[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-10-11 Thread Akira Hatanaka via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added a comment.

(I'm replying to the comment near TreeTransform.h:11967 because phab doesn't 
let me hit save)

It looks like RebuildCXXPseudoDestructorExpr isn't even called because a 
MemberExpr is created instead of a CXXPseudoDestructorExpr.




Comment at: lib/Sema/TreeTransform.h:2127
+
+if (isa(FoundDecl))
+  DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);

rsmith wrote:
> I don't see any reason why this should be specific to destructors. But this 
> is the wrong place for this change; by the time we reach `Rebuild*` we should 
> have already transformed everything that we need to transform.
> 
> Perhaps the problem is instead...
If we want to do the transformation before entering RebuildMemberExpr, I think 
it's also possible to do it in TreeTransform::TransformMemberExpr.


https://reviews.llvm.org/D24969



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-10-11 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 74324.
ahatanak added a comment.

Added a call to operator C1* in test case.


https://reviews.llvm.org/D24969

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/destructor.cpp


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2119,6 +2119,11 @@
NamedDecl *FirstQualifierInScope) {
 ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
   isArrow);
+DeclarationNameInfo DNI = MemberNameInfo;
+
+if (isa(FoundDecl))
+  DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+
 if (!Member->getDeclName()) {
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
@@ -2136,7 +2141,7 @@
   Base = BaseResult.get();
   ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
   MemberExpr *ME = new (getSema().Context)
-  MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo,
+  MemberExpr(Base, isArrow, OpLoc, Member, DNI,
  cast(Member)->getType(), VK, OK_Ordinary);
   return ME;
 }
@@ -2149,7 +2154,7 @@
 
 // FIXME: this involves duplicating earlier analysis in a lot of
 // cases; we should avoid this when possible.
-LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
+LookupResult R(getSema(), DNI, Sema::LookupMemberName);
 R.addDecl(FoundDecl);
 R.resolveKind();
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4846,7 +4846,11 @@
 
 NamedDecl *Result = nullptr;
 if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+  DeclarationName Name = D->getDeclName();
+  if (auto *DD = dyn_cast(D))
+Name =
+SubstDeclarationNameInfo(DD->getNameInfo(), 
TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2119,6 +2119,11 @@
NamedDecl *FirstQualifierInScope) {
 ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
   isArrow);
+DeclarationNameInfo DNI = MemberNameInfo;
+
+if (isa(FoundDecl))
+  DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+
 if (!Member->getDeclName()) {
   // We have a reference to an unnamed field.  This is always the
   // base of an anonymous struct/union member access, i.e. the
@@ -2136,7 +2141,7 @@
   Base = BaseResult.get();
   ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
   MemberExpr *ME = new (getSema().Context)
-  MemberExpr(Base, isArrow, OpLoc, Member, MemberNameInfo,
+  MemberExpr(Base, isArrow, OpLoc, Member, DNI,
  cast(Member)->getType(), VK, OK_Ordinary);
   return ME;
 }
@@ -2149,7 +2154,7 @@
 
 // FIXME: this involves duplicating earlier analysis in a lot of
 // cases; we should avoid this when possible.
-LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
+LookupResult R(getSema(), DNI, Sema::LookupMemberName);
 R.addDecl(FoundDecl);
 R.resolveKind();
 
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp

[libcxx] r283976 - Fix two more tests that hang when testing against libstdc++

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 23:56:23 2016
New Revision: 283976

URL: http://llvm.org/viewvc/llvm-project?rev=283976=rev
Log:
Fix two more tests that hang when testing against libstdc++

Modified:
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp

libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp

Modified: 
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp?rev=283976=283975=283976=diff
==
--- 
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp 
Tue Oct 11 23:56:23 2016
@@ -14,6 +14,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// This test hangs during recursive template instantiation with libstdc++
+// UNSUPPORTED: libstdc++
+
 #include 
 #include 
 #include 

Modified: 
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp?rev=283976=283975=283976=diff
==
--- 
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp
 Tue Oct 11 23:56:23 2016
@@ -14,5 +14,8 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// This test hangs during recursive template instantiation with libstdc++
+// UNSUPPORTED: libstdc++
+
 #define _LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE
 #include "make_integer_seq.fail.cpp"


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


[PATCH] D25491: [libcxx] Use C++14 when building libc++ with musl

2016-10-11 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.



Comment at: CMakeLists.txt:327
 # Required flags ==
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build 
dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})

phosek wrote:
> EricWF wrote:
> > Why not just set `LIBCXX_STANDARD_VER` differently instead of replacing it 
> > after the fact?
> I totally missed it; this change was a part of a downstream patch we were 
> using for building Fuchsia toolchain and it predates this option. Using this 
> option, I can override the dialect only for our build, which is perfectly 
> fine for Fuchsia since we default to C++14. I'd be happy to abandon this 
> patch unless you want to persist that setting for musl?
Since we support MUSL it would be nice if libc++ built out of the box. Making 
the option persistent for MUSL makes the most sense to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D25491



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


[libcxx] r283975 - Prevent the test suite from hanging when run against libstdc++

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 23:29:50 2016
New Revision: 283975

URL: http://llvm.org/viewvc/llvm-project?rev=283975=rev
Log:
Prevent the test suite from hanging when run against libstdc++

Modified:
libcxx/trunk/test/libcxx/test/config.py

libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=283975=283974=283975=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Oct 11 23:29:50 2016
@@ -226,6 +226,7 @@ class Configuration(object):
 'unsupported value for "cxx_stdlib_under_test": %s'
 % self.cxx_stdlib_under_test)
 if self.cxx_stdlib_under_test == 'libstdc++':
+self.config.available_features.add('libstdc++')
 # Manually enable the experimental and filesystem tests for 
libstdc++
 # if the options aren't present.
 # FIXME this is a hack.

Modified: 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp?rev=283975=283974=283975=diff
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp 
Tue Oct 11 23:29:50 2016
@@ -10,6 +10,11 @@
 // XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
+// This test hangs forever when built against libstdc++. In order to allow
+// validation of the test suite against other STLs we have to mark it
+// unsupported.
+// UNSUPPORTED: libstdc++
+
 // 
 
 // template 


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


[PATCH] D25491: [libcxx] Use C++14 when building libc++ with musl

2016-10-11 Thread Petr Hosek via cfe-commits
phosek added inline comments.



Comment at: CMakeLists.txt:327
 # Required flags ==
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build 
dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})

EricWF wrote:
> Why not just set `LIBCXX_STANDARD_VER` differently instead of replacing it 
> after the fact?
I totally missed it; this change was a part of a downstream patch we were using 
for building Fuchsia toolchain and it predates this option. Using this option, 
I can override the dialect only for our build, which is perfectly fine for 
Fuchsia since we default to C++14. I'd be happy to abandon this patch unless 
you want to persist that setting for musl?


Repository:
  rL LLVM

https://reviews.llvm.org/D25491



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


Re: r283963 - [CUDA] Make touching a kernel from a __host__ __device__ function a deferred error.

2016-10-11 Thread Justin Lebar via cfe-commits
Yes, I have yet to figure out when that REQUIRES comment is, erm,
required.  Sorry.  :-/

I believe Art checked in a fix.

On Oct 11, 2016 7:22 PM, "Chandler Carruth"  wrote:

> On Tue, Oct 11, 2016 at 6:39 PM Justin Lebar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: jlebar
>>
>> Date: Tue Oct 11 20:30:08 2016
>>
>> New Revision: 283963
>>
>>
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=283963=rev
>>
>> Log:
>>
>> [CUDA] Make touching a kernel from a __host__ __device__ function a
>> deferred error.
>>
>>
>>
>> Previously, this was an immediate, don't pass go, don't collect $200
>>
>> error.  But this precludes us from writing code like
>>
>>
>>
>>   __host__ __device__ void launch_kernel() {
>>
>> kernel<<<...>>>();
>>
>>   }
>>
>>
>>
>> Such code isn't wrong, following our notions of right and wrong in CUDA,
>>
>> unless it's codegen'ed.
>>
>>
>>
>> Added:
>>
>> cfe/trunk/test/SemaCUDA/function-overload-hd.cu
>
>
> This test fails for buildbots that don't configure the NVPTX backend:
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-
> a15/builds/15830/steps/ninja%20check%201/logs/FAIL%3A%
> 20Clang%3A%3Afunction-overload-hd.cu
>
>
>> Modified:
>>
>> cfe/trunk/lib/Sema/SemaCUDA.cpp
>>
>> cfe/trunk/test/SemaCUDA/function-overload.cu
>>
>> cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
>>
>>
>>
>> Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
>>
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
>> SemaCUDA.cpp?rev=283963=283962=283963=diff
>>
>> 
>> ==
>>
>> --- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
>>
>> +++ cfe/trunk/lib/Sema/SemaCUDA.cpp Tue Oct 11 20:30:08 2016
>>
>> @@ -120,8 +120,7 @@ Sema::IdentifyCUDAPreference(const Funct
>>
>>// (a) Can't call global from some contexts until we support CUDA's
>>
>>// dynamic parallelism.
>>
>>if (CalleeTarget == CFT_Global &&
>>
>> -  (CallerTarget == CFT_Global || CallerTarget == CFT_Device ||
>>
>> -   (CallerTarget == CFT_HostDevice && getLangOpts().CUDAIsDevice)))
>>
>> +  (CallerTarget == CFT_Global || CallerTarget == CFT_Device))
>>
>>  return CFP_Never;
>>
>>
>>
>>// (b) Calling HostDevice is OK for everyone.
>>
>>
>>
>> Added: cfe/trunk/test/SemaCUDA/function-overload-hd.cu
>>
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> SemaCUDA/function-overload-hd.cu?rev=283963=auto
>>
>> 
>> ==
>>
>> --- cfe/trunk/test/SemaCUDA/function-overload-hd.cu (added)
>>
>> +++ cfe/trunk/test/SemaCUDA/function-overload-hd.cu Tue Oct 11 20:30:08
>> 2016
>>
>> @@ -0,0 +1,28 @@
>>
>> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -o /dev/null
>> -verify \
>>
>> +// RUN:   -verify-ignore-unexpected=note %s
>>
>> +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -S -o /dev/null
>> -fcuda-is-device \
>>
>> +// RUN:   -verify -verify-ignore-unexpected=note %s
>>
>> +
>>
>> +#include "Inputs/cuda.h"
>>
>> +
>>
>> +// FIXME: Merge into function-overload.cu once deferred errors can be
>> emitted
>>
>> +// when non-deferred errors are present.
>>
>> +
>>
>> +#if !defined(__CUDA_ARCH__)
>>
>> +//expected-no-diagnostics
>>
>> +#endif
>>
>> +
>>
>> +typedef void (*GlobalFnPtr)();  // __global__ functions must return void.
>>
>> +
>>
>> +__global__ void g() {}
>>
>> +
>>
>> +__host__ __device__ void hd() {
>>
>> +  GlobalFnPtr fp_g = g;
>>
>> +#if defined(__CUDA_ARCH__)
>>
>> +  // expected-error@-2 {{reference to __global__ function 'g' in
>> __host__ __device__ function}}
>>
>> +#endif
>>
>> +  g<<<0,0>>>();
>>
>> +#if defined(__CUDA_ARCH__)
>>
>> +  // expected-error@-2 {{reference to __global__ function 'g' in
>> __host__ __device__ function}}
>>
>> +#endif  // __CUDA_ARCH__
>>
>> +}
>>
>>
>>
>> Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
>>
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> SemaCUDA/function-overload.cu?rev=283963=283962=283963=diff
>>
>> 
>> ==
>>
>> --- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
>>
>> +++ cfe/trunk/test/SemaCUDA/function-overload.cu Tue Oct 11 20:30:08 2016
>>
>> @@ -181,18 +181,7 @@ __host__ __device__ void hostdevicef() {
>>
>>CurrentFnPtr fp_cdh = cdh;
>>
>>CurrentReturnTy ret_cdh = cdh();
>>
>>
>>
>> -  GlobalFnPtr fp_g = g;
>>
>> -#if defined(__CUDA_ARCH__)
>>
>> -  // expected-error@-2 {{reference to __global__ function 'g' in
>> __host__ __device__ function}}
>>
>> -#endif
>>
>> -  g();
>>
>> -  g<<<0,0>>>();
>>
>> -#if !defined(__CUDA_ARCH__)
>>
>> -  // expected-error@-3 {{call to global function g not configured}}
>>
>> -#else
>>
>> -  // expected-error@-5 {{no matching function for call to 'g'}}
>>
>> -  // expected-error@-5 {{reference to __global__ function 'g' in
>> __host__ __device__ function}}
>>
>> -#endif  // 

Re: r283963 - [CUDA] Make touching a kernel from a __host__ __device__ function a deferred error.

2016-10-11 Thread Chandler Carruth via cfe-commits
On Tue, Oct 11, 2016 at 6:39 PM Justin Lebar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jlebar
>
> Date: Tue Oct 11 20:30:08 2016
>
> New Revision: 283963
>
>
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283963=rev
>
> Log:
>
> [CUDA] Make touching a kernel from a __host__ __device__ function a
> deferred error.
>
>
>
> Previously, this was an immediate, don't pass go, don't collect $200
>
> error.  But this precludes us from writing code like
>
>
>
>   __host__ __device__ void launch_kernel() {
>
> kernel<<<...>>>();
>
>   }
>
>
>
> Such code isn't wrong, following our notions of right and wrong in CUDA,
>
> unless it's codegen'ed.
>
>
>
> Added:
>
> cfe/trunk/test/SemaCUDA/function-overload-hd.cu


This test fails for buildbots that don't configure the NVPTX backend:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/15830/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Afunction-overload-hd.cu



> Modified:
>
> cfe/trunk/lib/Sema/SemaCUDA.cpp
>
> cfe/trunk/test/SemaCUDA/function-overload.cu
>
> cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
>
>
>
> Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
>
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=283963=283962=283963=diff
>
>
> ==
>
> --- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
>
> +++ cfe/trunk/lib/Sema/SemaCUDA.cpp Tue Oct 11 20:30:08 2016
>
> @@ -120,8 +120,7 @@ Sema::IdentifyCUDAPreference(const Funct
>
>// (a) Can't call global from some contexts until we support CUDA's
>
>// dynamic parallelism.
>
>if (CalleeTarget == CFT_Global &&
>
> -  (CallerTarget == CFT_Global || CallerTarget == CFT_Device ||
>
> -   (CallerTarget == CFT_HostDevice && getLangOpts().CUDAIsDevice)))
>
> +  (CallerTarget == CFT_Global || CallerTarget == CFT_Device))
>
>  return CFP_Never;
>
>
>
>// (b) Calling HostDevice is OK for everyone.
>
>
>
> Added: cfe/trunk/test/SemaCUDA/function-overload-hd.cu
>
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload-hd.cu?rev=283963=auto
>
>
> ==
>
> --- cfe/trunk/test/SemaCUDA/function-overload-hd.cu (added)
>
> +++ cfe/trunk/test/SemaCUDA/function-overload-hd.cu Tue Oct 11 20:30:08
> 2016
>
> @@ -0,0 +1,28 @@
>
> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -o /dev/null
> -verify \
>
> +// RUN:   -verify-ignore-unexpected=note %s
>
> +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -S -o /dev/null
> -fcuda-is-device \
>
> +// RUN:   -verify -verify-ignore-unexpected=note %s
>
> +
>
> +#include "Inputs/cuda.h"
>
> +
>
> +// FIXME: Merge into function-overload.cu once deferred errors can be
> emitted
>
> +// when non-deferred errors are present.
>
> +
>
> +#if !defined(__CUDA_ARCH__)
>
> +//expected-no-diagnostics
>
> +#endif
>
> +
>
> +typedef void (*GlobalFnPtr)();  // __global__ functions must return void.
>
> +
>
> +__global__ void g() {}
>
> +
>
> +__host__ __device__ void hd() {
>
> +  GlobalFnPtr fp_g = g;
>
> +#if defined(__CUDA_ARCH__)
>
> +  // expected-error@-2 {{reference to __global__ function 'g' in
> __host__ __device__ function}}
>
> +#endif
>
> +  g<<<0,0>>>();
>
> +#if defined(__CUDA_ARCH__)
>
> +  // expected-error@-2 {{reference to __global__ function 'g' in
> __host__ __device__ function}}
>
> +#endif  // __CUDA_ARCH__
>
> +}
>
>
>
> Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
>
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=283963=283962=283963=diff
>
>
> ==
>
> --- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
>
> +++ cfe/trunk/test/SemaCUDA/function-overload.cu Tue Oct 11 20:30:08 2016
>
> @@ -181,18 +181,7 @@ __host__ __device__ void hostdevicef() {
>
>CurrentFnPtr fp_cdh = cdh;
>
>CurrentReturnTy ret_cdh = cdh();
>
>
>
> -  GlobalFnPtr fp_g = g;
>
> -#if defined(__CUDA_ARCH__)
>
> -  // expected-error@-2 {{reference to __global__ function 'g' in
> __host__ __device__ function}}
>
> -#endif
>
> -  g();
>
> -  g<<<0,0>>>();
>
> -#if !defined(__CUDA_ARCH__)
>
> -  // expected-error@-3 {{call to global function g not configured}}
>
> -#else
>
> -  // expected-error@-5 {{no matching function for call to 'g'}}
>
> -  // expected-error@-5 {{reference to __global__ function 'g' in
> __host__ __device__ function}}
>
> -#endif  // __CUDA_ARCH__
>
> +  g(); // expected-error {{call to global function g not configured}}
>
>  }
>
>
>
>  // Test for address of overloaded function resolution in the global
> context.
>
>
>
> Modified: cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
>
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu?rev=283963=283962=283963=diff
>
>
> 

[PATCH] D25491: [libcxx] Use C++14 when building libc++ with musl

2016-10-11 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

> musl's pthread implementations use volatile types in their structs which is 
> not being constexpr in C++11 but is in C++14.

This means that libc++'s std::mutex is unsafe to use during dynamic 
initialization in C++11 with MUSL, which would really suck except that Clang 
emits always emits the initialization as a constant expression, ever if it's 
not guaranteed by the core language.

@mclow.lists Do you have any issue bumping the std version while building for 
MUSL only?




Comment at: CMakeLists.txt:327
 # Required flags ==
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build 
dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})

Why not just set `LIBCXX_STANDARD_VER` differently instead of replacing it 
after the fact?


Repository:
  rL LLVM

https://reviews.llvm.org/D25491



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


r283964 - Added REQUIRED triples to the test that fails on some ARM buildbots.

2016-10-11 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Oct 11 21:08:08 2016
New Revision: 283964

URL: http://llvm.org/viewvc/llvm-project?rev=283964=rev
Log:
Added REQUIRED triples to the test that fails on some ARM buildbots.

Modified:
cfe/trunk/test/SemaCUDA/function-overload-hd.cu

Modified: cfe/trunk/test/SemaCUDA/function-overload-hd.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload-hd.cu?rev=283964=283963=283964=diff
==
--- cfe/trunk/test/SemaCUDA/function-overload-hd.cu (original)
+++ cfe/trunk/test/SemaCUDA/function-overload-hd.cu Tue Oct 11 21:08:08 2016
@@ -1,3 +1,6 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -o /dev/null -verify \
 // RUN:   -verify-ignore-unexpected=note %s
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -S -o /dev/null 
-fcuda-is-device \


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


r283963 - [CUDA] Make touching a kernel from a __host__ __device__ function a deferred error.

2016-10-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Oct 11 20:30:08 2016
New Revision: 283963

URL: http://llvm.org/viewvc/llvm-project?rev=283963=rev
Log:
[CUDA] Make touching a kernel from a __host__ __device__ function a deferred 
error.

Previously, this was an immediate, don't pass go, don't collect $200
error.  But this precludes us from writing code like

  __host__ __device__ void launch_kernel() {
kernel<<<...>>>();
  }

Such code isn't wrong, following our notions of right and wrong in CUDA,
unless it's codegen'ed.

Added:
cfe/trunk/test/SemaCUDA/function-overload-hd.cu
Modified:
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/test/SemaCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=283963=283962=283963=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Tue Oct 11 20:30:08 2016
@@ -120,8 +120,7 @@ Sema::IdentifyCUDAPreference(const Funct
   // (a) Can't call global from some contexts until we support CUDA's
   // dynamic parallelism.
   if (CalleeTarget == CFT_Global &&
-  (CallerTarget == CFT_Global || CallerTarget == CFT_Device ||
-   (CallerTarget == CFT_HostDevice && getLangOpts().CUDAIsDevice)))
+  (CallerTarget == CFT_Global || CallerTarget == CFT_Device))
 return CFP_Never;
 
   // (b) Calling HostDevice is OK for everyone.

Added: cfe/trunk/test/SemaCUDA/function-overload-hd.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload-hd.cu?rev=283963=auto
==
--- cfe/trunk/test/SemaCUDA/function-overload-hd.cu (added)
+++ cfe/trunk/test/SemaCUDA/function-overload-hd.cu Tue Oct 11 20:30:08 2016
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -o /dev/null -verify \
+// RUN:   -verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -S -o /dev/null 
-fcuda-is-device \
+// RUN:   -verify -verify-ignore-unexpected=note %s
+
+#include "Inputs/cuda.h"
+
+// FIXME: Merge into function-overload.cu once deferred errors can be emitted
+// when non-deferred errors are present.
+
+#if !defined(__CUDA_ARCH__)
+//expected-no-diagnostics
+#endif
+
+typedef void (*GlobalFnPtr)();  // __global__ functions must return void.
+
+__global__ void g() {}
+
+__host__ __device__ void hd() {
+  GlobalFnPtr fp_g = g;
+#if defined(__CUDA_ARCH__)
+  // expected-error@-2 {{reference to __global__ function 'g' in __host__ 
__device__ function}}
+#endif
+  g<<<0,0>>>();
+#if defined(__CUDA_ARCH__)
+  // expected-error@-2 {{reference to __global__ function 'g' in __host__ 
__device__ function}}
+#endif  // __CUDA_ARCH__
+}

Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=283963=283962=283963=diff
==
--- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
+++ cfe/trunk/test/SemaCUDA/function-overload.cu Tue Oct 11 20:30:08 2016
@@ -181,18 +181,7 @@ __host__ __device__ void hostdevicef() {
   CurrentFnPtr fp_cdh = cdh;
   CurrentReturnTy ret_cdh = cdh();
 
-  GlobalFnPtr fp_g = g;
-#if defined(__CUDA_ARCH__)
-  // expected-error@-2 {{reference to __global__ function 'g' in __host__ 
__device__ function}}
-#endif
-  g();
-  g<<<0,0>>>();
-#if !defined(__CUDA_ARCH__)
-  // expected-error@-3 {{call to global function g not configured}}
-#else
-  // expected-error@-5 {{no matching function for call to 'g'}}
-  // expected-error@-5 {{reference to __global__ function 'g' in __host__ 
__device__ function}}
-#endif  // __CUDA_ARCH__
+  g(); // expected-error {{call to global function g not configured}}
 }
 
 // Test for address of overloaded function resolution in the global context.

Modified: cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu?rev=283963=283962=283963=diff
==
--- cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu (original)
+++ cfe/trunk/test/SemaCUDA/reference-to-kernel-fn.cu Tue Oct 11 20:30:08 2016
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -DDEVICE 
%s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify \
+// RUN:   -verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify \
+// RUN:   -verify-ignore-unexpected=note -DDEVICE %s
 
 // Check that we can reference (get a function pointer to) a __global__
 // function from the host side, but not the device side.  (We don't yet support
@@ -10,17 +12,16 @@
 struct Dummy 

[PATCH] D25494: Move x86-64 builtins from SemaChecking.cpp to BuiltinsX86_64.def

2016-10-11 Thread Albert Gutowski via cfe-commits
agutowski added inline comments.



Comment at: test/Sema/builtins-x86_64.c:17
+  v8ll vec8longlongs;
+  (void)__builtin_ia32_readeflags_u64(); // 
expected-error{{use of unknown builtin}} expected-note 0+ {{}}
+  (void)__builtin_ia32_writeeflags_u64(4);   // 
expected-error{{use of unknown builtin}} expected-note 0+ {{}}

Is there some way to ignore all notes? I needed to handle typo-correction notes 
(like: `did you mean '__builtin_ia32_readeflags_u32'`).


https://reviews.llvm.org/D25494



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


[PATCH] D25494: Move x86-64 builtins from SemaChecking.cpp to BuiltinsX86_64.def

2016-10-11 Thread Albert Gutowski via cfe-commits
agutowski created this revision.
agutowski added reviewers: rnk, hans, thakis.
agutowski added a subscriber: cfe-commits.

Follow-up to https://reviews.llvm.org/D24598 (separating builtins for x84-64 
and i386).


https://reviews.llvm.org/D25494

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  lib/Basic/Targets.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins-x86-disabled.c
  test/Sema/builtins-x86_64.c

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1590,58 +1590,6 @@
   return false;
 }
 
