r247500 - [CodeGen] Remove wrapper-free always_inline functions from COMDATs

2015-09-11 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sat Sep 12 01:37:42 2015
New Revision: 247500

URL: http://llvm.org/viewvc/llvm-project?rev=247500&view=rev
Log:
[CodeGen] Remove wrapper-free always_inline functions from COMDATs

always_inline functions without a wrapper don't need to be in a COMDAT.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=247500&r1=247499&r2=247500&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Sep 12 01:37:42 2015
@@ -494,8 +494,12 @@ void CodeGenModule::RewriteAlwaysInlineF
   FindNonDirectCallUses(Fn, &NonDirectCallUses);
   // Do not create the wrapper if there are no non-direct call uses, and we are
   // not required to emit an external definition.
-  if (NonDirectCallUses.empty() && Fn->isDiscardableIfUnused())
+  if (NonDirectCallUses.empty() && Fn->isDiscardableIfUnused()) {
+// An always inline function with no wrapper cannot legitimately use the
+// function's COMDAT symbol.
+Fn->setComdat(nullptr);
 return;
+  }
 
   llvm::FunctionType *FT = Fn->getFunctionType();
   llvm::LLVMContext &Ctx = getModule().getContext();

Modified: cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alwaysinline.cpp?rev=247500&r1=247499&r2=247500&view=diff
==
--- cfe/trunk/test/CodeGenCXX/alwaysinline.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alwaysinline.cpp Sat Sep 12 01:37:42 2015
@@ -33,20 +33,20 @@ void g3() {
   A3 a3;
 }
 
-// CHECK-DAG: define internal void @_ZN2A1C1Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI:[01-9]+]]
-// CHECK-DAG: define internal void @_ZN2A1C2Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI]]
-// CHECK-DAG: define internal void @_ZN2A1D1Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI]]
-// CHECK-DAG: define internal void @_ZN2A1D2Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI]]
+// CHECK-DAG: define internal void @_ZN2A1C1Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI:[01-9]+]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A1C2Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A1D1Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A1D2Ev.alwaysinline(%struct.A1* %this) 
unnamed_addr #[[AI]] align 2 {
 
-// CHECK-DAG: define internal void @_ZN2A2C1Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH:[01-9]+]]
-// CHECK-DAG: define internal void @_ZN2A2C2Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH]]
-// CHECK-DAG: define internal void @_ZN2A2D1Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH]]
-// CHECK-DAG: define internal void @_ZN2A2D2Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH]]
+// CHECK-DAG: define internal void @_ZN2A2C1Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH:[01-9]+]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A2C2Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A2D1Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A2D2Ev.alwaysinline(%struct.A2* %this) 
unnamed_addr #[[AIIH]] align 2 {
 
-// CHECK-DAG: define internal void @_ZN2A3C1Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]]
-// CHECK-DAG: define internal void @_ZN2A3C2Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]]
-// CHECK-DAG: define internal void @_ZN2A3D1Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]]
-// CHECK-DAG: define internal void @_ZN2A3D2Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]]
+// CHECK-DAG: define internal void @_ZN2A3C1Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A3C2Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A3D1Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]] align 2 {
+// CHECK-DAG: define internal void @_ZN2A3D2Ev.alwaysinline(%struct.A3* %this) 
unnamed_addr #[[AIIH]] align 2 {
 
 // CHECK-DAG: attributes #[[AI]] = {{.*alwaysinline.*}}
 // CHECK-DAG: attributes #[[AIIH]] = {{.*alwaysinline.*inlinehint.*}}


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


r247498 - Clean up trailing whitespace in the builtin headers

2015-09-11 Thread Sean Silva via cfe-commits
Author: silvas
Date: Fri Sep 11 21:55:19 2015
New Revision: 247498

URL: http://llvm.org/viewvc/llvm-project?rev=247498&view=rev
Log:
Clean up trailing whitespace in the builtin headers

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/lib/Headers/ammintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/htmxlintrin.h
cfe/trunk/lib/Headers/mmintrin.h
cfe/trunk/lib/Headers/pmmintrin.h
cfe/trunk/lib/Headers/smmintrin.h
cfe/trunk/lib/Headers/stdint.h
cfe/trunk/lib/Headers/tgmath.h
cfe/trunk/lib/Headers/tmmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=247498&r1=247497&r2=247498&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Fri Sep 11 21:55:19 2015
@@ -137,7 +137,7 @@ static vector double __ATTRS_o_ai vec_ab
 }
 #endif
 
-/* vec_abss */ 
+/* vec_abss */
 #define __builtin_altivec_abss_v16qi vec_abss
 #define __builtin_altivec_abss_v8hi vec_abss
 #define __builtin_altivec_abss_v4si vec_abss
@@ -3651,21 +3651,21 @@ static vector float __ATTRS_o_ai vec_vmr
 static vector bool int __ATTRS_o_ai
 vec_mergee(vector bool int __a, vector bool int __b) {
   return vec_perm(__a, __b, (vector unsigned char)
-  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 
+  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B));
 }
 
 static vector signed int __ATTRS_o_ai
 vec_mergee(vector signed int __a, vector signed int __b) {
   return vec_perm(__a, __b, (vector unsigned char)
-  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 
+  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B));
 }
 
 static vector unsigned int __ATTRS_o_ai
 vec_mergee(vector unsigned int __a, vector unsigned int __b) {
   return vec_perm(__a, __b, (vector unsigned char)
-  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13, 
+  (0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, 0x1A, 0x1B));
 }
 

Modified: cfe/trunk/lib/Headers/ammintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ammintrin.h?rev=247498&r1=247497&r2=247498&view=diff
==
--- cfe/trunk/lib/Headers/ammintrin.h (original)
+++ cfe/trunk/lib/Headers/ammintrin.h Fri Sep 11 21:55:19 2015
@@ -34,13 +34,13 @@
 ///
 /// \headerfile 
 ///
-/// \code 
+/// \code
 /// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx);
-/// \endcode 
+/// \endcode
 ///
-/// \code
+/// \code
 /// This intrinsic corresponds to the \c EXTRQ instruction.
-/// \endcode 
+/// \endcode
 ///
 /// \param x
 ///The value from which bits are extracted.
@@ -48,10 +48,10 @@
 ///Bits [5:0] specify the length; the other bits are ignored. If bits [5:0]
 ///are zero, the length is interpreted as 64.
 /// \param idx
-///Bits [5:0] specify the index of the least significant bit; the other 
-///bits are ignored. If the sum of the index and length is greater than 
-///64, the result is undefined. If the length and index are both zero, 
-///bits [63:0] of parameter x are extracted. If the length is zero 
+///Bits [5:0] specify the index of the least significant bit; the other
+///bits are ignored. If the sum of the index and length is greater than
+///64, the result is undefined. If the length and index are both zero,
+///bits [63:0] of parameter x are extracted. If the length is zero
 ///but the index is non-zero, the result is undefined.
 /// \returns A 128-bit integer vector whose lower 64 bits contain the bits
 ///extracted from the source operand.
@@ -64,21 +64,21 @@
 ///
 /// \headerfile 
 ///
-/// \code 
+/// \code
 /// This intrinsic corresponds to the \c EXTRQ instruction.
-/// \endcode 
+/// \endcode
 ///
 /// \param __x
 ///The value from which bits are extracted.
 /// \param __y
-///Specifies the index of the least significant bit at [13:8] 
-///and the length at [5:0]; all other bits are ignored. 
+///Specifies the index of the least significant bit at [13:8]
+///and the length at [5:0]; all other bits are ignored.
 ///If bits [5:0] are zero, the length is interpreted as 64.
-///If the sum of the index and length is greater than 64, the result is 
-///undefined. If the length and index are both zero, bits [63:0] of 
-///parameter __x are extracted. If the length is zero but the index is 
-///non-zero, the result is undefin

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

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

- Poison vtable in either complete or base dtor.


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,16 @@
+// 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;
+
+// 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
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:
@@ -52,14 +53,17 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison member and vtable pointer.
 // 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 member and vtable pointer.
 // 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 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
@@ -1684,11 +1700,11 @@
   // 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;
 }
@@ -1701,7 +1717,7 @@
 /// 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 = C

Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-09-11 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: include/clang/AST/Type.h:1210
@@ +1209,3 @@
+/// Which keyword(s) were used to create an AutoType.
+enum struct AutoTypeKeyword : unsigned char {
+  /// \brief auto

Please use `enum class` here; we don't use `enum struct` anywhere in Clang or 
LLVM.


Comment at: include/clang/AST/Type.h:1216
@@ +1215,3 @@
+  /// \brief __auto_type (GNU extension)
+  AutoTypeExt
+};

Maybe `GNUAutoType`?


Comment at: include/clang/AST/Type.h:3915-3916
@@ -3902,5 +3914,4 @@
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-Profile(ID, getDeducedType(), isDecltypeAuto(), 
-   isDependentType());
+Profile(ID, getDeducedType(), AutoTypeBits.Keyword, isDependentType());
   }

