Re: [PATCH] D12855: [OpenCL] Add new types for OpenCL 2.0.

2015-09-15 Thread Alexey Bader via cfe-commits
bader added a comment.

In http://reviews.llvm.org/D12855#246004, @pekka.jaaskelainen wrote:

> The patch seems straightforward enough. BTW does someone know if anyone has 
> worked on the 'pipe' qualifier?


I'm currently supporting Intel's implementation of 'pipe' qualifier and I'd 
like to contribute this implementation to the community if there is any 
interest.



Comment at: lib/Serialization/ASTCommon.cpp:70
@@ -69,1 +69,3 @@
   case BuiltinType::OCLImage2dArray:  ID = PREDEF_TYPE_IMAGE2D_ARR_ID;  break;
+  case BuiltinType::OCLImage2dDepth:
+ID = PREDEF_TYPE_IMAGE2D_DEP_ID;

pekka.jaaskelainen wrote:
> A nitpick, but why deviate from the style where each case has been stuffed to 
> a single line?
My guess it's effect of clang-format. Original patch sent by Pedro matched the 
style, but violated 80-character limit, so he was asked to run clang-format 
over the patch. Do you want me to run clang-format on surrounding code to unify 
the style?


http://reviews.llvm.org/D12855



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


r247667 - Make clang/test/CodeGen/catch-undef-behavior.c* capable of -Asserts with "opt -instnamer".

2015-09-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Sep 15 04:50:24 2015
New Revision: 247667

URL: http://llvm.org/viewvc/llvm-project?rev=247667&view=rev
Log:
Make clang/test/CodeGen/catch-undef-behavior.c* capable of -Asserts with "opt 
-instnamer".

It reverts r231717.

Modified:
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp

Modified: cfe/trunk/test/CodeGen/catch-undef-behavior.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-undef-behavior.c?rev=247667&r1=247666&r2=247667&view=diff
==
--- cfe/trunk/test/CodeGen/catch-undef-behavior.c (original)
+++ cfe/trunk/test/CodeGen/catch-undef-behavior.c Tue Sep 15 04:50:24 2015
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 
-fsanitize=alignment,null,object-size,shift-base,shift-exponent,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize-recover=alignment,null,object-size,shift-base,shift-exponent,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s 
--check-prefix=CHECK-COMMON --check-prefix=CHECK-UBSAN
-// RUN: %clang_cc1 
-fsanitize-trap=alignment,null,object-size,shift-base,shift-exponent,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize-recover=alignment,null,object-size,shift-base,shift-exponent,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize=alignment,null,object-size,shift-base,shift-exponent,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize-recover=alignment,null,object-size,shift-base,shift-exponent,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s 
--check-prefix=CHECK-COMMON --check-prefix=CHECK-TRAP
+// RUN: %clang_cc1 
-fsanitize=alignment,null,object-size,shift-base,shift-exponent,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize-recover=alignment,null,object-size,shift-base,shift-exponent,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 -emit-llvm %s -o - -triple x86_64-linux-gnu | opt -instnamer -S | FileCheck %s 
--check-prefix=CHECK-COMMON --check-prefix=CHECK-UBSAN
+// RUN: %clang_cc1 
-fsanitize-trap=alignment,null,object-size,shift-base,shift-exponent,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize-recover=alignment,null,object-size,shift-base,shift-exponent,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize=alignment,null,object-size,shift-base,shift-exponent,return,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 
-fsanitize-recover=alignment,null,object-size,shift-base,shift-exponent,signed-integer-overflow,vla-bound,float-cast-overflow,integer-divide-by-zero,bool,returns-nonnull-attribute,nonnull-attribute
 -emit-llvm %s -o - -triple x86_64-linux-gnu | opt -instnamer -S | FileCheck %s 
--check-prefix=CHECK-COMMON --check-prefix=CHECK-TRAP
 // RUN: %clang_cc1 -fsanitize=null -fsanitize-recover=null -emit-llvm %s -o - 
-triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-NULL
 // RUN: %clang_cc1 -fsanitize=signed-integer-overflow -emit-llvm %s -o - 
-triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK-OVERFLOW
-// REQUIRES: asserts
 
 // CHECK-UBSAN: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x 
i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
 

Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=247667&r1=247666&r2=247667&view=diff
==
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Tue Sep 15 04:50:24 2015
@@ -1,9 +1,8 @@
-// RUN: %clang_cc1 -std=c++11 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift-base,shift-exponent,unreachable,return,vla-bound,alignment,null,vptr,object-size,float-cast-overflow,bool,enum,array-bounds,function
 
-fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,float-divide-by-zero,shift-base,shift-e

Re: [PATCH] D12855: [OpenCL] Add new types for OpenCL 2.0.

2015-09-15 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen added a comment.

We are interested in the pipe.

I don't think it makes sense to increase the patch size by running the 
stylifier. Perhaps in an additional patch after this?


http://reviews.llvm.org/D12855



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


Re: [PATCH][Solaris] Default to -fno-cxa-finalize

2015-09-15 Thread Xan López via cfe-commits
On Mon, Sep 14, 2015 at 07:24:11PM -0400, Rafael Espíndola wrote:
> From the driver point of view, how does it know if it is targeting
> illumos or solaris? Do they use different triples?

At this point, they do not, se we can't.

> 
> In any case, if there is interest in the future this patch can be
> extended to work on illumos by
> 
> * Creating a shouldUseCxaAtexitByDefault and passing in whatever
> information is needed (Triple, a IsIlumos flag, etc)
> * Using it instead of the long boolean expression we have right now.
> 
> For now I committed this as r247634.

This sounds good. I'll try to contact the people at Illumos interested
in this to see if they want to work with me on making that happen.

Thanks!

> 
> Cheers,
> Rafael
> 
> 
> 
> On 8 September 2015 at 09:47, Xan López via cfe-commits
>  wrote:
> > On Tue, Sep 08, 2015 at 03:28:12PM +0200, Joerg Sonnenberger via 
> > cfe-commits wro> We don't distinguish Solaris and OpenSolaris forks 
> > currently. As such,
> >> changing one for the other is not a good choice, especially since you
> >> are more likely to find clang users for Illumos, IMO.
> >>
> >> https://www.illumos.org/issues/3849
> >
> > Well I'm still a bit confused about what were they using exactly,
> > since I'm pretty sure clang has never worked in its upstream form in a
> > general way from 2012/3. As I said maybe they ship a branch of their
> > own or something, not sure.
> >
> > In any case Solaris is not Illumos, so we still need a
> > solution. Should we add a way to distinguish between them and disable
> > this feature only for Sun/Oracle Solaris? If they are diverging in
> > things like this it seems sooner or later it would be needed anyway.
> >
> > Xan
> >
> >>
> >> Joerg
> >> ___
> >> 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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247676 - [OpenCL] Add new types for OpenCL 2.0.

2015-09-15 Thread Alexey Bader via cfe-commits
Author: bader
Date: Tue Sep 15 06:18:52 2015
New Revision: 247676

URL: http://llvm.org/viewvc/llvm-project?rev=247676&view=rev
Log:
[OpenCL] Add new types for OpenCL 2.0.

Patch by Pedro Ferreira.
Reviewers: pekka.jaaskelainen
Differential Revision: http://reviews.llvm.org/D12855

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/OpenCLExtensions.def
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/PCH/ocl_types.h
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=247676&r1=247675&r2=247676&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Sep 15 06:18:52 2015
@@ -839,9 +839,12 @@ public:
   CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy;
   CanQualType ObjCBuiltinBoolTy;
   CanQualType OCLImage1dTy, OCLImage1dArrayTy, OCLImage1dBufferTy;
-  CanQualType OCLImage2dTy, OCLImage2dArrayTy;
+  CanQualType OCLImage2dTy, OCLImage2dArrayTy, OCLImage2dDepthTy;
+  CanQualType OCLImage2dArrayDepthTy, OCLImage2dMSAATy, OCLImage2dArrayMSAATy;
+  CanQualType OCLImage2dMSAADepthTy, OCLImage2dArrayMSAADepthTy;
   CanQualType OCLImage3dTy;
-  CanQualType OCLSamplerTy, OCLEventTy;
+  CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
+  CanQualType OCLQueueTy, OCLNDRangeTy, OCLReserveIDTy;
   CanQualType OMPArraySectionTy;
 
   // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.

Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=247676&r1=247675&r2=247676&view=diff
==
--- cfe/trunk/include/clang/AST/BuiltinTypes.def (original)
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def Tue Sep 15 06:18:52 2015
@@ -160,6 +160,12 @@ BUILTIN_TYPE(OCLImage1dArray, OCLImage1d
 BUILTIN_TYPE(OCLImage1dBuffer, OCLImage1dBufferTy)
 BUILTIN_TYPE(OCLImage2d, OCLImage2dTy)
 BUILTIN_TYPE(OCLImage2dArray, OCLImage2dArrayTy)
+BUILTIN_TYPE(OCLImage2dDepth, OCLImage2dDepthTy)
+BUILTIN_TYPE(OCLImage2dArrayDepth, OCLImage2dArrayDepthTy)
+BUILTIN_TYPE(OCLImage2dMSAA, OCLImage2dMSAATy)
+BUILTIN_TYPE(OCLImage2dArrayMSAA, OCLImage2dArrayMSAATy)
+BUILTIN_TYPE(OCLImage2dMSAADepth, OCLImage2dMSAADepthTy)
+BUILTIN_TYPE(OCLImage2dArrayMSAADepth, OCLImage2dArrayMSAADepthTy)
 BUILTIN_TYPE(OCLImage3d, OCLImage3dTy)
 
 // OpenCL sampler_t.
@@ -168,6 +174,18 @@ BUILTIN_TYPE(OCLSampler, OCLSamplerTy)
 // OpenCL event_t.
 BUILTIN_TYPE(OCLEvent, OCLEventTy)
 
+// OpenCL clk_event_t.
+BUILTIN_TYPE(OCLClkEvent, OCLClkEventTy)
+
+// OpenCL queue_t.
+BUILTIN_TYPE(OCLQueue, OCLQueueTy)
+
+// OpenCL ndrange_t.
+BUILTIN_TYPE(OCLNDRange, OCLNDRangeTy)
+
+// OpenCL reserve_id_t.
+BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy)
+
 // This represents the type of an expression whose type is
 // totally unknown, e.g. 'T::foo'.  It is permitted for this to
 // appear in situations where the structure of the type is

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=247676&r1=247675&r2=247676&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Sep 15 06:18:52 2015
@@ -1683,17 +1683,27 @@ public:
   bool isNullPtrType() const;   // C++0x nullptr_t
   bool isAtomicType() const;// C11 _Atomic()
 
-  bool isImage1dT() const;  // OpenCL image1d_t
-  bool isImage1dArrayT() const; // OpenCL image1d_array_t
-  bool isImage1dBufferT() const;// OpenCL image1d_buffer_t
-  bool isImage2dT() const;  // OpenCL image2d_t
-  bool isImage2dArrayT() const; // OpenCL image2d_array_t
-  bool isImage3dT() const;  // OpenCL image3d_t
+  bool isImage1dT() const;   // OpenCL image1d_t
+  bool isImage1dArr

Re: [PATCH] D12855: [OpenCL] Add new types for OpenCL 2.0.

2015-09-15 Thread Alexey Bader via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247676: [OpenCL] Add new types for OpenCL 2.0. (authored by 
bader).

Changed prior to commit:
  http://reviews.llvm.org/D12855?vs=34709&id=34796#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12855

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/BuiltinTypes.def
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/OpenCLExtensions.def
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/NSAPI.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypeLoc.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Serialization/ASTCommon.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/PCH/ocl_types.h
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -1460,9 +1460,19 @@
   case BuiltinType::OCLImage1dBuffer:
   case BuiltinType::OCLImage2d:
   case BuiltinType::OCLImage2dArray:
+  case BuiltinType::OCLImage2dDepth:
+  case BuiltinType::OCLImage2dArrayDepth:
+  case BuiltinType::OCLImage2dMSAA:
+  case BuiltinType::OCLImage2dArrayMSAA:
+  case BuiltinType::OCLImage2dMSAADepth:
+  case BuiltinType::OCLImage2dArrayMSAADepth:
   case BuiltinType::OCLImage3d:
   case BuiltinType::OCLSampler:
   case BuiltinType::OCLEvent:
+  case BuiltinType::OCLClkEvent:
+  case BuiltinType::OCLQueue:
+  case BuiltinType::OCLNDRange:
+  case BuiltinType::OCLReserveID:
 #define BUILTIN_TYPE(Id, SingletonId)
 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
Index: cfe/trunk/include/clang/AST/BuiltinTypes.def
===
--- cfe/trunk/include/clang/AST/BuiltinTypes.def
+++ cfe/trunk/include/clang/AST/BuiltinTypes.def
@@ -160,14 +160,32 @@
 BUILTIN_TYPE(OCLImage1dBuffer, OCLImage1dBufferTy)
 BUILTIN_TYPE(OCLImage2d, OCLImage2dTy)
 BUILTIN_TYPE(OCLImage2dArray, OCLImage2dArrayTy)
+BUILTIN_TYPE(OCLImage2dDepth, OCLImage2dDepthTy)
+BUILTIN_TYPE(OCLImage2dArrayDepth, OCLImage2dArrayDepthTy)
+BUILTIN_TYPE(OCLImage2dMSAA, OCLImage2dMSAATy)
+BUILTIN_TYPE(OCLImage2dArrayMSAA, OCLImage2dArrayMSAATy)
+BUILTIN_TYPE(OCLImage2dMSAADepth, OCLImage2dMSAADepthTy)
+BUILTIN_TYPE(OCLImage2dArrayMSAADepth, OCLImage2dArrayMSAADepthTy)
 BUILTIN_TYPE(OCLImage3d, OCLImage3dTy)
 
 // OpenCL sampler_t.
 BUILTIN_TYPE(OCLSampler, OCLSamplerTy)
 
 // OpenCL event_t.
 BUILTIN_TYPE(OCLEvent, OCLEventTy)
 
+// OpenCL clk_event_t.
+BUILTIN_TYPE(OCLClkEvent, OCLClkEventTy)
+
+// OpenCL queue_t.
+BUILTIN_TYPE(OCLQueue, OCLQueueTy)
+
+// OpenCL ndrange_t.
+BUILTIN_TYPE(OCLNDRange, OCLNDRangeTy)
+
+// OpenCL reserve_id_t.
+BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy)
+
 // This represents the type of an expression whose type is
 // totally unknown, e.g. 'T::foo'.  It is permitted for this to
 // appear in situations where the structure of the type is
Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -1683,17 +1683,27 @@
   bool isNullPtrType() const;   // C++0x nullptr_t
   bool isAtomicType() const;// C11 _Atomic()
 
-  bool isImage1dT() const;  // OpenCL image1d_t
-  bool isImage1dArrayT() const; // OpenCL image1d_array_t
-  bool isImage1dBufferT() const;// OpenCL image1d_buffer_t
-  bool isImage2dT() const;  // OpenCL image2d_t
-  bool isImage2dArrayT() const; // OpenCL image2d_array_t
-  bool isImage3dT() const;  // OpenCL image3d_t
+  bool isImage1dT() const;   // OpenCL image1d_t
+  bool isImage1dArrayT() const;  // OpenCL image1d_array_t
+  bool isImage1dBufferT() const; // OpenCL image1d_buffer_t
+  bool isImage2dT() const;   // OpenCL image2d_t
+  bool isImage2dArrayT() const;  // OpenCL image2d_array_t
+  bool isImage2dDepthT() const;  // OpenCL image_2d_depth_t
+  bool isImage2dArrayDepthT() const; // OpenCL image_2d_array_depth_t
+  bool isImage2dMSAAT() const;   // OpenCL image_2d_msaa_t
+  bool isImage2dArrayMSAAT() const;  // OpenCL image_2d_array_msaa_t
+  bool isImage2dMSAATDepth() const;  // OpenCL image_2d_msaa_depth_t
+  bool isImage2dA

r247678 - Run clang-format to unify the switch statement style as suggest here: http://reviews.llvm.org/D12855#246073.

2015-09-15 Thread Alexey Bader via cfe-commits
Author: bader
Date: Tue Sep 15 07:18:29 2015
New Revision: 247678

URL: http://llvm.org/viewvc/llvm-project?rev=247678&view=rev
Log:
Run clang-format to unify the switch statement style as suggest here: 
http://reviews.llvm.org/D12855#246073.

NFC.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=247678&r1=247677&r2=247678&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Sep 15 07:18:29 2015
@@ -1985,34 +1985,79 @@ void CXXNameMangler::mangleType(const Bu
   // ::= Dn # std::nullptr_t (i.e., decltype(nullptr))
   // ::= u # vendor extended type
   switch (T->getKind()) {
-  case BuiltinType::Void: Out << 'v'; break;
-  case BuiltinType::Bool: Out << 'b'; break;
-  case BuiltinType::Char_U: case BuiltinType::Char_S: Out << 'c'; break;
-  case BuiltinType::UChar: Out << 'h'; break;
-  case BuiltinType::UShort: Out << 't'; break;
-  case BuiltinType::UInt: Out << 'j'; break;
-  case BuiltinType::ULong: Out << 'm'; break;
-  case BuiltinType::ULongLong: Out << 'y'; break;
-  case BuiltinType::UInt128: Out << 'o'; break;
-  case BuiltinType::SChar: Out << 'a'; break;
+  case BuiltinType::Void:
+Out << 'v';
+break;
+  case BuiltinType::Bool:
+Out << 'b';
+break;
+  case BuiltinType::Char_U:
+  case BuiltinType::Char_S:
+Out << 'c';
+break;
+  case BuiltinType::UChar:
+Out << 'h';
+break;
+  case BuiltinType::UShort:
+Out << 't';
+break;
+  case BuiltinType::UInt:
+Out << 'j';
+break;
+  case BuiltinType::ULong:
+Out << 'm';
+break;
+  case BuiltinType::ULongLong:
+Out << 'y';
+break;
+  case BuiltinType::UInt128:
+Out << 'o';
+break;
+  case BuiltinType::SChar:
+Out << 'a';
+break;
   case BuiltinType::WChar_S:
-  case BuiltinType::WChar_U: Out << 'w'; break;
-  case BuiltinType::Char16: Out << "Ds"; break;
-  case BuiltinType::Char32: Out << "Di"; break;
-  case BuiltinType::Short: Out << 's'; break;
-  case BuiltinType::Int: Out << 'i'; break;
-  case BuiltinType::Long: Out << 'l'; break;
-  case BuiltinType::LongLong: Out << 'x'; break;
-  case BuiltinType::Int128: Out << 'n'; break;
-  case BuiltinType::Half: Out << "Dh"; break;
-  case BuiltinType::Float: Out << 'f'; break;
-  case BuiltinType::Double: Out << 'd'; break;
+  case BuiltinType::WChar_U:
+Out << 'w';
+break;
+  case BuiltinType::Char16:
+Out << "Ds";
+break;
+  case BuiltinType::Char32:
+Out << "Di";
+break;
+  case BuiltinType::Short:
+Out << 's';
+break;
+  case BuiltinType::Int:
+Out << 'i';
+break;
+  case BuiltinType::Long:
+Out << 'l';
+break;
+  case BuiltinType::LongLong:
+Out << 'x';
+break;
+  case BuiltinType::Int128:
+Out << 'n';
+break;
+  case BuiltinType::Half:
+Out << "Dh";
+break;
+  case BuiltinType::Float:
+Out << 'f';
+break;
+  case BuiltinType::Double:
+Out << 'd';
+break;
   case BuiltinType::LongDouble:
 Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble()
 ? 'g'
 : 'e');
 break;
-  case BuiltinType::NullPtr: Out << "Dn"; break;
+  case BuiltinType::NullPtr:
+Out << "Dn";
+break;
 
 #define BUILTIN_TYPE(Id, SingletonId)
 #define PLACEHOLDER_TYPE(Id, SingletonId) \
@@ -2020,14 +2065,30 @@ void CXXNameMangler::mangleType(const Bu
 #include "clang/AST/BuiltinTypes.def"
   case BuiltinType::Dependent:
 llvm_unreachable("mangling a placeholder type");
-  case BuiltinType::ObjCId: Out << "11objc_object"; break;
-  case BuiltinType::ObjCClass: Out << "10objc_class"; break;
-  case BuiltinType::ObjCSel: Out << "13objc_selector"; break;
-  case BuiltinType::OCLImage1d: Out << "11ocl_image1d"; break;
-  case BuiltinType::OCLImage1dArray: Out << "16ocl_image1darray"; break;
-  case BuiltinType::OCLImage1dBuffer: Out << "17ocl_image1dbuffer"; break;
-  case BuiltinType::OCLImage2d: Out << "11ocl_image2d"; break;
-  case BuiltinType::OCLImage2dArray: Out << "16ocl_image2darray"; break;
+  case BuiltinType::ObjCId:
+Out << "11objc_object";
+break;
+  case BuiltinType::ObjCClass:
+Out << "10objc_class";
+break;
+  case BuiltinType::ObjCSel:
+Out << "13objc_selector";
+break;
+  case BuiltinType::OCLImage1d:
+Out << "11ocl_image1d";
+break;
+  case BuiltinType::OCLImage1dArray:
+Out << "16ocl_image1darray";
+break;
+  case BuiltinType::OCLImage1dBuffer:
+Out << "17ocl_image1dbuffer";
+break;
+  case BuiltinType::OCLImage2d:
+Out << "11ocl_image2d";
+break;
+  case BuiltinType::OCLImage2

r247668 - Doxygen fix InitializeBuiltins -> initializeBuiltins

2015-09-15 Thread Ismail Donmez via cfe-commits
Author: ismail
Date: Tue Sep 15 04:53:14 2015
New Revision: 247668

URL: http://llvm.org/viewvc/llvm-project?rev=247668&view=rev
Log:
Doxygen fix InitializeBuiltins -> initializeBuiltins


Modified:
cfe/trunk/lib/Basic/Builtins.cpp

Modified: cfe/trunk/lib/Basic/Builtins.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Builtins.cpp?rev=247668&r1=247667&r2=247668&view=diff
==
--- cfe/trunk/lib/Basic/Builtins.cpp (original)
+++ cfe/trunk/lib/Basic/Builtins.cpp Tue Sep 15 04:53:14 2015
@@ -62,7 +62,7 @@ bool Builtin::Context::builtinIsSupporte
  !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported;
 }
 
-/// InitializeBuiltins - Mark the identifiers for all the builtins with their
+/// initializeBuiltins - Mark the identifiers for all the builtins with their
 /// appropriate builtin ID # and mark any non-portable builtin identifiers as
 /// such.
 void Builtin::Context::initializeBuiltins(IdentifierTable &Table,


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


Re: [PATCH] D11240: Add basic #include sorting functionality to clang-format

2015-09-15 Thread Daniel Jasper via cfe-commits
djasper marked 8 inline comments as done.


Comment at: lib/Format/Format.cpp:1653
@@ +1652,3 @@
+Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev);
+if (!Line.endswith("\\")) {
+  if (IncludeRegex.match(Line, &Matches)) {

klimek wrote:
> I'd have expected early exit, but I can see it'd introduce a one-line 
> duplication. Not sure, just wanted to bring it up.
It's actually three lines I think. Also, I think we'll significantly extend the 
logic here shortly (e.g. to properly support Google and LLVM styles), so I 
don't think it is worth thinking about too much.


Comment at: lib/Format/Format.cpp:1662-1665
@@ +1661,6 @@
+IncludesInBlock.push_back({Matches[1], Line, Prev, Matches[2] == ">"});
+  } else {
+sortIncludes(Style, IncludesInBlock, Ranges, FileName, Replaces);
+IncludesInBlock.clear();
+  }
+  Prev = Pos + 1;

klimek wrote:
> Nit: I think this would be a bit more readable if we only call sortInlucdes 
> if !IncludesInBlock.empty() and add that as condition to the else.
Done and removed the check inside sortIncludes.


Comment at: lib/Tooling/Core/Replacement.cpp:332-336
@@ +331,7 @@
+// subsequent, non-overlapping replacements.
+int DeltaFirst = MergeSecond ? MergedText.size() - MergedLength : 0;
+int DeltaSecond = MergeSecond ? 0 : MergedText.size() - MergedLength;
+while ((MergeSecond && SecondI != Second.end()) ||
+   (!MergeSecond && FirstI != First.end())) {
+  if (MergeSecond) {
+// If we are merging an element from 'Second', the length of the

klimek wrote:
> This structure looks like we'd want 2 functions. I assume you had reasons not 
> to pull out two local functions? What are they? Too many parameters? (I'd 
> probably pull out a class to be able to put this into smaller methods, but 
> I'm probably weird).
Maybe a class would be the way to go here. I'll try in a subsequent patch 
(don't think it should be a priority at this point).


Comment at: lib/Tooling/Core/Replacement.cpp:341
@@ +340,3 @@
+unsigned MergedEnd = MergedOffset + MergedText.size();
+unsigned Offset = SecondI->getOffset() + DeltaSecond + Delta;
+if (Offset > MergedEnd)

klimek wrote:
> If SecondI == Second.end(), isn't this an undefined access?
Cannot happen. The while starts with MergeSecond && SecondI != Second.end().


Comment at: lib/Tooling/Core/Replacement.cpp:354
@@ +353,3 @@
+StringRef Tail = MergedRef.substr(End - MergedOffset);
+MergedText = (Twine(Head) + SecondI->getReplacementText() + 
Tail).str();
+DeltaSecond += SecondI->getReplacementText().size() - Length;

klimek wrote:
> I'm surprised the explicit Twine() is needed here...
How else would this know to use a Twine for efficient concatenation?


http://reviews.llvm.org/D11240



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


Re: [PATCH] D11240: Add basic #include sorting functionality to clang-format

2015-09-15 Thread Daniel Jasper via cfe-commits
djasper updated this revision to Diff 34800.
djasper marked 4 inline comments as done.
djasper added a comment.

Addressed (most) comments


http://reviews.llvm.org/D11240

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.cpp
  lib/Tooling/Core/Replacement.cpp
  tools/clang-format/CMakeLists.txt
  tools/clang-format/ClangFormat.cpp
  tools/clang-format/clang-format.py
  unittests/Format/CMakeLists.txt
  unittests/Format/SortIncludesTest.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -489,5 +489,98 @@
   }
 }
 
+class MergeReplacementsTest : public ::testing::Test {
+protected:
+  void mergeAndTestRewrite(StringRef Code, StringRef Intermediate,
+   StringRef Result, const Replacements &First,
+   const Replacements &Second) {
+// These are mainly to verify the test itself and make it easier to read.
+std::string AfterFirst = applyAllReplacements(Code, First);
+std::string InSequenceRewrite = applyAllReplacements(AfterFirst, Second);
+EXPECT_EQ(Intermediate, AfterFirst);
+EXPECT_EQ(Result, InSequenceRewrite);
+
+tooling::Replacements Merged = mergeReplacements(First, Second);
+std::string MergedRewrite = applyAllReplacements(Code, Merged);
+EXPECT_EQ(InSequenceRewrite, MergedRewrite);
+if (InSequenceRewrite != MergedRewrite)
+  for (tooling::Replacement M : Merged)
+llvm::errs() << M.getOffset() << " " << M.getLength() << " "
+ << M.getReplacementText() << "\n";
+  }
+  void mergeAndTestRewrite(StringRef Code, const Replacements &First,
+   const Replacements &Second) {
+std::string InSequenceRewrite =
+applyAllReplacements(applyAllReplacements(Code, First), Second);
+tooling::Replacements Merged = mergeReplacements(First, Second);
+std::string MergedRewrite = applyAllReplacements(Code, Merged);
+EXPECT_EQ(InSequenceRewrite, MergedRewrite);
+if (InSequenceRewrite != MergedRewrite)
+  for (tooling::Replacement M : Merged)
+llvm::errs() << M.getOffset() << " " << M.getLength() << " "
+ << M.getReplacementText() << "\n";
+  }
+};
+
+TEST_F(MergeReplacementsTest, Offsets) {
+  mergeAndTestRewrite("aaa", "aabab", "cacabab",
+  {{"", 2, 0, "b"}, {"", 3, 0, "b"}},
+  {{"", 0, 0, "c"}, {"", 1, 0, "c"}});
+  mergeAndTestRewrite("aaa", "babaa", "babacac",
+  {{"", 0, 0, "b"}, {"", 1, 0, "b"}},
+  {{"", 4, 0, "c"}, {"", 5, 0, "c"}});
+  mergeAndTestRewrite("", "aaa", "aac", {{"", 1, 1, ""}},
+  {{"", 2, 1, "c"}});
+
+  mergeAndTestRewrite("aa", "bbabba", "bbabcba",
+  {{"", 0, 0, "bb"}, {"", 1, 0, "bb"}}, {{"", 4, 0, "c"}});
+}
+
+TEST_F(MergeReplacementsTest, Concatenations) {
+  // Basic concatenations. It is important to merge these into a single
+  // replacement to ensure the correct order.
+  EXPECT_EQ((Replacements{{"", 0, 0, "ab"}}),
+mergeReplacements({{"", 0, 0, "a"}}, {{"", 1, 0, "b"}}));
+  EXPECT_EQ((Replacements{{"", 0, 0, "ba"}}),
+mergeReplacements({{"", 0, 0, "a"}}, {{"", 0, 0, "b"}}));
+  mergeAndTestRewrite("", "a", "ab", {{"", 0, 0, "a"}}, {{"", 1, 0, "b"}});
+  mergeAndTestRewrite("", "a", "ba", {{"", 0, 0, "a"}}, {{"", 0, 0, "b"}});
+}
+
+TEST_F(MergeReplacementsTest, NotChangingLengths) {
+  mergeAndTestRewrite("", "abba", "acca", {{"", 1, 2, "bb"}},
+  {{"", 1, 2, "cc"}});
+  mergeAndTestRewrite("", "abba", "abcc", {{"", 1, 2, "bb"}},
+  {{"", 2, 2, "cc"}});
+  mergeAndTestRewrite("", "abba", "ccba", {{"", 1, 2, "bb"}},
+  {{"", 0, 2, "cc"}});
+  mergeAndTestRewrite("aa", "abbdda", "abccda",
+  {{"", 1, 2, "bb"}, {"", 3, 2, "dd"}}, {{"", 2, 2, "cc"}});
+}
+
+TEST_F(MergeReplacementsTest, OverlappingRanges) {
+  mergeAndTestRewrite("aaa", "bbd", "bcbcd",
+  {{"", 0, 1, "bb"}, {"", 1, 2, "d"}},
+  {{"", 1, 0, "c"}, {"", 2, 0, "c"}});
+
+  mergeAndTestRewrite("", "aabbaa", "aa", {{"", 2, 0, "bb"}},
+  {{"", 1, 4, ""}});
+  mergeAndTestRewrite("", "aababa", "aa",
+  {{"", 2, 0, "b"}, {"", 3, 0, "b"}}, {{"", 1, 4, ""}});
+  mergeAndTestRewrite("aa", "aa", "abba", {{"", 1, 4, ""}},
+  {{"", 2, 2, ""}});
+  mergeAndTestRewrite("", "aa", "cc", {{"", 1, 1, ""}, {"", 2, 1, ""}},
+  {{"", 0, 2, "cc"}});
+  mergeAndTestRewrite("aa", "abbba", "abcbcba", {{"", 1, 0, "bbb"}},
+  {{"", 2, 0, "c"}, {"", 3, 0, "c"}});
+
+  mer

r247681 - [OPENMP] Emit __kmpc_cancel_barrier() and code for 'cancellation point' only if 'cancel' is found.

2015-09-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 15 07:52:43 2015
New Revision: 247681

URL: http://llvm.org/viewvc/llvm-project?rev=247681&view=rev
Log:
[OPENMP] Emit __kmpc_cancel_barrier() and code for 'cancellation point' only if 
'cancel' is found.
Patch improves codegen for OpenMP constructs. If the OpenMP region does not 
have internal 'cancel' construct, a call to 'void __kmpc_barrier()' runtime 
function is generated for all implicit/explicit barriers. If the region has 
inner 'cancel' directive, then
```
if (__kmpc_cancel_barrier())
  exit from outer construct;
```
code is generated.
Also, the code for 'canellation point' directive is not generated if parent 
directive does not have 'cancel' directive.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/cancel_codegen.cpp
cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/for_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/for_linear_codegen.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
cfe/trunk/test/OpenMP/for_simd_codegen.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp
cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
cfe/trunk/test/OpenMP/parallel_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp
cfe/trunk/test/OpenMP/sections_codegen.cpp
cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_reduction_codegen.cpp
cfe/trunk/test/OpenMP/single_firstprivate_codegen.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=247681&r1=247680&r2=247681&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Tue Sep 15 07:52:43 2015
@@ -230,6 +230,10 @@ public:
 /// variables 'c' and 'd'.
 ///
 class OMPParallelDirective : public OMPExecutableDirective {
+  friend class ASTStmtReader;
+  /// \brief true if the construct has inner cancel directive.
+  bool HasCancel;
+
   /// \brief Build directive with the given start and end location.
   ///
   /// \param StartLoc Starting location of the directive (directive keyword).
@@ -238,7 +242,8 @@ class OMPParallelDirective : public OMPE
   OMPParallelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
unsigned NumClauses)
   : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
-   StartLoc, EndLoc, NumClauses, 1) {}
+   StartLoc, EndLoc, NumClauses, 1),
+HasCancel(false) {}
 
   /// \brief Build an empty directive.
   ///
@@ -247,7 +252,11 @@ class OMPParallelDirective : public OMPE
   explicit OMPParallelDirective(unsigned NumClauses)
   : OMPExecutableDirective(this, OMPParallelDirectiveClass, OMPD_parallel,
SourceLocation(), SourceLocation(), NumClauses,
-   1) {}
+   1),
+HasCancel(false) {}
+
+  /// \brief Set cancel state.
+  void setHasCancel(bool Has) { HasCancel = Has; }
 
 public:
   /// \brief Creates directive with a list of \a Clauses.
@@ -257,10 +266,11 @@ public:
   /// \param EndLoc Ending Location of the directive.
   /// \param Clauses List of clauses.
   /// \param AssociatedStmt Statement associated with the directive.
+  /// \param HasCancel true if this directive has inner cancel directive.
   ///
   static OMPParallelDirective *
   Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
- ArrayRef Clauses, Stmt *AssociatedStmt);
+ ArrayRef Clauses, Stmt *AssociatedStmt, bool HasCancel);
 
   /// \brief Creates an empty directive with the place for \a N clauses.
   ///
