Re: [PATCH] D17378: Add additional Hi/Lo registers to Clang MipsTargetInfoBase

2016-03-22 Thread Hrvoje Varga via cfe-commits
hvarga added a comment.

Are there any thoughts about this patch?


http://reviews.llvm.org/D17378



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


Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-03-22 Thread Felix Berger via cfe-commits
flx added inline comments.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:42
@@ +41,3 @@
+  decl().bind("param"));
+  Finder->addMatcher(
+  functionDecl(isDefinition(), unless(cxxMethodDecl(isOverride())),

alexfh wrote:
> Can you first try adding tests with template parameter packs and C-style 
> variadic functions?
Ran over large corpus and the check is not needed. Removed.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:56
@@ +55,3 @@
+   Function->parameters().begin();
+  if (Index >= Function->getNumParams()) {
+return;

alexfh wrote:
> nit: No braces around single-line `if` bodies.
Code is gone. Was not needed.


Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:52
@@ +51,3 @@
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+}

fowles wrote:
> no fix for this case?
Good point. Added.


http://reviews.llvm.org/D17491



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


Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-03-22 Thread Felix Berger via cfe-commits
flx updated the summary for this revision.
flx updated this revision to Diff 51385.
flx marked 5 inline comments as done.
flx added a comment.

After testing the check against a large corpus  I was able to remove the 
unnecessary param index check. But I discovered that the check crashed on value 
arguments of deleted assignment operators due to the lack of a function body. I 
added a test case and added a guard to address this.


http://reviews.llvm.org/D17491

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -0,0 +1,171 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
+
+struct ExpensiveToCopyType {
+  const ExpensiveToCopyType & constReference() const {
+return *this;
+  }
+  void nonConstMethod();
+  virtual ~ExpensiveToCopyType();
+};
+
+void mutate(ExpensiveToCopyType &);
+void mutate(ExpensiveToCopyType *);
+void useAsConstReference(const ExpensiveToCopyType &);
+void useByValue(ExpensiveToCopyType);
+
+// This class simulates std::pair<>. It is trivially copy constructible
+// and trivially destructible, but not trivially copy assignable.
+class SomewhatTrivial {
+ public:
+  SomewhatTrivial();
+  SomewhatTrivial(const SomewhatTrivial&) = default;
+  ~SomewhatTrivial() = default;
+  SomewhatTrivial& operator=(const SomewhatTrivial&);
+};
+
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'Obj' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj) {
+}
+
+void positiveExpensiveValue(ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveValue(ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: the parameter 'Obj' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj) {
+  Obj.constReference();
+  useAsConstReference(Obj);
+  auto Copy = Obj;
+  useByValue(Obj);
+}
+
+void positiveWithComment(const ExpensiveToCopyType /* important */ S);
+// CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S);
+void positiveWithComment(const ExpensiveToCopyType /* important */ S) {
+  // CHECK-MESSAGES: [[@LINE-1]]:68: warning: the const qualified
+  // CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S) {
+}
+
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+  // CHECK-FIXES: void positiveUnnamedParam(const ExpensiveToCopyType&) {
+}
+
+void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToCopyType& ConstRef, ExpensiveToCopyType Copy);
+// CHECK-FIXES: void positiveAndNegative(const ExpensiveToCopyType& ConstCopy, const ExpensiveToCopyType& ConstRef, const ExpensiveToCopyType& Copy);
+void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToCopyType& ConstRef, ExpensiveToCopyType Copy) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-MESSAGES: [[@LINE-2]]:120: warning: the parameter 'Copy'
+  // CHECK-FIXES: void positiveAndNegative(const ExpensiveToCopyType& ConstCopy, const ExpensiveToCopyType& ConstRef, const ExpensiveToCopyType& Copy) {
+}
+
+struct PositiveConstValueConstructor {
+  PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+};
+
+template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
+  // CHECK-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
+}
+
+void instantiated() {
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), ExpensiveToCopyType());
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), 5);
+}
+
+template  void negativeTemplateType(const T V) {
+}
+
+void negativeArray(const ExpensiveToCopyType[]) {

[PATCH] D18385: [CUDA] Simplify SemaCUDA/function-overload.cu test.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Principally, don't hardcode the line numbers of various notes.  This
lets us make changes to the test without recomputing linenos everywhere.

Instead, just tell -verify that we may get 0 or more notes pointing to
the relevant function definitions.  Checking that we get exactly the
right note isn't so important (and anyway is checked elsewhere).

http://reviews.llvm.org/D18385

Files:
  test/SemaCUDA/function-overload.cu

Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -16,187 +16,182 @@
 
 #include "Inputs/cuda.h"
 
-typedef int (*fp_t)(void);
-typedef void (*gp_t)(void);
+typedef int (*fp_t)();
+typedef void (*gp_t)();
 
-// Host and unattributed functions can't be overloaded
-__host__ int hh(void) { return 1; } // expected-note {{previous definition is here}}
-int hh(void) { return 1; } // expected-error {{redefinition of 'hh'}}
+// Host and unattributed functions can't be overloaded.
+__host__ void hh() {} // expected-note {{previous definition is here}}
+void hh() {} // expected-error {{redefinition of 'hh'}}
 
-// H/D overloading is OK
-__host__ int dh(void) { return 2; }
-__device__ int dh(void) { return 2; }
+// H/D overloading is OK.
+__host__ int dh() { return 2; }
+__device__ int dh() { return 2; }
 
-// H/HD and D/HD are not allowed
-__host__ __device__ int hdh(void) { return 5; } // expected-note {{previous definition is here}}
-__host__ int hdh(void) { return 4; } // expected-error {{redefinition of 'hdh'}}
+// H/HD and D/HD are not allowed.
+__host__ __device__ int hdh() { return 5; } // expected-note {{previous definition is here}}
+__host__ int hdh() { return 4; } // expected-error {{redefinition of 'hdh'}}
 
-__host__ int hhd(void) { return 4; } // expected-note {{previous definition is here}}
-__host__ __device__ int hhd(void) { return 5; } // expected-error {{redefinition of 'hhd'}}
+__host__ int hhd() { return 4; } // expected-note {{previous definition is here}}
+__host__ __device__ int hhd() { return 5; } // expected-error {{redefinition of 'hhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-__host__ __device__ int hdd(void) { return 7; } // expected-note {{previous definition is here}}
-__device__ int hdd(void) { return 6; } // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ int hdd() { return 7; } // expected-note {{previous definition is here}}
+__device__ int hdd() { return 6; } // expected-error {{redefinition of 'hdd'}}
 
-__device__ int dhd(void) { return 6; } // expected-note {{previous definition is here}}
-__host__ __device__ int dhd(void) { return 7; } // expected-error {{redefinition of 'dhd'}}
+__device__ int dhd() { return 6; } // expected-note {{previous definition is here}}
+__host__ __device__ int dhd() { return 7; } // expected-error {{redefinition of 'dhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-// Same tests for extern "C" functions
-extern "C" __host__ int chh(void) {return 11;} // expected-note {{previous definition is here}}
-extern "C" int chh(void) {return 11;} // expected-error {{redefinition of 'chh'}}
+// Same tests for extern "C" functions.
+extern "C" __host__ int chh() {return 11;} // expected-note {{previous definition is here}}
+extern "C" int chh() {return 11;} // expected-error {{redefinition of 'chh'}}
 
-// H/D overloading is OK
-extern "C" __device__ int cdh(void) {return 10;}
-extern "C" __host__ int cdh(void) {return 11;}
+// H/D overloading is OK.
+extern "C" __device__ int cdh() {return 10;}
+extern "C" __host__ int cdh() {return 11;}
 
 // H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1(void) {return 12;} // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1(void) {return 13;} // expected-error {{redefinition of 'chhd1'}}
+extern "C" __host__ __device__ int chhd1() {return 12;} // expected-note {{previous definition is here}}
+extern "C" __host__ int chhd1() {return 13;} // expected-error {{redefinition of 'chhd1'}}
 
-extern "C" __host__ int chhd2(void) {return 13;} // expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2(void) {return 12;} // expected-error {{redefinition of 'chhd2'}}
+extern "C" __host__ int chhd2() {return 13;} // expected-note {{previous definition is here}}
+extern "C" __host__ __device__ int chhd2() {return 12;} // expected-error {{redefinition of 'chhd2'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
 // Helper functions to verify calling restrictions.
-__device__ int d(void) { return 8; }
-__host__ int h(void) {

[PATCH] D18386: [CUDA] Merge most of CodeGenCUDA/function-overload.cu into SemaCUDA/function-overload.cu.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Previously we were using the codegen test to ensure that we choose the
right overload.  But we can do this within sema, with a bit of
cleverness.

I left the constructor/destructor checks in CodeGen, because these
overloads (particularly on the destructors) are hard to check in Sema.

http://reviews.llvm.org/D18386

Files:
  test/CodeGenCUDA/function-overload.cu
  test/SemaCUDA/function-overload.cu

Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -16,58 +16,80 @@
 
 #include "Inputs/cuda.h"
 
-typedef int (*fp_t)();
-typedef void (*gp_t)();
+// Opaque return types used to check that we pick the right overloads.
+struct HostReturnTy {};
+struct HostReturnTy2 {};
+struct DeviceReturnTy {};
+struct DeviceReturnTy2 {};
+struct HostDeviceReturnTy {};
+struct TemplateReturnTy {};
+
+typedef HostReturnTy (*HostFnPtr)();
+typedef DeviceReturnTy (*DeviceFnPtr)();
+typedef HostDeviceReturnTy (*HostDeviceFnPtr)();
+typedef void (*GlobalFnPtr)();  // __global__ functions must return void.
+
+// CurrentReturnTy is {HostReturnTy,DeviceReturnTy} during {host,device}
+// compilation.
+#ifdef __CUDA_ARCH__
+typedef DeviceReturnTy CurrentReturnTy;
+#else
+typedef HostReturnTy CurrentReturnTy;
+#endif
+
+// CurrentFnPtr is a function pointer to a {host,device} function during
+// {host,device} compilation.
+typedef CurrentReturnTy (*CurrentFnPtr)();
 
 // Host and unattributed functions can't be overloaded.
 __host__ void hh() {} // expected-note {{previous definition is here}}
 void hh() {} // expected-error {{redefinition of 'hh'}}
 
 // H/D overloading is OK.
-__host__ int dh() { return 2; }
-__device__ int dh() { return 2; }
+__host__ HostReturnTy dh() { return HostReturnTy(); }
+__device__ DeviceReturnTy dh() { return DeviceReturnTy(); }
 
 // H/HD and D/HD are not allowed.
-__host__ __device__ int hdh() { return 5; } // expected-note {{previous definition is here}}
-__host__ int hdh() { return 4; } // expected-error {{redefinition of 'hdh'}}
+__host__ __device__ int hdh() { return 0; } // expected-note {{previous definition is here}}
+__host__ int hdh() { return 0; }// expected-error {{redefinition of 'hdh'}}
 
-__host__ int hhd() { return 4; } // expected-note {{previous definition is here}}
-__host__ __device__ int hhd() { return 5; } // expected-error {{redefinition of 'hhd'}}
+__host__ int hhd() { return 0; }// expected-note {{previous definition is here}}
+__host__ __device__ int hhd() { return 0; } // expected-error {{redefinition of 'hhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-__host__ __device__ int hdd() { return 7; } // expected-note {{previous definition is here}}
-__device__ int hdd() { return 6; } // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ int hdd() { return 0; } // expected-note {{previous definition is here}}
+__device__ int hdd() { return 0; }  // expected-error {{redefinition of 'hdd'}}
 
-__device__ int dhd() { return 6; } // expected-note {{previous definition is here}}
-__host__ __device__ int dhd() { return 7; } // expected-error {{redefinition of 'dhd'}}
+__device__ int dhd() { return 0; }  // expected-note {{previous definition is here}}
+__host__ __device__ int dhd() { return 0; } // expected-error {{redefinition of 'dhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
 // Same tests for extern "C" functions.
-extern "C" __host__ int chh() {return 11;} // expected-note {{previous definition is here}}
-extern "C" int chh() {return 11;} // expected-error {{redefinition of 'chh'}}
+extern "C" __host__ int chh() { return 0; } // expected-note {{previous definition is here}}
+extern "C" int chh() { return 0; }  // expected-error {{redefinition of 'chh'}}
 
 // H/D overloading is OK.
-extern "C" __device__ int cdh() {return 10;}
-extern "C" __host__ int cdh() {return 11;}
+extern "C" __device__ DeviceReturnTy cdh() { return DeviceReturnTy(); }
+extern "C" __host__ HostReturnTy cdh() { return HostReturnTy(); }
 
 // H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1() {return 12;} // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1() {return 13;} // expected-error {{redefinition of 'chhd1'}}
+extern "C" __host__ __device__ int chhd1() { return 0; } // expected-note {{previous definition is here}}
+extern "C" __host__ int chhd1() { return 0; }// expected-error {{redefinition of 'chhd1'}}
 
-extern "C" __host__ int chhd2() {return 13;} // expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2() {return 12;} // expected-

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 51384.
jlebar added a comment.

Update test as discussed -- now we check that we're invoking the correct 
overloads.


http://reviews.llvm.org/D18380

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/relaxed-constexpr.cu

Index: test/SemaCUDA/relaxed-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/relaxed-constexpr.cu
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-relaxed-constexpr
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-relaxed-constexpr -fcuda-is-device
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+static __device__ void f1();
+constexpr void f1();
+
+__device__ void f2();
+static constexpr void f2();
+
+// Different potential error depending on the order of declaration.
+constexpr void f3();
+static __device__ void f3();
+
+static constexpr void f4();
+__device__ void f4();
+
+// Variadic device functions are not allowed, so this is just treated as
+// host-only.
+constexpr void variadic(const char*, ...);
Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -49,22 +49,18 @@
 __host__ HostReturnTy dh() { return HostReturnTy(); }
 __device__ DeviceReturnTy dh() { return DeviceReturnTy(); }
 
-// H/HD and D/HD are not allowed.
-__host__ __device__ int hdh() { return 0; } // expected-note {{previous definition is here}}
-__host__ int hdh() { return 0; }// expected-error {{redefinition of 'hdh'}}
+// H/HD and D/HD are also OK.
+__host__ __device__ HostDeviceReturnTy hdh() { return HostDeviceReturnTy(); }
+__host__ HostReturnTy hdh() { return HostReturnTy(); }
 
-__host__ int hhd() { return 0; }// expected-note {{previous definition is here}}
-__host__ __device__ int hhd() { return 0; } // expected-error {{redefinition of 'hhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__host__ HostReturnTy hhd() { return HostReturnTy(); }
+__host__ __device__ HostDeviceReturnTy hhd() { return HostDeviceReturnTy(); }
 
-__host__ __device__ int hdd() { return 0; } // expected-note {{previous definition is here}}
-__device__ int hdd() { return 0; }  // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ HostDeviceReturnTy hdd() { return HostDeviceReturnTy(); }
+__device__ DeviceReturnTy hdd() { return DeviceReturnTy(); }
 
-__device__ int dhd() { return 0; }  // expected-note {{previous definition is here}}
-__host__ __device__ int dhd() { return 0; } // expected-error {{redefinition of 'dhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__device__ DeviceReturnTy dhd() { return DeviceReturnTy(); }
+__host__ __device__ HostDeviceReturnTy dhd() { return HostDeviceReturnTy(); }
 
 // Same tests for extern "C" functions.
 extern "C" __host__ int chh() { return 0; } // expected-note {{previous definition is here}}
@@ -74,14 +70,12 @@
 extern "C" __device__ DeviceReturnTy cdh() { return DeviceReturnTy(); }
 extern "C" __host__ HostReturnTy cdh() { return HostReturnTy(); }
 
-// H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1() { return 0; } // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1() { return 0; }// expected-error {{redefinition of 'chhd1'}}
+// H/HD and D/HD overloading is OK.
+extern "C" __host__ __device__ HostDeviceReturnTy chhd() { return HostDeviceReturnTy(); }
+extern "C" __host__ HostReturnTy chhd() { return HostReturnTy(); }
 
-extern "C" __host__ int chhd2() { return 0; }// expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2() { return 0; } // expected-error {{redefinition of 'chhd2'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+extern "C" __host__ __device__ HostDeviceReturnTy chdd() { return HostDeviceReturnTy(); }
+extern "C" __device__ DeviceReturnTy chdd() { return DeviceReturnTy(); }
 
 // Helper functions to verify calling restrictions.
 __device__ DeviceReturnTy d() { return DeviceReturnTy(); }
@@ -128,6 +122,16 @@
   HostFnPtr fp_cdh = cdh;
   HostReturnTy ret_cdh = cdh();
 
+  HostFnPtr fp_hdh = hdh;
+  HostReturnTy ret_hdh = hdh();
+  HostFnPtr fp_chhd = chhd;
+  HostReturnTy ret_chhd = chhd();
+
+  HostDeviceFnPtr fp_hdd = hdd;
+  HostDeviceReturnTy ret_hdd = hdd();
+  HostDeviceFnPtr fp_chdd = chdd;
+  HostDeviceReturnTy ret_chdd =

Re: [PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update

2016-03-22 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264132: [Sema] Allow implicit conversions of &overloaded_fn 
in C. (authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D13704?vs=49333&id=51378#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13704

Files:
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeGen/overloadable.c
  cfe/trunk/test/Sema/overloadable.c
  cfe/trunk/test/Sema/pass-object-size.c

Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -8488,7 +8488,7 @@
 // Cand1's first N enable_if attributes have precisely the same conditions as
 // Cand2's first N enable_if attributes (where N = the number of enable_if
 // attributes on Cand2), and Cand1 has more than N enable_if attributes.
-static bool hasBetterEnableIfAttrs(Sema &S, const FunctionDecl *Cand1,
+static bool hasBetterEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1,
const FunctionDecl *Cand2) {
 
   // FIXME: The next several lines are just
@@ -10299,13 +10299,25 @@
   bool hasComplained() const { return HasComplained; }
 
 private:
-  // Is A considered a better overload candidate for the desired type than B?
+  bool candidateHasExactlyCorrectType(const FunctionDecl *FD) {
+QualType Discard;
+return Context.hasSameUnqualifiedType(TargetFunctionType, FD->getType()) ||
+   S.IsNoReturnConversion(FD->getType(), TargetFunctionType, Discard);
+  }
+
+  /// \return true if A is considered a better overload candidate for the
+  /// desired type than B.
   bool isBetterCandidate(const FunctionDecl *A, const FunctionDecl *B) {
-return hasBetterEnableIfAttrs(S, A, B);
+// If A doesn't have exactly the correct type, we don't want to classify it
+// as "better" than anything else. This way, the user is required to
+// disambiguate for us if there are multiple candidates and no exact match.
+return candidateHasExactlyCorrectType(A) &&
+   (!candidateHasExactlyCorrectType(B) ||
+hasBetterEnableIfAttrs(S, A, B));
   }
 
-  // Returns true if we've eliminated any (read: all but one) candidates, false
-  // otherwise.
+  /// \return true if we were able to eliminate all but one overload candidate,
+  /// false otherwise.
   bool eliminiateSuboptimalOverloadCandidates() {
 // Same algorithm as overload resolution -- one pass to pick the "best",
 // another pass to be sure that nothing is better than the best.
@@ -10418,12 +10430,9 @@
   if (!S.checkAddressOfFunctionIsAvailable(FunDecl))
 return false;
 
-  QualType ResultTy;
-  if (Context.hasSameUnqualifiedType(TargetFunctionType,
- FunDecl->getType()) ||
-  S.IsNoReturnConversion(FunDecl->getType(), TargetFunctionType,
- ResultTy) ||
-  (!S.getLangOpts().CPlusPlus && TargetType->isVoidPointerType())) {
+  // If we're in C, we need to support types that aren't exactly identical.
+  if (!S.getLangOpts().CPlusPlus ||
+  candidateHasExactlyCorrectType(FunDecl)) {
 Matches.push_back(std::make_pair(
 CurAccessFunPair, cast(FunDecl->getCanonicalDecl(;
 FoundNonTemplateFunction = true;
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -260,6 +260,29 @@
 not ODR-equivalent.
 
 Query for this feature with ``__has_attribute(enable_if)``.
+
+Note that functions with one or more ``enable_if`` attributes may not have
+their address taken, unless all of the conditions specified by said
+``enable_if`` are constants that evaluate to ``true``. For example:
+
+.. code-block:: c
+
+  const int TrueConstant = 1;
+  const int FalseConstant = 0;
+  int f(int a) __attribute__((enable_if(a > 0, "")));
+  int g(int a) __attribute__((enable_if(a == 0 || a != 0, "")));
+  int h(int a) __attribute__((enable_if(1, "")));
+  int i(int a) __attribute__((enable_if(TrueConstant, "")));
+  int j(int a) __attribute__((enable_if(FalseConstant, "")));
+
+  void fn() {
+int (*ptr)(int);
+ptr = &f; // error: 'a > 0' is not always true
+ptr = &g; // error: 'a == 0 || a != 0' is not a truthy constant
+ptr = &h; // OK: 1 is a truthy constant
+ptr = &i; // OK: 'TrueConstant' is a truthy constant
+ptr = &j; // error: 'FalseConstant' is a constant, but not truthy
+  }
   }];
 }
 
Index: cfe/trunk/test/CodeGen/overloadable.c
===
--- cfe/trunk/test/CodeGen/overloadable.c
+++ cfe/trunk/test/CodeGen/overloadable.c
@@ -29,3 +29,33 @@
   cdv = f(cdv);
   vv = f(vv);
 }
+
+// Ensuring that we 

r264132 - [Sema] Allow implicit conversions of &overloaded_fn in C.

2016-03-22 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Mar 22 21:33:58 2016
New Revision: 264132

URL: http://llvm.org/viewvc/llvm-project?rev=264132&view=rev
Log:
[Sema] Allow implicit conversions of &overloaded_fn in C.

Also includes a minor ``enable_if`` docs update.

Currently, our address-of overload machinery will only allow implicit
conversions of overloaded functions to void* in C. For example:

```
void f(int) __attribute__((overloadable));
void f(double) __attribute__((overloadable, enable_if(0, "")));

void *fp = f; // OK. This is C and the target is void*.
void (*fp2)(void) = f; // Error. This is C, but the target isn't void*.
```

This patch makes the assignment of `fp2` select the `f(int)` overload,
rather than emitting an error (N.B. you'll still get a warning about the
`fp2` assignment if you use -Wincompatible-pointer-types).

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

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CodeGen/overloadable.c
cfe/trunk/test/Sema/overloadable.c
cfe/trunk/test/Sema/pass-object-size.c

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=264132&r1=264131&r2=264132&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Mar 22 21:33:58 2016
@@ -260,6 +260,29 @@ only a single candidate. In a call to g(
 not ODR-equivalent.
 
 Query for this feature with ``__has_attribute(enable_if)``.
+
+Note that functions with one or more ``enable_if`` attributes may not have
+their address taken, unless all of the conditions specified by said
+``enable_if`` are constants that evaluate to ``true``. For example:
+
+.. code-block:: c
+
+  const int TrueConstant = 1;
+  const int FalseConstant = 0;
+  int f(int a) __attribute__((enable_if(a > 0, "")));
+  int g(int a) __attribute__((enable_if(a == 0 || a != 0, "")));
+  int h(int a) __attribute__((enable_if(1, "")));
+  int i(int a) __attribute__((enable_if(TrueConstant, "")));
+  int j(int a) __attribute__((enable_if(FalseConstant, "")));
+
+  void fn() {
+int (*ptr)(int);
+ptr = &f; // error: 'a > 0' is not always true
+ptr = &g; // error: 'a == 0 || a != 0' is not a truthy constant
+ptr = &h; // OK: 1 is a truthy constant
+ptr = &i; // OK: 'TrueConstant' is a truthy constant
+ptr = &j; // error: 'FalseConstant' is a constant, but not truthy
+  }
   }];
 }
 

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=264132&r1=264131&r2=264132&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Mar 22 21:33:58 2016
@@ -8488,7 +8488,7 @@ Sema::AddArgumentDependentLookupCandidat
 // Cand1's first N enable_if attributes have precisely the same conditions as
 // Cand2's first N enable_if attributes (where N = the number of enable_if
 // attributes on Cand2), and Cand1 has more than N enable_if attributes.
-static bool hasBetterEnableIfAttrs(Sema &S, const FunctionDecl *Cand1,
+static bool hasBetterEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1,
const FunctionDecl *Cand2) {
 
   // FIXME: The next several lines are just
@@ -10299,13 +10299,25 @@ public:
   bool hasComplained() const { return HasComplained; }
 
 private:
-  // Is A considered a better overload candidate for the desired type than B?
+  bool candidateHasExactlyCorrectType(const FunctionDecl *FD) {
+QualType Discard;
+return Context.hasSameUnqualifiedType(TargetFunctionType, FD->getType()) ||
+   S.IsNoReturnConversion(FD->getType(), TargetFunctionType, Discard);
+  }
+
+  /// \return true if A is considered a better overload candidate for the
+  /// desired type than B.
   bool isBetterCandidate(const FunctionDecl *A, const FunctionDecl *B) {
-return hasBetterEnableIfAttrs(S, A, B);
+// If A doesn't have exactly the correct type, we don't want to classify it
+// as "better" than anything else. This way, the user is required to
+// disambiguate for us if there are multiple candidates and no exact match.
+return candidateHasExactlyCorrectType(A) &&
+   (!candidateHasExactlyCorrectType(B) ||
+hasBetterEnableIfAttrs(S, A, B));
   }
 
-  // Returns true if we've eliminated any (read: all but one) candidates, false
-  // otherwise.
+  /// \return true if we were able to eliminate all but one overload candidate,
+  /// false otherwise.
   bool eliminiateSuboptimalOverloadCandidates() {
 // Same algorithm as overload resolution -- one pass to pick the "best",
 // another pass to be sure that nothing is better than the best.
@@ -10418,12 +10430,9 @@ private:
   if (!S.chec

Re: [PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update

2016-03-22 Thread George Burgess IV via cfe-commits
george.burgess.iv marked 3 inline comments as done.


Comment at: lib/Sema/SemaOverload.cpp:10419
@@ -10418,3 +10429,1 @@
- ResultTy) ||
-  (!S.getLangOpts().CPlusPlus && TargetType->isVoidPointerType())) {
 Matches.push_back(std::make_pair(

rsmith wrote:
> george.burgess.iv wrote:
> > rsmith wrote:
> > > Why is the `void*` check removed from this case? Note that clang and GCC 
> > > intentionally treat these two cases differently today:
> > > 
> > > int f();
> > > void *p = f; // ok (warning under -pedantic)
> > > int *q = f; // warning: incompatible pointer types
> > > 
> > > (That is: the first is a silent-by-default extension and the second is a 
> > > warn-by-default extension.)
> > Because this is overload resolution logic, so we shouldn't care about what 
> > warnings we will emit :)
> > 
> > This is how we act prior to applying this patch:
> > 
> > ```
> > void f(int) __attribute__((overloadable));
> > void f(double) __attribute__((overloadable, enable_if(0, "")));
> > 
> > void *fp = f; // OK. This is C and the target is void*.
> > void (*fp)(void) = f; // Error. This is C, but the target isn't void*.
> > ```
> > 
> > I'm simply removing the "the target must be a `void*`" restriction; the 
> > user should still get warnings in the latter case (the tests changed in 
> > test/Sema/pass-object-size.c make sure of this).
> OK, this seems fine so long as we somewhere choose exact matches over inexact 
> ones:
> 
> void f(int) __attribute__((overloadable));
> void f(int, int) __attribute__((overloadable));
> void g(void (*)(int));
> void h() { g(f); } // should pick f(int)
We do; the tests in test/CodeGen/overloadable.c make sure of this -- thanks for 
the review! :)


http://reviews.llvm.org/D13704



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


Re: [PATCH] D18196: [CodeGen] Emit lifetime.end intrinsic after destructor call in landing pad

2016-03-22 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

In http://reviews.llvm.org/D18196#375997, @rjmccall wrote:

> You should also check that any back-end peepholes we have in place (null type 
> infos to signify a call-terminate landingpad?) aren't disturbed by the 
> lifetime intrinsics.


I looked at the back-end passes that might be affected by the insertion of 
lifetime markers. I don't think inserting lifetime markers will have an adverse 
effect on any of the back-end code-generation.


http://reviews.llvm.org/D18196



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


Re: [PATCH] D18196: [CodeGen] Emit lifetime.end intrinsic after destructor call in landing pad

2016-03-22 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 51376.
ahatanak added a comment.

Added a test in test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp to check expected 
patterns are emitted.


http://reviews.llvm.org/D18196

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/EHScopeStack.h
  test/CodeGenCXX/destructors.cpp
  test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
===
--- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -O3 -disable-llvm-optzns %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fexceptions -fcxx-exceptions -fno-rtti | FileCheck -check-prefix WIN32 -check-prefix WIN32-LIFETIME %s
 
 struct A {
   A();
@@ -206,3 +207,36 @@
 // WIN32: cleanuppad
 // WIN32: call x86_thiscallcc void @"\01??1D@noexcept_false_dtor@@QAE@XZ"(%"struct.noexcept_false_dtor::D"* %{{.*}})
 // WIN32: cleanupret
+
+namespace lifetime_marker {
+struct C {
+  ~C();
+};
+void g();
+void f() {
+  C c;
+  g();
+}
+
+// WIN32-LIFETIME-LABEL: define void @"\01?f@lifetime_marker@@YAXXZ"()
+// WIN32-LIFETIME: %[[c:.*]] = alloca %"struct.lifetime_marker::C"
+// WIN32-LIFETIME: %[[bc0:.*]] = bitcast %"struct.lifetime_marker::C"* %c to i8*
+// WIN32-LIFETIME: call void @llvm.lifetime.start(i64 1, i8* %[[bc0]])
+// WIN32-LIFETIME: invoke void @"\01?g@lifetime_marker@@YAXXZ"()
+// WIN32-LIFETIME-NEXT: to label %[[cont:[^ ]*]] unwind label %[[lpad0:[^ ]*]]
+//
+// WIN32-LIFETIME: [[cont]]:
+// WIN32-LIFETIME: call x86_thiscallcc void @"\01??1C@lifetime_marker@@QAE@XZ"({{.*}})
+// WIN32-LIFETIME: %[[bc1:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8*
+// WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc1]])
+//
+// WIN32-LIFETIME: [[lpad0]]:
+// WIN32-LIFETIME-NEXT: cleanuppad
+// WIN32-LIFETIME: call x86_thiscallcc void @"\01??1C@lifetime_marker@@QAE@XZ"({{.*}})
+// WIN32-LIFETIME: cleanupret {{.*}} unwind label %[[lpad1:[^ ]*]]
+//
+// WIN32-LIFETIME: [[lpad1]]:
+// WIN32-LIFETIME-NEXT: cleanuppad
+// WIN32-LIFETIME: %[[bc2:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8*
+// WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc2]])
+}
Index: test/CodeGenCXX/destructors.cpp
===
--- test/CodeGenCXX/destructors.cpp
+++ test/CodeGenCXX/destructors.cpp
@@ -4,6 +4,8 @@
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns -std=c++11 > %t2
+// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t2 %s
 
 struct A {
   int a;
@@ -428,3 +430,64 @@
 return true;
   }
 }
+
+#if __cplusplus >= 201103L
+namespace test11 {
+
+// Check that lifetime.end is emitted in the landing pad.
+
+// CHECK6-LABEL: define void @_ZN6test1115testLifetimeEndEi(
+// CHECK6: entry:
+// CHECK6: [[T1:%[a-z0-9]+]] = alloca %"struct.test11::S1"
+// CHECK6: [[T2:%[a-z0-9]+]] = alloca %"struct.test11::S1"
+// CHECK6: [[T3:%[a-z0-9]+]] = alloca %"struct.test11::S1"
+
+// CHECK6: {{^}}invoke.cont
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T1]])
+// CHECK6: [[BC1:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T1]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC1]])
+// CHECK6: {{^}}lpad
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T1]])
+// CHECK6: [[BC2:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T1]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC2]])
+
+// CHECK6: {{^}}invoke.cont
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T2]])
+// CHECK6: [[BC3:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T2]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC3]])
+// CHECK6: {{^}}lpad
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T2]])
+// CHECK6: [[BC4:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T2]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC4]])
+
+// CHECK6: {{^}}invoke.cont
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T3]])
+// CHECK6: [[BC5:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T3]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC5]])
+// CHECK6: {{^}}lpad
+// CHECK6: call void @_ZN6test112S1D1Ev(%"struct.test11::S1"* [[T3]])
+// CHECK6: [[BC6:%[a-z0-9]+]] = bitcast %"struct.test11::S1"* [[T3]] to i8*
+// CHECK6: call void @llvm.lifetime.end(i64 32, i8* [[BC6]])
+
+  struct S1 {
+~S1();
+int a[8];
+  };
+
+  void func1(S

Re: [PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update

2016-03-22 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Sema/SemaOverload.cpp:10419
@@ -10418,3 +10429,1 @@
- ResultTy) ||
-  (!S.getLangOpts().CPlusPlus && TargetType->isVoidPointerType())) {
 Matches.push_back(std::make_pair(

george.burgess.iv wrote:
> rsmith wrote:
> > Why is the `void*` check removed from this case? Note that clang and GCC 
> > intentionally treat these two cases differently today:
> > 
> > int f();
> > void *p = f; // ok (warning under -pedantic)
> > int *q = f; // warning: incompatible pointer types
> > 
> > (That is: the first is a silent-by-default extension and the second is a 
> > warn-by-default extension.)
> Because this is overload resolution logic, so we shouldn't care about what 
> warnings we will emit :)
> 
> This is how we act prior to applying this patch:
> 
> ```
> void f(int) __attribute__((overloadable));
> void f(double) __attribute__((overloadable, enable_if(0, "")));
> 
> void *fp = f; // OK. This is C and the target is void*.
> void (*fp)(void) = f; // Error. This is C, but the target isn't void*.
> ```
> 
> I'm simply removing the "the target must be a `void*`" restriction; the user 
> should still get warnings in the latter case (the tests changed in 
> test/Sema/pass-object-size.c make sure of this).
OK, this seems fine so long as we somewhere choose exact matches over inexact 
ones:

void f(int) __attribute__((overloadable));
void f(int, int) __attribute__((overloadable));
void g(void (*)(int));
void h() { g(f); } // should pick f(int)


http://reviews.llvm.org/D13704



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


r264125 - [Apple Clang] Expose llvm-config from stage2 builds in stage1

2016-03-22 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 22 20:47:05 2016
New Revision: 264125

URL: http://llvm.org/viewvc/llvm-project?rev=264125&view=rev
Log:
[Apple Clang] Expose llvm-config from stage2 builds in stage1

This exposes the stage2-llvm-config target though the stage1 build 
configuration.

Modified:
cfe/trunk/cmake/caches/Apple-stage1.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage1.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage1.cmake?rev=264125&r1=264124&r2=264125&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage1.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage1.cmake Tue Mar 22 20:47:05 2016
@@ -37,6 +37,7 @@ set(CLANG_BOOTSTRAP_TARGETS
   check-all
   check-llvm
   check-clang
+  llvm-config
   test-suite
   test-depends
   llvm-test-depends


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


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

2016-03-22 Thread George Burgess IV via cfe-commits
george.burgess.iv added inline comments.


Comment at: lib/CodeGen/CGCall.cpp:142-143
@@ -132,1 +141,4 @@
+  appendParameterTypes(CGT, prefix, FTP, FD, &SynthesizedParams);
+  RequiredArgs Required =
+  RequiredArgs::forPrototypePlus(FTP, StartParams + SynthesizedParams);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();

rsmith wrote:
> Would it make sense for `RequiredArgs::forPrototypePlus` to do this 
> computation? Are the other callers of that function also getting the wrong 
> number of required arguments in this case?
...There was a reason I didn't do that. I don't remember what it was, so either 
it disappeared, or I was just being dumb, but there was a reason. Either way, I 
moved this logic into `RequiredArgs`, and ended up fixing a few more bugs in 
the process. Yay for (fixing) bugs!


http://reviews.llvm.org/D17462



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


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

2016-03-22 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 51374.
george.burgess.iv marked an inline comment as done.
george.burgess.iv added a comment.

Addressed all feedback


http://reviews.llvm.org/D17462

Files:
  include/clang/CodeGen/CGFunctionInfo.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGVTables.cpp
  test/CodeGen/pass-object-size.c
  test/CodeGenCXX/pass-object-size.cpp

Index: test/CodeGenCXX/pass-object-size.cpp
===
--- test/CodeGenCXX/pass-object-size.cpp
+++ test/CodeGenCXX/pass-object-size.cpp
@@ -43,3 +43,30 @@
   (&OvlFoo)(nullptr);
 }
 }
+
+namespace variadic {
+// We had an issue where variadic member/operator calls with pass_object_size
+// would cause crashes.
+
+struct AsCtor {
+  AsCtor(const char *const c __attribute__((pass_object_size(0))), double a,
+ ...) {}
+};
+
+struct AsMember {
+  void bar(const char *const c __attribute__((pass_object_size(0))), double a,
+   ...) {}
+  void operator()(const char *const c __attribute__((pass_object_size(0))),
+  double a, ...) {}
+};
+
+// CHECK-LABEL: define void @_ZN8variadic4testEv()
+void test() {
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic6AsCtorC1EPKcU17pass_object_size0dz
+  AsCtor("a", 1.0);
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic8AsMember3barEPKcU17pass_object_size0dz
+  AsMember{}.bar("a", 1.0);
+  // CHECK-RE: call{{[^@]+}}@_ZN8variadic8AsMemberclEPKcU17pass_object_size0dz
+  AsMember{}("a", 1.0);
+}
+}
Index: test/CodeGen/pass-object-size.c
===
--- test/CodeGen/pass-object-size.c
+++ test/CodeGen/pass-object-size.c
@@ -351,3 +351,18 @@
   ObjectSize0(++p);
   ObjectSize0(p++);
 }