`auto` and `__auto_type` should probably not profile differently; they mangle 
the same, so this will lead to mangling collisions. (It's not completely clear 
that we need to retain the distinction between `auto` and `__auto_type` here at 
all, since they have identical semantics, but it's probably a good thing for 
source fidelity. We don't maintain a difference between `bool` and `_Bool`, for 
what it's worth.)


Comment at: lib/Sema/SemaExpr.cpp:352
@@ -351,1 +351,3 @@
   if (ParsingInitForAutoVars.count(D)) {
+const AutoType* AT = 
cast(D)->getType().getTypePtr()->getContainedAutoType();
+

`const AutoType* AT` -> const AutoType *AT`. Also, remove the unnecessary 
`.getTypePtr()` here.


Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp:4
@@ -3,3 +3,3 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {

vsk wrote:
> Do you know what this FIXME alludes to? Seems rather mysterious to me.
It says that the relevant wording in the standard got moved to a different 
paragraph number (due to the insertion of more rules beforehand for deduced 
return types and generic lambdas).


http://reviews.llvm.org/D12686



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


r247496 - clang/test/Driver/stackrealign.c REQUIRES clang-driver.

2015-09-11 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 11 20:29:35 2015
New Revision: 247496

URL: http://llvm.org/viewvc/llvm-project?rev=247496&view=rev
Log:
clang/test/Driver/stackrealign.c REQUIRES clang-driver.

GCC driver, for example cygwin, both "-mstackrealign" "-mno-stackrealign" are 
passed.

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

Modified: cfe/trunk/test/Driver/stackrealign.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stackrealign.c?rev=247496&r1=247495&r2=247496&view=diff
==
--- cfe/trunk/test/Driver/stackrealign.c (original)
+++ cfe/trunk/test/Driver/stackrealign.c Fri Sep 11 20:29:35 2015
@@ -1,6 +1,7 @@
 // RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
 // RUN: %clang -### -mno-stackrealign -mstackrealign %s 2>&1 | FileCheck %s 
-check-prefix=REALIGN
 // RUN: %clang -### -mstackrealign -mno-stackrealign %s 2>&1 | FileCheck %s 
-check-prefix=NO-REALIGN
+// REQUIRES: clang-driver
 
 // REALIGN: -mstackrealign
 // NO-REALIGN-NOT: -mstackrealign


___
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-11 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 34614.
nmusgrave marked 2 inline comments as done.
nmusgrave added a comment.

- Fixed testing callback emission order to account for vptr.


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,16 @@
+// 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;
+
+// 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
Index: test/CodeGenCXX/sanitize-dtor-derived-class.cpp
===
--- test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -52,14 +52,17 @@
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
+// Poison member and vtable pointer.
 // 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 member and vtable pointer.
 // 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 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
@@ -1684,11 +1700,11 @@
   // 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;
 }
@@ -1701,7 +1717,7 @@
 /// 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 =
@@ -1732,20 +1748,30 @@
   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;
+

Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk added a comment.

First off, welcome! And thanks for patch.

This basically LGTM, but I have one small change I'd like to see (inline 
comment).

Hm, the spec says "The sizeof operator shall not be applied to... an lvalue 
that designates a bit-field". Sounds like a bug to me.



Comment at: lib/Sema/SemaType.cpp:2698
@@ -2693,1 +2697,3 @@
+  const unsigned Keyword =
+  D.getDeclSpec().getTypeSpecType() - DeclSpec::TST_auto;
   SemaRef.Diag(AutoRange.getBegin(), diag::err_auto_not_allowed)

Hm, this is a little hard to read. IIUC it's also sensitive to re-ordering of 
enum values. I'd be happier if you introduced a switch here, and made the LHS 
enum type explicit.


Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp:4
@@ -3,3 +3,3 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {

Do you know what this FIXME alludes to? Seems rather mysterious to me.


http://reviews.llvm.org/D12686



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

second attempt in r247494


Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


r247494 - Always_inline codegen rewrite.

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Sep 11 20:07:37 2015
New Revision: 247494

URL: http://llvm.org/viewvc/llvm-project?rev=247494&view=rev
Log:
Always_inline codegen rewrite.

Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

Added:
cfe/trunk/test/CodeGen/always_inline-unused.c
cfe/trunk/test/CodeGen/always_inline-wrappers.c
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/always-inline.c
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/CodeGen/function-attributes.c
cfe/trunk/test/CodeGen/pr9614.c
cfe/trunk/test/Frontend/optimization-remark-line-directive.c
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/Modules/cxx-irgen.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=247494&r1=247493&r2=247494&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Sep 11 20:07:37 2015
@@ -109,6 +109,9 @@ bool CodeGenModule::TryEmitBaseDestructo
   D->getType()->getAs()->getCallConv())
 return true;
 
+  if (BaseD->hasAttr())
+return true;
+
   return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
   GlobalDecl(BaseD, Dtor_Base),
   false);
@@ -161,14 +164,7 @@ bool CodeGenModule::TryEmitDefinitionAsA
 
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
 Replacements[MangledName] = Aliasee;
 return false;
   }

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247494&r1=247493&r2=247494&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Sep 11 20:07:37 2015
@@ -1557,7 +1557,7 @@ void CodeGenFunction::EmitDestructorBody
 // -fapple-kext must inline any call to this dtor into
 // the caller's body.
 if (getLangOpts().AppleKext)
-  CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
+  CGM.AddAlwaysInlineFunction(CurFn);
 
 break;
   }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=247494&r1=247493&r2=247494&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Sep 11 20:07:37 2015
@@ -2114,7 +2114,7 @@ emitTaskPrivateMappingFunction(CodeGenMo
   ".omp_task_privates_map.", &CGM.getModule());
   CGM.SetLLVMFunctionAttributes(/*D=*/nullptr, TaskPrivatesMapFnInfo,
 TaskPrivatesMap);
-  TaskPrivatesMap->addFnAttr(llvm::Attribute::AlwaysInline);
+  CGM.AddAlwaysInlineFunction(TaskPrivatesMap);
   CodeGenFunction CGF(C

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgenii Stepanov via cfe-commits
Thanks. I just reproduced it on release w/o asserts build and fixed locally.
The other problem is fixed as well, I'll try re-landing now. I'll keep
an eye on the bot later today and will revert again if necessary.


On Fri, Sep 11, 2015 at 6:02 PM, H.J. Lu  wrote:
> On Fri, Sep 11, 2015 at 4:45 PM, Evgenii Stepanov  wrote:
>> Does it say that there is no entry basic block? I.e. the output
>> apparently looks like
>>
>> define void @h() #1 {
>>   store void ()* @f1, void ()** @p, align 8
>>
>> Could you confirm it? Never seen this behavior.
>>
>> I'm going to revert the change due to this and also one broken gdb
>> test (something wrong with debug info in the code that has been
>> always-inlined twice).
>
> I got
>
> [hjl@gnu-mic-2 llvm-clang]$
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
> x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
> ; ModuleID = 
> '/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c'
> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> target triple = "x86_64-pc-linux-gnu"
>
> ; Function Attrs: nounwind uwtable
> define i32 @f1() #0 {
>   %1 = call i32 @f0.alwaysinline()
>   ret i32 %1
> }
>
> ; Function Attrs: alwaysinline inlinehint nounwind uwtable
> define internal i32 @f2.alwaysinline() #1 {
>   ret i32 7
> }
>
> ; Function Attrs: inlinehint nounwind uwtable
> define i32 @f2() #2 {
> entry:
>   %0 = musttail call i32 @f2.alwaysinline() #2
>   ret i32 %0
> }
>
> ; Function Attrs: nounwind uwtable
> define i32 @f3() #0 {
>   %1 = call i32 @f2.alwaysinline()
>   ret i32 %1
> }
>
> ; Function Attrs: alwaysinline nounwind uwtable
> define internal i32 @f0.alwaysinline() #3 {
>   ret i32 1
> }
>
> attributes #0 = { nounwind uwtable "disable-tail-calls"="false"
> "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
> "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
> "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
> "target-cpu"="x86-64" "target-features"="+sse,+sse2"
> "unsafe-fp-math"="false" "use-soft-float"="false" }
> attributes #1 = { alwaysinline inlinehint nounwind uwtable
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-nans-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="x86-64"
> "target-features"="+sse,+sse2" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
> attributes #2 = { inlinehint nounwind uwtable
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-nans-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="x86-64"
> "target-features"="+sse,+sse2" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
> attributes #3 = { alwaysinline nounwind uwtable
> "disable-tail-calls"="false" "less-precise-fpmad"="false"
> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
> "no-infs-fp-math"="false" "no-nans-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="x86-64"
> "target-features"="+sse,+sse2" "unsafe-fp-math"="false"
> "use-soft-float"="false" }
>
> !llvm.ident = !{!0}
>
> !0 = !{!"clang version 3.8.0 (http://llvm.org/git/clang.git
> 4c682cf50f928f82e286df97d10a3d1fcf68e1a1)
> (http://llvm.org/git/llvm.git
> 125be70dbf9784ef4fab69633afa067c1cceffc9)"}
> [hjl@gnu-mic-2 llvm-clang]$
> [hjl@gnu-mic-2 llvm-clang]$
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
> x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
> --check-prefix=CHECK-NO-OPTZNS
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c:26:26:
> error: expected string not found in input
> // CHECK-NO-OPTZNS-NEXT: entry:
>  ^
> :24:18: note: scanning from here
> define i32 @f3() #0 {
>  ^
> :29:12: note: possible intended match here
> ; Function Attrs: alwaysinline nounwind uwtable
>^
> [hjl@gnu-mic-2 llvm-clang]$
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread H.J. Lu via cfe-commits
On Fri, Sep 11, 2015 at 4:45 PM, Evgenii Stepanov  wrote:
> Does it say that there is no entry basic block? I.e. the output
> apparently looks like
>
> define void @h() #1 {
>   store void ()* @f1, void ()** @p, align 8
>
> Could you confirm it? Never seen this behavior.
>
> I'm going to revert the change due to this and also one broken gdb
> test (something wrong with debug info in the code that has been
> always-inlined twice).

I got

[hjl@gnu-mic-2 llvm-clang]$
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
; ModuleID = 
'/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

; Function Attrs: nounwind uwtable
define i32 @f1() #0 {
  %1 = call i32 @f0.alwaysinline()
  ret i32 %1
}

; Function Attrs: alwaysinline inlinehint nounwind uwtable
define internal i32 @f2.alwaysinline() #1 {
  ret i32 7
}

; Function Attrs: inlinehint nounwind uwtable
define i32 @f2() #2 {
entry:
  %0 = musttail call i32 @f2.alwaysinline() #2
  ret i32 %0
}

; Function Attrs: nounwind uwtable
define i32 @f3() #0 {
  %1 = call i32 @f2.alwaysinline()
  ret i32 %1
}

; Function Attrs: alwaysinline nounwind uwtable
define internal i32 @f0.alwaysinline() #3 {
  ret i32 1
}

attributes #0 = { nounwind uwtable "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
"target-cpu"="x86-64" "target-features"="+sse,+sse2"
"unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { alwaysinline inlinehint nounwind uwtable
"disable-tail-calls"="false" "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+sse,+sse2" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #2 = { inlinehint nounwind uwtable
"disable-tail-calls"="false" "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+sse,+sse2" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #3 = { alwaysinline nounwind uwtable
"disable-tail-calls"="false" "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+sse,+sse2" "unsafe-fp-math"="false"
"use-soft-float"="false" }

!llvm.ident = !{!0}

!0 = !{!"clang version 3.8.0 (http://llvm.org/git/clang.git
4c682cf50f928f82e286df97d10a3d1fcf68e1a1)
(http://llvm.org/git/llvm.git
125be70dbf9784ef4fab69633afa067c1cceffc9)"}
[hjl@gnu-mic-2 llvm-clang]$
[hjl@gnu-mic-2 llvm-clang]$
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
--check-prefix=CHECK-NO-OPTZNS
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c:26:26:
error: expected string not found in input
// CHECK-NO-OPTZNS-NEXT: entry:
 ^
:24:18: note: scanning from here
define i32 @f3() #0 {
 ^
:29:12: note: possible intended match here
; Function Attrs: alwaysinline nounwind uwtable
   ^
[hjl@gnu-mic-2 llvm-clang]$
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk accepted this revision.
vsk added a reviewer: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


http://reviews.llvm.org/D12684



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:543
@@ +542,3 @@
+  if (Fn->isUsedByMetadata())
+llvm::ValueAsMetadata::handleRAUW(Fn, StubFn);
+}

As the comment says.
W/o this, the debug info for .alwaysinline instructions is attached to the 
.alwaysinline function, which gets deleted before codegen, and we end up with 
DI as if it is just a declaration (no low/high pc, etc).



Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 34610.
eugenis added a comment.

Fixed the debug info problem.


Repository:
  rL LLVM

http://reviews.llvm.org/D12087

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/always-inline.c
  test/CodeGen/always_inline-unused.c
  test/CodeGen/always_inline-wrappers.c
  test/CodeGen/always_inline.c
  test/CodeGen/function-attributes.c
  test/CodeGen/pr9614.c
  test/CodeGenCXX/alwaysinline.cpp
  test/Frontend/optimization-remark-line-directive.c
  test/Frontend/optimization-remark.c
  test/Modules/cxx-irgen.cpp

Index: test/Modules/cxx-irgen.cpp
===
--- test/Modules/cxx-irgen.cpp
+++ test/Modules/cxx-irgen.cpp
@@ -26,14 +26,14 @@
   };
 }
 
-// CHECK-DAG: define available_externally hidden {{.*}}{{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
+// CHECK-DAG: define internal i32 @_ZN1SIiE1gEv.alwaysinline() #[[ALWAYS_INLINE:.*]] align
 int a = S::g();
 
 int b = h();
 
 // CHECK-DAG: define linkonce_odr {{.*}}{{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
 int c = min(1, 2);
-// CHECK: define available_externally {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+// CHECK-DAG: define internal {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv.alwaysinline() #[[ALWAYS_INLINE]] align
 
 namespace ImplicitSpecialMembers {
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
Index: test/Frontend/optimization-remark.c
===
--- test/Frontend/optimization-remark.c
+++ test/Frontend/optimization-remark.c
@@ -32,6 +32,8 @@
 // CHECK-NOT: !llvm.dbg.cu = !{
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+2 {{foo.alwaysinline should always be inlined}}
+// expected-remark@+1 {{foo.alwaysinline inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
 float foz(int x, int y) __attribute__((noinline));
@@ -45,7 +47,7 @@
 // expected-remark@+5 {{foz will not be inlined into bar}}
 // expected-remark@+4 {{foz should never be inlined}}
 // expected-remark@+3 {{foz will not be inlined into bar}}
-// expected-remark@+2 {{foo should always be inlined}}
-// expected-remark@+1 {{foo inlined into bar}}
+// expected-remark@+2 {{foo.alwaysinline should always be inlined}}
+// expected-remark@+1 {{foo.alwaysinline inlined into bar}}
   return foo(j, j - 2) * foz(j - 2, j);
 }
Index: test/Frontend/optimization-remark-line-directive.c
===
--- test/Frontend/optimization-remark-line-directive.c
+++ test/Frontend/optimization-remark-line-directive.c
@@ -5,8 +5,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -gline-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+1 {{foo.alwaysinline inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
-// expected-remark@+2 {{foo inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
+// expected-remark@+2 {{foo.alwaysinline inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
 #line 1230 "/bad/path/to/original.c"
 int bar(int j) { return foo(j, j - 2); }
Index: test/CodeGenCXX/alwaysinline.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alwaysinline.cpp
@@ -0,0 +1,68 @@
+// Test different kinds of alwaysinline *structor definitions.
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+struct A1 {
+  __attribute__((__always_inline__)) A1() {}
+  __attribute__((__always_inline__)) ~A1() {}
+};
+
+void g1() {
+  A1 a1;
+}
+
+struct A2 {
+  inline __attribute__((__always_inline__)) A2() {}
+  inline __attribute__((__always_inline__)) ~A2() {}
+};
+
+void g2() {
+  A2 a2;
+}
+
+struct A3 {
+  inline __attribute__((gnu_inline, __always_inline__)) A3() {}
+  inline __attribute__((gnu_inline, __always_inline__)) ~A3() {}
+};
+
+void g3() {
+  A3 a3;
+}
+
+// CHECK-DAG: define internal void @_ZN2A1C1Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI:[01-9]+]]
+// CHECK-DAG: define internal void @_ZN2A1C2Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define interna

Re: [PATCH] D12251: Analyzer: Calculate field offset correctly

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

Ping!


http://reviews.llvm.org/D12251



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


Re: [PATCH] D12381: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 34606.
xazax.hun added a comment.

- Rebased on the top of latest trunk (which contains patch #1 and patch #2 from 
my previous comments)


http://reviews.llvm.org/D12381

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Checkers/ObjCGenericsChecker.cpp
  test/Analysis/generics.m

Index: test/Analysis/generics.m
===
--- test/Analysis/generics.m
+++ test/Analysis/generics.m
@@ -435,7 +435,7 @@
 // CHECK:descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextincompatibleTypesErased
 // CHECK:   issue_hash2
@@ -545,7 +545,7 @@
 // CHECK:descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextincompatibleTypesErased
 // CHECK:   issue_hash3
@@ -689,7 +689,7 @@
 // CHECK:descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextincompatibleTypesErased
 // CHECK:   issue_hash5
@@ -939,7 +939,7 @@
 // CHECK:descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextcrossProceduralErasedTypes
 // CHECK:   issue_hash1
@@ -1049,7 +1049,7 @@
 // CHECK:descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextincompatibleTypesErasedReverseConversion
 // CHECK:   issue_hash2
@@ -1193,7 +1193,7 @@
 // CHECK:descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextincompatibleTypesErasedReverseConversion
 // CHECK:   issue_hash4
@@ -1303,7 +1303,7 @@
 // CHECK:descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextidErasedIncompatibleTypesReverseConversion
 // CHECK:   issue_hash2
@@ -1447,7 +1447,7 @@
 // CHECK:descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextidErasedIncompatibleTypesReverseConversion
 // CHECK:   issue_hash4
@@ -1591,7 +1591,7 @@
 // CHECK:descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextidErasedIncompatibleTypes
 // CHECK:   issue_hash2
@@ -1701,7 +1701,7 @@
 // CHECK:descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
 // CHECK:categoryCore Foundation/Objective-C
 // CHECK:typeGenerics
-// CHECK:check_namealpha.osx.cocoa.ObjCGenerics
+// CHECK:check_namecore.DynamicTypePropagation
 // CHECK:   issue_context_kindfunction
 // CHECK:   issue_contextidErasedIncompatibleTypes
 // CHEC

r247491 - Revert "Specify target triple in alwaysinline tests."

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Sep 11 18:48:37 2015
New Revision: 247491

URL: http://llvm.org/viewvc/llvm-project?rev=247491&view=rev
Log:
Revert "Specify target triple in alwaysinline tests."
Revert "Always_inline codegen rewrite."

Breaks gdb & lldb tests.
Breaks on Fedora 22 x86_64.

Removed:
cfe/trunk/test/CodeGen/always_inline-unused.c
cfe/trunk/test/CodeGen/always_inline-wrappers.c
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/always-inline.c
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/CodeGen/function-attributes.c
cfe/trunk/test/CodeGen/pr9614.c
cfe/trunk/test/Frontend/optimization-remark-line-directive.c
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/Modules/cxx-irgen.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=247491&r1=247490&r2=247491&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Sep 11 18:48:37 2015
@@ -109,9 +109,6 @@ bool CodeGenModule::TryEmitBaseDestructo
   D->getType()->getAs()->getCallConv())
 return true;
 
-  if (BaseD->hasAttr())
-return true;
-
   return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
   GlobalDecl(BaseD, Dtor_Base),
   false);
@@ -164,7 +161,14 @@ bool CodeGenModule::TryEmitDefinitionAsA
 
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
+ (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
+  !TargetDecl.getDecl()->hasAttr())) {
+// FIXME: An extern template instantiation will create functions with
+// linkage "AvailableExternally". In libc++, some classes also define
+// members with attribute "AlwaysInline" and expect no reference to
+// be generated. It is desirable to reenable this optimisation after
+// corresponding LLVM changes.
 Replacements[MangledName] = Aliasee;
 return false;
   }

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247491&r1=247490&r2=247491&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Sep 11 18:48:37 2015
@@ -1557,7 +1557,7 @@ void CodeGenFunction::EmitDestructorBody
 // -fapple-kext must inline any call to this dtor into
 // the caller's body.
 if (getLangOpts().AppleKext)
-  CGM.AddAlwaysInlineFunction(CurFn);
+  CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
 
 break;
   }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=247491&r1=247490&r2=247491&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Sep 11 18:48:37 2015
@@ -2114,7 +2114,7 @@ emitTaskPrivateMappingFunction(CodeGenMo
   ".omp_task_privates_map.", &CGM.getModule());
   CGM.SetLLVMFunctionAttributes(/*D=*/nullptr, TaskPrivatesMapFnInfo,
 TaskPrivatesMap);
-  CGM.AddAlwaysInlineFunction(TaskPrivatesMap);
+  TaskPrivatesMap->addFnAttr(llvm::Attribute::AlwaysInline);
   CodeGenFunction CGF(CGM);
   CGF.disableDebugInfo();
   CGF.StartFunction(GlobalDecl(), C.VoidTy, TaskPrivatesMap,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=247491&r1=247490&r2=247491&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Sep 11 18:48:37 2015
@@ -448,103 +448,6 @@ void CodeGenModule::Release() {
   EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
-
-  RewriteAlwaysInlineFunctions();
-}
-
-void CodeGenModule::AddAlwaysInlineFunction(llvm::Function *Fn) {
-  AlwaysInlineFunctions.push_back(Fn);
-}
-
-/// Find all uses of GV that are not direct calls or invokes.
-static void FindNonDirectCallUses(llvm::GlobalValue *GV,
-  llvm::SmallVectorImpl *Uses) {
-  llvm::GlobalValue::use_iterator UI = GV->use_begin(), E = GV->use_end();
-  for (; UI != E;) {
-llvm::Use &U = *UI;
-++UI;
-
-llvm::C

Re: [PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-09-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ExprConstant.cpp:165
@@ -159,1 +164,3 @@
 
+/// Indicator of whether the most-derived object is an array.
+bool MostDerivedIsArrayElement : 1;

array -> array element.


Comment at: lib/AST/ExprConstant.cpp:4457-4460
@@ -4434,1 +4456,6 @@
 
+// Because we set the Base to be the MemberExpr instead of E->getBase(), 
the
+// Offset should be from the MemberExpr instead of the MemberExpr's base.
+if (Result.InvalidBase)
+  Result.Offset = CharUnits::Zero();
+

I think you should bail out above, with the base set to the `MemberExpr` and 
with an empty designator, rather than applying a member designator on top of a 
base that already refers to the member (and then needing to undo the effect on 
the offset here).


Comment at: lib/AST/ExprConstant.cpp:6402
@@ +6401,3 @@
+  // that behaves this way.
+  if (End.InvalidBase && (Type & 1) != 0 &&
+  End.Designator.MostDerivedIsArrayElement &&

This only seems necessary when `Type` is 1; for type 3, returning 1 would be 
conservatively correct as a lower bound on the known-accessible storage, and is 
better than giving up here and evaluating the object size as 0.


Comment at: lib/AST/ExprConstant.cpp:6403-6404
@@ +6402,4 @@
+  if (End.InvalidBase && (Type & 1) != 0 &&
+  End.Designator.MostDerivedIsArrayElement &&
+  End.Designator.MostDerivedArraySize < 2) {
+// EM_FoldDesignator requires that all invalid bases be MemberExprs

Ideally, we should walk the designator and make sure that at each step we 
picked the last subobject (last array element, last field, ...) -- that is, we 
want to know that we're really looking at a trailing flexible array member, and 
not just a size-1 array in the middle of some object.

You should also check that the designator refers to the most-derived object 
(that is, that `Entries.size() == MostDerivedPathLength`), because given:

  struct A { char buffer[10]; };
  struct B : A {};
  struct C { B b[1]; } *c;
  int m = __builtin_object_size(c->b[0], 1);
  int n = __builtin_object_size((A*)c->b[0], 1);

... we should presumably compute `m == -1` but `n == 10`, because for `n` the 
`A` subobject of the `B` object is known to have size 10, even though we're 
looking at a base subobject of a size-1 trailing array.


http://reviews.llvm.org/D12821



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgenii Stepanov via cfe-commits
Does it say that there is no entry basic block? I.e. the output
apparently looks like

define void @h() #1 {
  store void ()* @f1, void ()** @p, align 8

Could you confirm it? Never seen this behavior.

I'm going to revert the change due to this and also one broken gdb
test (something wrong with debug info in the code that has been
always-inlined twice).



On Fri, Sep 11, 2015 at 4:24 PM, H.J. Lu  wrote:
> On Fri, Sep 11, 2015 at 1:31 PM, Evgeniy Stepanov via cfe-commits
>  wrote:
>> eugenis closed this revision.
>> eugenis added a comment.
>>
>> r247465, thanks for the review!
>>
>
> On Fedora 22/x86-64, I got
>
> FAIL: Clang :: CodeGen/always_inline.c (3049 of 26132)
>  TEST 'Clang :: CodeGen/always_inline.c' FAILED
> 
> Script:
> --
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
> x86_64-pc-linux-gnu -emit-llvm -S -o -
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
> x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
> --check-prefix=CHECK-NO-OPTZNS
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c:26:26:
> error: expected string not found in input
> // CHECK-NO-OPTZNS-NEXT: entry:
>  ^
> :24:18: note: scanning from here
> define i32 @f3() #0 {
>  ^
> :29:12: note: possible intended match here
> ; Function Attrs: alwaysinline nounwind uwtable
>^
>
> --
>
> 
> Testing: 0 ..
> FAIL: Clang :: CodeGen/always_inline-wrappers.c (3052 of 26132)
>  TEST 'Clang :: CodeGen/always_inline-wrappers.c'
> FAILED 
> Script:
> --
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
> -internal-isystem
> /export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
> -nostdsysteminc -disable-llvm-optzns -emit-llvm
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> -o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> --check-prefix=CHECK --check-prefix=CHECK-INLINE
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
> -internal-isystem
> /export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
> -nostdsysteminc -disable-llvm-optzns -emit-llvm
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> -o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> --check-prefix=CHECK-USE
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
> -internal-isystem
> /export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
> -nostdsysteminc -disable-llvm-optzns -fno-inline -emit-llvm
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> -o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> --check-prefix=CHECK
> /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
> -internal-isystem
> /export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
> -nostdsysteminc -disable-llvm-optzns -fno-inline -emit-llvm
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> -o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
> --check-prefix=CHECK-USE
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c:85:20:
> error: expected string not found in input
> // CHECK-USE-NEXT: entry:
>^
> :47:18: note: scanning from here
> define void @g() #1 {
>  ^
> :58:12: note: possible intended match here
> ; Function Attrs: nounwind
>^
> /export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c:96:20:
> error: CHECK-USE-NEXT: is not on the line after the previous match
> // CHECK-USE-NEXT: entry:
>^
> :79:1: note: 'next' match was here
> entry:
> ^
> :59:17: note: previous match ended here
> define void @h() #1 {
> ^
> :60:1: note: non-matching line after previous match is here
>  store void ()* @f1, void ()** @p, align 8
> ^
>
> --
>
>
> --
> H.J.
_

Re: r246877 - Increase accuracy of __builtin_object_size.

2015-09-11 Thread George Burgess IV via cfe-commits
Proposed fix: http://reviews.llvm.org/D12821

On Fri, Sep 11, 2015 at 1:44 PM, George Burgess IV <
george.burgess...@gmail.com> wrote:

> > It might be reasonable for __builtin_object_size(..., 2) to give up if
> [...]
>
> That sounds like the best overall solution to me, as well. Working on a
> fix now.
>
> On Fri, Sep 11, 2015 at 1:22 PM, Richard Smith 
> wrote:
>
>> On Fri, Sep 11, 2015 at 12:15 PM, Mikhail Zolotukhin via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hi George,
>>>
>>> After this commit we started to trap on the following case:
>>>
>>> #include 
>>> typedef struct {
>>>   int n;
>>>   char key[1];
>>> } obj_t;
>>>
>>> char *str = "hello";
>>>
>>> int main() {
>>>   obj_t* p = (obj_t*)malloc(strlen(str) + 1 + sizeof(int));
>>>   strcpy(p->key, str);
>>>   free(p);
>>>   return 0;
>>> }
>>>
>>> As far as I understand, this might be a common pattern in pre-C99
>>> codebase, and it fails when compiled with -D_FORTIFY_SOURCE=2. Is there a
>>> way we could fix it in clang, or the only fix is to use less strict
>>> FORTIFY_SOURCE level?
>>>
>>
>> It might be reasonable for __builtin_object_size(..., 2) to give up if:
>>
>> 1) we lost track of the complete object, and
>> 2) the designator refers to the final subobject of the currently-known
>> complete object, and
>> 3) that subobject is either a flexible array member or an array of bound
>> 0 or 1.
>>
>> Then we'd leave it to IR generation to do the llvm.object.size(..., i1
>> false) dance, and in this case to grab the size of the malloc (minus the
>> offset of 'key').
>>
>> Thanks,
>>> Michael
>>>
>>> On Sep 4, 2015, at 2:28 PM, George Burgess IV via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>> Author: gbiv
>>> Date: Fri Sep  4 16:28:13 2015
>>> New Revision: 246877
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=246877&view=rev
>>> Log:
>>> Increase accuracy of __builtin_object_size.
>>>
>>> Improvements:
>>>
>>> - For all types, we would give up in a case such as:
>>>__builtin_object_size((char*)&foo, N);
>>>  even if we could provide an answer to
>>>__builtin_object_size(&foo, N);
>>>  We now provide the same answer for both of the above examples in all
>>>  cases.
>>>
>>> - For type=1|3, we now support subobjects with unknown bases, as long
>>>  as the designator is valid.
>>>
>>> Thanks to Richard Smith for the review + design planning.
>>>
>>> Review: http://reviews.llvm.org/D12169
>>>
>>>
>>> Modified:
>>>cfe/trunk/lib/AST/ExprConstant.cpp
>>>cfe/trunk/test/CodeGen/object-size.c
>>>
>>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=246877&r1=246876&r2=246877&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Sep  4 16:28:13 2015
>>> @@ -492,7 +492,11 @@ namespace {
>>>   /// optimizer if we don't constant fold them here, but in an
>>> unevaluated
>>>   /// context we try to fold them immediately since the optimizer
>>> never
>>>   /// gets a chance to look at it.
>>> -  EM_PotentialConstantExpressionUnevaluated
>>> +  EM_PotentialConstantExpressionUnevaluated,
>>> +
>>> +  /// Evaluate as a constant expression. Continue evaluating if we
>>> find a
>>> +  /// MemberExpr with a base that can't be evaluated.
>>> +  EM_DesignatorFold,
>>> } EvalMode;
>>>
>>> /// Are we checking whether the expression is a potential constant
>>> @@ -595,6 +599,7 @@ namespace {
>>>   case EM_PotentialConstantExpression:
>>>   case EM_ConstantExpressionUnevaluated:
>>>   case EM_PotentialConstantExpressionUnevaluated:
>>> +  case EM_DesignatorFold:
>>> HasActiveDiagnostic = false;
>>> return OptionalDiagnostic();
>>>   }
>>> @@ -674,6 +679,7 @@ namespace {
>>>   case EM_ConstantExpression:
>>>   case EM_ConstantExpressionUnevaluated:
>>>   case EM_ConstantFold:
>>> +  case EM_DesignatorFold:
>>> return false;
>>>   }
>>>   llvm_unreachable("Missed EvalMode case");
>>> @@ -702,10 +708,15 @@ namespace {
>>>   case EM_ConstantExpressionUnevaluated:
>>>   case EM_ConstantFold:
>>>   case EM_IgnoreSideEffects:
>>> +  case EM_DesignatorFold:
>>> return false;
>>>   }
>>>   llvm_unreachable("Missed EvalMode case");
>>> }
>>> +
>>> +bool allowInvalidBaseExpr() const {
>>> +  return EvalMode == EM_DesignatorFold;
>>> +}
>>>   };
>>>
>>>   /// Object used to treat all foldable expressions as constant
>>> expressions.
>>> @@ -736,6 +747,21 @@ namespace {
>>> }
>>>   };
>>>
>>> +  /// RAII object used to treat the current evaluation as the correct
>>> pointer
>>> +  /// offset fold for the current EvalMode
>>> +  struct FoldOffsetRAII {
>>> +EvalInfo &Info;
>>> +EvalInfo::EvaluationMode OldMode;
>>> 

[PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-09-11 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added subscribers: cfe-commits, mzolotukhin.

In C, a common idiom is:

```
struct Foo { int a; char cs[1] };
struct Foo *F = (struct Foo *)malloc(sizeof(Foo) + strlen(SomeString));
strcpy(F->cs, SomeString);
```

Currently, __builtin_object_size does not allow for this, which breaks some 
existing code. This patch makes us answer conservatively in Clang if the 
following conditions are met:

- Type is 1 or 3
- The Base is invalid/can't be determined
- The subobject we're referencing is the last subobject in the struct
- The subobject we're referencing is an array with 0 or 1 elements (for 0 
elements, both `char foo[]` and `char foo[0]` syntaxes are supported)

http://reviews.llvm.org/D12821

Files:
  lib/AST/ExprConstant.cpp
  test/CodeGen/object-size.c

Index: test/CodeGen/object-size.c
===
--- test/CodeGen/object-size.c
+++ test/CodeGen/object-size.c
@@ -391,3 +391,63 @@
   gi = __builtin_object_size(addCasts(&t[1].v[1]), 3);
 #undef addCasts
 }
+
+struct DynStructVar {
+  char fst[16];
+  char snd[];
+};
+
+struct DynStruct0 {
+  char fst[16];
+  char snd[0];
+};
+
+struct DynStruct1 {
+  char fst[16];
+  char snd[1];
+};
+
+struct StaticStruct {
+  char fst[16];
+  char snd[2];
+};
+
+// CHECK: @test29
+void test29(struct DynStructVar *dv, struct DynStruct0 *d0,
+struct DynStruct1 *d1, struct StaticStruct *ss) {
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(dv->snd, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(dv->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(dv->snd, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(dv->snd, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d0->snd, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d0->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(d0->snd, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(d0->snd, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d1->snd, 0);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(d1->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(d1->snd, 2);
+  // CHECK: store i32 0
+  gi = __builtin_object_size(d1->snd, 3);
+
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  gi = __builtin_object_size(ss->snd, 0);
+  // CHECK: store i32 2
+  gi = __builtin_object_size(ss->snd, 1);
+  // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 true)
+  gi = __builtin_object_size(ss->snd, 2);
+  // CHECK: store i32 2
+  gi = __builtin_object_size(ss->snd, 3);
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -114,7 +114,8 @@
   static
   unsigned findMostDerivedSubobject(ASTContext &Ctx, QualType Base,
 ArrayRef Path,
-uint64_t &ArraySize, QualType &Type) {
+uint64_t &ArraySize, QualType &Type,
+bool &IsArray) {
 unsigned MostDerivedLength = 0;
 Type = Base;
 for (unsigned I = 0, N = Path.size(); I != N; ++I) {
@@ -124,18 +125,22 @@
 Type = CAT->getElementType();
 ArraySize = CAT->getSize().getZExtValue();
 MostDerivedLength = I + 1;
+IsArray = true;
   } else if (Type->isAnyComplexType()) {
 const ComplexType *CT = Type->castAs();
 Type = CT->getElementType();
 ArraySize = 2;
 MostDerivedLength = I + 1;
+IsArray = true;
   } else if (const FieldDecl *FD = getAsField(Path[I])) {
 Type = FD->getType();
 ArraySize = 0;
 MostDerivedLength = I + 1;
+IsArray = false;
   } else {
 // Path[I] describes a base class.
 ArraySize = 0;
+IsArray = false;
   }
 }
 return MostDerivedLength;
@@ -157,12 +162,17 @@
 /// Is this a pointer one past the end of an object?
 bool IsOnePastTheEnd : 1;
 
+/// Indicator of whether the most-derived object is an array.
+bool MostDerivedIsArrayElement : 1;
+
 /// The length of the path to the most-derived object of which this is a
 /// subobject.
-unsigned MostDerivedPathLength : 30;
+unsigned MostDerivedPathLength : 29;
 
-/// The size of the array of which the most-derived object is an element, or
-/// 0 if the most-derived object

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread H.J. Lu via cfe-commits
On Fri, Sep 11, 2015 at 1:31 PM, Evgeniy Stepanov via cfe-commits
 wrote:
> eugenis closed this revision.
> eugenis added a comment.
>
> r247465, thanks for the review!
>

On Fedora 22/x86-64, I got

FAIL: Clang :: CodeGen/always_inline.c (3049 of 26132)
 TEST 'Clang :: CodeGen/always_inline.c' FAILED

Script:
--
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
x86_64-pc-linux-gnu -emit-llvm -S -o -
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang  -target
x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns -emit-llvm -S -o -
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c |
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c
--check-prefix=CHECK-NO-OPTZNS
--
Exit Code: 1

Command Output (stderr):
--
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline.c:26:26:
error: expected string not found in input
// CHECK-NO-OPTZNS-NEXT: entry:
 ^
:24:18: note: scanning from here
define i32 @f3() #0 {
 ^
:29:12: note: possible intended match here
; Function Attrs: alwaysinline nounwind uwtable
   ^

--


Testing: 0 ..
FAIL: Clang :: CodeGen/always_inline-wrappers.c (3052 of 26132)
 TEST 'Clang :: CodeGen/always_inline-wrappers.c'
FAILED 
Script:
--
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
-internal-isystem
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
-nostdsysteminc -disable-llvm-optzns -emit-llvm
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
-o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
--check-prefix=CHECK --check-prefix=CHECK-INLINE
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
-internal-isystem
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
-nostdsysteminc -disable-llvm-optzns -emit-llvm
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
-o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
--check-prefix=CHECK-USE
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
-internal-isystem
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
-nostdsysteminc -disable-llvm-optzns -fno-inline -emit-llvm
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
-o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
--check-prefix=CHECK
/export/build/gnu/llvm-clang/build-x86_64-linux/./bin/clang -cc1
-internal-isystem
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/../lib/clang/3.8.0/include
-nostdsysteminc -disable-llvm-optzns -fno-inline -emit-llvm
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
-o - | /export/build/gnu/llvm-clang/build-x86_64-linux/./bin/FileCheck
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c
--check-prefix=CHECK-USE
--
Exit Code: 1

Command Output (stderr):
--
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c:85:20:
error: expected string not found in input
// CHECK-USE-NEXT: entry:
   ^
:47:18: note: scanning from here
define void @g() #1 {
 ^
:58:12: note: possible intended match here
; Function Attrs: nounwind
   ^
/export/gnu/import/git/llvm/tools/clang/test/CodeGen/always_inline-wrappers.c:96:20:
error: CHECK-USE-NEXT: is not on the line after the previous match
// CHECK-USE-NEXT: entry:
   ^
:79:1: note: 'next' match was here
entry:
^
:59:17: note: previous match ended here
define void @h() #1 {
^
:60:1: note: non-matching line after previous match is here
 store void ()* @f1, void ()** @p, align 8
^

--


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


Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

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


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:321
@@ +320,3 @@
+// sink, we assume that a client requesting a transition to a state that is
+// the same as the predecessor state has made a mistake. We return the
+// predecessor and rather than cache out.

dcoughlin wrote:
> jordan_rose wrote:
> > What does "has made a mistake" mean? What is the mistake and how will they 
> > discover it?
> The mistake this guard protects against is adding a transition from a state 
> to itself, which would normally cause a cache out. My understanding is that 
> the whole point of this guard is to silently swallow that mistake. I found 
> that surprising, which is why I added the comment.
Should we add an assert here? I wonder if/how much it will get triggered.


http://reviews.llvm.org/D12780



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


Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

2015-09-11 Thread Devin Coughlin via cfe-commits
dcoughlin marked 3 inline comments as done.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:229
@@ -228,2 +228,3 @@
+  /// checkers should use generateErrorNode() instead.
   ExplodedNode *generateSink(ProgramStateRef State = nullptr,
  ExplodedNode *Pred = nullptr,

zaks.anna wrote:
> Most likely there are not much uses of this left and to avoid confusion we 
> could require State and Pred inputs. What do you think?
There are 7 uses left. Requiring State and Pred seems like the right thing to 
me. I will change it.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:321
@@ +320,3 @@
+// sink, we assume that a client requesting a transition to a state that is
+// the same as the predecessor state has made a mistake. We return the
+// predecessor and rather than cache out.

jordan_rose wrote:
> What does "has made a mistake" mean? What is the mistake and how will they 
> discover it?
The mistake this guard protects against is adding a transition from a state to 
itself, which would normally cause a cache out. My understanding is that the 
whole point of this guard is to silently swallow that mistake. I found that 
surprising, which is why I added the comment.


Comment at: lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp:53
@@ -52,3 +52,3 @@
 
-  if (ExplodedNode *N = C.addTransition()) {
+  if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
 if (!BT)

zaks.anna wrote:
> jordan_rose wrote:
> > zaks.anna wrote:
> > > Can this ever fail? In some cases we just assume it won't in others we 
> > > tests..
> > > 
> > > Maybe it only fails when we cache out?
> > It does fail when we cache out, and I think we can still cache out if Pred 
> > has a different tag the second time around.
> There some instances in this patch where we do not check if the returned node 
> is null. We should be consistent. 
Ok, I'll go through and add checks where they are missing.


http://reviews.llvm.org/D12780



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


[clang-tools-extra] r247489 - [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.

2015-09-11 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Sep 11 17:54:44 2015
New Revision: 247489

URL: http://llvm.org/viewvc/llvm-project?rev=247489&view=rev
Log:
[clang-tidy] misc-sizeof-container: whitelist std::bitset<>.

It's fine to use sizeof on std::bitset<>, since it doesn't have any external
storage, everything's inside.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp?rev=247489&r1=247488&r2=247489&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp Fri Sep 11 
17:54:44 2015
@@ -36,6 +36,7 @@ void SizeofContainerCheck::registerMatch
   expr(unless(isInTemplateInstantiation()),
expr(sizeOfExpr(has(expr(hasType(hasCanonicalType(hasDeclaration(
 recordDecl(matchesName("^(::std::|::string)"),
+   unless(hasName("::std::bitset")),
hasMethod(methodDecl(hasName("size"), 
isPublic(),
 isConst()))
.bind("sizeof"),

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp?rev=247489&r1=247488&r2=247489&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-sizeof-container.cpp Fri Sep 
11 17:54:44 2015
@@ -19,6 +19,12 @@ struct vector {
   size_t size() const;
 };
 
+// std::bitset<> is not a container. sizeof() is reasonable for it.
+template 
+struct bitset {
+  size_t size() const;
+};
+
 class fake_container1 {
   size_t size() const; // non-public
 };
@@ -78,9 +84,11 @@ void f() {
 
   std::fake_container1 f1;
   std::fake_container2 f2;
+  std::bitset<7> bs;
 
   a = sizeof(f1);
   a = sizeof(f2);
+  a = sizeof(bs);
 
 
   std::string arr[3];


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


r247488 - Add new test file missing from r247486.

2015-09-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep 11 17:54:01 2015
New Revision: 247488

URL: http://llvm.org/viewvc/llvm-project?rev=247488&view=rev
Log:
Add new test file missing from r247486.

Added:
cfe/trunk/test/Modules/Inputs/template-default-args/d.h

Added: cfe/trunk/test/Modules/Inputs/template-default-args/d.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/d.h?rev=247488&view=auto
==
--- cfe/trunk/test/Modules/Inputs/template-default-args/d.h (added)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/d.h Fri Sep 11 17:54:01 
2015
@@ -0,0 +1,6 @@
+BEGIN
+template struct L;
+struct FriendL {
+  template friend struct L;
+};
+END


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


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

2015-09-11 Thread Dmitri Gribenko via cfe-commits
gribozavr added inline comments.


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/Checkers.td:524
@@ +523,3 @@
+def MPIChecker : Checker<"MPI-Checker">,
+  HelpText<"Checks MPI code written in C">,
+  DescFile<"MPIChecker.cpp">;

Does it only works with C code, or does it work with C++ code that uses C 
bindings for MPI?  I think it is safe to describe it as "Checks MPI code".


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:1
@@ +1,2 @@
+//===-- Container.hpp - convenience templates for containers *- C++ 
-*-===//
+//

The file should use the `.h` extension (here and everywhere else in the patch).


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:10-11
@@ +9,4 @@
+///
+/// \file
+/// This file defines convenience templates for C++ container class usage.
+///

This file re-invents a lot of APIs that are currently under review by the C++ 
committee under the Ranges effort.  I think most of the wrappers are more or 
less trivial and should use STL directly, or the wrappers should match exactly 
the currently proposed STL APIs.


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:15
@@ +14,3 @@
+
+#ifndef CONTAINER_HPP_XM1FDRVJ
+#define CONTAINER_HPP_XM1FDRVJ

Please look at other files in Clang and follow the same include guard style 
(here and everywhere else in the patch).


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:22
@@ +21,3 @@
+
+/// \brief Check if given element is contained.
+///

Please drop `\brief` everywhere.


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:24-25
@@ +23,4 @@
+///
+/// \param container
+/// \param elementToCheck
+///

If there is no description for the parameter, please drop `\param`.


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:27
@@ +26,3 @@
+///
+/// \returns true if element contained
+template 

This is the gist of the documentation.  I think the doc comment should be just 
one line, `/// Returns true if \p container contains \p element.`


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:29
@@ +28,3 @@
+template 
+bool isContained(const T &container, const E &elementToCheck) {
+  return std::find(container.begin(), container.end(), elementToCheck) !=

I'd prefer the parameter to be called just `Element`.  The function name should 
probably be just `contains`.

Also, please follow the LLVM naming style everywhere (variable names start with 
a capital letter).


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:39
@@ +38,3 @@
+///
+/// \returns true if element that matched predicate is contained
+template 

`/// Returns true if \p container contains an element for which \p predicate 
returns true.`



Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:46-50
@@ +45,7 @@
+
+/// \brief Deletes first appearance of given element.
+///
+/// \param container
+/// \param elementToErase
+template  void erase(T &container, E &elementToErase) {
+  auto it = std::find(container.begin(), container.end(), elementToErase);

Same comments as above apply to this function as well as the rest of the patch. 
 I wouldn't be duplicating them over and over again, please scan the whole 
patch.


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:67
@@ +66,3 @@
+
+/// \brief Deletes first appearance of given pointer.
+///

Why is this a separate overload?


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:88-109
@@ +87,24 @@
+
+/// \brief Deletes element at given index.
+///
+/// \param container
+/// \param index
+template  void eraseIndex(T &container, size_t idx) {
+  container.erase(container.begin() + idx);
+}
+
+/// \brief Sort with default criterion.
+///
+/// \param container
+template  void sort(T &container) {
+  std::sort(container.begin(), container.end());
+}
+
+/// \brief Sort by given predicate.
+///
+/// \param container
+/// \param predicate
+template  void sortPred(T &container, P predicate) {
+  std::sort(container.begin(), container.end(), predicate);
+}
+

I question the value of such trivial wrappers.


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.hpp:22
@@ +21,3 @@
+
+namespace mpi {
+

The namespace should be nested under `clang`, we shouldn't be claiming the 
top-level `mpi` namespace.


Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.hpp:45-48
@@ +44,

r247486 - [modules] When picking one of two template declarations as a lookup result,

2015-09-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep 11 17:39:35 2015
New Revision: 247486

URL: http://llvm.org/viewvc/llvm-project?rev=247486&view=rev
Log:
[modules] When picking one of two template declarations as a lookup result,
it's not sufficient to prefer the declaration with more default arguments, or
the one that's visible; they might both be visible, but one of them might have
a visible default argument where the other has a hidden default argument.

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/template-default-args/a.h
cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap
cfe/trunk/test/Modules/template-default-args.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=247486&r1=247485&r2=247486&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Sep 11 17:39:35 2015
@@ -387,6 +387,8 @@ static bool isPreferredLookupResult(Sema
 // If D has more default arguments, it is preferred.
 if (DMin != EMin)
   return DMin < EMin;
+// FIXME: When we track visibility for default function arguments, check
+// that we pick the declaration with more visible default arguments.
   }
 
   // Pick the template with more default template arguments.
@@ -394,9 +396,22 @@ static bool isPreferredLookupResult(Sema
 auto *ETD = cast(EUnderlying);
 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
-// If D has more default arguments, it is preferred.
+// If D has more default arguments, it is preferred. Note that default
+// arguments (and their visibility) is monotonically increasing across the
+// redeclaration chain, so this is a quick proxy for "is more recent".
 if (DMin != EMin)
   return DMin < EMin;
+// If D has more *visible* default arguments, it is preferred. Note, an
+// earlier default argument being visible does not imply that a later
+// default argument is visible, so we can't just check the first one.
+for (unsigned I = DMin, N = DTD->getTemplateParameters()->size();
+I != N; ++I) {
+  if (!S.hasVisibleDefaultArgument(
+  ETD->getTemplateParameters()->getParam(I)) &&
+  S.hasVisibleDefaultArgument(
+  DTD->getTemplateParameters()->getParam(I)))
+return true;
+}
   }
 
   // For most kinds of declaration, it doesn't really matter which one we pick.

Modified: cfe/trunk/test/Modules/Inputs/template-default-args/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/a.h?rev=247486&r1=247485&r2=247486&view=diff
==
--- cfe/trunk/test/Modules/Inputs/template-default-args/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/a.h Fri Sep 11 17:39:35 
2015
@@ -9,4 +9,8 @@ template struct H;
 template struct J {};
 template struct J;
 struct K : J<> {};
+template struct L;
+struct FriendL {
+  template friend struct L;
+};
 END

Modified: cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap?rev=247486&r1=247485&r2=247486&view=diff
==
--- cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap 
(original)
+++ cfe/trunk/test/Modules/Inputs/template-default-args/module.modulemap Fri 
Sep 11 17:39:35 2015
@@ -3,3 +3,6 @@ module X {
   module B { header "b.h" }
   module C { header "c.h" }
 }
+module Y {
+  module D { header "d.h" }
+}

Modified: cfe/trunk/test/Modules/template-default-args.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/template-default-args.cpp?rev=247486&r1=247485&r2=247486&view=diff
==
--- cfe/trunk/test/Modules/template-default-args.cpp (original)
+++ cfe/trunk/test/Modules/template-default-args.cpp Fri Sep 11 17:39:35 2015
@@ -13,6 +13,7 @@ template struct A {};
@@ -41,4 +42,5 @@ G<> g; // expected-error {{default argum
 H<> h; // expected-error {{default argument of 'H' must be imported from 
module 'X.A' before it is required}}
 // expected-note@a.h:8 {{default argument declared here}}
 I<> i;
+L<> *l;
 END


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


[clang-tools-extra] r247485 - [clang-tidy] Fix minor issues in the testing script.

2015-09-11 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Sep 11 17:38:26 2015
New Revision: 247485

URL: http://llvm.org/viewvc/llvm-project?rev=247485&view=rev
Log:
[clang-tidy] Fix minor issues in the testing script.

Modified:
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=247485&r1=247484&r2=247485&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Fri Sep 11 
17:38:26 2015
@@ -41,13 +41,14 @@ def main():
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
-
+
   check_name = sys.argv[2]
   temp_file_name = sys.argv[3] + extension
 
   clang_tidy_extra_args = sys.argv[4:]
   if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' else 
['--']
+clang_tidy_extra_args = ['--', '--std=c++11'] if extension == '.cpp' \
+   else ['--']
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
@@ -97,7 +98,7 @@ def main():
'-check-prefix=CHECK-FIXES', '-strict-whitespace'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
-  print('FileCheck failed:\n' + e.output)
+  print('FileCheck failed:\n' + e.output.decode())
   raise
 
   if has_check_messages:
@@ -110,7 +111,7 @@ def main():
'-implicit-check-not={{warning|error}}:'],
   stderr=subprocess.STDOUT)
 except subprocess.CalledProcessError as e:
-  print('FileCheck failed:\n' + e.output)
+  print('FileCheck failed:\n' + e.output.decode())
   raise
 
 if __name__ == '__main__':


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


Re: [PATCH] D12759: [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stlcontainers.

2015-09-11 Thread Alexander Kornienko via cfe-commits
Indeed. But this has been fixed before I could get to it.

On Thu, Sep 10, 2015 at 10:47 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> aaron.ballman added a comment.
>
> This appears to have broken one of the bots:
>
> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/15065
>
>
> http://reviews.llvm.org/D12759
>
>
>
> ___
> 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


r247482 - When comparing two block captures for layout, don't crash

2015-09-11 Thread John McCall via cfe-commits
Author: rjmccall
Date: Fri Sep 11 17:00:51 2015
New Revision: 247482

URL: http://llvm.org/viewvc/llvm-project?rev=247482&view=rev
Log:
When comparing two block captures for layout, don't crash
if they have the same alignment and one was 'this'.

Fixes PR24780.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/test/CodeGenObjCXX/blocks.mm

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=247482&r1=247481&r2=247482&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Sep 11 17:00:51 2015
@@ -221,7 +221,7 @@ namespace {
   return left.Alignment > right.Alignment;
 
 auto getPrefOrder = [](const BlockLayoutChunk &chunk) {
-  if (chunk.Capture->isByRef())
+  if (chunk.Capture && chunk.Capture->isByRef())
 return 1;
   if (chunk.Lifetime == Qualifiers::OCL_Strong)
 return 0;

Modified: cfe/trunk/test/CodeGenObjCXX/blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/blocks.mm?rev=247482&r1=247481&r2=247482&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/blocks.mm Fri Sep 11 17:00:51 2015
@@ -8,6 +8,8 @@
 @end
 
 void f(int (^bl)(B* b));
+void takeBlock(void (^block)());
+void useValues(...);
 
 // Test1
 void g() {
@@ -59,3 +61,10 @@ void gun() {
 return foovar;
   };
 }
+
+// PR24780
+class CaptureThisAndAnotherPointer {
+  void test(void *ptr) {
+takeBlock(^{ useValues(ptr, this); });
+  }
+};


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


r247477 - Let selector-expr-lvalue.mm actually test something.

2015-09-11 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Sep 11 16:24:40 2015
New Revision: 247477

URL: http://llvm.org/viewvc/llvm-project?rev=247477&view=rev
Log:
Let selector-expr-lvalue.mm actually test something.

I accidentally introduced a bug locally, and noticed that none of the tests
caught it. No longer!

Modified:
cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm

Modified: cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm?rev=247477&r1=247476&r2=247477&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/selector-expr-lvalue.mm Fri Sep 11 16:24:40 
2015
@@ -1,16 +1,23 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5  -emit-llvm -o - %s 
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 
-fobjc-runtime=macosx-fragile-10.5  -emit-llvm -o - %s | FileCheck %s
 // PR7390
 
-@interface NSObject {}
-- (void)respondsToSelector:(const SEL&)s : (SEL*)s1;
-- (void) setPriority:(int)p;
+// CHECK: @[[setprioname:[^ ]*]] = {{.*}}"setPriority:
+// CHECK-NEXT: @[[setpriosel:[^ ]*]] = {{.*}}getelementptr{{.*}}[[setprioname]]
+@interface NSObject
+- (void)respondsToSelector:(const SEL &)s ps:(SEL *)s1;
+- (void)setPriority:(int)p;
 - (void)Meth;
 @end
 
-@implementation  NSObject
+@implementation NSObject
+
+// CHECK-LABEL: define internal void @"\01-[NSObject Meth]"(
 - (void)Meth {
-[self respondsToSelector:@selector(setPriority:) : 
&@selector(setPriority:)];
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, 
i8*, i8**, i8**)*){{.*}}, i8** @[[setpriosel]])
+  [self respondsToSelector:@selector(setPriority:) 
ps:&@selector(setPriority:)];
+}
+- (void)setPriority:(int)p {
+}
+- (void)respondsToSelector:(const SEL &)s ps:(SEL *)s1 {
 }
-- (void) setPriority:(int)p{}
-- (void)respondsToSelector:(const SEL&)s : (SEL*)s1 {}
 @end


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


r247476 - [Static Analyzer] Properly cash the configuration option for lambda support.

2015-09-11 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 11 16:19:39 2015
New Revision: 247476

URL: http://llvm.org/viewvc/llvm-project?rev=247476&view=rev
Log:
[Static Analyzer] Properly cash the configuration option for lambda support. 

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=247476&r1=247475&r2=247476&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Sep 11 16:19:39 
2015
@@ -334,5 +334,7 @@ bool AnalyzerOptions::shouldConditionali
 }
 
 bool AnalyzerOptions::shouldInlineLambdas() {
-  return getBooleanOption("inline-lambdas", /*Default=*/true);
+  if (!InlineLambdas.hasValue())
+InlineLambdas = getBooleanOption("inline-lambdas", /*Default=*/true);
+  return InlineLambdas.getValue();
 }


