Allow tools to work without compilation database

2015-12-02 Thread Russell Wallace via cfe-commits
Per discussion at
http://lists.llvm.org/pipermail/cfe-dev/2015-December/046321.html allow
tools to work in the absence of a compilation database, but warn the user
about the absence.
Index: lib/Tooling/CommonOptionsParser.cpp
===
--- lib/Tooling/CommonOptionsParser.cpp (revision 254518)
+++ lib/Tooling/CommonOptionsParser.cpp (working copy)
@@ -116,8 +116,7 @@
 
   cl::HideUnrelatedOptions(Category);
 
-  Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc,
-   argv));
+  Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, 
argv));
   cl::ParseCommandLineOptions(argc, argv, Overview);
   SourcePathList = SourcePaths;
   if (!Compilations) {
@@ -129,8 +128,13 @@
   Compilations = CompilationDatabase::autoDetectFromSource(SourcePaths[0],
ErrorMessage);
 }
-if (!Compilations)
-  llvm::report_fatal_error(ErrorMessage);
+if (!Compilations) {
+  errs() << "Compilation database not found - using default options\n";
+  int argc = 1;
+  const char *argv[] = {"--"};
+  Compilations.reset(
+  FixedCompilationDatabase::loadFromCommandLine(argc, argv));
+}
   }
   auto AdjustingCompilations =
   llvm::make_unique(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15140: Update clang to use the updated LLVM EH instructions

2015-12-02 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 41716.
majnemer added a comment.

- Updated for the latest EH changes


http://reviews.llvm.org/D15140

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGen/exceptions-seh-finally.c
  test/CodeGen/exceptions-seh-leave.c
  test/CodeGen/exceptions-seh.c
  test/CodeGenCXX/exceptions-cxx-new.cpp
  test/CodeGenCXX/exceptions-seh.cpp
  test/CodeGenCXX/microsoft-abi-arg-order.cpp
  test/CodeGenCXX/microsoft-abi-eh-catch.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
  test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
  test/CodeGenCXX/microsoft-abi-try-throw.cpp

Index: test/CodeGenCXX/microsoft-abi-try-throw.cpp
===
--- test/CodeGenCXX/microsoft-abi-try-throw.cpp
+++ test/CodeGenCXX/microsoft-abi-try-throw.cpp
@@ -19,7 +19,7 @@
 external(); // TRY: invoke void @"\01?external@@YAXXZ"
   } catch (int) {
 rv = 1;
-// TRY: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
+// TRY: catchpad within %0 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null]
 // TRY: catchret
   }
 #endif
@@ -39,7 +39,7 @@
 external();
   } catch (const int *) {
   }
-  // TRY: catchpad [%rtti.TypeDescriptor4* @"\01??_R0PAH@8", i32 1, i8* null]
+  // TRY: catchpad within %0 [%rtti.TypeDescriptor4* @"\01??_R0PAH@8", i32 1, i8* null]
   // TRY: catchret
 }
 #endif
Index: test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
===
--- test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
+++ test/CodeGenCXX/microsoft-abi-thread-safe-statics.cpp
@@ -39,7 +39,7 @@
 // CHECK-NEXT:  ret %struct.S* @"\01?s@?1??f@@YAAAUS@@XZ@4U2@A"
 
 // CHECK: [[lpad:.*]]:
-// CHECK-NEXT: cleanuppad []
+// CHECK-NEXT: cleanuppad within none []
 // CHECK:   %[[guard:.*]] = load i32, i32* @"\01??__J?1??f@@YAAAUS@@XZ@51"
 // CHECK-NEXT:  %[[mask:.*]] = and i32 %[[guard]], -2
 // CHECK-NEXT:  store i32 %[[mask]], i32* @"\01??__J?1??f@@YAAAUS@@XZ@51"
@@ -75,7 +75,7 @@
 // CHECK-NEXT:  ret %struct.S* @"\01?s@?1??g@@YAAAUS@@XZ@4U2@A"
 //
 // CHECK: [[lpad]]:
-// CHECK-NEXT: cleanuppad []
+// CHECK-NEXT: cleanuppad within none []
 // CHECK:   call void @_Init_thread_abort(i32* @"\01?$TSS0@?1??g@@YAAAUS@@XZ")
 // CHECK-NEXT:  cleanupret {{.*}} unwind to caller
   return s;
Index: test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
@@ -9,6 +9,6 @@
 // CHECK-LABEL: define void @"\01?never_throws@@YAXXZ"()
 // CHECK-SAME:  personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
 // CHECK:  invoke void @"\01?may_throw@@YAXXZ"()
-// MSVC2013:  terminatepad [void ()* @"\01?terminate@@YAXXZ"]
-// MSVC2015:  terminatepad [void ()* @__std_terminate]
+// MSVC2013:  terminatepad within none [void ()* @"\01?terminate@@YAXXZ"]
+// MSVC2015:  terminatepad within none [void ()* @__std_terminate]
 // CHECK-NEXT: unreachable
Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -27,7 +27,7 @@
 //
 //There should be one dtor call for unwinding from the second getA.
 // WIN32:   cleanuppad
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}}) #[[noinline:[0-9]+]]
+// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
 // WIN32-NOT: @"\01??1A@@QAE@XZ"
 // WIN32: }
 
@@ -62,7 +62,7 @@
 //Conditionally destroy arg1.
 // WIN32:   %[[cond:.*]] = load i1, i1* %[[isactive]]
 // WIN32:   br i1 %[[cond]]
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg1]]) #[[noinline]]
+// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg1]])
 // WIN32: }
 
 // Test putting the cleanups inside a conditional.
@@ -85,7 +85,7 @@
 // WIN32:   call i32 @"\01?CouldThrow@@YAHXZ"()
 //
 //Only one dtor in the invoke for arg1
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}}) #[[noinline]]
+// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
 // WIN32-NOT: invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"
 // WIN32: }
 
@@ -126,7 +126,7 @@
 //Somewhere in the landing pad soup, we conditionally destroy arg1.
 // WIN32:   %[[isactive:.*]] = load i1, i1* %[[arg1_cond]]
 // WIN32:   br i1 %[[isactive]]
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}}) #[[noinline]]
+// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"({{.*}})
 // WIN32: }
 
 namespace crash_on_partial_destroy {
@@ -16

[PATCH] D15174: [MSVC] Fix for http://llvm.org/PR25636: indexed accessor property not supported correctly.

2015-12-02 Thread Alexey Bataev via cfe-commits
ABataev created this revision.
ABataev added reviewers: rnk, rjmccall.
ABataev added a subscriber: cfe-commits.

All problems described in http://llvm.org/PR25636 are implemented except for 
return value of the 'put' property. This patch fixes this problem with the 
indexed properties

http://reviews.llvm.org/D15174

Files:
  lib/Sema/SemaPseudoObject.cpp
  test/CodeGenCXX/ms-property.cpp
  test/SemaCXX/ms-property-error.cpp
  test/SemaCXX/ms-property.cpp

Index: lib/Sema/SemaPseudoObject.cpp
===
--- lib/Sema/SemaPseudoObject.cpp
+++ lib/Sema/SemaPseudoObject.cpp
@@ -228,6 +228,11 @@
   ResultIndex = Semantics.size() - 1;
 }
 
+void setResultToNextSemantic() {
+  assert(ResultIndex == PseudoObjectExpr::NoResult);
+  ResultIndex = Semantics.size();
+}
+
 /// Return true if assignments have a non-void result.
 bool CanCaptureValue(Expr *exp) {
   if (exp->isGLValue())
@@ -1489,12 +1494,21 @@
 return ExprError();
   }
 
-  SmallVector ArgExprs;
+  SmallVector ArgExprs;
   ArgExprs.append(CallArgs.begin(), CallArgs.end());
   ArgExprs.push_back(op);
-  return S.ActOnCallExpr(S.getCurScope(), SetterExpr.get(),
- RefExpr->getSourceRange().getBegin(), ArgExprs,
- op->getSourceRange().getEnd());
+  ExprResult Res = S.ActOnCallExpr(S.getCurScope(), SetterExpr.get(),
+   RefExpr->getSourceRange().getBegin(),
+   ArgExprs, op->getSourceRange().getEnd());
+
+  if (!Res.isInvalid() && captureSetValueAsResult) {
+Expr *ResExpr = Res.get();
+if (!ResExpr->getType()->isVoidType() &&
+(ResExpr->getType()->isDependentType() || CanCaptureValue(ResExpr)))
+  setResultToNextSemantic();
+  }
+
+  return Res;
 }
 
 //===--===//
Index: test/SemaCXX/ms-property.cpp
===
--- test/SemaCXX/ms-property.cpp
+++ test/SemaCXX/ms-property.cpp
@@ -29,7 +29,7 @@
 public:
   __declspec(property(get=GetX,put=PutX)) T x[];
   T GetX(T i, T j) { return i+j; }
-  void PutX(T i, T j, T k) { j = i = k; }
+  T PutX(T i, T j, T k) { return j = i = k; }
   ~St() { x[0][0] = x[1][1]; }
 };
 
@@ -52,6 +52,8 @@
   ((p2->x)[23])[1] = j1;
   // CHECK-NEXT: ++(((p2->x)[23])[1]);
   ++(((p2->x)[23])[1]);
+  // CHECK-NEXT: j1 = ((p2->x)[23])[1] = j1;
+  j1 = ((p2->x)[23])[1] = j1;
   // CHECK-NEXT: return Test1::GetTest1()->X;
   return Test1::GetTest1()->X;
 }
Index: test/SemaCXX/ms-property-error.cpp
===
--- test/SemaCXX/ms-property-error.cpp
+++ test/SemaCXX/ms-property-error.cpp
@@ -7,17 +7,19 @@
   void PutX(int i, int j, int k) { j = i = k; } // expected-note {{'PutX' declared here}}
 };
 
+char *ptr;
 template 
 class St {
 public:
   __declspec(property(get=GetX,put=PutX)) T x[];
   T GetX(T i, T j) { return i+j; } // expected-note 3 {{'GetX' declared here}}
-  void PutX(T i, T j, T k) { j = i = k; }  // expected-note 2 {{'PutX' declared here}}
+  T PutX(T i, T j, T k) { return j = i = k; }  // expected-note 2 {{'PutX' declared here}}
   ~St() {
 x[1] = 0; // expected-error {{too few arguments to function call, expected 3, have 2}}
 x[2][3] = 4;
 ++x[2][3];
 x[1][2] = x[3][4][5]; // expected-error {{too many arguments to function call, expected 2, have 3}}
+ptr = x[1][2] = x[3][4]; // expected-error {{assigning to 'char *' from incompatible type 'int'}}
   }
 };
 
@@ -30,5 +32,6 @@
   (p1->x[23]) = argc; // expected-error {{too few arguments to function call, expected 3, have 2}}
   float j1 = (p2->x); // expected-error {{too few arguments to function call, expected 2, have 0}}
   ((p2->x)[23])[1][2] = *argv; // expected-error {{too many arguments to function call, expected 3, have 4}}
+  argv = p2->x[11][22] = argc; // expected-error {{assigning to 'char **' from incompatible type 'float'}}
   return ++(((p2->x)[23])); // expected-error {{too few arguments to function call, expected 2, have 1}}
 }
Index: test/CodeGenCXX/ms-property.cpp
===
--- test/CodeGenCXX/ms-property.cpp
+++ test/CodeGenCXX/ms-property.cpp
@@ -31,7 +31,7 @@
   __declspec(property(get=GetX,put=PutX)) T x[];
   T GetX(T i, T j) { return i+j; }
   T GetX() { return 0; }
-  void PutX(T i, T j, T k) { j = i = k; }
+  T PutX(T i, T j, T k) { return j = i = k; }
   __declspec(property(get=GetY,put=PutY)) T y[];
   char GetY(char i,  Test1 j) { return i+j.get_x(); }
   void PutY(char i, int j, double k) { j = i = k; }
@@ -61,14 +61,16 @@
   // CHECK: call float @"\01?GetX@?$St@M@@QEAAMMM@Z"(%class.St* %{{.+}}, float 2.23e+02, float 1.10e+01)
   float j1 = p2->x[223][11];
   // CHECK: [[J1:%.+]] = load float, float* %
-  // CHECK-NEXT: call void @"\01?PutX@?$St@M@@QEAAXMMM@Z

[PATCH] D15173: [Preprocessor] Fix assertion in AnnotatePreviousCachedTokens

2015-12-02 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added reviewers: doug.gregor, akyrtzi.
bruno added subscribers: cfe-commits, dexonsmith.

Consider the following ObjC++ snippet:

  @protocol PA;
  @protocol PB;

  @class NSArray;
  typedef int some_t;

  id FA(NSArray> *h, some_t group);

This would hit an assertion in the parser after generating an annotation token 
while
trying to update the token cache:

Assertion failed: (CachedTokens[CachedLexPos-1].getLastLoc() == 
Tok.getAnnotationEndLoc() && "The annotation should be until the most recent 
cached token")
...
7  clang::Preprocessor::AnnotatePreviousCachedTokens(clang::Token const&) + 494
8  clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool, bool, 
clang::CXXScopeSpec&, bool) + 1163
9  clang::Parser::TryAnnotateTypeOrScopeToken(bool, bool) + 361
10 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) + 
598
...

The cached preprocessor token in this case is:

greatergreater '>>' Loc= 

while the annotation ("NSArray>") ends at "testcase.mm:7:25", hence the 
assertion.
The mismatch only happens because of the cached token length and the assertion 
should account for that.

http://reviews.llvm.org/D15173

Files:
  lib/Lex/PPCaching.cpp
  test/Parser/objcxx11-protocol-in-template.mm

Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -97,8 +97,19 @@
 void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   assert(Tok.isAnnotation() && "Expected annotation token");
   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
-  assert(CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc()
- && "The annotation should be until the most recent cached token");
+
+  // The annotation should be until the most recent cached token. Since
+  // `Tok` length could be bigger than one (e.g. greatergreater '>>'), account
+  // for that cases before checking the assertion.
+  Token CachedLastTok = CachedTokens[CachedLexPos - 1];
+  unsigned CachedLastTokLoc = CachedLastTok.getLastLoc().getRawEncoding();
+  unsigned TokAnnEndLoc = Tok.getAnnotationEndLoc().getRawEncoding();
+  if (CachedLastTokLoc != TokAnnEndLoc && !CachedLastTok.isAnnotation())
+CachedLastTokLoc += CachedLastTok.getLength() - 1;
+  (void)CachedLastTokLoc;
+  (void)TokAnnEndLoc;
+  assert(CachedLastTokLoc == TokAnnEndLoc &&
+ "The annotation should be until the most recent cached token");
 
   // Start from the end of the cached tokens list and look for the token
   // that is the beginning of the annotation token.


Index: test/Parser/objcxx11-protocol-in-template.mm
===
--- test/Parser/objcxx11-protocol-in-template.mm
+++ test/Parser/objcxx11-protocol-in-template.mm
@@ -8,3 +8,11 @@
 
 vector> v;
 vector>> v2;
+
+@protocol PA;
+@protocol PB;
+
+@class NSArray;
+typedef int some_t;
+
+id FA(NSArray> *h, some_t group);
Index: lib/Lex/PPCaching.cpp
===
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -97,8 +97,19 @@
 void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
   assert(Tok.isAnnotation() && "Expected annotation token");
   assert(CachedLexPos != 0 && "Expected to have some cached tokens");
-  assert(CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc()
- && "The annotation should be until the most recent cached token");
+
+  // The annotation should be until the most recent cached token. Since
+  // `Tok` length could be bigger than one (e.g. greatergreater '>>'), account
+  // for that cases before checking the assertion.
+  Token CachedLastTok = CachedTokens[CachedLexPos - 1];
+  unsigned CachedLastTokLoc = CachedLastTok.getLastLoc().getRawEncoding();
+  unsigned TokAnnEndLoc = Tok.getAnnotationEndLoc().getRawEncoding();
+  if (CachedLastTokLoc != TokAnnEndLoc && !CachedLastTok.isAnnotation())
+CachedLastTokLoc += CachedLastTok.getLength() - 1;
+  (void)CachedLastTokLoc;
+  (void)TokAnnEndLoc;
+  assert(CachedLastTokLoc == TokAnnEndLoc &&
+ "The annotation should be until the most recent cached token");
 
   // Start from the end of the cached tokens list and look for the token
   // that is the beginning of the annotation token.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r254579 - Fix a comment typo from r251874.

2015-12-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Dec  2 20:25:26 2015
New Revision: 254579

URL: http://llvm.org/viewvc/llvm-project?rev=254579&view=rev
Log:
Fix a comment typo from r251874.

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

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=254579&r1=254578&r2=254579&view=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Dec  2 20:25:26 2015
@@ -418,7 +418,7 @@ Sema::HandlePropertyInClassExtension(Sco
   }
 
   // A readonly property declared in the primary class can be refined
