[PATCH] D46050: [Frontend] Avoid running plugins during code completion parse

2018-05-07 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik marked an inline comment as done.
nik added inline comments.



Comment at: test/Frontend/plugins.c:8
+// RUN: c-index-test -code-completion-at=%s:6:1 -load 
%llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck 
-check-prefix=CHECK-COMPLETION-WITHOUT-PLUGINS  %s
+// REQUIRES: plugins, examples
+

thakis wrote:
> nik wrote:
> > Note that I actually have problems with this REQUIRES line. I use 
> > -DCLANG_BUILD_EXAMPLES and -DDBUILD_SHARED_LIBS=ON and this test (and the 
> > one above too) is skipped/unsupported. What else do I need?
> > 
> > Note that If I remove this line, the test is run - apparently the 
> > requirements are fulfilled, but not properly detected. I guess this is set 
> > up issue on my local machine?
> Are you on Windows? plugins is set here: 
> http://llvm-cs.pcc.me.uk/tools/clang/test/lit.cfg.py#73
> enable_shared here: 
> http://llvm-cs.pcc.me.uk/tools/clang/test/lit.site.cfg.py.in#25
> from here: http://llvm-cs.pcc.me.uk/cmake/modules/AddLLVM.cmake#1193
> 
> So my guess is you need to set LLVM_ENABLE_PLUGINS (and that you are on 
> Windows), but I haven't tried it.
No, I'm not on Windows. Adding some debug-prints to the python scripts it looks 
like the "examples" thingy is actually not  fulfilled here. Anyway, that's 
something for another change (will upload a separate change for this)


https://reviews.llvm.org/D46050



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46050: [Frontend] Avoid running plugins during code completion parse

2018-05-07 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik updated this revision to Diff 145430.
nik added a comment.

Moved the test to "Index".


https://reviews.llvm.org/D46050

Files:
  lib/Frontend/FrontendAction.cpp
  test/Index/complete-and-plugins.c


Index: test/Index/complete-and-plugins.c
===
--- /dev/null
+++ test/Index/complete-and-plugins.c
@@ -0,0 +1,7 @@
+void x();
+
+// RUN: c-index-test -code-completion-at=%s:6:1 -load 
%llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck 
%s
+// REQUIRES: plugins, examples
+// CHECK: macro definition:{{.*}}
+// CHECK-NOT: top-level-decl: "x"
+
Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -153,6 +153,10 @@
   if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
 return Consumer;
 
+  // If this is a code completion run, avoid invoking the plugin consumers
+  if (CI.hasCodeCompletionConsumer())
+return Consumer;
+
   // Collect the list of plugins that go before the main action (in Consumers)
   // or after it (in AfterConsumers)
   std::vector> Consumers;


Index: test/Index/complete-and-plugins.c
===
--- /dev/null
+++ test/Index/complete-and-plugins.c
@@ -0,0 +1,7 @@
+void x();
+
+// RUN: c-index-test -code-completion-at=%s:6:1 -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck %s
+// REQUIRES: plugins, examples
+// CHECK: macro definition:{{.*}}
+// CHECK-NOT: top-level-decl: "x"
+
Index: lib/Frontend/FrontendAction.cpp
===
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -153,6 +153,10 @@
   if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
 return Consumer;
 
+  // If this is a code completion run, avoid invoking the plugin consumers
+  if (CI.hasCodeCompletionConsumer())
+return Consumer;
+
   // Collect the list of plugins that go before the main action (in Consumers)
   // or after it (in AfterConsumers)
   std::vector> Consumers;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40481: [libclang] Fix cursors for arguments of Subscript and Call operators

2018-05-07 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping.


https://reviews.llvm.org/D40481



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46504: [clang-tidy] Profile is a per-AST (per-TU) data.

2018-05-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:181
 std::unique_ptr OptionsProvider)
-: DiagEngine(nullptr), OptionsProvider(std::move(OptionsProvider)),
-  Profile(nullptr) {
+: DiagEngine(nullptr), OptionsProvider(std::move(OptionsProvider)) {
   // Before the first translation unit we can get errors related to 
command-line

Eugene.Zelenko wrote:
> Will be good idea to use default member initialization for DiagEngine too.
Yes, but in the context of the diff that would be a completely unrelated 
change, i try to avoid those..


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46504



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46176: Add SourceManagerForFile helper which sets up SourceManager and dependencies for a single file with code snippet

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Basic/SourceManager.h:1819
+/// SourceManager and necessary depdencies (e.g. VFS, FileManager) for a single
+/// file.
+class SourceManagerForFile {

nit: single in-memory file



Comment at: include/clang/Basic/SourceManager.h:1824
+  /// The main file in the SourceManager will be \p FileName with \p Content.
+  static std::unique_ptr create(StringRef FileName,
+  StringRef Content);

why is this not just a constructor? it looks like it can't fail?



Comment at: include/clang/Basic/SourceManager.h:1827
+
+  SourceManager &getSourceManager() { return SourceMgr; }
+

this could also just be `get()` or `operator*`



Comment at: lib/Format/TokenAnalyzer.h:71
 private:
+  std::unique_ptr VirtualSM;
+

add a comment that this is only present if constructed from a string?


Repository:
  rC Clang

https://reviews.llvm.org/D46176



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name

2018-05-07 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig added a comment.

In https://reviews.llvm.org/D44435#1088019, @tra wrote:

> Perhaps we should take a step back and consider whether this is the right 
> approach to solve your problem.
>
> If I understand it correctly, the real issue is that you repeatedly recompile 
> the same module and cling will only use the function from the first module 
> it's seen it in. Unlike regular functions that presumably remain the same in 
> all the modules they are present in, CUDA constructors do change and you need 
> cling to grab the one from the most recent module.
>
> This patch deals with the issue by attempting to add a unique sufix. 
> Presumably cling will then generate some sort of unique module name and will 
> get unique constructor name in return. The down side of this approach is that 
> module name is something that is derived from the file name and the 
> functionality you're changing is in the shared code, so you need to make sure 
> that whatever you implement makes sense for LLVM in general and that it does 
> what it claims it does. AFAICT, LLVM has no pressing need for the unique 
> constructor name -- it's a function with internal linkage and, if we ever 
> need to generate more than one, LLVM is capable of generating unique names 
> within the module all by itself. The patch currently does not fulfill the 
> "unique" part either.
>
> Perhaps you should consider a different approach which could handle the issue 
> completely in cling. E.g. You could rename the constructor in the module's IR 
> before passing it to JIT. Or you could rename it in PTX (it's just text after 
> all) before passing it to driver or PTXAS.


You are right. The clang commit is not the best solution. So, we searched for 
another solution and found one. The solution is similar to your suggestion. We 
found a possibility to integrate a llvm module pass, which detects the symbols 
`__cuda_module_ctor` and `__cuda_module_dtor` and append the module name to the 
symbol, before the llvm IR will be generated. So, we were able to move the 
solution from clang to cling, which is better for both projects.


https://reviews.llvm.org/D44435



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


?????? If I want to disable certain attributes, such as"swiftcall",isthereany way to do it now?

2018-05-07 Thread ???? via cfe-commits
hi, Aaron




  I may found a useful example. For example, I tested the alias attribute on my 
own Apple laptop (Target: x86_64-apple-darwin17.5.0). First, I use 
__has_attribute to test that the alias is usable or not. The test code is as 
follows:

 #include 

void print() {

#if __has_attribute(alias)

   printf("has attribute");

#else

   printf("has not attribute");

#endif

}

int main() {

print();

return 0;

}

Compiled using clang, the output result is has attribute, but when i use the 
following code to verify

#include 

int oldname = 1;

extern int newname __attribute__((alias("oldname"))); // declaration

void foo(void)

{

printf("newname = %d\n", newname); // prints 1

}

int main() {

foo();

return 0;

}

 

It told me alias.c:3:35: error: aliases are not supported on darwin,but if 
TargetNotSupportedAttr method is used, we can avoid __has_attribute (alias) 
returns true, so we can tell the user more clearly that we do not support this 
attribute on this platform.




  Thanks.







--  --
??: "Aaron Ballman";
: 2018??5??6??(??) 10:19
??: ""<772847...@qq.com>;
: "cfe-commits"; 
: Re: If I want to disable certain attributes, such 
as"swiftcall",isthereany way to do it now?



On Sun, May 6, 2018 at 10:01 AM,  <772847...@qq.com> wrote:
> hi, Aaron
>
>Can I ask you some questions?Is there such a demand for me in the
> community? Does my code need to be submitted to the community?
>Thanks.

Generally speaking, the community will accept production-quality
patches that solve a problem with the product or introduce some new,
desirable functionality. What you've described so far sounds like it
solves a specific problem you're having, but it doesn't sound like it
solves a problem the general public is having. Perhaps if you
described how you envision your solution being used in the product and
what immediate problems it solves, that would help me to understand
the situation a bit better. Basically, if you want to propose adding
TargetNotSupportedAttr, can you describe what attributes you would
propose using it on?

Thanks!

~Aaron


> --  --
> ??: "Aaron Ballman";
> : 2018??5??3??(??) 7:40
> ??: ""<772847...@qq.com>;
> : "cfe-commits";
> : Re: If I want to disable certain attributes, such as"swiftcall",isthere
> any way to do it now?
>
> On Thu, May 3, 2018 at 1:25 AM,  <772847...@qq.com> wrote:
>> hi, Aaron
>>
>>   The reason why i not use of TargetSpecificAttr is as follows.If I plan
>> to
>> support a new platform, I don't want to let users use certain attributes
>> because of hardware or simply not want to. Yes, we can use
>> TargetSpecificAttr, but if we use TargetSpecificAttr that we need to
>> include
>> platforms other than unsupported platforms, but we just need to exclude
>> that
>> platform, using TargetSpecificAttr may not be a good idea.
>
> Okay, that makes sense to me. Your design seems like a reasonable one.
>
> ~Aaron
>
>>
>>
>>
>> --  --
>> ??: "Aaron Ballman";
>> : 2018??5??2??(??) 10:05
>> ??: ""<772847...@qq.com>;
>> : "cfe-commits";
>> : Re: If I want to disable certain attributes, such as
>> "swiftcall",isthere
>> any way to do it now?
>>
>> On Wed, May 2, 2018 at 4:59 AM,  <772847...@qq.com> wrote:
>>> Thanks.
>>>
>>> If I remove some specific attributes, now I can think of the following
>>> method.First of all, let me talk about my method.
>>>
>>> 1.Define target platforms that do not support attributes.such as def
>>> TargetPower : TargetArch<["ppc", "ppc64", "ppc64le"]>;
>>>
>>> 2.Define TargetNotSupportedAttr class.such as class
>>> TargetNotSupportedAttr ;
>>
>> Why not make use of TargetSpecificAttr to mark the attributes that are
>> specific to a target rather than marking the attributes not supported
>> by a target?
>>
>>> 3.Using this approach, we need to modify the
>>> cfe-4.0.1.src/utils/TableGen/ClangAttrEmitter.cpp file.Modifying the code
>>> in
>>> the GenerateHasAttrSpellingStringSwitch function looks like this:
>>>
>>> if(Attr->isSubClassOf("TargetNotSupportedAttr")) {   // add
>>>
>>> #define GenerateTargetNotSupportedAttrChecks
>>> GenerateTargetSpecificAttrChecks // add
>>>
>>> const Record *R = Attr->getValueAsDef("Target");   // add
>>>
>>> std::vector Arches =
>>> R->getValueAsListOfStrings("Arches"); // add
>>>
>>> GenerateTargetNotSupportedAttrChecks(R, Arches, Test, nullptr);
>>> // add
>>>
>>> TestStr = !Test.empty() ? Test + " ? "  + " 0 :" +
>>> llvm::itostr(Version) : "0"; // add
>>>
>>> } else if (Attr->isSubClassOf("TargetSpecificAttr"))
>>>
>>> 4.And for classes that inherit from TargetNotSupportedAttr<> class, we
>>> don??t
>>> need to generate the attribute class, so add the following code in
>>> EmitClangAttrClass
>>>
>>> if (R->getName()

[PATCH] D46450: [Driver] Add mips_Features_Group to Options to improve documentation sorting

2018-05-07 Thread Vince Del Vecchio via Phabricator via cfe-commits
vdelvecc added a comment.

In https://reviews.llvm.org/D46450#1089105, @atanasyan wrote:

> LGTM
>
> Do you have commit access?


Nope.  Would you commit it please?  Thanks much!


Repository:
  rC Clang

https://reviews.llvm.org/D46450



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46519: [clang-format] Respect BreakBeforeClosingBrace while calculating length

2018-05-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.

This patch makes `getLengthToMatchingParen` respect the 
`BreakBeforeClosingBrace`
ParenState for matching scope closers. In order to distinguish between paren 
states
introduced by real vs. fake parens, I've added the token opening the ParensState
to that struct.


Repository:
  rC Clang

https://reviews.llvm.org/D46519

Files:
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestRawStrings.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -469,6 +469,7 @@
"ccc: <\n"
"  operator: 1\n"
"  operator: 2\n"
+   "  operator: 3\n"
"  operator { key: value }\n"
">\n"
"  >\n"
Index: unittests/Format/FormatTestRawStrings.cpp
===
--- unittests/Format/FormatTestRawStrings.cpp
+++ unittests/Format/FormatTestRawStrings.cpp
@@ -822,6 +822,41 @@
 )test", Style));
 }
 
+TEST_F(FormatTestRawStrings, KeepsRBraceFolloedByMoreLBracesOnSameLine) {
+  FormatStyle Style = getRawStringPbStyleWithColumns(80);
+
+  expect_eq(
+R"test(
+int f() {
+  if (1) {
+T s = PARSE_TEXT_PROTO(R"pb(
+  t {
+p {
+  [cc.pp.] { field_1: "123_1" }
+  [cc.pp.] { field_2: "123_2" }
+}
+  }
+)pb");
+  }
+}
+)test",
+format(
+R"test(
+int f() {
+  if (1) {
+   T s = PARSE_TEXT_PROTO(R"pb(
+   t {
+   p {
+   [cc.pp.] { field_1: "123_1" }
+   [cc.pp.] { field_2: "123_2" }}}
+   )pb");
+  }
+}
+)test",
+Style));
+}
+
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/FormatTestProto.cpp
===
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -486,6 +486,7 @@
"ccc: <\n"
"  operator: 1\n"
"  operator: 2\n"
+   "  operator: 3\n"
"  operator { key: value }\n"
">\n"
"  >\n"
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -659,8 +659,8 @@
 static void printLineState(const LineState &State) {
   llvm::dbgs() << "State: ";
   for (const ParenState &P : State.Stack) {
-llvm::dbgs() << P.Indent << "|" << P.LastSpace << "|" << P.NestedBlockIndent
- << " ";
+llvm::dbgs() << (P.Tok ? P.Tok->TokenText : "F") << "|" << P.Indent << "|"
+ << P.LastSpace << "|" << P.NestedBlockIndent << " ";
   }
   llvm::dbgs() << State.NextToken->TokenText << "\n";
 }
Index: lib/Format/ContinuationIndenter.h
===
--- lib/Format/ContinuationIndenter.h
+++ lib/Format/ContinuationIndenter.h
@@ -200,16 +200,20 @@
 };
 
 struct ParenState {
-  ParenState(unsigned Indent, unsigned LastSpace, bool AvoidBinPacking,
- bool NoLineBreak)
-  : Indent(Indent), LastSpace(LastSpace), NestedBlockIndent(Indent),
-BreakBeforeClosingBrace(false), AvoidBinPacking(AvoidBinPacking),
-BreakBeforeParameter(false), NoLineBreak(NoLineBreak),
-NoLineBreakInOperand(false), LastOperatorWrapped(true),
-ContainsLineBreak(false), ContainsUnwrappedBuilder(false),
-AlignColons(true), ObjCSelectorNameFound(false),
-HasMultipleNestedBlocks(false), NestedBlockInlined(false),
-IsInsideObjCArrayLiteral(false) {}
+  ParenState(const FormatToken *Tok, unsigned Indent, unsigned LastSpace,
+ bool AvoidBinPacking, bool NoLineBreak)
+  : Tok(Tok), Indent(Indent), LastSpace(LastSpace),
+NestedBlockIndent(Indent), BreakBeforeClosingBrace(false),
+AvoidBinPacking(AvoidBinPacking), BreakBeforeParameter(false),
+NoLineBreak(NoLineBreak), NoLineBreakInOperand(false),
+LastOperatorWrapped(true), ContainsLineBreak(false),
+ContainsUnwrappedBuilder(false), AlignColons(true),
+ObjCSelectorNameFound(false), HasMultipleNestedBlocks(false),
+NestedBlockInlined(false), IsInsideObjCArrayLit

[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-07 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 145445.
sepavloff marked an inline comment as done.
sepavloff added a comment.

Avoid redundant initializer calculation


Repository:
  rC Clang

https://reviews.llvm.org/D46241

Files:
  include/clang/AST/Expr.h
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/cxx11-initializer-aggregate.cpp

Index: test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -51,3 +51,27 @@
   // meaningful.
   B b[30] = {};
 }
+
+namespace ZeroInit {
+  enum { Zero, One };
+  constexpr int zero() { return 0; }
+  constexpr int *null() { return nullptr; }
+  struct Filler {
+int x;
+Filler();
+  };
+
+  // These declarations, if implemented elementwise, require huge
+  // amout of memory and compiler time.
+  unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 };
+  unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero };
+  unsigned char data_3[1024][1024][1024] = {{{0}}};
+  unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() };
+  int *data_5[1024 * 1024 * 512] = { nullptr };
+  int *data_6[1024 * 1024 * 512] = { null() };
+
+
+  // This variable must be initialized elementwise.
+  Filler data_e1[1024] = {};
+  // CHECK: getelementptr inbounds {{.*}} @_ZN8ZeroInit7data_e1E
+}
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -1392,20 +1392,40 @@
   return type;
 }
 
+/// Checks if the specified initializer is equivalent to zero initialization.
+static bool isZeroInitializer(ConstantEmitter &CE, const Expr *Init) {
+  QualType InitTy = Init->getType().getCanonicalType();
+  if (auto *E = dyn_cast_or_null(Init)) {
+CXXConstructorDecl *CD = E->getConstructor();
+return CD->isDefaultConstructor() && CD->isTrivial();
+  }
+  if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+  for (auto I : IL->inits())
+if (!isZeroInitializer(CE, I))
+  return false;
+  if (const Expr *Filler = IL->getArrayFiller()) {
+return isZeroInitializer(CE, Filler);
+  }
+  return true;
+}
+  } else {
+Expr::EvalResult Result;
+if (Init->EvaluateAsRValue(Result, CE.CGM.getContext()) &&
+!Result.hasUnacceptableSideEffect(Expr::SE_NoSideEffects))
+  return (Result.Val.isInt() && Result.Val.getInt().isNullValue()) ||
+ (Result.Val.isLValue() && Result.Val.isNullPointer());
+  }
+
+  return false;
+}
+
 llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) {
   // Make a quick check if variable can be default NULL initialized
   // and avoid going through rest of code which may do, for c++11,
   // initialization of memory to all NULLs.
-  if (!D.hasLocalStorage()) {
-QualType Ty = CGM.getContext().getBaseElementType(D.getType());
-if (Ty->isRecordType())
-  if (const CXXConstructExpr *E =
-  dyn_cast_or_null(D.getInit())) {
-const CXXConstructorDecl *CD = E->getConstructor();
-if (CD->isTrivial() && CD->isDefaultConstructor())
-  return CGM.EmitNullConstant(D.getType());
-  }
-  }
+  if (!D.hasLocalStorage() && isZeroInitializer(*this, D.getInit()))
+return CGM.EmitNullConstant(D.getType());
 
   QualType destType = D.getType();
 
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -10224,20 +10224,14 @@
  HandleConversionToBool(Scratch.Val, Result);
 }
 
-static bool hasUnacceptableSideEffect(Expr::EvalStatus &Result,
-  Expr::SideEffectsKind SEK) {
-  return (SEK < Expr::SE_AllowSideEffects && Result.HasSideEffects) ||
- (SEK < Expr::SE_AllowUndefinedBehavior && Result.HasUndefinedBehavior);
-}
-
 bool Expr::EvaluateAsInt(APSInt &Result, const ASTContext &Ctx,
  SideEffectsKind AllowSideEffects) const {
   if (!getType()->isIntegralOrEnumerationType())
 return false;
 
   EvalResult ExprResult;
   if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isInt() ||
-  hasUnacceptableSideEffect(ExprResult, AllowSideEffects))
+  ExprResult.hasUnacceptableSideEffect(AllowSideEffects))
 return false;
 
   Result = ExprResult.Val.getInt();
@@ -10251,7 +10245,7 @@
 
   EvalResult ExprResult;
   if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isFloat() ||
-  hasUnacceptableSideEffect(ExprResult, AllowSideEffects))
+  ExprResult.hasUnacceptableSideEffect(AllowSideEffects))
 return false;
 
   Result = ExprResult.Val.getFloat();
@@ -10317,7 +10311,7 @@
 bool Expr::isEvaluatable(const ASTContext &Ctx, SideEffectsKind SEK) const {
   EvalResult Result;
   return EvaluateAsRValue(Result, 

[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, hans, thakis.

Don't use the GNU extension form of line markers in MSVC mode.

  


Repository:
  rC Clang

https://reviews.llvm.org/D46520

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4217,7 +4217,7 @@
 
   // -fno-use-line-directives is default.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4217,7 +4217,7 @@
 
   // -fno-use-line-directives is default.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Seems reasonable to me (but please update the comment before landing).




Comment at: lib/Driver/ToolChains/Clang.cpp:4218
 
   // -fno-use-line-directives is default.
   if (Args.hasFlag(options::OPT_fuse_line_directives,

The comment needs an update I think.


Repository:
  rC Clang

https://reviews.llvm.org/D46520



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331630 - [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-05-07 Thread Peter Szecsi via cfe-commits
Author: szepet
Date: Mon May  7 05:08:27 2018
New Revision: 331630

URL: http://llvm.org/viewvc/llvm-project?rev=331630&view=rev
Log:
[ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, 
DependentScopeDeclRefExpr

The visit callback implementations for the 3 C++ AST Node added to the 
ASTImporter.

Differential Revision: https://reviews.llvm.org/D38845


Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=331630&r1=331629&r2=331630&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon May  7 05:08:27 2018
@@ -121,7 +121,7 @@ namespace clang {
 QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType 
*T);
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType 
*T);
 QualType VisitElaboratedType(const ElaboratedType *T);
-// FIXME: DependentNameType
+QualType VisitDependentNameType(const DependentNameType *T);
 QualType VisitPackExpansionType(const PackExpansionType *T);
 QualType VisitDependentTemplateSpecializationType(
 const DependentTemplateSpecializationType *T);
@@ -347,8 +347,10 @@ namespace clang {
 Expr *VisitCXXConstructExpr(CXXConstructExpr *E);
 Expr *VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
 Expr *VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+Expr *VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
 Expr *VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *CE);
 Expr *VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
+Expr *VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
@@ -938,6 +940,25 @@ QualType ASTNodeImporter::VisitDependent
 T->getKeyword(), Qualifier, Name, ToPack);
 }
 
+QualType ASTNodeImporter::VisitDependentNameType(const DependentNameType *T) {
+  NestedNameSpecifier *NNS = Importer.Import(T->getQualifier());
+  if (!NNS && T->getQualifier())
+return QualType();
+
+  IdentifierInfo *Name = Importer.Import(T->getIdentifier());
+  if (!Name && T->getIdentifier())
+return QualType();
+
+  QualType Canon = (T == T->getCanonicalTypeInternal().getTypePtr())
+   ? QualType()
+   : Importer.Import(T->getCanonicalTypeInternal());
+  if (!Canon.isNull())
+Canon = Canon.getCanonicalType();
+
+  return Importer.getToContext().getDependentNameType(T->getKeyword(), NNS,
+  Name, Canon);
+}
+
 QualType ASTNodeImporter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
   auto *Class =
   dyn_cast_or_null(Importer.Import(T->getDecl()));
@@ -6187,6 +6208,29 @@ Expr *ASTNodeImporter::VisitCXXDependent
   cast_or_null(ToFQ), MemberNameInfo, ResInfo);
 }
 
+Expr *
+ASTNodeImporter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
+  DeclarationName Name = Importer.Import(E->getDeclName());
+  if (!E->getDeclName().isEmpty() && Name.isEmpty())
+return nullptr;
+
+  DeclarationNameInfo NameInfo(Name, Importer.Import(E->getExprLoc()));
+  ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+  TemplateArgumentListInfo ToTAInfo(Importer.Import(E->getLAngleLoc()),
+Importer.Import(E->getRAngleLoc()));
+  TemplateArgumentListInfo *ResInfo = nullptr;
+  if (E->hasExplicitTemplateArgs()) {
+if (ImportTemplateArgumentListInfo(E->template_arguments(), ToTAInfo))
+  return nullptr;
+ResInfo = &ToTAInfo;
+  }
+
+  return DependentScopeDeclRefExpr::Create(
+  Importer.getToContext(), Importer.Import(E->getQualifierLoc()),
+  Importer.Import(E->getTemplateKeywordLoc()), NameInfo, ResInfo);
+}
+
 Expr *ASTNodeImporter::VisitCXXUnresolvedConstructExpr(
 CXXUnresolvedConstructExpr *CE) {
   unsigned NumArgs = CE->arg_size();
@@ -6244,6 +6288,47 @@ Expr *ASTNodeImporter::VisitUnresolvedLo
   E->isOverloaded(), ToDecls.begin(), ToDecls.end());
 }
 
