[PATCH] D32825: [clang-format] Improve understanding of combined typedef+record declarations

2017-05-09 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Ping :)


https://reviews.llvm.org/D32825



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


[PATCH] D32350: [Analyzer] Exception Checker

2017-05-09 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:80
+  bool WasReThrow;
+  Types CurrentThrows; // actually alive exceptions
+  FunctionExceptionsMap

There are some comment formatting issues along these lines.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:84
+  std::vector CallStack;// trace call hierarchy
+  SmallSet EnabledFuncs;  // allowed functions
+  SmallSet IgnoredExceptions; // ignored exceptions

I had to stop here for a moment and heavily think what this variable (and the 
relevant command-line argument) is used for.

Maybe this calls for a comment then. What is "allowed function"? One that is 
**explicitly** allowed to throw, based on the user's decision? This should be 
explained here.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:109
+  EnabledFuncs.insert(EnabledFuncsVec.begin(), EnabledFuncsVec.end());
+  EnabledFuncs.insert("swap");
+  EnabledFuncs.insert("main");

Why is `swap` hardcoded as an "enabledfunc"?



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:329
+  const FunctionDecl *callee = C->getDirectCallee();
+  // if is not exist body for this function we do not care about
+  if (!callee || !callee->hasBody()) {

The phrasing should be fixed here for easier understanding.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:336
+  FunctionExceptionsMap::const_iterator fnIt = ExceptionsThrown.find(name);
+  // already processed?
+  if (fnIt == ExceptionsThrown.end()) {

`already processed` what? A given exception type from a given function?



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:468
+  const auto *D = pNode.get();
+  if (D == nullptr)
+return false;

`if (!D)`



Comment at: test/Analysis/exception-misuse.cpp:18
+
+Y(Y&&) { // expected-warning{{This function should not throw}}
+throw data;

I would use a much more descriptive error message here. E.g., explicitly say, 
that `move (constructor|operator=) should not throw`.



Comment at: test/Analysis/exception-misuse.cpp:26
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting

Yet again, better wording: _Destructor not marked `noexcept(false)` should not 
throw_ (this is true since `C++11`, maybe this needs to be based on a 
conditional in the checker!)

@xazax.hun, any idea on what a good error message here should be?



Comment at: test/Analysis/exception-misuse.cpp:26
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting

whisperity wrote:
> Yet again, better wording: _Destructor not marked `noexcept(false)` should 
> not throw_ (this is true since `C++11`, maybe this needs to be based on a 
> conditional in the checker!)
> 
> @xazax.hun, any idea on what a good error message here should be?
Also, a test case for a throwing, and `noexcept(false)`-specified dtor is 
missing.


https://reviews.llvm.org/D32350



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


[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)

2017-05-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Looks good for me, I only have a few questions. Could you reupload the diff 
with contexts? It might make the review easier for others.




Comment at: lib/AST/ASTImporter.cpp:1311
+  EmptyDecl *ToD = EmptyDecl::Create(Importer.getToContext(), DC, Loc);
+  ToD->setLexicalDeclContext(LexicalDC);
+  LexicalDC->addDeclInternal(ToD);

Don't we need an Importer.Imported call here? 



Comment at: lib/AST/ASTImporter.cpp:1461
+
+  // NOTE: No any conflict resolution is done for namespace aliases.
+

Minor nit: do we need the any in this sentence?


https://reviews.llvm.org/D32751



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


[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation

2017-05-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Do you have a benchmark how this affects the performance and memory usage when 
the old constraint manager is used? I wonder if most of people are using the 
old one, it might make no sense to generate symbolic expressions that can not 
be solved anyway.
Maybe the analyzer could only generate these symbolic expressions when Z3 is 
used?


https://reviews.llvm.org/D28953



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


[PATCH] D32350: [Analyzer] Exception checker for misuse: uncaught/noncompliant throws

2017-05-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:105
+  ReportExnSpec(ReportExnSpec) {
+  // In the beginning we have to parse list formatted options
+  SmallVector EnabledFuncsVec;

All comments should be full sentences starting with a capital letter and ending 
with a period. 



Comment at: lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp:109
+  EnabledFuncs.insert(EnabledFuncsVec.begin(), EnabledFuncsVec.end());
+  EnabledFuncs.insert("swap");
+  EnabledFuncs.insert("main");

whisperity wrote:
> Why is `swap` hardcoded as an "enabledfunc"?
It is always possible to implement swap in a non-throwing way, and some 
implementations that are using the copy and swap idiom, expecting swap to be 
no-throw. 



Comment at: test/Analysis/exception-misuse.cpp:26
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting

whisperity wrote:
> whisperity wrote:
> > Yet again, better wording: _Destructor not marked `noexcept(false)` should 
> > not throw_ (this is true since `C++11`, maybe this needs to be based on a 
> > conditional in the checker!)
> > 
> > @xazax.hun, any idea on what a good error message here should be?
> Also, a test case for a throwing, and `noexcept(false)`-specified dtor is 
> missing.
In fact,  the function can throw, if the exception is catched before leaving 
the function body. And in case the function does not throw but a called 
function do, that is also an error. So maybe something like exception are not 
allowed to leave this function? 


https://reviews.llvm.org/D32350



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


[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-05-09 Thread Nikolai Bozhenov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302513: [X86] Clang option -fuse-init-array has no effect 
when generating for MCU target (authored by n.bozhenov).

Changed prior to commit:
  https://reviews.llvm.org/D32543?vs=97866&id=98262#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32543

Files:
  llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
  llvm/trunk/test/CodeGen/X86/constructor.ll


Index: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
@@ -87,7 +87,7 @@
 
   if (TT.isOSFreeBSD())
 return llvm::make_unique();
-  if (TT.isOSLinux() || TT.isOSNaCl())
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
 return llvm::make_unique();
   if (TT.isOSFuchsia())
 return llvm::make_unique();
Index: llvm/trunk/test/CodeGen/X86/constructor.ll
===
--- llvm/trunk/test/CodeGen/X86/constructor.ll
+++ llvm/trunk/test/CodeGen/X86/constructor.ll
@@ -3,6 +3,8 @@
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY 
%s
 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck 
--check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
+; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s 
--check-prefix=MCU-CTORS
+; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s 
--check-prefix=MCU-INIT-ARRAY
 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { 
i32 15, void ()* @g, i8* @v }]
 
 @v = weak_odr global i8 0
@@ -37,3 +39,6 @@
 ; NACL-NEXT:   .section.init_array,"aw",@init_array
 ; NACL-NEXT:   .p2align2
 ; NACL-NEXT:   .long   f
+
+; MCU-CTORS: .section.ctors,"aw",@progbits
+; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array


Index: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
@@ -87,7 +87,7 @@
 
   if (TT.isOSFreeBSD())
 return llvm::make_unique();
-  if (TT.isOSLinux() || TT.isOSNaCl())
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
 return llvm::make_unique();
   if (TT.isOSFuchsia())
 return llvm::make_unique();
Index: llvm/trunk/test/CodeGen/X86/constructor.ll
===
--- llvm/trunk/test/CodeGen/X86/constructor.ll
+++ llvm/trunk/test/CodeGen/X86/constructor.ll
@@ -3,6 +3,8 @@
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck --check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
+; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s --check-prefix=MCU-CTORS
+; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s --check-prefix=MCU-INIT-ARRAY
 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { i32 15, void ()* @g, i8* @v }]
 
 @v = weak_odr global i8 0
@@ -37,3 +39,6 @@
 ; NACL-NEXT:	.section	.init_array,"aw",@init_array
 ; NACL-NEXT:	.p2align	2
 ; NACL-NEXT:	.long	f
+
+; MCU-CTORS: .section.ctors,"aw",@progbits
+; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31588: Fix PR25627: Certain constant local variables must be usable as template arguments (without being odr-used)

2017-05-09 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

*ping*


https://reviews.llvm.org/D31588



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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: test/CodeGen/mips-aggregate-arg.c:3
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64| FileCheck -check-prefix=N32-N64 %s
+

Space after the -target-abi n64


https://reviews.llvm.org/D32900



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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Spotted a minor nit.




Comment at: test/CodeGen/mips-aggregate-arg.c:36
+  f2(g2);
+  f3(g3);  
+}

Nit: spurious whitespace here.


https://reviews.llvm.org/D32900



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


[clang-tools-extra] r302516 - docs: Fix Sphinx detection with out-of-tree builds

2017-05-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue May  9 06:11:52 2017
New Revision: 302516

URL: http://llvm.org/viewvc/llvm-project?rev=302516&view=rev
Log:
docs: Fix Sphinx detection with out-of-tree builds

Adapt to changes made in r302499.

Modified:
clang-tools-extra/trunk/docs/CMakeLists.txt

Modified: clang-tools-extra/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/CMakeLists.txt?rev=302516&r1=302515&r2=302516&view=diff
==
--- clang-tools-extra/trunk/docs/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/docs/CMakeLists.txt Tue May  9 06:11:52 2017
@@ -90,8 +90,8 @@ if (DOXYGEN_FOUND)
 endif()
 
 if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
   if (SPHINX_FOUND)
-include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html clang-tools)
 endif()


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


[libcxx] r302517 - docs: Fix Sphinx detection with out-of-tree builds

2017-05-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Tue May  9 06:18:03 2017
New Revision: 302517

URL: http://llvm.org/viewvc/llvm-project?rev=302517&view=rev
Log:
docs: Fix Sphinx detection with out-of-tree builds

Adapt to changes made in r302499.

Modified:
libcxx/trunk/docs/CMakeLists.txt

Modified: libcxx/trunk/docs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/CMakeLists.txt?rev=302517&r1=302516&r2=302517&view=diff
==
--- libcxx/trunk/docs/CMakeLists.txt (original)
+++ libcxx/trunk/docs/CMakeLists.txt Tue May  9 06:18:03 2017
@@ -1,9 +1,9 @@
 
 if (LLVM_ENABLE_SPHINX)
+  include(AddSphinxTarget)
   if (SPHINX_FOUND)
-include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html libcxx)
 endif()
   endif()
-endif()
\ No newline at end of file
+endif()


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


r302518 - Reland "Warn about unused static file scope function template declarations."

2017-05-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May  9 06:25:41 2017
New Revision: 302518

URL: http://llvm.org/viewvc/llvm-project?rev=302518&view=rev
Log:
Reland "Warn about unused static file scope function template declarations."

This patch reinstates r299930, reverted in r299956, as a separate diagnostic
option (-Wunused-template). 

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=302518&r1=302517&r2=302518&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue May  9 06:25:41 2017
@@ -486,6 +486,7 @@ def UnneededInternalDecl : DiagGroup<"un
 def UnneededMemberFunction : DiagGroup<"unneeded-member-function">;
 def UnusedPrivateField : DiagGroup<"unused-private-field">;
 def UnusedFunction : DiagGroup<"unused-function", [UnneededInternalDecl]>;
+def UnusedTemplate : DiagGroup<"unused-template", [UnneededInternalDecl]>;
 def UnusedMemberFunction : DiagGroup<"unused-member-function",
  [UnneededMemberFunction]>;
 def UnusedLabel : DiagGroup<"unused-label">;
@@ -627,6 +628,7 @@ def Conversion : DiagGroup<"conversion",
 def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
+// UnusedTemplate, (clean-up libc++ before enabling)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
 UnusedPrivateField, UnusedLambdaCapture,
 UnusedLocalTypedef, UnusedValue, UnusedVariable,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302518&r1=302517&r2=302518&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May  9 06:25:41 
2017
@@ -303,6 +303,8 @@ def note_empty_parens_zero_initialize :
   "replace parentheses with an initializer to declare a variable">;
 def warn_unused_function : Warning<"unused function %0">,
   InGroup, DefaultIgnore;
+def warn_unused_template : Warning<"unused %select{function|variable}0 
template %1">,
+  InGroup, DefaultIgnore;
 def warn_unused_member_function : Warning<"unused member function %0">,
   InGroup, DefaultIgnore;
 def warn_used_but_marked_unused: Warning<"%0 was marked unused but was used">,

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=302518&r1=302517&r2=302518&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue May  9 06:25:41 2017
@@ -477,6 +477,13 @@ static bool ShouldRemoveFromUnused(Sema
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
+// If this is a function template and none of its specializations is used,
+// we should warn.
+if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -500,6 +507,13 @@ static bool ShouldRemoveFromUnused(Sema
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
+if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
+  // If this is a variable template and none of its specializations is 
used,
+  // we should warn.
+  for (const auto *Spec : Template->specializations())
+if (ShouldRemoveFromUnused(SemaRef, Spec))
+  return true;
+
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();
@@ -905,10 +919,14 @@ void Sema::ActOnEndOfTranslationUnit() {
<< /*function*/0 << DiagD->getDeclName();
   }
 } else {
-  Diag(DiagD->getLocation(),
-   isa(DiagD) ? diag::warn_unused_member_function
- : diag::warn_unused_function)
-<< DiagD->getDeclName();
+  if (FD->getDescribedFunctionTemplate())
+Diag

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Relanded in r302518.


https://reviews.llvm.org/D29877



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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Stefan Maksimovic via Phabricator via cfe-commits
smaksimovic updated this revision to Diff 98269.
smaksimovic added a comment.
Herald added a subscriber: krytarowski.

Thanks, fixed.


https://reviews.llvm.org/D32900

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/mips-aggregate-arg.c


Index: test/CodeGen/mips-aggregate-arg.c
===
--- test/CodeGen/mips-aggregate-arg.c
+++ test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6696,6 +6696,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.


Index: test/CodeGen/mips-aggregate-arg.c
===
--- test/CodeGen/mips-aggregate-arg.c
+++ test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6696,6 +6696,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32997: clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

TypeScript uses triple slash directives of the form:

  /// 

For various non-source instructions that should not be wrapped.

Reference:
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html


https://reviews.llvm.org/D32997

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", 
getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a 
lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-05-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Paweł, are you planning to finish this patch?


https://reviews.llvm.org/D30748



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


r302521 - PR5935: Adjust documentation.

2017-05-09 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue May  9 07:37:15 2017
New Revision: 302521

URL: http://llvm.org/viewvc/llvm-project?rev=302521&view=rev
Log:
PR5935: Adjust documentation.

https://reviews.llvm.org/D31867

Patch by Johannes Altmanninger!

Modified:
cfe/trunk/include/clang/Basic/TargetOptions.h

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=302521&r1=302520&r2=302521&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Tue May  9 07:37:15 2017
@@ -24,8 +24,7 @@ namespace clang {
 /// \brief Options for controlling the target.
 class TargetOptions {
 public:
-  /// If given, the name of the target triple to compile for. If not given the
-  /// target will be selected to match the host.
+  /// The name of the target triple to compile for.
   std::string Triple;
 
   /// When compiling for the device side, contains the triple used to compile


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


[clang-tools-extra] r302522 - [clang-tidy] Minor cleanup + a disabled test case for PR26228. NFC

2017-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue May  9 07:41:11 2017
New Revision: 302522

URL: http://llvm.org/viewvc/llvm-project?rev=302522&view=rev
Log:
[clang-tidy] Minor cleanup + a disabled test case for PR26228. NFC

Modified:

clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp?rev=302522&r1=302521&r2=302522&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
Tue May  9 07:41:11 2017
@@ -39,7 +39,7 @@ SourceLocation forwardSkipWhitespaceAndC
 const ASTContext *Context) {
   assert(Loc.isValid());
   for (;;) {
-while (isWhitespace(*FullSourceLoc(Loc, SM).getCharacterData()))
+while (isWhitespace(*SM.getCharacterData(Loc)))
   Loc = Loc.getLocWithOffset(1);
 
 tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
@@ -69,7 +69,6 @@ SourceLocation findEndLocation(SourceLoc
 
   Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, Context->getLangOpts());
   // Loc points past the last token before end or after ';'.
-
   if (SkipEndWhitespaceAndComments) {
 Loc = forwardSkipWhitespaceAndComments(Loc, SM, Context);
 tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
@@ -79,10 +78,11 @@ SourceLocation findEndLocation(SourceLoc
 
   for (;;) {
 assert(Loc.isValid());
-while (isHorizontalWhitespace(*FullSourceLoc(Loc, SM).getCharacterData()))
+while (isHorizontalWhitespace(*SM.getCharacterData(Loc))) {
   Loc = Loc.getLocWithOffset(1);
+}
 
-if (isVerticalWhitespace(*FullSourceLoc(Loc, SM).getCharacterData())) {
+if (isVerticalWhitespace(*SM.getCharacterData(Loc))) {
   // EOL, insert brace before.
   break;
 }
@@ -159,7 +159,7 @@ void BracesAroundStatementsCheck::check(
   ForceBracesStmts.insert(Else);
 if (Else && !isa(Else)) {
   // Omit 'else if' statements here, they will be handled directly.
-  checkStmt(Result, Else, S->getElseLoc(), SourceLocation());
+  checkStmt(Result, Else, S->getElseLoc());
 }
   } else {
 llvm_unreachable("Invalid match");

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp?rev=302522&r1=302521&r2=302522&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
 Tue May  9 07:41:11 2017
@@ -172,6 +172,17 @@ void test() {
   // CHECK-FIXES-NEXT: }
 }
 
+void f(const char *p) {
+  if (!p)
+f("\
+");
+  // CHECK-MESSAGES: :[[@LINE-3]]:10: warning: statement should be inside 
braces
+  // CHECK-FIXES:  {{^  }}if (!p) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}}f("\{{$}}
+  // CHECK-FIXES-_NEXT: {{^}}");{{$}} FIXME: This breaks 
(http://llvm.org/PR26228)
+  // CHECK-FIXES-_NEXT: {{^}}}{{$}}
+}
+
 #define M(x) x
 
 int test_macros(bool b) {


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


[PATCH] D32997: clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D32997



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


[PATCH] D31867: Fix documentation for TargetOptions.

2017-05-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r302521.


https://reviews.llvm.org/D31867



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


[PATCH] D32997: clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302523: clang-format: [JS] keep triple slash directives 
intact. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32997?vs=98270&id=98272#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32997

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a 
lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", 
getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -637,9 +637,10 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1785,6 +1785,7 @@
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302523 - clang-format: [JS] keep triple slash directives intact.

2017-05-09 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue May  9 07:45:48 2017
New Revision: 302523

URL: http://llvm.org/viewvc/llvm-project?rev=302523&view=rev
Log:
clang-format: [JS] keep triple slash directives intact.

Summary:
TypeScript uses triple slash directives of the form:
/// 

For various non-source instructions that should not be wrapped.

Reference:
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=302523&r1=302522&r2=302523&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue May  9 07:45:48 2017
@@ -637,9 +637,10 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-// taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is
-// commonly followed by overlong URLs.
-GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
+// taze:, triple slash directives (`/// <...`), @tag followed by { for a 
lot
+// of JSDoc tags, and @see, which is commonly followed by overlong URLs.
+GoogleStyle.CommentPragmas =
+"(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302523&r1=302522&r2=302523&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue May  9 07:45:48 2017
@@ -1785,6 +1785,7 @@ TEST_F(FormatTestJS, ImportComments) {
   verifyFormat("import {x} from 'x';  // from some location",
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
+  verifyFormat("/// ", 
getGoogleJSStyleWithColumns(10));
 }
 
 TEST_F(FormatTestJS, Exponentiation) {


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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2346
 
+bool UnwrappedLineParser::isIIFE() const {
+  // Look for the start of an immediately invoked anonymous function.

Why not just a static function?



Comment at: lib/Format/UnwrappedLineParser.cpp:2351
+  // Example: (function() { ... })()
+  // FIXME: check for the end invocation or alternate ways to start function
+  // expressions?

The question is whether we ever expect to find lines starting with `(function() 
{` that do not end up being an IIFE. I think that's very unlikely, so I think 
I'd even drop this FIXME. I wouldn't expect that to be something that needs 
fixing.

If you wanted to, you could check FormatToken.MatchingParen and then parse from 
there, but I'm not sure if that pointer is already set up at this point.



Comment at: lib/Format/UnwrappedLineParser.cpp:2353
+  // expressions?
+  if (Line->Tokens.size() < 5)
+return false;

There's a `startsSequenceInternal` on `Line` that might come in handy here?



Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"

consider adding a test with comments between the tokens (which should work with 
`startsSequence`).



Comment at: unittests/Format/FormatTestJS.cpp:374
+   "}())");
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"

I find it hard to see how these cases are different - can you give them e.g. 
variable names that call out what's the point of the different cases?


https://reviews.llvm.org/D32989



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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2362
+  ++I;
+  if (I->Tok->isNot(tok::l_paren))
+return false;

One more - do we want to support IIFEs that take arguments?


```
(function(global) {
  ...
}(window));
```


https://reviews.llvm.org/D32989



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


Re: [PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-09 Thread Vassil Vassilev via cfe-commits

On 11/04/17 22:25, Richard Smith wrote:
On 11 April 2017 at 08:35, Marshall Clow via Phabricator via 
cfe-commits > wrote:


mclow.lists added a comment.

Complete reproducer:

// Tested with with:  clang++ -std=c++14 -Wunused-function
UnusedFVassily.cpp
//
// UnusedFVassily.cpp:8:39: warning: unused function '__test'
[-Wunused-function]
// template  static __two __test(...);
//   ^
// UnusedFVassily.cpp:9:38: warning: unused function '__test'
[-Wunused-function]
// template  static char __test(typename
_Up::pointer* = 0);
//  ^
// 2 warnings generated.

#include 

namespace foo {

struct __two {char __lx; char __lxx;};
namespace __has_pointer_type_imp
{

  template  static __two __test(...);
  template  static char __test(typename _Up::pointer* = 0);

}

template 
struct __has_pointer_type

  : public std::integral_constant(0)) == 1>


This is a bug in libc++. If this header is included into two 
translation units, they will be referencing different __test functions 
here (because the template has internal linkage due to the 'static'), 
resulting in an ODR violation.
Richard, shall we warn on template definitions marked static? This would 
keep this pattern still working.



{
};

}

struct S1 {};
struct S2 { typedef void *pointer; };

int main () {
static_assert (!foo::__has_pointer_type::value, "" );
static_assert ( foo::__has_pointer_type::value, "" );
}


https://reviews.llvm.org/D29877 



___
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] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 98275.
baloghadamsoftware marked 11 inline comments as done.
baloghadamsoftware added a comment.

Updated according to the review.


https://reviews.llvm.org/D32592

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/iterator-past-end.cpp
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- /dev/null
+++ test/Analysis/iterator-range.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void clang_analyzer_warnIfReached();
+
+void simple_good_end(const std::vector &v) {
+  auto i = v.end();
+  if (i != v.end()) {
+clang_analyzer_warnIfReached();
+*i; // no-warning
+  }
+}
+
+void simple_bad_end(const std::vector &v) {
+  auto i = v.end();
+  *i; // expected-warning{{Iterator accessed outside of its range}}
+}
Index: test/Analysis/iterator-past-end.cpp
===
--- test/Analysis/iterator-past-end.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
-
-#include "Inputs/system-header-simulator-cxx.h"
-
-void simple_good(const std::vector &v) {
-  auto i = v.end();
-  if (i != v.end())
-*i; // no-warning
-}
-
-void simple_good_negated(const std::vector &v) {
-  auto i = v.end();
-  if (!(i == v.end()))
-*i; // no-warning
-}
-
-void simple_bad(const std::vector &v) {
-  auto i = v.end();
-  *i; // expected-warning{{Iterator accessed past its end}}
-}
-
-void copy(const std::vector &v) {
-  auto i1 = v.end();
-  auto i2 = i1;
-  *i2; // expected-warning{{Iterator accessed past its end}}
-}
-
-void decrease(const std::vector &v) {
-  auto i = v.end();
-  --i;
-  *i; // no-warning
-}
-
-void copy_and_decrease1(const std::vector &v) {
-  auto i1 = v.end();
-  auto i2 = i1;
-  --i1;
-  *i1; // no-warning
-}
-
-void copy_and_decrease2(const std::vector &v) {
-  auto i1 = v.end();
-  auto i2 = i1;
-  --i1;
-  *i2; // expected-warning{{Iterator accessed past its end}}
-}
-
-void copy_and_increase1(const std::vector &v) {
-  auto i1 = v.begin();
-  auto i2 = i1;
-  ++i1;
-  if (i1 == v.end())
-*i2; // no-warning
-}
-
-void copy_and_increase2(const std::vector &v) {
-  auto i1 = v.begin();
-  auto i2 = i1;
-  ++i1;
-  if (i2 == v.end())
-*i2; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find(std::vector &vec, int e) {
-  auto first = std::find(vec.begin(), vec.end(), e);
-  if (vec.end() != first)
-*first; // no-warning
-}
-
-void bad_find(std::vector &vec, int e) {
-  auto first = std::find(vec.begin(), vec.end(), e);
-  *first; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find_end(std::vector &vec, std::vector &seq) {
-  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
-  if (vec.end() != last)
-*last; // no-warning
-}
-
-void bad_find_end(std::vector &vec, std::vector &seq) {
-  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
-  *last; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find_first_of(std::vector &vec, std::vector &seq) {
-  auto first =
-  std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end());
-  if (vec.end() != first)
-*first; // no-warning
-}
-
-void bad_find_first_of(std::vector &vec, std::vector &seq) {
-  auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
-  *first; // expected-warning{{Iterator accessed past its end}}
-}
-
-bool odd(int i) { return i % 2; }
-
-void good_find_if(std::vector &vec) {
-  auto first = std::find_if(vec.begin(), vec.end(), odd);
-  if (vec.end() != first)
-*first; // no-warning
-}
-
-void bad_find_if(std::vector &vec, int e) {
-  auto first = std::find_if(vec.begin(), vec.end(), odd);
-  *first; // expected-warning{{Iterator accessed past its end}}
-}
-
-void good_find_if_not(std::vector &vec) {
-  auto first = std::find_if_not(vec.begin(), vec.

[PATCH] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-09 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In https://reviews.llvm.org/D32592#747132, @NoQ wrote:

> Then, in methods that deal with iterator `SVal`s directly, i wish we had 
> hints explaining what's going on in these ~7 cases. In my opinion, that'd 
> greatly help people understand the code later, and it'd help us understand 
> how to avoid this variety and provide checker authors with a better API as 
> soon as we get to this, so it's the biggest concern for me about this checker.


I am not sure which method do you mean? I think here the crucial functions are 
the setIteratorPosition() and the getIteratorPosition() functions which provide 
a common way to handle all these SVals.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:166-167
+
+static llvm::APSInt Zero = llvm::APSInt::get(0);
+static llvm::APSInt One = llvm::APSInt::get(1);
+

NoQ wrote:
> I've a bit of doubt about those. Would they call their constructors every 
> time clang starts, regardless of whether the analyzer or the checker is 
> enabled? Maybe having them as private variables inside the checker class 
> would be better?
> 
> As in http://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors
Not needed in this patch. I delete them from here.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:219
+  OutOfRangeBugType.reset(
+  new BugType(this, "Iterator of out Range", "Misuse of STL APIs"));
+  OutOfRangeBugType->setSuppressOnSink(true);

baloghadamsoftware wrote:
> NoQ wrote:
> > Before we forget: Range -> range. As we've noticed recently in D32702 :), 
> > we don't capitalize every word in bug types and categories.
> Agree.
Also "out of" instead of "of out" :-)



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:294-297
+// Assumption: if return value is an iterator which is not yet bound to a
+// container, then look for the first iterator argument, and
+// bind the return value to the same container. This approach
+// works for STL algorithms.

NoQ wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > I guess this deserves a test case (we could split this out as a separate 
> > > feature as well).
> > > 
> > > I'm also afraid that we can encounter false positives on functions that 
> > > are not STL algorithms. I suggest doing this by default only for STL 
> > > functions (or maybe for other specific classes of functions for which we 
> > > know it works this way) and do this for other functions under a checker 
> > > option (i.e. something like `-analyzer-config 
> > > IteratorChecker:AggressiveAssumptions=true`, similar to `MallocChecker`'s 
> > > "Optimistic" option).
> > I will check whether this piece of code could be moved in a later part of 
> > the checker. However, I suggest to first wait for the first false positives 
> > before we introduce such an option. This far the false positives in my 
> > initial tests had different reasons, not this one.
> Unfortunately, we've had a poor experience with this approach in other 
> checkers. You never know, and it seems that it's always better to have a safe 
> fallback mode available under a flag, because if a few classes of false 
> positives are found, and we are forced to reduce the checker to a safer 
> behavior, it'd be hard to remember all the places where unsafe heuristics 
> were used.
I think this heuristic is well marked by the comment, easy to find if it causes 
false positives. When I started working on Clang (Tidy first) reviewers 
discouraged me to add options before experiencing false positives.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:323-324
+
+void IteratorChecker::checkLiveSymbols(ProgramStateRef State,
+   SymbolReaper &SR) const {
+  // Keep symbolic expressions of iterator positions, container begins and ends

NoQ wrote:
> This callback is currently untested as well. I'm doing this bit of manual 
> "mutation testing" by removing pieces of code and re-running tests because 
> not only we'd rather keep every commit self-sufficient, but also we'd rather 
> make sure we didn't forget anything, which is much easier to do 
> patch-by-patch.
OK, removed from the first patch.



Comment at: test/Analysis/iterator-range.cpp:1-2
+// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange 
-analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s 
-verify
+// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange 
-analyzer-eagerly-assume -analyzer-config c++-container-inlining=true 
-DINLINE=1 %s -verify
+

NoQ wrote:
> Could we add run-lines without `-analyzer-eagerly-assume`? Currently all 
> variants are passing, but if new tests will fail, we could 

[PATCH] D33000: Add support for pretty platform names to `@available`/`__builtin_available`

2017-05-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

We should allow macOS/iOS/tvOS/watchOS in `@available`/`__builtin_available`.


Repository:
  rL LLVM

https://reviews.llvm.org/D33000

Files:
  include/clang/Basic/Attr.td
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/FixIt/fixit-availability.c
  test/FixIt/fixit-availability.mm
  test/Parser/objc-available.m
  test/SemaObjC/unguarded-availability.m

Index: test/SemaObjC/unguarded-availability.m
===
--- test/SemaObjC/unguarded-availability.m
+++ test/SemaObjC/unguarded-availability.m
@@ -48,7 +48,7 @@
   } else
 func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
 
-  if (@available(macos 10.11, *)) {
+  if (@available(macOS 10.11, *)) {
 if (@available(ios 8, *)) {
   func_10_11();
   func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{enclose}}
@@ -176,7 +176,7 @@
 }
 
 int instantiate_availability() {
-  if (@available(macos 10.12, *))
+  if (@available(macOS 10.12, *))
 with_availability_attr();
   else
 with_availability_attr(); // expected-warning{{'with_availability_attr' is only available on macOS 10.11 or newer}} expected-warning{{'int_10_12' is only available on macOS 10.12 or newer}} expected-note 2 {{enclose}}
Index: test/Parser/objc-available.m
===
--- test/Parser/objc-available.m
+++ test/Parser/objc-available.m
@@ -21,6 +21,12 @@
   (void)@available; // expected-error{{expected '('}}
 }
 
+void prettyPlatformNames() {
+  (void)@available(iOS 8, tvOS 10, watchOS 3, macOS 10.11, *);
+  (void)__builtin_available(iOSApplicationExtension 8, tvOSApplicationExtension 10,
+   watchOSApplicationExtension 3, macOSApplicationExtension 10.11, *);
+}
+
 #if __has_builtin(__builtin_available)
 #error expected
 // expected-error@-1 {{expected}}
Index: test/FixIt/fixit-availability.mm
===
--- test/FixIt/fixit-availability.mm
+++ test/FixIt/fixit-availability.mm
@@ -7,58 +7,58 @@
 
 int use() {
   function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   int y = function(), x = 0;
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:29-[[@LINE-2]]:29}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   x += function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (1) {
 x = function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   }
   anotherFunction(function());
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:31-[[@LINE-2]]:31}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (function()) {
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE+1]]:4-[[@LINE+1]]:4}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   }
   while (function())
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE+1]]:6-[[@LINE+1]]:6}:"\n  } else {\n  // Fallback on earlier versions\n  }"
 ;
   do
 function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n"
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macOS 10.12, *)) {\n"
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:16-[[@LINE-2]]:

[PATCH] D33000: Add support for pretty platform names to `@available`/`__builtin_available`

2017-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for working on this!


Repository:
  rL LLVM

https://reviews.llvm.org/D33000



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


[clang-tools-extra] r302534 - Change EOL style to LF. NFC

2017-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue May  9 09:56:28 2017
New Revision: 302534

URL: http://llvm.org/viewvc/llvm-project?rev=302534&view=rev
Log:
Change EOL style to LF. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c
clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c

clang-tools-extra/trunk/test/clang-tidy/misc-undelegated-constructor-cxx98.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=302534&r1=302533&r2=302534&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Tue May  
9 09:56:28 2017
@@ -1,619 +1,619 @@
-//===--- tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp --=== 
//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-///  \file This file implements ClangTidyDiagnosticConsumer, ClangTidyContext
-///  and ClangTidyError classes.
-///
-///  This tool uses the Clang Tooling infrastructure, see
-///http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
-///  for details on setting it up with LLVM source tree.
-///
-//===--===//
-
-#include "ClangTidyDiagnosticConsumer.h"
-#include "ClangTidyOptions.h"
-#include "clang/AST/ASTDiagnostic.h"
-#include "clang/Basic/DiagnosticOptions.h"
-#include "clang/Frontend/DiagnosticRenderer.h"
-#include "llvm/ADT/SmallString.h"
-#include 
-#include 
-using namespace clang;
-using namespace tidy;
-
-namespace {
-class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
-public:
-  ClangTidyDiagnosticRenderer(const LangOptions &LangOpts,
-  DiagnosticOptions *DiagOpts,
-  ClangTidyError &Error)
-  : DiagnosticRenderer(LangOpts, DiagOpts), Error(Error) {}
-
-protected:
-  void emitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level, StringRef Message,
- ArrayRef Ranges,
- const SourceManager *SM,
- DiagOrStoredDiag Info) override {
-// Remove check name from the message.
-// FIXME: Remove this once there's a better way to pass check names than
-// appending the check name to the message in ClangTidyContext::diag and
-// using getCustomDiagID.
-std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
-if (Message.endswith(CheckNameInMessage))
-  Message = Message.substr(0, Message.size() - CheckNameInMessage.size());
-
-auto TidyMessage = Loc.isValid()
-   ? tooling::DiagnosticMessage(Message, *SM, Loc)
-   : tooling::DiagnosticMessage(Message);
-if (Level == DiagnosticsEngine::Note) {
-  Error.Notes.push_back(TidyMessage);
-  return;
-}
-assert(Error.Message.Message.empty() && "Overwriting a diagnostic 
message");
-Error.Message = TidyMessage;
-  }
-
-  void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc,
- DiagnosticsEngine::Level Level,
- ArrayRef Ranges,
- const SourceManager &SM) override {}
-
-  void emitCodeContext(SourceLocation Loc, DiagnosticsEngine::Level Level,
-   SmallVectorImpl &Ranges,
-   ArrayRef Hints,
-   const SourceManager &SM) override {
-assert(Loc.isValid());
-for (const auto &FixIt : Hints) {
-  CharSourceRange Range = FixIt.RemoveRange;
-  assert(Range.getBegin().isValid() && Range.getEnd().isValid() &&
- "Invalid range in the fix-it hint.");
-  assert(Range.getBegin().isFileID() && Range.getEnd().isFileID() &&
- "Only file locations supported in fix-it hints.");
-
-  tooling::Replacement Replacement(SM, Range, FixIt.CodeToInsert);
-  llvm::Error Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
-  // FIXME: better error handling (at least, don't let other replacements 
be
-  // applied).
-  if (Err) {
-llvm::errs() << "Fix conflicts with existing fix! "
- << llvm::toString(std::move(Err)) << "\n";
-assert(false && "Fix conflicts with existing fix!");
-  }
-}
-  }
-
-  void emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc,
-  

[PATCH] D33004: getIdentifierInfo now updates the returned information by default

2017-05-09 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.

Calling `Preprocessor::getIdentifierInfo` is not automatically updating the 
returned identifier at the moment. This patch adds a flag that is ensuring by 
default that the returned IdentifierInfo is updated. The flag is true by 
default because that seems like the most logical behavior for this method. Can 
be turned off for performance reasons


https://reviews.llvm.org/D33004

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/Preprocessor.cpp


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -245,6 +245,27 @@
   llvm::errs() << ">";
 }
 
+IdentifierInfo *Preprocessor::getIdentifierInfo(StringRef Name,
+bool CheckOutOfDate) const {
+  IdentifierInfo &II = Identifiers.get(Name);
+  // If the information about this identifier is out of date, update it from
+  // the external source.
+  // We have to treat __VA_ARGS__ in a special way, since it gets
+  // serialized with isPoisoned = true, but our preprocessor may have
+  // unpoisoned it if we're defining a C99 macro.
+  if (CheckOutOfDate && II.isOutOfDate()) {
+bool CurrentIsPoisoned = false;
+if (&II == Ident__VA_ARGS__)
+  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
+
+updateOutOfDateIdentifier(II);
+
+if (&II == Ident__VA_ARGS__)
+  II.setIsPoisoned(CurrentIsPoisoned);
+  }
+  return &II;
+}
+
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
   Loc.dump(SourceMgr);
 }
@@ -646,23 +667,8 @@
 
   IdentifierInfo &II = *Identifier.getIdentifierInfo();
 
-  // If the information about this identifier is out of date, update it from
-  // the external source.
-  // We have to treat __VA_ARGS__ in a special way, since it gets
-  // serialized with isPoisoned = true, but our preprocessor may have
-  // unpoisoned it if we're defining a C99 macro.
-  if (II.isOutOfDate()) {
-bool CurrentIsPoisoned = false;
-if (&II == Ident__VA_ARGS__)
-  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
-
-updateOutOfDateIdentifier(II);
-Identifier.setKind(II.getTokenID());
+  Identifier.setKind(II.getTokenID());
 
-if (&II == Ident__VA_ARGS__)
-  II.setIsPoisoned(CurrentIsPoisoned);
-  }
-  
   // If this identifier was poisoned, and if it was not produced from a macro
   // expansion, emit an error.
   if (II.isPoisoned() && CurPPLexer) {
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -939,11 +939,11 @@
   void setPredefines(const char *P) { Predefines = P; }
   void setPredefines(StringRef P) { Predefines = P; }
 
-  /// Return information about the specified preprocessor
-  /// identifier token.
-  IdentifierInfo *getIdentifierInfo(StringRef Name) const {
-return &Identifiers.get(Name);
-  }
+  /// Return information about the specified preprocessor identifier token.
+  /// If \p CheckOutOfDate is true, then the returned information is ensured
+  /// to be not out of date.
+  IdentifierInfo *getIdentifierInfo(StringRef Name,
+bool CheckOutOfDate = true) const;
 
   /// \brief Add the specified pragma handler to this preprocessor.
   ///


Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -245,6 +245,27 @@
   llvm::errs() << ">";
 }
 
+IdentifierInfo *Preprocessor::getIdentifierInfo(StringRef Name,
+bool CheckOutOfDate) const {
+  IdentifierInfo &II = Identifiers.get(Name);
+  // If the information about this identifier is out of date, update it from
+  // the external source.
+  // We have to treat __VA_ARGS__ in a special way, since it gets
+  // serialized with isPoisoned = true, but our preprocessor may have
+  // unpoisoned it if we're defining a C99 macro.
+  if (CheckOutOfDate && II.isOutOfDate()) {
+bool CurrentIsPoisoned = false;
+if (&II == Ident__VA_ARGS__)
+  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
+
+updateOutOfDateIdentifier(II);
+
+if (&II == Ident__VA_ARGS__)
+  II.setIsPoisoned(CurrentIsPoisoned);
+  }
+  return &II;
+}
+
 void Preprocessor::DumpLocation(SourceLocation Loc) const {
   Loc.dump(SourceMgr);
 }
@@ -646,23 +667,8 @@
 
   IdentifierInfo &II = *Identifier.getIdentifierInfo();
 
-  // If the information about this identifier is out of date, update it from
-  // the external source.
-  // We have to treat __VA_ARGS__ in a special way, since it gets
-  // serialized with isPoisoned = true, but our preprocessor may have
-  // unpoisoned it if we're defining a C99 macro.
-  if (II.isOutOfDate()) {
-bool CurrentIsPoisoned = false;
-if (&II == Ident__VA_ARGS__)
-  CurrentIsPoisoned = Ident__VA_ARGS__->isPoisone

[PATCH] D33004: getIdentifierInfo now updates the returned information by default

2017-05-09 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor planned changes to this revision.
teemperor added a comment.

Work in progress patch. We probably also need to update a few other places 
where we call this.


https://reviews.llvm.org/D33004



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


[clang-tools-extra] r302536 - [clang-tidy] Allow disabling compatibility check for generated fixes.

2017-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue May  9 10:10:26 2017
New Revision: 302536

URL: http://llvm.org/viewvc/llvm-project?rev=302536&view=rev
Log:
[clang-tidy] Allow disabling compatibility check for generated fixes.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=302536&r1=302535&r2=302536&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Tue May  
9 10:10:26 2017
@@ -237,9 +237,11 @@ StringRef ClangTidyContext::getCheckName
   return "";
 }
 
-ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
-: Context(Ctx), LastErrorRelatesToUserCode(false),
-  LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {
+ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
+ClangTidyContext &Ctx, bool RemoveIncompatibleErrors)
+: Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
+  LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
+  LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   Diags.reset(new DiagnosticsEngine(
   IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
@@ -611,7 +613,9 @@ void ClangTidyDiagnosticConsumer::finish
   std::sort(Errors.begin(), Errors.end(), LessClangTidyError());
   Errors.erase(std::unique(Errors.begin(), Errors.end(), 
EqualClangTidyError()),
Errors.end());
-  removeIncompatibleErrors(Errors);
+
+  if (RemoveIncompatibleErrors)
+removeIncompatibleErrors(Errors);
 
   for (const ClangTidyError &Error : Errors)
 Context.storeError(Error);

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=302536&r1=302535&r2=302536&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Tue May  9 
10:10:26 2017
@@ -223,7 +223,8 @@ private:
 // implementation file.
 class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
 public:
-  ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx);
+  ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx,
+  bool RemoveIncompatibleErrors = true);
 
   // FIXME: The concept of converting between FixItHints and Replacements is
   // more generic and should be pulled out into a more useful Diagnostics
@@ -249,6 +250,7 @@ private:
   bool passesLineFilter(StringRef FileName, unsigned LineNumber) const;
 
   ClangTidyContext &Context;
+  bool RemoveIncompatibleErrors;
   std::unique_ptr Diags;
   SmallVector Errors;
   std::unique_ptr HeaderFilter;


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


r302540 - Add support for pretty platform names to `@available`/

2017-05-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue May  9 10:34:46 2017
New Revision: 302540

URL: http://llvm.org/viewvc/llvm-project?rev=302540&view=rev
Log:
Add support for pretty platform names to `@available`/
`__builtin_available`

This commit allows us to use the macOS/iOS/tvOS/watchOS platform names in
`@available`/`__builtin_available`.

rdar://32067795

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/FixIt/fixit-availability.c
cfe/trunk/test/FixIt/fixit-availability.mm
cfe/trunk/test/Parser/objc-available.m
cfe/trunk/test/SemaObjC/unguarded-availability.m

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=302540&r1=302539&r2=302540&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue May  9 10:34:46 2017
@@ -652,6 +652,30 @@ def Availability : InheritableAttr {
  .Case("tvos_app_extension", "tvOS (App Extension)")
  .Case("watchos_app_extension", "watchOS (App Extension)")
  .Default(llvm::StringRef());
+}
+static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) 
{
+return llvm::StringSwitch(Platform)
+ .Case("ios", "iOS")
+ .Case("macos", "macOS")
+ .Case("tvos", "tvOS")
+ .Case("watchos", "watchOS")
+ .Case("ios_app_extension", "iOSApplicationExtension")
+ .Case("macos_app_extension", "macOSApplicationExtension")
+ .Case("tvos_app_extension", "tvOSApplicationExtension")
+ .Case("watchos_app_extension", "watchOSApplicationExtension")
+ .Default(Platform);
+}
+static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
+return llvm::StringSwitch(Platform)
+ .Case("iOS", "ios")
+ .Case("macOS", "macos")
+ .Case("tvOS", "tvos")
+ .Case("watchOS", "watchos")
+ .Case("iOSApplicationExtension", "ios_app_extension")
+ .Case("macOSApplicationExtension", "macos_app_extension")
+ .Case("tvOSApplicationExtension", "tvos_app_extension")
+ .Case("watchOSApplicationExtension", "watchos_app_extension")
+ .Default(Platform);
 } }];
   let HasCustomParsing = 1;
   let DuplicatesAllowedWhileMerging = 1;

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=302540&r1=302539&r2=302540&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue May  9 10:34:46 2017
@@ -3001,12 +3001,14 @@ Optional Parser::Parse
 if (Version.empty())
   return None;
 
-StringRef Platform = PlatformIdentifier->Ident->getName();
+StringRef GivenPlatform = PlatformIdentifier->Ident->getName();
+StringRef Platform =
+AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
 
 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
   Diag(PlatformIdentifier->Loc,
diag::err_avail_query_unrecognized_platform_name)
-  << Platform;
+  << GivenPlatform;
   return None;
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=302540&r1=302539&r2=302540&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue May  9 10:34:46 2017
@@ -7346,7 +7346,9 @@ void DiagnoseUnguardedAvailability::Diag
 llvm::raw_string_ostream FixItOS(FixItString);
 FixItOS << "if (" << (SemaRef.getLangOpts().ObjC1 ? "@available"
   : "__builtin_available")
-<< "(" << SemaRef.getASTContext().getTargetInfo().getPlatformName()
+<< "("
+<< AvailabilityAttr::getPlatformNameSourceSpelling(
+   SemaRef.getASTContext().getTargetInfo().getPlatformName())
 << " " << Introduced.getAsString() << ", *)) {\n"
 << Indentation << ExtraIndentation;
 FixitDiag << FixItHint::CreateInsertion(IfInsertionLoc, FixItOS.str());

Modified: cfe/trunk/test/FixIt/fixit-availability.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-availability.c?rev=302540&r1=302539&r2=302540&view=diff
==
--- cfe/trunk/test/FixIt/fixit-availability.c (original)
+++ cfe/trunk/test/FixIt/fixit-availability.c Tue May  9 10:34:46 2017
@@ -5,6 +5,6 @@ int function(void);

[PATCH] D33000: Add support for pretty platform names to `@available`/`__builtin_available`

2017-05-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302540: Add support for pretty platform names to 
`@available`/ (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D33000?vs=98276&id=98297#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33000

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/FixIt/fixit-availability.c
  cfe/trunk/test/FixIt/fixit-availability.mm
  cfe/trunk/test/Parser/objc-available.m
  cfe/trunk/test/SemaObjC/unguarded-availability.m

Index: cfe/trunk/test/Parser/objc-available.m
===
--- cfe/trunk/test/Parser/objc-available.m
+++ cfe/trunk/test/Parser/objc-available.m
@@ -21,6 +21,12 @@
   (void)@available; // expected-error{{expected '('}}
 }
 
+void prettyPlatformNames() {
+  (void)@available(iOS 8, tvOS 10, watchOS 3, macOS 10.11, *);
+  (void)__builtin_available(iOSApplicationExtension 8, tvOSApplicationExtension 10,
+   watchOSApplicationExtension 3, macOSApplicationExtension 10.11, *);
+}
+
 #if __has_builtin(__builtin_available)
 #error expected
 // expected-error@-1 {{expected}}
Index: cfe/trunk/test/SemaObjC/unguarded-availability.m
===
--- cfe/trunk/test/SemaObjC/unguarded-availability.m
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m
@@ -48,7 +48,7 @@
   } else
 func_10_11(); // expected-warning{{'func_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'func_10_11' in an @available check to silence this warning}}
 
-  if (@available(macos 10.11, *)) {
+  if (@available(macOS 10.11, *)) {
 if (@available(ios 8, *)) {
   func_10_11();
   func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 10.12 or newer}} expected-note{{enclose}}
@@ -176,7 +176,7 @@
 }
 
 int instantiate_availability() {
-  if (@available(macos 10.12, *))
+  if (@available(macOS 10.12, *))
 with_availability_attr();
   else
 with_availability_attr(); // expected-warning{{'with_availability_attr' is only available on macOS 10.11 or newer}} expected-warning{{'int_10_12' is only available on macOS 10.12 or newer}} expected-note 2 {{enclose}}
Index: cfe/trunk/test/FixIt/fixit-availability.c
===
--- cfe/trunk/test/FixIt/fixit-availability.c
+++ cfe/trunk/test/FixIt/fixit-availability.c
@@ -5,6 +5,6 @@
 
 void use() {
   function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (__builtin_available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (__builtin_available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
 }
Index: cfe/trunk/test/FixIt/fixit-availability.mm
===
--- cfe/trunk/test/FixIt/fixit-availability.mm
+++ cfe/trunk/test/FixIt/fixit-availability.mm
@@ -7,58 +7,58 @@
 
 int use() {
   function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:14-[[@LINE-2]]:14}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   int y = function(), x = 0;
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:29-[[@LINE-2]]:29}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   x += function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:19-[[@LINE-2]]:19}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (1) {
 x = function();
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:5-[[@LINE-1]]:5}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:20-[[@LINE-2]]:20}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   }
   anotherFunction(function());
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macos 10.12, *)) {\n  "
+// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"if (@available(macOS 10.12, *)) {\n  "
 // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:31-[[@LINE-2]]:31}:"\n  } else {\n  // Fallback on earlier versions\n  }"
   if (function()) {
-// CHECK: fix-it:{{.*}}:{[[@LINE-1]]:3-[[@LINE-1]]:3}:"

r302542 - Revert r302476 "Update testcase for upstream LLVM changes."

2017-05-09 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue May  9 10:55:39 2017
New Revision: 302542

URL: http://llvm.org/viewvc/llvm-project?rev=302542&view=rev
Log:
Revert r302476 "Update testcase for upstream LLVM changes."

That test update was for r302469, which was reverted in r302533 due to PR32977.

Modified:
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp

Modified: cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp?rev=302542&r1=302541&r2=302542&view=diff
==
--- cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp Tue May  9 
10:55:39 2017
@@ -12,10 +12,8 @@ void Derived::VariadicFunction(...) { }
 
 // CHECK: define void @_ZN7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP:[0-9]+]]
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
-// CHECK: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP_I:[0-9]+]]
-// CHECK: ret void, !dbg ![[LOC_I:[0-9]+]]
+// CHECK-LABEL: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz(
+// CHECK: ret void, !dbg ![[LOC:[0-9]+]]
 //
 // CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction"
 // CHECK: ![[LOC]] = !DILocation({{.*}}scope: ![[SP]])
-// CHECK: ![[SP_I]] = distinct !DISubprogram(name: "VariadicFunction"
-// CHECK: ![[LOC_I]] = !DILocation({{.*}}scope: ![[SP_I]])


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


[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-09 Thread Ben Craig via Phabricator via cfe-commits
bcraig added inline comments.



Comment at: include/__config:232-235
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+

I can see this helping when we are build libc++, but I don't think it helps 
client apps.  They could have included windows.h before including our headers.

Don't get me wrong, I dislike the min and max macros, and bear no hard feelings 
towards people that define this project wide on the command line, I'm just not 
sure it will get things done right here.

In the past, I've just surrounded my min and max declarations with parenthesis 
to suppress macro expansion.


https://reviews.llvm.org/D32988



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


r302545 - [CodeCompletion] Complete platform names in @available expressions

2017-05-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue May  9 11:05:04 2017
New Revision: 302545

URL: http://llvm.org/viewvc/llvm-project?rev=302545&view=rev
Log:
[CodeCompletion] Complete platform names in @available expressions

rdar://32074504

Added:
cfe/trunk/test/Index/complete-available.m
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302545&r1=302544&r2=302545&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May  9 11:05:04 2017
@@ -10009,6 +10009,7 @@ public:
  MacroInfo *MacroInfo,
  unsigned Argument);
   void CodeCompleteNaturalLanguage();
+  void CodeCompleteAvailabilityPlatformName();
   void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
CodeCompletionTUInfo &CCTUInfo,
   SmallVectorImpl &Results);

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=302545&r1=302544&r2=302545&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue May  9 11:05:04 2017
@@ -2989,6 +2989,11 @@ Optional Parser::Parse
 return AvailabilitySpec(ConsumeToken());
   } else {
 // Parse the platform name.
+if (Tok.is(tok::code_completion)) {
+  Actions.CodeCompleteAvailabilityPlatformName();
+  cutOffParsing();
+  return None;
+}
 if (Tok.isNot(tok::identifier)) {
   Diag(Tok, diag::err_avail_query_expected_platform_name);
   return None;

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=302545&r1=302544&r2=302545&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue May  9 11:05:04 2017
@@ -7811,6 +7811,23 @@ void Sema::CodeCompleteNaturalLanguage()
 nullptr, 0);
 }
 
+void Sema::CodeCompleteAvailabilityPlatformName() {
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_Other);
+  Results.EnterNewScope();
+  static const char *Platforms[] = {"macOS", "iOS", "watchOS", "tvOS"};
+  for (const char *Platform : llvm::makeArrayRef(Platforms)) {
+Results.AddResult(CodeCompletionResult(Platform));
+Results.AddResult(CodeCompletionResult(Results.getAllocator().CopyString(
+Twine(Platform) + "ApplicationExtension")));
+  }
+  Results.ExitScope();
+  HandleCodeCompleteResults(this, CodeCompleter,
+CodeCompletionContext::CCC_Other, Results.data(),
+Results.size());
+}
+
 void Sema::GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
CodeCompletionTUInfo &CCTUInfo,
  SmallVectorImpl &Results) {

Added: cfe/trunk/test/Index/complete-available.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-available.m?rev=302545&view=auto
==
--- cfe/trunk/test/Index/complete-available.m (added)
+++ cfe/trunk/test/Index/complete-available.m Tue May  9 11:05:04 2017
@@ -0,0 +1,20 @@
+/* The run lines are below, because this test is line- and
+   column-number sensitive. */
+void atAvailable() {
+  if (@available(macOS 10.10, *)) {
+
+  }
+  if (__builtin_available(iOS 8, *)) {
+  }
+}
+
+// RUN: c-index-test -code-completion-at=%s:4:18 %s | FileCheck 
-check-prefix=CHECK %s
+// RUN: c-index-test -code-completion-at=%s:7:27 %s | FileCheck 
-check-prefix=CHECK %s
+// CHECK: {TypedText iOS} (40)
+// CHECK: {TypedText iOSApplicationExtension} (40)
+// CHECK: {TypedText macOS} (40)
+// CHECK: {TypedText macOSApplicationExtension} (40)
+// CHECK: {TypedText tvOS} (40)
+// CHECK: {TypedText tvOSApplicationExtension} (40)
+// CHECK: {TypedText watchOS} (40)
+// CHECK: {TypedText watchOSApplicationExtension} (40)


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


[PATCH] D32972: [index] Index simple dependent declaration references

2017-05-09 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

A couple of minor comments, but otherwise LGTM.




Comment at: include/clang/AST/DeclCXX.h:1569
+  bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths,
+ bool LookupInDependent = false) const;
 