-static bool isX86_64Builtin(unsigned BuiltinID) {
-  // These builtins only work on x86-64 targets.
-  switch (BuiltinID) {
-  case X86::BI__builtin_ia32_addcarryx_u64:
-  case X86::BI__builtin_ia32_addcarry_u64:
-  case X86::BI__builtin_ia32_subborrow_u64:
-  case X86::BI__builtin_ia32_readeflags_u64:
-  case X86::BI__builtin_ia32_writeeflags_u64:
-  case X86::BI__builtin_ia32_bextr_u64:
-  case X86::BI__builtin_ia32_bextri_u64:
-  case X86::BI__builtin_ia32_bzhi_di:
-  case X86::BI__builtin_ia32_pdep_di:
-  case X86::BI__builtin_ia32_pext_di:
-  case X86::BI__builtin_ia32_crc32di:
-  case X86::BI__builtin_ia32_fxsave64:
-  case X86::BI__builtin_ia32_fxrstor64:
-  case X86::BI__builtin_ia32_xsave64:
-  case X86::BI__builtin_ia32_xrstor64:
-  case X86::BI__builtin_ia32_xsaveopt64:
-  case X86::BI__builtin_ia32_xrstors64:
-  case X86::BI__builtin_ia32_xsavec64:
-  case X86::BI__builtin_ia32_xsaves64:
-  case X86::BI__builtin_ia32_rdfsbase64:
-  case X86::BI__builtin_ia32_rdgsbase64:
-  case X86::BI__builtin_ia32_wrfsbase64:
-  case X86::BI__builtin_ia32_wrgsbase64:
-  case X86::BI__builtin_ia32_pbroadcastq512_gpr_mask:
-  case X86::BI__builtin_ia32_pbroadcastq256_gpr_mask:
-  case X86::BI__builtin_ia32_pbroadcastq128_gpr_mask:
-  case X86::BI__builtin_ia32_vcvtsd2si64:
-  case X86::BI__builtin_ia32_vcvtsd2usi64:
-  case X86::BI__builtin_ia32_vcvtss2si64:
-  case X86::BI__builtin_ia32_vcvtss2usi64:
-  case X86::BI__builtin_ia32_vcvttsd2si64:
-  case X86::BI__builtin_ia32_vcvttsd2usi64:
-  case X86::BI__builtin_ia32_vcvttss2si64:
-  case X86::BI__builtin_ia32_vcvttss2usi64:
-  case X86::BI__builtin_ia32_cvtss2si64:
-  case X86::BI__builtin_ia32_cvttss2si64:
-  case X86::BI__builtin_ia32_cvtsd2si64:
-  case X86::BI__builtin_ia32_cvttsd2si64:
-  case X86::BI__builtin_ia32_cvtsi2sd64:
-  case X86::BI__builtin_ia32_cvtsi2ss64:
-  case X86::BI__builtin_ia32_cvtusi2sd64:
-  case X86::BI__builtin_ia32_cvtusi2ss64:
-  case X86::BI__builtin_ia32_rdseed64_step:
-return true;
-  }
-
-  return false;
-}
-
 // Check if the rounding mode is legal.
 bool Sema::CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall) {
   // Indicates if this instruction has rounding control or just SAE.
@@ -1838,12 +1786,6 @@
   if (BuiltinID == X86::BI__builtin_ms_va_start)
 return SemaBuiltinMSVAStart(TheCall);
 
-  // Check for 64-bit only builtins on a 32-bit target.
-  const llvm::Triple  = Context.getTargetInfo().getTriple();
-  if (TT.getArch() != llvm::Triple::x86_64 && isX86_64Builtin(BuiltinID))
-return Diag(TheCall->getCallee()->getLocStart(),
-diag::err_x86_builtin_32_bit_tgt);
-
   // If the intrinsic has rounding or SAE make sure its valid.
   if (CheckX86BuiltinRoundingOrSAE(BuiltinID, TheCall))
 return true;
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2362,6 +2362,8 @@
 
 #define BUILTIN(ID, TYPE, ATTRS)   \
   { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
+  { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE },
 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
   { #ID, TYPE, ATTRS, HEADER, LANGS, FEATURE },
 #include "clang/Basic/BuiltinsX86_64.def"
Index: include/clang/Basic/BuiltinsX86_64.def
===
--- include/clang/Basic/BuiltinsX86_64.def
+++ include/clang/Basic/BuiltinsX86_64.def
@@ -14,6 +14,10 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
+#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 #if defined(BUILTIN) && !defined(TARGET_HEADER_BUILTIN)
 #  define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANG, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
@@ -25,6 +29,50 @@
 
 TARGET_HEADER_BUILTIN(__faststorefence, "v", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_BUILTIN(__builtin_ia32_readeflags_u64, "ULLi", "n", "")
+TARGET_BUILTIN(__builtin_ia32_writeeflags_u64, "vULLi", "n", "")
+TARGET_BUILTIN(__builtin_ia32_cvtss2si64, "LLiV4f", "", "sse")
+TARGET_BUILTIN(__builtin_ia32_cvttss2si64, "LLiV4f", 

[libcxxabi] r283962 - Fix libc++abi test config after recent libc++ changes

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 20:19:16 2016
New Revision: 283962

URL: http://llvm.org/viewvc/llvm-project?rev=283962=rev
Log:
Fix libc++abi test config after recent libc++ changes

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=283962=283961=283962=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Tue Oct 11 20:19:16 2016
@@ -55,6 +55,10 @@ class Configuration(LibcxxConfiguration)
 cxx_headers = self.get_lit_conf(
 'cxx_headers',
 os.path.join(self.libcxx_src_root, '/include'))
+if cxx_headers == '':
+self.lit_config.note('using the systems c++ headers')
+else:
+self.cxx.compile_flags += ['-nostdinc++']
 if not os.path.isdir(cxx_headers):
 self.lit_config.fatal("cxx_headers='%s' is not a directory."
   % cxx_headers)


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


[libcxx] r283960 - Add mork workarounds for running the test suite against libstdc++

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 19:28:14 2016
New Revision: 283960

URL: http://llvm.org/viewvc/llvm-project?rev=283960=rev
Log:
Add mork workarounds for running the test suite against libstdc++

Modified:
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/lit.cfg
libcxx/trunk/test/lit.site.cfg.in

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=283960=283959=283960=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Oct 11 19:28:14 2016
@@ -225,6 +225,14 @@ class Configuration(object):
 self.lit_config.fatal(
 'unsupported value for "cxx_stdlib_under_test": %s'
 % self.cxx_stdlib_under_test)
+if self.cxx_stdlib_under_test == 'libstdc++':
+# Manually enable the experimental and filesystem tests for 
libstdc++
+# if the options aren't present.
+# FIXME this is a hack.
+if self.get_lit_conf('enable_experimental') is None:
+self.config.enable_experimental = 'true'
+if self.get_lit_conf('enable_filesystem') is None:
+self.config.enable_filesystem = 'true'
 
 def configure_use_clang_verify(self):
 '''If set, run clang with -verify on failing tests.'''
@@ -467,7 +475,7 @@ class Configuration(object):
 assert os.path.isdir(static_env)
 self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="%s"' 
% static_env]
 
-dynamic_env = os.path.join(self.libcxx_obj_root, 'test',
+dynamic_env = os.path.join(self.config.test_exec_root,
'filesystem', 'Output', 'dynamic_env')
 dynamic_env = os.path.realpath(dynamic_env)
 if not os.path.isdir(dynamic_env):

Modified: libcxx/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=283960=283959=283960=diff
==
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Tue Oct 11 19:28:14 2016
@@ -37,7 +37,6 @@ if obj_root is None:
 obj_root = tempfile.mkdtemp(prefix='libcxx-testsuite-')
 lit_config.warning('Creating temporary directory for object root: %s' %
obj_root)
-config.libcxx_obj_root = obj_root
 
 config.test_exec_root = os.path.join(obj_root, 'test')
 

Modified: libcxx/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=283960=283959=283960=diff
==
--- libcxx/trunk/test/lit.site.cfg.in (original)
+++ libcxx/trunk/test/lit.site.cfg.in Tue Oct 11 19:28:14 2016
@@ -29,4 +29,5 @@ config.libcxxabi_shared = "@LIBC
 config.libcxx_external_thread_api  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
+config.loaded_site_config = True
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")


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


[PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-10-11 Thread Tavian Barnes via cfe-commits
tavianator added a comment.

In https://reviews.llvm.org/D21803#556857, @EricWF wrote:

> @rmaprath I'll merge this if needed. Feel free to commit your patch first.


Yeah, @rmaprath I'm happy to rebase this over your patch.

> @tavianator Do you need somebody to merge this for you?

I assume so, yeah.


https://reviews.llvm.org/D21803



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


[libcxx] r283958 - Make it easier to run the libc++ test suite against libstdc++

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 19:00:37 2016
New Revision: 283958

URL: http://llvm.org/viewvc/llvm-project?rev=283958=rev
Log:
Make it easier to run the libc++ test suite against libstdc++

Modified:
libcxx/trunk/docs/TestingLibcxx.rst
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/lit.cfg

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=283958=283957=283958=diff
==
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Tue Oct 11 19:00:37 2016
@@ -102,6 +102,12 @@ configuration. Passing the option on the
 
   Specify the compiler used to build the tests.
 
+.. option:: --cxx_stdlib_under_test=[libc++, libstdc++, cxx_default]
+
+  Specify the C++ standard library being tested. Unless otherwise specified
+  libc++ is used. This option is intended to allow running the libc++ test
+  suite against other standard library implementations.
+
 .. option:: std=
 
   **Values**: c++98, c++03, c++11, c++14, c++1z
@@ -113,10 +119,10 @@ configuration. Passing the option on the
   Specify the site configuration to use when running the tests.  This option
   overrides the enviroment variable LIBCXX_SITE_CONFIG.
 
-.. option:: --libcxx_headers=
+.. option:: --cxx_headers=
 
-  Specify the libc++ headers that are tested. By default the headers in the
-  source tree are used.
+  Specify the c++ standard library headers that are tested. By default the
+  headers in the source tree are used.
 
 .. option:: --cxx_library_root=
 

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=283958=283957=283958=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Oct 11 19:00:37 2016
@@ -57,6 +57,7 @@ class Configuration(object):
 self.lit_config = lit_config
 self.config = config
 self.cxx = None
+self.cxx_stdlib_under_test = None
 self.project_obj_root = None
 self.libcxx_src_root = None
 self.libcxx_obj_root = None
@@ -96,6 +97,7 @@ class Configuration(object):
 self.configure_triple()
 self.configure_src_root()
 self.configure_obj_root()
+self.configure_cxx_stdlib_under_test()
 self.configure_cxx_library_root()
 self.configure_use_system_cxx_lib()
 self.configure_use_clang_verify()
@@ -215,6 +217,15 @@ class Configuration(object):
 self.lit_config.note(
 "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib)
 
+def configure_cxx_stdlib_under_test(self):
+self.cxx_stdlib_under_test = self.get_lit_conf(
+'cxx_stdlib_under_test', 'libc++')
+if self.cxx_stdlib_under_test not in \
+['libc++', 'libstdc++', 'cxx_default']:
+self.lit_config.fatal(
+'unsupported value for "cxx_stdlib_under_test": %s'
+% self.cxx_stdlib_under_test)
+
 def configure_use_clang_verify(self):
 '''If set, run clang with -verify on failing tests.'''
 self.use_clang_verify = self.get_lit_bool('use_clang_verify')
@@ -329,7 +340,6 @@ class Configuration(object):
 self.cxx.compile_flags += ['-std={0}'.format(std)]
 self.config.available_features.add(std)
 # Configure include paths
-self.cxx.compile_flags += ['-nostdinc++']
 self.configure_compile_flags_header_includes()
 self.target_info.add_cxx_compile_flags(self.cxx.compile_flags)
 # Configure feature flags.
@@ -352,14 +362,22 @@ class Configuration(object):
 
 def configure_compile_flags_header_includes(self):
 support_path = os.path.join(self.libcxx_src_root, 'test/support')
-self.cxx.compile_flags += ['-include', os.path.join(support_path, 
'nasty_macros.hpp')]
+if self.cxx_stdlib_under_test != 'libstdc++':
+self.cxx.compile_flags += [
+'-include', os.path.join(support_path, 'nasty_macros.hpp')]
 self.configure_config_site_header()
-libcxx_headers = self.get_lit_conf(
-'libcxx_headers', os.path.join(self.libcxx_src_root, 'include'))
-if not os.path.isdir(libcxx_headers):
-self.lit_config.fatal("libcxx_headers='%s' is not a directory."
-  % libcxx_headers)
-self.cxx.compile_flags += ['-I' + libcxx_headers]
+cxx_headers = self.get_lit_conf('cxx_headers')
+if cxx_headers == '' or (cxx_headers is None
+ and self.cxx_stdlib_under_test != 'libc++'):
+self.lit_config.note('using the system cxx headers')
+return
+self.cxx.compile_flags += ['-nostdinc++']
+

[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-10-11 Thread Julian Bangert via cfe-commits
jbangert marked an inline comment as done.
jbangert added a comment.

Thanks for the review!


https://reviews.llvm.org/D24997



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


[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-10-11 Thread Julian Bangert via cfe-commits
jbangert updated this revision to Diff 74311.

https://reviews.llvm.org/D24997

Files:
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  clang-tidy/utils/NamespaceAliaser.cpp
  clang-tidy/utils/NamespaceAliaser.h
  clang-tidy/utils/UsingInserter.cpp
  clang-tidy/utils/UsingInserter.h
  unittests/clang-tidy/NamespaceAliaserTest.cpp
  unittests/clang-tidy/UsingInserterTest.cpp

Index: unittests/clang-tidy/UsingInserterTest.cpp
===
--- /dev/null
+++ unittests/clang-tidy/UsingInserterTest.cpp
@@ -0,0 +1,115 @@
+//=== UsingInserterTest.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../clang-tidy/utils/UsingInserter.h"
+
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// Replace all function calls with calls to foo::func. Inserts using
+// declarations as necessary. This checker is for testing only. It
+// can only run on one test case (e.g. wih one SourceManager).
+class InsertUsingCheck : public clang::tidy::ClangTidyCheck {
+public:
+  using clang::tidy::ClangTidyCheck::ClangTidyCheck;
+  void registerMatchers(clang::ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(clang::ast_matchers::callExpr().bind("foo"), this);
+  }
+  void
+  check(const clang::ast_matchers::MatchFinder::MatchResult ) override {
+if (!Inserter)
+  Inserter.reset(new UsingInserter(*Result.SourceManager,
+   Result.Context->getLangOpts()));
+
+const clang::CallExpr *Call =
+Result.Nodes.getNodeAs("foo");
+assert(Call != nullptr && "Did not find node \"foo\"");
+auto Hint =
+Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");
+
+if (Hint.hasValue())
+  diag(Call->getLocStart(), "Fix for testing") << Hint.getValue();
+
+diag(Call->getLocStart(), "insert call")
+<< clang::FixItHint::CreateReplacement(
+   Call->getCallee()->getSourceRange(),
+   Inserter->getShortName(*Result.Context, *Call, "::foo::func"));
+  }
+
+private:
+  std::unique_ptr Inserter;
+};
+
+template 
+std::string runChecker(StringRef Code, int ExpectedWarningCount) {
+  std::map AdditionalFileContents = {{"foo.h",
+"namespace foo {\n"
+"namespace bar {\n"
+"}\n"
+"void func() { }\n"
+"}"}};
+  std::vector errors;
+
+  std::string result =
+  test::runCheckOnCode(Code, , "foo.cc", None,
+  ClangTidyOptions(), AdditionalFileContents);
+
+  EXPECT_EQ(ExpectedWarningCount, errors.size());
+  return result;
+}
+
+TEST(UsingInserterTest, ReusesExisting) {
+  EXPECT_EQ("#include \"foo.h\"\n"
+"namespace {"
+"using ::foo::func;\n"
+"void f() { func(); }"
+"}",
+runChecker("#include \"foo.h\"\n"
+ "namespace {"
+ "using ::foo::func;\n"
+ "void f() { f(); }"
+ "}",
+ 1));
+}
+
+TEST(UsingInserterTest, ReusesExistingGlobal) {
+  EXPECT_EQ("#include \"foo.h\"\n"
+"using ::foo::func;\n"
+"namespace {"
+"void f() { func(); }"
+"}",
+runChecker("#include \"foo.h\"\n"
+ "using ::foo::func;\n"
+ "namespace {"
+ "void f() { f(); }"
+ "}",
+ 1));
+}
+
+TEST(UsingInserterTest, AvoidsConflict) {
+  EXPECT_EQ("#include \"foo.h\"\n"
+"namespace {"
+"void f() { int func; ::foo::func(); }"
+"}",
+runChecker("#include \"foo.h\"\n"
+ "namespace {"
+ "void f() { int func; f(); }"
+ "}",
+ 1));
+}
+
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: unittests/clang-tidy/NamespaceAliaserTest.cpp

[PATCH] D25373: Fix for Bug 30639: CGDebugInfo Null dereference with OpenMP array access

2016-10-11 Thread Erich Keane via cfe-commits
erichkeane updated the summary for this revision.
erichkeane removed a reviewer: gbenyei.
erichkeane removed rL LLVM as the repository for this revision.
erichkeane updated this revision to Diff 74310.
erichkeane added a comment.

Emailed with Alexey who identified the problem in the OpenMP implementation 
that was resulting in incomplete array types being emitted, which broke an 
assumption in the new CGDebugInfo code.


https://reviews.llvm.org/D25373

Files:
  lib/CodeGen/CGStmtOpenMP.cpp
  test/CodeGenCXX/debug-info-openmp-array.cpp
  test/OpenMP/for_reduction_codegen.cpp
  test/OpenMP/for_reduction_codegen_UDR.cpp
  test/OpenMP/target_firstprivate_codegen.cpp
  test/OpenMP/target_map_codegen.cpp

Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -232,8 +232,15 @@
   assert(I->capturesVariableArrayType());
   II = ().Idents.get("vla");
 }
-if (ArgType->isVariablyModifiedType())
-  ArgType = getContext().getVariableArrayDecayedType(ArgType);
+if (ArgType->isVariablyModifiedType()) {
+  bool IsReference = ArgType->isLValueReferenceType();
+  ArgType =
+  getContext().getCanonicalParamType(ArgType.getNonReferenceType());
+  if (IsReference && !ArgType->isPointerType()) {
+ArgType = getContext().getLValueReferenceType(
+ArgType, /*SpelledAsLValue=*/false);
+  }
+}
 Args.push_back(ImplicitParamDecl::Create(getContext(), nullptr,
  FD->getLocation(), II, ArgType));
 ++I;
@@ -297,8 +304,14 @@
   QualType VarTy = Var->getType();
   Address ArgAddr = ArgLVal.getAddress();
   if (!VarTy->isReferenceType()) {
-ArgAddr = EmitLoadOfReference(
-ArgAddr, ArgLVal.getType()->castAs());
+if (ArgLVal.getType()->isLValueReferenceType()) {
+  ArgAddr = EmitLoadOfReference(
+  ArgAddr, ArgLVal.getType()->castAs());
+} else {
+  assert(ArgLVal.getType()->isPointerType());
+  ArgAddr = this->EmitLoadOfPointer(
+  ArgAddr, ArgLVal.getType()->castAs());
+}
   }
   setAddrOfLocalVar(
   Var, Address(ArgAddr.getPointer(), getContext().getDeclAlign(Var)));
Index: test/OpenMP/for_reduction_codegen_UDR.cpp
===
--- test/OpenMP/for_reduction_codegen_UDR.cpp
+++ test/OpenMP/for_reduction_codegen_UDR.cpp
@@ -301,7 +301,7 @@
 // CHECK: fadd float 5.55e+02, %
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
 
 // Reduction list for runtime.
 // CHECK: [[RED_LIST:%.+]] = alloca [4 x i8*],
@@ -500,7 +500,7 @@
 
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK2]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(480) %{{.+}})
 
 // CHECK: [[ARRS_PRIV:%.+]] = alloca [10 x [4 x [[S_FLOAT_TY,
 
Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -675,7 +675,7 @@
   }
 }
 
-// CK13: define internal void [[KERNEL]](i[[sz]] [[VLA0:%.+]], i[[sz]] [[VLA1:%.+]], double* {{.+}}[[ARG:%.+]])
+// CK13: define internal void [[KERNEL]](i[[sz]] [[VLA0:%.+]], i[[sz]] [[VLA1:%.+]], double* {{.*}}[[ARG:%.+]])
 // CK13: [[ADDR0:%.+]] = alloca i[[sz]],
 // CK13: [[ADDR1:%.+]] = alloca i[[sz]],
 // CK13: [[ADDR2:%.+]] = alloca double*,
Index: test/OpenMP/for_reduction_codegen.cpp
===
--- test/OpenMP/for_reduction_codegen.cpp
+++ test/OpenMP/for_reduction_codegen.cpp
@@ -492,7 +492,7 @@
 // CHECK: store float [[UP]], float* [[T_VAR1_LHS]],
 // CHECK: ret void
 
-// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i32* nonnull %{{.+}}, [2 x i32]* dereferenceable(8) %{{.+}}, [10 x [4 x [[S_FLOAT_TY* dereferenceable(160) %{{.+}})
+// CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* 

[PATCH] D25458: Don't create builtin declaration when looking for typo corrections in C++

2016-10-11 Thread Albert Gutowski via cfe-commits
agutowski added a comment.

In https://reviews.llvm.org/D25458#567697, @rnk wrote:

> Can you provide a more complete motivating example where our diagnostics were 
> bad? I'm having a hard time figuring it out from the test


Sure, compiling the following program in C++ for i386 emits warnings about 
implicit declarations of __emul and __emulu:

  int main() {
__umul(1, 2);
return 0;
  }


https://reviews.llvm.org/D25458



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


[PATCH] D25491: [libcxx] Use C++14 when building libc++ with musl

2016-10-11 Thread Petr Hosek via cfe-commits
phosek added a comment.

libc++ was already building with musl after https://reviews.llvm.org/D21637 was 
commited, but this broke recently as a consequence of r282640 which introduced 
the use of `_LIBCPP_SAFE_STATIC` for libc++ internal globals. I'm not sure if 
this is the best solution, but it's the only one I could come up with, apart 
from removing the use of `_LIBCPP_SAFE_STATIC`, which is undesirable, or 
removing the use of `volatile` from musl pthread structs, which is unlikely.


Repository:
  rL LLVM

https://reviews.llvm.org/D25491



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


[PATCH] D25491: [libcxx] Use C++14 when building libc++ with musl

2016-10-11 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added reviewers: EricWF, mclow.lists.
phosek added a subscriber: cfe-commits.
phosek set the repository for this revision to rL LLVM.
Herald added subscribers: mgorny, beanz.

musl's pthread implementations use volatile types in their structs which is not 
being constexpr in C++11 but is in C++14.


Repository:
  rL LLVM

https://reviews.llvm.org/D25491

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -331,6 +331,11 @@
   message(FATAL_ERROR "C++11 or greater is required but the compiler does not 
support ${LIBCXX_STANDARD_VER}")
 endif()
 
+check_flag_supported(-std=c++14)
+if (LIBCXX_HAS_MUSL_LIBC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG)
+  string(REPLACE "-std=c++11" "-std=c++14" LIBCXX_COMPILE_FLAGS 
"${LIBCXX_COMPILE_FLAGS}")
+endif()
+
 # On all systems the system c++ standard library headers need to be excluded.
 # MSVC only has -X, which disables all default includes; including the crt.
 # Thus, we do nothing and hope we don't accidentally include any of the C++


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -331,6 +331,11 @@
   message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}")
 endif()
 
+check_flag_supported(-std=c++14)
+if (LIBCXX_HAS_MUSL_LIBC AND LIBCXX_SUPPORTS_STD_EQ_CXX14_FLAG)
+  string(REPLACE "-std=c++11" "-std=c++14" LIBCXX_COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}")
+endif()
+
 # On all systems the system c++ standard library headers need to be excluded.
 # MSVC only has -X, which disables all default includes; including the crt.
 # Thus, we do nothing and hope we don't accidentally include any of the C++
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25458: Don't create builtin declaration when looking for typo corrections in C++

2016-10-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Can you provide a more complete motivating example where our diagnostics were 
bad? I'm having a hard time figuring it out from the test


https://reviews.llvm.org/D25458



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


[libcxx] r283951 - Fix LWG2683 - filesystem::copy() should always clear the user-provided error_code

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 17:18:09 2016
New Revision: 283951

URL: http://llvm.org/viewvc/llvm-project?rev=283951=rev
Log:
Fix LWG2683 - filesystem::copy() should always clear the user-provided 
error_code

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=283951=283950=283951=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Tue Oct 11 17:18:09 
2016
@@ -236,12 +236,8 @@ void __copy(const path& from, const path
 }
 return;
 }
-else if (is_directory(f)) {
-if (not bool(copy_options::recursive & options) &&
-bool(copy_options::__in_recursive_copy & options))
-{
-return;
-}
+else if (is_directory(f) && (bool(copy_options::recursive & options) ||
+ copy_options::none == options)) {
 
 if (!exists(t)) {
 // create directory to with attributes from 'from'.

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp?rev=283951=283950=283951=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.copy/copy.pass.cpp
 Tue Oct 11 17:18:09 2016
@@ -69,37 +69,44 @@ TEST_CASE(test_error_reporting)
 const path fifo = env.create_fifo("fifo");
 TEST_REQUIRE(is_other(fifo));
 
+const auto test_ec = GetTestEC();
+
 // !exists(f)
 {
-std::error_code ec;
+std::error_code ec = test_ec;
 const path f = StaticEnv::DNE;
 const path t = env.test_root;
 fs::copy(f, t, ec);
 TEST_REQUIRE(ec);
+TEST_REQUIRE(ec != test_ec);
 TEST_CHECK(checkThrow(f, t, ec));
 }
 { // equivalent(f, t) == true
-std::error_code ec;
+std::error_code ec = test_ec;
 fs::copy(file, file, ec);
 TEST_REQUIRE(ec);
+TEST_REQUIRE(ec != test_ec);
 TEST_CHECK(checkThrow(file, file, ec));
 }
 { // is_directory(from) && is_file(to)
-std::error_code ec;
+std::error_code ec = test_ec;
 fs::copy(dir, file, ec);
 TEST_REQUIRE(ec);
+TEST_REQUIRE(ec != test_ec);
 TEST_CHECK(checkThrow(dir, file, ec));
 }
 { // is_other(from)
-std::error_code ec;
+std::error_code ec = test_ec;
 fs::copy(fifo, dir, ec);
 TEST_REQUIRE(ec);
+TEST_REQUIRE(ec != test_ec);
 TEST_CHECK(checkThrow(fifo, dir, ec));
 }
 { // is_other(to)
-std::error_code ec;
+std::error_code ec = test_ec;
 fs::copy(file, fifo, ec);
 TEST_REQUIRE(ec);
+TEST_REQUIRE(ec != test_ec);
 TEST_CHECK(checkThrow(file, fifo, ec));
 }
 }
@@ -129,11 +136,13 @@ TEST_CASE(from_is_symlink)
 std::error_code ec = GetTestEC();
 fs::copy(symlink, file, copy_options::copy_symlinks, ec);
 TEST_CHECK(ec);
+TEST_CHECK(ec != GetTestEC());
 }
 { // create symlinks but target exists
 std::error_code ec = GetTestEC();
 fs::copy(symlink, file, copy_options::create_symlinks, ec);
 TEST_CHECK(ec);
+TEST_CHECK(ec != GetTestEC());
 }
 }
 
@@ -246,6 +255,19 @@ TEST_CASE(from_is_directory)
 TEST_CHECK(file_size(nested_created) == FI.size);
 }
 }
+}
 
+TEST_CASE(test_otherwise_no_effects_clause)
+{
+scoped_test_env env;
+const path dir = env.create_dir("dir1");
+{ // skip copy because of directory
+const path dest = env.make_env_path("dest1");
+std::error_code ec;
+fs::copy(dir, dest, CO::directories_only, ec);
+TEST_CHECK(!ec);
+TEST_CHECK(!exists(dest));
+}
 }
