Re: r280104 - Disable clang/test/SemaTemplate/instantiation-depth-default.cpp temporarily for targeting mingw32. It crashes. Investigating.

2016-08-30 Thread Richard Smith via cfe-commits
On 30 Aug 2016 4:05 pm, "NAKAMURA Takumi"  wrote:

Thanks, Richard.

Conversely, do we need to give sufficient amount of stack to the clang
executable whenever this fails?

By default, clang.exe has 2MiB (and *-tblgen.exe(s) are gaven 16MiB) of
stack on mingw-w64. 10,000,000 bytes on MS-compiled executables. I can
easily increase the size.


Clang expects 8MB (we reserve this much from cc1_main when we know how, and
create per-thread stacks of this size when building modules or when
libclang does background parsing). Making this consistent across build
environments seems like a good idea.

See HandleLLVMOptions.cmake and TableGen.cmake.

On Wed, Aug 31, 2016 at 4:12 AM Richard Smith  wrote:

> On Tue, Aug 30, 2016 at 8:38 AM, NAKAMURA Takumi via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: chapuni
>> Date: Tue Aug 30 10:38:18 2016
>> New Revision: 280104
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=280104&view=rev
>> Log:
>> Disable clang/test/SemaTemplate/instantiation-depth-default.cpp
>> temporarily for targeting mingw32. It crashes. Investigating.
>>
>
> This is probably due to stack overflow. Is there a way we can raise the
> stack limit for mingw32?
>
>
>> Modified:
>> cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
>>
>> Modified: cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
>> SemaTemplate/instantiation-depth-default.cpp?rev=280104&
>> r1=280103&r2=280104&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
>> (original)
>> +++ cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp Tue Aug
>> 30 10:38:18 2016
>> @@ -12,3 +12,6 @@ template struct X : X
>>  // expected-note@8 {{use -ftemplate-depth=N to increase recursive
>> template instantiation depth}}
>>
>>  X<0, int> x; // expected-note {{in instantiation of}}
>> +
>> +// FIXME: It crashes. Investigating.
>> +// UNSUPPORTED: mingw32
>>
>>
>> ___
>> 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


r280197 - [AVX-512] Implement masked floating point logical operations with native IR and remove the builtins.

2016-08-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug 31 00:38:58 2016
New Revision: 280197

URL: http://llvm.org/viewvc/llvm-project?rev=280197&view=rev
Log:
[AVX-512] Implement masked floating point logical operations with native IR and 
remove the builtins.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=280197&r1=280196&r2=280197&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Aug 31 00:38:58 2016
@@ -1131,32 +1131,8 @@ TARGET_BUILTIN(__builtin_ia32_psubd512_m
 
 TARGET_BUILTIN(__builtin_ia32_pmulld512_mask, "V16iV16iV16iV16iUs", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_pmullq512_mask, "V8LLiV8LLiV8LLiV8LLiUc", "", 
"avx512dq")
-TARGET_BUILTIN(__builtin_ia32_xorpd512_mask, "V8dV8dV8dV8dUc", "", "avx512dq")
-TARGET_BUILTIN(__builtin_ia32_xorps512_mask, "V16fV16fV16fV16fUs", "", 
"avx512dq")
-TARGET_BUILTIN(__builtin_ia32_orpd512_mask, "V8dV8dV8dV8dUc", "", "avx512dq")
-TARGET_BUILTIN(__builtin_ia32_orps512_mask, "V16fV16fV16fV16fUs", "", 
"avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andpd512_mask, "V8dV8dV8dV8dUc", "", "avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andps512_mask, "V16fV16fV16fV16fUs", "", 
"avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andnpd512_mask, "V8dV8dV8dV8dUc", "", "avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andnps512_mask, "V16fV16fV16fV16fUs", "", 
"avx512dq")
 TARGET_BUILTIN(__builtin_ia32_pmullq256_mask, "V4LLiV4LLiV4LLiV4LLiUc", "", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_pmullq128_mask, "V2LLiV2LLiV2LLiV2LLiUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andnpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andnpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andnps256_mask, "V8fV8fV8fV8fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andnps128_mask, "V4fV4fV4fV4fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andps256_mask, "V8fV8fV8fV8fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_andps128_mask, "V4fV4fV4fV4fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_xorpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_xorpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_xorps256_mask, "V8fV8fV8fV8fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_xorps128_mask, "V4fV4fV4fV4fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_orpd256_mask, "V4dV4dV4dV4dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_orpd128_mask, "V2dV2dV2dV2dUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_orps256_mask, "V8fV8fV8fV8fUc", "", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_orps128_mask, "V4fV4fV4fV4fUc", "", 
"avx512vl,avx512dq")
 
 TARGET_BUILTIN(__builtin_ia32_pabsb512_mask, "V64cV64cV64cULLi", "", 
"avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pabsw512_mask, "V32sV32sV32sUi", "", "avx512bw")

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=280197&r1=280196&r2=280197&view=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Wed Aug 31 00:38:58 2016
@@ -54,179 +54,155 @@ _mm512_maskz_mullo_epi64 (__mmask8 __U,
 }
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
-_mm512_xor_pd (__m512d __A, __m512d __B) {
-  return (__m512d) ((__v8du) __A ^ (__v8du) __B);
+_mm512_xor_pd(__m512d __A, __m512d __B) {
+  return (__m512d)((__v8du)__A ^ (__v8du)__B);
 }
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
-_mm512_mask_xor_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) {
-  return (__m512d) __builtin_ia32_xorpd512_mask ((__v8df) __A,
- (__v8df) __B,
- (__v8df) __W,
- (__mmask8) __U);
+_mm512_mask_xor_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) {
+  return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U,
+  (__v8df)_mm512_xor_pd(__A, __B),
+  (__v8df)__W);
 }
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
-_mm512_maskz_xor_pd (__mmask8 __U, __m512d __A, __m512d __B) {
-  return (__m512d) __builtin_ia32_xorpd512_mask ((__v8df) __A,
-

r280196 - [X86] Use v2i64 vectors to implement _mm_and/andn/or/xor_pd.

2016-08-30 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Aug 31 00:38:55 2016
New Revision: 280196

URL: http://llvm.org/viewvc/llvm-project?rev=280196&view=rev
Log:
[X86] Use v2i64 vectors to implement _mm_and/andn/or/xor_pd.

These will be reused when removing some builtins from avx512vldqintrin.h and 
this will make the tests for that change show a better number of vector 
elements.

Modified:
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=280196&r1=280195&r2=280196&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Wed Aug 31 00:38:55 2016
@@ -141,25 +141,25 @@ _mm_max_pd(__m128d __a, __m128d __b)
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_and_pd(__m128d __a, __m128d __b)
 {
-  return (__m128d)((__v4su)__a & (__v4su)__b);
+  return (__m128d)((__v2du)__a & (__v2du)__b);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_andnot_pd(__m128d __a, __m128d __b)
 {
-  return (__m128d)(~(__v4su)__a & (__v4su)__b);
+  return (__m128d)(~(__v2du)__a & (__v2du)__b);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_or_pd(__m128d __a, __m128d __b)
 {
-  return (__m128d)((__v4su)__a | (__v4su)__b);
+  return (__m128d)((__v2du)__a | (__v2du)__b);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_xor_pd(__m128d __a, __m128d __b)
 {
-  return (__m128d)((__v4su)__a ^ (__v4su)__b);
+  return (__m128d)((__v2du)__a ^ (__v2du)__b);
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS

Modified: cfe/trunk/test/CodeGen/sse2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse2-builtins.c?rev=280196&r1=280195&r2=280196&view=diff
==
--- cfe/trunk/test/CodeGen/sse2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse2-builtins.c Wed Aug 31 00:38:55 2016
@@ -73,7 +73,7 @@ __m128i test_mm_adds_epu16(__m128i A, __
 
 __m128d test_mm_and_pd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_and_pd
-  // CHECK: and <4 x i32>
+  // CHECK: and <2 x i64>
   return _mm_and_pd(A, B);
 }
 
@@ -85,8 +85,8 @@ __m128i test_mm_and_si128(__m128i A, __m
 
 __m128d test_mm_andnot_pd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_andnot_pd
-  // CHECK: xor <4 x i32> %{{.*}}, 
-  // CHECK: and <4 x i32>
+  // CHECK: xor <2 x i64> %{{.*}}, 
+  // CHECK: and <2 x i64>
   return _mm_andnot_pd(A, B);
 }
 
@@ -845,7 +845,7 @@ __m128i test_mm_mullo_epi16(__m128i A, _
 
 __m128d test_mm_or_pd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_or_pd
-  // CHECK: or <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: or <2 x i64> %{{.*}}, %{{.*}}
   return _mm_or_pd(A, B);
 }
 
@@ -1529,7 +1529,7 @@ __m128d test_mm_unpacklo_pd(__m128d A, _
 
 __m128d test_mm_xor_pd(__m128d A, __m128d B) {
   // CHECK-LABEL: test_mm_xor_pd
-  // CHECK: xor <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: xor <2 x i64> %{{.*}}, %{{.*}}
   return _mm_xor_pd(A, B);
 }
 


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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Daniel Jasper via cfe-commits
djasper added a comment.

As per my comment, please add tests for cases where you currently don't do 
re-ordering (different access specifiers, partial initializers). Other than 
that, yes, this is fine to commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D24065: [libc++] Don't attempt to dllexport enum class

2016-08-30 Thread Shoaib Meenai via cfe-commits
smeenai marked 3 inline comments as done.
smeenai added a comment.

https://reviews.llvm.org/D24065



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


Re: [PATCH] D24065: [libc++] Don't attempt to dllexport enum class

2016-08-30 Thread Shoaib Meenai via cfe-commits
smeenai updated this revision to Diff 69797.
smeenai updated the summary for this revision.
smeenai added a comment.

Removing export entirely, per compnerd's suggestion


https://reviews.llvm.org/D24065

Files:
  include/__config

Index: include/__config
===
--- include/__config
+++ include/__config
@@ -716,7 +716,7 @@
 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
 };
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
 #endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
 


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -716,7 +716,7 @@
 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
 };
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
 #endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24065: [libc++] Don't attempt to dllexport enum class

2016-08-30 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: include/__config:719
@@ -718,3 +718,3 @@
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS_ONLY x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)

smeenai wrote:
> compnerd wrote:
> > I don't think that this is right.  On non-Windows, this would potentially 
> > expand out to `__attribute__ (( __type_visibility__ ("default") ))`.  I 
> > don't believe that `enum classes` have anything like RTTI associated with 
> > them, so we don't really want type visibility for that.
> Good point. Should I just drop the visibility macro entirely then?
I think that might be the correct approach here.  The definition will be 
inlined in the header, so the values should always be available, so the 
visibility attributes shouldn't change anything anyways.


https://reviews.llvm.org/D24065



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


Re: [PATCH] D24065: [libc++] Don't attempt to dllexport enum class

2016-08-30 Thread Shoaib Meenai via cfe-commits
smeenai added inline comments.


Comment at: include/__config:719
@@ -718,3 +718,3 @@
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS_ONLY x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)

compnerd wrote:
> I don't think that this is right.  On non-Windows, this would potentially 
> expand out to `__attribute__ (( __type_visibility__ ("default") ))`.  I don't 
> believe that `enum classes` have anything like RTTI associated with them, so 
> we don't really want type visibility for that.
Good point. Should I just drop the visibility macro entirely then?


https://reviews.llvm.org/D24065



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


Re: [PATCH] D24065: [libc++] Don't attempt to dllexport enum class

2016-08-30 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: include/__config:719
@@ -718,3 +718,3 @@
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS_ONLY x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)

I don't think that this is right.  On non-Windows, this would potentially 
expand out to `__attribute__ (( __type_visibility__ ("default") ))`.  I don't 
believe that `enum classes` have anything like RTTI associated with them, so we 
don't really want type visibility for that.


https://reviews.llvm.org/D24065



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


Re: [PATCH] D23734: Add -fprofile-dir= to clang.

2016-08-30 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: lib/Transforms/Instrumentation/GCOVProfiling.cpp:447
@@ -432,3 +446,3 @@
 return Filename.str();
   }
 }

A quick pass over this yielded something like:

if (N->getNumOperands() != 2 && N->getNumOperands() != 3)
  continue;

bool HasProfileDir = N->getNumOperands() == 3;
unsigned Offset = HasProfileDir ? 1 : 0;

auto *NotesFile = dyn_cast(N->getOperand(Offset + 0));
auto *CovFile = dyn_cast(N->getOperand(Offset + 0));
auto *CompileUnit = dyn_cast(N->getOperand(Offset + 1));

if ((!HasProfileDir || !NotesFile) || !CovFile || !CompileUnit)
  continue;

if (CompileUnit == CU) {
  bool GCNO = OutputType == GCovFileType::GCNO;
  if (HasProfileDir) {
return GCNO ? NotesFile->getString() : CovFile->getString();
  } else {
SmallString<128> FileName = CovFile->getString();
sys::path::replace_extension(FileName, GCNO ? "gcno" : "gcda");
return FileName.str();
  }
}

It does reduce a bit of the duplication, and still accounts for the string 
duplication that you were pointing out.  I think it makes it slightly easier to 
read due to the variable de-duplication (at the slight cost of an extra pointer 
on the stack and an extra lookup).


https://reviews.llvm.org/D23734



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


Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry

2016-08-30 Thread Philip Reames via cfe-commits
reames added a comment.

This seems to have landed a couple of days ago without problem, but if anyone 
sees any weird effects in shared builds for Linux, this change is probably the 
culprit.  The last time I tried to do something like this, I had to back out my 
change due to linker errors I never had the time to understand on some of the 
build bots.



Comment at: llvm/trunk/include/llvm/Support/Registry.h:132
@@ +131,3 @@
+  namespace llvm { \
+  template<> void REGISTRY_CLASS::add_node(REGISTRY_CLASS::node *N) { \
+if (Tail) \

Minor style comment: Extracting the body of add_node into an add_node_impl 
which is still static and having the macro just pound out a wrapper would be a 
bit cleaner.  


Repository:
  rL LLVM

https://reviews.llvm.org/D21385



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


r280190 - PR12298 et al: don't recursively instantiate a template specialization from

2016-08-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 30 21:15:21 2016
New Revision: 280190

URL: http://llvm.org/viewvc/llvm-project?rev=280190&view=rev
Log:
PR12298 et al: don't recursively instantiate a template specialization from
within the instantiation of that same specialization. This could previously
happen for eagerly-instantiated function templates, variable templates,
exception specifications, default arguments, and a handful of other cases.

We still have an issue here for default template arguments that recursively
make use of themselves and likewise for substitution into the type of a
non-type template parameter, but in those cases we're producing a different
entity each time, so they should instead be caught by the instantiation depth
limit. However, currently we will typically run out of stack before we reach
it. :(

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/instantiate-self.cpp
cfe/trunk/test/SemaTemplate/instantiation-depth-exception-spec.cpp
cfe/trunk/test/SemaTemplate/instantiation-depth.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=280190&r1=280189&r2=280190&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Tue Aug 30 21:15:21 2016
@@ -43,6 +43,8 @@ class VarTemplatePartialSpecializationDe
 typedef llvm::PointerUnion3 TemplateParameter;
 
+NamedDecl *getAsNamedDecl(TemplateParameter P);
+
 /// \brief Stores a list of template parameters for a TemplateDecl and its
 /// derived classes.
 class TemplateParameterList final
@@ -2937,6 +2939,14 @@ public:
   friend class ASTDeclWriter;
 };
 
+inline NamedDecl *getAsNamedDecl(TemplateParameter P) {
+  if (auto *PD = P.dyn_cast())
+return PD;
+  if (auto *PD = P.dyn_cast())
+return PD;
+  return P.get();
+}
+
 } /* end of namespace clang */
 
 #endif

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=280190&r1=280189&r2=280190&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 30 21:15:21 
2016
@@ -7001,6 +7001,10 @@ def err_in_class_initializer_not_yet_par
 def err_in_class_initializer_not_yet_parsed_outer_class
 : Error<"cannot use defaulted default constructor of %0 within "
 "%1 outside of member functions because %2 has an initializer">;
+def err_in_class_initializer_cycle
+: Error<"default member initializer for %0 uses itself">;
+def err_exception_spec_cycle
+: Error<"exception specification of %0 uses itself">;
 
 def ext_in_class_initializer_non_constant : Extension<
   "in-class initializer for static data member is not a constant expression; "

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=280190&r1=280189&r2=280190&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 30 21:15:21 2016
@@ -18,6 +18,7 @@
 #include "clang/AST/Attr.h"
 #include "clang/AST/Availability.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExternalASTSource.h"
@@ -6668,10 +6669,10 @@ public:
   TemplateInstantiation,
 
   /// We are instantiating a default argument for a template
-  /// parameter. The Entity is the template, and
-  /// TemplateArgs/NumTemplateArguments provides the template
-  /// arguments as specified.
-  /// FIXME: Use a TemplateArgumentList
+  /// parameter. The Entity is the template parameter whose argument is
+  /// being instantiated, the Template is the template, and the
+  /// TemplateArgs/NumTemplateArguments provide the template arguments as
+  /// specified.
   DefaultTemplateArgumentInstantiation,
 
   /// We are instantiating a default argument for a function.
@@ -6786,6 +6787,9 @@ public:
   SmallVector
 ActiveTemplateInstantiations;
 
+  /// Specializations whose definitions are currently being instantiated.
+  llvm::DenseSet> InstantiatingSpecializations;
+
   /// \brief Extra modules inspected when performing a lookup during a template
   /// instantiation. Com

r280189 - Concatenate two FileCheck lines in a test.

2016-08-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Aug 30 20:57:12 2016
New Revision: 280189

URL: http://llvm.org/viewvc/llvm-project?rev=280189&view=rev
Log:
Concatenate two FileCheck lines in a test.

'cc1' is a valid sequence of hexadecimal and sometimes can occur in the path
when testing.  This can lead to FileCheck matching the incorrect occurance
of the 'cc1' string and causing a test failure.  Join two adjacent flags
together into one check to prevent this.

Modified:
cfe/trunk/test/Driver/cl-pch.c

Modified: cfe/trunk/test/Driver/cl-pch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.c?rev=280189&r1=280188&r2=280189&view=diff
==
--- cfe/trunk/test/Driver/cl-pch.c (original)
+++ cfe/trunk/test/Driver/cl-pch.c Tue Aug 30 20:57:12 2016
@@ -12,8 +12,7 @@
 // /Yc with a .c file should build a c pch file.
 // RUN: %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c 
/Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC %s
-// CHECK-YC: cc1
-// CHECK-YC-SAME: -emit-pch
+// CHECK-YC: cc1{{.* .*}}-emit-pch
 // CHECK-YC-SAME: -o
 // CHECK-YC-SAME: pchfile.pch
 // CHECK-YC-SAME: -x
@@ -22,8 +21,7 @@
 // But not if /TP changes the input language to C++.
 // RUN: %clang_cl /TP -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c 
/Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTP %s
-// CHECK-YCTP: cc1
-// CHECK-YCTP-SAME: -emit-pch
+// CHECK-YCTP: cc1{{.* .*}}-emit-pch
 // CHECK-YCTP-SAME: -o
 // CHECK-YCTP-SAME: pchfile.pch
 // CHECK-YCTP-SAME: -x
@@ -32,8 +30,7 @@
 // Except if a later /TC changes it back.
 // RUN: %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c 
/Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTPTC %s
-// CHECK-YCTPTC: cc1
-// CHECK-YCTPTC-SAME: -emit-pch
+// CHECK-YCTPTC: cc1{{.* .*}}-emit-pch
 // CHECK-YCTPTC-SAME: -o
 // CHECK-YCTPTC-SAME: pchfile.pch
 // CHECK-YCTPTC-SAME: -x
@@ -42,8 +39,7 @@
 // Also check lower-case /Tp flag.
 // RUN: %clang_cl -Werror /Tp%s /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h 
/c /Fo%t/pchfile.obj /Fp%t/pchfile.pch -v 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTp %s
-// CHECK-YCTp: cc1
-// CHECK-YCTp-SAME: -emit-pch
+// CHECK-YCTp: cc1{{.* .*}}-emit-pch
 // CHECK-YCTp-SAME: -o
 // CHECK-YCTp-SAME: pchfile.pch
 // CHECK-YCTp-SAME: -x


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


r280187 - clangTooling: Update libdeps: LLVMOptions, since r280118.

2016-08-30 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Aug 30 19:46:32 2016
New Revision: 280187

URL: http://llvm.org/viewvc/llvm-project?rev=280187&view=rev
Log:
clangTooling: Update libdeps: LLVMOptions, since r280118.

Modified:
cfe/trunk/lib/Tooling/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CMakeLists.txt?rev=280187&r1=280186&r2=280187&view=diff
==
--- cfe/trunk/lib/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/CMakeLists.txt Tue Aug 30 19:46:32 2016
@@ -1,4 +1,7 @@
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  Option
+  Support
+  )
 
 add_subdirectory(Core)
 


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


r280186 - clangTooling depends on ClangDriverOptions since r280118.

2016-08-30 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Aug 30 19:46:25 2016
New Revision: 280186

URL: http://llvm.org/viewvc/llvm-project?rev=280186&view=rev
Log:
clangTooling depends on ClangDriverOptions since r280118.

Modified:
cfe/trunk/lib/Tooling/CMakeLists.txt

Modified: cfe/trunk/lib/Tooling/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CMakeLists.txt?rev=280186&r1=280185&r2=280186&view=diff
==
--- cfe/trunk/lib/Tooling/CMakeLists.txt (original)
+++ cfe/trunk/lib/Tooling/CMakeLists.txt Tue Aug 30 19:46:25 2016
@@ -13,6 +13,9 @@ add_clang_library(clangTooling
   RefactoringCallbacks.cpp
   Tooling.cpp
 
+  DEPENDS
+  ClangDriverOptions
+
   LINK_LIBS
   clangAST
   clangASTMatchers


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


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

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


Comment at: lib/Sema/SemaChecking.cpp:11054
@@ +11053,3 @@
+  auto AlignRecord = Context.getTypeAlignInChars(BaseType);
+  if ((RequiredAlignment > AlignRecord) ||
+  ((Context.toCharUnitsFromBits(

Suppose I have this:

  struct A { char c; int n; };
  struct __attribute__((packed)) B { A a; } b;
  char *p = &b.a.c;

Here, on the second iteration through this loop, it looks like you'll compute 
`RequiredAlignment == 4` (from `A`'s alignment of 4), with `AlignRecord == 1` 
(from the attribute), which would result in calling `Action`. This seems 
unnecessary, since we know we'll never diagnose this case, because the actual 
alignment of the field is (at least) the alignment of the original member `c`.


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: [PATCH] D23325: [WIP] Binding of references to packed fields

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


Comment at: include/clang/AST/Expr.h:441
@@ +440,3 @@
+  /// Likewise bitfields, we model gl-values referring to packed-fields as
+  /// an aspect of the value-kind type system.
+  bool refersToPackedField() const { return getObjectKind() == OK_PackedField; 
}

value-kind -> object kind.


Comment at: include/clang/Basic/Specifiers.h:119-140
@@ -118,21 +118,24 @@
   /// l-value or x-value.
   enum ExprObjectKind {
 /// An ordinary object is located at an address in memory.
 OK_Ordinary,
 
 /// A bitfield object is a bitfield on a C or C++ record.
 OK_BitField,
 
+/// A packed-field is a field on a C or C++ packed record.
+OK_PackedField,
+
 /// A vector component is an element or range of elements on a vector.
 OK_VectorComponent,
 
 /// An Objective-C property is a logical field of an Objective-C
 /// object which is read and written via Objective-C method calls.
 OK_ObjCProperty,
 
 /// An Objective-C array/dictionary subscripting which reads an
 /// object or writes at the subscripted array/dictionary element via
 /// Objective-C method calls.
 OK_ObjCSubscript
   };
 

Wait a second, how did this fit into 2 bits before your change?!


Comment at: lib/AST/Decl.cpp:3523
@@ +3522,3 @@
+  return !isBitField() &&
+ (this->hasAttr() || getParent()->hasAttr()) &&
+ Context.getDeclAlign(this) <

Does this properly handle anonymous struct/union members:

  struct A __attribute__((packed)) {
char a;
union { int b; };
  } a;
  int &r = a.b;


Comment at: lib/CodeGen/CGCall.cpp:3278
@@ -3277,3 +3277,3 @@
   if (E->isGLValue()) {
-assert(E->getObjectKind() == OK_Ordinary);
+assert(E->getObjectKind() == OK_Ordinary || E->getObjectKind() == 
OK_PackedField);
 return args.add(EmitReferenceBindingToExpr(E), type);

This looks wrong: we shouldn't be emitting reference bindings to packed fields. 
We should have rejected them in Sema.


Comment at: lib/Sema/SemaCast.cpp:1912
@@ -1911,2 +1911,3 @@
 case OK_Ordinary:
+case OK_PackedField:
   break;

Might be worth adding a comment here, "GCC allows a packed field to be 
explicitly cast to a reference type as a way of removing the 'packed' taint" or 
similar.


Comment at: lib/Sema/SemaExprMember.cpp:1772-1774
@@ -1771,4 +1771,5 @@
   if (!IsArrow) {
-if (BaseExpr->getObjectKind() == OK_Ordinary)
+if (BaseExpr->getObjectKind() == OK_Ordinary ||
+BaseExpr->getObjectKind() == OK_PackedField)
   VK = BaseExpr->getValueKind();
 else

If the `BaseExpr` is an `OK_PackedField` then the resulting `OK` for the field 
should also be an `OK_PackedField`:

  struct Q { int k; };
  struct __attribute__((packed)) A { Q k; } a;
  int &r = a.k.k; // error, binding reference to packed field

You should handle this here...


Comment at: lib/Sema/SemaExprMember.cpp:1782
@@ +1781,3 @@
+  OK = OK_BitField;
+else if (Field->isPackedField(S.Context) || 
BaseExpr->refersToPackedField())
+  OK = OK_PackedField;

... not here. This check does the wrong thing for the `IsArrow` case:

  struct Q { int k; };
  struct __attribute__((packed)) A { Q *k; } a;
  int &r = a.k->k; // should be valid, not a packed field


Comment at: lib/Sema/SemaInit.cpp:4186
@@ -4184,1 +4185,3 @@
 
+if (IsLValueRef && Initializer->refersToPackedField() &&
+Initializer->getType()->getAsCXXRecordDecl()) {

You don't need to special-case packed fields here. They just happen to be the 
only non-addressable object kind we have right now that can be a class type. If 
we had others, they should get this treatment too, so it seems better to remove 
the check.


Comment at: lib/Sema/SemaInit.cpp:4186
@@ -4184,1 +4185,3 @@
 
+if (IsLValueRef && Initializer->refersToPackedField() &&
+Initializer->getType()->getAsCXXRecordDecl()) {

rsmith wrote:
> You don't need to special-case packed fields here. They just happen to be the 
> only non-addressable object kind we have right now that can be a class type. 
> If we had others, they should get this treatment too, so it seems better to 
> remove the check.
Why are you treating lvalue references specially here? GCC doesn't seem to, and 
it's not obvious to me why rvalue references should get special treatment.


Comment at: lib/Sema/SemaInit.cpp:4202-4204
@@ +4201,5 @@
+
+   It is not possible to bind w to a temporary of a.x because this
+   would require (recursively) invoking the copy constructor of
+   std::vector to obtain first a (properly aligned) temporary of a.x.
+  */

rogfer01 wrote:
> Rereading this makes no sense to me now. I'll adress this in a later 

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

2016-08-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Are there any remaining issues with this patch?


https://reviews.llvm.org/D23385



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


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

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


Comment at: include/clang/Basic/AttrDocs.td:836
@@ +835,3 @@
+  let Content = [{
+This attribute specifies that the variable to which it is attached is intended
+to have a `constant initializer 
`_

rsmith wrote:
> For the record, in C the program is ill-formed if the initializer for a 
> global is non-constant, so it doesn't seem like this attribute would ever be 
> useful.
Ah I didn't know that! 


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-30 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

Sorry for long delay. I had some issues with git-svn on mac.


Repository:
  rL LLVM

https://reviews.llvm.org/D23343



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-30 Thread Piotr Padlewski via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280180: [clang-tidy] modernize-make-{smart_ptr} private ctor 
bugfix (authored by Prazek).

Changed prior to commit:
  https://reviews.llvm.org/D23343?vs=68824&id=69787#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23343

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
@@ -103,6 +103,38 @@
   std::unique_ptr Placement = std::unique_ptr(new (PInt) int{3});
 }
 
+// Calling make_smart_ptr from within a member function of a type with a
+// private or protected constructor would be ill-formed.
+class Private {
+private:
+  Private(int z) {}
+
+public:
+  Private() {}
+  void create() {
+auto callsPublic = std::unique_ptr(new Private);
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
+// CHECK-FIXES: auto callsPublic = std::make_unique();
+auto ptr = std::unique_ptr(new Private(42));
+  }
+
+  virtual ~Private();
+};
+
+class Protected {
+protected:
+  Protected() {}
+
+public:
+  Protected(int, int) {}
+  void create() {
+auto callsPublic = std::unique_ptr(new Protected(1, 2));
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
+// CHECK-FIXES: auto callsPublic = std::make_unique(1, 2);
+auto ptr = std::unique_ptr(new Protected);
+  }
+};
+
 void initialization(int T, Base b) {
   // Test different kinds of initialization of the pointee.
 
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
@@ -100,6 +100,38 @@
   std::shared_ptr Placement = std::shared_ptr(new (PInt) int{3});
 }
 
+// Calling make_smart_ptr from within a member function of a type with a
+// private or protected constructor would be ill-formed.
+class Private {
+private:
+  Private(int z) {}
+
+public:
+  Private() {}
+  void create() {
+auto callsPublic = std::shared_ptr(new Private);
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
+// CHECK-FIXES: auto callsPublic = std::make_shared();
+auto ptr = std::shared_ptr(new Private(42));
+  }
+
+  virtual ~Private();
+};
+
+class Protected {
+protected:
+  Protected() {}
+
+public:
+  Protected(int, int) {}
+  void create() {
+auto callsPublic = std::shared_ptr(new Protected(1, 2));
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
+// CHECK-FIXES: auto callsPublic = std::make_shared(1, 2);
+auto ptr = std::shared_ptr(new Protected);
+  }
+};
+
 void initialization(int T, Base b) {
   // Test different kinds of initialization of the pointee.
 
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -29,13 +29,19 @@
   if (!getLangOpts().CPlusPlus11)
 return;
 
+  // Calling make_smart_ptr from within a member function of a type with a
+  // private or protected constructor would be ill-formed.
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(unless(isPublic(;
+
   Finder->addMatcher(
   cxxBindTemporaryExpr(has(ignoringParenImpCasts(
   cxxConstructExpr(
   hasType(getSmartPointerTypeMatcher()), argumentCountIs(1),
   hasArgument(0,
   cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
- equalsBoundNode(PointerType))
+ equalsBoundNode(PointerType),
+ CanCallCtor)
   .bind(NewExpression)))
   .bind(ConstructorCall,
   this);
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -97,6 +97,14 @@
   Flags function parameters of a pointer type that could be changed to point to
   a constant type instead.
 
+Fixed bugs:
+- `modernize-make-unique
+  `_
+  and `modernize-make-share

[clang-tools-extra] r280180 - [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-30 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Tue Aug 30 19:06:55 2016
New Revision: 280180

URL: http://llvm.org/viewvc/llvm-project?rev=280180&view=rev
Log:
[clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

Summary:
Bugfix for 27321. When the constructor of stored pointer
type is private then it is invalid to change it to
make_shared or make_unique.

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=280180&r1=280179&r2=280180&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Tue Aug 
30 19:06:55 2016
@@ -29,13 +29,19 @@ void MakeSmartPtrCheck::registerMatchers
   if (!getLangOpts().CPlusPlus11)
 return;
 
+  // Calling make_smart_ptr from within a member function of a type with a
+  // private or protected constructor would be ill-formed.
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(unless(isPublic(;
+
   Finder->addMatcher(
   cxxBindTemporaryExpr(has(ignoringParenImpCasts(
   cxxConstructExpr(
   hasType(getSmartPointerTypeMatcher()), argumentCountIs(1),
   hasArgument(0,
   
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
- equalsBoundNode(PointerType))
+ equalsBoundNode(PointerType),
+ CanCallCtor)
   .bind(NewExpression)))
   .bind(ConstructorCall,
   this);

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=280180&r1=280179&r2=280180&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Aug 30 19:06:55 2016
@@ -97,6 +97,14 @@ Improvements to clang-tidy
   Flags function parameters of a pointer type that could be changed to point to
   a constant type instead.
 
+Fixed bugs:
+- `modernize-make-unique
+  `_
+  and `modernize-make-shared
+  `_
+  Calling ``make_{unique|shared}`` from within a member function of a type
+  with a private or protected constructor would be ill-formed.
+
 Improvements to include-fixer
 -
 

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp?rev=280180&r1=280179&r2=280180&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp Tue Aug 
30 19:06:55 2016
@@ -100,6 +100,38 @@ void basic() {
   std::shared_ptr Placement = std::shared_ptr(new (PInt) int{3});
 }
 
+// Calling make_smart_ptr from within a member function of a type with a
+// private or protected constructor would be ill-formed.
+class Private {
+private:
+  Private(int z) {}
+
+public:
+  Private() {}
+  void create() {
+auto callsPublic = std::shared_ptr(new Private);
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
+// CHECK-FIXES: auto callsPublic = std::make_shared();
+auto ptr = std::shared_ptr(new Private(42));
+  }
+
+  virtual ~Private();
+};
+
+class Protected {
+protected:
+  Protected() {}
+
+public:
+  Protected(int, int) {}
+  void create() {
+auto callsPublic = std::shared_ptr(new Protected(1, 2));
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
+// CHECK-FIXES: auto callsPublic = std::make_shared(1, 2);
+auto ptr = std::shared_ptr(new Protected);
+  }
+};
+
 void initialization(int T, Base b) {
   // Test different kinds of initialization of the pointee.
 

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=280180&r1=280179&r2=280180&view=diff
===

[PATCH] D24065: [libc++] Don't attempt to dllexport enum class

2016-08-30 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added reviewers: abdulras, EricWF, mclow.lists.
smeenai added subscribers: cfe-commits, kastiglione.

An enum class can't be dllexport'ed, and attempting to do so produces
warnings.

https://reviews.llvm.org/D24065

Files:
  include/__config

Index: include/__config
===
--- include/__config
+++ include/__config
@@ -716,7 +716,7 @@
 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
 };
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS_ONLY x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
 #endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
 


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -716,7 +716,7 @@
 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
 };
 #else  // _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS_ONLY x
 #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
 #endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


LLVM buildmaster will be restarted tonight

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

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


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

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


Comment at: include/clang/Basic/AttrDocs.td:836
@@ +835,3 @@
+  let Content = [{
+This attribute specifies that the variable to which it is attached is intended
+to have a `constant initializer 
`_

For the record, in C the program is ill-formed if the initializer for a global 
is non-constant, so it doesn't seem like this attribute would ever be useful.


https://reviews.llvm.org/D23385



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


r280178 - Don't try to run a test that generates code for x86 if it's not a registered target.

2016-08-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 30 18:53:34 2016
New Revision: 280178

URL: http://llvm.org/viewvc/llvm-project?rev=280178&view=rev
Log:
Don't try to run a test that generates code for x86 if it's not a registered 
target.

Modified:
cfe/trunk/test/Driver/cl-pch.c

Modified: cfe/trunk/test/Driver/cl-pch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.c?rev=280178&r1=280177&r2=280178&view=diff
==
--- cfe/trunk/test/Driver/cl-pch.c (original)
+++ cfe/trunk/test/Driver/cl-pch.c Tue Aug 30 18:53:34 2016
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+//
 // RUN: rm -rf %t
 // RUN: mkdir %t
 //


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


Re: r280133 - PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) input types.

2016-08-30 Thread Richard Smith via cfe-commits
Hopefully r280178 should fix this.

On Tue, Aug 30, 2016 at 4:00 PM, Renato Golin 
wrote:

> On 30 August 2016 at 22:44, Renato Golin  wrote:
> > This breakage was hidden by Duncan's build breakage:
> >
> > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/11172
>
> Also, http://lab.llvm.org:8011/builders/clang-cmake-aarch64-
> quick/builds/9813
>
> Same error...
>
> cheers,
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23944: Parsing MS pragma intrinsic

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

lgtm


https://reviews.llvm.org/D23944



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


Re: [PATCH] D23734: Add -fprofile-dir= to clang.

2016-08-30 Thread Nick Lewycky via cfe-commits
nlewycky added inline comments.


Comment at: lib/Transforms/Instrumentation/GCOVProfiling.cpp:447
@@ -432,3 +446,3 @@
 return Filename.str();
   }
 }

compnerd wrote:
> It really feels like these two cases can be collapsed.
I don't see a great way to do that, so I picked the one which minimizes the 
cost of the common case. Having an !llvm.gcov node but no CU for the specific 
.o is uncommon: to get here you're building a program with some .bc's built 
with a frontend that emits an !llvm.gcov and some .bc's without, and then you 
llvm-linked them and are running the insert-gcov-profiling pass afterwards. 
Also, I assume that copying SmallString<128>'s around is slow, while looking up 
Value*'s is faster.

If you have a specific idea, I'm happy to try it. I'm not thrilled with the way 
it's written now.


Comment at: test/Transforms/GCOVProfiling/three-element-mdnode.ll:27
@@ +26,2 @@
+
+!10 = !{i32 1, !"Debug Info Version", i32 3}

The way this test was written, !10 would be parsed before !9. Swizzled it 
around to make !9 the !llvm.module.flags and !10 the !llvm.gcov node.


https://reviews.llvm.org/D23734



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


Re: [PATCH] D23734: Add -fprofile-dir= to clang.

2016-08-30 Thread Nick Lewycky via cfe-commits
nlewycky updated this revision to Diff 69778.
nlewycky marked 5 inline comments as done.

https://reviews.llvm.org/D23734

Files:
  lib/Transforms/Instrumentation/GCOVProfiling.cpp
  test/Transforms/GCOVProfiling/three-element-mdnode.ll
  tools/clang/include/clang/Driver/CC1Options.td
  tools/clang/include/clang/Driver/Options.td
  tools/clang/include/clang/Frontend/CodeGenOptions.h
  tools/clang/lib/CodeGen/CodeGenModule.cpp
  tools/clang/lib/Driver/Tools.cpp
  tools/clang/lib/Frontend/CompilerInvocation.cpp
  tools/clang/test/CodeGen/code-coverage.c
  tools/clang/test/Driver/clang_f_opts.c
  tools/clang/test/Driver/coverage_no_integrated_as.c

Index: tools/clang/test/Driver/coverage_no_integrated_as.c
===
--- tools/clang/test/Driver/coverage_no_integrated_as.c
+++ tools/clang/test/Driver/coverage_no_integrated_as.c
@@ -17,7 +17,7 @@
 // RUN: %clang -### -c -fprofile-arcs -no-integrated-as %s -o foo/bar.o 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION-REL-PATH %s
 
 
-// CHECK-GCNO-DEFAULT-LOCATION: "-coverage-file" "{{.*}}{{/|}}coverage_no_integrated_as.c"
-// CHECK-GCNO-DEFAULT-LOCATION-NOT: "-coverage-file" "/tmp/{{.*}}/coverage_no_integrated_as.c"
-// CHECK-GCNO-LOCATION: "-coverage-file" "{{.*}}/foo/bar.o"
-// CHECK-GCNO-LOCATION-REL-PATH: "-coverage-file" "{{.*}}{{/|}}foo/bar.o"
+// CHECK-GCNO-DEFAULT-LOCATION: "-coverage-notes-file" "{{.*}}{{/|}}coverage_no_integrated_as.c"
+// CHECK-GCNO-DEFAULT-LOCATION-NOT: "-coverage-notes-file" "/tmp/{{.*}}/coverage_no_integrated_as.c"
+// CHECK-GCNO-LOCATION: "-coverage-notes-file" "{{.*}}/foo/bar.gcno"
+// CHECK-GCNO-LOCATION-REL-PATH: "-coverage-notes-file" "{{.*}}{{/|}}foo/bar.gcno"
Index: tools/clang/test/Driver/clang_f_opts.c
===
--- tools/clang/test/Driver/clang_f_opts.c
+++ tools/clang/test/Driver/clang_f_opts.c
@@ -66,6 +66,16 @@
 // CHECK-PROFILE-ARCS: "-femit-coverage-data"
 // CHECK-NO-PROFILE-ARCS-NOT: "-femit-coverage-data"
 
+// RUN: %clang -### -S -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR-UNUSED %s
+// RUN: %clang -### -S -ftest-coverage -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR-UNUSED %s
+// RUN: %clang -### -S -fprofile-arcs -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR %s
+// RUN: %clang -### -S --coverage -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR %s
+// RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR-NEITHER %s
+// CHECK-PROFILE-DIR: "-coverage-data-file" "abc
+// CHECK-PROFILE-DIR-UNUSED: argument unused
+// CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
+// CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
+
 // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
@@ -212,7 +222,6 @@
 // RUN: -fdefer-pop -fno-defer-pop\
 // RUN: -fprefetch-loop-arrays -fno-prefetch-loop-arrays  \
 // RUN: -fprofile-correction -fno-profile-correction  \
-// RUN: -fprofile-dir=bar \
 // RUN: -fprofile-values -fno-profile-values  \
 // RUN: -frounding-math -fno-rounding-math\
 // RUN: -fsee -fno-see\
@@ -290,7 +299,6 @@
 // RUN: -fkeep-inline-functions   \
 // RUN: -fno-keep-inline-functions\
 // RUN: -freorder-blocks  \
-// RUN: -fprofile-dir=/rand/dir   \
 // RUN: -falign-functions \
 // RUN: -falign-functions=1   \
 // RUN: -ffloat-store \
@@ -357,7 +365,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
-// CHECK-WARNING-DAG: optimization flag '-fprofile-dir=/rand/dir' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-functions=1' is not supported
 // CHECK-WARNING-DAG: optimization flag '-ffloat-store' is not supported
Index: tools/clang/test/CodeGen/code-coverage.c

r280174 - [analyzer] Use lazily created buffer in EmptyLocalizationContextChecker

2016-08-30 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Aug 30 18:07:14 2016
New Revision: 280174

URL: http://llvm.org/viewvc/llvm-project?rev=280174&view=rev
Log:
[analyzer] Use lazily created buffer in EmptyLocalizationContextChecker

Fix a crash when relexing the underlying memory buffer to find incorrect
arguments to NSLocalizedString(). With precompiled headers, the raw
buffer may be NULL. Instead, use the source manager to get the buffer,
which will lazily create the buffer for precompiled headers.

rdar://problem/27429091

Added:
cfe/trunk/test/Analysis/Inputs/localization-pch.h
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/test/Analysis/localization-aggressive.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=280174&r1=280173&r2=280174&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Tue Aug 30 
18:07:14 2016
@@ -1016,6 +1016,8 @@ void EmptyLocalizationContextChecker::ch
 void EmptyLocalizationContextChecker::MethodCrawler::VisitObjCMessageExpr(
 const ObjCMessageExpr *ME) {
 
+  // FIXME: We may be able to use PPCallbacks to check for empy context
+  // comments as part of preprocessing and avoid this re-lexing hack.
   const ObjCInterfaceDecl *OD = ME->getReceiverInterface();
   if (!OD)
 return;
@@ -1050,7 +1052,12 @@ void EmptyLocalizationContextChecker::Me
 SE = Mgr.getSourceManager().getSLocEntry(SLInfo.first);
   }
 
-  llvm::MemoryBuffer *BF = SE.getFile().getContentCache()->getRawBuffer();
+  bool Invalid = false;
+  llvm::MemoryBuffer *BF =
+  Mgr.getSourceManager().getBuffer(SLInfo.first, SL, &Invalid);
+  if (Invalid)
+return;
+
   Lexer TheLexer(SL, LangOptions(), BF->getBufferStart(),
  BF->getBufferStart() + SLInfo.second, BF->getBufferEnd());
 

Added: cfe/trunk/test/Analysis/Inputs/localization-pch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/localization-pch.h?rev=280174&view=auto
==
--- cfe/trunk/test/Analysis/Inputs/localization-pch.h (added)
+++ cfe/trunk/test/Analysis/Inputs/localization-pch.h Tue Aug 30 18:07:14 2016
@@ -0,0 +1,5 @@
+// Used to test missing checker for missing localization context comments
+// in precompiled headers.
+
+#define MyLocalizedStringInPCH(key) NSLocalizedString((key), @"")
+

Modified: cfe/trunk/test/Analysis/localization-aggressive.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/localization-aggressive.m?rev=280174&r1=280173&r2=280174&view=diff
==
--- cfe/trunk/test/Analysis/localization-aggressive.m (original)
+++ cfe/trunk/test/Analysis/localization-aggressive.m Tue Aug 30 18:07:14 2016
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region  
-analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker 
-analyzer-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker
 -verify  -analyzer-config AggressiveReport=true %s
+// RUN: %clang_cc1 -fblocks -x objective-c-header -emit-pch -o %t.pch 
%S/Inputs/localization-pch.h
+
+// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region  
-analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker 
-analyzer-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker
 -include-pch %t.pch -verify  -analyzer-config AggressiveReport=true %s
 
 // These declarations were reduced using Delta-Debugging from Foundation.h
 // on Mac OS X.
@@ -249,6 +251,10 @@ NSString *ForceLocalized(NSString *str)
   NSString *string3 = NSLocalizedString((0 ? @"Critical" : @"Current"),nil); 
// expected-warning {{Localized string macro should include a non-empty comment 
for translators}}
 }
 
+- (void)testMacroExpansionDefinedInPCH {
+  NSString *string = MyLocalizedStringInPCH(@"Hello"); // expected-warning 
{{Localized string macro should include a non-empty comment for translators}}
+}
+
 #define KCLocalizedString(x,comment) NSLocalizedString(x, comment)
 #define POSSIBLE_FALSE_POSITIVE(s,other) KCLocalizedString(s,@"Comment")
 


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


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

2016-08-30 Thread Eric Fiselier via cfe-commits
EricWF marked an inline comment as done.


Comment at: utils/TableGen/ClangAttrEmitter.cpp:2794
@@ -2794,1 +2793,3 @@
+if ((*I)->getValueAsBit("Negated")) {
+  FnName += "Not";
   Test += "!";

This is needed so that the `COnly` and `CPlusPlus` entries in `Attr.td` don't 
create the same function name.


https://reviews.llvm.org/D23385



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


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

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

Make the attribute C++ only.


https://reviews.llvm.org/D23385

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

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2790,8 +2790,10 @@
   std::string FnName = "check", Test;
   for (auto I = LangOpts.begin(), E = LangOpts.end(); I != E; ++I) {
 std::string Part = (*I)->getValueAsString("Name");
-if ((*I)->getValueAsBit("Negated"))
+if ((*I)->getValueAsBit("Negated")) {
+  FnName += "Not";
   Test += "!";
+}
 Test += "S.LangOpts." + Part;
 if (I + 1 != E)
   Test += " || ";
Index: test/SemaCXX/attr-require-constant-initialization.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-require-constant-initialization.cpp
@@ -0,0 +1,282 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DTEST_ONE -std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DTEST_ONE -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DTEST_ONE -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DTEST_TWO \
+// RUN: -Wglobal-constructors -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DTEST_THREE -xc %s
+
+#define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
+
+int ReturnInt();
+
+struct PODType {
+  int value;
+  int value2;
+};
+
+#if defined(__cplusplus)
+
+#if __cplusplus >= 201103L
+struct LitType {
+  constexpr LitType() : value(0) {}
+  constexpr LitType(int x) : value(x) {}
+  LitType(void *) : value(-1) {}
+  int value;
+};
+#endif
+
+struct NonLit {
+#if __cplusplus >= 201402L
+  constexpr NonLit() : value(0) {}
+  constexpr NonLit(int x) : value(x) {}
+#else
+  NonLit() : value(0) {}
+  NonLit(int x) : value(x) {}
+#endif
+  NonLit(void *) : value(-1) {}
+  ~NonLit() {}
+  int value;
+};
+
+struct StoresNonLit {
+#if __cplusplus >= 201402L
+  constexpr StoresNonLit() : obj() {}
+  constexpr StoresNonLit(int x) : obj(x) {}
+#else
+  StoresNonLit() : obj() {}
+  StoresNonLit(int x) : obj(x) {}
+#endif
+  StoresNonLit(void *p) : obj(p) {}
+  NonLit obj;
+};
+
+#endif // __cplusplus
+
+
+#if defined(TEST_ONE) // Test semantics of attribute
+
+// Test diagnostics when attribute is applied to non-static declarations.
+void test_func_local(ATTR int param) { // expected-error {{only applies to variables with static or thread}}
+  ATTR int x = 42; // expected-error {{only applies to variables with static or thread}}
+  ATTR extern int y;
+}
+struct ATTR class_mem { // expected-error {{only applies to variables with static or thread}}
+  ATTR int x;   // expected-error {{only applies to variables with static or thread}}
+};
+
+// [basic.start.static]p2.1
+// if each full-expression (including implicit conversions) that appears in
+// the initializer of a reference with static or thread storage duration is
+// a constant expression (5.20) and the reference is bound to a glvalue
+// designating an object with static storage duration, to a temporary object
+// (see 12.2) or subobject thereof, or to a function;
+
+// Test binding to a static glvalue
+const int glvalue_int = 42;
+const int glvalue_int2 = ReturnInt();
+ATTR const int &glvalue_ref ATTR = glvalue_int;
+ATTR const int &glvalue_ref2 ATTR = glvalue_int2;
+ATTR __thread const int &glvalue_ref_tl = glvalue_int;
+
+void test_basic_start_static_2_1() {
+  const int non_global = 42;
+  ATTR static const int &local_init = non_global; // expected-error {{variable does not have a constant initializer}}
+  // expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+  ATTR static const int &global_init = glvalue_int;
+  ATTR static const int &temp_init = 42;
+}
+
+ATTR const int &temp_ref = 42;
+ATTR const int &temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+ATTR const NonLit &nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+
+#if __cplusplus >= 201103L
+ATTR const LitType &lit_temp_ref = 42;
+ATTR const int &subobj_ref = LitType{}.value;
+#endif
+
+ATTR const int &nl_subobj_ref = NonLit().value; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{required by 'require_constant_initializer' attribute here}}
+
+struct TT1 {
+  ATTR static const int &no_init;
+  ATTR static const int &glvalue_init;

Re: r280104 - Disable clang/test/SemaTemplate/instantiation-depth-default.cpp temporarily for targeting mingw32. It crashes. Investigating.

2016-08-30 Thread NAKAMURA Takumi via cfe-commits
Thanks, Richard.

Conversely, do we need to give sufficient amount of stack to the clang
executable whenever this fails?

By default, clang.exe has 2MiB (and *-tblgen.exe(s) are gaven 16MiB) of
stack on mingw-w64. 10,000,000 bytes on MS-compiled executables. I can
easily increase the size.
See HandleLLVMOptions.cmake and TableGen.cmake.

On Wed, Aug 31, 2016 at 4:12 AM Richard Smith  wrote:

> On Tue, Aug 30, 2016 at 8:38 AM, NAKAMURA Takumi via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: chapuni
>> Date: Tue Aug 30 10:38:18 2016
>> New Revision: 280104
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=280104&view=rev
>> Log:
>> Disable clang/test/SemaTemplate/instantiation-depth-default.cpp
>> temporarily for targeting mingw32. It crashes. Investigating.
>>
>
> This is probably due to stack overflow. Is there a way we can raise the
> stack limit for mingw32?
>
>
>> Modified:
>> cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
>>
>> Modified: cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp?rev=280104&r1=280103&r2=280104&view=diff
>>
>> ==
>> --- cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp Tue Aug
>> 30 10:38:18 2016
>> @@ -12,3 +12,6 @@ template struct X : X
>>  // expected-note@8 {{use -ftemplate-depth=N to increase recursive
>> template instantiation depth}}
>>
>>  X<0, int> x; // expected-note {{in instantiation of}}
>> +
>> +// FIXME: It crashes. Investigating.
>> +// UNSUPPORTED: mingw32
>>
>>
>> ___
>> 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: r280133 - PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) input types.

2016-08-30 Thread Renato Golin via cfe-commits
On 30 August 2016 at 22:44, Renato Golin  wrote:
> This breakage was hidden by Duncan's build breakage:
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/11172

Also, http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/9813

Same error...

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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap marked 2 inline comments as done.
alexshap added a comment.

Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

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

Okay, many thanks for the code review.
May i commit this ?
I will add more tests as a follow-up


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: clang-reorder-fields/ReorderFieldsAction.cpp:179
@@ +178,3 @@
+const ASTContext &Context,
+std::map &Replacements) {
+  assert(InitListEx && "Init list expression is null");

alexshap wrote:
> >Also, I don't understand what the problem is. Just create separate local 
> >variable for >Replacements and only copy to the class member if everything 
> >is successful. Or clear >Replacements if something goes wrong. Am I missing 
> >something?
> the return code. I assumed that in this case the return code should not be 0, 
> but pls take a look at my comments above (regarding the signature of 
> HandleTranslationUnit and 
> http://clang.llvm.org/doxygen/CompilerInstance_8cpp_source.html#l00871
> line 871  Act.Execute(); (return value is ignored) ) it looks like the 
> return code is ignored at several layers - i might be missing smth  - pls, 
> correct me if i am wrong.
I don't really care about the return code. To me it's important that the tool 
doesn't do the wrong thing and that seems fine now. We can sort this out in a 
follow-up, I think.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Now that you can, you should add test cases for the different cases where you 
cannot reorder fields.

Otherwise looks good.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23944: Parsing MS pragma intrinsic

2016-08-30 Thread Albert Gutowski via cfe-commits
agutowski marked an inline comment as done.
agutowski added a comment.

https://reviews.llvm.org/D23944



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap marked 4 inline comments as done.
alexshap added a comment.

Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


Comment at: clang-reorder-fields/ReorderFieldsAction.cpp:179
@@ +178,3 @@
+const ASTContext &Context,
+std::map &Replacements) {
+  assert(InitListEx && "Init list expression is null");

>Also, I don't understand what the problem is. Just create separate local 
>variable for >Replacements and only copy to the class member if everything is 
>successful. Or clear >Replacements if something goes wrong. Am I missing 
>something?
the return code. I assumed that in this case the return code should not be 0, 
but pls take a look at my comments above (regarding the signature of 
HandleTranslationUnit and 
http://clang.llvm.org/doxygen/CompilerInstance_8cpp_source.html#l00871
line 871  Act.Execute(); (return value is ignored) ) it looks like the 
return code is ignored at several layers - i might be missing smth  - pls, 
correct me if i am wrong.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap updated this revision to Diff 69769.
alexshap marked an inline comment as not done.
alexshap added a comment.

Check the return value of reorderFieldsInInitListExpr.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp
  test/clang-reorder-fields/ClassMixedInitialization.cpp
  test/clang-reorder-fields/ClassSimpleCtor.cpp

Index: test/clang-reorder-fields/ClassSimpleCtor.cpp
===
--- test/clang-reorder-fields/ClassSimpleCtor.cpp
+++ test/clang-reorder-fields/ClassSimpleCtor.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %s -- | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK:  {{^  const char \*s1;}}
+  const char *s1; // CHECK-NEXT: {{^  int x;}}
+  const char *s2; // CHECK-NEXT: {{^  double z;}}
+  double z;   // CHECK-NEXT: {{^  const char \*s2;}}
+};
+
+Foo::Foo():
+  x(12),  // CHECK:  {{^  s1\("abc"\),}}
+  s1("abc"),  // CHECK-NEXT: {{^  x\(12\),}}
+  s2("def"),  // CHECK-NEXT: {{^  z\(3.14\),}}
+  z(3.14) // CHECK-NEXT: {{^  s2\("def"\)}}
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/ClassMixedInitialization.cpp
===
--- test/clang-reorder-fields/ClassMixedInitialization.cpp
+++ test/clang-reorder-fields/ClassMixedInitialization.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %s -- -std=c++11 | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK:  {{^  double e = 2.71;}}
+  const char *s1; // CHECK-NEXT: {{^  int x;}}
+  const char *s2; // CHECK-NEXT: {{^  double pi = 3.14;}}
+  double pi = 3.14;   // CHECK-NEXT: {{^  const char \*s2;}}
+  double e = 2.71;// CHECK-NEXT: {{^  const char \*s1;}}
+};
+
+Foo::Foo():
+  x(12),  // CHECK:  {{^  x\(12\)}},
+  s1("abc"),  // CHECK-NEXT: {{^  s2\("def"\)}},
+  s2("def")   // CHECK-NEXT: {{^  s1\("abc"\)}}
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %s -- | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK:  {{^  double z;}}
+  int y;// CHECK-NEXT: {{^  int w;}}
+  double z; // CHECK-NEXT: {{^  int y;}}
+  int w;// CHECK-NEXT: {{^  const int\* x}}
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { &x, 0, 1.29, 17 }; // CHECK: {{^  bar::Foo foo = { 1.29, 17, 0, &x };}} 
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-reorder-fields -record-name ::Foo -fields-order y,x %s -- | FileCheck %s
+
+struct Foo {
+  int x;// CHECK:  {{^  double y;}}
+  double y; // CHECK-NEXT: {{^  int x;}}
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK:  {{^  int x;}}
+  double y; // CHECK-NEXT: {{^  double y;}}
+};
+} // end namespace bar
+
+int main() {
+  bar::Foo foo = { 1, 1.7 }; // CHECK: {{^  bar::Foo foo = { 1, 1.7 };}}
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp
===
--- clang-reorder-fields/tool/ClangReorderFields.cpp
+++ clang-reorder-fields/tool/ClangReorderFields.cpp
@@ -0,0 +1,88 @@
+//===-- tools/extra/clang-reorder-fields/tool/ClangReorderFields.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the implementation of clang-reorder-fields tool
+///
+//===---

Re: [PATCH] D23944: Parsing MS pragma intrinsic

2016-08-30 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 69768.
agutowski added a comment.

Fixed typo


https://reviews.llvm.org/D23944

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/IdentifierTable.h
  include/clang/Parse/Parser.h
  lib/Parse/ParsePragma.cpp
  test/Preprocessor/pragma_microsoft.c

Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -161,6 +161,12 @@
   PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {}
 };
 
+struct PragmaMSIntrinsicHandler : public PragmaHandler {
+  PragmaMSIntrinsicHandler() : PragmaHandler("intrinsic") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+Token &FirstToken) override;
+};
+
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -229,6 +235,8 @@
 PP.AddPragmaHandler(MSSection.get());
 MSRuntimeChecks.reset(new PragmaMSRuntimeChecksHandler());
 PP.AddPragmaHandler(MSRuntimeChecks.get());
+MSIntrinsic.reset(new PragmaMSIntrinsicHandler());
+PP.AddPragmaHandler(MSIntrinsic.get());
   }
 
   OptimizeHandler.reset(new PragmaOptimizeHandler(Actions));
@@ -297,6 +305,8 @@
 MSSection.reset();
 PP.RemovePragmaHandler(MSRuntimeChecks.get());
 MSRuntimeChecks.reset();
+PP.RemovePragmaHandler(MSIntrinsic.get());
+MSIntrinsic.reset();
   }
 
   PP.RemovePragmaHandler("STDC", FPContractHandler.get());
@@ -2127,3 +2137,53 @@
   PP.EnterTokenStream(std::move(TokenArray), 1,
   /*DisableMacroExpansion=*/false);
 }
+
+/// \brief Handle the Microsoft \#pragma intrinsic extension.
+///
+/// The syntax is:
+/// \code
+///  #pragma intrinsic(memset)
+///  #pragma intrinsic(strlen, memcpy)
+/// \endcode
+///
+/// Pragma intrisic tells the compiler to use a builtin version of the
+/// function. Clang does it anyway, so the pragma doesn't really do anything.
+/// Anyway, we emit a warning if the function specified in \#pragma intrinsic
+/// isn't an intrinsic in clang and suggest to include intrin.h.
+void PragmaMSIntrinsicHandler::HandlePragma(Preprocessor &PP,
+PragmaIntroducerKind Introducer,
+Token &Tok) {
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::l_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
+<< "intrinsic";
+return;
+  }
+  PP.Lex(Tok);
+
+  bool SuggestIntrinH = !PP.isMacroDefined("__INTRIN_H");
+
+  while (Tok.is(tok::identifier)) {
+IdentifierInfo *II = Tok.getIdentifierInfo();
+if (!II->getBuiltinID())
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
+  << II << SuggestIntrinH;
+
+PP.Lex(Tok);
+if (Tok.isNot(tok::comma))
+  break;
+PP.Lex(Tok);
+  }
+
+  if (Tok.isNot(tok::r_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
+<< "intrinsic";
+return;
+  }
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::eod))
+PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
+<< "intrinsic";
+}
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -172,6 +172,7 @@
   std::unique_ptr MSCodeSeg;
   std::unique_ptr MSSection;
   std::unique_ptr MSRuntimeChecks;
+  std::unique_ptr MSIntrinsic;
   std::unique_ptr OptimizeHandler;
   std::unique_ptr LoopHintHandler;
   std::unique_ptr UnrollHintHandler;
Index: include/clang/Basic/IdentifierTable.h
===
--- include/clang/Basic/IdentifierTable.h
+++ include/clang/Basic/IdentifierTable.h
@@ -205,8 +205,7 @@
 
   /// \brief Return a value indicating whether this is a builtin function.
   ///
-  /// 0 is not-built-in.  1 is builtin-for-some-nonprimary-target.
-  /// 2+ are specific builtin functions.
+  /// 0 is not-built-in. 1+ are specific builtin functions.
   unsigned getBuiltinID() const {
 if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS)
   return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -911,6 +911,10 @@
 def warn_pragma_pack_malformed : Warning<
   "expected integer or identifier in '#pragma pack' - ignored">,
   InGroup;
+// - #pragma intrinsic
+def warn_pragma_intrinsic_builtin : Warning<
+  "%0 is not a recognized builtin%select{|; consider including  to access non-builtin intrinsics}1">,
+  InGroup;
 // - #pragma unused
 def warn_pragma_unused_expected_var : Warning<
   "expected '#pragma unused' argument to be a variable name">,
Index: test/Preprocessor/pragma_microsoft.c
==

[PATCH] D24059: NFC: refactor applyObjCProtocolQualifiers from SemaType.cpp to ASTContext so it can be shared.

2016-08-30 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: doug.gregor.
manmanren added a subscriber: cfe-commits.

To construct the canonical type of ObjCTypeParamType, we need to apply 
qualifiers on ObjCObjectPointerType. The updated applyObjCProtocolQualifiers 
handles this case by merging the protocol lists, constructing a new 
ObjCObjectType, then a new ObjCObjectPointerType.

https://reviews.llvm.org/D24059

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/Sema/SemaType.cpp

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1000,57 +1000,6 @@
   return S.Context.getObjCObjectType(type, finalTypeArgs, { }, false);
 }
 
-/// Apply Objective-C protocol qualifiers to the given type.
-static QualType applyObjCProtocolQualifiers(
-  Sema &S, SourceLocation loc, SourceRange range, QualType type,
-  ArrayRef protocols,
-  const SourceLocation *protocolLocs,
-  bool failOnError = false) {
-  ASTContext &ctx = S.Context;
-  if (const ObjCObjectType *objT = dyn_cast(type.getTypePtr())){
-// FIXME: Check for protocols to which the class type is already
-// known to conform.
-
-return ctx.getObjCObjectType(objT->getBaseType(),
- objT->getTypeArgsAsWritten(),
- protocols,
- objT->isKindOfTypeAsWritten());
-  }
-
-  if (type->isObjCObjectType()) {
-// Silently overwrite any existing protocol qualifiers.
-// TODO: determine whether that's the right thing to do.
-
-// FIXME: Check for protocols to which the class type is already
-// known to conform.
-return ctx.getObjCObjectType(type, { }, protocols, false);
-  }
-
-  // id
-  if (type->isObjCIdType()) {
-const ObjCObjectPointerType *objPtr = type->castAs();
-type = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, protocols,
- objPtr->isKindOfType());
-return ctx.getObjCObjectPointerType(type);
-  }
-
-  // Class
-  if (type->isObjCClassType()) {
-const ObjCObjectPointerType *objPtr = type->castAs();
-type = ctx.getObjCObjectType(ctx.ObjCBuiltinClassTy, { }, protocols,
- objPtr->isKindOfType());
-return ctx.getObjCObjectPointerType(type);
-  }
-
-  S.Diag(loc, diag::err_invalid_protocol_qualifiers)
-<< range;
-
-  if (failOnError)
-return QualType();
-
-  return type;
-}
-
 QualType Sema::BuildObjCObjectType(QualType BaseType,
SourceLocation Loc,
SourceLocation TypeArgsLAngleLoc,
@@ -1072,12 +1021,14 @@
   }
 
   if (!Protocols.empty()) {
-Result = applyObjCProtocolQualifiers(*this, Loc,
- SourceRange(ProtocolLAngleLoc,
- ProtocolRAngleLoc),
- Result, Protocols,
- ProtocolLocs.data(),
- FailOnError);
+bool HasError;
+Result = Context.applyObjCProtocolQualifiers(Result, Protocols,
+ HasError);
+if (HasError) {
+  Diag(Loc, diag::err_invalid_protocol_qualifiers)
+<< SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
+  if (FailOnError) Result = QualType();
+}
 if (FailOnError && Result.isNull())
   return QualType();
   }
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -3871,6 +3871,76 @@
   return QualType(T, 0);
 }
 
+/// Apply Objective-C protocol qualifiers to the given type.
+/// If this is for the canonical type of a type parameter, we can apply
+/// protocol qualifiers on the ObjCObjectPointerType.
+QualType
+ASTContext::applyObjCProtocolQualifiers(QualType type,
+  ArrayRef protocols, bool &hasError,
+  bool allowOnPointerType) const {
+  hasError = false;
+
+  // Apply protocol qualifiers to ObjCObjectPointerType.
+  if (allowOnPointerType) {
+if (const ObjCObjectPointerType *objPtr =
+dyn_cast(type.getTypePtr())) {
+  const ObjCObjectType *objT = objPtr->getObjectType();
+  // Merge protocol lists and construct ObjCObjectType.
+  SmallVector protocolsVec;
+  protocolsVec.append(objT->qual_begin(),
+  objT->qual_end());
+  protocolsVec.append(protocols.begin(), protocols.end());
+  ArrayRef protocols = protocolsVec;
+  type = getObjCObjectType(
+ objT->getBaseType(),
+ objT->getTypeArgsAsWritten(),
+ protocols,
+ objT->isKindOfTypeAsWritten());
+  return getObjCObjectPointerType(type);
+}
+  }
+
+  // Apply protocol qualifiers to

r280169 - Driver: use the canonical static library naming

2016-08-30 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Aug 30 17:10:27 2016
New Revision: 280169

URL: http://llvm.org/viewvc/llvm-project?rev=280169&view=rev
Log:
Driver: use the canonical static library naming

On Windows, static libraries are named lib.lib while import libraries are
named .lib.  Use the appropriate naming on itanium and msvc environments.
This is setup properly so that if a dynamic builtins is used on Windows, it
would do the right thing, although this is not currently wired through the
driver (i.e. there is no equivalent to -{shared,static}-gcc).

Modified:
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/test/Driver/arm-compiler-rt.c
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=280169&r1=280168&r2=280169&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Aug 30 17:10:27 2016
@@ -288,13 +288,13 @@ std::string ToolChain::getCompilerRT(con
  bool Shared) const {
   const llvm::Triple &TT = getTriple();
   const char *Env = TT.isAndroid() ? "-android" : "";
-  bool IsITANMSVCWindows =
+  bool IsWindowsIAMSVC =
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
-  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
+  const char *Prefix = (IsWindowsIAMSVC && Shared) ? "" : "lib";
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
-  : (IsITANMSVCWindows ? ".lib" : ".a");
+  : (IsWindowsIAMSVC ? ".lib" : ".a");
 
   SmallString<128> Path(getDriver().ResourceDir);
   StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS();

Modified: cfe/trunk/test/Driver/arm-compiler-rt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-compiler-rt.c?rev=280169&r1=280168&r2=280169&view=diff
==
--- cfe/trunk/test/Driver/arm-compiler-rt.c (original)
+++ cfe/trunk/test/Driver/arm-compiler-rt.c Tue Aug 30 17:10:27 2016
@@ -11,7 +11,7 @@
 // ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
 
 // RUN: %clang -target arm-windows-itanium -rtlib=compiler-rt -### %s 2>&1 | 
FileCheck %s -check-prefix ARM-WINDOWS
-// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins-arm.lib"
+// ARM-WINDOWS: "{{.*[/\\]}}libclang_rt.builtins-arm.lib"
 
 // RUN: %clang -target arm-linux-androideabi -rtlib=compiler-rt -### %s 2>&1 | 
FileCheck %s -check-prefix ARM-ANDROID
 // ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins-arm-android.a"

Modified: cfe/trunk/test/Driver/windows-cross.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-cross.c?rev=280169&r1=280168&r2=280169&view=diff
==
--- cfe/trunk/test/Driver/windows-cross.c (original)
+++ cfe/trunk/test/Driver/windows-cross.c Tue Aug 30 17:10:27 2016
@@ -6,27 +6,27 @@
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin 
-rtlib=compiler-rt -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-RTLIB
 
-// CHECK-RTLIB: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" 
"{{.*[\\/]}}clang_rt.builtins-arm.lib"
+// CHECK-RTLIB: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" 
"{{.*[\\/]}}libclang_rt.builtins-arm.lib"
 
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin 
-rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-C-LIBCXX
 
-// CHECK-C-LIBCXX: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "{{.*}}.o" "-lmsvcrt" 
"{{.*[\\/]}}clang_rt.builtins-arm.lib"
+// CHECK-C-LIBCXX: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.ob

Re: [PATCH] D23944: Parsing MS pragma intrinsic

2016-08-30 Thread Albert Gutowski via cfe-commits
agutowski updated this revision to Diff 69767.
agutowski added a comment.

Fixed checking if the function is an intrinsic. Updated getBuiltinID 
description.


https://reviews.llvm.org/D23944

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/IdentifierTable.h
  include/clang/Parse/Parser.h
  lib/Parse/ParsePragma.cpp
  test/Preprocessor/pragma_microsoft.c

Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -161,6 +161,12 @@
   PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {}
 };
 
+struct PragmaMSIntrinsicHandler : public PragmaHandler {
+  PragmaMSIntrinsicHandler() : PragmaHandler("intrinsic") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+Token &FirstToken) override;
+};
+
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -229,6 +235,8 @@
 PP.AddPragmaHandler(MSSection.get());
 MSRuntimeChecks.reset(new PragmaMSRuntimeChecksHandler());
 PP.AddPragmaHandler(MSRuntimeChecks.get());
+MSIntrinsic.reset(new PragmaMSIntrinsicHandler());
+PP.AddPragmaHandler(MSIntrinsic.get());
   }
 
   OptimizeHandler.reset(new PragmaOptimizeHandler(Actions));
@@ -297,6 +305,8 @@
 MSSection.reset();
 PP.RemovePragmaHandler(MSRuntimeChecks.get());
 MSRuntimeChecks.reset();
+PP.RemovePragmaHandler(MSIntrinsic.get());
+MSIntrinsic.reset();
   }
 
   PP.RemovePragmaHandler("STDC", FPContractHandler.get());
@@ -2127,3 +2137,53 @@
   PP.EnterTokenStream(std::move(TokenArray), 1,
   /*DisableMacroExpansion=*/false);
 }
+
+/// \brief Handle the Microsoft \#pragma intrinsic extension.
+///
+/// The syntax is:
+/// \code
+///  #pragma intrinsic(memset)
+///  #pragma intrinsic(strlen, memcpy)
+/// \endcode
+///
+/// Pragma intrisic tells the compiler to use a builtin version of the
+/// function. Clang does it anyway, so the pragma doesn't really do anything.
+/// Anyway, we emit a warning if the function specified in \#pragma intrinsic
+/// isn't an intrinsic in clang and suggest to include intrin.h.
+void PragmaMSIntrinsicHandler::HandlePragma(Preprocessor &PP,
+PragmaIntroducerKind Introducer,
+Token &Tok) {
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::l_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
+<< "intrinsic";
+return;
+  }
+  PP.Lex(Tok);
+
+  bool SuggestIntrinH = !PP.isMacroDefined("__INTRIN_H");
+
+  while (Tok.is(tok::identifier)) {
+IdentifierInfo *II = Tok.getIdentifierInfo();
+if (II->getBuiltinID())
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
+  << II << SuggestIntrinH;
+
+PP.Lex(Tok);
+if (Tok.isNot(tok::comma))
+  break;
+PP.Lex(Tok);
+  }
+
+  if (Tok.isNot(tok::r_paren)) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
+<< "intrinsic";
+return;
+  }
+  PP.Lex(Tok);
+
+  if (Tok.isNot(tok::eod))
+PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
+<< "intrinsic";
+}
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -172,6 +172,7 @@
   std::unique_ptr MSCodeSeg;
   std::unique_ptr MSSection;
   std::unique_ptr MSRuntimeChecks;
+  std::unique_ptr MSIntrinsic;
   std::unique_ptr OptimizeHandler;
   std::unique_ptr LoopHintHandler;
   std::unique_ptr UnrollHintHandler;
Index: include/clang/Basic/IdentifierTable.h
===
--- include/clang/Basic/IdentifierTable.h
+++ include/clang/Basic/IdentifierTable.h
@@ -205,8 +205,7 @@
 
   /// \brief Return a value indicating whether this is a builtin function.
   ///
-  /// 0 is not-built-in.  1 is builtin-for-some-nonprimary-target.
-  /// 2+ are specific builtin functions.
+  /// 0 is not-built-in. 1+ are specific builtin functions.
   unsigned getBuiltinID() const {
 if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS)
   return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -911,6 +911,10 @@
 def warn_pragma_pack_malformed : Warning<
   "expected integer or identifier in '#pragma pack' - ignored">,
   InGroup;
+// - #pragma intrinsic
+def warn_pragma_intrinsic_builtin : Warning<
+  "%0 is not a recognized builtin%select{|; consider including  to access non-builtin intrinsics}1">,
+  InGroup;
 // - #pragma unused
 def warn_pragma_unused_expected_var : Warning<
   "expected '#pragma unused' argument to be a variable name">,
Index: test/Preprocessor/pragma_microso

Re: [PATCH] D23080: ObjC: Use a new type for ObjC type parameter (patch 3 out of 3)

2016-08-30 Thread Manman Ren via cfe-commits
manmanren updated the summary for this revision.
manmanren updated this revision to Diff 69765.
manmanren added a comment.

This patch is now much simpler with the updated version of 
https://reviews.llvm.org/D23079.


https://reviews.llvm.org/D23080

Files:
  lib/AST/ASTContext.cpp
  lib/AST/DeclObjC.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaType.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  test/SemaObjC/kindof.m
  test/SemaObjC/parameterized_classes_subst.m

Index: test/SemaObjC/parameterized_classes_subst.m
===
--- test/SemaObjC/parameterized_classes_subst.m
+++ test/SemaObjC/parameterized_classes_subst.m
@@ -426,3 +426,36 @@
 // warning about likely protocol/class name typos.
 // --
 typedef NSArray ArrayOfNSObjectWarning; // expected-warning{{parameterized class 'NSArray' already conforms to the protocols listed; did you forget a '*'?}}
+
+// rdar://25060179
+@interface MyMutableDictionary : NSObject
+- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType )key; // expected-note{{passing argument to parameter 'obj' here}} \
+// expected-note{{passing argument to parameter 'key' here}}
+@end
+
+void bar(MyMutableDictionary *stringsByString,
+ NSNumber *n1, NSNumber *n2) {
+  // We warn here when the key types do not match.
+  stringsByString[n1] = n2; // expected-warning{{incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'}} \
+// expected-warning{{incompatible pointer types sending 'NSNumber *' to parameter of type 'NSString *'}}
+}
+
+@interface MyTest : NSObject 
+- (V)test:(K)key;
+- (V)test2:(K)key; // expected-note{{previous definition is here}}
+- (void)mapUsingBlock:(id (^)(V))block;
+- (void)mapUsingBlock2:(id (^)(V))block; // expected-note{{previous definition is here}}
+@end
+
+@implementation MyTest
+- (id)test:(id)key {
+  return key;
+}
+- (int)test2:(id)key{ // expected-warning{{conflicting return type in implementation}}
+  return 0;
+}
+- (void)mapUsingBlock:(id (^)(id))block {
+}
+- (void)mapUsingBlock2:(id)block { // expected-warning{{conflicting parameter types in implementation}}
+}
+@end
Index: test/SemaObjC/kindof.m
===
--- test/SemaObjC/kindof.m
+++ test/SemaObjC/kindof.m
@@ -385,7 +385,7 @@
 @end
 
 @interface NSGeneric : NSObject
-- (void)test:(__kindof ObjectType)T;
+- (void)test:(__kindof ObjectType)T; // expected-note{{passing argument to parameter 'T' here}}
 - (void)mapUsingBlock:(id (^)(__kindof ObjectType))block;
 @end
 @implementation NSGeneric
@@ -395,6 +395,14 @@
 }
 @end
 
+void testGeneric(NSGeneric *generic) {
+  NSObject *NSObject_obj;
+  // Assign from NSObject_obj to __kindof NSString*.
+  [generic test:NSObject_obj]; // expected-warning{{incompatible pointer types sending 'NSObject *' to parameter of type '__kindof NSString *'}}
+  NSString *NSString_str;
+  [generic test:NSString_str];
+}
+
 // Check that clang doesn't crash when a type parameter is illegal.
 @interface Array1 : NSObject
 @end
Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -626,7 +626,7 @@
   : public RecursiveASTVisitor {
   public:
 IsObjCTypeParamDependentTypeVisitor() : Result(false) {}
-bool VisitTypedefType(const TypedefType *Type) {
+bool VisitObjCTypeParamType(const ObjCTypeParamType *Type) {
   if (isa(Type->getDecl())) {
 Result = true;
 return false;
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1157,6 +1157,20 @@
 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
   }
 
+  if (auto OTPTL = ResultTL.getAs()) {
+// Protocol qualifier information.
+if (OTPTL.getNumProtocols() > 0) {
+  assert(OTPTL.getNumProtocols() == Protocols.size());
+  OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
+  OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
+  for (unsigned i = 0, n = Protocols.size(); i != n; ++i)
+OTPTL.setProtocolLoc(i, ProtocolLocs[i]);
+}
+
+// We're done. Return the completed type to the parser.
+return CreateParsedType(Result, ResultTInfo);
+  }
+
   auto ObjCObjectTL = ResultTL.castAs();
 
   // Type argument information.
@@ -5875,7 +5889,6 @@
   // For the context-sensitive keywords/Objective-C property
   // attributes, require that the type be a single-level pointer.
   if (isContextSensitive) {
-// Make sure that the pointee isn't itself a pointer type.
 QualType pointeeType = desugared->getPointeeType();
 if (pointeeType->isAnyPointerType() ||
 pointeeType->isObjC

Re: [PATCH] D23079: ObjC: Use a new type for ObjC type parameter (patch 2 out of 3)

2016-08-30 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 69764.
manmanren added a comment.

Address Doug's comment. ObjCTypeParamType is a non-canonical type now, it is 
canonicalized to the underlying type with protocol qualifiers.


https://reviews.llvm.org/D23079

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/AST/TypeNodes.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1534,6 +1534,18 @@
   return Visit(MakeCursorObjCClassRef(TL.getIFaceDecl(), TL.getNameLoc(), TU));
 }
 
+bool CursorVisitor::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (Visit(MakeCursorTypeRef(TL.getDecl(), TL.getLocStart(), TU)))
+return true;
+  for (unsigned I = 0, N = TL.getNumProtocols(); I != N; ++I) {
+if (Visit(MakeCursorObjCProtocolRef(TL.getProtocol(I), TL.getProtocolLoc(I),
+TU)))
+  return true;
+  }
+
+  return false;
+}
+
 bool CursorVisitor::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
   if (TL.hasBaseTypeAsWritten() && Visit(TL.getBaseLoc()))
 return true;
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -450,6 +450,14 @@
   Code = TYPE_OBJC_INTERFACE;
 }
 
+void ASTTypeWriter::VisitObjCTypeParamType(const ObjCTypeParamType *T) {
+  Record.AddDeclRef(T->getDecl());
+  Record.push_back(T->getNumProtocols());
+  for (const auto *I : T->quals())
+Record.AddDeclRef(I);
+  Code = TYPE_OBJC_TYPE_PARAM;
+}
+
 void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
   Record.AddTypeRef(T->getBaseType());
   Record.push_back(T->getTypeArgsAsWritten().size());
@@ -587,6 +595,14 @@
 void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   Record.AddSourceLocation(TL.getNameLoc());
 }
+void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (TL.getNumProtocols()) {
+Record.AddSourceLocation(TL.getProtocolLAngleLoc());
+Record.AddSourceLocation(TL.getProtocolRAngleLoc());
+  }
+  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+Record.AddSourceLocation(TL.getProtocolLoc(i));
+}
 void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   Record.AddSourceLocation(TL.getTypeofLoc());
   Record.AddSourceLocation(TL.getLParenLoc());
@@ -1066,6 +1082,7 @@
   RECORD(TYPE_ATOMIC);
   RECORD(TYPE_DECAYED);
   RECORD(TYPE_ADJUSTED);
+  RECORD(TYPE_OBJC_TYPE_PARAM);
   RECORD(LOCAL_REDECLARATIONS);
   RECORD(DECL_TYPEDEF);
   RECORD(DECL_TYPEALIAS);
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5546,6 +5546,16 @@
 return Context.getObjCInterfaceType(ItfD->getCanonicalDecl());
   }
 
+  case TYPE_OBJC_TYPE_PARAM: {
+unsigned Idx = 0;
+ObjCTypeParamDecl *Decl
+  = ReadDeclAs(*Loc.F, Record, Idx);
+unsigned NumProtos = Record[Idx++];
+SmallVector Protos;
+for (unsigned I = 0; I != NumProtos; ++I)
+  Protos.push_back(ReadDeclAs(*Loc.F, Record, Idx));
+return Context.getObjCTypeParamType(Decl, Protos);
+  }
   case TYPE_OBJC_OBJECT: {
 unsigned Idx = 0;
 QualType Base = readType(*Loc.F, Record, Idx);
@@ -5944,6 +5954,15 @@
 void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
   TL.setNameLoc(ReadSourceLocation(Record, Idx));
 }
+void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+  if (TL.getNumProtocols()) {
+TL.setProtocolLAngleLoc(ReadSourceLocation(Record, Idx));
+TL.setProtocolRAngleLoc(ReadSourceLocation(Record, Idx));
+  }
+  for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+TL.setProtocolLoc(i, ReadSourceLocation(Record, Idx));
+}
+
 void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
   TL.setHasBaseTypeAsWritten(Record[Idx++]);
   TL.setTypeArgsLAngleLoc(ReadSourceLocation(Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -699,6 +699,12 @@
   QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
 SourceLocation Sigil);
 
+  QualType Rebui

Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: clang-reorder-fields/ReorderFieldsAction.cpp:178
@@ +177,3 @@
+const InitListExpr *InitListEx, ArrayRef NewFieldsOrder,
+const ASTContext &Context,
+std::map &Replacements) {

alexshap wrote:
> yeah, i am aware of it. In general - yes, you are right.
> But to me it seems that for now it would be better to leave it as is (don't 
> drop all the other replacements because of this one case - now we write a 
> message about this issue to llvm::errs()).
> The other options don't look very good to me (or at least better) so decided 
> not to make things complicated (for now). Probably i need to provide more 
> context / explanations. Right now in my code there are two places where we 
> return true/false to signal about an issue and also write a message to 
> llvm::errs(). The first one is reorderFieldsInDefinition and the second one 
> is  reorderFieldsInInitListExpr. The first seems to be critical (if we are 
> not able to edit the definition doing anything else doesn't make sense - now 
> it works this way - so we should be good), the second 
> (reorderFieldsInInitListExpr) doesn't seem to be so critical (partial 
> initialization of an aggregate), so i would not like to drop all the other 
> replacements because of it. Okay, that was one part of the story. The other 
> part of the story: 
> A.
>void HandleTranslationUnit(ASTContext &Context) override
>  - it doesn't return anything (so i can not propagate the return code) (to be 
> honest i can, but not sure if those changes are really worth doing (taking 
> into account the context i described above))
> B.
>http://clang.llvm.org/doxygen/CompilerInstance_8cpp_source.html#l00871
>line 871  Act.Execute(); (return value is ignored)
> -- but this seems to be beyond the scope of my diff, and as i said above - 
> doing smth more complicated only for partial initialization (which is now not 
> supported by this tool anyway) - not sure if it's worth doing right now.
If you don't reorder a partial initializer then I think it is quite likely that 
the resulting code doesn't compile or, worse, compiles but has incorrect 
behavior. I don't think this is any better or worse than not reordering fields 
across different access specifiers.

Also, I don't understand what the problem is. Just create separate local 
variable for Replacements and only copy to the class member if everything is 
successful. Or clear Replacements if something goes wrong. Am I missing 
something?


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23944: Parsing MS pragma intrinsic

2016-08-30 Thread Reid Kleckner via cfe-commits
rnk added a comment.

One buglet, otherwise looks good.



Comment at: lib/Parse/ParsePragma.cpp:2169
@@ +2168,3 @@
+IdentifierInfo *II = Tok.getIdentifierInfo();
+if (II->getBuiltinID() < 2)
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)

This doesn't seem like the right test. I think '1' is a valid builtin. This 
should probably be != 0. `__builtin_atan2` looks like it has builtin id 1, and 
you can use that to test.


https://reviews.llvm.org/D23944



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


[PATCH] D24054: Do not validate pch when -fno-validate-pch is set

2016-08-30 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rsmith, Anastasia.
yaxunl added a subscriber: cfe-commits.

There is a bug causing pch to be validated even though -fno-validate-pch is 
set. This patch fixes it.

https://reviews.llvm.org/D24054

Files:
  lib/Serialization/ASTReader.cpp

Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -8708,7 +8708,8 @@
   bool AllowConfigurationMismatch, bool ValidateSystemInputs,
   bool UseGlobalIndex,
   std::unique_ptr ReadTimer)
-: Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
+: Listener(DisableValidation ? nullptr : new PCHValidator(PP, *this)),
+  DeserializationListener(nullptr),
   OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
   FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
   Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -8708,7 +8708,8 @@
   bool AllowConfigurationMismatch, bool ValidateSystemInputs,
   bool UseGlobalIndex,
   std::unique_ptr ReadTimer)
-: Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
+: Listener(DisableValidation ? nullptr : new PCHValidator(PP, *this)),
+  DeserializationListener(nullptr),
   OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
   FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
   Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Address all comments except making the attribute C++ only.


https://reviews.llvm.org/D23385

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

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

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

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


Comment at: include/clang/Basic/AttrDocs.td:836
@@ +835,3 @@
+  let Content = [{
+This attribute specifies that the variable to which it is attached is intended
+to have a `constant initializer 
`_

aaron.ballman wrote:
> I don't think I ever heard whether this attribute was usable in C or not. I 
> suspect it's not particularly needed in C. If that's true, we should state 
> that in the documentation, and consider making the attribute a C++-only 
> attribute?
I think it would be somewhat useful in C.  In particular if you have globals 
initialized from values you don't own. Example:

```
#include 
ATTR int x = y; // Will diagnose if  becomes 'y' is a non-constant expression.
```

However the current implementation only handles C++ and I'm satisfied with 
that. I'll mark the attribute as C++ only and document that change.


https://reviews.llvm.org/D23385



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


Re: r280133 - PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) input types.

2016-08-30 Thread Renato Golin via cfe-commits
On 30 August 2016 at 19:55, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Tue Aug 30 13:55:16 2016
> New Revision: 280133
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280133&view=rev
> Log:
> PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) 
> input types.
>
> Modified:
> cfe/trunk/include/clang/Driver/Types.h
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/lib/Driver/Types.cpp
> cfe/trunk/test/Driver/cl-pch.c

Hi Richard,

This breakage was hidden by Duncan's build breakage:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/11172

Just "Exit code 254"

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/11172/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Acl-pch.c

Can you have a look, pls?

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


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

2016-08-30 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Some minor nits; @rsmith may have more substantial comments.



Comment at: lib/Sema/SemaChecking.cpp:11039
@@ -11036,2 +11038,3 @@
 std::function Action) {
+  // return;
   const auto *ME = dyn_cast(E);

Spurious comment.


Comment at: lib/Sema/SemaChecking.cpp:11049
@@ -11044,5 +11048,3 @@
 ValueDecl *MD = ME->getMemberDecl();
-bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
-if (ByteAligned) // Attribute packed does not have any effect.
-  break;
+auto AlignField = Context.getTypeAlignInChars(MD->getType());
 

Please don't use auto here as the type is not spelled out in the initialization.


Comment at: lib/Sema/SemaChecking.cpp:11053
@@ +11052,3 @@
+if (RD->hasAttr() || MD->hasAttr()) {
+  auto AlignRecord = Context.getTypeAlignInChars(BaseType);
+  if ((RequiredAlignment > AlignRecord) ||

Don't use auto here either.


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: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap marked 5 inline comments as done.
alexshap added a comment.

Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


r280165 - clang-format: Correctly calculate affected ranges when sorting #includes.

2016-08-30 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Aug 30 16:33:41 2016
New Revision: 280165

URL: http://llvm.org/viewvc/llvm-project?rev=280165&view=rev
Log:
clang-format: Correctly calculate affected ranges when sorting #includes.

affectedRanges takes a start and an end offset, not offset and length.

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/SortIncludesTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=280165&r1=280164&r2=280165&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Aug 30 16:33:41 2016
@@ -1263,10 +1263,10 @@ static void sortCppIncludes(const Format
 ArrayRef Ranges, StringRef 
FileName,
 tooling::Replacements &Replaces, unsigned *Cursor) 
{
   unsigned IncludesBeginOffset = Includes.front().Offset;
-  unsigned IncludesBlockSize = Includes.back().Offset +
-   Includes.back().Text.size() -
-   IncludesBeginOffset;
-  if (!affectsRange(Ranges, IncludesBeginOffset, IncludesBlockSize))
+  unsigned IncludesEndOffset =
+  Includes.back().Offset + Includes.back().Text.size();
+  unsigned IncludesBlockSize = IncludesEndOffset - IncludesBeginOffset;
+  if (!affectsRange(Ranges, IncludesBeginOffset, IncludesEndOffset))
 return;
   SmallVector Indices;
   for (unsigned i = 0, e = Includes.size(); i != e; ++i)

Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=280165&r1=280164&r2=280165&view=diff
==
--- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original)
+++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Tue Aug 30 16:33:41 2016
@@ -24,8 +24,8 @@ protected:
 return std::vector(1, tooling::Range(0, Code.size()));
   }
 
-  std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
-auto Ranges = GetCodeRange(Code);
+  std::string sort(StringRef Code, std::vector Ranges,
+   StringRef FileName = "input.cc") {
 auto Replaces = sortIncludes(Style, Code, Ranges, FileName);
 Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges);
 auto Sorted = applyAllReplacements(Code, Replaces);
@@ -36,6 +36,10 @@ protected:
 return *Result;
   }
 
+  std::string sort(StringRef Code, StringRef FileName = "input.cpp") {
+return sort(Code, GetCodeRange(Code), FileName);
+  }
+
   unsigned newCursor(llvm::StringRef Code, unsigned Cursor) {
 sortIncludes(Style, Code, GetCodeRange(Code), "input.cpp", &Cursor);
 return Cursor;
@@ -52,6 +56,14 @@ TEST_F(SortIncludesTest, BasicSorting) {
 sort("#include \"a.h\"\n"
  "#include \"c.h\"\n"
  "#include \"b.h\"\n"));
+
+  EXPECT_EQ("// comment\n"
+"#include \n"
+"#include \n",
+sort("// comment\n"
+ "#include \n"
+ "#include \n",
+ {tooling::Range(25, 1)}));
 }
 
 TEST_F(SortIncludesTest, NoReplacementsForValidIncludes) {


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


Re: [PATCH] D23905: [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.

2016-08-30 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Thanks Richard. r280159


https://reviews.llvm.org/D23905



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


Re: [PATCH] D23325: [WIP] Binding of references to packed fields

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


Comment at: include/clang/AST/Expr.h:436
@@ -434,1 +435,3 @@
 
+  /// \brief Returns true if this expression is a gl-value that
+  /// potentially refers to a packed-field. Here packed-field means

s/gl-value/glvalue



Comment at: include/clang/AST/Expr.h:438
@@ +437,3 @@
+  /// potentially refers to a packed-field. Here packed-field means
+  /// that the field has got its alignment effectively reduced.
+  ///

"that the field has an effectively-reduced alignment"


Comment at: include/clang/AST/Expr.h:440
@@ +439,3 @@
+  ///
+  /// Likewise bitfields, we model gl-values referring to packed-fields as
+  /// an aspect of the value-kind type system.

Like bitfields
glvalues


Comment at: include/clang/AST/Stmt.h:135
@@ -134,3 +134,3 @@
   };
-  enum { NumExprBits = 16 };
+  enum { NumExprBits = 17 };
 

This is a bit unfortunate (not that I see a way around it)...


Comment at: lib/AST/ASTDumper.cpp:1878
@@ +1877,3 @@
+case OK_PackedField:
+  OS << " packfield";
+  break;

packedfield instead?


Comment at: lib/AST/Decl.cpp:37
@@ -36,1 +36,3 @@
 
+#include 
+

This should be removed.


Comment at: lib/Sema/SemaExprMember.cpp:1779
@@ +1778,3 @@
+  if (VK != VK_RValue)
+  {
+if (Field->isBitField())

Formatting of the brace is incorrect.


Comment at: lib/Sema/SemaInit.cpp:4188
@@ +4187,3 @@
+Initializer->getType()->getAsCXXRecordDecl()) {
+  auto Record = Initializer->getType()->getAsCXXRecordDecl();
+  /*

I don't know whether you should use `auto` here or not, the type is kinda-sorta 
spelled out in the initialization. At the very least, this should be `const 
auto *`.


https://reviews.llvm.org/D23325



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


r280159 - [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.

2016-08-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Aug 30 16:25:42 2016
New Revision: 280159

URL: http://llvm.org/viewvc/llvm-project?rev=280159&view=rev
Log:
[Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.

This adds support for modules that require (no-)gnu-inline-asm
environment, such as the compiler builtin cpuid submodule.

This is the gnu-inline-asm variant of https://reviews.llvm.org/D23871

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

rdar://problem/26931199

Added:
cfe/trunk/test/Modules/Inputs/GNUAsm/
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/

cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h

cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map
cfe/trunk/test/Modules/requires-gnuinlineasm.m
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Headers/module.modulemap

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=280159&r1=280158&r2=280159&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Tue Aug 30 16:25:42 2016
@@ -413,6 +413,9 @@ cplusplus
 cplusplus11
   C++11 support is available.
 
+gnuinlineasm
+  GNU inline ASM is available.
+
 objc
   Objective-C support is available.
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=280159&r1=280158&r2=280159&view=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Tue Aug 30 16:25:42 2016
@@ -64,6 +64,7 @@ static bool hasFeature(StringRef Feature
 .Case("blocks", LangOpts.Blocks)
 .Case("cplusplus", LangOpts.CPlusPlus)
 .Case("cplusplus11", LangOpts.CPlusPlus11)
+.Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC1)
 .Case("objc_arc", LangOpts.ObjCAutoRefCount)
 .Case("opencl", LangOpts.OpenCL)

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=280159&r1=280158&r2=280159&view=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Tue Aug 30 16:25:42 2016
@@ -68,6 +68,7 @@ module _Builtin_intrinsics [system] [ext
 }
 
 explicit module cpuid {
+  requires gnuinlineasm
   header "cpuid.h"
 }
 

Added: 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h?rev=280159&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/NeedsGNUInlineAsm.h
 Tue Aug 30 16:25:42 2016
@@ -0,0 +1 @@
+// NeedsGNUInlineAsm.h

Added: 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h?rev=280159&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/Headers/asm.h 
Tue Aug 30 16:25:42 2016
@@ -0,0 +1 @@
+__asm("foo");

Added: 
cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map?rev=280159&view=auto
==
--- cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map 
(added)
+++ cfe/trunk/test/Modules/Inputs/GNUAsm/NeedsGNUInlineAsm.framework/module.map 
Tue Aug 30 16:25:42 2016
@@ -0,0 +1,8 @@
+framework module NeedsGNUInlineAsm {
+  header "NeedsGNUInlineAsm.h"
+
+  explicit module Asm {
+requires gnuinlineasm
+header "asm.h"
+  }
+}

Added: cfe/trunk/test/Modules/requires-gnuinlineasm.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires-gnuinlineasm.m?rev=280159&view=auto
===

r280157 - Fix memory leak by storing returned pointer in std::unique_ptr

2016-08-30 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Aug 30 16:12:48 2016
New Revision: 280157

URL: http://llvm.org/viewvc/llvm-project?rev=280157&view=rev
Log:
Fix memory leak by storing returned pointer in std::unique_ptr

Modified:
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=280157&r1=280156&r2=280157&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Tue Aug 30 16:12:48 2016
@@ -244,10 +244,9 @@ bool ToolInvocation::run() {
   const char *const BinaryName = Argv[0];
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   unsigned MissingArgIndex, MissingArgCount;
-  llvm::opt::InputArgList ParsedArgs =
-  driver::createDriverOptTable()->ParseArgs(
-  ArrayRef(Argv).slice(1), MissingArgIndex,
-  MissingArgCount);
+  std::unique_ptr Opts(driver::createDriverOptTable());
+  llvm::opt::InputArgList ParsedArgs = Opts->ParseArgs(
+  ArrayRef(Argv).slice(1), MissingArgIndex, MissingArgCount);
   ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);


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


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Filipe Cabecinhas via cfe-commits
Haha, the joke is on me. I had the opposite opinion two years ago (I
guess by virtue of working on the sanitizers for a while, I've come to
see them as default libs?).

Making the behavior more consistent is good, and the r218541
discussion (+220455) makes me think your patch is good. We end up
having *some* weird behavior when mixing this type of flags. But I
think Bruno's suggestion to warn (I think maybe documenting it is
enough, though) might be good.

Thank you,

 Filipe


On Tue, Aug 30, 2016 at 9:15 PM, Bruno Cardoso Lopes via cfe-commits
 wrote:
> bruno added a subscriber: bruno.
> bruno added a comment.
>
> Regardless of the way we decide to go with this, it would be nice if a driver 
> level warning is used to tell users about any  non-obvious assumed behavior 
> when these flags are used together.
>
>
> https://reviews.llvm.org/D24048
>
>
>
> ___
> 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] D23767: DebugInfo: use llvm::DINode::DIFlags type for debug info flags

2016-08-30 Thread Victor via cfe-commits
vleschuk retitled this revision from "DebugInfo: use llvm::DIFlagsUnderlying 
type for debug info flags" to "DebugInfo: use llvm::DINode::DIFlags type for 
debug info flags".
vleschuk updated the summary for this revision.
vleschuk updated this revision to Diff 69755.
vleschuk added a comment.

Switched to include/llvm/ADT/BitmaskEnum for debug info flags.


https://reviews.llvm.org/D23767

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -517,7 +517,7 @@
 StringRef &Name, StringRef &LinkageName,
 llvm::DIScope *&FDContext,
 llvm::DINodeArray &TParamsArray,
-unsigned &Flags);
+llvm::DINode::DIFlags &Flags);
 
   /// Collect various properties of a VarDecl.
   void collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -497,12 +497,12 @@
 
 ObjTy =
 DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(),
-  0, 0, 0, 0, nullptr, llvm::DINodeArray());
+  0, 0, 0, llvm::DINode::FlagZero, nullptr, llvm::DINodeArray());
 
 DBuilder.replaceArrays(
 ObjTy,
 DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
-ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy)));
+ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, llvm::DINode::FlagZero, ISATy)));
 return ObjTy;
   }
   case BuiltinType::ObjCSel: {
@@ -787,7 +787,7 @@
   Elements = DBuilder.getOrCreateArray(EltTys);
   EltTys.clear();
 
-  unsigned Flags = llvm::DINode::FlagAppleBlock;
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
   unsigned LineNo = 0;
 
   auto *EltTy =
@@ -813,7 +813,7 @@
   FieldAlign = CGM.getContext().getTypeAlign(Ty);
   EltTys.push_back(DBuilder.createMemberType(Unit, "__descriptor", nullptr, LineNo,
  FieldSize, FieldAlign, FieldOffset,
- 0, DescTy));
+ llvm::DINode::FlagZero, DescTy));
 
   FieldOffset += FieldSize;
   Elements = DBuilder.getOrCreateArray(EltTys);
@@ -917,22 +917,22 @@
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  return DBuilder.createSubroutineType(EltTypeArray, 0,
+  return DBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero,
getDwarfCC(Ty->getCallConv()));
 }
 
 /// Convert an AccessSpecifier into the corresponding DINode flag.
 /// As an optimization, return 0 if the access specifier equals the
 /// default for the containing type.
-static unsigned getAccessFlag(AccessSpecifier Access, const RecordDecl *RD) {
+static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access, const RecordDecl *RD) {
   AccessSpecifier Default = clang::AS_none;
   if (RD && RD->isClass())
 Default = clang::AS_private;
   else if (RD && (RD->isStruct() || RD->isUnion()))
 Default = clang::AS_public;
 
   if (Access == Default)
-return 0;
+return llvm::DINode::FlagZero;
 
   switch (Access) {
   case clang::AS_private:
@@ -942,7 +942,7 @@
   case clang::AS_public:
 return llvm::DINode::FlagPublic;
   case clang::AS_none:
-return 0;
+return llvm::DINode::FlagZero;
   }
   llvm_unreachable("unexpected access enumerator");
 }
@@ -968,7 +968,7 @@
   uint64_t StorageOffsetInBits =
   CGM.getContext().toBits(BitFieldInfo.StorageOffset);
   uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset;
-  unsigned Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
+  llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
   return DBuilder.createBitFieldMemberType(
   RecordTy, Name, File, Line, SizeInBits, AlignInBits, OffsetInBits,
   StorageOffsetInBits, Flags, DebugType);
@@ -993,7 +993,7 @@
 AlignInBits = TI.Align;
   }
 
-  unsigned flags = getAccessFlag(AS, RD);
+  llvm::DINode::DIFlags flags = getAccessFlag(AS, RD);
   return DBuilder.createMemberType(scope, name, file, line, SizeInBits,
AlignInBits, offsetInBits, flags, debugType);
 }
@@ -1060,7 +1060,7 @@
 }
   }
 
-  unsigned Flags = getAccessFlag(Var->getAccess(), RD);
+  llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
   llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
   RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
   StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
@@ -1203,7 +1203,7 @@
 
   llvm::DITypeRefArray EltTypeAr

Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


Comment at: clang-reorder-fields/ReorderFieldsAction.cpp:83
@@ +82,3 @@
+static void
+addReplacement(SourceRange Old, SourceRange New, const ASTContext &Context,
+   std::map &Replacements) {

khm, it Replaces Old by New, not vice versa - so it's not a swap.
(and semantically we are not doing swaps either, but we extract the source code 
from some places and insert it into some other places) 


Comment at: clang-reorder-fields/ReorderFieldsAction.cpp:178
@@ +177,3 @@
+const InitListExpr *InitListEx, ArrayRef NewFieldsOrder,
+const ASTContext &Context,
+std::map &Replacements) {

yeah, i am aware of it. In general - yes, you are right.
But to me it seems that for now it would be better to leave it as is (don't 
drop all the other replacements because of this one case - now we write a 
message about this issue to llvm::errs()).
The other options don't look very good to me (or at least better) so decided 
not to make things complicated (for now). Probably i need to provide more 
context / explanations. Right now in my code there are two places where we 
return true/false to signal about an issue and also write a message to 
llvm::errs(). The first one is reorderFieldsInDefinition and the second one is  
reorderFieldsInInitListExpr. The first seems to be critical (if we are not able 
to edit the definition doing anything else doesn't make sense - now it works 
this way - so we should be good), the second (reorderFieldsInInitListExpr) 
doesn't seem to be so critical (partial initialization of an aggregate), so i 
would not like to drop all the other replacements because of it. Okay, that was 
one part of the story. The other part of the story: 
A.
   void HandleTranslationUnit(ASTContext &Context) override
 - it doesn't return anything (so i can not propagate the return code) (to be 
honest i can, but not sure if those changes are really worth doing (taking into 
account the context i described above))
B.
   http://clang.llvm.org/doxygen/CompilerInstance_8cpp_source.html#l00871
   line 871  Act.Execute(); (return value is ignored)
-- but this seems to be beyond the scope of my diff, and as i said above - 
doing smth more complicated only for partial initialization (which is now not 
supported by this tool anyway) - not sure if it's worth doing right now.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23895: [ms] Add support for parsing uuid as a MS attribute

2016-08-30 Thread Nico Weber via cfe-commits
thakis marked 2 inline comments as done.
thakis added a comment.

(Just wanted to ask if I'm missing something about these three bullets. I do 
need to make a few other changes: More tests, parsing for uuid(1-2-3) without 
quotes + tests, and I also want to add a deprecation warning with a fixit, 
given that msvs does that too)


https://reviews.llvm.org/D23895



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


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

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


Comment at: include/clang/Basic/AttrDocs.td:836
@@ +835,3 @@
+  let Content = [{
+This attribute specifies that the variable to which it is attached is intended
+to have a `constant initializer 
`_

I don't think I ever heard whether this attribute was usable in C or not. I 
suspect it's not particularly needed in C. If that's true, we should state that 
in the documentation, and consider making the attribute a C++-only attribute?


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE 
-std=c++03 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -DTEST_ONE 
-std=c++11 %s

Can you run this file through clang-format?


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:7-9
@@ +6,5 @@
+
+#if !__has_feature(cxx_static_assert)
+#define static_assert(b_, m_) _Static_assert(b_, m_)
+#endif
+

This doesn't appear to be needed by the test.


Comment at: test/SemaCXX/attr-require-constant-initialization.cpp:11
@@ +10,3 @@
+
+#define ATTR __attribute__((require_constant_initialization)) // expected-note 
0+ {{expanded from macro}}
+

Hah, I've not seen `0+` before in a verify comment, that's a neat trick!


https://reviews.llvm.org/D23385



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


Re: [PATCH] D23852: [SemaObjC] Fix crash while parsing type arguments and protocols

2016-08-30 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

In https://reviews.llvm.org/D23852#525291, @doug.gregor wrote:

> This will work, but it's *really* unfortunate to put tentative parsing into 
> this code path because tentative parsing is far from free, and specialized 
> Objective-C types are getting pretty common in Objective-C headers. Why can't 
> the callers be taught to handle EOF and bail out?


The unfortunate part of that is it makes all of the callers fragile -- we have 
to sprinkle "are we at EOF now" checks all over, or risk running into the same 
problem later. We don't typically do that (there are only 7 eof checks in the 
parser currently, this adds 6 more). I don't know which option is worse.


https://reviews.llvm.org/D23852



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


Re: [PATCH] D24042: [test] Add libLTO as a clang test dependency on Darwin

2016-08-30 Thread Vedant Kumar via cfe-commits
Done in r280149 (revert this commit) and r280150 (use fake libLTO.dylib).

thanks,
vedant

> On Aug 30, 2016, at 1:12 PM, Mehdi Amini  wrote:
> 
> Alternatively, since you only need the presence of a file named libLTO for 
> the driver to do its magic, test can create an empty file named libLTO.dylib 
> and use the  -ccc-install-dir to make sure the right flag is passed.
> 
>> On Aug 30, 2016, at 10:40 AM, Vedant Kumar  wrote:
>> 
>> vsk created this revision.
>> vsk added a reviewer: bruno.
>> vsk added a subscriber: cfe-commits.
>> Herald added a subscriber: mehdi_amini.
>> 
>> Running 'check-clang' on a stock checkout of llvm+clang doesn't work on 
>> Darwin, because test/Driver/darwin-ld-lto.c can't find libLTO.dylib. Add 
>> libLTO as a clang test dependency on Darwin to fix the problem.
>> 
>> Note: We don't have this issue with check-all because libLTO is in the 
>> test-depends target.
>> 
>> https://reviews.llvm.org/D24042
>> 
>> Files:
>> test/CMakeLists.txt
>> 
>> Index: test/CMakeLists.txt
>> ===
>> --- test/CMakeLists.txt
>> +++ test/CMakeLists.txt
>> @@ -82,6 +82,10 @@
>>  endif()
>> endif()
>> 
>> +if(APPLE)
>> +  list(APPEND CLANG_TEST_DEPS LTO)
>> +endif()
>> +
>> add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
>> set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
>> 
>> 
>> 
>> 
> 

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


r280150 - [test] Pass a fake libLTO.dylib to a driver test which depends on it

2016-08-30 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Aug 30 15:36:50 2016
New Revision: 280150

URL: http://llvm.org/viewvc/llvm-project?rev=280150&view=rev
Log:
[test] Pass a fake libLTO.dylib to a driver test which depends on it

This makes it possible to run 'check-clang' on Darwin without building
libLTO.dylib. See r280142 for more context.

Modified:
cfe/trunk/test/Driver/darwin-ld-lto.c

Modified: cfe/trunk/test/Driver/darwin-ld-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld-lto.c?rev=280150&r1=280149&r2=280150&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld-lto.c (original)
+++ cfe/trunk/test/Driver/darwin-ld-lto.c Tue Aug 30 15:36:50 2016
@@ -2,24 +2,24 @@
 
 // Check that ld gets "-lto_library" and warnings about libLTO.dylib path.
 
+// RUN: mkdir -p %T/bin
+// RUN: mkdir -p %T/lib
+// RUN: touch %T/lib/libLTO.dylib
 // RUN: %clang -target x86_64-apple-darwin10 -### %s \
-// RUN:   -mlinker-version=133 -flto 2> %t.log
-// RUN: cat %t.log
-// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s < %t.log
+// RUN:   -ccc-install-dir %T/bin -mlinker-version=133 -flto 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log
 //
 // LINK_LTOLIB_PATH: {{ld(.exe)?"}}
 // LINK_LTOLIB_PATH: "-lto_library"
 
 // RUN: %clang -target x86_64-apple-darwin10 -### %s \
 // RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -flto 2> %t.log
-// RUN: cat %t.log
-// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s < %t.log
+// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s -input-file %t.log
 //
 // LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed dir 
not found; using 'ld' default search path instead
 
 // RUN: %clang -target x86_64-apple-darwin10 -### %s \
 // RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 
-flto 2> %t.log
-// RUN: cat %t.log
-// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s < %t.log
+// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s -input-file %t.log
 //
 // LINK_LTOLIB_PATH_NOWRN-NOT: warning: libLTO.dylib relative to clang 
installed dir not found; using 'ld' default search path instead


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


r280149 - Revert "[test] Add libLTO as a clang test dependency on Darwin"

2016-08-30 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Aug 30 15:36:48 2016
New Revision: 280149

URL: http://llvm.org/viewvc/llvm-project?rev=280149&view=rev
Log:
Revert "[test] Add libLTO as a clang test dependency on Darwin"

This reverts commit r280142. Mehdi suggested a better way to fix up the
test: just create a fake libLTO.dylib and tell the driver where to find
it. Patch incoming...

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=280149&r1=280148&r2=280149&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Tue Aug 30 15:36:48 2016
@@ -82,10 +82,6 @@ if( NOT CLANG_BUILT_STANDALONE )
   endif()
 endif()
 
-if(APPLE)
-  list(APPEND CLANG_TEST_DEPS LTO)
-endif()
-
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
 


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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-30 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a reviewer: djasper.
alexshap updated this revision to Diff 69748.
alexshap added a comment.

Address @djasper 's comments


Repository:
  rL LLVM

https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp
  test/clang-reorder-fields/ClassMixedInitialization.cpp
  test/clang-reorder-fields/ClassSimpleCtor.cpp

Index: test/clang-reorder-fields/ClassSimpleCtor.cpp
===
--- test/clang-reorder-fields/ClassSimpleCtor.cpp
+++ test/clang-reorder-fields/ClassSimpleCtor.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %s -- | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK:  {{^  const char \*s1;}}
+  const char *s1; // CHECK-NEXT: {{^  int x;}}
+  const char *s2; // CHECK-NEXT: {{^  double z;}}
+  double z;   // CHECK-NEXT: {{^  const char \*s2;}}
+};
+
+Foo::Foo():
+  x(12),  // CHECK:  {{^  s1\("abc"\),}}
+  s1("abc"),  // CHECK-NEXT: {{^  x\(12\),}}
+  s2("def"),  // CHECK-NEXT: {{^  z\(3.14\),}}
+  z(3.14) // CHECK-NEXT: {{^  s2\("def"\)}}
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/ClassMixedInitialization.cpp
===
--- test/clang-reorder-fields/ClassMixedInitialization.cpp
+++ test/clang-reorder-fields/ClassMixedInitialization.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %s -- -std=c++11 | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK:  {{^  double e = 2.71;}}
+  const char *s1; // CHECK-NEXT: {{^  int x;}}
+  const char *s2; // CHECK-NEXT: {{^  double pi = 3.14;}}
+  double pi = 3.14;   // CHECK-NEXT: {{^  const char \*s2;}}
+  double e = 2.71;// CHECK-NEXT: {{^  const char \*s1;}}
+};
+
+Foo::Foo():
+  x(12),  // CHECK:  {{^  x\(12\)}},
+  s1("abc"),  // CHECK-NEXT: {{^  s2\("def"\)}},
+  s2("def")   // CHECK-NEXT: {{^  s1\("abc"\)}}
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %s -- | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK:  {{^  double z;}}
+  int y;// CHECK-NEXT: {{^  int w;}}
+  double z; // CHECK-NEXT: {{^  int y;}}
+  int w;// CHECK-NEXT: {{^  const int\* x}}
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { &x, 0, 1.29, 17 }; // CHECK: {{^  bar::Foo foo = { 1.29, 17, 0, &x };}} 
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-reorder-fields -record-name ::Foo -fields-order y,x %s -- | FileCheck %s
+
+struct Foo {
+  int x;// CHECK:  {{^  double y;}}
+  double y; // CHECK-NEXT: {{^  int x;}}
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK:  {{^  int x;}}
+  double y; // CHECK-NEXT: {{^  double y;}}
+};
+} // end namespace bar
+
+int main() {
+  bar::Foo foo = { 1, 1.7 }; // CHECK: {{^  bar::Foo foo = { 1, 1.7 };}}
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp
===
--- clang-reorder-fields/tool/ClangReorderFields.cpp
+++ clang-reorder-fields/tool/ClangReorderFields.cpp
@@ -0,0 +1,88 @@
+//===-- tools/extra/clang-reorder-fields/tool/ClangReorderFields.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the implementation of clang-reorder-fields tool
+///
+//===--===//
+
+#include "../

Re: [PATCH] D23895: [ms] Add support for parsing uuid as a MS attribute

2016-08-30 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D23895#529275, @thakis wrote:

> > There are things missing from this patch as well. To wit:
>
> > 
>
> > - Attributes.h needs to know about this attribute syntax, and 
> > `hasAttribute()` needs to support it (this hooks into `__has_attribute` 
> > support).
>
> > - AttributeList.h should be updated to expose the parsed attribute syntax.
>
> > - Both of these changes should be threaded through ClangAttrEmitter.cpp.
>
>
> All these are already part of this patch as far as I can tell. What am I 
> missing?


This is what happens when I split my review into two sessions. I think I was 
just tired, because I now see that you did change Attributes.h and 
AttributeList.h properly. Sorry about the noise! However, I think 
`GenerateHasAttrSpellingStringSwitch()` should be updated (the Microsoft 
variety shouldn't work if Microsoft extensions are disabled), but otherwise 
ClangAttrEmitter.cpp seems reasonable.



Comment at: lib/Parse/ParseDecl.cpp:1431
@@ -1427,4 +1430,3 @@
 // class-key affects the type instead of the variable.
-void Parser::handleDeclspecAlignBeforeClassKey(ParsedAttributesWithRange 
&Attrs,
-   DeclSpec &DS,
-   Sema::TagUseKind TUK) {
+// Also, Microsoft-style [attributes] affect the type instead of the variable.
+// This function moves attributes that should apply to the type off DS to 
Attrs.

thakis wrote:
> aaron.ballman wrote:
> > Is this documented somewhere, or just what you gather from experimentation?
> Experimentation.
It might be good to clarify that in the comment so we don't come along later 
and think it's a hard-and-fast rule.


Comment at: utils/TableGen/ClangAttrEmitter.cpp:2372
@@ -2363,3 +2371,3 @@
 .Case("Declspec", 2)
-.Case("Keyword", 3)
-.Case("Pragma", 4)
+.Case("Microsoft", 3)
+.Case("Keyword", 4)

thakis wrote:
> aaron.ballman wrote:
> > I think (but my memory is a bit fuzzy here) that these values need to match 
> > the ones from AttributeList.h. I think it's a bug that Pragma was at 4 
> > rather than 5, but since __has_attribute doesn't care about pragmas (or 
> > context sensitive keywords), it's likely benign.
> I can change pragma to map to one more in a separate patch if you want.
Yeah, or I can take care of it, either way is fine by me.


https://reviews.llvm.org/D23895



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


Re: [PATCH] D23905: [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.

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

LGTM, thanks!


https://reviews.llvm.org/D23905



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


Re: [PATCH] D23918: [clang-tidy docs] Add missing option docs.

2016-08-30 Thread Aaron Ballman via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Thank you for working on this!



Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst:24
@@ +23,3 @@
+
+   A string represents which include-style is used, `llvm` or `google`. Default
+   is `llvm`.

s/represents/specifying


Comment at: docs/clang-tidy/checks/google-build-namespaces.rst:20
@@ +19,3 @@
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). "h,hh,hpp,hxx" by default. For
+   extension-less header files, using an empty string or leaving an empty 
string

s/not contain/not include the


Comment at: docs/clang-tidy/checks/google-build-namespaces.rst:21
@@ +20,3 @@
+   extensions should not contain "." prefix). "h,hh,hpp,hxx" by default. For
+   extension-less header files, using an empty string or leaving an empty 
string
+   between "," if there are other filename extensions.

How about:
```
For header files without an extension, use an empty string (if there are no 
other desired extensions) or leave an empty element in the list. e.g., 
"h,hh,hpp,hxx," (note the trailing comma).
```
(assuming my example actually works.)


Comment at: docs/clang-tidy/checks/google-runtime-int.rst:19
@@ +18,3 @@
+
+   A string represents unsigned type prefix. Default is `uint`.
+

A string specifying the unsigned type prefix.


Comment at: docs/clang-tidy/checks/google-runtime-int.rst:23
@@ +22,3 @@
+
+   A string represents singed type prefix. Default is `int`.
+

A string specifying the signed type prefix.


Comment at: docs/clang-tidy/checks/google-runtime-int.rst:27
@@ +26,2 @@
+
+   A string represents type suffix. Default is an empty string.

A string specifying the type suffix.


Comment at: docs/clang-tidy/checks/llvm-namespace-comment.rst:20
@@ +19,3 @@
+
+   An unsigned integer represents the maximal number of lines of the namespace
+   that is not required closing commments. Default is `1U`.

How about:
```
Requires the closing brace of the namespace definition to be followed by a 
closing comment if the body of the namespace has more than 
`ShortNamespaceLines` lines of code. The value is an unsigned integer that 
defaults to `1U`. 
```


Comment at: docs/clang-tidy/checks/llvm-namespace-comment.rst:25
@@ +24,2 @@
+
+   An unsigned integer represents spaces before comments. Default is `1U`.

How about:
```
An unsigned integer specifying the number of spaces before the comment closing 
a namespace definition.
```


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:83
@@ +82,3 @@
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). "h,hh,hpp,hxx" by default. For
+   extension-less header files, using an empty string or leaving an empty 
string

Same suggestion here as above.


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:89
@@ +88,3 @@
+
+   When non-zero, the check will use use file extension to distinguish header
+   files. Default is `1`.

s/use use/use the


Comment at: docs/clang-tidy/checks/misc-move-constructor-init.rst:20
@@ +19,3 @@
+
+   A string represents which include-style is used, `llvm` or `google`. Default
+   is `llvm`.

s/represents/specifying



Comment at: docs/clang-tidy/checks/misc-move-constructor-init.rst:25-26
@@ +24,3 @@
+
+   When non-zero, the check is also used to implement
+   `cert-oop11-cpp `_. Default is `0`.

cert-oop11-cpp redirects to this file, so the link is a bit circular. Perhaps a 
better link is:

How about:
```
When non-zero, the check conforms to the behavior expected by the CERT secure 
coding recommendation `OOP11-CPP 
`_.
 Default is `0` for misc-move-constructor-init and `1` for cert-oop11-cpp
```


Comment at: docs/clang-tidy/checks/misc-sizeof-expression.rst:142
@@ +141,3 @@
+
+   When non-zero, the check will warn on expression like ``sizeof(CONSTANT)``.
+   Default is `1`.

s/on/on an


Comment at: docs/clang-tidy/checks/misc-sizeof-expression.rst:147
@@ +146,3 @@
+
+   When non-zero, the check will warn on expression like ``sizeof(this)``.
+   Default is `1`.

s/on/on an


Comment at: docs/clang-tidy/checks/misc-sizeof-expression.rst:152
@@ +151,3 @@
+
+   W

Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a subscriber: bruno.
bruno added a comment.

Regardless of the way we decide to go with this, it would be nice if a driver 
level warning is used to tell users about any  non-obvious assumed behavior 
when these flags are used together.


https://reviews.llvm.org/D24048



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


Re: [PATCH] D24042: [test] Add libLTO as a clang test dependency on Darwin

2016-08-30 Thread Mehdi Amini via cfe-commits
Alternatively, since you only need the presence of a file named libLTO for the 
driver to do its magic, test can create an empty file named libLTO.dylib and 
use the  -ccc-install-dir to make sure the right flag is passed.

> On Aug 30, 2016, at 10:40 AM, Vedant Kumar  wrote:
> 
> vsk created this revision.
> vsk added a reviewer: bruno.
> vsk added a subscriber: cfe-commits.
> Herald added a subscriber: mehdi_amini.
> 
> Running 'check-clang' on a stock checkout of llvm+clang doesn't work on 
> Darwin, because test/Driver/darwin-ld-lto.c can't find libLTO.dylib. Add 
> libLTO as a clang test dependency on Darwin to fix the problem.
> 
> Note: We don't have this issue with check-all because libLTO is in the 
> test-depends target.
> 
> https://reviews.llvm.org/D24042
> 
> Files:
>  test/CMakeLists.txt
> 
> Index: test/CMakeLists.txt
> ===
> --- test/CMakeLists.txt
> +++ test/CMakeLists.txt
> @@ -82,6 +82,10 @@
>   endif()
> endif()
> 
> +if(APPLE)
> +  list(APPEND CLANG_TEST_DEPS LTO)
> +endif()
> +
> add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
> set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
> 
> 
> 
> 

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


Re: [PATCH] D23895: [ms] Add support for parsing uuid as a MS attribute

2016-08-30 Thread Nico Weber via cfe-commits
thakis marked 3 inline comments as done.
thakis added a comment.

> There are things missing from this patch as well. To wit:

> 

> - Attributes.h needs to know about this attribute syntax, and 
> `hasAttribute()` needs to support it (this hooks into `__has_attribute` 
> support).

> - AttributeList.h should be updated to expose the parsed attribute syntax.

> - Both of these changes should be threaded through ClangAttrEmitter.cpp.


All these are already part of this patch as far as I can tell. What am I 
missing?



Comment at: lib/Parse/ParseDecl.cpp:1427-1428
@@ -1425,2 +1426,4 @@
 
+// Usually, `__attribute__((attrib)) class Foo {} var` means that attrib 
applies
+// to var, not the type Foo.
 // As an exception to the rule, __declspec(align(...)) before the

aaron.ballman wrote:
> I'd spell this out a bit more.
> ```
> // Usually, `__attribute__((attrib)) class Foo {} var;` means that the 
> attribute appertains to the declaration (var) rather than the type (Foo).
> ```
> 
(ish)


Comment at: lib/Parse/ParseDecl.cpp:1431
@@ -1427,4 +1430,3 @@
 // class-key affects the type instead of the variable.
-void Parser::handleDeclspecAlignBeforeClassKey(ParsedAttributesWithRange 
&Attrs,
-   DeclSpec &DS,
-   Sema::TagUseKind TUK) {
+// Also, Microsoft-style [attributes] affect the type instead of the variable.
+// This function moves attributes that should apply to the type off DS to 
Attrs.

aaron.ballman wrote:
> Is this documented somewhere, or just what you gather from experimentation?
Experimentation.


Comment at: utils/TableGen/ClangAttrEmitter.cpp:2372
@@ -2363,3 +2371,3 @@
 .Case("Declspec", 2)
-.Case("Keyword", 3)
-.Case("Pragma", 4)
+.Case("Microsoft", 3)
+.Case("Keyword", 4)

aaron.ballman wrote:
> I think (but my memory is a bit fuzzy here) that these values need to match 
> the ones from AttributeList.h. I think it's a bug that Pragma was at 4 rather 
> than 5, but since __has_attribute doesn't care about pragmas (or context 
> sensitive keywords), it's likely benign.
I can change pragma to map to one more in a separate patch if you want.


https://reviews.llvm.org/D23895



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


Re: [PATCH] D24042: [test] Add libLTO as a clang test dependency on Darwin

2016-08-30 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280142: [test] Add libLTO as a clang test dependency on 
Darwin (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D24042?vs=69723&id=69743#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24042

Files:
  cfe/trunk/test/CMakeLists.txt

Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -82,6 +82,10 @@
   endif()
 endif()
 
+if(APPLE)
+  list(APPEND CLANG_TEST_DEPS LTO)
+endif()
+
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
 


Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -82,6 +82,10 @@
   endif()
 endif()
 
+if(APPLE)
+  list(APPEND CLANG_TEST_DEPS LTO)
+endif()
+
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r280142 - [test] Add libLTO as a clang test dependency on Darwin

2016-08-30 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Aug 30 14:57:40 2016
New Revision: 280142

URL: http://llvm.org/viewvc/llvm-project?rev=280142&view=rev
Log:
[test] Add libLTO as a clang test dependency on Darwin

Running 'check-clang' on a stock checkout of llvm+clang doesn't work on
Darwin, because test/Driver/darwin-ld-lto.c can't find libLTO.dylib. Add
libLTO as a clang test dependency on Darwin to fix the problem.

Note: We don't have this issue with check-all because libLTO is in the
test-depends target.

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

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=280142&r1=280141&r2=280142&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Tue Aug 30 14:57:40 2016
@@ -82,6 +82,10 @@ if( NOT CLANG_BUILT_STANDALONE )
   endif()
 endif()
 
+if(APPLE)
+  list(APPEND CLANG_TEST_DEPS LTO)
+endif()
+
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang tests")
 


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


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Chris Bieneman via cfe-commits
Filipe,

You say that, but the darwin driver’s behavior is different from the FreeBSD or 
GNUTools behavior. This patch provides the GNUTools & FreeBSD behavior via the 
Darwin driver.

-Chris

> On Aug 30, 2016, at 12:26 PM, Filipe Cabecinhas 
>  wrote:
> 
> I don't think so. "No default libs" should mean "no default libs", not "some 
> default libs". Maybe you're using an alternate sanitizer lib or something, 
> hence usage of that flag.
> 
> Thank you,
> 
>  Filipe
> 
> On Tuesday, 30 August 2016, Chris Bieneman via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> beanz created this revision.
> beanz added reviewers: zaks.anna, kubabrecka, bogner.
> beanz added a subscriber: cfe-commits.
> 
> The -nodefaultlibs and -nostdlib flags suppress all the runtime libraries 
> that the driver puts on the link line. This feels wrong. If a user specifies 
> "-fsanitize=" I think it is expected that the sanitizer library would 
> be included on the link line.
> 
> https://reviews.llvm.org/D24048 
> 
> Files:
>   lib/Driver/ToolChains.cpp
>   lib/Driver/ToolChains.h
>   lib/Driver/Tools.cpp
> 
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -8032,6 +8032,8 @@
> 
>  // Let the tool chain choose which runtime library to link.
>  getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
> +  } else {
> +getMachOToolChain().AddLinkSanitizerLibArgs(Args, CmdArgs);
>}
> 
>if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
> Index: lib/Driver/ToolChains.h
> ===
> --- lib/Driver/ToolChains.h
> +++ lib/Driver/ToolChains.h
> @@ -282,6 +282,10 @@
>virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
>   llvm::opt::ArgStringList &CmdArgs) 
> const;
> 
> +  virtual void
> +  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
> +  llvm::opt::ArgStringList &CmdArgs) const {}
> +
>virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
>llvm::opt::ArgStringList &CmdArgs) 
> const {
>}
> @@ -571,6 +575,10 @@
> 
>RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const 
> override;
> 
> +  void
> +  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
> +  llvm::opt::ArgStringList &CmdArgs) const override;
> +
>void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
>   llvm::opt::ArgStringList &CmdArgs) const 
> override;
> 
> Index: lib/Driver/ToolChains.cpp
> ===
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -425,22 +425,7 @@
>  return;
>}
> 
> -  const SanitizerArgs &Sanitize = getSanitizerArgs();
> -  if (Sanitize.needsAsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
> -  if (Sanitize.needsUbsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
> -  if (Sanitize.needsTsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
> -  if (Sanitize.needsStatsRt()) {
> -StringRef OS = isTargetMacOS() ? "osx" : "iossim";
> -AddLinkRuntimeLib(Args, CmdArgs,
> -  (Twine("libclang_rt.stats_client_") + OS + ".a").str(),
> -  /*AlwaysLink=*/true);
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
> -  }
> -  if (Sanitize.needsEsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
> +  AddLinkSanitizerLibArgs(Args, CmdArgs);
> 
>// Otherwise link libSystem, then the dynamic runtime library, and finally 
> any
>// target specific static runtime library.
> @@ -495,6 +480,26 @@
>}
>  }
> 
> +void DarwinClang::AddLinkSanitizerLibArgs(
> +const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const 
> {
> +  const SanitizerArgs &Sanitize = getSanitizerArgs();
> +  if (Sanitize.needsAsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
> +  if (Sanitize.needsUbsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
> +  if (Sanitize.needsTsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
> +  if (Sanitize.needsStatsRt()) {
> +StringRef OS = isTargetMacOS() ? "osx" : "iossim";
> +AddLinkRuntimeLib(Args, CmdArgs,
> +  (Twine("libclang_rt.stats_client_") + OS + ".a").str(),
> +  /*AlwaysLink=*/true);
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
> +  }
> +  if (Sanitize.needsEsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
> +}
> +
>  void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
>const OptTable &Opts = getDriver().getOpts();
> 
> 
> 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
htt

Re: [PATCH] D24042: [test] Add libLTO as a clang test dependency on Darwin

2016-08-30 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Nice, LGTM


https://reviews.llvm.org/D24042



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


Re: [PATCH] D23746: Basic/Targets.cpp: Add polaris10 and polaris11 gpus

2016-08-30 Thread Niels Ole Salscheider via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280120: Basic/Targets.cpp: Add polaris10 and polaris11 gpus 
(authored by olesalscheider).

Changed prior to commit:
  https://reviews.llvm.org/D23746?vs=69485&id=69730#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23746

Files:
  cfe/trunk/lib/Basic/Targets.cpp

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2110,21 +2110,23 @@
 
   static GPUKind parseAMDGCNName(StringRef Name) {
 return llvm::StringSwitch(Name)
-  .Case("tahiti",   GK_SOUTHERN_ISLANDS)
-  .Case("pitcairn", GK_SOUTHERN_ISLANDS)
-  .Case("verde",GK_SOUTHERN_ISLANDS)
-  .Case("oland",GK_SOUTHERN_ISLANDS)
-  .Case("hainan",   GK_SOUTHERN_ISLANDS)
-  .Case("bonaire",  GK_SEA_ISLANDS)
-  .Case("kabini",   GK_SEA_ISLANDS)
-  .Case("kaveri",   GK_SEA_ISLANDS)
-  .Case("hawaii",   GK_SEA_ISLANDS)
-  .Case("mullins",  GK_SEA_ISLANDS)
-  .Case("tonga",GK_VOLCANIC_ISLANDS)
-  .Case("iceland",  GK_VOLCANIC_ISLANDS)
-  .Case("carrizo",  GK_VOLCANIC_ISLANDS)
-  .Case("fiji", GK_VOLCANIC_ISLANDS)
-  .Case("stoney",   GK_VOLCANIC_ISLANDS)
+  .Case("tahiti",GK_SOUTHERN_ISLANDS)
+  .Case("pitcairn",  GK_SOUTHERN_ISLANDS)
+  .Case("verde", GK_SOUTHERN_ISLANDS)
+  .Case("oland", GK_SOUTHERN_ISLANDS)
+  .Case("hainan",GK_SOUTHERN_ISLANDS)
+  .Case("bonaire",   GK_SEA_ISLANDS)
+  .Case("kabini",GK_SEA_ISLANDS)
+  .Case("kaveri",GK_SEA_ISLANDS)
+  .Case("hawaii",GK_SEA_ISLANDS)
+  .Case("mullins",   GK_SEA_ISLANDS)
+  .Case("tonga", GK_VOLCANIC_ISLANDS)
+  .Case("iceland",   GK_VOLCANIC_ISLANDS)
+  .Case("carrizo",   GK_VOLCANIC_ISLANDS)
+  .Case("fiji",  GK_VOLCANIC_ISLANDS)
+  .Case("stoney",GK_VOLCANIC_ISLANDS)
+  .Case("polaris10", GK_VOLCANIC_ISLANDS)
+  .Case("polaris11", GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
   }
 


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2110,21 +2110,23 @@
 
   static GPUKind parseAMDGCNName(StringRef Name) {
 return llvm::StringSwitch(Name)
-  .Case("tahiti",   GK_SOUTHERN_ISLANDS)
-  .Case("pitcairn", GK_SOUTHERN_ISLANDS)
-  .Case("verde",GK_SOUTHERN_ISLANDS)
-  .Case("oland",GK_SOUTHERN_ISLANDS)
-  .Case("hainan",   GK_SOUTHERN_ISLANDS)
-  .Case("bonaire",  GK_SEA_ISLANDS)
-  .Case("kabini",   GK_SEA_ISLANDS)
-  .Case("kaveri",   GK_SEA_ISLANDS)
-  .Case("hawaii",   GK_SEA_ISLANDS)
-  .Case("mullins",  GK_SEA_ISLANDS)
-  .Case("tonga",GK_VOLCANIC_ISLANDS)
-  .Case("iceland",  GK_VOLCANIC_ISLANDS)
-  .Case("carrizo",  GK_VOLCANIC_ISLANDS)
-  .Case("fiji", GK_VOLCANIC_ISLANDS)
-  .Case("stoney",   GK_VOLCANIC_ISLANDS)
+  .Case("tahiti",GK_SOUTHERN_ISLANDS)
+  .Case("pitcairn",  GK_SOUTHERN_ISLANDS)
+  .Case("verde", GK_SOUTHERN_ISLANDS)
+  .Case("oland", GK_SOUTHERN_ISLANDS)
+  .Case("hainan",GK_SOUTHERN_ISLANDS)
+  .Case("bonaire",   GK_SEA_ISLANDS)
+  .Case("kabini",GK_SEA_ISLANDS)
+  .Case("kaveri",GK_SEA_ISLANDS)
+  .Case("hawaii",GK_SEA_ISLANDS)
+  .Case("mullins",   GK_SEA_ISLANDS)
+  .Case("tonga", GK_VOLCANIC_ISLANDS)
+  .Case("iceland",   GK_VOLCANIC_ISLANDS)
+  .Case("carrizo",   GK_VOLCANIC_ISLANDS)
+  .Case("fiji",  GK_VOLCANIC_ISLANDS)
+  .Case("stoney",GK_VOLCANIC_ISLANDS)
+  .Case("polaris10", GK_VOLCANIC_ISLANDS)
+  .Case("polaris11", GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Filipe Cabecinhas via cfe-commits
I don't think so. "No default libs" should mean "no default libs", not
"some default libs". Maybe you're using an alternate sanitizer lib or
something, hence usage of that flag.

Thank you,

 Filipe

On Tuesday, 30 August 2016, Chris Bieneman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> beanz created this revision.
> beanz added reviewers: zaks.anna, kubabrecka, bogner.
> beanz added a subscriber: cfe-commits.
>
> The -nodefaultlibs and -nostdlib flags suppress all the runtime libraries
> that the driver puts on the link line. This feels wrong. If a user
> specifies "-fsanitize=" I think it is expected that the sanitizer
> library would be included on the link line.
>
> https://reviews.llvm.org/D24048
>
> Files:
>   lib/Driver/ToolChains.cpp
>   lib/Driver/ToolChains.h
>   lib/Driver/Tools.cpp
>
> Index: lib/Driver/Tools.cpp
> ===
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -8032,6 +8032,8 @@
>
>  // Let the tool chain choose which runtime library to link.
>  getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
> +  } else {
> +getMachOToolChain().AddLinkSanitizerLibArgs(Args, CmdArgs);
>}
>
>if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
> Index: lib/Driver/ToolChains.h
> ===
> --- lib/Driver/ToolChains.h
> +++ lib/Driver/ToolChains.h
> @@ -282,6 +282,10 @@
>virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
>   llvm::opt::ArgStringList &CmdArgs)
> const;
>
> +  virtual void
> +  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
> +  llvm::opt::ArgStringList &CmdArgs) const {}
> +
>virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
>llvm::opt::ArgStringList &CmdArgs)
> const {
>}
> @@ -571,6 +575,10 @@
>
>RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
> override;
>
> +  void
> +  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
> +  llvm::opt::ArgStringList &CmdArgs) const
> override;
> +
>void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
>   llvm::opt::ArgStringList &CmdArgs) const
> override;
>
> Index: lib/Driver/ToolChains.cpp
> ===
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -425,22 +425,7 @@
>  return;
>}
>
> -  const SanitizerArgs &Sanitize = getSanitizerArgs();
> -  if (Sanitize.needsAsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
> -  if (Sanitize.needsUbsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
> -  if (Sanitize.needsTsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
> -  if (Sanitize.needsStatsRt()) {
> -StringRef OS = isTargetMacOS() ? "osx" : "iossim";
> -AddLinkRuntimeLib(Args, CmdArgs,
> -  (Twine("libclang_rt.stats_client_") + OS +
> ".a").str(),
> -  /*AlwaysLink=*/true);
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
> -  }
> -  if (Sanitize.needsEsanRt())
> -AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
> +  AddLinkSanitizerLibArgs(Args, CmdArgs);
>
>// Otherwise link libSystem, then the dynamic runtime library, and
> finally any
>// target specific static runtime library.
> @@ -495,6 +480,26 @@
>}
>  }
>
> +void DarwinClang::AddLinkSanitizerLibArgs(
> +const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
> const {
> +  const SanitizerArgs &Sanitize = getSanitizerArgs();
> +  if (Sanitize.needsAsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
> +  if (Sanitize.needsUbsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
> +  if (Sanitize.needsTsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
> +  if (Sanitize.needsStatsRt()) {
> +StringRef OS = isTargetMacOS() ? "osx" : "iossim";
> +AddLinkRuntimeLib(Args, CmdArgs,
> +  (Twine("libclang_rt.stats_client_") + OS +
> ".a").str(),
> +  /*AlwaysLink=*/true);
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
> +  }
> +  if (Sanitize.needsEsanRt())
> +AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
> +}
> +
>  void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
>const OptTable &Opts = getDriver().getOpts();
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r280136 - PR29166: when merging declarations with typedef names for linkage purposes,

2016-08-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 30 14:13:18 2016
New Revision: 280136

URL: http://llvm.org/viewvc/llvm-project?rev=280136&view=rev
Log:
PR29166: when merging declarations with typedef names for linkage purposes,
don't assume that the anonymous struct will be part of the most recent
declaration of the typedef.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/merge-name-for-linkage.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=280136&r1=280135&r2=280136&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Aug 30 14:13:18 2016
@@ -2887,7 +2887,7 @@ static NamedDecl *getDeclForMerging(Name
 return nullptr;
 
   if (auto *TND = dyn_cast(Found))
-return TND->getAnonDeclWithTypedefName();
+return TND->getAnonDeclWithTypedefName(/*AnyRedecl*/true);
 
   return nullptr;
 }

Modified: cfe/trunk/test/Modules/merge-name-for-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-name-for-linkage.cpp?rev=280136&r1=280135&r2=280136&view=diff
==
--- cfe/trunk/test/Modules/merge-name-for-linkage.cpp (original)
+++ cfe/trunk/test/Modules/merge-name-for-linkage.cpp Tue Aug 30 14:13:18 2016
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-I%S/Inputs/merge-name-for-linkage -verify %s
 // expected-no-diagnostics
 typedef union {} pthread_mutex_t;
+typedef pthread_mutex_t pthread_mutex_t;
 #include "a.h"
 pthread_mutex_t x;
 #include "b.h"


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


r280134 - Unrevert r280035 now that the clang-cl bug it exposed has been fixed by

2016-08-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 30 14:06:26 2016
New Revision: 280134

URL: http://llvm.org/viewvc/llvm-project?rev=280134&view=rev
Log:
Unrevert r280035 now that the clang-cl bug it exposed has been fixed by
r280133. Original commit message:

C++ Modules TS: driver support for building modules.

This works as follows: we add --precompile to the existing gamut of options for
specifying how far to go when compiling an input (-E, -c, -S, etc.). This flag
specifies that an input is taken to the precompilation step and no further, and
this can be specified when building a .pcm from a module interface or when
building a .pch from a header file.

The .cppm extension (and some related extensions) are implicitly recognized as
C++ module interface files. If --precompile is /not/ specified, the file is
compiled (via a .pcm) to a .o file containing the code for the module (and then
potentially also assembled and linked, if -S, -c, etc. are not specified). We
do not yet suppress the emission of object code for other users of the module
interface, so for now this will only work if everything in the .cppm file has
vague linkage.

As with the existing support for module-map modules, prebuilt modules can be
provided as compiler inputs either via the -fmodule-file= command-line argument
or via files named ModuleName.pcm in one of the directories specified via
-fprebuilt-module-path=.

This also exposes the -fmodules-ts cc1 flag in the driver. This is still
experimental, and in particular, the concrete syntax is subject to change as
the Modules TS evolves in the C++ committee. Unlike -fmodules, this flag does
not enable support for implicitly loading module maps nor building modules via
the module cache, but those features can be turned on separately and used in
conjunction with the Modules TS support.

Added:
cfe/trunk/test/Driver/modules-ts.cpp
  - copied unchanged from r280090, cfe/trunk/test/Driver/modules-ts.cpp
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/Types.def
cfe/trunk/include/clang/Driver/Types.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Types.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/test/Driver/cl-pch.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=280134&r1=280133&r2=280134&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Aug 30 14:06:26 2016
@@ -397,8 +397,6 @@ def ast_dump_filter : Separate<["-"], "a
   HelpText<"Use with -ast-dump or -ast-print to dump/print only AST 
declaration"
" nodes having a certain substring in a qualified name. Use"
" -ast-list to list all filterable declaration node names.">;
-def fmodules_ts : Flag <["-"], "fmodules-ts">, Group,
-  HelpText<"Enable support for the C++ Modules TS">;
 def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">,
   HelpText<"Do not automatically generate or update the global module index">;
 def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=280134&r1=280133&r2=280134&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Aug 30 14:06:26 2016
@@ -875,6 +875,8 @@ def fmodules : Flag <["-"], "fmodules">,
 def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, 
Group,
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Implicitly search the file system for module map files.">;
+def fmodules_ts : Flag <["-"], "fmodules-ts">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">;
 def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias;
 def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group,
   Flags<[DriverOption,CC1Option]>, MetaVarName<"">,
@@ -2031,6 +2033,8 @@ def _output_EQ : Joined<["--"], "output=
 def _output : Separate<["--"], "output">, Alias;
 def _param : Separate<["--"], "param">, Group;
 def _param_EQ : Joined<["--"], "param=">, Alias<_param>;
+def _precompile : Flag<["--"], "precompile">, Flags<[DriverOption]>,
+  Group, HelpText<"Only precompile the input">;
 def _prefix_EQ : Joined<["--"], "prefix=">, Alias;
 def _prefix : Separate<["--"], "prefix">, Alias;
 def _preprocess : Flag<["--"], "preprocess">, Alias;

Modified: cfe/trunk/include/clang/Driver/Types.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=280134&r1=280133&r2=280134&view=diff
===

Re: r280104 - Disable clang/test/SemaTemplate/instantiation-depth-default.cpp temporarily for targeting mingw32. It crashes. Investigating.

2016-08-30 Thread Richard Smith via cfe-commits
On Tue, Aug 30, 2016 at 8:38 AM, NAKAMURA Takumi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Tue Aug 30 10:38:18 2016
> New Revision: 280104
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280104&view=rev
> Log:
> Disable clang/test/SemaTemplate/instantiation-depth-default.cpp
> temporarily for targeting mingw32. It crashes. Investigating.
>

This is probably due to stack overflow. Is there a way we can raise the
stack limit for mingw32?


> Modified:
> cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
>
> Modified: cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaTemplate/instantiation-depth-default.cpp?rev=280104&
> r1=280103&r2=280104&view=diff
> 
> ==
> --- cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp Tue Aug
> 30 10:38:18 2016
> @@ -12,3 +12,6 @@ template struct X : X
>  // expected-note@8 {{use -ftemplate-depth=N to increase recursive
> template instantiation depth}}
>
>  X<0, int> x; // expected-note {{in instantiation of}}
> +
> +// FIXME: It crashes. Investigating.
> +// UNSUPPORTED: mingw32
>
>
> ___
> 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] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-08-30 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: zaks.anna, kubabrecka, bogner.
beanz added a subscriber: cfe-commits.

The -nodefaultlibs and -nostdlib flags suppress all the runtime libraries that 
the driver puts on the link line. This feels wrong. If a user specifies 
"-fsanitize=" I think it is expected that the sanitizer library would be 
included on the link line.

https://reviews.llvm.org/D24048

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8032,6 +8032,8 @@
 
 // Let the tool chain choose which runtime library to link.
 getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
+  } else {
+getMachOToolChain().AddLinkSanitizerLibArgs(Args, CmdArgs);
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -282,6 +282,10 @@
   virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
 
+  virtual void
+  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const {}
+
   virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) const 
{
   }
@@ -571,6 +575,10 @@
 
   RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const 
override;
 
+  void
+  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const override;
+
   void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const override;
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -425,22 +425,7 @@
 return;
   }
 
-  const SanitizerArgs &Sanitize = getSanitizerArgs();
-  if (Sanitize.needsAsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
-  if (Sanitize.needsUbsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
-  if (Sanitize.needsTsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
-  if (Sanitize.needsStatsRt()) {
-StringRef OS = isTargetMacOS() ? "osx" : "iossim";
-AddLinkRuntimeLib(Args, CmdArgs,
-  (Twine("libclang_rt.stats_client_") + OS + ".a").str(),
-  /*AlwaysLink=*/true);
-AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
-  }
-  if (Sanitize.needsEsanRt())
-AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
+  AddLinkSanitizerLibArgs(Args, CmdArgs);
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -495,6 +480,26 @@
   }
 }
 
+void DarwinClang::AddLinkSanitizerLibArgs(
+const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const {
+  const SanitizerArgs &Sanitize = getSanitizerArgs();
+  if (Sanitize.needsAsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsUbsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
+  if (Sanitize.needsStatsRt()) {
+StringRef OS = isTargetMacOS() ? "osx" : "iossim";
+AddLinkRuntimeLib(Args, CmdArgs,
+  (Twine("libclang_rt.stats_client_") + OS + ".a").str(),
+  /*AlwaysLink=*/true);
+AddLinkSanitizerLibArgs(Args, CmdArgs, "stats");
+  }
+  if (Sanitize.needsEsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "esan");
+}
+
 void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const OptTable &Opts = getDriver().getOpts();
 


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8032,6 +8032,8 @@
 
 // Let the tool chain choose which runtime library to link.
 getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
+  } else {
+getMachOToolChain().AddLinkSanitizerLibArgs(Args, CmdArgs);
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -282,6 +282,10 @@
   virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
 
+  virtual void
+  AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const {}
+
   virtual void add

r280133 - PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) input types.

2016-08-30 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 30 13:55:16 2016
New Revision: 280133

URL: http://llvm.org/viewvc/llvm-project?rev=280133&view=rev
Log:
PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) input 
types.

Modified:
cfe/trunk/include/clang/Driver/Types.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Types.cpp
cfe/trunk/test/Driver/cl-pch.c

Modified: cfe/trunk/include/clang/Driver/Types.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.h?rev=280133&r1=280132&r2=280133&view=diff
==
--- cfe/trunk/include/clang/Driver/Types.h (original)
+++ cfe/trunk/include/clang/Driver/Types.h Tue Aug 30 13:55:16 2016
@@ -90,6 +90,10 @@ namespace types {
   /// C type (used for clang++ emulation of g++ behaviour)
   ID lookupCXXTypeForCType(ID Id);
 
+  /// Lookup header file input type that corresponds to given
+  /// source file type (used for clang-cl emulation of \Yc).
+  ID lookupHeaderTypeForSourceType(ID Id);
+
 } // end namespace types
 } // end namespace driver
 } // end namespace clang

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=280133&r1=280132&r2=280133&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Aug 30 13:55:16 2016
@@ -1685,12 +1685,14 @@ void Driver::BuildActions(Compilation &C
 if (YcArg) {
   // Add a separate precompile phase for the compile phase.
   if (FinalPhase >= phases::Compile) {
+const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType);
 llvm::SmallVector PCHPL;
-types::getCompilationPhases(types::TY_CXXHeader, PCHPL);
+types::getCompilationPhases(HeaderType, PCHPL);
 Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue());
 
 // Build the pipeline for the pch file.
-Action *ClangClPch = C.MakeAction(*PchInputArg, 
InputType);
+Action *ClangClPch =
+C.MakeAction(*PchInputArg, HeaderType);
 for (phases::ID Phase : PCHPL)
   ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch);
 assert(ClangClPch);
@@ -1812,6 +1814,8 @@ Action *Driver::ConstructPhaseAction(Com
 return C.MakeAction(Input, OutputTy);
   }
   case phases::Precompile: {
+assert(onlyPrecompileType(Input->getType()) &&
+   "asked to precompile non-precompilable type");
 types::ID OutputTy = types::TY_PCH;
 if (Args.hasArg(options::OPT_fsyntax_only)) {
   // Syntax checks should not emit a PCH file

Modified: cfe/trunk/lib/Driver/Types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=280133&r1=280132&r2=280133&view=diff
==
--- cfe/trunk/lib/Driver/Types.cpp (original)
+++ cfe/trunk/lib/Driver/Types.cpp Tue Aug 30 13:55:16 2016
@@ -259,3 +259,21 @@ ID types::lookupCXXTypeForCType(ID Id) {
 return types::TY_PP_CXXHeader;
   }
 }
+
+ID types::lookupHeaderTypeForSourceType(ID Id) {
+  switch (Id) {
+  default:
+return Id;
+
+  case types::TY_C:
+return types::TY_CHeader;
+  case types::TY_CXX:
+return types::TY_CXXHeader;
+  case types::TY_ObjC:
+return types::TY_ObjCHeader;
+  case types::TY_ObjCXX:
+return types::TY_ObjCXXHeader;
+  case types::TY_CL:
+return types::TY_CLHeader;
+  }
+}

Modified: cfe/trunk/test/Driver/cl-pch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.c?rev=280133&r1=280132&r2=280133&view=diff
==
--- cfe/trunk/test/Driver/cl-pch.c (original)
+++ cfe/trunk/test/Driver/cl-pch.c Tue Aug 30 13:55:16 2016
@@ -1,3 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
 // Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
@@ -5,41 +8,41 @@
 // a few things for .c inputs.
 
 // /Yc with a .c file should build a c pch file.
-// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c 
/Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC %s
 // CHECK-YC: cc1
-// CHECK-YC: -emit-pch
-// CHECK-YC: -o
-// CHECK-YC: pchfile.pch
-// CHECK-YC: -x
-// CHECK-YC: "c"
+// CHECK-YC-SAME: -emit-pch
+// CHECK-YC-SAME: -o
+// CHECK-YC-SAME: pchfile.pch
+// CHECK-YC-SAME: -x
+// CHECK-YC-SAME: c-header
 
 // But not if /TP changes the input language to C++.
-// RUN: %clang_cl /TP -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl /TP -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c 
/Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
 // RUN: 

Re: [PATCH] D23944: Parsing MS pragma intrinsic

2016-08-30 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, but you should wait for @rnk to accept as well.


https://reviews.llvm.org/D23944



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


Re: [PATCH] D23918: [clang-tidy docs] Add missing option docs.

2016-08-30 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: aaron.ballman.
Eugene.Zelenko added a comment.

I don't have further comments, but as non-English speaker and mediocre writer, 
I would like see other people comments. May be @aaron.ballman could help if 
Alexander is busy?


https://reviews.llvm.org/D23918



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


r280127 - typo + indentation [NFC]

2016-08-30 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Tue Aug 30 13:38:25 2016
New Revision: 280127

URL: http://llvm.org/viewvc/llvm-project?rev=280127&view=rev
Log:
typo + indentation [NFC]

Modified:
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=280127&r1=280126&r2=280127&view=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Tue Aug 30 13:38:25 2016
@@ -115,7 +115,7 @@ static bool readFullStringValue(HKEY hke
 std::wstring WideValue(reinterpret_cast(buffer.data()),
valueSize / sizeof(wchar_t));
 if (valueSize && WideValue.back() == L'\0') {
-WideValue.pop_back();
+  WideValue.pop_back();
 }
 // The destination buffer must be empty as an invariant of the conversion
 // function; but this function is sometimes called in a loop that passes in

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=280127&r1=280126&r2=280127&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Aug 30 13:38:25 2016
@@ -190,7 +190,7 @@ protected:
 /// \brief Print information about the detected CUDA installation.
 void print(raw_ostream &OS) const;
 
-/// \brief Get the deteced Cuda install's version.
+/// \brief Get the detected Cuda install's version.
 CudaVersion version() const { return Version; }
 /// \brief Get the detected Cuda installation path.
 StringRef getInstallPath() const { return InstallPath; }


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


Re: [PATCH] D23852: [SemaObjC] Fix crash while parsing type arguments and protocols

2016-08-30 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D23852



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


Re: [PATCH] D23905: [Modules] Add 'gnuinlineasm' to the 'requires-declaration' feature-list.

2016-08-30 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D23905



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


[libclc] r280121 - configure.py: Add polaris10 and polaris11

2016-08-30 Thread Niels Ole Salscheider via cfe-commits
Author: olesalscheider
Date: Tue Aug 30 13:00:41 2016
New Revision: 280121

URL: http://llvm.org/viewvc/llvm-project?rev=280121&view=rev
Log:
configure.py: Add polaris10 and polaris11

Modified:
libclc/trunk/configure.py

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=280121&r1=280120&r2=280121&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Tue Aug 30 13:00:41 2016
@@ -96,9 +96,9 @@ available_targets = {
 {'gpu' : 'barts',   'aliases' : ['turks', 'caicos'] },
 {'gpu' : 'cayman',  'aliases' : ['aruba']} ]},
   'amdgcn--': { 'devices' :
-[{'gpu' : 'tahiti', 'aliases' : ['pitcairn', 'verde', 'oland', 
'hainan', 'bonaire', 'kabini', 'kaveri', 
'hawaii','mullins','tonga','carrizo','iceland','fiji','stoney']} ]},
+[{'gpu' : 'tahiti', 'aliases' : ['pitcairn', 'verde', 'oland', 
'hainan', 'bonaire', 'kabini', 'kaveri', 
'hawaii','mullins','tonga','carrizo','iceland','fiji','stoney','polaris10','polaris11']}
 ]},
   'amdgcn--amdhsa': { 'devices' :
-  [{'gpu' : '', 'aliases' : ['bonaire', 'hawaii', 
'kabini', 'kaveri', 'mullins', 'carrizo', 'stoney', 'fiji', 'iceland', 
'tonga']} ]},
+  [{'gpu' : '', 'aliases' : ['bonaire', 'hawaii', 
'kabini', 'kaveri', 'mullins', 'carrizo', 'stoney', 'fiji', 'iceland', 
'tonga','polaris10','polaris11']} ]},
   'nvptx--'   : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},
   'nvptx64--' : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},
   'nvptx--nvidiacl'   : { 'devices' : [{'gpu' : '', 'aliases' : []} ]},


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


r280120 - Basic/Targets.cpp: Add polaris10 and polaris11 gpus

2016-08-30 Thread Niels Ole Salscheider via cfe-commits
Author: olesalscheider
Date: Tue Aug 30 13:00:22 2016
New Revision: 280120

URL: http://llvm.org/viewvc/llvm-project?rev=280120&view=rev
Log:
Basic/Targets.cpp: Add polaris10 and polaris11 gpus

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

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=280120&r1=280119&r2=280120&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 30 13:00:22 2016
@@ -2110,21 +2110,23 @@ public:
 
   static GPUKind parseAMDGCNName(StringRef Name) {
 return llvm::StringSwitch(Name)
-  .Case("tahiti",   GK_SOUTHERN_ISLANDS)
-  .Case("pitcairn", GK_SOUTHERN_ISLANDS)
-  .Case("verde",GK_SOUTHERN_ISLANDS)
-  .Case("oland",GK_SOUTHERN_ISLANDS)
-  .Case("hainan",   GK_SOUTHERN_ISLANDS)
-  .Case("bonaire",  GK_SEA_ISLANDS)
-  .Case("kabini",   GK_SEA_ISLANDS)
-  .Case("kaveri",   GK_SEA_ISLANDS)
-  .Case("hawaii",   GK_SEA_ISLANDS)
-  .Case("mullins",  GK_SEA_ISLANDS)
-  .Case("tonga",GK_VOLCANIC_ISLANDS)
-  .Case("iceland",  GK_VOLCANIC_ISLANDS)
-  .Case("carrizo",  GK_VOLCANIC_ISLANDS)
-  .Case("fiji", GK_VOLCANIC_ISLANDS)
-  .Case("stoney",   GK_VOLCANIC_ISLANDS)
+  .Case("tahiti",GK_SOUTHERN_ISLANDS)
+  .Case("pitcairn",  GK_SOUTHERN_ISLANDS)
+  .Case("verde", GK_SOUTHERN_ISLANDS)
+  .Case("oland", GK_SOUTHERN_ISLANDS)
+  .Case("hainan",GK_SOUTHERN_ISLANDS)
+  .Case("bonaire",   GK_SEA_ISLANDS)
+  .Case("kabini",GK_SEA_ISLANDS)
+  .Case("kaveri",GK_SEA_ISLANDS)
+  .Case("hawaii",GK_SEA_ISLANDS)
+  .Case("mullins",   GK_SEA_ISLANDS)
+  .Case("tonga", GK_VOLCANIC_ISLANDS)
+  .Case("iceland",   GK_VOLCANIC_ISLANDS)
+  .Case("carrizo",   GK_VOLCANIC_ISLANDS)
+  .Case("fiji",  GK_VOLCANIC_ISLANDS)
+  .Case("stoney",GK_VOLCANIC_ISLANDS)
+  .Case("polaris10", GK_VOLCANIC_ISLANDS)
+  .Case("polaris11", GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
   }
 


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


[clang-tools-extra] r280119 - [Release notes] Fix highlighting.

2016-08-30 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Aug 30 12:47:07 2016
New Revision: 280119

URL: http://llvm.org/viewvc/llvm-project?rev=280119&view=rev
Log:
[Release notes] Fix highlighting.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=280119&r1=280118&r2=280119&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Aug 30 12:47:07 2016
@@ -72,8 +72,8 @@ Improvements to clang-tidy
 - New `misc-move-forwarding-reference
   
`_
 check
 
-  Warns when `std::move` is applied to a forwarding reference instead of
-  `std::forward`.
+  Warns when ``std::move`` is applied to a forwarding reference instead of
+  ``std::forward``.
 
 - New `mpi-buffer-deref
   `_ check


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


Re: [PATCH] D23837: Fix colored diagnostics from tools

2016-08-30 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280118: Fix colored diagnostics from tools (authored by 
ogoffart).

Changed prior to commit:
  https://reviews.llvm.org/D23837?vs=69225&id=69725#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23837

Files:
  cfe/trunk/lib/Tooling/Tooling.cpp
  cfe/trunk/unittests/Tooling/ToolingTest.cpp

Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -15,6 +15,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 #include "clang/Frontend/ASTUnit.h"
@@ -26,6 +27,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
@@ -241,6 +243,12 @@
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  unsigned MissingArgIndex, MissingArgCount;
+  llvm::opt::InputArgList ParsedArgs =
+  driver::createDriverOptTable()->ParseArgs(
+  ArrayRef(Argv).slice(1), MissingArgIndex,
+  MissingArgCount);
+  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);
   DiagnosticsEngine Diagnostics(
Index: cfe/trunk/unittests/Tooling/ToolingTest.cpp
===
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp
@@ -332,6 +332,44 @@
   EXPECT_FALSE(llvm::sys::fs::remove(DepFilePath.str()));
 }
 
+struct CheckColoredDiagnosticsAction : public clang::ASTFrontendAction {
+  CheckColoredDiagnosticsAction(bool ShouldShowColor)
+  : ShouldShowColor(ShouldShowColor) {}
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef) override {
+if (Compiler.getDiagnosticOpts().ShowColors != ShouldShowColor)
+  Compiler.getDiagnostics().Report(
+  Compiler.getDiagnostics().getCustomDiagID(
+  DiagnosticsEngine::Fatal,
+  "getDiagnosticOpts().ShowColors != ShouldShowColor"));
+return llvm::make_unique();
+  }
+
+private:
+  bool ShouldShowColor = true;
+};
+
+TEST(runToolOnCodeWithArgs, DiagnosticsColor) {
+
+  EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), 
"",
+{"-fcolor-diagnostics"}));
+  EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false),
+"", {"-fno-color-diagnostics"}));
+  EXPECT_TRUE(
+  runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), "",
+{"-fno-color-diagnostics", 
"-fcolor-diagnostics"}));
+  EXPECT_TRUE(
+  runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false), "",
+{"-fcolor-diagnostics", 
"-fno-color-diagnostics"}));
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  new CheckColoredDiagnosticsAction(true), "",
+  {"-fno-color-diagnostics", "-fdiagnostics-color=always"}));
+
+  // Check that this test would fail if ShowColors is not what it should.
+  EXPECT_FALSE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false),
+ "", {"-fcolor-diagnostics"}));
+}
+
 TEST(ClangToolTest, ArgumentAdjusters) {
   FixedCompilationDatabase Compilations("/", std::vector());
 


Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -15,6 +15,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 #include "clang/Frontend/ASTUnit.h"
@@ -26,6 +27,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
@@ -241,6 +243,12 @@
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  unsigned MissingArgIndex, MissingArgCount;
+  llvm::opt::InputArgList ParsedArgs =
+  driver::createDriverOptTable()->ParseArgs(
+  ArrayRef(Argv).slice(1), MissingArgIndex,
+  MissingArgCount);
+  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
   TextDiagnosticPrinter Diagnosti

r280118 - Fix colored diagnostics from tools

2016-08-30 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Tue Aug 30 12:42:29 2016
New Revision: 280118

URL: http://llvm.org/viewvc/llvm-project?rev=280118&view=rev
Log:
Fix colored diagnostics from tools

r271042 changed the way the diagnostic arguments are parsed. It assumes that
the diagnostics options were already parsed by the "Driver".
For tools using clang::Tooling, the diagnostics argument were not parsed.

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

Modified:
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/unittests/Tooling/ToolingTest.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=280118&r1=280117&r2=280118&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Tue Aug 30 12:42:29 2016
@@ -15,6 +15,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 #include "clang/Frontend/ASTUnit.h"
@@ -26,6 +27,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
@@ -241,6 +243,12 @@ bool ToolInvocation::run() {
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  unsigned MissingArgIndex, MissingArgCount;
+  llvm::opt::InputArgList ParsedArgs =
+  driver::createDriverOptTable()->ParseArgs(
+  ArrayRef(Argv).slice(1), MissingArgIndex,
+  MissingArgCount);
+  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);
   DiagnosticsEngine Diagnostics(

Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=280118&r1=280117&r2=280118&view=diff
==
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Tue Aug 30 12:42:29 2016
@@ -332,6 +332,44 @@ TEST(runToolOnCodeWithArgs, TestNoDepFil
   EXPECT_FALSE(llvm::sys::fs::remove(DepFilePath.str()));
 }
 
+struct CheckColoredDiagnosticsAction : public clang::ASTFrontendAction {
+  CheckColoredDiagnosticsAction(bool ShouldShowColor)
+  : ShouldShowColor(ShouldShowColor) {}
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef) override {
+if (Compiler.getDiagnosticOpts().ShowColors != ShouldShowColor)
+  Compiler.getDiagnostics().Report(
+  Compiler.getDiagnostics().getCustomDiagID(
+  DiagnosticsEngine::Fatal,
+  "getDiagnosticOpts().ShowColors != ShouldShowColor"));
+return llvm::make_unique();
+  }
+
+private:
+  bool ShouldShowColor = true;
+};
+
+TEST(runToolOnCodeWithArgs, DiagnosticsColor) {
+
+  EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), 
"",
+{"-fcolor-diagnostics"}));
+  EXPECT_TRUE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false),
+"", {"-fno-color-diagnostics"}));
+  EXPECT_TRUE(
+  runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(true), "",
+{"-fno-color-diagnostics", 
"-fcolor-diagnostics"}));
+  EXPECT_TRUE(
+  runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false), "",
+{"-fcolor-diagnostics", 
"-fno-color-diagnostics"}));
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  new CheckColoredDiagnosticsAction(true), "",
+  {"-fno-color-diagnostics", "-fdiagnostics-color=always"}));
+
+  // Check that this test would fail if ShowColors is not what it should.
+  EXPECT_FALSE(runToolOnCodeWithArgs(new CheckColoredDiagnosticsAction(false),
+ "", {"-fcolor-diagnostics"}));
+}
+
 TEST(ClangToolTest, ArgumentAdjusters) {
   FixedCompilationDatabase Compilations("/", std::vector());
 


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


Re: [PATCH] D23492: Make function local tags visible.

2016-08-30 Thread Vassil Vassilev via cfe-commits
v.g.vassilev closed this revision.
v.g.vassilev added a comment.

Landed in r279164 and r279486.


https://reviews.llvm.org/D23492



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


  1   2   >