r278734 - [CUDA] Include CUDA headers before anything else.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 15:38:52 2016
New Revision: 278734

URL: http://llvm.org/viewvc/llvm-project?rev=278734&view=rev
Log:
[CUDA] Include CUDA headers before anything else.

Summary:
There's no point to --cuda-path if we then go and include /usr/include
first.  And if you install the right packages, Ubuntu will install (very
old) CUDA headers there.

Reviewers: tra

Subscribers: cfe-commits, Prazek

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=278734&r1=278733&r2=278734&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Aug 15 15:38:52 2016
@@ -410,6 +410,13 @@ void Clang::AddPreprocessingOptions(Comp
 }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@ void Clang::AddPreprocessingOptions(Comp
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.

Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278734&r1=278733&r2=278734&view=diff
==
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Mon Aug 15 15:38:52 2016
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"


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


Re: [PATCH] D23340: [CUDA] Fix CUDA install version parsing.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278733: [CUDA] Fix CUDA install version parsing. (authored 
by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23340?vs=67438&id=68071#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23340

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1730,8 +1730,8 @@
   int Major = -1, Minor = -1;
   auto First = V.split('.');
   auto Second = First.second.split('.');
-  if (!First.first.getAsInteger(10, Major) ||
-  !Second.first.getAsInteger(10, Minor))
+  if (First.first.getAsInteger(10, Major) ||
+  Second.first.getAsInteger(10, Minor))
 return CudaVersion::UNKNOWN;
 
   if (Major == 7 && Minor == 0) {


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1730,8 +1730,8 @@
   int Major = -1, Minor = -1;
   auto First = V.split('.');
   auto Second = First.second.split('.');
-  if (!First.first.getAsInteger(10, Major) ||
-  !Second.first.getAsInteger(10, Minor))
+  if (First.first.getAsInteger(10, Major) ||
+  Second.first.getAsInteger(10, Minor))
 return CudaVersion::UNKNOWN;
 
   if (Major == 7 && Minor == 0) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23341: [CUDA] Include CUDA headers before anything else.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278734: [CUDA] Include CUDA headers before anything else. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23341?vs=67439&id=68072#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23341

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -410,6 +410,13 @@
 }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
Index: cfe/trunk/test/Driver/cuda-detect.cu
===
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -410,6 +410,13 @@
 }
   }
 
+  // Add offload include arguments specific for CUDA.  This must happen before
+  // we -I or -include anything else, because we must pick up the CUDA headers
+  // from the particular CUDA installation, rather than from e.g.
+  // /usr/local/include.
+  if (JA.isOffloading(Action::OFK_Cuda))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless
@@ -607,10 +614,6 @@
 // For IAMCU add special include arguments.
 getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
   }
-
-  // Add offload include arguments specific for CUDA if that is required.
-  if (JA.isOffloading(Action::OFK_Cuda))
-getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
Index: cfe/trunk/test/Driver/cuda-detect.cu
===
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -96,6 +96,9 @@
 // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"
 // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"
 // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"
+// -internal-externc-isystem flags must come *after* the cuda include flags,
+// because we must search the cuda include directory first.
+// CUDAINC-SAME: "-internal-externc-isystem"
 // COMMON-SAME: "-x" "cuda"
 // CHECK-CXXINCLUDE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CHECK-CXXINCLUDE-SAME: {{.*}}"-internal-isystem" "{{.+}}/include/c++/4.8"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23241: Add the notion of deferred diagnostics.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278735: Add the notion of deferred diagnostics. (authored by 
jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23241?vs=68063&id=68073#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23241

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h

Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -3446,6 +3446,20 @@
   return 0;
 }
 
+void FunctionDecl::addDeferredDiag(PartialDiagnosticAt PD) {
+  getASTContext().getDeferredDiags()[this].push_back(std::move(PD));
+}
+
+std::vector FunctionDecl::takeDeferredDiags() const {
+  auto &DD = getASTContext().getDeferredDiags();
+  auto It = DD.find(this);
+  if (It == DD.end())
+return {};
+  auto Ret = std::move(It->second);
+  DD.erase(It);
+  return Ret;
+}
+
 //===--===//
 // FieldDecl Implementation
 //===--===//
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -497,6 +497,16 @@
   EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
+
+  // Emit any deferred diagnostics gathered during codegen.  We didn't emit them
+  // when we first discovered them because that would have halted codegen,
+  // preventing us from gathering other deferred diags.
+  for (const PartialDiagnosticAt &DiagAt : DeferredDiags) {
+SourceLocation Loc = DiagAt.first;
+const PartialDiagnostic &PD = DiagAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
@@ -2872,6 +2882,33 @@
  llvm::GlobalValue *GV) {
   const auto *D = cast(GD.getDecl());
 
+  // Emit this function's deferred diagnostics, if none of them are errors.  If
+  // any of them are errors, don't codegen the function, but also don't emit any
+  // of the diagnostics just yet.  Emitting an error during codegen stops
+  // further codegen, and we want to display as many deferred diags as possible.
+  // We'll emit the now twice-deferred diags at the very end of codegen.
+  //
+  // (If a function has both error and non-error diags, we don't emit the
+  // non-error diags here, because order can be significant, e.g. with notes
+  // that follow errors.)
+  auto Diags = D->takeDeferredDiags();
+  bool HasError = llvm::any_of(Diags, [this](const PartialDiagnosticAt &PDAt) {
+return getDiags().getDiagnosticLevel(PDAt.second.getDiagID(), PDAt.first) >=
+   DiagnosticsEngine::Error;
+  });
+  if (HasError) {
+DeferredDiags.insert(DeferredDiags.end(),
+ std::make_move_iterator(Diags.begin()),
+ std::make_move_iterator(Diags.end()));
+return;
+  }
+  for (PartialDiagnosticAt &PDAt : Diags) {
+const SourceLocation &Loc = PDAt.first;
+const PartialDiagnostic &PD = PDAt.second;
+DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID()));
+PD.Emit(Builder);
+  }
+
   // Compute the function info and LLVM type.
   const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
   llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -490,6 +490,10 @@
   /// MDNodes.
   llvm::DenseMap MetadataIdMap;
 
+  /// Diags gathered from FunctionDecl::takeDeferredDiags().  Emitted at the
+  /// very end of codegen.
+  std::vector> DeferredDiags;
+
 public:
   CodeGenModule(ASTContext &C, const HeaderSearchOptions &headersearchopts,
 const PreprocessorOptions &ppopts,
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -2271,6 +2271,14 @@
   /// returns 0.
   unsigned getMemoryFunctionKind() const;
 
+  /// Add a diagnostic to be emitted if and when this function is codegen'ed.
+  void addDeferredDiag(PartialDiagnosticAt PD);
+
+  /// Gets this object's list of deferred diagnostics, if there are any.
+  ///
+  /// Although this is logically const, it clears our list of deferred diags.
+  std::vector takeDeferredDiags() const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind

[libcxx] r278736 - Fix new ASAN failures

2016-08-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug 15 15:50:01 2016
New Revision: 278736

URL: http://llvm.org/viewvc/llvm-project?rev=278736&view=rev
Log:
Fix new ASAN failures

Modified:
libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp
libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp

Modified: libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp?rev=278736&r1=278735&r2=278736&view=diff
==
--- libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/containers/sequences/vector/asan.pass.cpp Mon Aug 
15 15:50:01 2016
@@ -61,8 +61,8 @@ int main()
 C c(std::begin(t), std::end(t));
 c.reserve(2*c.size());
 assert(is_contiguous_container_asan_correct(c));
-assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 
1, c.data() + c.capacity()));
-T foo = c[c.size()];// should trigger ASAN
+assert(!__sanitizer_verify_contiguous_container( c.data(), c.data() + 
1, c.data() + c.capacity()));
+volatile T foo = c[c.size()]; // should trigger ASAN. Use volatile to 
prevent being optimized away.
 assert(false);  // if we got here, ASAN didn't trigger
 }
 }

Modified: 
libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp?rev=278736&r1=278735&r2=278736&view=diff
==
--- libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp 
(original)
+++ libcxx/trunk/test/support/test.support/test_macros_header_rtti.pass.cpp Mon 
Aug 15 15:50:01 2016
@@ -25,4 +25,5 @@ struct B : A {};
 int main() {
 A* ptr = new B;
 (void)dynamic_cast(ptr);
+delete ptr;
 }


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


r278742 - Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.

2016-08-15 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Aug 15 16:05:00 2016
New Revision: 278742

URL: http://llvm.org/viewvc/llvm-project?rev=278742&view=rev
Log:
Objective-C diagnostics: isObjCNSObjectType should check through AttributedType.

For the following example:
typedef __attribute__((NSObject)) CGColorRef ColorAttrRef;
@property (strong, nullable) ColorAttrRef color;
The property type should be ObjC NSObject type and the compiler should not emit
error: property with 'retain (or strong)' attribute must be of object type

rdar://problem/27747154

Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/nsobject-attribute.m

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=278742&r1=278741&r2=278742&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Aug 15 16:05:00 2016
@@ -3686,10 +3686,18 @@ bool Type::isObjCARCImplicitlyUnretained
 }
 
 bool Type::isObjCNSObjectType() const {
-  if (const TypedefType *typedefType = dyn_cast(this))
-return typedefType->getDecl()->hasAttr();
-  return false;
+  const Type *cur = this;
+  while (true) {
+if (const TypedefType *typedefType = dyn_cast(cur))
+  return typedefType->getDecl()->hasAttr();
+
+// Single-step desugar until we run out of sugar.
+QualType next = cur->getLocallyUnqualifiedSingleStepDesugaredType();
+if (next.getTypePtr() == cur) return false;
+cur = next.getTypePtr();
+  }
 }