Since the other params are documented above, this should be too.



Comment at: lib/AST/CXXInheritance.cpp:281
+}
+  } else
+BaseRecord = cast(

Please put `{}` around this else.  The first two times I read this I thought 
the following if was nested inside this else.


Repository:
  rL LLVM

https://reviews.llvm.org/D32972



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


[PATCH] D30837: [libcxx] Support for shared_ptr

2017-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping! @mclow.lists: Do you have any thoughts here?


https://reviews.llvm.org/D30837



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


[PATCH] D32900: [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Petar Jovanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302547: [mips] Impose a threshold for coercion of aggregates 
(authored by petarj).

Changed prior to commit:
  https://reviews.llvm.org/D32900?vs=98269&id=98304#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32900

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/mips-aggregate-arg.c


Index: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
===
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6695,6 +6695,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.


Index: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
===
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -6695,6 +6695,14 @@
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302547 - [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Tue May  9 11:24:03 2017
New Revision: 302547

URL: http://llvm.org/viewvc/llvm-project?rev=302547&view=rev
Log:
[mips] Impose a threshold for coercion of aggregates

Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
structures only if the size of said aggregate is less than 16/64 bytes,
depending on the ABI.

Patch by Stefan Maksimovic.

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

Added:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302547&r1=302546&r2=302547&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May  9 11:24:03 2017
@@ -6695,6 +6695,14 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Added: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302547&view=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (added)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c Tue May  9 11:24:03 2017
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
+// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
+
+struct t1 {
+  char t1[10];
+};
+
+struct t2 {
+  char t2[20];
+};
+
+struct t3 {
+  char t3[65];
+};
+
+extern struct t1 g1;
+extern struct t2 g2;
+extern struct t3 g3;
+extern void f1(struct t1);
+extern void f2(struct t2);
+extern void f3(struct t3);
+
+void f() {
+
+// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
+// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
+// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
+
+// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
+// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
+// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
+
+  f1(g1);
+  f2(g2);
+  f3(g3);
+}
+


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


[PATCH] D31839: make -Winteger-overflow find overflows in function arguments

2017-05-09 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky added a comment.

Ping!


https://reviews.llvm.org/D31839



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


[PATCH] D32248: CodeGen: Cast alloca to expected address space

2017-05-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 98314.
yaxunl added a comment.

Revised by reviewers' comments.


https://reviews.llvm.org/D32248

Files:
  include/clang/AST/Type.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGen/address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp
  test/CodeGenOpenCL/amdgcn-automatic-variable.cl

Index: test/CodeGenOpenCL/amdgcn-automatic-variable.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgcn-automatic-variable.cl
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL1.2 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL12 %s
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck -check-prefixes=CHECK,CL20 %s
+
+// CL12-LABEL: define void @func1(i32 addrspace(5)* %x)
+// CL20-LABEL: define void @func1(i32* %x)
+void func1(int *x) {
+  // CL12: %[[x_addr:.*]] = alloca i32 addrspace(5)*{{.*}}addrspace(5)
+  // CL12: store i32 addrspace(5)* %x, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
+  // CL12: %[[r0:.*]] = load i32 addrspace(5)*, i32 addrspace(5)* addrspace(5)* %[[x_addr]]
+  // CL12: store i32 1, i32 addrspace(5)* %[[r0]]
+  // CL20: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
+  // CL20: store i32* %x, i32* addrspace(5)* %[[x_addr]]
+  // CL20: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
+  // CL20: store i32 1, i32* %[[r0]]
+  *x = 1;
+}
+
+// CHECK-LABEL: define void @func2()
+void func2(void) {
+  // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CL12: %lp1 = alloca i32 addrspace(5)*, align 4, addrspace(5)
+  // CL12: %lp2 = alloca i32 addrspace(5)*, align 4, addrspace(5)
+  // CL20: %lp1 = alloca i32*, align 4, addrspace(5)
+  // CL20: %lp2 = alloca i32*, align 4, addrspace(5)
+  // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+
+  // CHECK: store i32 1, i32 addrspace(5)* %lv1
+  int lv1;
+  lv1 = 1;
+  // CHECK: store i32 2, i32 addrspace(5)* %lv2
+  int lv2 = 2;
+
+  // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i64 0, i64 0
+  // CHECK: store i32 3, i32 addrspace(5)* %[[arrayidx]], align 4
+  int la[100];
+  la[0] = 3;
+
+  // CL12: store i32 addrspace(5)* %lv1, i32 addrspace(5)* addrspace(5)* %lp1, align 4
+  // CL20: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
+  // CL20: store i32* %[[r0]], i32* addrspace(5)* %lp1, align 4
+  int *lp1 = &lv1;
+
+  // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32] addrspace(5)* %la, i32 0, i32 0
+  // CL12: store i32 addrspace(5)* %[[arraydecay]], i32 addrspace(5)* addrspace(5)* %lp2, align 4
+  // CL20: %[[r1:.*]] = addrspacecast i32 addrspace(5)* %[[arraydecay]] to i32*
+  // CL20: store i32* %[[r1]], i32* addrspace(5)* %lp2, align 4
+  int *lp2 = la;
+
+  // CL12: call void @func1(i32 addrspace(5)* %lv1)
+  // CL20: %[[r2:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
+  // CL20: call void @func1(i32* %[[r2]])
+  func1(&lv1);
+
+  // CHECK: store i32 4, i32 addrspace(5)* %lvc
+  // CHECK: store i32 4, i32 addrspace(5)* %lv1
+  const int lvc = 4;
+  lv1 = lvc;
+}
Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -O0 -triple amdgcn---amdgiz -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define void @_Z5func1Pi(i32* %x)
+void func1(int *x) {
+  // CHECK: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
+  // CHECK: store i32* %x, i32* addrspace(5)* %[[x_addr]]
+  // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
+  // CHECK: store i32 1, i32* %[[r0]]
+  *x = 1;
+}
+
+// CHECK-LABEL: define void @_Z5func2v()
+void func2(void) {
+  // CHECK: %lv1 = alloca i32, align 4, addrspace(5)
+  // CHECK: %lv2 = alloca i32, align 4, addrspace(5)
+  // CHECK: %la = alloca [100 x i32], align 4, addrspace(5)
+  // CHECK: %lp1 = alloca i32*, align 4, addrspace(5)
+  // CHECK: %lp2 = alloca i32*, align 4, addrspace(5)
+  // CHECK: %lvc = alloca i32, align 4, addrspace(5)
+
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %lv1 to i32*
+  // CHECK: store i32 1, i32* %[[r0]]
+  int lv1;
+  lv1 = 1;
+  // CHECK: store i32 2, i32 addrspace(5)* %lv2
+  int lv2 = 2;
+
+  // CHECK: %[[r2:.*]] = addrspacecast [100 x i32] addrspace(5)* %la to [100 x i32]*
+  // CHECK: %[[arrayidx:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[r2]], i64 0, i64 0
+  // CHECK: store i32 3, i32* %[[arrayidx]], align 4
+  int la[100];
+  la[0] = 3;
+
+  // CHECK: store i32* %[[r0]], i32* addrspace(5)* %lp1, align 4
+  int *lp1 = &lv1;
+
+  // CHECK: %[[arraydecay:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[r2]]

[PATCH] D32499: Further delay calling DeclMustBeEmitted until it's safe.

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Let's go ahead with this. I've been unable to find a testcase that triggers the 
problem, but we shouldn't keep a known latent bug around just because we don't 
know how to expose it yet.


https://reviews.llvm.org/D32499



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


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D32724#747728, @aprantl wrote:

> Is it the right solution to use the module hash for correctness, or should 
> the mismatch of the serialized langopts trigger a module rebuild and the 
> module hash is only there to tune the performance/disk size tradeoff?


I'm not sure if there is (or should be) a hard-and-fast rule, but certainly in 
this case changing the hash SGTM.  Otherwise, users toggling back and forth 
between build configurations would have to rebuild the modules each time.


https://reviews.llvm.org/D32724



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


Re: r302547 - [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Hans Wennborg via cfe-commits
On Tue, May 9, 2017 at 9:24 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Tue May  9 11:24:03 2017
> New Revision: 302547
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302547&view=rev
> Log:
> [mips] Impose a threshold for coercion of aggregates
>
> Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
> structures only if the size of said aggregate is less than 16/64 bytes,
> depending on the ABI.
>
> Patch by Stefan Maksimovic.
>
> Differential Revision: https://reviews.llvm.org/D32900
>
> Added:
> cfe/trunk/test/CodeGen/mips-aggregate-arg.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp

Looks like a test is failing due to this:
http://bb.pgr.jp/builders/test-clang-x86_64-linux-R/builds/1932/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__mips-aggregate-arg.c
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31269: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This makes a lot of sense to me. See also r302463: I think we probably want 
three levels of shadowing here: the main input shadows -fmodule-map-file, which 
shadows module maps loaded implicitly. (There's also a question of what we do 
with module map information loaded from an AST file: currently when that 
happens, we ignore the tokens for the parsed module map entirely. It might make 
more sense to have the module loaded from the AST file shadow the module from 
the module map, especially for an explicit module build, now that we have that 
functionality.)




Comment at: lib/Lex/ModuleMap.cpp:2574-2575
 
+  llvm::SaveAndRestore OldExplicit(CurrentModuleMapIsExplicitlyProvided);
+  CurrentModuleMapIsExplicitlyProvided |= IsExplicitlyProvided;
+

It would seem cleaner to make this a member of `ModuleMapParser` (and 
explicitly pass down the flag when parsing an `extern module` declaration). Is 
there a reason to use (essentially) global state for this?


https://reviews.llvm.org/D31269



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


r302555 - Revert r302547 ([mips] Impose a threshold for coercion of aggregates)

2017-05-09 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Tue May  9 12:20:06 2017
New Revision: 302555

URL: http://llvm.org/viewvc/llvm-project?rev=302555&view=rev
Log:
Revert r302547 ([mips] Impose a threshold for coercion of aggregates)

Reverting
  Modified MipsABIInfo::classifyArgumentType so that it now coerces
  aggregate structures only if the size of said aggregate is less than 16/64
  bytes, depending on the ABI.
as it broke clang-with-lto-ubuntu builder.

Removed:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302555&r1=302554&r2=302555&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May  9 12:20:06 2017
@@ -6695,14 +6695,6 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
-// Use indirect if the aggregate cannot fit into registers for
-// passing arguments according to the ABI
-unsigned Threshold = IsO32 ? 16 : 64;
-
-if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
-  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
- getContext().getTypeAlign(Ty) / 8 > 
Align);
-
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=302554&view=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (original)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
-
-struct t1 {
-  char t1[10];
-};
-
-struct t2 {
-  char t2[20];
-};
-
-struct t3 {
-  char t3[65];
-};
-
-extern struct t1 g1;
-extern struct t2 g2;
-extern struct t3 g3;
-extern void f1(struct t1);
-extern void f2(struct t2);
-extern void f3(struct t3);
-
-void f() {
-
-// O32:  call void @f1(i32 inreg %3, i32 inreg %5, i16 inreg %7)
-// O32:  call void @f2(%struct.t2* byval align 4 %tmp)
-// O32:  call void @f3(%struct.t3* byval align 4 %tmp1)
-
-// N32-N64:  call void @f1(i64 inreg %3, i16 inreg %5)
-// N32-N64:  call void @f2(i64 inreg %9, i64 inreg %11, i32 inreg %13)
-// N32-N64:  call void @f3(%struct.t3* byval align 8 %tmp)
-
-  f1(g1);
-  f2(g2);
-  f3(g3);
-}
-


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


RE: r302547 - [mips] Impose a threshold for coercion of aggregates

2017-05-09 Thread Petar Jovanovic via cfe-commits
Reverted in r302555.

From: hwennb...@google.com [hwennb...@google.com] on behalf of Hans Wennborg 
[h...@chromium.org]
Sent: Tuesday, May 09, 2017 7:18 PM
To: Petar Jovanovic
Cc: cfe-commits
Subject: Re: r302547 - [mips] Impose a threshold for coercion of aggregates

On Tue, May 9, 2017 at 9:24 AM, Petar Jovanovic via cfe-commits
 wrote:
> Author: petarj
> Date: Tue May  9 11:24:03 2017
> New Revision: 302547
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302547&view=rev
> Log:
> [mips] Impose a threshold for coercion of aggregates
>
> Modified MipsABIInfo::classifyArgumentType so that it now coerces aggregate
> structures only if the size of said aggregate is less than 16/64 bytes,
> depending on the ABI.
>
> Patch by Stefan Maksimovic.
>
> Differential Revision: https://reviews.llvm.org/D32900
>
> Added:
> cfe/trunk/test/CodeGen/mips-aggregate-arg.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp

Looks like a test is failing due to this:
http://bb.pgr.jp/builders/test-clang-x86_64-linux-R/builds/1932/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__mips-aggregate-arg.c
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info

2017-05-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302556: Build the Apple-style stage2 with modules (authored 
by adrian).

Changed prior to commit:
  https://reviews.llvm.org/D32603?vs=96952&id=98320#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32603

Files:
  cfe/trunk/cmake/caches/Apple-stage2.cmake


Index: cfe/trunk/cmake/caches/Apple-stage2.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage2.cmake
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake
@@ -13,6 +13,7 @@
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")


Index: cfe/trunk/cmake/caches/Apple-stage2.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage2.cmake
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake
@@ -13,6 +13,7 @@
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302556 - Build the Apple-style stage2 with modules

2017-05-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue May  9 12:27:03 2017
New Revision: 302556

URL: http://llvm.org/viewvc/llvm-project?rev=302556&view=rev
Log:
Build the Apple-style stage2 with modules

Green dragon had a green stage2 modules bot for a long time now[1] and
it is time to retire it and make a modules build the default for
Apple-style stage2 builds.

This patch turns on LLVM_ENABLE_MODULES.

[1] http://green.lab.llvm.org/green/job/clang-stage2-cmake-modulesRDA_build/
rdar://problem/28672159

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

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=302556&r1=302555&r2=302556&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue May  9 12:27:03 2017
@@ -13,6 +13,7 @@ set(CLANG_LINKS_TO_CREATE clang++ cc c++
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_MODULES ON CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "")


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


r302557 - [X86][LWP] Removing LWP todo comment. NFCI.

2017-05-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue May  9 12:43:16 2017
New Revision: 302557

URL: http://llvm.org/viewvc/llvm-project?rev=302557&view=rev
Log:
[X86][LWP] Removing LWP todo comment. NFCI.

LWP / lwpintrin.h is now supported

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

Modified: cfe/trunk/lib/Headers/x86intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/x86intrin.h?rev=302557&r1=302556&r2=302557&view=diff
==
--- cfe/trunk/lib/Headers/x86intrin.h (original)
+++ cfe/trunk/lib/Headers/x86intrin.h Tue May  9 12:43:16 2017
@@ -88,6 +88,4 @@
 #include 
 #endif
 
-/* FIXME: LWP */
-
 #endif /* __X86INTRIN_H */


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


r302558 - [WebAssembly] Fix location and -flavor when running lld

2017-05-09 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue May  9 12:47:50 2017
New Revision: 302558

URL: http://llvm.org/viewvc/llvm-project?rev=302558&view=rev
Log:
[WebAssembly] Fix location and -flavor when running lld

Add the toolchain installation directory to the program
path so that lld can be found.

Change -flavor to wasm.  Although this new flavor hasn't
yet landed in upstream lld yet there are no point in
passing wasm objects the gnu flavor.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=302558&r1=302557&r2=302558&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Tue May  9 12:47:50 2017
@@ -42,7 +42,7 @@ void wasm::Linker::ConstructJob(Compilat
   const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("ld");
+  CmdArgs.push_back("wasm");
 
   // Enable garbage collection of unused input sections by default, since code
   // size is of particular importance. This is significantly facilitated by
@@ -101,6 +101,9 @@ WebAssembly::WebAssembly(const Driver &D
   : ToolChain(D, Triple, Args) {
 
   assert(Triple.isArch32Bit() != Triple.isArch64Bit());
+
+  getProgramPaths().push_back(getDriver().getInstalledDir());
+
   getFilePaths().push_back(
   getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
 }


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


r302559 - [X86][LWP] Remove MSVC LWP intrinsics stubs.

2017-05-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue May  9 12:50:16 2017
New Revision: 302559

URL: http://llvm.org/viewvc/llvm-project?rev=302559&view=rev
Log:
[X86][LWP] Remove MSVC LWP intrinsics stubs.

Now provided in lwpintrin.h

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

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=302559&r1=302558&r2=302559&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue May  9 12:50:16 2017
@@ -85,9 +85,6 @@ void __inwordstring(unsigned short, unsi
 void __lidt(void *);
 unsigned __int64 __ll_lshift(unsigned __int64, int);
 __int64 __ll_rshift(__int64, int);
-void __llwpcb(void *);
-unsigned char __lwpins32(unsigned int, unsigned int, unsigned int);
-void __lwpval32(unsigned int, unsigned int, unsigned int);
 unsigned int __lzcnt(unsigned int);
 unsigned short __lzcnt16(unsigned short);
 static __inline__
@@ -126,7 +123,6 @@ unsigned __int64 __readmsr(unsigned long
 unsigned __int64 __readpmc(unsigned long);
 unsigned long __segmentlimit(unsigned long);
 void __sidt(void *);
-void *__slwpcb(void);
 static __inline__
 void __stosb(unsigned char *, unsigned char, size_t);
 static __inline__
@@ -227,8 +223,6 @@ void __incgsbyte(unsigned long);
 void __incgsdword(unsigned long);
 void __incgsqword(unsigned long);
 void __incgsword(unsigned long);
-unsigned char __lwpins64(unsigned __int64, unsigned int, unsigned int);
-void __lwpval64(unsigned __int64, unsigned int, unsigned int);
 unsigned __int64 __lzcnt64(unsigned __int64);
 static __inline__
 void __movsq(unsigned long long *, unsigned long long const *, size_t);


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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

Looks good from my side.

@yaxunl , since you originally committed this. Could you please verify that 
changing from `SIZE_MAX` to `0` would be fine.

Btw, we have a similar definition for `CLK_NULL_EVENT`.


https://reviews.llvm.org/D32896



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


[PATCH] D32897: [OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins

2017-05-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! It's a pity we are not testing anything here.


https://reviews.llvm.org/D32897



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


[PATCH] D32898: [OpenCL] Handle OpenCL specific subelement types

2017-05-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added inline comments.
This revision is now accepted and ready to land.



Comment at: test/SemaOpenCL/array-init.cl:4
+
+__kernel void k2(queue_t q1, queue_t q2) {
+  queue_t q[] = {q1, q2};

Minor thing - I would use sequential numeration of kernel names i.e. k1, k2, 
k3...


https://reviews.llvm.org/D32898



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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-09 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3814
+  } else // TypeAliasTemplateDecl
+assert(0 && "TypeAliasTemplateDecl doesn't have specs!");
+}

llvm_unreachable()


Repository:
  rL LLVM

https://reviews.llvm.org/D29951



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


[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
Herald added subscribers: krytarowski, javed.absar, nhaehnle, rengolin, 
aemerson.

Now if clang driver is given wrong arguments, in some cases it
continues execution and returns zero code. This change fixes this
behavior.

The fix revealed some errors in clang test set.

File test/Driver/gfortran.f90 added in r118203 checks forwarding
gfortran flags to GCC. Now driver reports error on this file, because
the option -working-directory implemented in clang differs from the
option with the same name implemented in gfortran, in clang the option
requires argument, in gfortran does not.

In the file test/Driver/arm-darwin-builtin.c clang is called with
options -fbuiltin-strcat and -fbuiltin-strcpy. These option were removed
in r191435 and now clang reports error on this test.

File arm-default-build-attributes.s uses option -verify, which is not
supported by driver, it is cc1 option.

Similarly, the file split-debug.h uses options -fmodules-embed-all-files
and -fmodule-format=obj, which are not supported by driver.

Other revealed errors are mainly mistypes.


https://reviews.llvm.org/D33013

Files:
  lib/Driver/Driver.cpp
  test/Driver/aarch64-cpus.c
  test/Driver/amdgpu-features.c
  test/Driver/arm-darwin-builtin.c
  test/Driver/arm-default-build-attributes.s
  test/Driver/cl-outputs.c
  test/Driver/clang_f_opts.c
  test/Driver/debug-options.c
  test/Driver/gfortran.f90
  test/Driver/split-debug.h
  test/Driver/unknown-arg.c
  test/Index/index-attrs.c
  test/Index/index-attrs.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -454,40 +454,41 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
-  int Res = 0;
-  SmallVector, 4> FailingCommands;
-  if (C.get())
+  int Res = 1;
+  if (C.get()) {
+SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-  // Force a crash to test the diagnostics.
-  if (TheDriver.GenReproducer) {
-Diags.Report(diag::err_drv_force_crash)
+// Force a crash to test the diagnostics.
+if (TheDriver.GenReproducer) {
+  Diags.Report(diag::err_drv_force_crash)
 << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
 
-// Pretend that every command failed.
-FailingCommands.clear();
-for (const auto &J : C->getJobs())
-  if (const Command *C = dyn_cast(&J))
-FailingCommands.push_back(std::make_pair(-1, C));
-  }
+  // Pretend that every command failed.
+  FailingCommands.clear();
+  for (const auto &J : C->getJobs())
+if (const Command *C = dyn_cast(&J))
+  FailingCommands.push_back(std::make_pair(-1, C));
+}
 
-  for (const auto &P : FailingCommands) {
-int CommandRes = P.first;
-const Command *FailingCommand = P.second;
-if (!Res)
-  Res = CommandRes;
-
-// If result status is < 0, then the driver command signalled an error.
-// If result status is 70, then the driver command reported a fatal error.
-// On Windows, abort will return an exit code of 3.  In these cases,
-// generate additional diagnostic information if possible.
-bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+for (const auto &P : FailingCommands) {
+  int CommandRes = P.first;
+  const Command *FailingCommand = P.second;
+  if (!Res)
+Res = CommandRes;
+
+  // If result status is < 0, then the driver command signalled an error.
+  // If result status is 70, then the driver command reported a fatal error.
+  // On Windows, abort will return an exit code of 3.  In these cases,
+  // generate additional diagnostic information if possible.
+  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef LLVM_ON_WIN32
-DiagnoseCrash |= CommandRes == 3;
+  DiagnoseCrash |= CommandRes == 3;
 #endif
-if (DiagnoseCrash) {
-  TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
-  break;
+  if (DiagnoseCrash) {
+TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
+break;
+  }
 }
   }
 
Index: test/Index/index-attrs.cpp
===
--- test/Index/index-attrs.cpp
+++ test/Index/index-attrs.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test -index-file -check-prefix CHECK %s -target armv7-windows-gnu -fdeclspec
+// RUN: c-index-test -index-file %s -target armv7-windows-gnu -fdeclspec | FileCheck %s
 
 struct __declspec(dllexport) export_s {
   void m();
@@ -19,32 +19,32 @@
 class __attribute__((dllexport)) export_gnu_s {
   void m();
 };
-// CHECK: [indexDeclaration]: kind: struct | name: export_gnu_s | {{.*}} | lang: C++
+// CHECK: [indexDeclaration]: kind: c++-class | name: export_gnu_s | {{.*}} | lang: C++
 // CHECK: : attribute(dllexport)
 // CHECK: [indexDeclaration]: kind: c++-instan

[PATCH] D24933: Enable configuration files in clang

2017-05-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 98330.
sepavloff added a comment.
Herald added subscribers: krytarowski, rengolin.

Updated patch


https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Tooling/Tooling.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/config-file-errs.c
  test/Driver/config-file.c
  test/Driver/config-file2.c
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -199,23 +199,19 @@
 extern int cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
 
-static void insertTargetAndModeArgs(StringRef Target, StringRef Mode,
+static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
 SmallVectorImpl &ArgVector,
 std::set &SavedStrings) {
-  if (!Mode.empty()) {
+  if (!NameParts.ModeSuffix.empty()) {
 // Add the mode flag to the arguments.
-auto it = ArgVector.begin();
-if (it != ArgVector.end())
-  ++it;
-ArgVector.insert(it, GetStableCStr(SavedStrings, Mode));
+ArgVector.insert(ArgVector.end(),
+ GetStableCStr(SavedStrings, NameParts.ModeSuffix));
   }
 
-  if (!Target.empty()) {
-auto it = ArgVector.begin();
-if (it != ArgVector.end())
-  ++it;
-const char *arr[] = {"-target", GetStableCStr(SavedStrings, Target)};
-ArgVector.insert(it, std::begin(arr), std::end(arr));
+  if (NameParts.TargetIsValid) {
+const char *arr[] = {"-target", GetStableCStr(SavedStrings,
+  NameParts.TargetPrefix)};
+ArgVector.insert(ArgVector.end(), std::begin(arr), std::end(arr));
   }
 }
 
@@ -323,9 +319,7 @@
   }
 
   llvm::InitializeAllTargets();
-  std::string ProgName = argv[0];
-  std::pair TargetAndMode =
-  ToolChain::getTargetAndModeFromProgramName(ProgName);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
@@ -338,7 +332,7 @@
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
-  if (TargetAndMode.second == "--driver-mode=cl" ||
+  if (TargetAndMode.ModeSuffix == "--driver-mode=cl" ||
   std::find_if(argv.begin(), argv.end(), [](const char *F) {
 return F && strcmp(F, "--driver-mode=cl") == 0;
   }) != argv.end()) {
@@ -447,9 +441,9 @@
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
   SetInstallDir(argv, TheDriver, CanonicalPrefixes);
+  TheDriver.setTargetAndMode(TargetAndMode);
 
-  insertTargetAndModeArgs(TargetAndMode.first, TargetAndMode.second, argv,
-  SavedStrings);
+  insertTargetAndModeArgs(TargetAndMode, argv, SavedStrings);
 
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
@@ -491,7 +485,6 @@
   }
 }
   }
-
   Diags.getClient()->finish();
 
   // If any timers were active but haven't been destroyed yet, print their
Index: test/Driver/config-file2.c
===
--- /dev/null
+++ test/Driver/config-file2.c
@@ -0,0 +1,107 @@
+// REQUIRES: shell
+
+//--- Invocation qqq-clang tries to find config file qqq.cfg
+//
+// RUN: mkdir -p %T/testbin
+// RUN: [ ! -s %T/testbin/qqq-clang ] || rm %T/testbin/qqq-clang
+// RUN: ln -s %clang %T/testbin/qqq-clang
+// RUN: echo "-Wundefined-func-template" > %T/testbin/qqq.cfg
+//
+// RUN: %T/testbin/qqq-clang -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s
+//
+// CHECK: Configuration file: {{.*}}/testbin/qqq.cfg
+// CHECK: -Wundefined-func-template
+
+
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: [ ! -s %T/testbin/clang ] || rm %T/testbin/clang
+// RUN: ln -s %clang %T/testbin/clang
+// RUN: echo "-Werror" > %T/testbin/aaa.cfg
+//
+// RUN: %T/testbin/clang --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
+
+
+//--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by
+//that path.
+//
+// RUN: mkdir -p %T/workdir
+// RUN: echo "@subdir/cfg-s2" > %T/workdir/cfg-1
+// RUN: mkdir -p %T/workdir/subdir
+// RUN: echo "-Wundefined-var-template" > %T/workdir/subdir/cfg-s2
+//
+// RUN: ( c

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Dan Beam via Phabricator via cfe-commits
danbeam updated this revision to Diff 98332.
danbeam marked 4 inline comments as done.
danbeam added a comment.

mprobst@ review


https://reviews.llvm.org/D32989

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,25 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine &Line,
+   const AdditionalKeywords &Keywords) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,25 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine &Line,
+   const AdditionalKeywords &Keywords) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) {
   if (InitialToken.

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Dan Beam via Phabricator via cfe-commits
danbeam added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:2353
+  // expressions?
+  if (Line->Tokens.size() < 5)
+return false;

mprobst wrote:
> There's a `startsSequenceInternal` on `Line` that might come in handy here?
it wasn't on `Line` and unfortunately some of the state that `startsSequence` 
relies on isn't set up yet (at least as far as I know, I'm in a foreign land)



Comment at: lib/Format/UnwrappedLineParser.cpp:2362
+  ++I;
+  if (I->Tok->isNot(tok::l_paren))
+return false;

mprobst wrote:
> One more - do we want to support IIFEs that take arguments?
> 
> 
> ```
> (function(global) {
>   ...
> }(window));
> ```
"Less is more"



Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"

mprobst wrote:
> consider adding a test with comments between the tokens (which should work 
> with `startsSequence`).
not done yet, but seems uncommon.

do you want me to add a FIXME?


https://reviews.llvm.org/D32989



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


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 98333.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Reduce code duplication. Use llvm_unreachable.


https://reviews.llvm.org/D29951

Files:
  lib/Serialization/ASTReaderDecl.cpp

Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -206,6 +206,30 @@
 DeclContext *DC);
 FindExistingResult findExisting(NamedDecl *D);
 
+template 
+void AddLazySpecializations(T *D,
+SmallVectorImpl& IDs) {
+  assert(!IDs.empty() && "no IDs to add to list");
+  assert(isa(D) ||
+ isa(D) &&
+ "Decl doesn't have specializations.");
+
+  auto *CommonPtr = D->getCommonPtr();
+  ASTContext &C = Reader.getContext();
+
+  if (auto &Old = CommonPtr->LazySpecializations) {
+IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
+std::sort(IDs.begin(), IDs.end());
+IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
+  }
+
+  auto *Result = new (C) DeclID[1 + IDs.size()];
+  *Result = IDs.size();
+  std::copy(IDs.begin(), IDs.end(), Result + 1);
+
+  CommonPtr->LazySpecializations = Result;
+}
+
   public:
 ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record,
   ASTReader::RecordLocation Loc,
@@ -1951,21 +1975,6 @@
   return Redecl;
 }
 
-static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old,
- SmallVectorImpl &IDs) {
-  assert(!IDs.empty() && "no IDs to add to list");
-  if (Old) {
-IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-std::sort(IDs.begin(), IDs.end());
-IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
-  }
-
-  auto *Result = new (Context) DeclID[1 + IDs.size()];
-  *Result = IDs.size();
-  std::copy(IDs.begin(), IDs.end(), Result + 1);
-  return Result;
-}
-
 void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D);
 
@@ -1975,11 +1984,8 @@
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
 
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+if (!SpecIDs.empty())
+  AddLazySpecializations(D, SpecIDs);
   }
 
   if (D->getTemplatedDecl()->TemplateOrInstantiation) {
@@ -2007,11 +2013,8 @@
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
 
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+if (!SpecIDs.empty())
+  AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -2118,11 +2121,8 @@
 SmallVector SpecIDs;
 ReadDeclIDList(SpecIDs);
 
-if (!SpecIDs.empty()) {
-  auto *CommonPtr = D->getCommonPtr();
-  CommonPtr->LazySpecializations = newDeclIDList(
-  Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs);
-}
+if (!SpecIDs.empty())
+  AddLazySpecializations(D, SpecIDs);
   }
 }
 
@@ -3908,9 +3908,19 @@
   break;
 }
 
-case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
-  // It will be added to the template's specializations set when loaded.
-  (void)Record.readDecl();
+case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: {
+  // It will be added to the template's lazy specialization set when loaded.
+  SmallVector SpecID;
+  SpecID.push_back(ReadDeclID());
+  if (auto *CTD = dyn_cast(D))
+AddLazySpecializations(CTD, SpecID);
+  else if (auto *FTD = dyn_cast(D))
+AddLazySpecializations(FTD, SpecID);
+  else if (auto *VTD = dyn_cast(D))
+AddLazySpecializations(VTD, SpecID);
+  else // TypeAliasTemplateDecl
+llvm_unreachable("TypeAliasTemplateDecl doesn't have specs!");
+}
   break;
 
 case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29951: Load lazily the template specialization in multi-module setups.

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Serialization/ASTReaderDecl.cpp:213-215
+  assert(isa(D) ||
+ isa(D) &&
+ "Decl doesn't have specializations.");

Can this ever fail at runtime? I'd expect the below code to not compile if `D` 
isn't one of these types.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3911-3924
+case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: {
+  // It will be added to the template's lazy specialization set when 
loaded.
+  SmallVector SpecID;
+  SpecID.push_back(ReadDeclID());
+  if (auto *CTD = dyn_cast(D))
+AddLazySpecializations(CTD, SpecID);
+  else if (auto *FTD = dyn_cast(D))

This will end up being quadratic time and using quadratic storage if a module 
adds N specializations to a template; instead, please move the SmallVector out 
of the loop and call `AddLazySpecializations` once after reading all the update 
records for the declaration. (It's probably best to move it all the way out to 
`loadDeclUpdateRecords`, in case we have a large number of modules each adding 
some specializations -- eg, if module A imports std::vector and declares A, 
module B declares B and uses vector, module C declares C and uses vector, 
..., we again should avoid quadratic behavior.)


https://reviews.llvm.org/D29951



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


r302569 - [WebAssembly] Fix failing wasm-toolchain test

2017-05-09 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Tue May  9 13:44:23 2017
New Revision: 302569

URL: http://llvm.org/viewvc/llvm-project?rev=302569&view=rev
Log:
[WebAssembly] Fix failing wasm-toolchain test

This test was broken in r302558.

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

Modified:
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=302569&r1=302568&r2=302569&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Tue May  9 13:44:23 2017
@@ -27,18 +27,18 @@
 
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "ld" "-L/foo/lib32" "crt1.o" "crti.o" "[[temp]]" 
"-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "wasm" "-L/foo/lib32" "crt1.o" "crti.o" 
"[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // A basic C link command-line with optimization. WebAssembly is somewhat
 // special in enabling --gc-sections by default.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s
 // LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK_OPT: lld{{.*}}" "-flavor" "ld" "--gc-sections" "-L/foo/lib32" "crt1.o" 
"crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
+// LINK_OPT: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // Ditto, but ensure that a user --no-gc-sections comes after the
 // default --gc-sections.
 
 // RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo -Wl,--no-gc-sections %s 2>&1 | FileCheck 
-check-prefix=NO_GC_SECTIONS %s
 // NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "ld" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"
+// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "wasm" "--gc-sections" "-L/foo/lib32" 
"crt1.o" "crti.o" "--no-gc-sections" "[[temp]]" "-lc" "-lcompiler_rt" "crtn.o" 
"-o" "a.out"


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


[PATCH] D32828: [Modules] Fix conservative assertion for import diagnostics

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:4971-4972
   assert(Owner && "definition of hidden declaration is not in a module");
+  assert((!isVisible(Decl) || VisibleModules.isVisible(Owner)) &&
+ "missing import for non-hidden decl?");
 

`Decl` could also now be visible due to its lexically-enclosing context having 
a visible merged definition. I think this assertion should either be removed or 
changed to something like
```
assert(!isVisible(Decl) || );
```


https://reviews.llvm.org/D32828



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


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D32724#749868, @dexonsmith wrote:

> In https://reviews.llvm.org/D32724#747728, @aprantl wrote:
>
> > Is it the right solution to use the module hash for correctness, or should 
> > the mismatch of the serialized langopts trigger a module rebuild and the 
> > module hash is only there to tune the performance/disk size tradeoff?
>
>
> I'm not sure if there is (or should be) a hard-and-fast rule, but certainly 
> in this case changing the hash SGTM.  Otherwise, users toggling back and 
> forth between build configurations would have to rebuild the modules each 
> time.


Great, it looks like changing the module hash is acceptable. However, I'm not 
sure whether it's OK to make sanitizer feature mismatches errors for explicit 
modules. @aprantl suggests checking for language option mismatches early on 
instead of just relying on the module hash, but @rsmith mentioned:

> I would expect this [sanitizer features] to be permitted to differ between an 
> explicit module build and its use. (Ideally we would apply the sanitization 
> settings from the module build to the code generated for its inline functions 
> in that case, but that can wait.)

Should we diagnose sanitizer feature mismatches in ASTReader 
(checkLanguageOptions) as warnings, errors, or not at all?


https://reviews.llvm.org/D32724



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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Sema/Sema.h:1464
 
+  /// Determine if \p D abd \p Suggested have a structurally compatibale
+  /// layout as described in C11 6.2.7/1.

rsmith wrote:
> Typo 'abd'
Typo 'compatibale' =)



Comment at: lib/Parse/ParseDecl.cpp:4307
+Decl *D = SkipBody.CheckSameAsPrevious ? SkipBody.New : TagDecl;
+//ParseEnumBody(StartLoc, D);
+ParseEnumBody(StartLoc, D,

Commented-out code, please remove.



Comment at: lib/Parse/ParseDecl.cpp:4313-4321
+if (SkipBody.CheckSameAsPrevious) {
+  if (!Actions.hasStructuralCompatLayout(TagDecl, SkipBody.New)) {
+// Bail out.
+DS.SetTypeSpecError();
+return;
+  }
+  // Make the previous decl visible.

The parser shouldn't be doing this itself, please move this to a function on 
`Sema` (`ActOnDuplicateDefinition` or something) and call that from here.



Comment at: lib/Sema/SemaExpr.cpp:2198-2209
+  if (R.isAmbiguous()) {
+if (!IgnorePrevDef)
+  return ExprError();
+// We already know that there's a hidden decl included in the lookup,
+// ignore it and only use the first found (the local) one...
+auto RF = R.makeFilter();
+NamedDecl *ND = R.getRepresentativeDecl();

bruno wrote:
> rsmith wrote:
> > This is gross. In order to make this work, you'd need to propagate the 
> > `IgnorePrevDef` flag through the entire expression parsing machinery.
> > 
> > Instead of this, how about deferring making the old definition visible 
> > until after you complete parsing the new one and do the structural 
> > comparison?
> Thanks for pointing it out, I totally missed this approach. Your suggestion 
> works and I'll change the patch accordingly. However, `IgnorePrevDef` still 
> needs to be threaded in `ParseEnumBody` and `ActOnEnumConstant` in order to 
> prevent the latter to emit `err_redefinition_of_enumerator`-like diagnostics.
I think the problem is that we don't take module visibility into account when 
doing redefinition checking for enumerators. Instead of passing through this 
flag, we should probably just ignore hidden declarations when checking for a 
redefinition of an enumerator.


https://reviews.llvm.org/D31778



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


[PATCH] D32724: [Modules] Include the enabled sanitizers in the module hash

2017-05-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D32724#750074, @vsk wrote:

> In https://reviews.llvm.org/D32724#749868, @dexonsmith wrote:
>
> > In https://reviews.llvm.org/D32724#747728, @aprantl wrote:
> >
> > > Is it the right solution to use the module hash for correctness, or 
> > > should the mismatch of the serialized langopts trigger a module rebuild 
> > > and the module hash is only there to tune the performance/disk size 
> > > tradeoff?
> >
> >
> > I'm not sure if there is (or should be) a hard-and-fast rule, but certainly 
> > in this case changing the hash SGTM.  Otherwise, users toggling back and 
> > forth between build configurations would have to rebuild the modules each 
> > time.
>
>
> Great, it looks like changing the module hash is acceptable. However, I'm not 
> sure whether it's OK to make sanitizer feature mismatches errors for explicit 
> modules. @aprantl suggests checking for language option mismatches early on 
> instead of just relying on the module hash, but @rsmith mentioned:
>
> > I would expect this [sanitizer features] to be permitted to differ between 
> > an explicit module build and its use. (Ideally we would apply the 
> > sanitization settings from the module build to the code generated for its 
> > inline functions in that case, but that can wait.)


Ah, interesting.  That does seem ideal.

> Should we diagnose sanitizer feature mismatches in ASTReader 
> (checkLanguageOptions) as warnings, errors, or not at all?

Either warning or error seems fine with me; only compiler engineers are going 
to see this anyway (because implicit users are protected by the hash).  As long 
as it's overridable... there's a -cc1 flag to allow configuration mismatches, 
right?

Once the flag can be changed after the fact (i.e., in a post-Richard's-plan 
world), we should remove the error/warning, and possibly do something like: 
always build the module without sanitizers.


https://reviews.llvm.org/D32724



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


[PATCH] D32550: Supress all uses of LLVM_END_WITH_NULL

2017-05-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302572: Suppress all uses of LLVM_END_WITH_NULL. NFC. 
(authored by serge_sans_paille).

Changed prior to commit:
  https://reviews.llvm.org/D32550?vs=96798&id=98339#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32550

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCUDANV.cpp
  cfe/trunk/lib/CodeGen/CGCleanup.cpp
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Index: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
@@ -490,7 +490,7 @@
 llvm_unreachable("Unexpected undeduced type!");
   case Type::Complex: {
 llvm::Type *EltTy = ConvertType(cast(Ty)->getElementType());
-ResultType = llvm::StructType::get(EltTy, EltTy, nullptr);
+ResultType = llvm::StructType::get(EltTy, EltTy);
 break;
   }
   case Type::LValueReference:
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -2859,9 +2859,9 @@
   EmitTrapCheck(DataIsNotNullPtr);
 
   llvm::StructType *SourceLocationTy =
-  llvm::StructType::get(VoidPtrTy, Int32Ty, Int32Ty, nullptr);
+  llvm::StructType::get(VoidPtrTy, Int32Ty, Int32Ty);
   llvm::StructType *CfiCheckFailDataTy =
-  llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy, nullptr);
+  llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy);
 
   llvm::Value *V = Builder.CreateConstGEP2_32(
   CfiCheckFailDataTy,
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -4571,7 +4571,7 @@
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
@@ -7373,8 +7373,8 @@
 // unsigned int __cpu_type;
 // unsigned int __cpu_subtype;
 // unsigned int __cpu_features[1];
-llvm::Type *STy = llvm::StructType::get(
-Int32Ty, Int32Ty, Int32Ty, llvm::ArrayType::get(Int32Ty, 1), nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty,
+llvm::ArrayType::get(Int32Ty, 1));
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -1361,9 +1361,8 @@
 Value.getComplexIntImag());
 
 // FIXME: the target may want to specify that this is packed.
-llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
-  Complex[1]->getType(),
-  nullptr);
+llvm::StructType *STy =
+llvm::StructType::get(Complex[0]->getType(), Complex[1]->getType());
 return llvm::ConstantStruct::get(STy, Complex);
   }
   case APValue::Float: {
@@ -1384,9 +1383,8 @@
Value.getComplexFloatImag());
 
 // FIXME: the target may want to specify that this is packed.
-llvm::StructType *STy = llvm:

r302572 - Suppress all uses of LLVM_END_WITH_NULL. NFC.

2017-05-09 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue May  9 14:31:30 2017
New Revision: 302572

URL: http://llvm.org/viewvc/llvm-project?rev=302572&view=rev
Log:
Suppress all uses of LLVM_END_WITH_NULL. NFC.

Use variadic templates instead of relying on  + sentinel.

This enforces better type checking and makes code more readable.

Differential revision: https://reviews.llvm.org/D32550

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=302572&r1=302571&r2=302572&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May  9 14:31:30 2017
@@ -961,9 +961,8 @@ llvm::Type *CodeGenModule::getBlockDescr
   //   const char *signature;   // the block signature
   //   const char *layout;  // reserved
   // };
-  BlockDescriptorType =
-llvm::StructType::create("struct.__block_descriptor",
- UnsignedLongTy, UnsignedLongTy, nullptr);
+  BlockDescriptorType = llvm::StructType::create(
+  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
 
   // Now form a pointer to that.
   unsigned AddrSpace = 0;
@@ -987,9 +986,8 @@ llvm::Type *CodeGenModule::getGenericBlo
   //   struct __block_descriptor *__descriptor;
   // };
   GenericBlockLiteralType =
-llvm::StructType::create("struct.__block_literal_generic",
- VoidPtrTy, IntTy, IntTy, VoidPtrTy,
- BlockDescPtrTy, nullptr);
+  llvm::StructType::create("struct.__block_literal_generic", VoidPtrTy,
+   IntTy, IntTy, VoidPtrTy, BlockDescPtrTy);
 
   return GenericBlockLiteralType;
 }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302572&r1=302571&r2=302572&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May  9 14:31:30 2017
@@ -4571,7 +4571,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@ Value *CodeGenFunction::EmitAArch64Built
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
@@ -7373,8 +7373,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 // unsigned int __cpu_type;
 // unsigned int __cpu_subtype;
 // unsigned int __cpu_features[1];
-llvm::Type *STy = llvm::StructType::get(
-Int32Ty, Int32Ty, Int32Ty, llvm::ArrayType::get(Int32Ty, 1), nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty,
+llvm::ArrayType::get(Int32Ty, 1));
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=302572&r1=302571&r2=302572&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Tue May  9 14:31:30 2017
@@ -265,7 +265,7 @@ llvm::Func

[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Please first check in a change that just regenerates cxx_dr_status without your 
changes, to separate out the changes due to the new issues list from the 
changes due to this patch. (You can go ahead and do that with no review.)


https://reviews.llvm.org/D32984



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


r302577 - Update testcase for upstream LLVM changes (r302469).

2017-05-09 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue May  9 14:47:41 2017
New Revision: 302577

URL: http://llvm.org/viewvc/llvm-project?rev=302577&view=rev
Log:
Update testcase for upstream LLVM changes (r302469).

Modified:
cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp

Modified: cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp?rev=302577&r1=302576&r2=302577&view=diff
==
--- cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-virtual-variadic.cpp Tue May  9 
14:47:41 2017
@@ -12,8 +12,10 @@ void Derived::VariadicFunction(...) { }
 
 // CHECK: define void @_ZN7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP:[0-9]+]]
 // CHECK: ret void, !dbg ![[LOC:[0-9]+]]
-// CHECK-LABEL: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz(
-// CHECK: ret void, !dbg ![[LOC:[0-9]+]]
+// CHECK: define void @_ZT{{.+}}N7Derived16VariadicFunctionEz({{.*}} !dbg 
![[SP_I:[0-9]+]]
+// CHECK: ret void, !dbg ![[LOC_I:[0-9]+]]
 //
 // CHECK: ![[SP]] = distinct !DISubprogram(name: "VariadicFunction"
 // CHECK: ![[LOC]] = !DILocation({{.*}}scope: ![[SP]])
+// CHECK: ![[SP_I]] = distinct !DISubprogram(name: "VariadicFunction"
+// CHECK: ![[LOC_I]] = !DILocation({{.*}}scope: ![[SP_I]])


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


[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98343.
vsk retitled this revision from "[Modules] Include the enabled sanitizers in 
the module hash" to "[Modules] Handle sanitizer feature mismatches when 
importing modules".
vsk edited the summary of this revision.
vsk added a comment.

If compatible differences between a CU's lang opts and an imported module's 
lang opts are not allowed, issue an error when there is a mismatch in the set 
of enabled, non-modular sanitizers.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,29 @@
 return true;
   }
 
+  SanitizerMask ModularSanitizers = getModularSanitizers();
+  SanitizerSet ExistingSanitizers = ExistingLangOpts.Sanitize;
+  SanitizerSet ImportedSanitizers = LangOpts.Sanitize;
+  ExistingSanitizers.clear(ModularSanitizers);
+  ImportedSanit

[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-05-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

Anastasia wrote:
> Looks good from my side.
> 
> @yaxunl , since you originally committed this. Could you please verify that 
> changing from `SIZE_MAX` to `0` would be fine.
> 
> Btw, we have a similar definition for `CLK_NULL_EVENT`.
`__PIPE_RESERVE_ID_VALID_BIT` is implementation detail and not part of the 
spec. I would suggest to remove it from this header file.

The spec only requires CLK_NULL_RESERVE_ID to be defined but does not define 
its value. Naturally a valid id starts from 0 and increases. I don't see 
significant advantage to change CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.

Is there any reason that this change is needed?


https://reviews.llvm.org/D32896



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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst accepted this revision.
mprobst added inline comments.
This revision is now accepted and ready to land.



Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"

danbeam wrote:
> mprobst wrote:
> > consider adding a test with comments between the tokens (which should work 
> > with `startsSequence`).
> not done yet, but seems uncommon.
> 
> do you want me to add a FIXME?
I think that's OK the way it is.


https://reviews.llvm.org/D32989



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-05-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D29654



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


r302580 - clang-format: [JS] Don't indent JavaScript IIFEs.

2017-05-09 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue May  9 15:04:09 2017
New Revision: 302580

URL: http://llvm.org/viewvc/llvm-project?rev=302580&view=rev
Log:
clang-format: [JS] Don't indent JavaScript IIFEs.

Because IIFEs[1] are often used like an anonymous namespace around large
sections of JavaScript code, it's useful not to indent to them (which
effectively reduces the column limit by the indent amount needlessly).

It's also common for developers to wrap these around entire files or
libraries. When adopting clang-format, changing the indent entire file
can reduce the usefulness of the blame annotations.

Patch by danbeam, thanks!

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

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=302580&r1=302579&r2=302580&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue May  9 15:04:09 2017
@@ -476,6 +476,24 @@ static bool isGoogScope(const UnwrappedL
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine &Line,
+   const AdditionalKeywords &Keywords) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@ void UnwrappedLineParser::parseChildBloc
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302580&r1=302579&r2=302580&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue May  9 15:04:09 2017
@@ -367,6 +367,25 @@ TEST_F(FormatTestJS, GoogScopes) {
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));


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


[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302580: clang-format: [JS] Don't indent JavaScript IIFEs. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32989?vs=98332&id=98344#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32989

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine &Line,
+   const AdditionalKeywords &Keywords) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*FormatTok));
-Line->Level -= GoogScope ? 0 : 1;
+Line->Level -= SkipIndent ? 0 : 1;
   }
   nextToken();
 }
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -367,6 +367,25 @@
"});");
 }
 