+
+// There was a bug where variadic functions with pass_object_size would cause
+// problems in the form of failed assertions.
+void my_sprintf(char *const c __attribute__((pass_object_size(0))), ...) {}
+
+// CHECK-LABEL: define void @test14
+void test14(char *c) {
+  // CHECK: @llvm.objectsize
+  // CHECK: call void (i8*, i64, ...) @my_sprintf
+  my_sprintf(c);
+
+  // CHECK: @llvm.objectsize
+  // CHECK: call void (i8*, i64, ...) @my_sprintf
+  my_sprintf(c, 1, 2, 3);
+}
Index: lib/CodeGen/CGVTables.cpp
===
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -292,9 +292,8 @@
   const FunctionProtoType *FPT = MD->getType()->getAs();
 
 #ifndef NDEBUG
-  const CGFunctionInfo &CallFnInfo =
-CGM.getTypes().arrangeCXXMethodCall(CallArgs, FPT,
-   RequiredArgs::forPrototypePlus(FPT, 1));
+  const CGFunctionInfo &CallFnInfo = CGM.getTypes().arrangeCXXMethodCall(
+  CallArgs, FPT, RequiredArgs::forPrototypePlus(FPT, 1, MD));
   assert(CallFnInfo.getRegParm() == CurFnInfo->getRegParm() &&
  CallFnInfo.isNoReturn() == CurFnInfo->isNoReturn() &&
  CallFnInfo.getCallingConvention() == CurFnInfo->getCallingConvention());
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -54,7 +54,9 @@
   }
 
   const FunctionProtoType *FPT = MD->getType()->castAs();
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size());
+  // Don't pass in the MethodDecl, because we should already have the
+  // pass_object_size values in the arglist.
+  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, Args.size(), MD);
 
   // And the rest of the call args.
   if (CE) {
@@ -323,8 +325,7 @@
 
   // Push the this ptr.
   Args.add(RValue::get(ThisPtrForCall), ThisType);
-
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, 1);
+  RequiredArgs required = RequiredArgs::forPrototypePlus(FPT, 1, nullptr);
   
   // And the rest of the call args
   EmitCallArgs(Args, FPT, E->arguments(), E->getDirectCallee());
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -139,15 +139,16 @@
 CanQual FTP,
 const FunctionDecl *FD) {
   SmallVector paramInfos;
-  RequiredArgs required = RequiredArgs::forPrototypePlus(FTP, prefix.size());
+  RequiredArgs Required =
+  RequiredArgs::forPrototypePlus(FTP, prefix.size(), FD);
   // FIXME: Kill copy.
   appendParameterTypes(CGT, prefix, paramInfos, FTP, FD);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();
 
   return CGT.arrangeLLVMFunctionInfo(resultType, instanceMethod,
  /*chainCall=*/false, prefix,
  FTP->getExtInfo(), paramInfos,
- required);
+ Required);
 }
 
 /// Arrange the argument and result information for a value of the
@@ -336,7 +337,7 @@
 ArgTypes.push_back(Context.getCan

Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-03-22 Thread Eric Christopher via cfe-commits
Hi Daniel,

Sorry for the delay, but I've been both away and catching up:

On Wed, Mar 9, 2016 at 4:00 AM Daniel Sanders 
wrote:

> > > From: Eric Christopher [echri...@gmail.com]
> > > Sent: 09 March 2016 06:50
> > > To: reviews+d16139+public+275805419034a...@reviews.llvm.org; Bhushan
> Attarde; Vasileios Kalintiris; Daniel Sanders
> > > Cc: Sagar Thakur; Nitesh Jain; Mohit Bhakkad; Jaydeep Patil;
> cfe-commits@lists.llvm.org
> > > Subject: Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty
> string argument
> > >
> > > On Sat, Mar 5, 2016 at 6:16 AM Daniel Sanders <
> daniel.sand...@imgtec.com> wrote:
> > > dsanders added a comment.
> > >
> > > In http://reviews.llvm.org/D16139#368217, @echristo wrote:
> > >
> > > > This seems wrong. You should fix setCPU instead or set a default CPU.
> > >
> > > We already set a default CPU in the constructor (e.g.
> Mips32TargetInfoBase::Mips32TargetInfoBase() provides "mips32r2").
> > > It's the CPU argument to initFeatureMap() that's the root problem. In
> several targets, this argument has the same name as
> > > a member variable and is not subject to anything the constructor or
> setCPU() does to that member variable.
> >
> > To be clear, no, this is not the problem.
>
> I can agree that there are additional problems (and that fixing them also
> fixes this problem) but I disagree that it's not a part of
> the problem. At the moment, I think we're both looking at different
> aspects of it and saying "this is the whole problem" and I
> think we've each missed the piece the other is looking at.
>
> Suppose TargetOptions::CPU is the empty string and
> TargetInfo::CreateTargetInfo() is called. The call to AllocateTarget() will
> leave
> MipsTargetInfoBase::CPU set to the default mips32r2 or mips64r2 (depending
> on the subclass). The call to MipsTargetInfoBase::setCPU()
> will not happen because the CPU is the empty string. Then when
> MipsTargetInfoBase::initFeatureMap() is called we have the following
> state:
> * MipsTargetInfoBase::CPU is mips32r2 or mips64r2
> * The CPU argument of initFeatureMap() is the empty string.
> The CPU name came from a single place but only one path resolved the empty
> string to a CPU name. I think this is wrong and that
> both paths should resolve to the default CPU, or preferably, there should
> only be one CPU variable.
>
> Let's consider something other than MIPS for a moment. I'll pick SystemZ
> because it's the only other target that initializes its CPU
> to a non-empty value in the constructor. In SystemZ, we have the following
> state for the above example:
> * SystemZTargetInfo::CPU is z10
> * The CPU argument of initFeatureMap() is the empty string.
> Now, SystemZTargetInfo::initFeatureMap() doesn't have any checks for CPU
> == "z10" but if it did there would be a difference in
> behaviour between the default 'z10' and an explicit 'z10' since CPU ==
> "z10" would be false in the default 'z10' case (because CPU
> would be the empty string).
>
> Going back to MIPS, MipsTargetInfoBase::initFeatureMap() does encounter a
> difference between a default 'mips32r2' and an explicit
> 'mips32r2' because of the 'Features[CPU] = true' line. The clang driver
> currently makes sure we're always explicit but lldb doesn't have this.
>
> Fixing the above inconsistency would resolve the problem by itself, but I
> do agree that we're also handling the CPU name incorrectly
> in MipsTargetInfoBase::initFeatureMap(). I agree that the 'Features[CPU] =
> true' is bad and fixing that should also resolve the problem by
> itself. However, it would leave this weird inconsistency between the
> default 'mips32r2' and the explicit 'mips32r2'.
>
> I'm also wondering if the 'Features[CPU] = true' line might be redundant
> since the backend Processor<> and ProcessorModel<>
> definitions should have the same effect. I'll have to look into that when
> I get chance.
>
>
It should. Anything else should be a bug.


> > > I suspect the right thing to do is to drop the CPU argument and use
> the member variable instead but there may be differences in value/usage
> that make this difficult. For now, this patch serves as a stop-gap measure
> that resolves the empty string to a real CPU name.
> >
> > This is also not the problem. There are a few problems here:
> >
> > z) This code is terrible, I did my best to clean it up recently, but
> it's a lot of code and a bit painful.
> > a) There should be a testcase, everything can be done by the driver here
> as the code is pretty specialized for that use case.
>
> The test case is intended to be the lldb testsuite, without it lldb emits
> countless warnings about the '+' feature. I'm not aware of a
> way to trigger the problem from the clang driver since it always passes an
> explicit CPU name. As a result, I'm don't know of a way to
> test on the clang side.
>
>
See below.


> > b) CPUs are not subtarget features (or they shouldn't be), they're CPUs
> that contain features. They may 

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D18380#381031, @tra wrote:

> We need tests to demonstrate that we pick correct function when we have mix
>  of HD+H/D in the overload set.
>  Existing tests only cover resolution of {HD,HD}, {H,H} {D,D} {H,D} sets


Aha, got it.  I think adding this is simple given the existing framework -- lmk 
what you think.


http://reviews.llvm.org/D18380



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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 51366.
jlebar added a comment.

Add tests checking host+device overloading.


http://reviews.llvm.org/D18380

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/relaxed-constexpr.cu

Index: test/SemaCUDA/relaxed-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/relaxed-constexpr.cu
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-relaxed-constexpr
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-relaxed-constexpr -fcuda-is-device
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+static __device__ void f1();
+constexpr void f1();
+
+__device__ void f2();
+static constexpr void f2();
+
+// Different potential error depending on the order of declaration.
+constexpr void f3();
+static __device__ void f3();
+
+static constexpr void f4();
+__device__ void f4();
+
+// Variadic device functions are not allowed, so this is just treated as
+// host-only.
+constexpr void variadic(const char*, ...);
Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -27,22 +27,18 @@
 __host__ int dh(void) { return 2; }
 __device__ int dh(void) { return 2; }
 
-// H/HD and D/HD are not allowed
-__host__ __device__ int hdh(void) { return 5; } // expected-note {{previous definition is here}}
-__host__ int hdh(void) { return 4; } // expected-error {{redefinition of 'hdh'}}
+// H/HD and D/HD are OK
+__host__ __device__ int hdh(void) { return 5; }
+__host__ int hdh(void) { return 4; }
 
-__host__ int hhd(void) { return 4; } // expected-note {{previous definition is here}}
-__host__ __device__ int hhd(void) { return 5; } // expected-error {{redefinition of 'hhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__host__ int hhd(void) { return 4; }
+__host__ __device__ int hhd(void) { return 5; }
 
-__host__ __device__ int hdd(void) { return 7; } // expected-note {{previous definition is here}}
-__device__ int hdd(void) { return 6; } // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ int hdd(void) { return 7; }
+__device__ int hdd(void) { return 6; }
 
-__device__ int dhd(void) { return 6; } // expected-note {{previous definition is here}}
-__host__ __device__ int dhd(void) { return 7; } // expected-error {{redefinition of 'dhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__device__ int dhd(void) { return 6; }
+__host__ __device__ int dhd(void) { return 7; }
 
 // Same tests for extern "C" functions
 extern "C" __host__ int chh(void) {return 11;} // expected-note {{previous definition is here}}
@@ -52,14 +48,12 @@
 extern "C" __device__ int cdh(void) {return 10;}
 extern "C" __host__ int cdh(void) {return 11;}
 
-// H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1(void) {return 12;} // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1(void) {return 13;} // expected-error {{redefinition of 'chhd1'}}
+// H/HD and D/HD overloading is OK
+extern "C" __host__ __device__ int chhd1(void) {return 12;}
+extern "C" __host__ int chhd1(void) {return 13;}
 
-extern "C" __host__ int chhd2(void) {return 13;} // expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2(void) {return 12;} // expected-error {{redefinition of 'chhd2'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+extern "C" __host__ int chhd2(void) {return 13;}
+extern "C" __host__ __device__ int chhd2(void) {return 12;}
 
 // Helper functions to verify calling restrictions.
 __device__ int d(void) { return 8; }
@@ -71,22 +65,24 @@
 __host__ void hostf(void) {
   fp_t dp = d;
   // expected-error@-1 {{reference to __device__ function 'd' in __host__ function}}
-  // expected-note@65 {{'d' declared here}}
+  // expected-note@59 {{'d' declared here}}
   fp_t cdp = cd;
   // expected-error@-1 {{reference to __device__ function 'cd' in __host__ function}}
-  // expected-note@68 {{'cd' declared here}}
+  // expected-note@62 {{'cd' declared here}}
   fp_t hp = h;
   fp_t chp = ch;
   fp_t dhp = dh;
   fp_t cdhp = cdh;
+  fp_t hhdp = hdh;
+  fp_t dhdpp = dhd;
   gp_t gp = g;
 
   d();
   // expected-error@-1 {{no matching function for call to 'd'}}
-  // expected-note@65 {{candidate function not viable: call to __device__ function from __host__ function}}
+  // expected-note@59 {{candidate function not viable: call to __de

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Artem Belevich via cfe-commits
We need tests to demonstrate that we pick correct function when we have mix
of HD+H/D in the overload set.
Existing tests only cover resolution of {HD,HD}, {H,H} {D,D} {H,D} sets

On Tue, Mar 22, 2016 at 4:59 PM, Justin Lebar  wrote:

> jlebar added a comment.
>
> In http://reviews.llvm.org/D18380#381025, @tra wrote:
>
> > Now that H/D and HD cal all be in the same overload set, we'll also need
> additional tests in CodeGenCUDA/function-overload.cu for cases that now
> became legal.
>
>
> There are lots of tests that used to be compile errors and now aren't --
> what do you think we're missing?
>
>
> http://reviews.llvm.org/D18380
>
>
>
>


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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In http://reviews.llvm.org/D18380#381025, @tra wrote:

> Now that H/D and HD cal all be in the same overload set, we'll also need 
> additional tests in CodeGenCUDA/function-overload.cu for cases that now 
> became legal.


There are lots of tests that used to be compile errors and now aren't -- what 
do you think we're missing?


http://reviews.llvm.org/D18380



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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Artem Belevich via cfe-commits
tra added a comment.

Now that H/D and HD cal all be in the same overload set, we'll also need 
additional tests in CodeGenCUDA/function-overload.cu for cases that now became 
legal.


http://reviews.llvm.org/D18380



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


Re: [PATCH] D18275: [ASTMatchers] Add own version of VariadicFunction.

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

LG



Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:80
@@ +79,3 @@
+  ResultT operator()(ArrayRef Args) const {
+std::vector InnerArgs;
+for (const ArgT &Arg : Args)

It's unfortunate that we need to create an array of the argument pointers here, 
but it seems there's no larger common denominator of the two ways this 
functions can be called.

One nit though: SmallVector will be a better container here.


http://reviews.llvm.org/D18275



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


Re: [PATCH] D9888: [OPENMP] Driver support for OpenMP offloading

2016-03-22 Thread Eric Christopher via cfe-commits
echristo added a comment.

First I'd like to note that the code quality here is really high, most of my 
comments are higher level design decisions going with the driver and the 
implementation here rather than that.

One meta comment: offload appears to be something that could be used for CUDA 
and OpenMP (and OpenACC etc) as a term. I think we should either merge these 
concepts or pick a different name :)

Thanks for all of your work and patience here! The rest of the comments are 
inline.

-eric



Comment at: include/clang/Driver/Driver.h:210-213
@@ +209,6 @@
+  /// owns all the ToolChain objects stored in it, and will clean them up when
+  /// torn down. We use a different cache for offloading as it is possible to
+  /// have offloading toolchains with the same triple the host has, and the
+  /// implementation has to differentiate the two in order to adjust the
+  /// commands for offloading.
+  mutable llvm::StringMap OffloadToolChains;

Example?


Comment at: include/clang/Driver/Driver.h:216-217
@@ +215,4 @@
+
+  /// \brief Array of the toolchains of offloading targets in the order they
+  /// were requested by the user.
+  SmallVector OrderedOffloadingToolchains;

Any reason?


Comment at: include/clang/Driver/Driver.h:427-435
@@ -383,10 +426,11 @@
   /// action \p A.
   void BuildJobsForAction(Compilation &C,
   const Action *A,
   const ToolChain *TC,
   const char *BoundArch,
   bool AtTopLevel,
   bool MultipleArchs,
   const char *LinkingOutput,
-  InputInfo &Result) const;
+  InputInfo &Result,
+  OffloadingHostResultsTy &OffloadingHostResults) 
const;
 

This function is starting to get a little silly. Perhaps we should look into 
refactoring such that this doesn't need to be "the one function that rules them 
all". Perhaps a different ownership model for the things that are arguments 
here?


Comment at: lib/Driver/Compilation.cpp:66-67
@@ +65,4 @@
+
+// Check if there is any offloading specific translation to do.
+DerivedArgList *OffloadArgs = TC->TranslateOffloadArgs(*Entry, BoundArch);
+if (OffloadArgs) {

Hmm?


Comment at: lib/Driver/Driver.cpp:224-225
@@ +223,4 @@
+
+/// \brief Dump the job bindings for a given action.
+static void DumpJobBindings(ArrayRef TCs, StringRef 
ToolName,
+ArrayRef Inputs,

This can probably be done separately? Can you split this out and make it 
generally useful?


Comment at: lib/Driver/Driver.cpp:2045-2051
@@ -1739,11 +2044,9 @@
 // checking the backend tool, check if the tool for the CompileJob
-// has an integrated assembler.
-const ActionList *BackendInputs = &(*Inputs)[0]->getInputs();
-// Compile job may be wrapped in CudaHostAction, extract it if
-// that's the case and update CollapsedCHA if we combine phases.
-CudaHostAction *CHA = dyn_cast(*BackendInputs->begin());
-JobAction *CompileJA =
-cast(CHA ? *CHA->begin() : *BackendInputs->begin());
-assert(CompileJA && "Backend job is not preceeded by compile job.");
-const Tool *Compiler = TC->SelectTool(*CompileJA);
-if (!Compiler)
+// has an integrated assembler. However, if OpenMP offloading is required
+// the backend and compile jobs have to be kept separate and an integrated
+// assembler of the backend job will be queried instead.
+JobAction *CurJA = cast(*Inputs->begin());
+const ActionList *BackendInputs = &CurJA->getInputs();
+CudaHostAction *CHA = nullptr;
+if (!RequiresOpenMPOffloading(TC)) {
+  // Compile job may be wrapped in CudaHostAction, extract it if

Might be time to make some specialized versions of this function. This may take 
it from "ridiculously confusing" to "code no one should ever look at" :)


Comment at: lib/Driver/Tools.cpp:6032
@@ +6031,3 @@
+  // The (un)bundling command looks like this:
+  // clang-offload-bundler -type=bc
+  //   -omptargets=host-triple,device-triple1,device-triple2

Should we get the offload bundler in first so that the interface is there and 
testable? (Honest question, no particular opinion here). Though the command 
lines there will affect how this code is written. 


Comment at: test/OpenMP/target_driver.c:41-47
@@ +40,9 @@
+
+// CHK-PHASES-LIB-DAG: {{.*}}: linker, {[[L0:[0-9]+]], [[A0:[0-9]+]]}, image
+// CHK-PHASES-LIB-DAG: [[A0]]: assembler, {[[A1:[0-9]+]]}, object
+// CHK-PHASES-LIB-DAG: [[A1]]: backend, {[[A2:[0-9]+]]}, assembler
+// CHK-PHASES-LIB-DAG: [[A2]]: compiler, {[[A3:[0-9]+]]}, ir
+// CHK-PHASES-LIB-DAG: [[A3]]: preprocessor, {[[I:[0-9]+]]}, cpp-output
+// CHK-PH

Re: [Diffusion] rL244063: Add missing atomic libcall support.

2016-03-22 Thread Richard Smith via cfe-commits
rsmith resigned from this audit.

Users:
  jyknight (Author, Auditor)
  3.7-release (Auditor)
  cfe-commits (Auditor)
  tstellarAMD (Auditor)
  compnerd (Auditor)
  majnemer (Auditor)
  rsmith (Auditor)
  dim (Auditor)

http://reviews.llvm.org/rL244063



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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 51357.
jlebar added a comment.

Actually run the tests, and fix the CUDA overloading test.


http://reviews.llvm.org/D18380

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/relaxed-constexpr.cu

Index: test/SemaCUDA/relaxed-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/relaxed-constexpr.cu
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-relaxed-constexpr
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-relaxed-constexpr -fcuda-is-device
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+static __device__ void f1();
+constexpr void f1();
+
+__device__ void f2();
+static constexpr void f2();
+
+// Different potential error depending on the order of declaration.
+constexpr void f3();
+static __device__ void f3();
+
+static constexpr void f4();
+__device__ void f4();
+
+// Variadic device functions are not allowed, so this is just treated as
+// host-only.
+constexpr void variadic(const char*, ...);
Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -27,22 +27,18 @@
 __host__ int dh(void) { return 2; }
 __device__ int dh(void) { return 2; }
 
-// H/HD and D/HD are not allowed
-__host__ __device__ int hdh(void) { return 5; } // expected-note {{previous definition is here}}
-__host__ int hdh(void) { return 4; } // expected-error {{redefinition of 'hdh'}}
+// H/HD and D/HD are OK
+__host__ __device__ int hdh(void) { return 5; }
+__host__ int hdh(void) { return 4; }
 
-__host__ int hhd(void) { return 4; } // expected-note {{previous definition is here}}
-__host__ __device__ int hhd(void) { return 5; } // expected-error {{redefinition of 'hhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__host__ int hhd(void) { return 4; }
+__host__ __device__ int hhd(void) { return 5; }
 
-__host__ __device__ int hdd(void) { return 7; } // expected-note {{previous definition is here}}
-__device__ int hdd(void) { return 6; } // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ int hdd(void) { return 7; }
+__device__ int hdd(void) { return 6; }
 
-__device__ int dhd(void) { return 6; } // expected-note {{previous definition is here}}
-__host__ __device__ int dhd(void) { return 7; } // expected-error {{redefinition of 'dhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__device__ int dhd(void) { return 6; }
+__host__ __device__ int dhd(void) { return 7; }
 
 // Same tests for extern "C" functions
 extern "C" __host__ int chh(void) {return 11;} // expected-note {{previous definition is here}}
@@ -52,14 +48,12 @@
 extern "C" __device__ int cdh(void) {return 10;}
 extern "C" __host__ int cdh(void) {return 11;}
 
-// H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1(void) {return 12;} // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1(void) {return 13;} // expected-error {{redefinition of 'chhd1'}}
+// H/HD and D/HD overloading is OK
+extern "C" __host__ __device__ int chhd1(void) {return 12;}
+extern "C" __host__ int chhd1(void) {return 13;}
 
-extern "C" __host__ int chhd2(void) {return 13;} // expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2(void) {return 12;} // expected-error {{redefinition of 'chhd2'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+extern "C" __host__ int chhd2(void) {return 13;}
+extern "C" __host__ __device__ int chhd2(void) {return 12;}
 
 // Helper functions to verify calling restrictions.
 __device__ int d(void) { return 8; }
@@ -71,22 +65,22 @@
 __host__ void hostf(void) {
   fp_t dp = d;
   // expected-error@-1 {{reference to __device__ function 'd' in __host__ function}}
-  // expected-note@65 {{'d' declared here}}
+  // expected-note@59 {{'d' declared here}}
   fp_t cdp = cd;
   // expected-error@-1 {{reference to __device__ function 'cd' in __host__ function}}
-  // expected-note@68 {{'cd' declared here}}
+  // expected-note@62 {{'cd' declared here}}
   fp_t hp = h;
   fp_t chp = ch;
   fp_t dhp = dh;
   fp_t cdhp = cdh;
   gp_t gp = g;
 
   d();
   // expected-error@-1 {{no matching function for call to 'd'}}
-  // expected-note@65 {{candidate function not viable: call to __device__ function from __host__ function}}
+  // expected-note@59 {{candidate function not viable: call to __device__ function from __hos

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Richard Barton via cfe-commits
richard.barton.arm added a comment.

Thanks for the help Eric. I'm just running a new patch now will put the new 
patch up when I get back in to office tomorrow.


http://reviews.llvm.org/D18347



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


Re: [PATCH] D18373: [CUDA] Don't allow templated variadic functions.

2016-03-22 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264106: [CUDA] Don't allow templated variadic functions. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D18373?vs=51332&id=51354#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18373

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCUDA/vararg.cu

Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -8341,6 +8341,28 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not 
allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
@@ -8390,28 +8412,6 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA) {
-IdentifierInfo *II = NewFD->getIdentifier();
-if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
-NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), diag::err_config_scalar_return);
-
-  Context.setcudaConfigureCallDecl(NewFD);
-}
-
-// Variadic functions, other than a *declaration* of printf, are not 
allowed
-// in device-side CUDA code, unless someone passed
-// -fcuda-allow-variadic-functions.
-if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
-(NewFD->hasAttr() ||
- NewFD->hasAttr()) &&
-!(II && II->isStr("printf") && NewFD->isExternC() &&
-  !D.isFunctionDefinition())) {
-  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
-}
-  }
-
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.
Index: cfe/trunk/test/SemaCUDA/vararg.cu
===
--- cfe/trunk/test/SemaCUDA/vararg.cu
+++ cfe/trunk/test/SemaCUDA/vararg.cu
@@ -35,6 +35,12 @@
 // expected-error@-2 {{CUDA device code does not support variadic functions}}
 #endif
 
+template 
+__device__ void vararg(T t, ...) {}
+#ifdef EXPECT_VARARG_ERR
+// expected-error@-2 {{CUDA device code does not support variadic functions}}
+#endif
+
 extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
 
 // Definition of printf not allowed.


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -8341,6 +8341,28 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
@@ -8390,28 +8412,6 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA) {
-IdentifierInfo *II = NewFD->getIdentifier();
-if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
-NewFD->getDeclCon

r264106 - [CUDA] Don't allow templated variadic functions.

2016-03-22 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Mar 22 17:06:19 2016
New Revision: 264106

URL: http://llvm.org/viewvc/llvm-project?rev=264106&view=rev
Log:
[CUDA] Don't allow templated variadic functions.

Reviewers: tra

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCUDA/vararg.cu

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=264106&r1=264105&r2=264106&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Mar 22 17:06:19 2016
@@ -8341,6 +8341,28 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not 
allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
@@ -8390,28 +8412,6 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA) {
-IdentifierInfo *II = NewFD->getIdentifier();
-if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
-NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), diag::err_config_scalar_return);
-
-  Context.setcudaConfigureCallDecl(NewFD);
-}
-
-// Variadic functions, other than a *declaration* of printf, are not 
allowed
-// in device-side CUDA code, unless someone passed
-// -fcuda-allow-variadic-functions.
-if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
-(NewFD->hasAttr() ||
- NewFD->hasAttr()) &&
-!(II && II->isStr("printf") && NewFD->isExternC() &&
-  !D.isFunctionDefinition())) {
-  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
-}
-  }
-
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.

Modified: cfe/trunk/test/SemaCUDA/vararg.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/vararg.cu?rev=264106&r1=264105&r2=264106&view=diff
==
--- cfe/trunk/test/SemaCUDA/vararg.cu (original)
+++ cfe/trunk/test/SemaCUDA/vararg.cu Tue Mar 22 17:06:19 2016
@@ -35,6 +35,12 @@ __device__ void vararg(const char* x, ..
 // expected-error@-2 {{CUDA device code does not support variadic functions}}
 #endif
 
+template 
+__device__ void vararg(T t, ...) {}
+#ifdef EXPECT_VARARG_ERR
+// expected-error@-2 {{CUDA device code does not support variadic functions}}
+#endif
+
 extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
 
 // Definition of printf not allowed.


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


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

2016-03-22 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/CGCall.cpp:142-143
@@ -132,1 +141,4 @@
+  appendParameterTypes(CGT, prefix, FTP, FD, &SynthesizedParams);
+  RequiredArgs Required =
+  RequiredArgs::forPrototypePlus(FTP, StartParams + SynthesizedParams);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();

Would it make sense for `RequiredArgs::forPrototypePlus` to do this 
computation? Are the other callers of that function also getting the wrong 
number of required arguments in this case?


http://reviews.llvm.org/D17462



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


[PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: rsmith, rnk, cfe-commits.

All constexpr functions are implicitly host+device, except for variadic
functions, which are not allowed on the device side.

As part of this change, we now allow you to overload a host+device
function with another function of the same signature but different
attributes.

A side-effect is that we'd previously accept a decl that had __host__
__device__ plus an unannotated def -- there was no ambiguity, because
you couldn't override the decl with different attrs, but now there is
ambiguity.  This causes us to reject some programs we previously
accepted.

http://reviews.llvm.org/D18380

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/relaxed-constexpr.cu

Index: test/SemaCUDA/relaxed-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/relaxed-constexpr.cu
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-target-overloads -fcuda-is-device
+
+// expected-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+static __device__ void f1();
+constexpr void f1();
+
+__device__ void f2();
+static constexpr void f2();
+
+// Different potential error depending on the order of declaration.
+constexpr void f3();
+static __device__ void f3();
+
+static constexpr void f4();
+__device__ void f4();
+
+// Variadic device functions are not allowed, so this is just treated as
+// host-only.
+constexpr void variadic(const char*, ...);
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1126,13 +1126,10 @@
 
 assert((OldTarget != CFT_InvalidTarget) && "Unexpected invalid target.");
 
-// Don't allow mixing of HD with other kinds. This guarantees that
-// we have only one viable function with this signature on any
-// side of CUDA compilation .
-// __global__ functions can't be overloaded based on attribute
-// difference because, like HD, they also exist on both sides.
-if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice) ||
-(NewTarget == CFT_Global) || (OldTarget == CFT_Global))
+// Don't allow __global__ functions to be overloaded with other functions,
+// based solely on their CUDA attributes. This guarantees that we have only
+// one viable function with this signature on any side of CUDA compilation.
+if ((NewTarget == CFT_Global) || (OldTarget == CFT_Global))
   return false;
 
 // Allow overloading of functions with same signature, but
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8006,6 +8006,15 @@
   // Handle attributes.
   ProcessDeclAttributes(S, NewFD, D);
 
+  // With -fcuda-relaxed-constexpr, constexpr functions are treated as
+  // implicitly __host__ __device__.  Device-side variadic functions are not
+  // allowed, so we just treat those as host-only.
+  if (getLangOpts().CUDA && NewFD->isConstexpr() && !NewFD->isVariadic() &&
+  getLangOpts().CUDARelaxedConstexpr) {
+NewFD->addAttr(CUDAHostAttr::CreateImplicit(Context));
+NewFD->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+  }
+
   if (getLangOpts().OpenCL) {
 // OpenCL v1.1 s6.5: Using an address space qualifier in a function return
 // type declaration will generate a compilation error.
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1569,6 +1569,9 @@
   if (Args.hasArg(OPT_fcuda_allow_variadic_functions))
 Opts.CUDAAllowVariadicFunctions = 1;
 
+  if (Args.hasArg(OPT_fcuda_relaxed_constexpr))
+Opts.CUDARelaxedConstexpr = 1;
+
   if (Opts.ObjC1) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3594,6 +3594,7 @@
 CmdArgs.push_back(Args.MakeArgString(AuxToolChain->getTriple().str()));
 CmdArgs.push_back("-fcuda-target-overloads");
 CmdArgs.push_back("-fcuda-disable-target-call-checks");
+CmdArgs.push_back("-fcuda-relaxed-constexpr");
   }
 
   if (Triple.isOSWindows() && (Triple.getArch() == llvm::Triple::arm ||
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -699,6 +699,8 @@
   HelpText<"Enable function ov

Re: [PATCH] D18328: [CUDA] Add option to mark most functions inside as host+device.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar abandoned this revision.
jlebar marked 7 inline comments as done.
jlebar added a comment.

Okay, after much discussion, we've decided to go with --relaxed-constexpr 
instead of this.  I have a patch for that which seems to mostly work, will send 
it out soon.


http://reviews.llvm.org/D18328



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


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-22 Thread JF Bastien via cfe-commits
jfb updated this revision to Diff 51346.
jfb added a comment.

- Define __cpp_lib_atomic_is_always_lock_free in libc++


http://reviews.llvm.org/D17951

Files:
  include/atomic
  test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp

Index: test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
===
--- /dev/null
+++ test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -0,0 +1,97 @@
+//===--===//
+//
+// 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: libcpp-has-no-threads, c++98, c++03, c++11, c++14
+
+// 
+
+// static constexpr bool is_always_lock_free;
+
+#include 
+#include 
+
+template  void checkAlwaysLockFree() {
+  if (std::atomic::is_always_lock_free)
+assert(std::atomic().is_lock_free());
+}
+
+int main()
+{
+// structs and unions can't be defined in the template invocation.
+// Work around this with a typedef.
+#define CHECK_ALWAYS_LOCK_FREE(T)  \
+  do { \
+typedef T type;\
+checkAlwaysLockFree();   \
+  } while (0)
+
+CHECK_ALWAYS_LOCK_FREE(bool);
+CHECK_ALWAYS_LOCK_FREE(char);
+CHECK_ALWAYS_LOCK_FREE(signed char);
+CHECK_ALWAYS_LOCK_FREE(unsigned char);
+CHECK_ALWAYS_LOCK_FREE(char16_t);
+CHECK_ALWAYS_LOCK_FREE(char32_t);
+CHECK_ALWAYS_LOCK_FREE(wchar_t);
+CHECK_ALWAYS_LOCK_FREE(short);
+CHECK_ALWAYS_LOCK_FREE(unsigned short);
+CHECK_ALWAYS_LOCK_FREE(int);
+CHECK_ALWAYS_LOCK_FREE(unsigned int);
+CHECK_ALWAYS_LOCK_FREE(long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long);
+CHECK_ALWAYS_LOCK_FREE(long long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long long);
+CHECK_ALWAYS_LOCK_FREE(std::nullptr_t);
+CHECK_ALWAYS_LOCK_FREE(void*);
+CHECK_ALWAYS_LOCK_FREE(float);
+CHECK_ALWAYS_LOCK_FREE(double);
+CHECK_ALWAYS_LOCK_FREE(long double);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(1 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(2 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(4 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(16 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(32 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(1 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(2 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(4 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(16 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(32 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(1 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(2 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(4 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(16 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(32 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(struct{});
+CHECK_ALWAYS_LOCK_FREE(struct{ int i; });
+CHECK_ALWAYS_LOCK_FREE(struct{ int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[4]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[8]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[16]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ char c; /* padding */ long long int i; });
+CHECK_ALWAYS_LOCK_FREE(union{ int i; float f; });
+
+// C macro and static constexpr must be consistent.
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_BOOL_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR16_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR32_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_WCHAR_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_SHORT_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_SHORT_LOCK_FREE));
+static_asser

Re: [PATCH] D18289: Attach profile summary information to module

2016-03-22 Thread Easwaran Raman via cfe-commits
eraman marked 2 inline comments as done.


Comment at: lib/CodeGen/CodeGenModule.cpp:398-399
@@ -397,3 +397,4 @@
   if (PGOReader) {
 getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
+getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())

The previous line? Yes.


Comment at: test/Profile/profile-summary.c:6
@@ +5,3 @@
+//
+int begin(int i) {
+  if (i)

I didn't see David's comment and your subseqquent response. I have changed the 
test to only check for the presence of Profilesummary and DetailedSummary 
fields. 


http://reviews.llvm.org/D18289



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


Re: [PATCH] D18289: Attach profile summary information to module

2016-03-22 Thread Easwaran Raman via cfe-commits
eraman updated this revision to Diff 51342.
eraman added a comment.

Address Vedant's comments


http://reviews.llvm.org/D18289

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/Profile/Inputs/profile-summary.proftext
  test/Profile/profile-summary.c

Index: test/Profile/profile-summary.c
===
--- /dev/null
+++ test/Profile/profile-summary.c
@@ -0,0 +1,25 @@
+// Test that maximum function counts are set correctly.
+
+// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o 
%t.profdata
+// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S 
-fprofile-instr-use=%t.profdata | FileCheck %s
+//
+int begin(int i) {
+  if (i)
+return 0;
+  return 1;
+}
+
+int end(int i) {
+  if (i)
+return 0;
+  return 1;
+}
+
+int main(int argc, const char *argv[]) {
+  begin(0);
+  end(1);
+  end(1);
+  return 0;
+}
+// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
+// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
Index: test/Profile/Inputs/profile-summary.proftext
===
--- /dev/null
+++ test/Profile/Inputs/profile-summary.proftext
@@ -0,0 +1,26 @@
+begin
+# Func Hash:
+10
+# Num Counters:
+2
+# Counter Values:
+1
+0
+
+main
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+1
+
+end
+# Func Hash:
+10
+# Num Counters:
+2
+# Counter Values:
+2
+2
+
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -396,6 +396,7 @@
   AddGlobalCtor(OpenMPRegistrationFunction, 0);
   if (PGOReader) {
 getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
+getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())
   PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);
   }


Index: test/Profile/profile-summary.c
===
--- /dev/null
+++ test/Profile/profile-summary.c
@@ -0,0 +1,25 @@
+// Test that maximum function counts are set correctly.
+
+// RUN: llvm-profdata merge %S/Inputs/max-function-count.proftext -o %t.profdata
+// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s
+//
+int begin(int i) {
+  if (i)
+return 0;
+  return 1;
+}
+
+int end(int i) {
+  if (i)
+return 0;
+  return 1;
+}
+
+int main(int argc, const char *argv[]) {
+  begin(0);
+  end(1);
+  end(1);
+  return 0;
+}
+// CHECK: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
+// CHECK: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
Index: test/Profile/Inputs/profile-summary.proftext
===
--- /dev/null
+++ test/Profile/Inputs/profile-summary.proftext
@@ -0,0 +1,26 @@
+begin
+# Func Hash:
+10
+# Num Counters:
+2
+# Counter Values:
+1
+0
+
+main
+# Func Hash:
+0
+# Num Counters:
+1
+# Counter Values:
+1
+
+end
+# Func Hash:
+10
+# Num Counters:
+2
+# Counter Values:
+2
+2
+
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -396,6 +396,7 @@
   AddGlobalCtor(OpenMPRegistrationFunction, 0);
   if (PGOReader) {
 getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
+getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())
   PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Re-building clang now so I can test the most recent changes.



Comment at: include/atomic:850
@@ +849,3 @@
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = 
__atomic_always_lock_free(sizeof(__a_), 0);
+#endif

I think this needs a definition.



http://reviews.llvm.org/D17951



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


Re: [PATCH] D18289: Attach profile summary information to module

2016-03-22 Thread Vedant Kumar via cfe-commits
vsk added inline comments.


Comment at: test/Profile/profile-summary.c:5
@@ +4,3 @@
+// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S 
-fprofile-instr-use=%t.profdata | FileCheck %s
+//
+int begin(int i) {

davidxl wrote:
> vsk wrote:
> > ISTM that a lot of the lines in this file do not contribute additional 
> > coverage of the changes introduced by your patch.
> > 
> > We already have tests which show that the summary code works 
> > (`general.proftext`). I think we just need 1 empty function with 1 counter 
> > in this file. We don't need to check that the entire detailed summary 
> > appears in the metadata, just one cutoff entry should suffice.
> That test is actually not as good for testing summary computation as this 
> one. Perhaps we can simplify this test and move this test (removing the clang 
> dump part) into llvm-profdata dir.
Makes sense to me.


http://reviews.llvm.org/D18289



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


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-22 Thread JF Bastien via cfe-commits
jfb added a comment.

As discussed in now-abandoned http://reviews.llvm.org/D17950 I'll implement 
everything in libc++. I just have to move the feature test macro to libc++.


http://reviews.llvm.org/D17951



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


Re: [PATCH] D18289: Attach profile summary information to module

2016-03-22 Thread David Li via cfe-commits
davidxl added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:398
@@ -397,2 +397,3 @@
   if (PGOReader) {
 getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
+auto *SummaryMD = PGOReader->getSummary().getMD(getModule().getContext());

This line will be removed later once the client code has been updated right?


Comment at: lib/CodeGen/CodeGenModule.cpp:399
@@ -398,1 +398,3 @@
 getModule().setMaximumFunctionCount(PGOReader->getMaximumFunctionCount());
+auto *SummaryMD = PGOReader->getSummary().getMD(getModule().getContext());
+// Make sure returned metadata is non-null;

vsk wrote:
> `getModule().getContext()` -> `VMContext`?
or Module &M = getModule(); 
M is also referenced in previous line


Comment at: test/Profile/profile-summary.c:5
@@ +4,3 @@
+// RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S 
-fprofile-instr-use=%t.profdata | FileCheck %s
+//
+int begin(int i) {

vsk wrote:
> ISTM that a lot of the lines in this file do not contribute additional 
> coverage of the changes introduced by your patch.
> 
> We already have tests which show that the summary code works 
> (`general.proftext`). I think we just need 1 empty function with 1 counter in 
> this file. We don't need to check that the entire detailed summary appears in 
> the metadata, just one cutoff entry should suffice.
That test is actually not as good for testing summary computation as this one. 
Perhaps we can simplify this test and move this test (removing the clang dump 
part) into llvm-profdata dir.


http://reviews.llvm.org/D18289



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


Re: [PATCH] D17950: Implement is_always_lock_free

2016-03-22 Thread JF Bastien via cfe-commits
jfb abandoned this revision.


Comment at: lib/Frontend/InitPreprocessor.cpp:465
@@ +464,3 @@
+  if (LangOpts.CPlusPlus1z) {
+Builder.defineMacro("__cpp_lib_atomic_is_always_lock_free", "201603");
+  }

jfb wrote:
> rsmith wrote:
> > This should be defined by the relevant library header, not by the compiler, 
> > to indicate the library actually provides the new symbol.
> Ah yes, makes sense. Looks like libc++ doesn't do this for other library 
> features yet so I'll add it there.
> 
> This patch would then just fix test/Lexer/cxx-features.cpp for C++17 support 
> and have nothing to do with `is_always_lock_free`. It's probably better if I 
> close this patch and open a new one in that case.
On the mailing list @rsmith said:

> Feel free to commit that portion of the change.

Done in: http://reviews.llvm.org/rL264098

I'll abandon this change since it doesn't contain anything useful anymore (all 
in libc++ instead).

Thanks for the reviews!


http://reviews.llvm.org/D17950



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

Yes, you should just stick with your post-processing pass or something like it.

The design of linkonce_odr linkage is that such definitions will only be 
emitted when they are actually used.  Even with this attribute, a translation 
unit that consists solely of:

  __attribute__((linkonce_odr_linkage)) void foo() {}

would naturally be emitted as an empty object file.  It is possible that Clang 
as patched will not do this, because you haven't updated the places that 
implement lazy code emission to be aware of the new attribute.  However, that 
strikes me as a bug, not a guaranteed aspect of the semantics of the attribute. 
 Furthermore, LLVM module-level optimizations could also theoretically drop the 
function body at any time as soon as they see that it is unused.

It seems to me that the right solution is for the definitions to remain strong 
and then only be selectively brought in when necessary to satisfy dependencies. 
 That could be done with a post-pass that makes the definitions linkonce_odr, 
or perhaps with an IR linker that simulates static-archive behavior.


http://reviews.llvm.org/D18095



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


r264098 - Update cxx-features test to C++1z

2016-03-22 Thread JF Bastien via cfe-commits
Author: jfb
Date: Tue Mar 22 16:12:48 2016
New Revision: 264098

URL: http://llvm.org/viewvc/llvm-project?rev=264098&view=rev
Log:
Update cxx-features test to C++1z

Forked from the following patch:
  http://reviews.llvm.org/D17950

Modified:
cfe/trunk/test/Lexer/cxx-features.cpp

Modified: cfe/trunk/test/Lexer/cxx-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=264098&r1=264097&r2=264098&view=diff
==
--- cfe/trunk/test/Lexer/cxx-features.cpp (original)
+++ cfe/trunk/test/Lexer/cxx-features.cpp Tue Mar 22 16:12:48 2016
@@ -1,133 +1,137 @@
 // RUN: %clang_cc1 -std=c++98 -verify %s
 // RUN: %clang_cc1 -std=c++11 -verify %s
 // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s
-// RUN: %clang_cc1 -std=c++1y -fsized-deallocation -fconcepts-ts 
-DCONCEPTS_TS=1 -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s
+// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s
+// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts 
-DCONCEPTS_TS=1 -verify %s
 // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s
 
 // expected-no-diagnostics
 
 // FIXME using `defined` in a macro has undefined behavior.
 #if __cplusplus < 201103L
-#define check(macro, cxx98, cxx11, cxx1y) cxx98 == 0 ? defined(__cpp_##macro) 
: __cpp_##macro != cxx98
-#elif __cplusplus < 201304L
-#define check(macro, cxx98, cxx11, cxx1y) cxx11 == 0 ? defined(__cpp_##macro) 
: __cpp_##macro != cxx11
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx98
+#elif __cplusplus < 201402L
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx11
+#elif __cplusplus < 201406L
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx14
 #else
-#define check(macro, cxx98, cxx11, cxx1y) cxx1y == 0 ? defined(__cpp_##macro) 
: __cpp_##macro != cxx1y
+#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx1z
 #endif
 
-#if check(binary_literals, 0, 0, 201304)
+#if check(binary_literals, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_binary_literals"
 #endif
 
-#if check(digit_separators, 0, 0, 201309)
+#if check(digit_separators, 0, 0, 201309, 201309)
 #error "wrong value for __cpp_digit_separators"
 #endif
 
-#if check(init_captures, 0, 0, 201304)
+#if check(init_captures, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_init_captures"
 #endif
 
-#if check(generic_lambdas, 0, 0, 201304)
+#if check(generic_lambdas, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_generic_lambdas"
 #endif
 
-#if check(sized_deallocation, 0, 0, 201309)
+#if check(sized_deallocation, 0, 0, 201309, 201309)
 #error "wrong value for __cpp_sized_deallocation"
 #endif
 
-#if check(constexpr, 0, 200704, 201304)
+#if check(constexpr, 0, 200704, 201304, 201304)
 #error "wrong value for __cpp_constexpr"
 #endif
 
-#if check(decltype_auto, 0, 0, 201304)
+#if check(decltype_auto, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_decltype_auto"
 #endif
 
-#if check(return_type_deduction, 0, 0, 201304)
+#if check(return_type_deduction, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_return_type_deduction"
 #endif
 
-#if check(runtime_arrays, 0, 0, 0)
+#if check(runtime_arrays, 0, 0, 0, 0)
 #error "wrong value for __cpp_runtime_arrays"
 #endif
 
-#if check(aggregate_nsdmi, 0, 0, 201304)
+#if check(aggregate_nsdmi, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_aggregate_nsdmi"
 #endif
 
-#if check(variable_templates, 0, 0, 201304)
+#if check(variable_templates, 0, 0, 201304, 201304)
 #error "wrong value for __cpp_variable_templates"
 #endif
 
-#if check(unicode_characters, 0, 200704, 200704)
+#if check(unicode_characters, 0, 200704, 200704, 200704)
 #error "wrong value for __cpp_unicode_characters"
 #endif
 
-#if check(raw_strings, 0, 200710, 200710)
+#if check(raw_strings, 0, 200710, 200710, 200710)
 #error "wrong value for __cpp_raw_strings"
 #endif
 
-#if check(unicode_literals, 0, 200710, 200710)
+#if check(unicode_literals, 0, 200710, 200710, 200710)
 #error "wrong value for __cpp_unicode_literals"
 #endif
 
-#if check(user_defined_literals, 0, 200809, 200809)
+#if check(user_defined_literals, 0, 200809, 200809, 200809)
 #error "wrong value for __cpp_user_defined_literals"
 #endif
 
-#if check(lambdas, 0, 200907, 200907)
+#if check(lambdas, 0, 200907, 200907, 200907)
 #error "wrong value for __cpp_lambdas"
 #endif
 
-#if check(range_based_for, 0, 200907, 200907)
+#if check(range_based_for, 0, 200907, 200907, 200907)
 #error "wrong value for __cpp_range_based_for"
 #endif
 
-#if check(static_assert, 0, 200410, 200410)
+#if check(static_assert, 0, 200410, 200410, 200410)
 #error "wrong value for __cpp_static_assert"
 #endif
 
-#if check(decltype, 0, 200707, 200707)
+#if check(decltype, 

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

And looking at the current state of the single-threaded test suite this isn't 
the only test that needs this fix applied.

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-singlethreaded-x86_64-linux-debian/builds/869


http://reviews.llvm.org/D18347



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


r264092 - D18325: Added mm_malloc module export.

2016-03-22 Thread John Thompson via cfe-commits
Author: jtsoftware
Date: Tue Mar 22 15:57:51 2016
New Revision: 264092

URL: http://llvm.org/viewvc/llvm-project?rev=264092&view=rev
Log:
D18325: Added mm_malloc module export.

Modified:
cfe/trunk/lib/Headers/module.modulemap
cfe/trunk/test/Headers/xmmintrin.c

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=264092&r1=264091&r2=264092&view=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Tue Mar 22 15:57:51 2016
@@ -44,6 +44,7 @@ module _Builtin_intrinsics [system] [ext
 }
 
 explicit module sse {
+  export mm_malloc
   export mmx
   export sse2 // note: for hackish  dependency
   header "xmmintrin.h"

Modified: cfe/trunk/test/Headers/xmmintrin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/xmmintrin.c?rev=264092&r1=264091&r2=264092&view=diff
==
--- cfe/trunk/test/Headers/xmmintrin.c (original)
+++ cfe/trunk/test/Headers/xmmintrin.c Tue Mar 22 15:57:51 2016
@@ -23,3 +23,7 @@ __m128 test_xmmintrin_provides_emmintrin
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif


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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I think the correct fix is "// UNSUPPORTED: libcpp-has-no-threads"


http://reviews.llvm.org/D18347



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.

Hi John,

The problem we are trying to solve here is linking a LLVM bitcode program 
(OpenCL kernel in this specific case) with an LLVM bitcode library (OpenCL 
builtin library) and having the resulting LLVM bitcode module contain only the 
program code and the library functions that it uses.

The solution for this problem that we are using for libclc is to compile the 
OpenCL library to bitcode and then run a post-processing pass: 
https://github.com/llvm-mirror/libclc/blob/master/utils/prepare-builtins.cpp on 
the bitcode to set the linkage of the library functions to linkonce_odr.  Doing 
this gives us what we are looking for, because the LLVM IR linker will drop all 
the linkonce_odr definitions that aren't used when it links the bitcode library 
in with the program.

The rationale for this specific patch was that if we could apply the 
linkonce_odr attribute to the functions at the source level, then we could 
avoid having to use the LLVM IR post-processing pass, which seems like a much 
cleaner and more portable solution.

Based on this comment:

> You could also get this effect by somehow making the definitions linkonce_odr 
> when they're linked in from the library.


It seems like you are suggesting that a post-processing pass like we have would 
be better, but I'm not sure if you had the complete picture of what we were 
trying to do.  GIven the problem I've described above is a post-processing pass 
the way to go or do you have some other suggestion?

Thanks,
Tom


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Richard Barton via cfe-commits
richard.barton.arm added a comment.

Hi Eric

Sorry for the delay - I originally detected the failure while not running in a 
totally clean environment with clean sources, but I can reproduce on clean code.

I can reproduce by building with clean clang and libcxx sources:
cmake -DLLVM_PATH=/work/ricbar01/llvm_oss/ -DLIBCXX_CXX_ABI=libcxxabi 
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi_oss/include 
-DCMAKE_C_COMPILER=/work/ricbar01/llvm_oss/build/bin/clang 
-DCMAKE_CXX_COMPILER=/work/ricbar01/llvm_oss/build/bin/clang++ 
-DLIBCXX_ENABLE_THREADS=OFF -DLIBCXX_ENABLE_SHARED=OFF 
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF ..

I get errors like:
/work/ricbar01/libcxx_oss/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp:21:8:
 error: no type named 'mutex' in namespace 'std'

  std::mutex m;

From eyeballing the include/mutex it looks like the mutex class is #ifdeffec 
out when _LIBCPP_HAS_NO_THREADS is unset.


http://reviews.llvm.org/D18347



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


Re: [PATCH] D18170: [CUDA][OpenMP] Create generic offload toolchains

2016-03-22 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: include/clang/Driver/Action.h:79
@@ +78,3 @@
+OFFLOAD_None = 0x00,
+OFFLOAD_CUDA = 0x01,
+  };

Nit: All-caps CUDA looks weird here. _Cuda may be better choice.
If you can shorten the prefix that would be nice, too. OK_ is already taken, 
though. OFK_?


Comment at: include/clang/Driver/Compilation.h:42
@@ +41,3 @@
+  /// The tool chain of the offload host.
+  const ToolChain *OffloadHostToolChain;
+

This could be generalized into yet another toolchain kind and handled the same 
way as offload toolchains.


Comment at: include/clang/Driver/Compilation.h:46
@@ +45,3 @@
+  /// the host has to support.
+  unsigned OffloadHostKinds;
+

This could use a more descriptive name. ActiveOffloadMask?


Comment at: include/clang/Driver/Compilation.h:51
@@ -43,1 +50,3 @@
+  typedef std::pair OffloadToolChainTy;
+  SmallVector OrderedOffloadingToolchains;
 

Using std::multimap here would probably make 
specific_offload_kind_iterator unnecessary and would simplify toolchain lookup.


Comment at: lib/Driver/Driver.cpp:406
@@ +405,3 @@
+  // We need to generate a CUDA toolchain if any of the inputs has a CUDA type.
+  for (auto &I : Inputs)
+// Have we founs a CUDA file? If so generate the toolchain.

llvm::any_of() could be useful here:


```
if (llvm::any_of(Inputs, [](auto &I) { return types::isCuda(I.first)})) {
  ...addOffloadDeviceToolchain();
}
```


Comment at: lib/Driver/Driver.cpp:419
@@ +418,3 @@
+  //
+  // Add support for other offloading programming models here.
+  //

TODO:


Comment at: lib/Driver/Driver.cpp:543
@@ -520,1 +542,3 @@
 
+  // Get the toolchains for the offloading devices, if any.
+  CreateOffloadingDeviceToolChains(*C, Inputs);

Get is somewhat misplaced here. Perhaps populate or initialize would work 
better.


http://reviews.llvm.org/D18170



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

You could also get this effect by somehow making the definitions linkonce_odr 
when they're linked in from the library.  Or you could simply use the classic 
static-archive technique of putting each symbol in its own object file and 
linking against the whole thing as a static archive (.a), which only pulls in 
object files that provide symbols that are used.

Regardless, linkonce won't get the effect you want, because (1) linkonce 
definitions can be dropped at any time when they're not used, so they won't be 
emitted in the library if they're not used there, and (2) the overriding 
definitions will be strong.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

Does your linker not supported dead-code stripping?


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Sorry my previous example may have caused some confusion.

Previously I said I wanted to override function definitions. However the only 
reason we want to add this attribute is so that unused functions will be 
dropped by the linker.


http://reviews.llvm.org/D18095



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


[PATCH] D18373: [CUDA] Don't allow templated variadic functions.

2016-03-22 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

http://reviews.llvm.org/D18373

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/vararg.cu

Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -35,6 +35,12 @@
 // expected-error@-2 {{CUDA device code does not support variadic functions}}
 #endif
 
+template 
+__device__ void vararg(T t, ...) {}
+#ifdef EXPECT_VARARG_ERR
+// expected-error@-2 {{CUDA device code does not support variadic functions}}
+#endif
+
 extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
 
 // Definition of printf not allowed.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8341,6 +8341,28 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not 
allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
@@ -8390,28 +8412,6 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA) {
-IdentifierInfo *II = NewFD->getIdentifier();
-if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
-NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), diag::err_config_scalar_return);
-
-  Context.setcudaConfigureCallDecl(NewFD);
-}
-
-// Variadic functions, other than a *declaration* of printf, are not 
allowed
-// in device-side CUDA code, unless someone passed
-// -fcuda-allow-variadic-functions.
-if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
-(NewFD->hasAttr() ||
- NewFD->hasAttr()) &&
-!(II && II->isStr("printf") && NewFD->isExternC() &&
-  !D.isFunctionDefinition())) {
-  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
-}
-  }
-
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.


Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -35,6 +35,12 @@
 // expected-error@-2 {{CUDA device code does not support variadic functions}}
 #endif
 
+template 
+__device__ void vararg(T t, ...) {}
+#ifdef EXPECT_VARARG_ERR
+// expected-error@-2 {{CUDA device code does not support variadic functions}}
+#endif
+
 extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
 
 // Definition of printf not allowed.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8341,6 +8341,28 @@
 isExplicitSpecialization || isFunctionTemplateSpecialization);
   }
 
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not allowed
+// in device-side CUDA code, unless someone passed
+// -fcuda-allow-variadic-functions.
+if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
+(NewFD->hasAttr() ||
+ NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
+
   if (getLangOpts().CPlusPlus) {
 if (FunctionTemplate) {
   if (NewFD->isI

Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 51326.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Add -x cl to the test when compiling it for spir target.


http://reviews.llvm.org/D17552

Files:
  lib/CodeGen/BackendUtil.cpp
  test/Frontend/backend-option.c

Index: test/Frontend/backend-option.c
===
--- /dev/null
+++ test/Frontend/backend-option.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -x cl -emit-llvm -backend-option -time-passes -o - 
-triple spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report
+
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -97,6 +97,9 @@
 return PerFunctionPasses;
   }
 
+  /// Set LLVM command line options passed through -backend-option.
+  void setCommandLineOpts();
+
   void CreatePasses(FunctionInfoIndex *FunctionIndex);
 
   /// Generates the TargetMachine.
@@ -444,6 +447,24 @@
   PMBuilder.populateModulePassManager(*MPM);
 }
 
+void EmitAssemblyHelper::setCommandLineOpts() {
+  SmallVector BackendArgs;
+  BackendArgs.push_back("clang"); // Fake program name.
+  if (!CodeGenOpts.DebugPass.empty()) {
+BackendArgs.push_back("-debug-pass");
+BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
+  }
+  if (!CodeGenOpts.LimitFloatPrecision.empty()) {
+BackendArgs.push_back("-limit-float-precision");
+BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
+  }
+  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
+BackendArgs.push_back(BackendOption.c_str());
+  BackendArgs.push_back(nullptr);
+  llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
+BackendArgs.data());
+}
+
 TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
   // Create the TargetMachine for generating code.
   std::string Error;
@@ -466,22 +487,6 @@
   assert(CodeModel != ~0u && "invalid code model!");
   llvm::CodeModel::Model CM = static_cast(CodeModel);
 
-  SmallVector BackendArgs;
-  BackendArgs.push_back("clang"); // Fake program name.
-  if (!CodeGenOpts.DebugPass.empty()) {
-BackendArgs.push_back("-debug-pass");
-BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
-  }
-  if (!CodeGenOpts.LimitFloatPrecision.empty()) {
-BackendArgs.push_back("-limit-float-precision");
-BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
-  }
-  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
-BackendArgs.push_back(BackendOption.c_str());
-  BackendArgs.push_back(nullptr);
-  llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
-BackendArgs.data());
-
   std::string FeaturesStr =
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
 
@@ -620,6 +625,8 @@
   raw_pwrite_stream *OS) {
   TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
 
+  setCommandLineOpts();
+
   bool UsesCodeGen = (Action != Backend_EmitNothing &&
   Action != Backend_EmitBC &&
   Action != Backend_EmitLL);


Index: test/Frontend/backend-option.c
===
--- /dev/null
+++ test/Frontend/backend-option.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -x cl -emit-llvm -backend-option -time-passes -o - -triple spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report
+
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -97,6 +97,9 @@
 return PerFunctionPasses;
   }
 
+  /// Set LLVM command line options passed through -backend-option.
+  void setCommandLineOpts();
+
   void CreatePasses(FunctionInfoIndex *FunctionIndex);
 
   /// Generates the TargetMachine.
@@ -444,6 +447,24 @@
   PMBuilder.populateModulePassManager(*MPM);
 }
 
+void EmitAssemblyHelper::setCommandLineOpts() {
+  SmallVector BackendArgs;
+  BackendArgs.push_back("clang"); // Fake program name.
+  if (!CodeGenOpts.DebugPass.empty()) {
+BackendArgs.push_back("-debug-pass");
+BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
+  }
+  if (!CodeGenOpts.LimitFloatPrecision.empty()) {
+BackendArgs.push_back("-limit-float-precision");
+BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str());
+  }
+  for (const std::string &BackendOption : CodeGenOpts.BackendOptions)
+BackendArgs.push_back(BackendOption.c_str());
+  BackendArgs.push_back(nullptr);
+  llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1,
+Ba

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread John McCall via cfe-commits
rjmccall added a comment.

You still don't actually want linkonce_odr linkage.  You don't want the weak 
definition to be inlined, so it can't be ODR, and you want to force it to be 
emitted in your library, so it can't be linkonce.  You just want weak linkage.  
There's an existing attribute for that.

At best, you want a pass on your completed library to promote any still-weak 
definitions to strong.  That is not something we can usefully support in an 
attribute; it needs a custom pass.

Dropping unused definitions from your library when it's linked into an actual 
application is just standard dead-code stripping and does not need a special 
linkage.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18199: CodeGen: Implement IR generation for the relative vtable ABI (PR26723).

2016-03-22 Thread Peter Collingbourne via cfe-commits
pcc updated this revision to Diff 51324.
pcc added a comment.

- Use llvm.load.relative (http://reviews.llvm.org/D18367)


http://reviews.llvm.org/D18199

Files:
  docs/UsersManual.rst
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CGVTables.h
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  test/CodeGenCXX/vtable-relative-abi.cpp

Index: test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-windows-msvc -funstable-c++-abi-classes -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+
+// CHECK-ITANIUM: @_ZTV1S = unnamed_addr constant { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32 }, { i8*, i8*, i32, i32 }* @_ZTV1S, i32 0, i32 2) to i64)) to i32) }, align 8
+// CHECK-MS: @0 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @0, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7S@@6B@")
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = unnamed_addr constant { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32 }, { i8*, i8*, i32 }* @_ZTV1T, i32 0, i32 2) to i64)) to i32) }
+// CHECK-MS: @1 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4T@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @1, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7T@@6B@")
+struct T {
+  T();
+  virtual void g();
+};
+
+// CHECK-ITANIUM: @_ZTV1U = unnamed_addr constant { i8*, i8*, i32, i32, i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @_ZN1U2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 2) to i64)) to i32), i8* inttoptr (i64 -8 to i8*), i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i8*, i32, i32, i8*, i8*, i32 }, { i8*, i8*, i32, i32, i8*, i8*, i32 }* @_ZTV1U, i32 0, i32 6) to i64)) to i32) }, align 8
+// CHECK-MS: @2 = private unnamed_addr constant { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BS@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @"\01?f1@U@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"\01?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32, i32 }, { i8*, i32, i32 }* @2, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BS@@@")
+// CHECK-MS: @3 = private unnamed_addr constant { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4U@@6BT@@@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"\01?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @3, i32 0, i32 1) to i64)) to i32) }, comdat($"\01??_7U@@6BT@@@")
+struct U : S, T {
+  U();
+  virtual void f1();
+};
+
+S::S() {}
+void S::f1() {}
+
+T::T() {}
+void T::g() {}
+
+U::U() {}
+void U::f1() {}
+
+struct V {
+  virtua

Re: [PATCH] D18325: export additional header modules from xmmintrin

2016-03-22 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D18325



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


Buildbot numbers for week of 3/13/2016 - 3/19/2016

2016-03-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 3/13/2016 - 3/19/2016.

Thanks

Galina


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

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly| 51 |
38 |74.5
 perf-x86_64-penryn-O3-polly-parallel-fast  |203 |
115 |56.7
 clang-ppc64le-linux-lnt| 79 |
44 |55.7
 lldb-x86_64-darwin-13.4|118 |
43 |36.4
 lldb-windows7-android  | 96 |
18 |18.8
 clang-x86-win2008-selfhost | 94 |
16 |17.0
 clang-x64-ninja-win7   |157 |
26 |16.6
 sanitizer-ppc64le-linux| 50
|   8 |16.0
 sanitizer-x86_64-linux | 89 |
14 |15.7
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 13
|   2 |15.4
 sanitizer-x86_64-linux-bootstrap   | 47
|   6 |12.8
 clang-cmake-armv7-a15-selfhost | 33
|   4 |12.1
 perf-x86_64-penryn-O3-polly-fast   | 20
|   2 |10.0
 lldb-x86_64-ubuntu-14.04-cmake |200 |
20 |10.0
 clang-atom-d525-fedora-rel | 89
|   8 | 9.0
 perf-x86_64-penryn-O3  | 45
|   4 | 8.9
 lldb-x86_64-ubuntu-14.04-android   |117 |
10 | 8.5
 clang-native-aarch64-full  | 12
|   1 | 8.3
 clang-ppc64be-linux-multistage |124 |
10 | 8.1
 clang-cmake-aarch64-full   | 37
|   3 | 8.1
 clang-bpf-build|253 |
20 | 7.9
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   |311 |
22 | 7.1
 clang-ppc64be-linux-lnt|197 |
14 | 7.1
 lld-x86_64-freebsd |173 |
12 | 6.9
 clang-s390x-linux  |232 |
16 | 6.9
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast |310 |
20 | 6.5
 clang-hexagon-elf  |248 |
16 | 6.5
 lld-x86_64-darwin13|236 |
15 | 6.4
 clang-cmake-aarch64-quick  |140
|   9 | 6.4
 clang-cmake-thumbv7-a15|158 |
10 | 6.3
 clang-ppc64be-linux|229 |
14 | 6.1
 sanitizer-ppc64be-linux|104
|   6 | 5.8
 clang-cmake-armv7-a15  |146
|   8 | 5.5
 llvm-clang-lld-x86_64-debian-fast  |154
|   8 | 5.2
 llvm-hexagon-elf   |192 |
10 | 5.2
 clang-native-arm-lnt   |122
|   6 | 4.9
 clang-ppc64le-linux|170
|   8 | 4.7
 lld-x86_64-win7|239 |
10 | 4.2
 clang-cmake-armv7-a15-full |101
|   4 | 4.0
 perf-x86_64-penryn-O3-polly-unprofitable   |167
|   6 | 3.6
 llvm-mips-linux| 59
|   2 | 3.4
 sanitizer-x86_64-linux-fast|187
|   6 | 3.2
 clang-x86_64-linux-abi-test|258
|   8 | 3.1
 polly-amd64-linux  |194
|   6 | 3.1
 lldb-amd64-ninja-netbsd7   |135
|   4 | 3.0
 lldb-x86-windows-msvc2015  |169
|   5 | 3.0
 sanitizer-x86_64-li

Buildbot numbers for week of 3/06/2016 - 3/12/2016

2016-03-22 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 3/06/2016 - 3/12/2016.

Thanks

Galina


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

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly| 62 |
39 |62.9
 clang-ppc64le-linux-lnt| 81 |
40 |49.4
 perf-x86_64-penryn-O3-polly-parallel-fast  |179 |
87 |48.6
 lldb-windows7-android  | 93 |
43 |46.2
 libcxx-libcxxabi-x86_64-linux-debian   |  8
|   3 |37.5
 clang-cmake-armv7-a15-selfhost | 33 |
10 |30.3
 sanitizer-x86_64-linux | 86 |
22 |25.6
 lldb-x86_64-ubuntu-14.04-android   |117 |
30 |25.6
 lldb-x86_64-darwin-13.4|114 |
26 |22.8
 clang-cmake-aarch64-full   | 38
|   6 |15.8
 clang-ppc64be-linux-multistage |126 |
19 |15.1
 clang-x86-win2008-selfhost |129 |
17 |13.2
 clang-cmake-armv7-a15  |144 |
18 |12.5
 sanitizer-ppc64le-linux| 49
|   6 |12.2
 sanitizer-x86_64-linux-bootstrap   | 51
|   6 |11.8
 llvm-clang-lld-x86_64-debian-fast  |173 |
20 |11.6
 sanitizer-ppc64be-linux|103 |
11 |10.7
 clang-cmake-thumbv7-a15|154 |
16 |10.4
 lldb-x86_64-ubuntu-14.04-cmake |196 |
20 |10.2
 clang-ppc64le-linux|177 |
18 |10.2
 clang-cmake-aarch64-quick  |143 |
14 | 9.8
 llvm-mips-linux| 62
|   6 | 9.7
 clang-x64-ninja-win7   |166 |
15 | 9.0
 clang-ppc64be-linux-lnt|201 |
18 | 9.0
 sanitizer-x86_64-linux-fast|182 |
16 | 8.8
 clang-ppc64be-linux|228 |
20 | 8.8
 clang-cmake-armv7-a15-selfhost-neon| 23
|   2 | 8.7
 clang-cmake-mips   | 95
|   8 | 8.4
 clang-bpf-build|247 |
20 | 8.1
 clang-atom-d525-fedora-rel | 76
|   6 | 7.9
 clang-s390x-linux  |231 |
18 | 7.8
 clang-cmake-aarch64-42vma  |156 |
12 | 7.7
 clang-x86_64-debian-fast   |130 |
10 | 7.7
 lldb-x86-windows-msvc2015  |181 |
12 | 6.6
 clang-hexagon-elf  |244 |
16 | 6.6
 clang-cmake-armv7-a15-full | 96
|   6 | 6.3
 lldb-x86_64-ubuntu-14.04-buildserver   |136
|   8 | 5.9
 perf-x86_64-penryn-O3-polly-unprofitable   |182 |
10 | 5.5
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   |335 |
18 | 5.4
 lldb-amd64-ninja-freebsd11 |279 |
14 | 5.0
 polly-amd64-linux  |174
|   8 | 4.6
 sanitizer-x86_64-linux-fuzzer  |174
|   8 | 4.6
 lld-x86_64-win7|175
|   8 | 4.6
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast |335 |
14 | 4.2
 llvm-sphinx-docs   | 88
|   3 | 3.4
 lld-x86_64-darwin13|123
|   4 | 3.3
 llvm-hexagon-elf   |1

Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/Frontend/backend-option.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - -triple 
spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report

yaxunl wrote:
> Anastasia wrote:
> > I think conceptually it's not correct to pass spir target with C module, 
> > although it doesn't make any difference here for this test. I would still 
> > change it to some x86 one.
> if we change it to x86, it has a target machine, so the test no longer 
> reproduce the original issue.
> 
> How about add -x cl for the second command to force the source to be treated 
> as cl source code, then it can reproduce the original issue and at the same 
> time is valid for spir target?
Sure!


http://reviews.llvm.org/D17552



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


Re: r257934 - [CMake] Support generation of linker order files using dtrace

2016-03-22 Thread Sean Silva via cfe-commits
Thanks!

On Tue, Mar 22, 2016 at 9:34 AM, Chris Bieneman  wrote:

> Sean,
>
> All good feedback.
>
> Using print_function was done in r257936 with some other feedback from
> Bogner.
>
> The rest of your feedback I believe I have addressed in r264063.
>
> -Chris
>
> On Mar 21, 2016, at 9:21 PM, Sean Silva  wrote:
>
>
>
> On Fri, Jan 15, 2016 at 1:21 PM, Chris Bieneman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: cbieneman
>> Date: Fri Jan 15 15:21:12 2016
>> New Revision: 257934
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257934&view=rev
>> Log:
>> [CMake] Support generation of linker order files using dtrace
>>
>> Summary:
>> This patch extends the lit-based perf-training tooling supplied for PGO
>> data generation to also generate linker order files using dtrace.
>>
>> This patch should work on any system that has dtrace. If CMake can find
>> the dtrace tool it will generate a target 'generate-order-file' which will
>> run the per-training tests wrapped by dtrace to capture function entries.
>> There are several algorithms implemented for sorting the order files which
>> can be experimented with for best performance. The dtrace wrapper also
>> supports bot oneshot and pid probes.
>>
>> The perf-helper.py changes to support order file construction are ported
>> from internal changes by ddunbar; he gets all the credit for the hard work
>> here, I just copy and pasted.
>>
>> Note: I've tested these patches on FreeBSD and OS X 10.10.
>>
>> Reviewers: ddunbar, bogner, silvas
>>
>> Subscribers: llvm-commits, emaste
>>
>> Differential Revision: http://reviews.llvm.org/D16134
>>
>> Added:
>> cfe/trunk/utils/perf-training/order-files.lit.cfg
>> cfe/trunk/utils/perf-training/order-files.lit.site.cfg.in
>> Modified:
>> cfe/trunk/utils/perf-training/CMakeLists.txt
>> cfe/trunk/utils/perf-training/perf-helper.py
>>
>> Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=257934&r1=257933&r2=257934&view=diff
>>
>> ==
>> --- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
>> +++ cfe/trunk/utils/perf-training/CMakeLists.txt Fri Jan 15 15:21:12 2016
>> @@ -1,24 +1,24 @@
>> -if(LLVM_BUILD_INSTRUMENTED)
>> -  if (CMAKE_CFG_INTDIR STREQUAL ".")
>> -set(LLVM_BUILD_MODE ".")
>> -  else ()
>> -set(LLVM_BUILD_MODE "%(build_mode)s")
>> -  endif ()
>> +if (CMAKE_CFG_INTDIR STREQUAL ".")
>> +  set(LLVM_BUILD_MODE ".")
>> +else ()
>> +  set(LLVM_BUILD_MODE "%(build_mode)s")
>> +endif ()
>>
>> -  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR
>> ${LLVM_RUNTIME_OUTPUT_INTDIR})
>> +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR
>> ${LLVM_RUNTIME_OUTPUT_INTDIR})
>>
>> +if(LLVM_BUILD_INSTRUMENTED)
>>configure_lit_site_cfg(
>>  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
>> -${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
>> +${CMAKE_CURRENT_BINARY_DIR}/pgo-data/lit.site.cfg
>>  )
>>
>>add_lit_testsuite(generate-profraw "Generating clang PGO data"
>> -${CMAKE_CURRENT_BINARY_DIR}
>> +${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
>>  DEPENDS clang clear-profraw
>>  )
>>
>>add_custom_target(clear-profraw
>> -COMMAND ${PYTHON_EXECUTABLE}
>> ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean ${CMAKE_CURRENT_BINARY_DIR}
>> +COMMAND ${PYTHON_EXECUTABLE}
>> ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean
>> ${CMAKE_CURRENT_BINARY_DIR} profraw
>>  COMMENT "Clearing old profraw data")
>>
>>if(NOT LLVM_PROFDATA)
>> @@ -34,3 +34,26 @@ if(LLVM_BUILD_INSTRUMENTED)
>>  COMMENT "Merging profdata"
>>  DEPENDS generate-profraw)
>>  endif()
>> +
>> +find_program(DTRACE dtrace)
>> +if(DTRACE)
>> +  configure_lit_site_cfg(
>> +${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
>> +${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
>> +)
>> +
>> +  add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
>> +${CMAKE_CURRENT_BINARY_DIR}/order-files/
>> +DEPENDS clang clear-dtrace-logs
>> +)
>> +
>> +  add_custom_target(clear-dtrace-logs
>> +COMMAND ${PYTHON_EXECUTABLE}
>> ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py clean
>> ${CMAKE_CURRENT_BINARY_DIR} dtrace
>> +COMMENT "Clearing old dtrace data")
>> +
>> +
>> +  add_custom_target(generate-order-file
>> +COMMAND ${PYTHON_EXECUTABLE}
>> ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py gen-order-file --binary
>> $ --output ${CMAKE_CURRENT_BINARY_DIR}/clang.order
>> ${CMAKE_CURRENT_BINARY_DIR}
>> +COMMENT "Generating order file"
>> +DEPENDS generate-dtrace-logs)
>> +endif()
>>
>> Added: cfe/trunk/utils/perf-training/order-files.lit.cfg
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/order-files.lit.cfg?rev=257934&view=auto
>>
>> ===

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I don't actually understand this change. This test should compile with or 
without "-Wthread-safety" warning. This test doesn't actually turn the 
annotations on, that's the point. If annotations were actually enabled this 
test would fail to compile.

Could you explain the error your seeing here?


http://reviews.llvm.org/D18347



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


Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Richard Barton via cfe-commits
richard.barton.arm updated this revision to Diff 51316.
richard.barton.arm added a comment.

Sorry - not sure what happened there. That looks better for me.


http://reviews.llvm.org/D18347

Files:
  test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp

Index: 
test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- 
test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
+++ 
test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// REQUIRES: thread-safety
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it


Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
===
--- test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: thread-safety
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl marked an inline comment as done.


Comment at: test/Frontend/backend-option.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - -triple 
spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report

Anastasia wrote:
> I think conceptually it's not correct to pass spir target with C module, 
> although it doesn't make any difference here for this test. I would still 
> change it to some x86 one.
if we change it to x86, it has a target machine, so the test no longer 
reproduce the original issue.

How about add -x cl for the second command to force the source to be treated as 
cl source code, then it can reproduce the original issue and at the same time 
is valid for spir target?


http://reviews.llvm.org/D17552



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


Re: [PATCH] D18325: export additional header modules from xmmintrin

2016-03-22 Thread John Thompson via cfe-commits
jtsoftware edited reviewers, added: rsmith; removed: probinson, silvas.
jtsoftware updated this revision to Diff 51313.
jtsoftware added a comment.

Right.  Also undoing moving stuff around.  How about this?  Thanks.


http://reviews.llvm.org/D18325

Files:
  lib/Headers/module.modulemap
  test/Headers/xmmintrin.c

Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -23,3 +23,7 @@
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -44,6 +44,7 @@
 }
 
 explicit module sse {
+  export mm_malloc
   export mmx
   export sse2 // note: for hackish  dependency
   header "xmmintrin.h"


Index: test/Headers/xmmintrin.c
===
--- test/Headers/xmmintrin.c
+++ test/Headers/xmmintrin.c
@@ -23,3 +23,7 @@
   return _mm_add_sd(__a, __b);
 }
 
+#if __STDC_HOSTED__
+// Make sure stdlib.h symbols are accessible.
+void *p = NULL;
+#endif
Index: lib/Headers/module.modulemap
===
--- lib/Headers/module.modulemap
+++ lib/Headers/module.modulemap
@@ -44,6 +44,7 @@
 }
 
 explicit module sse {
+  export mm_malloc
   export mmx
   export sse2 // note: for hackish  dependency
   header "xmmintrin.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17552: Pass -backend-option to LLVM when there is no target machine

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM, apart from small remark on the test!



Comment at: test/Frontend/backend-option.c:2
@@ +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - 2>&1 | 
FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -backend-option -time-passes -o - -triple 
spir-unknown-unknown 2>&1 | FileCheck %s
+// CHECK: Pass execution timing report

I think conceptually it's not correct to pass spir target with C module, 
although it doesn't make any difference here for this test. I would still 
change it to some x86 one.


http://reviews.llvm.org/D17552



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


[clang-tools-extra] r264080 - [clang-tidy] Fix broken test with redundant string init (msvc).

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 13:21:17 2016
New Revision: 264080

URL: http://llvm.org/viewvc/llvm-project?rev=264080&view=rev
Log:
[clang-tidy] Fix broken test with redundant string init (msvc).

Summary:
There is a silly bug that got introduced after fixing incorrect paths with this 
patch:
http://reviews.llvm.org/D18293

The tests was present twice in the file.

Reviewers: alexfh, rnk

Subscribers: cfe-commits

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

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp?rev=264080&r1=264079&r2=264080&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 Tue Mar 22 13:21:17 2016
@@ -59,64 +59,3 @@ void g() {
   std::wstring y(LR"(y)");
   std::wstring z;
 }
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template , typename A = 
std::allocator>
-struct basic_string {
-  basic_string();
-  basic_string(const basic_string&);
-  // MSVC headers define two constructors instead of using optional arguments.
-  basic_string(const C *);
-  basic_string(const C *, const A &);
-  ~basic_string();
-};
-typedef basic_string string;
-typedef basic_string wstring;
-}
-
-void f() {
-  std::string a = "";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization 
[readability-redundant-string-init]
-  // CHECK-FIXES: std::string a;
-  std::string b("");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string b;
-  std::string c = R"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string c;
-  std::string d(R"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string d;
-
-  std::string u = "u";
-  std::string w("w");
-  std::string x = R"(x)";
-  std::string y(R"(y)");
-  std::string z;
-}
-
-void g() {
-  std::wstring a = L"";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring a;
-  std::wstring b(L"");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring b;
-  std::wstring c = LR"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring c;
-  std::wstring d(LR"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring d;
-
-  std::wstring u = L"u";
-  std::wstring w(L"w");
-  std::wstring x = LR"(x)";
-  std::wstring y(LR"(y)");
-  std::wstring z;
-}


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


Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


http://reviews.llvm.org/D17596



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


Re: [PATCH] D17955: [OpenCL] Fix pipe builtin bugs

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:1
@@ -1,2 +1,2 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 

Could you add a test case that fails before your modification here to show that 
your change improves on it!


http://reviews.llvm.org/D17955



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


Re: [PATCH] D18365: [clang-tidy] Fix broken test with redundant string init (msvc).

2016-03-22 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D18365



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


[PATCH] D18365: [clang-tidy] Fix broken test with redundant string init (msvc).

2016-03-22 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: rnk, alexfh.
etienneb added a subscriber: cfe-commits.

There is a silly bug that got introduced after fixing incorrect paths with this 
patch:
http://reviews.llvm.org/D18293

The tests was present twice in the file.

http://reviews.llvm.org/D18365

Files:
  test/clang-tidy/readability-redundant-string-init-msvc.cpp

Index: test/clang-tidy/readability-redundant-string-init-msvc.cpp
===
--- test/clang-tidy/readability-redundant-string-init-msvc.cpp
+++ test/clang-tidy/readability-redundant-string-init-msvc.cpp
@@ -59,64 +59,3 @@
   std::wstring y(LR"(y)");
   std::wstring z;
 }
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template , typename A = 
std::allocator>
-struct basic_string {
-  basic_string();
-  basic_string(const basic_string&);
-  // MSVC headers define two constructors instead of using optional arguments.
-  basic_string(const C *);
-  basic_string(const C *, const A &);
-  ~basic_string();
-};
-typedef basic_string string;
-typedef basic_string wstring;
-}
-
-void f() {
-  std::string a = "";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization 
[readability-redundant-string-init]
-  // CHECK-FIXES: std::string a;
-  std::string b("");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string b;
-  std::string c = R"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string c;
-  std::string d(R"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string d;
-
-  std::string u = "u";
-  std::string w("w");
-  std::string x = R"(x)";
-  std::string y(R"(y)");
-  std::string z;
-}
-
-void g() {
-  std::wstring a = L"";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring a;
-  std::wstring b(L"");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring b;
-  std::wstring c = LR"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring c;
-  std::wstring d(LR"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring d;
-
-  std::wstring u = L"u";
-  std::wstring w(L"w");
-  std::wstring x = LR"(x)";
-  std::wstring y(LR"(y)");
-  std::wstring z;
-}


Index: test/clang-tidy/readability-redundant-string-init-msvc.cpp
===
--- test/clang-tidy/readability-redundant-string-init-msvc.cpp
+++ test/clang-tidy/readability-redundant-string-init-msvc.cpp
@@ -59,64 +59,3 @@
   std::wstring y(LR"(y)");
   std::wstring z;
 }
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template , typename A = std::allocator>
-struct basic_string {
-  basic_string();
-  basic_string(const basic_string&);
-  // MSVC headers define two constructors instead of using optional arguments.
-  basic_string(const C *);
-  basic_string(const C *, const A &);
-  ~basic_string();
-};
-typedef basic_string string;
-typedef basic_string wstring;
-}
-
-void f() {
-  std::string a = "";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization [readability-redundant-string-init]
-  // CHECK-FIXES: std::string a;
-  std::string b("");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string b;
-  std::string c = R"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string c;
-  std::string d(R"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
-  // CHECK-FIXES: std::string d;
-
-  std::string u = "u";
-  std::string w("w");
-  std::string x = R"(x)";
-  std::string y(R"(y)");
-  std::string z;
-}
-
-void g() {
-  std::wstring a = L"";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring a;
-  std::wstring b(L"");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring b;
-  std::wstring c = LR"()";
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring c;
-  std::wstring d(LR"()");
-  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
-  // CHECK-FIXES: std::wstring d;
-
-  std::wstring u = L"u";
-  std::wstring w(L"w");
-  std::wstring x = LR"(x)";
-  std::wstring y(LR"(y)");
-  std::wstring z;
-}
___
cfe-commits mailing list
cfe-commits@lists

Re: [PATCH] D18363: Fix typo s/initalize/initialize/

2016-03-22 Thread Stephen Hines via cfe-commits
srhines accepted this revision.
srhines added a comment.
This revision is now accepted and ready to land.

I think this is trivial enough for me to accept. I also added cfe-commits, so 
that they at least have a chance to review/comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D18363



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


Re: r264071 - StaticAnalyzer: Avoid an unintentional copy

2016-03-22 Thread David Blaikie via cfe-commits
On Tue, Mar 22, 2016 at 10:50 AM, Justin Bogner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bogner
> Date: Tue Mar 22 12:50:05 2016
> New Revision: 264071
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264071&view=rev
> Log:
> StaticAnalyzer: Avoid an unintentional copy
>

Just to be clear - it sounds like a copy happens here regardless. It's just
best to be explicit so readers aren't confused about that. (sounds like the
iterator produces results by value (probably non-standard for an iterator
to do that, but probably not uncommon) & so taking a reference to it does
reference lifetime extension, etc) Now we're being explicit aobut the
pointer being copied, rather than implying that we refer to a pointer kept
inside the sequence/container.


>
> The range here isn't over references, so using `auto &` here incites a
> copy. Switching to `auto *` would do, but we might as well list an
> explicit type for clarity.
>
> Found by -Wrange-loop-analysis.
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp?rev=264071&r1=264070&r2=264071&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp Tue Mar 22
> 12:50:05 2016
> @@ -168,7 +168,7 @@ public:
>  const ASTRecordLayout &RL) {
>  CharUnits PaddingSum;
>  CharUnits Offset =
> ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
> -for (const auto &FD : RD->fields()) {
> +for (const FieldDecl *FD : RD->fields()) {
>// This checker only cares about the padded size of the
>// field, and not the data size. If the field is a record
>// with tail padding, then we won't put that number in our
>
>
> ___
> 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] D13126: New static analyzer checker for loss of sign/precision

2016-03-22 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:84
@@ +83,3 @@
+// Can E value be greater or equal than Val?
+static bool canBeGreaterEqual(CheckerContext &C, const Expr *E,
+  unsigned long long Val) {

danielmarjamaki wrote:
> zaks.anna wrote:
> > This function returns true if the value "is" greater or equal, not "can be" 
> > greater or equal. The latter would be "return StGE".
> > 
> > Also, it's slightly better to return the StGE state and use it to report 
> > the bug. This way, our assumption is explicitly recorded in the error state.
> NoQ made the same comment. I disagree.
> 
> int A = 0;
> if (X) {
>  A = 1000;
> }
> U8 = A;  // <- Imho; A _can_ be 1000
> 
> Imho it's better to say that A _can_ be 1000 unless A is 1000 for all 
> possible execution paths through the code.
> 
> Do you still think "is" is better than "can be"?
The Clang Static Analyzer performs path sensitive analysis of the program. (It 
does not merge the paths at the "U8 = A" statement!!!) You will only be 
changing the state along a single execution path of this program. Along that 
path, A will always be 1000. 

When analyzing your example, the analyzer is going to separately analyze 2 
paths:
1st path: A=0; X != 0; A =1000; U8 = A; // Here U8 is definitely 1000.
2d  path: A=0; X == 0; U8 = A;   // Here U8 is definitely 0.

This video contains an intuitive explanation of symbolic execution technique we 
use: http://llvm.org/devmtg/2012-11/videos/Zaks-Rose-Checker24Hours.mp4


http://reviews.llvm.org/D13126



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


[clang-tools-extra] r264075 - [clang-tidy] Fix redundant-string-cstr check with msvc 14 headers.

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 13:00:13 2016
New Revision: 264075

URL: http://llvm.org/viewvc/llvm-project?rev=264075&view=rev
Log:
[clang-tidy] Fix redundant-string-cstr check with msvc 14 headers.

Summary:
The string constructors are not defined using optional parameters and are not 
recognize by the checker.

The constructor defined in the MSVC header is defined with 1 parameter. 
Therefore, patterns are not recognized by the checker.
The current patch add support to accept constructor with only one parameter.

Repro on a Visual Studio 14 installation with the following code:
```
void f1(const std::string &s) {
  f1(s.c_str());
}
```

In the xstring.h header, the constructors are defined this way:
```
basic_string(const _Myt& _Right) [...]
basic_string(const _Myt& _Right, const _Alloc& _Al) [...]
```

The CXXConstructExpr to recognize only contains 1 parameter.
```
CXXConstructExpr 0x3f1a070  'const 
std::string':'const class std::basic_string, class
 std::allocator >' 'void (const char *) __attribute__((thiscall))'
`-CXXMemberCallExpr 0x3f1a008  'const char *'
  `-MemberExpr 0x3f19fe0  '' .c_str 
0x3cc22f8
`-DeclRefExpr 0x3f19fc8  'const std::string':'const class 
std::basic_string, class 
std::allocator >' lvalue ParmVar 0x3f19c80 's' 'const std::string &'
```

Reviewers: aaron.ballman, alexfh

Subscribers: aemerson

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

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp?rev=264075&r1=264074&r2=264075&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
Tue Mar 22 13:00:13 2016
@@ -85,23 +85,29 @@ void RedundantStringCStrCheck::registerM
   if (!getLangOpts().CPlusPlus)
 return;
 
-  Finder->addMatcher(
+  // Match string constructor.
+  const auto StringConstructorExpr = expr(anyOf(
+  cxxConstructExpr(
+  argumentCountIs(1),
+  hasDeclaration(cxxMethodDecl(hasName(StringConstructor,
   cxxConstructExpr(
-  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
   argumentCountIs(2),
-  // The first argument must have the form x.c_str() or p->c_str()
-  // where the method is string::c_str().  We can use the copy
-  // constructor of string instead (or the compiler might share
-  // the string object).
-  hasArgument(0, cxxMemberCallExpr(
- callee(memberExpr().bind("member")),
- callee(cxxMethodDecl(hasName(StringCStrMethod))),
- on(expr().bind("arg")))
- .bind("call")),
-  // The second argument is the alloc object which must not be
-  // present explicitly.
-  hasArgument(1, cxxDefaultArgExpr())),
+  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
+  // If present, the second argument is the alloc object which must not
+  // be present explicitly.
+  hasArgument(1, cxxDefaultArgExpr();
+
+  // Match a call to the string 'c_str()' method.
+  const auto StringCStrCallExpr = cxxMemberCallExpr(
+callee(memberExpr().bind("member")),
+callee(cxxMethodDecl(hasName(StringCStrMethod))),
+on(expr().bind("arg"))).bind("call");
+
+  Finder->addMatcher(
+  cxxConstructExpr(StringConstructorExpr,
+   hasArgument(0, StringCStrCallExpr)),
   this);
+
   Finder->addMatcher(
   cxxConstructExpr(
   // Implicit constructors of these classes are overloaded
@@ -117,11 +123,7 @@ void RedundantStringCStrCheck::registerM
   // a constructor from string which is more efficient (avoids
   // strlen), so we can construct StringRef from the string
   // directly.
-  hasArgument(0, cxxMemberCallExpr(
- callee(memberExpr().bind("member")),
- callee(cxxMethodDecl(hasName(StringCStrMethod))),
- on(expr().bind("arg")))
- .bind("call"))),
+  hasArgument(0, StringCStrCallExpr)),
   this);
 }
 

Added: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp?rev=264075&view=auto
=

Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-03-22 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 51303.
Anastasia added a comment.

Thanks to Aleksey Bader for rebasing this patch to ToT and fixing some tests 
issues!


http://reviews.llvm.org/D17821

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/OpenCLImageTypes.def
  include/clang/AST/Type.h
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/CodeGenOpenCL/images.cl
  test/CodeGenOpenCL/opencl_types.cl
  test/SemaOpenCL/images.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1454,18 +1454,9 @@
   case BuiltinType::Void:
   case BuiltinType::NullPtr:
   case BuiltinType::Dependent:
-  case BuiltinType::OCLImage1d:
-  case BuiltinType::OCLImage1dArray:
-  case BuiltinType::OCLImage1dBuffer:
-  case BuiltinType::OCLImage2d:
-  case BuiltinType::OCLImage2dArray:
-  case BuiltinType::OCLImage2dDepth:
-  case BuiltinType::OCLImage2dArrayDepth:
-  case BuiltinType::OCLImage2dMSAA:
-  case BuiltinType::OCLImage2dArrayMSAA:
-  case BuiltinType::OCLImage2dMSAADepth:
-  case BuiltinType::OCLImage2dArrayMSAADepth:
-  case BuiltinType::OCLImage3d:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   \
+  case BuiltinType::Id:
+#include "clang/AST/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
   case BuiltinType::OCLEvent:
   case BuiltinType::OCLClkEvent:
Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -27,7 +27,7 @@
   // TODO: Clean up needed - we don't really need to check for image, event, etc
   // as a note here any longer.
   // They are diagnosed as an error for all struct fields (OpenCL v1.2 s6.9b,r).
-  image2d_t imageField; // expected-note{{field of illegal type 'image2d_t' declared here}} expected-error{{the 'image2d_t' type cannot be used to declare a structure or union field}}
+  image2d_t imageField; // expected-note{{field of illegal type '__read_only image2d_t' declared here}} expected-error{{the '__read_only image2d_t' type cannot be used to declare a structure or union field}}
 } FooImage2D;
 
 kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct kernel parameters may not contain pointers}}
Index: test/SemaOpenCL/invalid-image.cl
===
--- test/SemaOpenCL/invalid-image.cl
+++ test/SemaOpenCL/invalid-image.cl
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -verify %s
 
-void test1(image1d_t *i){} // expected-error {{pointer to type 'image1d_t' is invalid in OpenCL}}
+void test1(image1d_t *i){} // expected-error {{pointer to type '__read_only image1d_t' is invalid in OpenCL}}
 
 void test2(image1d_t i) {
-  image1d_t ti; // expected-error {{type 'image1d_t' can only be used as a function parameter}}
-  image1d_t ai[] = {i,i};// expected-error {{array of 'image1d_t' type is invalid in OpenCL}}
+  image1d_t ti; // expected-error {{type '__read_only image1d_t' can only be used as a function parameter}}
+  image1d_t ai[] = {i,i};// expected-error {{array of '__read_only image1d_t' type is invalid in OpenCL}}
 }
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -10,5 +10,5 @@
 #ifdef CL20
 void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe'}}
 #else
-void test4(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for 'image1d_t' earlier than OpenCL2.0 version}}
+void test4(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL2.0 version}}
 #endif
Index: test/SemaOpenCL/im

[clang-tools-extra] r264073 - [clang-tidy] Skip reporting of not applicable fixes.

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 12:51:27 2016
New Revision: 264073

URL: http://llvm.org/viewvc/llvm-project?rev=264073&view=rev
Log:
[clang-tidy] Skip reporting of not applicable fixes.

Summary:
Invalid source location are causing clang-tidy to crash when manipulating an 
invalid file.

Macro definitions on the command line have locations in a virtual buffer and 
therefore
don't have a corresponding valid FilePath.

A recent patch added path conversion to absolute path. As the FilePath may now 
be empty,
the result of makeAbsolutePath may incorrectly be the folder WorkingDir.  The 
crash occurs
in getLocation which is not able to find the appropriate FileEntry (null 
pointer).

```
  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
  Files.makeAbsolutePath(FixAbsoluteFilePath);
  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
```

With relative path, the code was not crashing because getLocation was skipping 
empty path.



Example of code:

```
int main() { return X; }
```

With the given command-line:

```
clang-tidy test.cc --checks=misc-macro-*  --  -DX=0+0
```

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=264073&r1=264072&r2=264073&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Tue Mar 22 12:51:27 2016
@@ -128,13 +128,20 @@ public:
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+  Diag << FixItHint::CreateReplacement(Range, 
Fix.getReplacementText());
+}
+  
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);

Added: 
clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp?rev=264073&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp 
(added)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-macro-parentheses-cmdline.cpp 
Tue Mar 22 12:51:27 2016
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+
+// The previous command-line is producing warnings and fixes with the source
+// locations from a virtual buffer. VAL is replaced by '0+0'.
+// Fixes could not be applied and should not be reported.
+int foo() { return VAL; }
+
+#define V 0+0
+int bar() { return V; }
+// CHECK-FIXES: #define V (0+0)


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


Re: [PATCH] D18262: [clang-tidy] Skip reporting of not applicable fixes.

2016-03-22 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51305.
etienneb added a comment.

rebase + fixing invalid paths


http://reviews.llvm.org/D18262

Files:
  clang-tidy/ClangTidy.cpp
  test/clang-tidy/misc-macro-parentheses-cmdline.cpp

Index: test/clang-tidy/misc-macro-parentheses-cmdline.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-macro-parentheses-cmdline.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+
+// The previous command-line is producing warnings and fixes with the source
+// locations from a virtual buffer. VAL is replaced by '0+0'.
+// Fixes could not be applied and should not be reported.
+int foo() { return VAL; }
+
+#define V 0+0
+int bar() { return V; }
+// CHECK-FIXES: #define V (0+0)
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -128,13 +128,20 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+  Diag << FixItHint::CreateReplacement(Range, 
Fix.getReplacementText());
+}
+  
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);


Index: test/clang-tidy/misc-macro-parentheses-cmdline.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-macro-parentheses-cmdline.cpp
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s misc-macro-parentheses %t -- -- -DVAL=0+0
+
+// The previous command-line is producing warnings and fixes with the source
+// locations from a virtual buffer. VAL is replaced by '0+0'.
+// Fixes could not be applied and should not be reported.
+int foo() { return VAL; }
+
+#define V 0+0
+int bar() { return V; }
+// CHECK-FIXES: #define V (0+0)
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -128,13 +128,20 @@
   auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
   << Message.Message << Name;
   for (const tooling::Replacement &Fix : Error.Fix) {
-SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
-Files.makeAbsolutePath(FixAbsoluteFilePath);
-SourceLocation FixLoc =
-getLocation(FixAbsoluteFilePath, Fix.getOffset());
-SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
-Diag << FixItHint::CreateReplacement(SourceRange(FixLoc, FixEndLoc),
- Fix.getReplacementText());
+// Retrieve the source range for applicable fixes. Macro definitions
+// on the command line have locations in a virtual buffer and don't
+// have valid file paths and are therefore not applicable.
+SourceRange Range;
+SourceLocation FixLoc;
+if (Fix.isApplicable()) {
+  SmallString<128> FixAbsoluteFilePath = Fix.getFilePath();
+  Files.makeAbsolutePath(FixAbsoluteFilePath);
+  FixLoc = getLocation(FixAbsoluteFilePath, Fix.getOffset());
+  SourceLocation FixEndLoc = FixLoc.getLocWithOffset(Fix.getLength());
+  Range = SourceRange(FixLoc, FixEndLoc);
+  Diag << FixItHint::CreateReplacement(Range, Fix.getReplacementText());
+}
+  
 ++TotalFixes;
 if (ApplyFixes) {
   bool Success = Fix.isApplicable() && Fix.apply(Rewrite);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r264071 - StaticAnalyzer: Avoid an unintentional copy

2016-03-22 Thread Justin Bogner via cfe-commits
Author: bogner
Date: Tue Mar 22 12:50:05 2016
New Revision: 264071

URL: http://llvm.org/viewvc/llvm-project?rev=264071&view=rev
Log:
StaticAnalyzer: Avoid an unintentional copy

The range here isn't over references, so using `auto &` here incites a
copy. Switching to `auto *` would do, but we might as well list an
explicit type for clarity.

Found by -Wrange-loop-analysis.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp?rev=264071&r1=264070&r2=264071&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp Tue Mar 22 
12:50:05 2016
@@ -168,7 +168,7 @@ public:
 const ASTRecordLayout &RL) {
 CharUnits PaddingSum;
 CharUnits Offset = ASTContext.toCharUnitsFromBits(RL.getFieldOffset(0));
-for (const auto &FD : RD->fields()) {
+for (const FieldDecl *FD : RD->fields()) {
   // This checker only cares about the padded size of the
   // field, and not the data size. If the field is a record
   // with tail padding, then we won't put that number in our


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


Re: [PATCH] D17811: [clang-tidy] Add check to detect dangling references in value handlers.

2016-03-22 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

In http://reviews.llvm.org/D17811#380124, @jbcoe wrote:

> Do you have commit access? I can apply this patch for you if not.


I do.
I am waiting on http://reviews.llvm.org/D18275 to fix the problem with using 
internal::HasNameMatcher directly.


http://reviews.llvm.org/D17811



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


[PATCH] D18360: Add AIX Target/ToolChain to Clang Driver

2016-03-22 Thread Andrew Paprocki via cfe-commits
apaprocki created this revision.
apaprocki added a subscriber: cfe-commits.

This patch adds Clang driver support for the AIX platform.  This allows Clang 
to be used for compiling code / checking for errors, but does not allow for 
building executables, as AIX uses XCOFF and not ELF.

After applying this patch and the underlying D18359:

```
$ clang -v
clang version 3.8.0 (tags/RELEASE_380/final)
Target: powerpc-ibm-aix7.1.0.0
Thread model: posix
InstalledDir: /tmp/llvm-3.8/bin
Found candidate GCC installation: 
/tmp/gcc-4.8/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.5
Selected GCC installation: /tmp/gcc-4.8/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.5
Candidate multilib: .;@maix32
Candidate multilib: ppc64;@maix64
Selected multilib: .;@maix32
```

http://reviews.llvm.org/D18360

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  tools/libclang/CIndexer.cpp

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -643,6 +643,24 @@
   Tool *buildLinker() const override;
 };
 
+class LLVM_LIBRARY_VISIBILITY AIX : public Generic_GCC {
+public:
+  AIX(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
+  unsigned GetDefaultDwarfVersion() const override { return 2; }
+
+protected:
+  Tool *buildAssembler() const override;
+  Tool *buildLinker() const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
 public:
   MinGW(const Driver &D, const llvm::Triple &Triple,
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -649,6 +649,34 @@
 };
 } // end namespace solaris
 
+/// aix -- Directly call AIX assembler and linker
+namespace aix {
+class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
+public:
+  Assembler(const ToolChain &TC) : Tool("aix::Assembler", "assembler", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
+class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
+public:
+  Linker(const ToolChain &TC) : Tool("aix::Linker", "linker", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+}  // end namespace aix
+
 /// dragonfly -- Directly call GNU Binutils assembler and linker
 namespace dragonfly {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1719,13 +1719,14 @@
 // Filter to remove Multilibs that don't exist as a suffix to Path
 class FilterNonExistent {
   StringRef Base;
+  StringRef Crt;
   vfs::FileSystem &VFS;
 
 public:
-  FilterNonExistent(StringRef Base, vfs::FileSystem &VFS)
-  : Base(Base), VFS(VFS) {}
+  FilterNonExistent(StringRef Base, StringRef Crt, vfs::FileSystem &VFS)
+  : Base(Base), Crt(Crt), VFS(VFS) {}
   bool operator()(const Multilib &M) {
-return !VFS.exists(Base + M.gccSuffix() + "/crtbegin.o");
+return !VFS.exists(Base + M.gccSuffix() + Crt);
   }
 };
 } // end anonymous namespace
@@ -1811,7 +1812,7 @@
   // /usr
   //   /lib  <= crt*.o files compiled with '-mips32'
 
-  FilterNonExistent NonExistent(Path, D.getVFS());
+  FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS());
 
   // Check for FSF toolchain multilibs
   MultilibSet FSFMipsMultilibs;
@@ -2112,6 +2113,40 @@
   return false;
 }
 
+static bool findAIXBiarchMultilibs(const Driver &D,
+   const llvm::Triple &TargetTriple,
+   StringRef Path, const ArgList &Args,
+   bool NeedsBiarchSuffix,
+   DetectedMultilibs &Result) {
+  Multilib Default = Multilib()
+   .flag("+maix32")
+   .flag("-maix64");
+  Multilib Alt64 = Multilib()
+   .gccSuffix("/ppc64")
+   .includeSuffix("/ppc64")
+   .flag("-maix32")
+   .flag("+maix64");
+
+ 

[clang-tools-extra] r264069 - [clang-tidy] Fix redundant-string-init check with msvc 14 headers.

2016-03-22 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Mar 22 12:39:36 2016
New Revision: 264069

URL: http://llvm.org/viewvc/llvm-project?rev=264069&view=rev
Log:
[clang-tidy] Fix redundant-string-init check with msvc 14 headers.

Summary:
The string constructors are not defined using optional parameters and are not 
recognized by the redundant-string-init checker.

The following patch fixes the redundant-string-init checker for the Visual 
Studio 14 headers file.
The matcher now accept both variant (with 1 and 2 parameters).

Also added new unittests.

Similar issue than: [[ http://reviews.llvm.org/D18285 | review ]]

In the xstring.h header, the constructors are defined this way:
```
basic_string(const _Myt& _Right) [...]
basic_string(const _Myt& _Right, const _Alloc& _Al) [...]
```

Reviewers: alexfh, hokein

Subscribers: cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp?rev=264069&r1=264068&r2=264069&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp 
Tue Mar 22 12:39:36 2016
@@ -20,31 +20,48 @@ namespace {
 
 AST_MATCHER(StringLiteral, lengthIsZero) { return Node.getLength() == 0; }
 
+AST_MATCHER_P(Expr, ignoringImplicit,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  return InnerMatcher.matches(*Node.IgnoreImplicit(), Finder, Builder);
+}
+
 } // namespace
 
 void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
 
-  const auto StringCtorExpr = cxxConstructExpr(
-  hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
-  argumentCountIs(2),
-  hasArgument(0, ignoringParenImpCasts(stringLiteral(lengthIsZero(,
-  hasArgument(1, cxxDefaultArgExpr()));
-
-  // string foo = "";
-  // OR
-  // string bar("");
+  // Match string constructor.
+  const auto StringConstructorExpr = expr(anyOf(
+  cxxConstructExpr(argumentCountIs(1),
+   hasDeclaration(cxxMethodDecl(hasName("basic_string",
+  // If present, the second argument is the alloc object which must not
+  // be present explicitly.
+  cxxConstructExpr(argumentCountIs(2),
+   hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(1, cxxDefaultArgExpr();
+
+  // Match a string constructor expression with an empty string literal.
+  const auto EmptyStringCtorExpr =
+  cxxConstructExpr(StringConstructorExpr,
+  hasArgument(0, ignoringParenImpCasts(
+ stringLiteral(lengthIsZero();
+
+  const auto EmptyStringCtorExprWithTemporaries =
+  expr(ignoringImplicit(
+  cxxConstructExpr(StringConstructorExpr,
+  hasArgument(0, ignoringImplicit(EmptyStringCtorExpr);
+
+  // Match a variable declaration with an empty string literal as initializer.
+  // Examples:
+  // string foo = "";
+  // string bar("");
   Finder->addMatcher(
   namedDecl(varDecl(hasType(cxxRecordDecl(hasName("basic_string"))),
 hasInitializer(
-expr(anyOf(StringCtorExpr,
-   exprWithCleanups(has(expr(anyOf(
-   StringCtorExpr,
-   cxxConstructExpr(hasArgument(
-   0, cxxBindTemporaryExpr(has(
-  StringCtorExpr))
-.bind("expr"
+expr(anyOf(EmptyStringCtorExpr,
+   EmptyStringCtorExprWithTemporaries))
+.bind("expr"
   .bind("decl"),
   this);
 }

Added: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp?rev=264069&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init-msvc.cpp
 Tue Mar 22 12:39:36 2016
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s readability-redundant-string-init %

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-22 Thread Eric Fiselier via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

I think this diff is messed up a little.  Could you upload a fixed diff?


http://reviews.llvm.org/D18347



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


Re: r263740 - Revert "For MS ABI, emit dllexport friend functions defined inline in class"

2016-03-22 Thread Reid Kleckner via cfe-commits
Ugh, templates and friend function definitions strike again!

I think this is where "semantic" vs. "lexical" DeclContexts come into play.
Try doing D->getLexicalDeclContext()->isDependentContext().

On Tue, Mar 22, 2016 at 5:23 AM, Stephan Bergmann 
wrote:

> On 03/17/2016 09:06 PM, Reid Kleckner via cfe-commits wrote:
>
>> Author: rnk
>> Date: Thu Mar 17 15:06:58 2016
>> New Revision: 263740
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=263740&view=rev
>> Log:
>> Revert "For MS ABI, emit dllexport friend functions defined inline in
>> class"
>>
>> This reverts commit r263738.
>>
>> This appears to cause a failure in
>> CXX/temp/temp.decls/temp.friend/p1.cpp
>>
>
> Ah, indeed, if you stick "-triple %ms_abi_triple" in
> test/CXX/temp/temp.decls/temp.friend/p1.cpp, it would consistently have
> failed on all platforms.
>
> The problem is with friend functions defined inline within class templates
> (instead of classes), as in
>
>   template struct S { friend void f() {} };
>
> But which MSVC apparently wouldn't emit when parsing the class template,
> anyway, so we shouldn't either.
>
> So we should filter out friend functions that are defined within class
> templates:
>
> (a) either in Parser::ParseLexedMethodDef
> (lib/Parse/ParseCXXInlineMethods.cpp) before calling
> ActOnFinishInlineFunctionDef,
>
> (b) or (probably preferably) later in the "Handle friend functions" block
> in HandleInlineFunctionDefinition (lib/CodeGen/ModuleBuilder.cpp).
>
> However, I'm having trouble how to determine that condition, in either
> case.  For (a), I thought that maybe
>
>   CurTemplateDepthTracker.getDepth() != 0
>
> could work, but apparently doesn't.  And for (b),
>
>   !D->getDeclContext()->isDependentContext()
>
> doesn't work, either (as the context of the declaration presumably isn't
> the class template, but rather the surrounding namespace).
>
> Any hints?
>
>
>
> Modified:
>>  cfe/trunk/include/clang/AST/ASTConsumer.h
>>  cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
>>  cfe/trunk/include/clang/Sema/Sema.h
>>  cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>>  cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
>>  cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
>>  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
>>  cfe/trunk/lib/Sema/SemaDecl.cpp
>>  cfe/trunk/test/CodeGenCXX/dllexport.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTConsumer.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTConsumer.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTConsumer.h Thu Mar 17 15:06:58 2016
>> @@ -55,9 +55,9 @@ public:
>> /// \returns true to continue parsing, or false to abort parsing.
>> virtual bool HandleTopLevelDecl(DeclGroupRef D);
>>
>> -  /// \brief This callback is invoked each time an inline (method or
>> friend)
>> -  /// function definition in a class is completed.
>> -  virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {}
>> +  /// \brief This callback is invoked each time an inline method
>> definition is
>> +  /// completed.
>> +  virtual void HandleInlineMethodDefinition(CXXMethodDecl *D) {}
>>
>> /// HandleInterestingDecl - Handle the specified interesting
>> declaration. This
>> /// is called by the AST reader when deserializing things that might
>> interest
>>
>> Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=263740&r1=263739&r2=263740&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
>> +++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Mar 17
>> 15:06:58 2016
>> @@ -36,7 +36,7 @@ public:
>> void Initialize(ASTContext &Context) override;
>> void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override;
>> bool HandleTopLevelDecl(DeclGroupRef D) override;
>> -  void HandleInlineFunctionDefinition(FunctionDecl *D) override;
>> +  void HandleInlineMethodDefinition(CXXMethodDecl *D) override;
>> void HandleInterestingDecl(DeclGroupRef D) override;
>> void HandleTranslationUnit(ASTContext &Ctx) override;
>> void HandleTagDeclDefinition(TagDecl *D) override;
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=263740&r1=263739&r2=263740&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 17 15:06:58 2016
>> @@ -1773,7 +1773,7 @@ public:
>> Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
>> Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *B

Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check

2016-03-22 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

Looks like I forgot to remove brace initializers from the test files. I will 
fix that.

Chris Lattner has given me commit access now, so I can commit on my own.


http://reviews.llvm.org/D16529



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


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

2016-03-22 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:116-134
@@ +115,21 @@
+
+// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const
+int return1(int *p) {
+  // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}}
+  return *p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return2(int *p) {
+  // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}}
+  return p;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const
+const int *return3(int *p) {
+  // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}}
+  return p + 1;
+}
+
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const
+const char *return4(char *p) {

danielmarjamaki wrote:
> rsmith wrote:
> > The wording of this warning, and the name of the check, are highly 
> > misleading.
> > 
> > It's *not* the parameter that can be const, it's the parameter's *pointee*.
> I understand. Figuring out a better message is not easy. I and a collegue 
> brain stormed:
> 
> pointer parameter 'p' could be declared with const 'const int *p'
> 
> pointer parameter 'p' could be pointer to const
> 
> pointer parameter 'p' declaration could be pointer to const
> 
> missing const in pointer parameter 'p' declaration
> 
> declaration of pointer parameter 'p' could be 'const int *p'
> 
> Do you think any of these would be good?
> 
Regarding the name of the check, I can't think of anything better only things 
that are longer but aren't substantially more clear in revealing the intent of 
the check.  IMO, you don't blindly run clang-tidy checks based on the name, you 
run them after reading what they do and deciding if you want that 
transformation or not.

In order of my preference:

  - pointer parameter 'p' could be pointer to const
  - declaration of pointer parameter 'p' could be 'const int *p'

I might use the word 'can' instead of the world 'could', but that's a very 
minor quibble.


http://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] D18293: [clang-tidy] Fix redundant-string-init check with msvc 14 headers.

2016-03-22 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51298.
etienneb added a comment.

Rebased + fixing invalid paths.

The diff paths were wrong, invalid diff.


http://reviews.llvm.org/D18293

Files:
  clang-tidy/readability/RedundantStringInitCheck.cpp
  test/clang-tidy/readability-redundant-string-init-msvc.cpp
  test/clang-tidy/readability-redundant-string-init.cpp

Index: test/clang-tidy/readability-redundant-string-init.cpp
===
--- test/clang-tidy/readability-redundant-string-init.cpp
+++ test/clang-tidy/readability-redundant-string-init.cpp
@@ -84,3 +84,50 @@
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization
   // CHECK-FIXES: N
 }
+
+typedef std::string MyString;
+#define STRING MyString
+#define DECL_STRING(name, val) STRING name = val
+
+void i() {
+  MyString a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant string initialization
+  // CHECK-FIXES: MyString a;
+  STRING b = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: redundant string initialization
+  // CHECK-FIXES: STRING b;
+  MyString c = "" "" "";
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant string initialization
+  // CHECK-FIXES: MyString c;
+  STRING d = "" "" "";
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: redundant string initialization
+  // CHECK-FIXES: STRING d;
+  DECL_STRING(e, "");
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+
+  MyString f = "u";
+  STRING g = "u";
+  DECL_STRING(h, "u");
+}
+
+#define EMPTY_STR ""
+void j() {
+  std::string a(EMPTY_STR);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string a;
+  std::string b = (EMPTY_STR);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string b;
+
+  std::string c(EMPTY_STR "u" EMPTY_STR);
+}
+
+void k() {
+  std::string a = "", b = "", c = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-2]]:23: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-3]]:31: warning: redundant string initialization
+  // CHECK-FIXES: std::string a, b, c;
+
+  std::string d = "u", e = "u", f = "u";
+}
Index: test/clang-tidy/readability-redundant-string-init-msvc.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-string-init-msvc.cpp
@@ -0,0 +1,122 @@
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const basic_string&);
+  // MSVC headers define two constructors instead of using optional arguments.
+  basic_string(const C *);
+  basic_string(const C *, const A &);
+  ~basic_string();
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f() {
+  std::string a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization [readability-redundant-string-init]
+  // CHECK-FIXES: std::string a;
+  std::string b("");
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string b;
+  std::string c = R"()";
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string c;
+  std::string d(R"()");
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
+  // CHECK-FIXES: std::string d;
+
+  std::string u = "u";
+  std::string w("w");
+  std::string x = R"(x)";
+  std::string y(R"(y)");
+  std::string z;
+}
+
+void g() {
+  std::wstring a = L"";
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring a;
+  std::wstring b(L"");
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring b;
+  std::wstring c = LR"()";
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring c;
+  std::wstring d(LR"()");
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring d;
+
+  std::wstring u = L"u";
+  std::wstring w(L"w");
+  std::wstring x = LR"(x)";
+  std::wstring y(LR"(y)");
+  std::wstring z;
+}
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const basic_string&);
+  // MSVC headers define two constructors instead of using optional arguments.
+  basic_string(const C *);
+  basic_string(const C *, const A &);
+  ~basic_string();
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f() {
+  std::string a = "";

Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

If __attribute__((linkonce_odr_linkage)) is not a proper name for explicitly 
setting linkage, how about __attribute((linkage=linkonce_odr))? This can be 
extended to other linkages too.


http://reviews.llvm.org/D18095



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


Re: [PATCH] D18095: Add __attribute__((linkonce_odr_linkage))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl removed rL LLVM as the repository for this revision.
yaxunl updated this revision to Diff 51297.
yaxunl added a comment.

Simplify description of this attribute in AttrDocs since it causes some 
confusion.


http://reviews.llvm.org/D18095

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-linkonce-odr-linkage.c
  test/Sema/attr-linkonce-odr-linkage.c

Index: test/Sema/attr-linkonce-odr-linkage.c
===
--- /dev/null
+++ test/Sema/attr-linkonce-odr-linkage.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+extern int g0 __attribute__((linkonce_odr_linkage));
+int g2 __attribute__((linkonce_odr_linkage));
+int __attribute__((linkonce_odr_linkage)) g4(void);
+void __attribute__((linkonce_odr_linkage)) g5(void) {
+}
+
+struct __attribute__((linkonce_odr_linkage)) s0 {}; // expected-warning {{'linkonce_odr_linkage' attribute only applies to variables and functions}}
+
+static int x __attribute__((linkonce_odr_linkage)); // expected-error {{weak declaration cannot have internal linkage}}
+
+int C; // expected-note {{previous definition is here}}
+extern int C __attribute__((linkonce_odr_linkage)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
+
+static int pr14946_x;
+extern int pr14946_x  __attribute__((linkonce_odr_linkage)); // expected-error {{weak declaration cannot have internal linkage}}
+
+static void pr14946_f();
+void pr14946_f() __attribute__((linkonce_odr_linkage)); // expected-error {{weak declaration cannot have internal linkage}}
Index: test/CodeGen/attr-linkonce-odr-linkage.c
===
--- /dev/null
+++ test/CodeGen/attr-linkonce-odr-linkage.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu < %s | FileCheck %s
+
+// CHECK: @a = linkonce_odr global i32 0
+__attribute__((linkonce_odr_linkage)) int a;
+
+// CHECK: define linkonce_odr void @test1_g()
+void test1_g(void) __attribute__((linkonce_odr_linkage));
+
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3611,6 +3611,19 @@
   InternalLinkageAttr(Range, Context, AttrSpellingListIndex);
 }
 
+LinkOnceODRLinkageAttr *
+Sema::mergeLinkOnceODRLinkageAttr(Decl *D, SourceRange Range,
+  IdentifierInfo *Ident,
+  unsigned AttrSpellingListIndex) {
+  if (checkAttrMutualExclusion(*this, D, Range, Ident) ||
+  checkAttrMutualExclusion(*this, D, Range, Ident))
+return nullptr;
+
+  return ::new (Context) LinkOnceODRLinkageAttr(Range,
+Context,
+AttrSpellingListIndex);
+}
+
 MinSizeAttr *Sema::mergeMinSizeAttr(Decl *D, SourceRange Range,
 unsigned AttrSpellingListIndex) {
   if (OptimizeNoneAttr *Optnone = D->getAttr()) {
@@ -5206,6 +5219,14 @@
 D->addAttr(Internal);
 }
 
+static void handleLinkOnceODRLinkageAttr(Sema &S, Decl *D,
+  const AttributeList &Attr) {
+  if (LinkOnceODRLinkageAttr *LinkOnce =
+  S.mergeLinkOnceODRLinkageAttr(D, Attr.getRange(), Attr.getName(),
+Attr.getAttributeSpellingListIndex()))
+D->addAttr(LinkOnce);
+}
+
 /// Handles semantic checking for features that are common to all attributes,
 /// such as checking whether a parameter was properly specified, or the correct
 /// number of arguments were passed, etc.
@@ -5701,6 +5722,8 @@
   case AttributeList::AT_InternalLinkage:
 handleInternalLinkageAttr(S, D, Attr);
 break;
+  case AttributeList::AT_LinkOnceODRLinkage:
+handleLinkOnceODRLinkageAttr(S, D, Attr);
 
   // Microsoft attributes:
   case AttributeList::AT_MSNoVTable:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -752,7 +752,6 @@
 llvm::GlobalValue::LinkageTypes
 CodeGenModule::getFunctionLinkage(GlobalDecl GD) {
   const auto *D = cast(GD.getDecl());
-
   GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
 
   if (isa(D) &&
@@ -2626,6 +2625,9 @@
 
 llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
 const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable) {
+  if (D->hasAttr())
+return llvm::GlobalVariable::LinkOnceODRLinkage;
+
   if (Linkage == GVA_Internal)
 return llvm::Function::InternalLinkage;
 
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/c

r264066 - Make build bots happy

2016-03-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Mar 22 12:10:07 2016
New Revision: 264066

URL: http://llvm.org/viewvc/llvm-project?rev=264066&view=rev
Log:
Make build bots happy

BasicBlock's lose their names for some builders, don't mention such
names.

Modified:
cfe/trunk/test/CodeGenCXX/pr27030.cpp

Modified: cfe/trunk/test/CodeGenCXX/pr27030.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr27030.cpp?rev=264066&r1=264065&r2=264066&view=diff
==
--- cfe/trunk/test/CodeGenCXX/pr27030.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pr27030.cpp Tue Mar 22 12:10:07 2016
@@ -12,6 +12,5 @@ void test1() { (int A::*)(a); }
 
 // CHECK: %[[adj:.*]] = sub nsw i32 %[[load]], 0
 // CHECK: %[[nv_adj:.*]] = select i1 true, i32 %[[adj]], i32 0
-// CHECK: br label %memptr.converted
 
 // CHECK: %[[memptr_converted:.*]] = phi i32 [ -1, {{.*}} ], [ %[[nv_adj]], 
{{.*}} ]


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


Re: [PATCH] D17861: [OpenCL] Accept __attribute__((nosvm))

2016-03-22 Thread Yaxun Liu via cfe-commits
yaxunl marked an inline comment as done.


Comment at: include/clang/Basic/Attr.td:701
@@ -699,1 +700,3 @@
 
+def OpenCLNoSVM : Attr {
+  let Spellings = [GNU<"nosvm">];

aaron.ballman wrote:
> yaxunl wrote:
> > aaron.ballman wrote:
> > > Since the attribute is ignored by clang, you should inherit from 
> > > IgnoredAttr.
> > I tried that from beginning. If I inherit from IgnoredAttr, it seems to be 
> > ignored by the parser and won't reach the sema check part, and I cannot 
> > emit error msg based on OpenCL version.
> Ah. so it isn't *totally* ignored. Okay, in that case, you should set ASTNode 
> = 0 and SemaHandler = 0.
If I set ASTNode = 0 and SemaHandler = 0, tablegen will not generate an id 
AT_OpenCLNoSVM to identify this attribute, and I cannot diagnose its invalid 
usage in SemaDeclAttr.cpp due to that. Then it seems the only viable place to 
diagnose its invalid usage is in Parser::ParseGNUAttributes. However currently 
Parser::ParseGNUAttributes only does generic processing of GNU attributes and 
does not diagnose specific attribute. Since there is no id for NoSVM attribute, 
I have to diagnose based on its name string.

Do we really want to do this?


Repository:
  rL LLVM

http://reviews.llvm.org/D17861



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


r264065 - [MS ABI] Assign an inheritance model for the dest of a member pointer upcast

2016-03-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Mar 22 11:44:39 2016
New Revision: 264065

URL: http://llvm.org/viewvc/llvm-project?rev=264065&view=rev
Log:
[MS ABI] Assign an inheritance model for the dest of a member pointer upcast

While we correctly assigned an inheritance model for the source of a
member pointer upcast, we did not do so for the destination.

This fixes PR27030.

Added:
cfe/trunk/test/CodeGenCXX/pr27030.cpp
Modified:
cfe/trunk/lib/Sema/SemaCast.cpp

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=264065&r1=264064&r2=264065&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Tue Mar 22 11:44:39 2016
@@ -1402,8 +1402,10 @@ TryStaticMemberPointerUpcast(Sema &Self,
 
   // Lock down the inheritance model right now in MS ABI, whether or not the
   // pointee types are the same.
-  if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft())
+  if (Self.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 (void)Self.isCompleteType(OpRange.getBegin(), SrcType);
+(void)Self.isCompleteType(OpRange.getBegin(), DestType);
+  }
 
   // T == T, modulo cv
   if (!Self.Context.hasSameUnqualifiedType(SrcMemPtr->getPointeeType(),

Added: cfe/trunk/test/CodeGenCXX/pr27030.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr27030.cpp?rev=264065&view=auto
==
--- cfe/trunk/test/CodeGenCXX/pr27030.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/pr27030.cpp Tue Mar 22 11:44:39 2016
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s
+struct A {};
+struct B : A {};
+extern "C" {
+extern int B::*a;
+void test1() { (int A::*)(a); }
+}
+// CHECK-LABEL: define void @test1(
+// CHECK: %[[load:.*]]   = load i32, i32* @a
+// CHECK: %[[memptr_cmp:.*]] = icmp ne i32 %[[load]], -1
+// CHECK: br i1 %[[memptr_cmp]]
+
+// CHECK: %[[adj:.*]] = sub nsw i32 %[[load]], 0
+// CHECK: %[[nv_adj:.*]] = select i1 true, i32 %[[adj]], i32 0
+// CHECK: br label %memptr.converted
+
+// CHECK: %[[memptr_converted:.*]] = phi i32 [ -1, {{.*}} ], [ %[[nv_adj]], 
{{.*}} ]


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


Re: r264021 - [Perf-training] Fixing an issue with multi-threading PGO generation

2016-03-22 Thread Chris Bieneman via cfe-commits
I totally didn’t know python had a portable way to do that!

Updated in r264064.

Thanks!
-Chris

> On Mar 22, 2016, at 9:26 AM, Vedant Kumar  wrote:
> 
> I think setting `cc1_env["LLVM_PROFILE_FILE"] = os.devnull` would be simpler.
> 
> vedant
> 
>> On Mar 21, 2016, at 7:55 PM, Chris Bieneman via cfe-commits 
>>  wrote:
>> 
>> Author: cbieneman
>> Date: Mon Mar 21 21:55:40 2016
>> New Revision: 264021
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=264021&view=rev
>> Log:
>> [Perf-training] Fixing an issue with multi-threading PGO generation
>> 
>> When LIT parallelizes the profraw file generation we need to generate unique 
>> temp filenames then clean them up after the driver executes.
>> 
>> Modified:
>>   cfe/trunk/utils/perf-training/perf-helper.py
>> 
>> Modified: cfe/trunk/utils/perf-training/perf-helper.py
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=264021&r1=264020&r2=264021&view=diff
>> ==
>> --- cfe/trunk/utils/perf-training/perf-helper.py (original)
>> +++ cfe/trunk/utils/perf-training/perf-helper.py Mon Mar 21 21:55:40 2016
>> @@ -16,6 +16,7 @@ import argparse
>> import time
>> import bisect
>> import shlex
>> +import tempfile
>> 
>> test_env = { 'PATH': os.environ['PATH'] }
>> 
>> @@ -149,10 +150,12 @@ def cc1(args):
>> 
>>  # clear the profile file env, so that we don't generate profdata
>>  # when capturing the cc1 command
>> +  handle, profraw_file = tempfile.mkstemp()
>> +  os.close(handle)
>>  cc1_env = test_env
>> -  cc1_env["LLVM_PROFILE_FILE"] = "driver.prfraw"
>> +  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
>>  cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
>> -  os.remove("driver.prfraw")
>> +  os.remove(profraw_file)
>> 
>>  subprocess.check_call(cc1_cmd)
>>  return 0;
>> 
>> 
>> ___
>> 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


r264064 - [Perf-training] Using os.devnull instead of a temp file

2016-03-22 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 22 11:33:23 2016
New Revision: 264064

URL: http://llvm.org/viewvc/llvm-project?rev=264064&view=rev
Log:
[Perf-training] Using os.devnull instead of a temp file

This is based on post-commit feedback from Vedant. Totally didn't know that 
existed and worked on Windows.

Thanks Vedant!

Modified:
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=264064&r1=264063&r2=264064&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Mar 22 11:33:23 2016
@@ -152,12 +152,9 @@ def cc1(args):
 
   # clear the profile file env, so that we don't generate profdata
   # when capturing the cc1 command
-  handle, profraw_file = tempfile.mkstemp()
-  os.close(handle)
   cc1_env = test_env
-  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
+  cc1_env["LLVM_PROFILE_FILE"] = os.devnull
   cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
-  os.remove(profraw_file)
 
   subprocess.check_call(cc1_cmd)
   return 0;


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


Re: r257934 - [CMake] Support generation of linker order files using dtrace

2016-03-22 Thread Chris Bieneman via cfe-commits
Sean,

All good feedback.

Using print_function was done in r257936 with some other feedback from Bogner.

The rest of your feedback I believe I have addressed in r264063.

-Chris

> On Mar 21, 2016, at 9:21 PM, Sean Silva  wrote:
> 
> 
> 
> On Fri, Jan 15, 2016 at 1:21 PM, Chris Bieneman via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: cbieneman
> Date: Fri Jan 15 15:21:12 2016
> New Revision: 257934
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=257934&view=rev 
> 
> Log:
> [CMake] Support generation of linker order files using dtrace
> 
> Summary:
> This patch extends the lit-based perf-training tooling supplied for PGO data 
> generation to also generate linker order files using dtrace.
> 
> This patch should work on any system that has dtrace. If CMake can find the 
> dtrace tool it will generate a target 'generate-order-file' which will run 
> the per-training tests wrapped by dtrace to capture function entries. There 
> are several algorithms implemented for sorting the order files which can be 
> experimented with for best performance. The dtrace wrapper also supports bot 
> oneshot and pid probes.
> 
> The perf-helper.py changes to support order file construction are ported from 
> internal changes by ddunbar; he gets all the credit for the hard work here, I 
> just copy and pasted.
> 
> Note: I've tested these patches on FreeBSD and OS X 10.10.
> 
> Reviewers: ddunbar, bogner, silvas
> 
> Subscribers: llvm-commits, emaste
> 
> Differential Revision: http://reviews.llvm.org/D16134 
> 
> 
> Added:
> cfe/trunk/utils/perf-training/order-files.lit.cfg
> cfe/trunk/utils/perf-training/order-files.lit.site.cfg.in 
> 
> Modified:
> cfe/trunk/utils/perf-training/CMakeLists.txt
> cfe/trunk/utils/perf-training/perf-helper.py
> 
> Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=257934&r1=257933&r2=257934&view=diff
>  
> 
> ==
> --- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
> +++ cfe/trunk/utils/perf-training/CMakeLists.txt Fri Jan 15 15:21:12 2016
> @@ -1,24 +1,24 @@
> -if(LLVM_BUILD_INSTRUMENTED)
> -  if (CMAKE_CFG_INTDIR STREQUAL ".")
> -set(LLVM_BUILD_MODE ".")
> -  else ()
> -set(LLVM_BUILD_MODE "%(build_mode)s")
> -  endif ()
> +if (CMAKE_CFG_INTDIR STREQUAL ".")
> +  set(LLVM_BUILD_MODE ".")
> +else ()
> +  set(LLVM_BUILD_MODE "%(build_mode)s")
> +endif ()
> 
> -  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
> ${LLVM_RUNTIME_OUTPUT_INTDIR})
> +string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
> ${LLVM_RUNTIME_OUTPUT_INTDIR})
> 
> +if(LLVM_BUILD_INSTRUMENTED)
>configure_lit_site_cfg(
>  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 
> -${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
> +${CMAKE_CURRENT_BINARY_DIR}/pgo-data/lit.site.cfg
>  )
> 
>add_lit_testsuite(generate-profraw "Generating clang PGO data"
> -${CMAKE_CURRENT_BINARY_DIR}
> +${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
>  DEPENDS clang clear-profraw
>  )
> 
>add_custom_target(clear-profraw
> -COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
> clean ${CMAKE_CURRENT_BINARY_DIR}
> +COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
> clean ${CMAKE_CURRENT_BINARY_DIR} profraw
>  COMMENT "Clearing old profraw data")
> 
>if(NOT LLVM_PROFDATA)
> @@ -34,3 +34,26 @@ if(LLVM_BUILD_INSTRUMENTED)
>  COMMENT "Merging profdata"
>  DEPENDS generate-profraw)
>  endif()
> +
> +find_program(DTRACE dtrace)
> +if(DTRACE)
> +  configure_lit_site_cfg(
> +${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in 
> 
> +${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg
> +)
> +
> +  add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
> +${CMAKE_CURRENT_BINARY_DIR}/order-files/
> +DEPENDS clang clear-dtrace-logs
> +)
> +
> +  add_custom_target(clear-dtrace-logs
> +COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
> clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
> +COMMENT "Clearing old dtrace data")
> +
> +
> +  add_custom_target(generate-order-file
> +COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
> gen-order-file --binary $ --output 
> ${CMAKE_CURRENT_BINARY_DIR}/clang.order ${CMAKE_CURRENT_BINARY_DIR}
> +COMMENT "Generating order file"
> +DEPENDS generate-dtrace-logs)
> +endif()
> 
> Added: cfe/trunk/utils/perf-training/order-files.lit.cfg
> URL: 
> http://llvm.org/viewvc/l

r264063 - [Perf-training] Cleanup based on feedback from Sean Silvas

2016-03-22 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Mar 22 11:27:35 2016
New Revision: 264063

URL: http://llvm.org/viewvc/llvm-project?rev=264063&view=rev
Log:
[Perf-training] Cleanup based on feedback from Sean Silvas

Sean provided feedback based on r257934 on cfe-commits. This change addresses 
that feedback.

Modified:
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=264063&r1=264062&r2=264063&view=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Mar 22 11:27:35 2016
@@ -99,9 +99,11 @@ def dtrace(args):
   if sys.platform == "darwin":
 dtrace_args.append('-xmangled')
 
-  f = open("%d.dtrace" % os.getpid(), "w")
   start_time = time.time()
-  subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE)
+
+  with open("%d.dtrace" % os.getpid(), "w") as f:
+subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE)
+
   elapsed = time.time() - start_time
   print("... data collection took %.4fs" % elapsed)
 
@@ -111,7 +113,7 @@ def get_cc1_command_for_args(cmd, env):
   # Find the cc1 command used by the compiler. To do this we execute the
   # compiler with '-###' to figure out what it wants to do.
   cmd = cmd + ['-###']
-  cc_output = check_output(cmd, stderr=subprocess.STDOUT, env=env).strip()
+  cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, 
env=env).strip()
   cc_commands = []
   for ln in cc_output.split('\n'):
   # Filter out known garbage.
@@ -246,13 +248,6 @@ def parse_dtrace_symbol_file(path, all_s
 for s in possible_symbols:
   yield (current_timestamp, s)
 
-def check_output(*popen_args, **popen_kwargs):
-p = subprocess.Popen(stdout=subprocess.PIPE, *popen_args, **popen_kwargs)
-stdout,stderr = p.communicate()
-if p.wait() != 0:
-raise RuntimeError("process failed")
-return stdout
-
 def uniq(list):
   seen = set()
   for item in list:
@@ -346,7 +341,7 @@ def genOrderFile(args):
   # If the user gave us a binary, get all the symbols in the binary by
   # snarfing 'nm' output.
   if opts.binary_path is not None:
- output = check_output(['nm', '-P', opts.binary_path])
+ output = subprocess.check_output(['nm', '-P', opts.binary_path])
  lines = output.split("\n")
  all_symbols = [ln.split(' ',1)[0]
 for ln in lines


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


Re: r264021 - [Perf-training] Fixing an issue with multi-threading PGO generation

2016-03-22 Thread Vedant Kumar via cfe-commits
I think setting `cc1_env["LLVM_PROFILE_FILE"] = os.devnull` would be simpler.

vedant

> On Mar 21, 2016, at 7:55 PM, Chris Bieneman via cfe-commits 
>  wrote:
> 
> Author: cbieneman
> Date: Mon Mar 21 21:55:40 2016
> New Revision: 264021
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=264021&view=rev
> Log:
> [Perf-training] Fixing an issue with multi-threading PGO generation
> 
> When LIT parallelizes the profraw file generation we need to generate unique 
> temp filenames then clean them up after the driver executes.
> 
> Modified:
>cfe/trunk/utils/perf-training/perf-helper.py
> 
> Modified: cfe/trunk/utils/perf-training/perf-helper.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=264021&r1=264020&r2=264021&view=diff
> ==
> --- cfe/trunk/utils/perf-training/perf-helper.py (original)
> +++ cfe/trunk/utils/perf-training/perf-helper.py Mon Mar 21 21:55:40 2016
> @@ -16,6 +16,7 @@ import argparse
> import time
> import bisect
> import shlex
> +import tempfile
> 
> test_env = { 'PATH': os.environ['PATH'] }
> 
> @@ -149,10 +150,12 @@ def cc1(args):
> 
>   # clear the profile file env, so that we don't generate profdata
>   # when capturing the cc1 command
> +  handle, profraw_file = tempfile.mkstemp()
> +  os.close(handle)
>   cc1_env = test_env
> -  cc1_env["LLVM_PROFILE_FILE"] = "driver.prfraw"
> +  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
>   cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
> -  os.remove("driver.prfraw")
> +  os.remove(profraw_file)
> 
>   subprocess.check_call(cc1_cmd)
>   return 0;
> 
> 
> ___
> 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] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Adding Manuel, who might have better ideas.

In http://reviews.llvm.org/D17981#374904, @rnk wrote:

> In http://reviews.llvm.org/D17981#374553, @etienneb wrote:
>
> > This is a huge difference. I didn't expect dependencies to bring so much 
> > code.
> >  I'm not a fan of having an empty statement and increasing false positives 
> > ratio.
> >  Would it be possible to skip whole declarations with asm-stm, and flag 
> > them as "ignored / not parsable"?
>
>
> I don't actually think there are that many false positives, but I wanted to 
> hear from Alex in case I'm wrong. I was hoping he had better ideas on how to 
> suppress a diagnostic error in clang and run the clang-tidy checks anyway.


I'm not familiar with the capabilities of MS-asm blocks, but if they can 
contain function calls, for example, we might lose valuable information, if we 
skip them. The possibility of a false positive depends on a specific check, 
it's hard to tell in general. There's also a more generic thing that can stop 
working properly: finding compilation errors inside asm blocks and applying 
fixes to these errors (if there are any fixes generated from parsing MS-asm 
blocks). Not sure how frequently this will happen though.

> My best idea is that we make this diagnostic a default-error warning and then 
> build with -Wno-unparseable-assembly or something. That's not a very good 
> solution, though. =\


Yes, not a very good solution for the reasons outlined above.

> 

> 

> > We could gate this code under a define. I'm not a fan of define, but it 
> > seems to be a compromise for the size.

> 

> > 

> 

> > Something like: LIBTOOLING_ENABLE_INLINE_ASM_PARSER

> 

> > 

> 

> > If we decide to pursue that direction, then it should probably be for every 
> > tools.

> 

> 

> I'd really rather not do that.


What's your concern? If we want parsing code inside MS asm blocks like the 
compiler does, we'll need to pay the cost of the asm parser. If the binary size 
is a large problem here, can we maybe reduce the set of dependencies of the MS 
asm parser?

In any case, I'm sure many users don't need this functionality, so it should be 
made compile-time configurable.


http://reviews.llvm.org/D17981



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


Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-03-22 Thread Matt Kulukundis via cfe-commits
fowles added a subscriber: fowles.


Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:8
@@ +7,3 @@
+  void nonConstMethod() {}
+  virtual ~ExpensiveToCopyType() {}
+};

you don't actually need to fill in these methods, just declare them


Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:52
@@ +51,3 @@
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+}

no fix for this case?


http://reviews.llvm.org/D17491



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Matt Kulukundis via cfe-commits
fowles updated this revision to Diff 51289.
fowles added a comment.

rebased to latest.  Can someone submit this for me I don't have commit bits.


http://reviews.llvm.org/D18149

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -1,28 +1,33 @@
 // RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
 
 struct ExpensiveToCopyType {
-  ExpensiveToCopyType() {}
-  virtual ~ExpensiveToCopyType() {}
-  const ExpensiveToCopyType &reference() const { return *this; }
-  void nonConstMethod() {}
+  ExpensiveToCopyType();
+  virtual ~ExpensiveToCopyType();
+  const ExpensiveToCopyType &reference() const;
+  void nonConstMethod();
+  bool constMethod() const;
 };
 
 struct TrivialToCopyType {
-  const TrivialToCopyType &reference() const { return *this; }
+  const TrivialToCopyType &reference() const;
 };
 
-const ExpensiveToCopyType &ExpensiveTypeReference() {
-  static const ExpensiveToCopyType *Type = new ExpensiveToCopyType();
-  return *Type;
-}
+struct WeirdCopyCtorType {
+  WeirdCopyCtorType();
+  WeirdCopyCtorType(const WeirdCopyCtorType &w, bool oh_yes = true);
 
-const TrivialToCopyType &TrivialTypeReference() {
-  static const TrivialToCopyType *Type = new TrivialToCopyType();
-  return *Type;
-}
+  void nonConstMethod();
+  bool constMethod() const;
+};
+
+ExpensiveToCopyType global_expensive_to_copy_type;
+
+const ExpensiveToCopyType &ExpensiveTypeReference();
+const TrivialToCopyType &TrivialTypeReference();
 
 void mutate(ExpensiveToCopyType &);
 void mutate(ExpensiveToCopyType *);
+void useAsConstPointer(const ExpensiveToCopyType *);
 void useAsConstReference(const ExpensiveToCopyType &);
 void useByValue(ExpensiveToCopyType);
 
@@ -203,23 +208,133 @@
   ExpensiveToCopyType Obj;
 };
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)	\
-  void functionWith##TYPE(const TYPE& T) {		\
-auto AssignedInMacro = T.reference();		\
-  }			\
+#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)  \
+  void functionWith##TYPE(const TYPE &T) { \
+auto AssignedInMacro = T.reference();  \
+  }\
 // Ensure fix is not applied.
 // CHECK-FIXES: auto AssignedInMacro = T.reference();
 
-
 UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
 
-#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT)	\
-  ARGUMENT
+#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT) ARGUMENT
 
 void PositiveMacroArgument(const ExpensiveToCopyType &Obj) {
   UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(auto CopyInMacroArg = Obj.reference());
   // CHECK-MESSAGES: [[@LINE-1]]:48: warning: the variable 'CopyInMacroArg' is copy-constructed
   // Ensure fix is not applied.
   // CHECK-FIXES: auto CopyInMacroArg = Obj.reference()
 }
+
+void PositiveLocalCopyConstMethodInvoked() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_1 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_1 = orig;
+  copy_1.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyUsingExplicitCopyCtor() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_2(orig);
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_2'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_2(orig);
+  copy_2.constMethod();
+  orig.constMethod();
+}
+
+void PositiveLocalCopyCopyIsArgument(const ExpensiveToCopyType &orig) {
+  ExpensiveToCopyType copy_3 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_3'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_3 = orig;
+  copy_3.constMethod();
+}
+
+void PositiveLocalCopyUsedAsConstRef() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_4 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_4'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_4 = orig;
+  useAsConstReference(orig);
+}
+
+void PositiveLocalCopyTwice() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy_5 = orig;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_5'
+  // CHECK-FIXES: const ExpensiveToCopyType& copy_5 = orig;
+  ExpensiveToCopyType copy_6 = copy_5;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warni

Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Matt Kulukundis via cfe-commits
fowles added inline comments.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:21
@@ +20,3 @@
+
+void recordFixes(const VarDecl &Var, ASTContext &Context,
+ DiagnosticBuilder &Diagnostic) {

I am inclined to just leave it as is for the moment, this is already isolated 
code that doesn't escape the current file.


http://reviews.llvm.org/D18149



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


Re: [PATCH] D18149: Add check for unneeded copies of locals

2016-03-22 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG



Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:21
@@ +20,3 @@
+
+void recordFixes(const VarDecl &Var, ASTContext &Context,
+ DiagnosticBuilder &Diagnostic) {

nit: Alternatively, you could return llvm::Optional and apply it in 
the caller. Might result in a bit better separation of responsibilities.


http://reviews.llvm.org/D18149



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


  1   2   >