+Expr *ASTNodeImporter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
+  DeclarationName Name = Importer.Import(E->getName());
+  if (!E->getName().isEmpty() && Name.isEmpty())
+return nullptr;
+  DeclarationNameInfo NameInfo(Name, Importer.Import(E->getNameLoc()));
+  // Import additional name location/type info.
+  ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+  QualType BaseType = Importer.Import(E->getType());
+  if (!E->getType().isNull() && BaseType.isNull())
+return nullptr;
+
+  UnresolvedSet<8> ToDecls;
+  for (Decl *D : E->decls()) {
+if (NamedDecl *To = cast_or_null(Importer.Import(D)))
+  ToDecls.addDecl(To);

[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-05-07 Thread Peter Szecsi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331630: [ASTImporter] Support importing 
UnresolvedMemberExpr, DependentNameType… (authored by szepet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D38845?vs=145159&id=145447#toc

Repository:
  rC Clang

https://reviews.llvm.org/D38845

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -121,7 +121,7 @@
 QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T);
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
 QualType VisitElaboratedType(const ElaboratedType *T);
-// FIXME: DependentNameType
+QualType VisitDependentNameType(const DependentNameType *T);
 QualType VisitPackExpansionType(const PackExpansionType *T);
 QualType VisitDependentTemplateSpecializationType(
 const DependentTemplateSpecializationType *T);
@@ -347,8 +347,10 @@
 Expr *VisitCXXConstructExpr(CXXConstructExpr *E);
 Expr *VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
 Expr *VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+Expr *VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
 Expr *VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *CE);
 Expr *VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
+Expr *VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
@@ -938,6 +940,25 @@
 T->getKeyword(), Qualifier, Name, ToPack);
 }
 
+QualType ASTNodeImporter::VisitDependentNameType(const DependentNameType *T) {
+  NestedNameSpecifier *NNS = Importer.Import(T->getQualifier());
+  if (!NNS && T->getQualifier())
+return QualType();
+
+  IdentifierInfo *Name = Importer.Import(T->getIdentifier());
+  if (!Name && T->getIdentifier())
+return QualType();
+
+  QualType Canon = (T == T->getCanonicalTypeInternal().getTypePtr())
+   ? QualType()
+   : Importer.Import(T->getCanonicalTypeInternal());
+  if (!Canon.isNull())
+Canon = Canon.getCanonicalType();
+
+  return Importer.getToContext().getDependentNameType(T->getKeyword(), NNS,
+  Name, Canon);
+}
+
 QualType ASTNodeImporter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
   auto *Class =
   dyn_cast_or_null(Importer.Import(T->getDecl()));
@@ -6187,6 +6208,29 @@
   cast_or_null(ToFQ), MemberNameInfo, ResInfo);
 }
 
+Expr *
+ASTNodeImporter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
+  DeclarationName Name = Importer.Import(E->getDeclName());
+  if (!E->getDeclName().isEmpty() && Name.isEmpty())
+return nullptr;
+
+  DeclarationNameInfo NameInfo(Name, Importer.Import(E->getExprLoc()));
+  ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+  TemplateArgumentListInfo ToTAInfo(Importer.Import(E->getLAngleLoc()),
+Importer.Import(E->getRAngleLoc()));
+  TemplateArgumentListInfo *ResInfo = nullptr;
+  if (E->hasExplicitTemplateArgs()) {
+if (ImportTemplateArgumentListInfo(E->template_arguments(), ToTAInfo))
+  return nullptr;
+ResInfo = &ToTAInfo;
+  }
+
+  return DependentScopeDeclRefExpr::Create(
+  Importer.getToContext(), Importer.Import(E->getQualifierLoc()),
+  Importer.Import(E->getTemplateKeywordLoc()), NameInfo, ResInfo);
+}
+
 Expr *ASTNodeImporter::VisitCXXUnresolvedConstructExpr(
 CXXUnresolvedConstructExpr *CE) {
   unsigned NumArgs = CE->arg_size();
@@ -6244,6 +6288,47 @@
   E->isOverloaded(), ToDecls.begin(), ToDecls.end());
 }
 
+Expr *ASTNodeImporter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
+  DeclarationName Name = Importer.Import(E->getName());
+  if (!E->getName().isEmpty() && Name.isEmpty())
+return nullptr;
+  DeclarationNameInfo NameInfo(Name, Importer.Import(E->getNameLoc()));
+  // Import additional name location/type info.
+  ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+  QualType BaseType = Importer.Import(E->getType());
+  if (!E->getType().isNull() && BaseType.isNull())
+return nullptr;
+
+  UnresolvedSet<8> ToDecls;
+  for (Decl *D : E->decls()) {
+if (NamedDecl *To = cast_or_null(Importer.Import(D)))
+  ToDecls.addDecl(To);
+else
+  return nullptr;
+  }
+
+  TemplateArgumentListInfo ToTAInfo;
+  TemplateArgumentListInfo *ResInfo = nullptr;
+  if (E->hasExplicitTemplateArgs()) {
+if (ImportTemplateArgumentListInfo(E->template_arguments(), ToTAInfo))
+  return nullptr;
+ResInfo = &ToTAInfo;
+  }
+
+  Expr *BaseE = E->isImplicitAccess() ? nullptr : Importer.Import(E->getBase());
+  if (!BaseE && !E->isImplici

Re: If I want to disable certain attributes, such as"swiftcall", isthereany way to do it now?

2018-05-07 Thread Aaron Ballman via cfe-commits
On Mon, May 7, 2018 at 5:48 AM, 朴素 <772847...@qq.com> wrote:
> hi, Aaron
>
>
>   I may found a useful example. For example, I tested the alias attribute on
> my own Apple laptop (Target: x86_64-apple-darwin17.5.0). First, I use
> __has_attribute to test that the alias is usable or not. The test code is as
> follows:
>
>  #include 
>
> void print() {
>
> #if __has_attribute(alias)
>
>printf("has attribute");
>
> #else
>
>printf("has not attribute");
>
> #endif
>
> }
>
> int main() {
>
> print();
>
> return 0;
>
> }
>
> Compiled using clang, the output result is has attribute, but when i use the
> following code to verify
>
> #include 
>
> int oldname = 1;
>
> extern int newname __attribute__((alias("oldname"))); // declaration
>
> void foo(void)
>
> {
>
> printf("newname = %d\n", newname); // prints 1
>
> }
>
> int main() {
>
> foo();
>
> return 0;
>
> }
>
> It told me alias.c:3:35: error: aliases are not supported on darwin,but if
> TargetNotSupportedAttr method is used, we can avoid __has_attribute (alias)
> returns true, so we can tell the user more clearly that we do not support
> this attribute on this platform.

That's a bug with the definition of the alias attribute in Attr.td --
it doesn't specify that it's a target-specific attribute, so the
table-generated implementation of __has_attribute does not know to add
in the target-specific check. I think this can be corrected by
properly making the alias attribute inherit from TargetSpecificAttr
and pulling out the custom logic handleAliasAttr() in
SemaDeclAttr.cpp. That said, it could be easier to specify with a
negative version of a TargetSpec like we already do for LangOpt. This
is a difference from what we discussed above in that it doesn't
introduce a new Attr subclass to inherit from but continues to use the
existing TargetSpecificAttr base class.

~Aaron

>
>
>   Thanks.
>
>
>
> -- 原始邮件 --
> 发件人: "Aaron Ballman";
> 发送时间: 2018年5月6日(星期天) 晚上10:19
> 收件人: "朴素"<772847...@qq.com>;
> 抄送: "cfe-commits";
> 主题: Re: If I want to disable certain attributes, such
> as"swiftcall",isthereany way to do it now?
>
> On Sun, May 6, 2018 at 10:01 AM, 朴素 <772847...@qq.com> wrote:
>> hi, Aaron
>>
>>Can I ask you some questions?Is there such a demand for me in the
>> community? Does my code need to be submitted to the community?
>>Thanks.
>
> Generally speaking, the community will accept production-quality
> patches that solve a problem with the product or introduce some new,
> desirable functionality. What you've described so far sounds like it
> solves a specific problem you're having, but it doesn't sound like it
> solves a problem the general public is having. Perhaps if you
> described how you envision your solution being used in the product and
> what immediate problems it solves, that would help me to understand
> the situation a bit better. Basically, if you want to propose adding
> TargetNotSupportedAttr, can you describe what attributes you would
> propose using it on?
>
> Thanks!
>
> ~Aaron
>
>
>> -- 原始邮件 --
>> 发件人: "Aaron Ballman";
>> 发送时间: 2018年5月3日(星期四) 晚上7:40
>> 收件人: "朴素"<772847...@qq.com>;
>> 抄送: "cfe-commits";
>> 主题: Re: If I want to disable certain attributes, such
>> as"swiftcall",isthere
>> any way to do it now?
>>
>> On Thu, May 3, 2018 at 1:25 AM, 朴素 <772847...@qq.com> wrote:
>>> hi, Aaron
>>>
>>>   The reason why i not use of TargetSpecificAttr is as follows.If I plan
>>> to
>>> support a new platform, I don't want to let users use certain attributes
>>> because of hardware or simply not want to. Yes, we can use
>>> TargetSpecificAttr, but if we use TargetSpecificAttr that we need to
>>> include
>>> platforms other than unsupported platforms, but we just need to exclude
>>> that
>>> platform, using TargetSpecificAttr may not be a good idea.
>>
>> Okay, that makes sense to me. Your design seems like a reasonable one.
>>
>> ~Aaron
>>
>>>
>>>
>>>
>>> -- 原始邮件 --
>>> 发件人: "Aaron Ballman";
>>> 发送时间: 2018年5月2日(星期三) 晚上10:05
>>> 收件人: "朴素"<772847...@qq.com>;
>>> 抄送: "cfe-commits";
>>> 主题: Re: If I want to disable certain attributes, such as
>>> "swiftcall",isthere
>>> any way to do it now?
>>>
>>> On Wed, May 2, 2018 at 4:59 AM, 朴素 <772847...@qq.com> wrote:
 Thanks.

 If I remove some specific attributes, now I can think of the following
 method.First of all, let me talk about my method.

 1.Define target platforms that do not support attributes.such as def
 TargetPower : TargetArch<["ppc", "ppc64", "ppc64le"]>;

 2.Define TargetNotSupportedAttr class.such as class
 TargetNotSupportedAttr ;
>>>
>>> Why not make use of TargetSpecificAttr to mark the attributes that are
>>> specific to a target rather than marking the attributes not supported
>>> by a target?
>>>
 3.Using this approach, we need to modify the
 cfe-4.0.1.src/utils/TableGen/ClangAttrEmitter.cpp file.Modifying the
 c

[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-07 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1413
+  } else if (!Init->isEvaluatable(CE.CGM.getContext())) {
+return false;
+  } else if (InitTy->hasPointerRepresentation()) {

rsmith wrote:
> sepavloff wrote:
> > rjmccall wrote:
> > > Aren't the null-pointer and integer-constant-expression checks below 
> > > already checking this?  Also, `isEvaluatable` actually computes the full 
> > > value internally (as an `APValue`), so if you're worried about the memory 
> > > and compile-time effects of producing such a value, you really shouldn't 
> > > call it.
> > > 
> > > You could reasonably move this entire function to be a method on `Expr` 
> > > that takes an `ASTContext`.
> > Comment for `EvaluateAsRValue` says that it tries calculate expression 
> > agressively. Indeed, for the code:
> > ```
> >   decltype(nullptr) null();
> >   int *p = null();
> > ```
> > compiler ignores potential side effect of `null()` and removes the call, 
> > leaving only zero initialization. `isNullPointerConstant` behaves similarly.
> Nonetheless, it looks like this function could evaluate `Init` up to three 
> times, which seems unreasonable. Instead of the checks based on trying to 
> evaluate the initializer (`isNullPointerConstant` + `isIntegerConstantExpr`), 
> how about calling `VarDecl::evaluateValue()` (which will return a potentially 
> pre-computed and cached initializer value) and checking if the result is a 
> zero constant?
> 
> In fact, `tryEmitPrivateForVarInit` already does most of that for you, and 
> the right place to make this change is probably in `tryEmitPrivateForMemory`, 
> where you can test to see if the `APValue` is zero-initialized and produce a 
> `zeroinitializer` if so. As a side-benefit, putting the change there will 
> mean we'll also start using `zeroinitializer` for zero-initialized subobjects 
> of objects that have non-zero pieces.
An important point in this patch is that CodeGen tries to find out, if the 
initializer can be replaced with zeroinitializer, *prior* to the evaluation of 
it. For huge arrays the evaluation consumes huge amount of memory and time and 
it must be avoided.

With this patch CodeGen may evaluate parts of the initializer, if it is 
represented by `InitListExpr`. It may cause redundant calculation, for instance 
if the check for zero initialization failed but the initializer is constant. To 
avoid this redundancy we could cache result of evaluation in instances of 
`Expr` and then use the partial values in the evaluation of the initializer. 
The simple use case solved by this patch probably is not a sufficient 
justification for such redesign.


Repository:
  rC Clang

https://reviews.llvm.org/D46241



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46522: [clang] cmake: resolve symlinks in ClangConfig.cmake

2018-05-07 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn created this revision.
Lekensteyn added a reviewer: sylvestre.ledru.
Herald added subscribers: cfe-commits, mgorny.

Ensure that symlinks such as /usr/lib/cmake/clang-X.Y (pointing to
/usr/lib/llvm-X.Y/lib/cmake/llvm) are resolved. This ensures that
CLANG_INSTALL_PREFIX ends up to be /usr/lib/llvm-X.Y instead of /usr.

Partially addresses PR37128


Repository:
  rC Clang

https://reviews.llvm.org/D46522

Files:
  cmake/modules/CMakeLists.txt


Index: cmake/modules/CMakeLists.txt
===
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -30,10 +30,10 @@
 # Generate ClangConfig.cmake for the install tree.
 set(CLANG_CONFIG_CODE "
 # Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" 
PATH)")
+get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" 
REALPATH)")
 # Construct the proper number of get_filename_component(... PATH)
 # calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
+string(REGEX REPLACE "/" ";" _count "prefix/${CLANG_INSTALL_PACKAGE_DIR}")
 foreach(p ${_count})
   set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" 
PATH)")


Index: cmake/modules/CMakeLists.txt
===
--- cmake/modules/CMakeLists.txt
+++ cmake/modules/CMakeLists.txt
@@ -30,10 +30,10 @@
 # Generate ClangConfig.cmake for the install tree.
 set(CLANG_CONFIG_CODE "
 # Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
+get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" REALPATH)")
 # Construct the proper number of get_filename_component(... PATH)
 # calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
+string(REGEX REPLACE "/" ";" _count "prefix/${CLANG_INSTALL_PACKAGE_DIR}")
 foreach(p ${_count})
   set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
 get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-05-07 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 145452.
baloghadamsoftware added a comment.

Updated according to the comments.


https://reviews.llvm.org/D33537

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/bugprone/ExceptionEscapeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-exception-escape.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-exception-escape.cpp

Index: test/clang-tidy/bugprone-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-exception-escape.cpp
@@ -0,0 +1,265 @@
+// RUN: %check_clang_tidy %s bugprone-exception-escape %t -- -extra-arg=-std=c++11 -config="{CheckOptions: [{key: bugprone-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, {key: bugprone-exception-escape.FunctionsThatShouldNotThrow, value: 'enabled1,enabled2,enabled3'}]}" --
+
+struct throwing_destructor {
+  ~throwing_destructor() {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function '~throwing_destructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_constructor {
+  throwing_move_constructor(throwing_move_constructor&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'throwing_move_constructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_assignment {
+  throwing_move_assignment& operator=(throwing_move_assignment&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: function 'operator=' throws
+throw 1;
+  }
+};
+
+void throwing_noexcept() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_noexcept' throws
+  throw 1;
+}
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_throw_nothing' throws
+  throw 1;
+}
+
+void throw_and_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch' throws
+  try {
+throw 1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_some(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_catch_some' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_each(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_each' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(double &) {
+  }
+}
+
+void throw_and_catch_all(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_all' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(...) {
+  }
+}
+
+void throw_and_rethrow() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_rethrow' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw;
+  }
+}
+
+void throw_catch_throw() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_throw' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw 2;
+  }
+}
+
+void throw_catch_rethrow_the_rest(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_rethrow_the_rest' throws
+  try {
+if (n) throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(...) {
+throw;
+  }
+}
+
+class base {};
+class derived: public base {};
+
+void throw_derived_catch_base() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_derived_catch_base' throws
+  try {
+throw derived();
+  } catch(base &) {
+  }
+}
+
+void try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_try' throws
+  try {
+try {
+  if (n) throw 1;
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void bad_try_nested_try(int n) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_try_nested_try' throws
+  try {
+if (n) throw 1;
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void try_nested_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_catch' throws
+  try {
+try {
+  throw 1;
+} catch(int &) {
+  throw 1.1;
+}
+  } catch(double &) {
+  }
+}
+
+void catch_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1;
+} catch(int &) {
+}
+  }
+}
+
+void bad_catch_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void implicit_int_thrower() {
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_im

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-05-07 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 10 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: test/clang-tidy/bugprone-exception-escape.cpp:178
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' 
throws
+  implicit_int_thrower();

dberris wrote:
> How deep does this go? Say we have a call to a function that's extern which 
> doesn't have 'noexcept' nor a dynamic exception specifier -- do we assume 
> that the call to an extern function may throw? Does that warn? What does the 
> warning look like? Should it warn? How about when you call a function through 
> a function pointer?
> 
> The documentation should cover these cases and/or more explicitly say in the 
> warning that an exception may throw in a noexcept function (rather than just 
> "function <...> throws").
We take the most conservative way here. We assume that a function throws if and 
only if its body has a throw statement or its header has the (old) throw() 
exception specification. We do not follow function pointers.


https://reviews.llvm.org/D33537



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38455: [clang-tidy] new cppcoreguidelines-narrowing-conversions check.

2018-05-07 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

@aaron.ballman Ping


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38455



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-05-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/clang-tidy/bugprone-exception-escape.cpp:178
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' 
throws
+  implicit_int_thrower();

baloghadamsoftware wrote:
> dberris wrote:
> > How deep does this go? Say we have a call to a function that's extern which 
> > doesn't have 'noexcept' nor a dynamic exception specifier -- do we assume 
> > that the call to an extern function may throw? Does that warn? What does 
> > the warning look like? Should it warn? How about when you call a function 
> > through a function pointer?
> > 
> > The documentation should cover these cases and/or more explicitly say in 
> > the warning that an exception may throw in a noexcept function (rather than 
> > just "function <...> throws").
> We take the most conservative way here. We assume that a function throws if 
> and only if its body has a throw statement or its header has the (old) 
> throw() exception specification. We do not follow function pointers.
While i realize it may have more noise, it may be nice to have a more pedantic 
mode (guarded by an option?).
E.g. `noexcept` propagation, much like `const` on methods propagation.
Or at least a test that shows that it does not happen, unless i simply did not 
notice it :)


https://reviews.llvm.org/D33537



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, mgrang, jkorous, MaskRay, ioeric, 
mgorny, klimek.

Code completion scoring was embedded in CodeComplete.cpp, which is bad:

- awkward to test. The mechanisms (extracting info from index/sema) can be 
unit-tested well, the policy (scoring) should be quantitatively measured. 
Neither was easily possible, and debugging was hard. The intermediate signal 
struct makes this easier.
- hard to reuse. This is a bug in workspaceSymbols: it just presents the 
results in the index order, which is not sorted in practice, it needs to rank 
them! Also, index implementations care about scoring (both query-dependent and 
independent) in order to truncate result lists appropriately.

The main yak shaved here is the build() function that had 3 variants across
unit tests is unified in TestTU.h (rather than adding a 4th variant).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524

Files:
  clangd/CMakeLists.txt
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -12,15 +12,13 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "XRefs.h"
-#include "gmock/gmock.h"
 #include "index/FileIndex.h"
 #include "index/SymbolCollector.h"
-#include "clang/Frontend/CompilerInvocation.h"
-#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -39,34 +37,6 @@
   std::vector Diagnostics) override {}
 };
 
-// FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef MainCode, StringRef HeaderCode = "") {
-  auto HeaderPath = testPath("foo.h");
-  auto MainPath = testPath("foo.cpp");
-  llvm::IntrusiveRefCntPtr VFS(
-  new vfs::InMemoryFileSystem());
-  VFS->addFile(MainPath, 0, llvm::MemoryBuffer::getMemBuffer(MainCode));
-  VFS->addFile(HeaderPath, 0, llvm::MemoryBuffer::getMemBuffer(HeaderCode));
-  std::vector Cmd = {"clang", "-xc++", MainPath.c_str()};
-  if (!HeaderCode.empty()) {
-std::vector args = {"-include", HeaderPath.c_str()};
-Cmd.insert(Cmd.begin() + 1, args.begin(), args.end());
-  }
-  auto CI = createInvocationFromCommandLine(Cmd);
-
-  auto Buf = MemoryBuffer::getMemBuffer(MainCode);
-  auto AST = ParsedAST::Build(std::move(CI), nullptr, std::move(Buf),
-  std::make_shared(), VFS);
-  assert(AST.hasValue());
-  return std::move(*AST);
-}
-
-std::unique_ptr buildIndex(StringRef MainCode,
-StringRef HeaderCode) {
-  auto AST = build(MainCode, HeaderCode);
-  return MemIndex::build(indexAST(&AST));
-}
-
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -117,7 +87,7 @@
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = build(T.code());
+auto AST = TestTU(T.code()).build();
 EXPECT_THAT(findDocumentHighlights(AST, T.point()), HighlightsFrom(T))
 << Test;
   }
@@ -139,10 +109,9 @@
   void  $f1[[f1]]() {}
 )cpp");
 
-  auto Index = buildIndex(SymbolCpp.code(), SymbolHeader.code());
+  auto Index = TestTU(SymbolCpp.code(), SymbolHeader.code()).index();
   auto runFindDefinitionsWithIndex = [&Index](const Annotations &Main) {
-auto AST = build(/*MainCode=*/Main.code(),
- /*HeaderCode=*/"");
+auto AST = TestTU(Main.code()).build();
 return clangd::findDefinitions(AST, Main.point(), Index.get());
   };
 
@@ -329,7 +298,7 @@
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = build(T.code());
+auto AST = TestTU(T.code()).build();
 std::vector> ExpectedLocations;
 for (const auto &R : T.ranges())
   ExpectedLocations.push_back(RangeIs(R));