+TEST_F(FormatTestJS, IIFEs) {
+  // Internal calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var a = 1;\n"
+   "}())");
+  // External calling parens; no semi.
+  verifyFormat("(function() {\n"
+   "var b = 2;\n"
+   "})()");
+  // Internal calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var c = 3;\n"
+   "}());");
+  // External calling parens; with semi.
+  verifyFormat("(function() {\n"
+   "var d = 4;\n"
+   "})();");
+}
+
 TEST_F(FormatTestJS, GoogModules) {
   verifyFormat("goog.module('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -476,6 +476,24 @@
   return I->Tok->is(tok::l_paren);
 }
 
+static bool isIIFE(const UnwrappedLine &Line,
+   const AdditionalKeywords &Keywords) {
+  // Look for the start of an immediately invoked anonymous function.
+  // https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
+  // This is commonly done in JavaScript to create a new, anonymous scope.
+  // Example: (function() { ... })()
+  if (Line.Tokens.size() < 3)
+return false;
+  auto I = Line.Tokens.begin();
+  if (I->Tok->isNot(tok::l_paren))
+return false;
+  ++I;
+  if (I->Tok->isNot(Keywords.kw_function))
+return false;
+  ++I;
+  return I->Tok->is(tok::l_paren);
+}
+
 static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) {
   if (InitialToken.is(tok::kw_namespace))
@@ -493,15 +511,16 @@
   FormatTok->BlockKind = BK_Block;
   nextToken();
   {
-bool GoogScope =
-Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line);
+bool SkipIndent =
+(Style.Language == FormatStyle::LK_JavaScript &&
+ (isGoogScope(*Line) || isIIFE(*Line, Keywords)));
 ScopedLineState LineState(*this);
 ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack,
 /*MustBeDeclaration=*/false);