+
 TEST_SUITE_END()

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=283951=283950=283951=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Oct 11 17:18:09 2016
@@ -286,7 +286,7 @@
http://wg21.link/LWG2671;>2671Errors in 
CopyOuluComplete
http://wg21.link/LWG2673;>2673status() 
effects cannot be implemented as 
specifiedOuluComplete
http://wg21.link/LWG2674;>2674Bidirectional 

[PATCH] D25458: Don't create builtin declaration when looking for typo corrections in C++

2016-10-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

We shouldn't thread this kind of boolean all the way through name lookup. This 
is the kind of thing that callers should configure on the LookupResult object 
that they pass in.


https://reviews.llvm.org/D25458



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


r283950 - Revert - When optimizing for size, enable loop rerolling by default

2016-10-11 Thread Mike Edwards via cfe-commits
Author: sqlbyme
Date: Tue Oct 11 17:09:13 2016
New Revision: 283950

URL: http://llvm.org/viewvc/llvm-project?rev=283950=rev
Log:
Revert - When optimizing for size, enable loop rerolling by default

This reverts r283685 as it is causing test failures on Green Dragon.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283950=283949=283950=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 11 17:09:13 2016
@@ -5229,18 +5229,9 @@ void Clang::ConstructJob(Compilation ,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
-   options::OPT_fno_reroll_loops)) {
+   options::OPT_fno_reroll_loops))
 if (A->getOption().matches(options::OPT_freroll_loops))
   CmdArgs.push_back("-freroll-loops");
-  } else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-// If rerolling is not explicitly enabled or disabled, then enable when
-// optimizing for size.
-if (A->getOption().matches(options::OPT_O)) {
-  StringRef S(A->getValue());
-  if (S == "s" || S == "z")
-CmdArgs.push_back("-freroll-loops");
-}
-  }
 
   Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
   Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=283950=283949=283950=diff
==
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Tue Oct 11 17:09:13 2016
@@ -47,12 +47,7 @@
 // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"
 
 // RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
-// RUN: %clang -### -S -Os %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
-// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
 // RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
-// RUN: %clang -### -S -Os -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
-// RUN: %clang -### -S -Oz -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
-// RUN: %clang -### -S -O1 %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
 // RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
 // RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
 // CHECK-REROLL-LOOPS: "-freroll-loops"


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


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-11 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Added some comments to @EricWF's feedback. Will check back tomorrow (falling 
asleep...)

/ Asiri




Comment at: include/__threading_support:25
 // redundancy is intentional.
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)

EricWF wrote:
> If `_LIBCPP_HAS_THREAD_API_EXTERNAL` is defined can't we just assume that 
> `<__external_threading> is present?
So, `_LIBCPP_HAS_THREAD_API_EXTERNAL` is set from the cmake option for building 
the externally threaded variant. For the proof-of-concept implementation (that 
we use for running the test suite), we embed a pthread-based external API 
within `__threading_support` itself and provide its implementation in 
`test/support/external_threads.cpp` (which is built into a separate library 
when running the test suite).

That means, in the default externally-threaded variant (POC), we don't have a 
`__external_threading` header; the idea is to allow library vendors to drop-in 
a `__external_threading` header without conflicting with upstream sources, and 
it will be picked up automatically by `__threading_support` header. Moreover, 
this way we avoid the cost of shipping an additional header which is not 
necessary for the most common use case (direct pthread dependency).

This is why we need this contraption to detect if the externally threaded 
library is built with a `__external_threading` header (i.e. for production) or 
not (the default - vanilla upstream setup, the POC). 

Hope that makes sense? Perhaps I should explain all this in a comment as well?



Comment at: include/__threading_support:35
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 

EricWF wrote:
> Instead of using a new macro couldn't this just be 
> `_LIBCPP_HAS_THREAD_API_EXTERNAL`?
I think my comment above covers this point as well.


https://reviews.llvm.org/D25468



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


r283949 - [Profile] Update testcase for r283948 (NFC)

2016-10-11 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Oct 11 16:56:05 2016
New Revision: 283949

URL: http://llvm.org/viewvc/llvm-project?rev=283949=rev
Log:
[Profile] Update testcase for r283948 (NFC)

Old: "__DATA,__llvm_prf_data"
New: "__DATA,__llvm_prf_data,regular,live_support"

This should fix the following bot failure:

  http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55158

Modified:
cfe/trunk/test/Profile/c-linkage-available_externally.c

Modified: cfe/trunk/test/Profile/c-linkage-available_externally.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-linkage-available_externally.c?rev=283949=283948=283949=diff
==
--- cfe/trunk/test/Profile/c-linkage-available_externally.c (original)
+++ cfe/trunk/test/Profile/c-linkage-available_externally.c Tue Oct 11 16:56:05 
2016
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name 
c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instrument=clang 
| FileCheck %s
 
 // CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, 
section "__DATA,__llvm_prf_cnts", align 8
-// CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr 
inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section 
"__DATA,__llvm_prf_data", align 8
+// CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr 
inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section 
"__DATA,__llvm_prf_data,regular,live_support", align 8
 inline int foo(void) { return 1; }
 
 int main(void) {


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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:11356-11357
+  // Compute the EffectiveAlignment as the alignment of the whole chain.
+  CharUnits EffectiveAlignment = Context.getTypeAlignInChars(
+  ReverseMemberChain.back()->getParent()->getTypeForDecl());
+

In order to fix Joerg's latest false positives, you need to look at the type of 
the base expression itself rather than the class type containing the innermost 
member. (The base expression's type might provide more alignment than the 
struct being accessed guarantees.)


https://reviews.llvm.org/D23657



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


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Benjamin Kramer via cfe-commits
Yup, GCC is "fast enough" again. Thanks :)

On Tue, Oct 11, 2016 at 9:13 PM, Mehdi Amini  wrote:
> Reverted in r283920, can you check if it is enough to “fix” the GCC issue?
>
>> On Oct 11, 2016, at 12:04 PM, Benjamin Kramer  wrote:
>>
>> Committing this patch before the constexpr change seems backwards
>> then? The static initializers are already breaking stuff because it
>> takes GCC with optimization and debug info takes 10+ minutes to
>> generate megabytes of static initializer code in Targets.cpp. Can you
>> please revert this until the constexpr change is ready?
>>
>> On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
>>> This is temporary: the last patch of my series of patches adds the 
>>> constexpr ctor and remove all these static initializers.
>>>
 On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:

 I don't think this change is worth it. We create huge static arrays
 with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
 char*) is not constexpr (because of strlen). This means you'll get a
 huge generated initialization function for it. We want to reduce the
 number of global initializers in LLVM, not create new ones.

 On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
  wrote:
> Author: mehdi_amini
> Date: Mon Oct 10 16:34:29 2016
> New Revision: 283802
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
> Log:
> Change Builtins name to be stored as StringRef instead of raw pointers 
> (NFC)
>
> Modified:
>   cfe/trunk/include/clang/Basic/Builtins.h
>   cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>   cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> @@ -51,7 +51,8 @@ enum ID {
> };
>
> struct Info {
> -  const char *Name, *Type, *Attributes, *HeaderName;
> +  llvm::StringRef Name;
> +  const char *Type, *Attributes, *HeaderName;
>  LanguageID Langs;
>  const char *Features;
> };
> @@ -80,7 +81,7 @@ public:
>
>  /// \brief Return the identifier name for the specified builtin,
>  /// e.g. "__builtin_abs".
> -  const char *getName(unsigned ID) const {
> +  llvm::StringRef getName(unsigned ID) const {
>return getRecord(ID).Name;
>  }
>
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>  if (FD->hasAttr())
>Name = getMangledName(D);
>  else
> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>
>  llvm::FunctionType *Ty =
>cast(getTypes().ConvertType(FD->getType()));
> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>  checkTargetFeatures(E, FD);
>
>  // See if we have a target specific intrinsic.
> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>  Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>  StringRef Prefix =
>  llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>  if (!Prefix.empty()) {
> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), 
> Name);
>// NOTE we dont need to perform a compatibility flag check here since 
> the
>// intrinsics are declared in Builtins*.def via LANGBUILTIN which 
> filter the
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>  // Get the decl for the concrete builtin from this, we can tell what the
>  // concrete integer type we should convert to is.
>  unsigned NewBuiltinID = 

[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-10-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:4849
+  DeclarationName Name = D->getDeclName();
+  if (auto *DD = dyn_cast(D))
+Name =

ahatanak wrote:
> rsmith wrote:
> > Do we need to do this for conversion function names too? (Eg, `operator 
> > C1*`)
> I added a definition of "operator C1*" and called it in C1::foo1. I didn't 
> see any crashes or asserts.
> 
> Calls to a destructor and a conversion function create different AST nodes 
> (the former creates a MemberExpr and the latter creates a 
> CXXDependentScopeMemberExpr) and are transformed by different functions of 
> TreeTransform.
Please also check in that testcase.



Comment at: lib/Sema/TreeTransform.h:2127
+
+if (isa(FoundDecl))
+  DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);

I don't see any reason why this should be specific to destructors. But this is 
the wrong place for this change; by the time we reach `Rebuild*` we should have 
already transformed everything that we need to transform.

Perhaps the problem is instead...



Comment at: lib/Sema/TreeTransform.h:11967-11969
   TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
   DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
  SemaRef.Context.getCanonicalType(DestroyedType->getType(;

... that we fail to transform `DestroyedType` here. Can you try fixing this bug 
and see if that removes the need for your other changes?


https://reviews.llvm.org/D24969



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


[PATCH] D25406: Fix doubled whitespace in modernize-use-auto fixit

2016-10-11 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseAutoCheck.cpp:378
+  Lexer::getLocForEndOfToken(Range.getEnd(), 0, SM, 
Context->getLangOpts());
+  bool Whitespace = isWhitespace(*FullSourceLoc(Next, SM).getCharacterData());
+

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Oye, this is deceptively expensive because you now have to go back to the 
> > > actual source file for this information. That source file may live on a 
> > > network share somewhere, for instance.
> > > 
> > > Can you use `Token::hasLeadingSpace()` instead?
> > > 
> > > Also, doesn't this still need to care about the `RemoveStars` option?
> > Where would I get a Token from?
> Hrm, might not be as trivial as I was hoping (I thought we had a way to go 
> from a `SourceLocation` back to a `Token`, but I'm not seeing one off-hand). 
> Regardless, I worry about the expense of going all the way back to the source 
> for this.
> 
> @alexfh -- should this functionality be a part of a more general "we've made 
> a fixit, now make it not look ugly?" pass? At least then, if we go back to 
> the source, we can do it in a more controlled manner and hopefully get some 
> performance back from that.
`LineIsMarkedWithNOLINT` is going to read the source anyway, so I don't see any 
additional expense.


https://reviews.llvm.org/D25406



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


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-11 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:25
 // redundancy is intentional.
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)

If `_LIBCPP_HAS_THREAD_API_EXTERNAL` is defined can't we just assume that 
`<__external_threading> is present?



Comment at: include/__threading_support:35
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 

Instead of using a new macro couldn't this just be 
`_LIBCPP_HAS_THREAD_API_EXTERNAL`?


https://reviews.llvm.org/D25468



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


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/Decl.h:1213
+  bool isThisDeclarationADemotedDefinition() const {
+return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }

This is the bug. You can't read this bit here without first checking whether 
you are a ParmVarDecl, because ParmVarDecls don't have this bit at all.



Comment at: include/clang/AST/Decl.h:1222
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");

v.g.vassilev wrote:
> rsmith wrote:
> > You can remove this; it's covered by the next line.
> Ok. This would allow calling the method on already demoted definition. Do we 
> want to allow that?
Demoted definitions return false from `isThisDeclarationADefinition()`, so the 
next line catches this case.


https://reviews.llvm.org/D24508



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


[libcxx] r283945 - Remove extraneous 'const' in the implementation of is_move_assignable. Howard pleads temporary insanity about this. Discussed at http://stackoverflow.com/questions/39986185

2016-10-11 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Oct 11 16:24:06 2016
New Revision: 283945

URL: http://llvm.org/viewvc/llvm-project?rev=283945=rev
Log:
Remove extraneous 'const' in the implementation of is_move_assignable. Howard 
pleads temporary insanity about this.  Discussed at 
http://stackoverflow.com/questions/39986185

Modified:
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=283945=283944=283945=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Oct 11 16:24:06 2016
@@ -2082,7 +2082,7 @@ template  _LIBCPP_CONSTEXPR b
 template  struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 : public is_assignable::type,
- const typename add_rvalue_reference<_Tp>::type> {};
+   typename add_rvalue_reference<_Tp>::type> {};
 #else
 : public is_copy_assignable<_Tp> {};
 #endif


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


RE: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Yung, Douglas via cfe-commits
We noticed that this change also caused VS2015 to take a lot longer when 
building Targets.cpp. The revert in r283920 seems to have fixed it. The 
upstream PS4 Windows bot went from a build time of 17:53 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/12771)
 to 5:51 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/12772).

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of Mehdi Amini via cfe-commits
> Sent: Tuesday, October 11, 2016 12:14
> To: Benjamin Kramer
> Cc: cfe-commits
> Subject: Re: r283802 - Change Builtins name to be stored as StringRef
> instead of raw pointers (NFC)
> 
> Reverted in r283920, can you check if it is enough to “fix” the GCC
> issue?
> 
> > On Oct 11, 2016, at 12:04 PM, Benjamin Kramer 
> wrote:
> >
> > Committing this patch before the constexpr change seems backwards
> > then? The static initializers are already breaking stuff because it
> > takes GCC with optimization and debug info takes 10+ minutes to
> > generate megabytes of static initializer code in Targets.cpp. Can you
> > please revert this until the constexpr change is ready?
> >
> > On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini 
> wrote:
> >> This is temporary: the last patch of my series of patches adds the
> constexpr ctor and remove all these static initializers.
> >>
> >>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer 
> wrote:
> >>>
> >>> I don't think this change is worth it. We create huge static arrays
> >>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> >>> char*) is not constexpr (because of strlen). This means you'll get
> a
> >>> huge generated initialization function for it. We want to reduce
> the
> >>> number of global initializers in LLVM, not create new ones.
> >>>
> >>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
> >>>  wrote:
>  Author: mehdi_amini
>  Date: Mon Oct 10 16:34:29 2016
>  New Revision: 283802
> 
>  URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
>  Log:
>  Change Builtins name to be stored as StringRef instead of raw
>  pointers (NFC)
> 
>  Modified:
>    cfe/trunk/include/clang/Basic/Builtins.h
>    cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>    cfe/trunk/lib/Sema/SemaChecking.cpp
> 
>  Modified: cfe/trunk/include/clang/Basic/Builtins.h
>  URL:
>  http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Basic/B
>  uiltins.h?rev=283802=283801=283802=diff
> 
> ===
>  ===
>  --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>  +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29
>  +++ 2016
>  @@ -51,7 +51,8 @@ enum ID {
>  };
> 
>  struct Info {
>  -  const char *Name, *Type, *Attributes, *HeaderName;
>  +  llvm::StringRef Name;
>  +  const char *Type, *Attributes, *HeaderName;
>   LanguageID Langs;
>   const char *Features;
>  };
>  @@ -80,7 +81,7 @@ public:
> 
>   /// \brief Return the identifier name for the specified builtin,
>  /// e.g. "__builtin_abs".
>  -  const char *getName(unsigned ID) const {
>  +  llvm::StringRef getName(unsigned ID) const {
> return getRecord(ID).Name;
>   }
> 
> 
>  Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>  URL:
>  http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGBuiltin
>  .cpp?rev=283802=283801=283802=diff
> 
> ===
>  ===
>  --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>  +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
>  @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi  if
>  (FD->hasAttr())
> Name = getMangledName(D);
>   else
>  -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
>  +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
> 
>   llvm::FunctionType *Ty =
> cast(getTypes().ConvertType(FD-
> >getType()));
>  @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>  checkTargetFeatures(E, FD);
> 
>   // See if we have a target specific intrinsic.
>  -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;  StringRef
>  Prefix =
> 
> 
> llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>   if (!Prefix.empty()) {
>  +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
> IntrinsicID =
> Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
> // NOTE we dont need to perform a compatibility flag check 

[libcxx] r283944 - Fix std::pair on FreeBSD

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 16:22:21 2016
New Revision: 283944

URL: http://llvm.org/viewvc/llvm-project?rev=283944=rev
Log:
Fix std::pair on FreeBSD

Summary:
FreeBSD ships an old ABI for std::pair which requires that it have non-trivial 
copy/move constructors. Currently the non-trivial copy/move is achieved by 
providing explicit definitions of the constructors. This is problematic because 
it means the constructors don't SFINAE properly. In order to SFINAE copy/move 
constructors they have to be explicitly defaulted and hense non-trivial.

This patch attempts to provide SFINAE'ing copy/move constructors for std::pair 
while still making them non-trivial. It does this by adding a base class with a 
non-trivial copy constructor and then allowing pair's constructors to be 
generated by the compiler. This also allows the constructors to be constexpr.


Reviewers: emaste, theraven, rsmith, dim

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/utility

libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=283944=283943=283944=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Oct 11 16:22:21 2016
@@ -291,9 +291,20 @@ extern const piecewise_construct_t piece
 constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
 #endif
 
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+struct __non_trivially_copyable_base {
+  _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+  __non_trivially_copyable_base() _NOEXCEPT {}
+  _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+  __non_trivially_copyable_base(__non_trivially_copyable_base const&) 
_NOEXCEPT {}
+};
+#endif
 
 template 
 struct _LIBCPP_TYPE_VIS_ONLY pair
+#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+: private __non_trivially_copyable_base
+#endif
 {
 typedef _T1 first_type;
 typedef _T2 second_type;
@@ -301,26 +312,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
 _T1 first;
 _T2 second;
 
-#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
-_LIBCPP_INLINE_VISIBILITY
-pair(const pair& __p)
-_NOEXCEPT_(is_nothrow_copy_constructible::value &&
-   is_nothrow_copy_constructible::value)
-: first(__p.first),
-  second(__p.second)
-{
-}
-
-# ifndef _LIBCPP_CXX03_LANG
-_LIBCPP_INLINE_VISIBILITY
-pair(pair&& __p) 
_NOEXCEPT_(is_nothrow_move_constructible::value &&
-
is_nothrow_move_constructible::value)
-: first(_VSTD::forward(__p.first)),
-  second(_VSTD::forward(__p.second))
-{
-}
-# endif
-#elif !defined(_LIBCPP_CXX03_LANG)
+#if !defined(_LIBCPP_CXX03_LANG)
 pair(pair const&) = default;
 pair(pair&&) = default;
 #else

Modified: 
libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp?rev=283944=283943=283944=diff
==
--- 
libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
 Tue Oct 11 16:22:21 2016
@@ -7,49 +7,142 @@
 //
 
//===--===//
 
+// The test fails due to the missing is_trivially_constructible intrinsic.
+// XFAIL: gcc-4.9
+
 // 
 
 // template  struct pair
 
-// Test that we properly provide the old non-trivial copy operations
-// when the ABI macro is defined.
+// Test that we properly provide the trivial copy operations by default.
 
+// FreeBSD provides the old ABI. This test checks the new ABI so we need
+// to manually turn it on.
+#undef _LIBCPP_ABI_UNSTABLE
+#undef _LIBCPP_ABI_VERSION
+#define _LIBCPP_ABI_VERSION 1
 #define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
+
 #include 
+#include 
+#include 
 #include 
 
 #include "test_macros.h"
 
+#if !defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
+#error trivial ctor ABI macro defined
+#endif
+
+template 
+struct HasNonTrivialABI : std::integral_constant= 11
+   || (std::is_move_constructible::value && 
!std::is_trivially_move_constructible::value)
+#endif
+> {};
+
 #if TEST_STD_VER >= 11
-struct Dummy {
-  Dummy(Dummy const&) = delete;
-  Dummy(Dummy &&) = default;
+struct NonTrivialDtor {
+

r283943 - Module: for ObjectiveC, be consistent when checking hidden decls.

2016-10-11 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Oct 11 16:18:20 2016
New Revision: 283943

URL: http://llvm.org/viewvc/llvm-project?rev=283943=rev
Log:
Module: for ObjectiveC, be consistent when checking hidden decls.

In MatchAllMethodDeclarations, when checking a hidden decl, be sure
to allow hidden when searching for methods.

rdar://28699972

Added:
cfe/trunk/test/Modules/Inputs/objc-hidden/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/

cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/objc-hidden/System/
cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h
cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map
cfe/trunk/test/Modules/objc-hidden.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=283943=283942=283943=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Oct 11 16:18:20 2016
@@ -2741,7 +2741,7 @@ void Sema::MatchAllMethodDeclarations(co
 } else {
   ObjCMethodDecl *ImpMethodDecl =
 IMPDecl->getInstanceMethod(I->getSelector());
-  assert(CDecl->getInstanceMethod(I->getSelector()) &&
+  assert(CDecl->getInstanceMethod(I->getSelector(), true/*AllowHidden*/) &&
  "Expected to find the method through lookup as well");
   // ImpMethodDecl may be null as in a @dynamic property.
   if (ImpMethodDecl) {
@@ -2767,7 +2767,7 @@ void Sema::MatchAllMethodDeclarations(co
 } else {
   ObjCMethodDecl *ImpMethodDecl =
 IMPDecl->getClassMethod(I->getSelector());
-  assert(CDecl->getClassMethod(I->getSelector()) &&
+  assert(CDecl->getClassMethod(I->getSelector(), true/*AllowHidden*/) &&
  "Expected to find the method through lookup as well");
   // ImpMethodDecl may be null as in a @dynamic property.
   if (ImpMethodDecl) {

Added: 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h?rev=283943=auto
==
--- 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Headers/FakeUnavailableObjCFramework.h
 Tue Oct 11 16:18:20 2016
@@ -0,0 +1,7 @@
+#include 
+
+__attribute__((availability(macosx,introduced=1066.0)))  
__attribute__((availability(ios,introduced=1066.0)))
+@interface UnavailableObjCClass : NSObject
+- (void)someMethod;
+@end
+

Added: 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap?rev=283943=auto
==
--- 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/objc-hidden/FakeUnavailableObjCFramework.framework/Modules/module.modulemap
 Tue Oct 11 16:18:20 2016
@@ -0,0 +1,5 @@
+framework module FakeUnavailableObjCFramework {
+  umbrella header "FakeUnavailableObjCFramework.h"
+  // Do not export to test hidden decls.
+  // export *
+}

Added: cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h?rev=283943=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-hidden/System/X.h Tue Oct 11 16:18:20 
2016
@@ -0,0 +1,5 @@
+@protocol NSObject
+@property (readonly) int hash;
+@end
+@interface NSObject 
+@end

Added: cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map?rev=283943=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-hidden/System/module.map (added)
+++ 

[libcxx] r283941 - Fix incorrect exception handling behavior in the uninitialized algorithms

2016-10-11 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 11 16:13:44 2016
New Revision: 283941

URL: http://llvm.org/viewvc/llvm-project?rev=283941=rev
Log:
Fix incorrect exception handling behavior in the uninitialized algorithms

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=283941=283940=283941=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Oct 11 16:13:44 2016
@@ -3709,21 +3709,63 @@ uninitialized_fill_n(_ForwardIterator __
 
 #if _LIBCPP_STD_VER > 14
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void destroy_at(_Tp* __loc) {
+_LIBCPP_ASSERT(__loc, "null pointer given to destroy_at");
+__loc->~_Tp();
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void destroy(_ForwardIterator __first, _ForwardIterator __last) {
+for (; __first != __last; ++__first)
+_VSTD::destroy_at(_VSTD::addressof(*__first));
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
+for (; __n > 0; (void)++__first, --__n)
+_VSTD::destroy_at(_VSTD::addressof(*__first));
+return __first;
+}
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 void uninitialized_default_construct(_ForwardIterator __first, 
_ForwardIterator __last) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __first != __last; ++__first)
-::new((void*)_VSTD::addressof(*__first)) _Vt;
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __idx != __last; ++__idx)
+::new((void*)_VSTD::addressof(*__idx)) _Vt;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, 
_Size __n) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __n > 0; (void)++__first, --__n)
-::new((void*)_VSTD::addressof(*__first)) _Vt;
-return __first;
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __n > 0; (void)++__idx, --__n)
+::new((void*)_VSTD::addressof(*__idx)) _Vt;
+return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 
@@ -3731,60 +3773,79 @@ template 
 inline _LIBCPP_INLINE_VISIBILITY
 void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator 
__last) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __first != __last; ++__first)
-::new((void*)_VSTD::addressof(*__first)) _Vt();
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __idx != __last; ++__idx)
+::new((void*)_VSTD::addressof(*__idx)) _Vt();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, 
_Size __n) {
 using _Vt = typename iterator_traits<_ForwardIterator>::value_type;
-for (; __n > 0; (void)++__first, --__n)
-::new((void*)_VSTD::addressof(*__first)) _Vt();
-return __first;
+auto __idx = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+for (; __n > 0; (void)++__idx, --__n)
+::new((void*)_VSTD::addressof(*__idx)) _Vt();
+return __idx;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+} catch (...) {
+_VSTD::destroy(__first, __idx);
+throw;
+}
+#endif
 }
 
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt 
__res) {
+_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt 
__first_res) {
 using _Vt = typename iterator_traits<_ForwardIt>::value_type;
-for (; __first != __last; (void)++__res, ++__first)
-::new((void*)_VSTD::addressof(*__res)) _Vt(std::move(*__first));
-return __res;
+auto __idx = __first_res;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+try {
+#endif
+

r283932 - Pass the end of a component to SwiftAggLowering's enumerateComponents callback

2016-10-11 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Tue Oct 11 15:34:03 2016
New Revision: 283932

URL: http://llvm.org/viewvc/llvm-project?rev=283932=rev
Log:
Pass the end of a component to SwiftAggLowering's enumerateComponents callback

This is usefull for determining whether components overlap.

Modified:
cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp

Modified: cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h?rev=283932=283931=283932=diff
==
--- cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h (original)
+++ cfe/trunk/include/clang/CodeGen/SwiftCallingConv.h Tue Oct 11 15:34:03 2016
@@ -90,7 +90,7 @@ public:
   bool shouldPassIndirectly(bool asReturnValue) const;
 
   using EnumerationCallback =
-llvm::function_ref;
+llvm::function_ref;
 
   /// Enumerate the expanded components of this type.
   ///

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=283932=283931=283932=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Tue Oct 11 15:34:03 2016
@@ -506,7 +506,7 @@ void SwiftAggLowering::enumerateComponen
   assert(Finished && "haven't yet finished lowering");
 
   for (auto  : Entries) {
-callback(entry.Begin, entry.Type);
+callback(entry.Begin, entry.End, entry.Type);
   }
 }
 


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


r283933 - Swift Calling Convention: Parameters are allowed after the

2016-10-11 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Tue Oct 11 15:34:06 2016
New Revision: 283933

URL: http://llvm.org/viewvc/llvm-project?rev=283933=rev
Log:
Swift Calling Convention: Parameters are allowed after the
swift_error/swift_context parameter

We need to be able to decelare witness functions which append the self type and
the self witness tables at the end of the parameter list.

rdar://28720996

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/attr-swiftcall.c
cfe/trunk/test/SemaCXX/attr-swiftcall.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=283933=283932=283933=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Oct 11 15:34:06 2016
@@ -2400,28 +2400,16 @@ static void checkExtParameterInfos(Sema
   }
   continue;
 
-// swift_context parameters must be the last parameter except for
-// a possible swift_error parameter.
 case ParameterABI::SwiftContext:
   checkForSwiftCC(paramIndex);
-  if (!(paramIndex == numParams - 1 ||
-(paramIndex == numParams - 2 &&
- EPI.ExtParameterInfos[numParams - 1].getABI()
-   == ParameterABI::SwiftErrorResult))) {
-S.Diag(getParamLoc(paramIndex),
-   diag::err_swift_context_not_before_swift_error_result);
-  }
   continue;
 
-// swift_error parameters must be the last parameter.
+// swift_error parameters must be preceded by a swift_context parameter.
 case ParameterABI::SwiftErrorResult:
   checkForSwiftCC(paramIndex);
-  if (paramIndex != numParams - 1) {
-S.Diag(getParamLoc(paramIndex),
-   diag::err_swift_error_result_not_last);
-  } else if (paramIndex == 0 ||
- EPI.ExtParameterInfos[paramIndex - 1].getABI()
-   != ParameterABI::SwiftContext) {
+  if (paramIndex == 0 ||
+  EPI.ExtParameterInfos[paramIndex - 1].getABI() !=
+  ParameterABI::SwiftContext) {
 S.Diag(getParamLoc(paramIndex),
diag::err_swift_error_result_not_after_swift_context);
   }

Modified: cfe/trunk/test/Sema/attr-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-swiftcall.c?rev=283933=283932=283933=diff
==
--- cfe/trunk/test/Sema/attr-swiftcall.c (original)
+++ cfe/trunk/test/Sema/attr-swiftcall.c Tue Oct 11 15:34:06 2016
@@ -18,13 +18,13 @@ void indirect_result_single(INDIRECT_RES
 void indirect_result_multiple(INDIRECT_RESULT void *out1, INDIRECT_RESULT void 
*out2) SWIFTCALL;
 
 void error_result_nonswift(ERROR_RESULT void **error); // expected-error 
{{'swift_error_result' parameter can only be used with swiftcall calling 
convention}} expected-error{{'swift_error_result' parameter must follow 
'swift_context' parameter}}
-void error_result_bad_position(ERROR_RESULT void **error, int last) SWIFTCALL; 
// expected-error {{'swift_error_result' parameter must be last parameter of 
function}}
 void error_result_bad_position2(int first, ERROR_RESULT void **error) 
SWIFTCALL; // expected-error {{'swift_error_result' parameter must follow 
'swift_context' parameter}}
 void error_result_bad_type(CONTEXT void *context, ERROR_RESULT int error) 
SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer 
to unqualified pointer type; type here is 'int'}}
 void error_result_bad_type2(CONTEXT void *context, ERROR_RESULT int *error) 
SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer 
to unqualified pointer type; type here is 'int *'}}
 void error_result_okay(int a, int b, CONTEXT void *context, ERROR_RESULT void 
**error) SWIFTCALL;
+void error_result_okay2(CONTEXT void *context, ERROR_RESULT void **error, void 
*selfType, char **selfWitnessTable) SWIFTCALL;
 
 void context_nonswift(CONTEXT void *context); // expected-error 
{{'swift_context' parameter can only be used with swiftcall calling convention}}
-void context_bad_position(CONTEXT void *context, int x) SWIFTCALL; // 
expected-error {{'swift_context' parameter can only be followed by 
'swift_error_result' parameter}}
 void context_bad_type(CONTEXT int context) SWIFTCALL; // expected-error 
{{'swift_context' parameter must have pointer type; type here is 'int'}}
 void context_okay(CONTEXT void *context) SWIFTCALL;
+void context_okay2(CONTEXT void *context, void *selfType, char 
**selfWitnessTable) SWIFTCALL;

Modified: cfe/trunk/test/SemaCXX/attr-swiftcall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-swiftcall.cpp?rev=283933=283932=283933=diff
==
--- cfe/trunk/test/SemaCXX/attr-swiftcall.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-swiftcall.cpp Tue Oct 11 15:34:06 2016
@@ -17,16 

[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

bruno wrote:
> vbyakovlcl wrote:
> > bruno wrote:
> > > vbyakovlcl wrote:
> > > > bruno wrote:
> > > > > Besides `__ext_vector_type__`, would this also trigger for 
> > > > > `vector_size`? Right now this is an error for `vector_size` primarily 
> > > > > because the number of elements is different, can you confirm this 
> > > > > won't change?
> > > > I compare vector element sizes, so there must not be any differencies 
> > > > caused by different triggers. I added additional type definitions to 
> > > > the tests. All compiles fain.
> > > 
> > > I don't think this is right. When I try to compile similar code for 
> > > `vector_size` without your patch, I get the errors:
> > > 
> > > /tmp/x.c:80:15: error: vector operands do not have the same number of 
> > > elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> > > (vector of 8 'unsigned char' values))
> > >   vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have 
> > > the same elements sizes}}
> > >   ^  ~
> > > /tmp/x.c:81:17: error: vector operands do not have the same number of 
> > > elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 
> > > 'vector_int8n' (vector of 2 'int' values))
> > >   vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not 
> > > have the same elements sizes}}
> > >   ~ ^  
> > > /tmp/x.c:82:17: error: vector operands do not have the same number of 
> > > elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 
> > > 'vector_uint8n' (vector of 2 'unsigned int' values))
> > >   vus8n = vus8n << vui8n; // expected-warning {{vector operands do not 
> > > have the same elements sizes}}
> > >   ~ ^  ~
> > > /tmp/x.c:83:17: error: vector operands do not have the same number of 
> > > elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 
> > > 'vector_short8n' (vector of 4 'short' values))
> > >   vui8n = vui8n << vs8n; // expected-warning {{vector operands do not 
> > > have the same elements sizes}}
> > >   ~ ^   
> > > 
> > > Given your test changes, it seems that now, instead of "vector operands 
> > > do not have the same number of elements" we would get "vector operands do 
> > > not have the same elements sizes". I rather we stay with the first. 
> > > Additionally, even if we had "vector operands do not have the same 
> > > elements sizes" for `vector_size`, this should never be demoted to a 
> > > warning.
> > Argument of a GNU vector size attribute specifies vector size measured in 
> > bytes(see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). So 
> > you got right diagnostics. Both compilers with and without my changes print 
> > the same diagnostics  for yours case. Here is a small testcase used both 
> > GNU and clang extensions
> > 
> > $ cat bruno.c   
> > 
> >  
> > typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
> > typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;
> >  
> > typedef __attribute__((vector_size(8))) int vector_int8n;
> > typedef __attribute__((vector_size(8))) unsigned char vector_uchar8n;
> >  
> > vector_int8  vi8;
> > vector_uchar8 vuc8;
> > vector_int8n  vi8n;
> > vector_uchar8n vuc8n;
> >  
> > int foo() {
> >   vi8 = vi8 << vuc8;
> >   vi8n = vi8n << vuc8n;
> > 
> > $ clang -c bruno.c -Wno-error-vec-elem-size 
> > 
> >  
> > bruno.c:13:13: warning: vector operands do not have the same elements sizes 
> > ('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 
> > 'unsigned char' values)) [-Wvec-elem-size]
> >   vi8 = vi8 << vuc8;
> > ~~~ ^  
> > bruno.c:14:15: error: vector operands do not have the same number of 
> > elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> > (vector of 8 'unsigned char' values))
> >   vi8n = vi8n << vuc8n;
> > 
> > The compiler without the changes prints the second error only 
> > (bruno.c:14:15).
> What actually concerns me here is the following: if you invoke `clang -c 
> bruno.c -Wvec-elem-size`, will that override the `error: vector operands do 
> not have the same number of elements ` message for `vector_size` typed 
> vectors? If so, I don't think this is right.
No, this will not override the error because these diagnostics use independent 
conditions. The option  vec-elem-size is used only for 

Re: r283685 - When optimizing for size, enable loop rerolling by default

2016-10-11 Thread Hal Finkel via cfe-commits
Hi Chris, 

Thanks! Can you (or someone else) revert this. I won't be able to look at it 
until tonight. 

-Hal 

- Original Message -

> From: "Chris Matthews" 
> To: "Hal Finkel" , cfe-commits@lists.llvm.org
> Sent: Tuesday, October 11, 2016 2:32:33 PM
> Subject: Re: r283685 - When optimizing for size, enable loop
> rerolling by default

> I noticed since this commit there is a test-suite failure:

> http://lab.llvm.org:8080/green/job/perf_darwin_x86_Osflto/64/

> SingleSource.Benchmarks.Adobe-C++.loop_unroll appears to be failing.

> Tailing the output of the program gets:

> …
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed
> test 236 failed

> On October 8, 2016 at 8:15:40 PM, Hal Finkel via cfe-commits (
> cfe-commits@lists.llvm.org ) wrote:
> > Author: hfinkel
> 
> > Date: Sat Oct 8 22:06:31 2016
> 
> > New Revision: 283685
> 

> > URL: http://llvm.org/viewvc/llvm-project?rev=283685=rev
> 
> > Log:
> 
> > When optimizing for size, enable loop rerolling by default
> 

> > We have a loop-rerolling optimization which can be enabled by using
> 
> > -freroll-loops. While sometimes loops are hand-unrolled for
> > performance
> 
> > reasons, when optimizing for size, we should always undo this
> > manual
> 
> > optimization to produce smaller code (our optimizer's unroller will
> > still
> 
> > unroll the rerolled loops if it thinks that is a good idea).
> 

> > Modified:
> 
> > cfe/trunk/lib/Driver/Tools.cpp
> 
> > cfe/trunk/test/Driver/clang_f_opts.c
> 

> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> 
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283685=283684=283685=diff
> 
> > ==
> 
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> 
> > +++ cfe/trunk/lib/Driver/Tools.cpp Sat Oct 8 22:06:31 2016
> 
> > @@ -5227,9 +5227,18 @@ void Clang::ConstructJob(Compilation ,
> 
> > }
> 

> > if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
> 
> > - options::OPT_fno_reroll_loops))
> 
> > + options::OPT_fno_reroll_loops)) {
> 
> > if (A->getOption().matches(options::OPT_freroll_loops))
> 
> > CmdArgs.push_back("-freroll-loops");
> 
> > + } else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
> 
> > + // If rerolling is not explicitly enabled or disabled, then
> > enable
> > when
> 
> > + // optimizing for size.
> 
> > + if (A->getOption().matches(options::OPT_O)) {
> 
> > + StringRef S(A->getValue());
> 
> > + if (S == "s" || S == "z")
> 
> > + CmdArgs.push_back("-freroll-loops");
> 
> > + }
> 
> > + }
> 

> > Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
> 
> > Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,
> 

> > Modified: cfe/trunk/test/Driver/clang_f_opts.c
> 
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=283685=283684=283685=diff
> 
> > ==
> 
> > --- cfe/trunk/test/Driver/clang_f_opts.c (original)
> 
> > +++ cfe/trunk/test/Driver/clang_f_opts.c Sat Oct 8 22:06:31 2016
> 
> > @@ -47,7 +47,12 @@
> 
> > // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"
> 

> > // RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Os %s 2>&1 | FileCheck
> > -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck
> > -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > // RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Os -fno-reroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -Oz -fno-reroll-loops %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > +// RUN: %clang -### -S -O1 %s 2>&1 | FileCheck
> > -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > // RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 |
> > FileCheck -check-prefix=CHECK-REROLL-LOOPS %s
> 
> > // RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 |
> > FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s
> 
> > // CHECK-REROLL-LOOPS: "-freroll-loops"
> 

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

-- 

Hal Finkel 
Lead, Compiler Technology and Programming Languages 
Leadership Computing Facility 
Argonne National Laboratory 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r283685 - When optimizing for size, enable loop rerolling by default

2016-10-11 Thread Chris Matthews via cfe-commits

I noticed since this commit there is a test-suite failure:


http://lab.llvm.org:8080/green/job/perf_darwin_x86_Osflto/64/


SingleSource.Benchmarks.Adobe-C++.loop_unroll appears to be failing.


Tailing the output of the program gets:


…

test 236 failed

test 236 failed

test 236 failed

test 236 failed

test 236 failed

test 236 failed

test 236 failed



On October 8, 2016 at 8:15:40 PM, Hal Finkel via cfe-commits 
(cfe-commits@lists.llvm.org) wrote:

Author: hfinkel
Date: Sat Oct 8 22:06:31 2016
New Revision: 283685

URL: http://llvm.org/viewvc/llvm-project?rev=283685=rev
Log:
When optimizing for size, enable loop rerolling by default

We have a loop-rerolling optimization which can be enabled by using
-freroll-loops. While sometimes loops are hand-unrolled for performance
reasons, when optimizing for size, we should always undo this manual
optimization to produce smaller code (our optimizer's unroller will still
unroll the rerolled loops if it thinks that is a good idea).

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283685=283684=283685=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Oct 8 22:06:31 2016
@@ -5227,9 +5227,18 @@ void Clang::ConstructJob(Compilation ,
}

if (Arg *A = Args.getLastArg(options::OPT_freroll_loops,
- options::OPT_fno_reroll_loops))
+ options::OPT_fno_reroll_loops)) {
if (A->getOption().matches(options::OPT_freroll_loops))
CmdArgs.push_back("-freroll-loops");
+ } else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+ // If rerolling is not explicitly enabled or disabled, then enable when
+ // optimizing for size.
+ if (A->getOption().matches(options::OPT_O)) {
+ StringRef S(A->getValue());
+ if (S == "s" || S == "z")
+ CmdArgs.push_back("-freroll-loops");
+ }
+ }

Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=283685=283684=283685=diff
==
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Sat Oct 8 22:06:31 2016
@@ -47,7 +47,12 @@
// CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops"

// RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
+// RUN: %clang -### -S -Os %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
+// RUN: %clang -### -S -Oz %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
// RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
+// RUN: %clang -### -S -Os -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
+// RUN: %clang -### -S -Oz -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
+// RUN: %clang -### -S -O1 %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
// RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-REROLL-LOOPS %s
// RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-REROLL-LOOPS %s
// CHECK-REROLL-LOOPS: "-freroll-loops"


___
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] D25387: When optimizing for size, enable loop rerolling by default.

2016-10-11 Thread Chris Matthews via cfe-commits
Hal,

I noticed since this commit there is a test-suite failure:

http://lab.llvm.org:8080/green/job/perf_darwin_x86_Osflto/64/

SingleSource.Benchmarks.Adobe-C++.loop_unroll appears to be failing.

Tailing the output of the program gets:

…
test 236 failed
test 236 failed
test 236 failed
test 236 failed
test 236 failed
test 236 failed
test 236 failed


On October 8, 2016 at 8:16:18 PM, Hal Finkel via cfe-commits 
(cfe-commits@lists.llvm.org) wrote:

hfinkel closed this revision.
hfinkel added a comment.

r283685


https://reviews.llvm.org/D25387



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


