[PATCH] D29065: Split isUsingLTO() outside of embedBitcodeInObject() and embedBitcodeMarkerOnly().

2017-01-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: cfe/trunk/lib/Driver/Tools.cpp:6464
   if (C.getDriver().isSaveTempsEnabled() &&
-  !C.getDriver().embedBitcodeInObject() && isa(JA))
+  !C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO() &&
+  isa(JA))

steven_wu wrote:
> Should this line actually be:
> 
> ```
> !(C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO()) &&
> 
> ```
> 
Thanks, r293370


Repository:
  rL LLVM

https://reviews.llvm.org/D29065



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


r293370 - Fix typo introduced in r292960 that may affect -flto -save-temps (saving the optimized bitcode)

2017-01-27 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Sat Jan 28 00:07:17 2017
New Revision: 293370

URL: http://llvm.org/viewvc/llvm-project?rev=293370=rev
Log:
Fix typo introduced in r292960 that may affect -flto -save-temps (saving the 
optimized bitcode)

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=293370=293369=293370=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Jan 28 00:07:17 2017
@@ -6519,7 +6519,7 @@ void Clang::ConstructJob(Compilation ,
   // pristine IR generated by the frontend. Ideally, a new compile action 
should
   // be added so both IR can be captured.
   if (C.getDriver().isSaveTempsEnabled() &&
-  !C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO() &&
+  !(C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO()) &&
   isa(JA))
 CmdArgs.push_back("-disable-llvm-passes");
 


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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-01-27 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added a comment.

> Regarding incremental solving with Z3 (or with most SMT solvers in general), 
> let me just lower the expectations a bit: 

Ok, that is good to know. It seems that the performance benefits of incremental 
solving are unclear, and would be nontrivial to implement (maybe store the 
states in a DAG, then pop back to the lowest common ancestor from the previous 
state, and push down to the new state).

> The improvement here (200s vs. 250s) makes me think that some form of 
> caching/incrementalization could pay off.

I'm optimistic that implementing a SMT query cache would significantly improve 
performance (for both constraint managers), but the current version of that 
patch has some memory-safety problems (since ProgramStateRef is a 
reference-counting pointer), and I currently don't have the time to fix it up.

> We could add a new lit substitution '%clang_cc1_analyze' that expands to 
> '%clang_cc1 -analyze -analyzer-constraints=foo 
> -DANALYZER_HAS_CONSTRAINT_MANAGER_FOO" and change the analyzer tests to use 
> it.

I've updated the current version of this diff to use this approach, though 
there are still the two remaining testcase failures mentioned earlier that I'm 
not sure how to handle. I also had to remove the argument `-fsyntax-only` in 
some testcases, because the argument seems to need to appear before `-analyze` 
(which isn't possible using the substitution-based approach), though it doesn't 
seem to affect the outcome of the testcase. However, I haven't been able to 
figure out how to get llvm-lit to execute the same statement twice with 
different substitutions. From lit.cfg, it seems that I can only define 
additional substitutions, and not execute a test multiple times. I'm not 
familiar with the test infrastructure, do you have any suggestions?


https://reviews.llvm.org/D28952



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


r293369 - Attempt to unbreak buildbots.

2017-01-27 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Fri Jan 27 22:16:32 2017
New Revision: 293369

URL: http://llvm.org/viewvc/llvm-project?rev=293369=rev
Log:
Attempt to unbreak buildbots.

r293360 broke some ARM bots, because size_t on those targets is
apparently `unsigned int`, not `unsigned long`. `sizeof(whatever)`
should to give us a `size_t`, so we can just use the type of that
instead.

Modified:
cfe/trunk/test/SemaCXX/diagnose_if.cpp

Modified: cfe/trunk/test/SemaCXX/diagnose_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/diagnose_if.cpp?rev=293369=293368=293369=diff
==
--- cfe/trunk/test/SemaCXX/diagnose_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/diagnose_if.cpp Fri Jan 27 22:16:32 2017
@@ -2,7 +2,7 @@
 
 #define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
 
-using size_t = unsigned long;
+using size_t = decltype(sizeof(int));
 
 namespace type_dependent {
 template 


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


[PATCH] D29065: Split isUsingLTO() outside of embedBitcodeInObject() and embedBitcodeMarkerOnly().

2017-01-27 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Sorry I just notice that when I look at driver today.




Comment at: cfe/trunk/lib/Driver/Tools.cpp:6464
   if (C.getDriver().isSaveTempsEnabled() &&
-  !C.getDriver().embedBitcodeInObject() && isa(JA))
+  !C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO() &&
+  isa(JA))

Should this line actually be:

```
!(C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO()) &&

```



Repository:
  rL LLVM

https://reviews.llvm.org/D29065



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


r293367 - Switch the template specialization kind for a non-defining declaration of a

2017-01-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 27 20:56:07 2017
New Revision: 293367

URL: http://llvm.org/viewvc/llvm-project?rev=293367=rev
Log:
Switch the template specialization kind for a non-defining declaration of a
non-template function instantiated from a friend declaration in a class
template from TSK_ImplicitInstantiation to TSK_Undeclared.

It doesn't make sense for a non-template function to be flagged as being
instantiated from a template; that property really belongs to the entity
as a whole and not an individual declaration of it. There's some history
here:

 * r137934 started marking these functions as instantiations in order to
   work around an issue where we might instantiate a class template while
   we're still parsing its member definitions, and would otherwise fail
   to instantiate the friend definition

 * r177003 fixed the same issue but for friend templates, but did so by
   making the friends claim to be definitions even before we'd parsed
   their actual bodies; this made the r137934 change redundant

 * r293558 worked around a problem caused by the marking of a non-template
   function as a template instantiation in r137934

This change reverts the code changes from r293358 and r137934 and retains
all the tests.

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=293367=293366=293367=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Jan 27 20:56:07 2017
@@ -1656,8 +1656,6 @@ Decl *TemplateDeclInstantiator::VisitFun
 FunctionTemplate->setLexicalDeclContext(LexicalDC);
 
 if (isFriend && D->isThisDeclarationADefinition()) {
-  // TODO: should we remember this connection regardless of whether
-  // the friend declaration provided a body?
   FunctionTemplate->setInstantiatedFromMemberTemplate(
D->getDescribedFunctionTemplate());
 }
@@ -1668,13 +1666,10 @@ Decl *TemplateDeclInstantiator::VisitFun
 TemplateArgumentList::CreateCopy(SemaRef.Context,
  Innermost),
 /*InsertPos=*/nullptr);
-  } else if (isFriend) {
-// Note, we need this connection even if the friend doesn't have a body.
-// Its body may exist but not have been attached yet due to deferred
-// parsing.
-// FIXME: It might be cleaner to set this when attaching the body to the
-// friend function declaration, however that would require finding all the
-// instantiations and modifying them.
+  } else if (isFriend && D->isThisDeclarationADefinition()) {
+// Do not connect the friend to the template unless it's actually a
+// definition. We don't want non-template functions to be marked as being
+// template instantiations.
 Function->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation);
   }
 
@@ -3726,12 +3721,7 @@ void Sema::InstantiateFunctionDefinition
   PendingInstantiations.push_back(
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
-  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
-  // A non-template function that is only lexically in a dependent
-  // context, such as a friend function in a class template, should
-  // not produce a warning.
-  (PatternDecl->getDescribedFunctionTemplate() ||
-   PatternDecl->getDeclContext()->isDependentContext())) {
+  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);


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


r293364 - Avoid calling dump() in normal code

2017-01-27 Thread Matthias Braun via cfe-commits
Author: matze
Date: Fri Jan 27 20:36:00 2017
New Revision: 293364

URL: http://llvm.org/viewvc/llvm-project?rev=293364=rev
Log:
Avoid calling dump() in normal code

dump() is only available in debug builds and meant for debugger usage,
normal code should use something like print(errs());

Modified:
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=293364=293363=293364=diff
==
--- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original)
+++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Fri Jan 27 
20:36:00 2017
@@ -514,7 +514,10 @@ public:
 // Dump the contents of the temporary file if that was requested.
 if (DumpTemporaryFiles) {
   errs() << ";\n; Object file bundler IR file.\n;\n";
-  AuxModule.get()->dump();
+  AuxModule.get()->print(errs(), nullptr,
+ /*ShouldPreserveUseListOrder=*/false,
+ /*IsForDebug=*/true);
+  errs() << '\n';
 }
 
 // Find clang in order to create the bundle binary.


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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D28889



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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293360: Change how we handle diagnose_if attributes. 
(authored by gbiv).

Changed prior to commit:
  https://reviews.llvm.org/D28889?vs=86146=86155#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28889

Files:
  cfe/trunk/include/clang/Sema/Overload.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/Sema/diagnose_if.c
  cfe/trunk/test/SemaCXX/diagnose_if.cpp

Index: cfe/trunk/include/clang/Sema/Overload.h
===
--- cfe/trunk/include/clang/Sema/Overload.h
+++ cfe/trunk/include/clang/Sema/Overload.h
@@ -675,26 +675,6 @@
 /// to be used while performing partial ordering of function templates.
 unsigned ExplicitCallArguments;
 
