Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-04 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

If we want to save some space, could we use some macro to expand the gentype or 
some script to expand the gentype into each types when the clang is build?


http://reviews.llvm.org/D18369



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


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-04 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

Could we output a generic function in CodeGen?
This seems to have no big difference to have a lot of declaration in an opencl 
c header file.


http://reviews.llvm.org/D19932



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Nick Lewycky via cfe-commits
nicholas updated this revision to Diff 56236.
nicholas added a comment.

(Whoops, forgot to generate diff with full context for phab.)


http://reviews.llvm.org/D19851

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  test/Parser/cxx-casting.cpp
  test/SemaCXX/cstyle-cast.cpp
  test/SemaCXX/functional-cast.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/static-cast.cpp

Index: test/SemaCXX/static-cast.cpp
===
--- test/SemaCXX/static-cast.cpp
+++ test/SemaCXX/static-cast.cpp
@@ -43,11 +43,11 @@
   (void)static_cast((int*)0);
   (void)static_cast((const int*)0);
   (void)static_cast((B*)0);
-  (void)static_cast(*((B*)0));
+  (void)static_cast(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((C1*)0);
-  (void)static_cast(*((C1*)0));
+  (void)static_cast(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((D*)0);
-  (void)static_cast(*((D*)0));
+  (void)static_cast(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((int A::*)0);
   (void)static_cast((void (A::*)())0);
 
Index: test/SemaCXX/new-delete.cpp
===
--- test/SemaCXX/new-delete.cpp
+++ test/SemaCXX/new-delete.cpp
@@ -444,11 +444,11 @@
 
   template
   void tfn() {
-new (*(PlacementArg*)0) T[1];
+new (*(PlacementArg*)0) T[1]; // expected-warning 2 {{binding null pointer to reference has undefined behavior}}
   }
 
   void fn() {
-tfn();
+tfn();  // expected-note {{in instantiation of function template specialization 'r150682::tfn' requested here}}
   }
 
 }
Index: test/SemaCXX/functional-cast.cpp
===
--- test/SemaCXX/functional-cast.cpp
+++ test/SemaCXX/functional-cast.cpp
@@ -126,14 +126,14 @@
   typedef A *Ap;
   (void)Ap((B*)0);
   typedef A 
-  (void)Ar(*((B*)0));
+  (void)Ar(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef const B *cBp;
   (void)cBp((C1*)0);
   typedef B 
-  (void)Br(*((C1*)0));
+  (void)Br(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)Ap((D*)0);
   typedef const A 
-  (void)cAr(*((D*)0));
+  (void)cAr(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef int B::*Bmp;
   (void)Bmp((int A::*)0);
   typedef void (B::*Bmfp)();
Index: test/SemaCXX/cstyle-cast.cpp
===
--- test/SemaCXX/cstyle-cast.cpp
+++ test/SemaCXX/cstyle-cast.cpp
@@ -84,11 +84,11 @@
   (void)(void*)((int*)0);
   (void)(volatile const void*)((const int*)0);
   (void)(A*)((B*)0);
-  (void)(A&)(*((B*)0));
+  (void)(A&)(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(const B*)((C1*)0);
-  (void)(B&)(*((C1*)0));
+  (void)(B&)(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(A*)((D*)0);
-  (void)(const A&)(*((D*)0));
+  (void)(const A&)(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(int B::*)((int A::*)0);
   (void)(void (B::*)())((void (A::*)())0);
   (void)(A*)((E*)0); // C-style cast ignores access control
Index: test/Parser/cxx-casting.cpp
===
--- test/Parser/cxx-casting.cpp
+++ test/Parser/cxx-casting.cpp
@@ -37,7 +37,7 @@
 // This was being incorrectly tentatively parsed.
 namespace test1 {
   template  class A {}; // expected-note 2{{here}}
-  void foo() { A(*(A*)0); }
+  void foo() { A(*(A*)0); } // expected-warning {{binding null pointer to reference has undefined behavior}}
 }
 
 typedef char* c;
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -11,7 +11,7 @@
 
 template
 struct bogus_override_if_virtual : public T {
-  bogus_override_if_virtual() : T(*(T*)0) { }
+  bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding null pointer to reference has undefined behavior}}
   int operator()() const;
 };
 
@@ -36,7 +36,7 @@
   lv(); // expected-error{{no matching function for call to object of type}}
   mlv(); // expected-error{{no matching function for call to object of type}}
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }
 
 // Core issue 974: default arguments (8.3.6) may be specified 

Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Nick Lewycky via cfe-commits
nicholas updated this revision to Diff 56235.
nicholas marked an inline comment as done.

http://reviews.llvm.org/D19851

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
  test/Parser/cxx-casting.cpp
  test/SemaCXX/cstyle-cast.cpp
  test/SemaCXX/functional-cast.cpp
  test/SemaCXX/new-delete.cpp
  test/SemaCXX/static-cast.cpp

Index: test/SemaCXX/static-cast.cpp
===
--- test/SemaCXX/static-cast.cpp
+++ test/SemaCXX/static-cast.cpp
@@ -43,11 +43,11 @@
   (void)static_cast((int*)0);
   (void)static_cast((const int*)0);
   (void)static_cast((B*)0);
-  (void)static_cast(*((B*)0));
+  (void)static_cast(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((C1*)0);
-  (void)static_cast(*((C1*)0));
+  (void)static_cast(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((D*)0);
-  (void)static_cast(*((D*)0));
+  (void)static_cast(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)static_cast((int A::*)0);
   (void)static_cast((void (A::*)())0);
 
Index: test/SemaCXX/new-delete.cpp
===
--- test/SemaCXX/new-delete.cpp
+++ test/SemaCXX/new-delete.cpp
@@ -444,11 +444,11 @@
 
   template
   void tfn() {
-new (*(PlacementArg*)0) T[1];
+new (*(PlacementArg*)0) T[1]; // expected-warning 2 {{binding null pointer to reference has undefined behavior}}
   }
 
   void fn() {
-tfn();
+tfn();  // expected-note {{in instantiation of function template specialization 'r150682::tfn' requested here}}
   }
 
 }
Index: test/SemaCXX/functional-cast.cpp
===
--- test/SemaCXX/functional-cast.cpp
+++ test/SemaCXX/functional-cast.cpp
@@ -126,14 +126,14 @@
   typedef A *Ap;
   (void)Ap((B*)0);
   typedef A 
-  (void)Ar(*((B*)0));
+  (void)Ar(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef const B *cBp;
   (void)cBp((C1*)0);
   typedef B 
-  (void)Br(*((C1*)0));
+  (void)Br(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)Ap((D*)0);
   typedef const A 
-  (void)cAr(*((D*)0));
+  (void)cAr(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   typedef int B::*Bmp;
   (void)Bmp((int A::*)0);
   typedef void (B::*Bmfp)();
Index: test/SemaCXX/cstyle-cast.cpp
===
--- test/SemaCXX/cstyle-cast.cpp
+++ test/SemaCXX/cstyle-cast.cpp
@@ -84,11 +84,11 @@
   (void)(void*)((int*)0);
   (void)(volatile const void*)((const int*)0);
   (void)(A*)((B*)0);
-  (void)(A&)(*((B*)0));
+  (void)(A&)(*((B*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(const B*)((C1*)0);
-  (void)(B&)(*((C1*)0));
+  (void)(B&)(*((C1*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(A*)((D*)0);
-  (void)(const A&)(*((D*)0));
+  (void)(const A&)(*((D*)0)); // expected-warning {{binding null pointer to reference has undefined behavior}}
   (void)(int B::*)((int A::*)0);
   (void)(void (B::*)())((void (A::*)())0);
   (void)(A*)((E*)0); // C-style cast ignores access control
Index: test/Parser/cxx-casting.cpp
===
--- test/Parser/cxx-casting.cpp
+++ test/Parser/cxx-casting.cpp
@@ -37,7 +37,7 @@
 // This was being incorrectly tentatively parsed.
 namespace test1 {
   template  class A {}; // expected-note 2{{here}}
-  void foo() { A(*(A*)0); }
+  void foo() { A(*(A*)0); } // expected-warning {{binding null pointer to reference has undefined behavior}}
 }
 
 typedef char* c;
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -11,7 +11,7 @@
 
 template
 struct bogus_override_if_virtual : public T {
-  bogus_override_if_virtual() : T(*(T*)0) { }
+  bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding null pointer to reference has undefined behavior}}
   int operator()() const;
 };
 
@@ -36,7 +36,7 @@
   lv(); // expected-error{{no matching function for call to object of type}}
   mlv(); // expected-error{{no matching function for call to object of type}}
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }
 
 // Core issue 974: default arguments (8.3.6) may be specified in the
Index: lib/Sema/SemaInit.cpp

Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Nick Lewycky via cfe-commits
nicholas marked 2 inline comments as done.


Comment at: lib/Sema/SemaInit.cpp:3514-3518
@@ +3513,7 @@
+static void CheckForNullPointerDereference(Sema , const Expr *E) {
+  // Check to see if we are dereferencing a null pointer.  If so,
+  // and if not volatile-qualified, this is undefined behavior that the
+  // optimizer will delete, so warn about it.  People sometimes try to use this
+  // to get a deterministic trap and are surprised by clang's behavior.  This
+  // only handles the pattern "*null", which is a very syntactic check.
+  if (const UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))

rsmith wrote:
> This comment doesn't make sense for this case. Binding a reference to a 
> dereferenced null pointer isn't something that people would expect to trap. 
> But the idea is the same: we might delete people's code and they're probably 
> not expecting that.
We don't delete it, generally we "create a null reference" which is exactly 
what some programmers expect, when they think that references are just 
syntactically different pointers.


Comment at: lib/Sema/SemaInit.cpp:3519-3522
@@ +3518,6 @@
+  // only handles the pattern "*null", which is a very syntactic check.
+  if (const UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
+if (UO->getOpcode() == UO_Deref &&
+UO->getSubExpr()->IgnoreParenCasts()->
+  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+!UO->getType().isVolatileQualified()) {

rsmith wrote:
> It seems -- borderline -- worth factoring out these four lines between here 
> and SemaExpr. Maybe `isProvablyEmptyLvalue` or similar, if you feel inclined 
> to do so?
I'll pass. Initially I thought the two CheckForNullPointerDereference functions 
might be the same but for a diag::ID argument, but they're growing more and 
more different.

As for `isProvablyEmptyLvalue` we would still need to get the UO for the 
diagnostic anyways.


http://reviews.llvm.org/D19851



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


r268600 - Documentation updates for recent changes to VLAs and default-initialization of const-qualified class objects.

2016-05-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May  4 21:53:55 2016
New Revision: 268600

URL: http://llvm.org/viewvc/llvm-project?rev=268600=rev
Log:
Documentation updates for recent changes to VLAs and default-initialization of 
const-qualified class objects.

Modified:
cfe/trunk/www/compatibility.html

Modified: cfe/trunk/www/compatibility.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/compatibility.html?rev=268600=268599=268600=diff
==
--- cfe/trunk/www/compatibility.html (original)
+++ cfe/trunk/www/compatibility.html Wed May  4 21:53:55 2016
@@ -415,19 +415,11 @@ extern int c;  // allowed
 
 GCC and C99 allow an array's size to be determined at run
 time. This extension is not permitted in standard C++. However, Clang
-supports such variable length arrays in very limited circumstances for
-compatibility with GNU C and C99 programs:
+supports such variable length arrays for compatibility with GNU C and
+C99 programs.
 
-  
-  The element type of a variable length array must be a POD
-  ("plain old data") type, which means that it cannot have any
-  user-declared constructors or destructors, any base classes, or any
-  members of non-POD type. All C types are POD types.
-
-  Variable length arrays cannot be used as the type of a non-type
-template parameter. 
-
-If your code uses variable length arrays in a manner that Clang doesn't 
support, there are several ways to fix your code:
+If you would prefer not to use this extension, you can disable it with
+-Werror=vla. There are several ways to fix your code:
 
 
 replace the variable length array with a fixed-size array if you can
@@ -566,7 +558,7 @@ lookup in templates, see [temp.dep.candi
 Unqualified lookup into dependent bases of class 
templates
 
 
-Some versions of GCC accept the following invalid code:
+Some versions of GCC accept the following invalid code:
 
 
 template typename T struct Base {
@@ -636,7 +628,7 @@ dispatch!
 Incomplete types in templates
 
 
-The following code is invalid, but compilers are allowed to accept it:
+The following code is invalid, but compilers are allowed to accept it:
 
 
   class IOOptions;
@@ -667,7 +659,7 @@ other compilers accept.
 Templates with no valid instantiations
 
 
-The following code contains a typo: the programmer
+The following code contains a typo: the programmer
 meant init() but wrote innit() instead.
 
 
@@ -714,7 +706,7 @@ simple: since the code is unused, just r
 Default initialization of const variable of a 
class type requires user-defined default constructor
 
 
-If a class or struct has no user-defined default
+If a class or struct has no user-defined default
 constructor, C++ doesn't allow you to default construct a const
 instance of it like this ([dcl.init], p9):
 
@@ -747,11 +739,15 @@ void Bar() {
 }
 
 
+An upcoming change to the C++ standard is expected to weaken this rule to only
+apply when the compiler-supplied default constructor would leave a member
+uninitialized. Clang implements the more relaxed rule in version 3.8 onwards.
+
 
 Parameter name lookup
 
 
-Due to a bug in its implementation, GCC allows the redeclaration of 
function parameter names within a function prototype in C++ code, e.g.
+Some versions of GCC allow the redeclaration of function parameter names 
within a function prototype in C++ code, e.g.
 
 
 void f(int a, int a);


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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

majnemer wrote:
> rnk wrote:
> > majnemer wrote:
> > > andreybokhanko wrote:
> > > > majnemer wrote:
> > > > > andreybokhanko wrote:
> > > > > > Done. Test added.
> > > > > Hmm, can you give a concrete example why we need this line?
> > > > Sure. An example is:
> > > > 
> > > > __unaligned int unaligned_foo3() { return 0; }
> > > > 
> > > > MS mangles it as
> > > > 
> > > > ?unaligned_foo3@@YAHXZ
> > > > 
> > > > However, if __unaligned is taken into account, "if ((!IsPointer && 
> > > > Quals) || isa(T))" computes to true and clang adds "?A", 
> > > > resulting to
> > > > 
> > > > ?unaligned_foo3@@YA?AHXZ
> > > > 
> > > > Yours,
> > > > Andrey
> > > > 
> > > Wait, I thought __unaligned can only apply to pointer types.  Is this not 
> > > so?!
> > > Does `__unaligned int x;` really keep it's `__unaligned` qualifier?
> > Yeah it does:
> >   $ cat t.cpp
> >   __unaligned int x;
> >   $ cl -nologo -c t.cpp && dumpbin /symbols t.obj  | grep ?x
> >   t.cpp
> >   008  SECT3  notype   External | ?x@@3HFA (int __unaligned 
> > x)
> Woah.  So if you do:
> 
> > __unaligned int unaligned_foo3() { return 0; }
> > auto z = foo3();
> 
> How is `z` mangled?
`z` is mangled without the qualifiers.  In fact:

```
__unaligned int unaligned_foo3() { return 0; }
__unaligned int z;
auto z = unaligned_foo3();
```

Is an error:


> x.cpp(3): error C2373: 'z': redefinition; different type modifiers
> x.cpp(2): note: see declaration of 'z'

Do we have comparable behavior?


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 Thread Richard Smith via cfe-commits
rsmith added a comment.

In http://reviews.llvm.org/D19851#420762, @nicholas wrote:

> I did not expand this to SK_BindReferenceToTemporary, please review this 
> decision. It's also missing missing bit-field and vector element checks that 
> SK_BindReference has.


That's fine. SK_BindReferenceToTemporary can never bind to a dereferenced null 
pointer.



Comment at: lib/Sema/SemaInit.cpp:3514-3518
@@ +3513,7 @@
+static void CheckForNullPointerDereference(Sema , const Expr *E) {
+  // Check to see if we are dereferencing a null pointer.  If so,
+  // and if not volatile-qualified, this is undefined behavior that the
+  // optimizer will delete, so warn about it.  People sometimes try to use this
+  // to get a deterministic trap and are surprised by clang's behavior.  This
+  // only handles the pattern "*null", which is a very syntactic check.
+  if (const UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))

This comment doesn't make sense for this case. Binding a reference to a 
dereferenced null pointer isn't something that people would expect to trap. But 
the idea is the same: we might delete people's code and they're probably not 
expecting that.


Comment at: lib/Sema/SemaInit.cpp:3519-3522
@@ +3518,6 @@
+  // only handles the pattern "*null", which is a very syntactic check.
+  if (const UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
+if (UO->getOpcode() == UO_Deref &&
+UO->getSubExpr()->IgnoreParenCasts()->
+  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+!UO->getType().isVolatileQualified()) {

It seems -- borderline -- worth factoring out these four lines between here and 
SemaExpr. Maybe `isProvablyEmptyLvalue` or similar, if you feel inclined to do 
so?


Comment at: lib/Sema/SemaInit.cpp:3523
@@ +3522,3 @@
+  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+!UO->getType().isVolatileQualified()) {
+S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,

I don't think we need to, or should, care whether the type is 
volatile-qualified here. The reference binding has undefined behavior either 
way. In SemaExpr we had this check because we wanted to warn people that we 
were going to delete their code, which we didn't do in the volatile case, but 
in this case we may delete the code even if it's a reference-to-volatile.


http://reviews.llvm.org/D19851



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


Re: [PATCH] D19769: [clang-tidy] Add explicitly given array size heuristic to misc-suspicious-missing-comma check.

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb requested changes to this revision.
etienneb added a comment.
This revision now requires changes to proceed.

If the 'original' size is available, the checkers should by-pass the heuristic.
Can you check if there is a way to get the original size.



Comment at: clang-tidy/misc/SuspiciousMissingCommaCheck.cpp:106
@@ +105,3 @@
+  if (InitializerList->hasArrayFiller()) {
+  diag(InitializerList->getExprLoc(),
+   "wrong string array initialization: "

szdominik wrote:
> etienneb wrote:
> > The error should still be reported to the missing comma (concatenated 
> > token):
> >   ConcatenatedLiteral->getLocStart(),
> > 
> > We could add a NOTE to point to the array, stating that the size mismatch.
> > 
> > What do you think?
> Interesting question (the first idea was that we can't decide that the comma 
> is missing or the size is wrong, so report to the array, that's a more secure 
> solution), but I agree that the note could be more effective.
> And... it's still a suspicious-missing-comma checker, not a 
> wrong-string-array-size checker :)
How can you be sure the size was provided by the user? And not inferred by the 
type system?

For the following examples:
```
const char* listA[] = {"a", "b" };
const char* listB[5] = {"a", "b" };
```

We've got this:
```
VarDecl 0x5e9d840  col:13 
listA 'const char *[2]' cinit
`-InitListExpr 0x5e9d950  'const char *[2]'
  |-ImplicitCastExpr 0x5e9d978  'const char *' 
  | `-StringLiteral 0x5e9d8d8  'const char [2]' lvalue "a"
  `-ImplicitCastExpr 0x5e9d988  'const char *' 
`-StringLiteral 0x5e9d8fc  'const char [2]' lvalue "b"
```

```
VarDecl 0x5e9d840  col:13 
listA 'const char *[2]' cinit
`-InitListExpr 0x5e9d950  'const char *[2]'
  |-ImplicitCastExpr 0x5e9d978  'const char *' 
  | `-StringLiteral 0x5e9d8d8  'const char [2]' lvalue "a"
  `-ImplicitCastExpr 0x5e9d988  'const char *' 
`-StringLiteral 0x5e9d8fc  'const char [2]' lvalue "b"
```

How can I tell the "size" was written by the user?
How can you get the "5" and not the "2".



http://reviews.llvm.org/D19769



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


r268595 - Update FIXME.

2016-05-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May  4 21:14:06 2016
New Revision: 268595

URL: http://llvm.org/viewvc/llvm-project?rev=268595=rev
Log:
Update FIXME.

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

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=268595=268594=268595=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed May  4 21:14:06 2016
@@ -4960,8 +4960,6 @@ void Sema::diagnoseMissingImport(SourceL
   if (!Def)
 Def = Decl;
 
-  // FIXME: Add a Fix-It that imports the corresponding module or includes
-  // the header.
   Module *Owner = getOwningModule(Decl);
   assert(Owner && "definition of hidden declaration is not in a module");
 
@@ -5015,6 +5013,7 @@ void Sema::diagnoseMissingImport(SourceL
   << (int)MIK << Decl << Modules[0]->getFullModuleName()
   << getIncludeStringForHeader(PP, E);
   } else {
+// FIXME: Add a FixItHint that imports the corresponding module.
 Diag(UseLoc, diag::err_module_unimported_use)
   << (int)MIK << Decl << Modules[0]->getFullModuleName();
   }


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


r268594 - Fix implementation of C++'s restrictions on using-declarations referring to enumerators:

2016-05-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May  4 21:13:49 2016
New Revision: 268594

URL: http://llvm.org/viewvc/llvm-project?rev=268594=rev
Log:
Fix implementation of C++'s restrictions on using-declarations referring to 
enumerators:

 * an unscoped enumerator whose enumeration is a class member is itself a class
   member, so can only be the subject of a class-scope using-declaration.

 * a scoped enumerator cannot be the subject of a class-scope using-declaration.

Added:
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp
  - copied, changed from r268583, 
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx11.cpp
  - copied, changed from r268583, 
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
Removed:
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/SemaCXX/enum-scoped.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268594=268593=268594=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May  4 21:13:49 
2016
@@ -396,7 +396,9 @@ def note_using_decl_class_member_workaro
   "use %select{an alias declaration|a typedef declaration|a reference}0 "
   "instead">;
 def err_using_decl_can_not_refer_to_namespace : Error<
-  "using declaration cannot refer to namespace">;
+  "using declaration cannot refer to a namespace">;
+def err_using_decl_can_not_refer_to_scoped_enum : Error<
+  "using declaration cannot refer to a scoped enumerator">;
 def err_using_decl_constructor : Error<
   "using declaration cannot refer to a constructor">;
 def warn_cxx98_compat_using_decl_constructor : Warning<

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=268594=268593=268594=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed May  4 21:13:49 2016
@@ -7738,7 +7738,7 @@ bool Sema::CheckUsingShadowDecl(UsingDec
   // function will silently decide not to build a shadow decl, which
   // will pre-empt further diagnostics.
   //
-  // We don't need to do this in C++0x because we do the check once on
+  // We don't need to do this in C++11 because we do the check once on
   // the qualifier.
   //
   // FIXME: diagnose the following if we care enough:
@@ -8227,7 +8227,7 @@ NamedDecl *Sema::BuildUsingDeclaration(S
 }
   }
 
-  // C++0x N2914 [namespace.udecl]p6:
+  // C++14 [namespace.udecl]p6:
   // A using-declaration shall not name a namespace.
   if (R.getAsSingle()) {
 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
@@ -8235,6 +8235,16 @@ NamedDecl *Sema::BuildUsingDeclaration(S
 return BuildInvalid();
   }
 
+  // C++14 [namespace.udecl]p7:
+  // A using-declaration shall not name a scoped enumerator.
+  if (auto *ED = R.getAsSingle()) {
+if (cast(ED->getDeclContext())->isScoped()) {
+  Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_scoped_enum)
+<< SS.getRange();
+  return BuildInvalid();
+}
+  }
+
   UsingDecl *UD = BuildValid();
 
   // The normal rules do not apply to inheriting constructor declarations.
@@ -8359,8 +8369,10 @@ bool Sema::CheckUsingDeclQualifier(Sourc
 
 // If we weren't able to compute a valid scope, it must be a
 // dependent class scope.
-if (!NamedContext || NamedContext->isRecord()) {
-  auto *RD = dyn_cast_or_null(NamedContext);
+if (!NamedContext || NamedContext->getRedeclContext()->isRecord()) {
+  auto *RD = NamedContext
+ ? cast(NamedContext->getRedeclContext())
+ : nullptr;
   if (RD && RequireCompleteDeclContext(const_cast(SS), RD))
 RD = nullptr;
 
@@ -8444,7 +8456,7 @@ bool Sema::CheckUsingDeclQualifier(Sourc
 return true;
 
   if (getLangOpts().CPlusPlus11) {
-// C++0x [namespace.udecl]p3:
+// C++11 [namespace.udecl]p3:
 //   In a using-declaration used as a member-declaration, the
 //   nested-name-specifier shall name a base class of the class
 //   being defined.

Removed: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp?rev=268593=auto
==
--- 

r268589 - Do not add uwtable attribute by default for MachO targets.

2016-05-04 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May  4 20:41:07 2016
New Revision: 268589

URL: http://llvm.org/viewvc/llvm-project?rev=268589=rev
Log:
Do not add uwtable attribute by default for MachO targets.

r217178 changed clang to add function attribute uwtable by default on
Win64, which caused the __eh_frame section to be emitted by default.
This commit restores the previous behavior for MachO targets.

rdar://problem/25282627

Added:
cfe/trunk/test/Driver/win-macho-unwind.c
Modified:
cfe/trunk/lib/Driver/MSVCToolChain.cpp

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=268589=268588=268589=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Wed May  4 20:41:07 2016
@@ -71,6 +71,11 @@ bool MSVCToolChain::IsUnwindTablesDefaul
   // Emit unwind tables by default on Win64. All non-x86_32 Windows platforms
   // such as ARM and PPC actually require unwind tables, but LLVM doesn't know
   // how to generate them yet.
+
+  // Don't emit unwind tables by default for MachO targets.
+  if (getTriple().isOSBinFormatMachO())
+return false;
+
   return getArch() == llvm::Triple::x86_64;
 }
 

Added: cfe/trunk/test/Driver/win-macho-unwind.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/win-macho-unwind.c?rev=268589=auto
==
--- cfe/trunk/test/Driver/win-macho-unwind.c (added)
+++ cfe/trunk/test/Driver/win-macho-unwind.c Wed May  4 20:41:07 2016
@@ -0,0 +1,4 @@
+// RUN: %clang -target x86_64-pc-win32-macho -### -S %s -o %t.s 2>&1 | 
FileCheck %s
+ 
+// Do not add function attribute "uwtable" for macho targets.
+// CHECK-NOT: -munwind-tables


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


r268585 - [modules] Enforce the rules that an explicit or partial specialization must be

2016-05-04 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May  4 19:56:12 2016
New Revision: 268585

URL: http://llvm.org/viewvc/llvm-project?rev=268585=rev
Log:
[modules] Enforce the rules that an explicit or partial specialization must be
declared before it is used. Because we don't use normal name lookup to find
these, the normal code to filter out non-visible names from name lookup results
does not apply.

Added:
cfe/trunk/test/Modules/Inputs/cxx-templates-unimported.h
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Modules/Inputs/cxx-templates-common.h
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/cxx-templates.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=268585=268584=268585=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed May  4 19:56:12 2016
@@ -3184,6 +3184,10 @@ public:
 return isCompleteDefinition() || isFixed();
   }
 
+  /// \brief Retrieve the enum definition from which this enumeration could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  EnumDecl *getTemplateInstantiationPattern() const;
+
   /// \brief Returns the enumeration (declared within the template)
   /// from which this enumeration type was instantiated, or NULL if
   /// this enumeration was not instantiated from any template.

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=268585=268584=268585=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Wed May  4 19:56:12 2016
@@ -1876,6 +1876,10 @@ public:
 cast(getFirstDecl());
 return First->InstantiatedFromMember.getPointer();
   }
+  ClassTemplatePartialSpecializationDecl *
+  getInstantiatedFromMemberTemplate() const {
+return getInstantiatedFromMember();
+  }
 
   void setInstantiatedFromMember(
   ClassTemplatePartialSpecializationDecl *PartialSpec) 
{
@@ -2511,17 +2515,11 @@ public:
   /// it was instantiated.
   llvm::PointerUnion
   getInstantiatedFrom() const {
-if (getSpecializationKind() != TSK_ImplicitInstantiation &&
-getSpecializationKind() != TSK_ExplicitInstantiationDefinition &&
-getSpecializationKind() != TSK_ExplicitInstantiationDeclaration)
+if (!isTemplateInstantiation(getSpecializationKind()))
   return llvm::PointerUnion();
 
-if (SpecializedPartialSpecialization *PartialSpec =
-SpecializedTemplate.dyn_cast())
-  return PartialSpec->PartialSpecialization;
-
-return SpecializedTemplate.get();
+return getSpecializedTemplateOrPartial();
   }
 
   /// \brief Retrieve the variable template or variable template partial

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268585=268584=268585=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May  4 19:56:12 
2016
@@ -3710,6 +3710,8 @@ def err_template_spec_unknown_kind : Err
   "class template">;
 def note_specialized_entity : Note<
   "explicitly specialized declaration is here">;
+def note_explicit_specialization_declared_here : Note<
+  "explicit specialization declared here">;
 def err_template_spec_decl_function_scope : Error<
   "explicit specialization of %0 in function scope">;
 def err_template_spec_decl_class_scope : Error<
@@ -3832,6 +3834,8 @@ def err_partial_spec_ordering_ambiguous
 def note_partial_spec_match : Note<"partial specialization matches %0">;
 def err_partial_spec_redeclared : Error<
   "class template partial specialization %0 cannot be redeclared">;
+def note_partial_specialization_declared_here : Note<
+  "explicit specialization declared here">;
 def note_prev_partial_spec_here : Note<
   "previous declaration of class template partial specialization %0 is here">;
 def err_partial_spec_fully_specialized : Error<
@@ -8262,14 +8266,17 @@ def err_module_private_local_class : Err
   "local %select{struct|interface|union|class|enum}0 cannot be declared "
   

Re: [Clang] Convergent Attribute

2016-05-04 Thread Ettore Speziale via cfe-commits
Hello,

> I would appreciate a bit more background on this attribute's
> semantics. How would a user know when to add this attribute to their
> function definition? Are there other attributes that cannot be used in
> conjunction with this one? Should this apply to member functions? What
> about Objective-C methods?

The convergent attribute is meant to be used with languages supporting the SIMT 
execution model, like OpenCL.

I put the following example in the documentation:

  __attribute__((convergent)) __attribute__((pure)) int foo(void) {
int x;
...
barrier(CLK_GLOBAL_MEM_FENCE);
...
return x;
  }

  kernel void bar(global int *y) {
int z = foo();
*y = get_global_id() == 0 ? z : 0;
  }

The call to barrier must be either executed by all work-items in a work-group, 
or by none of them.
This is a requirement of OpenCL, and is left to the programmer to ensure that 
happens.

In the case of foo, there could be a problem.
If you do not mark it convergent, the LLVM sink pass push the call to foo to 
the then branch of the ternary operator, hence the program has been incorrectly 
optimized.

The LLVM convergent attribute has been introduced in order to solve this 
problem for intrinsic functions.
The goal of this patch is to expose that attribute at the CLANG level, so it 
can be used on all functions.

The user is supposed to add such attribute when the function requires 
convergent execution, like in the example above.

I’m not aware of any attribute that would conflict with convergent.

The convergent attribute can be applied as well to member functions.

The convergent attribute cannot be applied to Objective-C methods right now — 
it will be ignored:

test.c:14:27: warning: 'convergent' attribute only applies to functions 
[-Wignored-attributes]
- (void) x __attribute__((convergent));

Since convergent is meant for languages supporting the SIMT execution model, 
and to the best of my knowledge I’m not aware of any language based on 
Objective-C supporting that, I would guess there is no benefit in supporting 
convergent on ObjectiveC methods.

>> diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
>> index df41aeb..eafafc6 100644
>> --- a/include/clang/Basic/Attr.td
>> +++ b/include/clang/Basic/Attr.td
>> @@ -580,6 +580,12 @@ def Constructor : InheritableAttr {
>>   let Documentation = [Undocumented];
>> }
>> 
>> +def Convergent : InheritableAttr {
>> +  let Spellings = [GNU<"convergent">];
> 
> Is there a reason to not support this under CXX11<"clang",
> "convergent"> as well?

I’ve just used the most basic spelling, which fit the OpenCL case.
I can add support for the CXX11 spelling if you find it valuable.

>> +  let Subjects = SubjectList<[Function]>;
>> +  let Documentation = [Undocumented];
> 
> Please, no new undocumented attributes.

Fixed, here is updated patch:



convergent.diff
Description: Binary data


Thanks!

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

rnk wrote:
> majnemer wrote:
> > andreybokhanko wrote:
> > > majnemer wrote:
> > > > andreybokhanko wrote:
> > > > > Done. Test added.
> > > > Hmm, can you give a concrete example why we need this line?
> > > Sure. An example is:
> > > 
> > > __unaligned int unaligned_foo3() { return 0; }
> > > 
> > > MS mangles it as
> > > 
> > > ?unaligned_foo3@@YAHXZ
> > > 
> > > However, if __unaligned is taken into account, "if ((!IsPointer && Quals) 
> > > || isa(T))" computes to true and clang adds "?A", resulting to
> > > 
> > > ?unaligned_foo3@@YA?AHXZ
> > > 
> > > Yours,
> > > Andrey
> > > 
> > Wait, I thought __unaligned can only apply to pointer types.  Is this not 
> > so?!
> > Does `__unaligned int x;` really keep it's `__unaligned` qualifier?
> Yeah it does:
>   $ cat t.cpp
>   __unaligned int x;
>   $ cl -nologo -c t.cpp && dumpbin /symbols t.obj  | grep ?x
>   t.cpp
>   008  SECT3  notype   External | ?x@@3HFA (int __unaligned x)
Woah.  So if you do:

> __unaligned int unaligned_foo3() { return 0; }
> auto z = foo3();

How is `z` mangled?


http://reviews.llvm.org/D19654



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


[PATCH] D19947: [Clang] Fix some Clang-tidy readability-simplify-boolean-expr and Include What You Use warnings

2016-05-04 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: hans, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

I checked this patch on my own build on RHEL 6. Regressions were OK.

Repository:
  rL LLVM

http://reviews.llvm.org/D19947

Files:
  include/clang/Lex/Token.h
  include/clang/Sema/ParsedTemplate.h

Index: include/clang/Lex/Token.h
===
--- include/clang/Lex/Token.h
+++ include/clang/Lex/Token.h
@@ -14,12 +14,10 @@
 #ifndef LLVM_CLANG_LEX_TOKEN_H
 #define LLVM_CLANG_LEX_TOKEN_H
 
-#include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/TemplateKinds.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/StringRef.h"
-#include 
+#include 
 
 namespace clang {
 
@@ -69,8 +67,8 @@
 
   /// Flags - Bits we track about this token, members of the TokenFlags enum.
   unsigned short Flags;
-public:
 
+public:
   // Various flags set per token:
   enum TokenFlags {
 StartOfLine   = 0x01,  // At start of line or only after whitespace
@@ -236,6 +234,11 @@
 Flags |= Flag;
   }
 
+  /// \brief Get the specified flag.
+  bool getFlag(TokenFlags Flag) const {
+return (Flags & Flag) != 0;
+  }
+
   /// \brief Unset the specified flag.
   void clearFlag(TokenFlags Flag) {
 Flags &= ~Flag;
@@ -259,17 +262,15 @@
 
   /// isAtStartOfLine - Return true if this token is at the start of a line.
   ///
-  bool isAtStartOfLine() const { return (Flags & StartOfLine) ? true : false; }
+  bool isAtStartOfLine() const { return getFlag(StartOfLine); }
 
   /// \brief Return true if this token has whitespace before it.
   ///
-  bool hasLeadingSpace() const { return (Flags & LeadingSpace) ? true : false; }
+  bool hasLeadingSpace() const { return getFlag(LeadingSpace); }
 
   /// \brief Return true if this identifier token should never
   /// be expanded in the future, due to C99 6.10.3.4p2.
-  bool isExpandDisabled() const {
-return (Flags & DisableExpand) ? true : false;
-  }
+  bool isExpandDisabled() const { return getFlag(DisableExpand); }
 
   /// \brief Return true if we have an ObjC keyword identifier.
   bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const;
@@ -278,31 +279,25 @@
   tok::ObjCKeywordKind getObjCKeywordID() const;
 
   /// \brief Return true if this token has trigraphs or escaped newlines in it.
-  bool needsCleaning() const { return (Flags & NeedsCleaning) ? true : false; }
+  bool needsCleaning() const { return getFlag(NeedsCleaning); }
 
   /// \brief Return true if this token has an empty macro before it.
   ///
-  bool hasLeadingEmptyMacro() const {
-return (Flags & LeadingEmptyMacro) ? true : false;
-  }
+  bool hasLeadingEmptyMacro() const { return getFlag(LeadingEmptyMacro); }
 
   /// \brief Return true if this token is a string or character literal which
   /// has a ud-suffix.
-  bool hasUDSuffix() const { return (Flags & HasUDSuffix) ? true : false; }
+  bool hasUDSuffix() const { return getFlag(HasUDSuffix); }
 
   /// Returns true if this token contains a universal character name.
-  bool hasUCN() const { return (Flags & HasUCN) ? true : false; }
+  bool hasUCN() const { return getFlag(HasUCN); }
 
   /// Returns true if this token is formed by macro by stringizing or charizing
   /// operator.
-  bool stringifiedInMacro() const {
-return (Flags & StringifiedInMacro) ? true : false;
-  }
+  bool stringifiedInMacro() const { return getFlag(StringifiedInMacro); }
 
   /// Returns true if the comma after this token was elided.
-  bool commaAfterElided() const {
-return (Flags & CommaAfterElided) ? true : false;
-  }
+  bool commaAfterElided() const { return getFlag(CommaAfterElided); }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
@@ -324,11 +319,11 @@
   bool FoundElse;
 };
 
-}  // end namespace clang
+} // end namespace clang
 
 namespace llvm {
   template <>
   struct isPodLike { static const bool value = true; };
-}  // end namespace llvm
+} // end namespace llvm
 
-#endif
+#endif // LLVM_CLANG_LEX_TOKEN_H
Index: include/clang/Sema/ParsedTemplate.h
===
--- include/clang/Sema/ParsedTemplate.h
+++ include/clang/Sema/ParsedTemplate.h
@@ -1,4 +1,4 @@
-//===--- ParsedTemplate.h - Template Parsing Data Types ---===//
+//===--- ParsedTemplate.h - Template Parsing Data Types -*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -11,12 +11,19 @@
 //  templates.
 //
 //===--===//
+
 #ifndef LLVM_CLANG_SEMA_PARSEDTEMPLATE_H
 #define LLVM_CLANG_SEMA_PARSEDTEMPLATE_H
 
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TemplateKinds.h"
 #include "clang/Sema/DeclSpec.h"
 #include 

[clang-tools-extra] r268579 - [clang-tidy] Improve -warnings-as-errors tests.

2016-05-04 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May  4 19:09:29 2016
New Revision: 268579

URL: http://llvm.org/viewvc/llvm-project?rev=268579=rev
Log:
[clang-tidy] Improve -warnings-as-errors tests.

Added:
clang-tools-extra/trunk/test/clang-tidy/werrors-diagnostics.cpp
Modified:
clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp
clang-tools-extra/trunk/test/clang-tidy/werrors.cpp

Added: clang-tools-extra/trunk/test/clang-tidy/werrors-diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/werrors-diagnostics.cpp?rev=268579=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/werrors-diagnostics.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/werrors-diagnostics.cpp Wed May  4 
19:09:29 2016
@@ -0,0 +1,13 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN:   -- -Wunused-variable 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WARN 
-implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s 
-checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN:   -warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WERR 
-implicit-check-not='{{warning|error}}:'
+
+void f() { int i; }
+// CHECK-WARN: warning: unused variable 'i' [clang-diagnostic-unused-variable]
+// CHECK-WERR: error: unused variable 'i' 
[clang-diagnostic-unused-variable,-warnings-as-errors]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 1 warning treated as error

Modified: clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp?rev=268579=268578=268579=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/werrors-plural.cpp Wed May  4 
19:09:29 2016
@@ -1,5 +1,8 @@
-// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck 
%s --check-prefix=CHECK-WARN
-// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' 
-warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s 
--check-prefix=CHECK-WERR
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' -- 
2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WARN 
-implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s 
-checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN:   -warnings-as-errors='llvm-namespace-comment' -- 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WERR 
-implicit-check-not='{{warning|error}}:'
 
 namespace j {
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/werrors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/werrors.cpp?rev=268579=268578=268579=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/werrors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/werrors.cpp Wed May  4 19:09:29 2016
@@ -1,5 +1,5 @@
-// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck 
%s --check-prefix=CHECK-WARN
-// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' 
-warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s 
--check-prefix=CHECK-WERR
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck 
%s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' 
-warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s 
--check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
 
 namespace i {
 }


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


r268575 - [SystemZ] Add -mbackchain option.

2016-05-04 Thread Marcin Koscielnicki via cfe-commits
Author: koriakin
Date: Wed May  4 18:37:40 2016
New Revision: 268575

URL: http://llvm.org/viewvc/llvm-project?rev=268575=rev
Log:
[SystemZ] Add -mbackchain option.

This option, like the corresponding gcc option, is SystemZ-specific and
enables storing frame backchain links, as specified in the ABI.

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

Added:
cfe/trunk/test/CodeGen/mbackchain-2.c
cfe/trunk/test/CodeGen/mbackchain-3.c
cfe/trunk/test/CodeGen/mbackchain.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=268575=268574=268575=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed May  4 18:37:40 2016
@@ -1524,6 +1524,10 @@ def fno_zvector : Flag<["-"], "fno-zvect
 def mzvector : Flag<["-"], "mzvector">, Alias;
 def mno_zvector : Flag<["-"], "mno-zvector">, Alias;
 
+def mbackchain : Flag<["-"], "mbackchain">, Group, 
Flags<[DriverOption,CC1Option]>,
+  HelpText<"Link stack frames through backchain on System Z">;
+def mno_backchain : Flag<["-"], "mno-backchain">, Group, 
Flags<[DriverOption,CC1Option]>;
+
 def mno_warn_nonportable_cfstrings : Flag<["-"], 
"mno-warn-nonportable-cfstrings">, Group;
 def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, 
Group;
 def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, 
Group,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=268575=268574=268575=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed May  4 18:37:40 2016
@@ -34,6 +34,7 @@ CODEGENOPT(AsmVerbose, 1, 0) ///
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
+CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum 
for functions in GCNO files.
 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function 
names in GCDA files.
 CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit 
block before the body blocks in GCNO files.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=268575=268574=268575=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed May  4 18:37:40 2016
@@ -1714,6 +1714,8 @@ void CodeGenModule::ConstructAttributeLi
 
 if (CodeGenOpts.StackRealignment)
   FuncAttrs.addAttribute("stackrealign");
+if (CodeGenOpts.Backchain)
+  FuncAttrs.addAttribute("backchain");
 
 // Add target-cpu and target-features attributes to functions. If
 // we have a decl for the function and it has a target attribute then

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=268575=268574=268575=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed May  4 18:37:40 2016
@@ -1655,6 +1655,12 @@ void Clang::AddSparcTargetArgs(const Arg
   }
 }
 
+void Clang::AddSystemZTargetArgs(const ArgList ,
+ ArgStringList ) const {
+  if (Args.hasFlag(options::OPT_mbackchain, options::OPT_mno_backchain, false))
+CmdArgs.push_back("-mbackchain");
+}
+
 static const char *getSystemZTargetCPU(const ArgList ) {
   if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
 return A->getValue();
@@ -4241,6 +4247,10 @@ void Clang::ConstructJob(Compilation ,
 AddSparcTargetArgs(Args, CmdArgs);
 break;
 
+  case llvm::Triple::systemz:
+AddSystemZTargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 AddX86TargetArgs(Args, CmdArgs);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=268575=268574=268575=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ 

Re: [PATCH] D19891: [clang] [SystemZ] Add -mbackchain option.

2016-05-04 Thread Marcin Kościelnicki via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268575: [SystemZ] Add -mbackchain option. (authored by 
koriakin).

Changed prior to commit:
  http://reviews.llvm.org/D19891?vs=56072=56223#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19891

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/mbackchain-2.c
  cfe/trunk/test/CodeGen/mbackchain-3.c
  cfe/trunk/test/CodeGen/mbackchain.c

Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1714,6 +1714,8 @@
 
 if (CodeGenOpts.StackRealignment)
   FuncAttrs.addAttribute("stackrealign");
+if (CodeGenOpts.Backchain)
+  FuncAttrs.addAttribute("backchain");
 
 // Add target-cpu and target-features attributes to functions. If
 // we have a decl for the function and it has a target attribute then
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -1655,6 +1655,12 @@
   }
 }
 
+void Clang::AddSystemZTargetArgs(const ArgList ,
+ ArgStringList ) const {
+  if (Args.hasFlag(options::OPT_mbackchain, options::OPT_mno_backchain, false))
+CmdArgs.push_back("-mbackchain");
+}
+
 static const char *getSystemZTargetCPU(const ArgList ) {
   if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
 return A->getValue();
@@ -4241,6 +4247,10 @@
 AddSparcTargetArgs(Args, CmdArgs);
 break;
 
+  case llvm::Triple::systemz:
+AddSystemZTargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 AddX86TargetArgs(Args, CmdArgs);
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,8 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.Backchain = Args.hasArg(OPT_mbackchain);
+
   return Success;
 }
 
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -34,6 +34,7 @@
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
+CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files.
 CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit block before the body blocks in GCNO files.
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1524,6 +1524,10 @@
 def mzvector : Flag<["-"], "mzvector">, Alias;
 def mno_zvector : Flag<["-"], "mno-zvector">, Alias;
 
+def mbackchain : Flag<["-"], "mbackchain">, Group, Flags<[DriverOption,CC1Option]>,
+  HelpText<"Link stack frames through backchain on System Z">;
+def mno_backchain : Flag<["-"], "mno-backchain">, Group, Flags<[DriverOption,CC1Option]>;
+
 def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group;
 def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group;
 def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group,
Index: cfe/trunk/test/CodeGen/mbackchain-3.c
===
--- cfe/trunk/test/CodeGen/mbackchain-3.c
+++ cfe/trunk/test/CodeGen/mbackchain-3.c
@@ -0,0 +1,7 @@
+// RUN: %clang -mno-backchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @foo() [[NUW:#[0-9]+]]
+void foo(void) {
+}
+
+// CHECK-NOT: "backchain"
Index: cfe/trunk/test/CodeGen/mbackchain.c
===
--- cfe/trunk/test/CodeGen/mbackchain.c
+++ cfe/trunk/test/CodeGen/mbackchain.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -mbackchain -triple s390x-linux -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @foo() [[NUW:#[0-9]+]]
+void foo(void) {
+}
+
+// CHECK: attributes [[NUW]] = { {{.*}} "backchain" {{.*}} }
Index: cfe/trunk/test/CodeGen/mbackchain-2.c

Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-05-04 Thread Derek Schuff via cfe-commits
dschuff updated this revision to Diff 56218.
dschuff added a comment.

- Introduce CGCXXABI::canCallMismatchedFunctionType


http://reviews.llvm.org/D19275

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/static-destructor.cpp

Index: test/CodeGenCXX/static-destructor.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-destructor.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o - | FileCheck --check-prefix=X86 %s
+// RUN: %clang_cc1 %s -triple=wasm32 -emit-llvm -o - | FileCheck --check-prefix=WASM %s
+// RUN: %clang_cc1 %s -triple=armv7-apple-darwin9 -emit-llvm -o - | FileCheck --check-prefix=ARM %s
+
+// Test that destructors are not passed directly to __cxa_atexit when their
+// signatures do not match the type of its first argument.
+// e.g. ARM and WebAssembly have destructors that return this instead of void.
+
+
+class Foo {
+ public:
+  ~Foo() {
+  }
+};
+
+Foo global;
+
+// X86 destructors have void return, and are registered directly with __cxa_atexit.
+// X86: define internal void @__cxx_global_var_init()
+// X86-NEXT: entry:
+// X86-NEXT:   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle)
+
+// ARM destructors return this, but can be registered directly with __cxa_atexit
+// because the calling conventions tolerate the mismatch.
+// ARM: define internal void @__cxx_global_var_init()
+// ARM-NEXT: entry:
+// ARM-NEXT:   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (%class.Foo* (%class.Foo*)* @_ZN3FooD1Ev to void (i8*)*), i8* getelementptr inbounds (%class.Foo, %class.Foo* @global, i32 0, i32 0), i8* @__dso_handle)
+
+// Wasm destructors return this, and use a wrapper function, which is registered
+// with __cxa_atexit.
+// WASM: define internal void @__cxx_global_var_init()
+// WASM-NEXT: entry:
+// WASM-NEXT: %0 = call i32 @__cxa_atexit(void (i8*)* @__cxx_global_array_dtor, i8* null, i8* @__dso_handle)
+
+// WASM: define internal void @__cxx_global_array_dtor(i8*)
+// WASM: %call = call %class.Foo* @_ZN3FooD1Ev(%class.Foo* @global)
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -443,6 +443,7 @@
(isa(GD.getDecl()) &&
 GD.getDtorType() != Dtor_Deleting);
   }
+  bool canCallMismatchedFunctionType() const override { return false; }
 };
 }
 
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -86,13 +86,21 @@
   llvm::Constant *function;
   llvm::Constant *argument;
 
-  // Special-case non-array C++ destructors, where there's a function
-  // with the right signature that we can just call.
-  const CXXRecordDecl *record = nullptr;
-  if (dtorKind == QualType::DK_cxx_destructor &&
-  (record = type->getAsCXXRecordDecl())) {
-assert(!record->hasTrivialDestructor());
-CXXDestructorDecl *dtor = record->getDestructor();
+  // Special-case non-array C++ destructors, if they have the right signature.
+  // Under some ABIs, destructors return this instead of void, and cannot be
+  // passed directly to __cxa_atexit if the target does not allow this mismatch.
+  const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
+  bool CanRegisterDestructor =
+  Record && (!CGM.getCXXABI().HasThisReturn(
+ GlobalDecl(Record->getDestructor(), Dtor_Complete)) ||
+ CGM.getCXXABI().canCallMismatchedFunctionType());
+  // If __cxa_atexit is disabled via a flag, a different helper function is
+  // generated elsewhere which uses atexit instead, and it takes the destructor
+  // directly.
+  bool UsingExternalHelper = !CGM.getCodeGenOpts().CXAAtExit;
+  if (Record && (CanRegisterDestructor || UsingExternalHelper)) {
+assert(!Record->hasTrivialDestructor());
+CXXDestructorDecl *dtor = Record->getDestructor();
 
 function = CGM.getAddrOfCXXStructor(dtor, StructorType::Complete);
 argument = llvm::ConstantExpr::getBitCast(
Index: lib/CodeGen/CGCXXABI.h
===
--- lib/CodeGen/CGCXXABI.h
+++ lib/CodeGen/CGCXXABI.h
@@ -106,6 +106,16 @@
 
   virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; }
 
+  /// Returns true if the target allows calling a function through a pointer
+  /// with a different signature than the actual function (or equivalently,
+  /// bitcasting a function or function pointer to a different function type).
+  /// In principle in the most general case this could depend on the target, the
+  /// calling convention, and the actual types of the arguments and return
+  /// value. Here it just means whether the 

Re: [PATCH] D19275: Do not register incompatible C++ destructors with __cxa_atexit

2016-05-04 Thread Derek Schuff via cfe-commits
dschuff added a comment.

Thanks for the feedback, PTAL


http://reviews.llvm.org/D19275



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


Re: [PATCH] D19891: [clang] [SystemZ] Add -mbackchain option.

2016-05-04 Thread Ulrich Weigand via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D19891



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: lib/ASTMatchers/Dynamic/Marshallers.h:102
@@ +101,3 @@
+  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
+return llvm::StringSwitch(AttrKind)
+  .Case("CK_Dependent", CK_Dependent)

aaron.ballman wrote:
> This might be an awful idea, but let's explore it.
> 
> What if we moved the CastKind enumerator names into a .def (or .inc) file and 
> use macros to generate the enumeration as well as this monster switch 
> statement? We do this in other places where it makes sense to do so, such as 
> in Expr.h:
> ```
>   enum AtomicOp {
> #define BUILTIN(ID, TYPE, ATTRS)
> #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
> #include "clang/Basic/Builtins.def"
> // Avoid trailing comma
> BI_First = 0
>   };
> ```
Does the dynamic matching is used somewhere else than clang-query?
I wonder the impact of refactoring to support them if it's barely used.
It can't be worse than before as it wasn't supported at all (the matcher didn't 
exists).

I believe there is a larger cleanup to do to support correctly dynamic matcher 
like "equals".
And, this case is one among others.

I'm not a fan of this huge switch that may just get out-of-sync with the 
original enum.

I'm still in favor of adding this matcher to the unsupported list until we push 
the more complicated fix.
[which may fall in my plate anyway]

Any toughs?


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread andreybokhanko via cfe-commits
What Reid said...

Yours,
Andrey

> 5 мая 2016 г., в 1:48, Reid Kleckner  написал(а):
> 
> rnk added inline comments.
> 
> 
> Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
> @@ -1579,2 +1582,4 @@
>   case QMM_Result:
> +// Presence of __unaligned qualifier shouldn't affect mangling here.
> +Quals.removeUnaligned();
> if ((!IsPointer && Quals) || isa(T)) {
> 
> majnemer wrote:
>> andreybokhanko wrote:
>>> majnemer wrote:
 andreybokhanko wrote:
> Done. Test added.
 Hmm, can you give a concrete example why we need this line?
>>> Sure. An example is:
>>> 
>>> __unaligned int unaligned_foo3() { return 0; }
>>> 
>>> MS mangles it as
>>> 
>>> ?unaligned_foo3@@YAHXZ
>>> 
>>> However, if __unaligned is taken into account, "if ((!IsPointer && Quals) 
>>> || isa(T))" computes to true and clang adds "?A", resulting to
>>> 
>>> ?unaligned_foo3@@YA?AHXZ
>>> 
>>> Yours,
>>> Andrey
>> Wait, I thought __unaligned can only apply to pointer types.  Is this not 
>> so?!
>> Does `__unaligned int x;` really keep it's `__unaligned` qualifier?
> Yeah it does:
>  $ cat t.cpp
>  __unaligned int x;
>  $ cl -nologo -c t.cpp && dumpbin /symbols t.obj  | grep ?x
>  t.cpp
>  008  SECT3  notype   External | ?x@@3HFA (int __unaligned x)
> 
> 
> http://reviews.llvm.org/D19654
> 
> 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

Other opinions?
I'll proceed to the cleanup if no one else has comments.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1575
@@ +1574,3 @@
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";

aaron.ballman wrote:
> etienneb wrote:
> > aaron.ballman wrote:
> > > Split these onto two lines?
> > If I look around, it seems to be more consistent to keep it on the same 
> > line (line 1563)
> > 
> > ```
> > ///   char *s = "abcd"; wchar_t *ws = L"abcd";
> > ```
> > 
> > ```
> > ///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
> > ```
> > 
> > ```
> > ///   char ch = 'a'; wchar_t chw = L'a';
> > ``
> I don't have a strong opinion on it; however, since these get turned into 
> examples that are on the website, I would weakly prefer the examples not be 
> hideous. :-P
Ditto. No strong opinion.
But, I like consistency. I'm willing to fix all other instances too.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

aaron.ballman wrote:
> etienneb wrote:
> > etienneb wrote:
> > > aaron.ballman wrote:
> > > > Perhaps we can adjust the `hasSize()` matcher instead? It currently 
> > > > works with ConstantArrayType, but it seems reasonable for it to also 
> > > > work with StringLiteral.
> > > I didn't like the term "size" as it typically refer to the size in bytes.
> > > Which is not the same for a wide-string.
> > > 
> > > Now, there is two different convention for naming matchers:
> > >   hasLength   and  lengthIs  ?
> > > 
> > > Any toughs on that?
> > > 
> > > 
> > Here is the matcher for hasSize
> > ```
> > AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
> >   return Node.getSize() == N;
> > }
> > ```
> > 
> > It's getting the getSize attribute. I believe we should stick with the name 
> > of the attribute.
> > But, I'm not sure if we should use hasLength, or lengthIs.
> I'm not too worried about size vs length (for instance, std::string has 
> both). I would imagine this being implemented the same way we do other things 
> with variance in API but not concept. See GetBodyMatcher in 
> ASTMatchersInternal.h (and others near there) as an example.
> 
> I prefer hasSize because the two concepts are quite similar. For instance, a 
> string literal's type is of a constant array type already.
I do not have strong opinion too on the naming. I'm curious if others also has 
opinion on it?
Then, I'll proceed.


http://reviews.llvm.org/D19876



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

majnemer wrote:
> andreybokhanko wrote:
> > majnemer wrote:
> > > andreybokhanko wrote:
> > > > Done. Test added.
> > > Hmm, can you give a concrete example why we need this line?
> > Sure. An example is:
> > 
> > __unaligned int unaligned_foo3() { return 0; }
> > 
> > MS mangles it as
> > 
> > ?unaligned_foo3@@YAHXZ
> > 
> > However, if __unaligned is taken into account, "if ((!IsPointer && Quals) 
> > || isa(T))" computes to true and clang adds "?A", resulting to
> > 
> > ?unaligned_foo3@@YA?AHXZ
> > 
> > Yours,
> > Andrey
> > 
> Wait, I thought __unaligned can only apply to pointer types.  Is this not so?!
> Does `__unaligned int x;` really keep it's `__unaligned` qualifier?
Yeah it does:
  $ cat t.cpp
  __unaligned int x;
  $ cl -nologo -c t.cpp && dumpbin /symbols t.obj  | grep ?x
  t.cpp
  008  SECT3  notype   External | ?x@@3HFA (int __unaligned x)


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-05-04 Thread David Majnemer via cfe-commits
majnemer added inline comments.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584
@@ -1579,2 +1582,4 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {

andreybokhanko wrote:
> majnemer wrote:
> > andreybokhanko wrote:
> > > Done. Test added.
> > Hmm, can you give a concrete example why we need this line?
> Sure. An example is:
> 
> __unaligned int unaligned_foo3() { return 0; }
> 
> MS mangles it as
> 
> ?unaligned_foo3@@YAHXZ
> 
> However, if __unaligned is taken into account, "if ((!IsPointer && Quals) || 
> isa(T))" computes to true and clang adds "?A", resulting to
> 
> ?unaligned_foo3@@YA?AHXZ
> 
> Yours,
> Andrey
> 
Wait, I thought __unaligned can only apply to pointer types.  Is this not so?!
Does `__unaligned int x;` really keep it's `__unaligned` qualifier?


http://reviews.llvm.org/D19654



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


Re: [PATCH] D17462: Fix a codegen bug for variadic functions with pass_object_size params

2016-05-04 Thread George Burgess IV via cfe-commits
george.burgess.iv added a comment.

Ping :)


http://reviews.llvm.org/D17462



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


Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-04 Thread David Blaikie via cfe-commits
On Tue, May 3, 2016 at 4:38 PM, Paul Robinson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> probinson marked 2 inline comments as done.
>
> 
> Comment at: include/clang/Basic/Attr.td:86-88
> @@ -85,1 +85,5 @@
> +def NonParmVar : SubsetSubject +   [{S->getKind() != Decl::ImplicitParam &&
> + S->getKind() != Decl::ParmVar &&
> + S->getKind() !=
> Decl::NonTypeTemplateParm}]>;
>  def NonBitField : SubsetSubject 
> probinson wrote:
> > aaron.ballman wrote:
> > > Can you add tests for each of these cases to ensure that the
> diagnostic fires on all of them?
> > Actually not sure how to apply an attribute to an ImplicitParam
> Well, this is all very exciting.  I tried
> ```
> template<__attribute__((nodebug)) int i> int t() { return i; }
> int g() { return t<2>(); }
> ```
> but got no diagnostic.  In fact. putting assert(false) in
> handleNoDebugAttr shows that it's never called.  Unsurprisingly, debug info
> for the template parameter still appears.
> Maybe nobody has ever been so foolish as to try to put an attribute on a
> template parameter before?  (It is mildly disturbing that putting an
> attribute in an apparently impossible place yields no diagnostic and no
> semantic effect.)
> I was obviously modeling this check on NormalVar, which (it turns out) is
> never used. And if you can't put attributes on template parameters or (it
> would seem likely) implicit parameters, then NonParmVar should check for
> nothing more than ParmVar.
> And that's what I'll do.
>
> (Marking as Done because the set of tests now matches the specified
> condition.)
>
> 
> Comment at: test/CodeGenCXX/debug-info-nodebug.cpp:50
> @@ -49,1 +49,3 @@
>NODEBUG static int static_local = 6;
> +  NODEBUG const  int const_local = 7;
> +  NODEBUGint normal_local = 8;
> 
> dblaikie wrote:
> > Doesn't look like the const case is any different from the non-const
> case, is it?
> Given a white-box analysis of the compiler internals, you are correct;
> this is in contrast to the static const/non-const handling, which *does*
> use different paths.
> I am unwilling to trust that the const/non-const paths for locals will
> forever use the same path.  You could also look at it as "the test is the
> spec."
>

But even then - what about any other property of a variable? What if it's
in a nested scope instead of a top level scope? What if it's declared in a
condition (if (int x = ...)). What if it's volatile? We could pick
arbitrary properties that /could/ have an effect on debug info but we
generally believe to be orthogonal to the feature at hand & I'd say 'const'
is in the same group of things. (a const local variable still needs
storage, etc, - the address can be escaped and accessed from elsewhere and
determined to be unique - and both variables in this example could be
optimized away entirely by the compiler because they're unused, so the
const is no worse off there in that theoretical concern)


>
> 
> Comment at: test/CodeGenObjC/debug-info-nodebug.m:17
> @@ +16,3 @@
> +  // CHECK-NOT: !DILocalVariable(name: "strongSelf"
> +  __attribute__((nodebug)) __typeof(self) weakSelf = self;
> +  Block = [^{
> 
> dblaikie wrote:
> > Is this case outside of the block interesting in some way? It doesn't
> look like it.
> The attribute on "weakSelf" is what triggers the second modified path in
> CGDebugInfo and suppresses the DILocalVariable for that name.
> The attribute on "strongSelf" goes through the normal EmitDeclare path.
> So in that sense, it is not interesting.
>
> I should not have been so hesitant to work out what was going on here,
> sorry about that.  My cluelessness about Objective-C knows no bounds.
> I'm changing the test to verify that the DILocalVariable does not appear,
> while the member info does still appear, and updating the comment to
> reflect this new knowledge.
>
>
> http://reviews.llvm.org/D19754
>
>
>
> ___
> 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] D16962: clang-tidy: avoid std::bind

2016-05-04 Thread Arthur O'Dwyer via cfe-commits
On Wed, May 4, 2016 at 1:43 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> jbcoe wrote:
> > aaron.ballman wrote:
> > > I believe we use "modernize" to really mean "migrate from the old way
> to the new way", which this definitely fits into since I think the point to
> this check is to replace bind with better alternatives.
> > Would you prefer it to be in `modernize`? I can be easily convinced
> either way and am happy to move it. If I do move it I might add a script to
> facilitate doing so.
> My preference is for modernize, your preference is for readability, so I
> say: make @alexfh the tie-breaker! ;-) Alex, what are your thoughts? This
> seems like a heuristic we may want to state in our documentation to help
> others decide where to put new checks in the future as well.
>

FWIW, I'd prefer "modernize", and I'll point out that these waters are
muddied by the fact that three of the old ways (boost::bind, std::bind1st,
std::bind2nd) all existed prior to C++11, so the fact that *one* of the old
ways (std::bind) was introduced in C++11 doesn't matter so much.
(I haven't looked, but I'd assume that this clang-tidy check catches all
four cases, right?)

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


[clang-tools-extra] r268555 - [clang-tidy] Apply NOLINT filtering to Clang warnings.

2016-05-04 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed May  4 16:18:31 2016
New Revision: 268555

URL: http://llvm.org/viewvc/llvm-project?rev=268555=rev
Log:
[clang-tidy] Apply NOLINT filtering to Clang warnings.

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

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=268555=268554=268555=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Wed May  
4 16:18:31 2016
@@ -174,20 +174,6 @@ DiagnosticBuilder ClangTidyContext::diag
 StringRef CheckName, SourceLocation Loc, StringRef Description,
 DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
   assert(Loc.isValid());
-  bool Invalid;
-  const char *CharacterData =
-  DiagEngine->getSourceManager().getCharacterData(Loc, );
-  if (!Invalid) {
-const char *P = CharacterData;
-while (*P != '\0' && *P != '\r' && *P != '\n')
-  ++P;
-StringRef RestOfLine(CharacterData, P - CharacterData + 1);
-// FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
-if (RestOfLine.find("NOLINT") != StringRef::npos) {
-  Level = DiagnosticIDs::Ignored;
-  ++Stats.ErrorsIgnoredNOLINT;
-}
-  }
   unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
   Level, (Description + " [" + CheckName + "]").str());
   if (CheckNamesByDiagnosticID.count(ID) == 0)
@@ -290,8 +276,31 @@ void ClangTidyDiagnosticConsumer::finali
   LastErrorPassesLineFilter = false;
 }
 
+static bool LineIsMarkedWithNOLINT(SourceManager& SM, SourceLocation Loc) {
+  bool Invalid;
+  const char *CharacterData = SM.getCharacterData(Loc, );
+  if (!Invalid) {
+const char *P = CharacterData;
+while (*P != '\0' && *P != '\r' && *P != '\n')
+  ++P;
+StringRef RestOfLine(CharacterData, P - CharacterData + 1);
+// FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
+if (RestOfLine.find("NOLINT") != StringRef::npos) {
+  return true;
+}
+  }
+  return false;
+}
+
 void ClangTidyDiagnosticConsumer::HandleDiagnostic(
 DiagnosticsEngine::Level DiagLevel, const Diagnostic ) {
+  if (Info.getLocation().isValid() &&
+  DiagLevel != DiagnosticsEngine::Error &&
+  DiagLevel != DiagnosticsEngine::Fatal &&
+  LineIsMarkedWithNOLINT(Diags->getSourceManager(), Info.getLocation())) {
+++Context.Stats.ErrorsIgnoredNOLINT;
+return;
+  }
   // Count warnings/errors.
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
 

Modified: clang-tools-extra/trunk/test/clang-tidy/nolint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nolint.cpp?rev=268555=268554=268555=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/nolint.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nolint.cpp Wed May  4 16:18:31 2016
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s google-explicit-constructor %t
+// RUN: %check_clang_tidy %s 
google-explicit-constructor,clang-diagnostic-unused-variable %t -- 
-extra-arg=-Wunused-variable --
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
@@ -6,4 +6,11 @@ class A { A(int i); };
 class B { B(int i); }; // NOLINT
 
 class C { C(int i); }; // NOLINT(we-dont-care-about-categories-yet)
-// CHECK-MESSAGES: Suppressed 2 warnings (2 NOLINT)
+
+void f() {
+  int i;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: unused variable 'i' 
[clang-diagnostic-unused-variable]
+  int j; // NOLINT
+}
+
+// CHECK-MESSAGES: Suppressed 3 warnings (3 NOLINT)


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


Re: [PATCH] D19062: Add functions in ctype.h to builtin function database (Fix)

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I have commit in r268553


http://reviews.llvm.org/D19062



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


r268553 - Add the Pure attribute to C99 builtin functions from ctype.h. This is a corrected version of r266199 with test case fixes.

2016-05-04 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed May  4 16:08:13 2016
New Revision: 268553

URL: http://llvm.org/viewvc/llvm-project?rev=268553=rev
Log:
Add the Pure attribute to C99 builtin functions from ctype.h. This is a 
corrected version of r266199 with test case fixes.

Patch by Taewook Oh.

Added:
cfe/trunk/test/Sema/libbuiltins-ctype-powerpc64.c
cfe/trunk/test/Sema/libbuiltins-ctype-x86_64.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/FixIt/typo.m
cfe/trunk/test/Sema/enable_if.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=268553=268552=268553=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed May  4 16:08:13 2016
@@ -67,6 +67,7 @@
 // Builtin::Context class.  Currently we have:
 //  n -> nothrow
 //  r -> noreturn
+//  U -> pure
 //  c -> const
 //  t -> signature is meaningless, use custom typechecking
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
@@ -773,6 +774,22 @@ LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:
 LIBBUILTIN(vscanf, "icC*Ra",  "fS:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
+// C99 ctype.h
+LIBBUILTIN(isalnum, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isalpha, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isblank, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(iscntrl, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isgraph, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(islower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isprint, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(ispunct, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isspace, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isxdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=268553=268552=268553=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Wed May  4 16:08:13 2016
@@ -89,11 +89,16 @@ public:
 return getRecord(ID).Type;
   }
 
-  /// \brief Return true if this function is a target-specific builtin
+  /// \brief Return true if this function is a target-specific builtin.
   bool isTSBuiltin(unsigned ID) const {
 return ID >= Builtin::FirstTSBuiltin;
   }
 
+  /// \brief Return true if this function has no side effects.
+  bool isPure(unsigned ID) const {
+return strchr(getRecord(ID).Attributes, 'U') != nullptr;
+  }
+
   /// \brief Return true if this function has no side effects and doesn't
   /// read memory.
   bool isConst(unsigned ID) const {
@@ -155,7 +160,7 @@ public:
   /// \brief Completely forget that the given ID was ever considered a builtin,
   /// e.g., because the user provided a conflicting signature.
   void forgetBuiltin(unsigned ID, IdentifierTable );
-  
+
   /// \brief If this is a library function that comes from a specific
   /// header, retrieve that header name.
   const char *getHeaderName(unsigned ID) const {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=268553=268552=268553=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May  4 16:08:13 2016
@@ -273,7 +273,7 @@ ParsedType Sema::getTypeName(const Ident
 // so build a dependent node to describe the type.
 if (WantNontrivialTypeSourceInfo)
   return ActOnTypenameType(S, SourceLocation(), *SS, II, 
NameLoc).get();
-
+
 NestedNameSpecifierLoc QualifierLoc = SS->getWithLocInContext(Context);
 QualType T = CheckTypenameType(ETK_None, SourceLocation(), 
QualifierLoc,
II, NameLoc);
@@ -282,7 +282,7 @@ ParsedType Sema::getTypeName(const Ident
 
   return nullptr;
 }
-
+
 if (!LookupCtx->isDependentContext() &&
 RequireCompleteDeclContext(*SS, LookupCtx))
   return nullptr;
@@ -303,7 +303,7 @@ ParsedType Sema::getTypeName(const Ident
 if 

[PATCH] D19936: Adding omitted column to invalid loc diagnostic.

2016-05-04 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: olista01, t.p.northover.
bcraig added a subscriber: cfe-commits.

note_fe_backend_invalid_loc expects three arguments (file, line, column), and 
will assert when only given two.  The other two places in this file that use 
note_fe_backend_invalid_loc already supply the Column for the third parameter.

http://reviews.llvm.org/D19936

Files:
  lib/CodeGen/CodeGenAction.cpp

Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -454,7 +454,7 @@
 // we could not translate this location. This can happen in the
 // case of #line directives.
 Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
-<< Filename << Line;
+<< Filename << Line << Column;
 
   return Loc;
 }


Index: lib/CodeGen/CodeGenAction.cpp
===
--- lib/CodeGen/CodeGenAction.cpp
+++ lib/CodeGen/CodeGenAction.cpp
@@ -454,7 +454,7 @@
 // we could not translate this location. This can happen in the
 // case of #line directives.
 Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
-<< Filename << Line;
+<< Filename << Line << Column;
 
   return Loc;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-05-04 Thread Eric Christopher via cfe-commits
Sounds great. Thanks!

-eric

On Wed, May 4, 2016 at 4:36 AM Andrey Turetskiy 
wrote:

> aturetsk added a comment.
>
> Hi,
> Thanks for the review.
>
> Committed:
>
> 1. Add a test for driver options from m_x86_Features_Group (
> http://reviews.llvm.org/rL268487)
> 2. Add missing -mno-cx16 driver option (http://reviews.llvm.org/rL268488)
> 3. Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87 (
> http://reviews.llvm.org/rL268489)
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D19658
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268548 - Fix the doc extraction script to work with hasAnyName and with equalsNode.

2016-05-04 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Wed May  4 15:45:00 2016
New Revision: 268548

URL: http://llvm.org/viewvc/llvm-project?rev=268548=rev
Log:
Fix the doc extraction script to work with hasAnyName and with equalsNode.

The change from llvm::VariadicFunction to internal::VariadicFunction
broke the extraction of hasAnyName().
equalsNode was broken because the argument type is 'const *' and
the internal space caused a failure on the regex.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/docs/tools/dump_ast_matchers.py

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=268548=268547=268548=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed May  4 15:45:00 2016
@@ -410,7 +410,7 @@ decl(hasDeclContext(translationUnitDecl(
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typeAliasDecl()
   matches "using Y = int", but not "typedef int X"
 
@@ -421,7 +421,7 @@ typeAliasDecl()
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typedefDecl()
   matches "typedef int X", but not "using Y = int"
 
@@ -432,7 +432,7 @@ typedefDecl()
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typedefNameDecl()
   matches "typedef int X" and "using Y = int"
 
@@ -2238,6 +2238,13 @@ and reference to that variable declarati
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclequalsNodeconst Decl* Other
+Matches if a node equals 
another node.
+
+Decl has pointer identity in the AST.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DeclhasAttrattr::Kind AttrKind
 Matches declaration that 
has a given attribute.
 
@@ -2898,6 +2905,13 @@ and reference to that variable declarati
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtequalsNodeconst Stmt* Other
+Matches if a node equals 
another node.
+
+Stmt has pointer identity in the AST.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtisExpansionInFileMatchingstd::string
 RegExp
 Matches 
AST nodes that were expanded within files whose name is
 partially matching a given regex.
@@ -3072,6 +3086,13 @@ and reference to that variable declarati
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypeequalsNodeconst Type* Other
+Matches if a node equals 
another node.
+
+Type has pointer identity in the AST.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TyperealFloatingPointType
 Matches any 
real floating-point type (float, double, long double).
 
@@ -3286,6 +3307,16 @@ expr(nullPointerConstant())
 
 
 
+Matcherinternal::Matcherhttp://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html;>NamedDeclhasAnyNameStringRef, ..., 
StringRef
+Matches NamedDecl nodes 
that have any of the specified names.
+
+This matcher is only provided as a performance optimization of hasName.
+hasAnyName(a, b, c)
+ is equivalent to, but faster than
+anyOf(hasName(a), hasName(b), hasName(c))
+
+
+
 Matcherinternal::Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtisInTemplateInstantiation
 Matches 
statements inside of a template instantiation.
 

Modified: cfe/trunk/docs/tools/dump_ast_matchers.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_ast_matchers.py?rev=268548=268547=268548=diff
==
--- cfe/trunk/docs/tools/dump_ast_matchers.py (original)
+++ cfe/trunk/docs/tools/dump_ast_matchers.py Wed May  4 15:45:00 2016
@@ -95,7 +95,7 @@ def strip_doxygen(comment):
 def unify_arguments(args):
   """Gets rid of anything the user doesn't care about in the argument list."""
   args = re.sub(r'internal::', r'', args)
-  args = re.sub(r'const\s+', r'', args)
+  args = re.sub(r'const\s+(.*)&', r'\1 ', args)
   args = re.sub(r'&', r' ', args)
   args = re.sub(r'(^|\s)M\d?(\s)', r'\1Matcher<*>\2', args)
   return args
@@ -231,7 +231,7 @@ def act_on_decl(declaration, comment, al
 m = re.match(r"""^\s*AST_MATCHER(_P)?(.?)(?:_OVERLOAD)?\(
(?:\s*([^\s,]+)\s*,)?
   \s*([^\s,]+)\s*
-   (?:,\s*([^\s,]+)\s*
+   (?:,\s*([^,]+)\s*
   ,\s*([^\s,]+)\s*)?
(?:,\s*([^\s,]+)\s*
   ,\s*([^\s,]+)\s*)?
@@ -266,7 +266,7 @@ def act_on_decl(declaration, comment, al
 
 # Parse Variadic functions.
 m = re.match(
-r"""^.*llvm::VariadicFunction\s*<\s*([^,]+),\s*([^,]+),\s*[^>]+>\s*
+r"""^.*internal::VariadicFunction\s*<\s*([^,]+),\s*([^,]+),\s*[^>]+>\s*
   ([a-zA-Z]*)\s*=\s*{.*};$""",
 declaration, flags=re.X)
 if m:


___
cfe-commits mailing list

Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/ReadabilityTidyModule.cpp:17
@@ -15,2 +16,2 @@
 #include "ContainerSizeEmptyCheck.h"
 #include "DeletedDefaultCheck.h"

jbcoe wrote:
> aaron.ballman wrote:
> > I believe we use "modernize" to really mean "migrate from the old way to 
> > the new way", which this definitely fits into since I think the point to 
> > this check is to replace bind with better alternatives.
> Would you prefer it to be in `modernize`? I can be easily convinced either 
> way and am happy to move it. If I do move it I might add a script to 
> facilitate doing so.
My preference is for modernize, your preference is for readability, so I say: 
make @alexfh the tie-breaker! ;-) Alex, what are your thoughts? This seems like 
a heuristic we may want to state in our documentation to help others decide 
where to put new checks in the future as well.


http://reviews.llvm.org/D16962



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


[libcxx] r268543 - Removing some trailing whitespace

2016-05-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed May  4 15:29:19 2016
New Revision: 268543

URL: http://llvm.org/viewvc/llvm-project?rev=268543=rev
Log:
Removing some trailing whitespace

Modified:
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp?rev=268543=268542=268543=diff
==
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp Wed 
May  4 15:29:19 2016
@@ -17,7 +17,7 @@
 #include 
 
 struct S {
-int i; 
+int i;
 S() : i(0) {}
 S(int j) : i(j) {}
 S * operator& () { assert(false); return this; }

Modified: 
libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp?rev=268543=268542=268543=diff
==
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp 
Wed May  4 15:29:19 2016
@@ -23,7 +23,7 @@ int main()
 assert(p1.first == 3);
 assert(p1.second == 4);
 }
-
+
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 {
 typedef std::pair P1;


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


r268541 - fix docs

2016-05-04 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Wed May  4 15:24:54 2016
New Revision: 268541

URL: http://llvm.org/viewvc/llvm-project?rev=268541=rev
Log:
fix docs

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=268541=268540=268541=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed May  4 15:24:54 2016
@@ -985,6 +985,7 @@ are listed below.
program.
 
 **-f[no-]sanitize-recover=check1,check2,...**
+
 **-f[no-]sanitize-recover=all**
 
Controls which checks enabled by ``-fsanitize=`` flag are non-fatal.


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


r268540 - document -f[no-]sanitize-recover=all and mention it in warning messages

2016-05-04 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Wed May  4 15:21:47 2016
New Revision: 268540

URL: http://llvm.org/viewvc/llvm-project?rev=268540=rev
Log:
document -f[no-]sanitize-recover=all and mention it in warning messages

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=268540=268539=268540=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed May  4 15:21:47 2016
@@ -985,6 +985,7 @@ are listed below.
program.
 
 **-f[no-]sanitize-recover=check1,check2,...**
+**-f[no-]sanitize-recover=all**
 
Controls which checks enabled by ``-fsanitize=`` flag are non-fatal.
If the check is fatal, program will halt after the first error

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=268540=268539=268540=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Wed May  4 15:21:47 2016
@@ -340,11 +340,13 @@ SanitizerArgs::SanitizerArgs(const ToolC
   for (const auto *Arg : Args) {
 const char *DeprecatedReplacement = nullptr;
 if (Arg->getOption().matches(options::OPT_fsanitize_recover)) {
-  DeprecatedReplacement = "-fsanitize-recover=undefined,integer";
+  DeprecatedReplacement =
+  "-fsanitize-recover=undefined,integer' or '-fsanitize-recover=all";
   RecoverableKinds |= expandSanitizerGroups(LegacyFsanitizeRecoverMask);
   Arg->claim();
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_recover)) {
-  DeprecatedReplacement = "-fno-sanitize-recover=undefined,integer";
+  DeprecatedReplacement = "-fno-sanitize-recover=undefined,integer' or "
+  "'-fno-sanitize-recover=all";
   RecoverableKinds &= ~expandSanitizerGroups(LegacyFsanitizeRecoverMask);
   Arg->claim();
 } else if (Arg->getOption().matches(options::OPT_fsanitize_recover_EQ)) {

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=268540=268539=268540=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Wed May  4 15:21:47 2016
@@ -196,8 +196,8 @@
 // CHECK-DIAG-RECOVER: unsupported argument 'unreachable' to option 
'fsanitize-recover='
 
 // RUN: %clang -target x86_64-linux-gnu %s -fsanitize=undefined 
-fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEPRECATED-RECOVER
-// CHECK-DEPRECATED-RECOVER: argument '-fsanitize-recover' is deprecated, use 
'-fsanitize-recover=undefined,integer' instead
-// CHECK-DEPRECATED-RECOVER: argument '-fno-sanitize-recover' is deprecated, 
use '-fno-sanitize-recover=undefined,integer' instead
+// CHECK-DEPRECATED-RECOVER: argument '-fsanitize-recover' is deprecated, use 
'-fsanitize-recover=undefined,integer' or '-fsanitize-recover=all' instead
+// CHECK-DEPRECATED-RECOVER: argument '-fno-sanitize-recover' is deprecated, 
use '-fno-sanitize-recover=undefined,integer' or '-fno-sanitize-recover=all' 
instead
 // CHECK-DEPRECATED-RECOVER-NOT: is deprecated
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANL


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


Re: [PATCH] D19062: Add functions in ctype.h to builtin function database (Fix)

2016-05-04 Thread Taewook Oh via cfe-commits
twoh updated this revision to Diff 56198.
twoh added a comment.

Rebased on ToT. Thanks @aaron.ballman!


http://reviews.llvm.org/D19062

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  lib/Sema/SemaDecl.cpp
  test/FixIt/typo.m
  test/Sema/enable_if.c
  test/Sema/libbuiltins-ctype-powerpc64.c
  test/Sema/libbuiltins-ctype-x86_64.c

Index: test/Sema/libbuiltins-ctype-x86_64.c
===
--- test/Sema/libbuiltins-ctype-x86_64.c
+++ test/Sema/libbuiltins-ctype-x86_64.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s
+
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+
+void test(int x) {
+  // CHECK: call i32 @isalnum(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isalnum(x);
+  // CHECK: call i32 @isalpha(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isalpha(x);
+  // CHECK: call i32 @isblank(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isblank(x);
+  // CHECK: call i32 @iscntrl(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)iscntrl(x);
+  // CHECK: call i32 @isdigit(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isdigit(x);
+  // CHECK: call i32 @isgraph(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isgraph(x);
+  // CHECK: call i32 @islower(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)islower(x);
+  // CHECK: call i32 @isprint(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isprint(x);
+  // CHECK: call i32 @ispunct(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)ispunct(x);
+  // CHECK: call i32 @isspace(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isspace(x);
+  // CHECK: call i32 @isupper(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isupper(x);
+  // CHECK: call i32 @isxdigit(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isxdigit(x);
+  // CHECK: call i32 @tolower(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)tolower(x);
+  // CHECK: call i32 @toupper(i32 {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)toupper(x);
+}
+
+// CHECK: declare i32 @isalnum(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isalpha(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isblank(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @iscntrl(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isdigit(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isgraph(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @islower(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isprint(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @ispunct(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isspace(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isupper(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @isxdigit(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @tolower(i32) [[NUW_RO:#[0-9]+]]
+// CHECK: declare i32 @toupper(i32) [[NUW_RO:#[0-9]+]]
+
+// CHECK: attributes [[NUW_RO]] = { nounwind readonly{{.*}} }
+// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly }
Index: test/Sema/libbuiltins-ctype-powerpc64.c
===
--- test/Sema/libbuiltins-ctype-powerpc64.c
+++ test/Sema/libbuiltins-ctype-powerpc64.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s
+
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+
+void test(int x) {
+  // CHECK: call signext i32 @isalnum(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isalnum(x);
+  // CHECK: call signext i32 @isalpha(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isalpha(x);
+  // CHECK: call signext i32 @isblank(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isblank(x);
+  // CHECK: call signext i32 @iscntrl(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)iscntrl(x);
+  // CHECK: call signext i32 @isdigit(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isdigit(x);
+  // CHECK: call signext i32 @isgraph(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isgraph(x);
+  // CHECK: call signext i32 @islower(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)islower(x);
+  // CHECK: call signext i32 @isprint(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isprint(x);
+  // CHECK: call signext i32 @ispunct(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)ispunct(x);
+  // CHECK: call signext i32 @isspace(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isspace(x);
+  // CHECK: call signext i32 @isupper(i32 signext {{%[0-9]+}}) [[NUW_RO_CALL:#[0-9]+]]
+  (void)isupper(x);
+  // CHECK: call signext i32 

[PATCH] D19934: [NFC] Reorder fields of VersionTuple to reduce size

2016-05-04 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
erik.pilkington added a subscriber: cfe-commits.

Previously, `clang::VersionTuple`'s fields were laid out in an unfortunate way 
that made the object larger than it ought to have been. This patch just 
reorders the fields, reducing the size.

http://reviews.llvm.org/D19934

Files:
  include/clang/Basic/VersionTuple.h

Index: include/clang/Basic/VersionTuple.h
===
--- include/clang/Basic/VersionTuple.h
+++ include/clang/Basic/VersionTuple.h
@@ -25,39 +25,44 @@
 /// \brief Represents a version number in the form 
major[.minor[.subminor[.build]]].
 class VersionTuple {
   unsigned Major : 31;
+
+  unsigned UsesUnderscores : 1;
+
   unsigned Minor : 31;
-  unsigned Subminor : 31;
-  unsigned Build : 31;
   unsigned HasMinor : 1;
+
+  unsigned Subminor : 31;
   unsigned HasSubminor : 1;
+
+  unsigned Build : 31;
   unsigned HasBuild : 1;
-  unsigned UsesUnderscores : 1;
 
 public:
   VersionTuple()
-  : Major(0), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major)
-  : Major(Major), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(0), Build(0), HasMinor(true),
-HasSubminor(false), HasBuild(false), UsesUnderscores(UsesUnderscores) 
{}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
+HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(0),
-HasMinor(true), HasSubminor(true), HasBuild(false),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
+HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(Build),
-HasMinor(true), HasSubminor(true), HasBuild(true),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
+HasBuild(true) {}
 
   /// \brief Determine whether this version information is empty
   /// (e.g., all version components are zero).


Index: include/clang/Basic/VersionTuple.h
===
--- include/clang/Basic/VersionTuple.h
+++ include/clang/Basic/VersionTuple.h
@@ -25,39 +25,44 @@
 /// \brief Represents a version number in the form major[.minor[.subminor[.build]]].
 class VersionTuple {
   unsigned Major : 31;
+
+  unsigned UsesUnderscores : 1;
+
   unsigned Minor : 31;
-  unsigned Subminor : 31;
-  unsigned Build : 31;
   unsigned HasMinor : 1;
+
+  unsigned Subminor : 31;
   unsigned HasSubminor : 1;
+
+  unsigned Build : 31;
   unsigned HasBuild : 1;
-  unsigned UsesUnderscores : 1;
 
 public:
   VersionTuple()
-  : Major(0), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major)
-  : Major(Major), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(0), Build(0), HasMinor(true),
-HasSubminor(false), HasBuild(false), UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
+HasBuild(false) {}
 
   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
   

Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-04 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/readability/ReadabilityTidyModule.cpp:17
@@ -15,2 +16,2 @@
 #include "ContainerSizeEmptyCheck.h"
 #include "DeletedDefaultCheck.h"

aaron.ballman wrote:
> I believe we use "modernize" to really mean "migrate from the old way to the 
> new way", which this definitely fits into since I think the point to this 
> check is to replace bind with better alternatives.
Would you prefer it to be in `modernize`? I can be easily convinced either way 
and am happy to move it. If I do move it I might add a script to facilitate 
doing so.


http://reviews.llvm.org/D16962



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


Re: [PATCH] D16376: clang-tidy check: misc-deprecated-special-member-functions

2016-05-04 Thread Jonathan B Coe via cfe-commits
jbcoe added a comment.

After some pondering I think I **will**extend  move this check to 
cppcoreguidelines and call it rule-of-five.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all


http://reviews.llvm.org/D16376



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


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-04 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 56194.
yaxunl added a comment.

Update the test.


http://reviews.llvm.org/D19932

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Decl.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  constant int *con;
+
+  glob = to_global(glob, loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+#endif
+
+  int x;
+  glob = to_global(x);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument x to function: 'to_global'}}
+#endif
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con to function: 'to_global'}}
+#endif
+
+  loc = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+#endif
+
+}
Index: test/CodeGenOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/to_addr_builtin.cl
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %[[A:.*]] = type { float, float, float }
+typedef struct {
+  float x,y,z;
+} A;
+typedef private A *PA;
+typedef global A *GA;
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  private int *priv;
+  generic int *gen;
+
+  //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS1i(i32 addrspace(1)* %{{.*}})
+  glob = to_global(glob);
+  
+  //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS3i(i32 addrspace(3)* %{{.*}})
+  glob = to_global(loc);
+ 
+   //CHECK: call i32 addrspace(1)* @_Z9to_globalPi(i32* %{{.*}})
+  glob = to_global(priv);
+ 
+   //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS4i(i32 addrspace(4)* %{{.*}})
+  glob = to_global(gen);
+  
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS1i(i32 addrspace(1)* %{{.*}})
+  loc = to_local(glob);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS3i(i32 addrspace(3)* %{{.*}})
+  loc = to_local(loc);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPi(i32* %{{.*}})
+  loc = to_local(priv);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS4i(i32 addrspace(4)* %{{.*}})
+  loc = to_local(gen);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS1i(i32 addrspace(1)* %{{.*}})
+  priv = to_private(glob);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS3i(i32 addrspace(3)* %{{.*}})
+  priv = to_private(loc);
+
+  //CHECK: call i32* @_Z10to_privatePi(i32* %{{.*}})
+  priv = to_private(priv);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS4i(i32 addrspace(4)* %{{.*}})
+  priv = to_private(gen);
+
+  //CHECK; call %[[A]] addrspace(1)* @_Z9to_globalP1A(%[[A]]* %{{.*}})
+  PA pA;
+  GA gA = to_global(pA);
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5055,6 +5055,61 @@
   return Callee->getMinRequiredArguments() <= NumArgs;
 }
 
+/// OpenCL to_addr function accepts pointers to arbitrary type as argument.
+/// This function change the original declaration to match the argument.
+/// \return nullptr if this builtin is not OpenCL to_addr builtin function or
+/// there is no need to change the function declaration.
+static FunctionDecl *
+rewriteBuiltinFunctionDeclForOpenCLToAddr(Sema *Sema, ASTContext ,
+  const FunctionDecl *FDecl,
+  MultiExprArg ArgExprs) {
+  auto ID = FDecl->getBuiltinID();
+  if (ID != Builtin::BIto_global &&
+  ID != Builtin::BIto_local &&
+  ID != Builtin::BIto_private)
+return nullptr;
+
+  auto ArgT = ArgExprs[0]->getType();
+  if (!ArgT->isPointerType())
+return nullptr;
+
+  auto RT = ArgT->getPointeeType().getCanonicalType();
+  auto Qual = RT.getQualifiers();
+  switch (ID) {
+  case Builtin::BIto_global:
+Qual.setAddressSpace(LangAS::opencl_global);
+break;
+  case Builtin::BIto_local:
+Qual.setAddressSpace(LangAS::opencl_local);
+break;
+  default:
+Qual.removeAddressSpace();
+  }
+  RT = 

[PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-04 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, pxli168.
yaxunl added subscribers: cfe-commits, tstellarAMD.

OpenCL builtin functions to_{global|local|private} accepts argument of pointer 
type to arbitrary pointee type, and return a pointer to the same pointee type 
in different addr space, i.e.

  global gentype *to_global(gentype *p);

It is not desirable to declare it as

  global void *to_global(void *);

in opencl header file since it misses diagnostics and generates extra bitcasts.

This patch implements these builtin functions as Clang builtin functions. In 
the builtin def file they are defined to have signature void*(void*). When 
handling call expressions, their declarations are re-written to have correct 
parameter type and return type corresponding to the call argument.

http://reviews.llvm.org/D19932

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Decl.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  constant int *con;
+
+  glob = to_global(glob, loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+#endif
+
+  int x;
+  glob = to_global(x);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument x to function: 'to_global'}}
+#endif
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con to function: 'to_global'}}
+#endif
+
+  loc = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+#endif
+
+}
Index: test/CodeGenOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/to_addr_builtin.cl
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+typedef struct {
+  float x,y,z;
+} A;
+typedef private A *PA;
+typedef global A *GA;
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  private int *priv;
+  generic int *gen;
+
+  //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS1v(i32 addrspace(1)* %{{.*}})
+  glob = to_global(glob);
+  
+  //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS3v(i32 addrspace(3)* %{{.*}})
+  glob = to_global(loc);
+ 
+   //CHECK: call i32 addrspace(1)* @_Z9to_globalPv(i32* %{{.*}})
+  glob = to_global(priv);
+ 
+   //CHECK: call i32 addrspace(1)* @_Z9to_globalPU3AS4v(i32 addrspace(4)* %{{.*}})
+  glob = to_global(gen);
+  
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS1v(i32 addrspace(1)* %{{.*}})
+  loc = to_local(glob);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS3v(i32 addrspace(3)* %{{.*}})
+  loc = to_local(loc);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPv(i32* %{{.*}})
+  loc = to_local(priv);
+
+  //CHECK: call i32 addrspace(3)* @_Z8to_localPU3AS4v(i32 addrspace(4)* %{{.*}})
+  loc = to_local(gen);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS1v(i32 addrspace(1)* %{{.*}})
+  priv = to_private(glob);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS3v(i32 addrspace(3)* %{{.*}})
+  priv = to_private(loc);
+
+  //CHECK: call i32* @_Z10to_privatePv(i32* %{{.*}})
+  priv = to_private(priv);
+
+  //CHECK: call i32* @_Z10to_privatePU3AS4v(i32 addrspace(4)* %{{.*}})
+  priv = to_private(gen);
+
+  PA pA;
+  GA gA = to_global(pA);
+  };
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5055,6 +5055,61 @@
   return Callee->getMinRequiredArguments() <= NumArgs;
 }
 
+/// OpenCL to_addr function accepts pointers to arbitrary type as argument.
+/// This function change the original declaration to match the argument.
+/// \return nullptr if this builtin is not OpenCL to_addr builtin function or
+/// there is no need to change the function declaration.
+static FunctionDecl *
+rewriteBuiltinFunctionDeclForOpenCLToAddr(Sema *Sema, ASTContext ,
+  const FunctionDecl *FDecl,
+  MultiExprArg ArgExprs) {
+  auto ID = 

[PATCH] D19930: [Lifetime] Add lifetime markers for C++ lifetime-extended temporaries

2016-05-04 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: rsmith.
timshen added a subscriber: cfe-commits.

Use pushCleanupAfterFullExpr to add lifetime.end markers for 
lifetime-extended temporaries, similar to the way destructor calls get 
generated.

It does not change the AST representation. It doesn't generate normal temporary
lifetime markers, since normal temporaries appear in substantially different
places, which could be done in a separate patch.

http://reviews.llvm.org/D19930

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/EHScopeStack.h
  test/CodeGen/lifetime-extended-temporaries.cpp

Index: test/CodeGen/lifetime-extended-temporaries.cpp
===
--- /dev/null
+++ test/CodeGen/lifetime-extended-temporaries.cpp
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 %s -std=c++11 -O1 -DWITH_DTOR -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-DTOR %s
+// RUN: %clang_cc1 %s -std=c++11 -O1 -triple x86_64 -emit-llvm -o - | FileCheck -check-prefix=CHECK-NO-DTOR %s
+
+struct A {
+  A();
+#ifdef WITH_DTOR
+  ~A();
+#endif
+  char a[1024];
+  operator bool() const;
+};
+
+template 
+void Foo(T &&);
+
+template 
+void Bar(T &&);
+
+template 
+T Baz();
+
+void Test1() {
+  // CHECK-DTOR-LABEL: Test1
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test1
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR]])
+  // CHECK-NO-DTOR: }
+  {
+const A  = A{};
+Foo(a);
+  }
+  {
+const A  = A{};
+Foo(a);
+  }
+}
+
+void Test2() {
+  // CHECK-DTOR-LABEL: Test2
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR2]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-DTOR: call void @_ZN1AD1Ev(%struct.A* nonnull %[[VAR1]])
+  // CHECK-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-DTOR: }
+
+  // CHECK-NO-DTOR-LABEL: Test2
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR1:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR1:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.start(i64 1024, i8* %[[ADDR2:[0-9]+]])
+  // CHECK-NO-DTOR: call void @_ZN1AC1Ev(%struct.A* nonnull %[[VAR2:[^ ]+]])
+  // CHECK-NO-DTOR: call void @_Z3FooIRK1AEvOT_
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR2]])
+  // CHECK-NO-DTOR: call void @llvm.lifetime.end(i64 1024, i8* %[[ADDR1]])
+  // CHECK-NO-DTOR: }
+  const A  = A{};
+  Foo(a);
+  const A  = A{};
+  Foo(b);
+}
+
+void Test3() {
+  // CHECK-DTOR-LABEL: Test3
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: if.then:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: cleanup{{.*}}:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: }
+  const A  = A{};
+  if (const A  = A(a)) {
+Foo(b);
+return;
+  }
+  Bar(a);
+}
+
+void Test4() {
+  // CHECK-DTOR-LABEL: Test4
+  // CHECK-DTOR: entry:
+  // CHECK-DTOR: call void @llvm.lifetime.start
+  // CHECK-DTOR: for.cond.cleanup:
+  // CHECK-DTOR: call void @llvm.lifetime.end
+  // CHECK-DTOR: for.body:
+  // 

Re: [Clang] Convergent Attribute

2016-05-04 Thread Aaron Ballman via cfe-commits
On Tue, May 3, 2016 at 12:18 PM, Ettore Speziale
 wrote:
> Hello,
>
> the attached patch introduces the `convergent` attribute.
>
> It is meant to be lowered into the LLVM `convergent` attribute, to restrict 
> optimizations of attributed functions — e.g. you can attach convergent to 
> OpenCL’s barrier, and thus prevent a call site being moved to another 
> position which is not control equivalent.

I would appreciate a bit more background on this attribute's
semantics. How would a user know when to add this attribute to their
function definition? Are there other attributes that cannot be used in
conjunction with this one? Should this apply to member functions? What
about Objective-C methods?

> diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
> index df41aeb..eafafc6 100644
> --- a/include/clang/Basic/Attr.td
> +++ b/include/clang/Basic/Attr.td
> @@ -580,6 +580,12 @@ def Constructor : InheritableAttr {
>let Documentation = [Undocumented];
>  }
>
> +def Convergent : InheritableAttr {
> +  let Spellings = [GNU<"convergent">];

Is there a reason to not support this under CXX11<"clang",
"convergent"> as well?

> +  let Subjects = SubjectList<[Function]>;
> +  let Documentation = [Undocumented];

Please, no new undocumented attributes.

> +}
> +
>  def CUDAConstant : InheritableAttr {
>let Spellings = [GNU<"constant">];
>let Subjects = SubjectList<[Var]>;
> diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
> index 50ea7f7..3e69c79 100644
> --- a/lib/CodeGen/CGCall.cpp
> +++ b/lib/CodeGen/CGCall.cpp
> @@ -1626,6 +1626,8 @@ void CodeGenModule::ConstructAttributeList(
>FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
>  if (TargetDecl->hasAttr())
>FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate);
> +if (TargetDecl->hasAttr())
> +  FuncAttrs.addAttribute(llvm::Attribute::Convergent);
>
>  if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) {
>AddAttributesFromFunctionProtoType(
> diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
> index cbc95dc..847ed6c 100644
> --- a/lib/Sema/SemaDeclAttr.cpp
> +++ b/lib/Sema/SemaDeclAttr.cpp
> @@ -5426,6 +5426,9 @@ static void ProcessDeclAttribute(Sema , Scope *scope, 
> Decl *D,
>case AttributeList::AT_Constructor:
>  handleConstructorAttr(S, D, Attr);
>  break;
> +  case AttributeList::AT_Convergent:
> +handleSimpleAttribute(S, D, Attr);
> +break;
>case AttributeList::AT_CXX11NoReturn:
>  handleSimpleAttribute(S, D, Attr);
>  break;
> diff --git a/test/CodeGen/attr-convergent.c b/test/CodeGen/attr-convergent.c
> new file mode 100644
> index 000..d759e75
> --- /dev/null
> +++ b/test/CodeGen/attr-convergent.c
> @@ -0,0 +1,18 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | 
> FileCheck %s
> +
> +int f0(void) __attribute__((convergent));
> +
> +int f1(void) {
> +  return f0();
> +}
> +
> +// CHECK: define i32 @f1() [[ATTR_1:#[0-9]+]] {
> +// CHECK:   [[RET:%.+]] = call i32 @f0() [[ATTR_CS:#[0-9]+]]
> +// CHECK:   ret i32 [[RET]]
> +// CHECK: }
> +
> +// CHECK: declare i32 @f0() [[ATTR_0:#[0-9]+]]
> +
> +// CHECK-NOT: attributes [[ATTR_1]] = { convergent {{.*}} }
> +// CHECK: attributes [[ATTR_0]] = { convergent {{.*}} }
> +// CHECK: attributes [[ATTR_CS]] = { convergent }
> diff --git a/test/Sema/attr-convergent.c b/test/Sema/attr-convergent.c
> new file mode 100644
> index 000..d9a9db9
> --- /dev/null
> +++ b/test/Sema/attr-convergent.c
> @@ -0,0 +1,7 @@
> +// RUN: %clang_cc1 %s -verify -fsyntax-only
> +
> +int t0 __attribute__((convergent)); // expected-warning {{'convergent' 
> attribute only applies to functions}}
> +
> +void t1() __attribute__((convergent));
> +
> +void t2() __attribute__((convergent(2))); // expected-error {{'convergent' 
> attribute takes no arguments}}
>

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


Re: [PATCH] D19062: Add functions in ctype.h to builtin function database (Fix)

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D19062#41, @twoh wrote:

> Ping. Can someone please commit this patch for me? Thanks!


Can you rebase the diff on ToT and update the review with the new patch? When I 
try to apply, I get merge conflicts. Thanks!


http://reviews.llvm.org/D19062



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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/readability/ReadabilityTidyModule.cpp:17
@@ -15,2 +16,2 @@
 #include "ContainerSizeEmptyCheck.h"
 #include "DeletedDefaultCheck.h"

I believe we use "modernize" to really mean "migrate from the old way to the 
new way", which this definitely fits into since I think the point to this check 
is to replace bind with better alternatives.


http://reviews.llvm.org/D16962



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


Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-04 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!


http://reviews.llvm.org/D19754



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-04 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.

This generally LGTM, but you should wait for @rsmith to sign off before 
committing.



Comment at: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp:39
@@ -38,3 +38,3 @@
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in 
instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }

Yeah, totally not worth it then. Thank you for the explanation.


http://reviews.llvm.org/D19851



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


Re: [PATCH] D19909: [Attr] Add support for the `ms_hook_prologue` attribute.

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Generally, I think this should make use of the patchable function functionality 
from http://reviews.llvm.org/D19046 when lowering, but I do have some comments 
on the attribute itself as well.



Comment at: include/clang/Basic/Attr.td:2032
@@ -2031,1 +2031,3 @@
 
+def MSHookPrologue : InheritableAttr {
+  let Spellings = [GCC<"ms_hook_prologue">];

Does this attribute appertain to all targets, or only targets that MSVC 
supports?


Comment at: include/clang/Basic/Attr.td:2035
@@ +2034,3 @@
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}

Please, no undocumented new attributes.


http://reviews.llvm.org/D19909



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


Re: [PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-05-04 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268532: [CodeGenObjCXX] Fix handling of blocks in lambda. 
(authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D19536?vs=56090=56183#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19536

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp

Index: cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
===
--- cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
+++ cfe/trunk/test/CodeGenObjCXX/block-nested-in-lambda.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s
+
+// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
+// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
+// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
+// CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6
+// CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1
+// CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8
+// CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8
+
+void foo1(int &, int &);
+
+void block_in_lambda(int , int ) {
+  auto lambda = [, ]() {
+auto block = ^{
+  foo1(s1, s2);
+};
+block();
+  };
+
+  lambda();
+}
Index: cfe/trunk/lib/CodeGen/CGBlocks.cpp
===
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp
@@ -780,35 +780,34 @@
 // Compute the address of the thing we're going to move into the
 // block literal.
 Address src = Address::invalid();
-if (BlockInfo && CI.isNested()) {
-  // We need to use the capture from the enclosing block.
-  const CGBlockInfo::Capture  =
-BlockInfo->getCapture(variable);
-
-  // This is a [[type]]*, except that a byref entry wil just be an i8**.
-  src = Builder.CreateStructGEP(LoadBlockStruct(),
-enclosingCapture.getIndex(),
-enclosingCapture.getOffset(),
-"block.capture.addr");
-} else if (blockDecl->isConversionFromLambda()) {
+
+if (blockDecl->isConversionFromLambda()) {
   // The lambda capture in a lambda's conversion-to-block-pointer is
   // special; we'll simply emit it directly.
   src = Address::invalid();
-} else {
-  // Just look it up in the locals map, which will give us back a
-  // [[type]]*.  If that doesn't work, do the more elaborate DRE
-  // emission.
-  auto it = LocalDeclMap.find(variable);
-  if (it != LocalDeclMap.end()) {
-src = it->second;
+} else if (CI.isByRef()) {
+  if (BlockInfo && CI.isNested()) {
+// We need to use the capture from the enclosing block.
+const CGBlockInfo::Capture  =
+BlockInfo->getCapture(variable);
+
+// This is a [[type]]*, except that a byref entry wil just be an i8**.
+src = Builder.CreateStructGEP(LoadBlockStruct(),
+  enclosingCapture.getIndex(),
+  enclosingCapture.getOffset(),
+  "block.capture.addr");
   } else {
-DeclRefExpr declRef(
-const_cast(variable),
-/*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type,
-VK_LValue, SourceLocation());
-src = EmitDeclRefLValue().getAddress();
+auto I = LocalDeclMap.find(variable);
+assert(I != LocalDeclMap.end());
+src = I->second;
   }
-}
+} else {
+  DeclRefExpr declRef(const_cast(variable),
+  /*RefersToEnclosingVariableOrCapture*/ CI.isNested(),
+  type.getNonReferenceType(), VK_LValue,
+  SourceLocation());
+  src = EmitDeclRefLValue().getAddress();
+};
 
 // For byrefs, we just write the pointer to the byref struct into
 // the block field.  There's no need to chase the forwarding
@@ -842,8 +841,7 @@
 
 // If it's a reference variable, copy the reference into the block field.
 } else if (type->isReferenceType()) {
-  llvm::Value *ref = Builder.CreateLoad(src, "ref.val");
-  Builder.CreateStore(ref, blockField);
+  Builder.CreateStore(src.getPointer(), blockField);
 
 // If this 

Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-04 Thread Aaron Ballman via cfe-commits
On Wed, May 4, 2016 at 2:41 PM, Piotr Padlewski via cfe-commits
 wrote:
> Prazek added a comment.
>
> In http://reviews.llvm.org/D18919#419902, @curdeius wrote:
>
>> I'm really interested in the manner this check works when a typedef has 
>> multiple declarations in it (same example as in the comment):
>>
>>   typedef int m_int, *m_int_p, _int_r, m_int_arr[10], (_int_fun)(int, 
>> int);
>>
>>
>> I tried to implement such a check once, but this was the hard part. FYI, 
>> that's my stub: 
>> https://github.com/llvm-mirror/clang-tools-extra/compare/master...mkurdej:feature/use-using.
>
>
> I don't think that this featcher is necessary. I don't know a lot of code 
> using it. I am curious how this check will behave.

FWIW, this is a very common pattern in Win32 headers. You most often see it as:

typedef struct _THING {
  // members
} THING, *LPTHING;

You'll also see:

typedef THING THING32, *LPTHING32;

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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-04 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D18919#419902, @curdeius wrote:

> I'm really interested in the manner this check works when a typedef has 
> multiple declarations in it (same example as in the comment):
>
>   typedef int m_int, *m_int_p, _int_r, m_int_arr[10], (_int_fun)(int, 
> int);
>
>
> I tried to implement such a check once, but this was the hard part. FYI, 
> that's my stub: 
> https://github.com/llvm-mirror/clang-tools-extra/compare/master...mkurdej:feature/use-using.


I don't think that this featcher is necessary. I don't know a lot of code using 
it. I am curious how this check will behave.


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1575
@@ +1574,3 @@
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";

etienneb wrote:
> aaron.ballman wrote:
> > Split these onto two lines?
> If I look around, it seems to be more consistent to keep it on the same line 
> (line 1563)
> 
> ```
> ///   char *s = "abcd"; wchar_t *ws = L"abcd";
> ```
> 
> ```
> ///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
> ```
> 
> ```
> ///   char ch = 'a'; wchar_t chw = L'a';
> ``
I don't have a strong opinion on it; however, since these get turned into 
examples that are on the website, I would weakly prefer the examples not be 
hideous. :-P


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

etienneb wrote:
> etienneb wrote:
> > aaron.ballman wrote:
> > > Perhaps we can adjust the `hasSize()` matcher instead? It currently works 
> > > with ConstantArrayType, but it seems reasonable for it to also work with 
> > > StringLiteral.
> > I didn't like the term "size" as it typically refer to the size in bytes.
> > Which is not the same for a wide-string.
> > 
> > Now, there is two different convention for naming matchers:
> >   hasLength   and  lengthIs  ?
> > 
> > Any toughs on that?
> > 
> > 
> Here is the matcher for hasSize
> ```
> AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
>   return Node.getSize() == N;
> }
> ```
> 
> It's getting the getSize attribute. I believe we should stick with the name 
> of the attribute.
> But, I'm not sure if we should use hasLength, or lengthIs.
I'm not too worried about size vs length (for instance, std::string has both). 
I would imagine this being implemented the same way we do other things with 
variance in API but not concept. See GetBodyMatcher in ASTMatchersInternal.h 
(and others near there) as an example.

I prefer hasSize because the two concepts are quite similar. For instance, a 
string literal's type is of a constant array type already.


http://reviews.llvm.org/D19876



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


Re: [PATCH] D18815: [ObjC] Enter a new evaluation context before calling BuildBlockForLambdaConversion.

2016-05-04 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268527: [ObjC] Enter a new evaluation context before calling 
(authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D18815?vs=56092=56178#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18815

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaObjCXX/block-cleanup.mm

Index: cfe/trunk/test/SemaObjCXX/block-cleanup.mm
===
--- cfe/trunk/test/SemaObjCXX/block-cleanup.mm
+++ cfe/trunk/test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o 
/dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys 
count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;


Index: cfe/trunk/test/SemaObjCXX/block-cleanup.mm
===
--- cfe/trunk/test/SemaObjCXX/block-cleanup.mm
+++ cfe/trunk/test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o /dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268527 - [ObjC] Enter a new evaluation context before calling

2016-05-04 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed May  4 13:07:20 2016
New Revision: 268527

URL: http://llvm.org/viewvc/llvm-project?rev=268527=rev
Log:
[ObjC] Enter a new evaluation context before calling
BuildBlockForLambdaConversion.

Previously, clang would build an incorrect AST for the following code:

id test() {
  return @{@"a": [](){}, @"b": [](){}};
}

ReturnStmt 0x10d080448
`-ExprWithCleanups 0x10d080428
  |-cleanup Block 0x10d0801f0 // points to the second BlockDecl
...
-BlockDecl 0x10d07f150 // First block
...
-BlockDecl 0x10d0801f0 // Second block
...
 `-ExprWithCleanups 0x10d0801d0
   |-cleanup Block 0x10d07f150 // points to the first BlockDecl

To fix the bug, this commit enters a new evaluation context to reset
ExprNeedsCleanups before each block is parsed.

rdar://problem/16879958

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

Added:
cfe/trunk/test/SemaObjCXX/block-cleanup.mm
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=268527=268526=268527=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed May  4 13:07:20 2016
@@ -6229,9 +6229,12 @@ ExprResult Sema::BuildCXXMemberCallExpr(
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;

Added: cfe/trunk/test/SemaObjCXX/block-cleanup.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/block-cleanup.mm?rev=268527=auto
==
--- cfe/trunk/test/SemaObjCXX/block-cleanup.mm (added)
+++ cfe/trunk/test/SemaObjCXX/block-cleanup.mm Wed May  4 13:07:20 2016
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o 
/dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys 
count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}


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


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

Aaron? could you comment on it?



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1575
@@ +1574,3 @@
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";

aaron.ballman wrote:
> Split these onto two lines?
If I look around, it seems to be more consistent to keep it on the same line 
(line 1563)

```
///   char *s = "abcd"; wchar_t *ws = L"abcd";
```

```
///   int array[4] = {1}; vector int myvec = (vector int)(1, 2);
```

```
///   char ch = 'a'; wchar_t chw = L'a';
``


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

etienneb wrote:
> aaron.ballman wrote:
> > Perhaps we can adjust the `hasSize()` matcher instead? It currently works 
> > with ConstantArrayType, but it seems reasonable for it to also work with 
> > StringLiteral.
> I didn't like the term "size" as it typically refer to the size in bytes.
> Which is not the same for a wide-string.
> 
> Now, there is two different convention for naming matchers:
>   hasLength   and  lengthIs  ?
> 
> Any toughs on that?
> 
> 
Here is the matcher for hasSize
```
AST_MATCHER_P(ConstantArrayType, hasSize, unsigned, N) {
  return Node.getSize() == N;
}
```

It's getting the getSize attribute. I believe we should stick with the name of 
the attribute.
But, I'm not sure if we should use hasLength, or lengthIs.


http://reviews.llvm.org/D19876



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


Re: [PATCH] D19846: [clang-tidy] Lift parsing of sequence of names functions to utils.

2016-05-04 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 56173.
etienneb marked 4 inline comments as done.
etienneb added a comment.

address alexfh comments


http://reviews.llvm.org/D19846

Files:
  clang-tidy/misc/DanglingHandleCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/OptionsUtils.cpp
  clang-tidy/utils/OptionsUtils.h

Index: clang-tidy/utils/OptionsUtils.h
===
--- /dev/null
+++ clang-tidy/utils/OptionsUtils.h
@@ -0,0 +1,31 @@
+//===--- DanglingHandleCheck.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_OPTIONUTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace options {
+
+/// \brief Parse a semicolon separated list of strings.
+std::vector parseStrings(StringRef Option);
+
+/// \brief Serialize a sequence of names that can be parsed by 'parseStrings'.
+std::string serializeStrings(ArrayRef Strings);
+
+} // namespace options
+} // namespace utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OPTIONUTILS_H
Index: clang-tidy/utils/OptionsUtils.cpp
===
--- /dev/null
+++ clang-tidy/utils/OptionsUtils.cpp
@@ -0,0 +1,38 @@
+//===--- DanglingHandleCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "OptionsUtils.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace options {
+
+static const char StringsDelimiter[] = ";";
+
+std::vector parseStrings(StringRef Option) {
+  SmallVector Names;
+  Option.split(Names, StringsDelimiter);
+  std::vector Result;
+  for (StringRef  : Names) {
+Name = Name.trim();
+if (!Name.empty())
+  Result.push_back(Name);
+  }
+  return Result;
+}
+
+std::string serializeStrings(ArrayRef Strings) {
+  return llvm::join(Strings.begin(), Strings.end(), StringsDelimiter);
+}
+
+} // namespace options
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/utils/CMakeLists.txt
===
--- clang-tidy/utils/CMakeLists.txt
+++ clang-tidy/utils/CMakeLists.txt
@@ -3,11 +3,12 @@
 add_clang_library(clangTidyUtils
   DeclRefExprUtils.cpp
   FixItHintUtils.cpp
-  HeaderGuard.cpp
   HeaderFileExtensionsUtils.cpp
+  HeaderGuard.cpp
   IncludeInserter.cpp
   IncludeSorter.cpp
   LexerUtils.cpp
+  OptionsUtils.cpp
   TypeTraits.cpp
 
   LINK_LIBS
Index: clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tidy/performance/FasterStringFindCheck.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "FasterStringFindCheck.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/Optional.h"
@@ -21,20 +22,6 @@
 
 namespace {
 
-static const char StringLikeClassesDelimiter[] = ";";
-
-std::vector ParseClasses(StringRef Option) {
-  SmallVector Classes;
-  Option.split(Classes, StringLikeClassesDelimiter);
-  std::vector Result;
-  for (StringRef  : Classes) {
-Class = Class.trim();
-if (!Class.empty())
-  Result.push_back(Class);
-  }
-  return Result;
-}
-
 llvm::Optional MakeCharacterLiteral(const StringLiteral *Literal) {
   std::string Result;
   {
@@ -64,14 +51,13 @@
 FasterStringFindCheck::FasterStringFindCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  StringLikeClasses(
-  ParseClasses(Options.get("StringLikeClasses", "std::basic_string"))) {
+  StringLikeClasses(utils::options::parseStrings(
+  Options.get("StringLikeClasses", "std::basic_string"))) {
 }
 
 void FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "StringLikeClasses",
-llvm::join(StringLikeClasses.begin(), StringLikeClasses.end(),
-   StringLikeClassesDelimiter));
+utils::options::serializeStrings(StringLikeClasses));
 }
 

Re: [PATCH] D19925: Fixed test not to depend on loop unrolling pass

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai abandoned this revision.
mamai added a comment.

The test have been fixed otherwise in rev 268523.


Repository:
  rL LLVM

http://reviews.llvm.org/D19925



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


[PATCH] D19925: Fixed test not to depend on loop unrolling pass

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai created this revision.
mamai added a reviewer: compnerd.
mamai added a subscriber: cfe-commits.
mamai set the repository for this revision to rL LLVM.

This test have been broken by http://reviews.llvm.org/D19827, which re-enables 
loop unrolling at /Os. Since the goal of this test does not seem related 
unrolling, just disabled loop unroll pass when compiling this test.

Repository:
  rL LLVM

http://reviews.llvm.org/D19925

Files:
  test/CodeGenObjCXX/arc-cxx11-init-list.mm

Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os 
-fno-unroll-loops -emit-llvm -o - %s | FileCheck %s
 
 typedef __SIZE_TYPE__ size_t;
 


Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s
 
 typedef __SIZE_TYPE__ size_t;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-05-04 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 56164.
filcab added a comment.

Remove unneeded comments.
Simplify code.


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 using namespace clang;
@@ -2367,7 +2368,38 @@
 
   PresumedLoc PLoc = getContext().getSourceManager().getPresumedLoc(Loc);
   if (PLoc.isValid()) {
-auto FilenameGV = CGM.GetAddrOfConstantCString(PLoc.getFilename(), ".src");
+StringRef FilenameString = 

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@mclow.lists, @EricWF: Gentle ping.


http://reviews.llvm.org/D19412



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421230, @bcraig wrote:

> > We could, on the other hand, do this tightening for all the supported 
> > architectures (for the new, native-only libunwind build suggested by 
> > @jroelofs) with appropriate asserts in place so that we maintain these 
> > tight bounds as we move forward. Not sure if that effort would be worth 
> > though, given that for most non-ARM targets, unwinder stack usage is not a 
> > huge concern.
>
>
> libunwind doesn't currently support Hexagon, but it has been investigated 
> some there.  Hexagon would care about stack usage as well.  I wouldn't be 
> surprised if some embedded MIPS and Power targets also cared.  I don't think 
> any of those targets come close to using 1K for their unwind context.


Right, in that case, I will do the tightening for all the existing 
architectures. Will add a comment explaining the expected behaviour for future 
changes as well.

Thanks.

/ Asiri


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

> We could, on the other hand, do this tightening for all the supported 
> architectures (for the new, native-only libunwind build suggested by 
> @jroelofs) with appropriate asserts in place so that we maintain these tight 
> bounds as we move forward. Not sure if that effort would be worth though, 
> given that for most non-ARM targets, unwinder stack usage is not a huge 
> concern.


libunwind doesn't currently support Hexagon, but it has been investigated some 
there.  Hexagon would care about stack usage as well.  I wouldn't be surprised 
if some embedded MIPS and Power targets also cared.  I don't think any of those 
targets come close to using 1K for their unwind context.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:98-101
@@ +97,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string , const std::string 
,
+   const std::vector , int 
LineNumber,
+   const FunctionInfo );
+

hokein wrote:
> However, changing `SymbolInfo` to class requires us to add many 
> setters/getters in it.
> 
> Currently the `SymbolInfo` is like `ClangTidyOptions` structure. 
So, multiple thoughts:
- generally, I think symbol info would better be an immutable type; that would 
mean that we wouldn't have setters, just getters, and initialize everything in 
the constructor
- afaik llvm/clang style  doesn't require accessors just because something is a 
class
- I believe ClangTidyOptions is a very different use case



http://reviews.llvm.org/D19913



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


Re: [PATCH] D19725: [Coverage] Fix an issue where a coverage region might not be created for a macro containing for or while statements.

2016-05-04 Thread Igor Kudrin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268511: [Coverage] Fix an issue where a coverage region 
might not be created for a… (authored by ikudrin).

Changed prior to commit:
  http://reviews.llvm.org/D19725?vs=55602=56159#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19725

Files:
  cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
  cfe/trunk/test/CoverageMapping/macroscopes.cpp

Index: cfe/trunk/test/CoverageMapping/macroscopes.cpp
===
--- cfe/trunk/test/CoverageMapping/macroscopes.cpp
+++ cfe/trunk/test/CoverageMapping/macroscopes.cpp
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
+// CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
+// CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
+// CHECK-NEXT: File 15, 32:17 -> 34:4 = #11
Index: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
===
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
@@ -443,15 +443,31 @@
 return ExitCount;
   }
 
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc
+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
+[&](const SourceMappingRegion ) {
+  return Region.getStartLoc() == StartLoc &&
+ Region.getEndLoc() == EndLoc;
+});
+  }
+
   /// \brief Adjust the most recently visited location to \c EndLoc.
   ///
   /// This should be used after visiting any statements in non-source order.
   void adjustForOutOfOrderTraversal(SourceLocation EndLoc) {
 MostRecentLocation = EndLoc;
-// Avoid adding duplicate regions if we have a completed region on the top
-// of the stack and are adjusting to the end of a virtual file.
+// The code region for a whole macro is created in handleFileExit() when
+// it detects exiting of the virtual file of that macro. If we visited
+// statements in non-source order, we might already have such a region
+// added, for example, if a body of a loop is divided among multiple
+// macros. Avoid adding duplicate regions in such case.
 if (getRegion().hasEndLoc() &&
-MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
+MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation) &&
+isRegionAlreadyAdded(getStartOfFileOrMacro(MostRecentLocation),
+ MostRecentLocation))
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 


Index: cfe/trunk/test/CoverageMapping/macroscopes.cpp
===
--- cfe/trunk/test/CoverageMapping/macroscopes.cpp
+++ cfe/trunk/test/CoverageMapping/macroscopes.cpp
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 

r268511 - [Coverage] Fix an issue where a coverage region might not be created for a macro containing a loop statement.

2016-05-04 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Wed May  4 10:38:26 2016
New Revision: 268511

URL: http://llvm.org/viewvc/llvm-project?rev=268511=rev
Log:
[Coverage] Fix an issue where a coverage region might not be created for a 
macro containing a loop statement.

The issue happened when a macro contained a full for or
while statement, which body ended at the end of the macro.

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

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
cfe/trunk/test/CoverageMapping/macroscopes.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=268511=268510=268511=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Wed May  4 10:38:26 2016
@@ -443,15 +443,31 @@ struct CounterCoverageMappingBuilder
 return ExitCount;
   }
 
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc
+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
+[&](const SourceMappingRegion ) {
+  return Region.getStartLoc() == StartLoc &&
+ Region.getEndLoc() == EndLoc;
+});
+  }
+
   /// \brief Adjust the most recently visited location to \c EndLoc.
   ///
   /// This should be used after visiting any statements in non-source order.
   void adjustForOutOfOrderTraversal(SourceLocation EndLoc) {
 MostRecentLocation = EndLoc;
-// Avoid adding duplicate regions if we have a completed region on the top
-// of the stack and are adjusting to the end of a virtual file.
+// The code region for a whole macro is created in handleFileExit() when
+// it detects exiting of the virtual file of that macro. If we visited
+// statements in non-source order, we might already have such a region
+// added, for example, if a body of a loop is divided among multiple
+// macros. Avoid adding duplicate regions in such case.
 if (getRegion().hasEndLoc() &&
-MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
+MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation) &&
+isRegionAlreadyAdded(getStartOfFileOrMacro(MostRecentLocation),
+ MostRecentLocation))
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 

Modified: cfe/trunk/test/CoverageMapping/macroscopes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/macroscopes.cpp?rev=268511=268510=268511=diff
==
--- cfe/trunk/test/CoverageMapping/macroscopes.cpp (original)
+++ cfe/trunk/test/CoverageMapping/macroscopes.cpp Wed May  4 10:38:26 2016
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@ int main() {
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@ int main() {
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
+// CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
+// CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
+// CHECK-NEXT: File 15, 32:17 -> 34:4 = #11


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


Re: [PATCH] D18815: [ObjC] Enter a new evaluation context before calling BuildBlockForLambdaConversion.

2016-05-04 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM.


http://reviews.llvm.org/D18815



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


Re: [PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-05-04 Thread John McCall via cfe-commits
rjmccall added a comment.

Yes, that looks good, thanks.


http://reviews.llvm.org/D19536



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421189, @jroelofs wrote:

> In http://reviews.llvm.org/D19920#421173, @rmaprath wrote:
>
> > In http://reviews.llvm.org/D19920#421145, @jroelofs wrote:
> >
> > > Wouldn't this break cross unwinding?
> >
> >
> > I wasn't aware of cross unwinding, I think you are referring to [1]. Thanks 
> > for the pointer.
> >
> > Would it make sense to support a libunwind build that only supports native 
> > unwinding? For baremetal (embedded) applications, I don't think cross 
> > unwinding (if I understand it correctly) makes a lot of sense.
> >
> > Thanks!
> >
> > / Asiri
> >
> > [1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4
>
>
> Yeah, that's what I'm referring to. I have no idea if it's currently working 
> or not, but *adding* a build mode that only supports native unwinding sounds 
> like a good idea.


Makes sense. I will update the patch to hide behind a build option.

@rengolin, @t.p.northover: From what I gathered so far, `libunwind.h` is 
supposed to be platform independent, so we cannot make the size computation 
generic as suggested (without tying up `libunwind.h` into library sources).

We could, on the other hand, do this tightening for all the supported 
architectures (for the new, native-only libunwind build suggested by @jroelofs) 
with appropriate asserts in place so that we maintain these tight bounds as we 
move forward. Not sure if that effort would be worth though, given that for 
most non-ARM targets, unwinder stack usage is not a huge concern.

Cheers,

/ Asiri


http://reviews.llvm.org/D19920



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


[libcxx] r268510 - Fixed some spelling errors in assert messages. No functional change. Thanks to giffu...@yahoo.com for the report.

2016-05-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed May  4 10:35:50 2016
New Revision: 268510

URL: http://llvm.org/viewvc/llvm-project?rev=268510=rev
Log:
Fixed some spelling errors in assert messages. No functional change. Thanks to 
giffu...@yahoo.com for the report.

Modified:
libcxx/trunk/include/experimental/string_view

Modified: libcxx/trunk/include/experimental/string_view
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=268510=268509=268510=diff
==
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Wed May  4 10:35:50 2016
@@ -227,7 +227,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 basic_string_view(const _CharT* __s, size_type __len)
 : __data(__s), __size(__len)
 {
-// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, 
"string_view::string_view(_CharT *, size_t): recieved nullptr");
+// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, 
"string_view::string_view(_CharT *, size_t): received nullptr");
 }
 
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
@@ -413,7 +413,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find(basic_string_view __s, size_type __pos = 0) const 
_NOEXCEPT
 {
-_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): recieved nullptr");
+_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): received nullptr");
 return _VSTD::__str_find
 (data(), size(), __s.data(), __pos, __s.size());
 }
@@ -428,7 +428,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find(const _CharT* __s, size_type __pos, size_type __n) const
 {
-_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): 
recieved nullptr");
+_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): 
received nullptr");
 return _VSTD::__str_find
 (data(), size(), __s, __pos, __n);
 }
@@ -436,7 +436,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find(const _CharT* __s, size_type __pos = 0) const
 {
-_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved 
nullptr");
+_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received 
nullptr");
 return _VSTD::__str_find
 (data(), size(), __s, __pos, traits_type::length(__s));
 }
@@ -445,7 +445,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type rfind(basic_string_view __s, size_type __pos = npos) const 
_NOEXCEPT
 {
-_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): recieved nullptr");
+_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find(): received nullptr");
 return _VSTD::__str_rfind
 (data(), size(), __s.data(), __pos, __s.size());
 }
@@ -460,7 +460,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type rfind(const _CharT* __s, size_type __pos, size_type __n) 
const
 {
-_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): 
recieved nullptr");
+_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): 
received nullptr");
 return _VSTD::__str_rfind
 (data(), size(), __s, __pos, __n);
 }
@@ -468,7 +468,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type rfind(const _CharT* __s, size_type __pos=npos) const
 {
-_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved 
nullptr");
+_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received 
nullptr");
 return _VSTD::__str_rfind
 (data(), size(), __s, __pos, traits_type::length(__s));
 }
@@ -477,7 +477,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 size_type find_first_of(basic_string_view __s, size_type __pos = 0) 
const _NOEXCEPT
 {
-_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find_first_of(): recieved nullptr");
+_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, 
"string_view::find_first_of(): received 

Re: [PATCH] D19827: Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268509: Do not disable completely loop unroll when 
optimizing for size. (authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19827?vs=56133=56158#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19827

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268509 - Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
Author: mamai
Date: Wed May  4 10:26:28 2016
New Revision: 268509

URL: http://llvm.org/viewvc/llvm-project?rev=268509=rev
Log:
Do not disable completely loop unroll when optimizing for size.

Let the loop unroll pass handle /Os. It already checks that option and adjust 
its thresholds accordingly. Also, will allow the #pragma unroll to have an 
effect in /Os.

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=268509=268508=268509=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May  4 10:26:28 2016
@@ -513,7 +513,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D19920#421173, @rmaprath wrote:

> In http://reviews.llvm.org/D19920#421145, @jroelofs wrote:
>
> > Wouldn't this break cross unwinding?
>
>
> I wasn't aware of cross unwinding, I think you are referring to [1]. Thanks 
> for the pointer.
>
> Would it make sense to support a libunwind build that only supports native 
> unwinding? For baremetal (embedded) applications, I don't think cross 
> unwinding (if I understand it correctly) makes a lot of sense.
>
> Thanks!
>
> / Asiri
>
> [1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4


Yeah, that's what I'm referring to. I have no idea if it's currently working or 
not, but *adding* a build mode that only supports native unwinding sounds like 
a good idea.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19827: Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

To be clear, loop unrolling just lowers its size threshold when -Os is on:

  // Apply size attributes
  if (L->getHeader()->getParent()->optForSize()) {
UP.Threshold = UP.OptSizeThreshold;
UP.PartialThreshold = UP.PartialOptSizeThreshold;
  }

So this does more than enabling loop unrolling when pragmas are present. 
However, it that behavior is wrong then we should fix it in LLVM.


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421145, @jroelofs wrote:

> Wouldn't this break cross unwinding?


I wasn't aware of cross unwinding, I think you are referring to [1]. Thanks for 
the pointer.

Would it make sense to support a libunwind build that only supports native 
unwinding? For baremetal (embedded) applications, I don't think cross unwinding 
(if I understand it correctly) makes a lot of sense.

Thanks!

/ Asiri

[1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D19920#421131, @t.p.northover wrote:

> I think it would be better to use a generic method so the size is minimal 
> everywhere rather than making ARM a special case. Possibly move the #define 
> bits from libunwind.cpp to __libunwind_config.h and use REGISTER_KIND to 
> declare unw_context_t?


Wouldn't this make `libunwind.h` depend on `Registers_xxx` types? I thought the 
whole idea of statically allocated buffers was to keep these two separate. I 
may be wrong though, pretty new to unwinder.

Thanks.

/ Asiri


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Renato Golin via cfe-commits
rengolin added a comment.

I agree with Tim, I think this should be more generic.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Wouldn't this break cross unwinding?


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Tim Northover via cfe-commits
t.p.northover added a subscriber: t.p.northover.
t.p.northover added a comment.

I think it would be better to use a generic method so the size is minimal 
everywhere rather than making ARM a special case. Possibly move the #define 
bits from libunwind.cpp to __libunwind_config.h and use REGISTER_KIND to 
declare unw_context_t?



Comment at: src/CompactUnwinder.hpp:490
@@ -488,3 +489,3 @@
 
-
+#elif defined(__arm64__) || defined(__aarch64__)
 /// CompactUnwinder_arm64 uses a compact unwind info to virtually "step" (aka

`__aarch64__` is defined for iOS too, so no need for both.


http://reviews.llvm.org/D19920



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added a comment.

It looks good to me now, but need to wait @klimek acceptance.



Comment at: include-fixer/find-all-symbols/SymbolInfo.h:98-101
@@ +97,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string , const std::string 
,
+   const std::vector , int 
LineNumber,
+   const FunctionInfo );
+

However, changing `SymbolInfo` to class requires us to add many setters/getters 
in it.

Currently the `SymbolInfo` is like `ClangTidyOptions` structure. 


http://reviews.llvm.org/D19913



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


[PATCH] D19920: [libunwind][ARM] Improve unwinder stack usage on baremetal targets - part 1

2016-05-04 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added a reviewer: jroelofs.
rmaprath added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Currently, `unw_context_t` and `unw_cursor_t` are sized to allow the virtual 
register set of any target supported by libunwind. This does not work well for 
baremetal ARM targets (where memory is at a premium).

This patch makes `unw_context_t` and `unw_cursor_t` use just enough space to 
hold the ARM virtual register set on baremetal arm targets.

The various `Registers_xxx` definitions (and their dependencies) had to be 
conditionally compiled out in order to allow each of the targets to perform 
size checks independently.

This change saves about 1500 bytes of stack on ARM v7 (similar amount on 
AArch32).

http://reviews.llvm.org/D19920

Files:
  include/libunwind.h
  src/CompactUnwinder.hpp
  src/Registers.hpp
  src/UnwindCursor.hpp
  src/libunwind.cpp

Index: src/libunwind.cpp
===
--- src/libunwind.cpp
+++ src/libunwind.cpp
@@ -45,30 +45,29 @@
   _LIBUNWIND_TRACE_API("unw_init_local(cursor=%p, context=%p)\n",
static_cast(cursor),
static_cast(context));
-  // Use "placement new" to allocate UnwindCursor in the cursor buffer.
 #if defined(__i386__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_x86
 #elif defined(__x86_64__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_x86_64
 #elif defined(__ppc__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_ppc
 #elif defined(__arm64__) || defined(__aarch64__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_arm64
 #elif _LIBUNWIND_ARM_EHABI
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_arm
 #elif defined(__or1k__)
-  new ((void *)cursor) UnwindCursor(
- context, LocalAddressSpace::sThisAddressSpace);
+# define REGISTER_KIND Registers_or1k
 #elif defined(__mips__)
-#warning The MIPS architecture is not supported.
+# warning The MIPS architecture is not supported.
 #else
-#error Architecture not supported
+# error Architecture not supported
 #endif
+  static_assert(sizeof(UnwindCursor) <=
+sizeof(unw_cursor_t), "Unwind cursor does not fit in unw_cursor_t");
+  // Use "placement new" to allocate UnwindCursor in the cursor buffer.
+  new ((void *)cursor) UnwindCursor(
+ context, LocalAddressSpace::sThisAddressSpace);
+#undef REGISTER_KIND
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   co->setInfoBasedOnIPRegister();
 
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -481,30 +481,36 @@
 return stepWithCompactEncoding(dummy);
   }
 
+#if defined(__x86_64__)
   int stepWithCompactEncoding(Registers_x86_64 &) {
 return CompactUnwinder_x86_64::stepWithCompactEncoding(
 _info.format, _info.start_ip, _addressSpace, _registers);
   }
 
+#elif defined(__i386__)
   int stepWithCompactEncoding(Registers_x86 &) {
 return CompactUnwinder_x86::stepWithCompactEncoding(
 _info.format, (uint32_t)_info.start_ip, _addressSpace, _registers);
   }
 
+#elif defined(__ppc__)
   int stepWithCompactEncoding(Registers_ppc &) {
 return UNW_EINVAL;
   }
 
+#elif defined(__arm64__) || defined(__aarch64__)
   int stepWithCompactEncoding(Registers_arm64 &) {
 return CompactUnwinder_arm64::stepWithCompactEncoding(
 _info.format, _info.start_ip, _addressSpace, _registers);
   }
+#endif
 
   bool compactSaysUseDwarf(uint32_t *offset=NULL) const {
 R dummy;
 return compactSaysUseDwarf(dummy, offset);
   }
 
+#if defined(__x86_64__)
   bool compactSaysUseDwarf(Registers_x86_64 &, uint32_t *offset) const {
 if ((_info.format & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_DWARF) {
   if (offset)
@@ -514,6 +520,7 @@
 return false;
   }
 
+#elif defined(__i386__)
   bool compactSaysUseDwarf(Registers_x86 &, uint32_t *offset) const {
 if ((_info.format & UNWIND_X86_MODE_MASK) == UNWIND_X86_MODE_DWARF) {
   if (offset)
@@ -523,45 +530,54 @@
 return false;
   }
 
+#elif defined(__ppc__)

[PATCH] D19918: AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels.

2016-05-04 Thread Nikolay Haustov via cfe-commits
nhaustov created this revision.
nhaustov added reviewers: tstellarAMD, arsenm.
nhaustov added a subscriber: cfe-commits.

http://reviews.llvm.org/D19918

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGenOpenCL/amdgpu-calling-conv.cl
  test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl

Index: test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // 
expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() 
[[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // 
expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() 
[[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics
Index: test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6826,6 +6826,14 @@
   if (!FD)
 return;
 
+  if (M.getLangOpts().OpenCL) {
+if (FD->hasAttr()) {
+  // Set amdgpu_kernel calling convention for OpenCL kernels.
+  llvm::Function *Fn = cast(GV);
+  Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
+}
+  }
+
   if (const auto Attr = FD->getAttr()) {
 llvm::Function *F = cast(GV);
 uint32_t NumVGPR = Attr->getNumVGPR();


Index: test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics
Index: test/CodeGenOpenCL/amdgpu-calling-conv.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-calling-conv.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
+kernel void calling_conv_amdgpu_kernel()
+{
+}
+
+// CHECK: define void @calling_conv_none()
+void calling_conv_none()
+{
+}
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -6826,6 +6826,14 @@
   if (!FD)
 return;
 
+  if (M.getLangOpts().OpenCL) {
+if (FD->hasAttr()) {
+  // Set amdgpu_kernel 

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56147.
ioeric added a comment.

- Removed unused function in unit test.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto  : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo ) {
-return Reporter.getSymbolExtraInfo();
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher();
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory();
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,19 +89,6 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector ) {
-  SymbolInfo Symbol;
-  Symbol.Name = Name;
-  Symbol.Type = Type;
-  Symbol.FilePath = FilePath;
-  Symbol.LineNumber = LineNumber;
-  Symbol.Contexts = Contexts;
-  return Symbol;
-}
-
 TEST_F(FindAllSymbolsTest, VariableSymbols) {
   static const char Code[] = R"(
   extern int xargc;
@@ -127,29 +98,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +123,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +147,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56145.
ioeric added a comment.

- Use template to compare llvm::Optional types.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto  : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo ) {
-return Reporter.getSymbolExtraInfo();
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher();
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory();
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,10 +89,9 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector ) {
+SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
+const std::string FilePath, int LineNumber,
+const std::vector ) {
   SymbolInfo Symbol;
   Symbol.Name = Name;
   Symbol.Type = Type;
@@ -127,29 +110,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +135,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +159,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol =
+  

Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56143.
ioeric added a comment.

- Use static creator functions in SymbolInfo in FindAllSymbolTests, and make 
SymbolInfo::operator== compare all fields.


http://reviews.llvm.org/D19913

Files:
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -46,18 +46,6 @@
 return false;
   }
 
-  bool getSymbolExtraInfo(SymbolInfo *Symbol) {
-for (const auto  : Symbols) {
-  if (S == *Symbol) {
-Symbol->FunctionInfos = S.FunctionInfos;
-Symbol->TypedefNameInfos = S.TypedefNameInfos;
-Symbol->VariableInfos = S.VariableInfos;
-return true;
-  }
-}
-return false;
-  }
-
 private:
   std::vector Symbols;
 };
@@ -68,10 +56,6 @@
 return Reporter.hasSymbol(Symbol);
   }
 
-  bool getSymbolExtraInfo(SymbolInfo ) {
-return Reporter.getSymbolExtraInfo();
-  }
-
   bool runFindAllSymbols(StringRef Code) {
 FindAllSymbols matcher();
 clang::ast_matchers::MatchFinder MatchFinder;
@@ -87,7 +71,7 @@
 clang::tooling::newFrontendActionFactory();
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
- FileName},
+ std::string("-std=c++11"), FileName},
 Factory->create(), Files.get(),
 std::make_shared());
 
@@ -105,10 +89,9 @@
   MockReporter Reporter;
 };
 
-SymbolInfo
-CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
- const std::string FilePath, int LineNumber,
- const std::vector ) {
+SymbolInfo CreateSymbolInfo(StringRef Name, SymbolInfo::SymbolKind Type,
+const std::string FilePath, int LineNumber,
+const std::vector ) {
   SymbolInfo Symbol;
   Symbol.Name = Name;
   Symbol.Type = Type;
@@ -127,29 +110,19 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("xargc", SymbolInfo::Variable, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("", SymbolInfo::Variable, HeaderName, 4,
- {{SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("_Bool", Symbol.VariableInfos.getValue().Type);
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo(
-"", SymbolInfo::Variable, HeaderName, 5,
-{{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("const long long *", Symbol.VariableInfos.getValue().Type);
-  }
+  SymbolInfo Symbol =
+  SymbolInfo::CreateVariableSymbolInfo("xargc", HeaderName, {}, 2, {"int"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName, {{SymbolInfo::Namespace, "na"}}, 4, {"_Bool"});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateVariableSymbolInfo(
+  "", HeaderName,
+  {{SymbolInfo::Namespace, "nb"}, {SymbolInfo::Namespace, "na"}}, 5,
+  {"const long long *"});
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, ExternCSymbols) {
@@ -162,19 +135,12 @@
   })";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_Func", SymbolInfo::Function, HeaderName, 3, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-getSymbolExtraInfo(Symbol);
-EXPECT_EQ("int", Symbol.FunctionInfos.getValue().ReturnType);
-EXPECT_TRUE(Symbol.FunctionInfos.getValue().ParameterTypes.empty());
-  }
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("C_struct", SymbolInfo::Class, HeaderName, 4, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
+  SymbolInfo Symbol = SymbolInfo::CreateFunctionSymbolInfo("C_Func", HeaderName,
+   {}, 3, {"int", {}});
+  EXPECT_TRUE(hasSymbol(Symbol));
+
+  Symbol = SymbolInfo::CreateClassSymbolInfo("C_struct", HeaderName, {}, 4);
+  EXPECT_TRUE(hasSymbol(Symbol));
 }
 
 TEST_F(FindAllSymbolsTest, CXXRecordSymbols) {
@@ -193,16 +159,12 @@
   )";
   runFindAllSymbols(Code);
 
-  {
-SymbolInfo Symbol =
-CreateSymbolInfo("Glob", SymbolInfo::Class, HeaderName, 2, {});
-EXPECT_TRUE(hasSymbol(Symbol));
-  }
-  {
-SymbolInfo Symbol = CreateSymbolInfo("A", SymbolInfo::Class, HeaderName, 6,
- {{SymbolInfo::Namespace, 

Re: [PATCH] D19725: [Coverage] Fix an issue where a coverage region might not be created for a macro containing for or while statements.

2016-05-04 Thread Igor Kudrin via cfe-commits

Thank you!

On 02.05.2016 06:40, Justin Bogner wrote:

Igor Kudrin  writes:
  
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc

+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
Any particular reason for rbegin/rend? I guess you expect the match to
be near the end of the list when it exists?


Yes, exactly. I suppose that if that region exists, it's probably added 
recently.

+[=](const SourceMappingRegion ) {

There's no good reason to capture by value here. Best to use [&] for
efficiency.


OK.

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


Re: [PATCH] D19827: Do not disable completely loop unroll when optimizing for size.

2016-05-04 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai retitled this revision from "Do not disable completely loop unroll 
according to optimization level." to "Do not disable completely loop unroll 
when optimizing for size.".
mamai updated the summary for this revision.
mamai updated this revision to Diff 56133.
mamai added a comment.

Modified the patch not to affect /O1 optimization level.


Repository:
  rL LLVM

http://reviews.llvm.org/D19827

Files:
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -513,7 +513,7 @@
 getAllNoBuiltinFuncValues(Args, Opts.NoBuiltinFuncs);
   Opts.UnrollLoops =
   Args.hasFlag(OPT_funroll_loops, OPT_fno_unroll_loops,
-   (Opts.OptimizationLevel > 1 && !Opts.OptimizeSize));
+   (Opts.OptimizationLevel > 1));
   Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
 
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:90-93
@@ +89,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string , const std::string 
,
+   const std::vector , int 
LineNumber,
+   const FunctionInfo );
+

klimek wrote:
> To some degree this looks like we actually want a class hierarchy. But 
> currently only ClassSymbolInfo is used?
At this point yes, since Symbolnfo is only created in InMemoryXrefsDB and 
FindAllSymbols now, and it is not trivial to change FindAllSymbols to use these 
creators. 

But one immediate use case I can foresee is converting proto buffer SymbolInfo 
to clang SymbolInfo when integrating with Google3 XrefsDB. 


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein added a comment.

Not sure whether this is what @klimek expected..

You also need to update the FindAllSymbolsTests code (there is a 
CreateSymbolInfo function there).



Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:91
@@ +90,3 @@
+void SymbolInfo::SetCommonInfo(const std::string ,
+SymbolKind Kind, const std::string ,
+const std::vector ,

code indentation.


Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:105
@@ +104,3 @@
+const FunctionInfo ) {
+
+  SymbolInfo Ret;

A extra blank line.


Comment at: include-fixer/find-all-symbols/SymbolInfo.cpp:115
@@ +114,3 @@
+const std::vector , int LineNumber) {
+
+  SymbolInfo Ret;

The same.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:91
@@ +90,3 @@
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string , const std::string 
,
+   const std::vector , int 
LineNumber,

Use llvm::StringRef instead of `std::string&`.


http://reviews.llvm.org/D19913



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:418
@@ +417,3 @@
+
+  {
+SymbolInfo Symbol =

Why are the other test cases using an extra block?


http://reviews.llvm.org/D19816



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


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:90-93
@@ +89,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string , const std::string 
,
+   const std::vector , int 
LineNumber,
+   const FunctionInfo );
+

To some degree this looks like we actually want a class hierarchy. But 
currently only ClassSymbolInfo is used?


http://reviews.llvm.org/D19913



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


[clang-tools-extra] r268494 - [clang-tidy] Remove STL dependency from a test.

2016-05-04 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed May  4 07:17:55 2016
New Revision: 268494

URL: http://llvm.org/viewvc/llvm-project?rev=268494=rev
Log:
[clang-tidy] Remove STL dependency from a test.

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp?rev=268494=268493=268494=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
Wed May  4 07:17:55 2016
@@ -1,6 +1,16 @@
 // RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers
 
-#include 
+namespace std {
+template 
+struct remove_reference { typedef T type; };
+template 
+struct remove_reference { typedef T type; };
+template 
+struct remove_reference { typedef T type; };
+template 
+typename remove_reference::type &(T &);
+}
+
 
 struct Good {
   Good& operator=(const Good&);


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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56130.
hokein marked an inline comment as done.
hokein added a comment.

Update.


http://reviews.llvm.org/D19816

Files:
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -62,6 +65,41 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(),
+Matcher(Reporter, ) {
+Matcher.registerMatchers();
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance ,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler();
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo ) {
@@ -73,18 +111,16 @@
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher();
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers();
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory();
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory());
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  FileName},
@@ -371,5 +407,20 @@
   }
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+  }
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -8,8 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -82,6 +88,31 @@
   std::map Symbols;
 };
 
+class FindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  FindAllSymbolsAction()
+  : Reporter(), MatchFinder(), Collector(), Handler(),
+Matcher(, ) {
+Matcher.registerMatchers();
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance ,
+StringRef InFile) override {
+

Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-05-04 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Anna, will you commit this, or do you want me to commit the patches?


http://reviews.llvm.org/D12761



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


[clang-tools-extra] r268492 - [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature

2016-05-04 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Wed May  4 07:02:22 2016
New Revision: 268492

URL: http://llvm.org/viewvc/llvm-project?rev=268492=rev
Log:
[clang-tidy] New: checker misc-unconventional-assign-operator replacing 
misc-assign-operator-signature

Summary: Finds return statements in assign operator bodies where the return 
value is different from '*this'. Only assignment operators with correct return 
value Class& are checked.

Reviewers: aaron.ballman, alexfh, sbenza

Subscribers: o.gyorgy, baloghadamsoftware, LegalizeAdulthood, aaron.ballman, 
Eugene.Zelenko, xazax.hun, cfe-commits

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

Added:

clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-assign-operator-signature.rst
clang-tools-extra/trunk/test/clang-tidy/misc-assign-operator-signature.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=268492=268491=268492=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Wed May  4 07:02:22 2016
@@ -10,7 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
-#include "../misc/AssignOperatorSignatureCheck.h"
+#include "../misc/UnconventionalAssignOperatorCheck.h"
 #include "InterfacesGlobalInitCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
@@ -53,7 +53,7 @@ public:
 "cppcoreguidelines-pro-type-union-access");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-vararg");
-CheckFactories.registerCheck(
+CheckFactories.registerCheck(
 "cppcoreguidelines-c-copy-assignment-signature");
   }
 };

Removed: 
clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=268491=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp 
(removed)
@@ -1,80 +0,0 @@
-//===--- AssignOperatorSignatureCheck.cpp - clang-tidy --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "AssignOperatorSignatureCheck.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-void AssignOperatorSignatureCheck::registerMatchers(
-ast_matchers::MatchFinder *Finder) {
-  // Only register the matchers for C++; the functionality currently does not
-  // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus)
-return;
-
-  const auto HasGoodReturnType = cxxMethodDecl(returns(
-  lValueReferenceType(pointee(unless(isConstQualified()),
-  hasDeclaration(equalsBoundNode("class"));
-
-  const auto IsSelf = qualType(
-  anyOf(hasDeclaration(equalsBoundNode("class")),
-referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
-  const auto IsAssign =
-  cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
-hasName("operator="), ofClass(recordDecl().bind("class")))
-  .bind("method");
-  const auto IsSelfAssign =
-  cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf
-  .bind("method");
-
-  Finder->addMatcher(
-  cxxMethodDecl(IsAssign, 

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-04 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:48
@@ +47,3 @@
+  explicit FindAllSymbols(ResultReporter *Reporter,
+  HeaderMapCollector *Collector)
+  : Reporter(Reporter), Collector(Collector) {}

I'd pass in the HeaderMap here.


Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.h:22
@@ +21,3 @@
+
+/// \brief PragmaCommentHandler handle all pragma comment. It supports a way 
for
+/// clients to control their include path.

"PragmaCommentHandler handle all pragma comment"
This comment doesn't really tell me anything new.

Perhaps:
PragmaCommentHandler parses comments on include files to determine when we 
should include a different header from the header that directly defines a 
symbol.


Comment at: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp:418
@@ +417,3 @@
+
+  {
+SymbolInfo Symbol =

Any reason for the extra block here?


http://reviews.llvm.org/D19816



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


  1   2   >