___
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-11 Thread Zhengkai Wu via cfe-commits
zhengkai updated the summary for this revision.
zhengkai updated this revision to Diff 34588.

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
+  // CHECK: {{.*}}:58:5: warning: expression result unused
  

r247474 - [Shave]: pass -isystem dirs and "-Wa," args to moviAsm

2015-09-11 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Fri Sep 11 16:13:46 2015
New Revision: 247474

URL: http://llvm.org/viewvc/llvm-project?rev=247474&view=rev
Log:
[Shave]: pass -isystem dirs and "-Wa," args to moviAsm

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/shave-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=247474&r1=247473&r2=247474&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 11 16:13:46 2015
@@ -9716,13 +9716,14 @@ void tools::SHAVE::Assembler::ConstructJ
   assert(Output.getType() == types::TY_Object);
 
   CmdArgs.push_back("-no6thSlotCompression");
-  CmdArgs.push_back("-cv:myriad2"); // Chip Version ?
+  CmdArgs.push_back("-cv:myriad2"); // Chip Version
   CmdArgs.push_back("-noSPrefixing");
   CmdArgs.push_back("-a"); // Mystery option.
-  for (auto Arg : Args.filtered(options::OPT_I)) {
-Arg->claim();
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, 
options::OPT_Xassembler);
+  for (const Arg *A : Args.filtered(options::OPT_I, options::OPT_isystem)) {
+A->claim();
 CmdArgs.push_back(
-Args.MakeArgString(std::string("-i:") + Arg->getValue(0)));
+Args.MakeArgString(std::string("-i:") + A->getValue(0)));
   }
   CmdArgs.push_back("-elf"); // Output format.
   CmdArgs.push_back(II.getFilename());

Modified: cfe/trunk/test/Driver/shave-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/shave-toolchain.c?rev=247474&r1=247473&r2=247474&view=diff
==
--- cfe/trunk/test/Driver/shave-toolchain.c (original)
+++ cfe/trunk/test/Driver/shave-toolchain.c Fri Sep 11 16:13:46 2015
@@ -8,10 +8,11 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave -c -### %s -Icommon 2>&1 \
+// RUN: %clang -target shave -c -### %s -isystem somewhere -Icommon 
-Wa,-yippee 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
-// MOVICOMPILE: moviCompile" "-DMYRIAD2" "-mcpu=myriad2" "-S" "-I" "common"
-// MOVICOMPILE: moviAsm" "-no6thSlotCompression" "-cv:myriad2" "-noSPrefixing" 
"-a" "-i:common" "-elf"
+// MOVICOMPILE: moviCompile" "-DMYRIAD2" "-mcpu=myriad2" "-S" "-isystem" 
"somewhere" "-I" "common"
+// MOVICOMPILE: moviAsm" "-no6thSlotCompression" "-cv:myriad2" "-noSPrefixing" 
"-a"
+// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
 
 // RUN: %clang -target shave -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES


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


r247473 - Specify target triple in alwaysinline tests.

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Sep 11 16:10:12 2015
New Revision: 247473

URL: http://llvm.org/viewvc/llvm-project?rev=247473&view=rev
Log:
Specify target triple in alwaysinline tests.

This should fix the tests on Windows (failing due to mangling differencies).

Modified:
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp

Modified: cfe/trunk/test/CodeGen/always_inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/always_inline.c?rev=247473&r1=247472&r2=247473&view=diff
==
--- cfe/trunk/test/CodeGen/always_inline.c (original)
+++ cfe/trunk/test/CodeGen/always_inline.c Fri Sep 11 16:10:12 2015
@@ -1,5 +1,5 @@
-// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
-// RUN: %clang -mllvm -disable-llvm-optzns -emit-llvm -S -o - %s | FileCheck 
%s --check-prefix=CHECK-NO-OPTZNS
+// RUN: %clang -target x86_64-pc-linux-gnu -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -target x86_64-pc-linux-gnu -mllvm -disable-llvm-optzns 
-emit-llvm -S -o - %s | FileCheck %s --check-prefix=CHECK-NO-OPTZNS
 
 //static int f0() { 
 static int __attribute__((always_inline)) f0() { 

Modified: cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alwaysinline.cpp?rev=247473&r1=247472&r2=247473&view=diff
==
--- cfe/trunk/test/CodeGenCXX/alwaysinline.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/alwaysinline.cpp Fri Sep 11 16:10:12 2015
@@ -1,10 +1,10 @@
 // Test different kinds of alwaysinline *structor definitions.
 
-// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK
-// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s 
--check-prefix=CHECK-CALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm 
%s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-llvm-optzns -emit-llvm 
%s -o - | FileCheck %s --check-prefix=CHECK-CALL
 
-// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o 
- | FileCheck %s --check-prefix=CHECK
-// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o 
- | FileCheck %s --check-prefix=CHECK-CALL
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases 
-disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -mconstructor-aliases 
-disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
 
 struct A1 {
   __attribute__((__always_inline__)) A1() {}


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


Re: r247464 - [MS ABI] Select an inheritance model in template arguments

2015-09-11 Thread David Majnemer via cfe-commits
On Fri, Sep 11, 2015 at 1:23 PM, Richard Smith 
wrote:

> On Fri, Sep 11, 2015 at 1:18 PM, David Majnemer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: majnemer
>> Date: Fri Sep 11 15:18:09 2015
>> New Revision: 247464
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247464&view=rev
>> Log:
>> [MS ABI] Select an inheritance model in template arguments
>>
>> We used to only select an inheritance model if the pointer to member was
>> nullptr.  Instead, select a model regardless of the member pointer's
>> value.
>>
>> N.B.  This bug was exposed by making member pointers report true for
>> isIncompleteType but has been latent since the member pointer scheme's
>> inception.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247464&r1=247463&r2=247464&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep 11 15:18:09 2015
>> @@ -4222,7 +4222,11 @@ isNullPointerValueTemplateArgument(Sema
>> QualType ParamType, Expr *Arg) {
>>if (Arg->isValueDependent() || Arg->isTypeDependent())
>>  return NPV_NotNullPointer;
>> -
>> +
>> +  if (ParamType->isMemberPointerType())
>> +if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
>> +  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
>>
>
> It seems simpler to unconditionally require the type to be complete.
>

Done in r247472.


>
>
>> +
>>if (!S.getLangOpts().CPlusPlus11)
>>  return NPV_NotNullPointer;
>>
>> @@ -4670,8 +4674,6 @@ static bool CheckTemplateArgumentPointer
>>  S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
>>  Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),
>>   /*isNullPtr*/true);
>> -if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
>> -  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
>>  return false;
>>case NPV_NotNullPointer:
>>  break;
>>
>> Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247464&r1=247463&r2=247464&view=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Fri Sep
>> 11 15:18:09 2015
>> @@ -768,3 +768,14 @@ bool g(int J::*&p, int J::*&q) { return
>>  // CHECK-LABEL: @"\01?h@ReferenceToMPTWithIncompleteClass@@YAHAAPQK@1
>> @H@Z"(
>>  int h(int K::*&p) { return k->*p; }
>>  }
>> +
>> +namespace PMFInTemplateArgument {
>> +template 
>> +void JSMethod();
>> +class A {
>> +  int printd(int);
>> +  void printd();
>> +};
>> +void A::printd() { JSMethod(); }
>> +// CHECK-LABEL: @"\01??$JSMethod@VA@PMFInTemplateArgument@@$1?printd@12
>> @AAEHH@Z@PMFInTemplateArgument@@YAXXZ"(
>> +}
>>
>>
>> ___
>> 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


r247472 - Simplify logic introduced in r247464.

2015-09-11 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Fri Sep 11 15:55:29 2015
New Revision: 247472

URL: http://llvm.org/viewvc/llvm-project?rev=247472&view=rev
Log:
Simplify logic introduced in r247464.

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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247472&r1=247471&r2=247472&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep 11 15:55:29 2015
@@ -4223,9 +4223,9 @@ isNullPointerValueTemplateArgument(Sema
   if (Arg->isValueDependent() || Arg->isTypeDependent())
 return NPV_NotNullPointer;
 
-  if (ParamType->isMemberPointerType())
-if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
-  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
+  if (S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0))
+llvm_unreachable(
+"Incomplete parameter type in isNullPointerValueTemplateArgument!");
 
   if (!S.getLangOpts().CPlusPlus11)
 return NPV_NotNullPointer;


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


[PATCH] D12818: [Static Analyzer] Relaxing a caching out related assert.

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, jordan_rose, krememek.
xazax.hun added a subscriber: cfe-commits.

During the development of the nullability checkers I hit this assert several 
times. However it is very hard to reproduce it with a minimal example, and hard 
to come up with a test case. I could not identify any issue with the checkers 
themselves, and I think it is ok to cache out at this point of execution, when 
the node was created by a checker. 

http://reviews.llvm.org/D12818

Files:
  lib/StaticAnalyzer/Core/ExprEngineObjC.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -186,8 +186,11 @@
 
 // Generate a transition to non-Nil state.
 if (notNilState != State) {
+  bool HasTag = Pred->getLocation().getTag();
   Pred = Bldr.generateNode(ME, Pred, notNilState);
-  assert(Pred && "Should have cached out already!");
+  assert((Pred || HasTag) && "Should have cached out already!");
+  if (!Pred)
+continue;
 }
   }
 } else {


Index: lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -186,8 +186,11 @@
 
 // Generate a transition to non-Nil state.
 if (notNilState != State) {
+  bool HasTag = Pred->getLocation().getTag();
   Pred = Bldr.generateNode(ME, Pred, notNilState);
-  assert(Pred && "Should have cached out already!");
+  assert((Pred || HasTag) && "Should have cached out already!");
+  if (!Pred)
+continue;
 }
   }
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2015-09-11 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: chandlerc, echristo.
beanz added a subscriber: cfe-commits.

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.

http://reviews.llvm.org/D12817

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

Index: cmake/caches/README.txt
===
--- /dev/null
+++ 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: cmake/caches/Apple-stage2.cmake
===
--- /dev/null
+++ 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: cmake/caches/Apple-stage1.cmake
===
--- /dev/null
+++ 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: cmake/caches/README.txt
===
--- /dev/null
+++ 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: cmake/caches/Apple-stage2.cmake
===
--- /dev/null
+++ 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 

Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-09-11 Thread Антон Ярцев via cfe-commits
ayartsev updated this revision to Diff 34583.
ayartsev added a comment.

Updated the patch after r246978. Please review!


http://reviews.llvm.org/D9040

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/malloc.c

Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -263,21 +263,21 @@
 
 void CheckUseZeroAllocated7() {
   int *p = realloc(0, 0);
-  *p = 1; //TODO: warn about use of zero-allocated memory
+  *p = 1; // expected-warning {{Use of zero-allocated memory}}
   free(p);
 }
 
 void CheckUseZeroAllocated8() {
   int *p = malloc(8);
   int *q = realloc(p, 0);
-  *q = 1; //TODO: warn about use of zero-allocated memory
+  *q = 1; // expected-warning {{Use of zero-allocated memory}}
   free(q);
 }
 
 void CheckUseZeroAllocated9() {
   int *p = realloc(0, 0);
   int *q = realloc(p, 0);
-  *q = 1; //TODO: warn about use of zero-allocated memory
+  *q = 1; // expected-warning {{Use of zero-allocated memory}}
   free(q);
 }
 
@@ -307,6 +307,34 @@
   free(p);
 }
 
+void CheckUseZeroReallocatedPathNoWarn(_Bool b) {
+  int s = 0;
+  if (b)
+s= 10;
+
+  char *p = malloc(8);
+  char *q = realloc(p, s);
+
+  if (b)
+*q = 1; // no warning
+
+  free(q);
+}
+
+void CheckUseZeroReallocatedPathWarn(_Bool b) {
+  int s = 10;
+  if (b)
+s= 0;
+
+  char *p = malloc(8);
+  char *q = realloc(p, s);
+
+  if (b)
+*q = 1; // expected-warning {{Use of zero-allocated memory}}
+
+  free(q);
+}
+
 // This case tests that storing malloc'ed memory to a static variable which is
 // then returned is not leaked.  In the absence of known contracts for functions
 // or inter-procedural analysis, this is a conservative answer.
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -508,6 +508,7 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(RegionState, SymbolRef, RefState)
 REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, ReallocPair)
+REGISTER_SET_WITH_PROGRAMSTATE(ReallocSizeZeroSymbols, SymbolRef)
 
 // A map from the freed symbol to the symbol representing the return value of
 // the free function.
@@ -891,15 +892,19 @@
   return State;
 
 const RefState *RS = State->get(Sym);
-if (!RS)
-  return State; // TODO: change to assert(RS); after realloc() will
-// guarantee have a RegionState attached.
-
-if (!RS->isAllocated())
-  return State;
-
-return TrueState->set(Sym,
-   RefState::getAllocatedOfSizeZero(RS));
+if (RS) {
+  if (RS->isAllocated())
+return TrueState->set(Sym,
+  RefState::getAllocatedOfSizeZero(RS));
+  else
+return State;
+} else {
+  // Case of zero-size realloc. Historically 'realloc(ptr, 0)' is treated as
+  // 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not
+  // tracked. Add zero-reallocated Sym to the state to catch references
+  // to zero-allocated memory.
+  return TrueState->add(Sym);
+}
   }
 
   // Assume the value is non-zero going forward.
@@ -1487,6 +1492,9 @@
 Optional
 MallocChecker::getCheckIfTracked(CheckerContext &C, SymbolRef Sym,
  bool IsALeakCheck) const {
+  if (C.getState()->contains(Sym))
+return CK_MallocChecker;
+
   const RefState *RS = C.getState()->get(Sym);
   assert(RS);
   return getCheckIfTracked(RS->getAllocationFamily(), IsALeakCheck);
@@ -1929,7 +1937,7 @@
   }
 
   if (PrtIsNull && SizeIsZero)
-return nullptr;
+return State;
 
   // Get the from and to pointer symbols as in toPtr = realloc(fromPtr, size).
   assert(!PrtIsNull);