-/// The number of diagnose_if attributes that this overload triggered.
-/// If any of the triggered attributes are errors, this won't count
-/// diagnose_if warnings.
-unsigned NumTriggeredDiagnoseIfs = 0;
-
-/// Basically a TinyPtrVector that doesn't own the vector:
-/// If NumTriggeredDiagnoseIfs is 0 or 1, this is a DiagnoseIfAttr *,
-/// otherwise it's a pointer to an array of `NumTriggeredDiagnoseIfs`
-/// DiagnoseIfAttr *s.
-llvm::PointerUnion DiagnoseIfInfo;
-
-/// Gets an ArrayRef for the data at DiagnoseIfInfo. Note that this may give
-/// you a pointer into DiagnoseIfInfo.
-ArrayRef getDiagnoseIfInfo() const {
-  auto *Ptr = NumTriggeredDiagnoseIfs <= 1
-  ? DiagnoseIfInfo.getAddrOfPtr1()
-  : DiagnoseIfInfo.get();
-  return {Ptr, NumTriggeredDiagnoseIfs};
-}
-
 union {
   DeductionFailureInfo DeductionFailure;
   
@@ -759,9 +739,8 @@
 SmallVector Candidates;
 llvm::SmallPtrSet Functions;
 
-// Allocator for ConversionSequenceLists and DiagnoseIfAttr* arrays.
-// We store the first few of each of these inline to avoid allocation for
-// small sets.
+// Allocator for ConversionSequenceLists. We store the first few of these
+// inline to avoid allocation for small sets.
 llvm::BumpPtrAllocator SlabAllocator;
 
 SourceLocation Loc;
@@ -776,6 +755,8 @@
 /// from the slab allocator.
 /// FIXME: It would probably be nice to have a SmallBumpPtrAllocator
 /// instead.
+/// FIXME: Now that this only allocates ImplicitConversionSequences, do we
+/// want to un-generalize this?
 template 
 T *slabAllocate(unsigned N) {
   // It's simpler if this doesn't need to consider alignment.
@@ -809,11 +790,6 @@
 SourceLocation getLocation() const { return Loc; }
 CandidateSetKind getKind() const { return Kind; }
 
-/// Make a DiagnoseIfAttr* array in a block of memory that will live for
-/// as long as this OverloadCandidateSet. Returns a pointer to the start
-/// of that array.
-DiagnoseIfAttr **addDiagnoseIfComplaints(ArrayRef CA);
-
 /// \brief Determine when this overload candidate will be new to the
 /// overload set.
 bool isNewCandidate(Decl *F) {
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -2545,14 +2545,14 @@
   void AddMethodCandidate(DeclAccessPair FoundDecl,
   QualType ObjectType,
   Expr::Classification ObjectClassification,
-  Expr *ThisArg, ArrayRef Args,
+  ArrayRef Args,
   OverloadCandidateSet& CandidateSet,
   bool SuppressUserConversion = false);
   void AddMethodCandidate(CXXMethodDecl *Method,
   DeclAccessPair FoundDecl,
   CXXRecordDecl *ActingContext, QualType ObjectType,
   Expr::Classification ObjectClassification,
-  Expr *ThisArg, ArrayRef Args,
+  ArrayRef Args,
   OverloadCandidateSet& CandidateSet,
   bool SuppressUserConversions = false,
   bool PartialOverloading = false,
@@ -2563,7 +2563,6 @@
  TemplateArgumentListInfo *ExplicitTemplateArgs,
   QualType ObjectType,
   Expr::Classification ObjectClassification,
-  Expr *ThisArg,
   ArrayRef Args,
   OverloadCandidateSet& CandidateSet,
   bool SuppressUserConversions = false,
@@ -2637,37 +2636,27 @@
   EnableIfAttr 

r293360 - Change how we handle diagnose_if attributes.

2017-01-27 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Fri Jan 27 20:19:40 2017
New Revision: 293360

URL: http://llvm.org/viewvc/llvm-project?rev=293360=rev
Log:
Change how we handle diagnose_if attributes.

This patch changes how we handle argument-dependent `diagnose_if`
attributes. In particular, we now check them in the same place that we
check for things like passing NULL to Nonnull args, etc. This is
basically better in every way than how we were handling them before. :)

This fixes PR31638, PR31639, and PR31640.

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

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/diagnose_if.c
cfe/trunk/test/SemaCXX/diagnose_if.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=293360=293359=293360=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Fri Jan 27 20:19:40 2017
@@ -675,26 +675,6 @@ namespace clang {
 /// to be used while performing partial ordering of function templates.
 unsigned ExplicitCallArguments;
 
-/// The number of diagnose_if attributes that this overload triggered.
-/// If any of the triggered attributes are errors, this won't count
-/// diagnose_if warnings.
-unsigned NumTriggeredDiagnoseIfs = 0;
-
-/// Basically a TinyPtrVector that doesn't own the 
vector:
-/// If NumTriggeredDiagnoseIfs is 0 or 1, this is a DiagnoseIfAttr *,
-/// otherwise it's a pointer to an array of `NumTriggeredDiagnoseIfs`
-/// DiagnoseIfAttr *s.
-llvm::PointerUnion DiagnoseIfInfo;
-
-/// Gets an ArrayRef for the data at DiagnoseIfInfo. Note that this may 
give
-/// you a pointer into DiagnoseIfInfo.
-ArrayRef getDiagnoseIfInfo() const {
-  auto *Ptr = NumTriggeredDiagnoseIfs <= 1
-  ? DiagnoseIfInfo.getAddrOfPtr1()
-  : DiagnoseIfInfo.get();
-  return {Ptr, NumTriggeredDiagnoseIfs};
-}
-
 union {
   DeductionFailureInfo DeductionFailure;
   
@@ -759,9 +739,8 @@ namespace clang {
 SmallVector Candidates;
 llvm::SmallPtrSet Functions;
 
-// Allocator for ConversionSequenceLists and DiagnoseIfAttr* arrays.
-// We store the first few of each of these inline to avoid allocation for
-// small sets.
+// Allocator for ConversionSequenceLists. We store the first few of these
+// inline to avoid allocation for small sets.
 llvm::BumpPtrAllocator SlabAllocator;
 
 SourceLocation Loc;
@@ -776,6 +755,8 @@ namespace clang {
 /// from the slab allocator.
 /// FIXME: It would probably be nice to have a SmallBumpPtrAllocator
 /// instead.
+/// FIXME: Now that this only allocates ImplicitConversionSequences, do we
+/// want to un-generalize this?
 template 
 T *slabAllocate(unsigned N) {
   // It's simpler if this doesn't need to consider alignment.
@@ -809,11 +790,6 @@ namespace clang {
 SourceLocation getLocation() const { return Loc; }
 CandidateSetKind getKind() const { return Kind; }
 
-/// Make a DiagnoseIfAttr* array in a block of memory that will live for
-/// as long as this OverloadCandidateSet. Returns a pointer to the start
-/// of that array.
-DiagnoseIfAttr **addDiagnoseIfComplaints(ArrayRef CA);
-
 /// \brief Determine when this overload candidate will be new to the
 /// overload set.
 bool isNewCandidate(Decl *F) {

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=293360=293359=293360=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 27 20:19:40 2017
@@ -2545,14 +2545,14 @@ public:
   void AddMethodCandidate(DeclAccessPair FoundDecl,
   QualType ObjectType,
   Expr::Classification ObjectClassification,
-  Expr *ThisArg, ArrayRef Args,
+  ArrayRef Args,
   OverloadCandidateSet& CandidateSet,
   bool SuppressUserConversion = false);
   void AddMethodCandidate(CXXMethodDecl *Method,
   DeclAccessPair FoundDecl,
   CXXRecordDecl *ActingContext, QualType ObjectType,
   Expr::Classification ObjectClassification,
-  Expr *ThisArg, ArrayRef Args,
+  ArrayRef Args,
   OverloadCandidateSet& 

r293358 - -Wunused-func-template: do not warn on non-template function declarations that

2017-01-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 27 19:50:33 2017
New Revision: 293358

URL: http://llvm.org/viewvc/llvm-project?rev=293358=rev
Log:
-Wunused-func-template: do not warn on non-template function declarations that
were nonetheless instantiated (particularly, non-template friends declared
within class templates).

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/undefined-template.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=293358=293357=293358=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Jan 27 19:50:33 2017
@@ -3726,7 +3726,12 @@ void Sema::InstantiateFunctionDefinition
   PendingInstantiations.push_back(
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
-  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred()) {
+  if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
+  // A non-template function that is only lexically in a dependent
+  // context, such as a friend function in a class template, should
+  // not produce a warning.
+  (PatternDecl->getDescribedFunctionTemplate() ||
+   PatternDecl->getDeclContext()->isDependentContext())) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);

Modified: cfe/trunk/test/SemaTemplate/undefined-template.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/undefined-template.cpp?rev=293358=293357=293358=diff
==
--- cfe/trunk/test/SemaTemplate/undefined-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/undefined-template.cpp Fri Jan 27 19:50:33 2017
@@ -134,6 +134,14 @@ void func_23(C1::C2 *x) {
 // expected-note@-1{{add an explicit instantiation 
declaration to suppress this warning if 'C1::C2::tmeth_2' is 
explicitly instantiated in another translation unit}}
 }
 
+namespace test_24 {
+  template  struct X {
+friend void g(int);
+operator int() { return 0; }
+  };
+  void h(X x) { g(x); } // no warning for use of 'g' despite the 
declaration having been instantiated from a template
+}
+
 int main() {
   return 0;
 }


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


r293355 - Support '#pragma clang __debug dump' within C++ classes.

2017-01-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 27 19:20:57 2017
New Revision: 293355

URL: http://llvm.org/viewvc/llvm-project?rev=293355=rev
Log:
Support '#pragma clang __debug dump' within C++ classes.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=293355=293354=293355=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jan 27 19:20:57 2017
@@ -2988,6 +2988,9 @@ Parser::DeclGroupPtrTy Parser::ParseCXXC
   case tok::annot_pragma_ms_vtordisp:
 HandlePragmaMSVtorDisp();
 return nullptr;
+  case tok::annot_pragma_dump:
+HandlePragmaDump();
+return nullptr;
 
   case tok::kw_namespace:
 // If we see a namespace here, a close brace was missing somewhere.


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


r293354 - Convert sequence of 'if's on the same value to a switch. No functionality change intended.

2017-01-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 27 19:12:10 2017
New Revision: 293354

URL: http://llvm.org/viewvc/llvm-project?rev=293354=rev
Log:
Convert sequence of 'if's on the same value to a switch. No functionality 
change intended.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=293354=293353=293354=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Jan 27 19:12:10 2017
@@ -2958,56 +2958,47 @@ void Parser::SkipCXXMemberSpecification(
 Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas(
 AccessSpecifier , ParsedAttributesWithRange ,
 DeclSpec::TST TagType, Decl *TagDecl) {
-  if (getLangOpts().MicrosoftExt &&
-  Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
+  switch (Tok.getKind()) {
+  case tok::kw___if_exists:
+  case tok::kw___if_not_exists:
 ParseMicrosoftIfExistsClassDeclaration(TagType, AS);
 return nullptr;
-  }
 
-  // Check for extraneous top-level semicolon.
-  if (Tok.is(tok::semi)) {
+  case tok::semi:
+// Check for extraneous top-level semicolon.
 ConsumeExtraSemi(InsideStruct, TagType);
 return nullptr;
-  }
 
-  if (Tok.is(tok::annot_pragma_vis)) {
+// Handle pragmas that can appear as member declarations.
+  case tok::annot_pragma_vis:
 HandlePragmaVisibility();
 return nullptr;
-  }
-
-  if (Tok.is(tok::annot_pragma_pack)) {
+  case tok::annot_pragma_pack:
 HandlePragmaPack();
 return nullptr;
-  }
-
-  if (Tok.is(tok::annot_pragma_align)) {
+  case tok::annot_pragma_align:
 HandlePragmaAlign();
 return nullptr;
-  }
-
-  if (Tok.is(tok::annot_pragma_ms_pointers_to_members)) {
+  case tok::annot_pragma_ms_pointers_to_members:
 HandlePragmaMSPointersToMembers();
 return nullptr;
-  }
-
-  if (Tok.is(tok::annot_pragma_ms_pragma)) {
+  case tok::annot_pragma_ms_pragma:
 HandlePragmaMSPragma();
 return nullptr;
-  }
-
-  if (Tok.is(tok::annot_pragma_ms_vtordisp)) {
+  case tok::annot_pragma_ms_vtordisp:
 HandlePragmaMSVtorDisp();
 return nullptr;
-  }
 
-  // If we see a namespace here, a close brace was missing somewhere.
-  if (Tok.is(tok::kw_namespace)) {
+  case tok::kw_namespace:
+// If we see a namespace here, a close brace was missing somewhere.
 DiagnoseUnexpectedNamespace(cast(TagDecl));
 return nullptr;
-  }
 
-  AccessSpecifier NewAS = getAccessSpecifierIfPresent();
-  if (NewAS != AS_none) {
+  case tok::kw_public:
+  case tok::kw_protected:
+  case tok::kw_private: {
+AccessSpecifier NewAS = getAccessSpecifierIfPresent();
+assert(NewAS != AS_none);
 // Current token is a C++ access specifier.
 AS = NewAS;
 SourceLocation ASLoc = Tok.getLocation();
@@ -3042,12 +3033,13 @@ Parser::DeclGroupPtrTy Parser::ParseCXXC
 return nullptr;
   }
 
-  if (Tok.is(tok::annot_pragma_openmp))
+  case tok::annot_pragma_openmp:
 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, AccessAttrs, TagType,
   TagDecl);
 
-  // Parse all the comma separated declarators.
-  return ParseCXXClassMemberDeclaration(AS, AccessAttrs.getList());
+  default:
+return ParseCXXClassMemberDeclaration(AS, AccessAttrs.getList());
+  }
 }
 
 /// ParseCXXMemberSpecification - Parse the class definition.


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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:11933
 }
-

aaron.ballman wrote:
> Unintended change?
...I dunno what keeps making this change, but I'll re-undo it before I submit.


https://reviews.llvm.org/D28889



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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added inline comments.



Comment at: test/SemaCXX/diagnose_if.cpp:615
+// evaluator isn't able to evaluate `adl::Foo(1)` to a constexpr, though.
+// I'm assuming this is because we assign it to a temporary.
+for (void *p : adl::Foo(1)) {}

rsmith wrote:
> The range-based for is desugared to
> 
> ```
> auto &&__range = adl::Foo(1);
> auto __begin = begin(__range);
> auto __end = end(__range);
> // ...
> ```
> 
> so the argument in the call to `begin` is not considered constant.
Good to know. Thanks!


https://reviews.llvm.org/D28889



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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 86146.
george.burgess.iv marked 7 inline comments as done.
george.burgess.iv added a comment.

Addressed all feedback

> Another "fun" testcase

Ooh, shiny. Added.


https://reviews.llvm.org/D28889

Files:
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  test/Sema/diagnose_if.c
  test/SemaCXX/diagnose_if.cpp

Index: test/SemaCXX/diagnose_if.cpp
===
--- test/SemaCXX/diagnose_if.cpp
+++ test/SemaCXX/diagnose_if.cpp
@@ -2,6 +2,8 @@
 
 #define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
 
+using size_t = unsigned long;
+
 namespace type_dependent {
 template 
 void neverok() _diagnose_if(!T(), "oh no", "error") {} // expected-note 4{{from 'diagnose_if'}}
@@ -51,14 +53,14 @@
 }
 
 template 
-void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note{{from 'diagnose_if'}}
 
 template 
-void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note{{from 'diagnose_if'}}
 
 void runIf() {
   errorIf(0);
-  errorIf(1); // expected-error{{call to unavailable function}}
+  errorIf(1); // expected-error{{oh no}}
 
   warnIf(0);
   warnIf(1); // expected-warning{{oh no}}
@@ -114,14 +116,14 @@
 }
 
 template 
-void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note{{from 'diagnose_if'}}
 
 template 
-void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note{{from 'diagnose_if'}}
 
 void runIf() {
   errorIf<0>(0);
-  errorIf<0>(1); // expected-error{{call to unavailable function}}
+  errorIf<0>(1); // expected-error{{oh no}}
 
   warnIf<0>(0);
   warnIf<0>(1); // expected-warning{{oh no}}
@@ -135,17 +137,17 @@
 void bar(int);
 void bar(short) _diagnose_if(1, "oh no", "error");
 
-void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{candidate disabled: oh no}}
-void fooArg(short); // expected-note{{candidate function}}
+void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{from 'diagnose_if'}}
+void fooArg(short);
 
 void barArg(int);
 void barArg(short a) _diagnose_if(a, "oh no", "error");
 
 void runAll() {
   foo(1); // expected-error{{oh no}}
   bar(1);
 
-  fooArg(1); // expected-error{{call to unavailable function}}
+  fooArg(1); // expected-error{{oh no}}
   barArg(1);
 
   auto p = foo; // expected-error{{incompatible initializer of type ''}}
@@ -188,11 +190,11 @@
   void foo(int i) _diagnose_if(i, "bad i", "error"); // expected-note{{from 'diagnose_if'}}
   void bar(int i) _diagnose_if(i != T(), "bad i", "error"); // expected-note{{from 'diagnose_if'}}
 
-  void fooOvl(int i) _diagnose_if(i, "int bad i", "error"); // expected-note 2{{int bad i}}
-  void fooOvl(short i) _diagnose_if(i, "short bad i", "error"); // expected-note 2{{short bad i}}
+  void fooOvl(int i) _diagnose_if(i, "int bad i", "error"); // expected-note{{from 'diagnose_if'}}
+  void fooOvl(short i) _diagnose_if(i, "short bad i", "error"); // expected-note{{from 'diagnose_if'}}
 
-  void barOvl(int i) _diagnose_if(i != T(), "int bad i", "error"); // expected-note 2{{int bad i}}
-  void barOvl(short i) _diagnose_if(i != T(), "short bad i", "error"); // expected-note 2{{short bad i}}
+  void barOvl(int i) _diagnose_if(i != T(), "int bad i", "error"); // expected-note{{from 'diagnose_if'}}
+  void barOvl(short i) _diagnose_if(i != T(), "short bad i", "error"); // expected-note{{from 'diagnose_if'}}
 };
 
 void runErrors() {
@@ -203,14 +205,14 @@
   Errors().bar(1); // expected-error{{bad i}}
 
   Errors().fooOvl(0);
-  Errors().fooOvl(1); // expected-error{{call to unavailable}}
+  Errors().fooOvl(1); // expected-error{{int bad i}}
   Errors().fooOvl(short(0));
-  Errors().fooOvl(short(1)); // expected-error{{call to unavailable}}
+  Errors().fooOvl(short(1)); // expected-error{{short bad i}}
 
   Errors().barOvl(0);
-  Errors().barOvl(1); // expected-error{{call to unavailable}}
+  Errors().barOvl(1); // expected-error{{int bad i}}
   Errors().barOvl(short(0));
-  Errors().barOvl(short(1)); // expected-error{{call to unavailable}}
+  Errors().barOvl(short(1)); // expected-error{{short bad i}}
 }
 
 template 
@@ -275,8 +277,8 @@
 constexpr int foo();
 constexpr int foo(int a);
 
-void bar() _diagnose_if(foo(), "bad foo", "error"); // expected-note{{from 'diagnose_if'}} expected-note{{not viable: requires 0 arguments}}
-void bar(int a) 

r293350 - When converting a template argument representing to an expression for a

2017-01-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 27 18:38:35 2017
New Revision: 293350

URL: http://llvm.org/viewvc/llvm-project?rev=293350=rev
Log:
When converting a template argument representing  to an expression for a
pointer typed template parameter, form  rather than an array-to-pointer
decay on array.

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=293350=293349=293350=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Jan 27 18:38:35 2017
@@ -5830,8 +5830,9 @@ Sema::BuildExpressionFromDeclTemplateArg
 if (RefExpr.isInvalid())
   return ExprError();
 
-if (T->isFunctionType() || T->isArrayType()) {
-  // Decay functions and arrays.
+if (!Context.hasSameUnqualifiedType(ParamType->getPointeeType(), T) &&
+(T->isFunctionType() || T->isArrayType())) {
+  // Decay functions and arrays unless we're forming a pointer to array.
   RefExpr = DefaultFunctionArrayConversion(RefExpr.get());
   if (RefExpr.isInvalid())
 return ExprError();

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=293350=293349=293350=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Fri Jan 27 18:38:35 2017
@@ -455,3 +455,11 @@ namespace nondependent_default_arg_order
 X y; f(y); // expected-error {{ambiguous}}
   }
 }
+
+namespace pointer_to_char_array {
+  typedef char T[4];
+  template struct A { void f(); };
+  template void A::f() {}
+  T foo = "foo";
+  void g() { A<>().f(); }
+}


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


[PATCH] D28845: Prototype of modules codegen

2017-01-27 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.






Comment at: include/clang/AST/ASTContext.h:2490
   /// it is not used.
-  bool DeclMustBeEmitted(const Decl *D);
+  bool DeclMustBeEmitted(const Decl *D, bool WritingModule = false);
 

I think the name of this flag might be out of sync with its meaning; it looks 
like it means "must this declaration be emitted when performing modular 
codegen?"



Comment at: include/clang/Basic/Module.h:208
 
+  unsigned WithCodegen : 2;
+

Does this need to be two bits wide? Seems to only store true/false.



Comment at: include/clang/Driver/CC1Options.td:435-438
+def fmodule_codegen :
+  Flag<["-"], "fmodule-codegen">,
+  HelpText<"Generate code for uses of this module that assumes an explicit "
+   "object file will be built for the module">;

Maybe `module` -> `modules`, to match the other `-fmodules-*` flags controlling 
various options.



Comment at: lib/AST/ASTContext.cpp:9020-9023
+  if (auto *Ext = getExternalSource())
+if (Ext->hasExternalDefinitions(FD->getOwningModuleID()) ==
+ExternalASTSource::EK_Never)
+  return true;

I think this `return true` is unreachable and can be deleted: if we get here 
with `Linkage == GVA_DiscardableODR`, then the call to `hasExternalDefinitions` 
in `GetGVALinkageForFunction` must have returned `EK_ReplyHazy`. (In the case 
this is checking for, `GetGVALinkageForFunction` would return `GVA_StrongODR`, 
so the check below will return `true` anyway.)



Comment at: lib/AST/ASTContext.cpp:9029
 // Implicit template instantiations can also be deferred in C++.
 return !isDiscardableGVALinkage(GetGVALinkageForFunction(FD));
   }

Pass `Linkage` in here instead of recomputing it



Comment at: lib/AST/ExternalASTSource.cpp:33
+ExternalASTSource::hasExternalDefinitions(unsigned ID) {
+  return EK_ReplyHazy;
+}

You should add support for this function to 
`clang::MultiplexExternalSemaSource` too.



Comment at: lib/Serialization/ASTWriterDecl.cpp:2215-2219
+  if (isRequiredDecl(D, Context, WritingModule, false))
 EagerlyDeserializedDecls.push_back(ID);
+  else if (Context.getLangOpts().ModularCodegen && WritingModule &&
+   isRequiredDecl(D, Context, true, true))
+ModularCodegenDecls.push_back(ID);

I suspect we'll want to seriously prune back the contents of 
`EagerlyDeserializedDecls` for the modular codegen case at some point, but we 
don't need to do that in this change.


https://reviews.llvm.org/D28845



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


[PATCH] D21675: New ODR checker for modules

2017-01-27 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu updated this revision to Diff 86142.
rtrieu added a comment.

Changes made to the ODR hash algorithm:

Separated Decl and Type pointers into their own DenseMap's.
Removed the queue of pointers to process at the end.  Instead, process pointers 
at first use.
Save Boolean values and add them together at the end to reduce bits wasted.  
Shrinks data from bools 32x.

With these changes, the overhead is now 1-1.5%


https://reviews.llvm.org/D21675

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/ODRHash.h
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSerializationKinds.td
  lib/AST/CMakeLists.txt
  lib/AST/DeclCXX.cpp
  lib/AST/ODRHash.cpp
  lib/AST/StmtProfile.cpp
  lib/Sema/SemaDecl.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/merge-using-decls.cpp
  test/Modules/odr_hash.cpp

Index: test/Modules/odr_hash.cpp
===
--- test/Modules/odr_hash.cpp
+++ test/Modules/odr_hash.cpp
@@ -0,0 +1,1077 @@
+// Clear and create directories
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/cache
+// RUN: mkdir %t/Inputs
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/Inputs/first.h
+// RUN: cat %s   >> %t/Inputs/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/Inputs/second.h
+// RUN: cat %s>> %t/Inputs/second.h
+
+// Build module map file
+// RUN: echo "module first {"   >> %t/Inputs/module.map
+// RUN: echo "header \"first.h\""   >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+// RUN: echo "module second {"  >> %t/Inputs/module.map
+// RUN: echo "header \"second.h\""  >> %t/Inputs/module.map
+// RUN: echo "}">> %t/Inputs/module.map
+
+// Run test
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++11
+
+#if !defined(FIRST) && !defined(SECOND)
+#include "first.h"
+#include "second.h"
+#endif
+
+#if defined(FIRST)
+struct S1 {
+  public:
+};
+#elif defined(SECOND)
+struct S1 {
+  private:
+};
+#else
+S1 s1;
+// expected-error@first.h:* {{'S1' has different definitions in different modules; first difference is definition in module 'first' found public access specifier}}
+// expected-note@second.h:* {{but in 'second' found private access specifier}}
+#endif
+
+#if defined(FIRST)
+struct S2Friend2 {};
+struct S2 {
+  friend S2Friend2;
+};
+#elif defined(SECOND)
+struct S2Friend1 {};
+struct S2 {
+  friend S2Friend1;
+};
+#else
+S2 s2;
+// expected-error@first.h:* {{'S2' has different definitions in different modules; first difference is definition in module 'first' found friend 'S2Friend2'}}
+// expected-note@second.h:* {{but in 'second' found other friend 'S2Friend1'}}
+#endif
+
+#if defined(FIRST)
+template
+struct S3Template {};
+struct S3 {
+  friend S3Template;
+};
+#elif defined(SECOND)
+template
+struct S3Template {};
+struct S3 {
+  friend S3Template;
+};
+#else
+S3 s3;
+// expected-error@first.h:* {{'S3' has different definitions in different modules; first difference is definition in module 'first' found friend 'S3Template'}}
+// expected-note@second.h:* {{but in 'second' found other friend 'S3Template'}}
+#endif
+
+#if defined(FIRST)
+struct S4 {
+  static_assert(1 == 1, "First");
+};
+#elif defined(SECOND)
+struct S4 {
+  static_assert(1 == 1, "Second");
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{'S4' has different definitions in different modules; first difference is definition in module 'first' found static assert with message}}
+// expected-note@second.h:* {{but in 'second' found static assert with different message}}
+#endif
+
+#if defined(FIRST)
+struct S5 {
+  static_assert(1 == 1, "Message");
+};
+#elif defined(SECOND)
+struct S5 {
+  static_assert(2 == 2, "Message");
+};
+#else
+S5 s5;
+// expected-error@first.h:* {{'S5' has different definitions in different modules; first difference is definition in module 'first' found static assert with condition}}
+// expected-note@second.h:* {{but in 'second' found static assert with different condition}}
+#endif
+
+#if defined(FIRST)
+struct S6 {
+  int First();
+};
+#elif defined(SECOND)
+struct S6 {
+  int Second();
+};
+#else
+S6 s6;
+// expected-error@second.h:* {{'S6::Second' from module 'second' is not present in definition of 'S6' in module 'first'}}
+// expected-note@first.h:* {{definition has no member 'Second'}}
+#endif
+
+#if defined(FIRST)
+struct S7 {
+  double foo();
+};
+#elif defined(SECOND)
+struct S7 {
+  int foo();
+};
+#else
+S7 s7;
+// expected-error@second.h:* {{'S7::foo' from module 'second' is not present in definition of 'S7' in module 'first'}}
+// expected-note@first.h:* {{declaration of 'foo' does not match}}
+#endif
+
+#if defined(FIRST)
+struct S8 {
+  void foo();
+};
+#elif defined(SECOND)
+struct S8 {
+  void foo() {}
+};
+#else

[PATCH] D28845: Prototype of modules codegen

2017-01-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 86140.
dblaikie added a comment.

- More test coverage (for local static variables)


https://reviews.llvm.org/D28845

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/ExternalASTSource.h
  include/clang/Basic/LangOptions.def
  include/clang/Basic/Module.h
  include/clang/Driver/CC1Options.td
  include/clang/Serialization/ASTBitCodes.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  lib/AST/ASTContext.cpp
  lib/AST/ExternalASTSource.cpp
  lib/Basic/Module.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/ModuleMap.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/codegen/bar.h
  test/Modules/Inputs/codegen/bar.modulemap
  test/Modules/Inputs/codegen/foo.h
  test/Modules/Inputs/codegen/foo.modulemap
  test/Modules/Inputs/codegen/use.cpp
  test/Modules/codegen.test

Index: test/Modules/codegen.test
===
--- /dev/null
+++ test/Modules/codegen.test
@@ -0,0 +1,64 @@
+RUN: rm -rf %t
+
+RUN: %clang_cc1 -fmodule-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
+RUN: %clang_cc1 -fmodule-codegen -x c++ -fmodules -emit-module -fmodule-name=bar %S/Inputs/codegen/bar.modulemap -o %t/bar.pcm -fmodule-file=%t/foo.pcm
+
+RUN: %clang_cc1 -emit-llvm %t/foo.pcm -o - | FileCheck --check-prefix=FOO %s
+RUN: %clang_cc1 -emit-llvm %t/bar.pcm -o - -fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR %s
+RUN: %clang_cc1 -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen/use.cpp -emit-llvm -o - | FileCheck --check-prefix=USE-CMN --check-prefix=USE %s
+
+RUN: %clang_cc1 -O2 -disable-llvm-passes -emit-llvm %t/foo.pcm -o - | FileCheck --check-prefix=FOO %s
+RUN: %clang_cc1 -O2 -disable-llvm-passes -emit-llvm %t/bar.pcm -o - -fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR-OPT %s
+RUN: %clang_cc1 -O2 -disable-llvm-passes -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen/use.cpp -emit-llvm -o - | FileCheck --check-prefix=USE-CMN --check-prefix=USE-OPT %s
+
+FOO-NOT: comdat
+FOO: $_Z3foov = comdat any
+FOO: $_Z4foo2v = comdat any
+FOO: $_ZZ3foovE1i = comdat any
+FOO: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
+FOO-NOT: {{comdat|define|declare}}
+FOO: define void @_Z7foo_extv()
+FOO-NOT: {{define|declare}}
+FOO: define weak_odr void @_Z3foov() #{{[0-9]+}} comdat
+FOO-NOT: {{define|declare}}
+FOO: declare void @_Z2f1Ri(i32*
+FOO-NOT: {{define|declare}}
+
+FIXME: this internal function should be weak_odr, comdat, and with a new mangling
+FOO: define internal void @_ZL2f2v() #{{[0-9]+}}
+FOO-NOT: {{define|declare}}
+
+FOO: define weak_odr void @_Z4foo2v() #{{[0-9]+}} comdat
+FOO-NOT: {{define|declare}}
+
+
+BAR-CMN-NOT: comdat
+BAR-CMN: $_Z3barv = comdat any
+BAR-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
+BAR-CMN-NOT: {{comdat|define|declare}}
+BAR-CMN: define weak_odr void @_Z3barv() #{{[0-9]+}} comdat
+BAR-CMN-NOT: {{define|declare}}
+BAR: declare void @_Z3foov()
+Include all the available_externally definitions required for bar (foo -> f2)
+BAR-OPT: define available_externally void @_Z3foov()
+BAR-CMN-NOT: {{define|declare}}
+BAR-OPT: declare void @_Z2f1Ri(i32*
+BAR-OPT-NOT: {{define|declare}}
+BAR-OPT: define available_externally void @_ZL2f2v()
+BAR-OPT-NOT: {{define|declare}}
+
+
+USE-OPT: @_ZZ3foovE1i = linkonce_odr global i32 0, comdat
+USE-CMN-NOT: {{comdat|define|declare}}
+USE-CMN: define i32 @main()
+USE-CMN-NOT: {{define|declare}}
+USE: declare void @_Z3barv()
+Include all the available_externally definitions required for main (bar -> foo -> f2)
+USE-OPT: define available_externally void @_Z3barv()
+USE-CMN-NOT: {{define|declare}}
+USE-OPT: define available_externally void @_Z3foov()
+USE-OPT-NOT: {{define|declare}}
+USE-OPT: declare void @_Z2f1Ri(i32*
+USE-OPT-NOT: {{define|declare}}
+USE-OPT: define available_externally void @_ZL2f2v()
+USE-OPT-NOT: {{define|declare}}
Index: test/Modules/Inputs/codegen/use.cpp
===
--- /dev/null
+++ test/Modules/Inputs/codegen/use.cpp
@@ -0,0 +1,2 @@
+#include "bar.h"
+int main() { bar(); }
Index: test/Modules/Inputs/codegen/foo.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/codegen/foo.modulemap
@@ -0,0 +1 @@
+module foo { header "foo.h" }
Index: test/Modules/Inputs/codegen/foo.h
===
--- /dev/null
+++ test/Modules/Inputs/codegen/foo.h
@@ -0,0 +1,10 @@
+void f1(int&);
+static void f2() { }
+inline void foo() {
+  static int i;
+  f1(i);
+  f2();
+}
+inline void foo2() {
+}
+void foo_ext() {}
Index: test/Modules/Inputs/codegen/bar.modulemap

[PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293344: Fix linkage of static locals in available_externally 
functions to be… (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D29233?vs=86137=86138#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29233

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp


Index: cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
===
--- cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
+++ cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int 
ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -8892,22 +8892,30 @@
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-if (LexicalContext)
-  StaticLocalLinkage =
-  Context.GetGVALinkageForFunction(cast(LexicalContext));
-
-// GVA_StrongODR function linkage is stronger than what we need,
-// downgrade to GVA_DiscardableODR.
-// This allows us to discard the variable if we never end up needing it.
-return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
-   : StaticLocalLinkage;
+// ObjC Blocks can create local variables that don't have a FunctionDecl
+// LexicalContext.
+if (!LexicalContext)
+  return GVA_DiscardableODR;
+
+// Otherwise, let the static local variable inherit its linkage from the
+// nearest enclosing function.
+auto StaticLocalLinkage =
+Context.GetGVALinkageForFunction(cast(LexicalContext));
+
+// Itanium ABI 5.2.2: "Each COMDAT group [for a static local variable] must
+// be emitted in any object with references to the symbol for the object it
+// contains, whether inline or out-of-line."
+// Similar behavior is observed with MSVC. An alternative ABI could use
+// StrongODR/AvailableExternally to match the function, but none are
+// known/supported currently.
+if (StaticLocalLinkage == GVA_StrongODR ||
+StaticLocalLinkage == GVA_AvailableExternally)
+  return GVA_DiscardableODR;
+return StaticLocalLinkage;
   }
 
   // MSVC treats in-class initialized static data members as definitions.


Index: cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
===
--- cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
+++ cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -8892,22 +8892,30 @@
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-

[PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 86137.
dblaikie added a comment.

Improve comment/mention Itanium ABI


https://reviews.llvm.org/D29233

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenCXX/explicit-instantiation.cpp


Index: test/CodeGenCXX/explicit-instantiation.cpp
===
--- test/CodeGenCXX/explicit-instantiation.cpp
+++ test/CodeGenCXX/explicit-instantiation.cpp
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int 
ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8892,22 +8892,30 @@
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-if (LexicalContext)
-  StaticLocalLinkage =
-  Context.GetGVALinkageForFunction(cast(LexicalContext));
-
-// GVA_StrongODR function linkage is stronger than what we need,
-// downgrade to GVA_DiscardableODR.
-// This allows us to discard the variable if we never end up needing it.
-return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
-   : StaticLocalLinkage;
+// ObjC Blocks can create local variables that don't have a FunctionDecl
+// LexicalContext.
+if (!LexicalContext)
+  return GVA_DiscardableODR;
+
+// Otherwise, let the static local variable inherit its linkage from the
+// nearest enclosing function.
+auto StaticLocalLinkage =
+Context.GetGVALinkageForFunction(cast(LexicalContext));
+
+// Itanium ABI 5.2.2: "Each COMDAT group [for a static local variable] must
+// be emitted in any object with references to the symbol for the object it
+// contains, whether inline or out-of-line."
+// Similar behavior is observed with MSVC. An alternative ABI could use
+// StrongODR/AvailableExternally to match the function, but none are
+// known/supported currently.
+if (StaticLocalLinkage == GVA_StrongODR ||
+StaticLocalLinkage == GVA_AvailableExternally)
+  return GVA_DiscardableODR;
+return StaticLocalLinkage;
   }
 
   // MSVC treats in-class initialized static data members as definitions.


Index: test/CodeGenCXX/explicit-instantiation.cpp
===
--- test/CodeGenCXX/explicit-instantiation.cpp
+++ test/CodeGenCXX/explicit-instantiation.cpp
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8892,22 +8892,30 @@
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-if (LexicalContext)
-  StaticLocalLinkage =
-  Context.GetGVALinkageForFunction(cast(LexicalContext));
-
-// GVA_StrongODR function linkage is stronger than what we need,
-// downgrade to GVA_DiscardableODR.
-// This allows us to discard the variable if we never end up needing it.
-return 

r293344 - Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Jan 27 17:11:10 2017
New Revision: 293344

URL: http://llvm.org/viewvc/llvm-project?rev=293344=rev
Log:
Fix linkage of static locals in available_externally functions to be 
DiscardableODR/linkonce_odr

As Mehdi put it, entities should either be
available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
functions are emitted a_e/weak, their local variables were emitted
a_e/linkonce_odr.

While it might be nice to emit them a_e/weak, the Itanium ABI (& best
guess at MSVC's behavior as well) requires the local to be
linkonce/linkonce.

Reviewers: rsmith, mehdi_amini

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=293344=293343=293344=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jan 27 17:11:10 2017
@@ -8892,22 +8892,30 @@ static GVALinkage basicGVALinkageForVari
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-if (LexicalContext)
-  StaticLocalLinkage =
-  Context.GetGVALinkageForFunction(cast(LexicalContext));
+// ObjC Blocks can create local variables that don't have a FunctionDecl
+// LexicalContext.
+if (!LexicalContext)
+  return GVA_DiscardableODR;
 
-// GVA_StrongODR function linkage is stronger than what we need,
-// downgrade to GVA_DiscardableODR.
-// This allows us to discard the variable if we never end up needing it.
-return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
-   : StaticLocalLinkage;
+// Otherwise, let the static local variable inherit its linkage from the
+// nearest enclosing function.
+auto StaticLocalLinkage =
+Context.GetGVALinkageForFunction(cast(LexicalContext));
+
+// Itanium ABI 5.2.2: "Each COMDAT group [for a static local variable] must
+// be emitted in any object with references to the symbol for the object it
+// contains, whether inline or out-of-line."
+// Similar behavior is observed with MSVC. An alternative ABI could use
+// StrongODR/AvailableExternally to match the function, but none are
+// known/supported currently.
+if (StaticLocalLinkage == GVA_StrongODR ||
+StaticLocalLinkage == GVA_AvailableExternally)
+  return GVA_DiscardableODR;
+return StaticLocalLinkage;
   }
 
   // MSVC treats in-class initialized static data members as definitions.

Modified: cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp?rev=293344=293343=293344=diff
==
--- cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/explicit-instantiation.cpp Fri Jan 27 17:11:10 
2017
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int 
ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@ template  void S::f() {}
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}


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


[PATCH] D29234: [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)

2017-01-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293343: [ubsan] Sanity-check shift amounts before truncation 
(fixes PR27271) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29234?vs=86130=86134#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29234

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/ubsan-shift.c


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2751,8 +2751,8 @@
isa(Ops.LHS->getType())) {
 CodeGenFunction::SanitizerScope SanScope();
 SmallVector Checks;
-llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, RHS);
-llvm::Value *ValidExponent = Builder.CreateICmpULE(RHS, WidthMinusOne);
+llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
+llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS, WidthMinusOne);
 
 if (SanitizeExponent) {
   Checks.push_back(
Index: cfe/trunk/test/CodeGen/ubsan-shift.c
===
--- cfe/trunk/test/CodeGen/ubsan-shift.c
+++ cfe/trunk/test/CodeGen/ubsan-shift.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsanitize=shift-exponent 
-emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @f1
+int f1(int c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f2
+int f2(long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f3
+unsigned f3(unsigned c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f4
+unsigned f4(unsigned long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}


Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2751,8 +2751,8 @@
isa(Ops.LHS->getType())) {
 CodeGenFunction::SanitizerScope SanScope();
 SmallVector Checks;
-llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, RHS);
-llvm::Value *ValidExponent = Builder.CreateICmpULE(RHS, WidthMinusOne);
+llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
+llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS, WidthMinusOne);
 
 if (SanitizeExponent) {
   Checks.push_back(
Index: cfe/trunk/test/CodeGen/ubsan-shift.c
===
--- cfe/trunk/test/CodeGen/ubsan-shift.c
+++ cfe/trunk/test/CodeGen/ubsan-shift.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsanitize=shift-exponent -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @f1
+int f1(int c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f2
+int f2(long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f3
+unsigned f3(unsigned c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f4
+unsigned f4(unsigned long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r293343 - [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)

2017-01-27 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Jan 27 17:02:44 2017
New Revision: 293343

URL: http://llvm.org/viewvc/llvm-project?rev=293343=rev
Log:
[ubsan] Sanity-check shift amounts before truncation (fixes PR27271)

Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.

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

Added:
cfe/trunk/test/CodeGen/ubsan-shift.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=293343=293342=293343=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Jan 27 17:02:44 2017
@@ -2751,8 +2751,8 @@ Value *ScalarExprEmitter::EmitShl(const
isa(Ops.LHS->getType())) {
 CodeGenFunction::SanitizerScope SanScope();
 SmallVector Checks;
-llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, RHS);
-llvm::Value *ValidExponent = Builder.CreateICmpULE(RHS, WidthMinusOne);
+llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
+llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS, WidthMinusOne);
 
 if (SanitizeExponent) {
   Checks.push_back(

Added: cfe/trunk/test/CodeGen/ubsan-shift.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-shift.c?rev=293343=auto
==
--- cfe/trunk/test/CodeGen/ubsan-shift.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-shift.c Fri Jan 27 17:02:44 2017
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsanitize=shift-exponent 
-emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @f1
+int f1(int c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f2
+int f2(long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f3
+unsigned f3(unsigned c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f4
+unsigned f4(unsigned long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}


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


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread Richard Smith via cfe-commits
On 27 January 2017 at 14:44, David Blaikie  wrote:

>
>
> On Fri, Jan 27, 2017 at 2:11 PM Mehdi AMINI via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> mehdi_amini accepted this revision.
>> mehdi_amini added a comment.
>> This revision is now accepted and ready to land.
>>
>> LGTM.
>>
>>
>>
>> 
>> Comment at: lib/AST/ASTContext.cpp:8909
>> +
>> +// Itanium ABI (& MSVC seems to do similarly) requires static locals
>> in
>> +// inline functions to be emitted anywhere they're needed, even if
>> the
>> 
>> I assume you looked it up, do you have a ref? (Citation or pointer to
>> right section/paragraph).
>>
>
> Would you like a citation in source? I thought that might be a bit strong
> since this is ABI-neutral code, notionally (so I was straddling that line a
> bit).
>
> I can't quite figure out how to navigate/find the ABI document nor cast
> the runes as Richard did for the citation, so hopefully he can chime in
> here.
>

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-static

5.2.2: "Each COMDAT group [for a static local variable] must be emitted in
any object with references to the symbol for the object it contains,
whether inline or out-of-line."
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread Hans Wennborg via cfe-commits
On Fri, Jan 27, 2017 at 2:55 PM, David Blaikie  wrote:
>
>
> On Fri, Jan 27, 2017 at 2:51 PM Mehdi Amini  wrote:
>>
>> On Jan 27, 2017, at 2:43 PM, David Blaikie  wrote:
>>
>>
>>
>> On Fri, Jan 27, 2017 at 2:13 PM Mehdi Amini  wrote:
>>>
>>> CC Hans.
>>>
>>> This is not a regression (AFAICT), but this is a quality improvement, so
>>> may be worth considering in the 4.0 branch?
>>
>>
>> Perhaps - I'd generally err on the "if it's not a regression, don't hold
>> the boat”.
>>
>>
>> I agree with “don’t hold the boat”, but I usually understand by that
>> “don’t delay the release or change the schedule”, do you mean something
>> else?
>
>
> *nod* fair point - though usually there's some amount of risk to any change
> & I tend to err on the "unless there's a known/likely need, choose not to
> take that risk". In this case we've all been using this setup for years
> without incident so while it's possibly a problem it seems somewhat
> abstract.
>
>>
>> It is likely that the bar should get higher as we get closer to the
>> release, I don’t know if the branching point should be considered the point
>> where we stop taking changes that aren’t regression fixes?
>>
>>
>> LLVM's been this way for a while (good question as to how long - looks
>> like at the latest it was introduced in April 2014
>> (https://llvm.org/svn/llvm-project/cfe/trunk@207451,
>> http://reviews.llvm.org/D3515) & no one's noticed). But no big deal either
>> way if other's feel like it ought to go in.
>>
>>
>> I’m (very) biased by the way we (Apple) organize our release: we will
>> cherry-pick any bug fixes (and other “quality improvements”), regression or
>> not, for months after the branching point.
>>
>> So up to the release manager :)
>
>
> *nod* sure sure - I'm not fussed either way :)

I'll pass on this one since it's not a regression and not a trivial change.

Thanks,
Hans


>>> > On Jan 27, 2017, at 2:04 PM, David Blaikie via Phabricator
>>> >  wrote:
>>> >
>>> > dblaikie created this revision.
>>> >
>>> > As Mehdi put it, entities should either be
>>> > available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
>>> > functions are emitted a_e/weak, their local variables were emitted
>>> > a_e/linkonce_odr.
>>> >
>>> > While it might be nice to emit them a_e/weak, the Itanium ABI (& best
>>> > guess at MSVC's behavior as well) requires the local to be
>>> > linkonce/linkonce.
>>> >
>>> >
>>> > https://reviews.llvm.org/D29233
>>> >
>>> > Files:
>>> >  lib/AST/ASTContext.cpp
>>> >  test/CodeGenCXX/explicit-instantiation.cpp
>>> >
>>> >
>>> > Index: test/CodeGenCXX/explicit-instantiation.cpp
>>> > ===
>>> > --- test/CodeGenCXX/explicit-instantiation.cpp
>>> > +++ test/CodeGenCXX/explicit-instantiation.cpp
>>> > @@ -5,6 +5,9 @@
>>> > // This check logically is attached to 'template int S::i;' below.
>>> > // CHECK: @_ZN1SIiE1iE = weak_odr global i32
>>> >
>>> > +// This check is logically attached to 'template int
>>> > ExportedStaticLocal::f()' below.
>>> > +// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr
>>> > global
>>> > +
>>> > template
>>> > struct plus {
>>> >   Result operator()(const T& t, const U& u) const;
>>> > @@ -153,3 +156,17 @@
>>> > template  void S::g() {}
>>> > template  int S::i;
>>> > template  void S::S2::h() {}
>>> > +
>>> > +namespace ExportedStaticLocal {
>>> > +void sink(int&);
>>> > +template 
>>> > +inline void f() {
>>> > +  static int i;
>>> > +  sink(i);
>>> > +}
>>> > +// See the check line at the top of the file.
>>> > +extern template void f();
>>> > +void use() {
>>> > +  f();
>>> > +}
>>> > +}
>>> > Index: lib/AST/ASTContext.cpp
>>> > ===
>>> > --- lib/AST/ASTContext.cpp
>>> > +++ lib/AST/ASTContext.cpp
>>> > @@ -8892,22 +8892,27 @@
>>> > return GVA_Internal;
>>> >
>>> >   if (VD->isStaticLocal()) {
>>> > -GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
>>> > const DeclContext *LexicalContext =
>>> > VD->getParentFunctionOrMethod();
>>> > while (LexicalContext && !isa(LexicalContext))
>>> >   LexicalContext = LexicalContext->getLexicalParent();
>>> >
>>> > -// Let the static local variable inherit its linkage from the
>>> > nearest
>>> > -// enclosing function.
>>> > -if (LexicalContext)
>>> > -  StaticLocalLinkage =
>>> > -
>>> > Context.GetGVALinkageForFunction(cast(LexicalContext));
>>> > -
>>> > -// GVA_StrongODR function linkage is stronger than what we need,
>>> > -// downgrade to GVA_DiscardableODR.
>>> > -// This allows us to discard the variable if we never end up
>>> > needing it.
>>> > -return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
>>> > -   : StaticLocalLinkage;
>>> > +// ObjC Blocks can create local variables 

Re: Add warning for c++ member variable shadowing

2017-01-27 Thread Richard Smith via cfe-commits
+def warn_shadow_member_variable : Warning<
+  "shadowed variable '%0' in type '%1' inheriting from type '%2'">,

The phrasing of this is incorrect: the things you're warning about are not
variables, they're non-static data members. Perhaps something like:

  "non-static data member '%0' of '%1' shadows member inherited from type
'%2'"

+   InGroup;

Would it make sense to put this in a subgroup of -Wshadow so that it can be
controlled separately?

+  /// Check if there is a member variable shadowing

Please end comments in a period.

+  void CheckShadowInheritedVariables(const SourceLocation ,

Likewise, 'Variables' is wrong. We would typically use the C term 'Fields'
for these cases within Clang sources.

+  for (const auto  : DC->bases()) {
+if (const auto *TSI = Base.getTypeSourceInfo())
+  if (const auto *BaseClass = TSI->getType()->getAsCXXRecordDecl()) {
+for (const auto *Field : BaseClass->fields())
+  if (Field->getName() == FieldName)
+Diag(Loc, diag::warn_shadow_member_variable)
+  << FieldName << RD->getName() << BaseClass->getName();
+// Search parent's parents
+CheckShadowInheritedVariables(Loc, FieldName, RD, BaseClass);
+  }
+  }

Maybe we should avoid diagnosing shadowing of members that are inaccessible
from the derived class? What about if the field name is ambiguous? Also, we
shouldn't recurse if lookup finds something with the given name in this
class, and ideally we would only visit each class once, even if it appears
multiple times in a multiple-inheritance scenario.
CXXRecordDecl::lookupInBases can handle most of these cases for you
automatically, and will also let you build a set of paths to problematic
base classes in case you want to report those.

On 24 January 2017 at 20:52, James Sun  wrote:

> Thanks for the comments. The new version is attached.
>
> Wrt two of your questions:
>
>
>
> (1)  “The description that you have on CheckShadowInheritedVariables
> isn't really the type of comments that we have in doxygen form.  Im not
> sure if its in line with the rest of the code.”
>
> I’ve read through the doxygen wiki; hopefully it’s fixed; let me know if
> it’s still wrong
>
>
>
> (2) “Why are you checking that the DeclContext has a definition rather
> than the record itself?”
>
> There are cases like “struct A; struct B : A {};”, where A does not have a
> definition. The compiler will hit an assertion failure if we call A.bases()
> directly.
>
>
>
> Thanks
>
>
>
> James
>
>
>
>
>
> *From: *Saleem Abdulrasool 
> *Date: *Tuesday, January 24, 2017 at 7:10 PM
> *To: *James Sun 
> *Cc: *"cfe-commits@lists.llvm.org" , Aaron
> Ballman , Richard Smith 
> *Subject: *Re: Add warning for c++ member variable shadowing
>
>
>
> Some more stylistic comments:
>
>
>
> The description that you have on CheckShadowInheritedVariables isn't
> really the type of comments that we have in doxygen form.  Im not sure if
> its in line with the rest of the code.
>
>
>
> The ignore warning comments are restating what is in the code, please
> remove them.
>
>
>
> Could you make the header and the source file match the name?
>
>
>
> Why are you checking that the DeclContext has a definition rather than the
> record itself?
>
>
>
> Space after the <<.
>
>
>
> Don't use the cast for the check, use isa.  Although, since you use the
> value later, it is probably better to write this as:
>
>
>
> if (const auto *RD = cast(CurContext))
>
>   CheckShadowInheritedVariabless(Loc, Name.getAsString(), RD, RD);
>
>
>
>
>
>
>
> On Tue, Jan 24, 2017 at 4:06 PM, James Sun via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Coding style change
>
>
>
> *From: *James Sun 
> *Date: *Tuesday, January 24, 2017 at 2:36 PM
> *To: *"cfe-commits@lists.llvm.org" 
> *Subject: *Add warning for c++ member variable shadowing
>
>
>
> Dear members
>
>
>
> Here is a patch (attached) to create warnings where a member variable
> shadows the one in one of its inheriting classes. For cases where we really
> don't want to shadow member variables, e.g.
>
>
>
> class a {
>
>   int foo;
>
> }
>
>
>
> class b : a {
>
>   int foo; // Generate a warning
>
> }
>
>
>
> This patch
>
> (1) adds a member variable shadowing checking, and
>
> (2) incorporates it to the unit tests.
>
>
>
>
>
> Comments are welcome.
>
>
>
> Thanks
>
>
>
> James
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
>
>
>
>
>
> --
>
> Saleem Abdulrasool
> 

Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via cfe-commits
On Fri, Jan 27, 2017 at 2:51 PM Mehdi Amini  wrote:

> On Jan 27, 2017, at 2:43 PM, David Blaikie  wrote:
>
>
>
> On Fri, Jan 27, 2017 at 2:13 PM Mehdi Amini  wrote:
>
> CC Hans.
>
> This is not a regression (AFAICT), but this is a quality improvement, so
> may be worth considering in the 4.0 branch?
>
>
> Perhaps - I'd generally err on the "if it's not a regression, don't hold
> the boat”.
>
>
> I agree with “don’t hold the boat”, but I usually understand by that
> “don’t delay the release or change the schedule”, do you mean something
> else?
>

*nod* fair point - though usually there's some amount of risk to any change
& I tend to err on the "unless there's a known/likely need, choose not to
take that risk". In this case we've all been using this setup for years
without incident so while it's possibly a problem it seems somewhat
abstract.


> It is likely that the bar should get higher as we get closer to the
> release, I don’t know if the branching point should be considered the point
> where we stop taking changes that aren’t regression fixes?
>
>
> LLVM's been this way for a while (good question as to how long - looks
> like at the latest it was introduced in April 2014 (
> https://llvm.org/svn/llvm-project/cfe/trunk@207451,
> http://reviews.llvm.org/D3515) & no one's noticed). But no big deal
> either way if other's feel like it ought to go in.
>
>
> I’m (very) biased by the way we (Apple) organize our release: we will
> cherry-pick any bug fixes (and other “quality improvements”), regression or
> not, for months after the branching point.
>
> So up to the release manager :)
>

*nod* sure sure - I'm not fussed either way :)

- Dave


>
> —
> Mehdi
>
>
> > On Jan 27, 2017, at 2:04 PM, David Blaikie via Phabricator <
> revi...@reviews.llvm.org> wrote:
> >
> > dblaikie created this revision.
> >
> > As Mehdi put it, entities should either be
> > available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
> > functions are emitted a_e/weak, their local variables were emitted
> > a_e/linkonce_odr.
> >
> > While it might be nice to emit them a_e/weak, the Itanium ABI (& best
> > guess at MSVC's behavior as well) requires the local to be
> > linkonce/linkonce.
> >
> >
> > https://reviews.llvm.org/D29233
> >
> > Files:
> >  lib/AST/ASTContext.cpp
> >  test/CodeGenCXX/explicit-instantiation.cpp
> >
> >
> > Index: test/CodeGenCXX/explicit-instantiation.cpp
> > ===
> > --- test/CodeGenCXX/explicit-instantiation.cpp
> > +++ test/CodeGenCXX/explicit-instantiation.cpp
> > @@ -5,6 +5,9 @@
> > // This check logically is attached to 'template int S::i;' below.
> > // CHECK: @_ZN1SIiE1iE = weak_odr global i32
> >
> > +// This check is logically attached to 'template int
> ExportedStaticLocal::f()' below.
> > +// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr
> global
> > +
> > template
> > struct plus {
> >   Result operator()(const T& t, const U& u) const;
> > @@ -153,3 +156,17 @@
> > template  void S::g() {}
> > template  int S::i;
> > template  void S::S2::h() {}
> > +
> > +namespace ExportedStaticLocal {
> > +void sink(int&);
> > +template 
> > +inline void f() {
> > +  static int i;
> > +  sink(i);
> > +}
> > +// See the check line at the top of the file.
> > +extern template void f();
> > +void use() {
> > +  f();
> > +}
> > +}
> > Index: lib/AST/ASTContext.cpp
> > ===
> > --- lib/AST/ASTContext.cpp
> > +++ lib/AST/ASTContext.cpp
> > @@ -8892,22 +8892,27 @@
> > return GVA_Internal;
> >
> >   if (VD->isStaticLocal()) {
> > -GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
> > const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
> > while (LexicalContext && !isa(LexicalContext))
> >   LexicalContext = LexicalContext->getLexicalParent();
> >
> > -// Let the static local variable inherit its linkage from the
> nearest
> > -// enclosing function.
> > -if (LexicalContext)
> > -  StaticLocalLinkage =
> > -
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> > -
> > -// GVA_StrongODR function linkage is stronger than what we need,
> > -// downgrade to GVA_DiscardableODR.
> > -// This allows us to discard the variable if we never end up
> needing it.
> > -return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
> > -   : StaticLocalLinkage;
> > +// ObjC Blocks can create local variables that don't have a
> FunctionDecl
> > +// LexicalContext.
> > +if (!LexicalContext)
> > +  return GVA_DiscardableODR;
> > +
> > +// Otherwise, let the static local variable inherit its linkage
> from the
> > +// nearest enclosing function.
> > +auto StaticLocalLinkage =
> > +
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> > +
> > +// Itanium ABI 

Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread Mehdi Amini via cfe-commits

> On Jan 27, 2017, at 2:43 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Jan 27, 2017 at 2:13 PM Mehdi Amini  > wrote:
> CC Hans.
> 
> This is not a regression (AFAICT), but this is a quality improvement, so may 
> be worth considering in the 4.0 branch?
> 
> Perhaps - I'd generally err on the "if it's not a regression, don't hold the 
> boat”.

I agree with “don’t hold the boat”, but I usually understand by that “don’t 
delay the release or change the schedule”, do you mean something else?

It is likely that the bar should get higher as we get closer to the release, I 
don’t know if the branching point should be considered the point where we stop 
taking changes that aren’t regression fixes?


> LLVM's been this way for a while (good question as to how long - looks like 
> at the latest it was introduced in April 2014 
> (https://llvm.org/svn/llvm-project/cfe/trunk@207451 
> , 
> http://reviews.llvm.org/D3515 ) & no one's 
> noticed). But no big deal either way if other's feel like it ought to go in.

I’m (very) biased by the way we (Apple) organize our release: we will 
cherry-pick any bug fixes (and other “quality improvements”), regression or 
not, for months after the branching point.

So up to the release manager :)

— 
Mehdi


> > On Jan 27, 2017, at 2:04 PM, David Blaikie via Phabricator 
> > > wrote:
> >
> > dblaikie created this revision.
> >
> > As Mehdi put it, entities should either be
> > available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
> > functions are emitted a_e/weak, their local variables were emitted
> > a_e/linkonce_odr.
> >
> > While it might be nice to emit them a_e/weak, the Itanium ABI (& best
> > guess at MSVC's behavior as well) requires the local to be
> > linkonce/linkonce.
> >
> >
> > https://reviews.llvm.org/D29233 
> >
> > Files:
> >  lib/AST/ASTContext.cpp
> >  test/CodeGenCXX/explicit-instantiation.cpp
> >
> >
> > Index: test/CodeGenCXX/explicit-instantiation.cpp
> > ===
> > --- test/CodeGenCXX/explicit-instantiation.cpp
> > +++ test/CodeGenCXX/explicit-instantiation.cpp
> > @@ -5,6 +5,9 @@
> > // This check logically is attached to 'template int S::i;' below.
> > // CHECK: @_ZN1SIiE1iE = weak_odr global i32
> >
> > +// This check is logically attached to 'template int 
> > ExportedStaticLocal::f()' below.
> > +// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
> > +
> > template
> > struct plus {
> >   Result operator()(const T& t, const U& u) const;
> > @@ -153,3 +156,17 @@
> > template  void S::g() {}
> > template  int S::i;
> > template  void S::S2::h() {}
> > +
> > +namespace ExportedStaticLocal {
> > +void sink(int&);
> > +template 
> > +inline void f() {
> > +  static int i;
> > +  sink(i);
> > +}
> > +// See the check line at the top of the file.
> > +extern template void f();
> > +void use() {
> > +  f();
> > +}
> > +}
> > Index: lib/AST/ASTContext.cpp
> > ===
> > --- lib/AST/ASTContext.cpp
> > +++ lib/AST/ASTContext.cpp
> > @@ -8892,22 +8892,27 @@
> > return GVA_Internal;
> >
> >   if (VD->isStaticLocal()) {
> > -GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
> > const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
> > while (LexicalContext && !isa(LexicalContext))
> >   LexicalContext = LexicalContext->getLexicalParent();
> >
> > -// Let the static local variable inherit its linkage from the nearest
> > -// enclosing function.
> > -if (LexicalContext)
> > -  StaticLocalLinkage =
> > -  
> > Context.GetGVALinkageForFunction(cast(LexicalContext));
> > -
> > -// GVA_StrongODR function linkage is stronger than what we need,
> > -// downgrade to GVA_DiscardableODR.
> > -// This allows us to discard the variable if we never end up needing 
> > it.
> > -return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
> > -   : StaticLocalLinkage;
> > +// ObjC Blocks can create local variables that don't have a 
> > FunctionDecl
> > +// LexicalContext.
> > +if (!LexicalContext)
> > +  return GVA_DiscardableODR;
> > +
> > +// Otherwise, let the static local variable inherit its linkage from 
> > the
> > +// nearest enclosing function.
> > +auto StaticLocalLinkage =
> > +
> > Context.GetGVALinkageForFunction(cast(LexicalContext));
> > +
> > +// Itanium ABI (& MSVC seems to do similarly) requires static locals in
> > +// inline functions to be emitted anywhere they're needed, even if the
> > +// function they are local to is emitted StrongODR/AvailableExternally.
> > +if 

Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via cfe-commits
On Fri, Jan 27, 2017 at 2:48 PM Mehdi Amini  wrote:

> On Jan 27, 2017, at 2:44 PM, David Blaikie  wrote:
>
>
>
> On Fri, Jan 27, 2017 at 2:11 PM Mehdi AMINI via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
> mehdi_amini accepted this revision.
> mehdi_amini added a comment.
> This revision is now accepted and ready to land.
>
> LGTM.
>
>
>
> 
> Comment at: lib/AST/ASTContext.cpp:8909
> +
> +// Itanium ABI (& MSVC seems to do similarly) requires static locals
> in
> +// inline functions to be emitted anywhere they're needed, even if the
> 
> I assume you looked it up, do you have a ref? (Citation or pointer to
> right section/paragraph).
>
>
> Would you like a citation in source?
>
>
> Sure, why not?
>
> I thought that might be a bit strong since this is ABI-neutral code,
> notionally (so I was straddling that line a bit).
>
>
> Well you refer to the ABI anyway already to explain the chosen behavior :)
>
> And technically I’m not sure what the C++ standard mandates, the
> possibility of having different need for different ABI would indicate that
> the code can’t be totally ABI-neutral?
>

Right, this one is beyond the C++ standard's reach. It's really an ABI
issue, so arguably should be sunk into Clang's ABI understanding, just that
for now all (Itanium + MSVC) the situations we know of/support have this
behavior so there's no immediate need for that abstraction/extension point.


>
> —
> Mehdi
>
>
>
> I can't quite figure out how to navigate/find the ABI document nor cast
> the runes as Richard did for the citation, so hopefully he can chime in
> here.
>
>
>
>
> https://reviews.llvm.org/D29233
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via cfe-commits
Reid:

Richard and I played around with this with MSVC on godbolt

but
weren't able to get MSVC to inline an template under an explicit
instantiation declaration, so while we can see that the definition side
doesn't provide a definition for the static local if it optimizes it away
(so that seems consistent with the Itanium ABI and GCC's behavior here - no
weak_odr definition on the definition side) we couldn't check the
declaration/available_externally side to see if it would produce its own
linkonce_odr-type definition.

If you knew of any ways to check, or ways to verify Clang's behavior here
is consistent (it looks like it will be with this patch), that might be
handy.

- Dave

On Fri, Jan 27, 2017 at 2:04 PM David Blaikie via Phabricator via
cfe-commits  wrote:

> dblaikie created this revision.
>
> As Mehdi put it, entities should either be
> available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
> functions are emitted a_e/weak, their local variables were emitted
> a_e/linkonce_odr.
>
> While it might be nice to emit them a_e/weak, the Itanium ABI (& best
> guess at MSVC's behavior as well) requires the local to be
> linkonce/linkonce.
>
>
> https://reviews.llvm.org/D29233
>
> Files:
>   lib/AST/ASTContext.cpp
>   test/CodeGenCXX/explicit-instantiation.cpp
>
>
> Index: test/CodeGenCXX/explicit-instantiation.cpp
> ===
> --- test/CodeGenCXX/explicit-instantiation.cpp
> +++ test/CodeGenCXX/explicit-instantiation.cpp
> @@ -5,6 +5,9 @@
>  // This check logically is attached to 'template int S::i;' below.
>  // CHECK: @_ZN1SIiE1iE = weak_odr global i32
>
> +// This check is logically attached to 'template int
> ExportedStaticLocal::f()' below.
> +// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
> +
>  template
>  struct plus {
>Result operator()(const T& t, const U& u) const;
> @@ -153,3 +156,17 @@
>  template  void S::g() {}
>  template  int S::i;
>  template  void S::S2::h() {}
> +
> +namespace ExportedStaticLocal {
> +void sink(int&);
> +template 
> +inline void f() {
> +  static int i;
> +  sink(i);
> +}
> +// See the check line at the top of the file.
> +extern template void f();
> +void use() {
> +  f();
> +}
> +}
> Index: lib/AST/ASTContext.cpp
> ===
> --- lib/AST/ASTContext.cpp
> +++ lib/AST/ASTContext.cpp
> @@ -8892,22 +8892,27 @@
>  return GVA_Internal;
>
>if (VD->isStaticLocal()) {
> -GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
>  const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
>  while (LexicalContext && !isa(LexicalContext))
>LexicalContext = LexicalContext->getLexicalParent();
>
> -// Let the static local variable inherit its linkage from the nearest
> -// enclosing function.
> -if (LexicalContext)
> -  StaticLocalLinkage =
> -
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> -
> -// GVA_StrongODR function linkage is stronger than what we need,
> -// downgrade to GVA_DiscardableODR.
> -// This allows us to discard the variable if we never end up needing
> it.
> -return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
> -   : StaticLocalLinkage;
> +// ObjC Blocks can create local variables that don't have a
> FunctionDecl
> +// LexicalContext.
> +if (!LexicalContext)
> +  return GVA_DiscardableODR;
> +
> +// Otherwise, let the static local variable inherit its linkage from
> the
> +// nearest enclosing function.
> +auto StaticLocalLinkage =
> +
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> +
> +// Itanium ABI (& MSVC seems to do similarly) requires static locals
> in
> +// inline functions to be emitted anywhere they're needed, even if the
> +// function they are local to is 

[PATCH] D29234: [ubsan] Sanity-check shift amounts before truncation (fixes PR27271)

2017-01-27 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

Ubsan does not report UB shifts in some cases where the shift exponent
needs to be truncated to match the type of the shift base. We perform a
range check on the truncated shift amount, leading to false negatives.

Fix the issue (PR27271) by performing the range check on the original
shift amount.


https://reviews.llvm.org/D29234

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ubsan-shift.c


Index: test/CodeGen/ubsan-shift.c
===
--- /dev/null
+++ test/CodeGen/ubsan-shift.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsanitize=shift-exponent 
-emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @f1
+int f1(int c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f2
+int f2(long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f3
+unsigned f3(unsigned c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f4
+unsigned f4(unsigned long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2751,8 +2751,8 @@
isa(Ops.LHS->getType())) {
 CodeGenFunction::SanitizerScope SanScope();
 SmallVector Checks;
-llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, RHS);
-llvm::Value *ValidExponent = Builder.CreateICmpULE(RHS, WidthMinusOne);
+llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
+llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS, WidthMinusOne);
 
 if (SanitizeExponent) {
   Checks.push_back(


Index: test/CodeGen/ubsan-shift.c
===
--- /dev/null
+++ test/CodeGen/ubsan-shift.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsanitize=shift-exponent -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define i32 @f1
+int f1(int c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f2
+int f2(long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1 << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f3
+unsigned f3(unsigned c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+// CHECK: icmp ule i32 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
+
+// CHECK-LABEL: define i32 @f4
+unsigned f4(unsigned long c, int shamt) {
+// CHECK: icmp ule i32 %{{.*}}, 63, !nosanitize
+// CHECK: icmp ule i64 %{{.*}}, 31, !nosanitize
+  return 1U << (c << shamt);
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2751,8 +2751,8 @@
isa(Ops.LHS->getType())) {
 CodeGenFunction::SanitizerScope SanScope();
 SmallVector Checks;
-llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, RHS);
-llvm::Value *ValidExponent = Builder.CreateICmpULE(RHS, WidthMinusOne);
+llvm::Value *WidthMinusOne = GetWidthMinusOneValue(Ops.LHS, Ops.RHS);
+llvm::Value *ValidExponent = Builder.CreateICmpULE(Ops.RHS, WidthMinusOne);
 
 if (SanitizeExponent) {
   Checks.push_back(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread Mehdi Amini via cfe-commits

> On Jan 27, 2017, at 2:44 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Jan 27, 2017 at 2:11 PM Mehdi AMINI via Phabricator 
> > wrote:
> mehdi_amini accepted this revision.
> mehdi_amini added a comment.
> This revision is now accepted and ready to land.
> 
> LGTM.
> 
> 
> 
> 
> Comment at: lib/AST/ASTContext.cpp:8909
> +
> +// Itanium ABI (& MSVC seems to do similarly) requires static locals in
> +// inline functions to be emitted anywhere they're needed, even if the
> 
> I assume you looked it up, do you have a ref? (Citation or pointer to right 
> section/paragraph).
> 
> Would you like a citation in source?

Sure, why not?

> I thought that might be a bit strong since this is ABI-neutral code, 
> notionally (so I was straddling that line a bit).

Well you refer to the ABI anyway already to explain the chosen behavior :)

And technically I’m not sure what the C++ standard mandates, the possibility of 
having different need for different ABI would indicate that the code can’t be 
totally ABI-neutral?

— 
Mehdi
 

> 
> I can't quite figure out how to navigate/find the ABI document nor cast the 
> runes as Richard did for the citation, so hopefully he can chime in here.
>  
> 
> 
> https://reviews.llvm.org/D29233 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via cfe-commits
On Fri, Jan 27, 2017 at 2:11 PM Mehdi AMINI via Phabricator <
revi...@reviews.llvm.org> wrote:

> mehdi_amini accepted this revision.
> mehdi_amini added a comment.
> This revision is now accepted and ready to land.
>
> LGTM.
>
>
>
> 
> Comment at: lib/AST/ASTContext.cpp:8909
> +
> +// Itanium ABI (& MSVC seems to do similarly) requires static locals
> in
> +// inline functions to be emitted anywhere they're needed, even if the
> 
> I assume you looked it up, do you have a ref? (Citation or pointer to
> right section/paragraph).
>

Would you like a citation in source? I thought that might be a bit strong
since this is ABI-neutral code, notionally (so I was straddling that line a
bit).

I can't quite figure out how to navigate/find the ABI document nor cast the
runes as Richard did for the citation, so hopefully he can chime in here.


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


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via cfe-commits
On Fri, Jan 27, 2017 at 2:13 PM Mehdi Amini  wrote:

> CC Hans.
>
> This is not a regression (AFAICT), but this is a quality improvement, so
> may be worth considering in the 4.0 branch?
>

Perhaps - I'd generally err on the "if it's not a regression, don't hold
the boat". LLVM's been this way for a while (good question as to how long -
looks like at the latest it was introduced in April 2014 (
https://llvm.org/svn/llvm-project/cfe/trunk@207451,
http://reviews.llvm.org/D3515) & no one's noticed). But no big deal either
way if other's feel like it ought to go in.


>
> —
> Mehdi
>
> > On Jan 27, 2017, at 2:04 PM, David Blaikie via Phabricator <
> revi...@reviews.llvm.org> wrote:
> >
> > dblaikie created this revision.
> >
> > As Mehdi put it, entities should either be
> > available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
> > functions are emitted a_e/weak, their local variables were emitted
> > a_e/linkonce_odr.
> >
> > While it might be nice to emit them a_e/weak, the Itanium ABI (& best
> > guess at MSVC's behavior as well) requires the local to be
> > linkonce/linkonce.
> >
> >
> > https://reviews.llvm.org/D29233
> >
> > Files:
> >  lib/AST/ASTContext.cpp
> >  test/CodeGenCXX/explicit-instantiation.cpp
> >
> >
> > Index: test/CodeGenCXX/explicit-instantiation.cpp
> > ===
> > --- test/CodeGenCXX/explicit-instantiation.cpp
> > +++ test/CodeGenCXX/explicit-instantiation.cpp
> > @@ -5,6 +5,9 @@
> > // This check logically is attached to 'template int S::i;' below.
> > // CHECK: @_ZN1SIiE1iE = weak_odr global i32
> >
> > +// This check is logically attached to 'template int
> ExportedStaticLocal::f()' below.
> > +// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr
> global
> > +
> > template
> > struct plus {
> >   Result operator()(const T& t, const U& u) const;
> > @@ -153,3 +156,17 @@
> > template  void S::g() {}
> > template  int S::i;
> > template  void S::S2::h() {}
> > +
> > +namespace ExportedStaticLocal {
> > +void sink(int&);
> > +template 
> > +inline void f() {
> > +  static int i;
> > +  sink(i);
> > +}
> > +// See the check line at the top of the file.
> > +extern template void f();
> > +void use() {
> > +  f();
> > +}
> > +}
> > Index: lib/AST/ASTContext.cpp
> > ===
> > --- lib/AST/ASTContext.cpp
> > +++ lib/AST/ASTContext.cpp
> > @@ -8892,22 +8892,27 @@
> > return GVA_Internal;
> >
> >   if (VD->isStaticLocal()) {
> > -GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
> > const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
> > while (LexicalContext && !isa(LexicalContext))
> >   LexicalContext = LexicalContext->getLexicalParent();
> >
> > -// Let the static local variable inherit its linkage from the
> nearest
> > -// enclosing function.
> > -if (LexicalContext)
> > -  StaticLocalLinkage =
> > -
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> > -
> > -// GVA_StrongODR function linkage is stronger than what we need,
> > -// downgrade to GVA_DiscardableODR.
> > -// This allows us to discard the variable if we never end up
> needing it.
> > -return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
> > -   : StaticLocalLinkage;
> > +// ObjC Blocks can create local variables that don't have a
> FunctionDecl
> > +// LexicalContext.
> > +if (!LexicalContext)
> > +  return GVA_DiscardableODR;
> > +
> > +// Otherwise, let the static local variable inherit its linkage
> from the
> > +// nearest enclosing function.
> > +auto StaticLocalLinkage =
> > +
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> > +
> > +// Itanium ABI (& MSVC seems to do similarly) requires static
> locals in
> > +// inline functions to be emitted anywhere they're needed, even if
> the
> > +// function they are local to is emitted
> StrongODR/AvailableExternally.
> > +if (StaticLocalLinkage == GVA_StrongODR ||
> > +StaticLocalLinkage == GVA_AvailableExternally)
> > +  return GVA_DiscardableODR;
> > +return StaticLocalLinkage;
> >   }
> >
> >   // MSVC treats in-class initialized static data members as definitions.
> >
> >
> > 
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread Mehdi Amini via cfe-commits
CC Hans.

This is not a regression (AFAICT), but this is a quality improvement, so may be 
worth considering in the 4.0 branch?

— 
Mehdi

> On Jan 27, 2017, at 2:04 PM, David Blaikie via Phabricator 
>  wrote:
> 
> dblaikie created this revision.
> 
> As Mehdi put it, entities should either be
> available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
> functions are emitted a_e/weak, their local variables were emitted
> a_e/linkonce_odr.
> 
> While it might be nice to emit them a_e/weak, the Itanium ABI (& best
> guess at MSVC's behavior as well) requires the local to be
> linkonce/linkonce.
> 
> 
> https://reviews.llvm.org/D29233
> 
> Files:
>  lib/AST/ASTContext.cpp
>  test/CodeGenCXX/explicit-instantiation.cpp
> 
> 
> Index: test/CodeGenCXX/explicit-instantiation.cpp
> ===
> --- test/CodeGenCXX/explicit-instantiation.cpp
> +++ test/CodeGenCXX/explicit-instantiation.cpp
> @@ -5,6 +5,9 @@
> // This check logically is attached to 'template int S::i;' below.
> // CHECK: @_ZN1SIiE1iE = weak_odr global i32
> 
> +// This check is logically attached to 'template int 
> ExportedStaticLocal::f()' below.
> +// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
> +
> template
> struct plus {
>   Result operator()(const T& t, const U& u) const;
> @@ -153,3 +156,17 @@
> template  void S::g() {}
> template  int S::i;
> template  void S::S2::h() {}
> +
> +namespace ExportedStaticLocal {
> +void sink(int&);
> +template 
> +inline void f() {
> +  static int i;
> +  sink(i);
> +}
> +// See the check line at the top of the file.
> +extern template void f();
> +void use() {
> +  f();
> +}
> +}
> Index: lib/AST/ASTContext.cpp
> ===
> --- lib/AST/ASTContext.cpp
> +++ lib/AST/ASTContext.cpp
> @@ -8892,22 +8892,27 @@
> return GVA_Internal;
> 
>   if (VD->isStaticLocal()) {
> -GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
> const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
> while (LexicalContext && !isa(LexicalContext))
>   LexicalContext = LexicalContext->getLexicalParent();
> 
> -// Let the static local variable inherit its linkage from the nearest
> -// enclosing function.
> -if (LexicalContext)
> -  StaticLocalLinkage =
> -  
> Context.GetGVALinkageForFunction(cast(LexicalContext));
> -
> -// GVA_StrongODR function linkage is stronger than what we need,
> -// downgrade to GVA_DiscardableODR.
> -// This allows us to discard the variable if we never end up needing it.
> -return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
> -   : StaticLocalLinkage;
> +// ObjC Blocks can create local variables that don't have a FunctionDecl
> +// LexicalContext.
> +if (!LexicalContext)
> +  return GVA_DiscardableODR;
> +
> +// Otherwise, let the static local variable inherit its linkage from the
> +// nearest enclosing function.
> +auto StaticLocalLinkage =
> +Context.GetGVALinkageForFunction(cast(LexicalContext));
> +
> +// Itanium ABI (& MSVC seems to do similarly) requires static locals in
> +// inline functions to be emitted anywhere they're needed, even if the
> +// function they are local to is emitted StrongODR/AvailableExternally.
> +if (StaticLocalLinkage == GVA_StrongODR ||
> +StaticLocalLinkage == GVA_AvailableExternally)
> +  return GVA_DiscardableODR;
> +return StaticLocalLinkage;
>   }
> 
>   // MSVC treats in-class initialized static data members as definitions.
> 
> 
> 

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


[PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: lib/AST/ASTContext.cpp:8909
+
+// Itanium ABI (& MSVC seems to do similarly) requires static locals in
+// inline functions to be emitted anywhere they're needed, even if the

I assume you looked it up, do you have a ref? (Citation or pointer to right 
section/paragraph).


https://reviews.llvm.org/D29233



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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Another "fun" testcase:

  struct S {
void operator++(int n) _diagnose_if(n, "wat", "warning");
  };
  void f(S s) {
s++; // no warning
s.operator++(1); // warning
  }




Comment at: include/clang/Sema/Sema.h:2638
 
-  /// Check the diagnose_if attributes on the given function. Returns the
-  /// first succesful fatal attribute, or null if calling Function(Args) isn't
-  /// an error.
+  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
+  /// non-ArgDependent DiagnoseIfAttrs.

Can you add a comment somewhere about here explaining why these functions are 
split? Something like "Argument-dependent diagnose_if attributes are checked 
when the function is used as a direct callee of a function call." here, and 
"Argument-independent diagnose_if attributes are checked on every use of the 
function." below.



Comment at: include/clang/Sema/Sema.h:9925
  SourceLocation Loc, SourceRange Range,
- VariadicCallType CallType);
+ VariadicCallType CallType, const Expr *ThisArg);
 

We have a loose convention that function parameter argument order matches 
source order, which would suggest that `ThisArg` should precede `Args` here.



Comment at: lib/Sema/SemaExprCXX.cpp:6717
+
+  checkDiagnoseIfAttrsOnCall(Method, CE);
   return CE;

Can you call  `CheckFunctionCall` instead here, and remove 
`checkDiagnoseIfAttrsOnCall`? It looks like the only reason we don't already 
call that is because none of its checks could ever fire for a call to a 
conversion function before, and that's no longer true.



Comment at: lib/Sema/SemaOverload.cpp:12035
 
+  checkDiagnoseIfAttrsOnCall(FnDecl, TheCall);
   return MaybeBindToTemporary(TheCall);

Likewise call `CheckFunctionCall` here.



Comment at: lib/Sema/SemaOverload.cpp:12488
 
+checkDiagnoseIfAttrsOnCall(Method, TheCall);
 return MaybeBindToTemporary(TheCall);

... and here.



Comment at: lib/Sema/SemaOverload.cpp:13228
 
+  checkDiagnoseIfAttrsOnCall(Method, TheCall);
   return MaybeBindToTemporary(TheCall);

... and here.



Comment at: test/SemaCXX/diagnose_if.cpp:614
+// FIXME: This should emit diagnostics. It seems that our constexpr
+// evaluator isn't able to evaluate `adl::Foo(1)` to a constexpr, though.
+// I'm assuming this is because we assign it to a temporary.

`constexpr` is an adjective; "to a constant" might make more sense.



Comment at: test/SemaCXX/diagnose_if.cpp:615
+// evaluator isn't able to evaluate `adl::Foo(1)` to a constexpr, though.
+// I'm assuming this is because we assign it to a temporary.
+for (void *p : adl::Foo(1)) {}

The range-based for is desugared to

```
auto &&__range = adl::Foo(1);
auto __begin = begin(__range);
auto __end = end(__range);
// ...
```

so the argument in the call to `begin` is not considered constant.


https://reviews.llvm.org/D28889



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


[PATCH] D29233: Fix linkage of static locals in available_externally functions to be DiscardableODR/linkonce_odr

2017-01-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.

As Mehdi put it, entities should either be
available_externally+weak_odr, or linkonce_odr+linkonce_odr. While some
functions are emitted a_e/weak, their local variables were emitted
a_e/linkonce_odr.

While it might be nice to emit them a_e/weak, the Itanium ABI (& best
guess at MSVC's behavior as well) requires the local to be
linkonce/linkonce.


https://reviews.llvm.org/D29233

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenCXX/explicit-instantiation.cpp


Index: test/CodeGenCXX/explicit-instantiation.cpp
===
--- test/CodeGenCXX/explicit-instantiation.cpp
+++ test/CodeGenCXX/explicit-instantiation.cpp
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int 
ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8892,22 +8892,27 @@
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-if (LexicalContext)
-  StaticLocalLinkage =
-  Context.GetGVALinkageForFunction(cast(LexicalContext));
-
-// GVA_StrongODR function linkage is stronger than what we need,
-// downgrade to GVA_DiscardableODR.
-// This allows us to discard the variable if we never end up needing it.
-return StaticLocalLinkage == GVA_StrongODR ? GVA_DiscardableODR
-   : StaticLocalLinkage;
+// ObjC Blocks can create local variables that don't have a FunctionDecl
+// LexicalContext.
+if (!LexicalContext)
+  return GVA_DiscardableODR;
+
+// Otherwise, let the static local variable inherit its linkage from the
+// nearest enclosing function.
+auto StaticLocalLinkage =
+Context.GetGVALinkageForFunction(cast(LexicalContext));
+
+// Itanium ABI (& MSVC seems to do similarly) requires static locals in
+// inline functions to be emitted anywhere they're needed, even if the
+// function they are local to is emitted StrongODR/AvailableExternally.
+if (StaticLocalLinkage == GVA_StrongODR ||
+StaticLocalLinkage == GVA_AvailableExternally)
+  return GVA_DiscardableODR;
+return StaticLocalLinkage;
   }
 
   // MSVC treats in-class initialized static data members as definitions.


Index: test/CodeGenCXX/explicit-instantiation.cpp
===
--- test/CodeGenCXX/explicit-instantiation.cpp
+++ test/CodeGenCXX/explicit-instantiation.cpp
@@ -5,6 +5,9 @@
 // This check logically is attached to 'template int S::i;' below.
 // CHECK: @_ZN1SIiE1iE = weak_odr global i32
 
+// This check is logically attached to 'template int ExportedStaticLocal::f()' below.
+// CHECK-OPT: @_ZZN19ExportedStaticLocal1fIiEEvvE1i = linkonce_odr global
+
 template
 struct plus {
   Result operator()(const T& t, const U& u) const;
@@ -153,3 +156,17 @@
 template  void S::g() {}
 template  int S::i;
 template  void S::S2::h() {}
+
+namespace ExportedStaticLocal {
+void sink(int&);
+template 
+inline void f() {
+  static int i;
+  sink(i);
+}
+// See the check line at the top of the file.
+extern template void f();
+void use() {
+  f();
+}
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -8892,22 +8892,27 @@
 return GVA_Internal;
 
   if (VD->isStaticLocal()) {
-GVALinkage StaticLocalLinkage = GVA_DiscardableODR;
 const DeclContext *LexicalContext = VD->getParentFunctionOrMethod();
 while (LexicalContext && !isa(LexicalContext))
   LexicalContext = LexicalContext->getLexicalParent();
 
-// Let the static local variable inherit its linkage from the nearest
-// enclosing function.
-if (LexicalContext)
-  StaticLocalLinkage =
-  Context.GetGVALinkageForFunction(cast(LexicalContext));
-
-// GVA_StrongODR function linkage is stronger than what we need,
-// downgrade to 

Re: r293134 - [index] When indexing an ObjC method declaration use its base name for the location.

2017-01-27 Thread Argyrios Kyrtzidis via cfe-commits
Thanks!

> On Jan 27, 2017, at 9:07 AM, Hans Wennborg  wrote:
> 
> Merged in r293303.
> 
> Thanks,
> Hans
> 
> On Fri, Jan 27, 2017 at 8:19 AM, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>> *bump*
>> 
>>> On Jan 25, 2017, at 6:36 PM, Argyrios Kyrtzidis  wrote:
>>> 
>>> Hi Hans,
>>> 
>>> Could this go into the stable branch ?
>>> 
 On Jan 25, 2017, at 6:11 PM, Argyrios Kyrtzidis via cfe-commits 
  wrote:
 
 Author: akirtzidis
 Date: Wed Jan 25 20:11:50 2017
 New Revision: 293134
 
 URL: http://llvm.org/viewvc/llvm-project?rev=293134=rev
 Log:
 [index] When indexing an ObjC method declaration use its base name for the 
 location.
 
 Instead of using the location of the beginning '-'/'+'.
 This is consistent with location used for function decls and ObjC method 
 calls where we use the base name as the location as well.
 
 Modified:
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/test/Index/Core/index-source.m
  cfe/trunk/test/Index/Core/index-subkinds.m
  cfe/trunk/test/Index/index-decls.m
  cfe/trunk/test/Index/index-module.m
  cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
  cfe/trunk/tools/libclang/CXIndexDataConsumer.h
 
 Modified: cfe/trunk/lib/Index/IndexDecl.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=293134=293133=293134=diff
 ==
 --- cfe/trunk/lib/Index/IndexDecl.cpp (original)
 +++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Jan 25 20:11:50 2017
 @@ -92,7 +92,13 @@ public:
 Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
AssociatedProp);
 
 -if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
 +// getLocation() returns beginning token of a method declaration, but 
 for
 +// indexing purposes we want to point to the base name.
 +SourceLocation MethodLoc = D->getSelectorStartLoc();
 +if (MethodLoc.isInvalid())
 +  MethodLoc = D->getLocation();
 +
 +if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, 
 Relations))
 return false;
   IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
   bool hasIBActionAndFirst = D->hasAttr();
 
 Modified: cfe/trunk/test/Index/Core/index-source.m
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=293134=293133=293134=diff
 ==
 --- cfe/trunk/test/Index/Core/index-source.m (original)
 +++ cfe/trunk/test/Index/Core/index-source.m Wed Jan 25 20:11:50 2017
 @@ -3,10 +3,10 @@
 @interface Base
 // CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | 
 _OBJC_CLASS_$_Base | Decl | rel: 0
 -(void)meth;
 -// CHECK: [[@LINE-1]]:1 | instance-method/ObjC | meth | 
 c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
 +// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | 
 c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
 // CHECK-NEXT: RelChild | Base | c:objc(cs)Base
 +(Base*)class_meth;
 -// CHECK: [[@LINE-1]]:1 | class-method/ObjC | class_meth | 
 c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | 
 rel: 1
 +// CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | 
 c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | 
 rel: 1
 // CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | 
 _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
 // CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth
 
 @@ -92,7 +92,7 @@ extern int setjmp(jmp_buf);
 
 @class I1;
 @interface I1
 -// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | meth | 
 c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
 +// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | 
 c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
 -(void)meth;
 @end
 
 @@ -117,7 +117,7 @@ extern int setjmp(jmp_buf);
 // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
 @synthesize prop = _prop;
 
 -// CHECK: [[@LINE+5]]:1 | instance-method(IB)/ObjC | doAction:foo: | 
 c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | 
 rel: 1
 +// CHECK: [[@LINE+5]]:12 | instance-method(IB)/ObjC | doAction:foo: | 
 c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | 
 rel: 1
 // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
 // CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | 
 _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1
 // CHECK-NEXT: RelCont,RelIBType | 

r293333 - PR31783: Don't request the alignment of an invalid declaration.

2017-01-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan 27 15:28:37 2017
New Revision: 29

URL: http://llvm.org/viewvc/llvm-project?rev=29=rev
Log:
PR31783: Don't request the alignment of an invalid declaration.

Fixes an assertion failure on PS4 targets.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/auto-cxx0x.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=29=293332=29=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jan 27 15:28:37 2017
@@ -10930,7 +10930,8 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
   if (unsigned MaxAlign = Context.getTargetInfo().getMaxTLSAlign()) {
 // Protect the check so that it's not performed on dependent types and
 // dependent alignments (we can't determine the alignment in that case).
-if (VD->getTLSKind() && !hasDependentAlignment(VD)) {
+if (VD->getTLSKind() && !hasDependentAlignment(VD) &&
+!VD->isInvalidDecl()) {
   CharUnits MaxAlignChars = Context.toCharUnitsFromBits(MaxAlign);
   if (Context.getDeclAlign(VD) > MaxAlignChars) {
 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)

Modified: cfe/trunk/test/SemaCXX/auto-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/auto-cxx0x.cpp?rev=29=293332=29=diff
==
--- cfe/trunk/test/SemaCXX/auto-cxx0x.cpp (original)
+++ cfe/trunk/test/SemaCXX/auto-cxx0x.cpp Fri Jan 27 15:28:37 2017
@@ -6,3 +6,5 @@ void f() {
 }
 
 typedef auto PR25449(); // expected-error {{'auto' not allowed in typedef}}
+
+thread_local auto x; // expected-error {{requires an initializer}}


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


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 86111.
george.burgess.iv marked 2 inline comments as done.
george.burgess.iv added a comment.

Address feedback


https://reviews.llvm.org/D28889

Files:
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  test/Sema/diagnose_if.c
  test/SemaCXX/diagnose_if.cpp

Index: test/SemaCXX/diagnose_if.cpp
===
--- test/SemaCXX/diagnose_if.cpp
+++ test/SemaCXX/diagnose_if.cpp
@@ -2,6 +2,8 @@
 
 #define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
 
+using size_t = unsigned long;
+
 namespace type_dependent {
 template 
 void neverok() _diagnose_if(!T(), "oh no", "error") {} // expected-note 4{{from 'diagnose_if'}}
@@ -51,14 +53,14 @@
 }
 
 template 
-void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note{{from 'diagnose_if'}}
 
 template 
-void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note{{from 'diagnose_if'}}
 
 void runIf() {
   errorIf(0);
-  errorIf(1); // expected-error{{call to unavailable function}}
+  errorIf(1); // expected-error{{oh no}}
 
   warnIf(0);
   warnIf(1); // expected-warning{{oh no}}
@@ -114,14 +116,14 @@
 }
 
 template 
-void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note{{from 'diagnose_if'}}
 
 template 
-void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note{{from 'diagnose_if'}}
 
 void runIf() {
   errorIf<0>(0);
-  errorIf<0>(1); // expected-error{{call to unavailable function}}
+  errorIf<0>(1); // expected-error{{oh no}}
 
   warnIf<0>(0);
   warnIf<0>(1); // expected-warning{{oh no}}
@@ -135,17 +137,17 @@
 void bar(int);
 void bar(short) _diagnose_if(1, "oh no", "error");
 
-void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{candidate disabled: oh no}}
-void fooArg(short); // expected-note{{candidate function}}
+void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{from 'diagnose_if'}}
+void fooArg(short);
 
 void barArg(int);
 void barArg(short a) _diagnose_if(a, "oh no", "error");
 
 void runAll() {
   foo(1); // expected-error{{oh no}}
   bar(1);
 
-  fooArg(1); // expected-error{{call to unavailable function}}
+  fooArg(1); // expected-error{{oh no}}
   barArg(1);
 
   auto p = foo; // expected-error{{incompatible initializer of type ''}}
@@ -188,11 +190,11 @@
   void foo(int i) _diagnose_if(i, "bad i", "error"); // expected-note{{from 'diagnose_if'}}
   void bar(int i) _diagnose_if(i != T(), "bad i", "error"); // expected-note{{from 'diagnose_if'}}
 
-  void fooOvl(int i) _diagnose_if(i, "int bad i", "error"); // expected-note 2{{int bad i}}
-  void fooOvl(short i) _diagnose_if(i, "short bad i", "error"); // expected-note 2{{short bad i}}
+  void fooOvl(int i) _diagnose_if(i, "int bad i", "error"); // expected-note{{from 'diagnose_if'}}
+  void fooOvl(short i) _diagnose_if(i, "short bad i", "error"); // expected-note{{from 'diagnose_if'}}
 
-  void barOvl(int i) _diagnose_if(i != T(), "int bad i", "error"); // expected-note 2{{int bad i}}
-  void barOvl(short i) _diagnose_if(i != T(), "short bad i", "error"); // expected-note 2{{short bad i}}
+  void barOvl(int i) _diagnose_if(i != T(), "int bad i", "error"); // expected-note{{from 'diagnose_if'}}
+  void barOvl(short i) _diagnose_if(i != T(), "short bad i", "error"); // expected-note{{from 'diagnose_if'}}
 };
 
 void runErrors() {
@@ -203,14 +205,14 @@
   Errors().bar(1); // expected-error{{bad i}}
 
   Errors().fooOvl(0);
-  Errors().fooOvl(1); // expected-error{{call to unavailable}}
+  Errors().fooOvl(1); // expected-error{{int bad i}}
   Errors().fooOvl(short(0));
-  Errors().fooOvl(short(1)); // expected-error{{call to unavailable}}
+  Errors().fooOvl(short(1)); // expected-error{{short bad i}}
 
   Errors().barOvl(0);
-  Errors().barOvl(1); // expected-error{{call to unavailable}}
+  Errors().barOvl(1); // expected-error{{int bad i}}
   Errors().barOvl(short(0));
-  Errors().barOvl(short(1)); // expected-error{{call to unavailable}}
+  Errors().barOvl(short(1)); // expected-error{{short bad i}}
 }
 
 template 
@@ -275,8 +277,8 @@
 constexpr int foo();
 constexpr int foo(int a);
 
-void bar() _diagnose_if(foo(), "bad foo", "error"); // expected-note{{from 'diagnose_if'}} expected-note{{not viable: requires 0 arguments}}
-void bar(int a) _diagnose_if(foo(a), "bad foo", "error"); // 

[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for the feedback!




Comment at: lib/Sema/SemaChecking.cpp:2520
+
+// TODO: Call can technically be a const CallExpr, but const_casting feels 
ugly,
+// and I really don't want to duplicate unwrapCallExpr's logic. No caller 
really

aaron.ballman wrote:
> Thank you for this comment; I was about to ask about that very topic. :-D
ᕕ( ᐛ )ᕗ

Makes me kinda wish there was a clean way to say "the constness of the returned 
value depends on the constness of this arg," though. (For values of clean that 
don't involve some `constness_of::type` kind of thing)


https://reviews.llvm.org/D28889



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


[PATCH] D26345: Extend small data threshold driver options to PPC target

2017-01-27 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

LGTM


https://reviews.llvm.org/D26345



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


[libcxxabi] r293330 - Fix ASAN failure in cxa_demangle

2017-01-27 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Fri Jan 27 14:32:16 2017
New Revision: 293330

URL: http://llvm.org/viewvc/llvm-project?rev=293330=rev
Log:
Fix ASAN failure in cxa_demangle

Found with ASAN + libFuzzer by Kostya Serebryany 

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=293330=293329=293330=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Fri Jan 27 14:32:16 2017
@@ -1611,7 +1611,8 @@ parse_function_type(const char* first, c
 {
 if (t == last)
 {
-db.names.pop_back();
+if (!db.names.empty())
+  db.names.pop_back();
 return first;
 }
 if (*t == 'E')

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=293330=293329=293330=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Fri Jan 27 14:32:16 2017
@@ -29662,6 +29662,7 @@ const char* invalid_cases[] =
 
"\x44\x74\x71\x75\x35\x2A\xDF\x74\x44\x61\x73\x63\x35\x2A\x3B\x41\x72\x4D\x6E\x65\x34\x9F\xC1\x63\x41\x72\x4D\x6E\x77\x38\x9A\x8E\x44\x6F\x64\x6C\x53\xF9\x5F\x70\x74\x70\x69\x45\x33\x44\x76\x35",
 
"\x44\x74\x70\x74\x71\x75\x32\x43\x41\x38\x65\x6E\x9B\x72\x4D\xC1\x43\x41\x72\x4D\x6E\x77\x38\x9A\x8E\x44\x6F\x64\x6C\x53\xF9\x5F\x70\x74\x70\x69\x45\x38\xD3\x73\x9E\x2A\x37",
 
"\x46\x44\x74\x70\x74\x71\x75\x32\x43\x41\x72\x4D\x6E\x65\x34\x9F\xC1\x43\x41\x72\x4D\x6E\x77\x38\x9A\x8E\x44\x6F\x64\x6C\x53\xF9\x5F\x70\x74\x70\x69\x45\x34\xD3\x73\x9E\x2A\x37\x72\x33\x8E\x3A\x29\x8E\x44\x35",
+   "_ZcvCiIJEEDvT__T_vT_v",
 };
 
 const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);


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


[PATCH] D26345: Extend small data threshold driver options to PPC target

2017-01-27 Thread Jack Andersen via Phabricator via cfe-commits
jackoalan updated this revision to Diff 86088.
jackoalan added a comment.
Herald added a subscriber: nemanjai.

Remove already-aliased option matchings; add test case for patch.


https://reviews.llvm.org/D26345

Files:
  lib/Driver/Tools.cpp
  test/Driver/ppc-eabi-small-data.c


Index: test/Driver/ppc-eabi-small-data.c
===
--- /dev/null
+++ test/Driver/ppc-eabi-small-data.c
@@ -0,0 +1,9 @@
+// Check passing PowerPC EABI small-data threshold to the backend.
+
+// RUN: %clang -target powerpc-unknown-unknown-eabi -G 0 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-SDATA0 %s
+// RUN: %clang -target powerpc-unknown-unknown-eabi -G 8 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-SDATA8 %s
+
+// CHECK-SDATA0: "-mllvm" "-ppc-ssection-threshold=0"
+// CHECK-SDATA8: "-mllvm" "-ppc-ssection-threshold=8"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1887,6 +1887,13 @@
 CmdArgs.push_back("-target-abi");
 CmdArgs.push_back(ABIName);
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_G)) {
+StringRef v = A->getValue();
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-ppc-ssection-threshold=" + v));
+A->claim();
+  }
 }
 
 bool ppc::hasPPCAbiArg(const ArgList , const char *Value) {


Index: test/Driver/ppc-eabi-small-data.c
===
--- /dev/null
+++ test/Driver/ppc-eabi-small-data.c
@@ -0,0 +1,9 @@
+// Check passing PowerPC EABI small-data threshold to the backend.
+
+// RUN: %clang -target powerpc-unknown-unknown-eabi -G 0 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-SDATA0 %s
+// RUN: %clang -target powerpc-unknown-unknown-eabi -G 8 %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-SDATA8 %s
+
+// CHECK-SDATA0: "-mllvm" "-ppc-ssection-threshold=0"
+// CHECK-SDATA8: "-mllvm" "-ppc-ssection-threshold=8"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1887,6 +1887,13 @@
 CmdArgs.push_back("-target-abi");
 CmdArgs.push_back(ABIName);
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_G)) {
+StringRef v = A->getValue();
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-ppc-ssection-threshold=" + v));
+A->claim();
+  }
 }
 
 bool ppc::hasPPCAbiArg(const ArgList , const char *Value) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28889: Change where we handle arg-dependent diagnose_if attributes

2017-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I don't see anything that looks amiss, but you should wait for @rsmith to 
approve.




Comment at: lib/Sema/SemaChecking.cpp:2520
+
+// TODO: Call can technically be a const CallExpr, but const_casting feels 
ugly,
+// and I really don't want to duplicate unwrapCallExpr's logic. No caller 
really

Thank you for this comment; I was about to ask about that very topic. :-D



Comment at: lib/Sema/SemaChecking.cpp:11933
 }
-

Unintended change?



Comment at: lib/Sema/SemaOverload.cpp:6235
+  SmallVector Attrs;
+  for (const auto *DIA : FD->specific_attrs())
+if (ArgDependent == DIA->getArgDependent())

Braces might make this a bit easier to read due to the multiline if.


https://reviews.llvm.org/D28889



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


[PATCH] D29205: Change debug-info-for-profiling from a TargetOption to a function attribute.

2017-01-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:452
+  if (CodeGenOpts.DebugInfoForProfiling)
+getModule().addModuleFlag(llvm::Module::Warning, "DebugInfoForProfiling", 
1);
 

mehdi_amini wrote:
> danielcdh wrote:
> > mehdi_amini wrote:
> > > Why should we warn on mismatch?
> > In theory, we expect this to be the same across all modules. Otherwise when 
> > we use this binary for profiling, we may get inaccurate profiles.
> Oh I thought about the "unset" case but we wouldn't warn in this case.
> 
> Indeed we never even should have this flag with a zero value.
Unless you really intend to get a warning on mismatch, in which case you should 
always emit the flag, but with a zero value when not enabled.
I'd need more thought to really grasp all the consequences :)



https://reviews.llvm.org/D29205



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


[PATCH] D29205: Change debug-info-for-profiling from a TargetOption to a function attribute.

2017-01-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:452
+  if (CodeGenOpts.DebugInfoForProfiling)
+getModule().addModuleFlag(llvm::Module::Warning, "DebugInfoForProfiling", 
1);
 

danielcdh wrote:
> mehdi_amini wrote:
> > Why should we warn on mismatch?
> In theory, we expect this to be the same across all modules. Otherwise when 
> we use this binary for profiling, we may get inaccurate profiles.
Oh I thought about the "unset" case but we wouldn't warn in this case.

Indeed we never even should have this flag with a zero value.


https://reviews.llvm.org/D29205



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-01-27 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Thanks and sorry for the breakage.  Unfortunately, I'm unable to reproduce 
locally (OSX), but will try to get access to linux box this weekend.

Seems to be related to memory corruption wrt to improper StringRef usage, but I 
can't say for sure yet.


https://reviews.llvm.org/D20693



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


r293311 - ARM-Darwin: re-enable -momit-leaf-frame-pointer.

2017-01-27 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Jan 27 11:53:42 2017
New Revision: 293311

URL: http://llvm.org/viewvc/llvm-project?rev=293311=rev
Log:
ARM-Darwin: re-enable -momit-leaf-frame-pointer.

In r279546 I disabled all frame pointer elimination at the front-end on
ARM-Darwin (and warned about it) because before that the backend had been
silently ignoring these options. It turns out we didn't ignore
-momit-leaf-frame-pointer though, just the more general -fomit-frame-pointer.

So this re-enables passing that down to CodeGen so that everything really does
continue working as before (with better diagnostics).

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/frame-pointer-elim.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=293311=293310=293311=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jan 27 11:53:42 2017
@@ -1109,10 +1109,6 @@ Darwin::TranslateArgs(const DerivedArgLi
  options::OPT_fno_omit_frame_pointer, false))
   getDriver().Diag(clang::diag::warn_drv_unsupported_opt_for_target)
   << "-fomit-frame-pointer" << BoundArch;
-if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
- options::OPT_mno_omit_leaf_frame_pointer, false))
-  getDriver().Diag(clang::diag::warn_drv_unsupported_opt_for_target)
-  << "-momit-leaf-frame-pointer" << BoundArch;
   }
 
   return DAL;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=293311=293310=293311=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 27 11:53:42 2017
@@ -3455,7 +3455,7 @@ static bool areOptimizationsEnabled(cons
   return false;
 }
 
-static bool mustUseFramePointerForTarget(const llvm::Triple ) {
+static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple ) {
   switch (Triple.getArch()){
   default:
 return false;
@@ -3521,7 +3521,7 @@ static bool shouldUseFramePointer(const
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseFramePointerForTarget(Triple);
+   mustUseNonLeafFramePointerForTarget(Triple);
 
   if (Args.hasArg(options::OPT_pg))
 return true;
@@ -3533,8 +3533,7 @@ static bool shouldUseLeafFramePointer(co
   const llvm::Triple ) {
   if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer))
-return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer) ||
-   mustUseFramePointerForTarget(Triple);
+return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
 
   if (Args.hasArg(options::OPT_pg))
 return true;

Modified: cfe/trunk/test/Driver/frame-pointer-elim.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/frame-pointer-elim.c?rev=293311=293310=293311=diff
==
--- cfe/trunk/test/Driver/frame-pointer-elim.c (original)
+++ cfe/trunk/test/Driver/frame-pointer-elim.c Fri Jan 27 11:53:42 2017
@@ -49,9 +49,9 @@
 
 // RUN: %clang -### -target armv7s-apple-ios8.0 -momit-leaf-frame-pointer %s 
2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-LEAF-7S %s
-// WARN-OMIT-LEAF-7S: warning: optimization flag '-momit-leaf-frame-pointer' 
is not supported for target 'armv7s'
+// WARN-OMIT-LEAF-7S-NOT: warning: optimization flag 
'-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mdisable-fp-elim"
-// WARN-OMIT-LEAF-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-LEAF-7S: "-momit-leaf-frame-pointer"
 
 // On the PS4, we default to omitting the frame pointer on leaf functions
 // (OMIT_LEAF check line is above)


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


[PATCH] D29205: Change debug-info-for-profiling from a TargetOption to a function attribute.

2017-01-27 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:452
+  if (CodeGenOpts.DebugInfoForProfiling)
+getModule().addModuleFlag(llvm::Module::Warning, "DebugInfoForProfiling", 
1);
 

mehdi_amini wrote:
> Why should we warn on mismatch?
In theory, we expect this to be the same across all modules. Otherwise when we 
use this binary for profiling, we may get inaccurate profiles.


https://reviews.llvm.org/D29205



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


Re: [libcxx] r291928 - Update version to 5.0

2017-01-27 Thread Hans Wennborg via cfe-commits
Thanks! I tried to update all version numbers I could find, but I
obviously missed this one :-)

On Fri, Jan 13, 2017 at 10:29 AM, Eric Fiselier via cfe-commits
 wrote:
> Author: ericwf
> Date: Fri Jan 13 12:29:56 2017
> New Revision: 291928
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291928=rev
> Log:
> Update version to 5.0
>
> Added:
> libcxx/trunk/lib/abi/4.0/
> libcxx/trunk/lib/abi/4.0/x86_64-apple-darwin16.0.0.abilist
> libcxx/trunk/lib/abi/4.0/x86_64-unknown-linux-gnu.abilist
> Modified:
> libcxx/trunk/docs/conf.py
> libcxx/trunk/include/__config
> libcxx/trunk/include/__libcpp_version
>
> Modified: libcxx/trunk/docs/conf.py
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/conf.py?rev=291928=291927=291928=diff
> ==
> --- libcxx/trunk/docs/conf.py (original)
> +++ libcxx/trunk/docs/conf.py Fri Jan 13 12:29:56 2017
> @@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
>  # built documents.
>  #
>  # The short X.Y version.
> -version = '4.0'
> +version = '5.0'
>  # The full version, including alpha/beta/rc tags.
> -release = '4.0'
> +release = '5.0'

For llvm, clang, etc. I just put '5' here.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29205: Change debug-info-for-profiling from a TargetOption to a function attribute.

2017-01-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:452
+  if (CodeGenOpts.DebugInfoForProfiling)
+getModule().addModuleFlag(llvm::Module::Warning, "DebugInfoForProfiling", 
1);
 

Why should we warn on mismatch?


https://reviews.llvm.org/D29205



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


[PATCH] D29198: clang-cl: Warn about /U flags that look like filenames (PR31662)

2017-01-27 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293305: clang-cl: Warn about /U flags that look like 
filenames (PR31662) (authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D29198?vs=85963=86062#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29198

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -247,6 +247,10 @@
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as 
filenames">;
+
 def err_drv_ropi_rwpi_incompatible_with_pic : Error<
   "embedded and GOT-based position independence are incompatible">;
 def err_drv_ropi_incompatible_with_cxx : Error<
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -442,6 +442,12 @@
 // Xclang: "-cc1"
 // Xclang: "hellocc1"
 
+// Files under /Users are often confused with the /U flag. (This could happen
+// for other flags too, but this is the one people run into.)
+// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck 
-check-prefix=SlashU %s
+// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
+// SlashU: note: Use '--' to treat subsequent arguments as filenames
+
 // RTTI is on by default. /GR- controls -fno-rtti-data.
 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
 // NoRTTI: "-fno-rtti-data"
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1583,6 +1583,14 @@
 Diag(clang::diag::err_drv_unknown_language) << A->getValue();
 InputType = types::TY_Object;
   }
+} else if (A->getOption().getID() == options::OPT__SLASH_U) {
+  assert(A->getNumValues() == 1 && "The /U option has one value.");
+  StringRef Val = A->getValue(0);
+  if (Val.find_first_of("/\\") != StringRef::npos) {
+// Warn about e.g. "/Users/me/myfile.c".
+Diag(diag::warn_slash_u_filename) << Val;
+Diag(diag::note_use_dashdash);
+  }
 }
   }
   if (CCCIsCPP() && Inputs.empty()) {


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -247,6 +247,10 @@
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as filenames">;
+
 def err_drv_ropi_rwpi_incompatible_with_pic : Error<
   "embedded and GOT-based position independence are incompatible">;
 def err_drv_ropi_incompatible_with_cxx : Error<
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -442,6 +442,12 @@
 // Xclang: "-cc1"
 // Xclang: "hellocc1"
 
+// Files under /Users are often confused with the /U flag. (This could happen
+// for other flags too, but this is the one people run into.)
+// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s
+// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
+// SlashU: note: Use '--' to treat subsequent arguments as filenames
+
 // RTTI is on by default. /GR- controls -fno-rtti-data.
 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
 // NoRTTI: "-fno-rtti-data"
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1583,6 +1583,14 @@
 Diag(clang::diag::err_drv_unknown_language) << A->getValue();
 InputType = types::TY_Object;
   }
+} else if (A->getOption().getID() == options::OPT__SLASH_U) {
+  assert(A->getNumValues() == 1 && "The /U option has one value.");
+  StringRef Val = A->getValue(0);
+  if (Val.find_first_of("/\\") != StringRef::npos) {
+// Warn about e.g. "/Users/me/myfile.c".
+Diag(diag::warn_slash_u_filename) << Val;
+Diag(diag::note_use_dashdash);
+  }
 }
   }
   if (CCCIsCPP() && 

r293305 - clang-cl: Warn about /U flags that look like filenames (PR31662)

2017-01-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Jan 27 11:09:41 2017
New Revision: 293305

URL: http://llvm.org/viewvc/llvm-project?rev=293305=rev
Log:
clang-cl: Warn about /U flags that look like filenames (PR31662)

Both on Mac and Windows, it's common to have a 'Users' directory in the
root of the filesystem, so one might specify a filename as
'/Users/me/myfile.c'. clang-cl (as well as MSVC's cl.exe) will interpret
that as invoking the '/U' option, which is probably not what the user
wanted. Add a warning about this.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=293305=293304=293305=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jan 27 11:09:41 
2017
@@ -247,6 +247,10 @@ def err_test_module_file_extension_forma
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 
+def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
+  InGroup>;
+def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as 
filenames">;
+
 def err_drv_ropi_rwpi_incompatible_with_pic : Error<
   "embedded and GOT-based position independence are incompatible">;
 def err_drv_ropi_incompatible_with_cxx : Error<

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=293305=293304=293305=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 27 11:09:41 2017
@@ -1583,6 +1583,14 @@ void Driver::BuildInputs(const ToolChain
 Diag(clang::diag::err_drv_unknown_language) << A->getValue();
 InputType = types::TY_Object;
   }
+} else if (A->getOption().getID() == options::OPT__SLASH_U) {
+  assert(A->getNumValues() == 1 && "The /U option has one value.");
+  StringRef Val = A->getValue(0);
+  if (Val.find_first_of("/\\") != StringRef::npos) {
+// Warn about e.g. "/Users/me/myfile.c".
+Diag(diag::warn_slash_u_filename) << Val;
+Diag(diag::note_use_dashdash);
+  }
 }
   }
   if (CCCIsCPP() && Inputs.empty()) {

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=293305=293304=293305=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Jan 27 11:09:41 2017
@@ -442,6 +442,12 @@
 // Xclang: "-cc1"
 // Xclang: "hellocc1"
 
+// Files under /Users are often confused with the /U flag. (This could happen
+// for other flags too, but this is the one people run into.)
+// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck 
-check-prefix=SlashU %s
+// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
+// SlashU: note: Use '--' to treat subsequent arguments as filenames
+
 // RTTI is on by default. /GR- controls -fno-rtti-data.
 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
 // NoRTTI: "-fno-rtti-data"


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


Re: r292590 - [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows

2017-01-27 Thread Alexey Bataev via cfe-commits
Thanks a lot

-
Best regards,
Alexey Bataev

27.01.2017 19:57, Hans Wennborg пишет:
> I've got it. Merged in r293302.
>
> Thanks,
> Hans
>
> On Fri, Jan 27, 2017 at 4:49 AM, Alexey Bataev  wrote:
>> Yes. Could you do it yourself or you want me to do it?
>>
>> -
>> Best regards,
>> Alexey Bataev
>>
>> 27.01.2017 2:33, Hans Wennborg пишет:
>>> Should we merge this to the release branch?
>>>
>>> On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits
>>>  wrote:
 Author: abataev
 Date: Fri Jan 20 02:57:28 2017
 New Revision: 292590

 URL: http://llvm.org/viewvc/llvm-project?rev=292590=rev
 Log:
 [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
 with SEH and openmp

 In some cituations (during codegen for Windows SEH constructs)
 CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
 code does not expect such situation during cleanup.

 Added:
   cfe/trunk/test/OpenMP/openmp_seh.c
 Modified:
   cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

 Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=292590=292589=292590=diff
 ==
 --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017
 @@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
  if (FirstBlockInfo)
destroyBlockInfos(FirstBlockInfo);

 -  if (getLangOpts().OpenMP) {
 +  if (getLangOpts().OpenMP && CurFn)
CGM.getOpenMPRuntime().functionFinished(*this);
 -  }
}

CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,

 Added: cfe/trunk/test/OpenMP/openmp_seh.c
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_seh.c?rev=292590=auto
 ==
 --- cfe/trunk/test/OpenMP/openmp_seh.c (added)
 +++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017
 @@ -0,0 +1,18 @@
 +// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp 
 -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
 +// expected-no-diagnostics
 +// REQUIRES: x86-registered-target
 +extern "C" {
 +void __cpuid(int[4], int);
 +}
 +
 +// CHECK-LABEL: @main
 +int main(void) {
 +  __try {
 +int info[4];
 +__cpuid(info, 1);
 +  } __except (1) {
 +  }
 +
 +  return 0;
 +}
 +


 ___
 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


Re: r293134 - [index] When indexing an ObjC method declaration use its base name for the location.

2017-01-27 Thread Hans Wennborg via cfe-commits
Merged in r293303.

Thanks,
Hans

On Fri, Jan 27, 2017 at 8:19 AM, Argyrios Kyrtzidis via cfe-commits
 wrote:
> *bump*
>
>> On Jan 25, 2017, at 6:36 PM, Argyrios Kyrtzidis  wrote:
>>
>> Hi Hans,
>>
>> Could this go into the stable branch ?
>>
>>> On Jan 25, 2017, at 6:11 PM, Argyrios Kyrtzidis via cfe-commits 
>>>  wrote:
>>>
>>> Author: akirtzidis
>>> Date: Wed Jan 25 20:11:50 2017
>>> New Revision: 293134
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=293134=rev
>>> Log:
>>> [index] When indexing an ObjC method declaration use its base name for the 
>>> location.
>>>
>>> Instead of using the location of the beginning '-'/'+'.
>>> This is consistent with location used for function decls and ObjC method 
>>> calls where we use the base name as the location as well.
>>>
>>> Modified:
>>>   cfe/trunk/lib/Index/IndexDecl.cpp
>>>   cfe/trunk/test/Index/Core/index-source.m
>>>   cfe/trunk/test/Index/Core/index-subkinds.m
>>>   cfe/trunk/test/Index/index-decls.m
>>>   cfe/trunk/test/Index/index-module.m
>>>   cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
>>>   cfe/trunk/tools/libclang/CXIndexDataConsumer.h
>>>
>>> Modified: cfe/trunk/lib/Index/IndexDecl.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=293134=293133=293134=diff
>>> ==
>>> --- cfe/trunk/lib/Index/IndexDecl.cpp (original)
>>> +++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Jan 25 20:11:50 2017
>>> @@ -92,7 +92,13 @@ public:
>>>  Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
>>> AssociatedProp);
>>>
>>> -if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
>>> +// getLocation() returns beginning token of a method declaration, but 
>>> for
>>> +// indexing purposes we want to point to the base name.
>>> +SourceLocation MethodLoc = D->getSelectorStartLoc();
>>> +if (MethodLoc.isInvalid())
>>> +  MethodLoc = D->getLocation();
>>> +
>>> +if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, 
>>> Relations))
>>>  return false;
>>>IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
>>>bool hasIBActionAndFirst = D->hasAttr();
>>>
>>> Modified: cfe/trunk/test/Index/Core/index-source.m
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=293134=293133=293134=diff
>>> ==
>>> --- cfe/trunk/test/Index/Core/index-source.m (original)
>>> +++ cfe/trunk/test/Index/Core/index-source.m Wed Jan 25 20:11:50 2017
>>> @@ -3,10 +3,10 @@
>>> @interface Base
>>> // CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | 
>>> _OBJC_CLASS_$_Base | Decl | rel: 0
>>> -(void)meth;
>>> -// CHECK: [[@LINE-1]]:1 | instance-method/ObjC | meth | 
>>> c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
>>> +// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | 
>>> c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
>>> // CHECK-NEXT: RelChild | Base | c:objc(cs)Base
>>> +(Base*)class_meth;
>>> -// CHECK: [[@LINE-1]]:1 | class-method/ObjC | class_meth | 
>>> c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | 
>>> rel: 1
>>> +// CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | 
>>> c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | 
>>> rel: 1
>>> // CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | 
>>> _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
>>> // CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth
>>>
>>> @@ -92,7 +92,7 @@ extern int setjmp(jmp_buf);
>>>
>>> @class I1;
>>> @interface I1
>>> -// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | meth | 
>>> c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
>>> +// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | 
>>> c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
>>> -(void)meth;
>>> @end
>>>
>>> @@ -117,7 +117,7 @@ extern int setjmp(jmp_buf);
>>> // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
>>> @synthesize prop = _prop;
>>>
>>> -// CHECK: [[@LINE+5]]:1 | instance-method(IB)/ObjC | doAction:foo: | 
>>> c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | 
>>> rel: 1
>>> +// CHECK: [[@LINE+5]]:12 | instance-method(IB)/ObjC | doAction:foo: | 
>>> c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | 
>>> rel: 1
>>> // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
>>> // CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | 
>>> _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1
>>> // CHECK-NEXT: RelCont,RelIBType | doAction:foo: | 
>>> c:objc(cs)I2(im)doAction:foo:
>>> @@ -127,11 +127,11 @@ extern int setjmp(jmp_buf);
>>>
>>> @interface I3
>>> @property (readwrite) id prop;
>>> -// CHECK: [[@LINE+3]]:1 | 

Re: r292590 - [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows

2017-01-27 Thread Hans Wennborg via cfe-commits
I've got it. Merged in r293302.

Thanks,
Hans

On Fri, Jan 27, 2017 at 4:49 AM, Alexey Bataev  wrote:
> Yes. Could you do it yourself or you want me to do it?
>
> -
> Best regards,
> Alexey Bataev
>
> 27.01.2017 2:33, Hans Wennborg пишет:
>> Should we merge this to the release branch?
>>
>> On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits
>>  wrote:
>>> Author: abataev
>>> Date: Fri Jan 20 02:57:28 2017
>>> New Revision: 292590
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=292590=rev
>>> Log:
>>> [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
>>> with SEH and openmp
>>>
>>> In some cituations (during codegen for Windows SEH constructs)
>>> CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
>>> code does not expect such situation during cleanup.
>>>
>>> Added:
>>>  cfe/trunk/test/OpenMP/openmp_seh.c
>>> Modified:
>>>  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=292590=292589=292590=diff
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017
>>> @@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
>>> if (FirstBlockInfo)
>>>   destroyBlockInfos(FirstBlockInfo);
>>>
>>> -  if (getLangOpts().OpenMP) {
>>> +  if (getLangOpts().OpenMP && CurFn)
>>>   CGM.getOpenMPRuntime().functionFinished(*this);
>>> -  }
>>>   }
>>>
>>>   CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
>>>
>>> Added: cfe/trunk/test/OpenMP/openmp_seh.c
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_seh.c?rev=292590=auto
>>> ==
>>> --- cfe/trunk/test/OpenMP/openmp_seh.c (added)
>>> +++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017
>>> @@ -0,0 +1,18 @@
>>> +// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp 
>>> -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
>>> +// expected-no-diagnostics
>>> +// REQUIRES: x86-registered-target
>>> +extern "C" {
>>> +void __cpuid(int[4], int);
>>> +}
>>> +
>>> +// CHECK-LABEL: @main
>>> +int main(void) {
>>> +  __try {
>>> +int info[4];
>>> +__cpuid(info, 1);
>>> +  } __except (1) {
>>> +  }
>>> +
>>> +  return 0;
>>> +}
>>> +
>>>
>>>
>>> ___
>>> 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


[libcxx] r293301 - Merging r292607:

2017-01-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Jan 27 10:41:31 2017
New Revision: 293301

URL: http://llvm.org/viewvc/llvm-project?rev=293301=rev
Log:
Merging r292607:

r292607 | ericwf | 2017-01-20 04:54:45 -0800 (Fri, 20 Jan 2017) | 1 line

Don't default older GCC's to C++17, but C++14 or C++11 instead


Modified:
libcxx/branches/release_40/   (props changed)
libcxx/branches/release_40/test/libcxx/test/config.py

Propchange: libcxx/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 27 10:41:31 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:292013,292091,292990,293154
+/libcxx/trunk:292013,292091,292607,292990,293154

Modified: libcxx/branches/release_40/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/test/libcxx/test/config.py?rev=293301=293300=293301=diff
==
--- libcxx/branches/release_40/test/libcxx/test/config.py (original)
+++ libcxx/branches/release_40/test/libcxx/test/config.py Fri Jan 27 10:41:31 
2017
@@ -403,6 +403,15 @@ class Configuration(object):
 if not std:
 # Choose the newest possible language dialect if none is given.
 possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']
+if self.cxx.type == 'gcc':
+maj_v, _, _ = self.cxx.version
+maj_v = int(maj_v)
+if maj_v < 7:
+possible_stds.remove('c++1z')
+# FIXME: How many C++14 tests actually fail under GCC 5 and 6?
+# Should we XFAIL them individually instead?
+if maj_v <= 6:
+possible_stds.remove('c++14')
 for s in possible_stds:
 if self.cxx.hasCompileFlag('-std=%s' % s):
 std = s


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


[PATCH] D29205: Change debug-info-for-profiling from a TargetOption to a function attribute.

2017-01-27 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 86058.
danielcdh added a comment.

change to use module flag.


https://reviews.llvm.org/D29205

Files:
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -448,6 +448,8 @@
 // (and warn about it, too).
 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
   llvm::DEBUG_METADATA_VERSION);
+  if (CodeGenOpts.DebugInfoForProfiling)
+getModule().addModuleFlag(llvm::Module::Warning, "DebugInfoForProfiling", 
1);
 
   // We need to record the widths of enums and wchar_t, so that we can generate
   // the correct build attributes in the ARM backend.
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -573,7 +573,6 @@
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
-  Options.DebugInfoForProfiling = CodeGenOpts.DebugInfoForProfiling;
 
   // Set EABI version.
   Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -448,6 +448,8 @@
 // (and warn about it, too).
 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
   llvm::DEBUG_METADATA_VERSION);
+  if (CodeGenOpts.DebugInfoForProfiling)
+getModule().addModuleFlag(llvm::Module::Warning, "DebugInfoForProfiling", 1);
 
   // We need to record the widths of enums and wchar_t, so that we can generate
   // the correct build attributes in the ARM backend.
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -573,7 +573,6 @@
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
-  Options.DebugInfoForProfiling = CodeGenOpts.DebugInfoForProfiling;
 
   // Set EABI version.
   Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libunwind] r292723 - X86: swap EBP, ESP on !APPLE

2017-01-27 Thread Hans Wennborg via cfe-commits
r293298.

Thanks,
Hans

On Thu, Jan 26, 2017 at 6:38 PM, Saleem Abdulrasool
 wrote:
> I think that this is safe enough and does make libunwind work on x86 Linux,
> so lets go for it.
>
> On Thu, Jan 26, 2017 at 10:10 AM, Hans Wennborg  wrote:
>>
>> Michał suggested on the PR that this should be merged to the release
>> branch.
>>
>> Saleem, what do you think?
>>
>> On Sat, Jan 21, 2017 at 8:22 AM, Saleem Abdulrasool via cfe-commits
>>  wrote:
>> > Author: compnerd
>> > Date: Sat Jan 21 10:22:59 2017
>> > New Revision: 292723
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=292723=rev
>> > Log:
>> > X86: swap EBP, ESP on !APPLE
>> >
>> > Restore the `libunwind.h` enumeration values back to the inverted
>> > values.  This diverges from the DWARF definition of the register values.
>> > However, this allows our header to be compatible with other unwind
>> > implementations (e.g. HP, GNU Savannah, GCC).
>> >
>> > The register IDs are only swapped in the header and need to be unswapped
>> > when accessing the unwind register file.  The flipped EBP and ESP only
>> > applies on non-Apple x86 targets.
>> >
>> > When optimizations were enabled, EBP and ESP would no longer be
>> > equivalent.  As a result, the incorrect access on Linux would manifest
>> > as a failure to unwind the stack.  We can now unwind the stack with and
>> > without FPO on Linux x86.
>> >
>> > Resolves PR30879!
>> >
>> > Modified:
>> > libunwind/trunk/include/libunwind.h
>> > libunwind/trunk/src/Registers.hpp
>> >
>> > Modified: libunwind/trunk/include/libunwind.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=292723=292722=292723=diff
>> >
>> > ==
>> > --- libunwind/trunk/include/libunwind.h (original)
>> > +++ libunwind/trunk/include/libunwind.h Sat Jan 21 10:22:59 2017
>> > @@ -165,13 +165,8 @@ enum {
>> >UNW_X86_ECX = 1,
>> >UNW_X86_EDX = 2,
>> >UNW_X86_EBX = 3,
>> > -#if defined(__CloudABI__) || defined(__FreeBSD__)
>> > -  UNW_X86_ESP = 4,
>> > -  UNW_X86_EBP = 5,
>> > -#else
>> >UNW_X86_EBP = 4,
>> >UNW_X86_ESP = 5,
>> > -#endif
>> >UNW_X86_ESI = 6,
>> >UNW_X86_EDI = 7
>> >  };
>> >
>> > Modified: libunwind/trunk/src/Registers.hpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Registers.hpp?rev=292723=292722=292723=diff
>> >
>> > ==
>> > --- libunwind/trunk/src/Registers.hpp (original)
>> > +++ libunwind/trunk/src/Registers.hpp Sat Jan 21 10:22:59 2017
>> > @@ -122,9 +122,17 @@ inline uint32_t Registers_x86::getRegist
>> >  return _registers.__edx;
>> >case UNW_X86_EBX:
>> >  return _registers.__ebx;
>> > +#if !defined(__APPLE__)
>> > +  case UNW_X86_ESP:
>> > +#else
>> >case UNW_X86_EBP:
>> > +#endif
>> >  return _registers.__ebp;
>> > +#if !defined(__APPLE__)
>> > +  case UNW_X86_EBP:
>> > +#else
>> >case UNW_X86_ESP:
>> > +#endif
>> >  return _registers.__esp;
>> >case UNW_X86_ESI:
>> >  return _registers.__esi;
>> > @@ -154,10 +162,18 @@ inline void Registers_x86::setRegister(i
>> >case UNW_X86_EBX:
>> >  _registers.__ebx = value;
>> >  return;
>> > +#if !defined(__APPLE__)
>> > +  case UNW_X86_ESP:
>> > +#else
>> >case UNW_X86_EBP:
>> > +#endif
>> >  _registers.__ebp = value;
>> >  return;
>> > +#if !defined(__APPLE__)
>> > +  case UNW_X86_EBP:
>> > +#else
>> >case UNW_X86_ESP:
>> > +#endif
>> >  _registers.__esp = value;
>> >  return;
>> >case UNW_X86_ESI:
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r293298 - Merging r292723:

2017-01-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Jan 27 10:27:43 2017
New Revision: 293298

URL: http://llvm.org/viewvc/llvm-project?rev=293298=rev
Log:
Merging r292723:

r292723 | compnerd | 2017-01-21 08:22:59 -0800 (Sat, 21 Jan 2017) | 17 lines

X86: swap EBP, ESP on !APPLE

Restore the `libunwind.h` enumeration values back to the inverted
values.  This diverges from the DWARF definition of the register values.
However, this allows our header to be compatible with other unwind
implementations (e.g. HP, GNU Savannah, GCC).

The register IDs are only swapped in the header and need to be unswapped
when accessing the unwind register file.  The flipped EBP and ESP only
applies on non-Apple x86 targets.

When optimizations were enabled, EBP and ESP would no longer be
equivalent.  As a result, the incorrect access on Linux would manifest
as a failure to unwind the stack.  We can now unwind the stack with and
without FPO on Linux x86.

Resolves PR30879!


Modified:
libunwind/branches/release_40/   (props changed)
libunwind/branches/release_40/include/libunwind.h
libunwind/branches/release_40/src/Registers.hpp

Propchange: libunwind/branches/release_40/
--
svn:mergeinfo = /libunwind/trunk:292723

Modified: libunwind/branches/release_40/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_40/include/libunwind.h?rev=293298=293297=293298=diff
==
--- libunwind/branches/release_40/include/libunwind.h (original)
+++ libunwind/branches/release_40/include/libunwind.h Fri Jan 27 10:27:43 2017
@@ -165,13 +165,8 @@ enum {
   UNW_X86_ECX = 1,
   UNW_X86_EDX = 2,
   UNW_X86_EBX = 3,
-#if defined(__CloudABI__) || defined(__FreeBSD__)
-  UNW_X86_ESP = 4,
-  UNW_X86_EBP = 5,
-#else
   UNW_X86_EBP = 4,
   UNW_X86_ESP = 5,
-#endif
   UNW_X86_ESI = 6,
   UNW_X86_EDI = 7
 };

Modified: libunwind/branches/release_40/src/Registers.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_40/src/Registers.hpp?rev=293298=293297=293298=diff
==
--- libunwind/branches/release_40/src/Registers.hpp (original)
+++ libunwind/branches/release_40/src/Registers.hpp Fri Jan 27 10:27:43 2017
@@ -122,9 +122,17 @@ inline uint32_t Registers_x86::getRegist
 return _registers.__edx;
   case UNW_X86_EBX:
 return _registers.__ebx;
+#if !defined(__APPLE__)
+  case UNW_X86_ESP:
+#else
   case UNW_X86_EBP:
+#endif
 return _registers.__ebp;
+#if !defined(__APPLE__)
+  case UNW_X86_EBP:
+#else
   case UNW_X86_ESP:
+#endif
 return _registers.__esp;
   case UNW_X86_ESI:
 return _registers.__esi;
@@ -154,10 +162,18 @@ inline void Registers_x86::setRegister(i
   case UNW_X86_EBX:
 _registers.__ebx = value;
 return;
+#if !defined(__APPLE__)
+  case UNW_X86_ESP:
+#else
   case UNW_X86_EBP:
+#endif
 _registers.__ebp = value;
 return;
+#if !defined(__APPLE__)
+  case UNW_X86_EBP:
+#else
   case UNW_X86_ESP:
+#endif
 _registers.__esp = value;
 return;
   case UNW_X86_ESI:


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


Re: r292561 - PR31701: Fix crash on invalid caused by parsing a dependent initializer when we

2017-01-27 Thread Hans Wennborg via cfe-commits
r293297.

Cheers,
Hans

On Thu, Jan 26, 2017 at 4:45 PM, Richard Smith  wrote:
> Sure, why not.
>
> On 26 January 2017 at 15:56, Hans Wennborg  wrote:
>>
>> A candidate for clang 4?
>>
>> On Thu, Jan 19, 2017 at 5:19 PM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Thu Jan 19 19:19:46 2017
>> > New Revision: 292561
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=292561=rev
>> > Log:
>> > PR31701: Fix crash on invalid caused by parsing a dependent initializer
>> > when we
>> > don't know we're in a dependent context.
>> >
>> > Modified:
>> > cfe/trunk/lib/AST/ASTContext.cpp
>> > cfe/trunk/test/SemaCXX/constant-expression.cpp
>> >
>> > Modified: cfe/trunk/lib/AST/ASTContext.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=292561=292560=292561=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>> > +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jan 19 19:19:46 2017
>> > @@ -9021,7 +9021,8 @@ bool ASTContext::DeclMustBeEmitted(const
>> >
>> >// Variables that have initialization with side-effects are required.
>> >if (VD->getInit() && VD->getInit()->HasSideEffects(*this) &&
>> > -  !VD->evaluateValue())
>> > +  // We can get a value-dependent initializer during error
>> > recovery.
>> > +  (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
>> >  return true;
>> >
>> >// Likewise, variables with tuple-like bindings are required if their
>> >
>> > Modified: cfe/trunk/test/SemaCXX/constant-expression.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression.cpp?rev=292561=292560=292561=diff
>> >
>> > ==
>> > --- cfe/trunk/test/SemaCXX/constant-expression.cpp (original)
>> > +++ cfe/trunk/test/SemaCXX/constant-expression.cpp Thu Jan 19 19:19:46
>> > 2017
>> > @@ -143,3 +143,14 @@ namespace rdar16064952 {
>> >  }
>> >
>> >  char PR17381_ice = 100 * 100; // expected-warning {{overflow}}
>> > expected-warning {{changes value}}
>> > +
>> > +namespace PR31701 {
>> > +  struct C {
>> > +template static int n; // expected-warning {{extension}}
>> > +  };
>> > +  template  class D;
>> > +  template 
>> > +  template void D::set() { // expected-error {{from class
>> > 'D' without definition}}
>> > +const C c = C::n;
>> > +  }
>> > +}
>> >
>> >
>> > ___
>> > 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


Re: r293134 - [index] When indexing an ObjC method declaration use its base name for the location.

2017-01-27 Thread Argyrios Kyrtzidis via cfe-commits
*bump*

> On Jan 25, 2017, at 6:36 PM, Argyrios Kyrtzidis  wrote:
> 
> Hi Hans,
> 
> Could this go into the stable branch ?
> 
>> On Jan 25, 2017, at 6:11 PM, Argyrios Kyrtzidis via cfe-commits 
>>  wrote:
>> 
>> Author: akirtzidis
>> Date: Wed Jan 25 20:11:50 2017
>> New Revision: 293134
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=293134=rev
>> Log:
>> [index] When indexing an ObjC method declaration use its base name for the 
>> location.
>> 
>> Instead of using the location of the beginning '-'/'+'.
>> This is consistent with location used for function decls and ObjC method 
>> calls where we use the base name as the location as well.
>> 
>> Modified:
>>   cfe/trunk/lib/Index/IndexDecl.cpp
>>   cfe/trunk/test/Index/Core/index-source.m
>>   cfe/trunk/test/Index/Core/index-subkinds.m
>>   cfe/trunk/test/Index/index-decls.m
>>   cfe/trunk/test/Index/index-module.m
>>   cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
>>   cfe/trunk/tools/libclang/CXIndexDataConsumer.h
>> 
>> Modified: cfe/trunk/lib/Index/IndexDecl.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=293134=293133=293134=diff
>> ==
>> --- cfe/trunk/lib/Index/IndexDecl.cpp (original)
>> +++ cfe/trunk/lib/Index/IndexDecl.cpp Wed Jan 25 20:11:50 2017
>> @@ -92,7 +92,13 @@ public:
>>  Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
>> AssociatedProp);
>> 
>> -if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
>> +// getLocation() returns beginning token of a method declaration, but 
>> for
>> +// indexing purposes we want to point to the base name.
>> +SourceLocation MethodLoc = D->getSelectorStartLoc();
>> +if (MethodLoc.isInvalid())
>> +  MethodLoc = D->getLocation();
>> +
>> +if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, 
>> Relations))
>>  return false;
>>IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
>>bool hasIBActionAndFirst = D->hasAttr();
>> 
>> Modified: cfe/trunk/test/Index/Core/index-source.m
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=293134=293133=293134=diff
>> ==
>> --- cfe/trunk/test/Index/Core/index-source.m (original)
>> +++ cfe/trunk/test/Index/Core/index-source.m Wed Jan 25 20:11:50 2017
>> @@ -3,10 +3,10 @@
>> @interface Base
>> // CHECK: [[@LINE-1]]:12 | class/ObjC | Base | c:objc(cs)Base | 
>> _OBJC_CLASS_$_Base | Decl | rel: 0
>> -(void)meth;
>> -// CHECK: [[@LINE-1]]:1 | instance-method/ObjC | meth | 
>> c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
>> +// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | 
>> c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
>> // CHECK-NEXT: RelChild | Base | c:objc(cs)Base
>> +(Base*)class_meth;
>> -// CHECK: [[@LINE-1]]:1 | class-method/ObjC | class_meth | 
>> c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 
>> 1
>> +// CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | 
>> c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 
>> 1
>> // CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | 
>> _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
>> // CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth
>> 
>> @@ -92,7 +92,7 @@ extern int setjmp(jmp_buf);
>> 
>> @class I1;
>> @interface I1
>> -// CHECK: [[@LINE+1]]:1 | instance-method/ObjC | meth | 
>> c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
>> +// CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | 
>> c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
>> -(void)meth;
>> @end
>> 
>> @@ -117,7 +117,7 @@ extern int setjmp(jmp_buf);
>> // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
>> @synthesize prop = _prop;
>> 
>> -// CHECK: [[@LINE+5]]:1 | instance-method(IB)/ObjC | doAction:foo: | 
>> c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | 
>> rel: 1
>> +// CHECK: [[@LINE+5]]:12 | instance-method(IB)/ObjC | doAction:foo: | 
>> c:objc(cs)I2(im)doAction:foo: | -[I2 doAction:foo:] | Def,Dyn,RelChild | 
>> rel: 1
>> // CHECK-NEXT: RelChild | I2 | c:objc(cs)I2
>> // CHECK: [[@LINE+3]]:22 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 
>> | Ref,RelCont,RelIBType | rel: 1
>> // CHECK-NEXT: RelCont,RelIBType | doAction:foo: | 
>> c:objc(cs)I2(im)doAction:foo:
>> @@ -127,11 +127,11 @@ extern int setjmp(jmp_buf);
>> 
>> @interface I3
>> @property (readwrite) id prop;
>> -// CHECK: [[@LINE+3]]:1 | instance-method/acc-get/ObjC | prop | 
>> c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2
>> +// CHECK: [[@LINE+3]]:6 | instance-method/acc-get/ObjC | prop | 
>> c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2

[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-01-27 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano created this revision.

This change adds a feature to the clang-format VS extension that optionally 
enables the automatic formatting of documents when saving. Since developers 
always need to save their files, this eases the workflow of making sure source 
files are properly formatted. This feature exists in other IDEs, notably in 
Eclipse ; furthermore, there is a 
VS extension that provides this functionality 

 for generic formatters, so there is definitely a precedent for this type of 
feature.

Although this patch works, I know it's quite big and potentially contentious, 
so I'd like to start a discussion about it here. I would appreciate it if you 
could try it out locally for a couple days to see how it feels. Personally, 
I've been using it and like how it eases my workflow.

Here's a screenshot of what the options grid looks like now by default:
F3029838: pasted_file 

Things to note:

- I renamed the category "LLVM/Clang" to "Format Options" and added one to 
group the "Format on Save" options.

- The "File extensions" field is needed to filter out non-source code documents 
that are modified in VS, but that we don't want to format with clang-format. 
The list of extensions includes all possible C/C++ file extensions (I hope), 
and the list of extensions presently supported by clang-format.

- The "Mode" field allows you to select "All Documents" or "Current Document", 
which effectively scopes the formatting on save to all modified documents or 
current modified document respectively. I'm still on the fence on whether to 
even bother offering this mode, especially since "Current Document" can be 
weird since you could modify multiple files, then "save all" (which happens 
when you trigger a build), and find that only the current document gets 
formatted. Perhaps it's just better to only support "All Documents" and remove 
this field.

Other things I'd like to call out in this change:

- When formatting on save, we ignore the FallbackStyle in the user's options 
and set it to "none". This is to make sure we only format files based on Style: 
for e.g., if Style if "file", we only format on save when a .clang-format file 
is found; but we don't format files in projects that have no .clang-format. I 
think this makes sense since "format on save" is a global option, and users 
would be surprised to find it formatting files in projects that don't have a 
.clang-format file. The description of the "Enable" field in the options dialog 
explains this.

- I split out some helper functions into a VsixUtils class and file, and added 
new utility functions for format on save. I also added 2 new files with more 
related helpers.

- I added the attribute [ProvideAutoLoad(UIContextGuids80.SolutionExists)] to 
make the extension load as soon as a solution is loaded, rather than have it 
load lazily upon the first format line/document call. This is required so that 
I can register for the BeforeSave callback right away, otherwise formatting on 
save would not work until the user first explicitly formats (via menu or 
keyboard shortcut).

- I did some refactoring around OptionsPageGrid so that rather than accessing 
it directly in RunClangFormat(), we pass it down as args. This allows me to 
override user options, specifically the FallbackStyle, when formatting on save. 
(line 320)

Thanks, and I looked forward to your feedback!


https://reviews.llvm.org/D29221

Files:
  tools/clang-format-vs/ClangFormat/ClangFormat.csproj
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs
  tools/clang-format-vs/ClangFormat/TypeConverterUtils.cs
  tools/clang-format-vs/ClangFormat/VsixUtils.cs

Index: tools/clang-format-vs/ClangFormat/VsixUtils.cs
===
--- /dev/null
+++ tools/clang-format-vs/ClangFormat/VsixUtils.cs
@@ -0,0 +1,96 @@
+using EnvDTE;
+using Microsoft.VisualStudio.Editor;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.TextManager.Interop;
+using System;
+using System.IO;
+
+namespace LLVM.ClangFormat
+{
+internal sealed class VsixUtils
+{
+/// 
+/// Returns the currently active view if it is a IWpfTextView.
+/// 
+public static IWpfTextView GetCurrentView()
+{
+// The SVsTextManager is a service through which we can get the active view.
+var textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
+IVsTextView textView;
+textManager.GetActiveView(1, null, out textView);
+
+// Now we have the active view as IVsTextView, but the text 

[PATCH] D29118: [clang-tidy] safety-no-vector-bool

2017-01-27 Thread Ben Cox via Phabricator via cfe-commits
djehuti added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp:52
+<< MatchedDecl;
+  }
+}

JonasToth wrote:
> maybe an safety else with an failing assert, so you can see that unexpected 
> behaviour, see comment above
You mean like [[ 
http://www.codingstandard.com/rule/6-1-2-explicitly-cover-all-paths-through-multi-way-selection-statements/
 | High Integrity C++ rule 6.1.2 ]]?   :wink:


https://reviews.llvm.org/D29118



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


r293286 - [OpenCL] Add missing address spaces in IR generation of blocks

2017-01-27 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Fri Jan 27 09:11:34 2017
New Revision: 293286

URL: http://llvm.org/viewvc/llvm-project?rev=293286=rev
Log:
[OpenCL] Add missing address spaces in IR generation of blocks

Modify ObjC blocks impl wrt address spaces as follows:

- keep default private address space for blocks generated
as local variables (with captures);

- add global address space for global block literals (no captures);

- make the block invoke function and enqueue_kernel prototype with
the generic AS block pointer parameter to accommodate both 
private and global AS cases from above;

- add block handling into default AS because it's implemented as
a special pointer type (BlockPointer) in the frontend and therefore
it is used as a pointer everywhere. This is also needed to accommodate
both private and global AS blocks for the two cases above.

- removes ObjC RT specific symbols (NSConcreteStackBlock and
NSConcreteGlobalBlock) in the OpenCL mode.

Review: https://reviews.llvm.org/D28814


Added:
cfe/trunk/test/CodeGenOpenCL/blocks.cl
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
cfe/trunk/test/SemaOpenCL/invalid-block.cl

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=293286=293285=293286=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Jan 27 09:11:34 2017
@@ -1571,8 +1571,9 @@ bool CastExpr::CastConsistency() const {
 goto CheckNoBasePath;
 
   case CK_AddressSpaceConversion:
-assert(getType()->isPointerType());
-assert(getSubExpr()->getType()->isPointerType());
+assert(getType()->isPointerType() || getType()->isBlockPointerType());
+assert(getSubExpr()->getType()->isPointerType() ||
+   getSubExpr()->getType()->isBlockPointerType());
 assert(getType()->getPointeeType().getAddressSpace() !=
getSubExpr()->getType()->getPointeeType().getAddressSpace());
   // These should not have an inheritance path.

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=293286=293285=293286=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Jan 27 09:11:34 2017
@@ -718,7 +718,12 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
   // Otherwise, we have to emit this as a local block.
 
-  llvm::Constant *isa = CGM.getNSConcreteStackBlock();
+  llvm::Constant *isa =
+  (!CGM.getContext().getLangOpts().OpenCL)
+  ? CGM.getNSConcreteStackBlock()
+  : CGM.getNullPointer(cast(
+   CGM.getNSConcreteStackBlock()->getType()),
+   QualType(getContext().VoidPtrTy));
   isa = llvm::ConstantExpr::getBitCast(isa, VoidPtrTy);
 
   // Build the block descriptor.
@@ -906,9 +911,8 @@ llvm::Value *CodeGenFunction::EmitBlockL
 
   // Cast to the converted block-pointer type, which happens (somewhat
   // unfortunately) to be a pointer to function type.
-  llvm::Value *result =
-Builder.CreateBitCast(blockAddr.getPointer(),
-  ConvertType(blockInfo.getBlockExpr()->getType()));
+  llvm::Value *result = Builder.CreatePointerCast(
+  blockAddr.getPointer(), 
ConvertType(blockInfo.getBlockExpr()->getType()));
 
   return result;
 }
@@ -976,21 +980,41 @@ RValue CodeGenFunction::EmitBlockCallExp
   llvm::Value *BlockPtr = EmitScalarExpr(E->getCallee());
 
   // Get a pointer to the generic block literal.
+  // For OpenCL we generate generic AS void ptr to be able to reuse the same
+  // block definition for blocks with captures generated as private AS local
+  // variables and without captures generated as global AS program scope
+  // variables.
+  unsigned AddrSpace = 0;
+  if (getLangOpts().OpenCL)
+AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_generic);
+
   llvm::Type *BlockLiteralTy =
-llvm::PointerType::getUnqual(CGM.getGenericBlockLiteralType());
+  llvm::PointerType::get(CGM.getGenericBlockLiteralType(), AddrSpace);
 
   // Bitcast the callee to a block literal.
-  BlockPtr = Builder.CreateBitCast(BlockPtr, BlockLiteralTy, "block.literal");
+  BlockPtr =
+  Builder.CreatePointerCast(BlockPtr, BlockLiteralTy, "block.literal");
 
   // Get the function pointer from the literal.
   llvm::Value *FuncPtr =
 Builder.CreateStructGEP(CGM.getGenericBlockLiteralType(), BlockPtr, 3);
 
-  BlockPtr = Builder.CreateBitCast(BlockPtr, VoidPtrTy);
 
   // Add the block literal.
   CallArgList Args;
-  Args.add(RValue::get(BlockPtr), getContext().VoidPtrTy);
+
+  QualType VoidPtrQualTy = 

[PATCH] D29118: [clang-tidy] safety-no-vector-bool

2017-01-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp:50
+diag(MatchedDecl->getLocation(),
+ " function %0 returns an instance of std::vector")
+<< MatchedDecl;

jbcoe wrote:
> djehuti wrote:
> > JonasToth wrote:
> > > i think all those diag() calls can be merged into one. inside the 
> > > if/else-if you can just set a StringRef with the specific part of the 
> > > warning, and have a parameterized diag() at the end of the function.
> > > 
> > > in NoMallocCheck there is a similar pattern:
> > > 
> > >   const CallExpr *Call = nullptr; 
> > >  
> > >   StringRef Recommendation;   
> > >  
> > >   
> > >  
> > >   if ((Call = Result.Nodes.getNodeAs("aquisition")))
> > >  
> > > Recommendation = "consider a container or a smart pointer";   
> > >  
> > >   else if ((Call = Result.Nodes.getNodeAs("realloc")))  
> > >  
> > > Recommendation = "consider std::vector or std::string";   
> > >  
> > >   else if ((Call = Result.Nodes.getNodeAs("free"))) 
> > >  
> > > Recommendation = "use RAII";  
> > >  
> > >   
> > >  
> > >   assert(Call && "Unhandled binding in the Matcher"); 
> > >  
> > >   
> > >  
> > >   diag(Call->getLocStart(), "do not manage memory manually; %0")  
> > >  
> > >   << Recommendation << SourceRange(Call->getLocStart(), 
> > > Call->getLocEnd());
> > > 
> > Except with braces, right? (That's another High-Integrity C++ rule btw.)  ;)
> I agree that this _can_ be done but I'm not convinced it helps readability. 
> Repetition is partial and very localized. I'll happily make the change if you 
> feel strongly that it's an improvement.
i think either is ok. maybe someone else prefers one strongly over the other, 
but i dont mind.

but i think the else path should exist, make an failing assert or sth like 
that, for the safety ;)



Comment at: clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp:37
+std::vector v4;  
+

jbcoe wrote:
> JonasToth wrote:
> > what happens for types where std::vector would be an template 
> > argument? for example std::pair and tuple could contain a vector.
> > is there a warning as well?
> Nicely spotted. Those won't get picked up right now and need to be. 
> 
> I'm struggling to build a matcher for this. We really need to find any place 
> where `std::vector` is used as a template argument.
i found hasAnyTemplateArgument in the ast matcher refrence. did u use that one?


https://reviews.llvm.org/D29118



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


[PATCH] D29031: [mips] Add support for static model on N64

2017-01-27 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293285: [mips] Add support for static model on N64 (authored 
by sdardis).

Changed prior to commit:
  https://reviews.llvm.org/D29031?vs=85388=86047#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29031

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/mips-as.c

Index: cfe/trunk/test/Driver/mips-as.c
===
--- cfe/trunk/test/Driver/mips-as.c
+++ cfe/trunk/test/Driver/mips-as.c
@@ -21,17 +21,32 @@
 // MIPS32R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EL"
 //
 // RUN: %clang -target mips64-linux-gnu -### \
-// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EB-AS %s
-// MIPS64R2-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
+// MIPS64R2-EB-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-EB"
 //
-// RUN: %clang -target mips64el-linux-gnu -### \
+// RUN: %clang -target mips64-linux-gnu -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-EB-AS-PIC %s
+// MIPS64R2-EB-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB" "-KPIC"
+//
+// RUN: %clang -target mips64el-linux-gnu -### \
+// RUN:   -no-integrated-as -c -fno-pic %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-DEF-EL-AS %s
-// MIPS64R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"  "-mno-shared" "-KPIC" "-EL"
+// MIPS64R2-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64"  "-mno-shared" "-EL"
+//
+// RUN: %clang -target mips64el-linux-gnu -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-DEF-EL-AS-PIC %s
+// MIPS64R2-DEF-EL-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC"
 //
 // RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-N32-PIC %s
+// MIPS-N32-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-call_nonpic" "-EB" "-KPIC"
+//
+// RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \
+// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-N32 %s
 // MIPS-N32: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "n32" "-mno-shared" "-call_nonpic" "-EB"
 //
@@ -45,8 +60,13 @@
 //
 // RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS64R2-EL-AS-PIC %s
+// MIPS64R2-EL-AS-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EL" "-KPIC"
+//
+// RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \
+// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-EL-AS %s
-// MIPS64R2-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EL"
+// MIPS64R2-EL-AS: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-EL"
 //
 // RUN: %clang -target mips-linux-gnu -march=mips32r2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -60,8 +80,13 @@
 //
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-OCTEON-PIC %s
+// MIPS-OCTEON-PIC: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-EB" "-KPIC"
+//
+// RUN: %clang -target mips64-linux-gnu -march=octeon -### \
+// RUN:   -no-integrated-as -c %s -fno-pic 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s
-// MIPS-OCTEON: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
+// MIPS-OCTEON: as{{(.exe)?}}" "-march" "octeon" "-mabi" "64" "-mno-shared" "-EB"
 //
 // RUN: %clang -target mips-linux-gnu -mips1 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -115,28 +140,48 @@
 //
 // RUN: %clang -target mips64-linux-gnu -mips64 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64-PIC %s
+// MIPS-ALIAS-64-PIC: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" "-KPIC"
+//
+// RUN: %clang -target mips64-linux-gnu -mips64 -### \
+// RUN:   -no-integrated-as -c -fno-pic %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64 %s
-// MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
+// MIPS-ALIAS-64: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-mno-shared" "-EB"
 //
 // RUN: %clang -target mips64-linux-gnu -mips64r2 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2 %s
-// MIPS-ALIAS-64R2: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-mno-shared" "-KPIC" "-EB"
+// RUN:   | FileCheck -check-prefix=MIPS-ALIAS-64R2-PIC %s
+// MIPS-ALIAS-64R2-PIC: as{{(.exe)?}}" "-march" "mips64r2" "-mabi" "64" "-EB" "-KPIC"
 //
 // RUN: %clang -target 

r293285 - [mips] Add support for static model on N64

2017-01-27 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Fri Jan 27 09:05:25 2017
New Revision: 293285

URL: http://llvm.org/viewvc/llvm-project?rev=293285=rev
Log:
[mips] Add support for static model on N64

The patch teaches the Clang driver how to handle the N64 static
relocation model properly. It enforces the correct target feature
(+noabicalls) when -fno-pic is used. This is required as non-pic
N64 code as the abi extension to call PIC code (CPIC) is unsupported.

Make PIC the default for mips64 and mips64el, this affects both N32
& N64 ABIs, to better match GCC.

As part of this effort, clean up the assembler invocation command
builder, so the correct flags are used.

This and r293279 in LLVM resolves PR/23485.

Thanks to Brooks Davis for reporting the issue!

Reviewers: slthakur, seanbruno

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


Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/mips-as.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=293285=293284=293285=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jan 27 09:05:25 2017
@@ -2892,6 +2892,9 @@ bool Generic_GCC::isPICDefault() const {
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
 return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX();
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+return true;
   default:
 return false;
   }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=293285=293284=293285=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 27 09:05:25 2017
@@ -1540,8 +1540,54 @@ static void getMIPSTargetFeatures(const
   mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
   ABIName = getGnuCompatibleMipsABIName(ABIName);
 
-  AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
-   options::OPT_mabicalls, "noabicalls");
+  // Historically, PIC code for MIPS was associated with -mabicalls, a.k.a
+  // SVR4 abicalls. Static code does not use SVR4 calling sequences. An ABI
+  // extension was developed by Richard Sandiford & Code Sourcery to support
+  // static code calling PIC code (CPIC). For O32 and N32 this means we have
+  // several combinations of PIC/static and abicalls. Pure static, static
+  // with the CPIC extension, and pure PIC code.
+
+  // At final link time, O32 and N32 with CPIC will have another section
+  // added to the binary which contains the stub functions to perform
+  // any fixups required for PIC code.
+
+  // For N64, the situation is more regular: code can either be static
+  // (non-abicalls) or PIC (abicalls). GCC has traditionally picked PIC code
+  // code for N64. Since Clang has already built the relocation model portion
+  // of the commandline, we pick add +noabicalls feature in the N64 static
+  // case.
+
+  // The is another case to be accounted for: -msym32, which enforces that all
+  // symbols have 32 bits in size. In this case, N64 can in theory use CPIC
+  // but it is unsupported.
+
+  // The combinations for N64 are:
+  // a) Static without abicalls and 64bit symbols.
+  // b) Static with abicalls and 32bit symbols.
+  // c) PIC with abicalls and 64bit symbols.
+
+  // For case (a) we need to add +noabicalls for N64.
+
+  bool IsN64 = ABIName == "64";
+  bool NonPIC = false;
+
+  Arg *LastPICArg = Args.getLastArg(options::OPT_fPIC, options::OPT_fno_PIC,
+options::OPT_fpic, options::OPT_fno_pic,
+options::OPT_fPIE, options::OPT_fno_PIE,
+options::OPT_fpie, options::OPT_fno_pie);
+  if (LastPICArg) {
+Option O = LastPICArg->getOption();
+NonPIC =
+(O.matches(options::OPT_fno_PIC) || O.matches(options::OPT_fno_pic) ||
+ O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
+  }
+
+  if (IsN64 && NonPIC) {
+Features.push_back("+noabicalls");
+  } else {
+AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
+ options::OPT_mabicalls, "noabicalls");
+  }
 
   mips::FloatABI FloatABI = getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
@@ -3973,6 +4019,13 @@ ParsePICArgs(const ToolChain ,
   if ((ROPI || RWPI) && (PIC || PIE))
 ToolChain.getDriver().Diag(diag::err_drv_ropi_rwpi_incompatible_with_pic);
 
+  // When targettng MIPS64 with N64, the default is PIC, unless -mno-abicalls 
is
+  // used.
+  if ((Triple.getArch() == llvm::Triple::mips64 ||
+   Triple.getArch() == llvm::Triple::mips64el) &&
+  Args.hasArg(options::OPT_mno_abicalls))
+return 

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-01-27 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ping.


https://reviews.llvm.org/D25866



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


Re: [clang-tools-extra] r293217 - Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications.

2017-01-27 Thread Aaron Ballman via cfe-commits
On Fri, Jan 27, 2017 at 2:36 AM, Diana Picus  wrote:
> Hi Don, Hi Aaron,
>
> I had to revert this in r293267 because all the clang-tools-extra
> buildbots were still broken many hours after it was committed.
> See for instance
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1039
>
> Eugene Zelenko also had some small fixes to
> modernize-use-noexcept.rst, you might want to incorporate those as
> well before recommitting (see r293234).

Thank you, and sorry for the bot breakage -- I thought I had gotten
the bots back into a good state before I had to run off last night. I
had made a fix as well, in r293218 that you will also want to pull in.

~Aaron

>
> Regards,
> Diana
>
> On 27 January 2017 at 00:34, Aaron Ballman via cfe-commits
>  wrote:
>> Author: aaronballman
>> Date: Thu Jan 26 16:34:24 2017
>> New Revision: 293217
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=293217=rev
>> Log:
>> Implement a new clang-tidy check that suggests users replace dynamic 
>> exception specifications with noexcept exception specifications.
>>
>> Patch by Don Hinton.
>>
>> Added:
>> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h
>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> clang-tools-extra/trunk/docs/ReleaseNotes.rst
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=293217=293216=293217=diff
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Jan 26 
>> 16:34:24 2017
>> @@ -20,6 +20,7 @@ add_clang_library(clangTidyModernizeModu
>>UseEmplaceCheck.cpp
>>UseEqualsDefaultCheck.cpp
>>UseEqualsDeleteCheck.cpp
>> +  UseNoexceptCheck.cpp
>>UseNullptrCheck.cpp
>>UseOverrideCheck.cpp
>>UseTransparentFunctorsCheck.cpp
>>
>> Modified: 
>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=293217=293216=293217=diff
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
>> Jan 26 16:34:24 2017
>> @@ -26,6 +26,7 @@
>>  #include "UseEmplaceCheck.h"
>>  #include "UseEqualsDefaultCheck.h"
>>  #include "UseEqualsDeleteCheck.h"
>> +#include "UseNoexceptCheck.h"
>>  #include "UseNullptrCheck.h"
>>  #include "UseOverrideCheck.h"
>>  #include "UseTransparentFunctorsCheck.h"
>> @@ -63,6 +64,7 @@ public:
>>  
>> CheckFactories.registerCheck("modernize-use-equals-default");
>>  CheckFactories.registerCheck(
>>  "modernize-use-equals-delete");
>> +
>> CheckFactories.registerCheck("modernize-use-noexcept");
>>  CheckFactories.registerCheck("modernize-use-nullptr");
>>  
>> CheckFactories.registerCheck("modernize-use-override");
>>  CheckFactories.registerCheck(
>>
>> Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=293217=auto
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp (added)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp Thu 
>> Jan 26 16:34:24 2017
>> @@ -0,0 +1,114 @@
>> +//===--- UseNoexceptCheck.cpp - 
>> clang-tidy-===//
>> +//
>> +// The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===--===//
>> +
>> +#include "UseNoexceptCheck.h"
>> +#include "clang/AST/ASTContext.h"
>> +#include "clang/Lex/Lexer.h"
>> +
>> +using namespace clang::ast_matchers;
>> +
>> +namespace clang {
>> +namespace tidy {
>> +namespace modernize {
>> +
>> +UseNoexceptCheck::UseNoexceptCheck(StringRef 

[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2017-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

There were some issues with failing tests that caused this commit to need to be 
reverted in r293267

See for instance: 
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/1039

Eugene Zelenko also had some small fixes you might want to incorporate as well 
before recommitting (see r293234).


https://reviews.llvm.org/D20693



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


Re: r292590 - [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows

2017-01-27 Thread Alexey Bataev via cfe-commits
Yes. Could you do it yourself or you want me to do it?

-
Best regards,
Alexey Bataev

27.01.2017 2:33, Hans Wennborg пишет:
> Should we merge this to the release branch?
>
> On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits
>  wrote:
>> Author: abataev
>> Date: Fri Jan 20 02:57:28 2017
>> New Revision: 292590
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=292590=rev
>> Log:
>> [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows
>> with SEH and openmp
>>
>> In some cituations (during codegen for Windows SEH constructs)
>> CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related
>> code does not expect such situation during cleanup.
>>
>> Added:
>>  cfe/trunk/test/OpenMP/openmp_seh.c
>> Modified:
>>  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=292590=292589=292590=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017
>> @@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() {
>> if (FirstBlockInfo)
>>   destroyBlockInfos(FirstBlockInfo);
>>
>> -  if (getLangOpts().OpenMP) {
>> +  if (getLangOpts().OpenMP && CurFn)
>>   CGM.getOpenMPRuntime().functionFinished(*this);
>> -  }
>>   }
>>
>>   CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
>>
>> Added: cfe/trunk/test/OpenMP/openmp_seh.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_seh.c?rev=292590=auto
>> ==
>> --- cfe/trunk/test/OpenMP/openmp_seh.c (added)
>> +++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017
>> @@ -0,0 +1,18 @@
>> +// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp 
>> -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s
>> +// expected-no-diagnostics
>> +// REQUIRES: x86-registered-target
>> +extern "C" {
>> +void __cpuid(int[4], int);
>> +}
>> +
>> +// CHECK-LABEL: @main
>> +int main(void) {
>> +  __try {
>> +int info[4];
>> +__cpuid(info, 1);
>> +  } __except (1) {
>> +  }
>> +
>> +  return 0;
>> +}
>> +
>>
>>
>> ___
>> 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


r293280 - [analyzer] Consider function call arguments while building CallGraph.

2017-01-27 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Jan 27 06:14:56 2017
New Revision: 293280

URL: http://llvm.org/viewvc/llvm-project?rev=293280=rev
Log:
[analyzer] Consider function call arguments while building CallGraph.

Function call can appear in the arguments of another function call, eg.:

  foo(bar());

This patch adds support for such cases.

Patch by Ivan Sidorenko!

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

Modified:
cfe/trunk/lib/Analysis/CallGraph.cpp
cfe/trunk/test/Analysis/debug-CallGraph.c

Modified: cfe/trunk/lib/Analysis/CallGraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CallGraph.cpp?rev=293280=293279=293280=diff
==
--- cfe/trunk/lib/Analysis/CallGraph.cpp (original)
+++ cfe/trunk/lib/Analysis/CallGraph.cpp Fri Jan 27 06:14:56 2017
@@ -62,6 +62,7 @@ public:
   void VisitCallExpr(CallExpr *CE) {
 if (Decl *D = getDeclFromCall(CE))
   addCalledDecl(D);
+VisitChildren(CE);
   }
 
   // Adds may-call edges for the ObjC message sends.

Modified: cfe/trunk/test/Analysis/debug-CallGraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/debug-CallGraph.c?rev=293280=293279=293280=diff
==
--- cfe/trunk/test/Analysis/debug-CallGraph.c (original)
+++ cfe/trunk/test/Analysis/debug-CallGraph.c Fri Jan 27 06:14:56 2017
@@ -1,5 +1,17 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s -fblocks 
2>&1 | FileCheck %s
 
+int get5() {
+  return 5;
+}
+
+int add(int val1, int val2) {
+  return val1 + val2;
+}
+
+int test_add() {
+  return add(10, get5());
+}
+
 static void mmm(int y) {
   if (y != 0)
   y++;
@@ -32,7 +44,7 @@ void eee() {}
 void fff() { eee(); }
 
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: mmm foo aaa < > bbb ccc ddd eee fff 
$}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ccc ddd eee fff $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}
 // CHECK-NEXT: {{Function: eee calls: $}}
 // CHECK-NEXT: {{Function: ddd calls: ccc $}}
@@ -42,3 +54,6 @@ void fff() { eee(); }
 // CHECK-NEXT: {{Function: aaa calls: foo $}}
 // CHECK-NEXT: {{Function: foo calls: mmm $}}
 // CHECK-NEXT: {{Function: mmm calls: $}}
+// CHECK-NEXT: {{Function: test_add calls: add get5 $}}
+// CHECK-NEXT: {{Function: add calls: $}}
+// CHECK-NEXT: {{Function: get5 calls: $}}


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


[PATCH] D28905: [analyzer] Consider function call arguments while building CallGraph

2017-01-27 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293280: [analyzer] Consider function call arguments while 
building CallGraph. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D28905?vs=84973=86041#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28905

Files:
  cfe/trunk/lib/Analysis/CallGraph.cpp
  cfe/trunk/test/Analysis/debug-CallGraph.c


Index: cfe/trunk/test/Analysis/debug-CallGraph.c
===
--- cfe/trunk/test/Analysis/debug-CallGraph.c
+++ cfe/trunk/test/Analysis/debug-CallGraph.c
@@ -1,5 +1,17 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s -fblocks 
2>&1 | FileCheck %s
 
+int get5() {
+  return 5;
+}
+
+int add(int val1, int val2) {
+  return val1 + val2;
+}
+
+int test_add() {
+  return add(10, get5());
+}
+
 static void mmm(int y) {
   if (y != 0)
   y++;
@@ -32,7 +44,7 @@
 void fff() { eee(); }
 
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: mmm foo aaa < > bbb ccc ddd eee fff 
$}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > 
bbb ccc ddd eee fff $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}
 // CHECK-NEXT: {{Function: eee calls: $}}
 // CHECK-NEXT: {{Function: ddd calls: ccc $}}
@@ -42,3 +54,6 @@
 // CHECK-NEXT: {{Function: aaa calls: foo $}}
 // CHECK-NEXT: {{Function: foo calls: mmm $}}
 // CHECK-NEXT: {{Function: mmm calls: $}}
+// CHECK-NEXT: {{Function: test_add calls: add get5 $}}
+// CHECK-NEXT: {{Function: add calls: $}}
+// CHECK-NEXT: {{Function: get5 calls: $}}
Index: cfe/trunk/lib/Analysis/CallGraph.cpp
===
--- cfe/trunk/lib/Analysis/CallGraph.cpp
+++ cfe/trunk/lib/Analysis/CallGraph.cpp
@@ -62,6 +62,7 @@
   void VisitCallExpr(CallExpr *CE) {
 if (Decl *D = getDeclFromCall(CE))
   addCalledDecl(D);
+VisitChildren(CE);
   }
 
   // Adds may-call edges for the ObjC message sends.


Index: cfe/trunk/test/Analysis/debug-CallGraph.c
===
--- cfe/trunk/test/Analysis/debug-CallGraph.c
+++ cfe/trunk/test/Analysis/debug-CallGraph.c
@@ -1,5 +1,17 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s -fblocks 2>&1 | FileCheck %s
 
+int get5() {
+  return 5;
+}
+
+int add(int val1, int val2) {
+  return val1 + val2;
+}
+
+int test_add() {
+  return add(10, get5());
+}
+
 static void mmm(int y) {
   if (y != 0)
   y++;
@@ -32,7 +44,7 @@
 void fff() { eee(); }
 
 // CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: mmm foo aaa < > bbb ccc ddd eee fff $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ccc ddd eee fff $}}
 // CHECK-NEXT: {{Function: fff calls: eee $}}
 // CHECK-NEXT: {{Function: eee calls: $}}
 // CHECK-NEXT: {{Function: ddd calls: ccc $}}
@@ -42,3 +54,6 @@
 // CHECK-NEXT: {{Function: aaa calls: foo $}}
 // CHECK-NEXT: {{Function: foo calls: mmm $}}
 // CHECK-NEXT: {{Function: mmm calls: $}}
+// CHECK-NEXT: {{Function: test_add calls: add get5 $}}
+// CHECK-NEXT: {{Function: add calls: $}}
+// CHECK-NEXT: {{Function: get5 calls: $}}
Index: cfe/trunk/lib/Analysis/CallGraph.cpp
===
--- cfe/trunk/lib/Analysis/CallGraph.cpp
+++ cfe/trunk/lib/Analysis/CallGraph.cpp
@@ -62,6 +62,7 @@
   void VisitCallExpr(CallExpr *CE) {
 if (Decl *D = getDeclFromCall(CE))
   addCalledDecl(D);
+VisitChildren(CE);
   }
 
   // Adds may-call edges for the ObjC message sends.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27810: Normalize all filenames before searching FileManager caches

2017-01-27 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added inline comments.



Comment at: lib/Basic/FileManager.cpp:218
+#ifdef LLVM_ON_WIN32
+  SmallString<128> NormalizedPath(Filename.str());
+  llvm::sys::path::native(NormalizedPath);

yaron.keren wrote:
> I'd use a larger SmallString<256>, with large projects 128 bytes are 
> frequently not enough.
Well, the calling sides often use 128, so that's why I stuck with it.


https://reviews.llvm.org/D27810



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


[PATCH] D27810: Normalize all filenames before searching FileManager caches

2017-01-27 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

besc: I can't reproduce any crash. I tried trunk and the release_39 branch with 
msvc2015.


https://reviews.llvm.org/D27810



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


r293270 - clang-format: [JS] do not format MPEG transport streams.

2017-01-27 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Fri Jan 27 03:09:11 2017
New Revision: 293270

URL: http://llvm.org/viewvc/llvm-project?rev=293270=rev
Log:
clang-format: [JS] do not format MPEG transport streams.

Summary:
The MPEG transport stream file format also uses ".ts" as its file extension.
This change detects its specific framing format (0x47 every 189 bytes) and
simply ignores MPEG TS files.

Reviewers: djasper, sammccall

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/tools/clang-format/ClangFormat.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=293270=293269=293270=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan 27 03:09:11 2017
@@ -1462,12 +1462,22 @@ tooling::Replacements sortCppIncludes(co
   return Replaces;
 }
 
+bool isMpegTS(StringRef Code) {
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
+}
+
 tooling::Replacements sortIncludes(const FormatStyle , StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
+  isMpegTS(Code))
+return Replaces;
   if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
 return sortJavaScriptImports(Style, Code, Ranges, FileName);
   sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
@@ -1813,7 +1823,8 @@ tooling::Replacements reformat(const For
   FormatStyle Expanded = expandPresets(Style);
   if (Expanded.DisableFormat)
 return tooling::Replacements();
-
+  if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
+return tooling::Replacements();
   auto Env = Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
 
   if (Style.Language == FormatStyle::LK_JavaScript &&

Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=293270=293269=293270=diff
==
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Fri Jan 27 03:09:11 2017
@@ -256,6 +256,7 @@ static bool format(StringRef FileName) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
   }
+
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle->SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=293270=293269=293270=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jan 27 03:09:11 2017
@@ -1036,6 +1036,15 @@ TEST_F(FormatTestJS, RegexLiteralExample
   verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);");
 }
 
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  std::string MpegTS(200, ' ');
+  MpegTS.replace(0, strlen("nearlyLooks  +   like +   ts + code;  "),
+ "nearlyLooks  +   like +   ts + code;  ");
+  MpegTS[0] = 0x47;
+  MpegTS[188] = 0x47;
+  verifyFormat(MpegTS, MpegTS);
+}
+
 TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: string;");
   verifyFormat("var x: {a: string; b: number;} = {};");


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


[PATCH] D29186: clang-format: [JS] do not format MPEG transport streams.

2017-01-27 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293270: clang-format: [JS] do not format MPEG transport 
streams. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D29186?vs=85934=86028#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29186

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/tools/clang-format/ClangFormat.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
@@ -1462,12 +1462,22 @@
   return Replaces;
 }
 
+bool isMpegTS(StringRef Code) {
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
+}
+
 tooling::Replacements sortIncludes(const FormatStyle , StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
+  isMpegTS(Code))
+return Replaces;
   if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
 return sortJavaScriptImports(Style, Code, Ranges, FileName);
   sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
@@ -1813,7 +1823,8 @@
   FormatStyle Expanded = expandPresets(Style);
   if (Expanded.DisableFormat)
 return tooling::Replacements();
-
+  if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
+return tooling::Replacements();
   auto Env = Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
 
   if (Style.Language == FormatStyle::LK_JavaScript &&
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1036,6 +1036,15 @@
   verifyFormat("var regex = search.match(/(?:\?|&)times=([^?&]+)/i);");
 }
 
+TEST_F(FormatTestJS, IgnoresMpegTS) {
+  std::string MpegTS(200, ' ');
+  MpegTS.replace(0, strlen("nearlyLooks  +   like +   ts + code;  "),
+ "nearlyLooks  +   like +   ts + code;  ");
+  MpegTS[0] = 0x47;
+  MpegTS[188] = 0x47;
+  verifyFormat(MpegTS, MpegTS);
+}
+
 TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: string;");
   verifyFormat("var x: {a: string; b: number;} = {};");
Index: cfe/trunk/tools/clang-format/ClangFormat.cpp
===
--- cfe/trunk/tools/clang-format/ClangFormat.cpp
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp
@@ -256,6 +256,7 @@
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
   }
+
   if (SortIncludes.getNumOccurrences() != 0)
 FormatStyle->SortIncludes = SortIncludes;
   unsigned CursorPosition = Cursor;


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1462,12 +1462,22 @@
   return Replaces;
 }
 
+bool isMpegTS(StringRef Code) {
+  // MPEG transport streams use the ".ts" file extension. clang-format should
+  // not attempt to format those. MPEG TS' frame format starts with 0x47 every
+  // 189 bytes - detect that and return.
+  return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
+}
+
 tooling::Replacements sortIncludes(const FormatStyle , StringRef Code,
ArrayRef Ranges,
StringRef FileName, unsigned *Cursor) {
   tooling::Replacements Replaces;
   if (!Style.SortIncludes)
 return Replaces;
+  if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
+  isMpegTS(Code))
+return Replaces;
   if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
 return sortJavaScriptImports(Style, Code, Ranges, FileName);
   sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
@@ -1813,7 +1823,8 @@
   FormatStyle Expanded = expandPresets(Style);
   if (Expanded.DisableFormat)
 return tooling::Replacements();
-
+  if (Expanded.Language == FormatStyle::LK_JavaScript && isMpegTS(Code))
+return tooling::Replacements();
   auto Env = Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
 
   if (Style.Language == FormatStyle::LK_JavaScript &&
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1036,6 +1036,15 @@
   verifyFormat("var regex = 

[PATCH] D29186: clang-format: [JS] do not format MPEG transport streams.

2017-01-27 Thread Martin Probst via Phabricator via cfe-commits
mprobst added a comment.

In https://reviews.llvm.org/D29186#657828, @alexeagle wrote:

> confused, wasn't this committed last year? is this an extra check?


I think I fixed this in tslint, but not in clang-format. At least I cannot find 
a trace of it (but yeah, I thought I had fixed it, too).


https://reviews.llvm.org/D29186



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


RE: r293207 - PR0091R3: Implement parsing support for using templates as types.

2017-01-27 Thread Yung, Douglas via cfe-commits
Hi Richard, I've filed this issue as PR31783.

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Yung, Douglas via cfe-commits
> Sent: Thursday, January 26, 2017 15:36
> To: Richard Smith
> Cc: cfe-commits@lists.llvm.org
> Subject: RE: r293207 - PR0091R3: Implement parsing support for using
> templates as types.
> 
> Hi Richard,
> 
> I don't know if you have noticed, but the test you added in this commit
> is failing on both the Linux and Windows PS4 bots. The test is failing
> with an assertion failure:
> 
> Assertion failed: !A->getDeducedType().isNull() && "cannot request the
> size of an undeduced or dependent auto type", file
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
> fast\llvm.src\tools\clang\lib\AST\ASTContext.cpp, line 1884
> 
> Can you take a look?
> 
> Windows PS4 bot failure: http://lab.llvm.org:8011/builders/llvm-clang-
> lld-x86_64-scei-ps4-windows10pro-fast/builds/4531
> Linux PS4 bot failure: http://lab.llvm.org:8011/builders/llvm-clang-
> lld-x86_64-scei-ps4-ubuntu-fast/builds/5093
> 
> Douglas Yung
> 
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> Behalf
> > Of Richard Smith via cfe-commits
> > Sent: Thursday, January 26, 2017 12:41
> > To: cfe-commits@lists.llvm.org
> > Subject: r293207 - PR0091R3: Implement parsing support for using
> > templates as types.
> >
> > Author: rsmith
> > Date: Thu Jan 26 14:40:47 2017
> > New Revision: 293207
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=293207=rev
> > Log:
> > PR0091R3: Implement parsing support for using templates as types.
> >
> > This change adds a new type node, DeducedTemplateSpecializationType,
> to
> > represent a type template name that has been used as a type. This is
> > modeled
> > around AutoType, and shares a common base class for representing a
> > deduced
> > placeholder type.
> >
> > We allow deduced class template types in a few more places than the
> > standard
> > does: in conditions and for-range-declarators, and in new-type-ids.
> > This is
> > consistent with GCC and with discussion on the core reflector. This
> > patch
> > does not yet support deduced class template types being named in
> > typename
> > specifiers.
> >
> > Added:
> > cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp
> > Modified:
> > cfe/trunk/include/clang/AST/ASTContext.h
> > cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> > cfe/trunk/include/clang/AST/Type.h
> > cfe/trunk/include/clang/AST/TypeLoc.h
> > cfe/trunk/include/clang/AST/TypeNodes.def
> > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> > cfe/trunk/include/clang/Parse/Parser.h
> > cfe/trunk/include/clang/Sema/DeclSpec.h
> > cfe/trunk/include/clang/Sema/Sema.h
> > cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> > cfe/trunk/lib/AST/ASTContext.cpp
> > cfe/trunk/lib/AST/ASTImporter.cpp
> > cfe/trunk/lib/AST/ExprConstant.cpp
> > cfe/trunk/lib/AST/ItaniumMangle.cpp
> > cfe/trunk/lib/AST/MicrosoftMangle.cpp
> > cfe/trunk/lib/AST/Type.cpp
> > cfe/trunk/lib/AST/TypePrinter.cpp
> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> > cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> > cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> > cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> > cfe/trunk/lib/Parse/ParseDecl.cpp
> > cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> > cfe/trunk/lib/Parse/ParseExprCXX.cpp
> > cfe/trunk/lib/Parse/Parser.cpp
> > cfe/trunk/lib/Sema/SemaDecl.cpp
> > cfe/trunk/lib/Sema/SemaExpr.cpp
> > cfe/trunk/lib/Sema/SemaExprCXX.cpp
> > cfe/trunk/lib/Sema/SemaLookup.cpp
> > cfe/trunk/lib/Sema/SemaTemplate.cpp
> > cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
> > cfe/trunk/lib/Sema/SemaType.cpp
> > cfe/trunk/lib/Sema/TreeTransform.h
> > cfe/trunk/lib/Serialization/ASTReader.cpp
> > cfe/trunk/lib/Serialization/ASTWriter.cpp
> > cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
> > cfe/trunk/test/CXX/drs/dr5xx.cpp
> > cfe/trunk/test/Parser/backtrack-off-by-one.cpp
> > cfe/trunk/test/SemaTemplate/temp_arg.cpp
> > cfe/trunk/test/SemaTemplate/typename-specifier-3.cpp
> > cfe/trunk/tools/libclang/CIndex.cpp
> > cfe/trunk/tools/libclang/CXType.cpp
> >
> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
> > URL: http://llvm.org/viewvc/llvm-
> >
> project/cfe/trunk/include/clang/AST/ASTContext.h?rev=293207=293206
> > 2=293207=diff
> >
> ===
> > ===
> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> > +++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jan 26 14:40:47 2017
> > @@ -167,6 +167,8 @@ class ASTContext : public RefCountedBase
> >mutable llvm::FoldingSet
> >  DependentUnaryTransformTypes;
> >mutable llvm::FoldingSet AutoTypes;
> > +  mutable llvm::FoldingSet