-  // by adding a rewrite property within an extension.
+  // by adding a readwrite property within an extension.
   // Anything else is an error.
   unsigned PIkind = PIDecl->getPropertyAttributesAsWritten();
   if (!(isReadWrite && (PIkind & ObjCPropertyDecl::OBJC_PR_readonly))) {


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


Re: [PATCH] D15166: Fix C++ support on recent DragonFly BSD releases

2015-12-02 Thread Joerg Sonnenberger via cfe-commits
On Thu, Dec 03, 2015 at 12:15:25AM +, Dimitry Andric wrote:
> This patch updates the Clang driver to use libstdc++ from GCC 5.2

What about the abi tag mess? Or do you actually mean GCC 5.0?

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


r254576 - generalize CHECK lines to make buildbot happy

2015-12-02 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Wed Dec  2 19:51:39 2015
New Revision: 254576

URL: http://llvm.org/viewvc/llvm-project?rev=254576&view=rev
Log:
generalize CHECK lines to make buildbot happy

Modified:
cfe/trunk/test/CodeGen/fp-contract-pragma.cpp

Modified: cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fp-contract-pragma.cpp?rev=254576&r1=254575&r2=254576&view=diff
==
--- cfe/trunk/test/CodeGen/fp-contract-pragma.cpp (original)
+++ cfe/trunk/test/CodeGen/fp-contract-pragma.cpp Wed Dec  2 19:51:39 2015
@@ -68,8 +68,8 @@ float fp_contract_6(float a, float b, fl
 
 float fp_contract_7(float a, float b, float c) {
 // CHECK: _Z13fp_contract_7fff
-// CHECK:  %mul = fmul float %b, 2.00e+00
-// CHECK-NEXT: fsub float %mul, %c
+// CHECK:  %[[M:.+]] = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %[[M]], %c
   #pragma STDC FP_CONTRACT ON
   return (a = 2 * b) - c;
 }


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


Re: [PATCH] D15169: [SemaCXX] Fix handling of C-style casts from void pointers to pointers in different address space.

2015-12-02 Thread Manuel Jacob via cfe-commits
mjacob added inline comments.


Comment at: lib/Sema/SemaCast.cpp:1081-1083
@@ -1080,3 +1080,5 @@
   }
-  Kind = CK_BitCast;
+  unsigned SrcAS = SrcPointee.getAddressSpace();
+  unsigned DestAS = DestPointee.getAddressSpace();
+  Kind = SrcAS != DestAS ? CK_AddressSpaceConversion : CK_BitCast;
   return TC_Success;

rsmith wrote:
> I would expect to get both a `CK_BitCast` *and* a `CK_AddressSpaceCast` 
> created for this case. Note that by not returning `CK_BitCast`, you lose the 
> `checkCastAlign` call in the caller.
> 
> Instead, can you push this check down into wherever we're building the 
> conversion, so that if we try to create a `CK_BitCast` that crosses address 
> spaces, we additionally create a `CK_AddressSpaceCast`?
I'm not sure what you mean by "**additionally** create a 
`CK_AddressSpaceCast`". Please clarify.

Would it also be possible to extend all places which call `checkCastAlign()` to 
also call it for `CK_AddressSpaceCast`?


http://reviews.llvm.org/D15169



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


r254574 - PR17381: Treat undefined behavior during expression evaluation as an unmodeled

2015-12-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Dec  2 19:36:22 2015
New Revision: 254574

URL: http://llvm.org/viewvc/llvm-project?rev=254574&view=rev
Log:
PR17381: Treat undefined behavior during expression evaluation as an unmodeled
side-effect, so that we don't allow speculative evaluation of such expressions
during code generation.

This caused a diagnostic quality regression, so fix constant expression
diagnostics to prefer either the first "can't be constant folded" diagnostic or
the first "not a constant expression" diagnostic depending on the kind of
evaluation we're doing. This was always the intent, but didn't quite work
correctly before.

This results in certain initializers that used to be constant initializers to
no longer be; in particular, things like:

  float f = 1e100;

are no longer accepted in C. This seems appropriate, as such constructs would
lead to code being executed if sanitizers are enabled.

Added:
cfe/trunk/test/CodeGen/ubsan-conditional.c
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
cfe/trunk/test/CodeGen/complex-init-list.c
cfe/trunk/test/PCH/floating-literal.c
cfe/trunk/test/Sema/const-eval.c
cfe/trunk/test/Sema/integer-overflow.c
cfe/trunk/test/Sema/switch-1.c
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
cfe/trunk/test/SemaCXX/constexpr-printing.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=254574&r1=254573&r2=254574&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Dec  2 19:36:22 2015
@@ -473,6 +473,10 @@ namespace {
 /// notes attached to it will also be stored, otherwise they will not be.
 bool HasActiveDiagnostic;
 
+/// \brief Have we emitted a diagnostic explaining why we couldn't constant
+/// fold (not just why it's not strictly a constant expression)?
+bool HasFoldFailureDiagnostic;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the 
expression
   /// is not a constant expression.
@@ -537,7 +541,7 @@ namespace {
 BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
 EvaluatingDecl((const ValueDecl *)nullptr),
 EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
-EvalMode(Mode) {}
+HasFoldFailureDiagnostic(false), EvalMode(Mode) {}
 
 void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value) {
   EvaluatingDecl = Base;
@@ -597,7 +601,7 @@ namespace {
 /// Diagnose that the evaluation cannot be folded.
 OptionalDiagnostic Diag(SourceLocation Loc, diag::kind DiagId
   = diag::note_invalid_subexpr_in_const_expr,
-unsigned ExtraNotes = 0) {
+unsigned ExtraNotes = 0, bool IsCCEDiag = false) {
   if (EvalStatus.Diag) {
 // If we have a prior diagnostic, it will be noting that the expression
 // isn't a constant expression. This diagnostic is more important,
@@ -610,10 +614,9 @@ namespace {
   case EM_ConstantFold:
   case EM_IgnoreSideEffects:
   case EM_EvaluateForOverflow:
-if (!EvalStatus.HasSideEffects)
+if (!HasFoldFailureDiagnostic)
   break;
-// We've had side-effects; we want the diagnostic from them, not
-// some later problem.
+// We've already failed to fold something. Keep that diagnostic.
   case EM_ConstantExpression:
   case EM_PotentialConstantExpression:
   case EM_ConstantExpressionUnevaluated:
@@ -632,6 +635,7 @@ namespace {
   CallStackNotes = 0;
 
 HasActiveDiagnostic = true;
+HasFoldFailureDiagnostic = !IsCCEDiag;
 EvalStatus.Diag->clear();
 EvalStatus.Diag->reserve(1 + ExtraNotes + CallStackNotes);
 addDiag(Loc, DiagId);
@@ -645,9 +649,9 @@ namespace {
 
 OptionalDiagnostic Diag(const Expr *E, diag::kind DiagId
   = diag::note_invalid_subexpr_in_const_expr,
-unsigned ExtraNotes = 0) {
+unsigned ExtraNotes = 0, bool IsCCEDiag = false) {
   if (EvalStatus.Diag)
-return Diag(E->getExprLoc(), DiagId, ExtraNotes);
+return Diag(E->getExprLoc(), DiagId, ExtraNotes, IsCCEDiag);
   HasActiveDiagnostic = false;
   return OptionalDiagnostic();
 }
@@ -667,7 +671,7 @@ namespace {
 HasActiveDiagnostic = false;
 return OptionalDiagnostic();
   }
-  return Diag(Loc, DiagId, ExtraNotes);
+  return Diag(Loc, DiagId, ExtraNotes, true);
 }
 
 /// Add a note to a prior diagnostic.
@@ -1541,10 +1545,11 @@ static bool EvaluateAsBooleanCondition(c
 }
 
 template
-static void Hand

Re: [PATCH] D15169: [SemaCXX] Fix handling of C-style casts from void pointers to pointers in different address space.

2015-12-02 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaCast.cpp:1081-1083
@@ -1080,3 +1080,5 @@
   }
-  Kind = CK_BitCast;
+  unsigned SrcAS = SrcPointee.getAddressSpace();
+  unsigned DestAS = DestPointee.getAddressSpace();
+  Kind = SrcAS != DestAS ? CK_AddressSpaceConversion : CK_BitCast;
   return TC_Success;

I would expect to get both a `CK_BitCast` *and* a `CK_AddressSpaceCast` created 
for this case. Note that by not returning `CK_BitCast`, you lose the 
`checkCastAlign` call in the caller.

Instead, can you push this check down into wherever we're building the 
conversion, so that if we try to create a `CK_BitCast` that crosses address 
spaces, we additionally create a `CK_AddressSpaceCast`?


http://reviews.llvm.org/D15169



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


r254573 - change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Wed Dec  2 19:25:12 2015
New Revision: 254573

URL: http://llvm.org/viewvc/llvm-project?rev=254573&view=rev
Log:
change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

We don't want to generate fmuladd if there's a use of the fmul expression, but 
this shouldn't be an assert.

The test case is derived from the commit message for r253337:
http://reviews.llvm.org/rL253337

That commit reverted r253269:
http://reviews.llvm.org/rL253269

...but the bug exists independently of the default fp-contract setting. It just 
became easier to hit with that change.

PR25719:
https://llvm.org/bugs/show_bug.cgi?id=25719

Differential Revision: http://reviews.llvm.org/D15165


Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/fp-contract-pragma.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=254573&r1=254572&r2=254573&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Dec  2 19:25:12 2015
@@ -2564,19 +2564,17 @@ static Value* tryEmitFMulAdd(const BinOp
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
-  if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) 
{
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
+  if (auto *LHSBinOp = dyn_cast(op.LHS)) {
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->use_empty())
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (auto *RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->use_empty())
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
 
   return nullptr;

Modified: cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fp-contract-pragma.cpp?rev=254573&r1=254572&r2=254573&view=diff
==
--- cfe/trunk/test/CodeGen/fp-contract-pragma.cpp (original)
+++ cfe/trunk/test/CodeGen/fp-contract-pragma.cpp Wed Dec  2 19:25:12 2015
@@ -62,3 +62,15 @@ float fp_contract_6(float a, float b, fl
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+


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


Re: [PATCH] D15165: change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Sanjay Patel via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254573: change an assert when generating fmuladd to an 
ordinary 'if' check (PR25719) (authored by spatel).

Changed prior to commit:
  http://reviews.llvm.org/D15165?vs=41699&id=41702#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15165

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/fp-contract-pragma.cpp

Index: cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
===
--- cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
+++ cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
@@ -62,3 +62,15 @@
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2564,19 +2564,17 @@
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
-  if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) 
{
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
+  if (auto *LHSBinOp = dyn_cast(op.LHS)) {
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->use_empty())
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (auto *RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->use_empty())
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
 
   return nullptr;


Index: cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
===
--- cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
+++ cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
@@ -62,3 +62,15 @@
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -2564,19 +2564,17 @@
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
-  if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) {
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
+  if (auto *LHSBinOp = dyn_cast(op.LHS)) {
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->use_empty())
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (auto *RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->use_empty())
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
 
   return nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13618: [Extension] Optimizing const member objects.

2015-12-02 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: lib/CodeGen/CGDecl.cpp:933
@@ +932,3 @@
+  ASTContext &Ctx = getContext();
+  auto &OffsetsInfo = InvariantOffsets.FindAndConstruct(Record).second;
+  OffsetsType &Args = OffsetsInfo.Offsets;

Instead of tracking a separate `Computed` flag, use 
`InvariantOffsets.count(Record)` here, and insert the value below.


Comment at: lib/CodeGen/CGDecl.cpp:943-959
@@ -950,2 +942,19 @@
+
+  // Trace through fields collecting offsets of writeonce candidates.
+  for (const auto *Field : Record->fields()) {
+assert(dyn_cast(Field) && "Field decls only.");
+QualType FieldType = Field->getType();
+if (FieldType.isWriteOnce(Ctx)) {
+  CharUnits WidthChars = Ctx.getTypeSizeInChars(FieldType);
+  uint64_t Width = WidthChars.getQuantity();
+  Args.push_back(llvm::ConstantInt::get(Int64Ty, Width));  // Size
+
+  uint64_t Offset = Ctx.getFieldOffset(Field);
+  Args.push_back(llvm::ConstantInt::get(Int64Ty, Offset));  // Offset
+} else if (const CXXRecordDecl *RecField =
+   Ctx.getBaseElementType(FieldType)->getAsCXXRecordDecl()) {
+  auto &FieldArgs = ComputeInvariantOffsets(RecField);
+  Args.insert(Args.end(), FieldArgs.begin(), FieldArgs.end());
 }
   }
+

It'd be good to also handle the case of a `const` field of class type that 
contains a `mutable` member -- in that case, all members other than the 
`mutable` member can be marked as invariant.


Comment at: lib/CodeGen/CGDecl.cpp:956-957
@@ -950,1 +955,4 @@
+   Ctx.getBaseElementType(FieldType)->getAsCXXRecordDecl()) {
+  auto &FieldArgs = ComputeInvariantOffsets(RecField);
+  Args.insert(Args.end(), FieldArgs.begin(), FieldArgs.end());
 }

The recursive call to `ComputeInvariatOffsets` here invalidates your `Args` 
reference (`DenseMap` insertions invalidate all iterators and references to map 
elements).


http://reviews.llvm.org/D13618



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


Re: [PATCH] D15165: change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Steve Canon via cfe-commits
scanon added a comment.

LGTM.


http://reviews.llvm.org/D15165



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


Re: [PATCH] D14891: Replace assert with early-out in tryEmitFMulAdd

2015-12-02 Thread Steve Canon via cfe-commits
scanon abandoned this revision.
scanon added a comment.

Abandoned for http://reviews.llvm.org/D15165.


http://reviews.llvm.org/D14891



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


Re: [PATCH] D15165: change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Sanjay Patel via cfe-commits
spatel updated this revision to Diff 41699.
spatel added a comment.

Patch updated with suggestions from http://reviews.llvm.org/D14891:

1. Changed 'else if' to plain 'if' for RHS check.
2. Used 'auto*' for dyn_casted vars.
3. Replaced 'getNUses() == 0' with 'use_empty()'.


http://reviews.llvm.org/D15165

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/fp-contract-pragma.cpp

Index: test/CodeGen/fp-contract-pragma.cpp
===
--- test/CodeGen/fp-contract-pragma.cpp
+++ test/CodeGen/fp-contract-pragma.cpp
@@ -62,3 +62,15 @@
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2564,19 +2564,17 @@
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
-  if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) 
{
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
+  if (auto *LHSBinOp = dyn_cast(op.LHS)) {
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->use_empty())
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (auto *RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->use_empty())
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
 
   return nullptr;


Index: test/CodeGen/fp-contract-pragma.cpp
===
--- test/CodeGen/fp-contract-pragma.cpp
+++ test/CodeGen/fp-contract-pragma.cpp
@@ -62,3 +62,15 @@
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2564,19 +2564,17 @@
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
-  if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) {
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
+  if (auto *LHSBinOp = dyn_cast(op.LHS)) {
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->use_empty())
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
-}
-  } else if (llvm::BinaryOperator* RHSBinOp =
-   dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+  }
+  if (auto *RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->use_empty())
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
-}
   }
 
   return nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15165: change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Sanjay Patel via cfe-commits
spatel added a comment.

In http://reviews.llvm.org/D15165#300999, @scanon wrote:

> This is mostly http://reviews.llvm.org/D14891 with a test case added, but 
> http://reviews.llvm.org/D14891 also fixed a second very minor issue: that the 
> "else if" should just be "if".  Also, majnemer made a few style suggestions 
> there that it would be nice to adopt.  Either way, we should merge the two 
> patches.  This can be the canonical one if you want to update it.


Oops - too much mail and obviously missed your patch. But sure, I'll update 
with the suggested changes.


http://reviews.llvm.org/D15165



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


Re: [PATCH] D13614: [Extension] Optimizing passed by-value const objects.

2015-12-02 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith accepted this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision is now accepted and ready to land.

This looks fine (subject to the observation in http://reviews.llvm.org/D13603 
that `MarkWriteOnceWrittenRAII` can just be a function rather than an RAII 
class type).


http://reviews.llvm.org/D13614



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


Re: [PATCH] D13603: [Introduction] C++ Const object optimization in LLVM

2015-12-02 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

Your http://reviews.llvm.org/D14419 removes a lot of the code added here. Can 
you update this patch to not add that code? I'd prefer not to review the 
portion of this code that you're about to delete.



Comment at: lib/CodeGen/CGDecl.cpp:369
@@ -368,1 +368,3 @@
 
+  MarkWriteOnceWrittenRAII MWO(*this, &D, var);
+

The call to `AddInitializerToStaticVarDecl` above indirectly calls 
`EmitCXXGlobalVarDeclInit`, which already emits an `llvm.invariant.start` call 
when appropriate. Please extend the code in `EmitCXXGlobalVarDeclInit` to 
handle these new cases (constant types with non-trivial destructors) rather 
adding another codepath that creates an `llvm.invariant.start` here.


Comment at: lib/CodeGen/CGDecl.cpp:877-879
@@ +876,5 @@
+
+  // Only GlobalVariable's and AllocaInst's can be writeonce.
+  // Exit if the given address is none of these.
+  if (!GV && !AI) return;
+

I don't think this check is necessary; if we know some region of memory is 
locally constant, I don't think it matters whether we can trace it back to an 
alloca.


Comment at: lib/CodeGen/CGDecl.cpp:884
@@ +883,3 @@
+  // @llvm.invariant.end() intrinsic onto the cleanup stack.
+  if ((AI || !GV->isConstant()) && D->getType().isWriteOnce(CGF.getContext()))
+Args = CGF.EmitInvariantStart(*D, AddrPtr);

Do we need to add `QualType::isWriteOnce` for this? 
`CodeGenModule::isTypeConstant` seems to be doing mostly the right set of 
checks. I suggest you add a new flag to it to indicate whether it should check 
for trivial destructibility, and then use it here instead of using 
`isWriteOnce`.


Comment at: lib/CodeGen/CGDecl.cpp:902
@@ -848,2 +901,3 @@
   EmitAutoVarInit(emission);
+  MarkWriteOnceWrittenRAII MWO(*this, &D);
   EmitAutoVarCleanups(emission);

The use of RAII here seems unnecessary. You should be able to emit the 
invariant start and the invariant end cleanup at the same time, by moving this 
after the call to `EmitAutoVarCleanups`.


Comment at: lib/CodeGen/CGDecl.cpp:952-958
@@ +951,9 @@
+  llvm::Value *Size;
+  if (llvm::Constant *CAddr = dyn_cast(Addr)) {
+Size = llvm::ConstantInt::getSigned(Int64Ty, Width);
+Addr = llvm::ConstantExpr::getBitCast(CAddr, Int8PtrTy);
+  } else {
+Size = llvm::ConstantInt::get(Int64Ty, Width);
+Addr = Builder.CreateBitCast(Addr, Int8PtrTy);
+  }
+  llvm::CallInst *C = Builder.CreateCall(InvariantStart, {Size, Addr});

This conditional should not be necessary: `IRBuilder::CreateBitCast` should 
choose between a bitcast constant and a bitcast instruction for you. Just use 
the non-constant branch in all cases.


Comment at: lib/CodeGen/CGDecl.cpp:959
@@ +958,3 @@
+  }
+  llvm::CallInst *C = Builder.CreateCall(InvariantStart, {Size, Addr});
+  C->setDoesNotThrow();

Not all of our supported versions of MSVC accept this syntax. Create a separate 
array of `llvm::Value *` and pass it in here.


Comment at: lib/CodeGen/CGDeclCXX.cpp:478
@@ -491,2 +477,3 @@
   }
+  MarkWriteOnceWrittenRAII MWO(*this, D, Addr);
 

This should be unnecessary if you let `EmitCXXGlobalVarDeclInit` emit the 
invariant start.


Comment at: test/CodeGenCXX/init-invariant.cpp:47-48
@@ -46,4 +46,4 @@
 
 // CHECK: call void @_ZN1BC1Ev({{.*}}* nonnull @b)
-// CHECK-NOT: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @b 
to i8*))
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @b to 
i8*))
 

Please also check that `@llvm.invariant.end` is called later in the same global 
initialization function.


Comment at: test/CodeGenCXX/init-invariant.cpp:51
@@ -50,3 +50,3 @@
 // CHECK: call void @_ZN1CC1Ev({{.*}}* nonnull @c)
-// CHECK-NOT: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @c 
to i8*))
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @c to 
i8*))
 

Likewise for this case.


http://reviews.llvm.org/D13603



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


[PATCH] D15166: Fix C++ support on recent DragonFly BSD releases

2015-12-02 Thread Dimitry Andric via cfe-commits
dim created this revision.
dim added reviewers: joerg, rsmith.
dim added a subscriber: cfe-commits.

[ Copied from https://llvm.org/bugs/show_bug.cgi?id=25597 ]

Clang support for DragonFly BSD is lagging a bit, resulting in poor
support for c++.

DragonFlyBSD is unique in that it has two base compilers.  At the time
of the last Clang update for DragonFly, these compilers were GCC 4.4 and
GCC 4.7 (default).

With DragonFly Release 4.2, GCC 4.4 was replaced with GCC 5.0, partially
because the C++11 support of GCC 4.7 was incomplete.  The DragonFly
project will Release version 4.4 soon.

This patch updates the Clang driver to use libstdc++ from GCC 5.2 The
support for falling back to the alternate compiler was removed for two
reasons:

1) The last release to use GCC 4.7 is DF 4.0 which has already reached EOL
2) GCC 4.7 libstdc++ is insufficient for many "ports"

Therefore, I think it is reasonable that the development version of
clang expects GCC 5.2 to be in place and not try to fall back to another
compiler.

The attached patch will do this.  The Tools.cpp file was signficantly
modified to fix the linking which had been changed somewhere along the
line.  The rest of the changes should be self-explanatory.

http://reviews.llvm.org/D15166

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/dragonfly.c

Index: test/Driver/dragonfly.c
===
--- test/Driver/dragonfly.c
+++ test/Driver/dragonfly.c
@@ -2,6 +2,6 @@
 // RUN: FileCheck -input-file %t.log %s
 
 // CHECK: clang{{.*}}" "-cc1" "-triple" "x86_64-pc-dragonfly"
-// CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=both" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc4{{.*}}" "-rpath" "{{.*}}gcc4{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
+// CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=gnu" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc{{.*}}" "-rpath" "{{.*}}gcc{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
 
 
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -408,10 +408,7 @@
 }
 break;
   case llvm::Triple::DragonFly:
-if (llvm::sys::fs::exists("/usr/lib/gcc47"))
-  AddPath("/usr/include/c++/4.7", CXXSystem, false);
-else
-  AddPath("/usr/include/c++/4.4", CXXSystem, false);
+AddPath("/usr/include/c++/5.0", CXXSystem, false);
 break;
   case llvm::Triple::OpenBSD: {
 std::string t = triple.getTriple();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8978,7 +8978,6 @@
  const char *LinkingOutput) const {
   const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
-  bool UseGCC47 = llvm::sys::fs::exists("/usr/lib/gcc47");
 
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
@@ -8995,7 +8994,8 @@
   CmdArgs.push_back("-dynamic-linker");
   CmdArgs.push_back("/usr/libexec/ld-elf.so.2");
 }
-CmdArgs.push_back("--hash-style=both");
+CmdArgs.push_back("--hash-style=gnu");
+CmdArgs.push_back("--enable-new-dtags");
   }
 
   // When building 32-bit code on DragonFly/pc64, we have to explicitly
@@ -9041,21 +9041,11 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-// FIXME: GCC passes on -lgcc, -lgcc_pic and a whole lot of
-// rpaths
-if (UseGCC47)
-  CmdArgs.push_back("-L/usr/lib/gcc47");
-else
-  CmdArgs.push_back("-L/usr/lib/gcc44");
+CmdArgs.push_back("-L/usr/lib/gcc50");
 
 if (!Args.hasArg(options::OPT_static)) {
-  if (UseGCC47) {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back("/usr/lib/gcc47");
-  } else {
-CmdArgs.push_back("-rpath");
-CmdArgs.push_back("/usr/lib/gcc44");
-  }
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back("/usr/lib/gcc50");
 }
 
 if (D.CCCIsCXX()) {
@@ -9070,28 +9060,20 @@
   CmdArgs.push_back("-lc");
 }
 
-if (UseGCC47) {
-  if (Args.hasArg(options::OPT_static) ||
-  Args.hasArg(options::OPT_static_libgcc)) {
+if (Args.hasArg(options::OPT_static) ||
+Args.hasArg(options::OPT_static_libgcc)) {
 CmdArgs.push_back("-lgcc");
 CmdArgs.push_back("-lgcc_eh");
-  } else {
-if (Args.hasArg(options::OPT_shared_libgcc)) {
+} else {
+  if (Args.hasArg(options::OPT_shared_libgcc)) {
   CmdArgs.push_back("-lgcc_pic");
   if (!Args.hasArg(options::OPT_shared))
  

Re: [PATCH] D15165: change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Steve Canon via cfe-commits
scanon added a comment.

This is mostly http://reviews.llvm.org/D14891 with a test case added, but 
http://reviews.llvm.org/D14891 also fixed a second very minor issue: that the 
"else if" should just be "if".  Also, majnemer made a few style suggestions 
there that it would be nice to adopt.  Either way, we should merge the two 
patches.  This can be the canonical one if you want to update it.


http://reviews.llvm.org/D15165



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


[PATCH] D15165: change an assert when generating fmuladd to an ordinary 'if' check (PR25719)

2015-12-02 Thread Sanjay Patel via cfe-commits
spatel created this revision.
spatel added reviewers: lhames, scanon, hfinkel, klimek.
spatel added a subscriber: cfe-commits.

We don't want to generate fmuladd if there's a use of the fmul expression, but 
this shouldn't be an assert.

The test case is derived from the commit message for r253337:
http://reviews.llvm.org/rL253337

That commit reverted r253269:
http://reviews.llvm.org/rL253269

...but the bug exists independently of the default fp-contract setting. It just 
became easier to hit with that change.

PR25719:
https://llvm.org/bugs/show_bug.cgi?id=25719

http://reviews.llvm.org/D15165

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/fp-contract-pragma.cpp

Index: test/CodeGen/fp-contract-pragma.cpp
===
--- test/CodeGen/fp-contract-pragma.cpp
+++ test/CodeGen/fp-contract-pragma.cpp
@@ -62,3 +62,15 @@
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2564,17 +2564,17 @@
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
   if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) 
{
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->getNumUses() == 0) {
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
 }
   } else if (llvm::BinaryOperator* RHSBinOp =
dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->getNumUses() == 0) {
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
 }
   }


Index: test/CodeGen/fp-contract-pragma.cpp
===
--- test/CodeGen/fp-contract-pragma.cpp
+++ test/CodeGen/fp-contract-pragma.cpp
@@ -62,3 +62,15 @@
   return a * b + c;
 }
 
+// If the multiply has multiple uses, don't produce fmuladd.
+// This used to assert (PR25719):
+// https://llvm.org/bugs/show_bug.cgi?id=25719
+
+float fp_contract_7(float a, float b, float c) {
+// CHECK: _Z13fp_contract_7fff
+// CHECK:  %mul = fmul float %b, 2.00e+00
+// CHECK-NEXT: fsub float %mul, %c
+  #pragma STDC FP_CONTRACT ON
+  return (a = 2 * b) - c;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2564,17 +2564,17 @@
 return nullptr;
 
   // We have a potentially fusable op. Look for a mul on one of the operands.
+  // Also, make sure that the mul result isn't used directly. In that case,
+  // there's no point creating a muladd operation.
   if (llvm::BinaryOperator* LHSBinOp = dyn_cast(op.LHS)) {
-if (LHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(LHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+if (LHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+LHSBinOp->getNumUses() == 0) {
   return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
 }
   } else if (llvm::BinaryOperator* RHSBinOp =
dyn_cast(op.RHS)) {
-if (RHSBinOp->getOpcode() == llvm::Instruction::FMul) {
-  assert(RHSBinOp->getNumUses() == 0 &&
- "Operations with multiple uses shouldn't be contracted.");
+if (RHSBinOp->getOpcode() == llvm::Instruction::FMul &&
+RHSBinOp->getNumUses() == 0) {
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15163: Attach maximum function count to Module when using PGO mode.

2015-12-02 Thread David Li via cfe-commits
davidxl added a comment.

Should also add a test case as a followup. Example:

./projects/compiler-rt/test/profile/instrprof-basic.c

David


Repository:
  rL LLVM

http://reviews.llvm.org/D15163



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


Re: [PATCH] D15158: [PGO] Instrument only base constructors and destructors.

2015-12-02 Thread Justin Bogner via cfe-commits
Serge Pavlov  writes:
> sepavloff created this revision.
> sepavloff added a reviewer: bogner.
> sepavloff added subscribers: cfe-commits, silvas.
>
> Constructors and destructors may be represented by several functions
> in IR. Only the base structors correspond to source code, others
> are small pieces of code and eventually call the base variant. In
> this case instrumentation of non-base structors has little sense,
> this fix remove it. Now profile data of a declaration correspond to
> exactly one function in IR, it agrees with current logic of profile
> data loading.
>
> This change fixes PR24996.

This looks like the right thing to do. A couple of comments on the patch
below.

>
> http://reviews.llvm.org/D15158
>
> Files:
>   lib/CodeGen/CGBlocks.cpp
>   lib/CodeGen/CGObjC.cpp
>   lib/CodeGen/CGStmt.cpp
>   lib/CodeGen/CGStmtOpenMP.cpp
>   lib/CodeGen/CodeGenFunction.cpp
>   lib/CodeGen/CodeGenPGO.cpp
>   lib/CodeGen/CodeGenPGO.h
>   test/Profile/cxx-structors.cpp
>   test/Profile/cxx-virtual-destructor-calls.cpp
>
> Index: test/Profile/cxx-virtual-destructor-calls.cpp
> ===
> --- test/Profile/cxx-virtual-destructor-calls.cpp
> +++ test/Profile/cxx-virtual-destructor-calls.cpp
> @@ -13,18 +13,25 @@
>virtual ~B();
>  };
>  
> -// Complete dtor
> -// CHECK: @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] 
> c"_ZN1BD1Ev"
> +// Base dtor
> +// CHECK: @__llvm_profile_name__ZN1BD2Ev = private constant [9 x i8] 
> c"_ZN1BD2Ev"
>  
> -// Deleting dtor
> -// CHECK: @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] 
> c"_ZN1BD0Ev"
> +// Complete dtor must not be instrumented
> +// @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"

I guess these should be CHECK-NOT instead of just comments.

>  
> -// Complete dtor counters and profile data
> -// CHECK: @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] 
> zeroinitializer
> -// CHECK: @__llvm_profile_data__ZN1BD1Ev =
> +// Deleting dtor must not be instrumented
> +// @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"
>  
> -// Deleting dtor counters and profile data
> -// CHECK: @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] 
> zeroinitializer
> -// CHECK: @__llvm_profile_data__ZN1BD0Ev =
> +// Base dtor counters and profile data
> +// CHECK: @__llvm_profile_counters__ZN1BD2Ev = private global [1 x i64] 
> zeroinitializer
> +// CHECK: @__llvm_profile_data__ZN1BD2Ev =
> +
> +// Complete dtor counters and profile data must absent
> +// @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] 
> zeroinitializer
> +// @__llvm_profile_data__ZN1BD1Ev =
> +
> +// Deleting dtor counters and profile data must absent
> +// @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] 
> zeroinitializer
> +// @__llvm_profile_data__ZN1BD0Ev =
>  
>  B::~B() { }
> Index: test/Profile/cxx-structors.cpp
> ===
> --- /dev/null
> +++ test/Profile/cxx-structors.cpp
> @@ -0,0 +1,32 @@
> +// Tests for instrumentation of C++ constructors and destructors.
> +//
> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o - 
> -emit-llvm -fprofile-instr-generate | FileCheck %s
> +
> +struct Foo {
> +  Foo() {}
> +  Foo(int) {}
> +  ~Foo() {}
> +};
> +
> +struct Bar : public Foo {
> +  Bar() {}
> +  Bar(int x) : Foo(x) {}
> +  ~Bar();
> +};
> +
> +Foo foo;
> +Foo foo2(1);
> +Bar bar;
> +
> +// Profile data for complete constructors and destructors must absent.
> +
> +// CHECK-NOT: @__llvm_profile_name__ZN3FooC1Ev
> +// CHECK-NOT: @__llvm_profile_name__ZN3FooC1Ei
> +// CHECK-NOT: @__llvm_profile_name__ZN3FooD1Ev
> +// CHECK-NOT: @__llvm_profile_name__ZN3BarC1Ev
> +// CHECK-NOT: @__llvm_profile_name__ZN3BarD1Ev
> +// CHECK-NOT: @__llvm_profile_counters__ZN3FooD1Ev
> +// CHECK-NOT: @__llvm_profile_data__ZN3FooD1Ev
> +
> +int main() {
> +}
> Index: lib/CodeGen/CodeGenPGO.h
> ===
> --- lib/CodeGen/CodeGenPGO.h
> +++ lib/CodeGen/CodeGenPGO.h
> @@ -78,13 +78,11 @@
>setCurrentRegionCount(*Count);
>}
>  
> -  /// Check if we need to emit coverage mapping for a given declaration
> -  void checkGlobalDecl(GlobalDecl GD);
>/// Assign counters to regions and configure them for PGO of a given
>/// function. Does nothing if instrumentation is not enabled and either
>/// generates global variables or associates PGO data with each of the
>/// counters depending on whether we are generating or using 
> instrumentation.
> -  void assignRegionCounters(const Decl *D, llvm::Function *Fn);
> +  void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn);
>/// Emit a coverage mapping range with a counter zero
>/// for an unused declaration.
>void emitEmptyCounterMapping(const Decl *D, StringRef FuncName,
> Index: lib/CodeGen/CodeGenPGO.cpp
> ==

r254561 - fix typos; NFC

2015-12-02 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Wed Dec  2 17:06:17 2015
New Revision: 254561

URL: http://llvm.org/viewvc/llvm-project?rev=254561&view=rev
Log:
fix typos; NFC

Modified:
cfe/trunk/test/CodeGen/fp-contract-pragma.cpp

Modified: cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fp-contract-pragma.cpp?rev=254561&r1=254560&r2=254561&view=diff
==
--- cfe/trunk/test/CodeGen/fp-contract-pragma.cpp (original)
+++ cfe/trunk/test/CodeGen/fp-contract-pragma.cpp Wed Dec  2 17:06:17 2015
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | 
FileCheck %s
 
-// Is FP_CONTRACT is honored in a simple case?
+// Is FP_CONTRACT honored in a simple case?
 float fp_contract_1(float a, float b, float c) {
 // CHECK: _Z13fp_contract_1fff
 // CHECK: tail call float @llvm.fmuladd
@@ -19,7 +19,7 @@ float fp_contract_2(float a, float b, fl
   return a * b + c;  
 }
 
-// Does FP_CONTRACT survive template instatiation?
+// Does FP_CONTRACT survive template instantiation?
 class Foo {};
 Foo operator+(Foo, Foo);
 


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


Re: [PATCH] D7606: Fix adress cast for C++ in SEMA

2015-12-02 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Any more comments on this patch?

Thanks!
Samuel


http://reviews.llvm.org/D7606



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


Re: [PATCH] D7606: Fix adress cast for C++ in SEMA

2015-12-02 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 41676.
sfantao added a comment.

- Rebase.


http://reviews.llvm.org/D7606

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  test/CodeGen/address-space-explicit-cast.c

Index: test/CodeGen/address-space-explicit-cast.c
===
--- /dev/null
+++ test/CodeGen/address-space-explicit-cast.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -x c %s | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -emit-llvm -o - -x c++ %s | FileCheck 
-check-prefix=CHECK-CXX %s
+
+typedef __attribute__((address_space(1))) char *AddrSpaceCharType;
+
+// CHECK-LABEL: @foo()
+// CHECK-CXX-LABEL: @_Z3foov()
+void foo() {
+  // CHECK: %p = alloca i8 addrspace(1)*
+  // CHECK-CXX: %p = alloca i8 addrspace(1)*
+  AddrSpaceCharType p;
+
+  // CHECK: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), 
i8 addrspace(1)** %p
+  // CHECK-CXX: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 
addrspace(1)*), i8 addrspace(1)** %p
+  p = (AddrSpaceCharType) "a";
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2036,7 +2036,7 @@
   << OpRange;
 return TC_Success;
   }
-  
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of different type.
   // Void pointers are not specified, but supported by every compiler out 
there.
@@ -2104,6 +2104,22 @@
   return;
 }
 
+  // If we are casting pointers, we need to check whether this refers to an
+  // address space cast.
+  if (DestType->isPointerType() && SrcExpr.get()->getType()->isPointerType()) {
+QualType DTy =
+Self.getASTContext().getCanonicalType(DestType->getPointeeType());
+QualType STy = Self.getASTContext().getCanonicalType(
+SrcExpr.get()->getType()->getPointeeType());
+// If the pointer point to the same type in different address spaces, this
+// is an address-space cast.
+if (STy.getTypePtr() == DTy.getTypePtr() &&
+STy.getAddressSpace() != DTy.getAddressSpace()) {
+  Kind = CK_AddressSpaceConversion;
+  return;
+}
+  }
+
   // C++ [expr.cast]p5: The conversions performed by
   //   - a const_cast,
   //   - a static_cast,
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -391,6 +391,14 @@
   if (ExprTy == TypeTy)
 return E;
 
+  // In the event an address space cast is requested, the kind passed from the
+  // caller should not be CK_NoOp.
+  assert((Kind != CK_NoOp ||
+  !(ExprTy->isPointerType() && TypeTy->isPointerType() &&
+ExprTy->getPointeeType().getAddressSpace() !=
+TypeTy->getPointeeType().getAddressSpace())) &&
+ "NoOp is not a valid kind for and address cast");
+
   if (ImplicitCastExpr *ImpCast = dyn_cast(E)) {
 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
   ImpCast->setType(Ty);


Index: test/CodeGen/address-space-explicit-cast.c
===
--- /dev/null
+++ test/CodeGen/address-space-explicit-cast.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - -x c %s | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -emit-llvm -o - -x c++ %s | FileCheck -check-prefix=CHECK-CXX %s
+
+typedef __attribute__((address_space(1))) char *AddrSpaceCharType;
+
+// CHECK-LABEL: @foo()
+// CHECK-CXX-LABEL: @_Z3foov()
+void foo() {
+  // CHECK: %p = alloca i8 addrspace(1)*
+  // CHECK-CXX: %p = alloca i8 addrspace(1)*
+  AddrSpaceCharType p;
+
+  // CHECK: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), i8 addrspace(1)** %p
+  // CHECK-CXX: store i8 addrspace(1)* addrspacecast ({{.*}} to i8 addrspace(1)*), i8 addrspace(1)** %p
+  p = (AddrSpaceCharType) "a";
+}
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2036,7 +2036,7 @@
   << OpRange;
 return TC_Success;
   }
-  
+
   // C++ 5.2.10p7: A pointer to an object can be explicitly converted to
   //   a pointer to an object of different type.
   // Void pointers are not specified, but supported by every compiler out there.
@@ -2104,6 +2104,22 @@
   return;
 }
 
+  // If we are casting pointers, we need to check whether this refers to an
+  // address space cast.
+  if (DestType->isPointerType() && SrcExpr.get()->getType()->isPointerType()) {
+QualType DTy =
+Self.getASTContext().getCanonicalType(DestType->getPointeeType());
+QualType STy = Self.getASTContext().getCanonicalType(
+SrcExpr.get()->getType()->getPointeeType());
+// If the pointer point to the same type in different address spaces, this
+// is an address-space cast.
+if (STy.getTypePtr() == DTy.getTypePtr() &&
+ST

Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread David Blaikie via cfe-commits
(tangential: Should we just have a utility function llvm::adl_swap that we
could use everywhere rather than having to write two lines for every
caller? (& have a variant of this check that knows to suggest that in
LLVM?))

On Wed, Dec 2, 2015 at 1:35 PM, Marshall Clow via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> mclow.lists marked 5 inline comments as done.
> mclow.lists added a comment.
>
> http://reviews.llvm.org/D15121
>
>
>
> ___
> 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: [PATCH] D13263: Addition of __attribute__((pass_object_size)) to Clang

2015-12-02 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254554: Add the `pass_object_size` attribute to clang. 
(authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D13263?vs=41651&id=41675#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13263

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
  cfe/trunk/include/clang/Sema/Initialization.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Sema/TemplateDeduction.h
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
  cfe/trunk/test/SemaCXX/init-priority-attr.cpp

Index: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
===
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
@@ -36,6 +36,7 @@
 namespace clang {
 class ASTContext;
 class CXXRecordDecl;
+class CXXMethodDecl;
 class CodeGenOptions;
 class CoverageSourceInfo;
 class DiagnosticsEngine;
@@ -60,12 +61,13 @@
   const CGFunctionInfo &arrangeObjCMessageSendSignature(
  const ObjCMethodDecl *MD,
  QualType receiverType);
-  const CGFunctionInfo &arrangeFreeFunctionType(
-   CanQual Ty);
+  const CGFunctionInfo &arrangeFreeFunctionType(CanQual Ty,
+const FunctionDecl *FD);
   const CGFunctionInfo &arrangeFreeFunctionType(
  CanQual Ty);
   const CGFunctionInfo &arrangeCXXMethodType(const CXXRecordDecl *RD,
- const FunctionProtoType *FTP);
+ const FunctionProtoType *FTP,
+ const CXXMethodDecl *MD);
   const CGFunctionInfo &arrangeFreeFunctionCall(CanQualType returnType,
 ArrayRef argTypes,
 FunctionType::ExtInfo info,
Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -628,6 +628,16 @@
 const FunctionDecl *Callee,
 ArrayRef Args) const;
 
+  /// \brief If the current Expr is a pointer, this will try to statically
+  /// determine the number of bytes available where the pointer is pointing.
+  /// Returns true if all of the above holds and we were able to figure out the
+  /// size, false otherwise.
+  ///
+  /// \param Type - How to evaluate the size of the Expr, as defined by the
+  /// "type" parameter of __builtin_object_size
+  bool tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
+ unsigned Type) const;
+
   /// \brief Enumeration used to describe the kind of Null pointer constant
   /// returned from \c isNullPointerConstant().
   enum NullPointerConstantKind {
Index: cfe/trunk/include/clang/Sema/TemplateDeduction.h
===
--- cfe/trunk/include/clang/Sema/TemplateDeduction.h
+++ cfe/trunk/include/clang/Sema/TemplateDeduction.h
@@ -236,7 +236,7 @@
   }
 
   /// Diagnose a template argument deduction failure.
-  void NoteDeductionFailure(Sema &S);
+  void NoteDeductionFailure(Sema &S, bool ForTakingAddress);
 };
 
 /// TemplateSpecCandidateSet - A set of generalized overload candidates,
@@ -246,15 +246,20 @@
 class TemplateSpecCandidateSet {
   SmallVector Candidates;
   SourceLocation Loc;
+  // Stores whether we're taking the address of these candidates. This helps us
+  // produce better error messages when dealing with the pass_object_size
+  // attribute on parameters.
+  bool ForTakingAddress;
 
   Template

Re: [PATCH] D13263: Addition of __attribute__((pass_object_size)) to Clang

2015-12-02 Thread George Burgess IV via cfe-commits
george.burgess.iv marked 2 inline comments as done.


Comment at: lib/AST/ExprConstant.cpp:6507-6509
@@ -6506,5 +6544,1 @@
-// handle all cases where the expression has side-effects.
-// Likewise, if Type is 3, we must handle this because CodeGen cannot give 
a
-// conservatively correct answer in that case.
-if (E->getArg(0)->HasSideEffects(Info.Ctx) || Type == 3)
   return Success((Type & 2) ? 0 : -1, E);

WFM!


Repository:
  rL LLVM

http://reviews.llvm.org/D13263



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


r254554 - Add the `pass_object_size` attribute to clang.

2015-12-02 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Dec  2 15:58:08 2015
New Revision: 254554

URL: http://llvm.org/viewvc/llvm-project?rev=254554&view=rev
Log:
Add the `pass_object_size` attribute to clang.

`pass_object_size` is our way of enabling `__builtin_object_size` to
produce high quality results without requiring inlining to happen
everywhere.

A link to the design doc for this attribute is available at the
Differential review link below.

Differential Revision: http://reviews.llvm.org/D13263

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/TemplateDeduction.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
cfe/trunk/test/SemaCXX/init-priority-attr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=254554&r1=254553&r2=254554&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Dec  2 15:58:08 2015
@@ -628,6 +628,16 @@ public:
 const FunctionDecl *Callee,
 ArrayRef Args) const;
 
+  /// \brief If the current Expr is a pointer, this will try to statically
+  /// determine the number of bytes available where the pointer is pointing.
+  /// Returns true if all of the above holds and we were able to figure out the
+  /// size, false otherwise.
+  ///
+  /// \param Type - How to evaluate the size of the Expr, as defined by the
+  /// "type" parameter of __builtin_object_size
+  bool tryEvaluateObjectSize(uint64_t &Result, ASTContext &Ctx,
+ unsigned Type) const;
+
   /// \brief Enumeration used to describe the kind of Null pointer constant
   /// returned from \c isNullPointerConstant().
   enum NullPointerConstantKind {

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=254554&r1=254553&r2=254554&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Dec  2 15:58:08 2015
@@ -1012,6 +1012,15 @@ def ReturnsNonNull : InheritableAttr {
   let Documentation = [ReturnsNonNullDocs];
 }
 
+// pass_object_size(N) indicates that the parameter should have
+// __builtin_object_size with Type=N evaluated on the parameter at the 
callsite.
+def PassObjectSize : InheritableParamAttr {
+  let Spellings = [GNU<"pass_object_size">];
+  let Args = [IntArgument<"Type">];
+  let Subjects = SubjectList<[ParmVar]>;
+  let Documentation = [PassObjectSizeDocs];
+}
+
 // Nullability type attributes.
 def TypeNonNull : TypeAttr {
   let Spellings = [Keyword<"_Nonnull">];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=254554&r1=254553&r2=254554&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Dec  2 15:58:08 2015
@@ -263,6 +263,103 @@ Query for this feature with ``__has_attr
   }];
 }
 
+def PassObjectSizeDocs : Documentation {
+  let Category = DocCatVariable; // Technically it's a parameter doc, but eh.
+  let Content = [{
+.. Note:: The mangling of functions with parameters that are annotated with
+  ``pass_object_size`` is subject to change. You can get around this by
+  using ``__asm__("foo")`` to explicitly name your functions, thus preserving
+  your ABI; also, non-overloadable C functions with ``pass_object_size`` are
+  not mangled.
+
+The ``pass_object_size(Type)`` attribut

Re: [PATCH] D12614: [OpenMP] Offloading descriptor registration and device codegen.

2015-12-02 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Are there any more comments for this patch?

Thanks!
Samuel


http://reviews.llvm.org/D12614



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


Re: [PATCH] D15161: [CMake] On Darwin the LIBCXX_INSTALL_HEADERS and LIBCXX_INSTALL_LIBRARY options should default off

2015-12-02 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 41668.
beanz added a comment.

My patch dropped one of the gating checks. This fixes that. It only needs to 
apply to Darwin when installing to /usr.


http://reviews.llvm.org/D15161

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -55,8 +55,17 @@
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." 
${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
-option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
-option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+
+set(INSTALL_HEADERS_DEFAULT ON)
+set(INSTALL_LIBRARY_DEFAULT ON)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin"
+  AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
+  set(INSTALL_HEADERS_DEFAULT OFF)
+  set(INSTALL_LIBRARY_DEFAULT OFF)
+endif()
+option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." 
${INSTALL_HEADERS_DEFAULT})
+option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." 
${INSTALL_LIBRARY_DEFAULT})
+
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
@@ -133,23 +142,6 @@
 set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
 "The Profile-rt library used to build with code coverage")
 
-# Don't allow a user to accidentally overwrite the system libc++ installation 
on Darwin.
-# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for 
libc++
-# will not be generated and a warning will be issued.
-option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ 
installation." OFF)
-mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by 
default.
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT 
LIBCXX_OVERRIDE_DARWIN_INSTALL)
-  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
-message(WARNING "Disabling libc++ install rules because installation would 
"
-"overwrite the systems installation. Configure with "
-"-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this 
behaviour.")
-mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override 
option.
-set(LIBCXX_INSTALL_HEADERS OFF)
-set(LIBCXX_INSTALL_LIBRARY OFF)
-  endif()
-endif()
-
 
#===
 # Check option configurations
 
#===


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -55,8 +55,17 @@
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
-option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
-option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+
+set(INSTALL_HEADERS_DEFAULT ON)
+set(INSTALL_LIBRARY_DEFAULT ON)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin"
+  AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
+  set(INSTALL_HEADERS_DEFAULT OFF)
+  set(INSTALL_LIBRARY_DEFAULT OFF)
+endif()
+option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ${INSTALL_HEADERS_DEFAULT})
+option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ${INSTALL_LIBRARY_DEFAULT})
+
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
@@ -133,23 +142,6 @@
 set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
 "The Profile-rt library used to build with code coverage")
 
-# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
-# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
-# will not be generated and a warning will be issued.
-option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
-mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
-  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
-message(WARNING "Disabling libc++ install rules because installation would "
-"overwrite the systems installation. Configure with "
-"-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
-mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
-set(LIBCXX_INSTALL_HEADERS OFF)
-set(LIBCXX_INSTALL_LIBRARY OFF)
-  endif()
-endif()
-
 #===
 # Check option configurations
 #=

Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Marshall Clow via cfe-commits
mclow.lists marked 5 inline comments as done.
mclow.lists added a comment.

http://reviews.llvm.org/D15121



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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Marshall Clow via cfe-commits
mclow.lists updated this revision to Diff 41667.
mclow.lists added a comment.

Richard clued me in to the cool method `isStdNamespace()`, which made the code 
simpler.


http://reviews.llvm.org/D15121

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StdSwapCheck.cpp
  clang-tidy/misc/StdSwapCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-std-swap.rst
  test/clang-tidy/misc-StdSwap.cpp

Index: test/clang-tidy/misc-StdSwap.cpp
===
--- test/clang-tidy/misc-StdSwap.cpp
+++ test/clang-tidy/misc-StdSwap.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s misc-std-swap %t
+
+namespace std {
+  template  void swap(T&, T&) {}
+  }
+
+// FIXME: Add something that triggers the check here.
+// FIXME: Verify the applied fix.
+//   * Make the CHECK patterns specific enough and try to make verified lines
+// unique to avoid incorrect matches.
+//   * Use {{}} for regular expressions.
+
+// Bad code; don't overload in namespace std
+struct S1 { int x; };
+namespace std { void swap(S1& x, S1 &y) { swap(x.x, y.x); } };
+
+// Swap in namespace with type
+namespace foo { struct S2 { int i; }; void swap(S2& x, S2& y) {std::swap(x.i, y.i); } }
+
+// Swap in namespace.
+namespace bar {
+  struct S3 { int i; };
+  void swap(int&, int&) {}
+  namespace std {
+void swap(S3& x, S3& y) { ::std::swap(x.i, y.i); }
+  }
+}
+
+void test0()
+{
+  S1 i,j;
+  std::swap(i,j);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: let the compiler find the right swap via ADL
+  // CHECK-FIXES: { using std::swap; swap(i,j); }
+}
+
+void test1(bool b)
+{
+  foo::S2 x,y;
+  if ( b )
+std::swap(x,y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: let the compiler find the right swap via ADL
+  // CHECK-FIXES: { using std::swap; swap(x,y); }
+}
+
+namespace baz {
+  void test2()
+  {
+::S1 i,j;
+::std::swap(i,j);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: let the compiler find the right swap via ADL
+// CHECK-FIXES: { using ::std::swap; swap(i,j); }
+  }
+}
+
+void test_neg0()// Swap two builtins
+{
+{
+int i,j;
+std::swap(i,j);
+}
+{
+float i,j;
+std::swap(i,j);
+}
+}
+
+void test_neg1()// std::swap two pointers
+{
+S1 *i, *j;
+std::swap(i,j);
+}
+
+void test_neg2()  // Call a namespace-qualified swap that isn't "std::"
+{
+{
+int i,j;
+bar::swap(i,j);
+::bar::swap(i,j);
+}
+{
+bar::S3 i,j;
+bar::std::swap(i,j);
+::bar::std::swap(i,j);
+}
+}
+
+namespace bar {
+  void test_neg3()  // calling a non-global std::swap
+  {
+S3 x,y;
+std::swap(x,y);
+  }
+}
Index: docs/clang-tidy/checks/misc-std-swap.rst
===
--- docs/clang-tidy/checks/misc-std-swap.rst
+++ docs/clang-tidy/checks/misc-std-swap.rst
@@ -0,0 +1,19 @@
+misc-std-swap
+
+
+Adding an overload for `std:swap` (in the `std` namespace) is explicitly forbidden by the standard. 
+
+The best practice for implementing swap for user-defined data structures is to implement a non-member swap in the same namespace as the type. Then, when you wish to swap to values `x` and `y`, you call `swap(x,y)` without a namespace, and argument dependent lookup will find it. Unfortunately this will not work for types that have overloads of `swap` in namespace `std` (standard library types and primitive types). So you have to bring them into play with a `using` declaration.
+
+Instead of writing:
+> std::swap(x,y);
+
+you should write:
+> using std::swap; swap(x,y);
+
+This checker find this pattern and replaces it with the recommended usage; wrapping the call in a pair of braces to scope the using directive. For builtin types (such as `int` and `float`), as well as pointers, it leaves the calls to `std::swap` alone, because those are correct.
+
+FUTURE WORK: 
+
+Find overloads of `swap` in namespace std and put them in the correct namespace.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -46,6 +46,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-std-swap
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: clang-tidy/misc/StdSwapCheck.h
===
--- clang-tidy/misc/StdSwapCheck.h
+++ clang-tidy/misc/StdSwapCheck.h
@@ -0,0 +1,35 @@
+//===--- StdSwapCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTR

[PATCH] D15161: [CMake] On Darwin the LIBCXX_INSTALL_HEADERS and LIBCXX_INSTALL_LIBRARY options should default off

2015-12-02 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: mclow.lists, EricWF.
beanz added a subscriber: cfe-commits.

The current implementation doesn't work as intended because of CMake's caching 
behavior. The CMake set command doesn't globally override cached options.

This change removes LIBCXX_OVERRIDE_DARWIN_INSTALL, and instead defaults the 
options OFF on Darwin. The end result is the same, if you want to install the 
libraries or headers on Darwin you need to explicitly set the options.

http://reviews.llvm.org/D15161

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -55,8 +55,16 @@
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." 
${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
-option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
-option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+
+set(INSTALL_HEADERS_DEFAULT ON)
+set(INSTALL_LIBRARY_DEFAULT ON)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  set(INSTALL_HEADERS_DEFAULT OFF)
+  set(INSTALL_LIBRARY_DEFAULT OFF)
+endif()
+option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." 
${INSTALL_HEADERS_DEFAULT})
+option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." 
${INSTALL_LIBRARY_DEFAULT})
+
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
@@ -133,23 +141,6 @@
 set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
 "The Profile-rt library used to build with code coverage")
 
-# Don't allow a user to accidentally overwrite the system libc++ installation 
on Darwin.
-# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for 
libc++
-# will not be generated and a warning will be issued.
-option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ 
installation." OFF)
-mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by 
default.
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT 
LIBCXX_OVERRIDE_DARWIN_INSTALL)
-  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
-message(WARNING "Disabling libc++ install rules because installation would 
"
-"overwrite the systems installation. Configure with "
-"-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this 
behaviour.")
-mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override 
option.
-set(LIBCXX_INSTALL_HEADERS OFF)
-set(LIBCXX_INSTALL_LIBRARY OFF)
-  endif()
-endif()
-
 
#===
 # Check option configurations
 
#===


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -55,8 +55,16 @@
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
-option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
-option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
+
+set(INSTALL_HEADERS_DEFAULT ON)
+set(INSTALL_LIBRARY_DEFAULT ON)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  set(INSTALL_HEADERS_DEFAULT OFF)
+  set(INSTALL_LIBRARY_DEFAULT OFF)
+endif()
+option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ${INSTALL_HEADERS_DEFAULT})
+option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ${INSTALL_LIBRARY_DEFAULT})
+
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
@@ -133,23 +141,6 @@
 set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
 "The Profile-rt library used to build with code coverage")
 
-# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
-# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
-# will not be generated and a warning will be issued.
-option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
-mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
-
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
-  if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
-message(WARNING "Disabling libc++ install rules because installation would "
-"overwrite the systems installation. Configure with "
-"-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
-mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
-set(LIBCXX_I

Re: [PATCH] D14691: clang side of http://reviews.llvm.org/D14690

2015-12-02 Thread Rafael Ávila de Espíndola via cfe-commits
rafael abandoned this revision.
rafael added a comment.

In the end we changed only SetVector.


http://reviews.llvm.org/D14691



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


Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-02 Thread Reid Kleckner via cfe-commits
rnk added a comment.

lgtm


http://reviews.llvm.org/D14639



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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Marshall Clow via cfe-commits
mclow.lists updated this revision to Diff 41662.
mclow.lists added a comment.

More tests; incorporated some of the suggestions for making sure we don't step 
on other people's namespaces named `std`.


http://reviews.llvm.org/D15121

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StdSwapCheck.cpp
  clang-tidy/misc/StdSwapCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-std-swap.rst
  test/clang-tidy/misc-StdSwap.cpp

Index: test/clang-tidy/misc-StdSwap.cpp
===
--- test/clang-tidy/misc-StdSwap.cpp
+++ test/clang-tidy/misc-StdSwap.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s misc-std-swap %t
+
+namespace std {
+  template  void swap(T&, T&) {}
+  }
+
+// FIXME: Add something that triggers the check here.
+// FIXME: Verify the applied fix.
+//   * Make the CHECK patterns specific enough and try to make verified lines
+// unique to avoid incorrect matches.
+//   * Use {{}} for regular expressions.
+
+// Bad code; don't overload in namespace std
+struct S1 { int x; };
+namespace std { void swap(S1& x, S1 &y) { swap(x.x, y.x); } };
+
+// Swap in namespace with type
+namespace foo { struct S2 { int i; }; void swap(S2& x, S2& y) {std::swap(x.i, y.i); } }
+
+// Swap in namespace.
+namespace bar {
+  struct S3 { int i; };
+  void swap(int&, int&) {}
+  namespace std {
+void swap(S3& x, S3& y) { ::std::swap(x.i, y.i); }
+  }
+}
+
+void test0()
+{
+  S1 i,j;
+  std::swap(i,j);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: let the compiler find the right swap via ADL
+  // CHECK-FIXES: { using std::swap; swap(i,j); }
+}
+
+void test1(bool b)
+{
+  foo::S2 x,y;
+  if ( b )
+std::swap(x,y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: let the compiler find the right swap via ADL
+  // CHECK-FIXES: { using std::swap; swap(x,y); }
+}
+
+namespace baz {
+  void test2()
+  {
+::S1 i,j;
+::std::swap(i,j);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: let the compiler find the right swap via ADL
+// CHECK-FIXES: { using ::std::swap; swap(i,j); }
+  }
+}
+
+void test_neg0()// Swap two builtins
+{
+{
+int i,j;
+std::swap(i,j);
+}
+{
+float i,j;
+std::swap(i,j);
+}
+}
+
+void test_neg1()// std::swap two pointers
+{
+S1 *i, *j;
+std::swap(i,j);
+}
+
+void test_neg2()  // Call a namespace-qualified swap that isn't "std::"
+{
+{
+int i,j;
+bar::swap(i,j);
+::bar::swap(i,j);
+}
+{
+bar::S3 i,j;
+bar::std::swap(i,j);
+::bar::std::swap(i,j);
+}
+}
+
+namespace bar {
+  void test_neg3()  // calling a non-global std::swap
+  {
+S3 x,y;
+std::swap(x,y);
+  }
+}
Index: docs/clang-tidy/checks/misc-std-swap.rst
===
--- docs/clang-tidy/checks/misc-std-swap.rst
+++ docs/clang-tidy/checks/misc-std-swap.rst
@@ -0,0 +1,19 @@
+misc-std-swap
+
+
+Adding an overload for `std:swap` (in the `std` namespace) is explicitly forbidden by the standard. 
+
+The best practice for implementing swap for user-defined data structures is to implement a non-member swap in the same namespace as the type. Then, when you wish to swap to values `x` and `y`, you call `swap(x,y)` without a namespace, and argument dependent lookup will find it. Unfortunately this will not work for types that have overloads of `swap` in namespace `std` (standard library types and primitive types). So you have to bring them into play with a `using` declaration.
+
+Instead of writing:
+> std::swap(x,y);
+
+you should write:
+> using std::swap; swap(x,y);
+
+This checker find this pattern and replaces it with the recommended usage; wrapping the call in a pair of braces to scope the using directive. For builtin types (such as `int` and `float`), as well as pointers, it leaves the calls to `std::swap` alone, because those are correct.
+
+FUTURE WORK: 
+
+Find overloads of `swap` in namespace std and put them in the correct namespace.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -46,6 +46,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-std-swap
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: clang-tidy/misc/StdSwapCheck.h
===
--- clang-tidy/misc/StdSwapCheck.h
+++ clang-tidy/misc/StdSwapCheck.h
@@ -0,0 +1,35 @@
+//===--- StdSwapCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//

Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-02 Thread Stephen Hines via cfe-commits
srhines marked 3 inline comments as done.
srhines added a comment.

I uploaded a fixed version to use isPowerOf2_32() and more comments. Thanks for 
the reviews.


http://reviews.llvm.org/D14639



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


Re: [PATCH] D14691: clang side of http://reviews.llvm.org/D14690

2015-12-02 Thread Chandler Carruth via cfe-commits
chandlerc added inline comments.


Comment at: include/clang/Lex/HeaderSearchOptions.h:145
@@ -143,2 +144,3 @@
   /// of computing the module hash.
-  llvm::SetVector ModulesIgnoreMacros;
+  llvm::SetVector, std::set>
+  ModulesIgnoreMacros;

There is clearly a use case for a fast StringSetVector. If it is something 
other than SetVector, we should put it in LLVM's ADT and use it 
everywhere rather than reproducing this huge type.


Comment at: include/clang/Sema/Sema.h:6847
@@ -6844,3 +6846,3 @@
 
-  typedef llvm::SmallSet SrcLocSet;
+  typedef llvm::SmallSet> 
SrcLocSet;
   typedef llvm::DenseMap 
IdentifierSourceLocations;

Wow, do we really not have DenseMapInfo for SourceLocation? It seems like this 
would be a great candidate for DenseSet


Comment at: lib/Driver/Tools.cpp:6227
@@ -6226,3 +6226,3 @@
   CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("gnu");
+  CmdArgs.push_back("old-gnu");
   CmdArgs.push_back("-target");

Does this belong is this patch? If so, why?


http://reviews.llvm.org/D14691



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


Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-02 Thread Stephen Hines via cfe-commits
srhines updated this revision to Diff 41654.
srhines added a comment.

Switched to isPowerOf2_32() and added more details about Android's ABI.


http://reviews.llvm.org/D14639

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/arm-abi-vector.c

Index: test/CodeGen/arm-abi-vector.c
===
--- test/CodeGen/arm-abi-vector.c
+++ test/CodeGen/arm-abi-vector.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi aapcs -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple armv7-apple-darwin -target-abi apcs-gnu -emit-llvm -o - %s | FileCheck -check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple arm-linux-androideabi -emit-llvm -o - %s | FileCheck -check-prefix=ANDROID %s
 
 #include 
 
@@ -28,6 +29,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <2 x i32>*
 // APCS-GNU: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 4
 // APCS-GNU: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
+// ANDROID: varargs_vec_2i
+// ANDROID: [[VAR:%.*]] = alloca <2 x i32>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <2 x i32>*
+// ANDROID: [[VEC:%.*]] = load <2 x i32>, <2 x i32>* [[AP_CAST]], align 8
+// ANDROID: store <2 x i32> [[VEC]], <2 x i32>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -42,6 +51,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
 // APCS-GNU: test_2i
 // APCS-GNU: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
+// ANDROID: test_2i
+// ANDROID: call double (i32, ...) @varargs_vec_2i(i32 3, <2 x i32> {{%.*}})
   return varargs_vec_2i(3, *in);
 }
 
@@ -54,6 +65,10 @@
 // APCS-GNU: alloca <3 x i8>, align 4
 // APCS-GNU: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
 // APCS-GNU: bitcast i8* [[AP]] to <3 x i8>*
+// ANDROID: varargs_vec_3c
+// ANDROID: alloca <3 x i8>, align 4
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
+// ANDROID: bitcast i8* [[AP]] to <3 x i8>*
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -68,6 +83,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_3c(i32 3, i32 {{%.*}})
 // APCS-GNU: test_3c
 // APCS-GNU: call double (i32, ...) @varargs_vec_3c(i32 3, i32 {{%.*}})
+// ANDROID: test_3c
+// ANDROID: call double (i32, ...) @varargs_vec_3c(i32 3, <3 x i8> {{%.*}})
   return varargs_vec_3c(3, *in);
 }
 
@@ -87,6 +104,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <5 x i8>*
 // APCS-GNU: [[VEC:%.*]] = load <5 x i8>, <5 x i8>* [[AP_CAST]], align 4
 // APCS-GNU: store <5 x i8> [[VEC]], <5 x i8>* [[VAR]], align 8
+// ANDROID: varargs_vec_5c
+// ANDROID: [[VAR:%.*]] = alloca <5 x i8>, align 8
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 8
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <5 x i8>*
+// ANDROID: [[VEC:%.*]] = load <5 x i8>, <5 x i8>* [[AP_CAST]], align 8
+// ANDROID: store <5 x i8> [[VEC]], <5 x i8>* [[VAR]], align 8
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -101,6 +126,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
 // APCS-GNU: test_5c
 // APCS-GNU: call double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
+// ANDROID: test_5c
+// ANDROID: call double (i32, ...) @varargs_vec_5c(i32 5, <2 x i32> {{%.*}})
   return varargs_vec_5c(5, *in);
 }
 
@@ -120,6 +147,14 @@
 // APCS-GNU: [[AP_CAST:%.*]] = bitcast i8* [[AP]] to <9 x i8>*
 // APCS-GNU: [[VEC:%.*]] = load <9 x i8>, <9 x i8>* [[AP_CAST]], align 4
 // APCS-GNU: store <9 x i8> [[VEC]], <9 x i8>* [[VAR]], align 16
+// ANDROID: varargs_vec_9c
+// ANDROID: [[VAR:%.*]] = alloca <9 x i8>, align 16
+// ANDROID: [[ALIGN:%.*]] = and i32 {{%.*}}, -8
+// ANDROID: [[AP_ALIGN:%.*]] = inttoptr i32 [[ALIGN]] to i8*
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_ALIGN]], i32 16
+// ANDROID: [[AP_CAST:%.*]] = bitcast i8* [[AP_ALIGN]] to <9 x i8>*
+// ANDROID: [[T0:%.*]] = load <9 x i8>, <9 x i8>* [[AP_CAST]], align 8
+// ANDROID: store <9 x i8> [[T0]], <9 x i8>* [[VAR]], align 16
   va_list ap;
   double sum = fixed;
   va_start(ap, fixed);
@@ -134,6 +169,8 @@
 // CHECK: call arm_aapcscc double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
 // APCS-GNU: test_9c
 // APCS-GNU: call double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
+// ANDROID: test_9c
+// ANDROID: call double (i32, ...) @varargs_vec_9c(i32 9, <4 x i32> {{%.*}})
   return varargs_vec_9c(9, *in);
 }
 
@@ -146,6 +183,10 @@
 // APCS-GNU: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP:%.*]], i32 4
 //

Re: [PATCH] D13263: Addition of __attribute__((pass_object_size)) to Clang

2015-12-02 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Oops -- I didn't see Richard's comments before I pressed "save". Will address 
that feedback too. Sorry! :)


http://reviews.llvm.org/D13263



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


Re: r254515 - Amending r254423 by deleting the copy constructor and adding a move constructor instead; NFC as neither of these constructors are currently called, but this is a safer design.

2015-12-02 Thread Aaron Ballman via cfe-commits
On Wed, Dec 2, 2015 at 1:00 PM, David Blaikie  wrote:
> Oh, this type has a user-defined dtor, so it's deprecated to use the
> implicit copy ctor/assignment operator anyway - and I have the -Wdeprecated
> flag on in my build (& keep the LLVM build clean of any warnings it shows).
>
> At some point (would love help) we should just turn that on for everyone,
> then we wouldn't have to worry about types like this -Wdeprecated -Werror
> would catch them. I think last time I tried to turn it on there were some
> things in library headers, perhaps (maybe in cxxabi?) that needed cleaning
> up that I didn't have/build/see locally...

I would be amenable to turning that on for everyone if we can get away with it.

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


[PATCH] D15158: [PGO] Instrument only base constructors and destructors.

2015-12-02 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a reviewer: bogner.
sepavloff added subscribers: cfe-commits, silvas.

Constructors and destructors may be represented by several functions
in IR. Only the base structors correspond to source code, others
are small pieces of code and eventually call the base variant. In
this case instrumentation of non-base structors has little sense,
this fix remove it. Now profile data of a declaration correspond to
exactly one function in IR, it agrees with current logic of profile
data loading.

This change fixes PR24996.

http://reviews.llvm.org/D15158

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenPGO.cpp
  lib/CodeGen/CodeGenPGO.h
  test/Profile/cxx-structors.cpp
  test/Profile/cxx-virtual-destructor-calls.cpp

Index: test/Profile/cxx-virtual-destructor-calls.cpp
===
--- test/Profile/cxx-virtual-destructor-calls.cpp
+++ test/Profile/cxx-virtual-destructor-calls.cpp
@@ -13,18 +13,25 @@
   virtual ~B();
 };
 
-// Complete dtor
-// CHECK: @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"
+// Base dtor
+// CHECK: @__llvm_profile_name__ZN1BD2Ev = private constant [9 x i8] c"_ZN1BD2Ev"
 
-// Deleting dtor
-// CHECK: @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"
+// Complete dtor must not be instrumented
+// @__llvm_profile_name__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"
 
-// Complete dtor counters and profile data
-// CHECK: @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] zeroinitializer
-// CHECK: @__llvm_profile_data__ZN1BD1Ev =
+// Deleting dtor must not be instrumented
+// @__llvm_profile_name__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"
 
-// Deleting dtor counters and profile data
-// CHECK: @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] zeroinitializer
-// CHECK: @__llvm_profile_data__ZN1BD0Ev =
+// Base dtor counters and profile data
+// CHECK: @__llvm_profile_counters__ZN1BD2Ev = private global [1 x i64] zeroinitializer
+// CHECK: @__llvm_profile_data__ZN1BD2Ev =
+
+// Complete dtor counters and profile data must absent
+// @__llvm_profile_counters__ZN1BD1Ev = private global [1 x i64] zeroinitializer
+// @__llvm_profile_data__ZN1BD1Ev =
+
+// Deleting dtor counters and profile data must absent
+// @__llvm_profile_counters__ZN1BD0Ev = private global [1 x i64] zeroinitializer
+// @__llvm_profile_data__ZN1BD0Ev =
 
 B::~B() { }
Index: test/Profile/cxx-structors.cpp
===
--- /dev/null
+++ test/Profile/cxx-structors.cpp
@@ -0,0 +1,32 @@
+// Tests for instrumentation of C++ constructors and destructors.
+//
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
+
+struct Foo {
+  Foo() {}
+  Foo(int) {}
+  ~Foo() {}
+};
+
+struct Bar : public Foo {
+  Bar() {}
+  Bar(int x) : Foo(x) {}
+  ~Bar();
+};
+
+Foo foo;
+Foo foo2(1);
+Bar bar;
+
+// Profile data for complete constructors and destructors must absent.
+
+// CHECK-NOT: @__llvm_profile_name__ZN3FooC1Ev
+// CHECK-NOT: @__llvm_profile_name__ZN3FooC1Ei
+// CHECK-NOT: @__llvm_profile_name__ZN3FooD1Ev
+// CHECK-NOT: @__llvm_profile_name__ZN3BarC1Ev
+// CHECK-NOT: @__llvm_profile_name__ZN3BarD1Ev
+// CHECK-NOT: @__llvm_profile_counters__ZN3FooD1Ev
+// CHECK-NOT: @__llvm_profile_data__ZN3FooD1Ev
+
+int main() {
+}
Index: lib/CodeGen/CodeGenPGO.h
===
--- lib/CodeGen/CodeGenPGO.h
+++ lib/CodeGen/CodeGenPGO.h
@@ -78,13 +78,11 @@
   setCurrentRegionCount(*Count);
   }
 
-  /// Check if we need to emit coverage mapping for a given declaration
-  void checkGlobalDecl(GlobalDecl GD);
   /// Assign counters to regions and configure them for PGO of a given
   /// function. Does nothing if instrumentation is not enabled and either
   /// generates global variables or associates PGO data with each of the
   /// counters depending on whether we are generating or using instrumentation.
-  void assignRegionCounters(const Decl *D, llvm::Function *Fn);
+  void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn);
   /// Emit a coverage mapping range with a counter zero
   /// for an unused declaration.
   void emitEmptyCounterMapping(const Decl *D, StringRef FuncName,
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -602,27 +602,25 @@
   return endian::read(Result);
 }
 
-void CodeGenPGO::checkGlobalDecl(GlobalDecl GD) {
-  // Make sure we only emit coverage mapping for one constructor/destructor.
-  // Clang emits several functions for the constructor and the destructor of
-  // a class. Every function is instrumented, but we only want to provide
-  /

Re: [PATCH] D14639: LLDB JIT needs android vector passing rules.

2015-12-02 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

Ouch, that 2012 vector passing ABI break is a bummer. :(



Comment at: lib/CodeGen/TargetInfo.cpp:5236
@@ +5235,3 @@
+  if (const VectorType *VT = Ty->getAs ()) {
+if (isAndroid()) {
+  // Check whether VT is legal.

I think it would be useful to document that Android effectively shipped APIs 
compiled with Clang 3.1, so that is the behavior we are trying to match here.


Comment at: lib/CodeGen/TargetInfo.cpp:5240
@@ +5239,3 @@
+  // NumElements should be power of 2 or equal to 3.
+  if ((NumElements & (NumElements - 1)) != 0 && NumElements != 3)
+return true;

I'd appreciate the use of isPowerOf2_32() here.


Comment at: lib/CodeGen/TargetInfo.cpp:5247
@@ +5246,3 @@
+  // NumElements should be power of 2.
+  if ((NumElements & (NumElements - 1)) != 0)
+return true;

ditto


http://reviews.llvm.org/D14639



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


Re: [PATCH] D15130: Fix the clang driver when "-nostdlib" is present

2015-12-02 Thread Sumanth Gundapaneni via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254535: Fix the clang driver when "-nostdlib" is present 
(authored by sgundapa).

Changed prior to commit:
  http://reviews.llvm.org/D15130?vs=41582&id=41650#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15130

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/nostdlib.c

Index: cfe/trunk/test/Driver/nostdlib.c
===
--- cfe/trunk/test/Driver/nostdlib.c
+++ cfe/trunk/test/Driver/nostdlib.c
@@ -9,3 +9,19 @@
 // RUN: %clang -### -nostartfiles -nostdlib -target i386-apple-darwin %s \
 // RUN:   2>&1 | FileCheck %s -check-prefix=ARGSCLAIMED
 // ARGSCLAIMED-NOT: warning:
+
+// In the presence of -nostdlib, the standard libraries should not be
+// passed down to link line
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu -nostdlib --rtlib=compiler-rt \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu --rtlib=compiler-rt -nostdlib \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
+// CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8694,8 +8694,7 @@
   if (!isAndroid)
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
 }
-  } else if (Args.hasArg(options::OPT_rtlib_EQ))
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+  }
 
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }


Index: cfe/trunk/test/Driver/nostdlib.c
===
--- cfe/trunk/test/Driver/nostdlib.c
+++ cfe/trunk/test/Driver/nostdlib.c
@@ -9,3 +9,19 @@
 // RUN: %clang -### -nostartfiles -nostdlib -target i386-apple-darwin %s \
 // RUN:   2>&1 | FileCheck %s -check-prefix=ARGSCLAIMED
 // ARGSCLAIMED-NOT: warning:
+
+// In the presence of -nostdlib, the standard libraries should not be
+// passed down to link line
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu -nostdlib --rtlib=compiler-rt \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu --rtlib=compiler-rt -nostdlib \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt'
+// CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8694,8 +8694,7 @@
   if (!isAndroid)
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
 }
-  } else if (Args.hasArg(options::OPT_rtlib_EQ))
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+  }
 
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r254535 - Fix the clang driver when "-nostdlib" is present

2015-12-02 Thread Sumanth Gundapaneni via cfe-commits
Author: sgundapa
Date: Wed Dec  2 13:12:41 2015
New Revision: 254535

URL: http://llvm.org/viewvc/llvm-project?rev=254535&view=rev
Log:
Fix the clang driver when "-nostdlib" is present

This patch is a fix to r252901 which changed the behavior of 
clang driver. In the presence of "-nostdlib" none of the standard
libraries should be passed to link line.

Differential Revision: http://reviews.llvm.org/D15130

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/nostdlib.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=254535&r1=254534&r2=254535&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec  2 13:12:41 2015
@@ -8694,8 +8694,7 @@ void gnutools::Linker::ConstructJob(Comp
   if (!isAndroid)
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
 }
-  } else if (Args.hasArg(options::OPT_rtlib_EQ))
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+  }
 
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }

Modified: cfe/trunk/test/Driver/nostdlib.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=254535&r1=254534&r2=254535&view=diff
==
--- cfe/trunk/test/Driver/nostdlib.c (original)
+++ cfe/trunk/test/Driver/nostdlib.c Wed Dec  2 13:12:41 2015
@@ -9,3 +9,19 @@
 // RUN: %clang -### -nostartfiles -nostdlib -target i386-apple-darwin %s \
 // RUN:   2>&1 | FileCheck %s -check-prefix=ARGSCLAIMED
 // ARGSCLAIMED-NOT: warning:
+
+// In the presence of -nostdlib, the standard libraries should not be
+// passed down to link line
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu -nostdlib --rtlib=compiler-rt \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu --rtlib=compiler-rt -nostdlib \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: 
'--rtlib=compiler-rt'
+// CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-NOSTDLIB-NOT: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a"


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


Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-12-02 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you!


http://reviews.llvm.org/D14872



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


Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-12-02 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM, thanks!


http://reviews.llvm.org/D14872



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


Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-12-02 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 41648.
DmitryPolukhin marked 2 inline comments as done.
DmitryPolukhin added a comment.

Fixed warning and comment.


http://reviews.llvm.org/D14872

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/struct-packed-align.c

Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 
 // Packed structs.
 struct s {
@@ -138,3 +138,24 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{'packed' attribute was ignored on bit-fields with 
alignment 1 in older versions of GCC and Clang}}
+  char c:4;
+};
+
+#if defined(_WIN32)
+// On Windows clang uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#else
+extern int o1[sizeof(struct packed_chars) == 2 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#endif
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1036,17 +1036,14 @@
 TD->addAttr(::new (S.Context) PackedAttr(Attr.getRange(), S.Context,
 Attr.getAttributeSpellingListIndex()));
   else if (FieldDecl *FD = dyn_cast(D)) {
-// If the alignment is less than or equal to 8 bits, the packed attribute
-// has no effect.
+// Report warning about changed offset in the newer compiler versions.
 if (!FD->getType()->isDependentType() &&
-!FD->getType()->isIncompleteType() &&
+!FD->getType()->isIncompleteType() && FD->isBitField() &&
 S.Context.getTypeAlign(FD->getType()) <= 8)
-  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
-<< Attr.getName() << FD->getType();
-else
-  FD->addAttr(::new (S.Context)
-  PackedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
+  S.Diag(Attr.getLoc(), diag::warn_attribute_packed_for_bitfield);
+
+FD->addAttr(::new (S.Context) PackedAttr(
+Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
   } else
 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2784,9 +2784,10 @@
   "cast to %1 from smaller integer type %0">,
   InGroup;
 
-def warn_attribute_ignored_for_field_of_type : Warning<
-  "%0 attribute ignored for field of type %1">,
-  InGroup;
+def warn_attribute_packed_for_bitfield : Warning<
+  "'packed' attribute was ignored on bit-fields with single-byte alignment "
+  "in older versions of GCC and Clang">,
+  InGroup>;
 def warn_transparent_union_attribute_field_size_align : Warning<
   "%select{alignment|size}0 of field %1 (%2 bits) does not match the "
   "%select{alignment|size}0 of the first field in transparent union; "


Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 
 // Packed structs.
 struct s {
@@ -138,3 +138,24 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{'packed' attribute was ignored on bit-fields with alignment 1 in older versions of GCC an

r254528 - Move _mm256_cvtps_ph and _mm256_cvtph_ps to immintrin.h.

2015-12-02 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Wed Dec  2 12:41:52 2015
New Revision: 254528

URL: http://llvm.org/viewvc/llvm-project?rev=254528&view=rev
Log:
Move _mm256_cvtps_ph and _mm256_cvtph_ps to immintrin.h.

This more closely matches their locations as described by Intel
documentation, and lets us remove a pair of redundant typedefs.

Differential Revision: http://reviews.llvm.org/D15127

Modified:
cfe/trunk/lib/Headers/f16cintrin.h
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/lib/Headers/f16cintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/f16cintrin.h?rev=254528&r1=254527&r2=254528&view=diff
==
--- cfe/trunk/lib/Headers/f16cintrin.h (original)
+++ cfe/trunk/lib/Headers/f16cintrin.h Wed Dec  2 12:41:52 2015
@@ -28,30 +28,18 @@
 #ifndef __F16CINTRIN_H
 #define __F16CINTRIN_H
 
-typedef float __v8sf __attribute__ ((__vector_size__ (32)));
-typedef float __m256 __attribute__ ((__vector_size__ (32)));
-
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("f16c")))
 
 #define _mm_cvtps_ph(a, imm) __extension__ ({ \
  (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); })
 
-#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
- (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
-
 static __inline __m128 __DEFAULT_FN_ATTRS
 _mm_cvtph_ps(__m128i __a)
 {
   return (__m128)__builtin_ia32_vcvtph2ps((__v8hi)__a);
 }
 
-static __inline __m256 __DEFAULT_FN_ATTRS
-_mm256_cvtph_ps(__m128i __a)
-{
-  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
-}
-
 #undef __DEFAULT_FN_ATTRS
 
 #endif /* __F16CINTRIN_H */

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=254528&r1=254527&r2=254528&view=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Wed Dec  2 12:41:52 2015
@@ -42,6 +42,19 @@
 
 #include 
 
+/* The 256-bit versions of functions in f16cintrin.h.
+   Intel documents these as being in immintrin.h, and
+   they depend on typedefs from avxintrin.h. */
+
+#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
+ (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
+
+static __inline __m256 __attribute__((__always_inline__, __nodebug__, 
__target__("f16c")))
+_mm256_cvtph_ps(__m128i __a)
+{
+  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
+}
+
 #include 
 
 #include 


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


Re: [PATCH] D15127: Move _mm256_cvtps_ph and _mm256_cvtph_ps to immintrin.h.

2015-12-02 Thread Paul Robinson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254528: Move _mm256_cvtps_ph and _mm256_cvtph_ps to 
immintrin.h. (authored by probinson).

Changed prior to commit:
  http://reviews.llvm.org/D15127?vs=41555&id=41647#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15127

Files:
  cfe/trunk/lib/Headers/f16cintrin.h
  cfe/trunk/lib/Headers/immintrin.h

Index: cfe/trunk/lib/Headers/immintrin.h
===
--- cfe/trunk/lib/Headers/immintrin.h
+++ cfe/trunk/lib/Headers/immintrin.h
@@ -42,6 +42,19 @@
 
 #include 
 
+/* The 256-bit versions of functions in f16cintrin.h.
+   Intel documents these as being in immintrin.h, and
+   they depend on typedefs from avxintrin.h. */
+
+#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
+ (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
+
+static __inline __m256 __attribute__((__always_inline__, __nodebug__, 
__target__("f16c")))
+_mm256_cvtph_ps(__m128i __a)
+{
+  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
+}
+
 #include 
 
 #include 
Index: cfe/trunk/lib/Headers/f16cintrin.h
===
--- cfe/trunk/lib/Headers/f16cintrin.h
+++ cfe/trunk/lib/Headers/f16cintrin.h
@@ -28,30 +28,18 @@
 #ifndef __F16CINTRIN_H
 #define __F16CINTRIN_H
 
-typedef float __v8sf __attribute__ ((__vector_size__ (32)));
-typedef float __m256 __attribute__ ((__vector_size__ (32)));
-
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("f16c")))
 
 #define _mm_cvtps_ph(a, imm) __extension__ ({ \
  (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); })
 
-#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
- (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
-
 static __inline __m128 __DEFAULT_FN_ATTRS
 _mm_cvtph_ps(__m128i __a)
 {
   return (__m128)__builtin_ia32_vcvtph2ps((__v8hi)__a);
 }
 
-static __inline __m256 __DEFAULT_FN_ATTRS
-_mm256_cvtph_ps(__m128i __a)
-{
-  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
-}
-
 #undef __DEFAULT_FN_ATTRS
 
 #endif /* __F16CINTRIN_H */


Index: cfe/trunk/lib/Headers/immintrin.h
===
--- cfe/trunk/lib/Headers/immintrin.h
+++ cfe/trunk/lib/Headers/immintrin.h
@@ -42,6 +42,19 @@
 
 #include 
 
+/* The 256-bit versions of functions in f16cintrin.h.
+   Intel documents these as being in immintrin.h, and
+   they depend on typedefs from avxintrin.h. */
+
+#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
+ (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
+
+static __inline __m256 __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
+_mm256_cvtph_ps(__m128i __a)
+{
+  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
+}
+
 #include 
 
 #include 
Index: cfe/trunk/lib/Headers/f16cintrin.h
===
--- cfe/trunk/lib/Headers/f16cintrin.h
+++ cfe/trunk/lib/Headers/f16cintrin.h
@@ -28,30 +28,18 @@
 #ifndef __F16CINTRIN_H
 #define __F16CINTRIN_H
 
-typedef float __v8sf __attribute__ ((__vector_size__ (32)));
-typedef float __m256 __attribute__ ((__vector_size__ (32)));
-
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
 
 #define _mm_cvtps_ph(a, imm) __extension__ ({ \
  (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); })
 
-#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
- (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
-
 static __inline __m128 __DEFAULT_FN_ATTRS
 _mm_cvtph_ps(__m128i __a)
 {
   return (__m128)__builtin_ia32_vcvtph2ps((__v8hi)__a);
 }
 
-static __inline __m256 __DEFAULT_FN_ATTRS
-_mm256_cvtph_ps(__m128i __a)
-{
-  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
-}
-
 #undef __DEFAULT_FN_ATTRS
 
 #endif /* __F16CINTRIN_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.

2015-12-02 Thread Tom Stellard via cfe-commits
tstellarAMD resigned from this revision.
tstellarAMD removed a reviewer: tstellarAMD.
tstellarAMD added a comment.

Hans already commented on the release script changes, and I agrre they look 
good.


http://reviews.llvm.org/D13802



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


Re: [PATCH] D14691: clang side of http://reviews.llvm.org/D14690

2015-12-02 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.
This revision is now accepted and ready to land.

AMDGPU changes LGTM.


http://reviews.llvm.org/D14691



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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:68
@@ +67,3 @@
+
callee(expr(ignoringParenImpCasts(declRefExpr(has(nestedNameSpecifierLoc().bind("namespace"))).bind("swap"),
+this);
+}

I believe that if you do that, you lose the arguments as well.

std::swap(x,y);  -> { using ::std::swap; swap; }



Comment at: clang-tidy/misc/StdSwapCheck.h:19
@@ +18,3 @@
+/// A checker that finds ns-qualified calls to std::swap, and replaces them
+///with calls that use ADL instead.
+///

aaron.ballman wrote:
> Strange indentation on the second line of the comment.
I like that indentation :-) 
It indicates that this is a continuation of the previous line.


http://reviews.llvm.org/D15121



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


Re: r254515 - Amending r254423 by deleting the copy constructor and adding a move constructor instead; NFC as neither of these constructors are currently called, but this is a safer design.

2015-12-02 Thread David Blaikie via cfe-commits
Oh, this type has a user-defined dtor, so it's deprecated to use the
implicit copy ctor/assignment operator anyway - and I have the -Wdeprecated
flag on in my build (& keep the LLVM build clean of any warnings it shows).

At some point (would love help) we should just turn that on for everyone,
then we wouldn't have to worry about types like this -Wdeprecated -Werror
would catch them. I think last time I tried to turn it on there were some
things in library headers, perhaps (maybe in cxxabi?) that needed cleaning
up that I didn't have/build/see locally...

- Dave

On Wed, Dec 2, 2015 at 9:57 AM, David Blaikie  wrote:

>
>
> On Wed, Dec 2, 2015 at 7:05 AM, Aaron Ballman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: aaronballman
>> Date: Wed Dec  2 09:05:47 2015
>> New Revision: 254515
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=254515&view=rev
>> Log:
>> Amending r254423 by deleting the copy constructor and adding a move
>> constructor instead; NFC as neither of these constructors are currently
>> called, but this is a safer design.
>>
>> Modified:
>> cfe/trunk/include/clang/Sema/AttributeList.h
>>
>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=254515&r1=254514&r2=254515&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Dec  2 09:05:47 2015
>> @@ -557,6 +557,13 @@ public:
>>/// Create a new pool for a factory.
>>AttributePool(AttributeFactory &factory) : Factory(factory),
>> Head(nullptr) {}
>>
>> +  AttributePool(AttributePool &) = delete;
>>
>
> FWIW, once you add the move ctor, the copy ctor is implicitly deleted
> anyway
>
>
>> +
>> +  /// Move the given pool's allocations to this pool.
>> +  AttributePool(AttributePool &&pool) : Factory(pool.Factory),
>> Head(pool.Head) {
>> +pool.Head = nullptr;
>> +  }
>> +
>>AttributeFactory &getFactory() const { return Factory; }
>>
>>void clear() {
>>
>>
>> ___
>> 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: r254515 - Amending r254423 by deleting the copy constructor and adding a move constructor instead; NFC as neither of these constructors are currently called, but this is a safer design.

2015-12-02 Thread David Blaikie via cfe-commits
On Wed, Dec 2, 2015 at 7:05 AM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Wed Dec  2 09:05:47 2015
> New Revision: 254515
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254515&view=rev
> Log:
> Amending r254423 by deleting the copy constructor and adding a move
> constructor instead; NFC as neither of these constructors are currently
> called, but this is a safer design.
>
> Modified:
> cfe/trunk/include/clang/Sema/AttributeList.h
>
> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=254515&r1=254514&r2=254515&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
> +++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Dec  2 09:05:47 2015
> @@ -557,6 +557,13 @@ public:
>/// Create a new pool for a factory.
>AttributePool(AttributeFactory &factory) : Factory(factory),
> Head(nullptr) {}
>
> +  AttributePool(AttributePool &) = delete;
>

FWIW, once you add the move ctor, the copy ctor is implicitly deleted anyway


> +
> +  /// Move the given pool's allocations to this pool.
> +  AttributePool(AttributePool &&pool) : Factory(pool.Factory),
> Head(pool.Head) {
> +pool.Head = nullptr;
> +  }
> +
>AttributeFactory &getFactory() const { return Factory; }
>
>void clear() {
>
>
> ___
> 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: [PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2015-12-02 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/AST/RecordLayoutBuilder.cpp:1606
@@ -1605,1 +1605,3 @@
+} else if (ExplicitFieldAlign)
+  FieldOffset = llvm::RoundUpToAlignment(FieldOffset, ExplicitFieldAlign);
 

Be sure to test specifically with an APCS ARM target; newer ARM ABIs don't 
ignore bit-field layout. Sorry, I should have been more explicit about that. 
(You can figure this stuff out by looking at the various targets in Targets.cpp 
that set UseBitFieldTypeAlignment.)


http://reviews.llvm.org/D14980



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


r254520 - Making the deleted copy constructor parameter const; NFC.

2015-12-02 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec  2 11:07:30 2015
New Revision: 254520

URL: http://llvm.org/viewvc/llvm-project?rev=254520&view=rev
Log:
Making the deleted copy constructor parameter const; NFC.

Modified:
cfe/trunk/include/clang/Sema/AttributeList.h

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=254520&r1=254519&r2=254520&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Dec  2 11:07:30 2015
@@ -557,7 +557,7 @@ public:
   /// Create a new pool for a factory.
   AttributePool(AttributeFactory &factory) : Factory(factory), Head(nullptr) {}
 
-  AttributePool(AttributePool &) = delete;
+  AttributePool(const AttributePool &) = delete;
 
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &&pool) : Factory(pool.Factory), Head(pool.Head) 
{


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


Re: r254143 - Fix for merging decls in pragma weak

2015-12-02 Thread Joerg Sonnenberger via cfe-commits
On Thu, Nov 26, 2015 at 09:34:31AM -, Alexander Musman via cfe-commits 
wrote:
> Author: amusman
> Date: Thu Nov 26 03:34:30 2015
> New Revision: 254143
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=254143&view=rev
> Log:
> Fix for merging decls in pragma weak
> Calling CheckFunctionDeclaration so that 2 decls for the 'weak' are merged.
> Differential Revision: http://reviews.llvm.org/D13048

This crashes on the attached code.

Joerg
dmu_snapshots_destroy (char *, char *, int);
dsl_snapshots_destroy (char *, char *, int);
#pragma weak dmu_snapshots_destroy = dsl_snapshots_destroy
int
dsl_snapshots_destroy (char *p1, char *p2, int p3)
{
}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:86
@@ +85,3 @@
+ SourceLocation semiLoc = 
findSemiAfterLocation(swapSourceRange.getEnd(), *Result.Context, false);
+ assert(semiLoc != SourceLocation() && "Can't find the terminating 
semicolon" );
+

Extra space at the end of the assert before the closing paren.


Comment at: clang-tidy/misc/StdSwapCheck.h:19
@@ +18,3 @@
+/// A checker that finds ns-qualified calls to std::swap, and replaces them
+///with calls that use ADL instead.
+///

Strange indentation on the second line of the comment.


Comment at: test/clang-tidy/misc-StdSwap.cpp:4
@@ +3,3 @@
+#include 
+
+// FIXME: Add something that triggers the check here.

> The reason that  is included here is that that is where swap is 
> declared.

The usual approach we take in our tests is to declare the STL functionality 
inside of the source file being tested. For instance, see 
misc-move-constructor-init.cpp. Another approach, if you require the 
declaration to be in a header file (which you don't appear to from the checker) 
is to create a local test file and #include  it with "header" instead of 
. Relying on whatever STL happens to be found by header search logic 
makes the tests highly fragile (and bots will happily chirp at you when you do 
this).



http://reviews.llvm.org/D15121



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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Manuel Klimek via cfe-commits
klimek added a reviewer: bkramer.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:25
@@ +24,3 @@
+static SourceLocation findSemiAfterLocation(SourceLocation loc,
+ASTContext &Ctx,
+bool IsDecl) {

We should put that somewhere into Tooling/Core. Adding Benjamin who is our 
master of Yaks :D


http://reviews.llvm.org/D15121



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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:24
@@ +23,3 @@
+/// source location will be invalid.
+static SourceLocation findSemiAfterLocation(SourceLocation loc,
+ASTContext &Ctx,

aaron.ballman wrote:
> rsmith wrote:
> > Is there somewhere more central where this can live?
> If it is useful to multiple checkers, it could live in clangTidyUtils, or 
> were you thinking of something more general for clang itself?
I'd love to have this in a library somewhere; I found a discussion about this 
from a year ago; Manuel seemed to think that it was a good idea, but nothing 
apparently came of that. I lifted this code from 
`llvm/tools/clang/lib/ARCMigrate/Transforms.cpp`


Comment at: test/clang-tidy/misc-StdSwap.cpp:3
@@ +2,3 @@
+
+#include 
+

aaron.ballman wrote:
> It would be good to not have the #include  here -- for instance, I 
> think that this test will fail on Windows with MSVC if the only MSVC STL 
> headers that can be found are from VS 2015 because there's no 
> -fms-compatibility-version=19 option being used. 
The reason that  is included here is that that is where `swap` is 
declared.



http://reviews.llvm.org/D15121



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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Marshall Clow via cfe-commits
mclow.lists updated the summary for this revision.
mclow.lists updated this revision to Diff 41626.
mclow.lists marked 7 inline comments as done.
mclow.lists added a comment.

Fixed all the simple things that people commented on.


http://reviews.llvm.org/D15121

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StdSwapCheck.cpp
  clang-tidy/misc/StdSwapCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-std-swap.rst
  test/clang-tidy/misc-StdSwap.cpp

Index: test/clang-tidy/misc-StdSwap.cpp
===
--- test/clang-tidy/misc-StdSwap.cpp
+++ test/clang-tidy/misc-StdSwap.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s misc-std-swap %t
+
+#include 
+
+// FIXME: Add something that triggers the check here.
+// FIXME: Verify the applied fix.
+//   * Make the CHECK patterns specific enough and try to make verified lines
+// unique to avoid incorrect matches.
+//   * Use {{}} for regular expressions.
+
+// Bad code; don't overload in namespace std
+struct S1 { int x; };
+namespace std { void swap(S1& x, S1 &y) { swap(x.x, y.x); } };
+
+// Swap in namespace with type
+namespace foo { struct S2 { int i; }; void swap(S2& x, S2& y) {std::swap(x.i, y.i); } }
+
+// Swap in namespace.
+namespace bar {
+  void swap(int, int) {}
+  namespace std {
+void swap(int, int) {}
+  }
+}
+
+void test0()
+{
+  S1 i,j;
+  std::swap(i,j);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: let the compiler find the right swap via ADL
+  // CHECK-FIXES: { using std::swap; swap(i,j); }
+}
+
+void test1(bool b)
+{
+  foo::S2 x,y;
+  if ( b )
+std::swap(x,y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: let the compiler find the right swap via ADL
+  // CHECK-FIXES: { using std::swap; swap(x,y); }
+}
+
+void test_neg0()// Swap two builtins
+{
+{
+int i,j;
+std::swap(i,j);
+}
+{
+float i,j;
+std::swap(i,j);
+}
+}
+
+void test_neg1()// std::swap two pointers
+
+{
+S1 *i, *j;
+std::swap(i,j);
+}
+
+void test_neg2()  // Call a namespace-qualified swap that isn't "std::"
+{
+int i,j;
+bar::swap(i,j);
+bar::std::swap(i,j);
+}
Index: docs/clang-tidy/checks/misc-std-swap.rst
===
--- docs/clang-tidy/checks/misc-std-swap.rst
+++ docs/clang-tidy/checks/misc-std-swap.rst
@@ -0,0 +1,19 @@
+misc-std-swap
+
+
+Adding an overload for `std:swap` (in the `std` namespace) is explicitly forbidden by the standard. 
+
+The best practice for implementing swap for user-defined data structures is to implement a non-member swap in the same namespace as the type. Then, when you wish to swap to values `x` and `y`, you call `swap(x,y)` without a namespace, and argument dependent lookup will find it. Unfortunately this will not work for types that have overloads of `swap` in namespace `std` (standard library types and primitive types). So you have to bring them into play with a `using` declaration.
+
+Instead of writing:
+> std::swap(x,y);
+
+you should write:
+> using std::swap; swap(x,y);
+
+This checker find this pattern and replaces it with the recommended usage; wrapping the call in a pair of braces to scope the using directive. For builtin types (such as `int` and `float`), as well as pointers, it leaves the calls to `std::swap` alone, because those are correct.
+
+FUTURE WORK: 
+
+Find overloads of `swap` in namespace std and put them in the correct namespace.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -46,6 +46,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-std-swap
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
misc-undelegated-constructor
Index: clang-tidy/misc/StdSwapCheck.h
===
--- clang-tidy/misc/StdSwapCheck.h
+++ clang-tidy/misc/StdSwapCheck.h
@@ -0,0 +1,35 @@
+//===--- StdSwapCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STD_SWAP_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STD_SWAP_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// A checker that finds ns-qualified calls to std::swap, and replaces them
+///with calls that use ADL instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-std-swap.html
+class StdSwapCheck : public ClangTidyCheck {
+public:
+  StdSwapCheck(StringRef Name, ClangTi

Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-12-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2788
@@ +2787,3 @@
+def warn_attribute_packed_for_bitfield : Warning<
+  "'packed' attribute was ignored on bit-fields with alignment 1 "
+  "in older versions of GCC and Clang">,

Would this read better as "on bit-fields with single-byte alignment" instead of 
"on bit-fields with alignment 1"?


Comment at: test/Sema/struct-packed-align.c:155
@@ +154,3 @@
+#if defined(_WIN32)
+// On Windows clang ignores uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];

"ignores uses" -> "uses"


http://reviews.llvm.org/D14872



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


[clang-tools-extra] r254517 - Replace the custom AST matcher for nothrow functions with the canonical AST matcher from r254516.

2015-12-02 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec  2 09:24:47 2015
New Revision: 254517

URL: http://llvm.org/viewvc/llvm-project?rev=254517&view=rev
Log:
Replace the custom AST matcher for nothrow functions with the canonical AST 
matcher from r254516.

Modified:
clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h

Modified: clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp?rev=254517&r1=254516&r2=254517&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StaticObjectExceptionCheck.cpp Wed 
Dec  2 09:24:47 2015
@@ -26,7 +26,7 @@ void StaticObjectExceptionCheck::registe
   Finder->addMatcher(
   varDecl(anyOf(hasThreadStorageDuration(), hasStaticStorageDuration()),
   hasInitializer(cxxConstructExpr(hasDeclaration(
-  cxxConstructorDecl(unless(matchers::isNoThrow()))
+  cxxConstructorDecl(unless(isNoThrow()))
   .bind("ctor")
   .bind("var"),
   this);

Modified: clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp?rev=254517&r1=254516&r2=254517&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp Wed 
Dec  2 09:24:47 2015
@@ -23,7 +23,7 @@ void ThrownExceptionTypeCheck::registerM
   Finder->addMatcher(
   cxxThrowExpr(
   has(cxxConstructExpr(hasDeclaration(cxxConstructorDecl(
-  isCopyConstructor(), unless(matchers::isNoThrow()
+  isCopyConstructor(), unless(isNoThrow()
   .bind("expr"))),
   this);
 }

Modified: clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/Matchers.h?rev=254517&r1=254516&r2=254517&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/Matchers.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/Matchers.h Wed Dec  2 09:24:47 2015
@@ -23,22 +23,6 @@ AST_MATCHER(QualType, isExpensiveToCopy)
   return IsExpensive && *IsExpensive;
 }
 
-AST_MATCHER(FunctionDecl, isNoThrow) {
-  const auto *FnTy = Node.getType()->getAs();
-  
-  // If the function does not have a prototype, then it is assumed to be a
-  // throwing function (as it would if the function did not have any exception
-  // specification).
-  if (!FnTy)
-return false;
-
-  // Assume the best for any unresolved exception specification.
-  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
-return true;
-
-  return FnTy->isNothrow(Node.getASTContext());
-}
-
 } // namespace matchers
 } // namespace tidy
 } // namespace clang


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


Re: [clang-tools-extra] r254477 - Force test to a target that supports thread_local

2015-12-02 Thread Aaron Ballman via cfe-commits
On Tue, Dec 1, 2015 at 8:12 PM, Matthias Braun via cfe-commits
 wrote:
> Author: matze
> Date: Tue Dec  1 19:12:06 2015
> New Revision: 254477
>
> URL: http://llvm.org/viewvc/llvm-project?rev=254477&view=rev
> Log:
> Force test to a target that supports thread_local
>
> This should fix darwin bots.

Thank you for the fix!

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


r254516 - Add a narrowing AST matcher that matches on a FunctionDecl with a non-throwing exception specification.

2015-12-02 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec  2 09:23:59 2015
New Revision: 254516

URL: http://llvm.org/viewvc/llvm-project?rev=254516&view=rev
Log:
Add a narrowing AST matcher that matches on a FunctionDecl with a non-throwing 
exception specification.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=254516&r1=254515&r2=254516&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed Dec  2 09:23:59 2015
@@ -2236,6 +2236,20 @@ namespaceDecl(isInline()) will match n::
 
 
 
+MatcherFunctionDecl>isNoThrow
+Matches functions that 
have a non-throwing exception specification.
+
+Given:
+  void f();
+  void g() noexcept;
+  void h() throw();
+  void i() throw(int);
+  void j() noexcept(false);
+functionDecl(isNoThrow())
+  matches the declarations of g, and h, but not f, i or j.
+
+
+
 MatcherFunctionDecl>isTemplateInstantiation
 Matches 
template instantiations of function, class, or static
 member variable template instantiations.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=254516&r1=254515&r2=254516&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Dec  2 09:23:59 2015
@@ -2942,6 +2942,34 @@ AST_MATCHER(FunctionDecl, isDeleted) {
   return Node.isDeleted();
 }
 
+/// \brief Matches functions that have a non-throwing exception specification.
+///
+/// Given:
+/// \code
+///   void f();
+///   void g() noexcept;
+///   void h() throw();
+///   void i() throw(int);
+///   void j() noexcept(false);
+/// \endcode
+/// functionDecl(isNoThrow())
+///   matches the declarations of g, and h, but not f, i or j.
+AST_MATCHER(FunctionDecl, isNoThrow) {
+  const auto *FnTy = Node.getType()->getAs();
+
+  // If the function does not have a prototype, then it is assumed to be a
+  // throwing function (as it would if the function did not have any exception
+  // specification).
+  if (!FnTy)
+return false;
+
+  // Assume the best for any unresolved exception specification.
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return true;
+
+  return FnTy->isNothrow(Node.getASTContext());
+}
+
 /// \brief Matches constexpr variable and function declarations.
 ///
 /// Given:

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=254516&r1=254515&r2=254516&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Dec  2 09:23:59 2015
@@ -288,6 +288,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isListInitialization);
   REGISTER_MATCHER(isMemberInitializer);
   REGISTER_MATCHER(isMoveConstructor);
+  REGISTER_MATCHER(isNoThrow);
   REGISTER_MATCHER(isOverride);
   REGISTER_MATCHER(isPrivate);
   REGISTER_MATCHER(isProtected);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=254516&r1=254515&r2=254516&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Wed Dec  2 09:23:59 2015
@@ -1716,6 +1716,15 @@ TEST(IsDeleted, MatchesDeletedFunctionDe
   functionDecl(hasName("Func"), isDeleted(;
 }
 
+TEST(IsNoThrow, MatchesNoThrowFunctionDeclarations) {
+  EXPECT_TRUE(notMatches("void f();", functionDecl(isNoThrow(;
+  EXPECT_TRUE(notMatches("void f() throw(int);", functionDecl(isNoThrow(;
+  EXPECT_TRUE(
+  notMatches("void f() noexcept(false);", functionDecl(isNoThrow(;
+  EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow(;
+  EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow(;
+}
+
 TEST(isConstexpr, MatchesConstexprDeclarations) {
   EXPECT_TRUE(matches("constexpr int foo = 42;",
   varDecl(hasName("foo"), isConstexpr(;


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

Re: [PATCH] D14731: [libcxx] Add clang thread safety annotations to mutex and lock_guard

2015-12-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D14731#300074, @jamesr wrote:

> It looks like Aaron Ballman was involved with adding parsing for these 
> attributes in clang - perhaps he has an idea of a better way to detect these 
> than __has_attribute(acquire_capability).


__has_attribute is a reasonable approach. You are correct that there is 
(unfortunately) no good feature testing macro for these. The good news is, the 
attributes are relatively stable these days, and have been for a while.

FWIW, the annotations all LGTM.

~Aaron


http://reviews.llvm.org/D14731



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


r254515 - Amending r254423 by deleting the copy constructor and adding a move constructor instead; NFC as neither of these constructors are currently called, but this is a safer design.

2015-12-02 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Dec  2 09:05:47 2015
New Revision: 254515

URL: http://llvm.org/viewvc/llvm-project?rev=254515&view=rev
Log:
Amending r254423 by deleting the copy constructor and adding a move constructor 
instead; NFC as neither of these constructors are currently called, but this is 
a safer design.

Modified:
cfe/trunk/include/clang/Sema/AttributeList.h

Modified: cfe/trunk/include/clang/Sema/AttributeList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=254515&r1=254514&r2=254515&view=diff
==
--- cfe/trunk/include/clang/Sema/AttributeList.h (original)
+++ cfe/trunk/include/clang/Sema/AttributeList.h Wed Dec  2 09:05:47 2015
@@ -557,6 +557,13 @@ public:
   /// Create a new pool for a factory.
   AttributePool(AttributeFactory &factory) : Factory(factory), Head(nullptr) {}
 
+  AttributePool(AttributePool &) = delete;
+
+  /// Move the given pool's allocations to this pool.
+  AttributePool(AttributePool &&pool) : Factory(pool.Factory), Head(pool.Head) 
{
+pool.Head = nullptr;
+  }
+
   AttributeFactory &getFactory() const { return Factory; }
 
   void clear() {


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


Re: r254423 - It appears that this horrible mutating copy constructor is unused. Kill it with fire.

2015-12-02 Thread Aaron Ballman via cfe-commits
On Tue, Dec 1, 2015 at 6:47 PM, Richard Smith  wrote:
> On Tue, Dec 1, 2015 at 3:42 PM, Duncan P. N. Exon Smith via cfe-commits
>  wrote:
>>
>>
>> > On 2015-Dec-01, at 09:15, Aaron Ballman via cfe-commits
>> >  wrote:
>> >
>> > Author: aaronballman
>> > Date: Tue Dec  1 11:15:13 2015
>> > New Revision: 254423
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=254423&view=rev
>> > Log:
>> > It appears that this horrible mutating copy constructor is unused. Kill
>> > it with fire.
>> >
>> > Modified:
>> >cfe/trunk/include/clang/Sema/AttributeList.h
>> >
>> > Modified: cfe/trunk/include/clang/Sema/AttributeList.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=254423&r1=254422&r2=254423&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
>> > +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Dec  1 11:15:13
>> > 2015
>> > @@ -557,11 +557,6 @@ public:
>> >   /// Create a new pool for a factory.
>> >   AttributePool(AttributeFactory &factory) : Factory(factory),
>> > Head(nullptr) {}
>> >
>> > -  /// Move the given pool's allocations to this pool.
>> > -  AttributePool(AttributePool &pool) : Factory(pool.Factory),
>> > Head(pool.Head) {
>> > -pool.Head = nullptr;
>> > -  }
>> > -
>>
>> Moving without R-value references is weird, but it seems to me like
>> at least this was preventing double-ownership of the Head.
>>
>> I'm pretty sure now that this function has been removed, the copy
>> constructor will be auto-generated.  Should you `= delete` it?
>
>
> Or, preferably, reinstate it but make it a move constructor.

I originally replaced it with a move constructor, but felt that since
it was unused, no constructor was better. However, Duncan's point
still stands that the constructor would be auto-generated anyway, and
someone may accidentally copy or move this, so it should do the right
thing. I've fixed in r254515, thank you for the review!

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


Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-02 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/StdSwapCheck.cpp:24
@@ +23,3 @@
+/// source location will be invalid.
+static SourceLocation findSemiAfterLocation(SourceLocation loc,
+ASTContext &Ctx,

rsmith wrote:
> Is there somewhere more central where this can live?
If it is useful to multiple checkers, it could live in clangTidyUtils, or were 
you thinking of something more general for clang itself?


Comment at: clang-tidy/misc/StdSwapCheck.cpp:86
@@ +85,3 @@
+ SourceLocation semiLoc = 
findSemiAfterLocation(swapSourceRange.getEnd(), *Result.Context, false);
+ assert(semiLoc != SourceLocation());
+

Can we get an && message in here as to what is being asserted?


Comment at: clang-tidy/misc/StdSwapCheck.cpp:89
@@ +88,3 @@
+  nsSourceRange.setEnd(nsSourceRange.getEnd().getLocWithOffset(2));
+  Diag << FixItHint::CreateReplacement(nsSourceRange, "{ using std::swap; 
")
+   << FixItHint::CreateInsertion(semiLoc.getLocWithOffset(1), " }");

I wonder if there is a way to guard against code like:
```
SomeStruct S1, S2;

if (something) {  std::swap(S1, S2); }
```
from becoming:
```
SomeStruct S1, S2;

if (something) {{ using std::swap; swap(S3, S4); }}
```
Also, should the fixit be suppressed under some circumstances?

```
// Is the replacement always safe for all macro expansions?
#define SWAP(a, b) std::swap(a, b)

// I should probably be punished for considering this code
for (;;std::swap(a, b)) ;
if (std::swap(a, b), (bool)a) ; 
```



Comment at: clang-tidy/misc/StdSwapCheck.h:18
@@ +17,3 @@
+
+/// FIXME: Write a short description.
+///

Can this FIXME be fixed? ;-)


Comment at: docs/clang-tidy/checks/misc-StdSwap.rst:1
@@ +1,2 @@
+misc-StdSwap
+

This is incorrect, as is the file name (at least, compared to the comments in 
StdSwapCheck.h. Can this (and the file) be renamed to misc-std-swap instead?


Comment at: test/clang-tidy/misc-StdSwap.cpp:3
@@ +2,3 @@
+
+#include 
+

It would be good to not have the #include  here -- for instance, I 
think that this test will fail on Windows with MSVC if the only MSVC STL 
headers that can be found are from VS 2015 because there's no 
-fms-compatibility-version=19 option being used. 


Comment at: test/clang-tidy/misc-StdSwap.cpp:61
@@ +60,3 @@
+bar::swap(i,j);
+}
+

It would also be good to have a test that checks bar::std::swap(a, b) doesn't 
get flagged.


http://reviews.llvm.org/D15121



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


Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.

2015-12-02 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/AST/OpenMPClause.h:667
@@ -666,3 +666,3 @@
   OpenMPScheduleClauseKind Kind;
-  /// \brief Start location of the schedule ind in source code.
+  /// \brief Start location of the schedule kind in source code.
   SourceLocation KindLoc;

This must be in a separate patch


Comment at: include/clang/AST/OpenMPClause.h:708-709
@@ -707,4 +707,4 @@
 public:
-  /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
-  /// expression \a ChunkSize.
+  /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk
+  /// size expression \a ChunkSize.
   ///

I think this is wrong, this is not for dist_schedule, but for schedule clause


Comment at: include/clang/AST/OpenMPClause.h:779
@@ -778,1 +778,3 @@
 
+/// \brief This represents 'dist_schedule' clause in the '#pragma omp ...'
+/// directive.

This must be in a separate patch


Comment at: include/clang/AST/RecursiveASTVisitor.h:2732-2738
@@ -2727,1 +2731,9 @@
 template 
+bool RecursiveASTVisitor::VisitOMPDistScheduleClause(
+OMPDistScheduleClause *C) {
+  TRY_TO(TraverseStmt(C->getChunkSize()));
+  TRY_TO(TraverseStmt(C->getHelperChunkSize()));
+  return true;
+}
+
+template 

separate patch


Comment at: include/clang/AST/StmtOpenMP.h:2279
@@ +2278,3 @@
+  /// \brief true if current directive has inner cancel directive.
+  bool HasCancel;
+

Distribute directive cannot have inner cancel


Comment at: include/clang/Basic/OpenMPKinds.h:89-95
@@ -88,2 +88,9 @@
 
+/// \brief OpenMP attributes for 'dist_schedule' clause.
+enum OpenMPDistScheduleClauseKind {
+#define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name,
+#include "clang/Basic/OpenMPKinds.def"
+  OMPC_DIST_SCHEDULE_unknown
+};
+
 OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str);

Separate patch


Comment at: lib/AST/StmtPrinter.cpp:882
@@ +881,3 @@
+void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) 
{
+  OS << "schedule(" << getOpenMPSimpleClauseTypeName(
+   OMPC_dist_schedule, Node->getDistScheduleKind());

dist_schedule, not schedule


Comment at: lib/Basic/OpenMPKinds.cpp:475
@@ -452,1 +474,3 @@
+ DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
+ DKind == OMPD_distribute; // TODO add next directives.
 }

distribute is not a worksharing directive


Comment at: lib/Parse/ParseOpenMP.cpp:162
@@ -160,3 +161,3 @@
 /// 'for simd' | 'parallel for simd' | 'target' | 'target data' |
-/// 'taskgroup' | 'teams' {clause}
+/// 'taskgroup' | 'teams' {clause} | 'distribute'
 /// annot_pragma_openmp_end

'distribute' misses clauses, put your changes right after 'teams'


Comment at: lib/Parse/ParseOpenMP.cpp:239
@@ -238,1 +238,3 @@
+  case OMPD_distribute:
+  case OMPD_target_data: {
 ConsumeToken();

Restore the order of target_data and taskloop directives, put distribute right 
after taskloop


Comment at: lib/Sema/SemaOpenMP.cpp:1530
@@ -1521,2 +1529,3 @@
   // | Parent directive | Child directive | Closely (!), No-Closely(+), 
Both(*)|
+  // |  | | Strictly (!!)  
|
   // 
+--+-++

It is not required, closely without no-closely means strictly


Comment at: lib/Sema/SemaOpenMP.cpp:1989
@@ -1979,2 +1988,3 @@
   // | teams| taskloop| +  
|
+  // | teams| distribute  | !! 
|
   // 
+--+-++

Add rules for distribute to all other directives


Comment at: lib/Sema/SemaOpenMP.cpp:2026-2027
@@ -2015,3 +2025,4 @@
   ShouldBeInOrderedRegion,
-  ShouldBeInTargetRegion
+  ShouldBeInTargetRegion,
+  ShouldBeInTeamsRegion
 } Recommend = NoRecommend;

I don't think this change is required


Comment at: lib/Sema/SemaOpenMP.cpp:2062-2072
@@ -2050,2 +2061,13 @@
   return false;
+if (isOpenMPDistributeDirective(CurrentRegion)) {
+  // OpenMP 4.5 [2.17 Nesting of Regions]
+  // The region associated with the distribute construct must be strictly
+  // nested inside a teams region
+  if (ParentRegion != OMPD_teams) {
+SemaRef.Diag(StartLoc,
+ diag::err_omp_distribute_strictly_nested_in_teams);
+return true;
+  }
+  return false;
+}
 if (CurrentRegion == OMPD_cancellation_point ||
-

Re: [PATCH] D15149: Traverse the nested name specifier (loc) of namespace alias declarations.

2015-12-02 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r254510.


http://reviews.llvm.org/D15149



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


r254510 - Traverse the NestedNameSpecifier(Loc) of NamespaceAliasDecls.

2015-12-02 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Dec  2 07:57:46 2015
New Revision: 254510

URL: http://llvm.org/viewvc/llvm-project?rev=254510&view=rev
Log:
Traverse the NestedNameSpecifier(Loc) of NamespaceAliasDecls.

Review: http://reviews.llvm.org/D15149

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=254510&r1=254509&r2=254510&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Dec  2 07:57:46 2015
@@ -1324,6 +1324,8 @@ DEF_TRAVERSE_DECL(
 DEF_TRAVERSE_DECL(ExternCContextDecl, {})
 
 DEF_TRAVERSE_DECL(NamespaceAliasDecl, {
+  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
+
   // We shouldn't traverse an aliased namespace, since it will be
   // defined (and, therefore, traversed) somewhere else.
   //

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=254510&r1=254509&r2=254510&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Wed Dec  2 07:57:46 2015
@@ -4487,6 +4487,8 @@ TEST(NNS, MatchesNestedNameSpecifiers) {
   nestedNameSpecifier()));
   EXPECT_TRUE(matches("struct A { void f(); }; void A::f() {}",
   nestedNameSpecifier()));
+  EXPECT_TRUE(matches("namespace a { namespace b {} } namespace ab = a::b;",
+  nestedNameSpecifier()));
 
   EXPECT_TRUE(matches(
 "struct A { static void f() {} }; void g() { A::f(); }",


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


Re: [PATCH] D14871: [Power PC] fix calculating address of arguments on stack for variadic functions

2015-12-02 Thread Strahinja Petrovic via cfe-commits
spetrovic updated this revision to Diff 41613.
spetrovic marked an inline comment as done.

http://reviews.llvm.org/D14871

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/ppc-varargs-struct.c
  test/CodeGen/x86_64-arguments.c

Index: test/CodeGen/x86_64-arguments.c
===
--- test/CodeGen/x86_64-arguments.c
+++ test/CodeGen/x86_64-arguments.c
@@ -336,7 +336,8 @@
 
 // CHECK-LABEL: define i32 @f44
 // CHECK: ptrtoint
-// CHECK-NEXT: and {{.*}}, -32
+// CHECK-NEXT: add i64 %{{[0-9]+}}, 31
+// CHECK-NEXT: and i64 %{{[0-9]+}}, -32
 // CHECK-NEXT: inttoptr
 typedef int T44 __attribute((vector_size(32)));
 struct s44 { T44 x; int y; };
Index: test/CodeGen/ppc-varargs-struct.c
===
--- test/CodeGen/ppc-varargs-struct.c
+++ test/CodeGen/ppc-varargs-struct.c
@@ -39,9 +39,13 @@
 // CHECK-PPC:[[USING_OVERFLOW]]
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA:%.+]] = load i8*, i8** [[OVERFLOW_AREA_P]], align 4
-// CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* [[OVERFLOW_AREA]] to %struct.x**
-// CHECK-PPC-NEXT:  [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, i8* [[OVERFLOW_AREA]], i32 4
-// CHECK-PPC-NEXT:  store i8* [[NEW_OVERFLOW_AREA]], i8** [[OVERFLOW_AREA_P]]
+// CHECK-PPC-NEXT:  %{{[0-9]+}} =  ptrtoint i8* %argp.cur to i32
+// CHECK-PPC-NEXT:  %{{[0-9]+}} = add i32 %{{[0-9]+}}, 7
+// CHECK-PPC-NEXT:  %{{[0-9]+}} = and i32 %{{[0-9]+}}, -8
+// CHECK-PPC-NEXT:  %argp.cur.aligned = inttoptr i32 %{{[0-9]+}} to i8*
+// CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* %argp.cur.aligned to %struct.x**
+// CHECK-PPC-NEXT:  [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, i8* %argp.cur.aligned, i32 4
+// CHECK-PPC-NEXT:  store i8* [[NEW_OVERFLOW_AREA:%[0-9]+]], i8** [[OVERFLOW_AREA_P]], align 4
 // CHECK-PPC-NEXT:  br label %[[CONT]]
 //
 // CHECK-PPC:[[CONT]]
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -162,6 +162,23 @@
   OS << ")\n";
 }
 
+// Dynamically round a pointer up to a multiple of the given alignment.
+static llvm::Value *emitRoundPointerUpToAlignment(CodeGenFunction &CGF,
+  llvm::Value *Ptr,
+  CharUnits Align) {
+  llvm::Value *PtrAsInt = Ptr;
+  // OverflowArgArea = (OverflowArgArea + Align - 1) & -Align;
+  PtrAsInt = CGF.Builder.CreatePtrToInt(PtrAsInt, CGF.IntPtrTy);
+  PtrAsInt = CGF.Builder.CreateAdd(PtrAsInt,
+llvm::ConstantInt::get(CGF.IntPtrTy, Align.getQuantity() - 1));
+  PtrAsInt = CGF.Builder.CreateAnd(PtrAsInt,
+   llvm::ConstantInt::get(CGF.IntPtrTy, -Align.getQuantity()));
+  PtrAsInt = CGF.Builder.CreateIntToPtr(PtrAsInt,
+Ptr->getType(),
+Ptr->getName() + ".aligned");
+  return PtrAsInt;
+}
+
 /// Emit va_arg for a platform using the common void* representation,
 /// where arguments are simply emitted in an array of slots on the stack.
 ///
@@ -193,17 +210,10 @@
   // If the CC aligns values higher than the slot size, do so if needed.
   Address Addr = Address::invalid();
   if (AllowHigherAlign && DirectAlign > SlotSize) {
-llvm::Value *PtrAsInt = Ptr;
-PtrAsInt = CGF.Builder.CreatePtrToInt(PtrAsInt, CGF.IntPtrTy);
-PtrAsInt = CGF.Builder.CreateAdd(PtrAsInt,
-  llvm::ConstantInt::get(CGF.IntPtrTy, DirectAlign.getQuantity() - 1));
-PtrAsInt = CGF.Builder.CreateAnd(PtrAsInt,
- llvm::ConstantInt::get(CGF.IntPtrTy, -DirectAlign.getQuantity()));
-Addr = Address(CGF.Builder.CreateIntToPtr(PtrAsInt, Ptr->getType(),
-  "argp.cur.aligned"),
-   DirectAlign);
+Addr = Address(emitRoundPointerUpToAlignment(CGF, Ptr, DirectAlign),
+ DirectAlign);
   } else {
-Addr = Address(Ptr, SlotSize);
+Addr = Address(Ptr, SlotSize); 
   }
 
   // Advance the pointer past the argument, then store that back.
@@ -3072,19 +3082,10 @@
   // byte boundary if alignment needed by type exceeds 8 byte boundary.
   // It isn't stated explicitly in the standard, but in practice we use
   // alignment greater than 16 where necessary.
-  uint64_t Align = CGF.getContext().getTypeAlignInChars(Ty).getQuantity();
-  if (Align > 8) {
-// overflow_arg_area = (overflow_arg_area + align - 1) & -align;
-llvm::Value *Offset =
-  llvm::ConstantInt::get(CGF.Int64Ty, Align - 1);
-overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset);
-llvm::Value *AsInt = CGF.Builder.CreatePtrToInt(overflow_arg_area,
-CGF.I

Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.

2015-12-02 Thread Kelvin Li via cfe-commits
kkwli0 added inline comments.


Comment at: include/clang/AST/OpenMPClause.h:708
@@ -707,3 +707,3 @@
 public:
-  /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
-  /// expression \a ChunkSize.
+  /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk
+  /// size expression \a ChunkSize.

Is it 'schedule'?


Comment at: include/clang/AST/OpenMPClause.h:835
@@ +834,3 @@
+public:
+  /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size
+  /// expression \a ChunkSize.

'dist_schedule'


Comment at: lib/Parse/ParseOpenMP.cpp:670
@@ -666,1 +669,3 @@
   DelimLoc = ConsumeAnyToken();
+  } else if (Kind == OMPC_dist_schedule) {
+Arg = getOpenMPSimpleClauseType(

Can we merge it with the OMPC_schedule block?  The code is similar.


Comment at: lib/Sema/SemaOpenMP.cpp:5780
@@ +5779,3 @@
+  if (ChunkSize) {
+if (!ChunkSize->isValueDependent() && !ChunkSize->isTypeDependent() &&
+!ChunkSize->isInstantiationDependent() &&

Is the IsNotNegativeIntegerValue useful in this case?


Comment at: tools/libclang/CIndex.cpp:4489
@@ -4477,1 +4488,3 @@
+  case CXCursor_OMPDistributeDirective:
+return cxstring::createRef("OMPForDirective");
   case CXCursor_OverloadCandidate:

"OMPDistributeDirective"


Repository:
  rL LLVM

http://reviews.llvm.org/D15125



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


[PATCH] D15149: Traverse the nested name specifier (loc) of namespace alias declarations.

2015-12-02 Thread Daniel Jasper via cfe-commits
djasper created this revision.
djasper added a reviewer: klimek.
djasper added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

http://reviews.llvm.org/D15149

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4487,6 +4487,8 @@
   nestedNameSpecifier()));
   EXPECT_TRUE(matches("struct A { void f(); }; void A::f() {}",
   nestedNameSpecifier()));
+  EXPECT_TRUE(matches("namespace a { namespace b {} } namespace ab = a::b;",
+  nestedNameSpecifier()));
 
   EXPECT_TRUE(matches(
 "struct A { static void f() {} }; void g() { A::f(); }",
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -1324,6 +1324,8 @@
 DEF_TRAVERSE_DECL(ExternCContextDecl, {})
 
 DEF_TRAVERSE_DECL(NamespaceAliasDecl, {
+  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
+
   // We shouldn't traverse an aliased namespace, since it will be
   // defined (and, therefore, traversed) somewhere else.
   //


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4487,6 +4487,8 @@
   nestedNameSpecifier()));
   EXPECT_TRUE(matches("struct A { void f(); }; void A::f() {}",
   nestedNameSpecifier()));
+  EXPECT_TRUE(matches("namespace a { namespace b {} } namespace ab = a::b;",
+  nestedNameSpecifier()));
 
   EXPECT_TRUE(matches(
 "struct A { static void f() {} }; void g() { A::f(); }",
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -1324,6 +1324,8 @@
 DEF_TRAVERSE_DECL(ExternCContextDecl, {})
 
 DEF_TRAVERSE_DECL(NamespaceAliasDecl, {
+  TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
+
   // We shouldn't traverse an aliased namespace, since it will be
   // defined (and, therefore, traversed) somewhere else.
   //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15149: Traverse the nested name specifier (loc) of namespace alias declarations.

2015-12-02 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D15149



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


Re: [PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2015-12-02 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

This CL doesn't changes anything for ms_struct cases and ms_struct seems to be 
broken for bit-fields even for very simple cases so filed separate bug 
https://llvm.org/bugs/show_bug.cgi?id=25707

PTAL



Comment at: lib/AST/RecordLayoutBuilder.cpp:1606
@@ -1605,1 +1605,3 @@
+} else if (ExplicitFieldAlign)
+  FieldOffset = llvm::RoundUpToAlignment(FieldOffset, ExplicitFieldAlign);
 

rjmccall wrote:
> It does still seem to be limited by platforms that ignore natural alignment, 
> though, and by #pragma pack (2) and so on, so at least some of the 
> modifications made to FieldAlign need to be reflected in ExplicitFieldAlign.
> 
> I had to spend some time trying to work out counter-examples, but I did 
> convince myself that the effect of the fallback here is correct.  My concern 
> was that there was a way we might round up to FieldAlign when we only needed 
> to round up to ExplicitFieldAlign, which could matter if there were another 
> properly-aligned position within the current storage unit.  However, the 
> second clause of the first condition will only trigger at the very end of a 
> storage unit, which means that there cannot be any other properly-aligned 
> positions within it.
> 
> It might be wrong for zero-width bit-fields, though, since we'll always round 
> up to FieldAlign instead of ExplicitFieldAlign.
I think compiler can ignore natural type alignment here because it is bit-field 
and therefore compiler has to generate shift/mask sequence for accessing 
unaligned field anyway. I tried examples like:

struct __attribute__((packed)) B {
  char AField;
  __attribute__((aligned(1))) __int128 i : 124;
  char BField;
};

Both GCC and Clang with my patch generates the same result on x86 and ARM:
sizeof(struct B) = 18
offsetof(struct B, BField) = 17
__alignof(struct B) = 1

Also tried zero-width bit-filed, my patch works fine. So I was not able to find 
arch that requires round up for ExplicitFieldAlign and what is required. All 
examples that I can think of work identical on GCC and Clang.


http://reviews.llvm.org/D14980



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


Re: [PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

2015-12-02 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 41611.
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.

Fixed logic for warning calculation and added even more test-cases.


http://reviews.llvm.org/D14980

Files:
  lib/AST/RecordLayoutBuilder.cpp
  test/Sema/bitfield-layout.c

Index: test/Sema/bitfield-layout.c
===
--- test/Sema/bitfield-layout.c
+++ test/Sema/bitfield-layout.c
@@ -1,41 +1,73 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64
 // expected-no-diagnostics
+#include 
 
-#define CHECK_SIZE(kind, name, size) extern int name##1[sizeof(kind name) == size ? 1 : -1];
-#define CHECK_ALIGN(kind, name, size) extern int name##2[__alignof(kind name) == size ? 1 : -1];
+#define CHECK_SIZE(kind, name, size) \
+  extern int name##_1[sizeof(kind name) == size ? 1 : -1];
+#define CHECK_ALIGN(kind, name, size) \
+  extern int name##_2[__alignof(kind name) == size ? 1 : -1];
+#define CHECK_OFFSET(kind, name, member, offset) \
+  extern int name##_3[offsetof(kind name, member) == offset ? 1 : -1];
 
 // Zero-width bit-fields
 struct a {char x; int : 0; char y;};
+#if defined(__arm__) || defined(__aarch64__)
+CHECK_SIZE(struct, a, 8)
+CHECK_ALIGN(struct, a, 4)
+#else
 CHECK_SIZE(struct, a, 5)
 CHECK_ALIGN(struct, a, 1)
+#endif
 
 // Zero-width bit-fields with packed
 struct __attribute__((packed)) a2 { short x : 9; char : 0; int y : 17; };
 CHECK_SIZE(struct, a2, 5)
 CHECK_ALIGN(struct, a2, 1)
 
 // Zero-width bit-fields at the end of packed struct
 struct __attribute__((packed)) a3 { short x : 9; int : 0; };
+#if defined(__arm__) || defined(__aarch64__)
+CHECK_SIZE(struct, a3, 4)
+CHECK_ALIGN(struct, a3, 4)
+#else
 CHECK_SIZE(struct, a3, 4)
 CHECK_ALIGN(struct, a3, 1)
+#endif
 
 // For comparison, non-zero-width bit-fields at the end of packed struct
 struct __attribute__((packed)) a4 { short x : 9; int : 1; };
 CHECK_SIZE(struct, a4, 2)
 CHECK_ALIGN(struct, a4, 1)
 
 union b {char x; int : 0; char y;};
+#if defined(__arm__) || defined(__aarch64__)
+CHECK_SIZE(union, b, 4)
+CHECK_ALIGN(union, b, 4)
+#else
 CHECK_SIZE(union, b, 1)
 CHECK_ALIGN(union, b, 1)
+#endif
 
 // Unnamed bit-field align
 struct c {char x; int : 20;};
+#if defined(__arm__) || defined(__aarch64__)
+CHECK_SIZE(struct, c, 4)
+CHECK_ALIGN(struct, c, 4)
+#else
 CHECK_SIZE(struct, c, 4)
 CHECK_ALIGN(struct, c, 1)
+#endif
 
 union d {char x; int : 20;};
+#if defined(__arm__) || defined(__aarch64__)
+CHECK_SIZE(union, d, 4)
+CHECK_ALIGN(union, d, 4)
+#else
 CHECK_SIZE(union, d, 3)
 CHECK_ALIGN(union, d, 1)
+#endif
 
 // Bit-field packing
 struct __attribute__((packed)) e {int x : 4, y : 30, z : 30;};
@@ -56,3 +88,153 @@
 CHECK_SIZE(struct, s0, 0x3218)
 CHECK_ALIGN(struct, s0, 4)
 
+// Bit-field with explicit align bigger than normal.
+struct g0 {
+  char a;
+  __attribute__((aligned(16))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g0, 32);
+CHECK_ALIGN(struct, g0, 16);
+CHECK_OFFSET(struct, g0, c, 17);
+
+// Bit-field with explicit align smaller than normal.
+struct g1 {
+  char a;
+  __attribute__((aligned(2))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g1, 4);
+CHECK_ALIGN(struct, g1, 4);
+CHECK_OFFSET(struct, g1, c, 3);
+
+// Same as above but without explicit align.
+struct g2 {
+  char a;
+  int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g2, 4);
+CHECK_ALIGN(struct, g2, 4);
+CHECK_OFFSET(struct, g2, c, 2);
+
+// Explicit attribute align on bit-field has precedence over packed attribute
+// applied too the struct.
+struct __attribute__((packed)) g3 {
+  char a;
+  __attribute__((aligned(16))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g3, 32);
+CHECK_ALIGN(struct, g3, 16);
+CHECK_OFFSET(struct, g3, c, 17);
+
+struct __attribute__((packed)) g4 {
+  char a;
+  __attribute__((aligned(2))) int b : 1;
+  char c;
+};
+
+CHECK_SIZE(struct, g4, 4);
+CHECK_ALIGN(struct, g4, 2);
+CHECK_OFFSET(struct, g4, c, 3);
+
+struct g5 {
+  char : 1;
+  __attribute__((aligned(1))) int n : 24;
+};
+CHECK_SIZE(struct, g5, 4);
+CHECK_ALIGN(struct, g5, 4);
+
+struct __attribute__((packed)) g6 {
+  char : 1;
+  __attribute__((aligned(1))) int n : 24;
+};
+CHECK_SIZE(struct, g6, 4);
+CHECK_ALIGN(struct, g6, 1);
+
+struct g7 {
+  char : 1;
+  __attribute__((aligned(1))) int n : 25;
+};
+CHECK_SIZE(struct, g7, 8);
+CHECK_ALIGN(struct, g7, 4);
+
+struct __attribute__((packed)) g8 {
+  char : 1;
+  __attribute__((aligned(1))) int n : 25;
+};
+CHECK_SIZE(struct, g8, 5);
+CHECK_ALIGN(struct, g8, 1);
+
+struct g9 {
+  __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
+  int i;
+};
+CHECK_SIZE(struct, g9, 12);
+CHECK_ALIGN(struct, g9, 4);
+
+struct __attribute__((packed)) g10 {
+  __attribute__((aligned(1))) char a : 2, b : 2, c : 2, d : 2, e : 2;
+  int i;
+};
+CHECK_SIZE(struct, g10, 9);
+CHECK_ALIGN(struct,

Re: [PATCH] D15147: [clang-format] Reflow block comments when they're over the column limit

2015-12-02 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/BreakableToken.cpp:443
@@ -439,2 +442,3 @@
   }
 
+  const StringRef Line = Lines[LineIndex];

For posterity, from in-person chat:
Currently, this does the same as before when we're in DryRun mode, and only 
wraps when we apply the changes. Instead, we'll need to make this work with the 
DryRun mode for optimization.


http://reviews.llvm.org/D15147



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


[PATCH] D15147: [clang-format] Reflow block comments when they're over the column limit

2015-12-02 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added reviewers: djasper, klimek.
bkramer added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

/*  a
 * a*/

Now becomes

/* 
 * a a*/

instead of

/* 
 * a
 * a*/

This is implemented by glueing the next line on while fixing whitespace
and adding another break if that brings us over the column limit again.
We also have heuristics to avoid making existing comments worse:
  1. Only reflow when the existing comment is already over the column limit
  2. Don't reflow when there's an empty line (to avoid breaking paragraphs)
  3. Don't reflow when there's a non-alphanumeric char at the beginning of
 the next line. This is a weak attempt to avoid mangling ASCII art.

I intend to do the same thing for line comments, but that will require
changes to other parts of clang-format first.

http://reviews.llvm.org/D15147

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1568,8 +1568,8 @@
 " *   a comment\n"
 "* that we break\n"
 " * another comment\n"
-"* we have to break\n"
-"* a left comment\n"
+"* we have to break a\n"
+"* left comment\n"
 " */",
 format("  /* some comment\n"
"   *   a comment that we break\n"
@@ -1647,6 +1647,57 @@
getLLVMStyleWithColumns(20)));
 }
 
+TEST_F(FormatTest, ReflowsBlockComments) {
+  EXPECT_EQ("/*\n"
+" *  \n"
+" * \n"
+" */",
+format("/*\n"
+   " *  \n"
+   " * \n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+
+  EXPECT_EQ("/*\n"
+" * a\n"
+" * \n"
+" *\n"
+" * \n"
+" */",
+format("/*\n"
+   " * a \n"
+   " *\n"
+   " * \n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+
+  EXPECT_EQ("/*\n"
+" * a\n"
+" * \n"
+" * |--|\n"
+" * \n"
+" */",
+format("/*\n"
+   " * a \n"
+   " * |--|\n"
+   " * \n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+
+  EXPECT_EQ("/*\n"
+" * a\n"
+" *  \n"
+" * a\n"
+" * \n"
+" */",
+format("/*\n"
+   " * a \n"
+   " *  a\n"
+   " * \n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+}
+
 TEST_F(FormatTest, CommentsInStaticInitializers) {
   EXPECT_EQ(
   "static SomeType type = {, /* comment */\n"
Index: lib/Format/BreakableToken.h
===
--- lib/Format/BreakableToken.h
+++ lib/Format/BreakableToken.h
@@ -204,6 +204,10 @@
   // present) is also not considered part of the text.
   SmallVector Lines;
 
+  // For each line in a block comment this stores how many characters overflowed
+  // into the next line if it was wrapped. Otherwise the value is 0.
+  SmallVector WrappedLines;
+
   // LeadingWhitespace[i] is the number of characters regarded as whitespace in
   // front of Lines[i]. Note that this can include "* " sequences, which we
   // regard as whitespace when all lines have a "*" prefix.
Index: lib/Format/BreakableToken.cpp
===
--- lib/Format/BreakableToken.cpp
+++ lib/Format/BreakableToken.cpp
@@ -259,6 +259,7 @@
   TokenText.substr(2, TokenText.size() - 4).split(Lines, "\n");
 
   int IndentDelta = StartColumn - OriginalStartColumn;
+  WrappedLines.resize(Lines.size());
   LeadingWhitespace.resize(Lines.size());
   StartOfLineColumn.resize(Lines.size());
   StartOfLineColumn[0] = StartColumn + 2;
@@ -400,6 +401,8 @@
   Whitespaces.replaceWhitespaceInToken(
   Tok, BreakOffsetInToken, CharsToRemove, "", Prefix, InPPDirective, 1,
   IndentLevel, IndentAtLineBreak - Decoration.size());
+
+  WrappedLines[LineIndex] = Lines[LineIndex].size() - Split.first;
 }
 
 void BreakableBlockComment::replaceWhitespace(unsigned LineIndex,
@@ -438,13 +441,49 @@
 }
   }
 
-  unsigned WhitespaceOffsetInToken = Lines[LineIndex].data() -
- Tok.TokenText.data() -
- LeadingWhitespace[LineIndex];
+  const StringRef Li

r254505 - Teaches clang about Cortex-A35.

2015-12-02 Thread Christof Douma via cfe-commits
Author: christof
Date: Wed Dec  2 06:03:42 2015
New Revision: 254505

URL: http://llvm.org/viewvc/llvm-project?rev=254505&view=rev
Log:
Teaches clang about Cortex-A35.

Adds support for the new Cortex-A35 ARMv8-A core.

Differential Revision: http://reviews.llvm.org/D15142

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/CodeGen/arm-target-features.c
cfe/trunk/test/Driver/aarch64-cpus.c
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=254505&r1=254504&r2=254505&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Dec  2 06:03:42 2015
@@ -5311,7 +5311,7 @@ public:
   bool setCPU(const std::string &Name) override {
 bool CPUKnown = llvm::StringSwitch(Name)
 .Case("generic", true)
-.Cases("cortex-a53", "cortex-a57", "cortex-a72", true)
+.Cases("cortex-a53", "cortex-a57", "cortex-a72", 
"cortex-a35", true)
 .Case("cyclone", true)
 .Default(false);
 return CPUKnown;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=254505&r1=254504&r2=254505&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec  2 06:03:42 2015
@@ -2057,7 +2057,7 @@ static bool DecodeAArch64Mcpu(const Driv
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
   if (CPU == "cyclone" || CPU == "cortex-a53" || CPU == "cortex-a57" ||
-  CPU == "cortex-a72") {
+  CPU == "cortex-a72" || CPU == "cortex-a35") {
 Features.push_back("+neon");
 Features.push_back("+crc");
 Features.push_back("+crypto");

Modified: cfe/trunk/test/CodeGen/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-target-features.c?rev=254505&r1=254504&r2=254505&view=diff
==
--- cfe/trunk/test/CodeGen/arm-target-features.c (original)
+++ cfe/trunk/test/CodeGen/arm-target-features.c Wed Dec  2 06:03:42 2015
@@ -22,6 +22,7 @@
 
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a35 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8

Modified: cfe/trunk/test/Driver/aarch64-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=254505&r1=254504&r2=254505&view=diff
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (original)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Wed Dec  2 06:03:42 2015
@@ -18,6 +18,21 @@
 // RUN: %clang -target arm64-apple-darwin -arch arm64 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-DARWIN %s
 // ARM64-DARWIN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cyclone"
 
+// RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
+// RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
+// RUN: %clang -target aarch64 -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
+// CA35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a35"
+
+// RUN: %clang -target arm64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-CA35 %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-CA35 %s
+// RUN: %clang -target arm64 -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-CA35 %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 
| FileCheck -check-prefix=ARM64-CA35 %s
+// ARM64-CA35: "-cc1"{{.*}} "-

Re: [PATCH] D15142: Teaches clang about Cortex-A35.

2015-12-02 Thread Christof Douma via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254505: Teaches clang about Cortex-A35. (authored by 
christof).

Changed prior to commit:
  http://reviews.llvm.org/D15142?vs=41600&id=41609#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15142

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/CodeGen/arm-target-features.c
  cfe/trunk/test/Driver/aarch64-cpus.c
  cfe/trunk/test/Driver/arm-cortex-cpus.c
  cfe/trunk/test/Preprocessor/aarch64-target-features.c

Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -88,10 +88,12 @@
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"
 
 // RUN: %clang -target aarch64 -mcpu=cyclone -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-CYCLONE %s
+// RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A35 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A53 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A57 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A72 %s
 // CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
Index: cfe/trunk/test/CodeGen/arm-target-features.c
===
--- cfe/trunk/test/CodeGen/arm-target-features.c
+++ cfe/trunk/test/CodeGen/arm-target-features.c
@@ -22,6 +22,7 @@
 
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a35 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -394,33 +394,41 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=cortex-r7 -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV7R-THUMB %s
 // CHECK-BE-CPUV7R-THUMB: "-cc1"{{.*}} "-triple" "thumbebv7r-{{.*}}
 
+// RUN: %clang -target arm -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
+// RUN: %clang -target arm -mcpu=cortex-a35 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a53 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a57 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // RUN: %clang -target arm -mcpu=cortex-a72 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8A %s
 // CHECK-CPUV8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}
 
+// RUN: %clang -target armeb -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a57 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
 // RUN: %clang -target armeb -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-CPUV8A %s
+//

[PATCH] D15145: Add expressions to ignore vim swap files in .gitinore.

2015-12-02 Thread Vasileios Kalintiris via cfe-commits
vkalintiris created this revision.
vkalintiris added a subscriber: cfe-commits.

http://reviews.llvm.org/D15145

Files:
  .gitignore

Index: .gitignore
===
--- .gitignore
+++ .gitignore
@@ -52,3 +52,7 @@
 
 # PyBuilder
 target/
+
+# vim swap files
+.*.sw?
+.sw?


Index: .gitignore
===
--- .gitignore
+++ .gitignore
@@ -52,3 +52,7 @@
 
 # PyBuilder
 target/
+
+# vim swap files
+.*.sw?
+.sw?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15142: Teaches clang about Cortex-A35.

2015-12-02 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a reviewer: rengolin.
rengolin added a comment.
This revision is now accepted and ready to land.

Isn't it time we move AArch64 to the target parser, too?

Anyway, as it is, LGTM, for the time being. Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D15142



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


Re: [PATCH] D15130: Fix the clang driver when "-nostdlib" is present

2015-12-02 Thread Vasileios Kalintiris via cfe-commits
vkalintiris accepted this revision.
vkalintiris added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you for working on this.


http://reviews.llvm.org/D15130



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


Re: [PATCH] D14872: PR25575: Make GCC 4.4+ comatible layout for packed bit-fileds of char type

2015-12-02 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 41597.
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.

Warning text updated, PTAL.


http://reviews.llvm.org/D14872

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/struct-packed-align.c

Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 
 // Packed structs.
 struct s {
@@ -138,3 +138,24 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{'packed' attribute was ignored on bit-fields with 
alignment 1 in older versions of GCC and Clang}}
+  char c:4;
+};
+
+#if defined(_WIN32)
+// On Windows clang ignores uses MSVC compatible layout in this case.
+extern int o1[sizeof(struct packed_chars) == 3 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#else
+extern int o1[sizeof(struct packed_chars) == 2 ? 1 : -1];
+extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
+#endif
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1036,17 +1036,14 @@
 TD->addAttr(::new (S.Context) PackedAttr(Attr.getRange(), S.Context,
 Attr.getAttributeSpellingListIndex()));
   else if (FieldDecl *FD = dyn_cast(D)) {
-// If the alignment is less than or equal to 8 bits, the packed attribute
-// has no effect.
+// Report warning about changed offset in the newer compiler versions.
 if (!FD->getType()->isDependentType() &&
-!FD->getType()->isIncompleteType() &&
+!FD->getType()->isIncompleteType() && FD->isBitField() &&
 S.Context.getTypeAlign(FD->getType()) <= 8)
-  S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
-<< Attr.getName() << FD->getType();
-else
-  FD->addAttr(::new (S.Context)
-  PackedAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
+  S.Diag(Attr.getLoc(), diag::warn_attribute_packed_for_bitfield);
+
+FD->addAttr(::new (S.Context) PackedAttr(
+Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
   } else
 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2784,9 +2784,10 @@
   "cast to %1 from smaller integer type %0">,
   InGroup;
 
-def warn_attribute_ignored_for_field_of_type : Warning<
-  "%0 attribute ignored for field of type %1">,
-  InGroup;
+def warn_attribute_packed_for_bitfield : Warning<
+  "'packed' attribute was ignored on bit-fields with alignment 1 "
+  "in older versions of GCC and Clang">,
+  InGroup>;
 def warn_transparent_union_attribute_field_size_align : Warning<
   "%select{alignment|size}0 of field %1 (%2 bits) does not match the "
   "%select{alignment|size}0 of the first field in transparent union; "


Index: test/Sema/struct-packed-align.c
===
--- test/Sema/struct-packed-align.c
+++ test/Sema/struct-packed-align.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// expected-no-diagnostics
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 
 // Packed structs.
 struct s {
@@ -138,3 +138,24 @@
 extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
 extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 #endif
+
+// Packed attribute shouldn't be ignored for bit-field of char types.
+// Note from GCC reference manual: The 4.1, 4.2 and 4.3 series of GCC ignore
+// the packed attribute on bit-fields of type char. This has been fixed in
+// GCC 4.4 but the change can lead to differences in the structure layout.
+// See the documentation of -Wpacked-bitfield-compat for more information.
+struct packed_chars {
+  char a:4;
+  char b:8 __attribute__ ((packed));
+  // expected-warning@-1 {{'packed' attribute was ignored on bit-fields with alignment 1 in older versions of GCC and