-Line->Level += GoogScope ? 0 : 1;
+Line->Level += SkipIndent ? 0 : 1;
 parseLevel(/*HasOpeningBrace=*/true);
 flushComments(isOnNewLine(*For

[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

2017-05-09 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/D32743



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


[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98349.
vsk marked 7 inline comments as done.
vsk added a comment.

Add a comment explaining how and why ASTReader checks for sanitizer feature 
mismatches.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,33 @@
 return true;
   }
 
+  // Sanitizer feature mismatches are treated as compatible differences. If
+  // compatible differences aren't allowed, we still only want to check for
+  // mismatches of non-modular sanitizers (the only ones which can affect AST
+  // generation).
+  if (!AllowCompatibleDifferences) {
+SanitizerMask ModularSanitizers = getModularSanitizers();
+SanitizerSet E

Re: [PATCH] D24933: Enable configuration files in clang

2017-05-09 Thread Richard Smith via cfe-commits
On 1 March 2017 at 02:50, Serge Pavlov via Phabricator <
revi...@reviews.llvm.org> wrote:

> sepavloff added a comment.
>
> Glad to know that someone is interested in this feature!
> Below is actual proposal.
>
> **Adding named configuration files to clang driver**
>
> A configuration file is a collection of driver options, which are inserted
> into command line before other options specified in the clang invocation.
> It groups related options together and allows specifying them in simpler,
> more flexible and less error prone way than just listing the options
> somewhere in build scripts. Configuration file may be thought as a "macro"
> that names an option set and is expanded when the driver is called.  This
> feature must be helpful when a user need to specify many options, cross
> compilation is likely to be such case.
>
> Configuration file can be specified by either of two methods:
>
> - by command line option `--config `, or
> - by using special executable file names, such as `armv7l-clang`.
>
> If the option `--config` is used, its argument is treated as a path to
> configuration file if it contains a directory separator, otherwise the file
> is searched for in the set of directories described below. If option
> `--config` is absent and clang executable has name in the form
> `armv7l-clang`, driver will search for file `armv7l.cfg` in the same set of
> directories. Similar encoding is already used by clang to specify target.
>
> The set of directories where configuration files are searched for consists
> of at most three directories, checked in this order:
>
> - user directory (like `~/.llvm`),
> - system directory (like `/etc/llvm`),
> - the directory where clang executable resides.
>
> User and system directories are optional, they are reserved for
> distribution or SDK suppliers. By default they are absent, corresponding
> directories can be specified by cmake arguments
> `CLANG_CONFIG_FILE_SYSTEM_DIR` and `CLANG_CONFIG_FILE_USER_DIR`. The first
> found file is used.
>
> Format of configuration file is similar to file used in the construct
> `@file`, it is a set of options. Configuration file have advantage over
> this construct:
>
> - it is searched for in well-known places rather than in current directory,
>

This (and suppressing unused-argument warnings) might well be sufficient to
justify a different command-line syntax rather than @file...


> - it may contain comments, long options may be split between lines using
> trailing backslashes,
> - other files may be included by `@file` and they will be resolved
> relative to the including file,
>

... but I think we should just add these extensions to our @file handling,
and then use the exact same syntax and code to handle config files and
@file files. That is, the difference between @ and --config would be that
the latter looks in a different directory and suppresses "unused argument"
warnings, but they would otherwise be identical.

- the file may be encoded in executable name,
> - unused options from configuration file do not produce warnings.
>
>
> https://reviews.llvm.org/D24933
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302588 - Fix CGObjCGNU::init bug introduced by r302572

2017-05-09 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue May  9 16:19:44 2017
New Revision: 302588

URL: http://llvm.org/viewvc/llvm-project?rev=302588&view=rev
Log:
Fix CGObjCGNU::init bug introduced by r302572

Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=302588&r1=302587&r2=302588&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue May  9 16:19:44 2017
@@ -63,8 +63,13 @@ public:
 CGM = Mod;
 FunctionName = name;
 Function = nullptr;
-std::vector ArgTys{{Types...}};
-FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
+if(sizeof...(Tys)) {
+  SmallVector ArgTys({Types...});
+  FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
+}
+else {
+  FTy = llvm::FunctionType::get(RetTy, None, false);
+}
   }
 
   llvm::FunctionType *getType() { return FTy; }


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


[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Thank you, some of these test typos are ... alarming. =)

A couple of the test updates don't look quite right, but this mostly looks 
great.




Comment at: test/Driver/amdgpu-features.c:1
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=0.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s

This should say `-o -`



Comment at: test/Driver/amdgpu-features.c:5
 
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s

Likewise.



Comment at: test/Driver/split-debug.h:6-13
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-emit-module -fno-implicit-modules -fno-implicit-module-maps -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
 //
 // FIXME: This should fail using clang, except that the type of the output for
 // an object output with modules is given as clang::driver::types::TY_PCH
 // rather than TY_Object.
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-### %s 2> %t

These parts of the test don't make sense: the `-fmodule-format=obj` and 
`-emit-module` are `-cc1` options, so testing how the driver deals with them 
doesn't really make a lot of sense. I would suggest deleting the highlighted 
region of this test rather than making it test the same thing three times.


https://reviews.llvm.org/D33013



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


[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 98354.
eugenis marked an inline comment as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D32886

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/asan-globals-gc.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -126,6 +126,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
+// CHECK-NO-ASAN-GLOBALS-NOT: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
 
Index: test/CodeGen/asan-globals-gc.cpp
===
--- test/CodeGen/asan-globals-gc.cpp
+++ test/CodeGen/asan-globals-gc.cpp
@@ -1,5 +1,16 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-data-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-data-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITHOUT-GC
 
 int global;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -778,6 +778,8 @@
 Opts.SanitizeAddressUseAfterScope =
 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
   }
+  Opts.SanitizeAddressGlobalsDeadStripping =
+  Args.hasArg(OPT_fsanitize_address_globals_dead_stripping);
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -566,6 +566,13 @@
 AsanUseAft

[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

I'll fix the other unnecessary MakeArgString calls in a separate commit


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


[PATCH] D16171: Warning on redeclaring with a conflicting asm label

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Er, please ignore the inline review comments; those predated the realisation 
that this doesn't actually fix the glibc build problem.


https://reviews.llvm.org/D16171



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


[PATCH] D16171: Warning on redeclaring with a conflicting asm label

2017-05-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

In https://reviews.llvm.org/D16171#540261, @phabricss wrote:

>   ../include/sys/stat.h:16:15: error: cannot apply asm label to function 
> after its first use
>   hidden_proto (__fxstat)
>   ~~^
>   ./../include/libc-symbols.h:420:19: note: expanded from macro 'hidden_proto'
> __hidden_proto (name, , __GI_##name, ##attrs)
> ^
>   ./../include/libc-symbols.h:424:33: note: expanded from macro 
> '__hidden_proto'
> extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) 
> \
>


This patch does nothing about that error. This patch is dealing with a case 
where two distinct asm labels are provided for the same declaration, which 
would simply be a bug in the code. Given that we are not seeing that error any 
more, and that nicholas suggests that the reason is that the glibc maintainers 
applied a patch to fix it, this change seems unnecessary and deleterious.

As for the above change, we could theoretically accept such shenanigans, but it 
would require a much more invasive approach than the one in this patch -- in 
particular, it would require rewriting any code we've already emitted using the 
old name, changing it to use the new name instead. And even then, that is 
fundamentally not possible for some use cases of Clang (where we might have 
already, say, created machine code and started running it, possibly on a 
different machine, before we reach this asm label).

I would strongly suggest pushing back hard on the glibc maintainers and 
suggesting they don't rely on this working.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4275-4276
   "use of %0 with tag type that does not match previous declaration">;
+def warn_different_asm_label : Warning<"conflicting asm label">,
+InGroup;
 def warn_struct_class_tag_mismatch : Warning<

Move this earlier so that it's adjacent to the error form.

Please also use a different diagnostic group. This makes no sense in 
`-Wmismatched-tags`. Please also make this `DefaultError`; allowing it to be 
turned off might be OK, but this code pattern is still horribly broken, and we 
should not accept it by default.



Comment at: lib/Sema/SemaDecl.cpp:2388
 // This redeclaration changes __asm__ label.
-Diag(New->getLocation(), diag::err_different_asm_label);
+if (New->isUsed())
+  Diag(New->getLocation(), diag::err_different_asm_label);

This looks wrong. How could `New` already be used here, since it's new? Should 
this say `Old` instead?

Please also make sure we have test coverage for this. None of the tests below 
use the declaration before adding the conflicting label.


https://reviews.llvm.org/D16171



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


r302590 - Remove unnecessary calls to MakeArgString.

2017-05-09 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue May  9 16:57:39 2017
New Revision: 302590

URL: http://llvm.org/viewvc/llvm-project?rev=302590&view=rev
Log:
Remove unnecessary calls to MakeArgString.

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=302590&r1=302589&r2=302590&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue May  9 16:57:39 2017
@@ -633,7 +633,7 @@ void SanitizerArgs::addArgs(const ToolCh
 std::make_pair(CoverageNoPrune, "-fsanitize-coverage-no-prune")};
   for (auto F : CoverageFlags) {
 if (CoverageFeatures & F.first)
-  CmdArgs.push_back(Args.MakeArgString(F.second));
+  CmdArgs.push_back(F.second);
   }
 
   if (TC.getTriple().isOSWindows() && needsUbsanRt()) {
@@ -686,7 +686,7 @@ void SanitizerArgs::addArgs(const ToolCh
  llvm::utostr(MsanTrackOrigins)));
 
   if (MsanUseAfterDtor)
-CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-use-after-dtor"));
+CmdArgs.push_back("-fsanitize-memory-use-after-dtor");
 
   // FIXME: Pass these parameters as function attributes, not as -llvm flags.
   if (!TsanMemoryAccess) {
@@ -705,17 +705,17 @@ void SanitizerArgs::addArgs(const ToolCh
   }
 
   if (CfiCrossDso)
-CmdArgs.push_back(Args.MakeArgString("-fsanitize-cfi-cross-dso"));
+CmdArgs.push_back("-fsanitize-cfi-cross-dso");
 
   if (Stats)
-CmdArgs.push_back(Args.MakeArgString("-fsanitize-stats"));
+CmdArgs.push_back("-fsanitize-stats");
 
   if (AsanFieldPadding)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-field-padding=" +
  llvm::utostr(AsanFieldPadding)));
 
   if (AsanUseAfterScope)
-
CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-use-after-scope"));
+CmdArgs.push_back("-fsanitize-address-use-after-scope");
 
   // MSan: Workaround for PR16386.
   // ASan: This is mainly to help LSan with cases such as
@@ -723,7 +723,7 @@ void SanitizerArgs::addArgs(const ToolCh
   // We can't make this conditional on -fsanitize=leak, as that flag shouldn't
   // affect compilation.
   if (Sanitizers.has(Memory) || Sanitizers.has(Address))
-CmdArgs.push_back(Args.MakeArgString("-fno-assume-sane-operator-new"));
+CmdArgs.push_back("-fno-assume-sane-operator-new");
 
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   // enabled.

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=302590&r1=302589&r2=302590&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Tue May  9 16:57:39 2017
@@ -282,18 +282,18 @@ void mips::getMIPSTargetFeatures(const D
   if (Arg *A = Args.getLastArg(options::OPT_mfp32, options::OPT_mfpxx,
options::OPT_mfp64)) {
 if (A->getOption().matches(options::OPT_mfp32))
-  Features.push_back(Args.MakeArgString("-fp64"));
+  Features.push_back("-fp64");
 else if (A->getOption().matches(options::OPT_mfpxx)) {
-  Features.push_back(Args.MakeArgString("+fpxx"));
-  Features.push_back(Args.MakeArgString("+nooddspreg"));
+  Features.push_back("+fpxx");
+  Features.push_back("+nooddspreg");
 } else
-  Features.push_back(Args.MakeArgString("+fp64"));
+  Features.push_back("+fp64");
   } else if (mips::shouldUseFPXX(Args, Triple, CPUName, ABIName, FloatABI)) {
-Features.push_back(Args.MakeArgString("+fpxx"));
-Features.push_back(Args.MakeArgString("+nooddspreg"));
+Features.push_back("+fpxx");
+Features.push_back("+nooddspreg");
   } else if (mips::isFP64ADefault(Triple, CPUName)) {
-Features.push_back(Args.MakeArgString("+fp64"));
-Features.push_back(Args.MakeArgString("+nooddspreg"));
+Features.push_back("+fp64");
+Features.push_back("+nooddspreg");
   }
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,


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


r302591 - [asan] A clang flag to enable ELF globals-gc.

2017-05-09 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue May  9 16:57:43 2017
New Revision: 302591

URL: http://llvm.org/viewvc/llvm-project?rev=302591&view=rev
Log:
[asan] A clang flag to enable ELF globals-gc.

This feature is subtly broken when the linker is gold 2.26 or
earlier. See the following bug for details:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

Since the decision needs to be made at compilation time, we can not
test the linker version. The flag is off by default on ELF targets,
and on otherwise.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/asan-globals-gc.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=302591&r1=302590&r2=302591&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May  9 16:57:43 2017
@@ -827,6 +827,9 @@ def fno_sanitize_address_use_after_scope
Group,
Flags<[CoreOption, DriverOption]>,
HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
+def fsanitize_address_globals_dead_stripping : Flag<["-"], 
"fsanitize-address-globals-dead-stripping">,
+Group,
+HelpText<"Enable linker dead stripping 
of globals in AddressSanitizer">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
Flags<[CoreOption, DriverOption]>,

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=302591&r1=302590&r2=302591&view=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Tue May  9 16:57:43 2017
@@ -35,6 +35,7 @@ class SanitizerArgs {
   int AsanFieldPadding = 0;
   bool AsanSharedRuntime = false;
   bool AsanUseAfterScope = true;
+  bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
   bool Stats = false;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=302591&r1=302590&r2=302591&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue May  9 16:57:43 2017
@@ -137,6 +137,8 @@ CODEGENOPT(StructPathTBAA, 1, 0) ///
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope 
detection
 ///< in AddressSanitizer
+CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead 
stripping
+  ///< of globals in 
AddressSanitizer
 CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
  ///< MemorySanitizer
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=302591&r1=302590&r2=302591&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue May  9 16:57:43 2017
@@ -194,6 +194,8 @@ static void addSanitizerCoveragePass(con
 // where this is not a factor). Also, on ELF this feature requires an assembler
 // extension that only works with -integrated-as at the moment.
 static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
+  if (!CGOpts.SanitizeAddressGlobalsDeadStripping)
+return false;
   switch (T.getObjectFormat()) {
   case Triple::MachO:
   case Triple::COFF:

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=302591&r1=302590&r2=302591&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Tue May  9 16:57:43

[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r302591, thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


[PATCH] D32977: [OpenCL] Emit function-scope variable in constant address space as static variable

2017-05-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:7129
+NewVD->getType().getAddressSpace() != LangAS::opencl_constant) ||
 NewVD->hasExternalStorage()) {
   if (!T->isSamplerT() &&

Seeing criteria like this, and a lot of the other things you've modified, makes 
me feel like we should just have a VarDecl::getStorageDuration().



Comment at: lib/Sema/SemaDecl.cpp:10286
+  // these variables must be a compile time constant.
+  VDecl->getType().getAddressSpace() == LangAS::opencl_constant)
 CheckForConstantInitializer(Init, DclT);

Should this rule apply even in C++ mode?  I can't remember if there are any 
OpenCL/C++ hybrids.


https://reviews.llvm.org/D32977



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


r302592 - Update Clang C++ DR documentation for new issue list

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 17:17:23 2017
New Revision: 302592

URL: http://llvm.org/viewvc/llvm-project?rev=302592&view=rev
Log:
Update Clang C++ DR documentation for new issue list

Modified:
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=302592&r1=302591&r2=302592&view=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Tue May  9 17:17:23 2017
@@ -589,7 +589,7 @@
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#92";>92
-WP
+CD4
 Should exception-specifications be part of the type system?
 Clang 4 (C++17 onwards)
   
@@ -935,11 +935,11 @@
 Accessibility and ambiguity
 N/A
   
-  
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#150";>150
-open
+  
+http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#150";>150
+DR
 Template template parameters and default arguments
-Not resolved
+Unknown
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#151";>151
@@ -1310,7 +1310,7 @@ accessible?
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#212";>212
-DR
+CD4
 Implicit instantiation is not described clearly enough
 Unknown
   
@@ -1466,7 +1466,7 @@ accessible?
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#238";>238
-DR
+CD4
 Precision and accuracy constraints on floating point
 Unknown
   
@@ -1490,7 +1490,7 @@ accessible?
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#242";>242
-DR
+CD4
 Interpretation of old-style casts
 Unknown
   
@@ -2019,7 +2019,7 @@ of class templates
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#330";>330
-DRWP
+CD4
 Qualification conversions and pointers to arrays of pointers
 Unknown
   
@@ -2397,7 +2397,7 @@ of class templates
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#393";>393
-DRWP
+CD4
 Pointer to array of unknown bound in template argument list in 
parameter
 Unknown
   
@@ -3587,7 +3587,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#591";>591
-DRWP
+CD4
 When a dependent base class is the current instantiation
 No
   
@@ -3695,7 +3695,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#609";>609
-DRWP
+CD4
 What is a “top-level” cv-qualifier?
 Unknown
   
@@ -5735,7 +5735,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#987";>987
-DRWP
+CD4
 Which declarations introduce namespace members?
 Unknown
   
@@ -5939,7 +5939,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1021";>1021
-DRWP
+CD4
 Definitions of namespace members
 Unknown
   
@@ -6509,7 +6509,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1116";>1116
-DRWP
+CD4
 Aliasing of union members
 Unknown
   
@@ -7295,7 +7295,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1247";>1247
-DRWP
+CD4
 Restriction on alias name appearing in type-id
 Unknown
   
@@ -7457,7 +7457,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1274";>1274
-DRWP
+CD4
 Common nonterminal for expression and 
braced-init-list
 Unknown
   
@@ -7517,7 +7517,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1284";>1284
-DR
+CD4
 Should the lifetime of an array be independent of that of its 
elements?
 Unknown
   
@@ -7565,7 +7565,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1292";>1292
-DRWP
+CD4
 Dependent calls with braced-init-lists containing a pack 
expansion
 Unknown
   
@@ -7667,7 +7667,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1309";>1309
-DRWP
+CD4
 Incorrect note regarding lookup of a member of the current 
instantiation
 Unknown
   
@@ -7703,7 +7703,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1315";>1315
-DR
+CD4
 Restrictions on non-type template arguments in partial 
specializations
 Partial
   
@@ -7841,7 +7841,7 @@ and POD class
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1338";>1338
-DRWP
+CD4
 Aliasing and allocation functions
 Unknown
   
@@ -7870,8 +7870,8 @@ and POD class
 Not resolved
   
   
-http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1343";>134

[PATCH] D32984: [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-09 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 98359.
EricWF added a comment.

- Remove unrelated issues list changes.


https://reviews.llvm.org/D32984

Files:
  lib/AST/Type.cpp
  test/CXX/drs/dr20xx.cpp
  test/CXX/drs/dr4xx.cpp
  test/SemaCXX/type-traits.cpp
  www/cxx_dr_status.html

Index: www/cxx_dr_status.html
===
--- www/cxx_dr_status.html
+++ www/cxx_dr_status.html
@@ -3017,7 +3017,7 @@
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496";>496
 CD3
 Is a volatile-qualified type really a POD?
-No
+Superseded by dr2094
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497";>497
@@ -12379,7 +12379,7 @@
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094";>2094
 DR
 Trivial copy/move constructor for class with volatile member
-Unknown
+Clang 5.0
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2095";>2095
Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1256,7 +1256,7 @@
   int t33[F(__is_trivially_copyable(ExtDefaulted))];
 
   int t34[T(__is_trivially_copyable(const int))];
-  int t35[F(__is_trivially_copyable(volatile int))];
+  int t35[T(__is_trivially_copyable(volatile int))];
 }
 
 struct CStruct {
Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -1202,16 +1202,15 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2094
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // This checks the dr2094 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 
Index: test/CXX/drs/dr20xx.cpp
===
--- /dev/null
+++ test/CXX/drs/dr20xx.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:-Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2114,18 +2114,15 @@
   if (hasNonTrivialObjCLifetime())
 return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
 return false;
 
-  if (CanonicalType.isVolatileQualified())
-return false;
-
   // Return false for incomplete types after skipping any incomplete array types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r302593 - [Sema] Implement Core 2094: Trivial copy/move constructor for class with volatile member

2017-05-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  9 17:21:24 2017
New Revision: 302593

URL: http://llvm.org/viewvc/llvm-project?rev=302593&view=rev
Log:
[Sema] Implement Core 2094: Trivial copy/move constructor for class with 
volatile member

Summary: This patch implements 
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094 which reverts 
Core 496.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CXX/drs/dr20xx.cpp
Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=302593&r1=302592&r2=302593&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue May  9 17:21:24 2017
@@ -2114,18 +2114,15 @@ bool QualType::isTriviallyCopyableType(c
   if (hasNonTrivialObjCLifetime())
 return false;
 
-  // C++11 [basic.types]p9
+  // C++11 [basic.types]p9 - See Core 2094
   //   Scalar types, trivially copyable class types, arrays of such types, and
-  //   non-volatile const-qualified versions of these types are collectively
+  //   cv-qualified versions of these types are collectively
   //   called trivially copyable types.
 
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isDependentType())
 return false;
 
-  if (CanonicalType.isVolatileQualified())
-return false;
-
   // Return false for incomplete types after skipping any incomplete array 
types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())

Added: cfe/trunk/test/CXX/drs/dr20xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr20xx.cpp?rev=302593&view=auto
==
--- cfe/trunk/test/CXX/drs/dr20xx.cpp (added)
+++ cfe/trunk/test/CXX/drs/dr20xx.cpp Tue May  9 17:21:24 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors \
+// RUN:-Wno-variadic-macros -Wno-c11-extensions
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+
+// expected-no-diagnostics
+
+#if __cplusplus < 201103L
+#define static_assert(...) _Static_assert(__VA_ARGS__)
+#endif
+
+namespace dr2094 { // dr2094: 5.0
+  struct A { int n; };
+  struct B { volatile int n; };
+  static_assert(__is_trivially_copyable(volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int), "");
+  static_assert(__is_trivially_copyable(const volatile int[]), "");
+  static_assert(__is_trivially_copyable(A), "");
+  static_assert(__is_trivially_copyable(volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A), "");
+  static_assert(__is_trivially_copyable(const volatile A[]), "");
+  static_assert(__is_trivially_copyable(B), "");
+
+  static_assert(__is_trivially_constructible(A, A const&), "");
+  static_assert(__is_trivially_constructible(B, B const&), "");
+
+  static_assert(__is_trivially_assignable(A, const A&), "");
+  static_assert(__is_trivially_assignable(B, const B&), "");
+}

Modified: cfe/trunk/test/CXX/drs/dr4xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr4xx.cpp?rev=302593&r1=302592&r2=302593&view=diff
==
--- cfe/trunk/test/CXX/drs/dr4xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr4xx.cpp Tue May  9 17:21:24 2017
@@ -1202,16 +1202,15 @@ namespace dr495 { // dr495: 3.5
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: no
+namespace dr496 { // dr496: sup dr2094
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
-  int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
+  // This checks the dr2094 behavior, not dr496
+  int check2[ __is_trivially_copyable(volatile int) ? 1 : -1];
   int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
   int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
-  // FIXME: This is wrong.
   int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
 }
 

Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=302593&r1=302592&r2=302593&view=diff
=

r302594 - Fix clang_cl argument in fsanitize.c driver test.

2017-05-09 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue May  9 17:28:57 2017
New Revision: 302594

URL: http://llvm.org/viewvc/llvm-project?rev=302594&view=rev
Log:
Fix clang_cl argument in fsanitize.c driver test.

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

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=302594&r1=302593&r2=302594&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue May  9 17:28:57 2017
@@ -128,8 +128,8 @@
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
-// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
-// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address 
-fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address -### -- %s 
2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
 // CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-dead-stripping
 // CHECK-NO-ASAN-GLOBALS-NOT: 
-cc1{{.*}}-fsanitize-address-globals-dead-stripping
 


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


[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-05-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 98363.
vsk added a comment.

I've uploaded the correct diff this time, sorry for the confusion.


https://reviews.llvm.org/D32724

Files:
  include/clang/Basic/Sanitizers.h
  lib/Basic/LangOptions.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  test/Modules/Inputs/check-for-sanitizer-feature/check.h
  test/Modules/Inputs/check-for-sanitizer-feature/map
  test/Modules/check-for-sanitizer-feature.cpp

Index: test/Modules/check-for-sanitizer-feature.cpp
===
--- /dev/null
+++ test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: test/Modules/Inputs/check-for-sanitizer-feature/map
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/map
@@ -0,0 +1,3 @@
+module check_feature {
+  header "check.h"
+}
Index: test/Modules/Inputs/check-for-sanitizer-feature/check.h
===
--- /dev/null
+++ test/Modules/Inputs/check-for-sanitizer-feature/check.h
@@ -0,0 +1,5 @@
+#if __has_feature(address_sanitizer)
+#define HAS_ASAN 1
+#else
+#define HAS_ASAN 0
+#endif
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -292,6 +292,33 @@
 return true;
   }
 
+  // Sanitizer feature mismatches are treated as compatible differences. If
+  // compatible differences aren't allowed, we still only want to check for
+  // mismatches of non-modular sanitizers (the only ones which can affect AST
+  // generation).
+  if (!AllowCompatibleDifferences) {
+SanitizerMask ModularSanitizers = getModularSanitizers();
+SanitizerSet ExistingSanitizers = ExistingLangOpts.Sanitize;
+SanitizerSet ImportedSanitizers = LangOpts.Sanitize;
+ExistingSanitizers.clear(ModularSanitizers);
+ImportedSanitizers.clear(ModularSanitizers);
+

r302596 - Don't mark a member as a member specialization until we know we're keeping the specialization.

2017-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May  9 18:02:10 2017
New Revision: 302596

URL: http://llvm.org/viewvc/llvm-project?rev=302596&view=rev
Log:
Don't mark a member as a member specialization until we know we're keeping the 
specialization.

This improves our behavior in a few ways:

 * We now guarantee that if a member is marked as being a member
   specialization, there will actually be a member specialization declaration
   somewhere on its redeclaration chain. This fixes a crash in modules builds
   where we would try to check that there was a visible declaration of the
   member specialization and be surprised to not find any declaration of it at
   all.

 * We don't set the source location of the in-class declaration of the member
   specialization to the out-of-line declaration's location until we have
   actually finished merging them. This fixes some very silly looking
   diagnostics, where we'd point a "previous declaration is here" note at the
   same declaration we're complaining about. Ideally we wouldn't mess with the
   prior declaration's location at all, but too much code assumes that the
   first declaration of an entity is a reasonable thing to use as an indication
   of where it was declared, and that's not really true for a member
   specialization unless we fake it like this.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/PCH/cxx-templates.cpp
cfe/trunk/test/PCH/cxx-templates.h
cfe/trunk/test/SemaTemplate/explicit-specialization-member.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302596&r1=302595&r2=302596&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May  9 18:02:10 2017
@@ -6085,6 +6085,7 @@ public:
  TemplateArgumentListInfo *ExplicitTemplateArgs,
LookupResult &Previous);
   bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
+  void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
 
   DeclResult
   ActOnExplicitInstantiation(Scope *S,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=302596&r1=302595&r2=302596&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May  9 18:02:10 2017
@@ -1488,6 +1488,11 @@ bool Sema::ShouldWarnIfUnusedFileScopedD
   if (const FunctionDecl *FD = dyn_cast(D)) {
 if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return false;
+// A non-out-of-line declaration of a member specialization was implicitly
+// instantiated; it's the out-of-line declaration that we're interested in.
+if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
+  return false;
 
 if (const CXXMethodDecl *MD = dyn_cast(FD)) {
   if (MD->isVirtual() || IsDisallowedCopyOrAssign(MD))
@@ -1514,6 +1519,10 @@ bool Sema::ShouldWarnIfUnusedFileScopedD
 if (VD->isStaticDataMember() &&
 VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
   return false;
+if (VD->isStaticDataMember() &&
+VD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
+  return false;
 
 if (VD->isInline() && !isMainFileLoc(*this, VD->getLocation()))
   return false;
@@ -6706,6 +6715,9 @@ NamedDecl *Sema::ActOnVariableDeclarator
 return NewTemplate;
   }
 
+  if (IsMemberSpecialization && !NewVD->isInvalidDecl())
+CompleteMemberSpecialization(NewVD, Previous);
+
   return NewVD;
 }
 
@@ -8919,13 +8931,17 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 }
   }
 
+  MarkUnusedFileScopedDecl(NewFD);
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
-  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
+
+if (isMemberSpecialization && !NewFD->isInvalidDecl())
+  CompleteMemberSpecialization(NewFD, Previous);
   }
 
   if (NewFD->hasAttr()) {
@@ -8965,8 +8981,6 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 }
   }
 
-  MarkUnusedFileScopedDecl(NewFD);
-
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.
@@ -9183,7 +9197,9 @@ bool Sema::CheckFunctionDeclaration(Scop
 if (OldTemplateDecl->getTemplatedDecl()->isDeleted()) {

[PATCH] D32988: [libc++] Refactor Windows support headers.

2017-05-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added inline comments.



Comment at: include/__config:232-235
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+

bcraig wrote:
> I can see this helping when we are build libc++, but I don't think it helps 
> client apps.  They could have included windows.h before including our headers.
> 
> Don't get me wrong, I dislike the min and max macros, and bear no hard 
> feelings towards people that define this project wide on the command line, 
> I'm just not sure it will get things done right here.
> 
> In the past, I've just surrounded my min and max declarations with 
> parenthesis to suppress macro expansion.
Yeah, I don't think that this should be defined in `__config`.  Can we do 
something like `#pragma push_macro` and `#pragma pop_macro` in the necessary 
files?



Comment at: include/stdio.h:113-118
 #if defined(_LIBCPP_MSVCRT)
-extern "C++" {
-#include "support/win32/support.h"
+extern "C" {
+int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
+int asprintf(char **sptr, const char *__restrict fmt, ...);
 }
 #endif

Should this be hoisted above the `#ifdef __cplusplus`?  This seems like it 
should be defined by `stdio.h` but isn't in msvcrt?



Comment at: include/support/win32/locale_win32.h:24
+#define LC_MESSAGES_MASK _M_MESSAGES
+#define LC_ALL_MASK (  LC_COLLATE_MASK \
+ | LC_CTYPE_MASK \

Can you please clang-format this block?



Comment at: include/support/win32/msvc_builtin_support.h:33-51
+_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
+{
+  // Binary: 0101...
+  static const unsigned int m1 = 0x;
+  // Binary: 00110011..
+  static const unsigned int m2 = 0x;
+  // Binary:  4 zeros,  4 ones ...

I think I prefer the following implementation:

_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int value) {
  return __popcnt(value);
}



Comment at: include/support/win32/msvc_builtin_support.h:58-76
+_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x)
+{
+  // Binary: 0101...
+  static const unsigned long long m1 = 0x;
+  // Binary: 00110011..
+  static const unsigned long long m2 = 0x;
+  // Binary:  4 zeros,  4 ones ...

I think I prefer the following implementation:

_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long value) {
  return __popcnt64(value);
}



Comment at: src/string.cpp:430
 #else
-return static_cast(swprintf);
+return static_cast(_snwprintf);
 #endif

This seems scary.  Why do we need to cast the function?


https://reviews.llvm.org/D32988



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


  1   2   >