@@ -270,6 +280,9 @@ public:
   static OMPParallelDirective *CreateEmpty(const ASTContext &C,
unsigned NumClauses, EmptyShell);
 
+  /// \brief Return true if current directive has inner cancel directive.
+  bool hasCancel() const { return HasCancel; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OMPParallelDirectiveClass;
   }
@@ -732,6 +745,10 @@ public:
 ///
 class OMPForDirective : public OMPLoopDirective {
   friend class ASTStmtReader;
+
+  /// \brief true if current directive has inner cancel directive.
+  bool HasCancel;
+
   /// \brief Build directive with the given start and end

[clang-tools-extra] r247682 - [clang-tidy] Update check name in the comment. NFC.

2015-09-15 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Sep 15 08:13:48 2015
New Revision: 247682

URL: http://llvm.org/viewvc/llvm-project?rev=247682&view=rev
Log:
[clang-tidy] Update check name in the comment. NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=247682&r1=247681&r2=247682&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Tue Sep 15 
08:13:48 2015
@@ -20,7 +20,7 @@ Example usage for git/svn users:
 
   git diff -U0 HEAD^ | clang-tidy-diff.py -p1
   svn diff --diff-cmd=diff -x-U0 | \
-  clang-tidy-diff.py -fix -checks=-*,misc-use-override
+  clang-tidy-diff.py -fix -checks=-*,modernize-use-override
 
 """
 


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


r247683 - Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.

2015-09-15 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Tue Sep 15 08:17:40 2015
New Revision: 247683

URL: http://llvm.org/viewvc/llvm-project?rev=247683&view=rev
Log:
Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.

Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).

For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.

This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.

This commit also contains a trivial patch to clang to account for the C++ API
change.

Reviewers: rengolin

Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, 
javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, 
llvm-commits, rengolin

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


Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=247683&r1=247682&r2=247683&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Tue Sep 15 08:17:40 2015
@@ -546,8 +546,8 @@ StmtResult Parser::ParseMicrosoftAsmStat
   std::unique_ptr TargetParser(
   TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
 
-  std::unique_ptr IP(
-  TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));
+  std::unique_ptr IP(TheTarget->createMCInstPrinter(
+  llvm::TargetTuple(llvm::Triple(TT)), 1, *MAI, *MII, *MRI));
 
   // Change to the Intel dialect.
   Parser->setAssemblerDialect(1);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=247683&r1=247682&r2=247683&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Sep 15 08:17:40 2015
@@ -358,7 +358,8 @@ static bool ExecuteAssembler(AssemblerIn
   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
   if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
 MCInstPrinter *IP = TheTarget->createMCInstPrinter(
-llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI);
+llvm::TargetTuple(llvm::Triple(Opts.Triple)), Opts.OutputAsmVariant,
+*MAI, *MCII, *MRI);
 MCCodeEmitter *CE = nullptr;
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
@@ -382,10 +383,10 @@ static bool ExecuteAssembler(AssemblerIn
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
   Opts.CPU);
-Triple T(Opts.Triple);
-Str.reset(TheTarget->createMCObjectStreamer(T, Ctx, *MAB, *Out, CE, *STI,
-Opts.RelaxAll,
-/*DWARFMustBeAtTheEnd*/ true));
+Triple TT(Opts.Triple);
+Str.reset(TheTarget->createMCObjectStreamer(
+llvm::TargetTuple(TT), Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
+/*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }
 


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


r247686 - Revert r247684 - Replace Triple with a new TargetTuple ...

2015-09-15 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Tue Sep 15 08:46:21 2015
New Revision: 247686

URL: http://llvm.org/viewvc/llvm-project?rev=247686&view=rev
Log:
Revert r247684 - Replace Triple with a new TargetTuple ...

LLDB needs to be updated in the same commit.


Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=247686&r1=247685&r2=247686&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Tue Sep 15 08:46:21 2015
@@ -546,8 +546,8 @@ StmtResult Parser::ParseMicrosoftAsmStat
   std::unique_ptr TargetParser(
   TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
 
-  std::unique_ptr IP(TheTarget->createMCInstPrinter(
-  llvm::TargetTuple(llvm::Triple(TT)), 1, *MAI, *MII, *MRI));
+  std::unique_ptr IP(
+  TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));
 
   // Change to the Intel dialect.
   Parser->setAssemblerDialect(1);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=247686&r1=247685&r2=247686&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Sep 15 08:46:21 2015
@@ -358,8 +358,7 @@ static bool ExecuteAssembler(AssemblerIn
   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
   if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
 MCInstPrinter *IP = TheTarget->createMCInstPrinter(
-llvm::TargetTuple(llvm::Triple(Opts.Triple)), Opts.OutputAsmVariant,
-*MAI, *MCII, *MRI);
+llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI);
 MCCodeEmitter *CE = nullptr;
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
@@ -383,10 +382,10 @@ static bool ExecuteAssembler(AssemblerIn
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
   Opts.CPU);
-Triple TT(Opts.Triple);
-Str.reset(TheTarget->createMCObjectStreamer(
-llvm::TargetTuple(TT), Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
-/*DWARFMustBeAtTheEnd*/ true));
+Triple T(Opts.Triple);
+Str.reset(TheTarget->createMCObjectStreamer(T, Ctx, *MAB, *Out, CE, *STI,
+Opts.RelaxAll,
+/*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }
 


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


[clang-tools-extra] r247689 - Remove garbage. The issue was fixed in r246856.

2015-09-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Sep 15 09:01:09 2015
New Revision: 247689

URL: http://llvm.org/viewvc/llvm-project?rev=247689&view=rev
Log:
Remove garbage. The issue was fixed in r246856.

Modified:
clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp?rev=247689&r1=247688&r2=247689&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp Tue Sep 15 
09:01:09 2015
@@ -1,7 +1,5 @@
 // RUN: %python %S/check_clang_tidy.py %s llvm-include-order %t -- -isystem 
%S/Inputs/Headers
 
-// FIXME: Investigating.
-
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"


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


r247692 - Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.

2015-09-15 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Tue Sep 15 09:08:28 2015
New Revision: 247692

URL: http://llvm.org/viewvc/llvm-project?rev=247692&view=rev
Log:
Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and 
related. NFC.

Summary:
This is the first patch in the series to migrate Triple's (which are ambiguous)
to TargetTuple's (which aren't).

For the moment, TargetTuple simply passes all requests to the Triple object it
holds. Once it has replaced Triple, it will start to implement the interface in
a more suitable way.

This change makes some changes to the public C++ API. In particular,
InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer()
now take TargetTuples instead of Triples. The other public C++ API's have
been left as-is for the moment to reduce patch size.

This commit also contains a trivial patch to clang to account for the C++ API
change. Thanks go to Pavel Labath for fixing LLDB for me.

Reviewers: rengolin

Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, 
javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, 
llvm-commits, rengolin

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

Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=247692&r1=247691&r2=247692&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Tue Sep 15 09:08:28 2015
@@ -546,8 +546,8 @@ StmtResult Parser::ParseMicrosoftAsmStat
   std::unique_ptr TargetParser(
   TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
 
-  std::unique_ptr IP(
-  TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));
+  std::unique_ptr IP(TheTarget->createMCInstPrinter(
+  llvm::TargetTuple(llvm::Triple(TT)), 1, *MAI, *MII, *MRI));
 
   // Change to the Intel dialect.
   Parser->setAssemblerDialect(1);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=247692&r1=247691&r2=247692&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Sep 15 09:08:28 2015
@@ -358,7 +358,8 @@ static bool ExecuteAssembler(AssemblerIn
   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
   if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
 MCInstPrinter *IP = TheTarget->createMCInstPrinter(
-llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI);
+llvm::TargetTuple(llvm::Triple(Opts.Triple)), Opts.OutputAsmVariant,
+*MAI, *MCII, *MRI);
 MCCodeEmitter *CE = nullptr;
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
@@ -382,10 +383,10 @@ static bool ExecuteAssembler(AssemblerIn
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
   Opts.CPU);
-Triple T(Opts.Triple);
-Str.reset(TheTarget->createMCObjectStreamer(T, Ctx, *MAB, *Out, CE, *STI,
-Opts.RelaxAll,
-/*DWARFMustBeAtTheEnd*/ true));
+Triple TT(Opts.Triple);
+Str.reset(TheTarget->createMCObjectStreamer(
+llvm::TargetTuple(TT), Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
+/*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }
 


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


r247693 - Silencing a -Wreturn-type warning; NFC.

2015-09-15 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep 15 09:11:32 2015
New Revision: 247693

URL: http://llvm.org/viewvc/llvm-project?rev=247693&view=rev
Log:
Silencing a -Wreturn-type warning; NFC.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp?rev=247693&r1=247692&r2=247693&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp Tue Sep 15 09:11:32 
2015
@@ -240,6 +240,7 @@ CheckerManager::getObjCMessageCheckers(O
   case ObjCMessageVisitKind::MessageNil:
 return ObjCMessageNilCheckers;
   }
+  llvm_unreachable("Unknown Kind");
 }
 namespace {
   // FIXME: This has all the same signatures as CheckObjCMessageContext.


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


[libcxx] r247695 - Change initialization of mbstate_t objects in tests from '= {0}' to '= {}', which does the same thing, w/o having clang and gcc warn with -Wall.

2015-09-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Sep 15 09:46:03 2015
New Revision: 247695

URL: http://llvm.org/viewvc/llvm-project?rev=247695&view=rev
Log:
Change initialization of mbstate_t objects in tests from '= {0}' to '= {}', 
which does the same thing, w/o having clang and gcc warn with -Wall.

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp?rev=247695&r1=247694&r2=247695&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp Tue Sep 15 
09:46:03 2015
@@ -34,7 +34,7 @@
 
 int main()
 {
-mbstate_t mb = {0};
+mbstate_t mb = {};
 size_t s = 0;
 tm *tm = 0;
 wint_t w = 0;

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp?rev=247695&r1=247694&r2=247695&view=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
 Tue Sep 15 09:46:03 2015
@@ -28,7 +28,7 @@ int main()
 const char from[] = "some text";
 F::intern_type to[9];
 const F& f = std::use_facet(l);
-std::mbstate_t mbs = {0};
+std::mbstate_t mbs = {};
 const char* from_next = 0;
 F::intern_type* to_next = 0;
 assert(f.in(mbs, from, from + 9, from_next,

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp?rev=247695&r1=247694&r2=247695&view=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codec

r247696 - Mention that libcxx is required to build Compiler-RT tests on OS X.

2015-09-15 Thread Yury Gribov via cfe-commits
Author: ygribov
Date: Tue Sep 15 10:05:47 2015
New Revision: 247696

URL: http://llvm.org/viewvc/llvm-project?rev=247696&view=rev
Log:
Mention that libcxx is required to build Compiler-RT tests on OS X.

Modified:
cfe/trunk/www/get_started.html

Modified: cfe/trunk/www/get_started.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_started.html?rev=247696&r1=247695&r2=247696&view=diff
==
--- cfe/trunk/www/get_started.html (original)
+++ cfe/trunk/www/get_started.html Tue Sep 15 10:05:47 2015
@@ -76,6 +76,14 @@ follows:
 cd ../..
   
   
+  Checkout libcxx: (only required to build and run Compiler-RT tests on OS 
X, optional otherwise)
+  
+cd llvm/projects
+svn co http://llvm.org/svn/llvm-project/libcxx/trunk
+libcxx
+cd ../..
+  
+  
   Build LLVM and Clang:
   
 mkdir build (in-tree build is not supported)


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


Re: [clang-tools-extra] r247393 - clang-tidy/readability-inconsistent-declaration-parameter-name.cpp: Appease MS-incompatibility [-fno-delayed-template-parsing]

2015-09-15 Thread Alexander Kornienko via cfe-commits
On Fri, Sep 11, 2015 at 3:30 PM, Aaron Ballman 
wrote:

> On Fri, Sep 11, 2015 at 9:27 AM, Alexander Kornienko via cfe-commits
>  wrote:
> > Thank you for the fix and sorry for breaking this again. I wonder what's
> the
> > reason windows-targeting enables -fdelayed-template-parsing?
>
> Because that's required for MSVC compatibility.
>

That's what I understood from reading the flag description
, however it doesn't help
me understand why. But reading this

and this

made things clear. So it looks like we can't safely turn this off, because
some code may rely on this, but with this option the AST doesn't contain
bodies of FunctionTemplateDecls, which affects some checks.

And this seems to be the issue for other Clang Tools as well. There was a
discussion about that
 last
year, which has lead nowhere, I guess.


>
> > Would it be the right thing to always turn this off in clang-tidy?
>
>  I don't think it would be a good thing to turn off in clang-tidy as
> the behavior would diverge from the default in clang on Windows (with
> MSVC mode).
>
> ~Aaron
>
> >
> >
> > On Fri, Sep 11, 2015 at 10:16 AM, NAKAMURA Takumi via cfe-commits
> >  wrote:
> >>
> >> Author: chapuni
> >> Date: Fri Sep 11 03:16:22 2015
> >> New Revision: 247393
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=247393&view=rev
> >> Log:
> >> clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:
> >> Appease MS-incompatibility [-fno-delayed-template-parsing]
> >>
> >> Modified:
> >>
> >>
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> >>
> >> Modified:
> >>
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp?rev=247393&r1=247392&r2=247393&view=diff
> >>
> >>
> ==
> >> ---
> >>
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> >> (original)
> >> +++
> >>
> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
> >> Fri Sep 11 03:16:22 2015
> >> @@ -1,4 +1,4 @@
> >> -// RUN: %python %S/check_clang_tidy.py %s
> >> readability-inconsistent-declaration-parameter-name %t
> >> +// RUN: %python %S/check_clang_tidy.py %s
> >> readability-inconsistent-declaration-parameter-name %t -- -std=c++11
> >> -fno-delayed-template-parsing
> >>
> >>  void consistentFunction(int a, int b, int c);
> >>  void consistentFunction(int a, int b, int c);
> >>
> >>
> >> ___
> >> 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
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r247393 - clang-tidy/readability-inconsistent-declaration-parameter-name.cpp: Appease MS-incompatibility [-fno-delayed-template-parsing]

2015-09-15 Thread Aaron Ballman via cfe-commits
On Tue, Sep 15, 2015 at 11:31 AM, Alexander Kornienko  wrote:
> On Fri, Sep 11, 2015 at 3:30 PM, Aaron Ballman 
> wrote:
>>
>> On Fri, Sep 11, 2015 at 9:27 AM, Alexander Kornienko via cfe-commits
>>  wrote:
>> > Thank you for the fix and sorry for breaking this again. I wonder what's
>> > the
>> > reason windows-targeting enables -fdelayed-template-parsing?
>>
>> Because that's required for MSVC compatibility.
>
>
> That's what I understood from reading the flag description, however it
> doesn't help me understand why. But reading this and this made things clear.
> So it looks like we can't safely turn this off, because some code may rely
> on this, but with this option the AST doesn't contain bodies of
> FunctionTemplateDecls, which affects some checks.

Yeah, I have been surprised by this as well. Those checks behave as
expected when the template is actually instantiated, but not
otherwise, though.

> And this seems to be the issue for other Clang Tools as well. There was a
> discussion about that last year, which has lead nowhere, I guess.

Reopening the discussion might not be a bad thing, but I'm not certain
what could be done realistically since we need this in order to
properly handle some headers shipped by Microsoft.

~Aaron

>
>>
>>
>> > Would it be the right thing to always turn this off in clang-tidy?
>>
>>  I don't think it would be a good thing to turn off in clang-tidy as
>> the behavior would diverge from the default in clang on Windows (with
>> MSVC mode).
>>
>> ~Aaron
>>
>> >
>> >
>> > On Fri, Sep 11, 2015 at 10:16 AM, NAKAMURA Takumi via cfe-commits
>> >  wrote:
>> >>
>> >> Author: chapuni
>> >> Date: Fri Sep 11 03:16:22 2015
>> >> New Revision: 247393
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=247393&view=rev
>> >> Log:
>> >> clang-tidy/readability-inconsistent-declaration-parameter-name.cpp:
>> >> Appease MS-incompatibility [-fno-delayed-template-parsing]
>> >>
>> >> Modified:
>> >>
>> >>
>> >> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> >>
>> >> Modified:
>> >>
>> >> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp?rev=247393&r1=247392&r2=247393&view=diff
>> >>
>> >>
>> >> ==
>> >> ---
>> >>
>> >> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> >> (original)
>> >> +++
>> >>
>> >> clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
>> >> Fri Sep 11 03:16:22 2015
>> >> @@ -1,4 +1,4 @@
>> >> -// RUN: %python %S/check_clang_tidy.py %s
>> >> readability-inconsistent-declaration-parameter-name %t
>> >> +// RUN: %python %S/check_clang_tidy.py %s
>> >> readability-inconsistent-declaration-parameter-name %t -- -std=c++11
>> >> -fno-delayed-template-parsing
>> >>
>> >>  void consistentFunction(int a, int b, int c);
>> >>  void consistentFunction(int a, int b, int c);
>> >>
>> >>
>> >> ___
>> >> 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
>> >
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247702 - Revert r247692: Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC.

2015-09-15 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Tue Sep 15 11:17:27 2015
New Revision: 247702

URL: http://llvm.org/viewvc/llvm-project?rev=247702&view=rev
Log:
Revert r247692: Replace Triple with a new TargetTuple in MCTargetDesc/* and 
related. NFC.

Eric has replied and has demanded the patch be reverted.


Modified:
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=247702&r1=247701&r2=247702&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Tue Sep 15 11:17:27 2015
@@ -546,8 +546,8 @@ StmtResult Parser::ParseMicrosoftAsmStat
   std::unique_ptr TargetParser(
   TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
 
-  std::unique_ptr IP(TheTarget->createMCInstPrinter(
-  llvm::TargetTuple(llvm::Triple(TT)), 1, *MAI, *MII, *MRI));
+  std::unique_ptr IP(
+  TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));
 
   // Change to the Intel dialect.
   Parser->setAssemblerDialect(1);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=247702&r1=247701&r2=247702&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Sep 15 11:17:27 2015
@@ -358,8 +358,7 @@ static bool ExecuteAssembler(AssemblerIn
   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
   if (Opts.OutputType == AssemblerInvocation::FT_Asm) {
 MCInstPrinter *IP = TheTarget->createMCInstPrinter(
-llvm::TargetTuple(llvm::Triple(Opts.Triple)), Opts.OutputAsmVariant,
-*MAI, *MCII, *MRI);
+llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI);
 MCCodeEmitter *CE = nullptr;
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
@@ -383,10 +382,10 @@ static bool ExecuteAssembler(AssemblerIn
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
   Opts.CPU);
-Triple TT(Opts.Triple);
-Str.reset(TheTarget->createMCObjectStreamer(
-llvm::TargetTuple(TT), Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
-/*DWARFMustBeAtTheEnd*/ true));
+Triple T(Opts.Triple);
+Str.reset(TheTarget->createMCObjectStreamer(T, Ctx, *MAB, *Out, CE, *STI,
+Opts.RelaxAll,
+/*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }
 


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


Re: [PATCH] D5102: [analyzer][Bugfix/improvement] Fix for PR16833

2015-09-15 Thread Jordan Rose via cfe-commits
jordan_rose accepted this revision.
jordan_rose added a comment.
This revision is now accepted and ready to land.

Thanks for all the changes. This looks good to me! (And good catch for the 
constant expression case.)


http://reviews.llvm.org/D5102



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


Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-09-15 Thread Ismail Pazarbasi via cfe-commits
ismailp added a comment.

I don't have ubigraph installed either. The purpose of the test isn't to check 
as to whether we can generate a conforming/sensible ubigraph output, but to 
ensure that this tiny patch works and clang doesn't crash. So, I'd keep it. But 
if you are worried about other/unknown problems in ubigraph generator that the 
test might surface, then we can proceed without the test, and a ubigraph expert 
can write an output validation test.


http://reviews.llvm.org/D12119



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


[libcxx] r247704 - Suppress some warnings in the tests that snuck in. That 'tmpnam' is deprecated doesn't change the fact that we have to test it.

2015-09-15 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Sep 15 12:12:49 2015
New Revision: 247704

URL: http://llvm.org/viewvc/llvm-project?rev=247704&view=rev
Log:
Suppress some warnings in the tests that snuck in.  That 'tmpnam' is deprecated 
doesn't change the fact that we have to test it.

Modified:
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp?rev=247704&r1=247703&r2=247704&view=diff
==
--- libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp 
(original)
+++ libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp Tue 
Sep 15 12:12:49 2015
@@ -80,6 +80,7 @@
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wformat-zero-length"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
 
 int main()
 {

Modified: 
libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp?rev=247704&r1=247703&r2=247704&view=diff
==
--- libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp Tue 
Sep 15 12:12:49 2015
@@ -54,7 +54,7 @@ void test_comparisons()
 
 #if defined(__clang__)
 #pragma clang diagnostic push
-#pragma diagnostic ignored "-Wnull-conversion"
+#pragma clang diagnostic ignored "-Wnull-conversion"
 #endif
 void test_nullptr_conversions() {
 {


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


r247706 - [OPENMP] Emit an additional note during analysis of 'if' clause.

2015-09-15 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Sep 15 12:23:56 2015
New Revision: 247706

URL: http://llvm.org/viewvc/llvm-project?rev=247706&view=rev
Log:
[OPENMP] Emit an additional note during analysis of 'if' clause.
Patch adds emission of additional note for 'if' clauses with name modifiers in 
case if 'if' clause without name modified was specified or 'if' clause with the 
same name modifier was specified.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_if_messages.cpp
cfe/trunk/test/OpenMP/target_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/task_if_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=247706&r1=247705&r2=247706&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Sep 15 12:23:56 2015
@@ -2015,6 +2015,7 @@ static bool checkIfClauses(Sema &S, Open
   unsigned NamedModifiersNumber = 0;
   SmallVector FoundNameModifiers(
   OMPD_unknown + 1);
+  SmallVector NameModifierLoc;
   for (const auto *C : Clauses) {
 if (const auto *IC = dyn_cast_or_null(C)) {
   // At most one if clause without a directive-name-modifier can appear on
@@ -2025,8 +2026,10 @@ static bool checkIfClauses(Sema &S, Open
 << getOpenMPDirectiveName(Kind) << getOpenMPClauseName(OMPC_if)
 << (CurNM != OMPD_unknown) << getOpenMPDirectiveName(CurNM);
 ErrorFound = true;
-  } else if (CurNM != OMPD_unknown)
+  } else if (CurNM != OMPD_unknown) {
+NameModifierLoc.push_back(IC->getNameModifierLoc());
 ++NamedModifiersNumber;
+  }
   FoundNameModifiers[CurNM] = IC;
   if (CurNM == OMPD_unknown)
 continue;
@@ -2079,6 +2082,9 @@ static bool checkIfClauses(Sema &S, Open
  diag::err_omp_unnamed_if_clause)
   << (TotalAllowedNum > 1) << Values;
 }
+for (auto Loc : NameModifierLoc) {
+  S.Diag(Loc, diag::note_omp_previous_named_if_clause);
+}
 ErrorFound = true;
   }
   return ErrorFound;

Modified: cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp?rev=247706&r1=247705&r2=247706&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp Tue Sep 15 12:23:56 2015
@@ -46,7 +46,7 @@ int tmain(T argc, S **argv) {
   for (i = 0; i < argc; ++i) foo();
   #pragma omp parallel for if(parallel : argc) if (parallel:argc) // 
expected-error {{directive '#pragma omp parallel for' cannot contain more than 
one 'if' clause with 'parallel' name modifier}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for if(parallel : argc) if (argc) // expected-error 
{{no more 'if' clause is allowed}}
+  #pragma omp parallel for if(parallel : argc) if (argc) // expected-error 
{{no more 'if' clause is allowed}} expected-note {{previous clause with 
directive name modifier specified here}}
   for (i = 0; i < argc; ++i) foo();
 
   return 0;
@@ -90,7 +90,7 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) foo();
   #pragma omp parallel for if(parallel : argc) if (parallel:argc) // 
expected-error {{directive '#pragma omp parallel for' cannot contain more than 
one 'if' clause with 'parallel' name modifier}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for if(parallel : argc) if (argc) // expected-error 
{{no more 'if' clause is allowed}}
+  #pragma omp parallel for if(parallel : argc) if (argc) // expected-error 
{{no more 'if' clause is allowed}} expected-note {{previous clause with 
directive name modifier specified here}}
   for (i = 0; i < argc; ++i) foo();
 
   return tmain(argc, argv);

Modified: cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp?rev=247706&r1=247705&r2=247706&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp Tue Sep 15 12:23:56 
2015
@@ -46,7 +46,7 @@ int tmain(T argc, S **argv) {
   for (i = 0; i < argc; ++i) foo();
   #pragma omp parallel for simd if(parallel : argc) if (parallel:argc) // 
expected-error {{directive '#pragma omp parallel for simd' cannot contain more 
than one 'if' clause with 'parallel' name modifier}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp parallel for simd if(parallel : argc) if 

Re: [PATCH] D12817: [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Interesting. I'm down with putting this in - would it make more sense to put 
this alongside the buildit bits in the llvm/utils repo?

-eric


http://reviews.llvm.org/D12817



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


Re: [PATCH] D12817: [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Chris Bieneman via cfe-commits
beanz added a comment.

I had considered putting it in the LLVM repo, but this stuff actually works on 
standalone clang builds too, so I felt it might be better here.

-Chris


http://reviews.llvm.org/D12817



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


Re: recordDecl() AST matcher

2015-09-15 Thread Richard Smith via cfe-commits
On Mon, Sep 14, 2015 at 2:41 PM, Manuel Klimek  wrote:
>
> On Mon, Sep 14, 2015 at 2:29 PM Aaron Ballman 
> wrote:
>
>> On Mon, Sep 14, 2015 at 4:38 PM, Manuel Klimek  wrote:
>> >
>> >
>> > On Mon, Sep 14, 2015 at 12:26 PM Aaron Ballman 
>> > wrote:
>> >>
>> >> On Mon, Sep 14, 2015 at 2:45 PM, Daniel Jasper 
>> wrote:
>> >> > By this point, I see that change might be profitable overall.
>> However,
>> >> > lets
>> >> > completely map this out. Changing just cxxRecordDecl() can actually
>> >> > increase
>> >> > confusion in other areas. Right now, not a single AST matcher has the
>> >> > cxx
>> >> > prefix (although a total of 28 stand for the corresponding CXX.. AST
>> >> > node).
>> >> > This is consistent and people knowing this will never try to write
>> >> > cxxConstructExpr(). As soon as people have used cxxRecordDecl(), the
>> >> > chance
>> >> > of them trying cxxConstructExpr() increases. You have spent a long
>> time
>> >> > figuring out that recordDecl means cxxRecordDecl(), which is one
>> >> > datapoint,
>> >> > but I am not aware of anyone else having this specific issue. And we
>> >> > could
>> >> > make this less bad with better documentation, I think.
>> >> >
>> >> > So, for me, the questions are:
>> >> > 1) Do we want/need this change?
>> >>
>> >> We definitely need *a* change because there currently is no way to
>> >> match a C struct or union when compiling in C mode. I discovered this
>> >> because I was trying to write a new checker for clang-tidy that
>> >> focuses on C code and it would fail to match when compiling in C mode.
>> >> Whether we decide to go with cxxRecordDecl vs recordDecl vs structDecl
>> >> (etc) is less important to me than the ability to write clang-tidy
>> >> checks for C code.
>> >>
>> >> > 2) Do we want to be consistent and change the other 27 matchers as
>> well?
>> >>
>> >> I'm on the fence about this for all the reasons you point out.
>> >>
>> >> > A fundamental question is whether we want AST matchers to match AST
>> >> > nodes
>> >> > 1:1 or whether they should be an abstraction from some implementation
>> >> > details of the AST.
>> >>
>> >> I absolutely agree that this is a fundamental question. I think a
>> >> higher priority fundamental question that goes along with it is: are
>> >> we okay with breaking a lot of user code (are these meant to be stable
>> >> APIs like the LLVM C APIs)? If we want these APIs to be stable, that
>> >> changes the answer of what kind of mapping we can have.
>> >
>> >
>> > I think the AST matchers are so closely coupled to the AST that it
>> trying to
>> > be more stable than the AST doesn't help. Basically all uses of AST
>> matchers
>> > do something with the AST nodes afterwards, which will break anyway.
>>
>> I can get behind that logic. So we're okay with breaking their code
>> because there's no way around it -- it's tied to the AST, so users
>> cannot rely on the AST APIs remaining the same from release to release
>> anyway.
>>
>
> We might even *want* the code to break, as the use of the AST node might
> now be incorrect on a semantic level.
>
>
>>
>> >
>> >>
>> >> > And this is not an easy question to answer. There are
>> >> > many places where we don't follow a strict 1:1 mapping. Mostly node
>> >> > matchers, but also in traversal matchers, e.g. isDerivedFrom().
>> >> >
>> >> > Personally, I'd really hate to have the cxx Prefix everywhere, but
>> >> > that's
>> >> > just my personal opinion. I would even prefer matchers like record()
>> and
>> >> > method(), but I think somebody convinced me that that would be a very
>> >> > bad
>> >> > idea ;-).
>> >>
>> >> My personal opinion is that (1) breaking code is fine, but we should
>> >> avoid doing it without very clear benefit, and (2) the mapping between
>> >> AST node identifiers and AST matcher identifiers needs to be
>> >> incredibly obvious, but perhaps not slavishly 1:1. If we instead
>> >> decide we want a 1:1 mapping, then I think we need to start seriously
>> >> considering auto-generating the AST node (and type) matchers from
>> >> tablegen so that the AST nodes *cannot* get out of sync with the AST
>> >> matchers, otherwise we'll be right back here again in a few years when
>> >> we modify the name of an AST node.
>> >
>> >
>> > I do think we want to auto-generate the matchers, but I don't think
>> tablegen
>> > is the right approach (I think an ast-matcher based tool is ;)
>> > That said, auto-generating all the matchers is a) a lot of effort and
>> b) the
>> > code-size and compile time of matchers already matters, so it's unclear
>> > which ones we would want to generate, especially for traversal matchers
>> :(
>>
>> Oh, that's an excellent point (I'm talking about (b), I already knew
>> (a) was a lot of work). Thank you for pointing that out!
>>
>> >
>> >>
>> >> My definition of "incredibly obvious" is: if the AST has a prefixed
>> >> and unprefixed version, or two different prefixes, we should mimic
>> >> that directly with the matchers. Otherwise, exi

r247712 - Rebase tests after LLVM r247707.

2015-09-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep 15 13:49:51 2015
New Revision: 247712

URL: http://llvm.org/viewvc/llvm-project?rev=247712&view=rev
Log:
Rebase tests after LLVM r247707.

Modified:
cfe/trunk/test/CodeGenCXX/init-invariant.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
cfe/trunk/test/CodeGenObjC/exceptions.m

Modified: cfe/trunk/test/CodeGenCXX/init-invariant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/init-invariant.cpp?rev=247712&r1=247711&r2=247712&view=diff
==
--- cfe/trunk/test/CodeGenCXX/init-invariant.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/init-invariant.cpp Tue Sep 15 13:49:51 2015
@@ -56,5 +56,5 @@ void e() {
 
 // CHECK-LABEL: define void @_Z1ev(
 // CHECK: call void @_ZN1AC1Ev(%struct.A* nonnull @_ZZ1evE1a)
-// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} 
@_ZZ1evE1a to i8*))
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* nonnull bitcast ({{.*}} 
@_ZZ1evE1a to i8*))
 // CHECK-NOT: llvm.invariant.end

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp?rev=247712&r1=247711&r2=247712&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp Tue Sep 15 
13:49:51 2015
@@ -60,7 +60,7 @@ T* test5(A* x) { return dynamic_cast
 // CHECK-NEXT:   [[VBOFFP:%.*]] = getelementptr inbounds i32, i32* [[VBTBL]], 
i32 1
 // CHECK-NEXT:   [[VBOFFS:%.*]] = load i32, i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8, i8* [[VOIDP]], i32 
[[VBOFFS]]
-// CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], 
i32 [[VBOFFS]], i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUA@@@8" to 
i8*), i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 0)
+// CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], 
i32 [[VBOFFS]], i8* nonnull bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUA@@@8" 
to i8*), i8* nonnull bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to 
i8*), i32 0)
 // CHECK-NEXT:   [[RES:%.*]] = bitcast i8* [[CALL]] to %struct.T*
 // CHECK-NEXT:   br label
 // CHECK:[[RET:%.*]] = phi %struct.T*
@@ -78,7 +78,7 @@ T* test6(B* x) { return dynamic_cast
 // CHECK-NEXT:   [[VBOFFS:%.*]] = load i32, i32* [[VBOFFP]], align 4
 // CHECK-NEXT:   [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4
 // CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8, i8* [[CAST]], i32 
[[DELTA]]
-// CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], 
i32 [[DELTA]], i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUB@@@8" to i8*), 
i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 0)
+// CHECK-NEXT:   [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], 
i32 [[DELTA]], i8* nonnull bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUB@@@8" 
to i8*), i8* nonnull bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to 
i8*), i32 0)
 // CHECK-NEXT:   [[RES:%.*]] = bitcast i8* [[CALL]] to %struct.T*
 // CHECK-NEXT:   br label
 // CHECK:[[RET:%.*]] = phi %struct.T*

Modified: cfe/trunk/test/CodeGenObjC/exceptions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions.m?rev=247712&r1=247711&r2=247712&view=diff
==
--- cfe/trunk/test/CodeGenObjC/exceptions.m (original)
+++ cfe/trunk/test/CodeGenObjC/exceptions.m Tue Sep 15 13:49:51 2015
@@ -124,7 +124,7 @@ void f3() {
   }
 
   // CHECK:  call void @f3_helper(i32 4, i32* nonnull [[X]])
-  // CHECK-NEXT: call void @llvm.lifetime.end(i64 4, i8* [[XPTR]])
+  // CHECK-NEXT: call void @llvm.lifetime.end(i64 4, i8* nonnull [[XPTR]])
   // CHECK-NEXT: ret void
   f3_helper(4, &x);
 }


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


Re: [PATCH] D12712: Implementation and testing for poisoning vtable ptr in dtor.

2015-09-15 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 34822.
nmusgrave added a comment.

- Re-checking testing for poisoning vtable.


http://reviews.llvm.org/D12712

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  test/CodeGenCXX/sanitize-dtor-vtable.cpp

Index: test/CodeGenCXX/sanitize-dtor-vtable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-vtable.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+class A {
+ public:
+  int x;
+  A() {}
+  virtual ~A() {}
+};
+A a;
+
+class B : virtual public A {
+ public:
+  int y;
+  B() {}
+  ~B() {}
+};
+B b;
+
+// CHECK-LABEL: define {{.*}}AD1Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}AD2Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// After invoking base dtor and dtor for virtual base, poison vtable ptr.
+// CHECK-LABEL: define {{.*}}BD1Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}BD2Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}AD2Ev
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Since no virtual bases, poison vtable ptr here.
+// CHECK-LABEL: define {{.*}}AD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Poison members
+// CHECK-LABEL: define {{.*}}BD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
Index: test/CodeGenCXX/sanitize-dtor-derived-class.cpp
===
--- test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 
-// Only the last dtor of a class invokes the sanitizing callback
-// Sanitizing callback emited prior to base class dtor invocations
+// Base dtor poisons members
+// Complete dtor poisons vtable ptr after destroying members and
+// virtual bases
 
 class Base {
  public:
@@ -28,6 +29,7 @@
 
 Derived d;
 
+// Invoke base destructor. No vtable pointer to poison.
 // CHECK-LABEL: define {{.*}}DerivedD1Ev
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}DerivedD2Ev
@@ -40,6 +42,7 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Invokes base destructor, and poison vtable pointer.
 // CHECK-LABEL: define {{.*}}BaseD1Ev
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}BaseD2Ev
@@ -52,14 +55,17 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison members and vtable ptr.
 // CHECK-LABEL: define {{.*}}BaseD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison members and destroy non-virtual base.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}BaseD2Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK: ret void
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1648,11 +1648,27 @@
 }
   };
 
-  class SanitizeDtor final : public EHScopeStack::Cleanup {
+ static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
+ CharUnits::QuantityType PoisonSize) {
+   // Pass in void pointer and size of region as arguments to runtime
+   // function
+   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+   llvm::FunctionType *FnType =
+   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+   llvm::Value *Fn =
+   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+   CGF.EmitNounwindRuntimeCall(Fn, Args);
+ }
+
+  class

r247714 - [modules] Make sure we make hidden UsingShadowDecls visible to redeclaration

2015-09-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 15 13:51:56 2015
New Revision: 247714

URL: http://llvm.org/viewvc/llvm-project?rev=247714&view=rev
Log:
[modules] Make sure we make hidden UsingShadowDecls visible to redeclaration
lookup for the UsingShadowDecls themselves.

Modified:
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/test/Modules/Inputs/using-decl-a.h
cfe/trunk/test/Modules/Inputs/using-decl-b.h
cfe/trunk/test/Modules/using-decl.cpp

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=247714&r1=247713&r2=247714&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Tue Sep 15 13:51:56 2015
@@ -240,7 +240,7 @@ public:
 // If a using-shadow declaration is hidden, it's never visible, not
 // even to redeclaration lookup.
 // FIXME: Should this apply to typedefs and namespace aliases too?
-if (isa(ND))
+if (isa(ND) && LookupKind != Sema::LookupUsingDeclName)
   return false;
 return (AllowHidden &&
 (AllowHiddenInternal || ND->isExternallyVisible())) ||

Modified: cfe/trunk/test/Modules/Inputs/using-decl-a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-a.h?rev=247714&r1=247713&r2=247714&view=diff
==
--- cfe/trunk/test/Modules/Inputs/using-decl-a.h (original)
+++ cfe/trunk/test/Modules/Inputs/using-decl-a.h Tue Sep 15 13:51:56 2015
@@ -1,5 +1,6 @@
 typedef int using_decl_type;
 int using_decl_var;
+int merged;
 
 namespace UsingDecl {
   using ::using_decl_type;

Modified: cfe/trunk/test/Modules/Inputs/using-decl-b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-b.h?rev=247714&r1=247713&r2=247714&view=diff
==
--- cfe/trunk/test/Modules/Inputs/using-decl-b.h (original)
+++ cfe/trunk/test/Modules/Inputs/using-decl-b.h Tue Sep 15 13:51:56 2015
@@ -8,6 +8,7 @@ namespace UsingDecl {
 namespace UsingDecl {
   using ::using_decl_type;
   using ::using_decl_var;
+  using ::merged;
 }
 
 namespace X {

Modified: cfe/trunk/test/Modules/using-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/using-decl.cpp?rev=247714&r1=247713&r2=247714&view=diff
==
--- cfe/trunk/test/Modules/using-decl.cpp (original)
+++ cfe/trunk/test/Modules/using-decl.cpp Tue Sep 15 13:51:56 2015
@@ -3,9 +3,15 @@
 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify 
-UEARLY_IMPORT
 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify 
-DEARLY_IMPORT -fno-modules-hide-internal-linkage
 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify 
-UEARLY_IMPORT -fno-modules-hide-internal-linkage
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify 
-DEARLY_IMPORT -fmodules-local-submodule-visibility
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify 
-UEARLY_IMPORT -fmodules-local-submodule-visibility
 
 #ifdef EARLY_IMPORT
 @import using_decl.a;
+namespace UsingDecl {
+  using ::merged;
+}
+int k = UsingDecl::merged;
 #endif
 
 namespace Y {


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


Re: [PATCH] D11619: [OPENMP] allow static local variable on data-sharing attribute clause

2015-09-15 Thread Kelvin Li via cfe-commits
kkwli0 added a comment.

Committed revision 247715.


http://reviews.llvm.org/D11619



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


Re: [PATCH] D12840: [cfe-dev] Enabling ThreadSanitizer on PPC64(BE/LE) plarforms

2015-09-15 Thread Simone via cfe-commits
simoatze updated this revision to Diff 34825.
simoatze added a comment.

Added more context.


http://reviews.llvm.org/D12840

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3759,7 +3759,7 @@
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3759,7 +3759,7 @@
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12379: Fix the bugs in the mapDiagnosticRanges (Still in progress)

2015-09-15 Thread Zhengkai Wu via cfe-commits
zhengkai updated this revision to Diff 34826.
zhengkai added a comment.

Use the rtrieu's method to re write the implementation of SourceManager.


http://reviews.llvm.org/D12379

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp
  lib/Frontend/DiagnosticRenderer.cpp
  test/Index/fix-its.m
  test/Misc/caret-diags-macros.c
  test/Misc/diag-macro-backtrace2.c
  test/Misc/reduced-diags-macros.cpp
  test/Misc/serialized-diags.c

Index: test/Misc/serialized-diags.c
===
--- test/Misc/serialized-diags.c
+++ test/Misc/serialized-diags.c
@@ -55,7 +55,6 @@
 // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
 // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 {{.*[/\\]}}serialized-diags.c:22:18
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 'false' []
-// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
 // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16
 // CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
 // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
Index: test/Misc/reduced-diags-macros.cpp
===
--- test/Misc/reduced-diags-macros.cpp
+++ test/Misc/reduced-diags-macros.cpp
@@ -11,7 +11,7 @@
 // CHECK-NEXT: ~~^~
 // CHECK-NEXT: {{.*}}:3:34: note: expanded from macro 'NO_INITIATION'
 // CHECK-NEXT: #define NO_INITIATION(x) int a = x * 2
-// CHECK-NEXT:  ^
+// CHECK-NEXT:  ~   ^
 
 // CHECK: {{.*}}:7:15: error: use of undeclared identifier 'b'
 // CHECK-NEXT: NO_DEFINITION(b);
@@ -27,3 +27,18 @@
 // CHECK: {{.*}}:25:23: error: use of undeclared identifier 'x'
 // CHECK-NEXT: int  p = SWAP_ARGU(3, x);
 // CHECK-NEXT:   ^
+
+#define APPLY(f,x,y) x f y
+
+struct node {
+};
+
+node ff;
+
+int r = APPLY(+,ff,1);
+// CHECK: {{.*}}:38:15: error: invalid operands to binary expression ('node' and 'int')
+// CHECK-NEXT: int r = APPLY(+,ff,1);
+// CHECK-NEXT:   ^ ~~ ~
+// CHECK-NEXT: {{.*}}:31:24: note: expanded from macro 'APPLY'
+// CHECK-NEXT: #define APPLY(f,x,y) x f y
+// CHECK-NEXT:  ~ ^ ~
\ No newline at end of file
Index: test/Misc/diag-macro-backtrace2.c
===
--- test/Misc/diag-macro-backtrace2.c
+++ test/Misc/diag-macro-backtrace2.c
@@ -16,7 +16,7 @@
   // CHECK: :15:3: error: invalid operands to binary expression
   // CHECK:   ('const char *' and 'int')
   // CHECK:   a(str);
-  // CHECK:   ^ ~~~
+  // CHECK:   ^~
   // CHECK: :3:11: note: expanded from macro 'a'
   // CHECK: #define a b
   // CHECK:   ^
@@ -28,7 +28,7 @@
   // CHECK:  ^~~~
   // CHECK: :6:15: note: expanded from macro 'd'
   // CHECK: #define d(x) x*1
-  // CHECK:   ^~
+  // CHECK:  ~^~
 
   e(str);
   // CHECK: :33:5: warning: expression result unused
Index: test/Misc/caret-diags-macros.c
===
--- test/Misc/caret-diags-macros.c
+++ test/Misc/caret-diags-macros.c
@@ -16,9 +16,6 @@
 void bar() {
   C(1);
   // CHECK: {{.*}}:17:5: warning: expression result unused
-  // CHECK: {{.*}}:15:16: note: expanded from macro 'C'
-  // CHECK: {{.*}}:14:16: note: expanded from macro 'B'
-  // CHECK: {{.*}}:13:14: note: expanded from macro 'A'
 }
 
 // rdar://7597492
@@ -41,62 +38,59 @@
 
 void test() {
   macro_args3(11);
-  // CHECK: {{.*}}:43:15: warning: expression result unused
+  // CHECK: {{.*}}:40:15: warning: expression result unused
   // Also check that the 'caret' printing agrees with the location here where
   // its easy to FileCheck.
   // CHECK-NEXT:  macro_args3(11);
   // CHECK-NEXT: {{^  \^~}}
-  // CHECK: {{.*}}:36:36: note: expanded from macro 'macro_args3'
-  // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
-  // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
 
   macro_many_args3(
 1,
 2,
 3);
-  // CHECK: {{.*}}:55:5: warning: expression result unused
-  // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
-  // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
-  // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
+  // CHECK: {{.*}}:49:5: warning: expression result unused
+  // CHECK: {{.*}}:37:55: note: expanded from macro 'macro_many_args3'
+  // CHECK: {{.*}}:36:55: note: expanded from macro 'macro_many_args2'
+  // CHECK: {{.*}}:35:35: note: expanded from macro 'macro_many_args1'
 
   macro_many_args3(
 1,
 M2,
 3);
-  // CHECK: {{.*}}:64:5: warning: expression result unused
+  // CHE

Re: r247618 - C11 _Bool bitfield diagnostic

2015-09-15 Thread Nico Weber via cfe-commits
With this patch, we warn on `bool a : 4;`, yet we don't warn on `bool b`
(which has 8 bits storage, 1 bit value). Warning on `bool b` is silly of
course, but why is warning on `bool a : 4` useful? That's like 50% more
storage efficient than `bool b` ;-)

It's possible that this is a good warning for some reason, but I don't
quite see why yet.

On Mon, Sep 14, 2015 at 11:06 PM, Richard Smith 
wrote:

> On Mon, Sep 14, 2015 at 7:07 PM, Rachel Craik  wrote:
>
>> As of DR262, the C standard clarified that the width of a bit-field can
>> not exceed that of the specified type, and this change was primarily to
>> ensure that Clang correctly enforced this part of the standard. Looking at
>> the C++11 standard again, it states that although the specified width of a
>> bit-field may exceed the number of bits in the *object representation* (which
>> includes padding bits) of the specified type, the extra bits will not take
>> any part in the bit-field's *value representation*.
>>
>> Taking this into account, it seems that the correct way to validate the
>> width of a bit-field (ignoring the special case of MS in C mode) would be
>> to use getIntWidth in C mode, and getTypeSize in C++ mode.
>>
>> I would be happy create a patch to make this change tomorrow if people
>> are in agreement.
>>
> David Majnemer has already landed a couple of changes to fix this up, so
> hopefully that won't be necessary. Thanks for working on this!
>
>> Rachel
>>
>>
>> [image: Inactive hide details for Nico Weber ---09/14/2015 09:53:25
>> PM---On Mon, Sep 14, 2015 at 5:28 PM, Richard Smith > Weber ---09/14/2015 09:53:25 PM---On Mon, Sep 14, 2015 at 5:28 PM, Richard
>> Smith  wrote:
>>
>> From: Nico Weber 
>> To: Richard Smith 
>> Cc: Rachel Craik/Toronto/IBM@IBMCA, cfe-commits <
>> cfe-commits@lists.llvm.org>
>> Date: 09/14/2015 09:53 PM
>> Subject: Re: r247618 - C11 _Bool bitfield diagnostic
>> Sent by: tha...@google.com
>> --
>>
>>
>>
>> On Mon, Sep 14, 2015 at 5:28 PM, Richard Smith <*rich...@metafoo.co.uk*
>> > wrote:
>>
>>On Mon, Sep 14, 2015 at 5:18 PM, Nico Weber via cfe-commits <
>>*cfe-commits@lists.llvm.org* > wrote:
>>   This also fires for bool in C++ files, even though the commit
>>   message saying C11 and _Bool. Given the test changes, I suppose that's
>>   intentional? This fires a lot on existing code, for example protobuf:
>>
>>   ../../third_party/protobuf/src/google/protobuf/extension_set.h:465:10:
>>   error: width of bit-field 'is_cleared' (4 bits) exceeds the width of 
>> its
>>   type; value will be truncated to 1 bit [-Werror,-Wbitfield-width]
>>   bool is_cleared : 4;
>>^
>>   ../../third_party/protobuf/src/google/protobuf/extension_set.h:472:10:
>>   error: width of bit-field 'is_lazy' (4 bits) exceeds the width of its 
>> type;
>>   value will be truncated to 1 bit [-Werror,-Wbitfield-width]
>>   bool is_lazy : 4;
>>^
>>
>>   Is this expected? Is this a behavior change, or did the truncation
>>   happen previously and it's now just getting warned on?
>>
>>The code previously assumed that MSVC used the C rules here; it
>>appears that's not true in all cases.
>>
>>
>> This was on a Mac bot…
>>
>>
>>
>>Can we just remove the " || IsMsStruct
>>|| Context.getTargetInfo().getCXXABI().isMicrosoft()"? Is there some 
>> reason
>>we need to prohibit overwide bitfields for MS bitfield layout, rather than
>>just warning on them? (Does record layout fail somehow?)
>>On Mon, Sep 14, 2015 at 2:27 PM, Rachel Craik via cfe-commits <
>>   *cfe-commits@lists.llvm.org* > wrote:
>>  Author: rcraik
>>  Date: Mon Sep 14 16:27:36 2015
>>  New Revision: 247618
>>
>>  URL: *http://llvm.org/viewvc/llvm-project?rev=247618&view=rev*
>>  
>>  Log:
>>  C11 _Bool bitfield diagnostic
>>
>>  Summary: Implement DR262 (for C). This patch will mainly affect
>>  bitfields of type _Bool
>>
>>  Reviewers: fraggamuffin, rsmith
>>
>>  Subscribers: hubert.reinterpretcast, cfe-commits
>>
>>  Differential Revision: *http://reviews.llvm.org/D10018*
>>  
>>
>>  Modified:
>>  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>  cfe/trunk/lib/Sema/SemaDecl.cpp
>>  cfe/trunk/test/CodeGen/bitfield-2.c
>>  cfe/trunk/test/CodeGenCXX/warn-padded-packed.cpp
>>  cfe/trunk/test/Misc/warning-flags.c
>>  cfe/trunk/test/Sema/bitfield.c
>>  cfe/trunk/test/SemaCXX/bitfield-layout.cpp
>>  cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
>>  cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
>>  cfe/trunk/test/SemaCXX/ms_wide_bi

Re: [PATCH] D12840: [cfe-dev] Enabling ThreadSanitizer on PPC64(BE/LE) plarforms

2015-09-15 Thread Simone via cfe-commits
simoatze updated this revision to Diff 34830.
simoatze added a comment.

Ignore previous update.


http://reviews.llvm.org/D12840

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3759,7 +3759,7 @@
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3759,7 +3759,7 @@
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.

2015-09-15 Thread Aaron Ballman via cfe-commits
aaron.ballman added reviewers: rtrieu, rsmith.
aaron.ballman added a comment.

There is a -Wpessimizing-move frontend warning that Richard added not too long 
ago, which tells the user to remove calls to std::move() because they pessimize 
the code. The new functionality you are looking to add is basically the 
opposite: it tells the user to add std::move() because the code is currently 
pessimized due to copies. Given how general that concept is (it doesn't just 
appertain to constructor initializations), I wonder if this makes more sense as 
a frontend warning like -Wpessimizing-copy.

Richard (both of you), what do you think?

~Aaron



Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:32
@@ +31,3 @@
+  // excessive copying, we'll warn on them.
+  if (Node->isDependentType()) {
+return false;

Elide braces, here and elsewhere.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:36
@@ +35,3 @@
+  // Ignore trivially copyable types.
+  if (Node->isScalarType() ||
+  Node.isTriviallyCopyableType(Finder->getASTContext()) ||

Can turn this into a return statement directly instead of an if.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:38
@@ +37,3 @@
+  Node.isTriviallyCopyableType(Finder->getASTContext()) ||
+  classHasTrivialCopyAndDestroy(Node)) {
+return false;

Why do you need classHasTrivialCopyAndDestroy() when you're already checking if 
it's a trivially copyable type?


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:44
@@ +43,3 @@
+
+int parmVarDeclRefExprOccurences(const ParmVarDecl &MovableParam,
+ const CXXConstructorDecl &ConstructorDecl,

Should return unsigned, please.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:50
@@ +49,3 @@
+  findAll(declRefExpr(to(parmVarDecl(equalsNode(&MovableParam);
+  auto Matches = match(AllDeclRefs, *ConstructorDecl.getBody(), Context);
+  Occurrences += Matches.size();

You don't actually need Matches, you can call match().size() instead.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:52
@@ +51,3 @@
+  Occurrences += Matches.size();
+  for (const auto* Initializer : ConstructorDecl.inits()) {
+Matches = match(AllDeclRefs, *Initializer->getInit(), Context);

Should be *Initializer instead of * Initializer.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:120
@@ +119,3 @@
+  }
+  diag(InitArg->getLocStart(), "value parameter can be moved to avoid copy.");
+}

Perhaps: "argument can be moved to avoid a copy" instead?


Comment at: test/clang-tidy/misc-move-constructor-init.cpp:84
@@ +83,3 @@
+  Movable(const Movable&) = default;
+  Movable& operator =(const Movable&) = default;
+  ~Movable() {}

Formatting


Comment at: test/clang-tidy/misc-move-constructor-init.cpp:85
@@ +84,3 @@
+  Movable& operator =(const Movable&) = default;
+  ~Movable() {}
+};

Why not = default?


Comment at: test/clang-tidy/misc-move-constructor-init.cpp:113
@@ +112,3 @@
+
+struct NegativeParamTriviallyCopyable {
+  NegativeParamTriviallyCopyable(TriviallyCopyable T) : T_(T) {}

Should also have a test for scalars


http://reviews.llvm.org/D12839



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


Re: [PATCH] D12817: [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Eric Christopher via cfe-commits
echristo added a comment.

Standalone as "clang that only sorta depends on llvm"?


http://reviews.llvm.org/D12817



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


Re: [PATCH] D12817: [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Chris Bieneman via cfe-commits
beanz added a comment.

Standalone as in using the base system's LLVM installation. So you don't 
actually have to have an llvm checkout.

There's goop in the root clang CMakeLists file to support building clang as the 
top-level CMake tool, and all this stuff should work in that context as well.

-Chris


http://reviews.llvm.org/D12817



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


Re: [PATCH] D12817: [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Eric Christopher via cfe-commits
Ah sure. Make it so then.

On Tue, Sep 15, 2015, 1:04 PM Chris Bieneman  wrote:

> beanz added a comment.
>
> Standalone as in using the base system's LLVM installation. So you don't
> actually have to have an llvm checkout.
>
> There's goop in the root clang CMakeLists file to support building clang
> as the top-level CMake tool, and all this stuff should work in that context
> as well.
>
> -Chris
>
>
> http://reviews.llvm.org/D12817
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247717 - Add test coverage for @encode(SEL); completely untested until now.

2015-09-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep 15 15:05:20 2015
New Revision: 247717

URL: http://llvm.org/viewvc/llvm-project?rev=247717&view=rev
Log:
Add test coverage for @encode(SEL); completely untested until now.

Modified:
cfe/trunk/test/CodeGenObjC/encode-test.m

Modified: cfe/trunk/test/CodeGenObjC/encode-test.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test.m?rev=247717&r1=247716&r2=247717&view=diff
==
--- cfe/trunk/test/CodeGenObjC/encode-test.m (original)
+++ cfe/trunk/test/CodeGenObjC/encode-test.m Tue Sep 15 15:05:20 2015
@@ -177,3 +177,6 @@ const char g13[] = @encode(__typeof__(*t
 const char g14[] = @encode(__typeof__(*test_id));
 // CHECK: constant [14 x i8] c"{objc_class=}\00"
 // CHECK: constant [15 x i8] c"{objc_object=}\00"
+
+// CHECK: @g15 = constant [2 x i8] c":\00"
+const char g15[] = @encode(SEL);


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


Re: [PATCH] D12835: [X86][SSE] Replace 128-bit SSE41 PMOVSX intrinsics with native IR

2015-09-15 Thread Quentin Colombet via cfe-commits
qcolombet accepted this revision.
qcolombet added a comment.
This revision is now accepted and ready to land.

LGTM.

Thanks,
-Quentin


Repository:
  rL LLVM

http://reviews.llvm.org/D12835



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


Re: [PATCH] D12379: Fix the bugs in the mapDiagnosticRanges (Still in progress)

2015-09-15 Thread Zhengkai Wu via cfe-commits
zhengkai added a comment.

In http://reviews.llvm.org/D12379#245892, @rtrieu wrote:

> In http://reviews.llvm.org/D12379#245868, @zhengkai wrote:
>
> > In http://reviews.llvm.org/D12379#245861, @rtrieu wrote:
> >
> > > In http://reviews.llvm.org/D12379#245850, @zhengkai wrote:
> > >
> > > > In http://reviews.llvm.org/D12379#245849, @rtrieu wrote:
> > > >
> > > > > Why are you leaking the raw encoding of locations from the 
> > > > > SourceManager?  This is an internal implementation detail and should 
> > > > > not be relied on externally.  SourceLocation is the typical way to 
> > > > > use locations.
> > > >
> > > >
> > > > Because I want to check if all the ranges fit in the same argument of 
> > > > one macro invocation, they can be different Source Locations. In 
> > > > ExpansionInfo, these locations have the same ExpansionLocStart.
> > >
> > >
> > > If you call ExpansionInfo::getExpansionLocStart(), then the 
> > > SourceLocation will be the same if the ExpansionLocStart is the same.
> >
> >
> > But I still need to change the isMacroArg function to get the result of 
> > getExpansionLocStart(), and if I want to compare two SourceLocation, I 
> > still need to check the raw encoding. I don't know if it is needed not to 
> > leak the raw encoding.
>
>
> I kind of see what you are trying to do here, and we should fix it a 
> different way.
>
> 1. Get rid of changes to ExpansionInfo
> 2. Change the function SourceManager::isMacroArgExpansion to take two 
> arguments instead of one.  The new argument should be a SourceLocation 
> pointer named MacroBegin.
> 3. Change the last line of SourceManager::isMacroArgExpansion from "return 
> Expansion.isMacroArgExpansion();" to "if (!Expansion.isMacroArgExpansion()) 
> return false;"  After that, add the code to get the macro begin location.
> 4. Update DiagnosticRenderer to use SourceLocation instead of raw encodings.


Have changed the implementation.


http://reviews.llvm.org/D12379



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


Re: [PATCH] D12026: Decorating vptr load & stores with !invariant.group

2015-09-15 Thread Piotr Padlewski via cfe-commits
Prazek updated the summary for this revision.
Prazek updated this revision to Diff 34833.

http://reviews.llvm.org/D12026

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/invariant.group-for-vptrs.cpp

Index: test/CodeGenCXX/invariant.group-for-vptrs.cpp
===
--- /dev/null
+++ test/CodeGenCXX/invariant.group-for-vptrs.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -fstrict-vtable-pointers -O1 -o - -disable-llvm-optzns | FileCheck %s
+
+struct A {
+  virtual void foo();
+};
+
+struct D : A {
+  void foo();
+};
+
+// CHECK-LABEL: define void @_Z21testExternallyVisiblev()
+void testExternallyVisible() {
+  A *a = new A;
+
+  // CHECK: load {{.*}} !invariant.group ![[A_MD:[0-9]+]]
+  a->foo();
+
+  D *d = new D;
+  // CHECK: call void @_ZN1DC1Ev(
+  // CHECK: load {{.*}} !invariant.group ![[D_MD:[0-9]+]]
+  d->foo();
+  A *a2 = d;
+  // CHECK: load {{.*}} !invariant.group ![[A_MD]]
+  a2->foo();
+}
+// CHECK-LABEL: }
+
+namespace {
+
+struct B {
+  virtual void bar();
+};
+
+struct C : B {
+  void bar();
+};
+
+}
+
+// CHECK-LABEL: define void @_Z21testInternallyVisibleb(
+void testInternallyVisible(bool p) {
+  B *b = new B;
+  // CHECK: = load {{.*}}, !invariant.group ![[B_MD:[0-9]+]]
+  b->bar();
+
+  // CHECK: call void @_ZN12_GLOBAL__N_11CC1Ev(
+  C *c = new C;
+  // CHECK: = load {{.*}}, !invariant.group ![[C_MD:[0-9]+]]
+  c->bar();
+}
+
+// Checking A::A()
+// CHECK-LABEL: define linkonce_odr void @_ZN1AC2Ev(
+// CHECK: store {{.*}}, !invariant.group ![[A_MD]]
+// CHECK-LABEL: }
+
+// Checking D::D()
+// CHECK-LABEL: define linkonce_odr void @_ZN1DC2Ev(
+
+// CHECK:  call void @_ZN1AC2Ev(%struct.A*
+// CHECK:  = call i8* @llvm.invariant.group.barrier(i8*
+// CHECK: store {{.*}} !invariant.group ![[D_MD]]
+
+// Checking B::B()
+// CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11BC2Ev(
+// CHECK:  store {{.*}}, !invariant.group ![[B_MD]]
+
+// Checking C::C()
+// CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11CC2Ev(
+// CHECK:  store {{.*}}, !invariant.group ![[C_MD]]
+
+// CHECK: ![[A_MD]] = !{!"_ZTS1A"}
+// CHECK: ![[D_MD]] = !{!"_ZTS1D"}
+// CHECK: ![[B_MD]] = distinct !{}
+// CHECK: ![[C_MD]] = distinct !{}
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1831,7 +1831,9 @@
   Ty = Ty->getPointerTo()->getPointerTo();
   Address VPtr =
   adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true);
-  llvm::Value *VTable = CGF.GetVTablePtr(VPtr, Ty);
+
+  auto *MethodDecl = cast(GD.getDecl());
+  llvm::Value *VTable = CGF.GetVTablePtr(VPtr, Ty, MethodDecl->getParent());
 
   MicrosoftVTableContext::MethodVFTableLocation ML =
   CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
@@ -1958,7 +1960,8 @@
   // Load the vfptr and then callee from the vftable.  The callee should have
   // adjusted 'this' so that the vfptr is at offset zero.
   llvm::Value *VTable = CGF.GetVTablePtr(
-  getThisAddress(CGF), ThunkTy->getPointerTo()->getPointerTo());
+  getThisAddress(CGF), ThunkTy->getPointerTo()->getPointerTo(), MD->getParent());
+
   llvm::Value *VFuncPtr =
   CGF.Builder.CreateConstInBoundsGEP1_64(VTable, ML.Index, "vfn");
   llvm::Value *Callee =
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -584,7 +584,7 @@
 CGF.CGM.getDynamicOffsetAlignment(ThisAddr.getAlignment(), RD,
   CGF.getPointerAlign());
   llvm::Value *VTable =
-CGF.GetVTablePtr(Address(This, VTablePtrAlign), VTableTy);
+CGF.GetVTablePtr(Address(This, VTablePtrAlign), VTableTy, RD);
 
   // Apply the offset.
   llvm::Value *VTableOffset = FnAsInt;
@@ -1012,7 +1012,10 @@
 // to pass to the deallocation function.
 
 // Grab the vtable pointer as an intptr_t*.
-llvm::Value *VTable = CGF.GetVTablePtr(Ptr, CGF.IntPtrTy->getPointerTo());
+auto *ClassDecl =
+cast(ElementType->getAs()->getDecl());
+llvm::Value *VTable =
+CGF.GetVTablePtr(Ptr, CGF.IntPtrTy->getPointerTo(), ClassDecl);
 
 // Track back to entry -2 and pull out the offset there.
 llvm::Value *OffsetPtr = CGF.Builder.CreateConstInBoundsGEP1_64(
@@ -1211,8 +1214,10 @@
QualType SrcRecordTy,
Address ThisPtr,
llvm::Type *StdTypeInfoPtrTy) {
+  auto *ClassDecl =
+  cast(SrcRecordTy->getAs()->getDecl());
   llvm::Value *Value =
-  CGF.GetVTabl

Re: [PATCH] D12422: Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)

2015-09-15 Thread Hans Wennborg via cfe-commits
hans added a comment.

In http://reviews.llvm.org/D12422#235509, @majnemer wrote:

> We should probably do something about lambdas, they can't be imported or 
> exported but this can be done in a follow up patch.


Follow-up in r247718.


Repository:
  rL LLVM

http://reviews.llvm.org/D12422



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


r247718 - MS ABI: Don't allow dllexport/import on lambdas

2015-09-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Sep 15 16:05:30 2015
New Revision: 247718

URL: http://llvm.org/viewvc/llvm-project?rev=247718&view=rev
Log:
MS ABI: Don't allow dllexport/import on lambdas

This is to follow up on David's comment in
http://reviews.llvm.org/D12422#235509

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/dllexport.cpp
cfe/trunk/test/SemaCXX/dllimport.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=247718&r1=247717&r2=247718&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 15 16:05:30 
2015
@@ -2274,6 +2274,8 @@ def err_attribute_dll_not_extern : Error
   "%q0 must have external linkage when declared %q1">;
 def err_attribute_dll_thread_local : Error<
   "%q0 cannot be thread local when declared %q1">;
+def err_attribute_dll_lambda : Error<
+  "lambda cannot be declared %0">;
 def warn_attribute_invalid_on_definition : Warning<
   "'%0' attribute cannot be specified on a definition">,
   InGroup;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=247718&r1=247717&r2=247718&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Sep 15 16:05:30 2015
@@ -4335,6 +4335,14 @@ static void handleDLLAttr(Sema &S, Decl
 }
   }
 
+  if (auto *MD = dyn_cast(D)) {
+if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+MD->getParent()->isLambda()) {
+  S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << 
A.getName();
+  return;
+}
+  }
+
   unsigned Index = A.getAttributeSpellingListIndex();
   Attr *NewAttr = A.getKind() == AttributeList::AT_DLLExport
   ? (Attr *)S.mergeDLLExportAttr(D, A.getRange(), Index)

Modified: cfe/trunk/test/SemaCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllexport.cpp?rev=247718&r1=247717&r2=247718&view=diff
==
--- cfe/trunk/test/SemaCXX/dllexport.cpp (original)
+++ cfe/trunk/test/SemaCXX/dllexport.cpp Tue Sep 15 16:05:30 2015
@@ -1083,3 +1083,12 @@ template template bool { return true; };

Modified: cfe/trunk/test/SemaCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllimport.cpp?rev=247718&r1=247717&r2=247718&view=diff
==
--- cfe/trunk/test/SemaCXX/dllimport.cpp (original)
+++ cfe/trunk/test/SemaCXX/dllimport.cpp Tue Sep 15 16:05:30 2015
@@ -1339,3 +1339,14 @@ struct __declspec(dllimport) DerivedFrom
 template  struct ExplicitInstantiationDeclTemplateBase { void 
func() {} };
 extern template struct ExplicitInstantiationDeclTemplateBase;
 struct __declspec(dllimport) DerivedFromExplicitInstantiationDeclTemplateBase 
: public ExplicitInstantiationDeclTemplateBase {};
+
+//===--===//
+// Lambdas
+//===--===//
+// The MS ABI doesn't provide a stable mangling for lambdas, so they can't be 
imported or exported.
+#ifdef MS
+// expected-error@+4{{lambda cannot be declared 'dllimport'}}
+#else
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
+auto Lambda = []() __declspec(dllimport) -> bool { return true; };


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


Re: [PATCH] D12026: Decorating vptr load & stores with !invariant.group

2015-09-15 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/CodeGen/CodeGenModule.cpp:3859
@@ -3848,4 +3858,3 @@
   } else {
-InternalId = llvm::MDNode::getDistinct(getLLVMContext(),
-   llvm::ArrayRef());
+InternalId = llvm::MDNode::getDistinct(getLLVMContext(), {});
   }

I think this may break the MSVC build, and it looks unrelated to the other 
changes. Revert this bit, or use `llvm::None`. In the latter case, commit this 
separately.


http://reviews.llvm.org/D12026



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


Re: [PATCH] D12026: Decorating vptr load & stores with !invariant.group

2015-09-15 Thread Piotr Padlewski via cfe-commits
Prazek marked an inline comment as done.


Comment at: lib/CodeGen/CodeGenModule.cpp:3859
@@ -3848,4 +3858,3 @@
   } else {
-InternalId = llvm::MDNode::getDistinct(getLLVMContext(),
-   llvm::ArrayRef());
+InternalId = llvm::MDNode::getDistinct(getLLVMContext(), {});
   }

rsmith wrote:
> I think this may break the MSVC build, and it looks unrelated to the other 
> changes. Revert this bit, or use `llvm::None`. In the latter case, commit 
> this separately.
ok


http://reviews.llvm.org/D12026



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


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-09-15 Thread Samuel Antao via cfe-commits
sfantao abandoned this revision.
sfantao added a comment.

Closing revision. It has been replaced by http://reviews.llvm.org/D12871 has 
suggested by John.

Thanks!
Samuel


http://reviews.llvm.org/D11361



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


Re: [PATCH] D12312: Emiting invariant.group.barrier and adding -fstrict-vptrs

2015-09-15 Thread Piotr Padlewski via cfe-commits
Prazek marked an inline comment as done.
Prazek added a comment.

http://reviews.llvm.org/D12312



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


Re: [PATCH] D12312: Emiting invariant.group.barrier and adding -fstrict-vptrs

2015-09-15 Thread Piotr Padlewski via cfe-commits
Prazek accepted this revision.
Prazek added a reviewer: Prazek.
Prazek added a comment.
This revision is now accepted and ready to land.

Accept to close


http://reviews.llvm.org/D12312



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


r247725 - Decorating vptr load & stores with !invariant.group

2015-09-15 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Tue Sep 15 16:46:55 2015
New Revision: 247725

URL: http://llvm.org/viewvc/llvm-project?rev=247725&view=rev
Log:
Decorating vptr load & stores with !invariant.group

Adding !invariant.group to vptr load/stores for devirtualization purposes.
For more goto:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

http://reviews.llvm.org/D12026

Added:
cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=247725&r1=247724&r2=247725&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Tue Sep 15 16:46:55 2015
@@ -1246,7 +1246,7 @@ llvm::Value *AtomicInfo::EmitAtomicLoadO
   if (IsVolatile)
 Load->setVolatile(true);
   if (LVal.getTBAAInfo())
-CGF.CGM.DecorateInstruction(Load, LVal.getTBAAInfo());
+CGF.CGM.DecorateInstructionWithTBAA(Load, LVal.getTBAAInfo());
   return Load;
 }
 
@@ -1769,7 +1769,7 @@ void CodeGenFunction::EmitAtomicStore(RV
 if (IsVolatile)
   store->setVolatile(true);
 if (dest.getTBAAInfo())
-  CGM.DecorateInstruction(store, dest.getTBAAInfo());
+  CGM.DecorateInstructionWithTBAA(store, dest.getTBAAInfo());
 return;
   }
 

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247725&r1=247724&r2=247725&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Sep 15 16:46:55 2015
@@ -25,6 +25,7 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Metadata.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -2087,7 +2088,8 @@ void CodeGenFunction::EmitVTableAssumpti
 ApplyNonVirtualAndVirtualOffset(*this, This, NonVirtualOffset, nullptr,
 Vptr.VTableClass, Vptr.NearestVBase);
 
-  llvm::Value *VPtrValue = GetVTablePtr(This, VTableGlobal->getType());
+  llvm::Value *VPtrValue =
+  GetVTablePtr(This, VTableGlobal->getType(), Vptr.VTableClass);
   llvm::Value *Cmp =
   Builder.CreateICmpEQ(VPtrValue, VTableGlobal, "cmp.vtables");
   Builder.CreateAssumption(Cmp);
@@ -2306,7 +2308,10 @@ void CodeGenFunction::InitializeVTablePo
   VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
-  CGM.DecorateInstruction(Store, CGM.getTBAAInfoForVTablePtr());
+  CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAInfoForVTablePtr());
+  if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+  CGM.getCodeGenOpts().StrictVTablePointers)
+CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.VTableClass);
 }
 
 CodeGenFunction::VPtrsVector
@@ -2393,10 +2398,16 @@ void CodeGenFunction::InitializeVTablePo
 }
 
 llvm::Value *CodeGenFunction::GetVTablePtr(Address This,
-   llvm::Type *Ty) {
-  Address VTablePtrSrc = Builder.CreateElementBitCast(This, Ty);
+   llvm::Type *VTableTy,
+   const CXXRecordDecl *RD) {
+  Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy);
   llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable");
-  CGM.DecorateInstruction(VTable, CGM.getTBAAInfoForVTablePtr());
+  CGM.DecorateInstructionWithTBAA(VTable, CGM.getTBAAInfoForVTablePtr());
+
+  if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+  CGM.getCodeGenOpts().StrictVTablePointers)
+CGM.DecorateInstructionWithInvariantGroup(VTable, RD);
+
   return VTable;
 }
 
@@ -2481,7 +2492,8 @@ void CodeGenFunction::EmitVTablePtrCheck
   }
 
   llvm::Value *VTable =
-GetVTablePtr(Address(Derived, getPointerAlign()), Int8PtrTy);
+GetVTablePtr(Address(Derived, getPointerAlign()), Int8PtrTy, ClassDecl);
+
   EmitVTablePtrCheck(ClassDecl, VTable, TCK, Loc);
 
   if (MayBeNull) {

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=247725&r1=247724&r2=247725&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Sep 15 16:46:55 2015
@@ -1277,7 +1277,8 @@ llvm:

r247724 - Added llvm.module flag for strict vtable pointers

2015-09-15 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Tue Sep 15 16:46:50 2015
New Revision: 247724

URL: http://llvm.org/viewvc/llvm-project?rev=247724&view=rev
Log:
Added llvm.module flag for strict vtable pointers

It is dangerous to do LTO on code with strict-vtable-pointers, because
one module has invariant.group.barriers, and the other one not.

In the future I want to just strip all invariant.group metadata from
vptrs loads/stores and get rid of invariant.group.barrier calls.

http://reviews.llvm.org/D12580

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=247724&r1=247723&r2=247724&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Sep 15 16:46:50 2015
@@ -398,6 +398,22 @@ void CodeGenModule::Release() {
 // Indicate that we want CodeView in the metadata.
 getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
   }
+  if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
+// We don't support LTO with 2 with different StrictVTablePointers
+// FIXME: we could support it by stripping all the information introduced
+// by StrictVTablePointers.
+
+getModule().addModuleFlag(llvm::Module::Error, "StrictVTablePointers",1);
+
+llvm::Metadata *Ops[2] = {
+  llvm::MDString::get(VMContext, "StrictVTablePointers"),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  llvm::Type::getInt32Ty(VMContext), 1))};
+
+getModule().addModuleFlag(llvm::Module::Require,
+  "StrictVTablePointersRequirement",
+  llvm::MDNode::get(VMContext, Ops));
+  }
   if (DebugInfo)
 // We support a single version in the linked module. The LLVM
 // parser will drop debug info with a different version number

Modified: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp?rev=247724&r1=247723&r2=247724&view=diff
==
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp Tue Sep 15 16:46:50 
2015
@@ -2,6 +2,7 @@
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
+// RUN: FileCheck --check-prefix=CHECK-LINK-REQ %s < %t.ll
 
 typedef __typeof__(sizeof(0)) size_t;
 void *operator new(size_t, void*) throw();
@@ -191,3 +192,11 @@ struct DynamicFromStatic;
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN14DynamicDerivedD2Ev
 // CHECK-DTORS-NOT: call i8* @llvm.invariant.group.barrier(
 // CHECK-DTORS-LABEL: }
+
+
+// CHECK-LINK-REQ: !llvm.module.flags = !{![[FIRST:.*]], ![[SEC:.*]]{{.*}}}
+
+// CHECK-LINK-REQ: ![[FIRST]] = !{i32 1, !"StrictVTablePointers", i32 1}
+// CHECK-LINK-REQ: ![[SEC]] = !{i32 3, !"StrictVTablePointersRequirement", 
![[META:.*]]}
+// CHECK-LINK-REQ: ![[META]] = !{!"StrictVTablePointers", i32 1}
+


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


r247723 - Emiting llvm.invariant.group.barrier when dynamic type changes

2015-09-15 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Tue Sep 15 16:46:47 2015
New Revision: 247723

URL: http://llvm.org/viewvc/llvm-project?rev=247723&view=rev
Log:
Emiting llvm.invariant.group.barrier when dynamic type changes

For more goto:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

http://reviews.llvm.org/D12312

Added:
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.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=247723&r1=247722&r2=247723&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Sep 15 16:46:47 2015
@@ -862,6 +862,8 @@ def fno_strict_aliasing : Flag<["-"], "f
 def fstruct_path_tbaa : Flag<["-"], "fstruct-path-tbaa">, Group;
 def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group;
 def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group;
+def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">, 
+  Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
@@ -990,6 +992,10 @@ def fstrict_aliasing : Flag<["-"], "fstr
 def fstrict_enums : Flag<["-"], "fstrict-enums">, Group, 
Flags<[CC1Option]>,
   HelpText<"Enable optimizations based on the strict definition of an enum's "
"value range">;
+def fstrict_vtable_pointers: Flag<["-"], "fstrict-vtable-pointers">, 
+  Group, Flags<[CC1Option]>,
+  HelpText<"Enable optimizations based on the strict rules for overwriting "
+ "polymorphic C++ objects">;
 def fstrict_overflow : Flag<["-"], "fstrict-overflow">, Group;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
   Flags<[DriverOption,CoreOption,CC1Option]>, Group;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=247723&r1=247722&r2=247723&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Tue Sep 15 16:46:47 2015
@@ -132,6 +132,7 @@ CODEGENOPT(SanitizeCoverage8bitCounters,
 CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.
 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.
 CODEGENOPT(StrictEnums   , 1, 0) ///< Optimize based on strict enum 
definition.
+CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict 
vtable pointers
 CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report is enabled.
 CODEGENOPT(UnitAtATime   , 1, 1) ///< Unused. For mirroring GCC 
optimization
  ///< selection.

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247723&r1=247722&r2=247723&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Sep 15 16:46:47 2015
@@ -1344,6 +1344,13 @@ namespace {
 
 }
 
+static bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit) {
+  const Type *BaseType = BaseInit->getBaseClass();
+  const auto *BaseClassDecl =
+  cast(BaseType->getAs()->getDecl());
+  return BaseClassDecl->isDynamicClass();
+}
+
 /// EmitCtorPrologue - This routine generates necessary code to initialize
 /// base classes and non-static data members belonging to this constructor.
 void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
@@ -1367,9 +1374,13 @@ void CodeGenFunction::EmitCtorPrologue(c
 assert(BaseCtorContinueBB);
   }
 
+  bool BaseVPtrsInitialized = false;
   // Virtual base initializers first.
   for (; B != E && (*B)->isBaseInitializer() && (*B)->isBaseVirtual(); B++) {
+CXXCtorInitializer *BaseInit = *B;
 EmitBaseInitializer(*this, ClassDecl, *B, CtorType);
+BaseVPtrsInitialized |= BaseInitializerUsesThis(getContext(),
+BaseInit->getInit());
   }
 
   if (BaseCtorContinueBB) {
@@ -1382,8 +1393,15 @@ void CodeGenFunction::EmitCtorPrologue(c
   for (; B != E && (*B)->isBaseInitializer(); B++) {
 assert(!(*B)->isBaseVirtual());
 EmitBaseInitializer(*this, ClassDecl, *B, CtorType);
+BaseVPtrsInitialized |= isInitializerOfDynamicClass(*B);
   }
 
+  // Pointer to this requ

r247726 - [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Sep 15 16:52:42 2015
New Revision: 247726

URL: http://llvm.org/viewvc/llvm-project?rev=247726&view=rev
Log:
[CMake] Add cache scripts for Apple-style clang builds.

Summary:
These CMake cache scripts are my first pass at replicating Apple's packaging 
logic from autoconf. They can be used on any Darwin machine to approximate an 
Apple Clang build.

The included README file includes documentation and a sample CMake invocation.

Reviewers: chandlerc, echristo

Subscribers: echristo, cfe-commits

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

Added:
cfe/trunk/cmake/caches/
cfe/trunk/cmake/caches/Apple-stage1.cmake
cfe/trunk/cmake/caches/Apple-stage2.cmake
cfe/trunk/cmake/caches/README.txt

Added: cfe/trunk/cmake/caches/Apple-stage1.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage1.cmake?rev=247726&view=auto
==
--- cfe/trunk/cmake/caches/Apple-stage1.cmake (added)
+++ cfe/trunk/cmake/caches/Apple-stage1.cmake Tue Sep 15 16:52:42 2015
@@ -0,0 +1,32 @@
+# This file sets up a CMakeCache for Apple-style bootstrap builds. It can be
+# used on any Darwin system to approximate Apple Clang builds.
+
+if($ENV{DT_TOOLCHAIN_DIR})
+  set(CMAKE_INSTALL_PREFIX $ENV{DT_TOOLCHAIN_DIR}/usr/)
+else()
+  set(CMAKE_INSTALL_PREFIX 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.toolchain/usr/)
+endif()
+
+set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
+set(CLANG_VENDOR Apple CACHE STRING "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(PACKAGE_VERSION 7.1.0 CACHE STRING "")
+
+# LIBCXX Settings
+set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "")
+set(LIBCXX_OVERRIDE_DARWIN_INSTALL ON CACHE BOOL "")
+
+#bootstrap
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  -C ${CMAKE_CURRENT_LIST_DIR}/Apple-stage2.cmake
+  CACHE STRING "")

Added: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=247726&view=auto
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (added)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue Sep 15 16:52:42 2015
@@ -0,0 +1,29 @@
+# This file sets up a CMakeCache for Apple-style stage2 bootstrap. It is
+# specified by the stage1 build.
+
+set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") 
+set(CLANG_VENDOR Apple CACHE STRING "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" 
CACHE STRING "")
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(PACKAGE_VERSION 7.1.0 CACHE STRING "")
+
+set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
+
+# setup toolchain
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-dsymutil
+  llvm-cov
+  llvm-dwarfdump
+  llvm-profdata
+  CACHE STRING "")

Added: cfe/trunk/cmake/caches/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/README.txt?rev=247726&view=auto
==
--- cfe/trunk/cmake/caches/README.txt (added)
+++ cfe/trunk/cmake/caches/README.txt Tue Sep 15 16:52:42 2015
@@ -0,0 +1,18 @@
+CMake Caches
+
+
+This directory contains CMake cache scripts that pre-populate the CMakeCache in
+a build directory with commonly used settings.
+
+The first two cache files in the directory are used by Apple to build the clang
+distribution packaged with Xcode. You can use the caches with the following
+CMake invocation:
+
+cmake -G 
+  -C /tools/clang/cmake/caches/Apple-stage1.cmake
+  -DCMAKE_BUILD_TYPE=Release
+  [-DCMAKE_INSTALL_PREFIX=]
+  
+
+Building the `bootstrap` target from this generation will build clang, and
+`bootstrap-install` will install it.


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


Re: [PATCH] D12817: [CMake] Add cache scripts for Apple-style clang builds.

2015-09-15 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247726: [CMake] Add cache scripts for Apple-style clang 
builds. (authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D12817?vs=34586&id=34842#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12817

Files:
  cfe/trunk/cmake/caches/Apple-stage1.cmake
  cfe/trunk/cmake/caches/Apple-stage2.cmake
  cfe/trunk/cmake/caches/README.txt

Index: cfe/trunk/cmake/caches/Apple-stage2.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage2.cmake
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake
@@ -0,0 +1,29 @@
+# This file sets up a CMakeCache for Apple-style stage2 bootstrap. It is
+# specified by the stage1 build.
+
+set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") 
+set(CLANG_VENDOR Apple CACHE STRING "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" 
CACHE STRING "")
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(PACKAGE_VERSION 7.1.0 CACHE STRING "")
+
+set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
+
+# setup toolchain
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-dsymutil
+  llvm-cov
+  llvm-dwarfdump
+  llvm-profdata
+  CACHE STRING "")
Index: cfe/trunk/cmake/caches/Apple-stage1.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage1.cmake
+++ cfe/trunk/cmake/caches/Apple-stage1.cmake
@@ -0,0 +1,32 @@
+# This file sets up a CMakeCache for Apple-style bootstrap builds. It can be
+# used on any Darwin system to approximate Apple Clang builds.
+
+if($ENV{DT_TOOLCHAIN_DIR})
+  set(CMAKE_INSTALL_PREFIX $ENV{DT_TOOLCHAIN_DIR}/usr/)
+else()
+  set(CMAKE_INSTALL_PREFIX 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.toolchain/usr/)
+endif()
+
+set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
+set(CLANG_VENDOR Apple CACHE STRING "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(PACKAGE_VERSION 7.1.0 CACHE STRING "")
+
+# LIBCXX Settings
+set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(LIBCXX_INSTALL_HEADERS ON CACHE BOOL "")
+set(LIBCXX_OVERRIDE_DARWIN_INSTALL ON CACHE BOOL "")
+
+#bootstrap
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  -C ${CMAKE_CURRENT_LIST_DIR}/Apple-stage2.cmake
+  CACHE STRING "")
Index: cfe/trunk/cmake/caches/README.txt
===
--- cfe/trunk/cmake/caches/README.txt
+++ cfe/trunk/cmake/caches/README.txt
@@ -0,0 +1,18 @@
+CMake Caches
+
+
+This directory contains CMake cache scripts that pre-populate the CMakeCache in
+a build directory with commonly used settings.
+
+The first two cache files in the directory are used by Apple to build the clang
+distribution packaged with Xcode. You can use the caches with the following
+CMake invocation:
+
+cmake -G 
+  -C /tools/clang/cmake/caches/Apple-stage1.cmake
+  -DCMAKE_BUILD_TYPE=Release
+  [-DCMAKE_INSTALL_PREFIX=]
+  
+
+Building the `bootstrap` target from this generation will build clang, and
+`bootstrap-install` will install it.


Index: cfe/trunk/cmake/caches/Apple-stage2.cmake
===
--- cfe/trunk/cmake/caches/Apple-stage2.cmake
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake
@@ -0,0 +1,29 @@
+# This file sets up a CMakeCache for Apple-style stage2 bootstrap. It is
+# specified by the stage1 build.
+
+set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") 
+set(CLANG_VENDOR Apple CACHE STRING "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(PACKAGE_

Re: [PATCH] D12889: [Static Analyzer] Generics Checker: When an ObjC method returns a specialized object, track it properly.

2015-09-15 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:672
@@ +671,3 @@
+
+  if (IsDeclaredAsInstanceType)
+return SelfType;

If you swap this 'if' with the 'if' above, you do not need to check for 
IsDeclaredAsInstanceType twice.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:675
@@ +674,3 @@
+
+  QualType ResultType = Method->getReturnType().substObjCTypeArgs(
+  C, TypeArgs, ObjCSubstitutionContext::Result);

Could you use StaticResultType here?


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:795
@@ -817,1 +794,3 @@
+  // Checking that the return type is used correctly is done in pre-call to get
+  // cleaner diagnostic paths.
   checkReturnType(MessageExpr, *TrackedType, Sym, Method, *TypeArgs,

The path is longer if the call is inlined, correct? (Not much difference 
otherwise..)


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:803
@@ +802,3 @@
+/// initialized with by invoking the 'class' method on a class.
+/// This method is also used to infer the type information for the return
+/// types.

It looks like it's only inferring the type information of the specializations 
and not for non-generic types..


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:865
@@ +864,3 @@
+  // When the result is a specialized type, track it for the result symbol.
+  State = State->set(RetSym, ResultPtrType);
+  C.addTransition(State);

Please, rename the map to make it more explicit that it tracks the most 
specialized type. (I think I've mentioned it before in another review..)


http://reviews.llvm.org/D12889



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


r247733 - invariant.group-for-vptrs test fix

2015-09-15 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Tue Sep 15 18:04:47 2015
New Revision: 247733

URL: http://llvm.org/viewvc/llvm-project?rev=247733&view=rev
Log:
invariant.group-for-vptrs test fix

Modified:
cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp

Modified: cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp?rev=247733&r1=247732&r2=247733&view=diff
==
--- cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/invariant.group-for-vptrs.cpp Tue Sep 15 18:04:47 
2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s 
-fstrict-vtable-pointers -O1 -o - -disable-llvm-optzns | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s 
-fstrict-vtable-pointers -O1 -o - -disable-llvm-optzns | FileCheck %s
 
 struct A {
   virtual void foo();


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


r247739 - [Static Analyzer] Added an XFAIL test for inlining when the type inference involves generic types.

2015-09-15 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Sep 15 18:14:01 2015
New Revision: 247739

URL: http://llvm.org/viewvc/llvm-project?rev=247739&view=rev
Log:
[Static Analyzer] Added an XFAIL test for inlining when the type inference 
involves generic types.

Added:
cfe/trunk/test/Analysis/DynamicTypePropagation.m

Added: cfe/trunk/test/Analysis/DynamicTypePropagation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DynamicTypePropagation.m?rev=247739&view=auto
==
--- cfe/trunk/test/Analysis/DynamicTypePropagation.m (added)
+++ cfe/trunk/test/Analysis/DynamicTypePropagation.m Tue Sep 15 18:14:01 2015
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify %s
+// XFAIL: *
+
+#if !__has_feature(objc_generics)
+#  error Compiler does not support Objective-C generics?
+#endif
+
+#define nil 0
+typedef unsigned long NSUInteger;
+typedef int BOOL;
+
+@protocol NSCopying
+@end
+
+__attribute__((objc_root_class))
+@interface NSObject
+- (void) myFunction:(int*)p myParam:(int) n;
+@end
+
+@interface MyType : NSObject 
+- (void) myFunction:(int*)p myParam:(int) n;
+@end
+
+@interface NSArray : NSObject
+- (BOOL)contains:(ObjectType)obj;
+- (ObjectType)getObjAtIndex:(NSUInteger)idx;
+- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
+@property(readonly) ObjectType firstObject;
+@end
+
+@implementation NSObject
+- (void) myFunction:(int*)p myParam:(int) n {
+  (void)*p;// no warning
+}
+@end
+
+@implementation MyType
+- (void) myFunction:(int*)p myParam:(int) n {
+  int i = 5/n;  // expected-warning {{}}
+  (void)i;
+}
+@end
+
+void testReturnType(NSArray *arr) {
+  NSArray *erased = arr;
+  NSObject *element = [erased firstObject];
+  // TODO: myFunction currently dispatches to NSObject. Make it dispatch to
+  // MyType instead!
+  [element myFunction:0 myParam:0 ];
+}
+
+void testArgument(NSArray *arr, id element) {
+  NSArray *erased = arr;
+  [erased contains: element];
+  // TODO: myFunction currently is not dispatched to MyType. Make it dispatch 
to
+  // MyType!
+  [element myFunction:0 myParam:0 ];
+}


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


r247740 - Don't crash when passing &@selector to a _Nonnull parameter. Fixes PR24774.

2015-09-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep 15 18:17:17 2015
New Revision: 247740

URL: http://llvm.org/viewvc/llvm-project?rev=247740&view=rev
Log:
Don't crash when passing &@selector to a _Nonnull parameter. Fixes PR24774.

The root cause here is that ObjCSelectorExpr is an rvalue, yet it can have its
address taken.  That's kind of awkward, but fixing this is awkward in other
ways, see https://llvm.org/bugs/show_bug.cgi?id=24774#c16 .  For now, just
fix the crash.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaObjCXX/sel-address.mm

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=247740&r1=247739&r2=247740&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Sep 15 18:17:17 2015
@@ -4557,12 +4557,13 @@ public:
 } // end anonymous namespace
 
 /// Evaluate an expression as an lvalue. This can be legitimately called on
-/// expressions which are not glvalues, in two cases:
+/// expressions which are not glvalues, in three cases:
 ///  * function designators in C, and
 ///  * "extern void" objects
+///  * @selector() expressions in Objective-C
 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info) {
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
- E->getType()->isVoidType());
+ E->getType()->isVoidType() || isa(E));
   return LValueExprEvaluator(Info, Result).Visit(E);
 }
 

Modified: cfe/trunk/test/SemaObjCXX/sel-address.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/sel-address.mm?rev=247740&r1=247739&r2=247740&view=diff
==
--- cfe/trunk/test/SemaObjCXX/sel-address.mm (original)
+++ cfe/trunk/test/SemaObjCXX/sel-address.mm Tue Sep 15 18:17:17 2015
@@ -2,7 +2,8 @@
 // pr7390
 
 void f(const SEL& v2) {}
-void g() {
+void g(SEL* _Nonnull);
+void h() {
   f(@selector(dealloc));
 
   SEL s = @selector(dealloc);
@@ -11,4 +12,8 @@ void g() {
   @selector(dealloc) = s;  // expected-error {{expression is not assignable}}
 
   SEL* ps2 = &@selector(dealloc);
+
+  // Shouldn't crash.
+  g(&@selector(foo));
 }
+


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


r247742 - [MS ABI] Add a C++ test for -fnew-ms-eh

2015-09-15 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Sep 15 18:30:42 2015
New Revision: 247742

URL: http://llvm.org/viewvc/llvm-project?rev=247742&view=rev
Log:
[MS ABI] Add a C++ test for -fnew-ms-eh

Added:
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp

Added: cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp?rev=247742&view=auto
==
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Tue Sep 15 18:30:42 2015
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -fexceptions 
-fcxx-exceptions -fnew-ms-eh -emit-llvm -o - -std=c++11 | FileCheck %s
+
+int f(int);
+
+void test_catch() {
+  try {
+f(1);
+  } catch (int) {
+f(2);
+  } catch (double) {
+f(3);
+  }
+}
+
+// CHECK-LABEL: define void @"\01?test_catch@@YAXXZ"(
+// CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 1)
+// CHECK: to label %[[NORMAL:.*]] unwind label %[[CATCH_INT:.*]]
+
+// CHECK: [[CATCH_INT]]:
+// CHECK:   %[[CATCHPAD_INT:.*]] = catchpad [{{.*}} @llvm.eh.handlertype.H.0, 
i8* null]
+// CHECK: to label %[[CATCH_INT_HANDLER:.*]] unwind label 
%[[CATCH_DOUBLE:.*]]
+
+// CHECK: [[CATCH_INT_HANDLER]]:
+// CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 2)
+// CHECK:   to label %[[CATCH_INT_DONE:.*]] unwind label 
%[[CATCHENDPAD:.*]]
+
+// CHECK: [[CATCH_INT_DONE]]:
+// CHECK:   catchret %[[CATCHPAD_INT]] to label %[[LEAVE_INT_CATCH:.*]]
+
+// CHECK: [[LEAVE_INT_CATCH]]:
+// CHECK:   br label %[[LEAVE_FUNC:.*]]
+
+// CHECK: [[LEAVE_FUNC]]:
+// CHECK:   ret void
+
+// CHECK: [[CATCH_DOUBLE]]:
+// CHECK:   %[[CATCHPAD_DOUBLE:.*]] = catchpad [{{.*}} 
@llvm.eh.handlertype.N.0, i8* null]
+// CHECK:   to label %[[CATCH_DOUBLE_HANDLER:.*]] unwind label 
%[[CATCHENDPAD]]
+
+// CHECK: [[CATCH_DOUBLE_HANDLER]]:
+// CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 3)
+// CHECK:   to label %[[CATCH_DOUBLE_DONE:.*]] unwind label 
%[[CATCHENDPAD]]
+
+// CHECK: [[CATCH_DOUBLE_DONE]]:
+// CHECK:   catchret %[[CATCHPAD_DOUBLE]] to label %[[LEAVE_DOUBLE_CATCH:.*]]
+
+// CHECK: [[LEAVE_DOUBLE_CATCH]]:
+// CHECK:   br label %[[LEAVE_FUNC]]
+
+// CHECK: [[CATCHENDPAD]]:
+// CHECK:   catchendpad unwind to caller
+
+// CHECK: [[NORMAL]]:
+// CHECK:   br label %[[LEAVE_FUNC]]
+
+struct Cleanup {
+  ~Cleanup() { f(-1); }
+};
+
+void test_cleanup() {
+  Cleanup C;
+  f(1);
+}
+
+// CHECK-LABEL: define {{.*}} @"\01?test_cleanup@@YAXXZ"(
+// CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 1)
+// CHECK:   to label %[[LEAVE_FUNC:.*]] unwind label %[[CLEANUP:.*]]
+
+// CHECK: [[LEAVE_FUNC]]:
+// CHECK:   call x86_thiscallcc void @"\01??_DCleanup@@QAE@XZ"(
+// CHECK:   ret void
+
+// CHECK: [[CLEANUP]]:
+// CHECK:   %[[CLEANUPPAD:.*]] = cleanuppad []
+// CHECK:   call x86_thiscallcc void @"\01??_DCleanup@@QAE@XZ"(
+// CHECK:   cleanupret %[[CLEANUPPAD]] unwind to caller
+
+
+// CHECK-LABEL: define {{.*}} void @"\01??1Cleanup@@QAE@XZ"(
+// CHECK: entry:
+// CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 -1)
+// CHECK:   to label %[[LEAVE_FUNC:.*]] unwind label %[[TERMINATE:.*]]
+
+// CHECK: [[LEAVE_FUNC]]:
+// CHECK:   ret void
+
+// CHECK: [[TERMINATE]]:
+// CHECK:   terminatepad [void ()* @"\01?terminate@@YAXXZ"] unwind to caller
+


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


r247743 - Try to appease the build bots

2015-09-15 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Sep 15 18:34:59 2015
New Revision: 247743

URL: http://llvm.org/viewvc/llvm-project?rev=247743&view=rev
Log:
Try to appease the build bots

Modified:
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp

Modified: cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp?rev=247743&r1=247742&r2=247743&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Tue Sep 15 18:34:59 2015
@@ -16,41 +16,41 @@ void test_catch() {
 // CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 1)
 // CHECK: to label %[[NORMAL:.*]] unwind label %[[CATCH_INT:.*]]
 
-// CHECK: [[CATCH_INT]]:
+// CHECK: [[CATCH_INT]]
 // CHECK:   %[[CATCHPAD_INT:.*]] = catchpad [{{.*}} @llvm.eh.handlertype.H.0, 
i8* null]
 // CHECK: to label %[[CATCH_INT_HANDLER:.*]] unwind label 
%[[CATCH_DOUBLE:.*]]
 
-// CHECK: [[CATCH_INT_HANDLER]]:
+// CHECK: [[CATCH_INT_HANDLER]]
 // CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 2)
 // CHECK:   to label %[[CATCH_INT_DONE:.*]] unwind label 
%[[CATCHENDPAD:.*]]
 
-// CHECK: [[CATCH_INT_DONE]]:
+// CHECK: [[CATCH_INT_DONE]]
 // CHECK:   catchret %[[CATCHPAD_INT]] to label %[[LEAVE_INT_CATCH:.*]]
 
-// CHECK: [[LEAVE_INT_CATCH]]:
+// CHECK: [[LEAVE_INT_CATCH]]
 // CHECK:   br label %[[LEAVE_FUNC:.*]]
 
-// CHECK: [[LEAVE_FUNC]]:
+// CHECK: [[LEAVE_FUNC]]
 // CHECK:   ret void
 
-// CHECK: [[CATCH_DOUBLE]]:
+// CHECK: [[CATCH_DOUBLE]]
 // CHECK:   %[[CATCHPAD_DOUBLE:.*]] = catchpad [{{.*}} 
@llvm.eh.handlertype.N.0, i8* null]
 // CHECK:   to label %[[CATCH_DOUBLE_HANDLER:.*]] unwind label 
%[[CATCHENDPAD]]
 
-// CHECK: [[CATCH_DOUBLE_HANDLER]]:
+// CHECK: [[CATCH_DOUBLE_HANDLER]]
 // CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 3)
 // CHECK:   to label %[[CATCH_DOUBLE_DONE:.*]] unwind label 
%[[CATCHENDPAD]]
 
-// CHECK: [[CATCH_DOUBLE_DONE]]:
+// CHECK: [[CATCH_DOUBLE_DONE]]
 // CHECK:   catchret %[[CATCHPAD_DOUBLE]] to label %[[LEAVE_DOUBLE_CATCH:.*]]
 
-// CHECK: [[LEAVE_DOUBLE_CATCH]]:
+// CHECK: [[LEAVE_DOUBLE_CATCH]]
 // CHECK:   br label %[[LEAVE_FUNC]]
 
-// CHECK: [[CATCHENDPAD]]:
+// CHECK: [[CATCHENDPAD]]
 // CHECK:   catchendpad unwind to caller
 
-// CHECK: [[NORMAL]]:
+// CHECK: [[NORMAL]]
 // CHECK:   br label %[[LEAVE_FUNC]]
 
 struct Cleanup {
@@ -66,11 +66,11 @@ void test_cleanup() {
 // CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 1)
 // CHECK:   to label %[[LEAVE_FUNC:.*]] unwind label %[[CLEANUP:.*]]
 
-// CHECK: [[LEAVE_FUNC]]:
+// CHECK: [[LEAVE_FUNC]]
 // CHECK:   call x86_thiscallcc void @"\01??_DCleanup@@QAE@XZ"(
 // CHECK:   ret void
 
-// CHECK: [[CLEANUP]]:
+// CHECK: [[CLEANUP]]
 // CHECK:   %[[CLEANUPPAD:.*]] = cleanuppad []
 // CHECK:   call x86_thiscallcc void @"\01??_DCleanup@@QAE@XZ"(
 // CHECK:   cleanupret %[[CLEANUPPAD]] unwind to caller
@@ -81,9 +81,9 @@ void test_cleanup() {
 // CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 -1)
 // CHECK:   to label %[[LEAVE_FUNC:.*]] unwind label %[[TERMINATE:.*]]
 
-// CHECK: [[LEAVE_FUNC]]:
+// CHECK: [[LEAVE_FUNC]]
 // CHECK:   ret void
 
-// CHECK: [[TERMINATE]]:
+// CHECK: [[TERMINATE]]
 // CHECK:   terminatepad [void ()* @"\01?terminate@@YAXXZ"] unwind to caller
 


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


Re: [PATCH] D12712: Implementation and testing for poisoning vtable ptr in dtor.

2015-09-15 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 34851.
nmusgrave added a comment.

- Remove commented-out block.


http://reviews.llvm.org/D12712

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  test/CodeGenCXX/sanitize-dtor-vtable.cpp

Index: test/CodeGenCXX/sanitize-dtor-vtable.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-vtable.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+class A {
+ public:
+  int x;
+  A() {}
+  virtual ~A() {}
+};
+A a;
+
+class B : virtual public A {
+ public:
+  int y;
+  B() {}
+  ~B() {}
+};
+B b;
+
+// CHECK-LABEL: define {{.*}}AD1Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}AD2Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// After invoking base dtor and dtor for virtual base, poison vtable ptr.
+// CHECK-LABEL: define {{.*}}BD1Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}BD2Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void {{.*}}AD2Ev
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Since no virtual bases, poison vtable ptr here.
+// CHECK-LABEL: define {{.*}}AD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// Poison members
+// CHECK-LABEL: define {{.*}}BD2Ev
+// CHECK: call void @__sanitizer_dtor_callback
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
Index: test/CodeGenCXX/sanitize-dtor-derived-class.cpp
===
--- test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 
-// Only the last dtor of a class invokes the sanitizing callback
-// Sanitizing callback emited prior to base class dtor invocations
+// Base dtor poisons members
+// Complete dtor poisons vtable ptr after destroying members and
+// virtual bases
 
 class Base {
  public:
@@ -28,6 +29,7 @@
 
 Derived d;
 
+// Invoke base destructor. No vtable pointer to poison.
 // CHECK-LABEL: define {{.*}}DerivedD1Ev
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}DerivedD2Ev
@@ -40,6 +42,7 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Invokes base destructor, and poison vtable pointer.
 // CHECK-LABEL: define {{.*}}BaseD1Ev
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}BaseD2Ev
@@ -52,14 +55,17 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison members and vtable ptr.
 // CHECK-LABEL: define {{.*}}BaseD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison members and destroy non-virtual base.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: call void {{.*}}BaseD2Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
 // CHECK: ret void
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1648,11 +1648,27 @@
 }
   };
 
-  class SanitizeDtor final : public EHScopeStack::Cleanup {
+ static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
+ CharUnits::QuantityType PoisonSize) {
+   // Pass in void pointer and size of region as arguments to runtime
+   // function
+   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+   llvm::FunctionType *FnType =
+   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+   llvm::Value *Fn =
+   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+   CGF.EmitNounwindRuntimeCall(Fn, Args);
+ }
+
+  class SanitizeDtorM

r247750 - clang-format: In Java, `assert` is followed by an expression.

2015-09-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep 15 18:48:17 2015
New Revision: 247750

URL: http://llvm.org/viewvc/llvm-project?rev=247750&view=rev
Log:
clang-format: In Java, `assert` is followed by an expression.

Before: assert a&& b;
Now:assert a && b;

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=247750&r1=247749&r2=247750&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Tue Sep 15 18:48:17 2015
@@ -539,6 +539,7 @@ struct AdditionalKeywords {
 kw_var = &IdentTable.get("var");
 
 kw_abstract = &IdentTable.get("abstract");
+kw_assert = &IdentTable.get("assert");
 kw_extends = &IdentTable.get("extends");
 kw_implements = &IdentTable.get("implements");
 kw_instanceof = &IdentTable.get("instanceof");
@@ -580,6 +581,7 @@ struct AdditionalKeywords {
 
   // Java keywords.
   IdentifierInfo *kw_abstract;
+  IdentifierInfo *kw_assert;
   IdentifierInfo *kw_extends;
   IdentifierInfo *kw_implements;
   IdentifierInfo *kw_instanceof;

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=247750&r1=247749&r2=247750&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep 15 18:48:17 2015
@@ -860,7 +860,7 @@ private:
   Contexts.back().IsExpression = true;
 } else if (Current.is(TT_TrailingReturnArrow)) {
   Contexts.back().IsExpression = false;
-} else if (Current.is(TT_LambdaArrow)) {
+} else if (Current.is(TT_LambdaArrow) || Current.is(Keywords.kw_assert)) {
   Contexts.back().IsExpression = Style.Language == FormatStyle::LK_Java;
 } else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
!Line.InPPDirective &&

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=247750&r1=247749&r2=247750&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Sep 15 18:48:17 2015
@@ -393,6 +393,11 @@ TEST_F(FormatTestJava, SynchronizedKeywo
"}");
 }
 
+TEST_F(FormatTestJava, AssertKeyword) {
+  verifyFormat("assert a && b;");
+}
+
+
 TEST_F(FormatTestJava, PackageDeclarations) {
   verifyFormat("package some.really.loong.package;",
getStyleWithColumns(50));


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


r247752 - Remove accidental superfluous newline added in r247750.

2015-09-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep 15 18:51:08 2015
New Revision: 247752

URL: http://llvm.org/viewvc/llvm-project?rev=247752&view=rev
Log:
Remove accidental superfluous newline added in r247750.

Modified:
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=247752&r1=247751&r2=247752&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Sep 15 18:51:08 2015
@@ -397,7 +397,6 @@ TEST_F(FormatTestJava, AssertKeyword) {
   verifyFormat("assert a && b;");
 }
 
-
 TEST_F(FormatTestJava, PackageDeclarations) {
   verifyFormat("package some.really.loong.package;",
getStyleWithColumns(50));


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


Re: [PATCH] D12712: Implementation and testing for poisoning vtable ptr in dtor.

2015-09-15 Thread Evgeniy Stepanov via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D12712



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


[PATCH] D12891: [analyzer] SATestBuild.py: Move additional checkers logic so SATestAdd.py can use it as well.

2015-09-15 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: xazax.hun, zaks.anna.
dcoughlin added a subscriber: cfe-commits.

Move the logic looking for additional checkers in the SA_ADDITIONAL_CHECKERS 
environmental variable from SATestBuild's main() to runScanBuild(). This allows 
SATestAdd.py to use the variable as well. Without it, we won't include 
additional checkers when building reference results for the build bot.

http://reviews.llvm.org/D12891

Files:
  utils/analyzer/SATestBuild.py

Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -210,9 +210,14 @@
 if not os.path.exists(BuildScriptPath):
 print "Error: build script is not defined: %s" % BuildScriptPath
 sys.exit(-1)
+
+AllCheckers = Checkers
+if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
+AllCheckers = AllCheckers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
+
 SBOptions = "--use-analyzer " + Clang + " "
 SBOptions += "-plist-html -o " + SBOutputDir + " "
-SBOptions += "-enable-checker " + Checkers + " "
+SBOptions += "-enable-checker " + AllCheckers + " "
 SBOptions += "--keep-empty "
 # Always use ccc-analyze to ensure that we can locate the failures
 # directory.
@@ -614,7 +619,4 @@
 IsReference = True
 UpdateSVN = True
 
-if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
-Checkers = Checkers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
-
 testAll(IsReference, UpdateSVN, Strictness)


Index: utils/analyzer/SATestBuild.py
===
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -210,9 +210,14 @@
 if not os.path.exists(BuildScriptPath):
 print "Error: build script is not defined: %s" % BuildScriptPath
 sys.exit(-1)
+
+AllCheckers = Checkers
+if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
+AllCheckers = AllCheckers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
+
 SBOptions = "--use-analyzer " + Clang + " "
 SBOptions += "-plist-html -o " + SBOutputDir + " "
-SBOptions += "-enable-checker " + Checkers + " "
+SBOptions += "-enable-checker " + AllCheckers + " "
 SBOptions += "--keep-empty "
 # Always use ccc-analyze to ensure that we can locate the failures
 # directory.
@@ -614,7 +619,4 @@
 IsReference = True
 UpdateSVN = True
 
-if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
-Checkers = Checkers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
-
 testAll(IsReference, UpdateSVN, Strictness)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12892: [CUDA] Minor cuda-related driver fixes.

2015-09-15 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: echristo.
tra added a subscriber: cfe-commits.

* Only the last of the --cuda-host-only/--cuda-device-only options has effect.
* Added test cases.
* Fixed printing of empty action lists for -ccc-print-phases


http://reviews.llvm.org/D12892

Files:
  lib/Driver/Driver.cpp
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -21,22 +21,40 @@
 // Then link things.
 // RUN:   -check-prefix CUDA-L %s
 
-// Verify that -cuda-no-device disables device-side compilation and linking
+// Verify that --cuda-host-only disables device-side compilation and linking
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only %s 2>&1 \
 // Make sure we didn't run device-side compilation.
 // RUN:   | FileCheck -check-prefix CUDA-ND \
 // Then compile host side and make sure we don't attempt to incorporate GPU code.
 // RUN:-check-prefix CUDA-H -check-prefix CUDA-H-NI \
 // Linking is allowed to happen, even if we're missing GPU code.
 // RUN:-check-prefix CUDA-L %s
 
-// Verify that -cuda-no-host disables host-side compilation and linking
+// Same test as above, but with preceeding --cuda-device-only to make
+// sure only last option has effect.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \
+// Make sure we didn't run device-side compilation.
+// RUN:   | FileCheck -check-prefix CUDA-ND \
+// Then compile host side and make sure we don't attempt to incorporate GPU code.
+// RUN:-check-prefix CUDA-H -check-prefix CUDA-H-NI \
+// Linking is allowed to happen, even if we're missing GPU code.
+// RUN:-check-prefix CUDA-L %s
+
+// Verify that --cuda-device-only disables host-side compilation and linking
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
 // Compile device-side to PTX assembly
 // RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
 // Make sure there are no host cmpilation or linking.
 // RUN:   -check-prefix CUDA-NH -check-prefix CUDA-NL %s
 
+// Same test as above, but with preceeding --cuda-host-only to make
+// sure only last option has effect.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \
+// Compile device-side to PTX assembly
+// RUN:   | FileCheck -check-prefix CUDA-D1 -check-prefix CUDA-D1NS\
+// Make sure there are no host cmpilation or linking.
+// RUN:   -check-prefix CUDA-NH -check-prefix CUDA-NL %s
+
 // Verify that with -S we compile host and device sides to assembly
 // and incorporate device code on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu -S -c %s 2>&1 \
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -919,12 +919,15 @@
 } else
   AL = &A->getInputs();
 
-const char *Prefix = "{";
-for (Action *PreRequisite : *AL) {
-  os << Prefix << PrintActions1(C, PreRequisite, Ids);
-  Prefix = ", ";
-}
-os << "}";
+if (AL->size()) {
+  const char *Prefix = "{";
+  for (Action *PreRequisite : *AL) {
+os << Prefix << PrintActions1(C, PreRequisite, Ids);
+Prefix = ", ";
+  }
+  os << "}";
+} else
+  os << "{}";
   }
 
   unsigned Id = Ids.size();
@@ -1244,6 +1247,13 @@
 buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args,
  const Arg *InputArg, std::unique_ptr HostAction,
  ActionList &Actions) {
+  Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
+   options::OPT_cuda_device_only);
+  // Host-only compilation case.
+  if (PartialCompilationArg &&
+  PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
+return std::unique_ptr(
+new CudaHostAction(std::move(HostAction), {}));
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
@@ -1289,7 +1299,7 @@
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
-  bool DeviceOnlyCompilation = Args.hasArg(options::OPT_cuda_device_only);
+  bool DeviceOnlyCompilation = PartialCompilationArg != nullptr;
   if (PartialCompilation || DeviceOnlyCompilation) {
 // In case of partial or device-only compilation results of device actions
 // are not consumed by the host action device actions have to be added to
@@ -1422,11 +1432,8 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase;
-bool InjectCuda = (InputType == types::TY_CUDA &&
-   !Args.hasArg(options::OPT_cuda_host_only));
-CudaInjectionPhase = FinalPhase;
-for (auto &Phase : PL)
+phases::ID CudaInjectionPhase = FinalPhase;
+for (const auto &Phase :

Re: [PATCH] D12892: [CUDA] Minor cuda-related driver fixes.

2015-09-15 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Yuck. No better ideas off the top of my head other than diagnosing and erroring 
though.

(Is that a possibility? :)

-eric


http://reviews.llvm.org/D12892



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


[PATCH] D12893: Augmented CudaHostAction to carry device-side triple.

2015-09-15 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: echristo.
tra added a subscriber: cfe-commits.

Paves the way for the upcoming patch where host-side compilation will need to 
know device-side triple.

http://reviews.llvm.org/D12893

Files:
  include/clang/Driver/Action.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1247,13 +1247,18 @@
 buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args,
  const Arg *InputArg, std::unique_ptr HostAction,
  ActionList &Actions) {
+  // Figure out which NVPTX triple to use for device-side compilation based on
+  // whether host is 64-bit.
+  const char *DeviceTriple = TC.getTriple().isArch64Bit()
+ ? "nvptx64-nvidia-cuda"
+ : "nvptx-nvidia-cuda";
   Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
 return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+new CudaHostAction(std::move(HostAction), {}, DeviceTriple));
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
@@ -1291,12 +1296,6 @@
 }
   }
 
-  // Figure out which NVPTX triple to use for device-side compilation based on
-  // whether host is 64-bit.
-  const char *DeviceTriple = TC.getTriple().isArch64Bit()
- ? "nvptx64-nvidia-cuda"
- : "nvptx-nvidia-cuda";
-
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
   bool DeviceOnlyCompilation = PartialCompilationArg != nullptr;
@@ -1332,7 +1331,7 @@
   // Return a new host action that incorporates original host action and all
   // device actions.
   return std::unique_ptr(
-  new CudaHostAction(std::move(HostAction), DeviceActions));
+  new CudaHostAction(std::move(HostAction), DeviceActions, DeviceTriple));
 }
 
 void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -66,8 +66,10 @@
 void CudaHostAction::anchor() {}
 
 CudaHostAction::CudaHostAction(std::unique_ptr Input,
-   const ActionList &DeviceActions)
-: Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions) {}
+   const ActionList &DeviceActions,
+   const char *DeviceTriple)
+: Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions),
+  DeviceTriple(DeviceTriple) {}
 
 CudaHostAction::~CudaHostAction() {
   for (auto &DA : DeviceActions)
Index: include/clang/Driver/Action.h
===
--- include/clang/Driver/Action.h
+++ include/clang/Driver/Action.h
@@ -160,14 +160,16 @@
 class CudaHostAction : public Action {
   virtual void anchor();
   ActionList DeviceActions;
+  const char *DeviceTriple;
 
 public:
-  CudaHostAction(std::unique_ptr Input,
- const ActionList &DeviceActions);
+  CudaHostAction(std::unique_ptr Input, const ActionList 
&DeviceActions,
+ const char *DeviceTriple);
   ~CudaHostAction() override;
 
   ActionList &getDeviceActions() { return DeviceActions; }
   const ActionList &getDeviceActions() const { return DeviceActions; }
+  const char *getDeviceTriple() const { return DeviceTriple; }
 
   static bool classof(const Action *A) { return A->getKind() == CudaHostClass; 
}
 };


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1247,13 +1247,18 @@
 buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args,
  const Arg *InputArg, std::unique_ptr HostAction,
  ActionList &Actions) {
+  // Figure out which NVPTX triple to use for device-side compilation based on
+  // whether host is 64-bit.
+  const char *DeviceTriple = TC.getTriple().isArch64Bit()
+ ? "nvptx64-nvidia-cuda"
+ : "nvptx-nvidia-cuda";
   Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
 return std::unique_ptr(
-new CudaHostAction(std::mov

Re: [PATCH] D12893: Augmented CudaHostAction to carry device-side triple.

2015-09-15 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Commit message could use some more elaborating on why you'll need to know this 
information. Just a bit as the main commit will have a lot of that information.

Thanks!

-eric


http://reviews.llvm.org/D12893



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


Re: [PATCH] D12892: [CUDA] Minor cuda-related driver fixes.

2015-09-15 Thread Artem Belevich via cfe-commits
tra added a comment.

In http://reviews.llvm.org/D12892#246699, @echristo wrote:

> Yuck. No better ideas off the top of my head other than diagnosing and 
> erroring though.
>
> (Is that a possibility? :)


I need to be able to override preceding options, so no error is intentional.


http://reviews.llvm.org/D12892



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


Re: [PATCH] D12892: [CUDA] Minor cuda-related driver fixes.

2015-09-15 Thread Eric Christopher via cfe-commits
echristo added a comment.

Sure. Seems reasonable.

Thanks!

-eric


http://reviews.llvm.org/D12892



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


Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.

2015-09-15 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Oops, forgot to hit "Submit" yesterday. Sorry for the delay.



Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:28
@@ +27,3 @@
+
+AST_MATCHER(QualType, isExpensiveToCopy) {
+  // We can't reason about dependent types. Ignore them.

These helper functions can (and will) be useful for other checks as well. Let's 
move them to `clang-tidy/utils/ `. We can add `TypeTraits.h` for functions like 
`classHasTrivialCopyAndDestroy`, `isExpensiveTypeToCopy`, etc. And a separate 
header (`Matchers.h`, for example) for the matchers that are not suitable for 
the ASTMatchers.h.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:100
@@ -36,1 +99,3 @@
 void MoveConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
+  if (Result.Nodes.getNodeAs("move-init") != nullptr) {
+handleMoveConstructor(Result);

nit: It's common to omit braces around single-line statements in LLVM/Clang 
code.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:120
@@ +119,3 @@
+  }
+  diag(InitArg->getLocStart(), "value parameter can be moved to avoid copy.");
+}

aaron.ballman wrote:
> Perhaps: "argument can be moved to avoid a copy" instead?
nit: Please remove the trailing period.


Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:120
@@ +119,3 @@
+  }
+  diag(InitArg->getLocStart(), "value parameter can be moved to avoid copy.");
+}

alexfh wrote:
> aaron.ballman wrote:
> > Perhaps: "argument can be moved to avoid a copy" instead?
> nit: Please remove the trailing period.
Does anything stop us from suggesting fixes here (inserting "std::move()" 
around the argument and #include , if it's no there yet)?


Comment at: clang-tidy/misc/MoveConstructorInitCheck.h:21
@@ -20,1 +20,3 @@
 /// move constructor.
+/// It also flags constructor arguments that are passed by value, have a
+/// non-deleted move-constructor and are assigned to a class field by copy

I suggest updating the corresponding .rst file instead and adding the URL of 
the documentation in the comment along with a short summary of what the check 
does.

For example:
```
/// Flag missing move opportunities in constructor initializer lists.
///
/// For the user-facing documentation see:
/// 
http://clang.llvm.org/extra/clang-tidy/checks/misc-move-constructor-init.html
```


http://reviews.llvm.org/D12839



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


Re: [PATCH] D12893: Augmented CudaHostAction to carry device-side triple.

2015-09-15 Thread Eric Christopher via cfe-commits
echristo added a comment.

Sounds good. Thanks!


http://reviews.llvm.org/D12893



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


r247761 - clang/test/CodeGenCXX/exceptions-cxx-new.cpp: Don't assume the label "entry:".

2015-09-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Sep 15 19:33:59 2015
New Revision: 247761

URL: http://llvm.org/viewvc/llvm-project?rev=247761&view=rev
Log:
clang/test/CodeGenCXX/exceptions-cxx-new.cpp: Don't assume the label "entry:".

Seems it would be redundant.

Modified:
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp

Modified: cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp?rev=247761&r1=247760&r2=247761&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Tue Sep 15 19:33:59 2015
@@ -77,7 +77,6 @@ void test_cleanup() {
 
 
 // CHECK-LABEL: define {{.*}} void @"\01??1Cleanup@@QAE@XZ"(
-// CHECK: entry:
 // CHECK:   invoke i32 @"\01?f@@YAHH@Z"(i32 -1)
 // CHECK:   to label %[[LEAVE_FUNC:.*]] unwind label %[[TERMINATE:.*]]
 


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


r247762 - Implementation and testing for poisoning vtable

2015-09-15 Thread Naomi Musgrave via cfe-commits
Author: nmusgrave
Date: Tue Sep 15 19:38:22 2015
New Revision: 247762

URL: http://llvm.org/viewvc/llvm-project?rev=247762&view=rev
Log:
Implementation and testing for poisoning vtable
ptr in dtor.

Summary:
After destruction, invocation of virtual functions prevented
by poisoning vtable pointer.

Reviewers: eugenis, kcc

Subscribers: cfe-commits

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

Fixed testing callback emission order to account for vptr.
Poison vtable in either complete or base dtor, depending on
if virtual bases exist. If virtual bases exist, poison in
complete dtor. Otherwise, poison in base.
Remove commented-out block.

Added:
cfe/trunk/test/CodeGenCXX/sanitize-dtor-vtable.cpp
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247762&r1=247761&r2=247762&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Sep 15 19:38:22 2015
@@ -1676,11 +1676,27 @@ namespace {
 }
   };
 
-  class SanitizeDtor final : public EHScopeStack::Cleanup {
+ static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
+ CharUnits::QuantityType PoisonSize) {
+   // Pass in void pointer and size of region as arguments to runtime
+   // function
+   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+   llvm::FunctionType *FnType =
+   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+   llvm::Value *Fn =
+   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+   CGF.EmitNounwindRuntimeCall(Fn, Args);
+ }
+
+  class SanitizeDtorMembers final : public EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;
 
   public:
-SanitizeDtor(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
+SanitizeDtorMembers(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
 
 // Generate function call for handling object poisoning.
 // Disables tail call elimination, to prevent the current stack frame
@@ -1712,11 +1728,11 @@ namespace {
   // Currently on the last field, and it must be poisoned with the
   // current block.
   if (fieldIndex == Layout.getFieldCount() - 1) {
-PoisonBlock(CGF, startIndex, Layout.getFieldCount());
+PoisonMembers(CGF, startIndex, Layout.getFieldCount());
   }
 } else if (startIndex >= 0) {
   // No longer within a block of memory to poison, so poison the block
-  PoisonBlock(CGF, startIndex, fieldIndex);
+  PoisonMembers(CGF, startIndex, fieldIndex);
   // Re-set the start index
   startIndex = -1;
 }
@@ -1729,7 +1745,7 @@ namespace {
 /// start poisoning (inclusive)
 /// \param layoutEndOffset index of the ASTRecordLayout field to
 /// end poisoning (exclusive)
-void PoisonBlock(CodeGenFunction &CGF, unsigned layoutStartOffset,
+void PoisonMembers(CodeGenFunction &CGF, unsigned layoutStartOffset,
  unsigned layoutEndOffset) {
   ASTContext &Context = CGF.getContext();
   const ASTRecordLayout &Layout =
@@ -1760,20 +1776,30 @@ namespace {
   if (PoisonSize == 0)
 return;
 
-  // Pass in void pointer and size of region as arguments to runtime
-  // function
-  llvm::Value *Args[] = {CGF.Builder.CreateBitCast(OffsetPtr, 
CGF.VoidPtrTy),
- llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+  EmitSanitizerDtorCallback(CGF, OffsetPtr, PoisonSize);
+}
+  };
+
+ class SanitizeDtorVTable final : public EHScopeStack::Cleanup {
+const CXXDestructorDecl *Dtor;
 
-  llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+  public:
+SanitizeDtorVTable(const CXXDestructorDecl *Dtor) : Dtor(Dtor) {}
 
-  llvm::FunctionType *FnType =
-  llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
-  llvm::Value *Fn =
-  CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
-  CGF.EmitNounwindRuntimeCall(Fn, Args);
+// Generate function call for handling vtable pointer poisoning.
+void Emit(CodeGenFunction &CGF, Flags flags) override {
+  assert(Dtor->getParent()->isDynamicClass());
+  ASTContext &Context = CGF.getContext();
+  // Poison vtable and vtable ptr if they exist for this class.
+  llvm::Value *VTablePtr = CGF.LoadCXXThis();
+
+  CharUnits::QuantityType PoisonSize =
+  Context.toCharUnitsFromBits(CGF.PointerWidthInBits).getQuantity();
+  // Pass in void pointer and size of region as arguments to runtime
+  // function
+  EmitSanitizerDtorCallback(CGF, VTab

Re: [PATCH] D12889: [Static Analyzer] Generics Checker: When an ObjC method returns a specialized object, track it properly.

2015-09-15 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:675
@@ +674,3 @@
+
+  QualType ResultType = Method->getReturnType().substObjCTypeArgs(
+  C, TypeArgs, ObjCSubstitutionContext::Result);

zaks.anna wrote:
> Could you use StaticResultType here?
In StaticResultType every occurrence of a Type Argument is replaced with id, 
which is not suitable for type checking.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:795
@@ -817,1 +794,3 @@
+  // Checking that the return type is used correctly is done in pre-call to get
+  // cleaner diagnostic paths.
   checkReturnType(MessageExpr, *TrackedType, Sym, Method, *TypeArgs,

zaks.anna wrote:
> The path is longer if the call is inlined, correct? (Not much difference 
> otherwise..)
In fact there is a heuristic that omits the stepping in into the function when 
the diagnostic is generated. I moved this check to the post call callback.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:803
@@ +802,3 @@
+/// initialized with by invoking the 'class' method on a class.
+/// This method is also used to infer the type information for the return
+/// types.

zaks.anna wrote:
> It looks like it's only inferring the type information of the specializations 
> and not for non-generic types..
Added a todo for the missing case.


http://reviews.llvm.org/D12889



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


Re: [PATCH] D12889: [Static Analyzer] Generics Checker: When an ObjC method returns a specialized object, track it properly.

2015-09-15 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:680
@@ +679,3 @@
+return nullptr;
+
+  QualType ResultType = Method->getReturnType().substObjCTypeArgs(

From above:
 QualType StaticResultType = Method->getReturnType();

You could do 
 QualType ResultType = StaticResultType.substObjCTypeArgs(
  C, TypeArgs, ObjCSubstitutionContext::Result);


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:688
@@ -695,2 +687,3 @@
 /// Validate that the return type of a message expression is used correctly.
-void DynamicTypePropagation::checkReturnType(
+/// Returns true in case an error is detected.
+bool DynamicTypePropagation::checkReturnType(

Should the method be renamed to reflect this new behavior?


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:807
@@ +806,3 @@
+/// This method is also used to infer the type information for the return
+/// types.
+// TODO: right now it only tracks generic types. Extend this to track every

and to diagnose..


http://reviews.llvm.org/D12889



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


Re: r247618 - C11 _Bool bitfield diagnostic

2015-09-15 Thread Richard Smith via cfe-commits
On Tue, Sep 15, 2015 at 12:38 PM, Nico Weber  wrote:

> With this patch, we warn on `bool a : 4;`, yet we don't warn on `bool b`
> (which has 8 bits storage, 1 bit value). Warning on `bool b` is silly of
> course, but why is warning on `bool a : 4` useful? That's like 50% more
> storage efficient than `bool b` ;-)
>
> It's possible that this is a good warning for some reason, but I don't
> quite see why yet.
>

Why would we warn on "unsigned n : 57;"? The bit-field is wider than
necessary, and we have no idea what the programmer was trying to do, but it
doesn't seem likely they got that effect. Would you be more convinced if we
amended the diagnostic to provide a fixit suggesting using an anonymous
bit-field to insert padding?

On Mon, Sep 14, 2015 at 11:06 PM, Richard Smith 
> wrote:
>
>> On Mon, Sep 14, 2015 at 7:07 PM, Rachel Craik  wrote:
>>
>>> As of DR262, the C standard clarified that the width of a bit-field can
>>> not exceed that of the specified type, and this change was primarily to
>>> ensure that Clang correctly enforced this part of the standard. Looking at
>>> the C++11 standard again, it states that although the specified width of a
>>> bit-field may exceed the number of bits in the *object representation* 
>>> (which
>>> includes padding bits) of the specified type, the extra bits will not take
>>> any part in the bit-field's *value representation*.
>>>
>>> Taking this into account, it seems that the correct way to validate the
>>> width of a bit-field (ignoring the special case of MS in C mode) would be
>>> to use getIntWidth in C mode, and getTypeSize in C++ mode.
>>>
>>> I would be happy create a patch to make this change tomorrow if people
>>> are in agreement.
>>>
>> David Majnemer has already landed a couple of changes to fix this up, so
>> hopefully that won't be necessary. Thanks for working on this!
>>
>>> Rachel
>>>
>>>
>>> [image: Inactive hide details for Nico Weber ---09/14/2015 09:53:25
>>> PM---On Mon, Sep 14, 2015 at 5:28 PM, Richard Smith >> Weber ---09/14/2015 09:53:25 PM---On Mon, Sep 14, 2015 at 5:28 PM, Richard
>>> Smith  wrote:
>>>
>>> From: Nico Weber 
>>> To: Richard Smith 
>>> Cc: Rachel Craik/Toronto/IBM@IBMCA, cfe-commits <
>>> cfe-commits@lists.llvm.org>
>>> Date: 09/14/2015 09:53 PM
>>> Subject: Re: r247618 - C11 _Bool bitfield diagnostic
>>> Sent by: tha...@google.com
>>> --
>>>
>>>
>>>
>>> On Mon, Sep 14, 2015 at 5:28 PM, Richard Smith <*rich...@metafoo.co.uk*
>>> > wrote:
>>>
>>>On Mon, Sep 14, 2015 at 5:18 PM, Nico Weber via cfe-commits <
>>>*cfe-commits@lists.llvm.org* > wrote:
>>>   This also fires for bool in C++ files, even though the commit
>>>   message saying C11 and _Bool. Given the test changes, I suppose that's
>>>   intentional? This fires a lot on existing code, for example protobuf:
>>>
>>>   ../../third_party/protobuf/src/google/protobuf/extension_set.h:465:10:
>>>   error: width of bit-field 'is_cleared' (4 bits) exceeds the width of 
>>> its
>>>   type; value will be truncated to 1 bit [-Werror,-Wbitfield-width]
>>>   bool is_cleared : 4;
>>>^
>>>   ../../third_party/protobuf/src/google/protobuf/extension_set.h:472:10:
>>>   error: width of bit-field 'is_lazy' (4 bits) exceeds the width of its 
>>> type;
>>>   value will be truncated to 1 bit [-Werror,-Wbitfield-width]
>>>   bool is_lazy : 4;
>>>^
>>>
>>>   Is this expected? Is this a behavior change, or did the
>>>   truncation happen previously and it's now just getting warned on?
>>>
>>>The code previously assumed that MSVC used the C rules here; it
>>>appears that's not true in all cases.
>>>
>>>
>>> This was on a Mac bot…
>>>
>>>
>>>
>>>Can we just remove the " || IsMsStruct
>>>|| Context.getTargetInfo().getCXXABI().isMicrosoft()"? Is there some 
>>> reason
>>>we need to prohibit overwide bitfields for MS bitfield layout, rather 
>>> than
>>>just warning on them? (Does record layout fail somehow?)
>>>On Mon, Sep 14, 2015 at 2:27 PM, Rachel Craik via cfe-commits <
>>>   *cfe-commits@lists.llvm.org* > wrote:
>>>  Author: rcraik
>>>  Date: Mon Sep 14 16:27:36 2015
>>>  New Revision: 247618
>>>
>>>  URL: *http://llvm.org/viewvc/llvm-project?rev=247618&view=rev*
>>>  
>>>  Log:
>>>  C11 _Bool bitfield diagnostic
>>>
>>>  Summary: Implement DR262 (for C). This patch will mainly
>>>  affect bitfields of type _Bool
>>>
>>>  Reviewers: fraggamuffin, rsmith
>>>
>>>  Subscribers: hubert.reinterpretcast, cfe-commits
>>>
>>>  Differential Revision: *http://reviews.llvm.org/D10018*
>>>  
>>>
>>>  Modified:
>>>  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>>>  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> 

r247765 - [modules] Fix a corner case in the macro override rules: properly handle overridden leaf module macros.

2015-09-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep 15 19:55:50 2015
New Revision: 247765

URL: http://llvm.org/viewvc/llvm-project?rev=247765&view=rev
Log:
[modules] Fix a corner case in the macro override rules: properly handle 
overridden leaf module macros.

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Modules/macros.c

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=247765&r1=247764&r2=247765&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Sep 15 19:55:50 2015
@@ -145,8 +145,12 @@ void Preprocessor::updateModuleMacroInfo
 NumHiddenOverrides[O] = -1;
 
   // Collect all macros that are not overridden by a visible macro.
-  llvm::SmallVector Worklist(Leaf->second.begin(),
-Leaf->second.end());
+  llvm::SmallVector Worklist;
+  for (auto *LeafMM : Leaf->second) {
+assert(LeafMM->getNumOverridingMacros() == 0 && "leaf macro overridden");
+if (NumHiddenOverrides.lookup(LeafMM) == 0)
+  Worklist.push_back(LeafMM);
+  }
   while (!Worklist.empty()) {
 auto *MM = Worklist.pop_back_val();
 if (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {

Modified: cfe/trunk/test/Modules/macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=247765&r1=247764&r2=247765&view=diff
==
--- cfe/trunk/test/Modules/macros.c (original)
+++ cfe/trunk/test/Modules/macros.c Tue Sep 15 19:55:50 2015
@@ -18,7 +18,6 @@
 // expected-note@Inputs/macros_right.h:12{{expanding this definition of 
'LEFT_RIGHT_DIFFERENT'}}
 // expected-note@Inputs/macros_right.h:13{{expanding this definition of 
'LEFT_RIGHT_DIFFERENT2'}}
 // expected-note@Inputs/macros_left.h:14{{other definition of 
'LEFT_RIGHT_DIFFERENT'}}
-// expected-note@Inputs/macros_left.h:11{{other definition of 
'LEFT_RIGHT_DIFFERENT2'}}
 
 @import macros;
 
@@ -72,9 +71,14 @@ void f() {
 #  error TOP should not be visible
 #endif
 
+#undef INTEGER
+#define INTEGER int
+
 // Import left module (which also imports top)
 @import macros_left;
 
+INTEGER my_integer = 0;
+
 #ifndef LEFT
 #  error LEFT should be visible
 #endif


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


Re: [PATCH] D12379: Fix the bugs in the mapDiagnosticRanges (Still in progress)

2015-09-15 Thread Richard Trieu via cfe-commits
rtrieu added inline comments.


Comment at: include/clang/Basic/SourceManager.h:333
@@ -332,2 +332,3 @@
 
+
 bool isMacroBodyExpansion() const {

Remove unrelated whitespace change.


Comment at: include/clang/Basic/SourceManager.h:1155-1164
@@ -1153,2 +1154,12 @@
 
+  /// \brief Tests whether the given source location represents a macro
+  /// argument's expansion into the function-like macro definition.
+  ///
+  /// Such source locations only appear inside of the expansion
+  /// locations representing where a particular function-like macro was
+  /// expanded.
+  /// If the return value is true, the RawCode will store the raw encoding
+  /// of the source location of the expanded argument.
+  bool isMacroArgExpansion(SourceLocation Loc, SourceLocation &NewLoc) const;
+
   /// \brief Tests whether the given source location represents the expansion 
of

Merge the two isMacroArgExpansion functions by making the second argument a 
SourceLocation pointer with default argument of nullptr.  See 
isAtStartOfImmediateMacroExpansion or isAtEndOfImmediateMacroExpansion 
functions for how this is done.


Comment at: lib/Basic/SourceManager.cpp:1015-1024
@@ -1014,1 +1014,12 @@
 
+bool SourceManager::isMacroArgExpansion(SourceLocation Loc, 
+SourceLocation &NewLoc) const {
+  if (!Loc.isMacroID()) return false;
+
+  FileID FID = getFileID(Loc);
+  const SrcMgr::ExpansionInfo &Expansion = getSLocEntry(FID).getExpansion();
+  if (!Expansion.isMacroArgExpansion()) return false;
+  NewLoc = Expansion.getExpansionLocStart();
+  return true;
+}
+

Merge with other isMacroArgExpansion function


Comment at: lib/Frontend/DiagnosticRenderer.cpp:311
@@ +310,3 @@
+/// to match the \p CaretLocFileID.
+
+static bool retrieveBeginLocation(SourceLocation &Begin,

No newline between comment and function.  And what is the logic behind in this 
function that wasn't in the code it is replacing?


Comment at: lib/Frontend/DiagnosticRenderer.cpp:312
@@ +311,3 @@
+
+static bool retrieveBeginLocation(SourceLocation &Begin,
+ FileID &BeginFileID,

Why not return a SourceLocation instead of passing one in by reference?


Comment at: lib/Frontend/DiagnosticRenderer.cpp:313
@@ +312,3 @@
+static bool retrieveBeginLocation(SourceLocation &Begin,
+ FileID &BeginFileID,
+ FileID CaretLocFileID,

Why is this passed by reference?


Comment at: lib/Frontend/DiagnosticRenderer.cpp:314-350
@@ +313,39 @@
+ FileID &BeginFileID,
+ FileID CaretLocFileID,
+ const SourceManager *SM) {
+  if (BeginFileID == CaretLocFileID) return true;
+  if (!Begin.isMacroID()) return false;
+  SourceLocation Backup = Begin;
+  Begin = SM->getImmediateMacroCallerLoc(Begin);
+  if (SM->isMacroArgExpansion(Backup))
+Backup = SM->getImmediateExpansionRange(Backup).first;
+  else
+Backup = SM->getImmediateSpellingLoc(Backup);
+  BeginFileID = SM->getFileID(Begin);
+  if (retrieveBeginLocation(Begin,BeginFileID,CaretLocFileID,SM)) return true;
+  Begin = Backup;
+  BeginFileID = SM->getFileID(Backup);
+  return retrieveBeginLocation(Begin,BeginFileID,CaretLocFileID,SM);
+}
+
+static bool retrieveEndLocation(SourceLocation &End,
+FileID &EndFileID,
+FileID CaretLocFileID,
+const SourceManager *SM) {
+  if (EndFileID == CaretLocFileID) return true;
+  if (!End.isMacroID()) return false;
+  SourceLocation Backup = End;
+  End = SM->getImmediateMacroCallerLoc(End);
+  if (SM->isMacroArgExpansion(Backup))
+Backup = SM->getImmediateExpansionRange(Backup).second;
+  else {
+End = SM->getImmediateExpansionRange(Backup).second;
+Backup = SM->getImmediateSpellingLoc(Backup);
+  }
+  EndFileID = SM->getFileID(End);
+  if (retrieveEndLocation(End,EndFileID,CaretLocFileID,SM)) return true;
+  End = Backup;
+  EndFileID = SM->getFileID(Backup);
+  return retrieveEndLocation(End,EndFileID,CaretLocFileID,SM);
+}
+

Use more vertical whitespace when coding.


Comment at: lib/Frontend/DiagnosticRenderer.cpp:323
@@ +322,3 @@
+  else
+Backup = SM->getImmediateSpellingLoc(Backup);
+  BeginFileID = SM->getFileID(Begin);

In the other function, there is "End = 
SM->getImmediateExpansionRange(Backup).second;"  Why is there not a "Begin = 
SM->getImmediateExpansionRange(Backup).first;" here?


Comment at: lib/Frontend/DiagnosticRenderer.cpp:331
@@ +330,3 @@
+
+static bool retrieveEndLocation(SourceLocation &End,
+FileID &EndFileID,

There is a lot of duplicated co

Re: r247765 - [modules] Fix a corner case in the macro override rules: properly handle overridden leaf module macros.

2015-09-15 Thread Sean Silva via cfe-commits
On Tue, Sep 15, 2015 at 5:55 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Sep 15 19:55:50 2015
> New Revision: 247765
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247765&view=rev
> Log:
> [modules] Fix a corner case in the macro override rules: properly handle
> overridden leaf module macros.
>

What exactly is a "leaf module macro"?

-- Sean Silva


>
> Modified:
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/test/Modules/macros.c
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=247765&r1=247764&r2=247765&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Sep 15 19:55:50 2015
> @@ -145,8 +145,12 @@ void Preprocessor::updateModuleMacroInfo
>  NumHiddenOverrides[O] = -1;
>
>// Collect all macros that are not overridden by a visible macro.
> -  llvm::SmallVector Worklist(Leaf->second.begin(),
> -Leaf->second.end());
> +  llvm::SmallVector Worklist;
> +  for (auto *LeafMM : Leaf->second) {
> +assert(LeafMM->getNumOverridingMacros() == 0 && "leaf macro
> overridden");
> +if (NumHiddenOverrides.lookup(LeafMM) == 0)
> +  Worklist.push_back(LeafMM);
> +  }
>while (!Worklist.empty()) {
>  auto *MM = Worklist.pop_back_val();
>  if
> (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {
>
> Modified: cfe/trunk/test/Modules/macros.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=247765&r1=247764&r2=247765&view=diff
>
> ==
> --- cfe/trunk/test/Modules/macros.c (original)
> +++ cfe/trunk/test/Modules/macros.c Tue Sep 15 19:55:50 2015
> @@ -18,7 +18,6 @@
>  // expected-note@Inputs/macros_right.h:12{{expanding this definition of
> 'LEFT_RIGHT_DIFFERENT'}}
>  // expected-note@Inputs/macros_right.h:13{{expanding this definition of
> 'LEFT_RIGHT_DIFFERENT2'}}
>  // expected-note@Inputs/macros_left.h:14{{other definition of
> 'LEFT_RIGHT_DIFFERENT'}}
> -// expected-note@Inputs/macros_left.h:11{{other definition of
> 'LEFT_RIGHT_DIFFERENT2'}}
>
>  @import macros;
>
> @@ -72,9 +71,14 @@ void f() {
>  #  error TOP should not be visible
>  #endif
>
> +#undef INTEGER
> +#define INTEGER int
> +
>  // Import left module (which also imports top)
>  @import macros_left;
>
> +INTEGER my_integer = 0;
> +
>  #ifndef LEFT
>  #  error LEFT should be visible
>  #endif
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12895: Let cxa_demangle.cpp compile with gcc/libstdc++ 4.8 and clang-cl/MSVC2013's STL.

2015-09-15 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: mclow.lists.
thakis added a subscriber: cfe-commits.

I wanted a demangler that can demangle both Itanium-style and Microsoft-style 
mangled symbols, and that runs on all of Windows, Linux, and Mac OS X. I used 
libcxxabi's cxa_demangle for the Itanium demangling, but that required to get 
it to build with gcc on Linux and with clang-cl/MSVC on Windows. It required 
only small changes, and imho they look reasonable enough to send them upstream.

libstdc++ needs a few typedefs in malloc_alloc. MSVC's STL needs rebind(), 
construct(), destroy().

MSVC2013 also has no snprintf, but it allegedly exists in 2015. (I haven't 
tried building with 2015, though.)

http://reviews.llvm.org/D12895

Files:
  src/cxa_demangle.cpp

Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -18,6 +18,13 @@
 #include 
 #include 
 
+#ifdef _MSC_VER
+// snprintf is implemented in VS 2015
+#if _MSC_VER < 1900
+#define snprintf _snprintf_s
+#endif
+#endif
+
 namespace __cxxabiv1
 {
 
@@ -4818,6 +4825,12 @@
 {
 public:
 typedef T value_type;
+typedef T& reference;
+typedef const T& const_reference;
+typedef T* pointer;
+typedef const T* const_pointer;
+typedef std::size_t size_type;
+typedef std::ptrdiff_t difference_type;
 
 malloc_alloc() = default;
 template  malloc_alloc(const malloc_alloc&) noexcept {}
@@ -4830,6 +4843,17 @@
 {
 std::free(p);
 }
+
+template  struct rebind { using other = malloc_alloc; };
+template 
+void construct(U* p, Args&&... args)
+{
+::new ((void*)p) U(std::forward(args)...);
+}
+void destroy(T* p)
+{
+p->~T();
+}
 };
 
 template 


Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -18,6 +18,13 @@
 #include 
 #include 
 
+#ifdef _MSC_VER
+// snprintf is implemented in VS 2015
+#if _MSC_VER < 1900
+#define snprintf _snprintf_s
+#endif
+#endif
+
 namespace __cxxabiv1
 {
 
@@ -4818,6 +4825,12 @@
 {
 public:
 typedef T value_type;
+typedef T& reference;
+typedef const T& const_reference;
+typedef T* pointer;
+typedef const T* const_pointer;
+typedef std::size_t size_type;
+typedef std::ptrdiff_t difference_type;
 
 malloc_alloc() = default;
 template  malloc_alloc(const malloc_alloc&) noexcept {}
@@ -4830,6 +4843,17 @@
 {
 std::free(p);
 }
+
+template  struct rebind { using other = malloc_alloc; };
+template 
+void construct(U* p, Args&&... args)
+{
+::new ((void*)p) U(std::forward(args)...);
+}
+void destroy(T* p)
+{
+p->~T();
+}
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247767 - [analyzer] SATestBuild.py: Move additional checkers logic so SATestAdd.py can use it as well.

2015-09-15 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Sep 15 20:52:32 2015
New Revision: 247767

URL: http://llvm.org/viewvc/llvm-project?rev=247767&view=rev
Log:
[analyzer] SATestBuild.py: Move additional checkers logic so SATestAdd.py can 
use it as well.

Move the logic looking for additional checkers in the SA_ADDITIONAL_CHECKERS
environmental variable from SATestBuild's main() to runScanBuild(). This allows
SATestAdd.py to use the variable as well. Without it, we won't include
additional checkers when building reference results for the build bot.

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

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=247767&r1=247766&r2=247767&view=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Tue Sep 15 20:52:32 2015
@@ -210,9 +210,14 @@ def runScanBuild(Dir, SBOutputDir, PBuil
 if not os.path.exists(BuildScriptPath):
 print "Error: build script is not defined: %s" % BuildScriptPath
 sys.exit(-1)
+
+AllCheckers = Checkers
+if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
+AllCheckers = AllCheckers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
+
 SBOptions = "--use-analyzer " + Clang + " "
 SBOptions += "-plist-html -o " + SBOutputDir + " "
-SBOptions += "-enable-checker " + Checkers + " "
+SBOptions += "-enable-checker " + AllCheckers + " "
 SBOptions += "--keep-empty "
 # Always use ccc-analyze to ensure that we can locate the failures
 # directory.
@@ -614,7 +619,4 @@ if __name__ == '__main__':
 IsReference = True
 UpdateSVN = True
 
-if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
-Checkers = Checkers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
-
 testAll(IsReference, UpdateSVN, Strictness)


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


Re: [PATCH] D12891: [analyzer] SATestBuild.py: Move additional checkers logic so SATestAdd.py can use it as well.

2015-09-15 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247767: [analyzer] SATestBuild.py: Move additional checkers 
logic so SATestAdd.py can… (authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D12891?vs=34853&id=34864#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12891

Files:
  cfe/trunk/utils/analyzer/SATestBuild.py

Index: cfe/trunk/utils/analyzer/SATestBuild.py
===
--- cfe/trunk/utils/analyzer/SATestBuild.py
+++ cfe/trunk/utils/analyzer/SATestBuild.py
@@ -210,9 +210,14 @@
 if not os.path.exists(BuildScriptPath):
 print "Error: build script is not defined: %s" % BuildScriptPath
 sys.exit(-1)
+
+AllCheckers = Checkers
+if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
+AllCheckers = AllCheckers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
+
 SBOptions = "--use-analyzer " + Clang + " "
 SBOptions += "-plist-html -o " + SBOutputDir + " "
-SBOptions += "-enable-checker " + Checkers + " "
+SBOptions += "-enable-checker " + AllCheckers + " "
 SBOptions += "--keep-empty "
 # Always use ccc-analyze to ensure that we can locate the failures
 # directory.
@@ -614,7 +619,4 @@
 IsReference = True
 UpdateSVN = True
 
-if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
-Checkers = Checkers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
-
 testAll(IsReference, UpdateSVN, Strictness)


Index: cfe/trunk/utils/analyzer/SATestBuild.py
===
--- cfe/trunk/utils/analyzer/SATestBuild.py
+++ cfe/trunk/utils/analyzer/SATestBuild.py
@@ -210,9 +210,14 @@
 if not os.path.exists(BuildScriptPath):
 print "Error: build script is not defined: %s" % BuildScriptPath
 sys.exit(-1)
+
+AllCheckers = Checkers
+if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
+AllCheckers = AllCheckers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
+
 SBOptions = "--use-analyzer " + Clang + " "
 SBOptions += "-plist-html -o " + SBOutputDir + " "
-SBOptions += "-enable-checker " + Checkers + " "
+SBOptions += "-enable-checker " + AllCheckers + " "
 SBOptions += "--keep-empty "
 # Always use ccc-analyze to ensure that we can locate the failures
 # directory.
@@ -614,7 +619,4 @@
 IsReference = True
 UpdateSVN = True
 
-if os.environ.has_key('SA_ADDITIONAL_CHECKERS'):
-Checkers = Checkers + ',' + os.environ['SA_ADDITIONAL_CHECKERS']
-
 testAll(IsReference, UpdateSVN, Strictness)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12712: Implementation and testing for poisoning vtable ptr in dtor.

2015-09-15 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.


Comment at: lib/CodeGen/CGClass.cpp:1756
@@ +1755,3 @@
+ class SanitizeDtorVTable final : public EHScopeStack::Cleanup {
+const CXXDestructorDecl *Dtor;
+

It causes a warning in -Asserts. [-Wunused-private-field]


http://reviews.llvm.org/D12712



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


Re: [PATCH] D12871: [OpenMP] Target directive host codegen - rebased

2015-09-15 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 34869.
sfantao added a comment.

Update code to use implicit parameters for the captured variables using 
`GenerateOpenMPCapturedStmtFunction`, similarly to what is done to other 
directives.

`UseOnlyReferences` boolean was added to  `GenerateOpenMPCapturedStmtFunction`, 
given that for target regions, all the captures need to be references, VAT 
sizes included. `UseOnlyReferences` is set to false by default and only set to 
true when emitting a target directive.


http://reviews.llvm.org/D12871

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  test/OpenMP/target_codegen.cpp

Index: test/OpenMP/target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen.cpp
@@ -0,0 +1,606 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[TT:%.+]] = type { i64, i8 }
+// CHECK-DAG: [[S1:%.+]] = type { double }
+
+// We have 8 target regions, but only 7 that actually will generate offloading
+// code, only 6 will have mapped arguments, and only 4 have all-constant map
+// sizes.
+
+// CHECK-DAG: [[SIZET2:@.+]] = private unnamed_addr constant [1 x i{{32|64}}] [i[[SZ:32|64]] 2]
+// CHECK-DAG: [[MAPT2:@.+]] = private unnamed_addr constant [1 x i32] [i32 3]
+// CHECK-DAG: [[SIZET3:@.+]] = private unnamed_addr constant [2 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2]
+// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i32] [i32 3, i32 3]
+// CHECK-DAG: [[MAPT4:@.+]] = private unnamed_addr constant [9 x i32] [i32 3, i32 3, i32 1, i32 3, i32 3, i32 1, i32 1, i32 3, i32 3]
+// CHECK-DAG: [[SIZET5:@.+]] = private unnamed_addr constant [3 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT5:@.+]] = private unnamed_addr constant [3 x i32] [i32 3, i32 3, i32 3]
+// CHECK-DAG: [[SIZET6:@.+]] = private unnamed_addr constant [4 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 1, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT6:@.+]] = private unnamed_addr constant [4 x i32] [i32 3, i32 3, i32 3, i32 3]
+// CHECK-DAG: [[MAPT7:@.+]] = private unnamed_addr constant [5 x i32] [i32 3, i32 3, i32 1, i32 1, i32 3]
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// CHECK: define {{.*}}[[FOO:@.+]](
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 0, i8** null, i8** null, i[[SZ]]* null, i32* null)
+  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT0:@.+]]()
+  // CHECK-NEXT:  br label %[[END]]
+  // CHECK:   [[END]]
+  #pragma omp target
+  {
+  }
+
+  // CHECK:   call void [[HVT1:@.+]](i32* {{[^,]+}})
+  #pragma omp target if(0)
+  {
+a += 1;
+  }
+
+  // CHECK:   br label %[[TRY:[^,]+]]
+  // CHECK:   [[TRY]]
+  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds ([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))
+  // CHECK-DAG:   [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
+  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
+  // CHECK-DAG:   store i8* [[BP0:%[^,]+]], i8** [[BPADDR0]]
+  // CHECK-DAG:   store i8* [[P0:%[^,]+]], i

Re: [PATCH] D12262: [OpenMP] Capture global variables in target regions.

2015-09-15 Thread Samuel Antao via cfe-commits
sfantao updated the summary for this revision.
sfantao updated this revision to Diff 34870.
sfantao added a comment.

Rebase with the last changes in http://reviews.llvm.org/D12871.


http://reviews.llvm.org/D12262

Files:
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/Basic/OpenMPKinds.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_codegen_global_capture.cpp

Index: test/OpenMP/target_codegen_global_capture.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen_global_capture.cpp
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+
+// CHECK-DAG: [[GA:@.+]] = global double 1.00e+00
+// CHECK-DAG: [[GB:@.+]] = global double 2.00e+00
+// CHECK-DAG: [[GC:@.+]] = global double 3.00e+00
+// CHECK-DAG: [[GD:@.+]] = global double 4.00e+00
+// CHECK-DAG: [[FA:@.+]] = internal global float 5.00e+00
+// CHECK-DAG: [[FB:@.+]] = internal global float 6.00e+00
+// CHECK-DAG: [[FC:@.+]] = internal global float 7.00e+00
+// CHECK-DAG: [[FD:@.+]] = internal global float 8.00e+00
+// CHECK-DAG: [[BA:@.+]] = internal global float 9.00e+00
+// CHECK-DAG: [[BB:@.+]] = internal global float 1.00e+01
+// CHECK-DAG: [[BC:@.+]] = internal global float 1.10e+01
+// CHECK-DAG: [[BD:@.+]] = internal global float 1.20e+01
+double Ga = 1.0;
+double Gb = 2.0;
+double Gc = 3.0;
+double Gd = 4.0;
+
+// CHECK: define {{.*}} @{{.*}}foo{{.*}}(
+// CHECK-SAME: i16 {{[^,]*}}[[A:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[B:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[C:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[D:%[^,]+]])
+// CHECK: [[LA:%.+]] = alloca i16
+// CHECK: [[LB:%.+]] = alloca i16
+// CHECK: [[LC:%.+]] = alloca i16
+// CHECK: [[LD:%.+]] = alloca i16
+int foo(short a, short b, short c, short d){
+  static float Sa = 5.0;
+  static float Sb = 6.0;
+  static float Sc = 7.0;
+  static float Sd = 8.0;
+
+  // CHECK-DAG: [[REFB:%.+]] = bitcast i16* [[LB]] to i8*
+  // CHECK-DAG: store i8* [[REFB]], i8** [[GEPB:%.+]], align
+  // CHECK-DAG: [[REFC:%.+]] = bitcast i16* [[LC]] to i8*
+  // CHECK-DAG: store i8* [[REFC]], i8** [[GEPC:%.+]], align
+  // CHECK-DAG: [[REFD:%.+]] = bitcast i16* [[LD]] to i8*
+  // CHECK-DAG: store i8* [[REFD]], i8** [[GEPD:%.+]], align
+  // CHECK-DAG: store i8* bitcast (double* [[GB]] to i8*), i8** [[GEPGB:%.+]], align
+  // CHECK-DAG: store i8* bitcast (double* [[GC]] to i8*), i8** [[GEPGC:%.+]], align
+  // CHECK-DAG: store i8* bitcast (double* [[GD]] to i8*), i8** [[GEPGD:%.+]], align
+  // CHECK-DAG: store i8* bitcast (float* [[FB]] to i8*), i8** [[GEPFB:%.+]], align
+  // CHECK-DAG: store i8* bitcast (float* [[FC]] to i8*), i8** [[GEPFC:%.+]], align
+  // CHECK-DAG: store i8* bitcast (float* [[FD]] to i8*), i8** [[GEPFD:%.+]], align
+  // CHECK-DAG: [[GEPB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK: call i32 @__tgt_target
+  // CHECK: call void [[OFFLOADF:@.+]](
+  // Capture b, Gb, Sb, Gc, c, Sc, d, Gd, Sd
+  #pragma omp target if(Ga>0.0 && a>0 && Sa>0.0)
+  {
+b += 1;
+Gb += 1.0;
+Sb += 1.0;
+
+// CHECK: define internal void [[OFFLOADF]]({{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}}, {{.+}}* {{.*}}%{{.+}})
+// The parallel region only uses 3 captures.
+//

Re: r247765 - [modules] Fix a corner case in the macro override rules: properly handle overridden leaf module macros.

2015-09-15 Thread Richard Smith via cfe-commits
On Sep 15, 2015 6:28 PM, "Sean Silva"  wrote:
>
>
>
> On Tue, Sep 15, 2015 at 5:55 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>>
>> Author: rsmith
>> Date: Tue Sep 15 19:55:50 2015
>> New Revision: 247765
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247765&view=rev
>> Log:
>> [modules] Fix a corner case in the macro override rules: properly handle
overridden leaf module macros.
>
>
> What exactly is a "leaf module macro"?

This is a module macro that is not overridden by any other module macro. We
were sometimes not doing the right thing if such a module macro is
overridden by a local macro (one not imported from any module).

> -- Sean Silva
>
>>
>>
>> Modified:
>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> cfe/trunk/test/Modules/macros.c
>>
>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=247765&r1=247764&r2=247765&view=diff
>>
==
>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Tue Sep 15 19:55:50 2015
>> @@ -145,8 +145,12 @@ void Preprocessor::updateModuleMacroInfo
>>  NumHiddenOverrides[O] = -1;
>>
>>// Collect all macros that are not overridden by a visible macro.
>> -  llvm::SmallVector Worklist(Leaf->second.begin(),
>> -Leaf->second.end());
>> +  llvm::SmallVector Worklist;
>> +  for (auto *LeafMM : Leaf->second) {
>> +assert(LeafMM->getNumOverridingMacros() == 0 && "leaf macro
overridden");
>> +if (NumHiddenOverrides.lookup(LeafMM) == 0)
>> +  Worklist.push_back(LeafMM);
>> +  }
>>while (!Worklist.empty()) {
>>  auto *MM = Worklist.pop_back_val();
>>  if
(CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {
>>
>> Modified: cfe/trunk/test/Modules/macros.c
>> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macros.c?rev=247765&r1=247764&r2=247765&view=diff
>>
==
>> --- cfe/trunk/test/Modules/macros.c (original)
>> +++ cfe/trunk/test/Modules/macros.c Tue Sep 15 19:55:50 2015
>> @@ -18,7 +18,6 @@
>>  // expected-note@Inputs/macros_right.h:12{{expanding this definition of
'LEFT_RIGHT_DIFFERENT'}}
>>  // expected-note@Inputs/macros_right.h:13{{expanding this definition of
'LEFT_RIGHT_DIFFERENT2'}}
>>  // expected-note@Inputs/macros_left.h:14{{other definition of
'LEFT_RIGHT_DIFFERENT'}}
>> -// expected-note@Inputs/macros_left.h:11{{other definition of
'LEFT_RIGHT_DIFFERENT2'}}
>>
>>  @import macros;
>>
>> @@ -72,9 +71,14 @@ void f() {
>>  #  error TOP should not be visible
>>  #endif
>>
>> +#undef INTEGER
>> +#define INTEGER int
>> +
>>  // Import left module (which also imports top)
>>  @import macros_left;
>>
>> +INTEGER my_integer = 0;
>> +
>>  #ifndef LEFT
>>  #  error LEFT should be visible
>>  #endif
>>
>>
>> ___
>> 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] D12547: Add support for function attribute "disable_tail_calls"

2015-09-15 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 34872.
ahatanak added a comment.

Sorry for the delay in my response.

I had discussions with the users who requested this feature and it turns out 
they were asking for two different kinds of attributes. They are both needed to 
disable tail call optimization to preserve the stack frame but they differ in 
which stack frame they are trying to preserve. The attribute in this patch 
disables optimization on the call sites inside a function to preserve the stack 
frame of the function. The other attribute disables tail call *to* the function 
and therefore preserves the stack frame of the calling function.

I'll send a patch for the other attribute shortly.


http://reviews.llvm.org/D12547

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-disable-tail-calls.c
  test/Sema/disable-tail-calls-attr.c

Index: test/Sema/disable-tail-calls-attr.c
===
--- /dev/null
+++ test/Sema/disable-tail-calls-attr.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void __attribute__((disable_tail_calls,naked)) foo1(int a) { // expected-error {{'disable_tail_calls' and 'naked' attributes are not compatible}}
+  __asm__("");
+}
Index: test/CodeGen/attr-disable-tail-calls.c
===
--- test/CodeGen/attr-disable-tail-calls.c
+++ test/CodeGen/attr-disable-tail-calls.c
@@ -1,11 +1,19 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -mdisable-tail-calls -o - | FileCheck %s -check-prefix=CHECK -check-prefix=DISABLE
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK -check-prefix=ENABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -mdisable-tail-calls -o - | FileCheck %s -check-prefix=DISABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s -check-prefix=ENABLE
 
-// CHECK: define i32 @f1() [[ATTR:#[0-9]+]] {
+// DISABLE: define i32 @f1() [[ATTRTRUE:#[0-9]+]] {
+// DISABLE: define i32 @f2() [[ATTRTRUE]] {
+// ENABLE: define i32 @f1() [[ATTRFALSE:#[0-9]+]] {
+// ENABLE: define i32 @f2() [[ATTRTRUE:#[0-9]+]] {
 
 int f1() {
   return 0;
 }
 
-// DISABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
-// ENABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="false" {{.*}} }
+int f2() __attribute__((disable_tail_calls)) {
+  return 0;
+}
+
+// DISABLE: attributes [[ATTRTRUE]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
+// ENABLE: attributes [[ATTRFALSE]] = { {{.*}} "disable-tail-calls"="false" {{.*}} }
+// ENABLE: attributes [[ATTRTRUE]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1696,6 +1696,18 @@
Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleDisableTailCallsAttr(Sema &S, Decl *D,
+   const AttributeList &Attr) {
+  if (auto *A = D->getAttr()) {
+S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible)
+<< Attr.getName() << A;
+return;
+  }
+
+  D->addAttr(::new (S.Context) DisableTailCallsAttr(
+  Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   if (const VarDecl *VD = dyn_cast(D)) {
 if (VD->hasLocalStorage()) {
@@ -4886,6 +4898,9 @@
   case AttributeList::AT_ReturnsTwice:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_DisableTailCalls:
+handleDisableTailCallsAttr(S, D, Attr);
+break;
   case AttributeList::AT_Used:
 handleUsedAttr(S, D, Attr);
 break;
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1480,8 +1480,12 @@
   FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 }
 
+bool DisableTailCalls =
+(TargetDecl && TargetDecl->hasAttr()) ||
+CodeGenOpts.DisableTailCalls;
 FuncAttrs.addAttribute("disable-tail-calls",
-   llvm::toStringRef(CodeGenOpts.DisableTailCalls));
+   llvm::toStringRef(DisableTailCalls));
+
 FuncAttrs.addAttribute("less-precise-fpmad",
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
 FuncAttrs.addAttribute("no-infs-fp-math",
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1612,3 +1612,10 @@
 arguments, with arbitrary offsets.
   }];
 }
+
+def DisableTailCallsDocs : Documentation {
+  l

Re: [PATCH] D12547: Add support for function attribute "disable_tail_calls"

2015-09-15 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: include/clang/Basic/Attr.td:894
@@ -893,1 +893,3 @@
 
+def DisableTailCalls : InheritableAttr {
+  let Spellings = [GNU<"disable_tail_calls">,

aaron.ballman wrote:
> Pardon me if this is obvious, but -- are there times when you would want to 
> disable tail calls but leave other optimizations in place? I'm trying to 
> understand why these attributes are orthogonal.
Yes, that's correct. The new function attribute we are adding shouldn't disable 
other optimizations that are normally run at -O2 or -O3.


Comment at: include/clang/Basic/Attr.td:896
@@ +895,3 @@
+  let Spellings = [GNU<"disable_tail_calls">,
+   CXX11<"clang", "disable_tail_calls">];
+  let Subjects = SubjectList<[Function, ObjCMethod]>;

aaron.ballman wrote:
> Should this attribute be plural? Are there multiple tail calls within a 
> single method that can be optimized away?
I named it after the existing IR function attribute and I'm guessing the plural 
name was chosen because functions can have multiple tail call sites. I think 
the singular name is better if we want this attribute to mean "disable tail 
call optimization".


Comment at: include/clang/Basic/AttrDocs.td:1619
@@ +1618,3 @@
+  let Content = [{
+Use ``__attribute__((disable_tail_calls)))`` to instruct the backend not to do 
tail call optimization.
+  }];

aaron.ballman wrote:
> I would avoid using the exact syntax here because this is a GNU and C++ 
> attribute. Could just say:
> 
> The ``disable_tail_calls`` attribute instructs the backend to not perform 
> tail call optimization.
OK, done.


Comment at: lib/Sema/SemaDeclAttr.cpp:4882
@@ +4881,3 @@
+  case AttributeList::AT_DisableTailCalls:
+handleSimpleAttribute(S, D, Attr);
+break;

aaron.ballman wrote:
> Okay, that makes sense. I can contrive examples of noreturn where TCO could 
> happen, it just took me a while to think of them. ;-)
> 
> What about other semantic checks, like warning the user about disabling TCO 
> when TCO could never be enabled in the first place? Can you disable TCO for 
> functions that are marked __attribute__((naked))? What about returns_twice?
> 
> Unfortunately, we have a lot of attributes for which we've yet to write 
> documentation, so you may need to look through Attr.td.
Since "naked" allows only inline assembly statements, it should be an error to 
have disable-tail-calls and naked on the same function. I made changes in Sema 
to detect that case.

My understanding is that you can't do tail call optimization on call sites of a 
function that calls a "return_twice" function. However, attaching 
"return_twice" on the calling function doesn't block tail call optimizations on 
the call sites inside the function.

I didn't find any other attributes that seemed incompatible with 
disable-tail-calls.


http://reviews.llvm.org/D12547



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


r247778 - CGClass.cpp: Fix a warning in -Asserts. [-Wunused-private-field]

2015-09-15 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Sep 16 01:26:56 2015
New Revision: 247778

URL: http://llvm.org/viewvc/llvm-project?rev=247778&view=rev
Log:
CGClass.cpp: Fix a warning in -Asserts. [-Wunused-private-field]

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

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247778&r1=24&r2=247778&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Sep 16 01:26:56 2015
@@ -1789,6 +1789,7 @@ namespace {
 // Generate function call for handling vtable pointer poisoning.
 void Emit(CodeGenFunction &CGF, Flags flags) override {
   assert(Dtor->getParent()->isDynamicClass());
+  (void)Dtor;
   ASTContext &Context = CGF.getContext();
   // Poison vtable and vtable ptr if they exist for this class.
   llvm::Value *VTablePtr = CGF.LoadCXXThis();


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


Re: [PATCH] D12664: Fixed comparison.

2015-09-15 Thread James Touton via cfe-commits
jtouton added a comment.

Can I get this reviewed?


http://reviews.llvm.org/D12664



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