@@ -2291,10 +2299,14 @@
 void MallocChecker::checkUseZeroAllocated(SymbolRef Sym, CheckerContext &C,
   const Stmt *S) const {
   assert(Sym);
-  const RefState *RS = C.getState()->get(Sym);
 
-  if (RS && RS->isAllocatedOfSizeZero())
-ReportUseZeroAllocated(C, RS->getStmt()->getSourceRange(), Sym);
+  if (const RefState *RS = C.getState()->get(Sym)) {
+if (RS->isAllocatedOfSizeZero())
+  ReportUseZeroAllocated(C, RS->getStmt()->getSourceRange(), Sym);
+  }
+  else if (C.getState()->contains(Sym)) {
+ReportUseZeroAllocated(C, S->getSourceRange(), Sym);
+  }
 }
 
 bool MallocChecker::checkDoubleDelete(SymbolRef Sym, CheckerContext &C) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r246877 - Increase accuracy of __builtin_object_size.

2015-09-11 Thread George Burgess IV via cfe-commits
> It might be reasonable for __builtin_object_size(..., 2) to give up if
[...]

That sounds like the best overall solution to me, as well. Working on a fix
now.

On Fri, Sep 11, 2015 at 1:22 PM, Richard Smith 
wrote:

> On Fri, Sep 11, 2015 at 12:15 PM, Mikhail Zolotukhin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi George,
>>
>> After this commit we started to trap on the following case:
>>
>> #include 
>> typedef struct {
>>   int n;
>>   char key[1];
>> } obj_t;
>>
>> char *str = "hello";
>>
>> int main() {
>>   obj_t* p = (obj_t*)malloc(strlen(str) + 1 + sizeof(int));
>>   strcpy(p->key, str);
>>   free(p);
>>   return 0;
>> }
>>
>> As far as I understand, this might be a common pattern in pre-C99
>> codebase, and it fails when compiled with -D_FORTIFY_SOURCE=2. Is there a
>> way we could fix it in clang, or the only fix is to use less strict
>> FORTIFY_SOURCE level?
>>
>
> It might be reasonable for __builtin_object_size(..., 2) to give up if:
>
> 1) we lost track of the complete object, and
> 2) the designator refers to the final subobject of the currently-known
> complete object, and
> 3) that subobject is either a flexible array member or an array of bound 0
> or 1.
>
> Then we'd leave it to IR generation to do the llvm.object.size(..., i1
> false) dance, and in this case to grab the size of the malloc (minus the
> offset of 'key').
>
> Thanks,
>> Michael
>>
>> On Sep 4, 2015, at 2:28 PM, George Burgess IV via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: gbiv
>> Date: Fri Sep  4 16:28:13 2015
>> New Revision: 246877
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246877&view=rev
>> Log:
>> Increase accuracy of __builtin_object_size.
>>
>> Improvements:
>>
>> - For all types, we would give up in a case such as:
>>__builtin_object_size((char*)&foo, N);
>>  even if we could provide an answer to
>>__builtin_object_size(&foo, N);
>>  We now provide the same answer for both of the above examples in all
>>  cases.
>>
>> - For type=1|3, we now support subobjects with unknown bases, as long
>>  as the designator is valid.
>>
>> Thanks to Richard Smith for the review + design planning.
>>
>> Review: http://reviews.llvm.org/D12169
>>
>>
>> Modified:
>>cfe/trunk/lib/AST/ExprConstant.cpp
>>cfe/trunk/test/CodeGen/object-size.c
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=246877&r1=246876&r2=246877&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Sep  4 16:28:13 2015
>> @@ -492,7 +492,11 @@ namespace {
>>   /// optimizer if we don't constant fold them here, but in an
>> unevaluated
>>   /// context we try to fold them immediately since the optimizer
>> never
>>   /// gets a chance to look at it.
>> -  EM_PotentialConstantExpressionUnevaluated
>> +  EM_PotentialConstantExpressionUnevaluated,
>> +
>> +  /// Evaluate as a constant expression. Continue evaluating if we
>> find a
>> +  /// MemberExpr with a base that can't be evaluated.
>> +  EM_DesignatorFold,
>> } EvalMode;
>>
>> /// Are we checking whether the expression is a potential constant
>> @@ -595,6 +599,7 @@ namespace {
>>   case EM_PotentialConstantExpression:
>>   case EM_ConstantExpressionUnevaluated:
>>   case EM_PotentialConstantExpressionUnevaluated:
>> +  case EM_DesignatorFold:
>> HasActiveDiagnostic = false;
>> return OptionalDiagnostic();
>>   }
>> @@ -674,6 +679,7 @@ namespace {
>>   case EM_ConstantExpression:
>>   case EM_ConstantExpressionUnevaluated:
>>   case EM_ConstantFold:
>> +  case EM_DesignatorFold:
>> return false;
>>   }
>>   llvm_unreachable("Missed EvalMode case");
>> @@ -702,10 +708,15 @@ namespace {
>>   case EM_ConstantExpressionUnevaluated:
>>   case EM_ConstantFold:
>>   case EM_IgnoreSideEffects:
>> +  case EM_DesignatorFold:
>> return false;
>>   }
>>   llvm_unreachable("Missed EvalMode case");
>> }
>> +
>> +bool allowInvalidBaseExpr() const {
>> +  return EvalMode == EM_DesignatorFold;
>> +}
>>   };
>>
>>   /// Object used to treat all foldable expressions as constant
>> expressions.
>> @@ -736,6 +747,21 @@ namespace {
>> }
>>   };
>>
>> +  /// RAII object used to treat the current evaluation as the correct
>> pointer
>> +  /// offset fold for the current EvalMode
>> +  struct FoldOffsetRAII {
>> +EvalInfo &Info;
>> +EvalInfo::EvaluationMode OldMode;
>> +explicit FoldOffsetRAII(EvalInfo &Info, bool Subobject)
>> +: Info(Info), OldMode(Info.EvalMode) {
>> +  if (!Info.checkingPotentialConstantExpression())
>> +Info.EvalMode = Subobject ? EvalInfo::EM_DesignatorFold
>> +  : EvalInfo::EM_C

Re: PATCH: Expose the 'file' that is associated with a compile database command

2015-09-11 Thread Argyrios Kyrtzidis via cfe-commits
In r247468, thanks for reviewing!

> On Sep 11, 2015, at 10:24 AM, Manuel Klimek via cfe-commits 
>  wrote:
> 
> Ok, looked at the original patch again, and if we're fixing the 
> FixedCompilationDatabase to only insert the file when it actually produces a 
> CompileCommand it seems to be fine.
> 
> On Fri, Sep 11, 2015 at 6:32 PM Argyrios Kyrtzidis  > wrote:
>> On Sep 11, 2015, at 12:21 AM, Manuel Klimek > > wrote:
>> 
>> On Thu, Sep 10, 2015 at 8:36 PM Argyrios Kyrtzidis > > wrote:
>>> On Sep 10, 2015, at 1:48 AM, Manuel Klimek >> > wrote:
>>> 
>>> @@ -179,11 +185,13 @@ public:
>>>/// \param Directory The base directory used in the 
>>> FixedCompilationDatabase.
>>>static FixedCompilationDatabase *loadFromCommandLine(int &Argc,
>>> const char *const 
>>> *Argv,
>>> -   Twine Directory = 
>>> ".");
>>> +   Twine Directory = 
>>> ".",
>>> +   Twine File = 
>>> Twine());
>>>  
>>> A fixed compilation database returns the same command lines for all files, 
>>> thus having a file in the function seems strange.
>> 
>> Ah ok, thanks for clarifying.
>> 
>>> 
>>> What exactly is the use case? So far, the compilation database has been 
>>> designed for 2 use cases:
>>> 1. for a file, get the compile commands; the user already knows the file, 
>>> no need to get the file
>>> 2. get all compile commands; for that, we have the getAllFiles() method, so 
>>> a user can get all known files (for compilation databases that support 
>>> that), and then get the compile command line.
>> 
>> It’s #2, I want to get all compile commands. But it seems really strange to 
>> me that the ‘file’ starts as a property of the compile command in the json 
>> file but then it gets dropped and I need to do work to re-associate the 
>> files with the compile commands again.
>> 
>> The JSON file format is one possible implementation for the 
>> compilation-database interface. The FixedCompilationDatabase is another one, 
>> that doesn't have any information on files.
>>  
>> I need to get a list of all the files and then for each one do a lookup to 
>> get the associated commands. I then have to maintain this association 
>> myself, passing a command along with its file separately or the structure 
>> that keeps track of the association.
>> 
>> It seems simpler to me to include the file that was associated with the 
>> command (if the compilation database supports that) along with the command, 
>> is there a downside I’m missing ?
>> 
>> Well, to me, it's a design question - if it also makes sense to have a 
>> CompileCommand without a file associated with it, putting the file in there, 
>> while convenient, is a design smell.
> 
> It can be optional to communicate that it may not be there. Note that, IMO, 
> having multiple files and compile commands for them is the overwhelmingly 
> most common use of the compilation database.
> 
>> That said, I'm happy to be convinced that I'm wrong :) I guess I don't see 
>> yet that keeping track of the files outside is more than one line of extra 
>> code.
> 
> Not sure what one line this is, I have to declare a map and then populate it, 
> no ? And to do it in c-index-test it would take way more that one line.
> But it is also beyond populating a map, this has an effect on APIs using a 
> CompileCommand. For example:
> 
>   void doSomethingWithCompileCommand(const CompileCommand &cmd); 
> 
> Ah it would be useful to know the file that this command was associated with:
> 
>   void doSomethingWithCompileCommand(const CompileCommand &cmd, StringRef 
> filename); 
> 
> What do I have now ? This is a function taking a command and a string for the 
> filename separately.
> Is this flexibility useful ? Does it make sense to pass any filename there ? 
> No there’s only one filename that the command was associated with so this 
> ‘flexibility’ only increases the complexity of using the function. And this 
> can propagate to other function’s callees.
> This seems like a design smell to me.
> 
>> 
>> Cheers,
>> /Manuel
>>  
>> 
>>> 
>>> Thoughts?
>>> /Manuel
>>> 
>>> On Wed, Sep 9, 2015 at 9:36 PM Argyrios Kyrtzidis >> > wrote:
>>> Hi,
>>> 
>>> The attached patch exposes the ‘file’ entry in a compilation database 
>>> command, via the CompileCommand structure.
> ___
> 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


r247468 - [tooling] In CompileCommand, Expose the 'file' that was associated with the command.

2015-09-11 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Sep 11 15:43:05 2015
New Revision: 247468

URL: http://llvm.org/viewvc/llvm-project?rev=247468&view=rev
Log:
[tooling] In CompileCommand, Expose the 'file' that was associated with the 
command.

Modified:
cfe/trunk/include/clang-c/CXCompilationDatabase.h
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
cfe/trunk/tools/libclang/CXCompilationDatabase.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/CXCompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/CXCompilationDatabase.h?rev=247468&r1=247467&r2=247468&view=diff
==
--- cfe/trunk/include/clang-c/CXCompilationDatabase.h (original)
+++ cfe/trunk/include/clang-c/CXCompilationDatabase.h Fri Sep 11 15:43:05 2015
@@ -126,6 +126,12 @@ CINDEX_LINKAGE CXString
 clang_CompileCommand_getDirectory(CXCompileCommand);
 
 /**
+ * \brief Get the filename associated with the CompileCommand.
+ */
+CINDEX_LINKAGE CXString
+clang_CompileCommand_getFilename(CXCompileCommand);
+
+/**
  * \brief Get the number of arguments in the compiler invocation.
  *
  */

Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=247468&r1=247467&r2=247468&view=diff
==
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Fri Sep 11 15:43:05 
2015
@@ -42,12 +42,18 @@ namespace tooling {
 /// \brief Specifies the working directory and command of a compilation.
 struct CompileCommand {
   CompileCommand() {}
-  CompileCommand(Twine Directory, std::vector CommandLine)
-  : Directory(Directory.str()), CommandLine(std::move(CommandLine)) {}
+  CompileCommand(Twine Directory, Twine Filename,
+ std::vector CommandLine)
+  : Directory(Directory.str()),
+Filename(Filename.str()),
+CommandLine(std::move(CommandLine)) {}
 
   /// \brief The working directory the command was executed from.
   std::string Directory;
 
+  /// The source file associated with the command.
+  std::string Filename;
+
   /// \brief The command line that was executed.
   std::vector CommandLine;
 

Modified: cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h?rev=247468&r1=247467&r2=247468&view=diff
==
--- cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/JSONCompilationDatabase.h Fri Sep 11 
15:43:05 2015
@@ -99,13 +99,14 @@ private:
   /// failed.
   bool parse(std::string &ErrorMessage);
 
-  // Tuple (directory, commandline) where 'commandline' points to the
+  // Tuple (directory, filename, commandline) where 'commandline' points to the
   // corresponding scalar nodes in the YAML stream.
   // If the command line contains a single argument, it is a shell-escaped
   // command line.
   // Otherwise, each entry in the command line vector is a literal
   // argument to the compiler.
-  typedef std::pair> CompileCommandRef;
 
   /// \brief Converts the given array of CompileCommandRefs to CompileCommands.

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=247468&r1=247467&r2=247468&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Fri Sep 11 15:43:05 2015
@@ -299,13 +299,15 @@ FixedCompilationDatabase(Twine Directory
   std::vector ToolCommandLine(1, "clang-tool");
   ToolCommandLine.insert(ToolCommandLine.end(),
  CommandLine.begin(), CommandLine.end());
-  CompileCommands.emplace_back(Directory, std::move(ToolCommandLine));
+  CompileCommands.emplace_back(Directory, StringRef(),
+   std::move(ToolCommandLine));
 }
 
 std::vector
 FixedCompilationDatabase::getCompileCommands(StringRef FilePath) const {
   std::vector Result(CompileCommands);
   Result[0].CommandLine.push_back(FilePath);
+  Result[0].Filename = FilePath;
   return Result;
 }
 

Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=247468&r1=247467&r2=247468&view=diff
==
--- cfe/trunk/lib/Tooling/JSONCompilation

r247467 - [CMake] [Darwin] Add support for building bootstrap builds with -flto

2015-09-11 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 11 15:42:57 2015
New Revision: 247467

URL: http://llvm.org/viewvc/llvm-project?rev=247467&view=rev
Log:
[CMake] [Darwin] Add support for building bootstrap builds with -flto

When building with LTO the bootstrap builds need to depend on libLTO, llvm-ar, 
and llvm-ranlib, which all need to be passed into the bootstrap build. This 
functionality only works on Darwin.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=247467&r1=247466&r2=247467&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 11 15:42:57 2015
@@ -588,12 +588,21 @@ if (CLANG_ENABLE_BOOTSTRAP)
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/)
 
+  # If on Darwin we need to make bootstrap depend on LTO and pass
+  # DARWIN_LTO_LIBRARY so that -flto will work using the just-built compiler
+  if(APPLE)
+set(LTO_DEP LTO llvm-ar llvm-ranlib)
+set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${CMAKE_BINARY_DIR}/lib/libLTO.dylib)
+set(LTO_AR -DCMAKE_AR=${CMAKE_BINARY_DIR}/bin/llvm-ar)
+set(LTO_RANLIB -DCMAKE_RANLIB=${CMAKE_BINARY_DIR}/bin/llvm-ranlib)
+  endif()
+
   add_custom_target(bootstrap-clear
 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
 )
   add_custom_command(
 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
-DEPENDS clang
+DEPENDS clang ${LTO_DEP}
 COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
 COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
 COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
@@ -602,7 +611,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 )
 
   ExternalProject_Add(bootstrap
-DEPENDS clang
+DEPENDS clang ${LTO_DEP}
 PREFIX bootstrap
 SOURCE_DIR ${CMAKE_SOURCE_DIR}
 STAMP_DIR ${STAMP_DIR}
@@ -615,6 +624,8 @@ if (CLANG_ENABLE_BOOTSTRAP)
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
 -DCMAKE_CXX_COMPILER=${CMAKE_BINARY_DIR}/bin/clang++
 -DCMAKE_C_COMPILER=${CMAKE_BINARY_DIR}/bin/clang
+-DCMAKE_ASM_COMPILER=${CMAKE_BINARY_DIR}/bin/clang
+${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
 ${cmake_3_4_USES_TERMINAL_OPTIONS}


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


r247466 - [analyzer] Improve behavior if Clang not found.

2015-09-11 Thread Anton Yartsev via cfe-commits
Author: ayartsev
Date: Fri Sep 11 15:41:09 2015
New Revision: 247466

URL: http://llvm.org/viewvc/llvm-project?rev=247466&view=rev
Log:
[analyzer] Improve behavior if Clang not found.

- Eliminate 'No such file or directory at scan-build line ...' error if 
'$RealBin/bin/clang' or '$RealBin/clang' directory does not exist.
- Eliminate 'Use of uninitialized value $Clang in concatenation (.) or string 
at scan-build line ...' error if help is displayed while $Clang was not found.

Modified:
cfe/trunk/tools/scan-build/scan-build

Modified: cfe/trunk/tools/scan-build/scan-build
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=247466&r1=247465&r2=247466&view=diff
==
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Fri Sep 11 15:41:09 2015
@@ -1258,39 +1258,40 @@ LOADING CHECKERS:
  -load-plugin [plugin library]
 ENDTEXT
 
-  # Query clang for list of checkers that are enabled.
-
-  # create a list to load the plugins via the 'Xclang' command line
-  # argument
-  my @PluginLoadCommandline_xclang;
-  foreach my $param ( @{$Options{PluginsToLoad}} ) {
-push ( @PluginLoadCommandline_xclang, "-Xclang" );
-push ( @PluginLoadCommandline_xclang, "-load" );
-push ( @PluginLoadCommandline_xclang, "-Xclang" );
-push ( @PluginLoadCommandline_xclang, $param );
-  }
+  if (defined $Clang && -x $Clang) {
+# Query clang for list of checkers that are enabled.
 
-  my %EnabledCheckers;
-  foreach my $lang ("c", "objective-c", "objective-c++", "c++") {
-my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, 
"--analyze", "-x", $lang, "-", "-###", "2>&1", "|");
-open(PS, $ExecLine);
-while () {
-  foreach my $val (split /\s+/) {
-$val =~ s/\"//g;
-if ($val =~ /-analyzer-checker\=([^\s]+)/) {
-  $EnabledCheckers{$1} = 1;
+# create a list to load the plugins via the 'Xclang' command line
+# argument
+my @PluginLoadCommandline_xclang;
+foreach my $param ( @{$Options{PluginsToLoad}} ) {
+  push ( @PluginLoadCommandline_xclang, "-Xclang" );
+  push ( @PluginLoadCommandline_xclang, "-load" );
+  push ( @PluginLoadCommandline_xclang, "-Xclang" );
+  push ( @PluginLoadCommandline_xclang, $param );
+}
+
+my %EnabledCheckers;
+foreach my $lang ("c", "objective-c", "objective-c++", "c++") {
+  my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, 
"--analyze", "-x", $lang, "-", "-###", "2>&1", "|");
+  open(PS, $ExecLine);
+  while () {
+foreach my $val (split /\s+/) {
+  $val =~ s/\"//g;
+  if ($val =~ /-analyzer-checker\=([^\s]+)/) {
+$EnabledCheckers{$1} = 1;
+  }
 }
   }
 }
-  }
 
-  # Query clang for complete list of checkers.
-  my @PluginLoadCommandline;
-  foreach my $param ( @{$Options{PluginsToLoad}} ) {
-push ( @PluginLoadCommandline, "-load" );
-push ( @PluginLoadCommandline, $param );
-  }
-  if (defined $Clang && -x $Clang) {
+# Query clang for complete list of checkers.
+my @PluginLoadCommandline;
+foreach my $param ( @{$Options{PluginsToLoad}} ) {
+  push ( @PluginLoadCommandline, "-load" );
+  push ( @PluginLoadCommandline, $param );
+}
+
 my $ExecLine = join(' ', qq/"$Clang"/, "-cc1", @PluginLoadCommandline, 
"-analyzer-checker-help", "2>&1", "|");
 open(PS, $ExecLine);
 my $foundCheckers = 0;
@@ -1634,6 +1635,7 @@ if (!@ARGV) {
 }
 
 ProcessArgs(\@ARGV);
+# All arguments are now shifted from @ARGV. The rest is a build command, if 
any.
 
 if (!@ARGV and !$RequestDisplayHelp) {
   ErrorDiag("No build command specified.\n\n");
@@ -1642,9 +1644,9 @@ if (!@ARGV and !$RequestDisplayHelp) {
 
 # Find 'clang'
 if (!defined $Options{AnalyzerDiscoveryMethod}) {
-  $Clang = Cwd::realpath("$RealBin/bin/clang");
+  $Clang = Cwd::realpath("$RealBin/bin/clang") if (-d "$RealBin/bin/clang");
   if (!defined $Clang || ! -x $Clang) {
-$Clang = Cwd::realpath("$RealBin/clang");
+$Clang = Cwd::realpath("$RealBin/clang") if (-d "$RealBin/clang");
   }
   if (!defined $Clang || ! -x $Clang) {
 if (!$RequestDisplayHelp && !$ForceDisplayHelp) {


___
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-11 Thread Aaron Ballman via cfe-commits
On Fri, Sep 11, 2015 at 4:30 PM, Richard Smith  wrote:
> I don't think CXXRecordDecl is an anachronism, so much as an implementation
> detail; it makes sense to use a smaller class when in C mode, as we don't
> need most of the features and complexity that CXXRecordDecl brings with it.
> But... as a user of clang matchers, I don't think I'd want to care about the
> difference, and it'd be more convenient if I could nest (say) a hasMethod
> matcher within a recordDecl matcher, since it's completely obvious what that
> should mean. If I have a matcher that says:
>
>   recordDecl(or(hasMethod(...), hasField(...)))
>
> I would expect that to work in both C and C++ (and the only way it could
> match in C would be on a record with the specified field, since the
> hasMethod matcher would always fail).

Okay, so then it sounds like we want recordDecl to *mean* RecordDecl,
but we want the traversal and narrowing matchers that currently take a
CXXRecordDecl to instead take a RecordDecl and handle the CXX part
transparently? This means we would not need to add a cxxRecordDecl()
matcher, but could still access CXX-only functionality (like access
control, base classes, etc) through recordDecl()?

~Aaron

>
> On Fri, Sep 11, 2015 at 6:30 AM, Manuel Klimek  wrote:
>>
>> Richard! We need an informed opinion :D
>>
>> On Fri, Sep 11, 2015 at 3:07 PM Aaron Ballman 
>> wrote:
>>>
>>> Ping?
>>>
>>> On Tue, Sep 8, 2015 at 9:26 AM, Manuel Klimek  wrote:
>>> > On Tue, Sep 8, 2015 at 3:23 PM Aaron Ballman 
>>> > wrote:
>>> >>
>>> >> On Tue, Sep 8, 2015 at 9:18 AM, Manuel Klimek 
>>> >> wrote:
>>> >> > On Tue, Sep 8, 2015 at 2:23 PM Aaron Ballman
>>> >> > 
>>> >> > wrote:
>>> >> >>
>>> >> >> On Tue, Sep 8, 2015 at 5:40 AM, Manuel Klimek 
>>> >> >> wrote:
>>> >> >> > Yea, we had that discussion a few times, and I can never remember
>>> >> >> > why
>>> >> >> > we
>>> >> >> > ended up in the state we're in.
>>> >> >> > We definitely had a time where we switched to just using the
>>> >> >> > exact
>>> >> >> > same
>>> >> >> > name
>>> >> >> > as the node's class name for the matchers.
>>> >> >> > I *think* we didn't do it for cxxRecordDecl, because Richard said
>>> >> >> > that's
>>> >> >> > a
>>> >> >> > relic we should get rid of anyway, but I'm not sure.
>>> >> >>
>>> >> >> FWIW, I think the state we're in is the worst of all worlds. It's
>>> >> >> not
>>> >> >> intuitive that recordDecl() doesn't match a struct in C mode, and
>>> >> >> as
>>> >> >> it stands, there is no way to match a struct or union declaration
>>> >> >> in C
>>> >> >> at all.
>>> >> >
>>> >> >
>>> >> > Agreed. Best intentions. Worst possible outcome. That's software
>>> >> > development
>>> >> > :)
>>> >> >
>>> >> >> >
>>> >> >> > On Fri, Sep 4, 2015 at 8:32 PM Aaron Ballman
>>> >> >> > 
>>> >> >> > wrote:
>>> >> >> >>
>>> >> >> >> It turns out that the recordDecl() AST matcher doesn't match
>>> >> >> >> RecordDecl objects; instead, it matches CXXRecordDecl objects.
>>> >> >> >> This
>>> >> >> >> is... unfortunate... as it makes writing AST matchers more
>>> >> >> >> complicated
>>> >> >> >> because of having to translate between
>>> >> >> >> recordDecl()/CXXRecordDecl.
>>> >> >> >> It
>>> >> >> >> also makes it impossible to match a struct or union declaration
>>> >> >> >> in C
>>> >> >> >> or ObjC. However, given how prevalent recordDecl()'s use is in
>>> >> >> >> the
>>> >> >> >> wild (I'm guessing), changing it at this point would be a Bad
>>> >> >> >> Thing.
>>> >> >> >>
>>> >> >> >> For people trying to write AST matchers for languages like C or
>>> >> >> >> ObjC,
>>> >> >> >> I would like to propose adding:
>>> >> >> >>
>>> >> >> >> structDecl()
>>> >> >> >> unionDecl()
>>> >> >> >> tagDecl()
>>> >> >> >>
>>> >> >> >> These will match nicely with the existing enumDecl() AST
>>> >> >> >> matcher.
>>> >> >> >>
>>> >> >> >> Additionally, I would like to add cxxRecordDecl() to match
>>> >> >> >> CXXRecordDecl objects. While it duplicates the functionality
>>> >> >> >> exposed
>>> >> >> >> by recordDecl(), it more clearly matches the intention of which
>>> >> >> >> AST
>>> >> >> >> node it corresponds to.
>>> >> >> >>
>>> >> >> >> Finally, I would like to undocument recordDecl() and change our
>>> >> >> >> existing documentation and AST matcher uses to use
>>> >> >> >> cxxRecordDecl/structDecl() instead. Maybe someday we can
>>> >> >> >> deprecate
>>> >> >> >> recordDecl() more officially.
>>> >> >> >>
>>> >> >> >> I'm open to other ideas if there are better ways to move
>>> >> >> >> forward. If
>>> >> >> >> you think changing the meaning of recordDecl() is acceptable, I
>>> >> >> >> can
>>> >> >> >> also go that route (though I would still propose adding
>>> >> >> >> unionDecl()
>>> >> >> >> and cxxRecordDecl() in that case).
>>> >> >> >
>>> >> >> >
>>> >> >> > I think changing recordDecl is acceptable. I believe very few
>>> >> >> > tools
>>> >> >> > will
>>> >> >> > actually start doing wrong things because of it. I'd like more
>>> >> >> > opinions
>>> >> >

Re: [PATCH] D12406: [Analyzer] Add -analyzer-config option for function size the inliner considers as large

2015-09-11 Thread Ted Kremenek via cfe-commits
krememek added a comment.

LGTM as well.  Thanks Sean.


Repository:
  rL LLVM

http://reviews.llvm.org/D12406



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


Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

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


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:244
@@ +243,3 @@
+  const ProgramPointTag *Tag = nullptr) {
+return generateSink(State, /*Pred=*/nullptr,
+   (Tag ? Tag : Location.getTag()));

xazax.hun wrote:
> zaks.anna wrote:
> > Please, use a non-null Pred for clarity
> The following workflow is not supported by this API: a checker that generates 
> multiple transition in the same callback (the generated nodes are added 
> sequentially to the path), and one of the might be an error node.
> 
> This also applies to generateNonFatalErrorNode.
> 
> In case we would like to improve the documentation it might be useful to give 
> some pointers to the users which when should an error node be considered as 
> fatal.
 - We could introduce another API that requires a Pred node.
 - The workflow is supported right now by directly using addTransition API.


Comment at: lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp:53
@@ -52,3 +52,3 @@
 
-  if (ExplodedNode *N = C.addTransition()) {
+  if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
 if (!BT)

jordan_rose wrote:
> zaks.anna wrote:
> > Can this ever fail? In some cases we just assume it won't in others we 
> > tests..
> > 
> > Maybe it only fails when we cache out?
> It does fail when we cache out, and I think we can still cache out if Pred 
> has a different tag the second time around.
There some instances in this patch where we do not check if the returned node 
is null. We should be consistent. 


http://reviews.llvm.org/D12780



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

r247465, thanks for the review!


Repository:
  rL LLVM

http://reviews.llvm.org/D12087



___
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-11 Thread Richard Smith via cfe-commits
I don't think CXXRecordDecl is an anachronism, so much as an implementation
detail; it makes sense to use a smaller class when in C mode, as we don't
need most of the features and complexity that CXXRecordDecl brings with it.
But... as a user of clang matchers, I don't think I'd want to care about
the difference, and it'd be more convenient if I could nest (say) a
hasMethod matcher within a recordDecl matcher, since it's completely
obvious what that should mean. If I have a matcher that says:

  recordDecl(or(hasMethod(...), hasField(...)))

I would expect that to work in both C and C++ (and the only way it could
match in C would be on a record with the specified field, since the
hasMethod matcher would always fail).

On Fri, Sep 11, 2015 at 6:30 AM, Manuel Klimek  wrote:

> Richard! We need an informed opinion :D
>
> On Fri, Sep 11, 2015 at 3:07 PM Aaron Ballman 
> wrote:
>
>> Ping?
>>
>> On Tue, Sep 8, 2015 at 9:26 AM, Manuel Klimek  wrote:
>> > On Tue, Sep 8, 2015 at 3:23 PM Aaron Ballman 
>> wrote:
>> >>
>> >> On Tue, Sep 8, 2015 at 9:18 AM, Manuel Klimek 
>> wrote:
>> >> > On Tue, Sep 8, 2015 at 2:23 PM Aaron Ballman > >
>> >> > wrote:
>> >> >>
>> >> >> On Tue, Sep 8, 2015 at 5:40 AM, Manuel Klimek 
>> >> >> wrote:
>> >> >> > Yea, we had that discussion a few times, and I can never remember
>> why
>> >> >> > we
>> >> >> > ended up in the state we're in.
>> >> >> > We definitely had a time where we switched to just using the exact
>> >> >> > same
>> >> >> > name
>> >> >> > as the node's class name for the matchers.
>> >> >> > I *think* we didn't do it for cxxRecordDecl, because Richard said
>> >> >> > that's
>> >> >> > a
>> >> >> > relic we should get rid of anyway, but I'm not sure.
>> >> >>
>> >> >> FWIW, I think the state we're in is the worst of all worlds. It's
>> not
>> >> >> intuitive that recordDecl() doesn't match a struct in C mode, and as
>> >> >> it stands, there is no way to match a struct or union declaration
>> in C
>> >> >> at all.
>> >> >
>> >> >
>> >> > Agreed. Best intentions. Worst possible outcome. That's software
>> >> > development
>> >> > :)
>> >> >
>> >> >> >
>> >> >> > On Fri, Sep 4, 2015 at 8:32 PM Aaron Ballman <
>> aa...@aaronballman.com>
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> It turns out that the recordDecl() AST matcher doesn't match
>> >> >> >> RecordDecl objects; instead, it matches CXXRecordDecl objects.
>> This
>> >> >> >> is... unfortunate... as it makes writing AST matchers more
>> >> >> >> complicated
>> >> >> >> because of having to translate between
>> recordDecl()/CXXRecordDecl.
>> >> >> >> It
>> >> >> >> also makes it impossible to match a struct or union declaration
>> in C
>> >> >> >> or ObjC. However, given how prevalent recordDecl()'s use is in
>> the
>> >> >> >> wild (I'm guessing), changing it at this point would be a Bad
>> Thing.
>> >> >> >>
>> >> >> >> For people trying to write AST matchers for languages like C or
>> >> >> >> ObjC,
>> >> >> >> I would like to propose adding:
>> >> >> >>
>> >> >> >> structDecl()
>> >> >> >> unionDecl()
>> >> >> >> tagDecl()
>> >> >> >>
>> >> >> >> These will match nicely with the existing enumDecl() AST matcher.
>> >> >> >>
>> >> >> >> Additionally, I would like to add cxxRecordDecl() to match
>> >> >> >> CXXRecordDecl objects. While it duplicates the functionality
>> exposed
>> >> >> >> by recordDecl(), it more clearly matches the intention of which
>> AST
>> >> >> >> node it corresponds to.
>> >> >> >>
>> >> >> >> Finally, I would like to undocument recordDecl() and change our
>> >> >> >> existing documentation and AST matcher uses to use
>> >> >> >> cxxRecordDecl/structDecl() instead. Maybe someday we can
>> deprecate
>> >> >> >> recordDecl() more officially.
>> >> >> >>
>> >> >> >> I'm open to other ideas if there are better ways to move
>> forward. If
>> >> >> >> you think changing the meaning of recordDecl() is acceptable, I
>> can
>> >> >> >> also go that route (though I would still propose adding
>> unionDecl()
>> >> >> >> and cxxRecordDecl() in that case).
>> >> >> >
>> >> >> >
>> >> >> > I think changing recordDecl is acceptable. I believe very few
>> tools
>> >> >> > will
>> >> >> > actually start doing wrong things because of it. I'd like more
>> >> >> > opinions
>> >> >> > first, though :)
>> >> >>
>> >> >> I was giving this more thought over the long weekend, and I think
>> you
>> >> >> may be right. I think changing recordDecl() to mean RecordDecl will
>> >> >> fix more code than it breaks, so long as we take a holistic approach
>> >> >> to the change and see which narrowing and traversal matchers we need
>> >> >> to fix up at the same time. When I tried to think of AST matchers
>> that
>> >> >> mean CXXRecordDecl but *not* RecordDecl, they were horribly
>> contrived
>> >> >> because you usually are matching on additional selection criteria
>> that
>> >> >> is specific to C++ (such as hasMethod() or isDerivedFrom()) which
>> >> >> would cause the match to continue to fail, as expected. Code that
>> u

r247465 - Always_inline codegen rewrite.

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Sep 11 15:29:07 2015
New Revision: 247465

URL: http://llvm.org/viewvc/llvm-project?rev=247465&view=rev
Log:
Always_inline codegen rewrite.

Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

Added:
cfe/trunk/test/CodeGen/always_inline-unused.c
cfe/trunk/test/CodeGen/always_inline-wrappers.c
cfe/trunk/test/CodeGenCXX/alwaysinline.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGen/always-inline.c
cfe/trunk/test/CodeGen/always_inline.c
cfe/trunk/test/CodeGen/function-attributes.c
cfe/trunk/test/CodeGen/pr9614.c
cfe/trunk/test/Frontend/optimization-remark-line-directive.c
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/Modules/cxx-irgen.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=247465&r1=247464&r2=247465&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Sep 11 15:29:07 2015
@@ -109,6 +109,9 @@ bool CodeGenModule::TryEmitBaseDestructo
   D->getType()->getAs()->getCallConv())
 return true;
 
+  if (BaseD->hasAttr())
+return true;
+
   return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
   GlobalDecl(BaseD, Dtor_Base),
   false);
@@ -161,14 +164,7 @@ bool CodeGenModule::TryEmitDefinitionAsA
 
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliasee.
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
- (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
-  !TargetDecl.getDecl()->hasAttr())) {
-// FIXME: An extern template instantiation will create functions with
-// linkage "AvailableExternally". In libc++, some classes also define
-// members with attribute "AlwaysInline" and expect no reference to
-// be generated. It is desirable to reenable this optimisation after
-// corresponding LLVM changes.
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
 Replacements[MangledName] = Aliasee;
 return false;
   }

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=247465&r1=247464&r2=247465&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Sep 11 15:29:07 2015
@@ -1557,7 +1557,7 @@ void CodeGenFunction::EmitDestructorBody
 // -fapple-kext must inline any call to this dtor into
 // the caller's body.
 if (getLangOpts().AppleKext)
-  CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
+  CGM.AddAlwaysInlineFunction(CurFn);
 
 break;
   }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=247465&r1=247464&r2=247465&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Sep 11 15:29:07 2015
@@ -2114,7 +2114,7 @@ emitTaskPrivateMappingFunction(CodeGenMo
   ".omp_task_privates_map.", &CGM.getModule());
   CGM.SetLLVMFunctionAttributes(/*D=*/nullptr, TaskPrivatesMapFnInfo,
 TaskPrivatesMap);
-  TaskPrivatesMap->addFnAttr(llvm::Attribute::AlwaysInline);
+  CGM.AddAlwaysInlineFunction(TaskPrivatesMap);
   CodeGenFunction CGF(C

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-11 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 34578.
eugenis added a comment.

rebase, fix a merge conflict


Repository:
  rL LLVM

http://reviews.llvm.org/D12087

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/always-inline.c
  test/CodeGen/always_inline-unused.c
  test/CodeGen/always_inline-wrappers.c
  test/CodeGen/always_inline.c
  test/CodeGen/function-attributes.c
  test/CodeGen/pr9614.c
  test/CodeGenCXX/alwaysinline.cpp
  test/Frontend/optimization-remark-line-directive.c
  test/Frontend/optimization-remark.c
  test/Modules/cxx-irgen.cpp

Index: test/Modules/cxx-irgen.cpp
===
--- test/Modules/cxx-irgen.cpp
+++ test/Modules/cxx-irgen.cpp
@@ -26,14 +26,14 @@
   };
 }
 
-// CHECK-DAG: define available_externally hidden {{.*}}{{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
+// CHECK-DAG: define internal i32 @_ZN1SIiE1gEv.alwaysinline() #[[ALWAYS_INLINE:.*]] align
 int a = S::g();
 
 int b = h();
 
 // CHECK-DAG: define linkonce_odr {{.*}}{{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
 int c = min(1, 2);
-// CHECK: define available_externally {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+// CHECK-DAG: define internal {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv.alwaysinline() #[[ALWAYS_INLINE]] align
 
 namespace ImplicitSpecialMembers {
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
Index: test/Frontend/optimization-remark.c
===
--- test/Frontend/optimization-remark.c
+++ test/Frontend/optimization-remark.c
@@ -32,6 +32,8 @@
 // CHECK-NOT: !llvm.dbg.cu = !{
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+2 {{foo.alwaysinline should always be inlined}}
+// expected-remark@+1 {{foo.alwaysinline inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
 float foz(int x, int y) __attribute__((noinline));
@@ -45,7 +47,7 @@
 // expected-remark@+5 {{foz will not be inlined into bar}}
 // expected-remark@+4 {{foz should never be inlined}}
 // expected-remark@+3 {{foz will not be inlined into bar}}
-// expected-remark@+2 {{foo should always be inlined}}
-// expected-remark@+1 {{foo inlined into bar}}
+// expected-remark@+2 {{foo.alwaysinline should always be inlined}}
+// expected-remark@+1 {{foo.alwaysinline inlined into bar}}
   return foo(j, j - 2) * foz(j - 2, j);
 }
Index: test/Frontend/optimization-remark-line-directive.c
===
--- test/Frontend/optimization-remark-line-directive.c
+++ test/Frontend/optimization-remark-line-directive.c
@@ -5,8 +5,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -gline-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+1 {{foo.alwaysinline inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
-// expected-remark@+2 {{foo inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
+// expected-remark@+2 {{foo.alwaysinline inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
 #line 1230 "/bad/path/to/original.c"
 int bar(int j) { return foo(j, j - 2); }
Index: test/CodeGenCXX/alwaysinline.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alwaysinline.cpp
@@ -0,0 +1,68 @@
+// Test different kinds of alwaysinline *structor definitions.
+
+// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+struct A1 {
+  __attribute__((__always_inline__)) A1() {}
+  __attribute__((__always_inline__)) ~A1() {}
+};
+
+void g1() {
+  A1 a1;
+}
+
+struct A2 {
+  inline __attribute__((__always_inline__)) A2() {}
+  inline __attribute__((__always_inline__)) ~A2() {}
+};
+
+void g2() {
+  A2 a2;
+}
+
+struct A3 {
+  inline __attribute__((gnu_inline, __always_inline__)) A3() {}
+  inline __attribute__((gnu_inline, __always_inline__)) ~A3() {}
+};
+
+void g3() {
+  A3 a3;
+}
+
+// CHECK-DAG: define internal void @_ZN2A1C1Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI:[01-9]+]]
+// CHECK-DAG: define internal void @_ZN2A1C2Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define internal void @_ZN2A1D1Ev.alwaysinline(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define internal void @_ZN2

Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread David Majnemer via cfe-commits
On Fri, Sep 11, 2015 at 1:16 PM, Richard Smith 
wrote:

> On Fri, Sep 11, 2015 at 12:46 PM, David Majnemer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Reduced it a bit:
>> template 
>> void JSMethod();
>> class A {
>>   int printd(int);
>>   void printd();
>> };
>> void A::printd() { JSMethod(); }
>>
>> This test case will crash clang at the revision before this commit which
>> means that something more mysterious/horrific is going on...
>>
>
> Are we perhaps failing to RequireCompleteType on M's type after
> substituting the value of C into it?
>

Fixed in r247464.


>
> On Fri, Sep 11, 2015 at 11:10 AM, David Majnemer > > wrote:
>>
>>> Taking a look, would appreciate it if we didn't revert this until I give
>>> it a fair shot.  Shouldn't take too long.
>>>
>>> On Fri, Sep 11, 2015 at 10:58 AM, Hans Wennborg 
>>> wrote:
>>>
 This made the Chromium build sad. For example:

 http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio

 Reduction:

 $ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
 -fms-compatibility -fms-compatibility-version=18.0 -std=c++11
 -fdelayed-template-parsing a.ii

 template 
 void JSMethod(char *, char *, int);
 class A {
   int printd(int *, const int &, int &, int &);
   int printd_info;
   void printd() { JSMethod("", "", printd_info); }
 };


 On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
  wrote:
 > Author: majnemer
 > Date: Thu Sep 10 16:52:00 2015
 > New Revision: 247346
 >
 > URL: http://llvm.org/viewvc/llvm-project?rev=247346&view=rev
 > Log:
 > [MS ABI] Make member pointers return true for isIncompleteType
 >
 > The type of a member pointer is incomplete if it has no inheritance
 > model.  This lets us reuse more general logic already embedded in
 clang.

>>>
>>>
>>
>> ___
>> 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: r247464 - [MS ABI] Select an inheritance model in template arguments

2015-09-11 Thread Richard Smith via cfe-commits
On Fri, Sep 11, 2015 at 1:18 PM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: majnemer
> Date: Fri Sep 11 15:18:09 2015
> New Revision: 247464
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247464&view=rev
> Log:
> [MS ABI] Select an inheritance model in template arguments
>
> We used to only select an inheritance model if the pointer to member was
> nullptr.  Instead, select a model regardless of the member pointer's
> value.
>
> N.B.  This bug was exposed by making member pointers report true for
> isIncompleteType but has been latent since the member pointer scheme's
> inception.
>
> Modified:
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247464&r1=247463&r2=247464&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep 11 15:18:09 2015
> @@ -4222,7 +4222,11 @@ isNullPointerValueTemplateArgument(Sema
> QualType ParamType, Expr *Arg) {
>if (Arg->isValueDependent() || Arg->isTypeDependent())
>  return NPV_NotNullPointer;
> -
> +
> +  if (ParamType->isMemberPointerType())
> +if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
> +  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
>

It seems simpler to unconditionally require the type to be complete.


> +
>if (!S.getLangOpts().CPlusPlus11)
>  return NPV_NotNullPointer;
>
> @@ -4670,8 +4674,6 @@ static bool CheckTemplateArgumentPointer
>  S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
>  Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),
>   /*isNullPtr*/true);
> -if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
> -  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
>  return false;
>case NPV_NotNullPointer:
>  break;
>
> Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247464&r1=247463&r2=247464&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Fri Sep 11
> 15:18:09 2015
> @@ -768,3 +768,14 @@ bool g(int J::*&p, int J::*&q) { return
>  // CHECK-LABEL: @"\01?h@ReferenceToMPTWithIncompleteClass@@YAHAAPQK@1@H@Z
> "(
>  int h(int K::*&p) { return k->*p; }
>  }
> +
> +namespace PMFInTemplateArgument {
> +template 
> +void JSMethod();
> +class A {
> +  int printd(int);
> +  void printd();
> +};
> +void A::printd() { JSMethod(); }
> +// CHECK-LABEL: @"\01??$JSMethod@VA@PMFInTemplateArgument@@$1?printd@12
> @AAEHH@Z@PMFInTemplateArgument@@YAXXZ"(
> +}
>
>
> ___
> 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: r246877 - Increase accuracy of __builtin_object_size.

2015-09-11 Thread Richard Smith via cfe-commits
On Fri, Sep 11, 2015 at 12:15 PM, Mikhail Zolotukhin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi George,
>
> After this commit we started to trap on the following case:
>
> #include 
> typedef struct {
>   int n;
>   char key[1];
> } obj_t;
>
> char *str = "hello";
>
> int main() {
>   obj_t* p = (obj_t*)malloc(strlen(str) + 1 + sizeof(int));
>   strcpy(p->key, str);
>   free(p);
>   return 0;
> }
>
> As far as I understand, this might be a common pattern in pre-C99
> codebase, and it fails when compiled with -D_FORTIFY_SOURCE=2. Is there a
> way we could fix it in clang, or the only fix is to use less strict
> FORTIFY_SOURCE level?
>

It might be reasonable for __builtin_object_size(..., 2) to give up if:

1) we lost track of the complete object, and
2) the designator refers to the final subobject of the currently-known
complete object, and
3) that subobject is either a flexible array member or an array of bound 0
or 1.

Then we'd leave it to IR generation to do the llvm.object.size(..., i1
false) dance, and in this case to grab the size of the malloc (minus the
offset of 'key').

Thanks,
> Michael
>
> On Sep 4, 2015, at 2:28 PM, George Burgess IV via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: gbiv
> Date: Fri Sep  4 16:28:13 2015
> New Revision: 246877
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246877&view=rev
> Log:
> Increase accuracy of __builtin_object_size.
>
> Improvements:
>
> - For all types, we would give up in a case such as:
>__builtin_object_size((char*)&foo, N);
>  even if we could provide an answer to
>__builtin_object_size(&foo, N);
>  We now provide the same answer for both of the above examples in all
>  cases.
>
> - For type=1|3, we now support subobjects with unknown bases, as long
>  as the designator is valid.
>
> Thanks to Richard Smith for the review + design planning.
>
> Review: http://reviews.llvm.org/D12169
>
>
> Modified:
>cfe/trunk/lib/AST/ExprConstant.cpp
>cfe/trunk/test/CodeGen/object-size.c
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=246877&r1=246876&r2=246877&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Sep  4 16:28:13 2015
> @@ -492,7 +492,11 @@ namespace {
>   /// optimizer if we don't constant fold them here, but in an
> unevaluated
>   /// context we try to fold them immediately since the optimizer never
>   /// gets a chance to look at it.
> -  EM_PotentialConstantExpressionUnevaluated
> +  EM_PotentialConstantExpressionUnevaluated,
> +
> +  /// Evaluate as a constant expression. Continue evaluating if we
> find a
> +  /// MemberExpr with a base that can't be evaluated.
> +  EM_DesignatorFold,
> } EvalMode;
>
> /// Are we checking whether the expression is a potential constant
> @@ -595,6 +599,7 @@ namespace {
>   case EM_PotentialConstantExpression:
>   case EM_ConstantExpressionUnevaluated:
>   case EM_PotentialConstantExpressionUnevaluated:
> +  case EM_DesignatorFold:
> HasActiveDiagnostic = false;
> return OptionalDiagnostic();
>   }
> @@ -674,6 +679,7 @@ namespace {
>   case EM_ConstantExpression:
>   case EM_ConstantExpressionUnevaluated:
>   case EM_ConstantFold:
> +  case EM_DesignatorFold:
> return false;
>   }
>   llvm_unreachable("Missed EvalMode case");
> @@ -702,10 +708,15 @@ namespace {
>   case EM_ConstantExpressionUnevaluated:
>   case EM_ConstantFold:
>   case EM_IgnoreSideEffects:
> +  case EM_DesignatorFold:
> return false;
>   }
>   llvm_unreachable("Missed EvalMode case");
> }
> +
> +bool allowInvalidBaseExpr() const {
> +  return EvalMode == EM_DesignatorFold;
> +}
>   };
>
>   /// Object used to treat all foldable expressions as constant
> expressions.
> @@ -736,6 +747,21 @@ namespace {
> }
>   };
>
> +  /// RAII object used to treat the current evaluation as the correct
> pointer
> +  /// offset fold for the current EvalMode
> +  struct FoldOffsetRAII {
> +EvalInfo &Info;
> +EvalInfo::EvaluationMode OldMode;
> +explicit FoldOffsetRAII(EvalInfo &Info, bool Subobject)
> +: Info(Info), OldMode(Info.EvalMode) {
> +  if (!Info.checkingPotentialConstantExpression())
> +Info.EvalMode = Subobject ? EvalInfo::EM_DesignatorFold
> +  : EvalInfo::EM_ConstantFold;
> +}
> +
> +~FoldOffsetRAII() { Info.EvalMode = OldMode; }
> +  };
> +
>   /// RAII object used to suppress diagnostics and side-effects from a
>   /// speculative evaluation.
>   class SpeculativeEvaluationRAII {
> @@ -917,7 +943,8 @@ namespace {
>   struct LValue {
> APValue::LValueBase Base;
> CharUnits Offset;
> -unsigned CallIndex;
> +   

r247464 - [MS ABI] Select an inheritance model in template arguments

2015-09-11 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Fri Sep 11 15:18:09 2015
New Revision: 247464

URL: http://llvm.org/viewvc/llvm-project?rev=247464&view=rev
Log:
[MS ABI] Select an inheritance model in template arguments

We used to only select an inheritance model if the pointer to member was
nullptr.  Instead, select a model regardless of the member pointer's
value.

N.B.  This bug was exposed by making member pointers report true for
isIncompleteType but has been latent since the member pointer scheme's
inception.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247464&r1=247463&r2=247464&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Sep 11 15:18:09 2015
@@ -4222,7 +4222,11 @@ isNullPointerValueTemplateArgument(Sema
QualType ParamType, Expr *Arg) {
   if (Arg->isValueDependent() || Arg->isTypeDependent())
 return NPV_NotNullPointer;
-  
+
+  if (ParamType->isMemberPointerType())
+if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
+  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
+
   if (!S.getLangOpts().CPlusPlus11)
 return NPV_NotNullPointer;
   
@@ -4670,8 +4674,6 @@ static bool CheckTemplateArgumentPointer
 S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
 Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),
  /*isNullPtr*/true);
-if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
-  S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
 return false;
   case NPV_NotNullPointer:
 break;

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247464&r1=247463&r2=247464&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Fri Sep 11 
15:18:09 2015
@@ -768,3 +768,14 @@ bool g(int J::*&p, int J::*&q) { return
 // CHECK-LABEL: @"\01?h@ReferenceToMPTWithIncompleteClass@@YAHAAPQK@1@H@Z"(
 int h(int K::*&p) { return k->*p; }
 }
+
+namespace PMFInTemplateArgument {
+template 
+void JSMethod();
+class A {
+  int printd(int);
+  void printd();
+};
+void A::printd() { JSMethod(); }
+// CHECK-LABEL: 
@"\01??$JSMethod@VA@PMFInTemplateArgument@@$1?printd@12@AAEHH@Z@PMFInTemplateArgument@@YAXXZ"(
+}


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


Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread Richard Smith via cfe-commits
On Fri, Sep 11, 2015 at 12:46 PM, David Majnemer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Reduced it a bit:
> template 
> void JSMethod();
> class A {
>   int printd(int);
>   void printd();
> };
> void A::printd() { JSMethod(); }
>
> This test case will crash clang at the revision before this commit which
> means that something more mysterious/horrific is going on...
>

Are we perhaps failing to RequireCompleteType on M's type after
substituting the value of C into it?

On Fri, Sep 11, 2015 at 11:10 AM, David Majnemer 
> wrote:
>
>> Taking a look, would appreciate it if we didn't revert this until I give
>> it a fair shot.  Shouldn't take too long.
>>
>> On Fri, Sep 11, 2015 at 10:58 AM, Hans Wennborg 
>> wrote:
>>
>>> This made the Chromium build sad. For example:
>>>
>>> http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio
>>>
>>> Reduction:
>>>
>>> $ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
>>> -fms-compatibility -fms-compatibility-version=18.0 -std=c++11
>>> -fdelayed-template-parsing a.ii
>>>
>>> template 
>>> void JSMethod(char *, char *, int);
>>> class A {
>>>   int printd(int *, const int &, int &, int &);
>>>   int printd_info;
>>>   void printd() { JSMethod("", "", printd_info); }
>>> };
>>>
>>>
>>> On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
>>>  wrote:
>>> > Author: majnemer
>>> > Date: Thu Sep 10 16:52:00 2015
>>> > New Revision: 247346
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=247346&view=rev
>>> > Log:
>>> > [MS ABI] Make member pointers return true for isIncompleteType
>>> >
>>> > The type of a member pointer is incomplete if it has no inheritance
>>> > model.  This lets us reuse more general logic already embedded in
>>> clang.
>>>
>>
>>
>
> ___
> 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] D12406: [Analyzer] Add -analyzer-config option for function size the inliner considers as large

2015-09-11 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247463: [analyzer] Add -analyzer-config option for function 
size the inliner… (authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D12406?vs=34196&id=34574#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12406

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/analyzer-config.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -870,7 +870,8 @@
   // Do not inline large functions too many times.
   if ((Engine.FunctionSummaries->getNumTimesInlined(D) >
Opts.getMaxTimesInlineLarge()) &&
-  CalleeCFG->getNumBlockIDs() > 13) {
+   CalleeCFG->getNumBlockIDs() >=
+   Opts.getMinCFGSizeTreatFunctionsAsLarge()) {
 NumReachedInlineCountMax++;
 return false;
   }
Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -295,6 +295,13 @@
   return MaxTimesInlineLarge.getValue();
 }
 
+unsigned AnalyzerOptions::getMinCFGSizeTreatFunctionsAsLarge() {
+  if (!MinCFGSizeTreatFunctionsAsLarge.hasValue())
+MinCFGSizeTreatFunctionsAsLarge = getOptionAsInteger(
+  "min-cfg-size-treat-functions-as-large", 14);
+  return MinCFGSizeTreatFunctionsAsLarge.getValue();
+}
+
 unsigned AnalyzerOptions::getMaxNodesPerTopLevelFunction() {
   if (!MaxNodesPerTopLevelFunction.hasValue()) {
 int DefaultValue = 0;
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -253,6 +253,9 @@
   /// \sa getMaxTimesInlineLarge
   Optional MaxTimesInlineLarge;
 
+  /// \sa getMinCFGSizeTreatFunctionsAsLarge
+  Optional MinCFGSizeTreatFunctionsAsLarge;
+
   /// \sa getMaxNodesPerTopLevelFunction
   Optional MaxNodesPerTopLevelFunction;
 
@@ -505,6 +508,13 @@
   /// This is controlled by the 'max-times-inline-large' config option.
   unsigned getMaxTimesInlineLarge();
 
+  /// Returns the number of basic blocks a function needs to have to be
+  /// considered large for the 'max-times-inline-large' config option.
+  ///
+  /// This is controlled by the 'min-cfg-size-treat-functions-as-large' config
+  /// option.
+  unsigned getMinCFGSizeTreatFunctionsAsLarge();
+
   /// Returns the maximum number of nodes the analyzer can generate while
   /// exploring a top level function (for each exploded graph).
   /// 15 is default; 0 means no limit.
Index: cfe/trunk/test/Analysis/analyzer-config.c
===
--- cfe/trunk/test/Analysis/analyzer-config.c
+++ cfe/trunk/test/Analysis/analyzer-config.c
@@ -1,22 +1,30 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 void bar() {}
-void foo() { bar(); }
+void foo() {
+  // Call bar 33 times so max-times-inline-large is met and
+  // min-blocks-for-inline-large is checked
+  for (int i = 0; i < 34; ++i) {
+bar();
+  }
+}
 
 // CHECK: [config]
 // CHECK-NEXT: cfg-conditional-static-initializers = true
 // CHECK-NEXT: cfg-temporary-dtors = false
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
+// CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
 // CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 50
 // CHECK-NEXT: max-nodes = 15
 // CHECK-NEXT: max-times-inline-large = 32
+// CHECK-NEXT: min-cfg-size-treat-functions-as-large = 14
 // CHECK-NEXT: mode = deep
 // CHECK-NEXT: region-store-small-struct-limit = 2
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 12
+// CHECK-NEXT: num-entries = 14
 
Index: cfe/trunk/test/Analysis/analyzer-config.cpp
===
--- cfe/trunk/test/Analysis/analyzer-config.cpp
+++ cfe/trunk/test/Analysis/analyzer-config.cpp
@@ -1,8 +1,14 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper 

Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D12743#244375, @vsk wrote:

> Ah, ok. We have some objective-c++ code which calls into a boost routine 
> which throws an exception. That results in an undefined reference to 
> ___objc_personality_v0, because the boost library we linked against doesn't 
> have ___objc_personality_v0.
>
> Should the compiler have found the ___objc_personality_v0 symbol in this case 
> regardless?


It's pretty straightforward.  Sometimes people write code in ObjC++ files 
that's really pure C++.  Such code is generally compiled with -fexceptions 
because that's the default, and so it has cleanups, and those cleanups require 
us to pick a personality function.  When they do so, they generally don't link 
against the ObjC runtime, and so __objc_personality_v0 isn't found.  The 
workaround here is to recognize that they're not actually catching ObjC 
exception types and just quietly degrade to use the C++ personality.

It is probably technically an optimization, because it removes some overhead 
from double-parsing the exception tables (because the ObjC personality 
delegates to the C++ personality, instead of being tightly integrated with it), 
but that's not the real reason we do it.


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


r247463 - [analyzer] Add -analyzer-config option for function size the inliner considers as large

2015-09-11 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Sep 11 15:14:05 2015
New Revision: 247463

URL: http://llvm.org/viewvc/llvm-project?rev=247463&view=rev
Log:
[analyzer] Add -analyzer-config option for function size the inliner considers 
as large

Add an option (-analyzer-config min-blocks-for-inline-large=14) to control the 
function
size the inliner considers as large, in relation to "max-times-inline-large". 
The option
defaults to the original hard coded behaviour, which I believe should be 
adjustable with
the other inlining settings.

The analyzer-config test has been modified so that the analyzer will reach the
getMinBlocksForInlineLarge() method and store the result in the ConfigTable, to 
ensure it
is dumped by the debug checker.

A patch by Sean Eveson!

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=247463&r1=247462&r2=247463&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Sep 11 
15:14:05 2015
@@ -253,6 +253,9 @@ private:
   /// \sa getMaxTimesInlineLarge
   Optional MaxTimesInlineLarge;
 
+  /// \sa getMinCFGSizeTreatFunctionsAsLarge
+  Optional MinCFGSizeTreatFunctionsAsLarge;
+
   /// \sa getMaxNodesPerTopLevelFunction
   Optional MaxNodesPerTopLevelFunction;
 
@@ -505,6 +508,13 @@ public:
   /// This is controlled by the 'max-times-inline-large' config option.
   unsigned getMaxTimesInlineLarge();
 
+  /// Returns the number of basic blocks a function needs to have to be
+  /// considered large for the 'max-times-inline-large' config option.
+  ///
+  /// This is controlled by the 'min-cfg-size-treat-functions-as-large' config
+  /// option.
+  unsigned getMinCFGSizeTreatFunctionsAsLarge();
+
   /// Returns the maximum number of nodes the analyzer can generate while
   /// exploring a top level function (for each exploded graph).
   /// 15 is default; 0 means no limit.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=247463&r1=247462&r2=247463&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Fri Sep 11 15:14:05 
2015
@@ -295,6 +295,13 @@ unsigned AnalyzerOptions::getMaxTimesInl
   return MaxTimesInlineLarge.getValue();
 }
 
+unsigned AnalyzerOptions::getMinCFGSizeTreatFunctionsAsLarge() {
+  if (!MinCFGSizeTreatFunctionsAsLarge.hasValue())
+MinCFGSizeTreatFunctionsAsLarge = getOptionAsInteger(
+  "min-cfg-size-treat-functions-as-large", 14);
+  return MinCFGSizeTreatFunctionsAsLarge.getValue();
+}
+
 unsigned AnalyzerOptions::getMaxNodesPerTopLevelFunction() {
   if (!MaxNodesPerTopLevelFunction.hasValue()) {
 int DefaultValue = 0;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=247463&r1=247462&r2=247463&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Fri Sep 11 
15:14:05 2015
@@ -870,7 +870,8 @@ bool ExprEngine::shouldInlineCall(const
   // Do not inline large functions too many times.
   if ((Engine.FunctionSummaries->getNumTimesInlined(D) >
Opts.getMaxTimesInlineLarge()) &&
-  CalleeCFG->getNumBlockIDs() > 13) {
+   CalleeCFG->getNumBlockIDs() >=
+   Opts.getMinCFGSizeTreatFunctionsAsLarge()) {
 NumReachedInlineCountMax++;
 return false;
   }

Modified: cfe/trunk/test/Analysis/analyzer-config.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.c?rev=247463&r1=247462&r2=247463&view=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.c (original)
+++ cfe/trunk/test/Analysis/analyzer-config.c Fri Sep 11 15:14:05 2015
@@ -1,22 +1,30 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang 
-analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang 
-analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 >

Re: [PATCH] D10018: C11 _Bool bitfield diagnostic

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

Looks great, please go ahead. Sorry it's taken so long to get this reviewed.


http://reviews.llvm.org/D10018



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


r247462 - [Edit] Fix issue with tracking what macro argument inputs have been edited.

2015-09-11 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Sep 11 15:09:11 2015
New Revision: 247462

URL: http://llvm.org/viewvc/llvm-project?rev=247462&view=rev
Log:
[Edit] Fix issue with tracking what macro argument inputs have been edited.

This was not working correctly, leading to erroneously rejecting valid edits.

Modified:
cfe/trunk/include/clang/Edit/EditedSource.h
cfe/trunk/lib/Edit/EditedSource.cpp
cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m
cfe/trunk/test/ARCMT/objcmt-subscripting-literals.m.result

Modified: cfe/trunk/include/clang/Edit/EditedSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/EditedSource.h?rev=247462&r1=247461&r2=247462&view=diff
==
--- cfe/trunk/include/clang/Edit/EditedSource.h (original)
+++ cfe/trunk/include/clang/Edit/EditedSource.h Fri Sep 11 15:09:11 2015
@@ -10,9 +10,11 @@
 #ifndef LLVM_CLANG_EDIT_EDITEDSOURCE_H
 #define LLVM_CLANG_EDIT_EDITEDSOURCE_H
 
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Edit/FileOffset.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Support/Allocator.h"
 #include 
 
@@ -39,14 +41,18 @@ class EditedSource {
   typedef std::map FileEditsTy;
   FileEditsTy FileEdits;
 
-  llvm::DenseMap ExpansionToArgMap;
+  llvm::DenseMap>
+ExpansionToArgMap;
+  SmallVector, 2>
+CurrCommitMacroArgExps;
 
+  IdentifierTable IdentTable;
   llvm::BumpPtrAllocator StrAlloc;
 
 public:
   EditedSource(const SourceManager &SM, const LangOptions &LangOpts,
const PPConditionalDirectiveRecord *PPRec = nullptr)
-: SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec),
+: SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), IdentTable(LangOpts),
   StrAlloc() { }
 
   const SourceManager &getSourceManager() const { return SourceMgr; }
@@ -76,6 +82,12 @@ private:
   StringRef getSourceText(FileOffset BeginOffs, FileOffset EndOffs,
   bool &Invalid);
   FileEditsTy::iterator getActionForOffset(FileOffset Offs);
+  void deconstructMacroArgLoc(SourceLocation Loc,
+  SourceLocation &ExpansionLoc,
+  IdentifierInfo *&II);
+
+  void startingCommit();
+  void finishedCommit();
 };
 
 }

Modified: cfe/trunk/lib/Edit/EditedSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/EditedSource.cpp?rev=247462&r1=247461&r2=247462&view=diff
==
--- cfe/trunk/lib/Edit/EditedSource.cpp (original)
+++ cfe/trunk/lib/Edit/EditedSource.cpp Fri Sep 11 15:09:11 2015
@@ -23,6 +23,36 @@ void EditsReceiver::remove(CharSourceRan
   replace(range, StringRef());
 }
 
+void EditedSource::deconstructMacroArgLoc(SourceLocation Loc,
+  SourceLocation &ExpansionLoc,
+  IdentifierInfo *&II) {
+  assert(SourceMgr.isMacroArgExpansion(Loc));
+  SourceLocation DefArgLoc = SourceMgr.getImmediateExpansionRange(Loc).first;
+  ExpansionLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
+  SmallString<20> Buf;
+  StringRef ArgName = Lexer::getSpelling(SourceMgr.getSpellingLoc(DefArgLoc),
+ Buf, SourceMgr, LangOpts);
+  II = nullptr;
+  if (!ArgName.empty()) {
+II = &IdentTable.get(ArgName);
+  }
+}
+
+void EditedSource::startingCommit() {}
+
+void EditedSource::finishedCommit() {
+  for (auto &ExpArg : CurrCommitMacroArgExps) {
+SourceLocation ExpLoc;
+IdentifierInfo *II;
+std::tie(ExpLoc, II) = ExpArg;
+auto &ArgNames = ExpansionToArgMap[ExpLoc.getRawEncoding()];
+if (std::find(ArgNames.begin(), ArgNames.end(), II) == ArgNames.end()) {
+  ArgNames.push_back(II);
+}
+  }
+  CurrCommitMacroArgExps.clear();
+}
+
 StringRef EditedSource::copyString(const Twine &twine) {
   SmallString<128> Data;
   return copyString(twine.toStringRef(Data));
@@ -36,15 +66,27 @@ bool EditedSource::canInsertInOffset(Sou
   }
 
   if (SourceMgr.isMacroArgExpansion(OrigLoc)) {
-SourceLocation
-  DefArgLoc = SourceMgr.getImmediateExpansionRange(OrigLoc).first;
-SourceLocation
-  ExpLoc = SourceMgr.getImmediateExpansionRange(DefArgLoc).first;
-llvm::DenseMap::iterator
-  I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
-if (I != ExpansionToArgMap.end() && I->second != DefArgLoc)
-  return false; // Trying to write in a macro argument input that has
- // already been written for another argument of the same 
macro. 
+IdentifierInfo *II;
+SourceLocation ExpLoc;
+deconstructMacroArgLoc(OrigLoc, ExpLoc, II);
+auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
+if (I != ExpansionToArgMap.end() &&
+std::find(I->second.begin(), I->second.end(), II) != I->second.end()) {
+  // Trying to write in a macro argument input that

Re: [PATCH] D10018: C11 _Bool bitfield diagnostic

2015-09-11 Thread Rachel Craik via cfe-commits
rcraik marked 3 inline comments as done.
rcraik added a comment.

http://reviews.llvm.org/D10018



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


Re: [PATCH] D10018: C11 _Bool bitfield diagnostic

2015-09-11 Thread Rachel Craik via cfe-commits
rcraik updated the summary for this revision.
rcraik updated this revision to Diff 34571.
rcraik added a comment.

switched to using getIntWidth instead of getTypeSize and updated the error and 
warning messages accordingly, as have the necessary test cases. The separate 
check for _Bool bitfields has been removed, so the check is now consistent for 
all types.


http://reviews.llvm.org/D10018

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGen/bitfield-2.c
  test/CodeGenCXX/warn-padded-packed.cpp
  test/Misc/warning-flags.c
  test/Sema/bitfield.c
  test/SemaCXX/bitfield-layout.cpp
  test/SemaCXX/constant-expression-cxx11.cpp
  test/SemaCXX/constant-expression-cxx1y.cpp
  test/SemaCXX/ms_wide_bitfield.cpp
  test/SemaObjC/class-bitfield.m

Index: test/SemaObjC/class-bitfield.m
===
--- test/SemaObjC/class-bitfield.m
+++ test/SemaObjC/class-bitfield.m
@@ -5,7 +5,7 @@
   int a : -1; // expected-error{{bit-field 'a' has negative width}}
 
   // rdar://6081627
-  int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+  int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
 
   int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
   int d : (int)(1 + 0.25); 
Index: test/SemaCXX/ms_wide_bitfield.cpp
===
--- test/SemaCXX/ms_wide_bitfield.cpp
+++ test/SemaCXX/ms_wide_bitfield.cpp
@@ -1,9 +1,10 @@
 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1
 
 struct A {
-  char a : 9; // expected-error{{size of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}}
-  int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
-  bool c : 9; // expected-error{{size of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}}
+  char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds width of its type (8 bits)}}
+  int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds width of its type (32 bits)}}
+  bool c : 9; // expected-error{{width of bit-field 'c' (9 bits) exceeds width of its type (1 bit)}}
+  bool d : 3; // expected-error{{width of bit-field 'd' (3 bits) exceeds width of its type (1 bit)}}
 };
 
 int a[sizeof(A) == 1 ? 1 : -1];
Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -872,7 +872,7 @@
 
 namespace Bitfields {
   struct A {
-bool b : 3;
+bool b : 1;
 int n : 4;
 unsigned u : 5;
   };
Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -1801,9 +1801,9 @@
 bool b : 1;
 unsigned u : 5;
 int n : 5;
-bool b2 : 3;
-unsigned u2 : 74; // expected-warning {{exceeds the size of its type}}
-int n2 : 81; // expected-warning {{exceeds the size of its type}}
+bool b2 : 3; // expected-warning {{exceeds the width of its type}}
+unsigned u2 : 74; // expected-warning {{exceeds the width of its type}}
+int n2 : 81; // expected-warning {{exceeds the width of its type}}
   };
 
   constexpr A a = { false, 33, 31, false, 0x, 0x7fff }; // expected-warning 2{{truncation}}
Index: test/SemaCXX/bitfield-layout.cpp
===
--- test/SemaCXX/bitfield-layout.cpp
+++ test/SemaCXX/bitfield-layout.cpp
@@ -5,25 +5,25 @@
 
 // Simple tests.
 struct Test1 {
-  char c : 9; // expected-warning {{size of bit-field 'c' (9 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+  char c : 9; // expected-warning {{width of bit-field 'c' (9 bits) exceeds the width of its type; value will be truncated to 8 bits}}
 };
 CHECK_SIZE(Test1, 2);
 CHECK_ALIGN(Test1, 1);
 
 struct Test2 {
-  char c : 16; // expected-warning {{size of bit-field 'c' (16 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+  char c : 16; // expected-warning {{width of bit-field 'c' (16 bits) exceeds the width of its type; value will be truncated to 8 bits}}
 };
 CHECK_SIZE(Test2, 2);
 CHECK_ALIGN(Test2, 2);
 
 struct Test3 {
-  char c : 32; // expected-warning {{size of bit-field 'c' (32 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+  char c : 32; // expected-warning {{width of bit-field 'c' (32 bits) exceeds the width of its type; value will be truncated to 8 bits}}
 };
 CHECK_SIZE(Test3, 4);
 CHECK_ALIGN(Test3, 4);
 
 struct Test4 {
-  char c : 64; // expected-warning {{size of bit

Re: r247447 - Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).

2015-09-11 Thread David Blaikie via cfe-commits
On Fri, Sep 11, 2015 at 11:54 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Sep 11 13:54:28 2015
> New Revision: 247447
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247447&view=rev
> Log:
> Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247447&r1=247446&r2=247447&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:54:28 2015
> @@ -1480,14 +1480,8 @@ static bool shouldOmitDefinition(CodeGen
>   const RecordDecl *RD,
>   const LangOptions &LangOpts) {
>// Does the type exist in an imported clang module?
> -  if (DebugTypeExtRefs && RD->isFromASTFile()) {
> -if (auto *CTSD = dyn_cast(RD))
> -  if (CTSD->isExplicitInstantiationOrSpecialization())
> -// We may not assume that this type made it into the module.
> -return true;
> -if (RD->getDefinition())
> +  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
>

Oh - and do we need to check for "getDefinition" here? Since this function
is itself (by name/use) already about whether definitions should be
omitted? I'm not sure, maybe it still makes sense...


>return true;
> -  }
>
>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>  return false;
>
>
> ___
> 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: r247432 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread David Blaikie via cfe-commits
On Fri, Sep 11, 2015 at 11:55 AM, Adrian Prantl  wrote:

>
> On Sep 11, 2015, at 11:21 AM, David Blaikie  wrote:
>
>
>
> On Fri, Sep 11, 2015 at 10:23 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Fri Sep 11 12:23:08 2015
>> New Revision: 247432
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247432&view=rev
>> Log:
>> Module Debugging: Emit forward declarations for types that are defined in
>> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
>>
>> This reimplements r247369 in about a third of the amount of code.
>> Thanks to David Blaikie pointing this out in post-commit review!
>>
>> Added:
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.m
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247432&r1=247431&r2=247432&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:08 2015
>> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>>  }
>>
>>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
>> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
>> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
>> +  return getContextDescriptor(cast(D->getDeclContext()),
>> +  Mod ? Mod : TheCU);
>>
>
> Might've been nice to separate the module-parenting part of the change,
> smaller patches (easier to revert, review, etc), the usual stuff.
>
>
>>  }
>>
>>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
>> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>>  if (CXXDecl->isDynamicClass())
>>return;
>>
>> +  if (DebugTypeExtRefs && RD->isFromASTFile())
>> +return;
>> +
>>QualType Ty = CGM.getContext().getRecordType(RD);
>>llvm::DIType *T = getTypeOrNull(Ty);
>>if (T && T->isForwardDecl())
>> @@ -1478,8 +1483,19 @@ static bool hasExplicitMemberDefinition(
>>  }
>>
>>  static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind,
>> + bool DebugTypeExtRefs,
>>   const RecordDecl *RD,
>>   const LangOptions &LangOpts) {
>> +  // Does the type exist in an imported clang module?
>> +  if (DebugTypeExtRefs && RD->isFromASTFile()) {
>> +if (auto *CTSD = dyn_cast(RD))
>> +  if (CTSD->isExplicitInstantiationOrSpecialization())
>> +// We may not assume that this type made it into the module.
>>
>
> I guess you mean "we may assume this type made it into the module"? (the
> "not" seems erroneous - but perhaps I'm misparsing the sentence?)
>
>
> Yes, I inverted the condition without inverting the comment.
>
>
>
>> +return true;
>>
>
> Does this case ^ actually do anything? (aren't all these instantiations
> going to be definitions anyway? so if you removed that code the below would
> return true anyway, wouldn't it?)
>
>
> Good catch! I removed the condition.
>
>
>
>> +if (RD->getDefinition())
>> +  return true;
>> +  }
>> +
>>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>>  return false;
>>
>> @@ -1513,7 +1529,8 @@ static bool shouldOmitDefinition(CodeGen
>>  llvm::DIType *CGDebugInfo::CreateType(const RecordType *Ty) {
>>RecordDecl *RD = Ty->getDecl();
>>llvm::DIType *T =
>> cast_or_null(getTypeOrNull(QualType(Ty, 0)));
>> -  if (T || shouldOmitDefinition(DebugKind, RD, CGM.getLangOpts())) {
>> +  if (T || shouldOmitDefinition(DebugKind, DebugTypeExtRefs, RD,
>> +CGM.getLangOpts())) {
>>  if (!T)
>>T = getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
>>  return T;
>> @@ -1616,6 +1633,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
>>if (!ID)
>>  return nullptr;
>>
>> +  // Return a forward declaration if this type was imported from a clang
>> module.
>>
>
> What's this extra code needed for? Isn't this what shouldOmitDefinition
> already does? It causes calls to getOrCreateRecordFwdDecl and so we should
> never get into the CreateTypeDefinition function for the type.
>
>
> An ObjCInterfaceType is not a RecordDecl, so we have to replicate this
> here.
>
>
>
>> +  if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition())
>> +return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
>> +  ID->getName(),
>> +  getDeclContextDescriptor(ID),
>> Unit, 0);
>> +
>>// Get overall information about the record type for the debug info.
>>llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
>>unsigned Line = 

Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread David Majnemer via cfe-commits
Reduced it a bit:
template 
void JSMethod();
class A {
  int printd(int);
  void printd();
};
void A::printd() { JSMethod(); }

This test case will crash clang at the revision before this commit which
means that something more mysterious/horrific is going on...

On Fri, Sep 11, 2015 at 11:10 AM, David Majnemer 
wrote:

> Taking a look, would appreciate it if we didn't revert this until I give
> it a fair shot.  Shouldn't take too long.
>
> On Fri, Sep 11, 2015 at 10:58 AM, Hans Wennborg  wrote:
>
>> This made the Chromium build sad. For example:
>>
>> http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio
>>
>> Reduction:
>>
>> $ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
>> -fms-compatibility -fms-compatibility-version=18.0 -std=c++11
>> -fdelayed-template-parsing a.ii
>>
>> template 
>> void JSMethod(char *, char *, int);
>> class A {
>>   int printd(int *, const int &, int &, int &);
>>   int printd_info;
>>   void printd() { JSMethod("", "", printd_info); }
>> };
>>
>>
>> On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
>>  wrote:
>> > Author: majnemer
>> > Date: Thu Sep 10 16:52:00 2015
>> > New Revision: 247346
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=247346&view=rev
>> > Log:
>> > [MS ABI] Make member pointers return true for isIncompleteType
>> >
>> > The type of a member pointer is incomplete if it has no inheritance
>> > model.  This lets us reuse more general logic already embedded in clang.
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

2015-09-11 Thread Jordan Rose via cfe-commits
jordan_rose added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp:53
@@ -52,3 +52,3 @@
 
-  if (ExplodedNode *N = C.addTransition()) {
+  if (ExplodedNode *N = C.generateNonFatalErrorNode()) {
 if (!BT)

zaks.anna wrote:
> Can this ever fail? In some cases we just assume it won't in others we tests..
> 
> Maybe it only fails when we cache out?
It does fail when we cache out, and I think we can still cache out if Pred has 
a different tag the second time around.


http://reviews.llvm.org/D12780



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


Re: r246877 - Increase accuracy of __builtin_object_size.

2015-09-11 Thread Mikhail Zolotukhin via cfe-commits
Hi George,

After this commit we started to trap on the following case:

#include 
typedef struct {
  int n;
  char key[1];
} obj_t;

char *str = "hello";

int main() {
  obj_t* p = (obj_t*)malloc(strlen(str) + 1 + sizeof(int));
  strcpy(p->key, str);
  free(p);
  return 0;
}

As far as I understand, this might be a common pattern in pre-C99 codebase, and 
it fails when compiled with -D_FORTIFY_SOURCE=2. Is there a way we could fix it 
in clang, or the only fix is to use less strict FORTIFY_SOURCE level?

Thanks,
Michael

> On Sep 4, 2015, at 2:28 PM, George Burgess IV via cfe-commits 
>  wrote:
> 
> Author: gbiv
> Date: Fri Sep  4 16:28:13 2015
> New Revision: 246877
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=246877&view=rev
> Log:
> Increase accuracy of __builtin_object_size.
> 
> Improvements:
> 
> - For all types, we would give up in a case such as:
>__builtin_object_size((char*)&foo, N);
>  even if we could provide an answer to
>__builtin_object_size(&foo, N);
>  We now provide the same answer for both of the above examples in all
>  cases.
> 
> - For type=1|3, we now support subobjects with unknown bases, as long
>  as the designator is valid.
> 
> Thanks to Richard Smith for the review + design planning.
> 
> Review: http://reviews.llvm.org/D12169
> 
> 
> Modified:
>cfe/trunk/lib/AST/ExprConstant.cpp
>cfe/trunk/test/CodeGen/object-size.c
> 
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=246877&r1=246876&r2=246877&view=diff
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Sep  4 16:28:13 2015
> @@ -492,7 +492,11 @@ namespace {
>   /// optimizer if we don't constant fold them here, but in an unevaluated
>   /// context we try to fold them immediately since the optimizer never
>   /// gets a chance to look at it.
> -  EM_PotentialConstantExpressionUnevaluated
> +  EM_PotentialConstantExpressionUnevaluated,
> +
> +  /// Evaluate as a constant expression. Continue evaluating if we find a
> +  /// MemberExpr with a base that can't be evaluated.
> +  EM_DesignatorFold,
> } EvalMode;
> 
> /// Are we checking whether the expression is a potential constant
> @@ -595,6 +599,7 @@ namespace {
>   case EM_PotentialConstantExpression:
>   case EM_ConstantExpressionUnevaluated:
>   case EM_PotentialConstantExpressionUnevaluated:
> +  case EM_DesignatorFold:
> HasActiveDiagnostic = false;
> return OptionalDiagnostic();
>   }
> @@ -674,6 +679,7 @@ namespace {
>   case EM_ConstantExpression:
>   case EM_ConstantExpressionUnevaluated:
>   case EM_ConstantFold:
> +  case EM_DesignatorFold:
> return false;
>   }
>   llvm_unreachable("Missed EvalMode case");
> @@ -702,10 +708,15 @@ namespace {
>   case EM_ConstantExpressionUnevaluated:
>   case EM_ConstantFold:
>   case EM_IgnoreSideEffects:
> +  case EM_DesignatorFold:
> return false;
>   }
>   llvm_unreachable("Missed EvalMode case");
> }
> +
> +bool allowInvalidBaseExpr() const {
> +  return EvalMode == EM_DesignatorFold;
> +}
>   };
> 
>   /// Object used to treat all foldable expressions as constant expressions.
> @@ -736,6 +747,21 @@ namespace {
> }
>   };
> 
> +  /// RAII object used to treat the current evaluation as the correct pointer
> +  /// offset fold for the current EvalMode
> +  struct FoldOffsetRAII {
> +EvalInfo &Info;
> +EvalInfo::EvaluationMode OldMode;
> +explicit FoldOffsetRAII(EvalInfo &Info, bool Subobject)
> +: Info(Info), OldMode(Info.EvalMode) {
> +  if (!Info.checkingPotentialConstantExpression())
> +Info.EvalMode = Subobject ? EvalInfo::EM_DesignatorFold
> +  : EvalInfo::EM_ConstantFold;
> +}
> +
> +~FoldOffsetRAII() { Info.EvalMode = OldMode; }
> +  };
> +
>   /// RAII object used to suppress diagnostics and side-effects from a
>   /// speculative evaluation.
>   class SpeculativeEvaluationRAII {
> @@ -917,7 +943,8 @@ namespace {
>   struct LValue {
> APValue::LValueBase Base;
> CharUnits Offset;
> -unsigned CallIndex;
> +bool InvalidBase : 1;
> +unsigned CallIndex : 31;
> SubobjectDesignator Designator;
> 
> const APValue::LValueBase getLValueBase() const { return Base; }
> @@ -938,17 +965,23 @@ namespace {
>   assert(V.isLValue());
>   Base = V.getLValueBase();
>   Offset = V.getLValueOffset();
> +  InvalidBase = false;
>   CallIndex = V.getLValueCallIndex();
>   Designator = SubobjectDesignator(Ctx, V);
> }
> 
> -void set(APValue::LValueBase B, unsigned I = 0) {
> +void set(APValue::LValueBase B, unsigned I = 0, bool BInvalid = false) {
>   Base = B;
>   Offset = CharUnits::Zero();

Re: [PATCH] D12780: [analyzer] Add generateErrorNode() APIs to CheckerContext

2015-09-11 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In general I like this change, the node handling of the checkers are more 
readable and reflects the intent in a clearer way.  I have some comments inline.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:244
@@ +243,3 @@
+  const ProgramPointTag *Tag = nullptr) {
+return generateSink(State, /*Pred=*/nullptr,
+   (Tag ? Tag : Location.getTag()));

zaks.anna wrote:
> Please, use a non-null Pred for clarity
The following workflow is not supported by this API: a checker that generates 
multiple transition in the same callback (the generated nodes are added 
sequentially to the path), and one of the might be an error node.

This also applies to generateNonFatalErrorNode.

In case we would like to improve the documentation it might be useful to give 
some pointers to the users which when should an error node be considered as 
fatal.


Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:322
@@ -290,1 +321,3 @@
+// the same as the predecessor state has made a mistake. We return the
+// predecessor and rather than cache out.
 if (!State || (State == Pred->getState() && !Tag && !MarkAsSink))

As a slightly related note: is it documented anywhere what "cache out" means? 
Maybe it would be great to refer to that document or write it if it is not 
written yet.


http://reviews.llvm.org/D12780



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


Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-09-11 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247451: Record function attribute "stackrealign" instead of 
using backend option (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D11815?vs=33456&id=34569#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11815

Files:
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/CodeGen/stackrealign.c
  cfe/trunk/test/Driver/rewrite-legacy-objc.m
  cfe/trunk/test/Driver/rewrite-objc.m
  cfe/trunk/test/Driver/stackrealign.c

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -150,7 +150,7 @@
 CODEGENOPT(VerifyModule  , 1, 1) ///< Control whether the module should be run
  ///< through the LLVM Verifier.
 
-CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to permit stack
+CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to force stack
  ///< realignment.
 CODEGENOPT(UseInitArray  , 1, 0) ///< Control whether to use .init_array or
  ///< .ctors.
Index: cfe/trunk/test/CodeGen/stackrealign.c
===
--- cfe/trunk/test/CodeGen/stackrealign.c
+++ cfe/trunk/test/CodeGen/stackrealign.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -mstackrealign | FileCheck %s -check-prefix=REALIGN
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-REALIGN
+
+// REALIGN: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+// NO-REALIGN-NOT: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+
+void test1() {
+}
Index: cfe/trunk/test/Driver/rewrite-objc.m
===
--- cfe/trunk/test/Driver/rewrite-objc.m
+++ cfe/trunk/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
Index: cfe/trunk/test/Driver/stackrealign.c
===
--- cfe/trunk/test/Driver/stackrealign.c
+++ cfe/trunk/test/Driver/stackrealign.c
@@ -1,12 +1,6 @@
-// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NORMAL
-// NORMAL-NOT: -force-align-stack
-// NORMAL: -mstackrealign
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
+// RUN: %clang -### -mno-stackrealign -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=REALIGN
+// RUN: %clang -### -mstackrealign -mno-stackrealign %s 2>&1 | FileCheck %s -check-prefix=NO-REALIGN
 
-// RUN: %clang -### -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=MREALIGN
-// MREALIGN: -force-align-stack
-// MREALIGN: -mstackrealign
-
-// RUN: %clang -### -mno-stackrealign %s 2>&1 | \
-// RUN: FileCheck %s -check-prefix=MNOREALIGN
-// MNOREALIGN-NOT: -force-align-stack
-// MNOREALIGN-NOT: -mstackrealign
+// REALIGN: -mstackrealign
+// NO-REALIGN-NOT: -mstackrealign
Index: cfe/trunk/test/Driver/rewrite-legacy-objc.m
===
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | 

r247451 - Record function attribute "stackrealign" instead of using backend option

2015-09-11 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri Sep 11 13:55:09 2015
New Revision: 247451

URL: http://llvm.org/viewvc/llvm-project?rev=247451&view=rev
Log:
Record function attribute "stackrealign" instead of using backend option
-force-align-stack.

Also, make changes to the driver so that -mno-stack-realign is no longer
an option exposed to the end-user that disallows stack realignment in
the backend.

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

Added:
cfe/trunk/test/CodeGen/stackrealign.c
Modified:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/rewrite-legacy-objc.m
cfe/trunk/test/Driver/rewrite-objc.m
cfe/trunk/test/Driver/stackrealign.c

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=247451&r1=247450&r2=247451&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Sep 11 13:55:09 2015
@@ -150,7 +150,7 @@ CODEGENOPT(UseRegisterSizedBitfieldAcces
 CODEGENOPT(VerifyModule  , 1, 1) ///< Control whether the module should be 
run
  ///< through the LLVM Verifier.
 
-CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to permit stack
+CODEGENOPT(StackRealignment  , 1, 0) ///< Control whether to force stack
  ///< realignment.
 CODEGENOPT(UseInitArray  , 1, 0) ///< Control whether to use .init_array or
  ///< .ctors.

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=247451&r1=247450&r2=247451&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Sep 11 13:55:09 2015
@@ -1494,8 +1494,8 @@ void CodeGenModule::ConstructAttributeLi
 FuncAttrs.addAttribute("stack-protector-buffer-size",
llvm::utostr(CodeGenOpts.SSPBufferSize));
 
-if (!CodeGenOpts.StackRealignment)
-  FuncAttrs.addAttribute("no-realign-stack");
+if (CodeGenOpts.StackRealignment)
+  FuncAttrs.addAttribute("stackrealign");
 
 // Add target-cpu and target-features attributes to functions. If
 // we have a decl for the function and it has a target attribute then

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=247451&r1=247450&r2=247451&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 11 13:55:09 2015
@@ -4326,14 +4326,8 @@ void Clang::ConstructJob(Compilation &C,
 
   // Translate -mstackrealign
   if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
-   false)) {
-CmdArgs.push_back("-backend-option");
-CmdArgs.push_back("-force-align-stack");
-  }
-  if (!Args.hasFlag(options::OPT_mno_stackrealign, options::OPT_mstackrealign,
-false)) {
+   false))
 CmdArgs.push_back(Args.MakeArgString("-mstackrealign"));
-  }
 
   if (Args.hasArg(options::OPT_mstack_alignment)) {
 StringRef alignment = Args.getLastArgValue(options::OPT_mstack_alignment);

Added: cfe/trunk/test/CodeGen/stackrealign.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stackrealign.c?rev=247451&view=auto
==
--- cfe/trunk/test/CodeGen/stackrealign.c (added)
+++ cfe/trunk/test/CodeGen/stackrealign.c Fri Sep 11 13:55:09 2015
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -mstackrealign | FileCheck %s 
-check-prefix=REALIGN
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-REALIGN
+
+// REALIGN: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+// NO-REALIGN-NOT: attributes #{{[0-9]+}} = {{{.*}} "stackrealign"
+
+void test1() {
+}

Modified: cfe/trunk/test/Driver/rewrite-legacy-objc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-legacy-objc.m?rev=247451&r1=247450&r2=247451&view=diff
==
--- cfe/trunk/test/Driver/rewrite-legacy-objc.m (original)
+++ cfe/trunk/test/Driver/rewrite-legacy-objc.m Fri Sep 11 13:55:09 2015
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency 
instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" 
"-fblocks" "-fobjc-runtime=macosx-fragile" "-fencode-extended-block-signature" 
"-fno-objc-infer

r247449 - Fix a typo and make this test stricter.

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:54:34 2015
New Revision: 247449

URL: http://llvm.org/viewvc/llvm-project?rev=247449&view=rev
Log:
Fix a typo and make this test stricter.

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.m

Modified: cfe/trunk/test/Modules/ExtDebugInfo.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.m?rev=247449&r1=247448&r2=247449&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.m (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.m Fri Sep 11 13:54:34 2015
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// Test that only forward declarations are emitted for types dfined in modules.
+// Test that only forward declarations are emitted for types defined in 
modules.
 
 // Modules:
 // RUN: %clang_cc1 -x objective-c -g -dwarf-ext-refs -fmodules \
@@ -23,7 +23,10 @@ int foo(ObjCClass *c) {
   return [c property];
 }
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
 // CHECK-SAME: scope: ![[MOD:[0-9]+]],
 // CHECK-SAME: flags: DIFlagFwdDecl)
+// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,
 // CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugObjC
+// CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type,


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


r247448 - Remove an unnecessary check. NFC

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:54:31 2015
New Revision: 247448

URL: http://llvm.org/viewvc/llvm-project?rev=247448&view=rev
Log:
Remove an unnecessary check. NFC

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247448&r1=247447&r2=247448&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:54:31 2015
@@ -2129,7 +2129,7 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCI
 }
 
 llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
-  if (!DebugTypeExtRefs || !D || !D->isFromASTFile())
+  if (!DebugTypeExtRefs || !D->isFromASTFile())
 return nullptr;
 
   llvm::DIModule *ModuleRef = nullptr;


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


Re: r247432 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread Adrian Prantl via cfe-commits

> On Sep 11, 2015, at 11:21 AM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Sep 11, 2015 at 10:23 AM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Fri Sep 11 12:23:08 2015
> New Revision: 247432
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=247432&view=rev 
> 
> Log:
> Module Debugging: Emit forward declarations for types that are defined in
> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
> 
> This reimplements r247369 in about a third of the amount of code.
> Thanks to David Blaikie pointing this out in post-commit review!
> 
> Added:
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.m
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247432&r1=247431&r2=247432&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:08 2015
> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>  }
> 
>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
> +  return getContextDescriptor(cast(D->getDeclContext()),
> +  Mod ? Mod : TheCU);
> 
> Might've been nice to separate the module-parenting part of the change, 
> smaller patches (easier to revert, review, etc), the usual stuff.
>  
>  }
> 
>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>  if (CXXDecl->isDynamicClass())
>return;
> 
> +  if (DebugTypeExtRefs && RD->isFromASTFile())
> +return;
> +
>QualType Ty = CGM.getContext().getRecordType(RD);
>llvm::DIType *T = getTypeOrNull(Ty);
>if (T && T->isForwardDecl())
> @@ -1478,8 +1483,19 @@ static bool hasExplicitMemberDefinition(
>  }
> 
>  static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind,
> + bool DebugTypeExtRefs,
>   const RecordDecl *RD,
>   const LangOptions &LangOpts) {
> +  // Does the type exist in an imported clang module?
> +  if (DebugTypeExtRefs && RD->isFromASTFile()) {
> +if (auto *CTSD = dyn_cast(RD))
> +  if (CTSD->isExplicitInstantiationOrSpecialization())
> +// We may not assume that this type made it into the module.
> 
> I guess you mean "we may assume this type made it into the module"? (the 
> "not" seems erroneous - but perhaps I'm misparsing the sentence?)

Yes, I inverted the condition without inverting the comment.

>  
> +return true;
> 
> Does this case ^ actually do anything? (aren't all these instantiations going 
> to be definitions anyway? so if you removed that code the below would return 
> true anyway, wouldn't it?)

Good catch! I removed the condition.

>  
> +if (RD->getDefinition())
> +  return true;
> +  }
> +
>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>  return false;
> 
> @@ -1513,7 +1529,8 @@ static bool shouldOmitDefinition(CodeGen
>  llvm::DIType *CGDebugInfo::CreateType(const RecordType *Ty) {
>RecordDecl *RD = Ty->getDecl();
>llvm::DIType *T = cast_or_null(getTypeOrNull(QualType(Ty, 
> 0)));
> -  if (T || shouldOmitDefinition(DebugKind, RD, CGM.getLangOpts())) {
> +  if (T || shouldOmitDefinition(DebugKind, DebugTypeExtRefs, RD,
> +CGM.getLangOpts())) {
>  if (!T)
>T = getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
>  return T;
> @@ -1616,6 +1633,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
>if (!ID)
>  return nullptr;
> 
> +  // Return a forward declaration if this type was imported from a clang 
> module.
> 
> What's this extra code needed for? Isn't this what shouldOmitDefinition 
> already does? It causes calls to getOrCreateRecordFwdDecl and so we should 
> never get into the CreateTypeDefinition function for the type.

An ObjCInterfaceType is not a RecordDecl, so we have to replicate this here.
>  
> +  if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition())
> +return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
> +  ID->getName(),
> +  getDeclContextDescriptor(ID), Unit, 0);
> +
>// Get overall information about the record type for the debug info.
>llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocatio

r247447 - Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:54:28 2015
New Revision: 247447

URL: http://llvm.org/viewvc/llvm-project?rev=247447&view=rev
Log:
Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247447&r1=247446&r2=247447&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:54:28 2015
@@ -1480,14 +1480,8 @@ static bool shouldOmitDefinition(CodeGen
  const RecordDecl *RD,
  const LangOptions &LangOpts) {
   // Does the type exist in an imported clang module?
-  if (DebugTypeExtRefs && RD->isFromASTFile()) {
-if (auto *CTSD = dyn_cast(RD))
-  if (CTSD->isExplicitInstantiationOrSpecialization())
-// We may not assume that this type made it into the module.
-return true;
-if (RD->getDefinition())
+  if (DebugTypeExtRefs && RD->isFromASTFile() && RD->getDefinition())
   return true;
-  }
 
   if (DebugKind > CodeGenOptions::LimitedDebugInfo)
 return false;


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


r247445 - Cleanup: Get rid of a bunch of unnecessary invocations of internString()

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 13:45:02 2015
New Revision: 247445

URL: http://llvm.org/viewvc/llvm-project?rev=247445&view=rev
Log:
Cleanup: Get rid of a bunch of unnecessary invocations of internString()
in CGDebugInfo.cpp: MDString::get() copies its arguments.

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247445&r1=247444&r2=247445&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 13:45:02 2015
@@ -345,13 +345,6 @@ void CGDebugInfo::CreateCompileUnit() {
 }
   }
 
-  // Save filename string.
-  StringRef Filename = internString(MainFileName);
-
-  // Save split dwarf file string.
-  std::string SplitDwarfFile = CGM.getCodeGenOpts().SplitDwarfFile;
-  StringRef SplitDwarfFilename = internString(SplitDwarfFile);
-
   llvm::dwarf::SourceLanguage LangTag;
   const LangOptions &LO = CGM.getLangOpts();
   if (LO.CPlusPlus) {
@@ -377,13 +370,13 @@ void CGDebugInfo::CreateCompileUnit() {
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, Filename, getCurrentDirname(), Producer, LO.Optimize,
-  CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers, SplitDwarfFilename,
+  LangTag, MainFileName, getCurrentDirname(), Producer, LO.Optimize,
+  CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
+  CGM.getCodeGenOpts().SplitDwarfFile,
   DebugKind <= CodeGenOptions::DebugLineTablesOnly
   ? llvm::DIBuilder::LineTablesOnly
   : llvm::DIBuilder::FullDebug,
-  0 /* DWOid */,
-  DebugKind != CodeGenOptions::LocTrackingOnly);
+  0 /* DWOid */, DebugKind != CodeGenOptions::LocTrackingOnly);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
@@ -775,9 +768,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
   Ty->getTemplateName().getAsTemplateDecl())->getTemplatedDecl();
 
   SourceLocation Loc = AliasDecl->getLocation();
-  return DBuilder.createTypedef(
-  Src, internString(OS.str()), getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(AliasDecl));
+  return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc),
+getLineNumber(Loc),
+getDeclContextDescriptor(AliasDecl));
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
@@ -1688,13 +1681,13 @@ CGDebugInfo::getOrCreateModuleRef(Extern
 }
   }
   llvm::DIBuilder DIB(CGM.getModule());
-  auto *CU = DIB.createCompileUnit(
-  TheCU->getSourceLanguage(), internString(Mod.ModuleName),
-  internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
-  internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
-  llvm::DIModule *M = DIB.createModule(
-  CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
-  internString(CGM.getHeaderSearchOpts().Sysroot));
+  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.ModuleName,
+   Mod.Path, TheCU->getProducer(), true,
+   StringRef(), 0, Mod.ASTFile,
+   llvm::DIBuilder::FullDebug, Mod.Signature);
+  llvm::DIModule *M =
+  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
+   CGM.getHeaderSearchOpts().Sysroot);
   DIB.finalize();
   ModRef.reset(M);
   return M;


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


r247444 - [Static Analyzer] Fixed a typo in a diagnostic message.

2015-09-11 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 11 13:41:50 2015
New Revision: 247444

URL: http://llvm.org/viewvc/llvm-project?rev=247444&view=rev
Log:
[Static Analyzer] Fixed a typo in a diagnostic message.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=247444&r1=247443&r2=247444&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Fri Sep 11 
13:41:50 2015
@@ -99,7 +99,7 @@ const char *const ErrorMessages[] = {
 "Nullable pointer is returned from a function that is expected to return a 
"
 "non-null value",
 "Nullable pointer is dereferenced",
-"Nullable pointer is passed to a calle that requires a non-null argument"};
+"Nullable pointer is passed to a callee that requires a non-null 
argument"};
 
 class NullabilityChecker
 : public Checker,


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


Re: [PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Mike Spertus via cfe-commits
mspertus added a comment.

Thanks, Aaron! Hal mentioned that I might need to ask you to commit on my 
behalf as I don't have commit access as of now.


http://reviews.llvm.org/D12807



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


Re: [PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit in r247442, thank you for the patch!


http://reviews.llvm.org/D12807



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


r247442 - Extend the Token visualizer used by MSVC to display the identifier text for tok::identifier tokens.

2015-09-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Sep 11 13:35:18 2015
New Revision: 247442

URL: http://llvm.org/viewvc/llvm-project?rev=247442&view=rev
Log:
Extend the Token visualizer used by MSVC to display the identifier text for 
tok::identifier tokens.

Patch by Mike Spertus.

Modified:
cfe/trunk/utils/clang.natvis

Modified: cfe/trunk/utils/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang.natvis?rev=247442&r1=247441&r2=247442&view=diff
==
--- cfe/trunk/utils/clang.natvis (original)
+++ cfe/trunk/utils/clang.natvis Fri Sep 11 13:35:18 2015
@@ -24,13 +24,14 @@ or create a symbolic link so it updates
   *(clang::IdentifierInfo *)(Ptr & 
~PtrMask)
   *(clang::IdentifierInfo *)(Ptr & 
~PtrMask)
   (clang::DeclarationNameExtra::ExtraKind)((clang::DeclarationNameExtra
 *)(Ptr & ~PtrMask))->ExtraKindOrNumArgs
-
-  
-  
-{(clang::tok::TokenKind)Kind}
-  
-  
-[{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]
+
+  
+  
+{(clang::tok::TokenKind)Kind}
+{{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
+  
+  
+[{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]
   
   
 {Name,s}


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


Re: r247432 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread David Blaikie via cfe-commits
On Fri, Sep 11, 2015 at 10:23 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Sep 11 12:23:08 2015
> New Revision: 247432
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247432&view=rev
> Log:
> Module Debugging: Emit forward declarations for types that are defined in
> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
>
> This reimplements r247369 in about a third of the amount of code.
> Thanks to David Blaikie pointing this out in post-commit review!
>
> Added:
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.m
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247432&r1=247431&r2=247432&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:08 2015
> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>  }
>
>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
> +  return getContextDescriptor(cast(D->getDeclContext()),
> +  Mod ? Mod : TheCU);
>

Might've been nice to separate the module-parenting part of the change,
smaller patches (easier to revert, review, etc), the usual stuff.


>  }
>
>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>  if (CXXDecl->isDynamicClass())
>return;
>
> +  if (DebugTypeExtRefs && RD->isFromASTFile())
> +return;
> +
>QualType Ty = CGM.getContext().getRecordType(RD);
>llvm::DIType *T = getTypeOrNull(Ty);
>if (T && T->isForwardDecl())
> @@ -1478,8 +1483,19 @@ static bool hasExplicitMemberDefinition(
>  }
>
>  static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind,
> + bool DebugTypeExtRefs,
>   const RecordDecl *RD,
>   const LangOptions &LangOpts) {
> +  // Does the type exist in an imported clang module?
> +  if (DebugTypeExtRefs && RD->isFromASTFile()) {
> +if (auto *CTSD = dyn_cast(RD))
> +  if (CTSD->isExplicitInstantiationOrSpecialization())
> +// We may not assume that this type made it into the module.
>

I guess you mean "we may assume this type made it into the module"? (the
"not" seems erroneous - but perhaps I'm misparsing the sentence?)


> +return true;
>

Does this case ^ actually do anything? (aren't all these instantiations
going to be definitions anyway? so if you removed that code the below would
return true anyway, wouldn't it?)


> +if (RD->getDefinition())
> +  return true;
> +  }
> +
>if (DebugKind > CodeGenOptions::LimitedDebugInfo)
>  return false;
>
> @@ -1513,7 +1529,8 @@ static bool shouldOmitDefinition(CodeGen
>  llvm::DIType *CGDebugInfo::CreateType(const RecordType *Ty) {
>RecordDecl *RD = Ty->getDecl();
>llvm::DIType *T = cast_or_null(getTypeOrNull(QualType(Ty,
> 0)));
> -  if (T || shouldOmitDefinition(DebugKind, RD, CGM.getLangOpts())) {
> +  if (T || shouldOmitDefinition(DebugKind, DebugTypeExtRefs, RD,
> +CGM.getLangOpts())) {
>  if (!T)
>T = getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
>  return T;
> @@ -1616,6 +1633,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
>if (!ID)
>  return nullptr;
>
> +  // Return a forward declaration if this type was imported from a clang
> module.
>

What's this extra code needed for? Isn't this what shouldOmitDefinition
already does? It causes calls to getOrCreateRecordFwdDecl and so we should
never get into the CreateTypeDefinition function for the type.


> +  if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition())
> +return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
> +  ID->getName(),
> +  getDeclContextDescriptor(ID), Unit,
> 0);
> +
>// Get overall information about the record type for the debug info.
>llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
>unsigned Line = getLineNumber(ID->getLocation());
> @@ -1669,9 +1692,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>TheCU->getSourceLanguage(), internString(Mod.ModuleName),
>internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
>internString(Mod.ASTFile), llvm::DIBuilder::FullDebug,
> Mod.Signature);
> -  llvm::DIModule *M =
> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros,
> internString(Mod.Path),
> -   

Re: [PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank for you this (I think it's going to help me out quite a bit)!


http://reviews.llvm.org/D12807



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


[PATCH] D12807: Display name of identifier tokens in Visual Studio native visualizer

2015-09-11 Thread Mike Spertus via cfe-commits
mspertus created this revision.
mspertus added a subscriber: cfe-commits.

The Token visualizer in clang.natvis makes debugging Clang in Visual Studio 
much easier for keywords (because a given keyword is always the same), but it 
doesn't work very well for identifiers (because they are all different). This 
change has the visualizer display the name of the identifier. I have been using 
this daily, and I find this simple change has lead to a much-improved 
day-to-day experience.

http://reviews.llvm.org/D12807

Files:
  utils/clang.natvis

Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -27,7 +27,8 @@
 
   
   
-{(clang::tok::TokenKind)Kind}
+{(clang::tok::TokenKind)Kind}
+{{Identifier 
({*(clang::IdentifierInfo *)(PtrData)})}}
   
   
 [{(clang::DeclSpec::SCS)StorageClassSpec}], 
[{(clang::TypeSpecifierType)TypeSpecType}]


Index: utils/clang.natvis
===
--- utils/clang.natvis
+++ utils/clang.natvis
@@ -27,7 +27,8 @@
 
   
   
-{(clang::tok::TokenKind)Kind}
+{(clang::tok::TokenKind)Kind}
+{{Identifier ({*(clang::IdentifierInfo *)(PtrData)})}}
   
   
 [{(clang::DeclSpec::SCS)StorageClassSpec}], [{(clang::TypeSpecifierType)TypeSpecType}]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread David Majnemer via cfe-commits
Taking a look, would appreciate it if we didn't revert this until I give it
a fair shot.  Shouldn't take too long.

On Fri, Sep 11, 2015 at 10:58 AM, Hans Wennborg  wrote:

> This made the Chromium build sad. For example:
>
> http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio
>
> Reduction:
>
> $ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
> -fms-compatibility -fms-compatibility-version=18.0 -std=c++11
> -fdelayed-template-parsing a.ii
>
> template 
> void JSMethod(char *, char *, int);
> class A {
>   int printd(int *, const int &, int &, int &);
>   int printd_info;
>   void printd() { JSMethod("", "", printd_info); }
> };
>
>
> On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
>  wrote:
> > Author: majnemer
> > Date: Thu Sep 10 16:52:00 2015
> > New Revision: 247346
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=247346&view=rev
> > Log:
> > [MS ABI] Make member pointers return true for isIncompleteType
> >
> > The type of a member pointer is incomplete if it has no inheritance
> > model.  This lets us reuse more general logic already embedded in clang.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Ah, ok. We have some objective-c++ code which calls into a boost routine which 
throws an exception. That results in an undefined reference to 
___objc_personality_v0, because the boost library we linked against doesn't 
have ___objc_personality_v0.

Should the compiler have found the ___objc_personality_v0 symbol in this case 
regardless?


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


Re: r247346 - [MS ABI] Make member pointers return true for isIncompleteType

2015-09-11 Thread Hans Wennborg via cfe-commits
This made the Chromium build sad. For example:
http://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/3092/steps/compile/logs/stdio

Reduction:

$ clang -cc1 -triple i686-pc-windows-msvc18.0.0 -w -fms-extensions
-fms-compatibility -fms-compatibility-version=18.0 -std=c++11
-fdelayed-template-parsing a.ii

template 
void JSMethod(char *, char *, int);
class A {
  int printd(int *, const int &, int &, int &);
  int printd_info;
  void printd() { JSMethod("", "", printd_info); }
};


On Thu, Sep 10, 2015 at 2:52 PM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Thu Sep 10 16:52:00 2015
> New Revision: 247346
>
> URL: http://llvm.org/viewvc/llvm-project?rev=247346&view=rev
> Log:
> [MS ABI] Make member pointers return true for isIncompleteType
>
> The type of a member pointer is incomplete if it has no inheritance
> model.  This lets us reuse more general logic already embedded in clang.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247438 - Use Itanium C++ ABI triple for new modules+debug test

2015-09-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Sep 11 12:50:14 2015
New Revision: 247438

URL: http://llvm.org/viewvc/llvm-project?rev=247438&view=rev
Log:
Use Itanium C++ ABI triple for new modules+debug test

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=247438&r1=247437&r2=247438&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Sep 11 12:50:14 2015
@@ -4,13 +4,16 @@
 // Modules:
 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -g -dwarf-ext-refs -fmodules \
 // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
+// RUN: -triple %itanium_abi_triple \
 // RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o 
%t-mod.ll
 // RUN: cat %t-mod.ll |  FileCheck %s
 
 // PCH:
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs 
\
+// RUN: -triple %itanium_abi_triple \
 // RUN: -o %t.pch %S/Inputs/DebugCXX.h
 // RUN: %clang_cc1 -std=c++11 -g -dwarf-ext-refs -fmodule-format=obj \
+// RUN: -triple %itanium_abi_triple \
 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
 // RUN: cat %t-pch.ll |  FileCheck %s
 
@@ -66,4 +69,4 @@ char _anchor = anon_enum + conflicting_u
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
 // CHECK-SAME: line: 16
 
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: 21)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: 24)


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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Right, I understand the behavior change, I'm just wondering why it results in 
link failures. There isn't a ton of public info about how ObjC++ EH interacts 
with C++ EH.


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk marked an inline comment as done.
vsk added a comment.

Addressed Reid's comment w.r.t exception object type.


Repository:
  rL LLVM

http://reviews.llvm.org/D12743



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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247437: [test] Specify exception object type in two tests 
(authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D12743?vs=34408&id=34560#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12743

Files:
  cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
  cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm

Index: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
===
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
@@ -11,7 +11,7 @@
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }
Index: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
===
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
@@ -5,7 +5,7 @@
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }


Index: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
===
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
@@ -11,7 +11,7 @@
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }
Index: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
===
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
@@ -5,7 +5,7 @@
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247437 - [test] Specify exception object type in two tests

2015-09-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Sep 11 12:39:34 2015
New Revision: 247437

URL: http://llvm.org/viewvc/llvm-project?rev=247437&view=rev
Log:
[test] Specify exception object type in two tests

Replace:
'try { throw 0; } catch (...)'
with
'try { throw 0; } catch (int e)'

in two test cases.

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

Modified:
cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm

Modified: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm?rev=247437&r1=247436&r2=247437&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm Fri Sep 11 12:39:34 2015
@@ -5,7 +5,7 @@ namespace test0 {
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }

Modified: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm?rev=247437&r1=247436&r2=247437&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm Fri Sep 11 12:39:34 2015
@@ -11,7 +11,7 @@ void *abuse_personality_func() {
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }


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


r247436 - [CMake] Making the bootstrap-clear target always delete the boostrap build directories.

2015-09-11 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 11 12:38:38 2015
New Revision: 247436

URL: http://llvm.org/viewvc/llvm-project?rev=247436&view=rev
Log:
[CMake] Making the bootstrap-clear target always delete the boostrap build 
directories.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=247436&r1=247435&r2=247436&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 11 12:38:38 2015
@@ -598,7 +598,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
 COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
 COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
 COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}
-COMMAND ${CMAKE_COMMAND} -E touch 
${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared
 COMMENT "Clobberring bootstrap build and stamp directories"
 )
 


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


Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Vedant Kumar via cfe-commits
vsk added a comment.

I think 'optimization' is a bit of a misnomer. There's a comment in this code 
that reads: "Can't do the optimization if it has non-C++ uses", so that's why I 
picked up the word. Without SimplifyPersonality(), some objective c++ code can 
no longer link against c++ libraries.

Consider the following test:
$ echo "#include " "\n" 'void foo() { throw 
std::runtime_error("foo"); }' | clang -x objective-cxx -S -emit-llvm - -o - | 
grep personality

After we moved personality from landingpadinst to functions, the output of the 
test changes (from __gxx_personality to __objc_personality). This commit just 
takes us back to the original behavior.

The original comment, "Otherwise, it has to be a landingpad instruction.", is 
wrong after David's patch.


http://reviews.llvm.org/D12743



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


r247434 - Update test expectations for LLVM asm printing change

2015-09-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Sep 11 12:27:53 2015
New Revision: 247434

URL: http://llvm.org/viewvc/llvm-project?rev=247434&view=rev
Log:
Update test expectations for LLVM asm printing change

Modified:
cfe/trunk/test/CodeGen/exceptions-seh-new.c

Modified: cfe/trunk/test/CodeGen/exceptions-seh-new.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-new.c?rev=247434&r1=247433&r2=247434&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh-new.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-new.c Fri Sep 11 12:27:53 2015
@@ -30,8 +30,9 @@ int safe_div(int numerator, int denomina
 // CHECK:   to label %{{.*}} unwind label %[[catchpad:[^ ]*]]
 //
 // CHECK: [[catchpad]]
-// X64: %[[padtoken:[^ ]*]] = catchpad [i8* null] to label %[[exceptret:[^ 
]*]] unwind label
-// X86: %[[padtoken:[^ ]*]] = catchpad [i8* bitcast (i32 ()* 
@"\01?filt$0@0@safe_div@@" to i8*)] to label %[[exceptret:[^ ]*]] unwind label
+// X64: %[[padtoken:[^ ]*]] = catchpad [i8* null]
+// X86: %[[padtoken:[^ ]*]] = catchpad [i8* bitcast (i32 ()* 
@"\01?filt$0@0@safe_div@@" to i8*)]
+// CHECK-NEXT:to label %[[exceptret:[^ ]*]] unwind label
 //
 // CHECK: [[exceptret]]
 // CHECK: catchret %[[padtoken]] to label %[[except:[^ ]*]]
@@ -113,7 +114,8 @@ int nested_try(void) {
 // CHECK:   to label %[[cont:[^ ]*]] unwind label %[[cpad_inner:[^ ]*]]
 //
 // CHECK: [[cpad_inner]]
-// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$1@0@nested_try@@" to 
i8*)] to label %[[exceptret_inner:[^ ]*]] unwind label %[[cpad_outer:[^ ]*]]
+// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$1@0@nested_try@@" to 
i8*)]
+// CHECK-NEXT: to label %[[exceptret_inner:[^ ]*]] unwind label 
%[[cpad_outer:[^ ]*]]
 //
 // CHECK: [[exceptret_inner]]
 // CHECK: catchret {{.*}} to label %[[except_inner:[^ ]*]]
@@ -126,7 +128,8 @@ int nested_try(void) {
 // CHECK: br label %[[outer_try_cont:[^ ]*]]
 //
 // CHECK: [[cpad_outer]]
-// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$0@0@nested_try@@" to 
i8*)] to label %[[exceptret_outer:[^ ]*]] unwind label
+// CHECK: catchpad [i8* bitcast (i32 ({{.*}})* @"\01?filt$0@0@nested_try@@" to 
i8*)]
+// CHECK-NEXT: to label %[[exceptret_outer:[^ ]*]] unwind label
 //
 // CHECK: [[exceptret_outer]]
 // CHECK: catchret {{.*}} to label %[[except_outer:[^ ]*]]


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


Re: r247369 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread Adrian Prantl via cfe-commits

> On Sep 11, 2015, at 8:27 AM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Sep 11, 2015 at 8:18 AM, Adrian Prantl  > wrote:
> 
>> On Sep 10, 2015, at 6:56 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Thu, Sep 10, 2015 at 6:40 PM, David Blaikie > > wrote:
>> 
>> 
>> On Thu, Sep 10, 2015 at 6:03 PM, Adrian Prantl via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: adrian
>> Date: Thu Sep 10 20:03:26 2015
>> New Revision: 247369
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=247369&view=rev 
>> 
>> Log:
>> Module Debugging: Emit forward declarations for types that are defined in
>> clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.
>> 
>> This change seems to have a lot more code in it than I was expecting... 
>> 
>> I was rather expecting something a lot like the flimit-debug-info support. 
>> Specifically, I would've expected one more conditional added to 
>> CGDebugInfo::shouldOmitDefinition.
>> 
>> Why the extra complexity?
>> 
>> I guess part of it is to be able to omit definitions of things other than 
>> record types - is there much value in that? (especially typedefs - it seems 
>> like a typedef is too small to benefit from a declaration (even if we could 
>> emit one)?)
> 
> The typedef itself is not interesting, but it can be used to anchor template 
> instantiations like std::string. The contract between the debug info in the 
> module and the debug info referencing the module is that all explicit 
> template specializations 
> 
> This I get ^ (though does that case need any special handling, or will the 
> isFromASTFile return true for the location of the explicit specialization 
> declaration/definition?)
>  
> and template instantiations referenced used in a typedef can be expected to 
> exist in the module.
> 
> This I do not get & would imagine it could cause substantial size increase... 
> 
> Might be worth splitting out that change to look at it more carefully. I'd 
> love to see numbers here.
>> Also, we could possibly solve both the problem of "don't emit definitions 
>> for module things when compiling the main source file" and "don't emit 
>> definitions for module things defined in other modules" with the same tool. 
>> If there's a way to say "is this in a foreign AST file" then testing for 
>> that in CGDebugInfo::shouldOmitDefinition would solve both problems, I think 
>> (conditionalized on the appropriate flags, either dwarf-ext-refs or "I'm 
>> building a module here”).
> 
> I believe that this is a good point. Really, getExtRefOrNull is a separate 
> function mostly for evolutionary reasons — it used to do different things 
> like mangling names of ObjC types etc. I will see if I can merge the existing 
> functionality into shouldOmitDefinition().
> 
> From a review perspective it might be easier to revert this & commit a new 
> patch - I haven't reviewed all these changes in detail because they just 
> seemed more complex than necessary, but if you're going to evolve it from 
> here I'll need to dig into the current implementation/be more careful about 
> checking that future changes remove the complexity along with whatever they 
> add.
> 

I just did this in r24743[12].

-- adrian

> - Dave
>  
> 
> -- adrian
> 
>>  
>>  
>> 
>> Added:
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.m
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247369&r1=247368&r2=247369&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 10 20:03:26 2015
>> @@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
>>  }
>> 
>>  llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
>> -  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
>> +  llvm::DIScope *Mod = getParentModuleOrNull(D);
>> +  return getContextDescriptor(cast(D->getDeclContext()),
>> +  Mod ? Mod : TheCU);
>>  }
>> 
>>  llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
>> @@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
>>  if (CXXDecl->isDynamicClass())
>>return;
>> 
>> +  if (DebugTypeExtRefs && RD->isFromASTFile())
>> +return;
>> +
>>QualType Ty = CGM.getContext().getRecordType(RD);
>>llvm::DIType *T = getTypeOrNull(Ty);
>>if (T && T->isForwardDecl())
>> @@ -1669,9 +1674,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>>TheCU->

r247431 - Revert "Module Debugging: Emit forward declarations for types that are defined in"

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 12:23:03 2015
New Revision: 247431

URL: http://llvm.org/viewvc/llvm-project?rev=247431&view=rev
Log:
Revert "Module Debugging: Emit forward declarations for types that are defined 
in"

This reverts commit r247369 to facilitate reviewing of the following patch.