+
 bool Type::isObjCIndependentClassType() const {
   if (const TypedefType *typedefType = dyn_cast(this))
 return typedefType->getDecl()->hasAttr();

Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=278742&r1=278741&r2=278742&view=diff
==
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Mon Aug 15 16:05:00 2016
@@ -21,6 +21,8 @@ typedef struct CGColor * __attribute__((
 @property (nonatomic, retain) CGColorRefNoNSObject color;
 // rdar://problem/12197822
 @property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning
+//rdar://problem/27747154
+@property (strong, nullable) CGColorRefNoNSObject color2; // no-warning
 @end
 
 void setProperty(id self, id value)  {


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


[PATCH] D23524: [libc++abi] Fix backtrace_test.pass.cpp failure seemingly caused by inlining differences.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: danalbert, jroelofs, mclow.lists.
EricWF added a subscriber: cfe-commits.

The modified assertion fails when the test is compiled at various optimization 
levels.
The value of `nothrow_traced` and `throw_traced` at various optimization levels 
are:

* `-O0`: `nothrow_traced = 7`, `throw_traced = 7`
* `-O1`: `nothrow_traced = 4`, `throw_traced = 5`
* `-O2`: `nothrow_traced = 4`, `throw_traced = 4`
* `-O3`: `nothrow_traced = 4`, `throw_traced = 4`

I'm not sure exactly what this test is doing, so I would like somebody else to 
sign off on this change.


https://reviews.llvm.org/D23524

Files:
  test/backtrace_test.pass.cpp

Index: test/backtrace_test.pass.cpp
===
--- test/backtrace_test.pass.cpp
+++ test/backtrace_test.pass.cpp
@@ -60,6 +60,6 @@
   // Different platforms (and different runtimes) will unwind a different 
number
   // of times, so we can't make any better assumptions than this.
   assert(nothrow_ntraced > 1);
-  assert(throw_ntraced == nothrow_ntraced); // Make sure we unwind through 
catch
+  assert(throw_ntraced >= nothrow_ntraced); // Make sure we unwind through 
catch
   return 0;
 }


Index: test/backtrace_test.pass.cpp
===
--- test/backtrace_test.pass.cpp
+++ test/backtrace_test.pass.cpp
@@ -60,6 +60,6 @@
   // Different platforms (and different runtimes) will unwind a different number
   // of times, so we can't make any better assumptions than this.
   assert(nothrow_ntraced > 1);
-  assert(throw_ntraced == nothrow_ntraced); // Make sure we unwind through catch
+  assert(throw_ntraced >= nothrow_ntraced); // Make sure we unwind through catch
   return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope

2016-08-15 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 68078.
ahatanak added a comment.

Fix Sema::getTemplateInstantiationArgs to return the template instantiation 
args when variable templates are being instantiated.


https://reviews.llvm.org/D23096

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/vartemplate-lambda.cpp
  test/SemaTemplate/default-expr-arguments-3.cpp

Index: test/SemaTemplate/default-expr-arguments-3.cpp
===
--- /dev/null
+++ test/SemaTemplate/default-expr-arguments-3.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++14 -ast-dump %s 2>&1 | FileCheck %s
+
+namespace PR28795 {
+  // CHECK: FunctionDecl{{.*}}func 'void (void)'
+  // CHECK:  LambdaExpr
+  // CHECK:   CXXMethodDecl{{.*}}operator() 'enum foo (enum foo) const' inline
+  // CHECK:ParmVarDecl{{.*}}f 'enum foo' cinit
+  // CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo'
+
+  template
+  void func() {
+enum class foo { a, b };
+auto bar = [](foo f = foo::a) { return f; };
+bar();
+  }
+
+  void foo() {
+func();
+  }
+}
+
+// Template struct case:
+
+// CHECK: ClassTemplateSpecializationDecl{{.*}}struct class2 definition
+// CHECK:  LambdaExpr
+// CHECK:   CXXMethodDecl{{.*}}used operator() 'enum foo (enum foo) const' inline
+// CHECK:ParmVarDecl{{.*}}f 'enum foo' cinit
+// CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo'
+
+template  struct class2 {
+  void bar() {
+enum class foo { a, b };
+[](foo f = foo::a) { return f; }();
+  }
+};
+
+template struct class2;
+
+// CHECK: FunctionDecl{{.*}}f1 'void (void)'
+// CHECK:  CXXMethodDecl{{.*}}g1 'int (enum foo)'
+// CHECK:   ParmVarDecl{{.*}}n 'enum foo' cinit
+// CHECK:DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo'
+
+template
+void f1() {
+  enum class foo { a, b };
+  struct S {
+int g1(foo n = foo::a);
+  };
+}
+
+template void f1();
Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- test/SemaCXX/vartemplate-lambda.cpp
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -1,15 +1,22 @@
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  auto fn0 = [] {};
 template  void foo0() { fn0(); }
 
 template auto fn1 = [](auto a) { return a + T(1); };
+template auto v1 = [](int a = T(1)) { return a; }();
+
+struct S {
+  template
+  static constexpr T t = [](int f = T(7)){return f;}(); // expected-error{{constexpr variable 't' must be initialized by a constant expression}} expected-error{{a lambda expression may not appear inside of a constant expression}} expected-note{{cannot be used in a constant expression}}
+};
 
 template 
 int foo2() {
   X a = 0x61;
   fn1(a);
+  (void)v1;
+  (void)S::t; // expected-note{{in instantiation of static data member 'S::t' requested here}}
   return 0;
 }
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3728,7 +3728,8 @@
   if (FromVar->isInvalidDecl())
 return nullptr;
 
-  InstantiatingTemplate Inst(*this, PointOfInstantiation, FromVar);
+  InstantiatingTemplate Inst(*this, PointOfInstantiation, FromVar,
+ SourceRange(), TemplateArgList.asArray());
   if (Inst.isInvalid())
 return nullptr;
 
@@ -4022,7 +4023,8 @@
 !Var->hasInit()) {
   // FIXME: Factor out the duplicated instantiation context setup/tear down
   // code here.
-  InstantiatingTemplate Inst(*this, PointOfInstantiation, Var);
+  InstantiatingTemplate Inst(*this, PointOfInstantiation, Var,
+ SourceRange(), TemplateArgs.getInnermost());
   if (Inst.isInvalid())
 return;
   PrettyDeclStackTraceEntry CrashInfo(*this, Var, SourceLocation(),
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -57,9 +57,16 @@
   // Accumulate the set of template argument lists in this structure.
   MultiLevelTemplateArgumentList Result;
 
+  ArrayRef VarTemplateArgs = varTemplateArguments();
+
+  if (!VarTemplateArgs.empty()) {
+Result.addOuterTemplateArguments(VarTemplateArgs);
+return Result;
+  }
+
   if (Innermost)
 Result.addOuterTemplateArguments(Innermost);
-  
+
   DeclContext *Ctx = dyn_cast(D);
   if (!Ctx) {
 Ctx = D->getDeclContext();
@@ -183,6 +190,19 @@
   return Result;
 }
 
+ArrayRef Sema::varTemplateArguments() const {
+  if (ActiveTemplateInstantiations.empty())
+return ArrayRef();
+
+  const auto &Inst = ActiveTemplateInstantiations.back();
+
+  if (const auto *VD = dyn_cast_or_null(Inst.Entity))
+if (VD->get

[libcxx] r278745 - libcxx: Fix path.compare.pass expected result

2016-08-15 Thread Adhemerval Zanella via cfe-commits
Author: azanella
Date: Mon Aug 15 16:24:50 2016
New Revision: 278745

URL: http://llvm.org/viewvc/llvm-project?rev=278745&view=rev
Log:
libcxx: Fix path.compare.pass expected result

The expected 'filesystem::path::compare' result states that for different
path only result sign contains the information about passed arguments
(not its integer value).  This is due it uses the output of other compare
functions (basic_string_view and char_traits) without further handling and
char_traits uses memcmp for final buffer comparison.

However for GLIBC on AArch64 the code:

  int ret = memcmp ("b/a/c", "a/b/c", 1);

Results in '64' where for x86_64 it results in '1'.

This patch fixes the expected 'filesystem::path::compare' by normalizing
all the results before assert comparison.

Modified:

libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp?rev=278745&r1=278744&r2=278745&view=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp
 Mon Aug 15 16:24:50 2016
@@ -73,6 +73,11 @@ const PathCompareTest CompareTestCases[]
 #undef LONGC
 #undef LONGD
 
+static inline int normalize_ret(int ret)
+{
+  return ret < 0 ? -1 : (ret > 0 ? 1 : 0);
+}
+
 int main()
 {
   using namespace fs;
@@ -86,13 +91,12 @@ int main()
   DisableAllocationGuard g; // none of these operations should allocate
 
   // check runtime results
-  int ret1 = p1.compare(p2);
-  int ret2 = p1.compare(R);
-  int ret3 = p1.compare(TC.RHS);
-  int ret4 = p1.compare(RV);
+  int ret1 = normalize_ret(p1.compare(p2));
+  int ret2 = normalize_ret(p1.compare(R));
+  int ret3 = normalize_ret(p1.compare(TC.RHS));
+  int ret4 = normalize_ret(p1.compare(RV));
   assert(ret1 == ret2 && ret1 == ret3 && ret1 == ret4);
-  int normalized_ret = ret1 < 0 ? -1 : (ret1 > 0 ? 1 : 0);
-  assert(normalized_ret == E);
+  assert(ret1 == E);
 
   // check signatures
   ASSERT_NOEXCEPT(p1.compare(p2));


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


r278746 - [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Aug 15 16:27:56 2016
New Revision: 278746

URL: http://llvm.org/viewvc/llvm-project?rev=278746&view=rev
Log:
[ADT] Change PostOrderIterator to use NodeRef. NFC.

Summary: Corresponding LLVM change: D23522

Reviewers: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Analysis/CallGraph.h

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=278746&r1=278745&r2=278746&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Aug 15 16:27:56 2016
@@ -999,6 +999,7 @@ template <> struct simplify_type< ::clan
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@ template <> struct GraphTraits< ::clang:
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@ template <> struct GraphTraits< const ::
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@ template <> struct GraphTraits struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)

Modified: cfe/trunk/include/clang/Analysis/CallGraph.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CallGraph.h?rev=278746&r1=278745&r2=278746&view=diff
==
--- cfe/trunk/include/clang/Analysis/CallGraph.h (original)
+++ cfe/trunk/include/clang/Analysis/CallGraph.h Mon Aug 15 16:27:56 2016
@@ -172,6 +172,7 @@ public:
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@ template <> struct GraphTraits struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}


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


Re: [PATCH] D23523: [ADT] Change PostOrderIterator to use NodeRef. NFC.

2016-08-15 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278746: [ADT] Change PostOrderIterator to use NodeRef. NFC. 
(authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23523?vs=68070&id=68082#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23523

Files:
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/Analysis/CallGraph.h

Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; 
}
   static inline ChildIteratorType child_begin(NodeType *N) { return 
N->begin();}


Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -999,6 +999,7 @@
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(::clang::CFGBlock *BB)
@@ -1013,6 +1014,7 @@
 
 template <> struct GraphTraits< const ::clang::CFGBlock *> {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_succ_iterator ChildIteratorType;
 
   static NodeType* getEntryNode(const clang::CFGBlock *BB)
@@ -1027,6 +1029,7 @@
 
 template <> struct GraphTraits > {
   typedef ::clang::CFGBlock NodeType;
+  typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse< ::clang::CFGBlock*> G)
@@ -1041,6 +1044,7 @@
 
 template <> struct GraphTraits > {
   typedef const ::clang::CFGBlock NodeType;
+  typedef const ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::const_pred_iterator ChildIteratorType;
 
   static NodeType *getEntryNode(Inverse G)
Index: cfe/trunk/include/clang/Analysis/CallGraph.h
===
--- cfe/trunk/include/clang/Analysis/CallGraph.h
+++ cfe/trunk/include/clang/Analysis/CallGraph.h
@@ -172,6 +172,7 @@
 namespace llvm {
 template <> struct GraphTraits {
   typedef clang::CallGraphNode NodeType;
+  typedef clang::CallGraphNode *NodeRef;
   typedef clang::CallGraphNode::CallRecord CallRecordTy;
   typedef std::pointer_to_unary_function CGNDerefFun;
@@ -190,6 +191,7 @@
 
 template <> struct GraphTraits {
   typedef const clang::CallGraphNode NodeType;
+  typedef const clang::CallGraphNode *NodeRef;
   typedef NodeType::const_iterator ChildIteratorType;
   static NodeType *getEntryNode(const clang::CallGraphNode *CGN) { return CGN; }
   static inline ChildIteratorType child_begin(NodeType *N) { return N->begin();}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r278710 - Replace an obsolete company name.

2016-08-15 Thread Robinson, Paul via cfe-commits
I had tried doing that in the Users.html page when I first added an entry 
there, and it caused problems.  So, I'd rather not embed a unicode character 
directly into the file, and I'd rather use a semi-intelligible substitution 
name than some raw hex value.  The intent is clearer.
--paulr

From: Sean Silva [mailto:chisophu...@gmail.com]
Sent: Monday, August 15, 2016 1:09 PM
To: Robinson, Paul
Cc: cfe-commits
Subject: Re: r278710 - Replace an obsolete company name.

You may also want to just try using the unicode character (not that it really 
matters that much though).

On Mon, Aug 15, 2016 at 11:45 AM, Paul Robinson via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: probinson
Date: Mon Aug 15 13:45:52 2016
New Revision: 278710

URL: http://llvm.org/viewvc/llvm-project?rev=278710&view=rev
Log:
Replace an obsolete company name.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=278710&r1=278709&r2=278710&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Aug 15 13:45:52 2016
@@ -2,6 +2,8 @@
 Clang Compiler User's Manual
 

+.. include:: 
+
 .. contents::
:local:

@@ -1650,7 +1652,7 @@ features. You can "tune" the debug info

 .. option:: -ggdb, -glldb, -gsce

-  Tune the debug info for the ``gdb``, ``lldb``, or Sony Computer Entertainment
+  Tune the debug info for the ``gdb``, ``lldb``, or Sony PlayStation\ |reg|
   debugger, respectively. Each of these options implies **-g**. (Therefore, if
   you want both **-gline-tables-only** and debugger tuning, the tuning option
   must come first.)


___
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] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/Attr.td:1384
@@ +1383,3 @@
+def RequireConstantInit : InheritableAttr {
+  let Spellings = [GCC<"require_constant_initialization">,
+   CXX11<"clang", "require_constant_initialization">];

Providing both seems fine, but regardless this should be a GNU spelling not a 
GCC spelling, because GCC doesn't support the attribute.


Comment at: include/clang/Basic/AttrDocs.td:836-840
@@ +835,7 @@
+  let Content = [{
+This attribute specifies expectations about the initialization of static and
+thread local variables. Specifically that the variable has a
+`constant initializer 
`_
+according to the rules of [basic.start.static]. Failure to meet this 
expectation
+will result in an error.
+

This reads a bit awkwardly, since you don't actually say what the attribute 
does until the second sentence. Maybe fold the first two sentences together:

"This attribute specifies that the variable to which it is attached is intended 
to have a constant initializer according to the rules of [basic.start.static]. 
The variable is required to have static or thread storage duration. If the 
initialization of the variable is not a constant initializer, an error will be 
produced."


Comment at: include/clang/Basic/AttrDocs.td:842
@@ +841,3 @@
+
+Static objects with constant initializers avoid hard-to-find bugs caused by
+the indeterminate order of dynamic initialization. They can also be safely

Static objects -> Static storage duration variables


Comment at: include/clang/Basic/AttrDocs.td:844
@@ +843,3 @@
+the indeterminate order of dynamic initialization. They can also be safely
+used by other static constructors across translation units.
+

static constructors -> dynamic initializers?


Comment at: include/clang/Basic/AttrDocs.td:858
@@ +857,3 @@
+  };
+  SAFE_STATIC T x = {42}; // OK.
+  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer

OK even though T has a non-trivial destructor? This makes the variable unsafe 
to use during program shutdown in the general case.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2575
@@ -2574,3 +2574,3 @@
   "functions, variables, classes, and Objective-C interfaces|"
-  "Objective-C protocols|"
+  "Objective-C protocols|variables with static or thread-local storage 
duration|"
   "functions and global variables|structs, unions, and typedefs|structs and 
typedefs|"

thread-local -> thread, per standard terminology


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+def err_require_constant_init_failed : Error<
+  "variable does not have a constant initializer">;
+

It may be useful for this diagnostic to say why we consider this to be an error 
(that is, mention that there is a `require_constant_initialization` attribute 
attached to the variable). The attribute will typically be hidden behind a 
(perhaps unfamiliar to the reader) macro, so it may not be obvious if we don't 
point it out.


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

Falling back to `checkConstInit` here will suppress the warning on some cases 
that are not technically constant initializers (but that Clang can emit as 
constants regardless). Is that what you want? If so, you should update the 
documentation to say that instead of saying that we only check for a constant 
initializer.


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:7-15
@@ +6,11 @@
+
+#if !__has_feature(cxx_static_assert)
+# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_)
+# define CONCAT1_(X_, Y_) X_ ## Y_
+
+// This emulation can be used multiple times on one line (and thus in
+// a macro), except at class scope
+# define static_assert(b_, m_) \
+  typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1]
+#endif
+

Just use `_Static_assert`.


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:96-100
@@ +95,7 @@
+ATTR static const int& temp_init = 42;
+#if 0
+/// FIXME: Why is this failing?
+__thread const int& tl_init = 42;
+static_assert(__has_constant_initializer(tl_init), "");
+#endif
+}

Did you mean for this to still be here?


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23453: Add a c2x language mode

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added a comment.

This seems premature; according to the charter, we are more than three years 
away from the C2x committee draft phase. Perhaps we should wait until we have 
either a new working draft or a paper approved by the WG14 for such a working 
draft.


https://reviews.llvm.org/D23453



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


Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 68086.
sfantao marked 5 inline comments as done.
sfantao added a comment.

- Fix comments and diagnostics.


https://reviews.llvm.org/D13909

Files:
  test/CMakeLists.txt
  test/Driver/clang-offload-bundler.c
  tools/CMakeLists.txt
  tools/clang-offload-bundler/CMakeLists.txt
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- /dev/null
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -0,0 +1,681 @@
+//===-- clang-offload-bundler/ClangOffloadBundler.cpp - Clang format tool -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements a clang-offload-bundler that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+// Mark all our options with this category, everything else (except for -version
+// and -help) will be hidden.
+static cl::OptionCategory
+ClangOffloadBundlerCategory("clang-offload-bundler options");
+
+static cl::list
+InputFileNames("inputs", cl::CommaSeparated, cl::OneOrMore,
+   cl::desc("[,...]"),
+   cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+OutputFileNames("outputs", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::list
+TargetNames("targets", cl::CommaSeparated, cl::OneOrMore,
+cl::desc("[-,...]"),
+cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+FilesType("type", cl::Required,
+  cl::desc("Type of the files to be bundled/unbundled.\n"
+   "Current supported types are:\n"
+   "  i   - cpp-output\n"
+   "  ii  - c++-cpp-output\n"
+   "  ll  - llvm\n"
+   "  bc  - llvm-bc\n"
+   "  s   - assembler\n"
+   "  o   - object\n"
+   "  gch - precompiled-header\n"
+   "  ast - clang AST file"),
+  cl::cat(ClangOffloadBundlerCategory));
+static cl::opt
+Unbundle("unbundle",
+ cl::desc("Unbundle bundled file into several output files.\n"),
+ cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+/// Magic string that marks the existence of offloading data.
+#define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
+
+/// The index of the host input in the list of inputs.
+static unsigned HostInputIndex = ~0u;
+
+/// Obtain the offload kind and real machine triple out of the target
+/// information specified by the user.
+static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
+StringRef &Triple) {
+  auto KindTriplePair = Target.split('-');
+  OffloadKind = KindTriplePair.first;
+  Triple = KindTriplePair.second;
+}
+static bool hasHostKind(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return OffloadKind == "host";
+}
+
+/// Generic file handler interface.
+class FileHandler {
+public:
+  /// Update the file handler with information from the header of the bundled
+  /// file
+  virtual void ReadHeader(MemoryBuffer &Input) = 0;
+  /// Read the marker of the next bundled to be read in the file. The triple of
+  /// the target associated with that bundle is returned. An empty string is
+  /// returned if there are no more bundles to be read.
+  virtual StringRef ReadBundleStart(MemoryBuffer &Input) = 0;
+  /// Read the marker that closes the current bundle.
+  virtual void ReadBundleEnd(MemoryBuffer &Input) = 0;
+  /// Read the current bundle and write the result i

Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Jonas,

Thanks for the review!



Comment at: test/CMakeLists.txt:27-33
@@ -26,8 +26,9 @@
 
 list(APPEND CLANG_TEST_DEPS
   clang clang-headers
   clang-format
   c-index-test diagtool
   clang-tblgen
+  clang-offload-bundler
   )
   

Hahnfeld wrote:
> I think `clang-offload-bundler` needs to be added as dependency for the 
> `clang` target because it will really need the bundler at runtime, not only 
> when testing...
> 
> (Disclaimer: I'm no CMake expert)
The bundler tool already depends on clang, so that would cause a circular 
dependency. I think that in general not building the bundler is fine - the user 
may not be interested in doing offloading, so if he attempts to do so, that 
would fail as, say, ld was not in the system.

I'm adding it only for testing because there are tests that will exercise the 
bundler that will fail if the driver does not detect the tool. 

Should we ask someone in specific for an opinion? Let me know your thoughts. 


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:151
@@ +150,3 @@
+
+/// Read 8-byte integers to/from a buffer in little-endian format.
+static uint64_t Read8byteIntegerFromBuffer(StringRef Buffer, size_t pos) {

Hahnfeld wrote:
> `to/from`?
Thanks for catching this! Fixed in the last diff, it should be `from`.


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:164
@@ +163,3 @@
+
+/// Write and write 8-byte integers to/from a buffer in little-endian format.
+static void Write8byteIntegerToBuffer(raw_fd_ostream &OS, uint64_t Val) {

Hahnfeld wrote:
> Duplicate `and write`? `to/from`?
Fixed in the last diff, it should be `to`.


Comment at: tools/clang-offload-bundler/ClangOffloadBundler.cpp:568
@@ +567,3 @@
+  if (!FoundHostBundle) {
+llvm::errs() << "error: Can't find bundles for all requested targets\n";
+return true;

Hahnfeld wrote:
> Better say that we haven't found the bundle for the host?
Makes sense, I changed the message in the last diff.


https://reviews.llvm.org/D13909



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


Re: [PATCH] D23453: Add a c2x language mode

2016-08-15 Thread Aaron Ballman via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

In https://reviews.llvm.org/D23453#515816, @rsmith wrote:

> This seems premature; according to the charter, we are more than three years 
> away from the C2x committee draft phase. Perhaps we should wait until we have 
> either a new working draft or a paper approved by the WG14 for such a working 
> draft.


The problem is: I think I need the flag for working on some features that are 
being proposed, as WG14 does not typically accept novel language features. 
Specifically, I am planning work on N2049, adding attributes to C. This work 
will be done under a separate flag anyway (since it's obviously not approved 
and in the working draft), but I would like the feature to only be enabled for 
C2x and not C11 or earlier (at least initially) so that I don't have to worry 
about someone turning on the feature flag for C11 and running into a situation 
later where we don't want the feature supported in C11 (not that I have such a 
situation in mind currently). This is not entirely unlike how we don't support 
C++-style attributes in C++03 mode.


https://reviews.llvm.org/D23453



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


[PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jlebar, sfantao.
tra added a subscriber: cfe-commits.

If they are, we end up with the last intermediary output preserved
in the current directory after compilation.

Added a test case to verify that we're using appropriate filenames
for outputs of different phases.


https://reviews.llvm.org/D23526

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

Index: test/Driver/cuda-bindings.cu
===
--- /dev/null
+++ test/Driver/cuda-bindings.cu
@@ -0,0 +1,137 @@
+// Tests the bindings generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+// It parallels cuda-phases.cu test, but verifies whether output file is temporary or not.
+
+// It's hard to check whether file name is temporary in a portable
+// way. Instead we check whether we've generated a permanent name on
+// device side which appends '-device-cuda-' suffix.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+// No intermediary device files should have "-device-cuda..." in the name.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test two gpu architecturess up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
+// ASM2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test one or more gpu architecture with complete compilation in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// HBIN-NOT: cuda-bindings-device-cuda-nvptx64
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test one or more gpu architecture up to the assemble phase in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only -S 2>&1 \
+// RUN: | FileCheck -check-prefix=HASM %s
+// RUN: %c

Re: [PATCH] D21851: [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of the host binary format.

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 68089.
sfantao marked an inline comment as done.
sfantao added a comment.

- Remove redundant return statement.


https://reviews.llvm.org/D21851

Files:
  test/Driver/clang-offload-bundler.c
  test/Driver/clang-offload-bundler.c.o
  tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -72,20 +72,40 @@
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
 
+static cl::opt PrintExternalCommands(
+"###",
+cl::desc("Print any external commands that are to be executed "
+ "instead of actually executing them - for testing purposes.\n"),
+cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
+static cl::opt DumpTemporaryFiles(
+"dump-temporary-files",
+cl::desc("Dumps any temporary files created - for testing purposes.\n"),
+cl::init(false), cl::cat(ClangOffloadBundlerCategory));
+
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
 /// The index of the host input in the list of inputs.
 static unsigned HostInputIndex = ~0u;
 
+/// Path to the current binary.
+static std::string BundlerExecutable;
+
 /// Obtain the offload kind and real machine triple out of the target
 /// information specified by the user.
 static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
 StringRef &Triple) {
   auto KindTriplePair = Target.split('-');
   OffloadKind = KindTriplePair.first;
   Triple = KindTriplePair.second;
 }
+static StringRef getTriple(StringRef Target) {
+  StringRef OffloadKind;
+  StringRef Triple;
+  getOffloadKindAndTriple(Target, OffloadKind, Triple);
+  return Triple;
+}
 static bool hasHostKind(StringRef Target) {
   StringRef OffloadKind;
   StringRef Triple;
@@ -116,8 +136,8 @@
   /// \a OS.
   virtual void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
   /// Write the marker that closes a bundle for the triple \a TargetTriple to \a
-  /// OS.
-  virtual void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
+  /// OS. Return true if any error was found.
+  virtual bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) = 0;
   /// Write the bundle from \a Input into \a OS.
   virtual void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
 
@@ -303,15 +323,250 @@
 }
   }
   void WriteBundleStart(raw_fd_ostream &OS, StringRef TargetTriple) {}
-  void WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {}
+  bool WriteBundleEnd(raw_fd_ostream &OS, StringRef TargetTriple) {
+return false;
+  }
   void WriteBundle(raw_fd_ostream &OS, MemoryBuffer &Input) {
 OS.write(Input.getBufferStart(), Input.getBufferSize());
   }
 
   BinaryFileHandler() : FileHandler() {}
   ~BinaryFileHandler() {}
 };
 
+/// Handler for object files. The bundles are organized by sections with a
+/// designated name.
+///
+/// In order to bundle we create an IR file with the content of each section and
+/// use incremental linking to produce the resulting object. We also add section
+/// with a single byte to state the name of the component the main object file
+/// (the one we are bundling into) refers to.
+///
+/// To unbundle, we use just copy the contents of the designated section. If the
+/// requested bundle refer to the main object file, we just copy it with no
+/// changes.
+class ObjectFileHandler final : public FileHandler {
+
+  /// The object file we are currently dealing with.
+  ObjectFile &Obj;
+
+  /// Return the input file contents.
+  StringRef getInputFileContents() const { return Obj.getData(); }
+
+  /// Return true if the provided section is an offload section and return the
+  /// triple by reference.
+  static bool IsOffloadSection(SectionRef CurSection,
+   StringRef &OffloadTriple) {
+StringRef SectionName;
+CurSection.getName(SectionName);
+
+if (SectionName.empty())
+  return false;
+
+// If it does not start with the reserved suffix, just skip this section.
+if (!SectionName.startswith(OFFLOAD_BUNDLER_MAGIC_STR))
+  return false;
+
+// Return the triple that is right after the reserved prefix.
+OffloadTriple = SectionName.substr(sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1);
+return true;
+  }
+
+  /// Total number of inputs.
+  unsigned NumberOfInputs = 0;
+
+  /// Total number of processed inputs, i.e, inputs that were already
+  /// read from the buffers.
+  unsigned NumberOfProcessedInputs = 0;
+
+  /// LLVM context used to to create the auxiliar modules.
+  LLVMContext VMContext;
+
+  /// LLVM module used to create an object with all the 

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF marked 7 inline comments as done.


Comment at: include/clang/Basic/AttrDocs.td:844
@@ +843,3 @@
+the indeterminate order of dynamic initialization. They can also be safely
+used by other static constructors across translation units.
+

rsmith wrote:
> static constructors -> dynamic initializers?
Changed "by other static constructors" -> "during dynamic initialization"


Comment at: include/clang/Basic/AttrDocs.td:858
@@ +857,3 @@
+  };
+  SAFE_STATIC T x = {42}; // OK.
+  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer

rsmith wrote:
> OK even though T has a non-trivial destructor? This makes the variable unsafe 
> to use during program shutdown in the general case.
Right, but I want this attribute to be able to work with (A)  the union trick 
for "trivial" destructors and (B) variables not used during shutdown.
I was planning on following this up with an additional feature to aid in the 
shutdown case as well, but I think there is value in separating the features.

Currently -Wglobal-destructors will still warn on that declaration, so at least 
the unsafe shutdown is not silently missed.

Does this behavior make sense to you?


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+def err_require_constant_init_failed : Error<
+  "variable does not have a constant initializer">;
+

rsmith wrote:
> It may be useful for this diagnostic to say why we consider this to be an 
> error (that is, mention that there is a `require_constant_initialization` 
> attribute attached to the variable). The attribute will typically be hidden 
> behind a (perhaps unfamiliar to the reader) macro, so it may not be obvious 
> if we don't point it out.
"variable does not have a constant initializer as required by 
'require_constant_initializer' attribute"?

Or do we want the diagnostic to point to the attribute token in a "required 
from here"-like note?


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

rsmith wrote:
> Falling back to `checkConstInit` here will suppress the warning on some cases 
> that are not technically constant initializers (but that Clang can emit as 
> constants regardless). Is that what you want? If so, you should update the 
> documentation to say that instead of saying that we only check for a constant 
> initializer.
> Falling back to checkConstInit here will suppress the warning on some cases 
> that are not technically constant initializers (but that Clang can emit as 
> constants regardless). Is that what you want?

Not really. I would prefer this strictly conform to the standard so it can be 
used to portably detect possible dynamic initializers on other toolchains.

What would the correct fallback here be?


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:96-100
@@ +95,7 @@
+ATTR static const int& temp_init = 42;
+#if 0
+/// FIXME: Why is this failing?
+__thread const int& tl_init = 42;
+static_assert(__has_constant_initializer(tl_init), "");
+#endif
+}

rsmith wrote:
> Did you mean for this to still be here?
No.


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 68094.
EricWF marked 2 inline comments as done.
EricWF added a comment.

Address most of @rsmiths review comments.


https://reviews.llvm.org/D23385

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-require-constant-initialization.cpp

Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_TWO \
+// RUN: -Wglobal-constructors -std=c++14 %s
+
+#if !__has_feature(cxx_static_assert)
+#define static_assert(b_, m_) _Static_assert(b_, m_)
+#endif
+
+#define ATTR __attribute__((require_constant_initialization))
+
+// Test diagnostics when attribute is applied to non-static declarations.
+void test_func_local(ATTR int param) { // expected-error {{only applies to variables with static or thread-local}}
+ATTR int x = 42; // expected-error {{only applies to variables with static or thread-local}}
+ATTR extern int y;
+}
+struct ATTR class_mem { // expected-error {{only applies to variables with static or thread-local}}
+  ATTR int x; // expected-error {{only applies to variables with static or thread-local}}
+};
+
+int ReturnInt();
+
+struct PODType {
+int value;
+int value2;
+};
+#if __cplusplus >= 201103L
+struct LitType {
+constexpr LitType() : value(0) {}
+constexpr LitType(int x) : value(x) {}
+LitType(void*) : value(-1) {}
+int value;
+};
+#endif
+
+struct NonLit {
+#if __cplusplus >= 201402L
+constexpr NonLit() : value(0) {}
+constexpr NonLit(int x ) : value(x) {}
+#else
+NonLit() : value(0) {}
+NonLit(int x) : value(x) {}
+#endif
+NonLit(void*) : value(-1) {}
+~NonLit() {}
+int value;
+};
+
+struct StoresNonLit {
+#if __cplusplus >= 201402L
+constexpr StoresNonLit() : obj() {}
+constexpr StoresNonLit(int x) : obj(x) {}
+#else
+StoresNonLit() : obj() {}
+StoresNonLit(int x) : obj(x) {}
+#endif
+StoresNonLit(void* p) : obj(p) {}
+NonLit obj;
+};
+
+const bool NonLitHasConstInit =
+#if __cplusplus >= 201402L
+true;
+#else
+false;
+#endif
+
+#if defined(TEST_ONE) // Test semantics of attribute
+
+// [basic.start.static]p2.1
+// if each full-expression (including implicit conversions) that appears in
+// the initializer of a reference with static or thread storage duration is
+// a constant expression (5.20) and the reference is bound to a glvalue
+// designating an object with static storage duration, to a temporary object
+// (see 12.2) or subobject thereof, or to a function;
+
+// Test binding to a static glvalue
+const int glvalue_int = 42;
+const int glvalue_int2 = ReturnInt();
+ATTR const int& glvalue_ref ATTR = glvalue_int;
+ATTR const int& glvalue_ref2 ATTR = glvalue_int2;
+ATTR __thread const int& glvalue_ref_tl = glvalue_int;
+
+void test_basic_start_static_2_1() {
+const int non_global = 42;
+ATTR static const int& local_init = non_global; // expected-error {{variable does not have a constant initializer}}
+ATTR static const int& global_init = glvalue_int;
+ATTR static const int& temp_init = 42;
+}
+
+ATTR const int& temp_ref = 42;
+ATTR const int& temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+ATTR const NonLit& nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+
+#if __cplusplus >= 201103L
+ATTR const LitType& lit_temp_ref = 42;
+ATTR const int& subobj_ref = LitType{}.value;
+#endif
+
+ATTR const int& nl_subobj_ref = NonLit().value;  // expected-error {{variable does not have a constant initializer}}
+
+struct TT1 {
+  ATTR static const int& no_init;
+  ATTR static const int& glvalue_init;
+  ATTR static const int& temp_init;
+  ATTR static const int& subobj_init;
+#if __cplusplus >= 201103L
+  ATTR static thread_local const int& tl_glvalue_init;
+  ATTR static thread_local const int& tl_temp_init;
+#endif
+};
+const int& TT1::glvalue_init = glvalue_int;
+const int& TT1::temp_init = 42;
+const int& TT1::subobj_init = PODType().value;
+#if __cplusplus >= 201103L
+thread_local const int& TT1::tl_glvalue_init = glvalue_int;
+thread_local const int& TT1::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+#endif
+
+// [basic.start.static]p2.2
+// if an object with static or thread storage duration is initialized by a
+// constructor call, and if the initialization full-expression is a constant
+// init

Re: [PATCH] D20561: Warn when taking address of packed member

2016-08-15 Thread Matthias Braun via cfe-commits
MatzeB added a subscriber: MatzeB.
MatzeB added a comment.

The sanitizer code triggers this warning for code that looks conceptually like 
this:

  typedef struct Bla { char bar; int foo; } __attribute__((packed));
  
  uintptr_t getu(struct Bla *b) { return (uintptr_t)&b->foo; }

Resulting in:

  taking address of packed member 'foo' of class or structure
'Bla' may result in an unaligned pointer value
[-Waddress-of-packed-member]

Of course the warning can be silenced with `return (uintptr_t)(char*)&b->foo;` 
still casting to an int type seems like a benign case for this warning so maybe 
we should exclude that?


Repository:
  rL LLVM

https://reviews.llvm.org/D20561



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


Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-15 Thread Faisal Vali via cfe-commits
faisalv removed rL LLVM as the repository for this revision.
faisalv updated this revision to Diff 68091.
faisalv added a comment.

Updated the patch per Richard's direction (which helped clarify my thinking 
about this): Check only the current call frame - if the VarDecl is contained 
within the current callee - only then does it make sense to dig into the 
stack-variables of the frame.  No other scenario really makes sense (even for 
lambdas, we care about the parent decl-contexts (static binding), not variables 
within the call-frame stack (run-time binding).

Thanks Richard.


https://reviews.llvm.org/D23493

Files:
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/constant-expression-cxx11.cpp

Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -2066,3 +2066,33 @@
   constexpr Z z(1);
   static_assert(z.w == 1 && z.x == 2 && z.y == 3 && z.z == 4, "");
 }
+
+
+namespace PR28366 {
+namespace ns1 {
+
+void f(char c) { //expected-note2{{declared here}}
+  struct X {
+static constexpr char f() { //expected-error{{never produces a constant 
expression}}
+  return c; //expected-error{{reference to local}} 
expected-note{{non-const variable}}
+}
+  };
+  int I = X::f();
+}
+
+void g() {
+  const int c = 'c';
+  static const int d = 'd';
+  struct X {
+static constexpr int f() {
+  return c + d;
+}
+  };
+  constexpr int CD = X::f();
+}
+
+
+} // end ns1
+
+} //end ns PR28366
+
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -187,7 +187,7 @@
 
   SmallVector Diags;
   if (A->getCond()->isValueDependent() && !Cond->isValueDependent() &&
-  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(Tmpl),
+  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(New),
 Diags)) {
 S.Diag(A->getLocation(), diag::err_enable_if_never_constant_expr);
 for (int I = 0, N = Diags.size(); I != N; ++I)
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -4788,10 +4788,19 @@
   return Error(E);
 }
 
+
 bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
   CallStackFrame *Frame = nullptr;
-  if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1)
-Frame = Info.CurrentCall;
+  if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1) {
+// Only if the DeclContext of VD is the same as the called function do we
+// set the Frame to the Current CallStackFrame, so that we can find its
+// associated value from the variable-objects associated with that frame.
+if (Info.CurrentCall->Callee && isa(VD->getDeclContext()) &&
+cast(VD->getDeclContext()->getRedeclContext())
+->getFirstDecl() == Info.CurrentCall->Callee->getFirstDecl()) {
+  Frame = Info.CurrentCall;
+}
+  }
 
   if (!VD->getType()->isReferenceType()) {
 if (Frame) {


Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -2066,3 +2066,33 @@
   constexpr Z z(1);
   static_assert(z.w == 1 && z.x == 2 && z.y == 3 && z.z == 4, "");
 }
+
+
+namespace PR28366 {
+namespace ns1 {
+
+void f(char c) { //expected-note2{{declared here}}
+  struct X {
+static constexpr char f() { //expected-error{{never produces a constant expression}}
+  return c; //expected-error{{reference to local}} expected-note{{non-const variable}}
+}
+  };
+  int I = X::f();
+}
+
+void g() {
+  const int c = 'c';
+  static const int d = 'd';
+  struct X {
+static constexpr int f() {
+  return c + d;
+}
+  };
+  constexpr int CD = X::f();
+}
+
+
+} // end ns1
+
+} //end ns PR28366
+
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -187,7 +187,7 @@
 
   SmallVector Diags;
   if (A->getCond()->isValueDependent() && !Cond->isValueDependent() &&
-  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(Tmpl),
+  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(New),
 Diags)) {
 S.Diag(A->getLocation(), diag::err_enable_if_never_constant_expr);
 for (int I = 0, N = Diags.size(); I != N; ++I)
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -4788,10 +4788,19 @@
   return Error(E);
 }

Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-15 Thread Faisal Vali via cfe-commits
faisalv marked an inline comment as done.
faisalv added a comment.

https://reviews.llvm.org/D23493



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


Re: [PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

2016-08-15 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.



> This is done so containers, such as `vector` can be used 
> safely provided `partially_available` is safe at the point of instantiation. 
> I think the way to improve this is in `Sema::getVersionForDecl()`. There we 
> could look at function and template parameters to determine the best base 
> version, then diagnose against it.


Let's fix the diagnostics for dependent type in a follow-up patch. And your 
suggestion above sounds reasonable to me.

Thanks for the work!
Manman


https://reviews.llvm.org/D23003



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


Re: [PATCH] D23524: [libc++abi] Fix backtrace_test.pass.cpp failure seemingly caused by inlining differences.

2016-08-15 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

I'm not sure that's guaranteed behavior either. That being said, I don't see a 
more robust way to write this test.


https://reviews.llvm.org/D23524



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


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Wow, I have no idea if this is right.  I can try to figure it out, but if 
sfantao can review, that's easier.



Comment at: test/Driver/cuda-bindings.cu:10
@@ +9,3 @@
+// way. Instead we check whether we've generated a permanent name on
+// device side which appends '-device-cuda-' suffix.
+

Nonrestrictive subordinating clause, comma before "which".


Comment at: test/Driver/cuda-bindings.cu:60
@@ +59,3 @@
+//
+// Test two gpu architecturess up to the assemble phase.
+//

Spelling


https://reviews.llvm.org/D23526



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


Re: [PATCH] D23242: [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-15 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm



Comment at: clang/include/clang/Sema/Sema.h:9162
@@ -9161,1 +9161,3 @@
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///

FWIW I never insert doxygen annotations. I figure if someone cares they can 
come insert them for me. =P


https://reviews.llvm.org/D23242



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


[PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-15 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: ddunbar, bob.wilson.
beanz added a subscriber: cfe-commits.

The eprintf library was added before the general OS X builtins library existed 
as a place to store one builtin function. Since we have for several years had 
an actual mandated builtin library for OS X > 10.5, we should just merge 
eprintf into the main library.

This change will resolve PR28855.

As a follow up I'll also patch compiler-rt to not generate the eprintf library 
anymore.

https://reviews.llvm.org/D23531

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -483,8 +483,6 @@
 if (isMacosxVersionLT(10, 5)) {
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
 } else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
 }
   }


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -483,8 +483,6 @@
 if (isMacosxVersionLT(10, 5)) {
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
 } else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 68100.
tra added a comment.

Addressed comments.


https://reviews.llvm.org/D23526

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

Index: test/Driver/cuda-bindings.cu
===
--- /dev/null
+++ test/Driver/cuda-bindings.cu
@@ -0,0 +1,137 @@
+// Tests the bindings generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+// It parallels cuda-phases.cu test, but verifies whether output file is temporary or not.
+
+// It's hard to check whether file name is temporary in a portable
+// way. Instead we check whether we've generated a permanent name on
+// device side, which appends '-device-cuda-' suffix.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+// No intermediary device files should have "-device-cuda..." in the name.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test two gpu architectures up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
+// ASM2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test one or more gpu architecture with complete compilation in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// HBIN-NOT: cuda-bindings-device-cuda-nvptx64
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test one or more gpu architecture up to the assemble phase in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only -S 2>&1 \
+// RUN: | FileCheck -check-prefix=HASM %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only -S 2>&1 \
+// RUN: | FileCheck -check-prefix=HASM %s
+// HASM: # "powerpc64le-ibm-linux-gnu

Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-15 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

Might want to fix the braces while you're there.

-eric


https://reviews.llvm.org/D23531



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


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Artem Belevich via cfe-commits
tra marked 2 inline comments as done.
tra added a comment.

https://reviews.llvm.org/D23526



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


Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-15 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 68102.
beanz added a comment.
Herald added a subscriber: mehdi_amini.

Updating code comment and removing unneeded braces.

I'm going to sit on this for a bit before committing in case anyone comes up 
with a reason this is a bad idea.


https://reviews.llvm.org/D23531

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -472,21 +472,26 @@
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -472,21 +472,26 @@
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278759 - [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 18:00:49 2016
New Revision: 278759

URL: http://llvm.org/viewvc/llvm-project?rev=278759&view=rev
Log:
[CUDA] Raise an error if a wrong-side call is codegen'ed.

Summary:
Some function calls in CUDA are allowed to appear in
semantically-correct programs but are an error if they're ever
codegen'ed.  Specifically, a host+device function may call a host
function, but it's an error if such a function is ever codegen'ed in
device mode (and vice versa).

Previously, clang made no attempt to catch these errors.  For the most
part, they would be caught by ptxas, and reported as "call to unknown
function 'foo'".

Now we catch these errors and report them the same as we report other
illegal calls (e.g. a call from a host function to a device function).

This has a small change in error-message behavior for calls that were
previously disallowed (e.g. calls from a host to a device function).
Previously, we'd catch disallowed calls fairly early, before doing
additional semantic checking e.g. of the call's arguments.  Now we catch
these illegal calls at the very end of our semantic checks, so we'll
only emit a "illegal CUDA call" error if the call is otherwise
well-formed.

Reviewers: tra, rnk

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
Removed:
cfe/trunk/test/CodeGenCUDA/host-device-calls-host.cu
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCUDA/Inputs/cuda.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=278759&r1=278758&r2=278759&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Aug 15 18:00:49 2016
@@ -9186,6 +9186,18 @@ public:
   void maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *FD,
const LookupResult &Previous);
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///
+  /// If the call is never allowed in a semantically-correct program
+  /// (CFP_Never), emits an error and returns false.
+  ///
+  /// If the call is allowed in semantically-correct programs, but only if it's
+  /// never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to be
+  /// emitted if and when the caller is codegen'ed, and returns true.
+  ///
+  /// Otherwise, returns true without emitting any diagnostics.
+  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
+
   /// Finds a function in \p Matches with highest calling priority
   /// from \p Caller context and erases all functions with lower
   /// calling priority.

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=278759&r1=278758&r2=278759&view=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Mon Aug 15 18:00:49 2016
@@ -480,3 +480,33 @@ void Sema::maybeAddCUDAHostDeviceAttrs(S
   NewD->addAttr(CUDAHostAttr::CreateImplicit(Context));
   NewD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
 }
+
+bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee) {
+  assert(getLangOpts().CUDA &&
+ "Should only be called during CUDA compilation.");
+  assert(Callee && "Callee may not be null.");
+  FunctionDecl *Caller = dyn_cast(CurContext);
+  if (!Caller)
+return true;
+
+  Sema::CUDAFunctionPreference Pref = IdentifyCUDAPreference(Caller, Callee);
+  if (Pref == Sema::CFP_Never) {
+Diag(Loc, diag::err_ref_bad_target) << IdentifyCUDATarget(Callee) << Callee
+<< IdentifyCUDATarget(Caller);
+Diag(Callee->getLocation(), diag::note_previous_decl) << Callee;
+return false;
+  }
+  if (Pref == Sema::CFP_WrongSide) {
+// We have to do this odd dance to create our PartialDiagnostic because we
+// want its storage to be allocated with operator new, not in an arena.
+PartialDiagnostic PD{PartialDiagnostic::NullDiagnostic()};
+PD.Reset(diag::err_ref_bad_target);
+PD << IdentifyCUDATarget(Callee) << Callee << IdentifyCUDATarget(Caller);
+Caller->addDeferredDiag({Loc, std::move(PD)});
+Diag(Callee->getLocation(), diag::note_previous_decl) << Callee;
+// This is not immediately an error, so return true.  The deferred errors
+// will be emitted if and when Caller is codegen'ed.
+return true;
+  }
+  return true;
+}

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=27

Re: [PATCH] D23242: [CUDA] Raise an error if a wrong-side call is codegen'ed.

2016-08-15 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278759: [CUDA] Raise an error if a wrong-side call is 
codegen'ed. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D23242?vs=67378&id=68103#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23242

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeGenCUDA/host-device-calls-host.cu
  cfe/trunk/test/SemaCUDA/Inputs/cuda.h
  cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
  cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9186,6 +9186,18 @@
   void maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *FD,
const LookupResult &Previous);
 
+  /// Check whether we're allowed to call Callee from the current context.
+  ///
+  /// If the call is never allowed in a semantically-correct program
+  /// (CFP_Never), emits an error and returns false.
+  ///
+  /// If the call is allowed in semantically-correct programs, but only if it's
+  /// never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to be
+  /// emitted if and when the caller is codegen'ed, and returns true.
+  ///
+  /// Otherwise, returns true without emitting any diagnostics.
+  bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
+
   /// Finds a function in \p Matches with highest calling priority
   /// from \p Caller context and erases all functions with lower
   /// calling priority.
Index: cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
===
--- cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
+++ cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - -verify
+
+// Note: This test won't work with -fsyntax-only, because some of these errors
+// are emitted during codegen.
+
+#include "Inputs/cuda.h"
+
+extern "C" void host_fn() {}
+
+struct S {
+  S() {}
+  ~S() { host_fn(); }
+  int x;
+};
+
+struct T {
+  __host__ __device__ void hd() { host_fn(); }
+  // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+
+  // No error; this is (implicitly) inline and is never called, so isn't
+  // codegen'ed.
+  __host__ __device__ void hd2() { host_fn(); }
+
+  __host__ __device__ void hd3();
+
+  void h() {}
+};
+
+__host__ __device__ void T::hd3() {
+  host_fn();
+  // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+}
+
+template  __host__ __device__ void hd2() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+__global__ void kernel() { hd2(); }
+
+__host__ __device__ void hd() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+
+template  __host__ __device__ void hd3() { host_fn(); }
+// expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+__device__ void device_fn() { hd3(); }
+
+// No error because this is never instantiated.
+template  __host__ __device__ void hd4() { host_fn(); }
+
+__host__ __device__ void local_var() {
+  S s;
+  // expected-error@-1 {{reference to __host__ function 'S' in __host__ __device__ function}}
+}
+
+__host__ __device__ void placement_new(char *ptr) {
+  ::new(ptr) S();
+  // expected-error@-1 {{reference to __host__ function 'S' in __host__ __device__ function}}
+}
+
+__host__ __device__ void explicit_destructor(S *s) {
+  s->~S();
+  // expected-error@-1 {{reference to __host__ function '~S' in __host__ __device__ function}}
+}
+
+__host__ __device__ void hd_member_fn() {
+  T t;
+  // Necessary to trigger an error on T::hd.  It's (implicitly) inline, so
+  // isn't codegen'ed until we call it.
+  t.hd();
+}
+
+__host__ __device__ void h_member_fn() {
+  T t;
+  t.h();
+  // expected-error@-1 {{reference to __host__ function 'h' in __host__ __device__ function}}
+}
+
+__host__ __device__ void fn_ptr() {
+  auto* ptr = &host_fn;
+  // expected-error@-1 {{reference to __host__ function 'host_fn' in __host__ __device__ function}}
+}
+
+template 
+__host__ __device__ void fn_ptr_template() {
+  auto* ptr = &host_fn;  // Not an error because the template isn't instantiated.
+}
Index: cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
===
--- cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
+++ cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 %s --std=c++

Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a couple of nits.



Comment at: clang-rename/USRFinder.cpp:182
@@ -179,5 +181,3 @@
   // We only want to search the decls that exist in the same file as the point.
-  auto Decls = Context.getTranslationUnitDecl()->decls();
-  for (auto &CurrDecl : Decls) {
-const auto FileLoc = CurrDecl->getLocStart();
-const auto FileName = Context.getSourceManager().getFilename(FileLoc);
+  for (const auto &CurrDecl : Context.getTranslationUnitDecl()->decls()) {
+const SourceLocation FileLoc = CurrDecl->getLocStart();

Should this be `const auto *` instead?


Comment at: clang-rename/USRLocFinder.cpp:132
@@ +131,3 @@
+const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ BeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());

I suspect, clang-format will join the arguments to one line. Can you try? 
(maybe just `git clang-format`)


https://reviews.llvm.org/D23397



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


Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 68104.
omtcyfz added a comment.

Address comments.


https://reviews.llvm.org/D23397

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/USRFinder.cpp
  clang-rename/USRFindingAction.cpp
  clang-rename/USRLocFinder.cpp

Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -67,7 +67,7 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager &Manager = Decl->getASTContext().getSourceManager();
@@ -79,7 +79,7 @@
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager &Manager = Decl->getASTContext().getSourceManager();
   SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
@@ -116,7 +116,8 @@
   // Namespace traversal:
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
 checkAndAddLocation(NameLoc.getLocalBeginLoc());
   }
@@ -126,8 +127,8 @@
 
 private:
   void checkAndAddLocation(SourceLocation Loc) {
-const auto BeginLoc = Loc;
-const auto EndLoc = Lexer::getLocForEndOfToken(
+const SourceLocation BeginLoc = Loc;
+const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
 BeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
 StringRef TokenName =
 Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc),
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -116,14 +116,14 @@
 
   void addUSRsOfOverridenFunctions(const CXXMethodDecl *MethodDecl) {
 USRSet.insert(getUSRForDecl(MethodDecl));
-for (auto &OverriddenMethod : MethodDecl->overridden_methods()) {
+for (const auto &OverriddenMethod : MethodDecl->overridden_methods()) {
   // Recursively visit each OverridenMethod.
   addUSRsOfOverridenFunctions(OverriddenMethod);
 }
   }
 
   bool checkIfOverriddenFunctionAscends(const CXXMethodDecl *MethodDecl) {
-for (auto &OverriddenMethod : MethodDecl->overridden_methods()) {
+for (const auto &OverriddenMethod : MethodDecl->overridden_methods()) {
   if (USRSet.find(getUSRForDecl(OverriddenMethod)) != USRSet.end()) {
 return true;
   }
@@ -143,10 +143,11 @@
 
 struct NamedDeclFindingConsumer : public ASTConsumer {
   void HandleTranslationUnit(ASTContext &Context) override {
-const auto &SourceMgr = Context.getSourceManager();
+const SourceManager &SourceMgr = Context.getSourceManager();
 // The file we look for the USR in will always be the main source file.
-const auto Point = SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID())
-   .getLocWithOffset(SymbolOffset);
+const SourceLocation Point =
+SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID())
+.getLocWithOffset(SymbolOffset);
 if (!Point.isValid())
   return;
 const NamedDecl *FoundDecl = nullptr;
Index: clang-rename/USRFinder.cpp
===
--- clang-rename/USRFinder.cpp
+++ clang-rename/USRFinder.cpp
@@ -60,23 +60,24 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 return setResult(Decl, Expr->getLocation(),
  Decl->getNameAsString().length());
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 return setResult(Decl, Expr->getMemberLoc(),
  Decl->getNameAsString().length());
   }
 
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
-const auto TypeBeginLoc = Loc.getBeginLoc();
-const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
+ TypeBeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());
 

Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
omtcyfz marked 2 inline comments as done.


Comment at: clang-rename/USRFinder.cpp:182-184
@@ -179,6 +181,5 @@
   // We only want to search the decls that exist in the same file as the point.
-  auto Decls = Context.getTranslationUnitDecl()->decls();
-  for (auto &CurrDecl : Decls) {
-const auto FileLoc = CurrDecl->getLocStart();
-const auto FileName = Context.getSourceManager().getFilename(FileLoc);
+  for (const auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
+const SourceLocation FileLoc = CurrDecl->getLocStart();
+StringRef FileName = Context.getSourceManager().getFilename(FileLoc);
 // FIXME: Add test.

Aww, sure. Thanks!


https://reviews.llvm.org/D23397



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


[PATCH] D23532: [LibTooling] Allow compilation database to explicitly specify compilation database file and source root

2016-08-15 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added a reviewer: cfe-commits.
zturner added subscribers: klimek, alexfh, djasper.

Allow explicit specification of a compilation database file and source root.

While trying to create a compilation database test for D23455, I ran into the 
problem that compilation database tests require a command shell, evidenced by 
the fact that at the top of `clang-tidy-run-with-database-cpp` contains the 
line `REQUIRES: SHELL`.  This makes it impossible to write the test that was 
requested in D23455 (not to mention it means the existing test is not running 
on Windows either).

I solve this by introducing a new command line parameter and slightly enhancing 
the functionality of an existing one, detailed below:

1. There was no way to specify an arbitrary compilation database.  At best you 
could specify the directory of a compilation database, but it would still be 
forced to look for `compile_commands.json`.  This is an inflexible design when 
you want to have multiple tests which each use their own compilation database.  
You could put them in different folders and call each one 
`compile_commands.json`, but that leads to many different directories with only 
one file, which is kind of silly.

The `-p` option let you specify a build path, which would be the folder where a 
compilation database existed, but it did not let you specify a *specific file* 
to use as a compilation database.  I improved expanded this behavior of this 
option to check if the specified path is a regular file or a directory.  If it 
is a regular file it doesn't search for a compilation database, and instead 
just uses the file you specify.  The nice thing about this is that now we can 
put many compilation databases for various tests in the same directory, and 
have the run line of the test reference the exact compilation database needed 
for the test.

2. Instead of a "real" compilation database, the test consisted of a template.  
And the test used shell in order to invoke `sed` to modify the template so that 
the files and directories would be correct.  So the test would output the 
modified template into the CMake output directory, and then it had to use more 
shell commands to copy the source files over to the CMake output directory so 
that they would be in the right hierarchy in order to be found by the relative 
paths written to the compilation database.

In order to remove the dependency on shell, we need a way to reference the 
source files in their original location in the source tree, and not require 
them to be copied to the output tree.  To do this I introduced a new command 
line option `-r` that lets you specify the root at which relative paths are 
resolved against.  

These two things combined eliminate the need to modify the compilation database 
with `sed` and write it to the output folder because we can write *actual* 
source code on disk and check it in for the tests, and the compilation database 
can refer to these files using actual relative paths.  Then because of #1, the 
run line can point directly to the compilation database in question.

I re-wrote the compilation database test to use this new method, and it now no 
longer depends on shell.  I will upload the re-written test in a separate patch 
since I can't do cross-repo diffs.

https://reviews.llvm.org/D23532

Files:
  include/clang/Tooling/CompilationDatabase.h
  include/clang/Tooling/JSONCompilationDatabase.h
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/JSONCompilationDatabase.cpp
  lib/Tooling/Tooling.cpp

Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -407,10 +407,12 @@
   // difference for example on network filesystems, where symlinks might be
   // switched during runtime of the tool. Fixing this depends on having a
   // file system abstraction that allows openat() style interactions.
-  if (OverlayFileSystem->setCurrentWorkingDirectory(
-  CompileCommand.Directory))
-llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+  if (!CompileCommand.Directory.empty()) {
+if (OverlayFileSystem->setCurrentWorkingDirectory(
+CompileCommand.Directory))
+  llvm::report_fatal_error("Cannot chdir into \"" +
+   Twine(CompileCommand.Directory) + "\n!");
+  }
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,10 +16,12 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #i

Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:858
@@ +857,3 @@
+  };
+  SAFE_STATIC T x = {42}; // OK.
+  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer

Sure, if that's a conscious design decision for the attribute.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6842
@@ +6841,3 @@
+
+def err_require_constant_init_failed : Error<
+  "variable does not have a constant initializer as required by the "

A separate note pointed at the attribute would make it clearer how the 
attribute got involved (especially via the macro expansion backtrace).


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. In 
C++98, `checkInitIsICE` is appropriate for globals of integral type; we do not 
have an implementation of strict constant expression checking for other types. 
Perhaps just documenting that (and maybe adding a FIXME here) is the best you 
can do for now, assuming you're not interested in implementing the C++98 rules.


https://reviews.llvm.org/D23385



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


[PATCH] D23533: [clang-tidy] Rewrite compilation database test to not require shell

2016-08-15 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added reviewers: alexfh, klimek, djasper.
zturner added a subscriber: cfe-commits.

This allows the test to run on windows, and also makes writing compilation 
database tests easier in general.  See D23532 for more information.

https://reviews.llvm.org/D23533

Files:
  test/clang-tidy/Inputs/compilation-database/a/a.cpp
  test/clang-tidy/Inputs/compilation-database/a/b.cpp
  test/clang-tidy/Inputs/compilation-database/b/b.cpp
  test/clang-tidy/Inputs/compilation-database/b/c.cpp
  test/clang-tidy/Inputs/compilation-database/b/d.cpp
  test/clang-tidy/Inputs/compilation-database/clang-tidy-database.json
  test/clang-tidy/Inputs/compilation-database/include/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- test/clang-tidy/clang-tidy-run-with-database.cpp
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -1,24 +1,35 @@
-// REQUIRES: shell
-// RUN: mkdir -p %T/compilation-database-test/include
-// RUN: mkdir -p %T/compilation-database-test/a
-// RUN: mkdir -p %T/compilation-database-test/b
-// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp
-// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp
-// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp
-// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
-// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
-// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
-// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix
-// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
-// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
-// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
-// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4
-// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %S/Inputs/compilation-database/clang-tidy-database.json \
+// RUN: -r %S/Inputs/compilation-database %S/Inputs/compilation-database/a/a.cpp %S/Inputs/compilation-database/a/b.cpp \
+// RUN: %S/Inputs/compilation-database/b/b.cpp %S/Inputs/compilation-database/b/c.cpp %S/Inputs/compilation-database/b/d.cpp \
+// RUN: -header-filter=.* -export-fixes=%t.yaml > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
+// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
 
-// CHECK-FIX1: int *AA = nullptr;
-// CHECK-FIX2: int *AB = nullptr;
-// CHECK-FIX3: int *BB = nullptr;
-// CHECK-FIX4: int *BC = nullptr;
-// CHECK-FIX5: int *HP = nullptr;
+// CHECK-MESSAGES: int *AA = 0;
+// CHECK-MESSAGES: int *AB = 0;
+// CHECK-MESSAGES: int *BB = 0;
+// CHECK-MESSAGES: int *BC = 0;
+// CHECK-MESSAGES: int *HP = 0;
+
+// CHECK-YAML: MainSourceFile:  ''
+// CHECK-YAML: Replacements:
+// CHECK-YAML:   - FilePath:a.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:b.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:b{{[/\\]}}b.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:..{{[/\\]}}b{{[/\\]}}c.cpp
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
+// CHECK-YAML:   - FilePath:'..{{[/\\]}}include{{[/\\]}}header.h'
+// CHECK-YAML: Offset:  10
+// CHECK-YAML: Length:  1
+// CHECK-YAML: ReplacementText: nullptr
\ No newline at end of file
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- test/clang-tidy/Inputs/compilation-database/template.json
+++ /dev/null
@@ -1,32 +0,0 @@
-[
-{
-  "directory": "test_dir/a",
-  "command": "clang++ -o test.o test_dir/a/a.cpp",
-  "file": "test_dir/a/a.cpp"
-},
-{
-  "directory": "test_dir/a",
-  "command": "clang++ -o test.o test_dir/

[clang-tools-extra] r278760 - [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Mon Aug 15 18:20:05 2016
New Revision: 278760

URL: http://llvm.org/viewvc/llvm-project?rev=278760&view=rev
Log:
[clang-rename] cleanup `auto` usages

As Alexander pointed out, LLVM Coding Standards are more conservative about
using auto, i.e. it should be used in the following situations:

* When the type is obvious, i.e. explicitly mentioned in the same expression.
For example `if (const clang::FieldDecl *FieldDecl = Initializer->getMember())`.
* When the type is totally non-obvious and one iterates over something. For
example
`for (const auto &CurrDecl : Context.getTranslationUnitDecl()->decls())`.

Otherwise the type should be explicitly stated.

Reviewers: alexfh

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

Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=278760&r1=278759&r2=278760&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Mon Aug 15 18:20:05 
2016
@@ -52,7 +52,7 @@ public:
   void HandleOneRename(ASTContext &Context, const std::string &NewName,
const std::string &PrevName,
const std::vector &USRs) {
-const auto &SourceMgr = Context.getSourceManager();
+const SourceManager &SourceMgr = Context.getSourceManager();
 std::vector RenamingCandidates;
 std::vector NewCandidates;
 
@@ -61,7 +61,7 @@ public:
 RenamingCandidates.insert(RenamingCandidates.end(), NewCandidates.begin(),
   NewCandidates.end());
 
-auto PrevNameLen = PrevName.length();
+unsigned PrevNameLen = PrevName.length();
 for (const auto &Loc : RenamingCandidates) {
   if (PrintLocations) {
 FullSourceLoc FullLoc(Loc, SourceMgr);
@@ -70,8 +70,8 @@ public:
<< FullLoc.getSpellingColumnNumber() << "\n";
   }
   // FIXME: better error handling.
-  auto Replace = tooling::Replacement(SourceMgr, Loc, PrevNameLen, 
NewName);
-  auto Err = FileToReplaces[Replace.getFilePath()].add(Replace);
+  tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
+  llvm::Error Err = FileToReplaces[Replace.getFilePath()].add(Replace);
   if (Err)
 llvm::errs() << "Renaming failed in " << Replace.getFilePath() << "! "
  << llvm::toString(std::move(Err)) << "\n";

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=278760&r1=278759&r2=278760&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Mon Aug 15 18:20:05 2016
@@ -60,13 +60,13 @@ public:
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 return setResult(Decl, Expr->getLocation(),
  Decl->getNameAsString().length());
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 return setResult(Decl, Expr->getMemberLoc(),
  Decl->getNameAsString().length());
   }
@@ -74,9 +74,10 @@ public:
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
-const auto TypeBeginLoc = Loc.getBeginLoc();
-const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
+ TypeBeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());
 if (const auto *TemplateTypeParm =
 dyn_cast(Loc.getType())) {
   return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
@@ -117,7 +118,8 @@ public:
   // \returns false on success and sets Result.
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
   NameLoc = NameLoc.getPrefix();
  

Re: [PATCH] D23397: [clang-rename] cleanup `auto` usages

2016-08-15 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
omtcyfz marked an inline comment as done.
Closed by commit rL278760: [clang-rename] cleanup `auto` usages (authored by 
omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D23397?vs=68104&id=68107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23397

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRFinder.cpp
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Index: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp
@@ -60,23 +60,24 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 return setResult(Decl, Expr->getLocation(),
  Decl->getNameAsString().length());
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 return setResult(Decl, Expr->getMemberLoc(),
  Decl->getNameAsString().length());
   }
 
   // Other visitors:
 
   bool VisitTypeLoc(const TypeLoc Loc) {
-const auto TypeBeginLoc = Loc.getBeginLoc();
-const auto TypeEndLoc = Lexer::getLocForEndOfToken(
-TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
+const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
+const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
+ TypeBeginLoc, 0, Context.getSourceManager(),
+ Context.getLangOpts());
 if (const auto *TemplateTypeParm =
 dyn_cast(Loc.getType())) {
   return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);
@@ -117,7 +118,8 @@
   // \returns false on success and sets Result.
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   setResult(Decl, NameLoc.getLocalBeginLoc(), NameLoc.getLocalEndLoc());
   NameLoc = NameLoc.getPrefix();
 }
@@ -173,14 +175,13 @@
 
 const NamedDecl *getNamedDeclAt(const ASTContext &Context,
 const SourceLocation Point) {
-  const auto SearchFile = Context.getSourceManager().getFilename(Point);
+  StringRef SearchFile = Context.getSourceManager().getFilename(Point);
   NamedDeclFindingASTVisitor Visitor(Point, Context);
 
   // We only want to search the decls that exist in the same file as the point.
-  auto Decls = Context.getTranslationUnitDecl()->decls();
-  for (auto &CurrDecl : Decls) {
-const auto FileLoc = CurrDecl->getLocStart();
-const auto FileName = Context.getSourceManager().getFilename(FileLoc);
+  for (const auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
+const SourceLocation FileLoc = CurrDecl->getLocStart();
+StringRef FileName = Context.getSourceManager().getFilename(FileLoc);
 // FIXME: Add test.
 if (FileName == SearchFile) {
   Visitor.TraverseDecl(CurrDecl);
Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -67,7 +67,7 @@
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl();
+const NamedDecl *Decl = Expr->getFoundDecl();
 
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager &Manager = Decl->getASTContext().getSourceManager();
@@ -79,7 +79,7 @@
   }
 
   bool VisitMemberExpr(const MemberExpr *Expr) {
-const auto *Decl = Expr->getFoundDecl().getDecl();
+const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
 if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
   const SourceManager &Manager = Decl->getASTContext().getSourceManager();
   SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc());
@@ -116,7 +116,8 @@
   // Namespace traversal:
   void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) {
 while (NameLoc) {
-  const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace();
+  const NamespaceDecl *Decl =
+  NameLoc.getNestedNameSpecifier()->getAsNamespace();
   if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) {
 checkAndAddLocation(NameLoc.getLocalBeginLoc());
   }
@@ -126,8 +127,8 @@
 
 private:
   void checkAndAd

Buildbot numbers for the week of 7/31/2016 - 8/06/2016

2016-08-15 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 7/31/2016 - 8/06/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time);

Thanks

Galina


The longest time each builder was red during the last week:

 buildername|  was_red
+---
 clang-3stage-ubuntu| 104:26:38
 clang-x64-ninja-win7   | 57:39:42
 clang-x86-win2008-selfhost | 37:12:21
 sanitizer-windows  | 35:59:16
 lldb-windows7-android  | 30:43:38
 lldb-x86_64-darwin-13.4| 28:53:57
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian| 16:52:14
 sanitizer-x86_64-linux | 12:57:21
 clang-native-aarch64-full  | 11:32:22
 clang-cmake-aarch64-full   | 09:10:29
 clang-ppc64le-linux-multistage | 07:58:21
 sanitizer-ppc64le-linux| 07:55:40
 clang-ppc64le-linux-lnt| 07:29:25
 sanitizer-ppc64be-linux| 07:17:24
 clang-ppc64be-linux-multistage | 06:42:28
 clang-cmake-thumbv7-a15-full-sh| 06:28:20
 clang-cmake-mips   | 06:27:27
 clang-ppc64be-linux-lnt| 06:21:39
 perf-x86_64-penryn-O3  | 06:19:35
 perf-x86_64-penryn-O3-polly-fast   | 06:13:02
 sanitizer-x86_64-linux-bootstrap   | 05:50:16
 clang-ppc64le-linux| 05:31:03
 clang-atom-d525-fedora-rel | 05:30:36
 clang-ppc64be-linux| 05:28:39
 clang-cmake-armv7-a15-selfhost | 05:23:07
 lldb-x86_64-ubuntu-14.04-cmake | 05:21:03
 clang-cmake-aarch64-42vma  | 05:15:20
 clang-cmake-aarch64-quick  | 04:58:26
 perf-x86_64-penryn-O3-polly-unprofitable   | 04:41:49
 clang-cmake-armv7-a15-full | 04:30:53
 perf-x86_64-penryn-O3-polly-parallel-fast  | 04:22:43
 clang-cuda-build   | 04:16:57
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 04:14:49
 clang-native-arm-lnt   | 04:08:27
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 02:55:42
 llvm-clang-lld-x86_64-debian-fast  | 02:54:29
 sanitizer-x86_64-linux-autoconf| 02:50:25
 llvm-mips-linux| 02:35:15
 sanitizer-x86_64-linux-fuzzer  | 02:01:54
 clang-x86_64-debian-fast   | 01:34:05
 lldb-amd64-ninja-netbsd7   | 01:30:36
 sanitizer-x86_64-linux-fast| 01:24:45
 lld-x86_64-freebsd | 01:23:58
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 01:20:51
 lld-x86_64-win7| 01:20:37
 lld-x86_64-darwin13| 01:20:27
 lldb-x86_64-ubuntu-14.04-buildserver   | 01:18:06
 lldb-x86_64-ubuntu-14.04-android   | 01:14:59
 clang-cmake-armv7-a15  | 01:07:50
 clang-cmake-thumbv7-a15| 01:07:50
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 01:04:32
 clang-hexagon-elf  | 00:58:54
 llvm-hexagon-elf   | 00:52:51
 polly-amd64-linux  | 00:42:35
 clang-x86_64-linux-abi-test| 00:40:12
 clang-s390x-linux  | 00:32:48
 lldb-amd64-ninja-freebsd11 | 00:23:50
(57 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername 

Buildbot numbers for the last week of 8/07/2016 - 8/13/2016

2016-08-15 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 8/07/2016 - 8/13/2016.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time);

Thanks

Galina


The longest time each builder was red during the last week:

 buildername|  was_red
+---
 lldb-windows7-android  | 58:07:37
 clang-ppc64be-linux-lnt| 30:43:16
 clang-native-aarch64-full  | 26:00:07
 libcxx-libcxxabi-libunwind-arm-linux-noexceptions  | 24:33:36
 libcxx-libcxxabi-libunwind-x86_64-linux-debian | 24:14:15
 libcxx-libcxxabi-libunwind-arm-linux   | 23:14:43
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu | 22:38:52
 clang-cmake-armv7-a15-selfhost-neon| 18:00:25
 clang-cmake-thumbv7-a15-full-sh| 17:46:36
 clang-cmake-armv7-a15-selfhost | 16:41:55
 clang-ppc64le-linux-multistage | 15:50:57
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 14:17:49
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 14:14:15
 sanitizer-ppc64be-linux| 13:53:48
 sanitizer-ppc64le-linux| 13:14:27
 clang-ppc64be-linux-multistage | 13:04:22
 sanitizer-x86_64-linux | 13:00:15
 clang-native-arm-lnt   | 12:19:32
 clang-x86-win2008-selfhost | 10:05:12
 clang-x64-ninja-win7   | 10:00:44
 sanitizer-x86_64-linux-bootstrap   | 09:34:04
 sanitizer-windows  | 09:29:19
 clang-cmake-armv7-a15-full | 08:39:13
 clang-cmake-thumbv7-a15| 08:36:47
 clang-cmake-armv7-a15  | 08:36:08
 sanitizer-x86_64-linux-fast| 08:31:37
 clang-atom-d525-fedora-rel | 08:15:31
 clang-cmake-mips   | 07:15:00
 perf-x86_64-penryn-O3-polly| 06:24:47
 perf-x86_64-penryn-O3-polly-fast   | 06:03:32
 clang-ppc64le-linux| 05:28:22
 lldb-x86_64-ubuntu-14.04-android   | 05:17:18
 llvm-mips-linux| 05:10:10
 clang-ppc64be-linux| 04:49:44
 clang-cmake-aarch64-quick  | 04:22:23
 clang-ppc64le-linux-lnt| 04:17:03
 llvm-clang-lld-x86_64-debian-fast  | 04:11:50
 clang-cmake-aarch64-42vma  | 03:46:22
 polly-amd64-linux  | 03:27:00
 clang-cmake-aarch64-full   | 03:04:35
 lldb-x86_64-darwin-13.4| 02:55:02
 clang-x86_64-debian-fast   | 02:42:25
 lldb-x86_64-ubuntu-14.04-cmake | 02:31:13
 clang-bpf-build| 02:15:46
 clang-cuda-build   | 02:14:35
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 02:14:03
 llvm-sphinx-docs   | 02:08:21
 libomp-ompt-gcc-x86_64-linux-debian| 02:05:29
 libomp-gcc-x86_64-linux-debian | 02:05:24
 perf-x86_64-penryn-O3-polly-unprofitable   | 02:03:12
 lldb-x86_64-ubuntu-14.04-buildserver   | 01:49:26
 perf-x86_64-penryn-O3-polly-parallel-fast  | 01:44:41
 sanitizer-x86_64-linux-fuzzer  | 01:15:34
 clang-3stage-ubuntu| 01:10:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03 | 01:08:59
 sanitizer-x86_64-linux-autoconf| 01:02:47
 llvm-hexagon-elf   | 00:59:27
 clang-hexagon-elf  | 00:59:10
 clang-x86_64-linux-abi-test| 00:47:13
 lld-x86_64-win7

Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-15 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Art,

Thanks for the patch! That looks good.


https://reviews.llvm.org/D23526



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


Re: [PATCH] D23375: Add kfree( ) to MallocChecker.cpp

2016-08-15 Thread Andrew Wells via cfe-commits
andrewmw94 added a comment.

I agree that more tests would be good.  Where should I put them? Should it be 
in a separate file or should I just have kmalloc/kfree tests next to the 
malloc/free ones?


https://reviews.llvm.org/D23375



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


Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-15 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.
manmanren added a comment.

The fix looks reasonable to me.

Cheers,
Manman



Comment at: test/CodeGenObjCXX/encode.mm:231
@@ +230,3 @@
+struct S {
+  typedef T Ty;
+  Ty *t;

I wonder if we can further reduce the testing case. Is this necessary to cause 
the infinite recursion?


https://reviews.llvm.org/D22929



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


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-15 Thread Adrian McCarthy via cfe-commits
amccarth updated this revision to Diff 68114.
amccarth added a comment.

Added a test.


https://reviews.llvm.org/D23462

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-dllimport-base-class.cpp

Index: test/CodeGenCXX/debug-info-dllimport-base-class.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-dllimport-base-class.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview 
-debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show 
the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1685,7 +1685,8 @@
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;


Index: test/CodeGenCXX/debug-info-dllimport-base-class.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-dllimport-base-class.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview -debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1685,7 +1685,8 @@
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-15 Thread Adrian McCarthy via cfe-commits
amccarth added a comment.

Thank, dblaikie, for correcting my terminology.


https://reviews.llvm.org/D23462



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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

rsmith wrote:
> In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. In 
> C++98, `checkInitIsICE` is appropriate for globals of integral type; we do 
> not have an implementation of strict constant expression checking for other 
> types. Perhaps just documenting that (and maybe adding a FIXME here) is the 
> best you can do for now, assuming you're not interested in implementing the 
> C++98 rules.
SGTM. I think I'll fall back to `isConstantInitializer()` in C++03. Do you have 
an example of what `checkConstantInitializer()` gets wrong in C++03?


https://reviews.llvm.org/D23385



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


r278763 - PR28978: If we need overload resolution for the move constructor of an

2016-08-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Aug 15 19:13:47 2016
New Revision: 278763

URL: http://llvm.org/viewvc/llvm-project?rev=278763&view=rev
Log:
PR28978: If we need overload resolution for the move constructor of an
anonymous union member of a class, we need overload resolution for the move
constructor of the class itself too; we can't rely on Sema to do the right
thing for us for anonymous union types.

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=278763&r1=278762&r2=278763&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 2016
@@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(Decl *D)
 data().DefaultedDestructorIsDeleted = true;
 }
 
+// For an anonymous union member, our overload resolution will perform
+// overload resolution for its members.
+if (Field->isAnonymousStructOrUnion()) {
+  data().NeedOverloadResolutionForMoveConstructor |=
+  FieldRec->data().NeedOverloadResolutionForMoveConstructor;
+  data().NeedOverloadResolutionForMoveAssignment |=
+  FieldRec->data().NeedOverloadResolutionForMoveAssignment;
+  data().NeedOverloadResolutionForDestructor |=
+  FieldRec->data().NeedOverloadResolutionForDestructor;
+}
+
 // C++0x [class.ctor]p5:
 //   A default constructor is trivial [...] if:
 //-- for all the non-static data members of its class that are of

Modified: cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp?rev=278763&r1=278762&r2=278763&view=diff
==
--- cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp (original)
+++ cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp Mon Aug 15 19:13:47 
2016
@@ -4,6 +4,9 @@ struct Trivial {};
 struct NonTrivial {
   NonTrivial(NonTrivial&&); // expected-note{{copy constructor is implicitly 
deleted}}
 };
+struct DeletedCopy {
+  DeletedCopy(const DeletedCopy&) = delete;
+};
 
 // A defaulted move constructor for a class X is defined as deleted if X has:
 
@@ -22,6 +25,15 @@ struct DeletedNTVariant2 {
 };
 DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // 
expected-error{{would delete}}
 
+// Note, move constructor is not a candidate because it is deleted.
+template struct DeletedNTVariant3 { // expected-note 2{{default}} 
expected-note 2{{copy}}
+  union {
+T NT;
+  };
+};
+extern DeletedNTVariant3 dntv3a(0); // expected-error {{no 
matching}}
+extern DeletedNTVariant3 dntv3a(0); // expected-error {{no 
matching}}
+
 // -- a non-static data member of class type M (or array thereof) that cannot 
be
 //copied because overload resolution results in an ambiguity or a function
 //that is deleted or inaccessible


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


Re: [PATCH] D22494: [analyzer] Explain why analyzer report is not generated (fix for PR12421).

2016-08-15 Thread Anton Yartsev via cfe-commits
ayartsev added a comment.

Ping.


https://reviews.llvm.org/D22494



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


Re: [PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

2016-08-15 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.


Comment at: lib/Sema/SemaDecl.cpp:9739
@@ +9738,3 @@
+  DeducedType = DeducedType.setNullability(
+  Init->getType()->getNullability(Context), Context);
+

Do we propagate other attributes for deduced types?


https://reviews.llvm.org/D22794



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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:10519-10520
@@ +10518,4 @@
+  auto *CE = dyn_cast(Init);
+  bool DiagErr = (var->isInitKnownICE() || (CE && 
CE->getConstructor()->isConstexpr()))
+  ? !var->checkInitIsICE() : !checkConstInit();
+  if (DiagErr)

EricWF wrote:
> rsmith wrote:
> > In C++11 onwards, `checkInitIsICE` is the right thing to use in all cases. 
> > In C++98, `checkInitIsICE` is appropriate for globals of integral type; we 
> > do not have an implementation of strict constant expression checking for 
> > other types. Perhaps just documenting that (and maybe adding a FIXME here) 
> > is the best you can do for now, assuming you're not interested in 
> > implementing the C++98 rules.
> SGTM. I think I'll fall back to `isConstantInitializer()` in C++03. Do you 
> have an example of what `checkConstantInitializer()` gets wrong in C++03?
   struct A {
 ~A();
 int n;
   } a;
   int *p = &a.n; // constant initializer, but not a C++98 address constant 
expression


https://reviews.llvm.org/D23385



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


Re: [PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

2016-08-15 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

Is this really a good idea? If I write:

  int *_Nullable f();
  int n;
  int *_Nonnull g() {
auto *p = f();
if (!p) p = &n;
return p;
  }

... it would be wrong to produce a warning that I'm converting from a nullable 
pointer to a non-nullable pointer.


https://reviews.llvm.org/D22794



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


[PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added a reviewer: tstellarAMD.
alexshap added a subscriber: cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".
Herald added subscribers: arsenm, aemerson.

The structs ImmOp and RegOp are in AArch64AsmParser.cpp (inside anonymous 
namespace).
This diff changes the order of fields and removes the excessive padding (8 
bytes).

https://reviews.llvm.org/D23536

Files:
  lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
===
--- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -136,18 +136,18 @@
   };
 
   struct ImmOp {
+int64_t Val;
+ImmTy Type;
 bool IsFPImm;
-ImmTy Type;
-int64_t Val;
 Modifiers Mods;
   };
 
   struct RegOp {
-unsigned RegNo;
-Modifiers Mods;
 const MCRegisterInfo *TRI;
 const MCSubtargetInfo *STI;
+unsigned RegNo;
 bool IsForcedVOP3;
+Modifiers Mods;
   };
 
   union {


Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
===
--- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -136,18 +136,18 @@
   };
 
   struct ImmOp {
+int64_t Val;
+ImmTy Type;
 bool IsFPImm;
-ImmTy Type;
-int64_t Val;
 Modifiers Mods;
   };
 
   struct RegOp {
-unsigned RegNo;
-Modifiers Mods;
 const MCRegisterInfo *TRI;
 const MCSubtargetInfo *STI;
+unsigned RegNo;
 bool IsForcedVOP3;
+Modifiers Mods;
   };
 
   union {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23530: Remove excessive padding from BarrierOp, PrefetchOp, PSBHintOp.

2016-08-15 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

The `Data` and `Length` fields are tied together.  Wouldn't it be possible to 
reorder this as `Val`, `Length`, `Data` and have it  achieve similar sizes and 
keep the `Data` and `Length` fields together?


https://reviews.llvm.org/D23530



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


Re: r278763 - PR28978: If we need overload resolution for the move constructor of an

2016-08-15 Thread Richard Smith via cfe-commits
Hi Hans, Eric Fiselier requested that we fix this bug for 3.9 (it affects
libc++'s std::optional implementation), so this would be a good candidate
for the branch.

On Mon, Aug 15, 2016 at 5:13 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Aug 15 19:13:47 2016
> New Revision: 278763
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278763&view=rev
> Log:
> PR28978: If we need overload resolution for the move constructor of an
> anonymous union member of a class, we need overload resolution for the move
> constructor of the class itself too; we can't rely on Sema to do the right
> thing for us for anonymous union types.
>
> Modified:
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> DeclCXX.cpp?rev=278763&r1=278762&r2=278763&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 2016
> @@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(Decl *D)
>  data().DefaultedDestructorIsDeleted = true;
>  }
>
> +// For an anonymous union member, our overload resolution will
> perform
> +// overload resolution for its members.
> +if (Field->isAnonymousStructOrUnion()) {
> +  data().NeedOverloadResolutionForMoveConstructor |=
> +  FieldRec->data().NeedOverloadResolutionForMoveConstructor;
> +  data().NeedOverloadResolutionForMoveAssignment |=
> +  FieldRec->data().NeedOverloadResolutionForMoveAssignment;
> +  data().NeedOverloadResolutionForDestructor |=
> +  FieldRec->data().NeedOverloadResolutionForDestructor;
> +}
> +
>  // C++0x [class.ctor]p5:
>  //   A default constructor is trivial [...] if:
>  //-- for all the non-static data members of its class that
> are of
>
> Modified: cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/
> special/class.copy/p11.0x.move.cpp?rev=278763&r1=278762&
> r2=278763&view=diff
> 
> ==
> --- cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp (original)
> +++ cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp Mon Aug 15
> 19:13:47 2016
> @@ -4,6 +4,9 @@ struct Trivial {};
>  struct NonTrivial {
>NonTrivial(NonTrivial&&); // expected-note{{copy constructor is
> implicitly deleted}}
>  };
> +struct DeletedCopy {
> +  DeletedCopy(const DeletedCopy&) = delete;
> +};
>
>  // A defaulted move constructor for a class X is defined as deleted if X
> has:
>
> @@ -22,6 +25,15 @@ struct DeletedNTVariant2 {
>  };
>  DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; //
> expected-error{{would delete}}
>
> +// Note, move constructor is not a candidate because it is deleted.
> +template struct DeletedNTVariant3 { // expected-note
> 2{{default}} expected-note 2{{copy}}
> +  union {
> +T NT;
> +  };
> +};
> +extern DeletedNTVariant3 dntv3a(0); // expected-error {{no
> matching}}
> +extern DeletedNTVariant3 dntv3a(0); // expected-error {{no
> matching}}
> +
>  // -- a non-static data member of class type M (or array thereof) that
> cannot be
>  //copied because overload resolution results in an ambiguity or a
> function
>  //that is deleted or inaccessible
>
>
> ___
> 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] D20561: Warn when taking address of packed member

2016-08-15 Thread Aaron Ballman via cfe-commits
On Mon, Aug 15, 2016 at 6:20 PM, Matthias Braun  wrote:
> MatzeB added a subscriber: MatzeB.
> MatzeB added a comment.
>
> The sanitizer code triggers this warning for code that looks conceptually 
> like this:
>
>   typedef struct Bla { char bar; int foo; } __attribute__((packed));
>
>   uintptr_t getu(struct Bla *b) { return (uintptr_t)&b->foo; }
>
> Resulting in:
>
>   taking address of packed member 'foo' of class or structure
> 'Bla' may result in an unaligned pointer value
> [-Waddress-of-packed-member]
>
> Of course the warning can be silenced with `return 
> (uintptr_t)(char*)&b->foo;` still casting to an int type seems like a benign 
> case for this warning so maybe we should exclude that?

I agree, it seems sensible to silence the warning in that case, yes.

~Aaron

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


Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Test plan: make -j8 check-llvm-unit

F2273124: Screen Shot 2016-08-15 at 5.14.59 PM.png 


F2273127: Screen Shot 2016-08-15 at 5.14.29 PM.png 



https://reviews.llvm.org/D23536



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


Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a reviewer: arsenm.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D23536



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


r278767 - [CUDA] Fix "declared here" note on deferred wrong-side errors.

2016-08-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon Aug 15 19:48:21 2016
New Revision: 278767

URL: http://llvm.org/viewvc/llvm-project?rev=278767&view=rev
Log:
[CUDA] Fix "declared here" note on deferred wrong-side errors.

Previously we weren't deferring these "declared here" notes, which is
obviously wrong.

Modified:
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=278767&r1=278766&r2=278767&view=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Mon Aug 15 19:48:21 2016
@@ -499,11 +499,16 @@ bool Sema::CheckCUDACall(SourceLocation
   if (Pref == Sema::CFP_WrongSide) {
 // We have to do this odd dance to create our PartialDiagnostic because we
 // want its storage to be allocated with operator new, not in an arena.
-PartialDiagnostic PD{PartialDiagnostic::NullDiagnostic()};
-PD.Reset(diag::err_ref_bad_target);
-PD << IdentifyCUDATarget(Callee) << Callee << IdentifyCUDATarget(Caller);
-Caller->addDeferredDiag({Loc, std::move(PD)});
-Diag(Callee->getLocation(), diag::note_previous_decl) << Callee;
+PartialDiagnostic ErrPD{PartialDiagnostic::NullDiagnostic()};
+ErrPD.Reset(diag::err_ref_bad_target);
+ErrPD << IdentifyCUDATarget(Callee) << Callee << 
IdentifyCUDATarget(Caller);
+Caller->addDeferredDiag({Loc, std::move(ErrPD)});
+
+PartialDiagnostic NotePD{PartialDiagnostic::NullDiagnostic()};
+NotePD.Reset(diag::note_previous_decl);
+NotePD << Callee;
+Caller->addDeferredDiag({Callee->getLocation(), std::move(NotePD)});
+
 // This is not immediately an error, so return true.  The deferred errors
 // will be emitted if and when Caller is codegen'ed.
 return true;

Modified: cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu?rev=278767&r1=278766&r2=278767&view=diff
==
--- cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu (original)
+++ cfe/trunk/test/SemaCUDA/call-device-fn-from-host.cu Mon Aug 15 19:48:21 2016
@@ -6,10 +6,18 @@
 #include "Inputs/cuda.h"
 
 __device__ void device_fn() {}
+// expected-note@-1 {{'device_fn' declared here}}
+// expected-note@-2 {{'device_fn' declared here}}
+// expected-note@-3 {{'device_fn' declared here}}
+// expected-note@-4 {{'device_fn' declared here}}
+// expected-note@-5 {{'device_fn' declared here}}
 
 struct S {
   __device__ S() {}
+  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-2 {{'S' declared here}}
   __device__ ~S() { device_fn(); }
+  // expected-note@-1 {{'~S' declared here}}
   int x;
 };
 
@@ -24,6 +32,7 @@ struct T {
   __host__ __device__ void hd3();
 
   __device__ void d() {}
+  // expected-note@-1 {{'d' declared here}}
 };
 
 __host__ __device__ void T::hd3() {

Modified: cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu?rev=278767&r1=278766&r2=278767&view=diff
==
--- cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu (original)
+++ cfe/trunk/test/SemaCUDA/call-host-fn-from-device.cu Mon Aug 15 19:48:21 2016
@@ -6,10 +6,19 @@
 #include "Inputs/cuda.h"
 
 extern "C" void host_fn() {}
+// expected-note@-1 {{'host_fn' declared here}}
+// expected-note@-2 {{'host_fn' declared here}}
+// expected-note@-3 {{'host_fn' declared here}}
+// expected-note@-4 {{'host_fn' declared here}}
+// expected-note@-5 {{'host_fn' declared here}}
+// expected-note@-6 {{'host_fn' declared here}}
 
 struct S {
   S() {}
+  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-2 {{'S' declared here}}
   ~S() { host_fn(); }
+  // expected-note@-1 {{'~S' declared here}}
   int x;
 };
 
@@ -24,6 +33,7 @@ struct T {
   __host__ __device__ void hd3();
 
   void h() {}
+  // expected-note@-1 {{'h' declared here}}
 };
 
 __host__ __device__ void T::hd3() {


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


Re: [PATCH] D23385: Implement __attribute__((require_constant_initialization)) for safe static initialization.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 68121.
EricWF added a comment.

Do strict 'constant initializer' checking in C++11, but fall back to 
`isConstantInitializer()` in C++03. Add documentation about non-strict C++03 
checking.

This has weird results for POD types, for example:

  struct PODType { int x; int y; };
  __attribute__((require_constant_initialization)) PODType pod; // error in 
C++11, OK in C++03.


https://reviews.llvm.org/D23385

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCXX/attr-require-constant-initialization.cpp

Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -0,0 +1,280 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_TWO \
+// RUN: -Wglobal-constructors -std=c++14 %s
+
+#if !__has_feature(cxx_static_assert)
+#define static_assert(b_, m_) _Static_assert(b_, m_)
+#endif
+
+#define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
+
+// Test diagnostics when attribute is applied to non-static declarations.
+void test_func_local(ATTR int param) { // expected-error {{only applies to variables with static or thread}}
+ATTR int x = 42; // expected-error {{only applies to variables with static or thread}}
+ATTR extern int y;
+}
+struct ATTR class_mem { // expected-error {{only applies to variables with static or thread}}
+  ATTR int x; // expected-error {{only applies to variables with static or thread}}
+};
+
+int ReturnInt();
+
+struct PODType {
+int value;
+int value2;
+};
+#if __cplusplus >= 201103L
+struct LitType {
+constexpr LitType() : value(0) {}
+constexpr LitType(int x) : value(x) {}
+LitType(void*) : value(-1) {}
+int value;
+};
+#endif
+
+struct NonLit {
+#if __cplusplus >= 201402L
+constexpr NonLit() : value(0) {}
+constexpr NonLit(int x ) : value(x) {}
+#else
+NonLit() : value(0) {}
+NonLit(int x) : value(x) {}
+#endif
+NonLit(void*) : value(-1) {}
+~NonLit() {}
+int value;
+};
+
+struct StoresNonLit {
+#if __cplusplus >= 201402L
+constexpr StoresNonLit() : obj() {}
+constexpr StoresNonLit(int x) : obj(x) {}
+#else
+StoresNonLit() : obj() {}
+StoresNonLit(int x) : obj(x) {}
+#endif
+StoresNonLit(void* p) : obj(p) {}
+NonLit obj;
+};
+
+const bool NonLitHasConstInit =
+#if __cplusplus >= 201402L
+true;
+#else
+false;
+#endif
+
+#if defined(TEST_ONE) // Test semantics of attribute
+
+// [basic.start.static]p2.1
+// if each full-expression (including implicit conversions) that appears in
+// the initializer of a reference with static or thread storage duration is
+// a constant expression (5.20) and the reference is bound to a glvalue
+// designating an object with static storage duration, to a temporary object
+// (see 12.2) or subobject thereof, or to a function;
+
+// Test binding to a static glvalue
+const int glvalue_int = 42;
+const int glvalue_int2 = ReturnInt();
+ATTR const int& glvalue_ref ATTR = glvalue_int;
+ATTR const int& glvalue_ref2 ATTR = glvalue_int2;
+ATTR __thread const int& glvalue_ref_tl = glvalue_int;
+
+void test_basic_start_static_2_1() {
+const int non_global = 42;
+ATTR static const int& local_init = non_global; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+ATTR static const int& global_init = glvalue_int;
+ATTR static const int& temp_init = 42;
+}
+
+ATTR const int& temp_ref = 42;
+ATTR const int& temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+ATTR const NonLit& nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+
+#if __cplusplus >= 201103L
+ATTR const LitType& lit_temp_ref = 42;
+ATTR const int& subobj_ref = LitType{}.value;
+#endif
+
+ATTR const int& nl_subobj_ref = NonLit().value;  // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+
+struct TT1 {
+  ATTR static const int& no_init;
+  ATTR static const int& glvalue_init;
+  ATTR static const int& temp_init;
+  ATTR static const int& subobj_init;
+#if __cplusplus >= 201103L
+  ATTR static thread_local const int

Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thx, I don't have commit access, need smb to land this patch


https://reviews.llvm.org/D23536



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


Re: [PATCH] D23530: Remove excessive padding from BarrierOp, PrefetchOp, PSBHintOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Yes: "Data, Length, Val" would work as well, i will update this diff


https://reviews.llvm.org/D23530



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


Re: [clang-tools-extra] r278760 - [clang-rename] cleanup `auto` usages

2016-08-15 Thread Eric Fiselier via cfe-commits
On Mon, Aug 15, 2016 at 5:20 PM, Kirill Bobyrev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: omtcyfz
> Date: Mon Aug 15 18:20:05 2016
> New Revision: 278760
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278760&view=rev
> Log:
> [clang-rename] cleanup `auto` usages
>
> As Alexander pointed out, LLVM Coding Standards are more conservative about
> using auto, i.e. it should be used in the following situations:
>
> * When the type is obvious, i.e. explicitly mentioned in the same
> expression.
> For example `if (const clang::FieldDecl *FieldDecl =
> Initializer->getMember())`.
> * When the type is totally non-obvious and one iterates over something. For
> example
> `for (const auto &CurrDecl : Context.getTranslationUnitDecl()->decls())`.
>
> Otherwise the type should be explicitly stated.
>
> Reviewers: alexfh
>
> Differential Revision: https://reviews.llvm.org/D23397
>
> Modified:
> clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
> clang-tools-extra/trunk/clang-rename/USRFinder.cpp
> clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
> clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
>
> Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-rename/RenamingAction.cpp?rev=278760&
> r1=278759&r2=278760&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
> +++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Mon Aug 15
> 18:20:05 2016
> @@ -52,7 +52,7 @@ public:
>void HandleOneRename(ASTContext &Context, const std::string &NewName,
> const std::string &PrevName,
> const std::vector &USRs) {
> -const auto &SourceMgr = Context.getSourceManager();
> +const SourceManager &SourceMgr = Context.getSourceManager();
>  std::vector RenamingCandidates;
>  std::vector NewCandidates;
>
> @@ -61,7 +61,7 @@ public:
>  RenamingCandidates.insert(RenamingCandidates.end(),
> NewCandidates.begin(),
>NewCandidates.end());
>
> -auto PrevNameLen = PrevName.length();
> +unsigned PrevNameLen = PrevName.length();
>  for (const auto &Loc : RenamingCandidates) {
>if (PrintLocations) {
>  FullSourceLoc FullLoc(Loc, SourceMgr);
> @@ -70,8 +70,8 @@ public:
> << FullLoc.getSpellingColumnNumber() << "\n";
>}
>// FIXME: better error handling.
> -  auto Replace = tooling::Replacement(SourceMgr, Loc, PrevNameLen,
> NewName);
> -  auto Err = FileToReplaces[Replace.getFilePath()].add(Replace);
> +  tooling::Replacement Replace(SourceMgr, Loc, PrevNameLen, NewName);
> +  llvm::Error Err = FileToReplaces[Replace.
> getFilePath()].add(Replace);
>if (Err)
>  llvm::errs() << "Renaming failed in " << Replace.getFilePath() <<
> "! "
>   << llvm::toString(std::move(Err)) << "\n";
>
> Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-rename/USRFinder.cpp?rev=278760&r1=278759&r2=278760&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
> +++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Mon Aug 15
> 18:20:05 2016
> @@ -60,13 +60,13 @@ public:
>// Expression visitors:
>
>bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
> -const auto *Decl = Expr->getFoundDecl();
> +const NamedDecl *Decl = Expr->getFoundDecl();
>  return setResult(Decl, Expr->getLocation(),
>   Decl->getNameAsString().length());
>}
>
>bool VisitMemberExpr(const MemberExpr *Expr) {
> -const auto *Decl = Expr->getFoundDecl().getDecl();
> +const NamedDecl *Decl = Expr->getFoundDecl().getDecl();
>  return setResult(Decl, Expr->getMemberLoc(),
>   Decl->getNameAsString().length());
>}
> @@ -74,9 +74,10 @@ public:
>// Other visitors:
>
>bool VisitTypeLoc(const TypeLoc Loc) {
> -const auto TypeBeginLoc = Loc.getBeginLoc();
> -const auto TypeEndLoc = Lexer::getLocForEndOfToken(
> -TypeBeginLoc, 0, Context.getSourceManager(),
> Context.getLangOpts());
> +const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
> +const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
> + TypeBeginLoc, 0, Context.getSourceManager(),
> + Context.getLangOpts());
>  if (const auto *TemplateTypeParm =
>  dyn_cast(Loc.getType())) {
>return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc,
> TypeEndLoc);
> @@ -117,7 +118,8 @@ public:
>// \returns false on success and sets Result.
>void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) 

Re: [PATCH] D23485: [Branch 3.9] Remove any traces of partial constexpr lambda implementation (per Richard's request)

2016-08-15 Thread Faisal Vali via cfe-commits
faisalv closed this revision.
faisalv added a comment.

Closed by http://llvm.org/viewvc/llvm-project?view=revision&revision=278771


https://reviews.llvm.org/D23485



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


[libcxxabi] r278773 - Default LIBCXXABI_LIBDIR_SUFFIX to LLVM_LIBDIR_SUFFIX

2016-08-15 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Aug 15 22:44:55 2016
New Revision: 278773

URL: http://llvm.org/viewvc/llvm-project?rev=278773&view=rev
Log:
Default LIBCXXABI_LIBDIR_SUFFIX to LLVM_LIBDIR_SUFFIX

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=278773&r1=278772&r2=278773&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Aug 15 22:44:55 2016
@@ -93,7 +93,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 set(LLVM_INCLUDE_TESTS OFF)
   endif()
 
-  set(LIBCXXABI_LIBDIR_SUFFIX "" CACHE STRING
+  set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
   "Define suffix of library directory name (32/64)")
 
   set(LIBCXXABI_BUILT_STANDALONE 1)


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


Re: [PATCH] D23530: Remove excessive padding from BarrierOp, PrefetchOp, PSBHintOp.

2016-08-15 Thread Alexander Shaposhnikov via cfe-commits
alexshap updated this revision to Diff 68128.
alexshap added a comment.

Address code review comment


https://reviews.llvm.org/D23530

Files:
  lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -208,9 +208,9 @@
   };
 
   struct BarrierOp {
+const char *Data; 
+unsigned Length;
 unsigned Val; // Not the enum since not all values have names.
-const char *Data;
-unsigned Length;
   };
 
   struct SysRegOp {
@@ -226,15 +226,15 @@
   };
 
   struct PrefetchOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct PSBHintOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct ShiftExtendOp {


Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -208,9 +208,9 @@
   };
 
   struct BarrierOp {
+const char *Data; 
+unsigned Length;
 unsigned Val; // Not the enum since not all values have names.
-const char *Data;
-unsigned Length;
   };
 
   struct SysRegOp {
@@ -226,15 +226,15 @@
   };
 
   struct PrefetchOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct PSBHintOp {
-unsigned Val;
 const char *Data;
 unsigned Length;
+unsigned Val;
   };
 
   struct ShiftExtendOp {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r278780 - [clang-rename] fix broken build

2016-08-15 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Tue Aug 16 01:19:06 2016
New Revision: 278780

URL: http://llvm.org/viewvc/llvm-project?rev=278780&view=rev
Log:
[clang-rename] fix broken build

As Eric Fiselier pointed out, r278760 breaks build, because RecursiveASTVisitor
doesn't have a const overload. This patch is a quick fix.

Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=278780&r1=278779&r2=278780&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Tue Aug 16 01:19:06 2016
@@ -179,7 +179,7 @@ const NamedDecl *getNamedDeclAt(const AS
   NamedDeclFindingASTVisitor Visitor(Point, Context);
 
   // We only want to search the decls that exist in the same file as the point.
-  for (const auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
+  for (auto *CurrDecl : Context.getTranslationUnitDecl()->decls()) {
 const SourceLocation FileLoc = CurrDecl->getLocStart();
 StringRef FileName = Context.getSourceManager().getFilename(FileLoc);
 // FIXME: Add test.


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


[PATCH] D23543: Adapt to TraverseLambdaCapture interface change from D23204

2016-08-15 Thread Martin Böhme via cfe-commits
mboehme created this revision.
mboehme added a reviewer: alexfh.
mboehme added a subscriber: cfe-commits.
mboehme added a dependency: D23204: Visit lambda capture inits from 
RecursiveASTVisitor::TraverseLambdaCapture()..

Depends on D23204.

This is intended to be submitted immediately after D23204 lands.

https://reviews.llvm.org/D23543

Files:
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/LoopConvertUtils.h
  modularize/Modularize.cpp

Index: modularize/Modularize.cpp
===
--- modularize/Modularize.cpp
+++ modularize/Modularize.cpp
@@ -571,7 +571,10 @@
 return true;
   }
   bool TraverseConstructorInitializer(CXXCtorInitializer *Init) { return true; 
}
-  bool TraverseLambdaCapture(LambdaCapture C) { return true; }
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init) {
+return true;
+  }
 
   // Check 'extern "*" {}' block for #include directives.
   bool VisitLinkageSpecDecl(LinkageSpecDecl *D) {
@@ -756,7 +759,10 @@
 return true;
   }
   bool TraverseConstructorInitializer(CXXCtorInitializer *Init) { return true; 
}
-  bool TraverseLambdaCapture(LambdaCapture C) { return true; }
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init) {
+return true;
+  }
 
   // Check 'extern "*" {}' block for #include directives.
   bool VisitLinkageSpecDecl(LinkageSpecDecl *D) {
Index: clang-tidy/modernize/LoopConvertUtils.h
===
--- clang-tidy/modernize/LoopConvertUtils.h
+++ clang-tidy/modernize/LoopConvertUtils.h
@@ -337,7 +337,8 @@
   bool TraverseArraySubscriptExpr(ArraySubscriptExpr *E);
   bool TraverseCXXMemberCallExpr(CXXMemberCallExpr *MemberCall);
   bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *OpCall);
-  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C);
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init);
   bool TraverseMemberExpr(MemberExpr *Member);
   bool TraverseUnaryDeref(UnaryOperator *Uop);
   bool VisitDeclRefExpr(DeclRefExpr *E);
Index: clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tidy/modernize/LoopConvertUtils.cpp
@@ -763,7 +763,8 @@
 ///   }
 /// \endcode
 bool ForLoopIndexUseVisitor::TraverseLambdaCapture(LambdaExpr *LE,
-   const LambdaCapture *C) {
+   const LambdaCapture *C,
+   Expr *Init) {
   if (C->capturesVariable()) {
 const VarDecl *VDecl = C->getCapturedVar();
 if (areSameVariable(IndexVar, cast(VDecl))) {
@@ -776,7 +777,7 @@
  C->getLocation()));
 }
   }
-  return VisitorBase::TraverseLambdaCapture(LE, C);
+  return VisitorBase::TraverseLambdaCapture(LE, C, Init);
 }
 
 /// \brief If we find that another variable is created just to refer to the 
loop


Index: modularize/Modularize.cpp
===
--- modularize/Modularize.cpp
+++ modularize/Modularize.cpp
@@ -571,7 +571,10 @@
 return true;
   }
   bool TraverseConstructorInitializer(CXXCtorInitializer *Init) { return true; }
-  bool TraverseLambdaCapture(LambdaCapture C) { return true; }
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init) {
+return true;
+  }
 
   // Check 'extern "*" {}' block for #include directives.
   bool VisitLinkageSpecDecl(LinkageSpecDecl *D) {
@@ -756,7 +759,10 @@
 return true;
   }
   bool TraverseConstructorInitializer(CXXCtorInitializer *Init) { return true; }
-  bool TraverseLambdaCapture(LambdaCapture C) { return true; }
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init) {
+return true;
+  }
 
   // Check 'extern "*" {}' block for #include directives.
   bool VisitLinkageSpecDecl(LinkageSpecDecl *D) {
Index: clang-tidy/modernize/LoopConvertUtils.h
===
--- clang-tidy/modernize/LoopConvertUtils.h
+++ clang-tidy/modernize/LoopConvertUtils.h
@@ -337,7 +337,8 @@
   bool TraverseArraySubscriptExpr(ArraySubscriptExpr *E);
   bool TraverseCXXMemberCallExpr(CXXMemberCallExpr *MemberCall);
   bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *OpCall);
-  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C);
+  bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C,
+ Expr *Init);
   bool TraverseMemberExpr(MemberExpr *Member);
   bool TraverseUnaryDeref(UnaryOperator *Uop);
   bool VisitDeclRefExpr(DeclRefExpr *E);
Index: clang-tidy/modernize/LoopCon

Re: [PATCH] D23204: Visit lambda capture inits from RecursiveASTVisitor::TraverseLambdaCapture().

2016-08-15 Thread Martin Böhme via cfe-commits
mboehme updated this revision to Diff 68139.
mboehme added a comment.

Update to a clean diff.

(Sorry, the last diff included a large number of extraneous changes by others.)


https://reviews.llvm.org/D23204

Files:
  include/clang/AST/RecursiveASTVisitor.h
  lib/Index/IndexBody.cpp
  unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
  unittests/Tooling/TestVisitor.h

Index: unittests/Tooling/TestVisitor.h
===
--- unittests/Tooling/TestVisitor.h
+++ unittests/Tooling/TestVisitor.h
@@ -43,6 +43,7 @@
 Lang_C,
 Lang_CXX98,
 Lang_CXX11,
+Lang_CXX14,
 Lang_OBJC,
 Lang_OBJCXX11,
 Lang_CXX = Lang_CXX98
@@ -55,6 +56,7 @@
   case Lang_C: Args.push_back("-std=c99"); break;
   case Lang_CXX98: Args.push_back("-std=c++98"); break;
   case Lang_CXX11: Args.push_back("-std=c++11"); break;
+  case Lang_CXX14: Args.push_back("-std=c++14"); break;
   case Lang_OBJC: Args.push_back("-ObjC"); break;
   case Lang_OBJCXX11:
 Args.push_back("-ObjC++");
@@ -127,9 +129,12 @@
   /// \brief Expect 'Match' to occur at the given 'Line' and 'Column'.
   ///
   /// Any number of expected matches can be set by calling this repeatedly.
-  /// Each is expected to be matched exactly once.
-  void ExpectMatch(Twine Match, unsigned Line, unsigned Column) {
-ExpectedMatches.push_back(ExpectedMatch(Match, Line, Column));
+  /// Each is expected to be matched 'Times' number of times. (This is useful in
+  /// cases in which different AST nodes can match at the same source code
+  /// location.)
+  void ExpectMatch(Twine Match, unsigned Line, unsigned Column,
+   unsigned Times = 1) {
+ExpectedMatches.push_back(ExpectedMatch(Match, Line, Column, Times));
   }
 
   /// \brief Checks that all expected matches have been found.
@@ -200,30 +205,34 @@
   };
 
   struct ExpectedMatch {
-ExpectedMatch(Twine Name, unsigned LineNumber, unsigned ColumnNumber)
-  : Candidate(Name, LineNumber, ColumnNumber), Found(false) {}
+ExpectedMatch(Twine Name, unsigned LineNumber, unsigned ColumnNumber,
+  unsigned Times)
+: Candidate(Name, LineNumber, ColumnNumber), TimesExpected(Times),
+  TimesSeen(0) {}
 
 void UpdateFor(StringRef Name, FullSourceLoc Location, SourceManager &SM) {
   if (Candidate.Matches(Name, Location)) {
-EXPECT_TRUE(!Found);
-Found = true;
-  } else if (!Found && Candidate.PartiallyMatches(Name, Location)) {
+EXPECT_LT(TimesSeen, TimesExpected);
+++TimesSeen;
+  } else if (TimesSeen < TimesExpected &&
+ Candidate.PartiallyMatches(Name, Location)) {
 llvm::raw_string_ostream Stream(PartialMatches);
 Stream << ", partial match: \"" << Name << "\" at ";
 Location.print(Stream, SM);
   }
 }
 
 void ExpectFound() const {
-  EXPECT_TRUE(Found)
+  EXPECT_EQ(TimesExpected, TimesSeen)
   << "Expected \"" << Candidate.ExpectedName
   << "\" at " << Candidate.LineNumber
   << ":" << Candidate.ColumnNumber << PartialMatches;
 }
 
 MatchCandidate Candidate;
 std::string PartialMatches;
-bool Found;
+unsigned TimesExpected;
+unsigned TimesSeen;
   };
 
   std::vector DisallowedMatches;
Index: unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
+++ unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
@@ -161,10 +161,21 @@
 
 class DeclRefExprVisitor : public ExpectedLocationVisitor {
 public:
+  DeclRefExprVisitor() : ShouldVisitImplicitCode(false) {}
+
+  bool shouldVisitImplicitCode() const { return ShouldVisitImplicitCode; }
+
+  void setShouldVisitImplicitCode(bool NewValue) {
+ShouldVisitImplicitCode = NewValue;
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *Reference) {
 Match(Reference->getNameInfo().getAsString(), Reference->getLocation());
 return true;
   }
+
+private:
+  bool ShouldVisitImplicitCode;
 };
 
 TEST(RecursiveASTVisitor, VisitsBaseClassTemplateArguments) {
@@ -191,14 +202,44 @@
 "void x(); void y() { x(); }"));
 }
 
-TEST(RecursiveASTVisitor, VisitsLambdaCaptureInit) {
+TEST(RecursiveASTVisitor, VisitsExplicitLambdaCaptureInit) {
   DeclRefExprVisitor Visitor;
   Visitor.ExpectMatch("i", 1, 20);
   EXPECT_TRUE(Visitor.runOver(
-"void f() { int i; [i]{}; };",
+"void f() { int i; [i]{}; }",
 DeclRefExprVisitor::Lang_CXX11));
 }
 
+TEST(RecursiveASTVisitor, VisitsImplicitLambdaCaptureInit) {
+  {
+DeclRefExprVisitor Visitor;
+Visitor.ExpectMatch("i", 1, 24);
+EXPECT_TRUE(Visitor.runOver(
+  "void f() { int i; [=]{ i; }; }",
+  DeclRefExprVisitor::Lang_CXX11));
+  }
+  {
+DeclRefExprVisitor Visitor;
+Visitor.setShouldVisitImplicitCode(true);
+// We're expecting the "i" in the lambda to be visited 

Re: [PATCH] D23204: Visit lambda capture inits from RecursiveASTVisitor::TraverseLambdaCapture().

2016-08-15 Thread Martin Böhme via cfe-commits
mboehme marked 2 inline comments as done.


Comment at: include/clang/AST/RecursiveASTVisitor.h:892
@@ -891,1 +891,3 @@
+  else
+TRY_TO(TraverseStmt(LE->capture_init_begin()[C - LE->capture_begin()]));
   return true;

klimek wrote:
> I'd rather pass in the offset than doing math with what's semantically a 
> pointer vs an iterator.
I think the cleanest way to do this would be to pass in both the LambdaCapture 
and the Expr for the corresponding initialization (and handle the offsets in 
TraverseLambdaExpr).

This will first require transitioning all users of TraverseLambdaCapture to the 
new interface, which I'll do in a separate patch.


Comment at: include/clang/AST/RecursiveASTVisitor.h:895
@@ -891,1 +894,3 @@
+  else
+TRY_TO(TraverseStmt(Init));
   return true;

I've now decided to do the interface change for TraverseLambdaCapture in this 
same patch.

There are a few users of TraverseLambdaCapture in clang-tools-extra; the 
required changes are in D23543. The intent is to wait until the reviews for 
both patches are complete, then submit them at the same time.


https://reviews.llvm.org/D23204



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


Re: [PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

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


Comment at: clang-tidy/cert/LimitedRandomnessCheck.cpp:22-23
@@ +21,4 @@
+  Finder->addMatcher(
+  declRefExpr(hasDeclaration(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+  .bind("randomGenerator"),

aaron.ballman wrote:
> Prazek wrote:
> > aaron.ballman wrote:
> > > Prazek wrote:
> > > > aaron.ballman wrote:
> > > > > This should be looking at a callExpr() rather than a declRefExpr(), 
> > > > > should it not?
> > > > I was also thinking about this, but this is actually better, because it 
> > > > will also match with binding rand with function pointer.
> > > True, but a DeclRefExpr doesn't mean it's a function call. Binding the 
> > > function is not contrary to the CERT rule, just calling it. For instance, 
> > > the following pathological case will be caught by this check:
> > > ```
> > > if (std::rand) {}
> > > ```
> > > The behavior of this check should be consistent with cert-env33-c, which 
> > > only looks at calls. (If we really care about bound functions, we'd need 
> > > flow control analysis, and I think that's overkill for both of those 
> > > checks, but wouldn't be opposed to someone writing the flow analysis if 
> > > they really wanted to.)
> > It would indeed fire on this pathological case, but I don't think we should 
> > care about cases like this, because no one is writing code like this (and 
> > if he would then it would probably be a bug).
> > I don't think that there is much code that binds pointer to std::rand 
> > either, but I think it would be good to display warning for this, because 
> > even if the function would be never called, then it means that this is a 
> > bug, and if it would be called then it would be nice to tell user that rand 
> > might be used here.
> > 
> > Anyway I don't oppose for changing it to callExpr, but I think it is better 
> > this way.
> > It would indeed fire on this pathological case, but I don't think we should 
> > care about cases like this, because no one is writing code like this (and 
> > if he would then it would probably be a bug).
> 
> It would be a known false-positive for a check designed to conform to a 
> particular coding standard. When deviations have come up in the past for 
> various coding standards, we've added an option to enable the additional 
> functionality, which I don't think would be reasonable in this case. 
> Alternatively, the CERT guideline could be modified, but that is unlikely to 
> occur because binding the function pointer is not a security concern (only 
> calling the function).
In case you let binding to function pointer you introduce potential false 
negatives which is worse in this case in my opinion. 


Repository:
  rL LLVM

https://reviews.llvm.org/D22346



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


r278656 - [CodeGen] Ignore unnamed bitfields before handling vector fields

2016-08-15 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Aug 15 02:20:40 2016
New Revision: 278656

URL: http://llvm.org/viewvc/llvm-project?rev=278656&view=rev
Log:
[CodeGen] Ignore unnamed bitfields before handling vector fields

We processed unnamed bitfields after our logic for non-vector field
elements in records larger than 128 bits.  The vector logic would
determine that the bit-field disqualifies the record from occupying a
register despite the unnamed bit-field not participating in the record
size nor its alignment.

N.B. This behavior matches GCC and ICC.

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/x86_64-arguments.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=278656&r1=278655&r2=278656&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Aug 15 02:20:40 2016
@@ -2589,6 +2589,10 @@ void X86_64ABIInfo::classify(QualType Ty
   uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);
   bool BitField = i->isBitField();
 
+  // Ignore padding bit-fields.
+  if (BitField && i->isUnnamedBitfield())
+continue;
+
   // AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger than
   // four eightbytes, or it contains unaligned fields, it has class MEMORY.
   //
@@ -2621,10 +2625,7 @@ void X86_64ABIInfo::classify(QualType Ty
   // structure to be passed in memory even if unaligned, and
   // therefore they can straddle an eightbyte.
   if (BitField) {
-// Ignore padding bit-fields.
-if (i->isUnnamedBitfield())
-  continue;
-
+assert(!i->isUnnamedBitfield());
 uint64_t Offset = OffsetBase + Layout.getFieldOffset(idx);
 uint64_t Size = i->getBitWidthValue(getContext());
 

Modified: cfe/trunk/test/CodeGen/x86_64-arguments.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-arguments.c?rev=278656&r1=278655&r2=278656&view=diff
==
--- cfe/trunk/test/CodeGen/x86_64-arguments.c (original)
+++ cfe/trunk/test/CodeGen/x86_64-arguments.c Mon Aug 15 02:20:40 2016
@@ -536,3 +536,12 @@ void f64() {
   f64_helper(x64, x64, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
   f64_helper(x64, x64, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
 }
+
+struct t65 {
+  __m256 m;
+  int : 0;
+};
+// SSE-LABEL: @f65(%struct.t65* byval align 32 %{{[^,)]+}})
+// AVX: @f65(<8 x float> %{{[^,)]+}})
+void f65(struct t65 a0) {
+}


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


[PATCH] D23495: Remove std::tuple's reduced-arity-extension on implicit constructors.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, rsmith.
EricWF added a subscriber: cfe-commits.

The reduced-arity-extension on tuple's implicit constructors breaks conforming 
code. eg

```
#include 
#include 
using namespace std;
int count(tuple) { return 2; }
int count(tuple) { return 3; }

int main() {
  int c = count({"abc", "def"}); // expected-error {{call to 'count' is 
ambiguous}}
}
```

To fix this the I removed the reduced-arity-extension only on the implicit 
constructors. This breaks the following code:

```
std::tuple foo() { return {1, 2}  }
```

But it still allows for
```
using Tup = std::tuple;
Tup foo() { return Tup{1, 2}; } 
```

@Marshall should we provide a way to turn this ctor back on in case in breaks a 
bunch of real-world code? Maybe deprecate it for a release?

See also:
  * http://llvm.org/PR27374
  * http://wg21.link/lwg2419

https://reviews.llvm.org/D23495

Files:
  include/tuple

Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -706,7 +706,7 @@
   typename enable_if
   <
  _CheckArgsConstructor<
- sizeof...(_Up) <= sizeof...(_Tp)
+ sizeof...(_Up) == sizeof...(_Tp)
  && !_PackExpandsToThisTuple<_Up...>::value
  >::template __enable_implicit<_Up...>(),
  bool
@@ -716,26 +716,30 @@
 tuple(_Up&&... __u)
 _NOEXCEPT_((
 is_nothrow_constructible::type,
-typename __make_tuple_types::type,
-typename __make_tuple_indices::type,
-typename __make_tuple_types::type,
+typename __make_tuple_indices::type,
+__tuple_types<_Tp...>,
+__tuple_indices<>,
+__tuple_types<>,
 _Up...
 >::value
 ))
-: base_(typename __make_tuple_indices::type(),
-typename __make_tuple_types::type(),
-typename __make_tuple_indices::type(),
-typename __make_tuple_types::type(),
+: base_(typename __make_tuple_indices::type{},
+__tuple_types<_Tp...>{},
+__tuple_indices<>{},
+__tuple_types<>{},
 _VSTD::forward<_Up>(__u)...) {}
 
 template ::value
- >::template __enable_explicit<_Up...>(),
+ >::template __enable_explicit<_Up...>()  ||
+ _CheckArgsConstructor<
+ sizeof...(_Up) < sizeof...(_Tp)
+ && !_PackExpandsToThisTuple<_Up...>::value
+ >::template __enable_implicit<_Up...>(),
  bool
   >::type = false
  >


Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -706,7 +706,7 @@
   typename enable_if
   <
  _CheckArgsConstructor<
- sizeof...(_Up) <= sizeof...(_Tp)
+ sizeof...(_Up) == sizeof...(_Tp)
  && !_PackExpandsToThisTuple<_Up...>::value
  >::template __enable_implicit<_Up...>(),
  bool
@@ -716,26 +716,30 @@
 tuple(_Up&&... __u)
 _NOEXCEPT_((
 is_nothrow_constructible::type,
-typename __make_tuple_types::type,
-typename __make_tuple_indices::type,
-typename __make_tuple_types::type,
+typename __make_tuple_indices::type,
+__tuple_types<_Tp...>,
+__tuple_indices<>,
+__tuple_types<>,
 _Up...
 >::value
 ))
-: base_(typename __make_tuple_indices::type(),
-typename __make_tuple_types::type(),
-typename __make_tuple_indices::type(),
-typename __make_tuple_types::type(),
+: base_(typename __make_tuple_indices::type{},
+__tuple_types<_Tp...>{},
+__tuple_indices<>{},
+__tuple_types<>{},
 _VSTD::forward<_Up>(__u)...) {}
 
 template ::value
- >::template __enable_explicit<_Up...>(),
+ >::template __enable_explicit<_Up...>()  ||
+ _CheckArgsConstructor<
+ sizeof...(_Up) < sizeof...(_Tp)
+ && !_PackExpandsToThisTuple<_Up...>::value
+ >::template __enable_implicit<_Up...>(

Re: [PATCH] D23495: Remove std::tuple's reduced-arity-extension on implicit constructors.

2016-08-15 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 68001.
EricWF added a comment.

Add missing test case.


https://reviews.llvm.org/D23495

Files:
  include/tuple
  
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27374_implicit_reduced_arity_extension_non_conforming.pass.cpp

Index: 
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27374_implicit_reduced_arity_extension_non_conforming.pass.cpp
===
--- /dev/null
+++ 
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27374_implicit_reduced_arity_extension_non_conforming.pass.cpp
@@ -0,0 +1,53 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// template  class tuple;
+
+// Check that the reduced arity constructors are never implicit.
+// See also:
+//  http://llvm.org/PR27374
+//  http://wg21.link/lwg2419
+
+#include 
+#include 
+#include 
+
+bool eat_tuple(const std::tuple& w) { return false; }
+template 
+auto eat_char(Args&&... args) -> decltype(eat_tuple(args...)) { return 
eat_tuple(args...); }
+bool eat_char(const char&) { return true; }
+
+int count(std::tuple) {
+return 2;
+}
+
+int count(std::tuple) {
+   return 3;
+}
+
+using Tup = std::tuple;
+Tup explicit_still_allowed() { return Tup{1, 2}; }
+
+int main() {
+{
+const char ch = 'a';
+assert(eat_char(ch));
+}
+{
+assert(count({ "hungry", "zombies" }) == 2);
+assert(count({ "cute", "fluffy", "kittens" }) == 3);
+}
+{
+explicit_still_allowed();
+}
+}
Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -706,7 +706,7 @@
   typename enable_if
   <
  _CheckArgsConstructor<
- sizeof...(_Up) <= sizeof...(_Tp)
+ sizeof...(_Up) == sizeof...(_Tp)
  && !_PackExpandsToThisTuple<_Up...>::value
  >::template __enable_implicit<_Up...>(),
  bool
@@ -735,7 +735,11 @@
  _CheckArgsConstructor<
  sizeof...(_Up) <= sizeof...(_Tp)
  && !_PackExpandsToThisTuple<_Up...>::value
- >::template __enable_explicit<_Up...>(),
+ >::template __enable_explicit<_Up...>() ||
+ _CheckArgsConstructor<
+ sizeof...(_Up) < sizeof...(_Tp)
+ && !_PackExpandsToThisTuple<_Up...>::value
+ >::template __enable_implicit<_Up...>(),
  bool
   >::type = false
  >


Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27374_implicit_reduced_arity_extension_non_conforming.pass.cpp
===
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR27374_implicit_reduced_arity_extension_non_conforming.pass.cpp
@@ -0,0 +1,53 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// template  class tuple;
+
+// Check that the reduced arity constructors are never implicit.
+// See also:
+//  http://llvm.org/PR27374
+//  http://wg21.link/lwg2419
+
+#include 
+#include 
+#include 
+
+bool eat_tuple(const std::tuple& w) { return false; }
+template 
+auto eat_char(Args&&... args) -> decltype(eat_tuple(args...)) { return eat_tuple(args...); }
+bool eat_char(const char&) { return true; }
+
+int count(std::tuple) {
+return 2;
+}
+
+int count(std::tuple) {
+   return 3;
+}
+
+using Tup = std::tuple;
+Tup explicit_still_allowed() { return Tup{1, 2}; }
+
+int main() {
+{
+const char ch = 'a';
+assert(eat_char(ch));
+}
+{
+assert(count({ "hungry", "zombies" }) == 2);
+assert(count({ "cute", "fluffy", "kittens" }) == 3);
+}
+{
+explicit_still_allowed();
+}
+}
Index: include/tuple
===
--- include/tuple
+++ include/tuple
@@ -706,7 +706,7 @@
   typename enable_if
   <
  _CheckArgsConstructor<
- sizeof...(_Up) <= size

Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

2016-08-15 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:95-98
@@ +94,6 @@
+const QualType T = VD->getType();
+if (T->isPointerType() && !T->getPointeeType().isConstQualified())
+  markCanNotBeConst(VD->getInit(), true);
+else if (T->isArrayType())
+  markCanNotBeConst(VD->getInit(), true);
+  }

Prazek wrote:
> This looks like it could be in the same if.
Yes it could. But would it make the code more or less readable? It wouldn't be 
a 1-line condition anymore then.


https://reviews.llvm.org/D15332



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


Re: [PATCH] D12689: [libc++][static linking] std streams are not initialized prior to their use in static object constructors

2016-08-15 Thread Evgeny Astigeevich via cfe-commits
eastig added a comment.

The issue is reported as:
https://llvm.org/bugs/show_bug.cgi?id=28954


https://reviews.llvm.org/D12689



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


Re: [PATCH] D22862: [analyzer] Fix for PR15623: eliminate unwanted ProgramState checker data propagation.

2016-08-15 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

> @dcoughlin, @NoQ, could you, please, tell, how you get dumps of symbolic 
> expressions and constraints like "(conj_$6{void *}) != 0U"? Tried different 
> debug.* checkers and clang_analyzer_explain() but failed.


That's `SVal.dump()`, `SymbolRef->dump()`, `MemRegion.dump()` (you can also 
push those directly into `llvm::errs()`), `ProgramStateRef->dump()`, and 
ultimately `ExprEngine.ViewExplodedGraph()` (the last one can be activated in 
run-time with `debug.ViewExplodedGraph` checker or with 
`-analyzer-viz-egraph-graphviz` which was the one i used, see also 
http://clang-analyzer.llvm.org/checker_dev_manual.html#commands In fact 
`clang-analyzer-explain()` was an attempt to make these dumps a bit more 
understandable.

> Hm, updated to trunk, now the test passes without the patch. Changing "_Bool" 
> to "int" in the test reproduces the issue.


Aha, i see! The cast to `int` gets represented as a `nonloc::LocAsInteger` 
value:

  &element{SymRegion{conj_$6{void *}},0 S64b,char} [as 32 bit integer]

which is, of course, incorrect, and Devin's fix makes perfect sense here in my 
opinion :)


https://reviews.llvm.org/D22862



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


[PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-15 Thread James Molloy via cfe-commits
jmolloy created this revision.
jmolloy added reviewers: davide, aaron.ballman.
jmolloy added a subscriber: cfe-commits.

This means we shouldn't emit ubsan detection code or warn.
Fixes PR25552.

https://reviews.llvm.org/D23498

Files:
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/wrapv-lshr-sanitize.c
  test/Sema/negative-shift-wrapv.c

Index: test/Sema/negative-shift-wrapv.c
===
--- /dev/null
+++ test/Sema/negative-shift-wrapv.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
+
+#include 
+
+#define WORD_BIT (sizeof(int) * CHAR_BIT)
+
+void test() {
+  int i;
+  i = -1 << (WORD_BIT - 1); // no-warning
+}
+
+// expected-no-diagnostics
Index: test/CodeGen/wrapv-lshr-sanitize.c
===
--- /dev/null
+++ test/CodeGen/wrapv-lshr-sanitize.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple 
x86_64-linux-gnu -fwrapv | opt -instnamer -S | FileCheck %s
+
+// CHECK-LABEL: @lsh_overflow
+int lsh_overflow(int a, int b) {
+  // CHECK-NOT: br
+  // CHECK-NOT: call void @__ubsan_
+  // CHECK-NOT: call void @llvm.trap
+  
+  // CHECK:  %[[RET:.*]] = shl i32
+  // CHECK-NEXT: ret i32 %[[RET]]
+  return a << b;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8567,7 +8567,7 @@
 
   // If LHS does not have a signed type and non-negative value
   // then, the behavior is undefined. Warn about it.
-  if (Left.isNegative()) {
+  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
 << LHS.get()->getSourceRange());
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2706,7 +2706,8 @@
 RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
 
   bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
-  Ops.Ty->hasSignedIntegerRepresentation();
+  Ops.Ty->hasSignedIntegerRepresentation() &&
+  !CGF.getLangOpts().isSignedOverflowDefined();
   bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
   if (CGF.getLangOpts().OpenCL)


Index: test/Sema/negative-shift-wrapv.c
===
--- /dev/null
+++ test/Sema/negative-shift-wrapv.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
+
+#include 
+
+#define WORD_BIT (sizeof(int) * CHAR_BIT)
+
+void test() {
+  int i;
+  i = -1 << (WORD_BIT - 1); // no-warning
+}
+
+// expected-no-diagnostics
Index: test/CodeGen/wrapv-lshr-sanitize.c
===
--- /dev/null
+++ test/CodeGen/wrapv-lshr-sanitize.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple x86_64-linux-gnu -fwrapv | opt -instnamer -S | FileCheck %s
+
+// CHECK-LABEL: @lsh_overflow
+int lsh_overflow(int a, int b) {
+  // CHECK-NOT: br
+  // CHECK-NOT: call void @__ubsan_
+  // CHECK-NOT: call void @llvm.trap
+  
+  // CHECK:  %[[RET:.*]] = shl i32
+  // CHECK-NEXT: ret i32 %[[RET]]
+  return a << b;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8567,7 +8567,7 @@
 
   // If LHS does not have a signed type and non-negative value
   // then, the behavior is undefined. Warn about it.
-  if (Left.isNegative()) {
+  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
 << LHS.get()->getSourceRange());
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2706,7 +2706,8 @@
 RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
 
   bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
-  Ops.Ty->hasSignedIntegerRepresentation();
+  Ops.Ty->hasSignedIntegerRepresentation() &&
+  !CGF.getLangOpts().isSignedOverflowDefined();
   bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
   if (CGF.getLangOpts().OpenCL)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lis

Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-08-15 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 68011.
rmaprath added a comment.

Rebased.


https://reviews.llvm.org/D21968

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  
test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,172 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#ifndef SUPPORT_EXTERNAL_THREADS
+#define SUPPORT_EXTERNAL_THREADS
+
+#include <__threading_support>
+#include 
+#include 
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+//-- Mutex --//
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{
+// Initialize the allocated pthread_mutex_t object as a recursive mutex
+pthread_mutexattr_t attr;
+int __ec = pthread_mutexattr_init(&attr);
+if (__ec)
+  goto fail;
+
+__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutex_init(__m, &attr);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutexattr_destroy(&attr);
+if (__ec)
+{
+pthread_mutex_destroy(__m);
+goto fail;
+}
+
+return 0;
+
+fail:
+return __ec;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_lock(__m);
+}
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_trylock(__m);
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) {
+return pthread_mutex_destroy(__m);
+}
+
+//-- Condition variable --//
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_signal(__cv);
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_broadcast(__cv);
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
+{
+return pthread_cond_wait(__cv, __m);
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts)
+{
+return pthread_cond_timedwait(__cv, __m, __ts);
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_destroy(__cv);
+}
+
+//-- Thread --//
+
+bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) {
+return pthread_equal(t1, t2) != 0;
+}
+
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) {
+return t1 < t2;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+return static_cast<__libcpp_thread_id>(pthread_self());
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
+{
+return *__t;
+}
+
+int __libcpp_thread_join(__libcpp_thread_t* __t)
+{
+// Must return non-zero if the internal state has already been invalidated
+// This can happen for example, if std::thread::join() has been called
+// before.
+if (*__t == 0)
+return -1;
+
+return pthread_join(*__t, 0);
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t)
+{
+// Must return non-zero if the internal state has already been invalidated
+// This can happen for example, if std::thread::detach() has been called
+// before.
+if (*__t == 0)
+return -1;
+
+return pthread_detach(*__t);
+}
+
+void __libcpp_thread_yield()
+{
+sched_yield();
+}
+
+//-- TLS --//
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit)(void*))
+{
+return pthread_key_create(__key, __at_exit);
+}
+
+void* __libcpp_tl_get(__libcpp_tl_key __key)
+{
+return pthread_getspecific(__key);
+}
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p)
+{
+pthread_setspecific(__key, __p);
+}
+
+_LIBCPP_

[PATCH] D23503: [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.

2016-08-15 Thread pierre gousseau via cfe-commits
pgousseau created this revision.
pgousseau added reviewers: rsmith, majnemer.
pgousseau added subscribers: cfe-commits, wristow, gbedwell, probinson.

Checking for the type of the command line tokenizer should not be the criteria 
to enable support for the CL environment variable, this change checks that we 
are in clang-cl mode instead.

https://reviews.llvm.org/D23503

Files:
  test/Driver/cl-options.c
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -393,7 +393,7 @@
 
   // Handle CL and _CL_ which permits additional command line options to be
   // prepended or appended.
-  if (Tokenizer == &llvm::cl::TokenizeWindowsCommandLine) {
+  if (ClangCLMode) {
 // Arguments in "CL" are prepended.
 llvm::Optional OptCL = llvm::sys::Process::GetEnv("CL");
 if (OptCL.hasValue()) {
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -468,6 +468,8 @@
 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck 
-check-prefix=ENV-_CL_ %s
 // ENV-_CL_-NOT: "-ffunction-sections"
 
+// RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \


Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -393,7 +393,7 @@
 
   // Handle CL and _CL_ which permits additional command line options to be
   // prepended or appended.
-  if (Tokenizer == &llvm::cl::TokenizeWindowsCommandLine) {
+  if (ClangCLMode) {
 // Arguments in "CL" are prepended.
 llvm::Optional OptCL = llvm::sys::Process::GetEnv("CL");
 if (OptCL.hasValue()) {
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -468,6 +468,8 @@
 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
 // ENV-_CL_-NOT: "-ffunction-sections"
 
+// RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23112: [analyzer] Correctly add assumptions based on array bounds.

2016-08-15 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 68023.
xazax.hun added a comment.

- Simplifiy generated constraints.


https://reviews.llvm.org/D23112

Files:
  lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  test/Analysis/out-of-bounds.c

Index: test/Analysis/out-of-bounds.c
===
--- test/Analysis/out-of-bounds.c
+++ test/Analysis/out-of-bounds.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
 
 // Tests doing an out-of-bounds access after the end of an array using:
 // - constant integer index
@@ -128,22 +130,22 @@
   buf[0][0] = 1; // no-warning
 }
 
-// *** FIXME ***
-// We don't get a warning here yet because our symbolic constraint solving
-// doesn't handle:  (symbol * constant) < constant
 void test3(int x) {
   int buf[100];
   if (x < 0)
-buf[x] = 1;
+buf[x] = 1; // expected-warning{{Out of bound memory access}}
 }
 
-// *** FIXME ***
-// We don't get a warning here yet because our symbolic constraint solving
-// doesn't handle:  (symbol * constant) < constant
 void test4(int x) {
   int buf[100];
   if (x > 99)
-buf[x] = 1; 
+buf[x] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test_assume_after_access(unsigned long x) {
+  int buf[100];
+  buf[x] = 1;
+  clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}}
 }
 
 // Don't warn when indexing below the start of a symbolic region's whose
@@ -166,3 +168,9 @@
   p[1] = 42; // no-warning
 }
 
+void test_assume_after_access2(unsigned long x) {
+  char buf[100];
+  buf[x] = 1;
+  clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}}
+}
+
Index: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallString.h"
@@ -81,6 +82,40 @@
 }
 }
 
+// TODO: once the constraint manager is smart enough to handle non simplified
+// symbolic expressions remove this function.
+static std::pair
+getSimplifiedOffsets(NonLoc offset, nonloc::ConcreteInt extent,
+ SValBuilder &svalBuilder) {
+  Optional SymVal = offset.getAs();
+  if (SymVal && SymVal->isExpression()) {
+if (const SymIntExpr *SIE = dyn_cast(SymVal->getSymbol())) {
+  llvm::APSInt constant =
+  APSIntType(extent.getValue()).convert(SIE->getRHS());
+  switch (SIE->getOpcode()) {
+  case BO_Mul:
+// The constant should never be 0 here, since it the result of scaling
+// based on the size of a type which is never 0.
+if ((extent.getValue() % constant) != 0)
+  return std::pair(offset, extent);
+else
+  return getSimplifiedOffsets(
+  nonloc::SymbolVal(SIE->getLHS()),
+  svalBuilder.makeIntVal(extent.getValue() / constant),
+  svalBuilder);
+  case BO_Add:
+return getSimplifiedOffsets(
+nonloc::SymbolVal(SIE->getLHS()),
+svalBuilder.makeIntVal(extent.getValue() - constant), svalBuilder);
+  default:
+break;
+  }
+}
+  }
+
+  return std::pair(offset, extent);
+}
+
 void ArrayBoundCheckerV2::checkLocation(SVal location, bool isLoad,
 const Stmt* LoadS,
 CheckerContext &checkerContext) const {
@@ -104,16 +139,26 @@
   if (!rawOffset.getRegion())
 return;
 
+  NonLoc rawOffsetVal = rawOffset.getByteOffset();
+
   // CHECK LOWER BOUND: Is byteOffset < extent begin?
   //  If so, we are doing a load/store
   //  before the first valid offset in the memory region.
 
   SVal extentBegin = computeExtentBegin(svalBuilder, rawOffset.getRegion());
 
   if (Optional NV = extentBegin.getAs()) {
-SVal lowerBound =
-svalBuilder.evalBinOpNN(state, BO_LT, rawOffset.getByteOffset(), *NV,
-svalBuilder.getConditionType());
+if (NV->getAs()) {
+  std::pair simplifiedOffsets =
+  getSimplifiedOffsets(rawOffset.getByteOffset(),
+   NV->castAs(),
+   svalBuilder);
+  rawOffsetVal = simplifiedOffsets.first;
+  *NV = simplifiedOffsets.second;
+}
+
+SVal lowerBound = svalBuilder.evalBinOpNN(state, BO_LT, rawOffsetVal, *NV,
+

Re: [PATCH] D23112: [analyzer] Correctly add assumptions based on array bounds.

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

I added a (proof of concept?) implementation to simplify the constraints in the 
checker. I wonder what do you think.


https://reviews.llvm.org/D23112



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


Re: [PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-08-15 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cert/LimitedRandomnessCheck.cpp:22-23
@@ +21,4 @@
+  Finder->addMatcher(
+  declRefExpr(hasDeclaration(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+  .bind("randomGenerator"),

xazax.hun wrote:
> aaron.ballman wrote:
> > Prazek wrote:
> > > aaron.ballman wrote:
> > > > Prazek wrote:
> > > > > aaron.ballman wrote:
> > > > > > This should be looking at a callExpr() rather than a declRefExpr(), 
> > > > > > should it not?
> > > > > I was also thinking about this, but this is actually better, because 
> > > > > it will also match with binding rand with function pointer.
> > > > True, but a DeclRefExpr doesn't mean it's a function call. Binding the 
> > > > function is not contrary to the CERT rule, just calling it. For 
> > > > instance, the following pathological case will be caught by this check:
> > > > ```
> > > > if (std::rand) {}
> > > > ```
> > > > The behavior of this check should be consistent with cert-env33-c, 
> > > > which only looks at calls. (If we really care about bound functions, 
> > > > we'd need flow control analysis, and I think that's overkill for both 
> > > > of those checks, but wouldn't be opposed to someone writing the flow 
> > > > analysis if they really wanted to.)
> > > It would indeed fire on this pathological case, but I don't think we 
> > > should care about cases like this, because no one is writing code like 
> > > this (and if he would then it would probably be a bug).
> > > I don't think that there is much code that binds pointer to std::rand 
> > > either, but I think it would be good to display warning for this, because 
> > > even if the function would be never called, then it means that this is a 
> > > bug, and if it would be called then it would be nice to tell user that 
> > > rand might be used here.
> > > 
> > > Anyway I don't oppose for changing it to callExpr, but I think it is 
> > > better this way.
> > > It would indeed fire on this pathological case, but I don't think we 
> > > should care about cases like this, because no one is writing code like 
> > > this (and if he would then it would probably be a bug).
> > 
> > It would be a known false-positive for a check designed to conform to a 
> > particular coding standard. When deviations have come up in the past for 
> > various coding standards, we've added an option to enable the additional 
> > functionality, which I don't think would be reasonable in this case. 
> > Alternatively, the CERT guideline could be modified, but that is unlikely 
> > to occur because binding the function pointer is not a security concern 
> > (only calling the function).
> In case you let binding to function pointer you introduce potential false 
> negatives which is worse in this case in my opinion. 
Basically: this half-measure is sufficient for the CERT coding rule, but isn't 
ideal. The ideal check isn't likely to uncover many more cases than the 
half-measure, which is why it was not implemented in the past. If someone wants 
to implement the whole-measure, that's great! But implementing a half, 
half-measure that isn't consistent with other, similar checks is the wrong 
thing to do.


Repository:
  rL LLVM

https://reviews.llvm.org/D22346



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


Re: [PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

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


Comment at: clang-tidy/cert/LimitedRandomnessCheck.cpp:22-23
@@ +21,4 @@
+  Finder->addMatcher(
+  declRefExpr(hasDeclaration(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+  .bind("randomGenerator"),

aaron.ballman wrote:
> xazax.hun wrote:
> > aaron.ballman wrote:
> > > Prazek wrote:
> > > > aaron.ballman wrote:
> > > > > Prazek wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > This should be looking at a callExpr() rather than a 
> > > > > > > declRefExpr(), should it not?
> > > > > > I was also thinking about this, but this is actually better, 
> > > > > > because it will also match with binding rand with function pointer.
> > > > > True, but a DeclRefExpr doesn't mean it's a function call. Binding 
> > > > > the function is not contrary to the CERT rule, just calling it. For 
> > > > > instance, the following pathological case will be caught by this 
> > > > > check:
> > > > > ```
> > > > > if (std::rand) {}
> > > > > ```
> > > > > The behavior of this check should be consistent with cert-env33-c, 
> > > > > which only looks at calls. (If we really care about bound functions, 
> > > > > we'd need flow control analysis, and I think that's overkill for both 
> > > > > of those checks, but wouldn't be opposed to someone writing the flow 
> > > > > analysis if they really wanted to.)
> > > > It would indeed fire on this pathological case, but I don't think we 
> > > > should care about cases like this, because no one is writing code like 
> > > > this (and if he would then it would probably be a bug).
> > > > I don't think that there is much code that binds pointer to std::rand 
> > > > either, but I think it would be good to display warning for this, 
> > > > because even if the function would be never called, then it means that 
> > > > this is a bug, and if it would be called then it would be nice to tell 
> > > > user that rand might be used here.
> > > > 
> > > > Anyway I don't oppose for changing it to callExpr, but I think it is 
> > > > better this way.
> > > > It would indeed fire on this pathological case, but I don't think we 
> > > > should care about cases like this, because no one is writing code like 
> > > > this (and if he would then it would probably be a bug).
> > > 
> > > It would be a known false-positive for a check designed to conform to a 
> > > particular coding standard. When deviations have come up in the past for 
> > > various coding standards, we've added an option to enable the additional 
> > > functionality, which I don't think would be reasonable in this case. 
> > > Alternatively, the CERT guideline could be modified, but that is unlikely 
> > > to occur because binding the function pointer is not a security concern 
> > > (only calling the function).
> > In case you let binding to function pointer you introduce potential false 
> > negatives which is worse in this case in my opinion. 
> Basically: this half-measure is sufficient for the CERT coding rule, but 
> isn't ideal. The ideal check isn't likely to uncover many more cases than the 
> half-measure, which is why it was not implemented in the past. If someone 
> wants to implement the whole-measure, that's great! But implementing a half, 
> half-measure that isn't consistent with other, similar checks is the wrong 
> thing to do.
You can not implement an ideal checker. In general, it is undecidable whether 
std::rand is called or not. (You can easily create an example where you would 
need to solve the halting problem in order to decide whether std::rand is 
called.)

Since the ideal checker is infeasible the question is whether you are OK with 
false positives or false negatives. The approach you are suggesting result in 
false negatives. The current approach results in false positives. I think, for 
this security checker, a false positive is much less serious to have than a 
false negative. Moreover, I doubt that people write code where such false 
positives are intended and the code should not be changed. But in case you can 
think of an example, please let us know.


Repository:
  rL LLVM

https://reviews.llvm.org/D22346



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


Re: [PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

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


Comment at: clang-tidy/cert/LimitedRandomnessCheck.cpp:22-23
@@ +21,4 @@
+  Finder->addMatcher(
+  declRefExpr(hasDeclaration(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+  .bind("randomGenerator"),

xazax.hun wrote:
> aaron.ballman wrote:
> > xazax.hun wrote:
> > > aaron.ballman wrote:
> > > > Prazek wrote:
> > > > > aaron.ballman wrote:
> > > > > > Prazek wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > This should be looking at a callExpr() rather than a 
> > > > > > > > declRefExpr(), should it not?
> > > > > > > I was also thinking about this, but this is actually better, 
> > > > > > > because it will also match with binding rand with function 
> > > > > > > pointer.
> > > > > > True, but a DeclRefExpr doesn't mean it's a function call. Binding 
> > > > > > the function is not contrary to the CERT rule, just calling it. For 
> > > > > > instance, the following pathological case will be caught by this 
> > > > > > check:
> > > > > > ```
> > > > > > if (std::rand) {}
> > > > > > ```
> > > > > > The behavior of this check should be consistent with cert-env33-c, 
> > > > > > which only looks at calls. (If we really care about bound 
> > > > > > functions, we'd need flow control analysis, and I think that's 
> > > > > > overkill for both of those checks, but wouldn't be opposed to 
> > > > > > someone writing the flow analysis if they really wanted to.)
> > > > > It would indeed fire on this pathological case, but I don't think we 
> > > > > should care about cases like this, because no one is writing code 
> > > > > like this (and if he would then it would probably be a bug).
> > > > > I don't think that there is much code that binds pointer to std::rand 
> > > > > either, but I think it would be good to display warning for this, 
> > > > > because even if the function would be never called, then it means 
> > > > > that this is a bug, and if it would be called then it would be nice 
> > > > > to tell user that rand might be used here.
> > > > > 
> > > > > Anyway I don't oppose for changing it to callExpr, but I think it is 
> > > > > better this way.
> > > > > It would indeed fire on this pathological case, but I don't think we 
> > > > > should care about cases like this, because no one is writing code 
> > > > > like this (and if he would then it would probably be a bug).
> > > > 
> > > > It would be a known false-positive for a check designed to conform to a 
> > > > particular coding standard. When deviations have come up in the past 
> > > > for various coding standards, we've added an option to enable the 
> > > > additional functionality, which I don't think would be reasonable in 
> > > > this case. Alternatively, the CERT guideline could be modified, but 
> > > > that is unlikely to occur because binding the function pointer is not a 
> > > > security concern (only calling the function).
> > > In case you let binding to function pointer you introduce potential false 
> > > negatives which is worse in this case in my opinion. 
> > Basically: this half-measure is sufficient for the CERT coding rule, but 
> > isn't ideal. The ideal check isn't likely to uncover many more cases than 
> > the half-measure, which is why it was not implemented in the past. If 
> > someone wants to implement the whole-measure, that's great! But 
> > implementing a half, half-measure that isn't consistent with other, similar 
> > checks is the wrong thing to do.
> You can not implement an ideal checker. In general, it is undecidable whether 
> std::rand is called or not. (You can easily create an example where you would 
> need to solve the halting problem in order to decide whether std::rand is 
> called.)
> 
> Since the ideal checker is infeasible the question is whether you are OK with 
> false positives or false negatives. The approach you are suggesting result in 
> false negatives. The current approach results in false positives. I think, 
> for this security checker, a false positive is much less serious to have than 
> a false negative. Moreover, I doubt that people write code where such false 
> positives are intended and the code should not be changed. But in case you 
> can think of an example, please let us know.
I think consisteny with other checks are not always a good argument. You might 
want to ask what is the expected false positive and false nagtive rate from a 
check, and what is the guarantee that a user expects from a check. And I think 
base on that it is a unique decision that should be considered independently 
for each check. In this case I think it is more valuable to have a guarantee 
that in case all of the code is covered, std::rand() is not invoked. Using a 
callExpr instead of declRefExpr we would loose this guarantee at the cost of 
not reporting some false positive cases that are unlikely to annoy anyone 
anyways.


Repository:
  rL

Re: [PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-08-15 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cert/LimitedRandomnessCheck.cpp:22-23
@@ +21,4 @@
+  Finder->addMatcher(
+  declRefExpr(hasDeclaration(functionDecl(namedDecl(hasName("::rand")),
+  parameterCountIs(0
+  .bind("randomGenerator"),

xazax.hun wrote:
> aaron.ballman wrote:
> > xazax.hun wrote:
> > > aaron.ballman wrote:
> > > > Prazek wrote:
> > > > > aaron.ballman wrote:
> > > > > > Prazek wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > This should be looking at a callExpr() rather than a 
> > > > > > > > declRefExpr(), should it not?
> > > > > > > I was also thinking about this, but this is actually better, 
> > > > > > > because it will also match with binding rand with function 
> > > > > > > pointer.
> > > > > > True, but a DeclRefExpr doesn't mean it's a function call. Binding 
> > > > > > the function is not contrary to the CERT rule, just calling it. For 
> > > > > > instance, the following pathological case will be caught by this 
> > > > > > check:
> > > > > > ```
> > > > > > if (std::rand) {}
> > > > > > ```
> > > > > > The behavior of this check should be consistent with cert-env33-c, 
> > > > > > which only looks at calls. (If we really care about bound 
> > > > > > functions, we'd need flow control analysis, and I think that's 
> > > > > > overkill for both of those checks, but wouldn't be opposed to 
> > > > > > someone writing the flow analysis if they really wanted to.)
> > > > > It would indeed fire on this pathological case, but I don't think we 
> > > > > should care about cases like this, because no one is writing code 
> > > > > like this (and if he would then it would probably be a bug).
> > > > > I don't think that there is much code that binds pointer to std::rand 
> > > > > either, but I think it would be good to display warning for this, 
> > > > > because even if the function would be never called, then it means 
> > > > > that this is a bug, and if it would be called then it would be nice 
> > > > > to tell user that rand might be used here.
> > > > > 
> > > > > Anyway I don't oppose for changing it to callExpr, but I think it is 
> > > > > better this way.
> > > > > It would indeed fire on this pathological case, but I don't think we 
> > > > > should care about cases like this, because no one is writing code 
> > > > > like this (and if he would then it would probably be a bug).
> > > > 
> > > > It would be a known false-positive for a check designed to conform to a 
> > > > particular coding standard. When deviations have come up in the past 
> > > > for various coding standards, we've added an option to enable the 
> > > > additional functionality, which I don't think would be reasonable in 
> > > > this case. Alternatively, the CERT guideline could be modified, but 
> > > > that is unlikely to occur because binding the function pointer is not a 
> > > > security concern (only calling the function).
> > > In case you let binding to function pointer you introduce potential false 
> > > negatives which is worse in this case in my opinion. 
> > Basically: this half-measure is sufficient for the CERT coding rule, but 
> > isn't ideal. The ideal check isn't likely to uncover many more cases than 
> > the half-measure, which is why it was not implemented in the past. If 
> > someone wants to implement the whole-measure, that's great! But 
> > implementing a half, half-measure that isn't consistent with other, similar 
> > checks is the wrong thing to do.
> You can not implement an ideal checker. In general, it is undecidable whether 
> std::rand is called or not. (You can easily create an example where you would 
> need to solve the halting problem in order to decide whether std::rand is 
> called.)
> 
> Since the ideal checker is infeasible the question is whether you are OK with 
> false positives or false negatives. The approach you are suggesting result in 
> false negatives. The current approach results in false positives. I think, 
> for this security checker, a false positive is much less serious to have than 
> a false negative. Moreover, I doubt that people write code where such false 
> positives are intended and the code should not be changed. But in case you 
> can think of an example, please let us know.
> You can not implement an ideal checker. In general, it is undecidable whether 
> std::rand is called or not. (You can easily create an example where you would 
> need to solve the halting problem in order to decide whether std::rand is 
> called.)

I said "ideal", not "perfect", but we're splitting hairs. You are correct, 
you're never going to get perfect clarity without runtime instrumentation. By 
"ideal", I meant "something that actually pays attention to the bound value 
from the point it is bound to the point the function pointer is called." Simply 
having the address of the function is not a security concern; calling it is.

> I thi

[PATCH] D23507: include/math.h: Re-enable missing C++11 decls on SunOS

2016-08-15 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: EricWF, mclow.lists.
mgorny added a subscriber: cfe-commits.

The SunOS (tested on OpenIndiana 5.11) C library  includes
 which provides declarations for the standard math
routines, both for C and C++(03). However, it lacks the additional
integral variants for C++11 and the additional functions.

Therefore, replace the '#ifndef __sun__' that disables almost all
declarations with disabling the C++03 variants of common functions which
happens to overlap the AIX checks.

Bug: https://llvm.org/bugs/show_bug.cgi?id=28506

https://reviews.llvm.org/D23507

Files:
  include/cmath
  include/math.h

Index: include/math.h
===
--- include/math.h
+++ include/math.h
@@ -636,11 +636,9 @@
 
 #endif  // isunordered
 
-#ifndef __sun__
-
 // abs
 
-#if !defined(_AIX)
+#if !(defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY
 float
 abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
@@ -652,11 +650,11 @@
 inline _LIBCPP_INLINE_VISIBILITY
 long double
 abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
-#endif // !defined(_AIX)
+#endif // !(defined(_AIX) || defined(__sun__))
 
 // acos
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   acos(float __lcpp_x) _NOEXCEPT   {return acosf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
 #endif
@@ -668,7 +666,7 @@
 
 // asin
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   asin(float __lcpp_x) _NOEXCEPT   {return asinf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
 #endif
@@ -680,7 +678,7 @@
 
 // atan
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   atan(float __lcpp_x) _NOEXCEPT   {return atanf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
 #endif
@@ -692,7 +690,7 @@
 
 // atan2
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
 #endif
@@ -715,7 +713,7 @@
 
 // ceil
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   ceil(float __lcpp_x) _NOEXCEPT   {return ceilf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
 #endif
@@ -727,7 +725,7 @@
 
 // cos
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   cos(float __lcpp_x) _NOEXCEPT   {return cosf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);}
 #endif
@@ -739,7 +737,7 @@
 
 // cosh
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   cosh(float __lcpp_x) _NOEXCEPT   {return coshf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);}
 #endif
@@ -751,7 +749,7 @@
 
 // exp
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   exp(float __lcpp_x) _NOEXCEPT   {return expf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);}
 #endif
@@ -763,7 +761,7 @@
 
 // fabs
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   fabs(float __lcpp_x) _NOEXCEPT   {return fabsf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
 #endif
@@ -775,7 +773,7 @@
 
 // floor
 
-#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
 inline _LIBCPP_INLINE_VISIBILITY float   floor(float __lcpp_x) _NOEXCEPT   {return floorf(__lcpp_x);}
 inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCE

Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-15 Thread Filipe Cabecinhas via cfe-commits
filcab added a subscriber: filcab.


Comment at: test/CodeGen/wrapv-lshr-sanitize.c:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple 
x86_64-linux-gnu -fwrapv | opt -instnamer -S | FileCheck %s
+

Do you really need `instnamer`?


Comment at: test/Sema/negative-shift-wrapv.c:9
@@ +8,3 @@
+  int i;
+  i = -1 << (WORD_BIT - 1); // no-warning
+}

It's a bit weird to have the test function be dead code, but I don't see a big 
problem anyway.

Do you need to do the whole `WORD_BIT` thing? I'd rather just shift -1 by 1 
(which is already UB in non -fwrapv world, but defined in -fwrapv world).


https://reviews.llvm.org/D23498



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


Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-15 Thread James Molloy via cfe-commits
jmolloy updated this revision to Diff 68033.
jmolloy added a comment.

Hi Filipe,

Thanks for the review! SGTM on both counts.


https://reviews.llvm.org/D23498

Files:
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGen/wrapv-lshr-sanitize.c
  test/Sema/negative-shift-wrapv.c

Index: test/Sema/negative-shift-wrapv.c
===
--- /dev/null
+++ test/Sema/negative-shift-wrapv.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
+
+int test() {
+  int i;
+  i = -1 << 1; // no-warning
+  return i;
+}
+
+// expected-no-diagnostics
Index: test/CodeGen/wrapv-lshr-sanitize.c
===
--- /dev/null
+++ test/CodeGen/wrapv-lshr-sanitize.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple 
x86_64-linux-gnu -fwrapv | FileCheck %s
+
+// CHECK-LABEL: @lsh_overflow
+int lsh_overflow(int a, int b) {
+  // CHECK-NOT: br
+  // CHECK-NOT: call void @__ubsan_
+  // CHECK-NOT: call void @llvm.trap
+  
+  // CHECK:  %[[RET:.*]] = shl i32
+  // CHECK-NEXT: ret i32 %[[RET]]
+  return a << b;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8567,7 +8567,7 @@
 
   // If LHS does not have a signed type and non-negative value
   // then, the behavior is undefined. Warn about it.
-  if (Left.isNegative()) {
+  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
 << LHS.get()->getSourceRange());
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2706,7 +2706,8 @@
 RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
 
   bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
-  Ops.Ty->hasSignedIntegerRepresentation();
+  Ops.Ty->hasSignedIntegerRepresentation() &&
+  !CGF.getLangOpts().isSignedOverflowDefined();
   bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
   if (CGF.getLangOpts().OpenCL)


Index: test/Sema/negative-shift-wrapv.c
===
--- /dev/null
+++ test/Sema/negative-shift-wrapv.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
+
+int test() {
+  int i;
+  i = -1 << 1; // no-warning
+  return i;
+}
+
+// expected-no-diagnostics
Index: test/CodeGen/wrapv-lshr-sanitize.c
===
--- /dev/null
+++ test/CodeGen/wrapv-lshr-sanitize.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple x86_64-linux-gnu -fwrapv | FileCheck %s
+
+// CHECK-LABEL: @lsh_overflow
+int lsh_overflow(int a, int b) {
+  // CHECK-NOT: br
+  // CHECK-NOT: call void @__ubsan_
+  // CHECK-NOT: call void @llvm.trap
+  
+  // CHECK:  %[[RET:.*]] = shl i32
+  // CHECK-NEXT: ret i32 %[[RET]]
+  return a << b;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8567,7 +8567,7 @@
 
   // If LHS does not have a signed type and non-negative value
   // then, the behavior is undefined. Warn about it.
-  if (Left.isNegative()) {
+  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
 << LHS.get()->getSourceRange());
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2706,7 +2706,8 @@
 RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
 
   bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
-  Ops.Ty->hasSignedIntegerRepresentation();
+  Ops.Ty->hasSignedIntegerRepresentation() &&
+  !CGF.getLangOpts().isSignedOverflowDefined();
   bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
   if (CGF.getLangOpts().OpenCL)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23314: [analyzer] CloneDetector allows comparing clones for suspicious variable pattern errors.

2016-08-15 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

I couldn't find any real problems - the code's getting mature! Please accept a 
few very important "please rename this variable" comments :)



Comment at: include/clang/Analysis/CloneDetection.h:236
@@ +235,3 @@
+///clone in this pair.
+struct SuspiciousClone {
+  /// The variable which referencing in this clone was against the pattern.

It surprised me that you cannot really retrieve the clone (i.e. statement 
sequence) from the `SuspiciousClone` object. Maybe rename to eg. 
`SuspiciousCloneInfo`?


Comment at: lib/Analysis/CloneDetection.cpp:92
@@ -91,1 +91,3 @@
+/// The location in the code where the variable was references.
+SourceRange Location;
 

It's surprising that `Location` is not of type `SourceLocation`, so much that 
i'd agree to rename it to `Range`, no matter how generic this word is.


Comment at: lib/Analysis/CloneDetection.cpp:174
@@ -165,2 +173,3 @@
   /// pattern and the statements of this objects are clones of each other.
-  bool comparePattern(const VariablePattern &Other) {
+  unsigned getPatternDifferences(
+  const VariablePattern &Other,

Because this function doesn't return pattern differences, maybe rename to 
`countPatternDifferences()`? And the optional parameter kinda comes as a bonus 
feature.


Comment at: lib/Analysis/CloneDetection.cpp:183
@@ +182,3 @@
+  auto OtherOccurence = Other.Occurences[i];
+  if (ThisOccurence.KindID != OtherOccurence.KindID) {
+++NumberOfDifferences;

Maybe reduce indent here through `if (... == ...) continue`, like in other 
places?


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:39
@@ +38,3 @@
+  /// \brief Reports all clones to the user.
+  void reportClones(SourceManager &SM, AnalysisManager &Mgr,
+int MinComplexity) const {

Maybe move those out-of-line? They look pretty big.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:43
@@ +42,3 @@
+std::vector CloneGroups;
+CloneDetector.findClones(CloneGroups, MinComplexity);
+

I renamed the member variable to `Detector` in r276791, because it caused 
compile errors on buildbots (because class and member have the same name), so 
this patch would need to be patched up a bit - here and in one more place.


Comment at: lib/StaticAnalyzer/Checkers/CloneChecker.cpp:97
@@ +96,3 @@
+  DiagEngine.Report(Pair.FirstClone.Location.getBegin(), WarnID)
+  << Pair.FirstClone.Location << Pair.FirstClone.Suggestion;
+

This line probably explains why i'm so much into renaming variables: it reads 
as if we're putting the location of the clone into the report, even though 
we're putting the location of a variable reference into it. 
`Pair.FirstCloneInfo.VarRange` would have been much more intuitive.


https://reviews.llvm.org/D23314



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


Re: [PATCH] D23507: [libcxx] include/math.h: Re-enable missing C++11 decls on SunOS

2016-08-15 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

I can't vouch for the correctness (not having a sun system to play with), but 
this LGTM.

at some point, the repeated expression `!(defined(_LIBCPP_MSVCRT) || 
defined(_AIX) || defined(__sun__))` will get unwieldy enough that we'll want to 
give it a name, but that's for another patch.

Do you need someone to commit this for you?


https://reviews.llvm.org/D23507



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


Re: [PATCH] D23507: [libcxx] include/math.h: Re-enable missing C++11 decls on SunOS

2016-08-15 Thread Michał Górny via cfe-commits
mgorny added a comment.

Yes, I don't have commit access. However, Eric wanted to review it as well, so 
please don't commit it yet.


https://reviews.llvm.org/D23507



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


Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.

2016-08-15 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Considering the refactoring planned in https://reviews.llvm.org/D23418, i've no 
more comments on the part of the code that isn't rewritten in the subsequent 
review. I like how the new hashing system is put to work here.



Comment at: lib/Analysis/CloneDetection.cpp:565
@@ +564,3 @@
+///argument of the StmtDataCollector.
+class FoldingSetWrapper {
+

Hmm. `FoldingSetNodeIDWrapper`? Because in fact we're wrapping neither a set, 
nor a node, but only an ID.


Comment at: lib/Analysis/CloneDetection.cpp:576
@@ +575,3 @@
+};
+}
+

`// end anonymous namespace`?


https://reviews.llvm.org/D22515



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


[libcxxabi] r278675 - Merging r278579:

2016-08-15 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug 15 11:10:06 2016
New Revision: 278675

URL: http://llvm.org/viewvc/llvm-project?rev=278675&view=rev
Log:
Merging r278579:

r278579 | mehdi_amini | 2016-08-12 17:02:33 -0700 (Fri, 12 Aug 2016) | 3 lines

Fix ASAN failures in the demangler

These were found fuzzing with ASAN.


Modified:
libcxxabi/branches/release_39/   (props changed)
libcxxabi/branches/release_39/src/cxa_demangle.cpp
libcxxabi/branches/release_39/test/test_demangle.pass.cpp

Propchange: libcxxabi/branches/release_39/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 15 11:10:06 2016
@@ -1 +1 @@
-/libcxxabi/trunk:278030
+/libcxxabi/trunk:278030,278579

Modified: libcxxabi/branches/release_39/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_39/src/cxa_demangle.cpp?rev=278675&r1=278674&r2=278675&view=diff
==
--- libcxxabi/branches/release_39/src/cxa_demangle.cpp (original)
+++ libcxxabi/branches/release_39/src/cxa_demangle.cpp Mon Aug 15 11:10:06 2016
@@ -624,6 +624,8 @@ parse_const_cast_expr(const char* first,
 return first;
 auto expr = db.names.back().move_full();
 db.names.pop_back();
+if (db.names.empty())
+return first;
 db.names.back() = "const_cast<" + db.names.back().move_full() 
+ ">(" + expr + ")";
 first = t1;
 }
@@ -650,6 +652,8 @@ parse_dynamic_cast_expr(const char* firs
 return first;
 auto expr = db.names.back().move_full();
 db.names.pop_back();
+if (db.names.empty())
+return first;
 db.names.back() = "dynamic_cast<" + 
db.names.back().move_full() + ">(" + expr + ")";
 first = t1;
 }
@@ -676,6 +680,8 @@ parse_reinterpret_cast_expr(const char*
 return first;
 auto expr = db.names.back().move_full();
 db.names.pop_back();
+if (db.names.empty())
+return first;
 db.names.back() = "reinterpret_cast<" + 
db.names.back().move_full() + ">(" + expr + ")";
 first = t1;
 }
@@ -1294,6 +1300,8 @@ parse_dot_expr(const char* first, const
 return first;
 auto name = db.names.back().move_full();
 db.names.pop_back();
+if (db.names.empty())
+return first;
 db.names.back().first += "." + name;
 first = t1;
 }
@@ -2896,6 +2904,8 @@ base_name(String& s)
 ++c;
 }
 }
+if (pe - pf <= 1)
+  return String();
 const char* p0 = pe - 1;
 for (; p0 != pf; --p0)
 {
@@ -3016,7 +3026,8 @@ parse_unnamed_type_name(const char* firs
 const char* t1 = parse_type(t0, last, db);
 if (t1 == t0)
 {
-db.names.pop_back();
+if(!db.names.empty())
+db.names.pop_back();
 return first;
 }
 if (db.names.size() < 2)
@@ -3041,17 +3052,21 @@ parse_unnamed_type_name(const char* firs
 }
 t0 = t1;
 }
+if(db.names.empty())
+  return first;
 db.names.back().first.append(")");
 }
 if (t0 == last || *t0 != 'E')
 {
+  if(!db.names.empty())
 db.names.pop_back();
 return first;
 }
 ++t0;
 if (t0 == last)
 {
-db.names.pop_back();
+if(!db.names.empty())
+  db.names.pop_back();
 return first;
 }
 if (std::isdigit(*t0))
@@ -3064,7 +3079,8 @@ parse_unnamed_type_name(const char* firs
 }
 if (t0 == last || *t0 != '_')
 {
-db.names.pop_back();
+if(!db.names.empty())
+  db.names.pop_back();
 return first;
 }
 first = t0 + 1;
@@ -3251,7 +3267,7 @@ parse_binary_expression(const char* firs
 nm += ')';
 first = t2;
 }
-else
+else if(!db.names.empty())
 db.names.pop_back();
 }
 return first;
@@ -3490,7 +3506,7 @@ parse_expression(const char* first, cons
 db.names.back() = "(" + op1 + ")[" + op2 + "]";
 first = t2;
 }
-

Re: [libcxxabi] r278579 - Fix ASAN failures in the demangler

2016-08-15 Thread Hans Wennborg via cfe-commits
Merged in r278675. Thanks!

On Fri, Aug 12, 2016 at 5:54 PM, Mehdi Amini  wrote:
> CC hans.
>
>
>> On Aug 12, 2016, at 5:50 PM, Duncan P. N. Exon Smith  
>> wrote:
>>
>> This seems like a good candidate to cherry-pick to 3.9.
>>
>>> On 2016-Aug-12, at 17:02, Mehdi Amini via cfe-commits 
>>>  wrote:
>>>
>>> Author: mehdi_amini
>>> Date: Fri Aug 12 19:02:33 2016
>>> New Revision: 278579
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=278579&view=rev
>>> Log:
>>> Fix ASAN failures in the demangler
>>>
>>> These were found fuzzing with ASAN.
>>>
>>> Modified:
>>>   libcxxabi/trunk/src/cxa_demangle.cpp
>>>   libcxxabi/trunk/test/test_demangle.pass.cpp
>>>
>>> Modified: libcxxabi/trunk/src/cxa_demangle.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=278579&r1=278578&r2=278579&view=diff
>>> ==
>>> --- libcxxabi/trunk/src/cxa_demangle.cpp (original)
>>> +++ libcxxabi/trunk/src/cxa_demangle.cpp Fri Aug 12 19:02:33 2016
>>> @@ -624,6 +624,8 @@ parse_const_cast_expr(const char* first,
>>>return first;
>>>auto expr = db.names.back().move_full();
>>>db.names.pop_back();
>>> +if (db.names.empty())
>>> +return first;
>>>db.names.back() = "const_cast<" + 
>>> db.names.back().move_full() + ">(" + expr + ")";
>>>first = t1;
>>>}
>>> @@ -650,6 +652,8 @@ parse_dynamic_cast_expr(const char* firs
>>>return first;
>>>auto expr = db.names.back().move_full();
>>>db.names.pop_back();
>>> +if (db.names.empty())
>>> +return first;
>>>db.names.back() = "dynamic_cast<" + 
>>> db.names.back().move_full() + ">(" + expr + ")";
>>>first = t1;
>>>}
>>> @@ -676,6 +680,8 @@ parse_reinterpret_cast_expr(const char*
>>>return first;
>>>auto expr = db.names.back().move_full();
>>>db.names.pop_back();
>>> +if (db.names.empty())
>>> +return first;
>>>db.names.back() = "reinterpret_cast<" + 
>>> db.names.back().move_full() + ">(" + expr + ")";
>>>first = t1;
>>>}
>>> @@ -1294,6 +1300,8 @@ parse_dot_expr(const char* first, const
>>>return first;
>>>auto name = db.names.back().move_full();
>>>db.names.pop_back();
>>> +if (db.names.empty())
>>> +return first;
>>>db.names.back().first += "." + name;
>>>first = t1;
>>>}
>>> @@ -2896,6 +2904,8 @@ base_name(String& s)
>>>++c;
>>>}
>>>}
>>> +if (pe - pf <= 1)
>>> +  return String();
>>>const char* p0 = pe - 1;
>>>for (; p0 != pf; --p0)
>>>{
>>> @@ -3016,7 +3026,8 @@ parse_unnamed_type_name(const char* firs
>>>const char* t1 = parse_type(t0, last, db);
>>>if (t1 == t0)
>>>{
>>> -db.names.pop_back();
>>> +if(!db.names.empty())
>>> +db.names.pop_back();
>>>return first;
>>>}
>>>if (db.names.size() < 2)
>>> @@ -3041,17 +3052,21 @@ parse_unnamed_type_name(const char* firs
>>>}
>>>t0 = t1;
>>>}
>>> +if(db.names.empty())
>>> +  return first;
>>>db.names.back().first.append(")");
>>>}
>>>if (t0 == last || *t0 != 'E')
>>>{
>>> +  if(!db.names.empty())
>>>db.names.pop_back();
>>>return first;
>>>}
>>>++t0;
>>>if (t0 == last)
>>>{
>>> -db.names.pop_back();
>>> +if(!db.names.empty())
>>> +  db.names.pop_back();
>>>return first;
>>>}
>>>if (std::isdigit(*t0))
>>> @@ -3064,7 +3079,8 @@ parse_unnamed_type_name(const char* firs
>>>}
>>>if (t0 == last || *t0 != '_')
>>>{
>>> -db.names.pop_back();
>>> +if(!db.names.empty())
>>> +  db.names.pop_back();
>>>return first;
>>>}
>>>first = t0 + 1;
>>> @@ -3251,7 +3267,7 @@ parse_binary_expression(const char* firs
>>>nm += ')';
>>>first = t2;
>>>}
>>> -else
>>> +else if(!db.names.empty())
>>>db.names.pop_back();
>>>}
>>>return first;
>>> @@ -3490,7 +3506,7 @@ parse_expression(const char* first, cons
>>>db.names.back() = "(" + op1 + ")[" + op2 + "]";
>>>first = t2;
>>>  

Re: [PATCH] D22130: Link static PIE programs against rcrt0.o on OpenBSD

2016-08-15 Thread Stefan Kempf via cfe-commits
sisnkemp updated this revision to Diff 68046.
sisnkemp added a comment.

Now with test case.


https://reviews.llvm.org/D22130

Files:
  lib/Driver/Tools.cpp
  test/Driver/openbsd.c

Index: test/Driver/openbsd.c
===
--- test/Driver/openbsd.c
+++ test/Driver/openbsd.c
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie 
%s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static 
-nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8301,6 +8301,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));


Index: test/Driver/openbsd.c
===
--- test/Driver/openbsd.c
+++ test/Driver/openbsd.c
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static -nopie %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8301,6 +8301,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
___
cfe-commits mailing list
cfe-commits@lists.ll

  1   2   >