[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

In https://reviews.llvm.org/D25480#567552, @ahatanak wrote:

> __builtin_fpclassify takes five int arguments followed by one last argument 
> that is of floating point type. Do you know if there is a way to specify the 
> last one argument is a floating point rather than using '.'?


There is already code in `clang/lib/Sema/SemaChecking.cpp` to generate 
`diag::err_typecheck_call_invalid_unary_fp`.


https://reviews.llvm.org/D25480



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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-10-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

malcolm.parsons wrote:
> aaron.ballman wrote:
> > mgehre wrote:
> > > aaron.ballman wrote:
> > > > Hmm, it seems like this is boilerplate we are going to want for every 
> > > > rule, and that it's pretty easy to not get this right (for instance, if 
> > > > you change the way the check is spelled, you have to remember to update 
> > > > this as well). Could this actually be handled more transparently, by 
> > > > gathering this information when the check is registered and exposing it 
> > > > to the check?
> > > > 
> > > > The checks would still need to use `unless(isSuppressed(Rules))` in 
> > > > some form, but I am thinking that it would be more convenient if we 
> > > > could do: 
> > > > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> > > >  this);`
> > > I see multiple ways on how to integrate that into clang-tidy:
> > > 1) Add something like you proposed to each matcher of each check
> > > 2) Change (or add overload of)
> > > ```
> > >  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
> > >  DiagnosticIDs::Level Level = 
> > > DiagnosticIDs::Warning);
> > > ```
> > > to add a AST node as parameter and make the SourceLocation optional. Most 
> > > checks anyhow
> > > call this like diag(E->getLoc(), ""), and then they would do diag(E, 
> > > "...").
> > > Diag then would check from the that AST node upwards to see if it finds a 
> > > matching [[suppress]] attribute
> > > 
> > > 3) Change the RecursiveASTVistor that drives the AST Matches to prune 
> > > certain matchers from the list of to-be-evaluated matchers
> > > for all AST subtrees that are below a certain [[suppress]] attribute. 
> > > (This is based on how I image that the AST matchers work)
> > Ideally, I would like to see this attribute used to suppress Clang 
> > diagnostics as well, however. So while I think Option 2 is better suited to 
> > that future direction, it's still not ideal because all instances of diag() 
> > need to be updated to take advantage. Options 1 and 3 are basically limited 
> > to clang-tidy use.
> > 
> > I wonder if there's a way to modify the diagnostic builder to transparently 
> > handle this without requiring modifying all of the call sites?
> clang-tidy reports how many warnings were suppressed by NOLINT comments.
> I'd expect the number of warnings suppressed by [[clang::suppress]] to be 
> included in the count.
> Handling suppressions in the matchers or visitors would prevent this.
As would handling the suppression transparently within the diagnostic engine 
itself.


https://reviews.llvm.org/D24888



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


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Reverted in r283920, can you check if it is enough to “fix” the GCC issue?

> On Oct 11, 2016, at 12:04 PM, Benjamin Kramer  wrote:
> 
> Committing this patch before the constexpr change seems backwards
> then? The static initializers are already breaking stuff because it
> takes GCC with optimization and debug info takes 10+ minutes to
> generate megabytes of static initializer code in Targets.cpp. Can you
> please revert this until the constexpr change is ready?
> 
> On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
>> This is temporary: the last patch of my series of patches adds the constexpr 
>> ctor and remove all these static initializers.
>> 
>>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
>>> 
>>> I don't think this change is worth it. We create huge static arrays
>>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
>>> char*) is not constexpr (because of strlen). This means you'll get a
>>> huge generated initialization function for it. We want to reduce the
>>> number of global initializers in LLVM, not create new ones.
>>> 
>>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>>>  wrote:
 Author: mehdi_amini
 Date: Mon Oct 10 16:34:29 2016
 New Revision: 283802
 
 URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
 Log:
 Change Builtins name to be stored as StringRef instead of raw pointers 
 (NFC)
 
 Modified:
   cfe/trunk/include/clang/Basic/Builtins.h
   cfe/trunk/lib/CodeGen/CGBuiltin.cpp
   cfe/trunk/lib/Sema/SemaChecking.cpp
 
 Modified: cfe/trunk/include/clang/Basic/Builtins.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
 ==
 --- cfe/trunk/include/clang/Basic/Builtins.h (original)
 +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
 @@ -51,7 +51,8 @@ enum ID {
 };
 
 struct Info {
 -  const char *Name, *Type, *Attributes, *HeaderName;
 +  llvm::StringRef Name;
 +  const char *Type, *Attributes, *HeaderName;
  LanguageID Langs;
  const char *Features;
 };
 @@ -80,7 +81,7 @@ public:
 
  /// \brief Return the identifier name for the specified builtin,
  /// e.g. "__builtin_abs".
 -  const char *getName(unsigned ID) const {
 +  llvm::StringRef getName(unsigned ID) const {
return getRecord(ID).Name;
  }
 
 
 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
 @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
  if (FD->hasAttr())
Name = getMangledName(D);
  else
 -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
 +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
 
  llvm::FunctionType *Ty =
cast(getTypes().ConvertType(FD->getType()));
 @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
  checkTargetFeatures(E, FD);
 
  // See if we have a target specific intrinsic.
 -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
  Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
  StringRef Prefix =
  llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
  if (!Prefix.empty()) {
 +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
// NOTE we dont need to perform a compatibility flag check here since 
 the
// intrinsics are declared in Builtins*.def via LANGBUILTIN which 
 filter the
 
 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
 ==
 --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
 @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
  // Get the decl for the concrete builtin from this, we can tell what the
  // concrete integer type we should convert to is.
  unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
 -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
  FunctionDecl *NewBuiltinDecl;
  if (NewBuiltinID == BuiltinID)
NewBuiltinDecl = FDecl;
  else {
// 

r283920 - Revert "Change Builtins name to be stored as StringRef instead of raw pointers (NFC)"

2016-10-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Tue Oct 11 14:04:24 2016
New Revision: 283920

URL: http://llvm.org/viewvc/llvm-project?rev=283920=rev
Log:
Revert "Change Builtins name to be stored as StringRef instead of raw pointers 
(NFC)"

This reverts commit r283802. It introduces temporarily static
initializers, because StringRef ctor isn't (yet) constexpr for
string literals.
I plan to get there this week, but apparently GCC is so terrible
with these static initializer right now (10 min+ extra codegen
time was reported) that I'll hold on to this patch till the
constexpr one is ready, and land these at the same time.

Modified:
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283920=283919=283920=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Tue Oct 11 14:04:24 2016
@@ -51,8 +51,7 @@ enum ID {
 };
 
 struct Info {
-  llvm::StringRef Name;
-  const char *Type, *Attributes, *HeaderName;
+  const char *Name, *Type, *Attributes, *HeaderName;
   LanguageID Langs;
   const char *Features;
 };
@@ -81,7 +80,7 @@ public:
 
   /// \brief Return the identifier name for the specified builtin,
   /// e.g. "__builtin_abs".
-  llvm::StringRef getName(unsigned ID) const {
+  const char *getName(unsigned ID) const {
 return getRecord(ID).Name;
   }
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283920=283919=283920=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Oct 11 14:04:24 2016
@@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
   if (FD->hasAttr())
 Name = getMangledName(D);
   else
-Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
+Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
 
   llvm::FunctionType *Ty =
 cast(getTypes().ConvertType(FD->getType()));
@@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   checkTargetFeatures(E, FD);
 
   // See if we have a target specific intrinsic.
+  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
   StringRef Prefix =
   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
   if (!Prefix.empty()) {
-StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
 IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
 // NOTE we dont need to perform a compatibility flag check here since the
 // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter 
the

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283920=283919=283920=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Oct 11 14:04:24 2016
@@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
   // Get the decl for the concrete builtin from this, we can tell what the
   // concrete integer type we should convert to is.
   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
+  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
   FunctionDecl *NewBuiltinDecl;
   if (NewBuiltinID == BuiltinID)
 NewBuiltinDecl = FDecl;
   else {
 // Perform builtin lookup to avoid redeclaring it.
-StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
 DeclarationName DN((NewBuiltinName));
 LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
 LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
@@ -6263,7 +6263,7 @@ static void emitReplacement(Sema , Sou
 unsigned AbsKind, QualType ArgType) {
   bool EmitHeaderHint = true;
   const char *HeaderName = nullptr;
-  StringRef FunctionName;
+  const char *FunctionName = nullptr;
   if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
 FunctionName = "std::abs";
 if (ArgType->isIntegralOrEnumerationType()) {
@@ -6381,7 +6381,7 @@ void Sema::CheckAbsoluteValueFunction(co
   // Unsigned types cannot be negative.  Suggest removing the absolute value
   // function call.
   if (ArgType->isUnsignedIntegerType()) {
-StringRef FunctionName =
+const char *FunctionName =
 IsStdAbs ? "std::abs" : Context.BuiltinInfo.getName(AbsKind);
 Diag(Call->getExprLoc(), diag::warn_unsigned_abs) << ArgType << ParamType;
 Diag(Call->getExprLoc(), diag::note_remove_abs)



Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Yes, do you have a specific concern for this table size in particular?

> On Oct 11, 2016, at 12:07 PM, Craig Topper  wrote:
> 
> But this also increases the size of the builtin table too right? Since 
> StringRef is twice the size of a pointer.
> 
> ~Craig
> 
> On Tue, Oct 11, 2016 at 11:40 AM, Mehdi Amini via cfe-commits 
> > wrote:
> This is temporary: the last patch of my series of patches adds the constexpr 
> ctor and remove all these static initializers.
> 
> > On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  > > wrote:
> >
> > I don't think this change is worth it. We create huge static arrays
> > with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> > char*) is not constexpr (because of strlen). This means you'll get a
> > huge generated initialization function for it. We want to reduce the
> > number of global initializers in LLVM, not create new ones.
> >
> > On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
> > > wrote:
> >> Author: mehdi_amini
> >> Date: Mon Oct 10 16:34:29 2016
> >> New Revision: 283802
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev 
> >> 
> >> Log:
> >> Change Builtins name to be stored as StringRef instead of raw pointers 
> >> (NFC)
> >>
> >> Modified:
> >>cfe/trunk/include/clang/Basic/Builtins.h
> >>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >>cfe/trunk/lib/Sema/SemaChecking.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> >> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> >> @@ -51,7 +51,8 @@ enum ID {
> >> };
> >>
> >> struct Info {
> >> -  const char *Name, *Type, *Attributes, *HeaderName;
> >> +  llvm::StringRef Name;
> >> +  const char *Type, *Attributes, *HeaderName;
> >>   LanguageID Langs;
> >>   const char *Features;
> >> };
> >> @@ -80,7 +81,7 @@ public:
> >>
> >>   /// \brief Return the identifier name for the specified builtin,
> >>   /// e.g. "__builtin_abs".
> >> -  const char *getName(unsigned ID) const {
> >> +  llvm::StringRef getName(unsigned ID) const {
> >> return getRecord(ID).Name;
> >>   }
> >>
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> >> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
> >>   if (FD->hasAttr())
> >> Name = getMangledName(D);
> >>   else
> >> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> >> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
> >>
> >>   llvm::FunctionType *Ty =
> >> cast(getTypes().ConvertType(FD->getType()));
> >> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >>   checkTargetFeatures(E, FD);
> >>
> >>   // See if we have a target specific intrinsic.
> >> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
> >>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
> >>   StringRef Prefix =
> >>   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
> >>   if (!Prefix.empty()) {
> >> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
> >> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), 
> >> Name);
> >> // NOTE we dont need to perform a compatibility flag check here since 
> >> the
> >> // intrinsics are declared in Builtins*.def via LANGBUILTIN which 
> >> filter the
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
> >>  
> >> 
> >> ==
> >> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> >> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
> >>   // Get the decl for the concrete builtin from this, we can 

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits

> On Oct 11, 2016, at 12:04 PM, Benjamin Kramer  wrote:
> 
> Committing this patch before the constexpr change seems backwards
> then?

Well not really because I need to make StringRef(const char *) explicit, so all 
the others have to go first.

> The static initializers are already breaking stuff because it
> takes GCC with optimization and debug info takes 10+ minutes to
> generate megabytes of static initializer code in Targets.cpp. Can you
> please revert this until the constexpr change is ready?

I already landed > 30 patches like this one, I have no problem temporarily 
reverting this one in particular, but there are others instance of static 
initializers in the other patches.

— 
Mehdi



> 
> On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
>> This is temporary: the last patch of my series of patches adds the constexpr 
>> ctor and remove all these static initializers.
>> 
>>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
>>> 
>>> I don't think this change is worth it. We create huge static arrays
>>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
>>> char*) is not constexpr (because of strlen). This means you'll get a
>>> huge generated initialization function for it. We want to reduce the
>>> number of global initializers in LLVM, not create new ones.
>>> 
>>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>>>  wrote:
 Author: mehdi_amini
 Date: Mon Oct 10 16:34:29 2016
 New Revision: 283802
 
 URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
 Log:
 Change Builtins name to be stored as StringRef instead of raw pointers 
 (NFC)
 
 Modified:
   cfe/trunk/include/clang/Basic/Builtins.h
   cfe/trunk/lib/CodeGen/CGBuiltin.cpp
   cfe/trunk/lib/Sema/SemaChecking.cpp
 
 Modified: cfe/trunk/include/clang/Basic/Builtins.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
 ==
 --- cfe/trunk/include/clang/Basic/Builtins.h (original)
 +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
 @@ -51,7 +51,8 @@ enum ID {
 };
 
 struct Info {
 -  const char *Name, *Type, *Attributes, *HeaderName;
 +  llvm::StringRef Name;
 +  const char *Type, *Attributes, *HeaderName;
  LanguageID Langs;
  const char *Features;
 };
 @@ -80,7 +81,7 @@ public:
 
  /// \brief Return the identifier name for the specified builtin,
  /// e.g. "__builtin_abs".
 -  const char *getName(unsigned ID) const {
 +  llvm::StringRef getName(unsigned ID) const {
return getRecord(ID).Name;
  }
 
 
 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
 ==
 --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
 @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
  if (FD->hasAttr())
Name = getMangledName(D);
  else
 -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
 +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
 
  llvm::FunctionType *Ty =
cast(getTypes().ConvertType(FD->getType()));
 @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
  checkTargetFeatures(E, FD);
 
  // See if we have a target specific intrinsic.
 -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
  Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
  StringRef Prefix =
  llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
  if (!Prefix.empty()) {
 +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
// NOTE we dont need to perform a compatibility flag check here since 
 the
// intrinsics are declared in Builtins*.def via LANGBUILTIN which 
 filter the
 
 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
 ==
 --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
 @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
  // Get the decl for the concrete builtin from this, we can tell what the
  // concrete integer type we should convert to is.
  unsigned NewBuiltinID = 

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Craig Topper via cfe-commits
But this also increases the size of the builtin table too right? Since
StringRef is twice the size of a pointer.

~Craig

On Tue, Oct 11, 2016 at 11:40 AM, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This is temporary: the last patch of my series of patches adds the
> constexpr ctor and remove all these static initializers.
>
> > On Oct 11, 2016, at 11:26 AM, Benjamin Kramer 
> wrote:
> >
> > I don't think this change is worth it. We create huge static arrays
> > with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> > char*) is not constexpr (because of strlen). This means you'll get a
> > huge generated initialization function for it. We want to reduce the
> > number of global initializers in LLVM, not create new ones.
> >
> > On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
> >  wrote:
> >> Author: mehdi_amini
> >> Date: Mon Oct 10 16:34:29 2016
> >> New Revision: 283802
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
> >> Log:
> >> Change Builtins name to be stored as StringRef instead of raw pointers
> (NFC)
> >>
> >> Modified:
> >>cfe/trunk/include/clang/Basic/Builtins.h
> >>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >>cfe/trunk/lib/Sema/SemaChecking.cpp
> >>
> >> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Builtins.h?rev=283802=283801=283802=diff
> >> 
> ==
> >> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> >> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> >> @@ -51,7 +51,8 @@ enum ID {
> >> };
> >>
> >> struct Info {
> >> -  const char *Name, *Type, *Attributes, *HeaderName;
> >> +  llvm::StringRef Name;
> >> +  const char *Type, *Attributes, *HeaderName;
> >>   LanguageID Langs;
> >>   const char *Features;
> >> };
> >> @@ -80,7 +81,7 @@ public:
> >>
> >>   /// \brief Return the identifier name for the specified builtin,
> >>   /// e.g. "__builtin_abs".
> >> -  const char *getName(unsigned ID) const {
> >> +  llvm::StringRef getName(unsigned ID) const {
> >> return getRecord(ID).Name;
> >>   }
> >>
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGBuiltin.cpp?rev=283802=283801=283802=diff
> >> 
> ==
> >> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> >> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
> >>   if (FD->hasAttr())
> >> Name = getMangledName(D);
> >>   else
> >> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> >> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
> >>
> >>   llvm::FunctionType *Ty =
> >> cast(getTypes().ConvertType(FD->getType()));
> >> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
> >>   checkTargetFeatures(E, FD);
> >>
> >>   // See if we have a target specific intrinsic.
> >> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
> >>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
> >>   StringRef Prefix =
> >>   llvm::Triple::getArchTypePrefix(getTarget().
> getTriple().getArch());
> >>   if (!Prefix.empty()) {
> >> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
> >> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(),
> Name);
> >> // NOTE we dont need to perform a compatibility flag check here
> since the
> >> // intrinsics are declared in Builtins*.def via LANGBUILTIN which
> filter the
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaChecking.cpp?rev=283802=283801=283802=diff
> >> 
> ==
> >> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> >> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
> >>   // Get the decl for the concrete builtin from this, we can tell what
> the
> >>   // concrete integer type we should convert to is.
> >>   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
> >> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(
> NewBuiltinID);
> >>   FunctionDecl *NewBuiltinDecl;
> >>   if (NewBuiltinID == BuiltinID)
> >> NewBuiltinDecl = FDecl;
> >>   else {
> >> // Perform builtin lookup to avoid redeclaring it.
> >> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(
> NewBuiltinID);
> >> DeclarationName DN((NewBuiltinName));
> >> LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
> >> LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
> >> @@ 

Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Benjamin Kramer via cfe-commits
Committing this patch before the constexpr change seems backwards
then? The static initializers are already breaking stuff because it
takes GCC with optimization and debug info takes 10+ minutes to
generate megabytes of static initializer code in Targets.cpp. Can you
please revert this until the constexpr change is ready?

On Tue, Oct 11, 2016 at 8:40 PM, Mehdi Amini  wrote:
> This is temporary: the last patch of my series of patches adds the constexpr 
> ctor and remove all these static initializers.
>
>> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
>>
>> I don't think this change is worth it. We create huge static arrays
>> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
>> char*) is not constexpr (because of strlen). This means you'll get a
>> huge generated initialization function for it. We want to reduce the
>> number of global initializers in LLVM, not create new ones.
>>
>> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>>  wrote:
>>> Author: mehdi_amini
>>> Date: Mon Oct 10 16:34:29 2016
>>> New Revision: 283802
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
>>> Log:
>>> Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
>>>
>>> Modified:
>>>cfe/trunk/include/clang/Basic/Builtins.h
>>>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>>cfe/trunk/lib/Sema/SemaChecking.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Builtins.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>>> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
>>> @@ -51,7 +51,8 @@ enum ID {
>>> };
>>>
>>> struct Info {
>>> -  const char *Name, *Type, *Attributes, *HeaderName;
>>> +  llvm::StringRef Name;
>>> +  const char *Type, *Attributes, *HeaderName;
>>>   LanguageID Langs;
>>>   const char *Features;
>>> };
>>> @@ -80,7 +81,7 @@ public:
>>>
>>>   /// \brief Return the identifier name for the specified builtin,
>>>   /// e.g. "__builtin_abs".
>>> -  const char *getName(unsigned ID) const {
>>> +  llvm::StringRef getName(unsigned ID) const {
>>> return getRecord(ID).Name;
>>>   }
>>>
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
>>> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>>>   if (FD->hasAttr())
>>> Name = getMangledName(D);
>>>   else
>>> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
>>> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>>>
>>>   llvm::FunctionType *Ty =
>>> cast(getTypes().ConvertType(FD->getType()));
>>> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>>>   checkTargetFeatures(E, FD);
>>>
>>>   // See if we have a target specific intrinsic.
>>> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>>>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>>>   StringRef Prefix =
>>>   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>>>   if (!Prefix.empty()) {
>>> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>>> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
>>> // NOTE we dont need to perform a compatibility flag check here since 
>>> the
>>> // intrinsics are declared in Builtins*.def via LANGBUILTIN which 
>>> filter the
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
>>> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>>>   // Get the decl for the concrete builtin from this, we can tell what the
>>>   // concrete integer type we should convert to is.
>>>   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
>>> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>>>   FunctionDecl *NewBuiltinDecl;
>>>   if (NewBuiltinID == BuiltinID)
>>> NewBuiltinDecl = FDecl;
>>>   else {
>>> // Perform builtin lookup to avoid redeclaring it.
>>> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>>> DeclarationName DN((NewBuiltinName));
>>> LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
>>> 

[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

__builtin_fpclassify takes five int arguments followed by one last argument 
that is of floating point type. Do you know if there is a way to specify the 
last one argument is a floating point rather than using '.'?


https://reviews.llvm.org/D25480



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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-10-11 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

aaron.ballman wrote:
> mgehre wrote:
> > aaron.ballman wrote:
> > > Hmm, it seems like this is boilerplate we are going to want for every 
> > > rule, and that it's pretty easy to not get this right (for instance, if 
> > > you change the way the check is spelled, you have to remember to update 
> > > this as well). Could this actually be handled more transparently, by 
> > > gathering this information when the check is registered and exposing it 
> > > to the check?
> > > 
> > > The checks would still need to use `unless(isSuppressed(Rules))` in some 
> > > form, but I am thinking that it would be more convenient if we could do: 
> > > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> > >  this);`
> > I see multiple ways on how to integrate that into clang-tidy:
> > 1) Add something like you proposed to each matcher of each check
> > 2) Change (or add overload of)
> > ```
> >  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
> >  DiagnosticIDs::Level Level = 
> > DiagnosticIDs::Warning);
> > ```
> > to add a AST node as parameter and make the SourceLocation optional. Most 
> > checks anyhow
> > call this like diag(E->getLoc(), ""), and then they would do diag(E, 
> > "...").
> > Diag then would check from the that AST node upwards to see if it finds a 
> > matching [[suppress]] attribute
> > 
> > 3) Change the RecursiveASTVistor that drives the AST Matches to prune 
> > certain matchers from the list of to-be-evaluated matchers
> > for all AST subtrees that are below a certain [[suppress]] attribute. (This 
> > is based on how I image that the AST matchers work)
> Ideally, I would like to see this attribute used to suppress Clang 
> diagnostics as well, however. So while I think Option 2 is better suited to 
> that future direction, it's still not ideal because all instances of diag() 
> need to be updated to take advantage. Options 1 and 3 are basically limited 
> to clang-tidy use.
> 
> I wonder if there's a way to modify the diagnostic builder to transparently 
> handle this without requiring modifying all of the call sites?
clang-tidy reports how many warnings were suppressed by NOLINT comments.
I'd expect the number of warnings suppressed by [[clang::suppress]] to be 
included in the count.
Handling suppressions in the matchers or visitors would prevent this.


https://reviews.llvm.org/D24888



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


[PATCH] D25483: [libcxx] [test] Fix non-Standard assumptions about how many elements are allocated

2016-10-11 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

The recently-added limited_allocator is much more conformant than the evil old 
stack_allocator. However, limited_allocator encodes non-Standard assumptions 
about how many allocations containers perform, which don't hold for MSVC. 
Specifically, MSVC's STL dynamically allocates sentinel nodes and "container 
proxies" (for debug mode checking), and its vector famously grows by 1.5x 
instead of 2x. I would like to retain the limited_allocator coverage, but tweak 
things so that they pass for both libc++ and MSVC.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
deque is too weird. (MSVC's deque reallocates its blockmap several times while 
doing this.) Just mark the tests as LIBCPP_ONLY, the coward's way out.

test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
test/std/containers/sequences/list/list.cons/size_type.pass.cpp
test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
"Add 2 for implementations that dynamically allocate a sentinel node and 
container proxy."

test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
"Add 1 for implementations that dynamically allocate a container proxy."

test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
Ditto. The (InIt, InIt) ctor is unchanged at 63 elements allocated (MSVC's 1.5x 
results in fewer element allocations, enough to make room for the container 
proxy).

test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
Adjust numbers for container proxy and 1.5x growth, with the calculations in 
the comments.


https://reviews.llvm.org/D25483

Files:
  test/std/containers/sequences/deque/deque.cons/size.pass.cpp
  test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
  test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
  test/std/containers/sequences/list/list.cons/size_type.pass.cpp
  test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
  test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
  test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
  
test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
  test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
  test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
  test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
  
test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp

Index: test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
===
--- test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
+++ test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -50,7 +50,10 @@
 assert(c[j] == MoveOnly(j));
 }
 {
-std::vector > c;
+// libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
+// Use 17 for implementations that dynamically allocate a container proxy
+// and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
+std::vector > c;
 c.push_back(MoveOnly(0));
 assert(c.size() == 1);
 assert(is_contiguous_container_asan_correct(c));
Index: test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
===
--- test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
+++ test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -48,7 +48,10 @@
 assert(c[j] == j);
 }
 {
-std::vector > c;
+// libc++ needs 15 because it grows by 2x (1 + 2 + 4 + 8).
+// Use 17 for implementations that dynamically allocate a container proxy
+// and grow by 1.5x (1 for proxy + 1 + 2 + 3 + 4 + 6).
+std::vector > c;
 c.push_back(0);
 assert(c.size() == 1);
 assert(is_contiguous_container_asan_correct(c));
Index: test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
===
--- test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
+++ 

r283917 - [Driver] Use -fsyntax-only in test/Driver/show-option-names.c

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 11 13:38:33 2016
New Revision: 283917

URL: http://llvm.org/viewvc/llvm-project?rev=283917=rev
Log:
[Driver] Use -fsyntax-only in test/Driver/show-option-names.c

Make the test less expensive, follow up from r283915.

Modified:
cfe/trunk/test/Driver/show-option-names.c

Modified: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283917=283916=283917=diff
==
--- cfe/trunk/test/Driver/show-option-names.c (original)
+++ cfe/trunk/test/Driver/show-option-names.c Tue Oct 11 13:38:33 2016
@@ -1,7 +1,7 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -target x86_64-apple-darwin -c -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
+// RUN: %clang -target x86_64-apple-darwin -fsyntax-only -isysroot /FOO %s 
2>&1 | FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
 // CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
 
-// RUN: %clang -target x86_64-apple-darwin -c -fno-diagnostics-show-option 
-isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
+// RUN: %clang -target x86_64-apple-darwin -fsyntax-only 
-fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
 // CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
This is temporary: the last patch of my series of patches adds the constexpr 
ctor and remove all these static initializers.

> On Oct 11, 2016, at 11:26 AM, Benjamin Kramer  wrote:
> 
> I don't think this change is worth it. We create huge static arrays
> with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
> char*) is not constexpr (because of strlen). This means you'll get a
> huge generated initialization function for it. We want to reduce the
> number of global initializers in LLVM, not create new ones.
> 
> On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
>  wrote:
>> Author: mehdi_amini
>> Date: Mon Oct 10 16:34:29 2016
>> New Revision: 283802
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
>> Log:
>> Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
>> 
>> Modified:
>>cfe/trunk/include/clang/Basic/Builtins.h
>>cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>>cfe/trunk/lib/Sema/SemaChecking.cpp
>> 
>> Modified: cfe/trunk/include/clang/Basic/Builtins.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
>> @@ -51,7 +51,8 @@ enum ID {
>> };
>> 
>> struct Info {
>> -  const char *Name, *Type, *Attributes, *HeaderName;
>> +  llvm::StringRef Name;
>> +  const char *Type, *Attributes, *HeaderName;
>>   LanguageID Langs;
>>   const char *Features;
>> };
>> @@ -80,7 +81,7 @@ public:
>> 
>>   /// \brief Return the identifier name for the specified builtin,
>>   /// e.g. "__builtin_abs".
>> -  const char *getName(unsigned ID) const {
>> +  llvm::StringRef getName(unsigned ID) const {
>> return getRecord(ID).Name;
>>   }
>> 
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
>> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>>   if (FD->hasAttr())
>> Name = getMangledName(D);
>>   else
>> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
>> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>> 
>>   llvm::FunctionType *Ty =
>> cast(getTypes().ConvertType(FD->getType()));
>> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>>   checkTargetFeatures(E, FD);
>> 
>>   // See if we have a target specific intrinsic.
>> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>>   Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>>   StringRef Prefix =
>>   llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>>   if (!Prefix.empty()) {
>> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>> IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
>> // NOTE we dont need to perform a compatibility flag check here since the
>> // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter 
>> the
>> 
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
>> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>>   // Get the decl for the concrete builtin from this, we can tell what the
>>   // concrete integer type we should convert to is.
>>   unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
>> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>>   FunctionDecl *NewBuiltinDecl;
>>   if (NewBuiltinID == BuiltinID)
>> NewBuiltinDecl = FDecl;
>>   else {
>> // Perform builtin lookup to avoid redeclaring it.
>> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>> DeclarationName DN((NewBuiltinName));
>> LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
>> LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
>> @@ -6263,7 +6263,7 @@ static void emitReplacement(Sema , Sou
>> unsigned AbsKind, QualType ArgType) {
>>   bool EmitHeaderHint = true;
>>   const char *HeaderName = nullptr;
>> -  const char *FunctionName = nullptr;
>> +  StringRef FunctionName;
>>   if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
>> FunctionName = "std::abs";
>> if (ArgType->isIntegralOrEnumerationType()) {
>> @@ 

r283915 - [Driver] Fix test from r283913 to unbreak bots

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 11 13:31:45 2016
New Revision: 283915

URL: http://llvm.org/viewvc/llvm-project?rev=283915=rev
Log:
[Driver] Fix test from r283913 to unbreak bots

Followup from r283913 & r283827

http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55135

Modified:
cfe/trunk/test/Driver/show-option-names.c

Modified: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283915=283914=283915=diff
==
--- cfe/trunk/test/Driver/show-option-names.c (original)
+++ cfe/trunk/test/Driver/show-option-names.c Tue Oct 11 13:31:45 2016
@@ -1,5 +1,7 @@
-// RUN: %clang -c -isysroot /FOO %s 2>&1 | FileCheck 
--check-prefix=CHECK-SHOW-OPTION-NAMES %s
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target x86_64-apple-darwin -c -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-SHOW-OPTION-NAMES %s
 // CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
 
-// RUN: %clang -c -fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
+// RUN: %clang -target x86_64-apple-darwin -c -fno-diagnostics-show-option 
-isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
 // CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Let's see how it goes: Committed r283913

On Tue, Oct 11, 2016 at 11:13 AM, Bruno Cardoso Lopes
 wrote:
> On Tue, Oct 11, 2016 at 10:09 AM, Renato Golin  
> wrote:
>> On 11 October 2016 at 16:34, Bruno Cardoso Lopes
>>  wrote:
>>> Thanks Renato!
>>
>> So, Daniel Jasper did a trick on r283853 (clang || true) to make it
>> not fail when it returns on error. However, I wasn't able to make it
>> return anything but 0, so I'm at odds why this fails on the bot.
>>
>> I was expecting it to actually return non-zero, since it emits an
>> error, which is even weirder. So, using "not clang" doesn't work in
>> this case. Do you have any ideas why this behaviour is like that?
>
> I have no idea. I'm gonna try to re-introduce the commit without a
> target specifc triple, that hopefully should be enough to get it
> working (there was no specific reason this test should be using a
> specific target anyway)
>
> Thanks again Renato
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283913 - Reapply [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 11 13:21:26 2016
New Revision: 283913

URL: http://llvm.org/viewvc/llvm-project?rev=283913=rev
Log:
Reapply [Driver][Diagnostics] Make 'show option names' default for driver 
warnings

Reapply r283827 by fixing the tests to not be target specific

Currently, driver level warnings do not show option names (e.g. warning:
complain about foo [-Woption-name]) in a diagnostic unless
-fdiagnostics-show-option is explictly specified. OTOH, the driver by
default turn this option on for CC1. Change the logic to show option
names by default in the driver as well.

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

rdar://problem/27300909

Added:
cfe/trunk/test/Driver/show-option-names.c
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=283913=283912=283913=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Tue Oct 11 13:21:26 
2016
@@ -48,7 +48,8 @@ class DiagnosticsEngine;
 /// report the error(s).
 bool ParseDiagnosticArgs(DiagnosticOptions , llvm::opt::ArgList ,
  DiagnosticsEngine *Diags = nullptr,
- bool DefaultDiagColor = true);
+ bool DefaultDiagColor = true,
+ bool DefaultShowOpt = true);
 
 class CompilerInvocationBase : public RefCountedBase {
   void operator=(const CompilerInvocationBase &) = delete;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=283913=283912=283913=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Oct 11 13:21:26 2016
@@ -957,7 +957,7 @@ static bool parseShowColorsArgs(const Ar
 
 bool clang::ParseDiagnosticArgs(DiagnosticOptions , ArgList ,
 DiagnosticsEngine *Diags,
-bool DefaultDiagColor) {
+bool DefaultDiagColor, bool DefaultShowOpt) {
   using namespace options;
   bool Success = true;
 
@@ -977,7 +977,9 @@ bool clang::ParseDiagnosticArgs(Diagnost
   Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
   Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
   Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
-  Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
+  Opts.ShowOptionNames =
+  Args.hasFlag(OPT_fdiagnostics_show_option,
+   OPT_fno_diagnostics_show_option, DefaultShowOpt);
 
   llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
 
@@ -2404,8 +2406,9 @@ bool CompilerInvocation::CreateFromArgs(
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
-  Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, ,
- false /*DefaultDiagColor*/);
+  Success &=
+  ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, ,
+  false /*DefaultDiagColor*/, false 
/*DefaultShowOpt*/);
   ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here

Added: cfe/trunk/test/Driver/show-option-names.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/show-option-names.c?rev=283913=auto
==
--- cfe/trunk/test/Driver/show-option-names.c (added)
+++ cfe/trunk/test/Driver/show-option-names.c Tue Oct 11 13:21:26 2016
@@ -0,0 +1,5 @@
+// RUN: %clang -c -isysroot /FOO %s 2>&1 | FileCheck 
--check-prefix=CHECK-SHOW-OPTION-NAMES %s
+// CHECK-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO' [-Wmissing-sysroot]
+
+// RUN: %clang -c -fno-diagnostics-show-option -isysroot /FOO %s 2>&1 | 
FileCheck --check-prefix=CHECK-NO-SHOW-OPTION-NAMES %s
+// CHECK-NO-SHOW-OPTION-NAMES: warning: no such sysroot directory: 
'{{([A-Za-z]:.*)?}}/FOO'{{$}}


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


Re: r283802 - Change Builtins name to be stored as StringRef instead of raw pointers (NFC)

2016-10-11 Thread Benjamin Kramer via cfe-commits
I don't think this change is worth it. We create huge static arrays
with Builtin::Info in Builtins.cpp and Targets.cpp, StringRef(const
char*) is not constexpr (because of strlen). This means you'll get a
huge generated initialization function for it. We want to reduce the
number of global initializers in LLVM, not create new ones.

On Mon, Oct 10, 2016 at 11:34 PM, Mehdi Amini via cfe-commits
 wrote:
> Author: mehdi_amini
> Date: Mon Oct 10 16:34:29 2016
> New Revision: 283802
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283802=rev
> Log:
> Change Builtins name to be stored as StringRef instead of raw pointers (NFC)
>
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.h
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=283802=283801=283802=diff
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.h (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.h Mon Oct 10 16:34:29 2016
> @@ -51,7 +51,8 @@ enum ID {
>  };
>
>  struct Info {
> -  const char *Name, *Type, *Attributes, *HeaderName;
> +  llvm::StringRef Name;
> +  const char *Type, *Attributes, *HeaderName;
>LanguageID Langs;
>const char *Features;
>  };
> @@ -80,7 +81,7 @@ public:
>
>/// \brief Return the identifier name for the specified builtin,
>/// e.g. "__builtin_abs".
> -  const char *getName(unsigned ID) const {
> +  llvm::StringRef getName(unsigned ID) const {
>  return getRecord(ID).Name;
>}
>
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=283802=283801=283802=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 10 16:34:29 2016
> @@ -50,7 +50,7 @@ llvm::Value *CodeGenModule::getBuiltinLi
>if (FD->hasAttr())
>  Name = getMangledName(D);
>else
> -Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
> +Name = Context.BuiltinInfo.getName(BuiltinID).drop_front(10);
>
>llvm::FunctionType *Ty =
>  cast(getTypes().ConvertType(FD->getType()));
> @@ -2523,11 +2523,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
>checkTargetFeatures(E, FD);
>
>// See if we have a target specific intrinsic.
> -  const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
>Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
>StringRef Prefix =
>llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch());
>if (!Prefix.empty()) {
> +StringRef Name = getContext().BuiltinInfo.getName(BuiltinID);
>  IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
>  // NOTE we dont need to perform a compatibility flag check here since the
>  // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter 
> the
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=283802=283801=283802=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 10 16:34:29 2016
> @@ -3199,12 +3199,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
>// Get the decl for the concrete builtin from this, we can tell what the
>// concrete integer type we should convert to is.
>unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
> -  const char *NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>FunctionDecl *NewBuiltinDecl;
>if (NewBuiltinID == BuiltinID)
>  NewBuiltinDecl = FDecl;
>else {
>  // Perform builtin lookup to avoid redeclaring it.
> +StringRef NewBuiltinName = Context.BuiltinInfo.getName(NewBuiltinID);
>  DeclarationName DN((NewBuiltinName));
>  LookupResult Res(*this, DN, DRE->getLocStart(), LookupOrdinaryName);
>  LookupName(Res, TUScope, /*AllowBuiltinCreation=*/true);
> @@ -6263,7 +6263,7 @@ static void emitReplacement(Sema , Sou
>  unsigned AbsKind, QualType ArgType) {
>bool EmitHeaderHint = true;
>const char *HeaderName = nullptr;
> -  const char *FunctionName = nullptr;
> +  StringRef FunctionName;
>if (S.getLangOpts().CPlusPlus && !ArgType->isAnyComplexType()) {
>  FunctionName = "std::abs";
>  if (ArgType->isIntegralOrEnumerationType()) {
> @@ -6381,7 +6381,7 @@ void Sema::CheckAbsoluteValueFunction(co
>// Unsigned types cannot be negative.  Suggest removing the absolute value
>// function call.
>if (ArgType->isUnsignedIntegerType()) {
> -const char *FunctionName =
> +StringRef FunctionName =
>  

[PATCH] D25397: [change-namespace] don't miss comments in the beginning of a namespace block.

2016-10-11 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:387
+  Token Tok;
+  while (!Lex->LexFromRawLexer(Tok) && Tok.isNot(tok::TokenKind::l_brace)) {
+  }

hokein wrote:
> Maybe we can use `findLocationAfterToken` here? 
This doesn't seem to work in this case. Note that we are lexing from the 
beginning of `NsDecl`, which is `namespace` or `inline`, and the next token is 
not necessarily `{`.

  /// \brief Checks that the given token is the first token that occurs after 
the
  /// given location (this excludes comments and whitespace). Returns the 
location
  /// immediately after the specified token. If the token is not found or the
  /// location is inside a macro, the returned source location will be invalid.
  SourceLocation Lexer::findLocationAfterToken(...);



https://reviews.llvm.org/D25397



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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Oct 11, 2016 at 10:09 AM, Renato Golin  wrote:
> On 11 October 2016 at 16:34, Bruno Cardoso Lopes
>  wrote:
>> Thanks Renato!
>
> So, Daniel Jasper did a trick on r283853 (clang || true) to make it
> not fail when it returns on error. However, I wasn't able to make it
> return anything but 0, so I'm at odds why this fails on the bot.
>
> I was expecting it to actually return non-zero, since it emits an
> error, which is even weirder. So, using "not clang" doesn't work in
> this case. Do you have any ideas why this behaviour is like that?

I have no idea. I'm gonna try to re-introduce the commit without a
target specifc triple, that hopefully should be enough to get it
working (there was no specific reason this test should be using a
specific target anyway)

Thanks again Renato



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

A test should probably be added as well.


https://reviews.llvm.org/D25480



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


r283907 - [CUDA] Re-land support for (r283683 and r283680).

2016-10-11 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Oct 11 12:36:03 2016
New Revision: 283907

URL: http://llvm.org/viewvc/llvm-project?rev=283907=rev
Log:
[CUDA] Re-land support for  (r283683 and r283680).

These were reverted in r283753 and r283747.

The first patch added a header to the root 'Headers' install directory,
instead of into 'Headers/cuda_wrappers'.  This was fixed in the second
patch, but by then the damage was done: The bad header stayed in the
'Headers' directory, continuing to break the build.

We reverted both patches in an attempt to fix things, but that still
didn't get rid of the header, so the Windows boostrap build remained
broken.

It's probably worth fixing up our cmake logic to remove things from the
install dirs, but in the meantime, re-land these patches, since we
believe they no longer have this bug.

Added:
cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
cfe/trunk/lib/Headers/cuda_wrappers/
cfe/trunk/lib/Headers/cuda_wrappers/algorithm
cfe/trunk/lib/Headers/cuda_wrappers/complex
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=283907=283906=283907=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 11 12:36:03 2016
@@ -4694,6 +4694,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
 
 void Linux::AddCudaIncludeArgs(const ArgList ,
ArgStringList ) const {
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+// Add cuda_wrappers/* to our system include path.  This lets us wrap
+// standard library headers.
+SmallString<128> P(getDriver().ResourceDir);
+llvm::sys::path::append(P, "include");
+llvm::sys::path::append(P, "cuda_wrappers");
+addSystemInclude(DriverArgs, CC1Args, P);
+  }
+
   if (DriverArgs.hasArg(options::OPT_nocudainc))
 return;
 

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=283907=283906=283907=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue Oct 11 12:36:03 2016
@@ -24,6 +24,7 @@ set(files
   bmiintrin.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_cmath.h
+  __clang_cuda_complex_builtins.h
   __clang_cuda_intrinsics.h
   __clang_cuda_math_forward_declares.h
   __clang_cuda_runtime_wrapper.h
@@ -89,6 +90,11 @@ set(files
   xtestintrin.h
   )
 
+set(cuda_wrapper_files
+  cuda_wrappers/algorithm
+  cuda_wrappers/complex
+)
+
 set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
 
 # Generate arm_neon.h
@@ -96,7 +102,7 @@ clang_tablegen(arm_neon.h -gen-arm-neon
   SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td)
 
 set(out_files)
-foreach( f ${files} )
+foreach( f ${files} ${cuda_wrapper_files} )
   set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
   set( dst ${output_dir}/${f} )
   add_custom_command(OUTPUT ${dst}
@@ -121,6 +127,12 @@ install(
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
 
+install(
+  FILES ${cuda_wrapper_files}
+  COMPONENT clang-headers
+  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+  DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
+
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
   add_custom_target(install-clang-headers
 DEPENDS clang-headers

Added: cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h?rev=283907=auto
==
--- cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h (added)
+++ cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h Tue Oct 11 12:36:03 
2016
@@ -0,0 +1,203 @@
+/*===-- __clang_cuda_complex_builtins - CUDA impls of runtime complex fns 
---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT 

[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-10-11 Thread Paweł Żukowski via cfe-commits
idlecode marked an inline comment as done.
idlecode added a comment.

Sure, I will upload diff as soon as I test it


https://reviews.llvm.org/D25439



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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
bruno added inline comments.



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

vbyakovlcl wrote:
> bruno wrote:
> > vbyakovlcl wrote:
> > > bruno wrote:
> > > > Besides `__ext_vector_type__`, would this also trigger for 
> > > > `vector_size`? Right now this is an error for `vector_size` primarily 
> > > > because the number of elements is different, can you confirm this won't 
> > > > change?
> > > I compare vector element sizes, so there must not be any differencies 
> > > caused by different triggers. I added additional type definitions to the 
> > > tests. All compiles fain.
> > 
> > I don't think this is right. When I try to compile similar code for 
> > `vector_size` without your patch, I get the errors:
> > 
> > /tmp/x.c:80:15: error: vector operands do not have the same number of 
> > elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> > (vector of 8 'unsigned char' values))
> >   vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ^  ~
> > /tmp/x.c:81:17: error: vector operands do not have the same number of 
> > elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 
> > 'vector_int8n' (vector of 2 'int' values))
> >   vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ~ ^  
> > /tmp/x.c:82:17: error: vector operands do not have the same number of 
> > elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 
> > 'vector_uint8n' (vector of 2 'unsigned int' values))
> >   vus8n = vus8n << vui8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ~ ^  ~
> > /tmp/x.c:83:17: error: vector operands do not have the same number of 
> > elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 
> > 'vector_short8n' (vector of 4 'short' values))
> >   vui8n = vui8n << vs8n; // expected-warning {{vector operands do not have 
> > the same elements sizes}}
> >   ~ ^   
> > 
> > Given your test changes, it seems that now, instead of "vector operands do 
> > not have the same number of elements" we would get "vector operands do not 
> > have the same elements sizes". I rather we stay with the first. 
> > Additionally, even if we had "vector operands do not have the same elements 
> > sizes" for `vector_size`, this should never be demoted to a warning.
> Argument of a GNU vector size attribute specifies vector size measured in 
> bytes(see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). So you 
> got right diagnostics. Both compilers with and without my changes print the 
> same diagnostics  for yours case. Here is a small testcase used both GNU and 
> clang extensions
> 
> $ cat bruno.c 
>   
>  
> typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
> typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;
>  
> typedef __attribute__((vector_size(8))) int vector_int8n;
> typedef __attribute__((vector_size(8))) unsigned char vector_uchar8n;
>  
> vector_int8  vi8;
> vector_uchar8 vuc8;
> vector_int8n  vi8n;
> vector_uchar8n vuc8n;
>  
> int foo() {
>   vi8 = vi8 << vuc8;
>   vi8n = vi8n << vuc8n;
> 
> $ clang -c bruno.c -Wno-error-vec-elem-size   
>   
>  
> bruno.c:13:13: warning: vector operands do not have the same elements sizes 
> ('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 
> 'unsigned char' values)) [-Wvec-elem-size]
>   vi8 = vi8 << vuc8;
> ~~~ ^  
> bruno.c:14:15: error: vector operands do not have the same number of elements 
> ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' (vector of 8 
> 'unsigned char' values))
>   vi8n = vi8n << vuc8n;
> 
> The compiler without the changes prints the second error only (bruno.c:14:15).
What actually concerns me here is the following: if you invoke `clang -c 
bruno.c -Wvec-elem-size`, will that override the `error: vector operands do not 
have the same number of elements ` message for `vector_size` typed vectors? If 
so, I don't think this is right.


https://reviews.llvm.org/D24669



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


[PATCH] D25480: __builtin_fpclassify missing one int parameter

2016-10-11 Thread Tania Albarghouthi via cfe-commits
taniabarg created this revision.
taniabarg added reviewers: davidsh, hubert.reinterpretcast.
taniabarg added a subscriber: cfe-commits.

BIF fpclassify has the wrong number of integer parameters specified in 
Builtins.def. There should be 5 int parameters (each representing the values 
FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL and FP_ZERO) but Builtins.def 
previously specified 4.


https://reviews.llvm.org/D25480

Files:
  include/clang/Basic/Builtins.def


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -367,7 +367,7 @@
 BUILTIN(__builtin_isunordered   , "i.", "Fnc")

 // Unary FP classification
-BUILTIN(__builtin_fpclassify, "i.", "Fnc")
+BUILTIN(__builtin_fpclassify, "ii.", "Fnc")
 BUILTIN(__builtin_isfinite,   "i.", "Fnc")
 BUILTIN(__builtin_isinf,  "i.", "Fnc")
 BUILTIN(__builtin_isinf_sign, "i.", "Fnc")


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -367,7 +367,7 @@
 BUILTIN(__builtin_isunordered   , "i.", "Fnc")

 // Unary FP classification
-BUILTIN(__builtin_fpclassify, "i.", "Fnc")
+BUILTIN(__builtin_fpclassify, "ii.", "Fnc")
 BUILTIN(__builtin_isfinite,   "i.", "Fnc")
 BUILTIN(__builtin_isinf,  "i.", "Fnc")
 BUILTIN(__builtin_isinf_sign, "i.", "Fnc")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283906 - Fix the build with MSVC 2013 after r283856

2016-10-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Oct 11 12:24:09 2016
New Revision: 283906

URL: http://llvm.org/viewvc/llvm-project?rev=283906=rev
Log:
Fix the build with MSVC 2013 after r283856

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

Modified: cfe/trunk/lib/Frontend/CacheTokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CacheTokens.cpp?rev=283906=283905=283906=diff
==
--- cfe/trunk/lib/Frontend/CacheTokens.cpp (original)
+++ cfe/trunk/lib/Frontend/CacheTokens.cpp Tue Oct 11 12:24:09 2016
@@ -60,8 +60,10 @@ public:
 class PTHEntryKeyVariant {
   union {
 const FileEntry *FE;
-StringRef Path;
+// FIXME: Use "StringRef Path;" when MSVC 2013 is dropped.
+const char *PathPtr;
   };
+  size_t PathSize;
   enum { IsFE = 0x1, IsDE = 0x2, IsNoExist = 0x0 } Kind;
   FileData *Data;
 
@@ -69,15 +71,17 @@ public:
   PTHEntryKeyVariant(const FileEntry *fe) : FE(fe), Kind(IsFE), Data(nullptr) 
{}
 
   PTHEntryKeyVariant(FileData *Data, StringRef Path)
-  : Path(Path), Kind(IsDE), Data(new FileData(*Data)) {}
+  : PathPtr(Path.data()), PathSize(Path.size()), Kind(IsDE),
+Data(new FileData(*Data)) {}
 
   explicit PTHEntryKeyVariant(StringRef Path)
-  : Path(Path), Kind(IsNoExist), Data(nullptr) {}
+  : PathPtr(Path.data()), PathSize(Path.size()), Kind(IsNoExist),
+Data(nullptr) {}
 
   bool isFile() const { return Kind == IsFE; }
 
   StringRef getString() const {
-return Kind == IsFE ? FE->getName() : Path;
+return Kind == IsFE ? FE->getName() : StringRef(PathPtr, PathSize);
   }
 
   unsigned getKind() const { return (unsigned) Kind; }


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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-10-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

mgehre wrote:
> aaron.ballman wrote:
> > Hmm, it seems like this is boilerplate we are going to want for every rule, 
> > and that it's pretty easy to not get this right (for instance, if you 
> > change the way the check is spelled, you have to remember to update this as 
> > well). Could this actually be handled more transparently, by gathering this 
> > information when the check is registered and exposing it to the check?
> > 
> > The checks would still need to use `unless(isSuppressed(Rules))` in some 
> > form, but I am thinking that it would be more convenient if we could do: 
> > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> >  this);`
> I see multiple ways on how to integrate that into clang-tidy:
> 1) Add something like you proposed to each matcher of each check
> 2) Change (or add overload of)
> ```
>  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
>  DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
> ```
> to add a AST node as parameter and make the SourceLocation optional. Most 
> checks anyhow
> call this like diag(E->getLoc(), ""), and then they would do diag(E, 
> "...").
> Diag then would check from the that AST node upwards to see if it finds a 
> matching [[suppress]] attribute
> 
> 3) Change the RecursiveASTVistor that drives the AST Matches to prune certain 
> matchers from the list of to-be-evaluated matchers
> for all AST subtrees that are below a certain [[suppress]] attribute. (This 
> is based on how I image that the AST matchers work)
Ideally, I would like to see this attribute used to suppress Clang diagnostics 
as well, however. So while I think Option 2 is better suited to that future 
direction, it's still not ideal because all instances of diag() need to be 
updated to take advantage. Options 1 and 3 are basically limited to clang-tidy 
use.

I wonder if there's a way to modify the diagnostic builder to transparently 
handle this without requiring modifying all of the call sites?



Comment at: clang-tidy/cppcoreguidelines/Suppression.h:59
+ anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))),
+   hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules)
+  .matches(Node, Finder, Builder);

mgehre wrote:
> aaron.ballman wrote:
> > Why is the check for `hasAttrs` required?
> > 
> > Also, this use of `hasAncestor()` makes this expensive to use, and that 
> > expense may be hidden from the caller. Is there a way to structure this so 
> > that we don't need to walk the entire ancestor tree?
> hasAttr() is needed here, because inside of hasSuppressAttr(), we call 
> getAttrs() which would assert if hasAttr() is false.
> I cannot push hasAttr() into hasSuppressAttr(), because hasSuppressAttr() is 
> a template getting either Decl or AttributedStmt,
> and AttributedStmt does not have an hasAttr() method.
I believe that `getSpecificAttr` should be resilient to no attributes being 
present (since it also has to handle the case there are no attributes of the 
specific type, so no attributes at all is simply a degenerate case), and so the 
check for `hasAttrs()` should be redundant.


https://reviews.llvm.org/D24888



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


[PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute

2016-10-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:1469
+  let Spellings = [CXX11<"clang", "suppress">, CXX11<"gsl", "suppress">];
+  let Args = [VariadicStringArgument<"Rules">];
+  let Documentation = [SuppressDocs];

Perhaps we should name this something other than "Rules" -- you don't suppress 
a rule, you're suppressing a diagnostic based on some identifier, so I'd go 
with `DiagnosticIdentifiers` or something along those lines.



Comment at: include/clang/Basic/AttrDocs.td:2509
+to suppress specific clang-tidy warnings. They can be attached to a scope,
+statement or type. The ``[[gsl::suppress]]`` is an alias of 
``[[clang::suppress]]``
+which is intended to be used for suppressing rules of the C++ Core Guidelines_

This statement does not match the test cases -- it does not appear to be 
possible to attach the attribute to a type.


https://reviews.llvm.org/D24886



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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Renato Golin via cfe-commits
On 11 October 2016 at 16:34, Bruno Cardoso Lopes
 wrote:
> Thanks Renato!

So, Daniel Jasper did a trick on r283853 (clang || true) to make it
not fail when it returns on error. However, I wasn't able to make it
return anything but 0, so I'm at odds why this fails on the bot.

I was expecting it to actually return non-zero, since it emits an
error, which is even weirder. So, using "not clang" doesn't work in
this case. Do you have any ideas why this behaviour is like that?

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


Re: r283856 - Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)

2016-10-11 Thread Reid Kleckner via cfe-commits
This breaks MSVC 2013 builds:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/30238/steps/run%20tests/logs/stdio

FAILED:
tools/clang/lib/Frontend/CMakeFiles/clangFrontend.dir/CacheTokens.cpp.obj
...
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(63)
: error C2620: '`anonymous-namespace'::PTHEntryKeyVariant::Path' : illegal
union member; type 'llvm::StringRef' has a user-defined constructor or
non-trivial default constructor
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(71)
: error C2614: '`anonymous-namespace'::PTHEntryKeyVariant' : illegal member
initialization: 'Path' is not a base or member
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(74)
: error C2614: '`anonymous-namespace'::PTHEntryKeyVariant' : illegal member
initialization: 'Path' is not a base or member
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CacheTokens.cpp(80)
: error C2065: 'Path' : undeclared identifier

On Tue, Oct 11, 2016 at 12:31 AM, Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mehdi_amini
> Date: Tue Oct 11 02:31:29 2016
> New Revision: 283856
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283856=rev
> Log:
> Turn FileManager DirectoryEntry::Name from raw pointer to StringRef (NFC)
>
> Modified:
> cfe/trunk/include/clang/Basic/FileManager.h
> cfe/trunk/include/clang/Basic/FileSystemStatCache.h
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/lib/Basic/FileSystemStatCache.cpp
> cfe/trunk/lib/Frontend/CacheTokens.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PTHLexer.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>
> Modified: cfe/trunk/include/clang/Basic/FileManager.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/FileManager.h?rev=283856=283855=283856=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> +++ cfe/trunk/include/clang/Basic/FileManager.h Tue Oct 11 02:31:29 2016
> @@ -38,11 +38,10 @@ class FileSystemStatCache;
>  /// \brief Cached information about one directory (either on disk or in
>  /// the virtual file system).
>  class DirectoryEntry {
> -  const char *Name;   // Name of the directory.
> +  StringRef Name; // Name of the directory.
>friend class FileManager;
>  public:
> -  DirectoryEntry() : Name(nullptr) {}
> -  const char *getName() const { return Name; }
> +  StringRef getName() const { return Name; }
>  };
>
>  /// \brief Cached information about one file (either on disk
> @@ -165,7 +164,7 @@ class FileManager : public RefCountedBas
>// Caching.
>std::unique_ptr StatCache;
>
> -  bool getStatValue(const char *Path, FileData , bool isFile,
> +  bool getStatValue(StringRef Path, FileData , bool isFile,
>  std::unique_ptr *F);
>
>/// Add all ancestors of the given path (pointing to either a file
>
> Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> FileSystemStatCache.h?rev=283856=283855=283856=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original)
> +++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Oct 11
> 02:31:29 2016
> @@ -68,7 +68,7 @@ public:
>/// success for directories (not files).  On a successful file lookup,
> the
>/// implementation can optionally fill in \p F with a valid \p File
> object and
>/// the client guarantees that it will close it.
> -  static bool get(const char *Path, FileData , bool isFile,
> +  static bool get(StringRef Path, FileData , bool isFile,
>std::unique_ptr *F, FileSystemStatCache
> *Cache,
>vfs::FileSystem );
>
> @@ -92,11 +92,11 @@ protected:
>// FIXME: The pointer here is a non-owning/optional reference to the
>// unique_ptr. Optional might be nicer, but
>// Optional needs some work to support references so this isn't
> possible yet.
> -  virtual LookupResult getStat(const char *Path, FileData , bool
> isFile,
> +  virtual LookupResult getStat(StringRef Path, FileData , bool
> isFile,
> std::unique_ptr *F,
> vfs::FileSystem ) = 0;
>
> -  LookupResult statChained(const char *Path, FileData , bool isFile,
> +  LookupResult statChained(StringRef Path, FileData , bool isFile,
> std::unique_ptr *F, vfs::FileSystem
> ) {
>  if (FileSystemStatCache *Next = getNextStatCache())
>return Next->getStat(Path, Data, isFile, F, FS);
> @@ -121,7 +121,7 @@ public:
>iterator begin() const { return StatCalls.begin(); }
>iterator end() const { return StatCalls.end(); }
>
> -  LookupResult getStat(const char *Path, FileData , bool isFile,
> +  

[PATCH] D25244: [clang-tidy] Add a whitelist option in google-runtime-references.

2016-10-11 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/google/NonConstReferences.cpp:73
+   [&](llvm::StringRef WhiteListType) {
+ return ReferencedType.getCanonicalType().getAsString(
+Result.Context->getPrintingPolicy()) ==

It should be possible to check the whitelist in the matcher 
(`qualType(unless(anyOf(isConstQualified(), 
hasDeclaration(namedDecl(hasAnyName(WhiteListTypes))` or something similar).


https://reviews.llvm.org/D25244



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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8787
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();

bruno wrote:
> vbyakovlcl wrote:
> > bruno wrote:
> > > Besides `__ext_vector_type__`, would this also trigger for `vector_size`? 
> > > Right now this is an error for `vector_size` primarily because the number 
> > > of elements is different, can you confirm this won't change?
> > I compare vector element sizes, so there must not be any differencies 
> > caused by different triggers. I added additional type definitions to the 
> > tests. All compiles fain.
> 
> I don't think this is right. When I try to compile similar code for 
> `vector_size` without your patch, I get the errors:
> 
> /tmp/x.c:80:15: error: vector operands do not have the same number of 
> elements ('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' 
> (vector of 8 'unsigned char' values))
>   vi8n = vi8n << vuc8n; // expected-warning {{vector operands do not have the 
> same elements sizes}}
>   ^  ~
> /tmp/x.c:81:17: error: vector operands do not have the same number of 
> elements ('vector_uchar8n' (vector of 8 'unsigned char' values) and 
> 'vector_int8n' (vector of 2 'int' values))
>   vuc8n = vuc8n << vi8n; // expected-warning {{vector operands do not have 
> the same elements sizes}}
>   ~ ^  
> /tmp/x.c:82:17: error: vector operands do not have the same number of 
> elements ('vector_ushort8n' (vector of 4 'unsigned short' values) and 
> 'vector_uint8n' (vector of 2 'unsigned int' values))
>   vus8n = vus8n << vui8n; // expected-warning {{vector operands do not have 
> the same elements sizes}}
>   ~ ^  ~
> /tmp/x.c:83:17: error: vector operands do not have the same number of 
> elements ('vector_uint8n' (vector of 2 'unsigned int' values) and 
> 'vector_short8n' (vector of 4 'short' values))
>   vui8n = vui8n << vs8n; // expected-warning {{vector operands do not have 
> the same elements sizes}}
>   ~ ^   
> 
> Given your test changes, it seems that now, instead of "vector operands do 
> not have the same number of elements" we would get "vector operands do not 
> have the same elements sizes". I rather we stay with the first. Additionally, 
> even if we had "vector operands do not have the same elements sizes" for 
> `vector_size`, this should never be demoted to a warning.
Argument of a GNU vector size attribute specifies vector size measured in 
bytes(see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). So you 
got right diagnostics. Both compilers with and without my changes print the 
same diagnostics  for yours case. Here is a small testcase used both GNU and 
clang extensions

$ cat bruno.c   

 
typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
typedef __attribute__((__ext_vector_type__(8))) unsigned char vector_uchar8;
 
typedef __attribute__((vector_size(8))) int vector_int8n;
typedef __attribute__((vector_size(8))) unsigned char vector_uchar8n;
 
vector_int8  vi8;
vector_uchar8 vuc8;
vector_int8n  vi8n;
vector_uchar8n vuc8n;
 
int foo() {
  vi8 = vi8 << vuc8;
  vi8n = vi8n << vuc8n;

$ clang -c bruno.c -Wno-error-vec-elem-size 

 
bruno.c:13:13: warning: vector operands do not have the same elements sizes 
('vector_int8' (vector of 8 'int' values) and 'vector_uchar8' (vector of 8 
'unsigned char' values)) [-Wvec-elem-size]
  vi8 = vi8 << vuc8;
~~~ ^  
bruno.c:14:15: error: vector operands do not have the same number of elements 
('vector_int8n' (vector of 2 'int' values) and 'vector_uchar8n' (vector of 8 
'unsigned char' values))
  vi8n = vi8n << vuc8n;

The compiler without the changes prints the second error only (bruno.c:14:15).



Comment at: llvm/tools/clang/lib/Sema/SemaExpr.cpp:8795-8798
+if (S.Diags.getDiagnosticLevel(
+diag::warn_typecheck_vector_element_sizes_not_equal, Loc) ==
+DiagnosticsEngine::Level::Error)
+  return QualType();

majnemer wrote:
> Why `return QualType()` here? Would returning `LHSType` provide confusing or 
> incorrect diagnostics?
This is really excessive. Thanks.


https://reviews.llvm.org/D24669



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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-11 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl updated this revision to Diff 74269.

https://reviews.llvm.org/D24669

Files:
  llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
  llvm/tools/clang/lib/Sema/SemaExpr.cpp
  llvm/tools/clang/test/CodeGen/vecshift.c
  llvm/tools/clang/test/Sema/vecshift.c

Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8784,6 +8784,16 @@
 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();
+  const BuiltinType *RHSBT = RHSEleType->getAs();
+  if (LHSBT != RHSBT &&
+  S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) {
+S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
+<< LHS.get()->getType() << RHS.get()->getType()
+<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+  }
+}
   } else {
 // ...else expand RHS to match the number of elements in LHS.
 QualType VecTy =
Index: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2301,6 +2301,9 @@
   "cannot convert between vector and non-scalar values (%0 and %1)">;
 def err_typecheck_vector_lengths_not_equal : Error<
   "vector operands do not have the same number of elements (%0 and %1)">;
+def warn_typecheck_vector_element_sizes_not_equal : Warning<
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup>, DefaultError;
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<
Index: llvm/tools/clang/test/CodeGen/vecshift.c
===
--- llvm/tools/clang/test/CodeGen/vecshift.c
+++ llvm/tools/clang/test/CodeGen/vecshift.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-vec-elem-size -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1  -Wno-error-vec-elem-size -DEXT -emit-llvm %s -o - | FileCheck %s
 
+#ifdef EXT
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
 typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
@@ -12,6 +14,20 @@
 typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4;
+#else
+typedef __attribute__((vector_size(8))) char vector_char8;
+typedef __attribute__((vector_size(16))) short vector_short8;
+typedef __attribute__((vector_size(32))) int vector_int8;
+typedef __attribute__((vector_size(8))) unsigned char vector_uchar8;
+typedef __attribute__((vector_size(16))) unsigned short vector_ushort8;
+typedef __attribute__((vector_size(32))) unsigned int vector_uint8;
+typedef __attribute__((vector_size(4))) char vector_char4;
+typedef __attribute__((vector_size(4))) short vector_short4;
+typedef __attribute__((vector_size(16))) int vector_int4;
+typedef __attribute__((vector_size(4))) unsigned char vector_uchar4;
+typedef __attribute__((vector_size(8))) unsigned short vector_ushort4;
+typedef __attribute__((vector_size(16))) unsigned int vector_uint4;
+#endif
 
 char c;
 short s;
Index: llvm/tools/clang/test/Sema/vecshift.c
===
--- llvm/tools/clang/test/Sema/vecshift.c
+++ llvm/tools/clang/test/Sema/vecshift.c
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DERR -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-error-vec-elem-size -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DEXT -DERR -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DEXT -Wno-error-vec-elem-size -verify %s
 
+#ifdef EXT
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
 typedef __attribute__((__ext_vector_type__(8))) int vector_int8;
@@ -12,6 +16,20 @@
 typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4;
 typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4;
+#else
+typedef __attribute__((vector_size(8))) char vector_char8;
+typedef __attribute__((vector_size(16))) short vector_short8;
+typedef __attribute__((vector_size(32))) int vector_int8;
+typedef __attribute__((vector_size(8))) unsigned char 

Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-11 Thread Reid Kleckner via cfe-commits
On Tue, Oct 11, 2016 at 9:34 AM, Justin Lebar  wrote:

> > Can we figure out why having an incremental stage1 is problematic? I
> want to keep it that way to speed up the bot.
>
> The problem is that the cmake install rule that we use does not remove
> extra files that happen to be present in the install directory.  So if
> you put something bad in there, as I did, it's never coming out.
>
> I spent a few hours trying to figure out how to do this yesterday to no
> avail.
>
> But it would be nice not to block this change on fixing our cmake
> rules, especially if the relevant expertise is hard to come by.


Sure. I don't think the "install" step is expensive. We should be able to
fix this problem going forward by changing our bot config to clean out the
installation directory before the install step.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-11 Thread Justin Lebar via cfe-commits
> Can we figure out why having an incremental stage1 is problematic? I want to 
> keep it that way to speed up the bot.

The problem is that the cmake install rule that we use does not remove
extra files that happen to be present in the install directory.  So if
you put something bad in there, as I did, it's never coming out.

I spent a few hours trying to figure out how to do this yesterday to no avail.

But it would be nice not to block this change on fixing our cmake
rules, especially if the relevant expertise is hard to come by.

On Tue, Oct 11, 2016 at 9:31 AM, Reid Kleckner  wrote:
> Can we figure out why having an incremental stage1 is problematic? I want to
> keep it that way to speed up the bot.
>
> It sounds like the problem is that we do not delete the stage1 install
> directory before installing to it, or our install step uses a glob that may
> include stale files from previous builds.
>
> On Mon, Oct 10, 2016 at 8:56 AM, Justin Lebar  wrote:
>>
>> As discussed over IM, builds are still failing after reverting this.
>>
>> The issue seems to be that the stage 1 build in bootstrap compiles is
>> not a clean build.  Therefore the errant  and 
>> headers are never removed from the install directory.
>>
>> I believe I fixed the cmake in r283683 (sent a few hours after this
>> one), but because the stage 1 builds are not clean, they were still
>> broken after that change.
>>
>> Easiest fix at this point would be to find someone with ssh access to
>> the buildbots to rm -rf the stage 1 directory.
>>
>> On Mon, Oct 10, 2016 at 7:19 AM, Nico Weber  wrote:
>> > This broke bootstrap builds, I reverted it for now in r283747.
>> >
>> > On Sat, Oct 8, 2016 at 6:16 PM, Justin Lebar via cfe-commits
>> >  wrote:
>> >>
>> >> Author: jlebar
>> >> Date: Sat Oct  8 17:16:12 2016
>> >> New Revision: 283680
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=283680=rev
>> >> Log:
>> >> [CUDA] Support  and std::min/max on the device.
>> >>
>> >> Summary:
>> >> We do this by wrapping  and .
>> >>
>> >> Tests are in the test-suite.
>> >>
>> >> Reviewers: tra
>> >>
>> >> Subscribers: jhen, beanz, cfe-commits, mgorny
>> >>
>> >> Differential Revision: https://reviews.llvm.org/D24979
>> >>
>> >> Added:
>> >> cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
>> >> cfe/trunk/lib/Headers/cuda_wrappers/
>> >> cfe/trunk/lib/Headers/cuda_wrappers/algorithm
>> >> cfe/trunk/lib/Headers/cuda_wrappers/complex
>> >> Modified:
>> >> cfe/trunk/lib/Driver/ToolChains.cpp
>> >> cfe/trunk/lib/Headers/CMakeLists.txt
>> >> cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
>> >>
>> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=283680=283679=283680=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
>> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Sat Oct  8 17:16:12 2016
>> >> @@ -4694,6 +4694,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
>> >>
>> >>  void Linux::AddCudaIncludeArgs(const ArgList ,
>> >> ArgStringList ) const {
>> >> +  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
>> >> +// Add cuda_wrappers/* to our system include path.  This lets us
>> >> wrap
>> >> +// standard library headers.
>> >> +SmallString<128> P(getDriver().ResourceDir);
>> >> +llvm::sys::path::append(P, "include");
>> >> +llvm::sys::path::append(P, "cuda_wrappers");
>> >> +addSystemInclude(DriverArgs, CC1Args, P);
>> >> +  }
>> >> +
>> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
>> >>  return;
>> >>
>> >>
>> >> Modified: cfe/trunk/lib/Headers/CMakeLists.txt
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=283680=283679=283680=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Headers/CMakeLists.txt (original)
>> >> +++ cfe/trunk/lib/Headers/CMakeLists.txt Sat Oct  8 17:16:12 2016
>> >> @@ -24,10 +24,13 @@ set(files
>> >>bmiintrin.h
>> >>__clang_cuda_builtin_vars.h
>> >>__clang_cuda_cmath.h
>> >> +  __clang_cuda_complex_builtins.h
>> >>__clang_cuda_intrinsics.h
>> >>__clang_cuda_math_forward_declares.h
>> >>__clang_cuda_runtime_wrapper.h
>> >>cpuid.h
>> >> +  cuda_wrappers/algorithm
>> >> +  cuda_wrappers/complex
>> >>clflushoptintrin.h
>> >>emmintrin.h
>> >>f16cintrin.h
>> >>
>> >> Added: cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h?rev=283680=auto
>> >>
>> >>
>> >> ==
>> >> --- 

[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols

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

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D25436



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


Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-11 Thread Reid Kleckner via cfe-commits
Can we figure out why having an incremental stage1 is problematic? I want
to keep it that way to speed up the bot.

It sounds like the problem is that we do not delete the stage1 install
directory before installing to it, or our install step uses a glob that may
include stale files from previous builds.

On Mon, Oct 10, 2016 at 8:56 AM, Justin Lebar  wrote:

> As discussed over IM, builds are still failing after reverting this.
>
> The issue seems to be that the stage 1 build in bootstrap compiles is
> not a clean build.  Therefore the errant  and 
> headers are never removed from the install directory.
>
> I believe I fixed the cmake in r283683 (sent a few hours after this
> one), but because the stage 1 builds are not clean, they were still
> broken after that change.
>
> Easiest fix at this point would be to find someone with ssh access to
> the buildbots to rm -rf the stage 1 directory.
>
> On Mon, Oct 10, 2016 at 7:19 AM, Nico Weber  wrote:
> > This broke bootstrap builds, I reverted it for now in r283747.
> >
> > On Sat, Oct 8, 2016 at 6:16 PM, Justin Lebar via cfe-commits
> >  wrote:
> >>
> >> Author: jlebar
> >> Date: Sat Oct  8 17:16:12 2016
> >> New Revision: 283680
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=283680=rev
> >> Log:
> >> [CUDA] Support  and std::min/max on the device.
> >>
> >> Summary:
> >> We do this by wrapping  and .
> >>
> >> Tests are in the test-suite.
> >>
> >> Reviewers: tra
> >>
> >> Subscribers: jhen, beanz, cfe-commits, mgorny
> >>
> >> Differential Revision: https://reviews.llvm.org/D24979
> >>
> >> Added:
> >> cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
> >> cfe/trunk/lib/Headers/cuda_wrappers/
> >> cfe/trunk/lib/Headers/cuda_wrappers/algorithm
> >> cfe/trunk/lib/Headers/cuda_wrappers/complex
> >> Modified:
> >> cfe/trunk/lib/Driver/ToolChains.cpp
> >> cfe/trunk/lib/Headers/CMakeLists.txt
> >> cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
> >>
> >> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains.cpp?rev=283680=283679=283680=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> >> +++ cfe/trunk/lib/Driver/ToolChains.cpp Sat Oct  8 17:16:12 2016
> >> @@ -4694,6 +4694,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
> >>
> >>  void Linux::AddCudaIncludeArgs(const ArgList ,
> >> ArgStringList ) const {
> >> +  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
> >> +// Add cuda_wrappers/* to our system include path.  This lets us
> wrap
> >> +// standard library headers.
> >> +SmallString<128> P(getDriver().ResourceDir);
> >> +llvm::sys::path::append(P, "include");
> >> +llvm::sys::path::append(P, "cuda_wrappers");
> >> +addSystemInclude(DriverArgs, CC1Args, P);
> >> +  }
> >> +
> >>if (DriverArgs.hasArg(options::OPT_nocudainc))
> >>  return;
> >>
> >>
> >> Modified: cfe/trunk/lib/Headers/CMakeLists.txt
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> CMakeLists.txt?rev=283680=283679=283680=diff
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Headers/CMakeLists.txt (original)
> >> +++ cfe/trunk/lib/Headers/CMakeLists.txt Sat Oct  8 17:16:12 2016
> >> @@ -24,10 +24,13 @@ set(files
> >>bmiintrin.h
> >>__clang_cuda_builtin_vars.h
> >>__clang_cuda_cmath.h
> >> +  __clang_cuda_complex_builtins.h
> >>__clang_cuda_intrinsics.h
> >>__clang_cuda_math_forward_declares.h
> >>__clang_cuda_runtime_wrapper.h
> >>cpuid.h
> >> +  cuda_wrappers/algorithm
> >> +  cuda_wrappers/complex
> >>clflushoptintrin.h
> >>emmintrin.h
> >>f16cintrin.h
> >>
> >> Added: cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> __clang_cuda_complex_builtins.h?rev=283680=auto
> >>
> >> 
> ==
> >> --- cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h (added)
> >> +++ cfe/trunk/lib/Headers/__clang_cuda_complex_builtins.h Sat Oct  8
> >> 17:16:12 2016
> >> @@ -0,0 +1,203 @@
> >> +/*===-- __clang_cuda_complex_builtins - CUDA impls of runtime complex
> fns
> >> ---===
> >> + *
> >> + * Permission is hereby granted, free of charge, to any person
> obtaining
> >> a copy
> >> + * of this software and associated documentation files (the
> "Software"),
> >> to deal
> >> + * in the Software without restriction, including without limitation
> the
> >> rights
> >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
> >> sell
> >> + * copies of the Software, and to permit persons to whom the Software
> is
> >> + * furnished to do so, subject to the 

r283895 - Fix clang-offload-bundler test.

2016-10-11 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Tue Oct 11 11:06:32 2016
New Revision: 283895

URL: http://llvm.org/viewvc/llvm-project?rev=283895=rev
Log:
Fix clang-offload-bundler test.

A recent change to llvm::cl slightly changed the format of
the help output, and it broke this test.  NFC

Modified:
cfe/trunk/test/Driver/clang-offload-bundler.c

Modified: cfe/trunk/test/Driver/clang-offload-bundler.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-offload-bundler.c?rev=283895=283894=283895=diff
==
--- cfe/trunk/test/Driver/clang-offload-bundler.c (original)
+++ cfe/trunk/test/Driver/clang-offload-bundler.c Tue Oct 11 11:06:32 2016
@@ -31,7 +31,7 @@
 // CK-HELP: {{.*}}referring to the same source file but different targets into 
a single
 // CK-HELP: {{.*}}one. The resulting file can also be unbundled into different 
files by
 // CK-HELP: {{.*}}this tool if -unbundle is provided.
-// CK-HELP: {{.*}}USAGE: clang-offload-bundler [subcommand] [options]
+// CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]
 // CK-HELP: {{.*}}-inputs=  - [,...]
 // CK-HELP: {{.*}}-outputs= - [,...]
 // CK-HELP: {{.*}}-targets= - [-,...]


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


[PATCH] D25335: [OpenCL] Allow partial initializer for array and struct

2016-10-11 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283891: [OpenCL] Allow partial initializer for array and 
struct (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D25335?vs=73818=74266#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25335

Files:
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl


Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -1238,8 +1238,9 @@
   //   subaggregate, brace elision is assumed and the initializer is
   //   considered for the initialization of the first member of
   //   the subaggregate.
-  if (!SemaRef.getLangOpts().OpenCL && 
-  (ElemType->isAggregateType() || ElemType->isVectorType())) {
+  // OpenCL vector initializer is handled elsewhere.
+  if ((!SemaRef.getLangOpts().OpenCL && ElemType->isVectorType()) ||
+  ElemType->isAggregateType()) {
 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
   StructuredIndex);
 ++StructuredIndex;
Index: cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
===
--- cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
+++ cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm %s 
-O0 -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(2) ))  int int2;
+typedef __attribute__(( ext_vector_type(4) ))  int int4;
+
+// CHECK: %struct.StrucTy = type { i32, i32, i32 }
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHECK:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 
x float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 
+float GA[6][6]  = {1.0f, 2.0f};
+
+typedef struct {
+  int x;
+  int y;
+  int z;
+} StrucTy;
+
+// CHECK: @GS = addrspace(1) global %struct.StrucTy { i32 1, i32 2, i32 0 }, 
align 4
+StrucTy GS = {1, 2};
+
+// CHECK: @GV1 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV1 = (int4)((int2)(1,2),3,4);
+
+// CHECK: @GV2 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV2 = (int4)(1);
+
+// CHECK: @f.S = private unnamed_addr constant %struct.StrucTy { i32 1, i32 2, 
i32 0 }, align 4
+
+// CHECK-LABEL: define spir_func void @f()
+void f(void) {
+  // CHECK: %[[A:.*]] = alloca [6 x [6 x float]], align 4
+  // CHECK: %[[S:.*]] = alloca %struct.StrucTy, align 4
+  // CHECK: %[[V1:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral1:.*]] = alloca <2 x i32>, align 8
+  // CHECK: %[[V2:.*]] = alloca <4 x i32>, align 16
+
+  // CHECK: %[[v0:.*]] = bitcast [6 x [6 x float]]* %A to i8*
+  // CHECK: call void @llvm.memset.p0i8.i32(i8* %[[v0]], i8 0, i32 144, i32 4, 
i1 false)
+  // CHECK: %[[v1:.*]] = bitcast i8* %[[v0]] to [6 x [6 x float]]*
+  // CHECK: %[[v2:.*]] = getelementptr [6 x [6 x float]], [6 x [6 x float]]* 
%[[v1]], i32 0, i32 0
+  // CHECK: %[[v3:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 0
+  // CHECK: store float 1.00e+00, float* %[[v3]]
+  // CHECK: %[[v4:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 1
+  // CHECK: store float 2.00e+00, float* %[[v4]]
+  float A[6][6]  = {1.0f, 2.0f};
+
+  // CHECK: %[[v5:.*]] = bitcast %struct.StrucTy* %S to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[v5]], i8* bitcast 
(%struct.StrucTy* @f.S to i8*), i32 12, i32 4, i1 false)
+  StrucTy S = {1, 2};
+
+  // CHECK: store <2 x i32> , <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[v6:.*]] = load <2 x i32>, <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[vext:.*]] = shufflevector <2 x i32> %[[v6]], <2 x i32> undef, 
<4 x i32> 
+  // CHECK: %[[vecinit:.*]] = shufflevector <4 x i32> %[[vext]], <4 x i32> 
undef, <4 x i32> 
+  // CHECK: %[[vecinit2:.*]] = insertelement <4 x i32> %[[vecinit]], i32 3, 
i32 2
+  // CHECK: %[[vecinit3:.*]] = insertelement <4 x i32> %[[vecinit2]], i32 4, 
i32 3
+  // CHECK: store <4 x i32> %[[vecinit3]], <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: %[[v7:.*]] = load <4 x i32>, <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: store <4 x i32> %[[v7]], <4 x i32>* %[[V1]], align 16
+  int4 V1 = (int4)((int2)(1,2),3,4);
+
+  // CHECK: store <4 x i32> , <4 x i32>* %[[V2]], 
align 16
+  int4 V2 = (int4)(1);
+}
+


Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -1238,8 +1238,9 @@
   //   subaggregate, brace elision is 

r283891 - [OpenCL] Allow partial initializer for array and struct

2016-10-11 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Oct 11 10:53:28 2016
New Revision: 283891

URL: http://llvm.org/viewvc/llvm-project?rev=283891=rev
Log:
[OpenCL] Allow partial initializer for array and struct

Currently Clang allows partial initializer for C99 but not for OpenCL, e.g.

float a[16][16] = {1.0f, 2.0f};

is allowed in C99 but not allowed in OpenCL.

This patch fixes that.

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

Added:
cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=283891=283890=283891=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Oct 11 10:53:28 2016
@@ -1238,8 +1238,9 @@ void InitListChecker::CheckSubElementTyp
   //   subaggregate, brace elision is assumed and the initializer is
   //   considered for the initialization of the first member of
   //   the subaggregate.
-  if (!SemaRef.getLangOpts().OpenCL && 
-  (ElemType->isAggregateType() || ElemType->isVectorType())) {
+  // OpenCL vector initializer is handled elsewhere.
+  if ((!SemaRef.getLangOpts().OpenCL && ElemType->isVectorType()) ||
+  ElemType->isAggregateType()) {
 CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList,
   StructuredIndex);
 ++StructuredIndex;

Added: cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl?rev=283891=auto
==
--- cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl Tue Oct 11 10:53:28 2016
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm %s 
-O0 -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(2) ))  int int2;
+typedef __attribute__(( ext_vector_type(4) ))  int int4;
+
+// CHECK: %struct.StrucTy = type { i32, i32, i32 }
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHECK:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 
x float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 
+float GA[6][6]  = {1.0f, 2.0f};
+
+typedef struct {
+  int x;
+  int y;
+  int z;
+} StrucTy;
+
+// CHECK: @GS = addrspace(1) global %struct.StrucTy { i32 1, i32 2, i32 0 }, 
align 4
+StrucTy GS = {1, 2};
+
+// CHECK: @GV1 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV1 = (int4)((int2)(1,2),3,4);
+
+// CHECK: @GV2 = addrspace(1) global <4 x i32> , 
align 16
+int4 GV2 = (int4)(1);
+
+// CHECK: @f.S = private unnamed_addr constant %struct.StrucTy { i32 1, i32 2, 
i32 0 }, align 4
+
+// CHECK-LABEL: define spir_func void @f()
+void f(void) {
+  // CHECK: %[[A:.*]] = alloca [6 x [6 x float]], align 4
+  // CHECK: %[[S:.*]] = alloca %struct.StrucTy, align 4
+  // CHECK: %[[V1:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral:.*]] = alloca <4 x i32>, align 16
+  // CHECK: %[[compoundliteral1:.*]] = alloca <2 x i32>, align 8
+  // CHECK: %[[V2:.*]] = alloca <4 x i32>, align 16
+
+  // CHECK: %[[v0:.*]] = bitcast [6 x [6 x float]]* %A to i8*
+  // CHECK: call void @llvm.memset.p0i8.i32(i8* %[[v0]], i8 0, i32 144, i32 4, 
i1 false)
+  // CHECK: %[[v1:.*]] = bitcast i8* %[[v0]] to [6 x [6 x float]]*
+  // CHECK: %[[v2:.*]] = getelementptr [6 x [6 x float]], [6 x [6 x float]]* 
%[[v1]], i32 0, i32 0
+  // CHECK: %[[v3:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 0
+  // CHECK: store float 1.00e+00, float* %[[v3]]
+  // CHECK: %[[v4:.*]] = getelementptr [6 x float], [6 x float]* %[[v2]], i32 
0, i32 1
+  // CHECK: store float 2.00e+00, float* %[[v4]]
+  float A[6][6]  = {1.0f, 2.0f};
+
+  // CHECK: %[[v5:.*]] = bitcast %struct.StrucTy* %S to i8*
+  // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[v5]], i8* bitcast 
(%struct.StrucTy* @f.S to i8*), i32 12, i32 4, i1 false)
+  StrucTy S = {1, 2};
+
+  // CHECK: store <2 x i32> , <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[v6:.*]] = load <2 x i32>, <2 x i32>* %[[compoundliteral1]], 
align 8
+  // CHECK: %[[vext:.*]] = shufflevector <2 x i32> %[[v6]], <2 x i32> undef, 
<4 x i32> 
+  // CHECK: %[[vecinit:.*]] = shufflevector <4 x i32> %[[vext]], <4 x i32> 
undef, <4 x i32> 
+  // CHECK: %[[vecinit2:.*]] = insertelement <4 x i32> %[[vecinit]], i32 3, 
i32 2
+  // CHECK: %[[vecinit3:.*]] = insertelement <4 x i32> %[[vecinit2]], i32 4, 
i32 3
+  // CHECK: store <4 x i32> %[[vecinit3]], <4 x i32>* %[[compoundliteral]], 
align 16
+  // CHECK: %[[v7:.*]] = load <4 x i32>, <4 x i32>* 

r283890 - Revert r283887 and r283882, until the issue is understood and fixed.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:51:06 2016
New Revision: 283890

URL: http://llvm.org/viewvc/llvm-project?rev=283890=rev
Log:
Revert r283887 and r283882, until the issue is understood and fixed.

Removed:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283890=283889=283890=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 10:51:06 2016
@@ -865,11 +865,6 @@ protected:
 
 unsigned : NumVarDeclBits;
 
-// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
-/// \brief Whether this variable is a definition which was demoted due to
-/// module merge.
-unsigned IsThisDeclarationADemotedDefinition : 1;
-
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1203,27 +1198,12 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
+
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
-  /// \brief If this definition should pretend to be a declaration.
-  bool isThisDeclarationADemotedDefinition() const {
-return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
-  }
-
-  /// \brief This is a definition which should be demoted to a declaration.
-  ///
-  /// In some cases (mostly module merging) we can end up with two visible
-  /// definitions one of which needs to be demoted to a declaration to keep
-  /// the AST invariants.
-  void demoteThisDefinitionToDeclaration() {
-assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
-assert (isThisDeclarationADefinition() && "Not a definition!");
-NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
-  }
-
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1322,10 +1302,6 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
-  /// \brief Retrieve the variable declaration from which this variable could
-  /// be instantiated, if it is an instantiation (rather than a non-template).
-  VarDecl *getTemplateInstantiationPattern() const;
-
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283890=283889=283890=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 10:51:06 2016
@@ -1926,9 +1926,6 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
-  if (isThisDeclarationADemotedDefinition())
-return DeclarationOnly;
-
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2253,56 +2250,6 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
-VarDecl *VarDecl::getTemplateInstantiationPattern() const {
-  // If it's a variable template specialization, find the template or partial
-  // specialization from which it was instantiated.
-  if (auto *VDTemplSpec = dyn_cast(this)) {
-auto From = VDTemplSpec->getInstantiatedFrom();
-if (auto *VTD = From.dyn_cast()) {
-  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
-if (NewVTD->isMemberSpecialization())
-  break;
-VTD = NewVTD;
-  }
-  return VTD->getTemplatedDecl()->getDefinition();
-}
-if (auto *VTPSD =
-From.dyn_cast()) {
-  while (auto *NewVTPSD = VTPSD->getInstantiatedFromMember()) {
-if (NewVTPSD->isMemberSpecialization())
-  break;
-VTPSD = NewVTPSD;
-  }
-  return VTPSD->getDefinition();
-}
-  }
-
-  if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) {
-if (isTemplateInstantiation(MSInfo->getTemplateSpecializationKind())) {
-  VarDecl *VD = getInstantiatedFromStaticDataMember();
-  

[PATCH] D25479: Guard flag –fdenormal-fp-math with –fno-fast-math

2016-10-11 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: rengolin, jmolloy.
SjoerdMeijer added a subscriber: cfe-commits.

Guard the -fdenormal-fp-math with -fno-fast-math. This allows disabling the FP 
options with just one flag: –fno-fast-math.


https://reviews.llvm.org/D25479

Files:
  lib/Driver/Tools.cpp
  test/Driver/denormal-fp-math.c


Index: test/Driver/denormal-fp-math.c
===
--- test/Driver/denormal-fp-math.c
+++ test/Driver/denormal-fp-math.c
@@ -1,9 +1,11 @@
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s 
-fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck 
-check-prefix=CHECK-NO-UNSAFE %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo 
-v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
 
 // CHECK-IEEE: "-fdenormal-fp-math=ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
 // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4390,11 +4390,16 @@
   if (ReciprocalMath)
 CmdArgs.push_back("-freciprocal-math");
 
-  if (!TrappingMath) 
+  if (!TrappingMath)
 CmdArgs.push_back("-fno-trapping-math");
 
-  if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ))
-Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
+
+  if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
+   options::OPT_fno_fast_math,
+   options::OPT_fdenormal_fp_math_EQ))
+if (A->getOption().getID() != options::OPT_fno_fast_math &&
+A->getOption().getID() != options::OPT_fno_unsafe_math_optimizations)
+  Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
 
   // Validate and pass through -fp-contract option.
   if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,


Index: test/Driver/denormal-fp-math.c
===
--- test/Driver/denormal-fp-math.c
+++ test/Driver/denormal-fp-math.c
@@ -1,9 +1,11 @@
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s
 // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s
+// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck -check-prefix=CHECK-NO-UNSAFE %s
 // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
 
 // CHECK-IEEE: "-fdenormal-fp-math=ieee"
 // CHECK-PS: "-fdenormal-fp-math=preserve-sign"
 // CHECK-PZ: "-fdenormal-fp-math=positive-zero"
+// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee"
 // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4390,11 +4390,16 @@
   if (ReciprocalMath)
 CmdArgs.push_back("-freciprocal-math");
 
-  if (!TrappingMath) 
+  if (!TrappingMath)
 CmdArgs.push_back("-fno-trapping-math");
 
-  if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ))
-Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
+
+  if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
+   options::OPT_fno_fast_math,
+   options::OPT_fdenormal_fp_math_EQ))
+if (A->getOption().getID() != options::OPT_fno_fast_math &&
+A->getOption().getID() != options::OPT_fno_unsafe_math_optimizations)
+  Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ);
 
   // Validate and pass through -fp-contract option.
   if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-11 Thread Steve O'Brien via cfe-commits
elsteveogrande updated this revision to Diff 74265.
elsteveogrande added a comment.

Thanks very much @vsk for the feedback!  Updated per your recommendations; 
`CHECK` looks much better


https://reviews.llvm.org/D25153

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/PreprocessorOutputOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Preprocessor/dump_import.h
  test/Preprocessor/dump_import.m
  test/Preprocessor/dump_include.c
  test/Preprocessor/dump_include.h

Index: test/Preprocessor/dump_include.h
===
--- /dev/null
+++ test/Preprocessor/dump_include.h
@@ -0,0 +1,2 @@
+#pragma once
+#define DUMP_INCLUDE_TESTVAL 1
Index: test/Preprocessor/dump_include.c
===
--- /dev/null
+++ test/Preprocessor/dump_include.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -w -E -dI -isystem %S -imacros %S/dump_include.h %s -o - | FileCheck %s
+// CHECK: {{^}}#__include_macros "/{{([^/]+/)+}}dump_
+// CHECK: {{^}}#include 
+#include "dump_include.h"
+#include_next "dump_include.h"
Index: test/Preprocessor/dump_import.m
===
--- /dev/null
+++ test/Preprocessor/dump_import.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E -dI %s -o - | FileCheck %s
+// CHECK: {{^}}#import "dump_
+
+// See also `dump_include.c` which tests other inclusion cases with `-dI`.
+
+#import "dump_import.h"
Index: test/Preprocessor/dump_import.h
===
--- /dev/null
+++ test/Preprocessor/dump_import.h
@@ -0,0 +1 @@
+#define DUMP_IMPORT_TESTVAL 1
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -93,13 +93,16 @@
   bool Initialized;
   bool DisableLineMarkers;
   bool DumpDefines;
+  bool DumpIncludeDirectives;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
 public:
   PrintPPOutputPPCallbacks(Preprocessor , raw_ostream , bool lineMarkers,
-   bool defines, bool UseLineDirectives)
+   bool defines, bool DumpIncludeDirectives,
+   bool UseLineDirectives)
   : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
 DisableLineMarkers(lineMarkers), DumpDefines(defines),
+DumpIncludeDirectives(DumpIncludeDirectives),
 UseLineDirectives(UseLineDirectives) {
 CurLine = 0;
 CurFilename += "";
@@ -320,20 +323,20 @@
   StringRef SearchPath,
   StringRef RelativePath,
   const Module *Imported) {
-  // When preprocessing, turn implicit imports into @imports.
-  // FIXME: This is a stop-gap until a more comprehensive "preprocessing with
-  // modules" solution is introduced.
   if (Imported) {
+// When preprocessing, turn implicit imports into @imports.
+// FIXME: This is a stop-gap until a more comprehensive "preprocessing with
+// modules" solution is introduced.
 startNewLineIfNeeded();
 MoveToLine(HashLoc);
 if (PP.getLangOpts().ObjC2) {
   OS << "@import " << Imported->getFullModuleName() << ";"
  << " /* clang -E: implicit import for \"" << File->getName()
  << "\" */";
 } else {
-  // FIXME: Preseve whether this was a
-  // #include/#include_next/#include_macros/#import.
-  OS << "#include "
+  const std::string TokenText = PP.getSpelling(IncludeTok);
+  assert(!TokenText.empty());
+  OS << "#" << TokenText << " "
  << (IsAngled ? '<' : '"')
  << FileName
  << (IsAngled ? '>' : '"')
@@ -344,6 +347,18 @@
 // line immediately.
 EmittedTokensOnThisLine = true;
 startNewLineIfNeeded();
+  } else {
+// Not a module import; it's a more vanilla inclusion of some file using one
+// of: #include, #import, #include_next, #include_macros.
+if (DumpIncludeDirectives) {
+  const std::string TokenText = PP.getSpelling(IncludeTok);
+  assert(!TokenText.empty());
+  OS << "#" << TokenText << " "
+ << (IsAngled ? '<' : '"') << FileName << (IsAngled ? '>' : '"')
+ << " /* clang -E -dI */";
+  setEmittedDirectiveOnThisLine();
+  startNewLineIfNeeded();
+}
   }
 }
 
@@ -751,7 +766,8 @@
   PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments);
 
   PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks(
-  PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros, Opts.UseLineDirectives);
+  PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros,
+  Opts.ShowIncludeDirectives, Opts.UseLineDirectives);
 
   // Expand macros in pragmas with -fms-extensions.  The assumption is that
   // 

[PATCH] D25343: [OpenCL] Mark group functions as noduplicate in opencl-c.h

2016-10-11 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.

In https://reviews.llvm.org/D25343#565288, @Anastasia wrote:

> Do you have any code example where Clang/LLVM performs wrong optimizations 
> with respect to the control flow of SPMD execution?
>
> My understanding from the earlier discussion we have had: 
> https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that 
> noduplicate is essentially enough for the frontend to prevent erroneous 
> optimizations. Because in general compiler can't do much with unknown 
> function calls.


noduplicate is enough for correctness, but it prevents legal optimizations, 
like unrolling loops with barriers.  The convergent attribute was added 
specifically for these kinds of builtins, so we should be using it here instead 
of noduplicate.

> For LLVM intrinsics it is slightly different as I can deduce from this 
> discussion:http://lists.llvm.org/pipermail/llvm-dev/2015-May/085558.html . It 
> seems like by default it's assumed to be side effect free and can be 
> optimized in various ways.




https://reviews.llvm.org/D25343



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


[PATCH] D25335: [OpenCL] Allow partial initializer for array and struct

2016-10-11 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.



Comment at: test/CodeGenOpenCL/partial_initializer.cl:5
+
+// CHECK: @GA = addrspace(1) global [6 x [6 x float]] {{[[][[]}}6 x float] 
[float 1.00e+00, float 2.00e+00, float 0.00e+00, float 
0.00e+00, float 0.00e+00, float 0.00e+00],
+// CHEC:[6 x float] zeroinitializer, [6 x float] zeroinitializer, [6 x 
float] zeroinitializer, [6 x float] zeroinitializer, [6 x float] 
zeroinitializer], align 4 

Anastasia wrote:
> These could be moved down to each member.
Will do when committing. Thanks.


https://reviews.llvm.org/D25335



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


Re: r283827 - [Driver][Diagnostics] Make 'show option names' default for driver warnings

2016-10-11 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Renato!

On Tue, Oct 11, 2016 at 3:36 AM, Renato Golin  wrote:
> On 11 October 2016 at 10:14, Renato Golin  wrote:
>> clang-4.0: warning: no such sysroot directory: '/FOO' [-Wmissing-sysroot]
>> error: unable to create target: 'No available targets are compatible
>> with this triple.'
>> 1 error generated.
>
> Reverted in r283868, as it was also breaking ARM bots.
>
> cheers,
> --renato



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283888 - Use StringRef instead of raw pointer in SourceManagerInternals LineTableInfo API (NFC)

2016-10-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Tue Oct 11 10:15:32 2016
New Revision: 283888

URL: http://llvm.org/viewvc/llvm-project?rev=283888=rev
Log:
Use StringRef instead of raw pointer in SourceManagerInternals LineTableInfo 
API (NFC)

Modified:
cfe/trunk/include/clang/Basic/SourceManagerInternals.h

Modified: cfe/trunk/include/clang/Basic/SourceManagerInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManagerInternals.h?rev=283888=283887=283888=diff
==
--- cfe/trunk/include/clang/Basic/SourceManagerInternals.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManagerInternals.h Tue Oct 11 10:15:32 
2016
@@ -95,9 +95,9 @@ public:
   }
 
   unsigned getLineTableFilenameID(StringRef Str);
-  const char *getFilename(unsigned ID) const {
+  StringRef getFilename(unsigned ID) const {
 assert(ID < FilenamesByID.size() && "Invalid FilenameID");
-return FilenamesByID[ID]->getKeyData();
+return FilenamesByID[ID]->getKey();
   }
   unsigned getNumFilenames() const { return FilenamesByID.size(); }
 


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


r283887 - r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 10:09:26 2016
New Revision: 283887

URL: http://llvm.org/viewvc/llvm-project?rev=283887=rev
Log:
r283882 followup. Don't demote ParmVarDecls. This should fix our module builds.

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

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=283887=283886=283887=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 11 10:09:26 2016
@@ -9709,20 +9709,22 @@ void Sema::AddInitializerToDecl(Decl *Re
   // The previous definition is hidden, and multiple definitions are
   // permitted (in separate TUs). Form another definition of it.
 
-  // Demote the newly parsed definition to a fake declaration.
-  if (!VDecl->isThisDeclarationADemotedDefinition())
-VDecl->demoteThisDefinitionToDeclaration();
+  if (!isa(VDecl)) {
+// Demote the newly parsed definition to a fake declaration.
+if (!VDecl->isThisDeclarationADemotedDefinition())
+  VDecl->demoteThisDefinitionToDeclaration();
 
-  // Make the definition visible from the point of the demotion on.
-  assert (!Hidden || Def == Hidden &&
-  "We were suggested another hidden definition!");
-  makeMergedDefinitionVisible(Def, VDecl->getLocation());
+// Make the definition visible from the point of the demotion on.
+assert (!Hidden || Def == Hidden &&
+"We were suggested another hidden definition!");
+makeMergedDefinitionVisible(Def, VDecl->getLocation());
 
-  // If this is a variable template definition, make its enclosing template
-  // visible.
-  if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
-if (VarPattern->isThisDeclarationADefinition())
-  makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+// If this is a variable template definition, make its enclosing 
template
+// visible.
+if (VarDecl *VarPattern = Def->getTemplateInstantiationPattern())
+  if (VarPattern->isThisDeclarationADefinition())
+makeMergedDefinitionVisible(VarPattern, VDecl->getLocation());
+  }
 } else {
   Diag(VDecl->getLocation(), diag::err_redefinition)
 << VDecl->getDeclName();


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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-11 Thread Kirill Romanenkov via cfe-commits
kromanenkov created this revision.
kromanenkov added reviewers: zaks.anna, NoQ, dcoughlin.
kromanenkov added subscribers: a.sidorin, cfe-commits.

Add a new type of NonLoc SVal for pointer-to-member operations. This SVal 
supports both pointers to member functions and pointers to member data.


https://reviews.llvm.org/D25475

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/pointer-to-member.cpp

Index: test/Analysis/pointer-to-member.cpp
===
--- test/Analysis/pointer-to-member.cpp
+++ test/Analysis/pointer-to-member.cpp
@@ -35,8 +35,7 @@
   clang_analyzer_eval(::getPtr == ::getPtr); // expected-warning{{TRUE}}
   clang_analyzer_eval(::getPtr == 0); // expected-warning{{FALSE}}
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(::m_ptr == ::m_ptr); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(::m_ptr == ::m_ptr); // expected-warning{{TRUE}}
 }
 
 namespace PR15742 {
@@ -72,11 +71,65 @@
 
   A::MemberPointer member = ::m_ptr;
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(obj.*member == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(obj.*member == 0); // expected-warning{{TRUE}}
 
   member = 0;
 
   // FIXME: Should emit a null dereference.
   return obj.*member; // no-warning
 }
+
+namespace testPointerToMemberFunction {
+  struct A {
+virtual int foo() { return 1; }
+int bar() { return 2;  }
+  };
+
+  struct B : public A {
+virtual int foo() { return 3; }
+  };
+
+  typedef int (A::*AFnPointer)();
+  typedef int (B::*BFnPointer)();
+
+  void testPointerToMemberCasts() {
+AFnPointer AFP = ::bar;
+BFnPointer StaticCastedBase2Derived = static_cast(::bar),
+   CCastedBase2Derived = (BFnPointer) (::bar);
+A a;
+B b;
+
+clang_analyzer_eval((a.*AFP)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval((b.*StaticCastedBase2Derived)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval(((b.*CCastedBase2Derived)() == 2)); // expected-warning{{TRUE}}
+  }
+
+  void testPointerToMemberVirtualCall() {
+A a;
+B b;
+A *APtr = 
+AFnPointer AFP = ::foo;
+
+clang_analyzer_eval((APtr->*AFP)() == 1); // expected-warning{{TRUE}}
+
+APtr = 
+
+clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberFunction namespace
+
+namespace testPointerToMemberData {
+  struct A {
+int i;
+  };
+
+  void testPointerToMemberData() {
+int A::*AMdPointer = ::i;
+A a;
+
+a.i = 42;
+a.*AMdPointer += 1;
+
+clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberData namespace
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -69,6 +69,9 @@
 
   bool isLocType = Loc::isLocType(castTy);
 
+  if (val.getAs())
+return val;
+
   if (Optional LI = val.getAs()) {
 if (isLocType)
   return LI->getLoc();
@@ -335,6 +338,21 @@
 switch (lhs.getSubKind()) {
 default:
   return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+case nonloc::PointerToMemberKind: {
+  assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
+ "Both SVals should have pointer-to-member-type");
+  const DeclaratorDecl *LDD =
+  lhs.castAs().getDecl(),
+  *RDD = rhs.castAs().getDecl();
+  switch (op) {
+case BO_EQ:
+  return makeTruthVal(LDD == RDD, resultTy);
+case BO_NE:
+  return makeTruthVal(LDD != RDD, resultTy);
+default:
+  return UnknownVal();
+  }
+}
 case nonloc::LocAsIntegerKind: {
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
@@ -857,6 +875,14 @@
 SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
   BinaryOperator::Opcode op,
   Loc lhs, NonLoc rhs, QualType resultTy) {
+  if (op >= BO_PtrMemD && op <= BO_PtrMemI) {
+if (auto PTMSV = rhs.getAs())
+  if (const FieldDecl *FD = PTMSV->getDeclAs())
+return state->getLValue(FD, lhs);
+
+return rhs;
+  }
+
   assert(!BinaryOperator::isComparisonOp(op) &&
  "arguments to comparison ops must be of the same type");
 
Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- 

[clang-tools-extra] r283886 - [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init

2016-10-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Oct 11 09:49:24 2016
New Revision: 283886

URL: http://llvm.org/viewvc/llvm-project?rev=283886=rev
Log:
[clang-tidy] Ignore empty members and bases in 
cppcoreguidelines-pro-type-member-init

Summary: Empty/incomplete variables/members/bases don't need to be initialized

Reviewers: mgehre, aaron.ballman, alexfh

Subscribers: nemanjai, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=283886=283885=283886=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue Oct 11 09:49:24 2016
@@ -317,6 +317,28 @@ void ProTypeMemberInitCheck::storeOption
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
+static bool isIncompleteOrZeroLengthArrayType(ASTContext , QualType T) 
{
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext , const QualType ) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext , const CXXRecordDecl ,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@ void ProTypeMemberInitCheck::checkMissin
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=283886=283885=283886=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Tue Oct 11 09:49:24 2016
@@ -423,3 +423,30 @@ UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUA
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: G
+
+struct NegativeEmpty {
+};
+
+static void NegativeEmptyVar() {
+  NegativeEmpty e;
+  (void)e;
+}
+
+struct NegativeEmptyMember {
+  NegativeEmptyMember() {}
+  NegativeEmpty e;
+};
+
+struct NegativeEmptyBase : NegativeEmpty {
+  NegativeEmptyBase() {}
+};
+
+struct NegativeEmptyArrayMember {
+  NegativeEmptyArrayMember() {}
+  char e[0];
+};
+
+struct NegativeIncompleteArrayMember {
+  NegativeIncompleteArrayMember() {}
+  char e[];
+};


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


[PATCH] D25238: [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init

2016-10-11 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283886: [clang-tidy] Ignore empty members and bases in 
cppcoreguidelines-pro-type… (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25238?vs=74125=74256#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25238

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -317,6 +317,28 @@
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
+static bool isIncompleteOrZeroLengthArrayType(ASTContext , QualType T) 
{
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext , const QualType ) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext , const CXXRecordDecl ,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -423,3 +423,30 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: G
+
+struct NegativeEmpty {
+};
+
+static void NegativeEmptyVar() {
+  NegativeEmpty e;
+  (void)e;
+}
+
+struct NegativeEmptyMember {
+  NegativeEmptyMember() {}
+  NegativeEmpty e;
+};
+
+struct NegativeEmptyBase : NegativeEmpty {
+  NegativeEmptyBase() {}
+};
+
+struct NegativeEmptyArrayMember {
+  NegativeEmptyArrayMember() {}
+  char e[0];
+};
+
+struct NegativeIncompleteArrayMember {
+  NegativeIncompleteArrayMember() {}
+  char e[];
+};


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -317,6 +317,28 @@
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
+static bool isIncompleteOrZeroLengthArrayType(ASTContext , QualType T) {
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext , const QualType ) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext , const CXXRecordDecl ,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 

[PATCH] D25437: [clang-tidy] Fix template agrument false positives in unused-using-decls.

2016-10-11 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283879: [clang-tidy] Fix template agrument false positives 
in unused-using-decls. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25437?vs=74239=74254#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25437

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult ) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,16 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 @@
   int t3 = 0;
   a.func1();
   a.func2(t3);
+
+  n::L l;
 }
+
+template
+void h(n::M* t) {}
+// n::N is used the explicit template instantiation.
+template void h(n::M* t);
+
+// Test on Non-type template arguments.
+template 
+void i(n::P* t) {}
+template void i(n::P* t);


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -42,6 +42,8 @@
   anyOf(refersToTemplate(templateName().bind("used")),
 refersToDeclaration(functionDecl().bind("used"))),
   this);
+  Finder->addMatcher(loc(templateSpecializationType(
+  hasAnyTemplateArgument(templateArgument().bind("used", this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult ) {
@@ -91,6 +93,18 @@
 return;
   }
 
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+// FIXME: Support non-type template parameters.
+if (Used->getKind() == TemplateArgument::Template) {
+  if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
+removeFromFoundDecls(TD);
+} else if (Used->getKind() == TemplateArgument::Type) {
+  if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+removeFromFoundDecls(RD);
+}
+return;
+  }
+
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
 removeFromFoundDecls(Used->getAsTemplateDecl());
 return;
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -21,6 +21,16 @@
 class G;
 class H;
 
+template  class K {};
+template  class S>
+class L {};
+
+template  class M {};
+class N {};
+
+template  class P {};
+const int Constant = 0;
+
 class Base {
  public:
   void f();
@@ -150,6 +160,14 @@
 using ns::AA;
 using ns::ff;
 
+using n::K;
+
+using n::N;
+
+// FIXME: Currently non-type template arguments are not supported.
+using n::Constant;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+
 // - Usages -
 void f(B b);
 void g() {
@@ -170,4 +188,16 @@
   int 

[PATCH] D25474: [ARM] Fix - missing target-cpu in test

2016-10-11 Thread Javed Absar via cfe-commits
javed.absar created this revision.
javed.absar added reviewers: jmolloy, rengolin.
javed.absar added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

This patch fixes an incomplete test, wherein the target-cpu name (cortex-r52) 
was missing.


https://reviews.llvm.org/D25474

Files:
  test/Driver/arm-cortex-cpus.c


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -165,7 +165,7 @@
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
 // RUN: %clang -target arm -march=armv8r -mthumb -mbig-endian -### -c %s 2>&1 
| \
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
-// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} "-target-cpu
+// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} 
"-target-cpu" "cortex-r52"
 
 // RUN: %clang -mcpu=generic -target armv8 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8A-GENERIC %s
 // RUN: %clang -mcpu=generic -target arm -march=armv8 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V8A-GENERIC %s


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -165,7 +165,7 @@
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
 // RUN: %clang -target arm -march=armv8r -mthumb -mbig-endian -### -c %s 2>&1 | \
 // RUN: FileCheck -check-prefix=CHECK-V8R-THUMB-BIG %s
-// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} "-target-cpu
+// CHECK-V8R-THUMB-BIG: "-cc1"{{.*}} "-triple" "thumbebv8r-{{.*}} "-target-cpu" "cortex-r52"
 
 // RUN: %clang -mcpu=generic -target armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
 // RUN: %clang -mcpu=generic -target arm -march=armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A-GENERIC %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24508: PR28752: Do not instantiate var decls which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Landed in r283882.




Comment at: include/clang/AST/Decl.h:1222
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");

rsmith wrote:
> You can remove this; it's covered by the next line.
Ok. This would allow calling the method on already demoted definition. Do we 
want to allow that?



Comment at: lib/AST/Decl.cpp:2284
+  while (auto *NewVD = VD->getInstantiatedFromStaticDataMember())
+VD = NewVD;
+  return VD->getDefinition();

rsmith wrote:
> Missing a member specialization check here.
Isn't that covered by the cases above? It seems there is no API to make such 
check, here. The current state looks to me consistent with 
`CXXRecordDecl::getTemplateInstantiationPattern` and 
`FunctionDecl::getTemplateInstantiationPattern`.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3086-3090
+  if (CurD->isThisDeclarationADemotedDefinition()) {
+VD->demoteThisDefinitionToDeclaration();
+break;
+  }
+  if (CurD->isThisDeclarationADefinition()) {

rsmith wrote:
> Maybe combine these two `if`s into one, since their bodies are identical?
Good point ;)


https://reviews.llvm.org/D24508



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


r283882 - [modules] PR28752: Do not instantiate variable declarations which are not visible.

2016-10-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Oct 11 08:57:36 2016
New Revision: 283882

URL: http://llvm.org/viewvc/llvm-project?rev=283882=rev
Log:
[modules] PR28752: Do not instantiate variable declarations which are not 
visible.

https://reviews.llvm.org/D24508

Patch developed in collaboration with Richard Smith!

Added:
cfe/trunk/test/Modules/Inputs/PR28752/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/b.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/c.h
cfe/trunk/test/Modules/Inputs/PR28752/Subdir1/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/a.h
cfe/trunk/test/Modules/Inputs/PR28752/module.modulemap
cfe/trunk/test/Modules/Inputs/PR28752/vector
cfe/trunk/test/Modules/pr28752.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=283882=283881=283882=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 11 08:57:36 2016
@@ -865,6 +865,11 @@ protected:
 
 unsigned : NumVarDeclBits;
 
+// FIXME: We need something similar to CXXRecordDecl::DefinitionData.
+/// \brief Whether this variable is a definition which was demoted due to
+/// module merge.
+unsigned IsThisDeclarationADemotedDefinition : 1;
+
 /// \brief Whether this variable is the exception variable in a C++ catch
 /// or an Objective-C @catch statement.
 unsigned ExceptionVar : 1;
@@ -1198,12 +1203,27 @@ public:
   InitializationStyle getInitStyle() const {
 return static_cast(VarDeclBits.InitStyle);
   }
-
   /// \brief Whether the initializer is a direct-initializer (list or call).
   bool isDirectInit() const {
 return getInitStyle() != CInit;
   }
 
+  /// \brief If this definition should pretend to be a declaration.
+  bool isThisDeclarationADemotedDefinition() const {
+return NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
+  }
+
+  /// \brief This is a definition which should be demoted to a declaration.
+  ///
+  /// In some cases (mostly module merging) we can end up with two visible
+  /// definitions one of which needs to be demoted to a declaration to keep
+  /// the AST invariants.
+  void demoteThisDefinitionToDeclaration() {
+assert (!isThisDeclarationADemotedDefinition() && "Aleady demoted!");
+assert (isThisDeclarationADefinition() && "Not a definition!");
+NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
+  }
+
   /// \brief Determine whether this variable is the exception variable in a
   /// C++ catch statememt or an Objective-C \@catch statement.
   bool isExceptionVariable() const {
@@ -1302,6 +1322,10 @@ public:
 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
   }
 
+  /// \brief Retrieve the variable declaration from which this variable could
+  /// be instantiated, if it is an instantiation (rather than a non-template).
+  VarDecl *getTemplateInstantiationPattern() const;
+
   /// \brief If this variable is an instantiated static data member of a
   /// class template specialization, returns the templated static data member
   /// from which it was instantiated.

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=283882=283881=283882=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 11 08:57:36 2016
@@ -1926,6 +1926,9 @@ VarDecl::isThisDeclarationADefinition(AS
   //
   // FIXME: How do you declare (but not define) a partial specialization of
   // a static data member template outside the containing class?
+  if (isThisDeclarationADemotedDefinition())
+return DeclarationOnly;
+
   if (isStaticDataMember()) {
 if (isOutOfLine() &&
 !(getCanonicalDecl()->isInline() &&
@@ -2250,6 +2253,56 @@ bool VarDecl::checkInitIsICE() const {
   return Eval->IsICE;
 }
 
+VarDecl *VarDecl::getTemplateInstantiationPattern() const {
+  // If it's a variable template specialization, find the template or partial
+  // specialization from which it was instantiated.
+  if (auto *VDTemplSpec = dyn_cast(this)) {
+auto From = VDTemplSpec->getInstantiatedFrom();
+if (auto *VTD = From.dyn_cast()) {
+  while (auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
+if (NewVTD->isMemberSpecialization())
+  break;
+VTD = NewVTD;
+  }
+  return VTD->getTemplatedDecl()->getDefinition();
+}
+if (auto *VTPSD 

  1   2   >