Removed:
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.m
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247431&r1=247430&r2=247431&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:03 2015
@@ -148,9 +148,7 @@ void CGDebugInfo::setLocation(SourceLoca
 }
 
 llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
-  llvm::DIScope *Mod = getParentModuleOrNull(D);
-  return getContextDescriptor(cast(D->getDeclContext()),
-  Mod ? Mod : TheCU);
+  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
 }
 
 llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
@@ -1450,9 +1448,6 @@ void CGDebugInfo::completeRequiredType(c
 if (CXXDecl->isDynamicClass())
   return;
 
-  if (DebugTypeExtRefs && RD->isFromASTFile())
-return;
-
   QualType Ty = CGM.getContext().getRecordType(RD);
   llvm::DIType *T = getTypeOrNull(Ty);
   if (T && T->isForwardDecl())
@@ -1674,9 +1669,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   TheCU->getSourceLanguage(), internString(Mod.ModuleName),
   internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
   internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
-  llvm::DIModule *M = DIB.createModule(
-  CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
-  internString(CGM.getHeaderSearchOpts().Sysroot));
+  llvm::DIModule *M =
+  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, 
internString(Mod.Path),
+   internString(CGM.getHeaderSearchOpts().Sysroot));
   DIB.finalize();
   ModRef.reset(M);
   return M;
@@ -2086,16 +2081,9 @@ llvm::DIType *CGDebugInfo::getOrCreateTy
   if (auto *T = getTypeOrNull(Ty))
 return T;
 
-  llvm::DIType *Res = nullptr;
-  if (DebugTypeExtRefs)
-// Make a forward declaration of an external type.
-Res = getTypeExtRefOrNull(Ty, Unit);
-
   // Otherwise create the type.
-  if (!Res)
-Res = CreateTypeNode(Ty, Unit);
-
-  void* TyPtr = Ty.getAsOpaquePtr();
+  llvm::DIType *Res = CreateTypeNode(Ty, Unit);
+  void *TyPtr = Ty.getAsOpaquePtr();
 
   // And update the type cache.
   TypeCache[TyPtr].reset(Res);
@@ -2127,123 +2115,6 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCI
   }
 }
 
-llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
-  if (!DebugTypeExtRefs || !D || !D->isFromASTFile())
-return nullptr;
-
-  llvm::DIModule *ModuleRef = nullptr;
-  auto *Reader = CGM.getContext().getExternalSource();
-  auto Idx = D->getOwningModuleID();
-  auto Info = Reader->getSourceDescriptor(Idx);
-  if (Info)
-ModuleRef = getOrCreateModuleRef(*Info);
-  return ModuleRef;
-}
-
-llvm::DIType *CGDebugInfo::getTypeExtRefOrNull(QualType Ty, llvm::DIFile *F,
-   bool Anchored) {
-  assert(DebugTypeExtRefs && "module debugging only");
-  Decl *TyDecl = nullptr;
-  StringRef Name;
-  SmallString<256> UID;
-  unsigned Tag = 0;
-
-  // Handle all types that have a declaration.
-  switch (Ty->getTypeClass()) {
-  case Type::Typedef: {
-TyDecl = cast(Ty)->getDecl();
-if (!TyDecl->isFromASTFile())
-  return nullptr;
-
-// A typedef will anchor a type in the module.
-if (auto *TD = dyn_cast(TyDecl)) {
-  // This is a working around the fact that LLVM does not allow
-  // typedefs to be forward declarations.
-  QualType Ty = TD->getUnderlyingType();
-  Ty = UnwrapTypeForDebugInfo(Ty, CGM.getContext());
-  if (auto *AnchoredTy = getTypeExtRefOrNull(Ty, F, /*Anchored=*/true)) {
-TypeCache[Ty.getAsOpaquePtr()].reset(AnchoredTy);
-SourceLocation Loc = TD->getLocation();
-return DBuilder.createTypedef(AnchoredTy, TD->getName(),
-  getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(TD));
-  }
-}
-break;
-  }
-
-  case Type::Record: {
-TyDecl = cast(Ty)->getDecl();
-if (!TyDecl->isFromASTFile())
-  return nullptr;
-
-if (auto *CTSD = dyn_cast(TyDecl))
-  if (!CTSD->isExplicitInstantiationOrSpecialization() && !Anchored)
-// We may not assume that this type made it into the module.
-return nullptr;
-// C++ classes and template instantiations.
-if (auto *RD = dyn_cast(TyDecl)) {
-  if (!RD->getDefinit

Re: PATCH: Expose the 'file' that is associated with a compile database command

2015-09-11 Thread Manuel Klimek via cfe-commits
Ok, looked at the original patch again, and if we're fixing the
FixedCompilationDatabase to only insert the file when it actually produces
a CompileCommand it seems to be fine.

On Fri, Sep 11, 2015 at 6:32 PM Argyrios Kyrtzidis 
wrote:

> On Sep 11, 2015, at 12:21 AM, Manuel Klimek  wrote:
>
> On Thu, Sep 10, 2015 at 8:36 PM Argyrios Kyrtzidis 
> wrote:
>
>> On Sep 10, 2015, at 1:48 AM, Manuel Klimek  wrote:
>>
>> @@ -179,11 +185,13 @@ public:
>>/// \param Directory The base directory used in the
>> FixedCompilationDatabase.
>>static FixedCompilationDatabase *loadFromCommandLine(int &Argc,
>> const char
>> *const *Argv,
>> -   Twine Directory =
>> ".");
>> +   Twine Directory =
>> ".",
>> +   Twine File =
>> Twine());
>>
>> A fixed compilation database returns the same command lines for all
>> files, thus having a file in the function seems strange.
>>
>>
>> Ah ok, thanks for clarifying.
>>
>>
>> What exactly is the use case? So far, the compilation database has been
>> designed for 2 use cases:
>> 1. for a file, get the compile commands; the user already knows the file,
>> no need to get the file
>> 2. get all compile commands; for that, we have the getAllFiles() method,
>> so a user can get all known files (for compilation databases that support
>> that), and then get the compile command line.
>>
>>
>> It’s #2, I want to get all compile commands. But it seems really strange
>> to me that the ‘file’ starts as a property of the compile command in the
>> json file but then it gets dropped and I need to do work to re-associate
>> the files with the compile commands again.
>>
>
> The JSON file format is one possible implementation for the
> compilation-database interface. The FixedCompilationDatabase is another
> one, that doesn't have any information on files.
>
>
>> I need to get a list of all the files and then for each one do a lookup
>> to get the associated commands. I then have to maintain this association
>> myself, passing a command along with its file separately or the structure
>> that keeps track of the association.
>>
>> It seems simpler to me to include the file that was associated with the
>> command (if the compilation database supports that) along with the command,
>> is there a downside I’m missing ?
>>
>
> Well, to me, it's a design question - if it also makes sense to have a
> CompileCommand without a file associated with it, putting the file in
> there, while convenient, is a design smell.
>
>
> It can be optional to communicate that it may not be there. Note that,
> IMO, having multiple files and compile commands for them is the
> overwhelmingly most common use of the compilation database.
>
> That said, I'm happy to be convinced that I'm wrong :) I guess I don't see
> yet that keeping track of the files outside is more than one line of extra
> code.
>
>
> Not sure what *one* line this is, I have to declare a map and then
> populate it, no ? And to do it in c-index-test it would take way more that
> one line.
> But it is also beyond populating a map, this has an effect on APIs using a
> CompileCommand. For example:
>
> void doSomethingWithCompileCommand(const CompileCommand &cmd);
>
> Ah it would be useful to know the file that this command was associated
> with:
>
> void doSomethingWithCompileCommand(const CompileCommand &cmd, StringRef
> filename);
>
> What do I have now ? This is a function taking a command and a string for
> the filename separately.
> Is this flexibility useful ? Does it make sense to pass any filename there
> ? No there’s only one filename that the command was associated with so this
> ‘flexibility’ only increases the complexity of using the function. And this
> can propagate to other function’s callees.
> This seems like a design smell to me.
>
>
> Cheers,
> /Manuel
>
>
>>
>>
>> Thoughts?
>> /Manuel
>>
>> On Wed, Sep 9, 2015 at 9:36 PM Argyrios Kyrtzidis 
>> wrote:
>>
>>> Hi,
>>>
>>> The attached patch exposes the ‘file’ entry in a compilation database
>>> command, via the CompileCommand structure.
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247432 - Module Debugging: Emit forward declarations for types that are defined in

2015-09-11 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 11 12:23:08 2015
New Revision: 247432

URL: http://llvm.org/viewvc/llvm-project?rev=247432&view=rev
Log:
Module Debugging: Emit forward declarations for types that are defined in
clang modules, if -dwarf-ext-refs (DebugTypesExtRefs) is specified.

This reimplements r247369 in about a third of the amount of code.
Thanks to David Blaikie pointing this out in post-commit review!

Added:
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.m
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=247432&r1=247431&r2=247432&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 11 12:23:08 2015
@@ -148,7 +148,9 @@ void CGDebugInfo::setLocation(SourceLoca
 }
 
 llvm::DIScope *CGDebugInfo::getDeclContextDescriptor(const Decl *D) {
-  return getContextDescriptor(cast(D->getDeclContext()), TheCU);
+  llvm::DIScope *Mod = getParentModuleOrNull(D);
+  return getContextDescriptor(cast(D->getDeclContext()),
+  Mod ? Mod : TheCU);
 }
 
 llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context,
@@ -1448,6 +1450,9 @@ void CGDebugInfo::completeRequiredType(c
 if (CXXDecl->isDynamicClass())
   return;
 
+  if (DebugTypeExtRefs && RD->isFromASTFile())
+return;
+
   QualType Ty = CGM.getContext().getRecordType(RD);
   llvm::DIType *T = getTypeOrNull(Ty);
   if (T && T->isForwardDecl())
@@ -1478,8 +1483,19 @@ static bool hasExplicitMemberDefinition(
 }
 
 static bool shouldOmitDefinition(CodeGenOptions::DebugInfoKind DebugKind,
+ bool DebugTypeExtRefs,
  const RecordDecl *RD,
  const LangOptions &LangOpts) {
+  // Does the type exist in an imported clang module?
+  if (DebugTypeExtRefs && RD->isFromASTFile()) {
+if (auto *CTSD = dyn_cast(RD))
+  if (CTSD->isExplicitInstantiationOrSpecialization())
+// We may not assume that this type made it into the module.
+return true;
+if (RD->getDefinition())
+  return true;
+  }
+
   if (DebugKind > CodeGenOptions::LimitedDebugInfo)
 return false;
 
@@ -1513,7 +1529,8 @@ static bool shouldOmitDefinition(CodeGen
 llvm::DIType *CGDebugInfo::CreateType(const RecordType *Ty) {
   RecordDecl *RD = Ty->getDecl();
   llvm::DIType *T = cast_or_null(getTypeOrNull(QualType(Ty, 0)));
-  if (T || shouldOmitDefinition(DebugKind, RD, CGM.getLangOpts())) {
+  if (T || shouldOmitDefinition(DebugKind, DebugTypeExtRefs, RD,
+CGM.getLangOpts())) {
 if (!T)
   T = getOrCreateRecordFwdDecl(Ty, getDeclContextDescriptor(RD));
 return T;
@@ -1616,6 +1633,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
   if (!ID)
 return nullptr;
 
+  // Return a forward declaration if this type was imported from a clang 
module.
+  if (DebugTypeExtRefs && ID->isFromASTFile() && ID->getDefinition())
+return DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
+  ID->getName(),
+  getDeclContextDescriptor(ID), Unit, 0);
+
   // Get overall information about the record type for the debug info.
   llvm::DIFile *DefUnit = getOrCreateFile(ID->getLocation());
   unsigned Line = getLineNumber(ID->getLocation());
@@ -1669,9 +1692,9 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   TheCU->getSourceLanguage(), internString(Mod.ModuleName),
   internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
   internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
-  llvm::DIModule *M =
-  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, 
internString(Mod.Path),
-   internString(CGM.getHeaderSearchOpts().Sysroot));
+  llvm::DIModule *M = DIB.createModule(
+  CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
+  internString(CGM.getHeaderSearchOpts().Sysroot));
   DIB.finalize();
   ModRef.reset(M);
   return M;
@@ -1930,6 +1953,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
   const EnumDecl *ED = Ty->getDecl();
+
   uint64_t Size = 0;
   uint64_t Align = 0;
   if (!ED->getTypeForDecl()->isIncompleteType()) {
@@ -1939,9 +1963,12 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
 
   SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
 
+  bool isImportedFromModule =
+  DebugTypeExtRefs && ED->isFromASTFile() && ED->getDefinition();
+
   // If this is just a forward declaration, construct an appropriately
   // marked node and just return it.
-  if (!ED->getDefinition()) {
+  if (isImportedFromModule || !ED->getDefinition()) 

  1   2   >