@@ -661,7 +630,7 @@
 
   for (const OneTest &Test : Tests) {
 Annotations T(Test.Input);
-auto AST = build(T.code());
+auto AST = TestTU(T.code()).build();
 Hover H = getHover(AST, T.point());
 
 EXPECT_EQ(H.contents.value, Test.ExpectedHover) << Test.Input;
Index: unittests/clangd/TestTU.h
===
--- /dev/null
+++ unittests/clangd/TestTU.h
@@ -0,0 +1,51 @@
+//===--- TestTU.h - Scratch source files for testing *- C++-*-===

[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via Phabricator via cfe-commits
abeserminji updated this revision to Diff 145460.
abeserminji marked 4 inline comments as done.
abeserminji added a comment.

Comments resolved.


https://reviews.llvm.org/D44684

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/mips-abicalls-error.c
  test/Driver/mips-abicalls-warning.c
  test/Driver/mips-as.c
  test/Driver/mips-features.c

Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -11,7 +11,7 @@
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
 // -mno-abicalls non-PIC N64
-// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
 // CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
 //
@@ -86,13 +86,13 @@
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
 // MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
 // CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
 //
 // MIPS64 + N64: -fno-pic -mno-gpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls -mno-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
 // CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
Index: test/Driver/mips-as.c
===
--- test/Driver/mips-as.c
+++ test/Driver/mips-as.c
@@ -21,7 +21,7 @@
 // MIPS32R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EL"
 //
 // RUN: %clang -target mips64-linux-gnu -### \
-// RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
+// RUN:   -no-integrated-as -fno-pic -mno-abicalls -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EB-AS %s
 // MIPS64R2-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -31,7 +31,7 @@
 // MIPS64R2-EB-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64el-linux-gnu -### \
-// RUN:   -no-integrated-as -c -fno-pic %s 2>&1 \
+// RUN:   -no-integrated-as -c -fno-pic -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-DEF-EL-AS %s
 // MIPS64R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"  "-mno-shared" "-EL"
 //
@@ -64,7 +64,7 @@
 // MIPS64R2-EL-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC"
 //
 // RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EL-AS %s
 // MIPS64R2-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-EL"
 //
@@ -84,7 +84,7 @@
 // MIPS-OCTEON-PIC: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s
 // MIPS-OCTEON: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -144,7 +144,7 @@
 // MIPS-ALIAS-64-PIC: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64 -### \
-// RUN:   -no-integrated-as -c -fno-pic %s 2>&1 \
+// RUN:   -no-integrated-as -c -fno-pic -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64 %s
 // MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -159,7 +159,7 @@
 // MIPS-ALIAS-64R3-PIC: as{{(.exe)?}}" "-march" "mips64r3" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r3 -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R3 %s
 // MIPS-ALIAS-64R3: as{{(.exe)?}}" "-march" "mips64r3" "-mabi" "64" "-mno-shared" "-EB"
 //
@@ -169,7 +169,7 @@
 // MIPS-ALIAS-64R5-PIC: as{{(.exe)?}}" "-march" "mips64r5" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r5 -### \
-// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
+// RUN:   -no-integrated-as -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R5 %s
 // MIPS-ALIAS-64R5: as{{(.exe)?}}" "-march" "mips64r5" "-mabi" "64" "-mno-shared" "-EB"
 //

[PATCH] D44684: [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331636: [mips] Improve handling of -fno-[pic/PIC] option 
(authored by abeserminji, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44684?vs=145460&id=145462#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44684

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/mips-abicalls-warning.c
  cfe/trunk/test/Driver/mips-as.c
  cfe/trunk/test/Driver/mips-features.c

Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -339,10 +339,12 @@
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_abicalls : Warning<
-  "ignoring '-mabicalls' option as it cannot be used with "
-  "non position-independent code and the N64 ABI">,
+def warn_drv_unsupported_pic_with_mabicalls : Warning<
+  "ignoring '%0' option as it cannot be used with "
+  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_noabicalls_pic : Error<
+  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -11,7 +11,7 @@
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
 // -mno-abicalls non-PIC N64
-// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC -mno-abicalls %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
 // CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
 //
@@ -86,13 +86,13 @@
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
 // MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
 // CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
 //
 // MIPS64 + N64: -fno-pic -mno-gpopt
-// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-abicalls -mno-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
 // CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
 // CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
Index: cfe/trunk/test/Driver/mips-abicalls-warning.c
===
--- cfe/trunk/test/Driver/mips-abicalls-warning.c
+++ cfe/trunk/test/Driver/mips-abicalls-warning.c
@@ -1,6 +1,27 @@
 // REQUIRES: mips-registered-target
-// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck %s
-// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non position-independent code and the N64 ABI
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pic %s 2>&1 | FileCheck -check-prefix=CHECK-PIC1-IMPLICIT %s
+// CHECK-PIC1-IMPLICIT: warning: ignoring '-fno-pic' option as it cannot be used with implicit usage of -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pic -mabicalls %s 2>&1 | FileCheck -check-prefix=CHECK-PIC1-EXPLICIT %s
+// CHECK-PIC1-EXPLICIT: warning: ignoring '-fno-pic' option as it cannot be used with -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC %s 2>&1 | FileCheck -check-prefix=CHECK-PIC2-IMPLICIT %s
+// CHECK-PIC2-IMPLICIT: warning: ignoring '-fno-PIC' option as it cannot be used with implicit usage of -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck -check-prefix=CHECK-PIC2-EXPLICIT %s
+// CHECK-PIC2-EXPLICIT: warning: ignoring '-fno-PIC' option as it cannot be used with -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pie %s 2>&1 | FileCheck -check-prefix=CHECK-PIE1-IMPLICIT %s
+// CHECK-PIE1-IMPLICIT: warning: ignoring '-fno-pie' option as it cannot be used with implicit usage of -mabicalls and the N64 ABI
+
+// RUN: %clang -### -c -target mips64-mti-elf -fno-pie -mabicalls %s 2>&1 | FileCheck -check-prefix=CHECK-PIE1-EXPLICIT %s
+// CHECK-PIE1-EXPLICIT: warning: ignoring '-fno-pie' option as it cannot be used with -mabic

[libcxx] r331638 - Update for Rapperswil

2018-05-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May  7 07:21:52 2018
New Revision: 331638

URL: http://llvm.org/viewvc/llvm-project?rev=331638&view=rev
Log:
Update for Rapperswil

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=331638&r1=331637&r2=331638&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Mon May  7 07:21:52 2018
@@ -60,86 +60,52 @@
   
Issue #Issue 
NameMeetingStatus
 
-https://wg21.link/LWG2164";>2164What are the 
semantics of vector.emplace(vector.begin(), 
vector.back())?Jacksonville
-https://wg21.link/LWG2243";>2243istream::putback 
problemJacksonvilleComplete
-https://wg21.link/LWG2816";>2816resize_file has 
impossible postconditionJacksonvilleNothing to 
do
-https://wg21.link/LWG2843";>2843Unclear behavior 
of 
std::pmr::memory_resource::do_allocate()Jacksonville
-https://wg21.link/LWG2849";>2849Why does 
!is_regular_file(from) cause copy_file to report a "file 
already exists" error?JacksonvilleNothing to 
do
-https://wg21.link/LWG2851";>2851std::filesystem enum 
classes are now underspecifiedJacksonvilleNothing to 
do
-https://wg21.link/LWG2969";>2969polymorphic_allocator::construct()
 shouldn't pass resource()Jacksonville
-https://wg21.link/LWG2975";>2975Missing case for 
pair construction in scoped and polymorphic 
allocatorsJacksonville
-https://wg21.link/LWG2989";>2989path's 
stream insertion operator lets you insert everything under the 
sunJacksonvilleCompleted
-https://wg21.link/LWG3000";>3000monotonic_memory_resource::do_is_equal
 uses dynamic_cast 
unnecessarilyJacksonville
-https://wg21.link/LWG3002";>3002[networking.ts] 
basic_socket_acceptor::is_open() isn't 
noexceptJacksonville
-https://wg21.link/LWG3004";>3004§[string.capacity] and 
§[vector.capacity] should specify time complexity for 
capacity()JacksonvilleNothing to do
-https://wg21.link/LWG3005";>3005Destruction order 
of arrays by make_shared/allocate_shared only 
recommended?Jacksonville
-https://wg21.link/LWG3007";>3007allocate_shared 
should rebind allocator to cv-unqualified value_type for 
constructionJacksonville
-https://wg21.link/LWG3009";>3009Including 
 doesn't provide 
std::size/empty/dataJacksonvilleComplete
-https://wg21.link/LWG3010";>3010[networking.ts] 
uses_executor says "if a type T::executor_type 
exists"Jacksonville
-https://wg21.link/LWG3013";>3013(recursive_)directory_iterator
 construction and traversal should not be 
noexceptJacksonvilleComplete
-https://wg21.link/LWG3014";>3014More 
noexcept issues with filesystem 
operationsJacksonvilleComplete
-https://wg21.link/LWG3015";>3015copy_options::unspecified
 underspecifiedJacksonvilleNothing to do
-https://wg21.link/LWG3017";>3017list 
splice functions should use 
addressofJacksonville
-https://wg21.link/LWG3020";>3020[networking.ts] 
Remove spurious nested value_type buffer sequence 
requirementJacksonville
-https://wg21.link/LWG3026";>3026filesystem::weakly_canonical
 still defined in terms of canonical(p, 
base)Jacksonville
-https://wg21.link/LWG3030";>3030Who shall meet 
the requirements of try_lock?JacksonvilleNothing 
to do
-https://wg21.link/LWG3034";>3034P0767R1 breaks 
previously-standard-layout typesJacksonvillePatch 
Ready
-https://wg21.link/LWG3035";>3035std::allocator's 
constructors should be constexprJacksonvillePatch 
Ready
-https://wg21.link/LWG3039";>3039Unnecessary 
decay in thread and 
packaged_taskJacksonvillePatch Ready
-https://wg21.link/LWG3041";>3041Unnecessary 
decay in 
reference_wrapperJacksonvillePatch 
Ready
-https://wg21.link/LWG3042";>3042is_literal_type_v 
should be inlineJacksonvilleComplete
-https://wg21.link/LWG3043";>3043Bogus 
postcondition for filesystem_error 
constructorJacksonville
-https://wg21.link/LWG3045";>3045atomic
 doesn't have value_type or 
difference_typeJacksonville
-https://wg21.link/LWG3048";>3048transform_reduce(exec, 
first1, last1, first2, init) discards execution 
policyJacksonville
-https://wg21.link/LWG3051";>3051Floating 
point classifications were inadvertently changed in 
P0175JacksonvilleNothing to do
+https://wg21.link/LWG2139";>2139What is a 
user-defined type?Rapperswil
+https://wg21.link/LWG2970";>2970Return type of 
std::visit misspecifiedRapperswil
+https://wg21.link/LWG3058";>3058Parallel 
adjacent_difference shouldn't require creating 
temporariesRapperswil
+https://wg21.link/LWG3062";>3062Unnecessary 
decay_t in is_execution_policy_v should be 
remove_cvref_tRapperswil
+https://wg21.link/LWG3067";>3067recursive_directory_iterator::pop
 must invalidateRapperswil
+https://wg21.link/LWG3071";>3071[networking.ts] 
read_until still refers to "input 
sequence"RapperswilNothing to do
+https://wg21.link/LWG3074";>3074Non-member 
functions for valarray should only deduce from the 
valarrayRap

r331636 - [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via cfe-commits
Author: abeserminji
Date: Mon May  7 07:19:54 2018
New Revision: 331636

URL: http://llvm.org/viewvc/llvm-project?rev=331636&view=rev
Log:
[mips] Improve handling of -fno-[pic/PIC] option

In order to disable PIC and to match GCC behaviour, -mno-abicalls
option is neccessary. When -fno-[pic/PIC] is used witout -mno-abicalls,
warning is reported. An error is reported when -fno-pic or -fno-PIC is
used in combination with -mabicalls.

Depends on D44381.

Differential Revision: https://reviews.llvm.org/D44684

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/mips-abicalls-warning.c
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=331636&r1=331635&r2=331636&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon May  7 07:19:54 
2018
@@ -339,10 +339,12 @@ def warn_drv_unsupported_longcalls : War
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_abicalls : Warning<
-  "ignoring '-mabicalls' option as it cannot be used with "
-  "non position-independent code and the N64 ABI">,
+def warn_drv_unsupported_pic_with_mabicalls : Warning<
+  "ignoring '%0' option as it cannot be used with "
+  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_noabicalls_pic : Error<
+  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=331636&r1=331635&r2=331636&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon May  7 07:19:54 2018
@@ -214,6 +214,7 @@ void mips::getMIPSTargetFeatures(const D
   // For case (a) we need to add +noabicalls for N64.
 
   bool IsN64 = ABIName == "64";
+  bool IsPIC = false;
   bool NonPIC = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
@@ -225,6 +226,9 @@ void mips::getMIPSTargetFeatures(const D
 NonPIC =
 (O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
+IsPIC =
+(O.matches(options::OPT_fPIC) || O.matches(options::OPT_fpic) ||
+ O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie));
   }
 
   bool UseAbiCalls = false;
@@ -234,9 +238,14 @@ void mips::getMIPSTargetFeatures(const D
   UseAbiCalls =
   !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls);
 
-  if (UseAbiCalls && IsN64 && NonPIC) {
-D.Diag(diag::warn_drv_unsupported_abicalls);
-UseAbiCalls = false;
+  if (IsN64 && NonPIC && (!ABICallsArg || UseAbiCalls)) {
+D.Diag(diag::warn_drv_unsupported_pic_with_mabicalls)
+<< LastPICArg->getAsString(Args) << (!ABICallsArg ? 0 : 1);
+NonPIC = false;
+  }
+
+  if (ABICallsArg && !UseAbiCalls && IsPIC) {
+D.Diag(diag::err_drv_unsupported_noabicalls_pic);
   }
 
   if (!UseAbiCalls)

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=331636&r1=331635&r2=331636&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon May  7 07:19:54 2018
@@ -1018,6 +1018,14 @@ tools::ParsePICArgs(const ToolChain &Too
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::mips64 ||
Triple.getArch() == llvm::Triple::mips64el) {
+StringRef CPUName;
+StringRef ABIName;
+mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+// When targeting the N64 ABI, PIC is the default, except in the case
+// when the -mno-abicalls option is used. In that case we exit
+// at next check regardless of PIC being set below.
+if (ABIName == "n64")
+  PIC = true;
 // When targettng MIPS with -mno-abicalls, it's always static.
 if(Args.hasArg(options::OPT_mno_abicalls))
   return std::make_tuple(llvm::Reloc::Static, 0U, false);

Modified: cfe/trunk/test/Driver/m

r331639 - Revert "[mips] Improve handling of -fno-[pic/PIC] option"

2018-05-07 Thread Aleksandar Beserminji via cfe-commits
Author: abeserminji
Date: Mon May  7 07:28:42 2018
New Revision: 331639

URL: http://llvm.org/viewvc/llvm-project?rev=331639&view=rev
Log:
Revert "[mips] Improve handling of -fno-[pic/PIC] option"

This reverts commit r331636. Forgot to add the test case.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/mips-abicalls-warning.c
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=331639&r1=331638&r2=331639&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon May  7 07:28:42 
2018
@@ -339,12 +339,10 @@ def warn_drv_unsupported_longcalls : War
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_pic_with_mabicalls : Warning<
-  "ignoring '%0' option as it cannot be used with "
-  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and the N64 ABI">,
   InGroup;
-def err_drv_unsupported_noabicalls_pic : Error<
-  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=331639&r1=331638&r2=331639&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon May  7 07:28:42 2018
@@ -214,7 +214,6 @@ void mips::getMIPSTargetFeatures(const D
   // For case (a) we need to add +noabicalls for N64.
 
   bool IsN64 = ABIName == "64";
-  bool IsPIC = false;
   bool NonPIC = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
@@ -226,9 +225,6 @@ void mips::getMIPSTargetFeatures(const D
 NonPIC =
 (O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
-IsPIC =
-(O.matches(options::OPT_fPIC) || O.matches(options::OPT_fpic) ||
- O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie));
   }
 
   bool UseAbiCalls = false;
@@ -238,14 +234,9 @@ void mips::getMIPSTargetFeatures(const D
   UseAbiCalls =
   !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls);
 
-  if (IsN64 && NonPIC && (!ABICallsArg || UseAbiCalls)) {
-D.Diag(diag::warn_drv_unsupported_pic_with_mabicalls)
-<< LastPICArg->getAsString(Args) << (!ABICallsArg ? 0 : 1);
-NonPIC = false;
-  }
-
-  if (ABICallsArg && !UseAbiCalls && IsPIC) {
-D.Diag(diag::err_drv_unsupported_noabicalls_pic);
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+UseAbiCalls = false;
   }
 
   if (!UseAbiCalls)

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=331639&r1=331638&r2=331639&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon May  7 07:28:42 2018
@@ -1018,14 +1018,6 @@ tools::ParsePICArgs(const ToolChain &Too
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::mips64 ||
Triple.getArch() == llvm::Triple::mips64el) {
-StringRef CPUName;
-StringRef ABIName;
-mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
-// When targeting the N64 ABI, PIC is the default, except in the case
-// when the -mno-abicalls option is used. In that case we exit
-// at next check regardless of PIC being set below.
-if (ABIName == "n64")
-  PIC = true;
 // When targettng MIPS with -mno-abicalls, it's always static.
 if(Args.hasArg(options::OPT_mno_abicalls))
   return std::make_tuple(llvm::Reloc::Static, 0U, false);

Modified: cfe/trunk/test/Driver/mips-abicalls-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abicalls-warning.c?rev=331639&r1=331638&r2=331639&view=diff
==
--- cfe/trunk/test/Driv

[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:4218
 
   // -fno-use-line-directives is default.
   if (Args.hasFlag(options::OPT_fuse_line_directives,

hans wrote:
> The comment needs an update I think.
Thanks, will change into "-fno-use-line-directives is default, except for MSVC 
targets." before pushing.


Repository:
  rC Clang

https://reviews.llvm.org/D46520



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The change makes both testing and scoring code better.
Even though those are largely independent changes, perfectly happy to review 
them together.

I mostly have NITs here, overall the changes LG.




Comment at: clangd/CodeComplete.cpp:36
 
+#define DEBUG_TYPE "codecomplete"
+

Is this used by `DEBUG()` macro?
It would be nice to have a short comment saying why we need this define.



Comment at: clangd/CodeComplete.cpp:909
+
+auto QualScore = Quality.evaluate(), RelScore = Relevance.evaluate();
+CompletionItemScores Scores;

NIT: Maybe use `float` here instead of auto? Would remove the need to look at 
`evaluate` for anyone reading the code for the first time.



Comment at: clangd/Quality.cpp:83
+// That is: a < b <==> encodeFloat(a) < encodeFloat(b).
+uint32_t encodeFloat(float F) {
+  static_assert(std::numeric_limits::is_iec559, "");

This function does not seem to be exposed outside this C++ file. Maybe add 
`static`?



Comment at: clangd/Quality.h:45
+
+// Attributes of a symbol that affect how much we like it.
+struct SymbolQualitySignals {

Maybe use doxygen-style comments to be consistent with the rest of LLVM?



Comment at: clangd/Quality.h:66
+  float NameMatch = 1;
+  bool Unavailable = false;
+

Maybe rename to `Inaccessible`? It seems to be closer to what this bool means 
in C++, if I'm reading the code correctly.
Or add a comment explaining what "unavailable" means?



Comment at: clangd/Quality.h:80
+// TopN is a lossy container that preserves only the "best" N elements.
+template > class TopN {
+public:

As you mentioned  in the change description, moving `TopN` and `sortText` to a 
separate file might be a good idea since they don't depend on various 
clangd-specific bits.
But I'm perfectly happy to leave it as is and do this later if needed.



Comment at: clangd/Quality.h:119
+
+// Returns a string that sorts like (-Score, Tiebreak).
+std::string sortText(float Score, llvm::StringRef Tiebreak = "");

Maybe mention that it's used for LSP sortText? To give a bit more context on 
why we need this function.



Comment at: unittests/clangd/TestTU.cpp:56
+  const Symbol *Result = nullptr;
+  for (const Symbol &S : Slab)
+if (QName == (S.Scope + S.Name).str()) {

Maybe add braces for the loop body here? It seems to be long enough that it 
could actually, arguably, improve readability.
We could some nesting by inverting the condition too:
`if (QName != ...) continue;`



Comment at: unittests/clangd/TestTU.cpp:62
+  << S;
+llvm_unreachable("QName is not unique");
+  }

Maybe use `FAIL()` instead of `ADD_FAILURE()` followed by `llvm_unreachable()`?
`llvm_unreachable` may produce surprising behaviors, i.e. miscompiles in opt 
mode etc, IIUC.
Both failing or returning a first matching symbol while also signalling an 
error seem like good alternatives here.



Comment at: unittests/clangd/TestTU.h:28
+  TestTU() = default;
+  TestTU(llvm::StringRef Code, llvm::StringRef HeaderCode = "")
+  : Code(Code), HeaderCode(HeaderCode) {}

I really like this helper, now that we can reuse the code between different 
tests!
It took me some time to get the semantics of this constructor, though.
I suggest to have a few constructor functions with more descriptive name (my 
names are not great, but should give the idea):
```
static TestTU FromSourceFile(StringRef Code);
static TestTU FromHeaderFile(StringRef Code);
static TestTU WithImplicitInclude(StringRef Source, StringRef IncludedHeader);
```





Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331642 - [OPENMP, NVPTX] Added support for L2 parallelism.

2018-05-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  7 07:50:05 2018
New Revision: 331642

URL: http://llvm.org/viewvc/llvm-project?rev=331642&view=rev
Log:
[OPENMP, NVPTX] Added support for L2 parallelism.

Added initial codegen for level 2, 3 etc. parallelism. Currently, all
the second, the third etc. parallel regions will run sequentially.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=331642&r1=331641&r2=331642&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon May  7 07:50:05 2018
@@ -2764,13 +2764,6 @@ Address CGOpenMPRuntime::getAddrOfArtifi
   CGM.getPointerAlign());
 }
 
-/// \brief Emits code for OpenMP 'if' clause using specified \a CodeGen
-/// function. Here is the logic:
-/// if (Cond) {
-///   ThenGen();
-/// } else {
-///   ElseGen();
-/// }
 void CGOpenMPRuntime::emitOMPIfClause(CodeGenFunction &CGF, const Expr *Cond,
   const RegionCodeGenTy &ThenGen,
   const RegionCodeGenTy &ElseGen) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=331642&r1=331641&r2=331642&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon May  7 07:50:05 2018
@@ -93,6 +93,9 @@ enum OpenMPRTLFunctionNVPTX {
   OMPRTL_NVPTX__kmpc_end_sharing_variables,
   /// \brief Call to void __kmpc_get_shared_variables(void ***GlobalArgs)
   OMPRTL_NVPTX__kmpc_get_shared_variables,
+  /// Call to uint16_t __kmpc_parallel_level(ident_t *loc, kmp_int32
+  /// global_tid);
+  OMPRTL_NVPTX__kmpc_parallel_level,
 };
 
 /// Pre(post)-action for different OpenMP constructs specialized for NVPTX.
@@ -131,19 +134,17 @@ public:
   }
 };
 
-// A class to track the execution mode when codegening directives within
-// a target region. The appropriate mode (generic/spmd) is set on entry
-// to the target region and used by containing directives such as 'parallel'
-// to emit optimized code.
+/// A class to track the execution mode when codegening directives within
+/// a target region. The appropriate mode (SPMD|NON-SPMD) is set on entry
+/// to the target region and used by containing directives such as 'parallel'
+/// to emit optimized code.
 class ExecutionModeRAII {
 private:
-  CGOpenMPRuntimeNVPTX::ExecutionMode SavedMode;
-  CGOpenMPRuntimeNVPTX::ExecutionMode &Mode;
+  bool SavedMode;
+  bool &Mode;
 
 public:
-  ExecutionModeRAII(CGOpenMPRuntimeNVPTX::ExecutionMode &Mode,
-CGOpenMPRuntimeNVPTX::ExecutionMode NewMode)
-  : Mode(Mode) {
+  ExecutionModeRAII(bool &Mode, bool NewMode) : Mode(Mode) {
 SavedMode = Mode;
 Mode = NewMode;
   }
@@ -579,24 +580,171 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
 }
 
 bool CGOpenMPRuntimeNVPTX::isInSpmdExecutionMode() const {
-  return CurrentExecutionMode == CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
+  return IsInSPMDExecutionMode;
 }
 
-static CGOpenMPRuntimeNVPTX::ExecutionMode
-getExecutionMode(CodeGenModule &CGM) {
-  return CGM.getLangOpts().OpenMPCUDAMode
- ? CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd
- : CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
+static CGOpenMPRuntimeNVPTX::DataSharingMode
+getDataSharingMode(CodeGenModule &CGM) {
+  return CGM.getLangOpts().OpenMPCUDAMode ? CGOpenMPRuntimeNVPTX::CUDA
+  : CGOpenMPRuntimeNVPTX::Generic;
+}
+
+/// Check for inner (nested) SPMD construct, if any
+static bool hasNestedSPMDDirective(const OMPExecutableDirective &D) {
+  const auto *CS = D.getCapturedStmt(OMPD_target);
+  const auto *Body = CS->getCapturedStmt()->IgnoreContainers();
+  const Stmt *ChildStmt = nullptr;
+  if (const auto *C = dyn_cast(Body))
+if (C->size() == 1)
+  ChildStmt = C->body_front();
+  if (!ChildStmt)
+return false;
+
+  if (const auto *NestedDir = dyn_cast(ChildStmt)) {
+OpenMPDirectiveKind DKind = NestedDir->getDirectiveKind();
+// TODO: add further analysis for inner teams|distribute directives, if 
any.
+switch (D.getDirectiveKind()) {
+case OMPD_target:
+  return (isOpenMPParallelDirective(DKind) &&
+  !isOpenMPTeamsDirective(DKind) &&
+  !isOpenMPDistributeDirective(DKind)) ||
+ isOpenMPSimdDirective(DKind) ||
+   

r331640 - [mips] Improve handling of -fno-[pic/PIC] option

2018-05-07 Thread Aleksandar Beserminji via cfe-commits
Author: abeserminji
Date: Mon May  7 07:30:49 2018
New Revision: 331640

URL: http://llvm.org/viewvc/llvm-project?rev=331640&view=rev
Log:
[mips] Improve handling of -fno-[pic/PIC] option

In order to disable PIC and to match GCC behaviour, -mno-abicalls
option is neccessary. When -fno-[pic/PIC] is used witout -mno-abicalls,
warning is reported. An error is reported when -fno-pic or -fno-PIC is
used in combination with -mabicalls.

In this commit, test case is added.

Depends on D44381.

Differential Revision: https://reviews.llvm.org/D44684


Added:
cfe/trunk/test/Driver/mips-abicalls-error.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/test/Driver/mips-abicalls-warning.c
cfe/trunk/test/Driver/mips-as.c
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=331640&r1=331639&r2=331640&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon May  7 07:30:49 
2018
@@ -339,10 +339,12 @@ def warn_drv_unsupported_longcalls : War
   "ignoring '-mlong-calls' option as it is not currently supported with "
   "%select{|the implicit usage of }0-mabicalls">,
   InGroup;
-def warn_drv_unsupported_abicalls : Warning<
-  "ignoring '-mabicalls' option as it cannot be used with "
-  "non position-independent code and the N64 ABI">,
+def warn_drv_unsupported_pic_with_mabicalls : Warning<
+  "ignoring '%0' option as it cannot be used with "
+  "%select{implicit usage of|}1 -mabicalls and the N64 ABI">,
   InGroup;
+def err_drv_unsupported_noabicalls_pic : Error<
+  "position-independent code requires ‘-mabicalls’">;
 def err_drv_unsupported_indirect_jump_opt : Error<
   "'-mindirect-jump=%0' is unsupported with the '%1' architecture">;
 def err_drv_unknown_indirect_jump_opt : Error<

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=331640&r1=331639&r2=331640&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Mon May  7 07:30:49 2018
@@ -214,6 +214,7 @@ void mips::getMIPSTargetFeatures(const D
   // For case (a) we need to add +noabicalls for N64.
 
   bool IsN64 = ABIName == "64";
+  bool IsPIC = false;
   bool NonPIC = false;
 
   Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
@@ -225,6 +226,9 @@ void mips::getMIPSTargetFeatures(const D
 NonPIC =
 (O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
+IsPIC =
+(O.matches(options::OPT_fPIC) || O.matches(options::OPT_fpic) ||
+ O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie));
   }
 
   bool UseAbiCalls = false;
@@ -234,9 +238,14 @@ void mips::getMIPSTargetFeatures(const D
   UseAbiCalls =
   !ABICallsArg || ABICallsArg->getOption().matches(options::OPT_mabicalls);
 
-  if (UseAbiCalls && IsN64 && NonPIC) {
-D.Diag(diag::warn_drv_unsupported_abicalls);
-UseAbiCalls = false;
+  if (IsN64 && NonPIC && (!ABICallsArg || UseAbiCalls)) {
+D.Diag(diag::warn_drv_unsupported_pic_with_mabicalls)
+<< LastPICArg->getAsString(Args) << (!ABICallsArg ? 0 : 1);
+NonPIC = false;
+  }
+
+  if (ABICallsArg && !UseAbiCalls && IsPIC) {
+D.Diag(diag::err_drv_unsupported_noabicalls_pic);
   }
 
   if (!UseAbiCalls)

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=331640&r1=331639&r2=331640&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Mon May  7 07:30:49 2018
@@ -1018,6 +1018,14 @@ tools::ParsePICArgs(const ToolChain &Too
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::mips64 ||
Triple.getArch() == llvm::Triple::mips64el) {
+StringRef CPUName;
+StringRef ABIName;
+mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+// When targeting the N64 ABI, PIC is the default, except in the case
+// when the -mno-abicalls option is used. In that case we exit
+// at next check regardless of PIC being set below.
+if (ABIName == "n64")
+  PIC = true;
 // When targettng MIPS with -mno-abicalls, it's always static.
 if(Args.hasArg(options::OPT_mno_abicalls))

[PATCH] D46497: [clangd] Populate #include insertions as additional edits in completion items.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm concerned about the scope of this patch - it does too many things and 
touches too many files for me to feel comfortable that I understand it well 
enough to review.
Is it possible to split it up? (You mention 6 distinct things in the 
description).

Have tried to focus comments on what seems to be the core parts.




Comment at: clangd/CodeComplete.cpp:247
+// Calculates include path and insertion edit for a new header.
+class IncludeInsertion {
+public:

I can't parse this name as it relates to this class. This inserts includes, it 
isn't itself an insertion.
Maybe `IncludeInserter`?



Comment at: clangd/CodeComplete.h:72
+PathRef FileName, const tooling::CompileCommand &Command,
+PrecompiledPreamble const *Preamble, const InclusionLocations 
&IncLocations,
+StringRef Contents, Position Pos, IntrusiveRefCntPtr VFS,

IncLocations isn't an appropriate name for the variable - it's coupled to the 
preamble



Comment at: clangd/Headers.h:1
 //===--- Headers.h - Include headers -*- 
C++-*-===//
 //

The interface to this header looks a bit complex and entangled after this 
change.
- The construction/lifecycle of IncludePaths is confusing (comments below)
- here we provide all the information needed to compute the edits (style, 
code...) but don't actually do so

it would be nice to achieve a simpler interface with the restricted set of 
functionality, or expand the functionality...



Comment at: clangd/Headers.h:29
 
+// A header inclusion in the main file.
+struct InclusionLocation {

I had some trouble working out the role of this struct (e.g. that it might have 
been a *proposed* inclusion).
Strictly it's not just the location, but also identifies the header being 
included.

So this could maybe be
```
// An #include directive that we found in the main file.
struct Inclusion
```

but it does also seem a little strange that this is part of the public 
interface at all (other than for testing)



Comment at: clangd/Headers.h:40
+
+using InclusionLocations = std::vector;
+

This doesn't seem to add any semantics over the vector, so it just seems to 
obscure a bit.
In fact it does have semantics: it's the stored list of inclusion locations for 
the preamble. But those semantics don't belong in this layer. I'd suggest 
moving it back to the preamble code, or avoiding the typedef altogether.



Comment at: clangd/Headers.h:55
 
-/// Determines the preferred way to #include a file, taking into account the
-/// search path. Usually this will prefer a shorter representation like
-/// 'Foo/Bar.h' over a longer one like 'Baz/include/Foo/Bar.h'.
-///
-/// \param File is an absolute file path.
-/// \param DeclaringHeader is the original header corresponding to \p
-/// InsertedHeader e.g. the header that declares a symbol.
-/// \param InsertedHeader The preferred header to be inserted. This could be 
the
-/// same as DeclaringHeader but must be provided.
-//  \return A quoted "path" or . This returns an empty string if:
-///   - Either \p DeclaringHeader or \p InsertedHeader is already (directly)
-///   included in the file (including those included via different paths).
-///   - \p DeclaringHeader or \p InsertedHeader is the same as \p File.
-llvm::Expected
-calculateIncludePath(PathRef File, llvm::StringRef Code,
- const HeaderFile &DeclaringHeader,
- const HeaderFile &InsertedHeader,
- const tooling::CompileCommand &CompileCommand,
- IntrusiveRefCntPtr FS);
+/// Calculates #include paths for inserting new headers into a file, based on
+/// preprocessor and build configs.

the main value-add of this class over HeaderSearch is that it determines 
whether to insert, so that should probably be mentioned.



Comment at: clangd/Headers.h:56
+/// Calculates #include paths for inserting new headers into a file, based on
+/// preprocessor and build configs.
+class IncludePaths {

can you describe the design a little bit here?
e.g. "We simply keep track of which files were already inserted, and delegate 
to clang's HeaderSearch if a header is new"



Comment at: clangd/Headers.h:57
+/// preprocessor and build configs.
+class IncludePaths {
+public:

This name suggests a set or sequence of include path entries (`-I` flags).
Can we merge this with `IncludeInsertion` and call it `IncludeInserter` or 
similar?



Comment at: clangd/Headers.h:60
+  /// This must be called before preprocessor is run (this registers a
+  /// PPCallback on \p PP).
+  /// \p SM is used in the PPCallbacks to filter source locations in main file.

hmm, if we require the InclusionLocations to be prebuilt for the preamble,

[PATCH] D46501: [OpenCL] Guard all half float usage based on cl_khr_fp16 extension

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Only halfn type requires cl_khr_fp16. These functions do not use halfn type, 
therefore cl_khr_fp16 is not required.


Repository:
  rC Clang

https://reviews.llvm.org/D46501



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46471: [HIP] Add hip offload kind

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/Driver/Compilation.cpp:201
+  // not compiled again if there are already failures. It is OK to abort the
+  // CUDA pipeline on errors.
+  if (A->isOffloading(Action::OFK_Cuda) || A->isOffloading(Action::OFK_HIP))

rjmccall wrote:
> Mentioning only CUDA in the second clause makes me wonder whether it's *only* 
> okay to abort a CUDA pipeline, not a HIP one.  That is presumably not your 
> intent.  You could just drop "CUDA" there.
The second sentence is OK for both CUDA and HIP. Will drop CUDA in the second 
sentence.


https://reviews.llvm.org/D46471



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46471: [HIP] Add hip offload kind

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 145472.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Updated comments.


https://reviews.llvm.org/D46471

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  lib/Driver/Compilation.cpp
  lib/Driver/ToolChains/Clang.cpp

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -132,6 +132,11 @@
   else if (JA.isDeviceOffloading(Action::OFK_Cuda))
 Work(*C.getSingleOffloadToolChain());
 
+  if (JA.isHostOffloading(Action::OFK_HIP))
+Work(*C.getSingleOffloadToolChain());
+  else if (JA.isDeviceOffloading(Action::OFK_HIP))
+Work(*C.getSingleOffloadToolChain());
+
   if (JA.isHostOffloading(Action::OFK_OpenMP)) {
 auto TCs = C.getOffloadToolChains();
 for (auto II = TCs.first, IE = TCs.second; II != IE; ++II)
@@ -3104,13 +3109,14 @@
   // Check number of inputs for sanity. We need at least one input.
   assert(Inputs.size() >= 1 && "Must have at least one input.");
   const InputInfo &Input = Inputs[0];
-  // CUDA compilation may have multiple inputs (source file + results of
+  // CUDA/HIP compilation may have multiple inputs (source file + results of
   // device-side compilations). OpenMP device jobs also take the host IR as a
   // second input. All other jobs are expected to have exactly one
   // input.
   bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
+  bool IsHIP = JA.isOffloading(Action::OFK_HIP);
   bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
-  assert((IsCuda || (IsOpenMPDevice && Inputs.size() == 2) ||
+  assert((IsCuda || IsHIP || (IsOpenMPDevice && Inputs.size() == 2) ||
   Inputs.size() == 1) &&
  "Unable to handle multiple inputs.");
 
@@ -3122,10 +3128,10 @@
   bool IsWindowsMSVC = RawTriple.isWindowsMSVCEnvironment();
   bool IsIAMCU = RawTriple.isOSIAMCU();
 
-  // Adjust IsWindowsXYZ for CUDA compilations.  Even when compiling in device
-  // mode (i.e., getToolchain().getTriple() is NVPTX, not Windows), we need to
-  // pass Windows-specific flags to cc1.
-  if (IsCuda) {
+  // Adjust IsWindowsXYZ for CUDA/HIP compilations.  Even when compiling in
+  // device mode (i.e., getToolchain().getTriple() is NVPTX/AMDGCN, not
+  // Windows), we need to pass Windows-specific flags to cc1.
+  if (IsCuda || IsHIP) {
 IsWindowsMSVC |= AuxTriple && AuxTriple->isWindowsMSVCEnvironment();
 IsWindowsGNU |= AuxTriple && AuxTriple->isWindowsGNUEnvironment();
 IsWindowsCygnus |= AuxTriple && AuxTriple->isWindowsCygwinEnvironment();
@@ -3149,18 +3155,21 @@
 Args.ClaimAllArgs(options::OPT_MJ);
   }
 
-  if (IsCuda) {
-// We have to pass the triple of the host if compiling for a CUDA device and
-// vice-versa.
+  if (IsCuda || IsHIP) {
+// We have to pass the triple of the host if compiling for a CUDA/HIP device
+// and vice-versa.
 std::string NormalizedTriple;
-if (JA.isDeviceOffloading(Action::OFK_Cuda))
+if (JA.isDeviceOffloading(Action::OFK_Cuda) ||
+JA.isDeviceOffloading(Action::OFK_HIP))
   NormalizedTriple = C.getSingleOffloadToolChain()
  ->getTriple()
  .normalize();
 else
-  NormalizedTriple = C.getSingleOffloadToolChain()
- ->getTriple()
- .normalize();
+  NormalizedTriple =
+  (IsCuda ? C.getSingleOffloadToolChain()
+  : C.getSingleOffloadToolChain())
+  ->getTriple()
+  .normalize();
 
 CmdArgs.push_back("-aux-triple");
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -196,10 +196,10 @@
   if (FailingCommands.empty())
 return false;
 
-  // CUDA can have the same input source code compiled multiple times so do not
-  // compiled again if there are already failures. It is OK to abort the CUDA
+  // CUDA/HIP can have the same input source code compiled multiple times so do
+  // not compiled again if there are already failures. It is OK to abort the
   // pipeline on errors.
-  if (A->isOffloading(Action::OFK_Cuda))
+  if (A->isOffloading(Action::OFK_Cuda) || A->isOffloading(Action::OFK_HIP))
 return true;
 
   for (const auto &CI : FailingCommands)
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -96,16 +96,23 @@
 return "device-cuda";
   case OFK_OpenMP:
 return "device-openmp";
+  case OFK_HIP:
+return "device-hip";
 
 // TODO: Add other programming models here.
   }
 
   if (!ActiveOffloadKindMask)
 return {};
 
   std::string Res("host");
+  assert(!((ActiveOffloadKindMask & OFK_Cuda) &&
+   (ActiveOffl

[PATCH] D46472: [HIP] Support offloading by linkscript

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGCUDANV.cpp:317
+  if (GpuBinaryFileName.empty() && !IsHIP)
 return nullptr;
 

rjmccall wrote:
> Is this filename string only used for CUDA?  If so, please rename it to make 
> that clear, or at least add a comment.
Yes. Will do.


https://reviews.llvm.org/D46472



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 145478.
sammccall marked 9 inline comments as done.
sammccall added a comment.

Address comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524

Files:
  clang-move/ClangMove.cpp
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
  clang-tidy/google/IntegerTypesCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.h
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
  clang-tidy/tool/ClangTidyMain.cpp
  clangd/AST.cpp
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Protocol.h
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  clangd/XRefs.h
  clangd/index/FileIndex.cpp
  clangd/index/FileIndex.h
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/SymbolCollector.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/google-runtime-int.cpp
  test/clang-tidy/modernize-raw-string-literal.cpp
  test/clang-tidy/objc-property-declaration.m
  test/clang-tidy/temporaries.cpp
  test/clangd/rename.test
  unittests/clang-tidy/ClangTidyOptionsTest.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DraftStoreTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/SourceCodeTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp
  unittests/clangd/TestFS.cpp
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -12,10 +12,11 @@
 #include "Matchers.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
+#include "TestTU.h"
 #include "XRefs.h"
-#include "clang/Frontend/CompilerInvocation.h"
-#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/Frontend/Utils.h"
+#include "index/FileIndex.h"
+#include "index/SymbolCollector.h"
+#include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -36,18 +37,6 @@
   std::vector Diagnostics) override {}
 };
 
-// FIXME: this is duplicated with FileIndexTests. Share it.
-ParsedAST build(StringRef Code) {
-  auto CI = createInvocationFromCommandLine(
-  {"clang", "-xc++", testPath("Foo.cpp").c_str()});
-  auto Buf = MemoryBuffer::getMemBuffer(Code);
-  auto AST = ParsedAST::Build(std::move(CI), nullptr, std::move(Buf),
-  std::make_shared(),
-  vfs::getRealFileSystem());
-  assert(AST.hasValue());
-  return std::move(*AST);
-}
-
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -98,14 +87,75 @@
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
-auto AST = build(T.code());
+auto AST = TestTU::withCode(T.code()).build();
 EXPECT_THAT(findDocumentHighlights(AST, T.point()), HighlightsFrom(T))
 << Test;
   }
 }
 
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
 
+TEST(GoToDefinition, WithIndex) {
+  Annotations SymbolHeader(R"cpp(
+class $forward[[Forward]];
+class $foo[[Foo]] {};
+
+void $f1[[f1]]();
+
+inline void $f2[[f2]]() {}
+  )cpp");
+  Annotations SymbolCpp(R"cpp(
+  class $forward[[forward]] {};
+  void  $f1[[f1]]() {}
+)cpp");
+
+  TestTU TU;
+  TU.Code = SymbolCpp.code();
+  TU.HeaderCode = SymbolHeader.code();
+  auto Index = TU.index();
+  auto runFindDefinitionsWithIndex = [&Index](const Annotations &Main) {
+auto AST = TestTU::withCode(Main.code()).build();
+return clangd::findDefinitions(AST, Main.point(), Index.get());
+  };
+
+  Annotations Test(R"cpp(// only declaration in AST.
+void [[f1]]();
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(SymbolCpp.range("f1")), RangeIs(Test.range())}));
+
+  Test = Annotations(R"cpp(// definition in AST.
+void [[f1]]() {}
+int main() {
+  ^f1();
+}
+  )cpp");
+  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
+  testing::ElementsAreArray(
+  {RangeIs(Test.range()), RangeIs(SymbolHeader.ran

[PATCH] D46524: [clangd] Extract scoring/ranking logic, and shave yaks.

2018-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/CodeComplete.cpp:909
+
+auto QualScore = Quality.evaluate(), RelScore = Relevance.evaluate();
+CompletionItemScores Scores;

ilya-biryukov wrote:
> NIT: Maybe use `float` here instead of auto? Would remove the need to look at 
> `evaluate` for anyone reading the code for the first time.
Done. I was worried we might switch to double one day, seems unlikely.



Comment at: clangd/Quality.h:66
+  float NameMatch = 1;
+  bool Unavailable = false;
+

ilya-biryukov wrote:
> Maybe rename to `Inaccessible`? It seems to be closer to what this bool means 
> in C++, if I'm reading the code correctly.
> Or add a comment explaining what "unavailable" means?
So it's `Unavailable || Inaccessible`, where neither is all that well-defined 
:-)
I renamed to `Forbidden` to avoid conflation with either, and added examples as 
a comment.



Comment at: clangd/Quality.h:80
+// TopN is a lossy container that preserves only the "best" N elements.
+template > class TopN {
+public:

ilya-biryukov wrote:
> As you mentioned  in the change description, moving `TopN` and `sortText` to 
> a separate file might be a good idea since they don't depend on various 
> clangd-specific bits.
> But I'm perfectly happy to leave it as is and do this later if needed.
Yeah, I'd rather punt on this for now to avoid creating too many tiny files and 
a random standard library supplement. If TopN is pulled out, llvm/Support might 
be a better place for it.



Comment at: clangd/Quality.h:119
+
+// Returns a string that sorts like (-Score, Tiebreak).
+std::string sortText(float Score, llvm::StringRef Tiebreak = "");

ilya-biryukov wrote:
> Maybe mention that it's used for LSP sortText? To give a bit more context on 
> why we need this function.
Oops, I wrote the comment but put it in the cpp file by mistake...



Comment at: unittests/clangd/TestTU.cpp:62
+  << S;
+llvm_unreachable("QName is not unique");
+  }

ilya-biryukov wrote:
> Maybe use `FAIL()` instead of `ADD_FAILURE()` followed by 
> `llvm_unreachable()`?
> `llvm_unreachable` may produce surprising behaviors, i.e. miscompiles in opt 
> mode etc, IIUC.
> Both failing or returning a first matching symbol while also signalling an 
> error seem like good alternatives here.
`FAIL()` is the same as `ADD_FAILURE()` but it causes the enclosing function to 
immediately return - it can only be used from void functions.

> llvm_unreachable may produce surprising behaviors, i.e. miscompiles in opt 
> mode etc, IIUC
Right. After offline discussion, we don't care about asserts-disabled test 
behavior if the asserts-enabled failure is sensible, so just replaced with an 
assert.



Comment at: unittests/clangd/TestTU.h:28
+  TestTU() = default;
+  TestTU(llvm::StringRef Code, llvm::StringRef HeaderCode = "")
+  : Code(Code), HeaderCode(HeaderCode) {}

ilya-biryukov wrote:
> I really like this helper, now that we can reuse the code between different 
> tests!
> It took me some time to get the semantics of this constructor, though.
> I suggest to have a few constructor functions with more descriptive name (my 
> names are not great, but should give the idea):
> ```
> static TestTU FromSourceFile(StringRef Code);
> static TestTU FromHeaderFile(StringRef Code);
> static TestTU WithImplicitInclude(StringRef Source, StringRef IncludedHeader);
> ```
> 
> 
> 
Done, Just added `withCode` and `withHeaderCode` for now, and anyone who wants 
something more complicated can set the fields directly.
(The names mirror the struct fields)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46472: [HIP] Support offloading by linkscript

2018-05-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 145480.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Rename variables used for CUDA only.


https://reviews.llvm.org/D46472

Files:
  include/clang/Driver/Options.td
  lib/CodeGen/CGCUDANV.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Gnu.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,22 +1,22 @@
 // RUN: echo "GPU binary would be here" > %t
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - \
-// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,CUDA
+// RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,CUDA,CUDANORDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS \
-// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,CUDANOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - \
-// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,CUDA
+// RUN:   | FileCheck %s --check-prefixes=ALL,RDC,CUDA,CUDARDC
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \
 // RUN:   | FileCheck %s -check-prefix=NOGPUBIN
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
 // RUN:   | FileCheck %s --check-prefixes=ALL,NORDC,HIP
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o -  -DNOGLOBALS -x hip \
-// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN:   | FileCheck %s -check-prefixes=NOGLOBALS,HIPNOGLOBALS
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-rdc -fcuda-include-gpubinary %t -o - -x hip \
 // RUN:   | FileCheck %s --check-prefixes=ALL,RDC,HIP
@@ -64,15 +64,17 @@
 // * constant unnamed string with the kernel name
 // ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
-// ALL: private unnamed_addr constant{{.*GPU binary would be here.*}}\00"
-// NORDC-SAME: section ".nv_fatbin", align 8
-// RDC-SAME: section "__nv_relfatbin", align 8
+// HIP: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin"
+// CUDA: @[[FATBIN:.*]] = private unnamed_addr constant{{.*GPU binary would be here.*}}\00",
+// CUDANORDC-SAME: section ".nv_fatbin", align 8
+// CUDARDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
-// CUDA: @__[[PREFIX:cuda]]_fatbin_wrapper = internal constant
-// CUDA-SAME: { i32, i32, i8*, i8* }
-// HIP: @__[[PREFIX:hip]]_fatbin_wrapper = internal constant
-// HIP-SAME:  { i32, i32, i8*, i8* }
-// ALL-SAME: { i32 1180844977, i32 1, {{.*}}, i8* null }
+// ALL: @__[[PREFIX:cuda|hip]]_fatbin_wrapper = internal constant
+// ALL-SAME: { i32, i32, i8*, i8* }
+// ALL-SAME: { i32 1180844977, i32 1,
+// CUDA-SAME: i8* getelementptr inbounds ({{.*}}@[[FATBIN]], i64 0, i64 0),
+// HIP-SAME:  i8* @[[FATBIN]],
+// ALL-SAME: i8* null }
 // ALL-SAME: section ".nvFatBinSegment"
 // * variable to save GPU binary handle after initialization
 // NORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
@@ -136,9 +138,10 @@
 // There should be no __[[PREFIX]]_register_globals if we have no
 // device-side globals, but we still need to register GPU binary.
 // Skip GPU binary string first.
-// NOGLOBALS: @0 = private unnamed_addr constant{{.*}}
+// CUDANOGLOBALS: @{{.*}} = private unnamed_addr constant{{.*}}
+// HIPNOGLOBALS: @{{.*}} = external constant{{.*}}
 // NOGLOBALS-NOT: define internal void @__{{.*}}_register_globals
-// NOGLOBALS: define internal void @__[[PREFIX:.*]]_module_ctor
+// NOGLOBALS: define internal void @__[[PREFIX:cuda|hip]]_module_ctor
 // NOGLOBALS: call{{.*}}[[PREFIX]]RegisterFatBinary{{.*}}__[[PREFIX]]_fatbin_wrapper
 // NOGLOBALS-NOT: call void @__[[PREFIX]]_register_globals
 // NOGLOBALS: define internal void @__[[PREFIX]]_module_dtor
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -535,6 +535,10 @@
   // Add OpenMP offloading linker script args if required.
   AddOpenMPLinkerScript(getToolChain(), C, Output, Inputs, Args, CmdArgs, JA);
 
+  // Add HIP offloading linker script args if required.
+  AddHIPLinkerScript(getToolChain(), C, Output, Inputs, Args, CmdArgs, JA,
+ *this);
+
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
Index: lib/Driver/ToolChains/CommonArgs.h
===
--- lib/Driver/ToolChains/CommonArgs.h
+++ lib/Driver/ToolChains/CommonArgs.h
@@ -52,6 +52,12 @@

r331644 - [docs] Fix typos in the Clang User's Manual.

2018-05-07 Thread Joel Galenson via cfe-commits
Author: jgalenson
Date: Mon May  7 09:23:46 2018
New Revision: 331644

URL: http://llvm.org/viewvc/llvm-project?rev=331644&view=rev
Log:
[docs] Fix typos in the Clang User's Manual.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=331644&r1=331643&r2=331644&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon May  7 09:23:46 2018
@@ -1735,11 +1735,11 @@ profile creation and use.
 .. option:: -fprofile-generate[=]
 
   The ``-fprofile-generate`` and ``-fprofile-generate=`` flags will use
-  an alterantive instrumentation method for profile generation. When
+  an alternative instrumentation method for profile generation. When
   given a directory name, it generates the profile file
   ``default_%m.profraw`` in the directory named ``dirname`` if specified.
   If ``dirname`` does not exist, it will be created at runtime. ``%m`` 
specifier
-  will be substibuted with a unique id documented in step 2 above. In other 
words,
+  will be substituted with a unique id documented in step 2 above. In other 
words,
   with ``-fprofile-generate[=]`` option, the "raw" profile data 
automatic
   merging is turned on by default, so there will no longer any risk of profile
   clobbering from different running processes.  For example,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-07 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl updated this revision to Diff 145486.
r.stahl edited the summary of this revision.
r.stahl added a comment.

full patch with test


https://reviews.llvm.org/D46115

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  test/Import/attr/Inputs/S.cpp
  test/Import/attr/test.cpp

Index: test/Import/attr/Inputs/S.cpp
===
--- test/Import/attr/Inputs/S.cpp
+++ test/Import/attr/Inputs/S.cpp
@@ -0,0 +1,14 @@
+extern void f() __attribute__((const));
+
+struct S
+{
+struct {
+int a __attribute__((packed));
+};
+};
+
+void stmt()
+{
+#pragma unroll
+for (;;);
+}
Index: test/Import/attr/test.cpp
===
--- test/Import/attr/test.cpp
+++ test/Import/attr/test.cpp
@@ -0,0 +1,26 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/S.cpp -expression %s | FileCheck %s
+// CHECK: FunctionDecl
+// CHECK-SAME: S.cpp:1:1, col:13
+// CHECK-NEXT: ConstAttr
+// CHECK-SAME: col:32
+
+// CHECK: IndirectFieldDecl
+// CHECK-NEXT: Field
+// CHECK-NEXT: Field
+// CHECK-NEXT: PackedAttr
+// CHECK-SAME: col:30
+
+// CHECK: AttributedStmt
+// CHECK-NEXT: LoopHintAttr
+// CHECK-SAME: line:12:13
+
+extern void f() __attribute__((const));
+
+struct S;
+
+void stmt();
+
+void expr() {
+  f();
+  struct S s;
+}
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2646,8 +2646,8 @@
   Importer.getToContext(), DC, Loc, Name.getAsIdentifierInfo(), T,
   {NamedChain, D->getChainingSize()});
 
-  for (const auto *Attr : D->attrs())
-ToIndirectField->addAttr(Attr->clone(Importer.getToContext()));
+  for (const auto *A : D->attrs())
+ToIndirectField->addAttr(Importer.Import(const_cast(A)));
 
   ToIndirectField->setAccess(D->getAccess());
   ToIndirectField->setLexicalDeclContext(LexicalDC);
@@ -4721,10 +4721,9 @@
   SourceLocation ToAttrLoc = Importer.Import(S->getAttrLoc());
   ArrayRef FromAttrs(S->getAttrs());
   SmallVector ToAttrs(FromAttrs.size());
-  ASTContext &_ToContext = Importer.getToContext();
   std::transform(FromAttrs.begin(), FromAttrs.end(), ToAttrs.begin(),
-[&_ToContext](const Attr *A) -> const Attr * {
-  return A->clone(_ToContext);
+[this](const Attr *A) -> const Attr * {
+  return Importer.Import(const_cast(A));
 });
   for (const auto *ToA : ToAttrs) {
 if (!ToA)
@@ -6544,6 +6543,15 @@
Import(FromTSI->getTypeLoc().getLocStart()));
 }
 
+Attr *ASTImporter::Import(Attr *FromAttr) {
+  if (!FromAttr)
+return nullptr;
+
+  Attr *ToAttr = FromAttr->clone(ToContext);
+  ToAttr->setRange(Import(FromAttr->getRange()));
+  return ToAttr;
+}
+
 Decl *ASTImporter::GetAlreadyImportedOrNull(Decl *FromD) {
   llvm::DenseMap::iterator Pos = ImportedDecls.find(FromD);
   if (Pos != ImportedDecls.end()) {
@@ -7200,7 +7208,7 @@
 Decl *ASTImporter::Imported(Decl *From, Decl *To) {
   if (From->hasAttrs()) {
 for (auto *FromAttr : From->getAttrs())
-  To->addAttr(FromAttr->clone(To->getASTContext()));
+  To->addAttr(Import(FromAttr));
   }
   if (From->isUsed()) {
 To->setIsUsed();
Index: include/clang/AST/ASTImporter.h
===
--- include/clang/AST/ASTImporter.h
+++ include/clang/AST/ASTImporter.h
@@ -41,6 +41,7 @@
 class Stmt;
 class TagDecl;
 class TypeSourceInfo;
+class Attr;
 
   /// \brief Imports selected nodes from one AST context into another context,
   /// merging AST nodes where appropriate.
@@ -130,6 +131,13 @@
 /// context, or NULL if an error occurred.
 TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
 
+/// \brief Import the given attribute from the "from" context into the
+/// "to" context.
+///
+/// \returns the equivalent attribute in the "to" context, or NULL if an
+/// error occurred.
+Attr *Import(Attr *FromAttr);
+
 /// \brief Import the given declaration from the "from" context into the 
 /// "to" context.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: aaron.ballman, spatel, RKSimon.

As identified and briefly discussed here:
https://bugs.llvm.org/show_bug.cgi?id=37305

Converting a floating point number to an integer type when
the integral part is out of the range of the integer type is
undefined behavior in C.  Additionally, CodeGen emits an undef
in this situation.

HOWEVER, we've been giving a warning that says that the value is
changed.  This patch corrects the warning to list that it is actually
undefined behavior.


Repository:
  rC Clang

https://reviews.llvm.org/D46535

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/warn-float-conversion.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9429,6 +9429,20 @@
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool) {
+  if (IntegerValue.isSigned() &&
+  (IntegerValue.isMaxSignedValue() || IntegerValue.isMinSignedValue()))
+return DiagnoseImpCast(
+S, E, T, CContext,
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+  if (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(
+S, E, T, CContext,
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+}
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9458,19 @@
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3140,14 +3140,20 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -157,7 +157,7 @@
 void yield() {
   co_yield 0;
   co_yield {"foo", 1, 2};
-  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
   co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
   co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
Index: test/SemaCXX/warn-literal-conversion.cpp
===
--- test/SemaCXX/warn-literal-conver

r331651 - Fix explicit template parameter reporting for narrowing conversions

2018-05-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon May  7 10:05:20 2018
New Revision: 331651

URL: http://llvm.org/viewvc/llvm-project?rev=331651&view=rev
Log:
Fix explicit template parameter reporting for narrowing conversions

I found that explicit template parameters that caused a
narrowing integer conversion resulted in the incorrect parameter
being mentioned in the note (see test attached). This is because
the argument checking code doesn't check to see if it caused
SFINAE errors when checking the arguments, so instead of giving
up on the first error, it continues through the list. This
makes the error reporting pick up the last template param every time.

This patch checks these parameters on each argument and gives up
if there is an error. The result is that only the required amount
of arguments are checked, and that the 'Converted' array contains
only the successful arguments before the first failure, as the
calls seem to all expect.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=331651&r1=331650&r2=331651&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon May  7 10:05:20 2018
@@ -4668,11 +4668,15 @@ bool Sema::CheckTemplateArgument(NamedDe
 
 case TemplateArgument::Expression: {
   TemplateArgument Result;
+  unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
 CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
   Result, CTAK);
   if (Res.isInvalid())
 return true;
+  // If the current template argument causes an error, give up now.
+  if (CurSFINAEErrors < NumSFINAEErrors)
+return true;
 
   // If the resulting expression is new, then use it in place of the
   // old expression in the template argument.

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp?rev=331651&r1=331650&r2=331651&view=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Mon May  7 10:05:20 
2018
@@ -36,3 +36,15 @@ namespace check_conversion_early {
   struct Y { constexpr operator int() const { return 0; } };
   template struct A {}; // expected-error {{cannot be deduced}} 
expected-note {{'y'}}
 }
+
+namespace ReportCorrectParam {
+template 
+void TempFunc() {}
+
+void Useage() {
+  //expected-error@+2 {{no matching function}}
+  //expected-note@-4 {{candidate template ignored: invalid 
explicitly-specified argument for template parameter 'b'}}
+  TempFunc<1, -1, 1>();
+}
+}
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42664: Fix explicit template parameter reporting for narrowing conversions

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

Did Review-after-commit, in retrospect this is a pretty tiny change.


https://reviews.llvm.org/D42664



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Rafael! Please find my comments inline.




Comment at: lib/AST/ASTImporter.cpp:2650
+  for (const auto *A : D->attrs())
+ToIndirectField->addAttr(Importer.Import(const_cast(A)));
 

Could we just remove 'const' qualifier from `A` to avoid `const_cast`? (Same 
below)



Comment at: lib/AST/ASTImporter.cpp:6547
+Attr *ASTImporter::Import(Attr *FromAttr) {
+  if (!FromAttr)
+return nullptr;

Is it possible to get into a situation where a nullptr attribute is imported?



Comment at: lib/AST/ASTImporter.cpp:7211
 for (auto *FromAttr : From->getAttrs())
-  To->addAttr(FromAttr->clone(To->getASTContext()));
+  To->addAttr(Import(FromAttr));
   }

As I can see, `Import(Attr *)` can return nullptr. And I'm not sure that 
`addAttr(nullptr)` has well-defined behaviour.



Comment at: test/Import/attr/Inputs/S.cpp:4
+struct S
+{
+struct {

Could you please clang-format the file?


https://reviews.llvm.org/D46115



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46115: [ASTImporter] properly import SrcLoc of Attr

2018-05-07 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Sorry, two more nits.




Comment at: include/clang/AST/ASTImporter.h:137
+///
+/// \returns the equivalent attribute in the "to" context, or NULL if an
+/// error occurred.

nullptr



Comment at: lib/AST/ASTImporter.cpp:4724
   SmallVector ToAttrs(FromAttrs.size());
-  ASTContext &_ToContext = Importer.getToContext();
   std::transform(FromAttrs.begin(), FromAttrs.end(), ToAttrs.begin(),
+[this](const Attr *A) -> const Attr * {

Could we use ImportArrayChecked instead?


https://reviews.llvm.org/D46115



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331652 - [OPENMP, NVPTX] Codegen for critical construct.

2018-05-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  7 10:23:05 2018
New Revision: 331652

URL: http://llvm.org/viewvc/llvm-project?rev=331652&view=rev
Log:
[OPENMP, NVPTX] Codegen for critical construct.

Added correct codegen for the critical construct on NVPTX devices.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=331652&r1=331651&r2=331652&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon May  7 10:23:05 2018
@@ -1837,6 +1837,66 @@ void CGOpenMPRuntimeNVPTX::emitSpmdParal
   emitOutlinedFunctionCall(CGF, Loc, OutlinedFn, OutlinedFnArgs);
 }
 
+void CGOpenMPRuntimeNVPTX::emitCriticalRegion(
+CodeGenFunction &CGF, StringRef CriticalName,
+const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc,
+const Expr *Hint) {
+  llvm::BasicBlock *LoopBB = CGF.createBasicBlock("omp.critical.loop");
+  llvm::BasicBlock *TestBB = CGF.createBasicBlock("omp.critical.test");
+  llvm::BasicBlock *SyncBB = CGF.createBasicBlock("omp.critical.sync");
+  llvm::BasicBlock *BodyBB = CGF.createBasicBlock("omp.critical.body");
+  llvm::BasicBlock *ExitBB = CGF.createBasicBlock("omp.critical.exit");
+
+  // Fetch team-local id of the thread.
+  llvm::Value *ThreadID = getNVPTXThreadID(CGF);
+
+  // Get the width of the team.
+  llvm::Value *TeamWidth = getNVPTXNumThreads(CGF);
+
+  // Initialize the counter variable for the loop.
+  QualType Int32Ty =
+  CGF.getContext().getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/0);
+  Address Counter = CGF.CreateMemTemp(Int32Ty, "critical_counter");
+  LValue CounterLVal = CGF.MakeAddrLValue(Counter, Int32Ty);
+  CGF.EmitStoreOfScalar(llvm::Constant::getNullValue(CGM.Int32Ty), CounterLVal,
+/*isInit=*/true);
+
+  // Block checks if loop counter exceeds upper bound.
+  CGF.EmitBlock(LoopBB);
+  llvm::Value *CounterVal = CGF.EmitLoadOfScalar(CounterLVal, Loc);
+  llvm::Value *CmpLoopBound = CGF.Builder.CreateICmpSLT(CounterVal, TeamWidth);
+  CGF.Builder.CreateCondBr(CmpLoopBound, TestBB, ExitBB);
+
+  // Block tests which single thread should execute region, and which threads
+  // should go straight to synchronisation point.
+  CGF.EmitBlock(TestBB);
+  CounterVal = CGF.EmitLoadOfScalar(CounterLVal, Loc);
+  llvm::Value *CmpThreadToCounter =
+  CGF.Builder.CreateICmpEQ(ThreadID, CounterVal);
+  CGF.Builder.CreateCondBr(CmpThreadToCounter, BodyBB, SyncBB);
+
+  // Block emits the body of the critical region.
+  CGF.EmitBlock(BodyBB);
+
+  // Output the critical statement.
+  CriticalOpGen(CGF);
+
+  // After the body surrounded by the critical region, the single executing
+  // thread will jump to the synchronisation point.
+  // Block waits for all threads in current team to finish then increments the
+  // counter variable and returns to the loop.
+  CGF.EmitBlock(SyncBB);
+  getNVPTXCTABarrier(CGF);
+
+  llvm::Value *IncCounterVal =
+  CGF.Builder.CreateNSWAdd(CounterVal, CGF.Builder.getInt32(1));
+  CGF.EmitStoreOfScalar(IncCounterVal, CounterLVal);
+  CGF.EmitBranch(LoopBB);
+
+  // Block that is reached when  all threads in the team complete the region.
+  CGF.EmitBlock(ExitBB, /*IsFinished=*/true);
+}
+
 /// Cast value to the specified type.
 static llvm::Value *castValueToType(CodeGenFunction &CGF, llvm::Value *Val,
 QualType ValTy, QualType CastTy,

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h?rev=331652&r1=331651&r2=331652&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h Mon May  7 10:23:05 2018
@@ -250,6 +250,16 @@ public:
 ArrayRef CapturedVars,
 const Expr *IfCond) override;
 
+  /// Emits a critical region.
+  /// \param CriticalName Name of the critical region.
+  /// \param CriticalOpGen Generator for the statement associated with the 
given
+  /// critical region.
+  /// \param Hint Value of the 'hint' clause (optional).
+  void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
+  const RegionCodeGenTy &CriticalOpGen,
+  SourceLocation Loc,
+  const Expr *Hint = nullptr) override;
+
   /// Emit a code for reduction clause.
   ///
   /// \param Privates List of private copies for original reduction arguments.

Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/t

[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-05-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/Representation.cpp:53
+  move(Namespace, std::move(Other.Namespace));
+  extend(Description, std::move(Other.Description));
+  return true;

sammccall wrote:
> is plain concatenation of comments what you want?
Yes, in this case, as they aren't comment strings but vectors of comment infos. 


https://reviews.llvm.org/D43341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1403
+  if (auto *IL = dyn_cast_or_null(Init)) {
+if (InitTy->isConstantArrayType()) {
+  for (auto I : IL->inits())

sepavloff wrote:
> rjmccall wrote:
> > Do you actually care if it's an array initialization instead of a 
> > struct/enum initialization?
> If this code is enabled for for records too, some tests start to fail. For 
> instance, the code:
> ```
> union { int i; double f; } u2 = { };
> ```
> produces output:
> ```
> %union.anon = type { double }
> @u2 = global %union.anon zeroinitializer, align 4
> ```
> while previously it produced:
> ```
> @u2 = global { i32, [4 x i8] } { i32 0, [4 x i8] undef }, align 4
> ```
> The latter looks more correct.
Hmm.  In C++, a static object which isn't constant-initialized is 
zero-initialized, which is required to set any padding bits to zero (N4640 
[dcl.init]p6) in both structs and unions.  In C, a static object which doesn't 
have an initializer also has all any padding bits set to zero (N1548 6.7.9p10). 
 Now, this object has an initializer (that acts as a constant-initializer in 
C++), so those rules don't directly apply; but I would argue that the intent of 
the standards is not that padding bits become undefined when you happen to have 
an initializer.  So I actually think the `zeroinitializer` emission is more 
correct.


Repository:
  rC Clang

https://reviews.llvm.org/D46241



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46471: [HIP] Add hip offload kind

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D46471



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331654 - [OPENMP, NVPTX] Small test fix, NFC.

2018-05-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  7 10:38:13 2018
New Revision: 331654

URL: http://llvm.org/viewvc/llvm-project?rev=331654&view=rev
Log:
[OPENMP, NVPTX] Small test fix, NFC.

Modified:
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp?rev=331654&r1=331653&r2=331654&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp Mon May  7 10:38:13 2018
@@ -317,8 +317,8 @@ int bar(int n){
 
 // CHECK-LABEL: define internal void @{{.+}}(i32* noalias %{{.+}}, i32* 
noalias %{{.+}}, i32* dereferenceable{{.*}})
 // CHECK:  [[CC:%.+]] = alloca i32,
-// CHECK:  [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x(),
-// CHECK:  [[NUM_THREADS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x(),
+// CHECK:  [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK:  [[NUM_THREADS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
 // CHECK:  store i32 0, i32* [[CC]],
 // CHECK:  br label
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExprAgg.cpp:964
+RHS = CGF.EmitAnyExpr(E->getRHS()).getAggregatePointer();
+break;
+  case TEK_Complex:

EricWF wrote:
> EricWF wrote:
> > rjmccall wrote:
> > > It looks like we don't actually support any aggregate types here, which I 
> > > think is fine because comparing those types is only sensible for things 
> > > like calls.  If you do want to pave the way for that, or (probably more 
> > > usefully) for supporting complex types, you should make EmitCompare take 
> > > the operands as RValues and just use EmitAnyExpr here without paying any 
> > > attention to the evaluation kind.
> > Initially I thought the same thing, but apparently member pointers are 
> > Aggregates under the Microsoft ABI.
> > 
> > I'll give  trafficking in `RValue`s, but all the functions `EmitCompare` 
> > calls use `Value*`, so it'll take some work.
> *I'll give trafficking in `RValue`s a shot, but ...*
Okay, this would be a *lot* cleaner with RValue.  You can break it down in your 
EmitCmp helper function instead of EmitCompare if you want, but you've 
basically just inlined EmitAnyExpr here.



Comment at: lib/CodeGen/CGExprAgg.cpp:924
+  }();
+  ArgTy->isAnyComplexType();
+  if (ArgTy->hasFloatingRepresentation())

Dead code?


https://reviews.llvm.org/D45476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-07 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments.



Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:45
+  anyOf(TypesMatcher, pointerType(pointee(TypesMatcher)),
+  callee(namedDecl(hasName("data"
+  .bind("call",

aaron.ballman wrote:
> shuaiwang wrote:
> > aaron.ballman wrote:
> > > Eugene.Zelenko wrote:
> > > > aaron.ballman wrote:
> > > > > Should this check apply equally to `std::string::c_str()` as well as 
> > > > > `std::string::data()`?
> > > > readability-redundant-string-cstr do both.
> > > Yup! But that makes me wonder if the name "redundant-data-call" is an 
> > > issue. Perhaps the check name should focus more on the array subscript in 
> > > the presence of an operator[]()?
> > How about "readability-circumlocutionary-subscript"?
> > "readability-circumlocutionary-element-access"?
> > "circumlocutionary" -> "verbose"?
> hah, I think circumlocutionary might be a bit too much. ;-) I think 
> `readability-simplify-array-subscript-expr` might be reasonable, however. 
> Right now, the simplification is just for `foo.data()[0]` but it seems 
> plausible that there are other array subscript simplifications that could be 
> added in the future, like `a[1 + 1]` being converted to `a[2]` or `x ? a[200] 
> : a[400]` going to `a[x ? 200 : 400]` (etc).
Just `readability-simplify-subscript-expr`?
Since after simplification the subscript operation is done by calling 
overloaded `operator[]` on an object instead of built-in subscript operator on 
an array.

Let me know if this name looks good to you and I'll do the actual renaming 
(together with addressing other comments) after your confirmation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/AST/ExprConstant.cpp:8829
+  return EvaluateComparisonBinaryOperator(Info, E, OnSuccess, [&]() {
+return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
+  });

rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > It'd be clearer to call `VisitBinCmp` rather than `VisitBinaryOperator`.
> > @rsmith: OK, so I'm confused about this. Originally I had an 
> > `llvm_unreachable` that the continuation was never reached, but you 
> > suggested it was. I'm not sure how. Could you provide an example?
> > 
> > The precondition of calling `VisitBinCmp` is that we have a call to a 
> > builtin operator. For `<=>`,  where the composite type is either an 
> > arithmetic type, pointer type, or member pointer type (which includes enum 
> > types after conversions),  *All* of these cases should be handled before 
> > reaching the function.
> > 
> > Is there a control flow path I'm missing? 
> What about comparisons of `_Complex` types, vector types, and any other 
> builtin type that gets added after you commit this patch? The right thing to 
> do (at least for now) in all of those cases is to call the base class 
> implementation, which will deal with emitting the "sorry, I don't know how to 
> constant-evaluate this" diagnostic.
> 
> My comment here was simply that when doing so, you should call the base-class 
> version of the *same* function, which you now do, so that concern is 
> addressed.
Ah, I didn't think about how errors were handled. Thank you.




Comment at: lib/CodeGen/CGExprAgg.cpp:964
+RHS = CGF.EmitAnyExpr(E->getRHS()).getAggregatePointer();
+break;
+  case TEK_Complex:

rjmccall wrote:
> EricWF wrote:
> > EricWF wrote:
> > > rjmccall wrote:
> > > > It looks like we don't actually support any aggregate types here, which 
> > > > I think is fine because comparing those types is only sensible for 
> > > > things like calls.  If you do want to pave the way for that, or 
> > > > (probably more usefully) for supporting complex types, you should make 
> > > > EmitCompare take the operands as RValues and just use EmitAnyExpr here 
> > > > without paying any attention to the evaluation kind.
> > > Initially I thought the same thing, but apparently member pointers are 
> > > Aggregates under the Microsoft ABI.
> > > 
> > > I'll give  trafficking in `RValue`s, but all the functions `EmitCompare` 
> > > calls use `Value*`, so it'll take some work.
> > *I'll give trafficking in `RValue`s a shot, but ...*
> Okay, this would be a *lot* cleaner with RValue.  You can break it down in 
> your EmitCmp helper function instead of EmitCompare if you want, but you've 
> basically just inlined EmitAnyExpr here.
OK, I think I've cleaned it up. Let me know what you think.



Comment at: lib/CodeGen/CGExprAgg.cpp:924
+  }();
+  ArgTy->isAnyComplexType();
+  if (ArgTy->hasFloatingRepresentation())

rjmccall wrote:
> Dead code?
Woops. Removed.


https://reviews.llvm.org/D45476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46540: [X86] ptwrite intrinsic

2018-05-07 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added a reviewer: craig.topper.
Herald added subscribers: cfe-commits, mgorny.

Repository:
  rC Clang

https://reviews.llvm.org/D46540

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cpuid.h
  lib/Headers/module.modulemap
  lib/Headers/ptwriteintrin.h
  lib/Headers/x86intrin.h
  test/CodeGen/ptwrite.c
  test/Driver/x86-target-features.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1400,6 +1400,7 @@
 // CHECK_GLMP_M32: #define __PCLMUL__ 1
 // CHECK_GLMP_M32: #define __POPCNT__ 1
 // CHECK_GLMP_M32: #define __PRFCHW__ 1
+// CHECK_GLMP_M32: #define __PTWRITE__ 1
 // CHECK_GLMP_M32: #define __RDPID__ 1
 // CHECK_GLMP_M32: #define __RDRND__ 1
 // CHECK_GLMP_M32: #define __RDSEED__ 1
@@ -1435,6 +1436,7 @@
 // CHECK_GLMP_M64: #define __PCLMUL__ 1
 // CHECK_GLMP_M64: #define __POPCNT__ 1
 // CHECK_GLMP_M64: #define __PRFCHW__ 1
+// CHECK_GLMP_M64: #define __PTWRITE__ 1
 // CHECK_GLMP_M64: #define __RDPID__ 1
 // CHECK_GLMP_M64: #define __RDRND__ 1
 // CHECK_GLMP_M64: #define __RDSEED__ 1
@@ -1472,6 +1474,7 @@
 // CHECK_TRM_M32: #define __PCLMUL__ 1
 // CHECK_TRM_M32: #define __POPCNT__ 1
 // CHECK_TRM_M32: #define __PRFCHW__ 1
+// CHECK_TRM_M32: #define __PTWRITE__ 1
 // CHECK_TRM_M32: #define __RDPID__ 1
 // CHECK_TRM_M32: #define __RDRND__ 1
 // CHECK_TRM_M32: #define __RDSEED__ 1
@@ -1512,6 +1515,7 @@
 // CHECK_TRM_M64: #define __PCLMUL__ 1
 // CHECK_TRM_M64: #define __POPCNT__ 1
 // CHECK_TRM_M64: #define __PRFCHW__ 1
+// CHECK_TRM_M64: #define __PTWRITE__ 1
 // CHECK_TRM_M64: #define __RDPID__ 1
 // CHECK_TRM_M64: #define __RDRND__ 1
 // CHECK_TRM_M64: #define __RDSEED__ 1
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -159,3 +159,8 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIR64B %s
 // MOVDIR64B: "-target-feature" "+movdir64b"
 // NO-MOVDIR64B: "-target-feature" "-movdir64b"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mptwrite %s -### -o %t.o 2>&1 | FileCheck -check-prefix=PTWRITE %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-ptwrite %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-PTWRITE %s
+// PTWRITE: "-target-feature" "+ptwrite"
+// NO-PTWRITE: "-target-feature" "-ptwrite"
Index: test/CodeGen/ptwrite.c
===
--- /dev/null
+++ test/CodeGen/ptwrite.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +ptwrite -emit-llvm -o - -Wall -Werror -pedantic | FileCheck %s --check-prefix=X86 --check-prefix=X86_64
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +ptwrite -emit-llvm -o - -Wall -Werror -pedantic | FileCheck %s --check-prefix=X86
+
+#include 
+
+#include 
+
+void test_ptwrite32(uint32_t value) {
+  //X86-LABEL: @test_ptwrite32
+  //X86: call void @llvm.x86.ptwrite32(i32 %{{.*}})
+  _ptwrite32(value);
+}
+
+#ifdef __x86_64__
+
+void test_ptwrite64(uint64_t value) {
+  //X86_64-LABEL: @test_ptwrite64
+  //X86_64: call void @llvm.x86.ptwrite64(i64 %{{.*}})
+  _ptwrite64(value);
+}
+
+#endif /* __x86_64__ */
Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -105,4 +105,8 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PTWRITE__)
+#include 
+#endif
+
 #endif /* __X86INTRIN_H */
Index: lib/Headers/ptwriteintrin.h
===
--- /dev/null
+++ lib/Headers/ptwriteintrin.h
@@ -0,0 +1,51 @@
+/*=== ptwriteintrin.h - PTWRITE intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE W

Re: r331556 - [analyzer] Treat more const variables and fields as known contants.

2018-05-07 Thread Alexander Kornienko via cfe-commits
It looks like this commit has introduced an assertion failure. See
https://bugs.llvm.org/show_bug.cgi?id=37357.

On Fri, May 4, 2018 at 10:56 PM Artem Dergachev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dergachev
> Date: Fri May  4 13:52:39 2018
> New Revision: 331556
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331556&view=rev
> Log:
> [analyzer] Treat more const variables and fields as known contants.
>
> When loading from a variable or a field that is declared as constant,
> the analyzer will try to inspect its initializer and constant-fold it.
> Upon success, the analyzer would skip normal load and return the respective
> constant.
>
> The new behavior also applies to fields/elements of brace-initialized
> structures
> and arrays.
>
> Patch by Rafael Stahl!
>
> Differential Revision: https://reviews.llvm.org/D45774
>
> Added:
> cfe/trunk/test/Analysis/globals.cpp
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=331556&r1=331555&r2=331556&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri May  4 13:52:39
> 2018
> @@ -1606,7 +1606,7 @@ SVal RegionStoreManager::getBindingForEl
>const MemRegion* superR = R->getSuperRegion();
>
>// Check if the region is an element region of a string literal.
> -  if (const StringRegion *StrR=dyn_cast(superR)) {
> +  if (const StringRegion *StrR = dyn_cast(superR)) {
>  // FIXME: Handle loads from strings where the literal is treated as
>  // an integer, e.g., *((unsigned int*)"hello")
>  QualType T =
> Ctx.getAsArrayType(StrR->getValueType())->getElementType();
> @@ -1629,6 +1629,27 @@ SVal RegionStoreManager::getBindingForEl
>char c = (i >= length) ? '\0' : Str->getCodeUnit(i);
>return svalBuilder.makeIntVal(c, T);
>  }
> +  } else if (const VarRegion *VR = dyn_cast(superR)) {
> +// Check if the containing array is const and has an initialized
> value.
> +const VarDecl *VD = VR->getDecl();
> +// Either the array or the array element has to be const.
> +if (VD->getType().isConstQualified() ||
> R->getElementType().isConstQualified()) {
> +  if (const Expr *Init = VD->getInit()) {
> +if (const auto *InitList = dyn_cast(Init)) {
> +  // The array index has to be known.
> +  if (auto CI = R->getIndex().getAs()) {
> +int64_t i = CI->getValue().getSExtValue();
> +// Return unknown value if index is out of bounds.
> +if (i < 0 || i >= InitList->getNumInits())
> +  return UnknownVal();
> +
> +if (const Expr *ElemInit = InitList->getInit(i))
> +  if (Optional V = svalBuilder.getConstantVal(ElemInit))
> +return *V;
> +  }
> +}
> +  }
> +}
>}
>
>// Check for loads from a code text region.  For such loads, just give
> up.
> @@ -1678,7 +1699,28 @@ SVal RegionStoreManager::getBindingForFi
>if (const Optional &V = B.getDirectBinding(R))
>  return *V;
>
> -  QualType Ty = R->getValueType();
> +  // Is the field declared constant and has an in-class initializer?
> +  const FieldDecl *FD = R->getDecl();
> +  QualType Ty = FD->getType();
> +  if (Ty.isConstQualified())
> +if (const Expr *Init = FD->getInClassInitializer())
> +  if (Optional V = svalBuilder.getConstantVal(Init))
> +return *V;
> +
> +  // If the containing record was initialized, try to get its constant
> value.
> +  const MemRegion* superR = R->getSuperRegion();
> +  if (const auto *VR = dyn_cast(superR)) {
> +const VarDecl *VD = VR->getDecl();
> +QualType RecordVarTy = VD->getType();
> +// Either the record variable or the field has to be const qualified.
> +if (RecordVarTy.isConstQualified() || Ty.isConstQualified())
> +  if (const Expr *Init = VD->getInit())
> +if (const auto *InitList = dyn_cast(Init))
> +  if (const Expr *FieldInit =
> InitList->getInit(FD->getFieldIndex()))
> +if (Optional V = svalBuilder.getConstantVal(FieldInit))
> +  return *V;
> +  }
> +
>return getBindingForFieldOrElementCommon(B, R, Ty);
>  }
>
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=331556&r1=331555&r2=331556&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Fri May  4 13:52:39
> 2018
> @@ -119,7 +119,7 @@ SValBuilder::getRegionValueSymbolVal(con

[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes

2018-05-07 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added reviewers: craig.topper, echristo, dblaikie.
Herald added a subscriber: cfe-commits.

When requirement imposed by __target__ attributes on functions
are not satisfied, prefer printing those requirements, which
are explicitly mentioned in the attributes.

This makes such messages more useful, e.g. printing avx512f instead of avx2
in the following scenario:

  $ cat foo.c
  static inline void __attribute__((__always_inline__, __target__("avx512f")))
  x(void)
  {
  }
  
  int main(void)
  {
x();
  }
  $ clang foo.c
  foo.c:7:2: error: always_inline function 'x' requires target feature 'avx2', 
but would be inlined into function 'main' that is compiled without support for 
'avx2'
  x();
^
  1 error generated.

bugzilla: https://bugs.llvm.org/show_bug.cgi?id=37338


Repository:
  rC Clang

https://reviews.llvm.org/D46541

Files:
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/target-features-error-2.c
  test/CodeGen/target-features-error.c

Index: test/CodeGen/target-features-error.c
===
--- test/CodeGen/target-features-error.c
+++ test/CodeGen/target-features-error.c
@@ -3,6 +3,5 @@
   return a + 4;
 }
 int bar() {
-  return foo(4); // expected-error {{always_inline function 'foo' requires target feature 'sse4.2', but would be inlined into function 'bar' that is compiled without support for 'sse4.2'}}
+  return foo(4); // expected-error {{always_inline function 'foo' requires target feature 'avx', but would be inlined into function 'bar' that is compiled without support for 'avx'}}
 }
-
Index: test/CodeGen/target-features-error-2.c
===
--- test/CodeGen/target-features-error-2.c
+++ test/CodeGen/target-features-error-2.c
@@ -3,13 +3,14 @@
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX512f
 
 #define __MM_MALLOC_H
 #include 
 
 #if NEED_SSE42
 int baz(__m256i a) {
-  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be inlined into function 'baz' that is compiled without support for 'sse4.2'}}
+  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'avx', but would be inlined into function 'baz' that is compiled without support for 'avx'}}
 }
 #endif
 
@@ -36,3 +37,9 @@
   return _mm_cmp_sd(a, b, 0); // expected-error {{'__builtin_ia32_cmpsd' needs target feature avx}}
 }
 #endif
+
+#if NEED_AVX512f
+unsigned short need_avx512f(unsigned short a, unsigned short b) {
+  return __builtin_ia32_korhi(a, b); // expected-error {{'__builtin_ia32_korhi' needs target feature avx512f}}
+}
+#endif
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1082,6 +1082,8 @@
   /// It's up to you to ensure that this is safe.
   void AddDefaultFnAttrs(llvm::Function &F);
 
+  TargetAttr::ParsedTargetAttr getFunctionTargetAttrs(const FunctionDecl *FD);
+
   // Fills in the supplied string map with the set of target features for the
   // passed in function.
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4995,11 +4995,8 @@
   }
 }
 
-// Fills in the supplied string map with the set of target features for the
-// passed in function.
-void CodeGenModule::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
-  const FunctionDecl *FD) {
-  StringRef TargetCPU = Target.getTargetOpts().CPU;
+TargetAttr::ParsedTargetAttr CodeGenModule::getFunctionTargetAttrs(const FunctionDecl *FD)
+{
   if (const auto *TD = FD->getAttr()) {
 // If we have a TargetAttr build up the feature map based on that.
 TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
@@ -5011,7 +5008,20 @@
   StringRef{Feat}.substr(1));
 }),
 ParsedAttr.Features.end());
+return ParsedAttr;
+  } else {
+return TargetAttr::ParsedTargetAttr();
+  }
+}
+
 
+// Fills in the supplied string map with the set of target features for the
+// passed in function.
+void CodeGenModule::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
+  const FunctionDecl *FD) {
+  StringRef TargetCPU = Target.getTargetOpts().CPU;
+  TargetAttr::ParsedTargetAttr ParsedA

[PATCH] D24867: Request init/fini array on FreeBSD 12 and later

2018-05-07 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Brooks, I can commit this if you prefer.  Maybe it can go into 6.0.2 still...


https://reviews.llvm.org/D24867



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r331661 - Status updates for Rapperswil

2018-05-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May  7 11:59:04 2018
New Revision: 331661

URL: http://llvm.org/viewvc/llvm-project?rev=331661&view=rev
Log:
Status updates for Rapperswil

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=331661&r1=331660&r2=331661&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Mon May  7 11:59:04 2018
@@ -64,7 +64,7 @@
 https://wg21.link/LWG2970";>2970Return type of 
std::visit misspecifiedRapperswil
 https://wg21.link/LWG3058";>3058Parallel 
adjacent_difference shouldn't require creating 
temporariesRapperswil
 https://wg21.link/LWG3062";>3062Unnecessary 
decay_t in is_execution_policy_v should be 
remove_cvref_tRapperswil
-https://wg21.link/LWG3067";>3067recursive_directory_iterator::pop
 must invalidateRapperswil
+https://wg21.link/LWG3067";>3067recursive_directory_iterator::pop
 must invalidateRapperswilNothing to do
 https://wg21.link/LWG3071";>3071[networking.ts] 
read_until still refers to "input 
sequence"RapperswilNothing to do
 https://wg21.link/LWG3074";>3074Non-member 
functions for valarray should only deduce from the 
valarrayRapperswil
 https://wg21.link/LWG3076";>3076basic_string CTAD 
ambiguityRapperswil
@@ -74,7 +74,7 @@
 https://wg21.link/LWG3094";>3094[time.duration.io]p4 makes 
surprising claims about encodingRapperswil
 https://wg21.link/LWG3100";>3100Unnecessary and 
confusing "empty span" wordingRapperswilNothing to 
do
 https://wg21.link/LWG3102";>3102Clarify span 
iterator and const_iterator behaviorRapperswil
-https://wg21.link/LWG3104";>3104Fixing duration 
divisionRapperswil
+https://wg21.link/LWG3104";>3104Fixing duration 
divisionRapperswilComplete
 
 
 
@@ -95,7 +95,7 @@
 2970 - 
 3058 - 
 3062 - This should be very easy.
-3067 - 
+3067 - Adding restrictions; no code changes needed.
 3071 - This is just wording cleanup.
 3074 - 
 3076 - 
@@ -105,7 +105,7 @@
 3094 - 
 3100 - This is just wording cleanup.
 3102 - This should be just adding tests.
-3104 - 
+3104 - We already do this.
 
 
 Comments about the "Review" issues


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r331536 - [NFC]Convert Class to use member initialization instead of inline.

2018-05-07 Thread David Blaikie via cfe-commits
Perhaps this should use non-static data member initializers instead?

On Fri, May 4, 2018 at 9:23 AM Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Fri May  4 09:19:53 2018
> New Revision: 331536
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331536&view=rev
> Log:
> [NFC]Convert Class to use member initialization instead of inline.
>
> Modified:
> cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
>
> Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=331536&r1=331535&r2=331536&view=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Fri May  4
> 09:19:53 2018
> @@ -65,15 +65,11 @@ public:
>std::string ModuleDependencyOutputDir;
>
>  public:
> -  DependencyOutputOptions() {
> -IncludeSystemHeaders = 0;
> -ShowHeaderIncludes = 0;
> -UsePhonyTargets = 0;
> -AddMissingHeaderDeps = 0;
> -IncludeModuleFiles = 0;
> -ShowIncludesDest = ShowIncludesDestination::None;
> -OutputFormat = DependencyOutputFormat::Make;
> -  }
> +  DependencyOutputOptions()
> +  : IncludeSystemHeaders(0), ShowHeaderIncludes(0),
> UsePhonyTargets(0),
> +AddMissingHeaderDeps(0), IncludeModuleFiles(0),
> +ShowIncludesDest(ShowIncludesDestination::None),
> +OutputFormat(DependencyOutputFormat::Make) {}
>  };
>
>  }  // end namespace clang
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.

2018-05-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 145514.
manojgupta added a comment.

Added docs, Sema test case for the attribute.


Repository:
  rC Clang

https://reviews.llvm.org/D46300

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/stack-protector.c
  test/Sema/no_stack_protector.c

Index: test/Sema/no_stack_protector.c
===
--- /dev/null
+++ test/Sema/no_stack_protector.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void __attribute__((no_stack_protector)) foo() {}
+int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}}
Index: test/CodeGen/stack-protector.c
===
--- test/CodeGen/stack-protector.c
+++ test/CodeGen/stack-protector.c
@@ -22,6 +22,14 @@
   printf("%s\n", a);
 }
 
+// DEF: define {{.*}}void @test2(i8* %msg) #[[B:.*]] {
+__attribute__((no_stack_protector))
+void test2(const char *msg) {
+  char a[strlen(msg) + 1];
+  strcpy(a, msg);
+  printf("%s\n", a);
+}
+
 // NOSSP-NOT: attributes #[[A]] = {{.*}} ssp
 // SSP: attributes #[[A]] = {{.*}} ssp{{ }}
 // SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong
@@ -33,3 +41,15 @@
 // SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }}
 // SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong
 // SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq
+
+// NOSSP-NOT: attributes #[[B]] = {{.*}} ssp
+// SSP-NOT: attributes #[[B]] = {{.*}} ssp{{ }}
+// SSPSTRONG-NOT: attributes #[[B]] = {{.*}} sspstrong
+// SSPREQ-NOT: attributes #[[B]] = {{.*}} sspreq
+
+// SAFESTACK-SSP: attributes #[[B]] = {{.*}} safestack
+// SAFESTACK-SSP-NOT: attributes #[[B]] = {{.*}} safestack ssp{{ }}
+// SAFESTACK-SSPSTRONG: attributes #[[B]] = {{.*}} safestack
+// SAFESTACK-SSPSTRONG-NOT: attributes #[[B]] = {{.*}} safestack sspstrong
+// SAFESTACK-SSPREQ: attributes #[[B]] = {{.*}} safestack
+// SAFESTACK-SSPREQ-NOT: attributes #[[B]] = {{.*}} safestack sspreq
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6230,6 +6230,10 @@
   case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg.
 handleSimpleAttribute(S, D, AL);
 break;
+  case AttributeList::AT_NoStackProtector:
+// Interacts with -fstack-protector options.
+handleSimpleAttribute(S, D, AL);
+break;
   case AttributeList::AT_StdCall:
   case AttributeList::AT_CDecl:
   case AttributeList::AT_FastCall:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1142,12 +1142,14 @@
   if (!hasUnwindExceptions(LangOpts))
 B.addAttribute(llvm::Attribute::NoUnwind);
 
-  if (LangOpts.getStackProtector() == LangOptions::SSPOn)
-B.addAttribute(llvm::Attribute::StackProtect);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
-B.addAttribute(llvm::Attribute::StackProtectStrong);
-  else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
-B.addAttribute(llvm::Attribute::StackProtectReq);
+  if (!D || !D->hasAttr()) {
+if (LangOpts.getStackProtector() == LangOptions::SSPOn)
+  B.addAttribute(llvm::Attribute::StackProtect);
+else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
+  B.addAttribute(llvm::Attribute::StackProtectStrong);
+else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
+  B.addAttribute(llvm::Attribute::StackProtectReq);
+  }
 
   if (!D) {
 // If we don't have a declaration to control inlining, the function isn't
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2740,6 +2740,27 @@
   }];
 }
 
+def NoStackProtectorDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((no_stack_protector))`` attribute to disable
+stack protector on the specified functions. This attribute is useful for
+selectively disabling stack protector on some functions when building with
+-fstack-protector compiler options.
+
+For example, it disables stack protector for the function foo but function bar
+will still be built with stack protector with -fstack-protector option.
+
+.. code-block:: c
+
+int __attribute__((no_stack_protector))
+foo (int); // stack protection will be disabled for foo.
+
+int bar(int a); // bar can be built with stack protector.
+
+}];
+}
+
 def NotTailCalledDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: include/clang/Basic/Attr.td
===
--

[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D45093#1087652, @aaron.ballman wrote:

> This approach generally looks good to me, but I'd like @rsmith's opinion on 
> whether we should be trying to make -ast-print have good source fidelity or 
> not. I was under the impression we wanted -ast-print to faithfully reproduce 
> code at least as a low priority desire, but it sounds like it may only be 
> intended as an approximation of the user's source code, so adding extra 
> machinery to support better fidelity may be more maintenance burden than it's 
> worth.


Thanks for your comment.  Give the discussion in 
https://reviews.llvm.org/D45463, it seems I need a more precise understanding 
of the purpose of -ast-print before I write any more fixes like these.


https://reviews.llvm.org/D45093



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46024: [clang-format] Add SpaceBeforeCpp11BracedList option.

2018-05-07 Thread Ross Kirsling via Phabricator via cfe-commits
rkirsling added a comment.

Any further commentary? :)


Repository:
  rC Clang

https://reviews.llvm.org/D46024



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.

2018-05-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: include/clang/Basic/Attr.td:1494
+def NoStackProtector : InheritableAttr {
+  let Spellings = [GCC<"no_stack_protector">];
+  let Subjects = SubjectList<[Function]>;

aaron.ballman wrote:
> This is not a GCC attribute, so this should use the Clang spelling.
> 
> However, why spell the attribute this way rather than use the GCC spelling 
> (`optimize("no-stack-protector")`?
Thanks, I have changed it to use Clang spelling.

Regarding __attribute__((optimize("..."))), it is a generic facility in GCC 
that works for many optimizer flags.
Clang currently does not support this syntax currently instead preferring its 
own version for some options e.g. -O0. 
e.g.  
```
__attribute__((optimize("O0")))  // clang version is __attribute__((optnone)) 
```
If we want to support the GCC syntax, future expectation would be support more 
flags under this syntax. Is that the path we want to take (I do not know the 
history related to previous syntax decisions but better GCC compatibility will 
be a nice thing to have) 


Repository:
  rC Clang

https://reviews.llvm.org/D46300



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Fine, that works.


https://reviews.llvm.org/D45476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r331536 - [NFC]Convert Class to use member initialization instead of inline.

2018-05-07 Thread Keane, Erich via cfe-commits
I don’t believe the member initialization for bitfields (of which all the ‘0’ 
values are) happened until C++17, right?  I could definitely member initialize 
the two enum fields though.

From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Monday, May 7, 2018 12:03 PM
To: Keane, Erich 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r331536 - [NFC]Convert Class to use member initialization instead 
of inline.

Perhaps this should use non-static data member initializers instead?

On Fri, May 4, 2018 at 9:23 AM Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Fri May  4 09:19:53 2018
New Revision: 331536

URL: http://llvm.org/viewvc/llvm-project?rev=331536&view=rev
Log:
[NFC]Convert Class to use member initialization instead of inline.

Modified:
cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h

Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=331536&r1=331535&r2=331536&view=diff
==
--- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Fri May  4 
09:19:53 2018
@@ -65,15 +65,11 @@ public:
   std::string ModuleDependencyOutputDir;

 public:
-  DependencyOutputOptions() {
-IncludeSystemHeaders = 0;
-ShowHeaderIncludes = 0;
-UsePhonyTargets = 0;
-AddMissingHeaderDeps = 0;
-IncludeModuleFiles = 0;
-ShowIncludesDest = ShowIncludesDestination::None;
-OutputFormat = DependencyOutputFormat::Make;
-  }
+  DependencyOutputOptions()
+  : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
+AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+ShowIncludesDest(ShowIncludesDestination::None),
+OutputFormat(DependencyOutputFormat::Make) {}
 };

 }  // end namespace clang


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-07 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.
Herald added a reviewer: javed.absar.

I was just looking at this, and I think @arphaman's patch is pretty much the 
right approach (with 2 suggested fixes below).

I don't think the code we're currently warning on is broken: a user code has 
`NSInteger` with `%zd` or `NSUInteger` with `%zu`, and on all platforms which 
support those types the implementor has guaranteed that `(sizeof(size_t) == 
sizeof(NSInteger)) && (sizeof(ssize_t) == sizeof(NSUInteger))`. I agree that, 
if we're playing C++ pedant and look at the typedefs, then it's undefined 
behavior and the code is broken. However the implementation provided more 
guarantees than C++ does through its platform typedefs so pendantry need not 
apply (or rather: clang should look no further than the typedef, and trust the 
platform in this particular case).

We of course should still warn on sign mismatch.

I don't think this should even be a warning with pedantic on: there's no 
portability issue at all because all OSes and architectures where this could 
ever fire are guaranteed to do the right thing.

Suggested fixes:

1. Don't compare `CastTyName` directly, instead recurse as 
`shouldNotPrintDirectly` does so `typedef` nesting is also handled.
2. Add a test that sign mismatched is still diagnosed.

If you all agree I'll post an updated patch.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24867: Request init/fini array on FreeBSD 12 and later

2018-05-07 Thread Brooks Davis via Phabricator via cfe-commits
brooks accepted this revision.
brooks added a comment.

I do think we should make this change, but don't have a strong opinion on the 
timing.  If we do it for 12 and not 13 then we should probably try to get it 
into a 6.0.2.


https://reviews.llvm.org/D24867



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice updated this revision to Diff 145524.
cmtice added a comment.

Fix test failure that my previous changes caused.


https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall 
-flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
===
--- test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
+++ test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
@@ -0,0 +1,19 @@
+[cfi-unrelated-cast]
+# The specification of std::get_temporary_buffer mandates a cast to
+# uninitialized T* (libstdc++, libc++, MSVC stdlib).
+fun:_ZSt20get_temporary_buffer*
+fun:_ZNSt3__120get_temporary_buffer*
+fun:*get_temporary_buffer@.*@std@@*
+
+# STL address-of magic (libstdc++, libc++).
+fun:*__addressof*
+fun:_ZNSt3__19addressof*
+
+# Windows C++ stdlib headers that contain bad unrelated casts.
+src:*xmemory0
+src:*xstddef
+
+# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++).
+# This ctor is used by std::make_shared and needs to cast to uninitialized T*
+# in order to call std::allocator_traits::construct.
+fun:_ZNSt23_Sp_counted_ptr_inplace*
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt
===
--- 

[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Do you have commit access? If not I'd be happy to land this for you.




Comment at: 
test/Driver/Inputs/resource_dir_with_cfi_blacklist/cfi_blacklist.txt:19
+# in order to call std::allocator_traits::construct.
+fun:_ZNSt23_Sp_counted_ptr_inplace*

Would the test work if this were an empty file? If so, I'd suggest doing that 
for simplicity's sake.


https://reviews.llvm.org/D46403



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:45
+  anyOf(TypesMatcher, pointerType(pointee(TypesMatcher)),
+  callee(namedDecl(hasName("data"
+  .bind("call",

shuaiwang wrote:
> aaron.ballman wrote:
> > shuaiwang wrote:
> > > aaron.ballman wrote:
> > > > Eugene.Zelenko wrote:
> > > > > aaron.ballman wrote:
> > > > > > Should this check apply equally to `std::string::c_str()` as well 
> > > > > > as `std::string::data()`?
> > > > > readability-redundant-string-cstr do both.
> > > > Yup! But that makes me wonder if the name "redundant-data-call" is an 
> > > > issue. Perhaps the check name should focus more on the array subscript 
> > > > in the presence of an operator[]()?
> > > How about "readability-circumlocutionary-subscript"?
> > > "readability-circumlocutionary-element-access"?
> > > "circumlocutionary" -> "verbose"?
> > hah, I think circumlocutionary might be a bit too much. ;-) I think 
> > `readability-simplify-array-subscript-expr` might be reasonable, however. 
> > Right now, the simplification is just for `foo.data()[0]` but it seems 
> > plausible that there are other array subscript simplifications that could 
> > be added in the future, like `a[1 + 1]` being converted to `a[2]` or `x ? 
> > a[200] : a[400]` going to `a[x ? 200 : 400]` (etc).
> Just `readability-simplify-subscript-expr`?
> Since after simplification the subscript operation is done by calling 
> overloaded `operator[]` on an object instead of built-in subscript operator 
> on an array.
> 
> Let me know if this name looks good to you and I'll do the actual renaming 
> (together with addressing other comments) after your confirmation.
I think `readability-simplify-subscript-expr` is a reasonable name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45702



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Note that the alignment matters in addition to the size.

The pattern I've seen internally is people using `%zd` for NSInteger and `%tu` 
for NSUInteger, since until clang 6 neither of those were format-checked at all.

I'd be fine with adding an option to relax the printf checking if the size and 
alignment of the specifier and the actual type match, even if the types 
themselves differ (`-Wformat-relaxed` or something similar), so that you'd 
still get warnings on cases where the specifier mismatch could cause runtime 
issues. I think that would be preferable to special-casing the Apple types.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice added a comment.

I'm not sure if I have commit access or not; Peter was working with me on 
trying to commit the change.


https://reviews.llvm.org/D46403



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:9432
   if (IsLiteral) {
+// Conversion of a floating point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.

floating point -> floating-point



Comment at: lib/Sema/SemaChecking.cpp:9440-9441
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+  if (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(

I think you can combine all of the predicates into:
```
if (!IsBool && ((IntegerValue.isSigned() && (...) || (IntegerValue.isUnsigned() 
&& (...
  return DiagnoseImpCast(S, E, T, CContext, 
diag::warn_impcast_literal_float_to_integer_out_of_range);
```


Repository:
  rC Clang

https://reviews.llvm.org/D46535



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: test/Frontend/dependency-gen.c:24
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall 
-flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist

Shouldn't this be `%S/../Driver/Inputs/resource_dir_with_cfi_blacklist`?


https://reviews.llvm.org/D46403



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

If you want to force a particular printing policy to be used for `-ast-print`, 
I think it would be better to change the `print` call in 
`lib/Frontend/ASTConsumers.cpp` to pass your desired printing policy, rather 
than changing other components to prevent them from changing the `ASTContext`'s 
default printing policy.

(For what it's worth, I think we should also try to change the way we print 
diagnostics so that `Sema` is asked for a printing policy when it's needed 
rather than it setting global `ASTContext` state each time we consider printing 
a diagnostic. That way we could also take the `SourceLocation` information into 
account to figure out whether `bool` is suitably `#define`d at the point of the 
diagnostic rather than checking whether it's defined at the current 
end-of-preprocessing state. But that's not really relevant for this patch, 
except that generally I think we should be moving away from stashing a global 
`PrintingPolicy` on the `ASTContext`.)

>> I'd like @rsmith's opinion on whether we should be trying to make -ast-print 
>> have good source fidelity or not. I was under the impression we wanted 
>> -ast-print to faithfully reproduce code at least as a low priority desire, 
>> but it sounds like it may only be intended as an approximation of the user's 
>> source code, so adding extra machinery to support better fidelity may be 
>> more maintenance burden than it's worth.
> 
> Given the discussion in https://reviews.llvm.org/D45463, it seems I need a 
> more precise understanding of the purpose of -ast-print before I write any 
> more fixes like these.

As things stand, I'd generally consider `-ast-print` to be a "best-effort" 
feature: we don't guarantee that it produces valid code, but we would prefer 
that it does. I do not think we yet have a clear argument that it's worth 
accepting costs elsewhere in order to solely improve `-ast-print`, but 
fortunately most improvements to `-ast-print` also improve our diagnostic 
quality, the usability of our AST in tooling scenarios, or some other property 
that we do care about, so this issue seldom arises. (For example, in the 
context of https://reviews.llvm.org/D45463, information on whether a 
declaration owns a `TagDecl` is directly useful to tooling (for instance, 
refactoring tools care how a multi-declarator declaration was written so that 
they can properly rewrite it), as well as being useful for `-ast-print` 
fidelity. So it would make sense to consider how to better represent this 
information in the AST so that all the interested users have access to it.)

However... Clang is an open-source meritocracy. As such, the goals of the Clang 
project are a synthesized amalgam of the goals of the Clang contributors. If 
you want to take ownership of the AST printer and, for instance, make it always 
generate valid code, we can discuss the technical merits of that (use cases, 
benefit to you and to other users, maintenance costs, etc) even if the original 
purpose of the flag did not extend that far.


https://reviews.llvm.org/D45093



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331666 - [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon May  7 13:26:09 2018
New Revision: 331666

URL: http://llvm.org/viewvc/llvm-project?rev=331666&view=rev
Log:
[Driver] Use -fuse-line-directives by default in MSVC mode

Don't use the GNU extension form of line markers in MSVC mode.

Differential Revision: https://reviews.llvm.org/D46520

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=331666&r1=331665&r2=331666&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon May  7 13:26:09 2018
@@ -4215,9 +4215,9 @@ void Clang::ConstructJob(Compilation &C,
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=331666&r1=331665&r2=331666&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon May  7 13:26:09 2018
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331666: [Driver] Use -fuse-line-directives by default in 
MSVC mode (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46520?vs=145446&id=145528#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46520

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46520: [Driver] Use -fuse-line-directives by default in MSVC mode

2018-05-07 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331666: [Driver] Use -fuse-line-directives by default in 
MSVC mode (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46520?vs=145446&id=145529#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46520

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.


Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -28,6 +28,7 @@
 
 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
 // E: "-E"
+// E: "-fuse-line-directives"
 // E: "-o" "-"
 
 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4215,9 +4215,9 @@
IsWindowsMSVC))
 CmdArgs.push_back("-fms-extensions");
 
-  // -fno-use-line-directives is default.
+  // -fno-use-line-directives is default, except for MSVC targets.
   if (Args.hasFlag(options::OPT_fuse_line_directives,
-   options::OPT_fno_use_line_directives, false))
+   options::OPT_fno_use_line_directives, IsWindowsMSVC))
 CmdArgs.push_back("-fuse-line-directives");
 
   // -fms-compatibility=0 is default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:9440-9441
+diag::warn_impcast_literal_float_to_integer_out_of_range);
+  if (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(

aaron.ballman wrote:
> I think you can combine all of the predicates into:
> ```
> if (!IsBool && ((IntegerValue.isSigned() && (...) || 
> (IntegerValue.isUnsigned() && (...
>   return DiagnoseImpCast(S, E, T, CContext, 
> diag::warn_impcast_literal_float_to_integer_out_of_range);
> ```
I'd waffled on whether to combine those ore not, since I was 50/50 and you have 
an opinion, combining it :)


Repository:
  rC Clang

https://reviews.llvm.org/D46535



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46300: [Clang] Implement function attribute no_stack_protector.

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman edited reviewers, added: probinson; removed: void.
aaron.ballman added a subscriber: probinson.
aaron.ballman added a comment.

Adding in @probinson as he originally added the `optnone` attribute. Paul, do 
you recall why you opted (haha, pun totally intended) to implement `optnone` 
rather than `optimize("O0")` from GCC?




Comment at: include/clang/Basic/Attr.td:1494
+def NoStackProtector : InheritableAttr {
+  let Spellings = [GCC<"no_stack_protector">];
+  let Subjects = SubjectList<[Function]>;

manojgupta wrote:
> aaron.ballman wrote:
> > This is not a GCC attribute, so this should use the Clang spelling.
> > 
> > However, why spell the attribute this way rather than use the GCC spelling 
> > (`optimize("no-stack-protector")`?
> Thanks, I have changed it to use Clang spelling.
> 
> Regarding __attribute__((optimize("..."))), it is a generic facility in GCC 
> that works for many optimizer flags.
> Clang currently does not support this syntax currently instead preferring its 
> own version for some options e.g. -O0. 
> e.g.  
> ```
> __attribute__((optimize("O0")))  // clang version is __attribute__((optnone)) 
> ```
> If we want to support the GCC syntax, future expectation would be support 
> more flags under this syntax. Is that the path we want to take (I do not know 
> the history related to previous syntax decisions but better GCC compatibility 
> will be a nice thing to have) 
The history of `optnone` predates my involvement with Clang and I've not been 
able to find the original review thread (I did find the one where I gave my 
LGTM on the original patch, but that was a resubmission after the original 
design was signed off).

I'm not keen on attributes that have the same semantics but differ in spelling 
from attributes supported by GCC unless there's a good reason to deviate. Given 
that we've already deviated, I'd like to understand why better -- I don't want 
to push you to implement something we've already decided was a poor design, but 
I also don't want to accept code if we can instead use syntax that is 
compatible with GCC.


Repository:
  rC Clang

https://reviews.llvm.org/D46300



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 145536.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Aaron's comments :)


https://reviews.llvm.org/D46535

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/warn-float-conversion.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9429,6 +9429,16 @@
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating-point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool &&
+((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
+  IntegerValue.isMinSignedValue())) ||
+ IntegerValue.isUnsigned() &&
+ (IntegerValue.isMaxValue() || IntegerValue.isMinValue(
+  return DiagnoseImpCast(
+  S, E, T, CContext,
+  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9454,19 @@
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3140,14 +3140,20 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -157,7 +157,7 @@
 void yield() {
   co_yield 0;
   co_yield {"foo", 1, 2};
-  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
   co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
   co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
Index: test/SemaCXX/warn-literal-conversion.cpp
===
--- test/SemaCXX/warn-literal-conversion.cpp
+++ test/SemaCXX/warn-literal-conversion.cpp
@@ -48,4 +48,11 @@
   // values.
   bool b3 = 0.0f;
   bool b4 = 0.0;
+
+  // These all warn because they overflow the target type.
+  short s = 32768.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'short' is undefined}}
+  unsigned short us = 65536.0; // expected-warning{{implicit conversion of out of range value from 'double' to 'unsigned short' is undefined}}
+
+  short s2 = -32769.0; // expected-warning{{implicit conversion of out of range

[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice updated this revision to Diff 145537.
cmtice added a comment.

Make -resource-dir point to correct directory, in test case; move 
cfi_blacklist.txt file to 'share' subdirectory in test resource dir.


https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: 
test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
===
--- test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
+++ test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
@@ -0,0 +1,19 @@
+[cfi-unrelated-cast]
+# The specification of std::get_temporary_buffer mandates a cast to
+# uninitialized T* (libstdc++, libc++, MSVC stdlib).
+fun:_ZSt20get_temporary_buffer*
+fun:_ZNSt3__120get_temporary_buffer*
+fun:*get_temporary_buffer@.*@std@@*
+
+# STL address-of magic (libstdc++, libc++).
+fun:*__addressof*
+fun:_ZNSt3__19addressof*
+
+# Windows C++ stdlib headers that contain bad unrelated casts.
+src:*xmemory0
+src:*xstddef
+
+# std::_Sp_counted_ptr_inplace::_Sp_counted_ptr_inplace() (libstdc++).
+# This ctor is used by std::make_shared and needs to cast to uninitialized T*
+# in order to call std::allocator_traits::construct.
+fun:_ZNSt23_Sp_counted_ptr_inplace*
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Drive

[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D46535



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Caroline Tice via Phabricator via cfe-commits
cmtice updated this revision to Diff 145540.
cmtice added a comment.

Make cfi_blacklist.txt be an empty file.


https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.

LGTM


https://reviews.llvm.org/D46403



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46535: Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331673: Correct warning on Float->Integer conversions. 
(authored by erichkeane, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46535?vs=145536&id=145542#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46535

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/coroutines.cpp
  test/SemaCXX/warn-float-conversion.cpp
  test/SemaCXX/warn-literal-conversion.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9429,6 +9429,16 @@
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating-point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool &&
+((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
+  IntegerValue.isMinSignedValue())) ||
+ (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()
+  return DiagnoseImpCast(
+  S, E, T, CContext,
+  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9454,19 @@
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -3140,14 +3140,20 @@
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
 
 def warn_impcast_float_to_integer : Warning<
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;
Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -157,7 +157,7 @@
 void yield() {
   co_yield 0;
   co_yield {"foo", 1, 2};
-  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+  co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
   co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
   co_yield {"foo"};
   co_yield "foo"; // expected-error {{no matching}}
Index: test/SemaCXX/warn-float-conversion.cpp
===
--- test/SemaCXX/warn-float-conversion.cpp
+++ test/SemaCXX/warn-float-conversion.cpp
@@ -81,9 +81,9 @@
   char b = -500.0;  // caught by -Wliteral-conversion
 
   const float LargeNumber = 1024;
-  char c = LargeNumber;  // expected-warning{{implicit conversion of out of range value from 'const float' to 'char' changes value from 1024 to 127}}
-  char d = 400.0 + 400.0;  // expected-warning{{implicit conversion of out

r331673 - Correct warning on Float->Integer conversions.

2018-05-07 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon May  7 13:52:56 2018
New Revision: 331673

URL: http://llvm.org/viewvc/llvm-project?rev=331673&view=rev
Log:
Correct warning on Float->Integer conversions.

As identified and briefly discussed here:
https://bugs.llvm.org/show_bug.cgi?id=37305

Converting a floating point number to an integer type when
the integral part is out of the range of the integer type is
undefined behavior in C. Additionally, CodeGen emits an undef
in this situation.

HOWEVER, we've been giving a warning that says that the value is
changed. This patch corrects the warning to list that it is actually
undefined behavior.

Differential Revision: https://reviews.llvm.org/D46535

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp
cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
cfe/trunk/test/SemaCXX/warn-literal-conversion.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=331673&r1=331672&r2=331673&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  7 13:52:56 
2018
@@ -3140,6 +3140,9 @@ def warn_impcast_bitfield_precision_cons
 def warn_impcast_literal_float_to_integer : Warning<
   "implicit conversion from %0 to %1 changes value from %2 to %3">,
   InGroup;
+def warn_impcast_literal_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup;
 def warn_impcast_float_integer : Warning<
   "implicit conversion turns floating-point number into integer: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3148,6 +3151,9 @@ def warn_impcast_float_to_integer : Warn
   "implicit conversion of out of range value from %0 to %1 changes value "
   "from %2 to %3">,
   InGroup, DefaultIgnore;
+def warn_impcast_float_to_integer_out_of_range : Warning<
+  "implicit conversion of out of range value from %0 to %1 is undefined">,
+  InGroup, DefaultIgnore;
 def warn_impcast_float_to_integer_zero : Warning<
   "implicit conversion from %0 to %1 changes non-zero value from %2 to %3">,
   InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=331673&r1=331672&r2=331673&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon May  7 13:52:56 2018
@@ -9429,6 +9429,16 @@ static void DiagnoseFloatingImpCast(Sema
 
   unsigned DiagID = 0;
   if (IsLiteral) {
+// Conversion of a floating-point value to a non-bool integer where the
+// integral part cannot be represented by the integer type is undefined.
+if (!IsBool &&
+((IntegerValue.isSigned() && (IntegerValue.isMaxSignedValue() ||
+  IntegerValue.isMinSignedValue())) ||
+ (IntegerValue.isUnsigned() &&
+  (IntegerValue.isMaxValue() || IntegerValue.isMinValue()
+  return DiagnoseImpCast(
+  S, E, T, CContext,
+  diag::warn_impcast_literal_float_to_integer_out_of_range);
 // Warn on floating point literal to integer.
 DiagID = diag::warn_impcast_literal_float_to_integer;
   } else if (IntegerValue == 0) {
@@ -9444,12 +9454,19 @@ static void DiagnoseFloatingImpCast(Sema
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, 
PruneWarnings);
   }
+  if (!IsBool && (IntegerValue.isMaxValue() || IntegerValue.isMinValue()))
+return DiagnoseImpCast(S, E, T, CContext,
+   
diag::warn_impcast_float_to_integer_out_of_range,
+   PruneWarnings);
 } else {  // IntegerValue.isSigned()
   if (!IntegerValue.isMaxSignedValue() &&
   !IntegerValue.isMinSignedValue()) {
 return DiagnoseImpCast(S, E, T, CContext,
diag::warn_impcast_float_integer, 
PruneWarnings);
   }
+  return DiagnoseImpCast(S, E, T, CContext,
+ diag::warn_impcast_float_to_integer_out_of_range,
+ PruneWarnings);
 }
 // Warn on evaluatable floating point expression to integer conversion.
 DiagID = diag::warn_impcast_float_to_integer;

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=331673&r1=331672&r2=331673&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Mon May  7 13:52:56 2018
@@ -157,7

r331674 - [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May  7 13:54:05 2018
New Revision: 331674

URL: http://llvm.org/viewvc/llvm-project?rev=331674&view=rev
Log:
[CFI] Force LLVM to die if the implicit blacklist files cannot be found.

Currently LLVM CFI tries to use an implicit blacklist file, currently
in /usr/lib64/clang//share. If the file is not there, LLVM
happily continues, which causes CFI to add checks to files/functions
that are known to fail, generating binaries that fail. This CL causes
LLVM to die (I hope) if it can't find these implicit blacklist files.

Patch by Caroline Tice!

Differential Revision: https://reviews.llvm.org/D46403

Added:
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/

cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-blacklist.c
cfe/trunk/test/Frontend/dependency-gen.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=331674&r1=331673&r2=331674&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon May  7 13:54:05 2018
@@ -115,6 +115,10 @@ static void addDefaultBlacklists(const D
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 

Added: 
cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt?rev=331674&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=331674&r1=331673&r2=331674&view=diff
==
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Mon May  7 13:54:05 2018
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}

Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=331674&r1=331673&r2=331674&view=diff
==
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Mon May  7 13:54:05 2018
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-05-07 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331674: [CFI] Force LLVM to die if the implicit blacklist 
files cannot be found. (authored by pcc, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D46403

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir_with_cfi_blacklist/share/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/dependency-gen.c


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck 
-check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck 
-check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only 
-resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist 
-fsanitize=cfi-vcall -flto -fvisibility=hidden 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -115,6 +115,10 @@
 llvm::sys::path::append(Path, "share", BL.File);
 if (llvm::sys::fs::exists(Path))
   BlacklistFiles.push_back(Path.str());
+else if (BL.Mask == CFI)
+  // If cfi_blacklist.txt cannot be found in the resource dir, driver
+  // should fail.
+  D.Diag(clang::diag::err_drv_no_such_file) << Path;
   }
 }
 
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -62,4 +62,8 @@
 // CHECK-ONLY-FIRST-DISABLED: -fsanitize-blacklist={{.*}}.second
 // CHECK-ONLY_FIRST-DISABLED-NOT: good
 
+// If cfi_blacklist.txt cannot be found in the resource dir, driver should fail.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: '{{.*}}/share/cfi_blacklist.txt'
+
 // DELIMITERS: {{^ *"}}
Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -21,7 +21,7 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
 // CHECK-SIX: {{ }}x.h
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -resource-dir=%S/../Driver/Inputs/resource_dir_with_cfi_blacklist -fsanitize=cfi-vcall -flto -fvisibility=hidden -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

2018-05-07 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D42933#1090286, @smeenai wrote:

> Note that the alignment matters in addition to the size.


Sure, but AFAICT from `./lib/Basic/Targets/*` the alignment is also specified 
properly, is it not?

> The pattern I've seen internally is people using `%zd` for NSInteger and 
> `%tu` for NSUInteger, since until clang 6 neither of those were 
> format-checked at all.
> 
> I'd be fine with adding an option to relax the printf checking if the size 
> and alignment of the specifier and the actual type match, even if the types 
> themselves differ (`-Wformat-relaxed` or something similar), so that you'd 
> still get warnings on cases where the specifier mismatch could cause runtime 
> issues.

What are the cases that you're worried about? The only ones I'm trying to 
capture here are `NSInteger` with `%zd` and `NSUInteger` with `%zu`, are there 
others?

> I think that would be preferable to special-casing the Apple types.

If there are more that should be captured and a similar point solution doesn't 
apply, agreed. However I'd like to understand if we agree on the guarantees 
that the platform offers for the two specific cases I'm targeting.


Repository:
  rC Clang

https://reviews.llvm.org/D42933



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45093: [AST] Fix -ast-print for _Bool when have diagnostics

2018-05-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D45093#1090292, @rsmith wrote:

> If you want to force a particular printing policy to be used for 
> `-ast-print`, I think it would be better to change the `print` call in 
> `lib/Frontend/ASTConsumers.cpp` to pass your desired printing policy, rather 
> than changing other components to prevent them from changing the 
> `ASTContext`'s default printing policy.


Thanks.  I'll look into that.

> (For what it's worth, I think we should also try to change the way we print 
> diagnostics so that `Sema` is asked for a printing policy when it's needed 
> rather than it setting global `ASTContext` state each time we consider 
> printing a diagnostic. That way we could also take the `SourceLocation` 
> information into account to figure out whether `bool` is suitably `#define`d 
> at the point of the diagnostic rather than checking whether it's defined at 
> the current end-of-preprocessing state. But that's not really relevant for 
> this patch, except that generally I think we should be moving away from 
> stashing a global `PrintingPolicy` on the `ASTContext`.)

I'll keep that in mind in case I have more work in that area.

>>> I'd like @rsmith's opinion on whether we should be trying to make 
>>> -ast-print have good source fidelity or not. I was under the impression we 
>>> wanted -ast-print to faithfully reproduce code at least as a low priority 
>>> desire, but it sounds like it may only be intended as an approximation of 
>>> the user's source code, so adding extra machinery to support better 
>>> fidelity may be more maintenance burden than it's worth.
>> 
>> Given the discussion in https://reviews.llvm.org/D45463, it seems I need a 
>> more precise understanding of the purpose of -ast-print before I write any 
>> more fixes like these.
> 
> As things stand, I'd generally consider `-ast-print` to be a "best-effort" 
> feature: we don't guarantee that it produces valid code, but we would prefer 
> that it does. I do not think we yet have a clear argument that it's worth 
> accepting costs elsewhere in order to solely improve `-ast-print`, but 
> fortunately most improvements to `-ast-print` also improve our diagnostic 
> quality, the usability of our AST in tooling scenarios, or some other 
> property that we do care about, so this issue seldom arises. (For example, in 
> the context of https://reviews.llvm.org/D45463, information on whether a 
> declaration owns a `TagDecl` is directly useful to tooling (for instance, 
> refactoring tools care how a multi-declarator declaration was written so that 
> they can properly rewrite it), as well as being useful for `-ast-print` 
> fidelity. So it would make sense to consider how to better represent this 
> information in the AST so that all the interested users have access to it.)

Thanks.  That helps.

> However... Clang is an open-source meritocracy. As such, the goals of the 
> Clang project are a synthesized amalgam of the goals of the Clang 
> contributors. If you want to take ownership of the AST printer and, for 
> instance, make it always generate valid code, we can discuss the technical 
> merits of that (use cases, benefit to you and to other users, maintenance 
> costs, etc) even if the original purpose of the flag did not extend that far.

For the moment, I'll just fix issues as I encounter them.  If I decide 
-ast-print fidelity is vital to my work in the long term, or if my fixes 
introduce problematic costs so that our goals for -ast-print then conflict, 
then we can have that larger discussion.

I'm not sure I'm experienced enough to take ownership of -ast-print just yet.  
However, if there are as many fidelity issues as you've suggested, I'll 
probably get there eventually.


https://reviews.llvm.org/D45093



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-05-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ASTContext.h:1983
+  /// \brief Types and expressions required to build C++2a three-way 
comparisons
+  ///   using operator<=>, including the values return by builtin <=> 
operators.
+  ComparisonCategories CompCategories;

We don't generally indent comments after a `\brief` like this. Also, we enable 
autobrief, so these `\brief`s are redundant.



Comment at: include/clang/AST/ComparisonCategories.h:56
+///   comparison. These values map onto instances of comparison category types
+///   defined in the standard library. i.e. 'std::strong_ordering::less'.
+enum class ComparisonCategoryResult : unsigned char {

You mean "eg", not "ie" here.



Comment at: include/clang/AST/ComparisonCategories.h:84-103
+/// \brief True iff we've successfully evaluated the variable as a constant
+/// expression and extracted its integer value.
+bool hasValidIntValue() const { return HasValue; }
+
+/// \brief Get the constant integer value used by this variable to 
represent
+/// the comparison category result type.
+llvm::APSInt getIntValue() const {

This seems unnecessary; we can get this information from the `VarDecl` instead. 
(You're caching a result here that is already cached there.)



Comment at: lib/AST/ComparisonCategories.cpp:25
+/// category result by evaluating the initializer for the specified VarDecl as
+/// a constant expression and retreiving the value of the classes first
+/// (and only) field.

classes -> class's



Comment at: lib/AST/ComparisonCategories.cpp:43-46
+  Expr::EvalResult Result;
+  if (!Info->VD->hasInit() ||
+  !Info->VD->getInit()->EvaluateAsRValue(Result, Ctx))
+return true;

Use `VD->evaluateValue()` to get the cached value already stored by the 
`VarDecl`.



Comment at: lib/CodeGen/CGExprAgg.cpp:959
+  !ArgTy->isMemberPointerType() && !ArgTy->isAnyComplexType()) {
+return CGF.ErrorUnsupported(E, "aggregate three-way comparisoaoeun");
+  }

Typo. I'm almost tempted to say we should keep this for entertainment value, 
but on balance let's fix it :)



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:2899-2937
   assert(!location.getAs() && "location cannot be a NonLoc.");
+
+  // Are we loading from a region?  This actually results in two loads; one
+  // to fetch the address of the referenced value and one to fetch the
+  // referenced value.
+  if (const auto *TR =
+dyn_cast_or_null(location.getAsRegion())) {

This does not look related to your three-way comparison changes.



Comment at: test/SemaCXX/compare-cxx2a.cpp:40
 
-#if 0
+  (void)(A < 42);
   // (A,b)

Did you intend to add this here? It doesn't look related to the code under test.



Comment at: test/SemaCXX/std-compare-cxx2a.cpp:6
+void compare_not_found_test() {
+  // expected-error@+1 {{cannot deduce return type of 'operator<=>' because 
type partial_ordering was not found; include }}
+  (void)(0.0 <=> 42.123);

This diagnostic says just `partial_ordering` whereas the one below says 
`'std::partial_ordering'`. I prefer the latter more-explicit form, but in any 
case it would seem good to be consistent.


Repository:
  rL LLVM

https://reviews.llvm.org/D45476



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/RestrictIncludesCheck.cpp:75
+for (const auto &Include : FileDirectives) {
+  auto D = Check.diag(Include.Loc, "restricted include found");
+

aaron.ballman wrote:
> I believe this check will be finding transitive includes, correct? If so, 
> maybe this should be two diagnostics: one to say `"'%0' is prohibited from 
> being included"` and a note for the transitive case to say `"file included 
> transitively from here"`?
> 
> Regardless of the behavior you'd like for it, we should have a test case:
> ```
> // a.h
> // Assumed that a.h is prohibited
> void f();
> 
> // b.h
> #include "a.h"
> 
> // c.c
> #include "b.h"
> 
> int main() {
>   f();
> }
> ```
It will flag, but not fix, if a disallowed file is transitively included *and* 
the relevant flag is passed (e.g. -system-headers for system, or 
-header-filter=.* for other. I changed the warning text for header warnings to 
clarify that.



Comment at: clang-tidy/fuchsia/RestrictIncludesCheck.cpp:83
+
+  D << FixItHint::CreateRemoval(ToRange);
+}

aaron.ballman wrote:
> Are you okay with breaking user's code from this removal? If you remove the 
> header file, but not the parts of the code that require that header file to 
> be included, this FixIt will break code.
Yes, but I did add a note to the documentation to call that out.



Comment at: docs/clang-tidy/checks/fuchsia-restrict-includes.rst:27
+
+   A string containing a comma-separated list of header filenames to restrict. 
Default is an empty string.

hokein wrote:
> The check seems do nothing with the default option.
> 
> Do we have a corresponding guideline of fuchsia? 
The idea is to maintain a list of disallowed headers in the local .clang-tidy 
file, so it will be dependent on that. If no headers are restricted, the check 
won't do anything. I'll add documentation to that effect.


https://reviews.llvm.org/D43778



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43778: [clang-tidy] Adding RestrictIncludes check to Fuchsia module

2018-05-07 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 145547.
juliehockett marked 9 inline comments as done.
juliehockett edited the summary of this revision.
juliehockett added a comment.

Sorry for the delay in updating this -- check now restricts includes to a 
whitelist, rather than a blacklist, and only applies to system headers, to more 
strictly control which are allowed.

Also updated warning text and addressed comments.


https://reviews.llvm.org/D43778

Files:
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/fuchsia/RestrictIncludesCheck.cpp
  clang-tidy/fuchsia/RestrictIncludesCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-restrict-includes.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/fuchsia-restrict-includes/a.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/b.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/j.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/r.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/s.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/t.h
  test/clang-tidy/Inputs/fuchsia-restrict-includes/system/transitive.h
  test/clang-tidy/fuchsia-restrict-includes.cpp

Index: test/clang-tidy/fuchsia-restrict-includes.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-restrict-includes.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s fuchsia-restrict-includes %t \
+// RUN:		-- -config="{CheckOptions: [{key: fuchsia-restrict-includes.Includes, value: 's.h;transitive.h'}]}" \
+// RUN:   -system-headers -header-filter=.* \
+// RUN:   -- -std=c++11 -I %S/Inputs/fuchsia-restrict-includes -isystem %S/Inputs/fuchsia-restrict-includes/system
+
+#include "a.h"
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include t.h not allowed
+// CHECK-FIXES-NOT: #include 
+#include 
+
+#define foo 
+
+#include foo
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed
+// CHECK-FIXES-NOT: #include foo
+
+#/* comment */ include /* comment */ foo
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system include j.h not allowed
+// CHECK-FIXES-NOT: # /* comment */ include /* comment */ foo
+
+// transitive.h includes 
+#include 
+// CHECK-MESSAGES: :1:1: warning: system include r.h not allowed, transitively included from {{(.*\/)}}Inputs/fuchsia-restrict-includes/system/transitive.h
+
+int main() {
+  // f() is declared in r.h
+  f();
+}
\ No newline at end of file
Index: test/clang-tidy/Inputs/fuchsia-restrict-includes/system/transitive.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/fuchsia-restrict-includes/system/transitive.h
@@ -0,0 +1 @@
+#include 
\ No newline at end of file
Index: test/clang-tidy/Inputs/fuchsia-restrict-includes/system/r.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/fuchsia-restrict-includes/system/r.h
@@ -0,0 +1 @@
+void f() {}
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -95,6 +95,7 @@
fuchsia-default-arguments
fuchsia-multiple-inheritance
fuchsia-overloaded-operator
+   fuchsia-restrict-includes
fuchsia-statically-constructed-objects
fuchsia-trailing-return
fuchsia-virtual-inheritance
Index: docs/clang-tidy/checks/fuchsia-restrict-includes.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-restrict-includes.rst
@@ -0,0 +1,31 @@
+.. title:: clang-tidy - fuchsia-restrict-includes
+
+fuchsia-restrict-includes
+=
+
+Checks for allowed includes and suggests removal of any others. If no includes
+are specified, the check will exit without issuing any warnings. 
+
+It is important to note that running this check with fixes may break code, as
+the fix removes headers.
+
+Note that the separator for identifying allowed includes is a semi-colon, and
+therefore this check is unable to allow an include with a semi-colon in the
+filename (e.g. 'foo;bar.h' will be parsed as allowing 'foo' and 'bar.h', and not
+as allowing a file called 'foo;bar.h').
+
+For example, given the allowed system includes 'a.h; b.h':
+
+.. code-block:: c++
+
+  #include 
+  #include 
+  #include // Warning, as c.h is not explicitly allowed
+  
+Options
+---
+
+.. option:: Includes
+
+   A string containing a semi-colon separated list of allowed include filenames.
+   The default is an empty string, which allows all includes.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -110,8 +110,14 @@
   Checks whether a ``std::string::find()`` result is compared with 0, and
   suggests replacing with ``ab

[PATCH] D46550: Support Swift calling convention for PPC64 targets

2018-05-07 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson created this revision.
bob.wilson added a reviewer: aschwaighofer.
Herald added subscribers: kbarton, nemanjai, mcrosier.

This adds basic support for the Swift calling convention with PPC64 targets.
Patch provided by Atul Sowani in bug report #37223


Repository:
  rC Clang

https://reviews.llvm.org/D46550

Files:
  lib/Basic/Targets/PPC.h
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4287,7 +4287,7 @@
 
 namespace {
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
-class PPC64_SVR4_ABIInfo : public ABIInfo {
+class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
 public:
   enum ABIKind {
 ELFv1 = 0,
@@ -4331,7 +4331,7 @@
 public:
   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind, bool HasQPX,
  bool SoftFloatABI)
-  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
+  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
 IsSoftFloatABI(SoftFloatABI) {}
 
   bool isPromotableTypeForABI(QualType Ty) const;
@@ -4374,6 +4374,15 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
Index: lib/Basic/Targets/PPC.h
===
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -335,6 +335,15 @@
 }
 return false;
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinPPC32TargetInfo


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4287,7 +4287,7 @@
 
 namespace {
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
-class PPC64_SVR4_ABIInfo : public ABIInfo {
+class PPC64_SVR4_ABIInfo : public SwiftABIInfo {
 public:
   enum ABIKind {
 ELFv1 = 0,
@@ -4331,7 +4331,7 @@
 public:
   PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind, bool HasQPX,
  bool SoftFloatABI)
-  : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
+  : SwiftABIInfo(CGT), Kind(Kind), HasQPX(HasQPX),
 IsSoftFloatABI(SoftFloatABI) {}
 
   bool isPromotableTypeForABI(QualType Ty) const;
@@ -4374,6 +4374,15 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
Index: lib/Basic/Targets/PPC.h
===
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -335,6 +335,15 @@
 }
 return false;
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+switch (CC) {
+case CC_Swift:
+  return CCCR_OK;
+default:
+  return CCCR_Warning;
+}
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinPPC32TargetInfo
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46550: Support Swift calling convention for PPC64 targets

2018-05-07 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson added a comment.

Previous review (for the swift-llvm GitHub repo): 
https://github.com/apple/swift-clang/pull/167


Repository:
  rC Clang

https://reviews.llvm.org/D46550



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46052: GNUstep Objective-C ABI version 2

2018-05-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks, the comments help a lot.




Comment at: lib/CodeGen/CGObjCGNU.cpp:439
+ ArrayRef IvarOffsets,
+ ArrayRef IvarAlign,
+ ArrayRef IvarOwnership);

theraven wrote:
> DHowett-MSFT wrote:
> > While we're here, is there value in storing the ivar size in layout as 
> > well, so that the runtime doesn't need to calculate it from the distance to 
> > the next ivar/end of the instance?
> Normally the runtime calculates it from the type encoding, if it's required.  
> I agree that it might be nice to have though.  Do you have strong feelings 
> about needing it in the 2.0 ABI?  The looser coupling means that it would be 
> easy to add in the 2.1 ABI if we want it later.  Are you seeing cases where 
> the runtime is calculating it incorrectly because of insufficient information 
> in the type encoding, or where calculating it is causing performance problems?
The distance between ivar offsets wouldn't be correct anyway because of 
alignment padding.  A set-ivar function might be able to get away with copying 
too many bytes from an input buffer (although I wouldn't recommend it!), but a 
get-ivar function definitely should not copy too many bytes into an output 
buffer.

And all that's assuming that the runtime promises not to reorder ivars 
dynamically.  I don't know what the GNU runtime says about that.  (Static 
reordering is fine, since the runtime can reasonably demand that the compiler 
emit ivars in layout order.)



Comment at: lib/CodeGen/CGObjCGNU.cpp:1065
+  }
+}
+auto *ObjCStrGV =

Seems much more reasonable, thanks.



Comment at: lib/CodeGen/CGObjCGNU.cpp:1067
+auto *ObjCStrGV =
+  Fields.finishAndCreateGlobal(isNamed ? StringName : ".objc_string",
+  Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage :

Micro-optimization: I'm pretty sure the type of this ternary is an r-value 
`std::string`, which means copying the string in either case; if you explicitly 
build a StringRef from StringName, the ternary will instead construct a 
StringRef and you'll avoid those unnecessary copies.



Comment at: lib/CodeGen/CGObjCGNU.cpp:1069
+  Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage :
+  llvm::GlobalValue::PrivateLinkage);
+ObjCStrGV->setSection(ConstantStringSection);

The indentation here is a little misleading; I'd suggest aligning the two cases 
of the ternary operator.



Comment at: lib/CodeGen/CGObjCGNU.cpp:1172
+if (isWeak) {
+  // Placeholder for the real symbol.
+  ClassSymbol->setInitializer(new llvm::GlobalVariable(TheModule,

I would suggest clarifying in what sense this is a placeholder.  Does the 
runtime recognize it specially?  If so, how?  Is it replaced statically by a 
later pass in IRGen?


Repository:
  rC Clang

https://reviews.llvm.org/D46052



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331681 - Relax a FileCheck pattern to make it pass on Windows.

2018-05-07 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May  7 14:40:53 2018
New Revision: 331681

URL: http://llvm.org/viewvc/llvm-project?rev=331681&view=rev
Log:
Relax a FileCheck pattern to make it pass on Windows.

Should fix Windows bot failure:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16956

Modified:
cfe/trunk/test/Driver/fsanitize-blacklist.c

Modified: cfe/trunk/test/Driver/fsanitize-blacklist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-blacklist.c?rev=331681&r1=331680&r2=331681&view=diff
==
--- cfe/trunk/test/Driver/fsanitize-blacklist.c (original)
+++ cfe/trunk/test/Driver/fsanitize-blacklist.c Mon May  7 14:40:53 2018
@@ -64,6 +64,6 @@
 
 // If cfi_blacklist.txt cannot be found in the resource dir, driver should 
fail.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -resource-dir=/dev/null 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MISSING-CFI-BLACKLIST
-// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}/share/cfi_blacklist.txt'
+// CHECK-MISSING-CFI-BLACKLIST: error: no such file or directory: 
'{{.*}}cfi_blacklist.txt'
 
 // DELIMITERS: {{^ *"}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331682 - [X86] Make _mm256_gf2p8mul_epi8 require avx features since its 256 bits.

2018-05-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May  7 14:47:11 2018
New Revision: 331682

URL: http://llvm.org/viewvc/llvm-project?rev=331682&view=rev
Log:
[X86] Make _mm256_gf2p8mul_epi8 require avx features since its 256 bits.

Without this we throw an error on the header file instead of the user code when 
the right features aren't enabled in clang.

Rename the other DEFAULT_FN_ATTRS defines to _Z for 512-bit since I used _Y for 
this case.

Modified:
cfe/trunk/lib/Headers/gfniintrin.h

Modified: cfe/trunk/lib/Headers/gfniintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/gfniintrin.h?rev=331682&r1=331681&r2=331682&view=diff
==
--- cfe/trunk/lib/Headers/gfniintrin.h (original)
+++ cfe/trunk/lib/Headers/gfniintrin.h Mon May  7 14:47:11 2018
@@ -122,8 +122,11 @@
 /* Default attributes for simple form (no masking). */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("gfni")))
 
+/* Default attributes for YMM unmasked form. */
+#define __DEFAULT_FN_ATTRS_Y __attribute__((__always_inline__, __nodebug__, 
__target__("avx,gfni")))
+
 /* Default attributes for ZMM forms. */
-#define __DEFAULT_FN_ATTRS_F __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw,gfni")))
+#define __DEFAULT_FN_ATTRS_Z __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw,gfni")))
 
 /* Default attributes for VLX forms. */
 #define __DEFAULT_FN_ATTRS_VL __attribute__((__always_inline__, __nodebug__, 
__target__("avx512bw,avx512vl,gfni")))
@@ -150,7 +153,7 @@ _mm_maskz_gf2p8mul_epi8(__mmask16 __U, _
   __U, __A, __B);
 }
 
-static __inline__ __m256i __DEFAULT_FN_ATTRS
+static __inline__ __m256i __DEFAULT_FN_ATTRS_Y
 _mm256_gf2p8mul_epi8(__m256i __A, __m256i __B)
 {
   return (__m256i) __builtin_ia32_vgf2p8mulb_v32qi((__v32qi) __A,
@@ -172,14 +175,14 @@ _mm256_maskz_gf2p8mul_epi8(__mmask32 __U
   __U, __A, __B);
 }
 
-static __inline__ __m512i __DEFAULT_FN_ATTRS_F
+static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
 _mm512_gf2p8mul_epi8(__m512i __A, __m512i __B)
 {
   return (__m512i) __builtin_ia32_vgf2p8mulb_v64qi((__v64qi) __A,
   (__v64qi) __B);
 }
 
-static __inline__ __m512i __DEFAULT_FN_ATTRS_F
+static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
 _mm512_mask_gf2p8mul_epi8(__m512i __S, __mmask64 __U, __m512i __A, __m512i __B)
 {
   return (__m512i) __builtin_ia32_selectb_512(__U,
@@ -187,7 +190,7 @@ _mm512_mask_gf2p8mul_epi8(__m512i __S, _
   (__v64qi) __S);
 }
 
-static __inline__ __m512i __DEFAULT_FN_ATTRS_F
+static __inline__ __m512i __DEFAULT_FN_ATTRS_Z
 _mm512_maskz_gf2p8mul_epi8(__mmask64 __U, __m512i __A, __m512i __B)
 {
   return _mm512_mask_gf2p8mul_epi8((__m512i)_mm512_setzero_qi(),
@@ -195,7 +198,8 @@ _mm512_maskz_gf2p8mul_epi8(__mmask64 __U
 }
 
 #undef __DEFAULT_FN_ATTRS
-#undef __DEFAULT_FN_ATTRS_F
+#undef __DEFAULT_FN_ATTRS_Y
+#undef __DEFAULT_FN_ATTRS_Z
 #undef __DEFAULT_FN_ATTRS_VL
 
 #endif // __GFNIINTRIN_H


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >