r271777 - [AVX512] Remove space in -1 constants. NFC

2016-06-03 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Jun  4 00:43:37 2016
New Revision: 271777

URL: http://llvm.org/viewvc/llvm-project?rev=271777=rev
Log:
[AVX512] Remove space in -1 constants. NFC

Modified:
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512ifmaintrin.h
cfe/trunk/lib/Headers/avx512ifmavlintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=271777=271776=271777=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Sat Jun  4 00:43:37 2016
@@ -881,7 +881,7 @@ _mm512_broadcast_f32x2 (__m128 __A)
 {
   return (__m512) __builtin_ia32_broadcastf32x2_512_mask ((__v4sf) __A,
 (__v16sf)_mm512_undefined_ps(),
-(__mmask16) - 1);
+(__mmask16) -1);
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
@@ -905,7 +905,7 @@ _mm512_broadcast_f32x8 (__m256 __A)
 {
   return (__m512) __builtin_ia32_broadcastf32x8_512_mask ((__v8sf) __A,
 _mm512_undefined_ps(),
-(__mmask16) - 1);
+(__mmask16) -1);
 }
 
 static __inline__ __m512 __DEFAULT_FN_ATTRS
@@ -929,7 +929,7 @@ _mm512_broadcast_f64x2 (__m128d __A)
 {
   return (__m512d) __builtin_ia32_broadcastf64x2_512_mask ((__v2df) __A,
  (__v8df)_mm512_undefined_pd(),
- (__mmask8) - 1);
+ (__mmask8) -1);
 }
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
@@ -953,7 +953,7 @@ _mm512_broadcast_i32x2 (__m128i __A)
 {
   return (__m512i) __builtin_ia32_broadcasti32x2_512_mask ((__v4si) __A,
  (__v16si)_mm512_setzero_si512(),
- (__mmask16) - 1);
+ (__mmask16) -1);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
@@ -977,7 +977,7 @@ _mm512_broadcast_i32x8 (__m256i __A)
 {
   return (__m512i) __builtin_ia32_broadcasti32x8_512_mask ((__v8si) __A,
  (__v16si)_mm512_setzero_si512(),
- (__mmask16) - 1);
+ (__mmask16) -1);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
@@ -1002,7 +1002,7 @@ _mm512_broadcast_i64x2 (__m128i __A)
 {
   return (__m512i) __builtin_ia32_broadcasti64x2_512_mask ((__v2di) __A,
  (__v8di)_mm512_setzero_si512(),
- (__mmask8) - 1);
+ (__mmask8) -1);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/avx512ifmaintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512ifmaintrin.h?rev=271777=271776=271777=diff
==
--- cfe/trunk/lib/Headers/avx512ifmaintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512ifmaintrin.h Sat Jun  4 00:43:37 2016
@@ -37,7 +37,7 @@ _mm512_madd52hi_epu64 (__m512i __X, __m5
   return (__m512i) __builtin_ia32_vpmadd52huq512_mask ((__v8di) __X,
(__v8di) __Y,
(__v8di) __Z,
-   (__mmask8) - 1);
+   (__mmask8) -1);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
@@ -65,7 +65,7 @@ _mm512_madd52lo_epu64 (__m512i __X, __m5
   return (__m512i) __builtin_ia32_vpmadd52luq512_mask ((__v8di) __X,
(__v8di) __Y,
(__v8di) __Z,
-   (__mmask8) - 1);
+   (__mmask8) -1);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/avx512ifmavlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512ifmavlintrin.h?rev=271777=271776=271777=diff
==
--- cfe/trunk/lib/Headers/avx512ifmavlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512ifmavlintrin.h Sat Jun  4 00:43:37 2016
@@ -39,7 +39,7 @@ _mm_madd52hi_epu64 (__m128i __X, __m128i
   return (__m128i) __builtin_ia32_vpmadd52huq128_mask ((__v2di) __X,
(__v2di) __Y,
(__v2di) __Z,
-   (__mmask8) - 1);
+   (__mmask8) -1);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
@@ -66,7 +66,7 @@ _mm256_madd52hi_epu64 (__m256i __X, __m2
   return (__m256i) __builtin_ia32_vpmadd52huq256_mask ((__v4di) __X,
(__v4di) __Y,
(__v4di) __Z,
-   (__mmask8) - 1);
+   (__mmask8) -1);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
@@ -94,7 +94,7 @@ _mm_madd52lo_epu64 (__m128i __X, __m128i
   return (__m128i) __builtin_ia32_vpmadd52luq128_mask ((__v2di) __X,
(__v2di) __Y,
(__v2di) __Z,
-   (__mmask8) - 1);
+   (__mmask8) -1);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
@@ -121,7 +121,7 @@ _mm256_madd52lo_epu64 (__m256i __X, __m2
  

r271778 - [X86] Use unsigned types for vector arithmetic in intrinsics to avoid undefined behavior for signed integer overflow.

2016-06-03 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Jun  4 00:43:41 2016
New Revision: 271778

URL: http://llvm.org/viewvc/llvm-project?rev=271778=rev
Log:
[X86] Use unsigned types for vector arithmetic in intrinsics to avoid undefined 
behavior for signed integer overflow.

This is really only needed for addition, subtraction, and multiplication, but I 
did the bitwise ops too for overall consistency. Clang currently doesn't set 
NSW for signed vector operations so the undefined behavior shouldn't happen 
today.

Modified:
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/smmintrin.h
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/lib/Headers/avx2intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx2intrin.h?rev=271778=271777=271778=diff
==
--- cfe/trunk/lib/Headers/avx2intrin.h (original)
+++ cfe/trunk/lib/Headers/avx2intrin.h Sat Jun  4 00:43:41 2016
@@ -81,25 +81,25 @@ _mm256_packus_epi32(__m256i __V1, __m256
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_add_epi8(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v32qi)__a + (__v32qi)__b);
+  return (__m256i)((__v32qu)__a + (__v32qu)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_add_epi16(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v16hi)__a + (__v16hi)__b);
+  return (__m256i)((__v16hu)__a + (__v16hu)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_add_epi32(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v8si)__a + (__v8si)__b);
+  return (__m256i)((__v8su)__a + (__v8su)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_add_epi64(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v4di)__a + (__v4di)__b);
+  return (__m256i)((__v4du)__a + (__v4du)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
@@ -133,13 +133,13 @@ _mm256_adds_epu16(__m256i __a, __m256i _
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_and_si256(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v4di)__a & (__v4di)__b);
+  return (__m256i)((__v4du)__a & (__v4du)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_andnot_si256(__m256i __a, __m256i __b)
 {
-  return (__m256i)(~(__v4di)__a & (__v4di)__b);
+  return (__m256i)(~(__v4du)__a & (__v4du)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
@@ -462,13 +462,13 @@ _mm256_mulhi_epi16(__m256i __a, __m256i
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_mullo_epi16(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v16hi)__a * (__v16hi)__b);
+  return (__m256i)((__v16hu)__a * (__v16hu)__b);
 }
 
 static __inline__  __m256i __DEFAULT_FN_ATTRS
 _mm256_mullo_epi32 (__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v8si)__a * (__v8si)__b);
+  return (__m256i)((__v8su)__a * (__v8su)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
@@ -480,7 +480,7 @@ _mm256_mul_epu32(__m256i __a, __m256i __
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_or_si256(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v4di)__a | (__v4di)__b);
+  return (__m256i)((__v4du)__a | (__v4du)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
@@ -658,25 +658,25 @@ _mm256_srl_epi64(__m256i __a, __m128i __
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_sub_epi8(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v32qi)__a - (__v32qi)__b);
+  return (__m256i)((__v32qu)__a - (__v32qu)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_sub_epi16(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v16hi)__a - (__v16hi)__b);
+  return (__m256i)((__v16hu)__a - (__v16hu)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_sub_epi32(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v8si)__a - (__v8si)__b);
+  return (__m256i)((__v8su)__a - (__v8su)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_sub_epi64(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v4di)__a - (__v4di)__b);
+  return (__m256i)((__v4du)__a - (__v4du)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
@@ -754,7 +754,7 @@ _mm256_unpacklo_epi64(__m256i __a, __m25
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_xor_si256(__m256i __a, __m256i __b)
 {
-  return (__m256i)((__v4di)__a ^ (__v4di)__b);
+  return (__m256i)((__v4du)__a ^ (__v4du)__b);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=271778=271777=271778=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Sat Jun  4 00:43:41 2016
@@ -30,8 +30,6 @@
 
 typedef 

Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Taewook Oh via cfe-commits
twoh added a comment.

Reverted in r271761.


http://reviews.llvm.org/D19843



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Taewook Oh via cfe-commits
I reverted the patch with r271761 and r271764.

Thanks,
Taewook

On 6/3/16, 6:40 PM, "Bruno Cardoso Lopes"  wrote:

>> The information about whether the file is in a system path is already being
>> computed, so it would incur no extra overhead. I'm not sure that's the right
>> fix. You are more than welcome to revert the (clang) commit while we think
>> of the right fix.
>
>I'm not sure what the right fix is either, but given the windows issue
>and the ASAN bot failing, it doesn't make sense to leave the commit
>here without a proper fix :-)
>Taewook, can you please revert it until you guys sort out what needs
>to be done to appease the buildbots / have the solution for windows?
>
>Thanks,
>
>-- 
>Bruno Cardoso Lopes
>https://urldefense.proofpoint.com/v2/url?u=http-3A__www.brunocardoso.cc=CwIBaQ=5VD0RTtNlTh3ycd41b3MUw=kOsLCgQzH7N8ptZ7diJD9g=c5XZbyZ2UApk2hO-CxcLwd7rLibhZiOTy7SKZNpNwvc=n3ZPgVAw1y5bVd933hdXCrEkcLpjkFODPjPDfxmg9Dc=
> 

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


Re: r271761 - Revert commit r271708

2016-06-03 Thread Chandler Carruth via cfe-commits
On Fri, Jun 3, 2016 at 8:21 PM Taewook Oh via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: twoh
> Date: Fri Jun  3 22:14:43 2016
> New Revision: 271761
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271761=rev
> Log:
> Revert commit r271708
>

Please actually explain why you are reverting a patch in your change
description!


>
>
> Removed:
> cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> cfe/trunk/test/Lexer/case-insensitive-include.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/FileManager.h
> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> cfe/trunk/include/clang/Lex/DirectoryLookup.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/test/PCH/case-insensitive-include.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271761=271760=271761=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 22:14:43
> 2016
> @@ -390,7 +390,6 @@ def : DiagGroup<"sequence-point", [Unseq
>  def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
>  def KeywordAsMacro : DiagGroup<"keyword-macro">;
>  def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
> -def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
>
>  // Just silence warnings about -Wstrict-aliasing for now.
>  def : DiagGroup<"strict-aliasing=0">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271761=271760=271761=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3
> 22:14:43 2016
> @@ -274,10 +274,6 @@ def ext_missing_whitespace_after_macro_n
>"whitespace required after macro name">;
>  def warn_missing_whitespace_after_macro_name : Warning<
>"whitespace recommended after macro name">;
> -def pp_nonportable_path : Warning<
> -  "non-portable path to file '%0'; specified path differs in case from
> file"
> -  " name on disk">,
> -  InGroup;
>
>  def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
>InGroup>;
>
> Modified: cfe/trunk/include/clang/Basic/FileManager.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271761=271760=271761=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> +++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 22:14:43 2016
> @@ -52,7 +52,6 @@ public:
>  /// descriptor for the file.
>  class FileEntry {
>const char *Name;   // Name of the file.
> -  std::string RealPathName;   // Real path to the file; could be empty.
>off_t Size; // File size in bytes.
>time_t ModTime; // Modification time of file.
>const DirectoryEntry *Dir;  // Directory file lives in.
> @@ -83,7 +82,6 @@ public:
>}
>
>const char *getName() const { return Name; }
> -  StringRef tryGetRealPathName() const { return RealPathName; }
>bool isValid() const { return IsValid; }
>off_t getSize() const { return Size; }
>unsigned getUID() const { return UID; }
>
> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271761=271760=271761=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3 22:14:43
> 2016
> @@ -91,13 +91,6 @@ public:
>virtual ~File();
>/// \brief Get the status of the file.
>virtual llvm::ErrorOr status() = 0;
> -  /// \brief Get the name of the file
> -  virtual llvm::ErrorOr getName() {
> -if (auto Status = status())
> -  return Status->getName();
> -else
> -  return Status.getError();
> -  }
>/// \brief Get the contents of the file as a \p MemoryBuffer.
>virtual llvm::ErrorOr
>getBuffer(const Twine , int64_t FileSize = -1,
>
> Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
> URL:
> 

r271762 - Sema: do not attempt to sizeof a dependent type

2016-06-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jun  3 22:16:21 2016
New Revision: 271762

URL: http://llvm.org/viewvc/llvm-project?rev=271762=rev
Log:
Sema: do not attempt to sizeof a dependent type

We would attempt to evaluate the sizeof a dependent type to check for an
integral overflow.  However, because the dependent type is not yet resolved, we
cannot determine if the expression would overflow.  Report a failure to perform
a symbolic evaluation of a constant involving the dependent type.

Added:
cfe/trunk/test/SemaCXX/eval-sizeof-dependent-type.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=271762=271761=271762=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jun  3 22:16:21 2016
@@ -2024,6 +2024,11 @@ static bool HandleSizeof(EvalInfo ,
 return true;
   }
 
+  if (Type->isDependentType()) {
+Info.Diag(Loc);
+return false;
+  }
+
   if (!Type->isConstantSizeType()) {
 // sizeof(vla) is not a constantexpr: C99 6.5.3.4p2.
 // FIXME: Better diagnostic.

Added: cfe/trunk/test/SemaCXX/eval-sizeof-dependent-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/eval-sizeof-dependent-type.cpp?rev=271762=auto
==
--- cfe/trunk/test/SemaCXX/eval-sizeof-dependent-type.cpp (added)
+++ cfe/trunk/test/SemaCXX/eval-sizeof-dependent-type.cpp Fri Jun  3 22:16:21 
2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -std=c++11 
-x c++ %s
+
+typedef __SIZE_TYPE__ size_t;
+template  struct array { _Tp _M_elems[_Nm]; };
+template  struct s {
+  array v{static_cast(sizeof (T) / sizeof(T))};
+};
+


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


r271761 - Revert commit r271708

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 22:14:43 2016
New Revision: 271761

URL: http://llvm.org/viewvc/llvm-project?rev=271761=rev
Log:
Revert commit r271708


Removed:
cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/PCH/case-insensitive-include.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271761=271760=271761=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 22:14:43 2016
@@ -390,7 +390,6 @@ def : DiagGroup<"sequence-point", [Unseq
 def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
 def KeywordAsMacro : DiagGroup<"keyword-macro">;
 def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
-def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
 
 // Just silence warnings about -Wstrict-aliasing for now.
 def : DiagGroup<"strict-aliasing=0">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271761=271760=271761=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3 22:14:43 2016
@@ -274,10 +274,6 @@ def ext_missing_whitespace_after_macro_n
   "whitespace required after macro name">;
 def warn_missing_whitespace_after_macro_name : Warning<
   "whitespace recommended after macro name">;
-def pp_nonportable_path : Warning<
-  "non-portable path to file '%0'; specified path differs in case from file"
-  " name on disk">,
-  InGroup;
   
 def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
   InGroup>;

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271761=271760=271761=diff
==
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 22:14:43 2016
@@ -52,7 +52,6 @@ public:
 /// descriptor for the file.
 class FileEntry {
   const char *Name;   // Name of the file.
-  std::string RealPathName;   // Real path to the file; could be empty.
   off_t Size; // File size in bytes.
   time_t ModTime; // Modification time of file.
   const DirectoryEntry *Dir;  // Directory file lives in.
@@ -83,7 +82,6 @@ public:
   }
 
   const char *getName() const { return Name; }
-  StringRef tryGetRealPathName() const { return RealPathName; }
   bool isValid() const { return IsValid; }
   off_t getSize() const { return Size; }
   unsigned getUID() const { return UID; }

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271761=271760=271761=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3 22:14:43 2016
@@ -91,13 +91,6 @@ public:
   virtual ~File();
   /// \brief Get the status of the file.
   virtual llvm::ErrorOr status() = 0;
-  /// \brief Get the name of the file
-  virtual llvm::ErrorOr getName() {
-if (auto Status = status())
-  return Status->getName();
-else
-  return Status.getError();
-  }
   /// \brief Get the contents of the file as a \p MemoryBuffer.
   virtual llvm::ErrorOr
   getBuffer(const Twine , int64_t FileSize = -1,

Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=271761=271760=271761=diff
==
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h (original)
+++ cfe/trunk/include/clang/Lex/DirectoryLookup.h Fri Jun  3 22:14:43 2016
@@ -151,9 +151,6 @@ public:
   ///
   /// \param HS The header search instance to search with.
   ///
-  /// \param IncludeLoc the source 

Re: [clang-tools-extra] r261991 - [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-06-03 Thread Tom Stellard via cfe-commits
On Thu, Jun 02, 2016 at 01:27:51PM +0200, Alexander Kornienko wrote:
> Thank you, Tom. I'm not very familiar with the release process and it will
> indeed be better, if you merge the patch.
> 

Hi,

There were some merge conflicts, so I wasn't sure about merging the
patch. Can you either port the patch to the 3.8 branch and send it to me
or ask the maintainer to do the merge.

I'm still waiting on one more approval of another patch, so I'm going to delay 
-rc1
until Monday.

-Tom

> On Thu, Jun 2, 2016 at 3:27 AM, Tom Stellard  wrote:
> 
> > On Wed, Jun 01, 2016 at 11:19:44PM +0200, Edoardo P. wrote:
> > > Ping.
> > >
> > > Deadline to merge the changes to the 3.8 branch is today.
> > >
> >
> > I will make sure to merge this before -rc1.  Thanks for reminding me.
> >
> > -Tom
> >
> > > Cheers,
> > > Edward-san
> > >
> > > 2016-05-24 20:25 GMT+02:00 Edoardo P. :
> > > > Ping,
> > > >
> > > > who's going to merge? I have no commit access.
> > > >
> > > > Cheers,
> > > > Edward-san
> > > >
> > > >
> > > > 2016-05-20 18:34 GMT+02:00 Tom Stellard :
> > > >> Hi,
> > > >>
> > > >> This looks fine to me, go ahead and merge.
> > > >>
> > > >> -Tom
> > > >>
> > > >> On Thu, May 19, 2016 at 08:29:14PM +0200, Alexander Kornienko wrote:
> > > >>> On Thu, May 19, 2016 at 4:45 PM, Hans Wennborg 
> > wrote:
> > > >>>
> > > >>> > +Tom who manages 3.8.1
> > > >>> > +Alex who's owner of clang-tidy: is this ok for 3.8.1?
> > > >>> >
> > > >>>
> > > >>> Yes, would be nice to have this in 3.8.1. This fixes a rather
> > annoying
> > > >>> problem.
> > > >>>
> > > >>>
> > > >>> >
> > > >>> > On Thu, May 19, 2016 at 1:56 AM, Edoardo P. via cfe-commits
> > > >>> >  wrote:
> > > >>> > > Is it possible to port this commit to 3.8.1?
> > > >>> > >
> > > >>> > > Cheers,
> > > >>> > > Edward-san
> > > >>> > >
> > > >>> > > 2016-02-26 10:19 GMT+01:00 Haojian Wu via cfe-commits
> > > >>> > > :
> > > >>> > >> Author: hokein
> > > >>> > >> Date: Fri Feb 26 03:19:33 2016
> > > >>> > >> New Revision: 261991
> > > >>> > >>
> > > >>> > >> URL: http://llvm.org/viewvc/llvm-project?rev=261991=rev
> > > >>> > >> Log:
> > > >>> > >> [clang-tidy] Fix a crash issue when clang-tidy runs with
> > compilation
> > > >>> > database.
> > > >>> > >>
> > > >>> > >> Summary:
> > > >>> > >> The clang-tidy will trigger an assertion if it's not in the
> > building
> > > >>> > directory.
> > > >>> > >>
> > > >>> > >> TEST:
> > > >>> > >> cd /
> > > >>> > >> ./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p
> > build
> > > >>> > tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
> > > >>> > >>
> > > >>> > >> The crash issue is gone after applying this patch.
> > > >>> > >>
> > > >>> > >> Fixes PR24834, PR26241
> > > >>> > >>
> > > >>> > >> Reviewers: bkramer, alexfh
> > > >>> > >>
> > > >>> > >> Subscribers: rizsotto.mailinglist, cfe-commits
> > > >>> > >>
> > > >>> > >> Differential Revision: http://reviews.llvm.org/D17335
> > > >>> > >>
> > > >>> > >> Added:
> > > >>> > >>
> >  clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/
> > > >>> > >>
> > > >>> >
> > clang-tools-extra/trunk/test/clang-tidy/Inputs/compilation-database/template.json
> > > >>> > >>
> > > >>> >
> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
> > > >>> > >> Modified:
> > > >>> > >> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> > > >>> > >>
> >  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
> > > >>> > >>
> >  clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
> > > >>> > >>
> > > >>> > >> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> > > >>> > >> URL:
> > > >>> >
> > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=261991=261990=261991=diff
> > > >>> > >>
> > > >>> >
> > ==
> > > >>> > >> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
> > > >>> > >> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Feb 26
> > > >>> > 03:19:33 2016
> > > >>> > >> @@ -107,6 +107,10 @@ public:
> > > >>> > >>  DiagPrinter->BeginSourceFile(LangOpts);
> > > >>> > >>}
> > > >>> > >>
> > > >>> > >> +  SourceManager& getSourceManager() {
> > > >>> > >> +return SourceMgr;
> > > >>> > >> +  }
> > > >>> > >> +
> > > >>> > >>void reportDiagnostic(const ClangTidyError ) {
> > > >>> > >>  const ClangTidyMessage  = Error.Message;
> > > >>> > >>  SourceLocation Loc = getLocation(Message.FilePath,
> > > >>> > Message.FileOffset);
> > > >>> > >> @@ -124,7 +128,10 @@ public:
> > > >>> > >>auto Diag = Diags.Report(Loc,
> > Diags.getCustomDiagID(Level, "%0
> > > >>> > [%1]"))
> > > >>> > >><< Message.Message << Name;
> > > >>> > >>for (const tooling::Replacement  : Error.Fix) {
> > > >>> > 

Re: [PATCH] D20933: Preallocate ExplodedNode hash table

2016-06-03 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Ben,

By the way, thanks for the patch! It's a clever idea.

> The implementation of FoldingSet has a vector of bucket pointers. Reserve 
> preallocates that vector of 

>  bucket pointers to the correct size to avoid rehashing. The allocation of 
> the nodes themselves hasn't 

>  changed.


My point was that we are now preallocating more.

> With a value of 150,000 steps (the default?),


This is the maximum number of steps after which we just give up analysis. It's 
very unlikely that the analyzer will execute this many steps on average. 
Moreover, this number can be reset from command line.

I would prefer not to use the same constant here. We should use another 
constant. Maybe, we could determine the default setting from the average number 
of steps that is being executed?

You can gather statistics these and see what we get 
(http://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option):
STATISTIC(NumSteps,

  "The # of steps executed.");

STATISTIC(NumReachedMaxSteps,

  "The # of times we reached the max number of steps.");

STATISTIC(NumPathsExplored,

  "The # of paths explored by the analyzer.");

> reserve will preallocate 131072 bucket pointers 

>  (this gives a node capacity of double that). On a 64-bit system, that's a 1 
> MB allocation.

>  Note that the biggest savings are in avoiding the last rehashing. If we 
> shrink the initial size, but still 

>  rehash frequently, we'll lose a lot of the benefits.


Please, update patches with full context: 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


http://reviews.llvm.org/D20933



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Bruno Cardoso Lopes via cfe-commits
> The information about whether the file is in a system path is already being
> computed, so it would incur no extra overhead. I'm not sure that's the right
> fix. You are more than welcome to revert the (clang) commit while we think
> of the right fix.

I'm not sure what the right fix is either, but given the windows issue
and the ASAN bot failing, it doesn't make sense to leave the commit
here without a proper fix :-)
Taewook, can you please revert it until you guys sort out what needs
to be done to appease the buildbots / have the solution for windows?

Thanks,

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


Re: [PATCH] D20857: [clang-tidy] Add modernize-explicit-operator-bool check.

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

Looks like a useful check to have. I'm not sure though, that it has anything to 
do with "modernize". I'd suggest adding a new "bugprone" module (should be 
added by http://reviews.llvm.org/D18821, hopefully soon) and moving the check 
there.



Comment at: test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp:6
@@ +5,3 @@
+  operator const void *() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: implicit operator const void* 
declaration should probably be explicit operator bool 
[modernize-explicit-operator-bool]
+return reinterpret_cast(something != 0);

From the first glance, this doesn't look like an easy mistake to make. Have you 
actually seen this pattern in real code?


Comment at: test/clang-tidy/modernize-explicit-operator-bool-void-pointer.cpp:14
@@ +13,3 @@
+class SomethingGood {
+  //Note: Use modernize-explicit-operator-bool to check for implicit operator 
bool.
+  explicit operator bool() const {

nit: Please insert a space after //


http://reviews.llvm.org/D20857



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


Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

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

Most of the fixits are still useless, but I didn't notice any false positives 
(i.e. all warnings would be useful to some degree). So I suggest disabling the 
fixes completely at least for now.



Comment at: include/llvm-c/Core.h:604
@@ -603,3 +603,3 @@
  */
-LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
+bool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
char **ErrorMessage);

Prazek wrote:
> deadalnix wrote:
> > Please keep LLVMBool in the C API. ABI change are a NO NO.
> As I said in my comment, I won't commit most of the changes. This review is 
> only to show what check has found.
From what I see in this patch, changing the function type to bool not a useful 
fix, and certainly a dangerous one, since 1. ABI changes, 2. The check can't 
see all the users of the function.


Comment at: lib/AST/Decl.cpp:173
@@ -172,4 +172,3 @@
 /// and if so, is it an explicit specialization?
-template  static typename
-std::enable_if::value, 
bool>::type
+template  static bool
 isExplicitMemberSpecialization(const T *D) {

Apparently, the check should filter out template instantiations.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:1934
@@ -1933,3 +1933,3 @@
   auto Int32Ty =
-  CGF.getContext().getIntTypeForBitwidth(/*DestWidth*/ 32, /*Signed*/ 
true);
+  CGF.getContext().getIntTypeForBitwidth(/*DestWidth*/ 32, /*Signed*/ 1);
   auto ThreadIDTemp = CGF.CreateMemTemp(Int32Ty, /*Name*/ ".threadid_temp.");

Looks like the parameter type should be changed to bool instead.


Comment at: lib/CodeGen/SplitKit.h:298
@@ -297,3 +297,3 @@
 
-  typedef PointerIntPair ValueForcePair;
+  typedef PointerIntPair ValueForcePair;
   typedef DenseMap, ValueForcePair> ValueMap;

Is it an automated fix?


Comment at: lib/Target/ARM/ARMConstantIslandPass.cpp:1643
@@ -1642,3 +1642,3 @@
 bool ARMConstantIslands::removeUnusedCPEntries() {
-  unsigned MadeChange = false;
+  unsigned MadeChange = 0;
   for (unsigned i = 0, e = CPEntries.size(); i != e; ++i) {

In this case, changing the type would be better.


Comment at: utils/TableGen/CTagsEmitter.cpp:36
@@ -35,3 +35,3 @@
   : Id(), Loc(Location) {}
-  int operator<(const Tag ) const { return *Id < *B.Id; }
+  bool operator<(const Tag ) const { return *Id < *B.Id; }
   void emit(raw_ostream ) const {

One of the few cases where changing the function return type makes sense.


http://reviews.llvm.org/D19105



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


r271758 - [Modules] Improve diagnostics for LockFileManager errors

2016-06-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun  3 20:13:22 2016
New Revision: 271758

URL: http://llvm.org/viewvc/llvm-project?rev=271758=rev
Log:
[Modules] Improve diagnostics for LockFileManager errors

Uses error message now provided by LockFileManager in LLVM r271755.

rdar://problem/26529101

Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=271758=271757=271758=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri Jun  3 20:13:22 
2016
@@ -89,7 +89,7 @@ def err_module_unavailable : Error<
 def err_module_header_missing : Error<
   "%select{|umbrella }0header '%1' not found">;
 def err_module_lock_failure : Error<
-  "could not acquire lock file for module '%0'">, DefaultFatal;
+  "could not acquire lock file for module '%0': %1">, DefaultFatal;
 def err_module_lock_timeout : Error<
   "timed out waiting to acquire lock file for module '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=271758=271757=271758=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Jun  3 20:13:22 2016
@@ -1086,7 +1086,7 @@ static bool compileAndLoadModule(Compile
 switch (Locked) {
 case llvm::LockFileManager::LFS_Error:
   Diags.Report(ModuleNameLoc, diag::err_module_lock_failure)
-  << Module->Name;
+  << Module->Name << Locked.getErrorMessage();
   return false;
 
 case llvm::LockFileManager::LFS_Owned:


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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Eric Niebler via cfe-commits
The information about whether the file is in a system path is already being
computed, so it would incur no extra overhead. I'm not sure that's the
right fix. You are more than welcome to revert the (clang) commit while we
think of the right fix.

\e
On Jun 3, 2016 5:25 PM, "Bruno Cardoso Lopes" 
wrote:

I think this should be reverted until we figure out how to solve it.
Moreover, it looks expensive to check for each file if it's within a system
path. I would really like to measure compile time for this change before it
goes definitely in.

On Fri, Jun 3, 2016 at 4:53 PM, Justin Bogner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Taewook Oh via cfe-commits  writes:
> > Author: twoh
> > Date: Fri Jun  3 13:52:51 2016
> > New Revision: 271708
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
> > Log:
> > Use the name of the file on disk to issue a new diagnostic about
> > non-portable #include and #import paths.
> >
> > Differential Revision: http://reviews.llvm.org/D19843
> > Corresponding LLVM change: http://reviews.llvm.org/D19842
> >
> > Patch by Eric Niebler
> >
> >
> > Added:
> > cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> > cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> > cfe/trunk/test/Lexer/case-insensitive-include.c
> > Modified:
> > cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> > cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> > cfe/trunk/include/clang/Basic/FileManager.h
> > cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> > cfe/trunk/include/clang/Lex/DirectoryLookup.h
> > cfe/trunk/include/clang/Lex/HeaderSearch.h
> > cfe/trunk/lib/Basic/FileManager.cpp
> > cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> > cfe/trunk/lib/Lex/HeaderSearch.cpp
> > cfe/trunk/lib/Lex/PPDirectives.cpp
> > cfe/trunk/test/PCH/case-insensitive-include.c
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
> >
> ==
> >
> > --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3
> 13:52:51 2016
> > @@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
> >  def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
> >  def KeywordAsMacro : DiagGroup<"keyword-macro">;
> >  def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
> > +def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
> >
> >  // Just silence warnings about -Wstrict-aliasing for now.
> >  def : DiagGroup<"strict-aliasing=0">;
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708=271707=271708=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3
> 13:52:51 2016
> > @@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
> >"whitespace required after macro name">;
> >  def warn_missing_whitespace_after_macro_name : Warning<
> >"whitespace recommended after macro name">;
> > +def pp_nonportable_path : Warning<
> > +  "non-portable path to file '%0'; specified path differs in case from
> file"
> > +  " name on disk">,
> > +  InGroup;
> >
> >  def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
> >InGroup>;
> >
> > Modified: cfe/trunk/include/clang/Basic/FileManager.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708=271707=271708=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> > +++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
> > @@ -52,6 +52,7 @@ public:
> >  /// descriptor for the file.
> >  class FileEntry {
> >const char *Name;   // Name of the file.
> > +  std::string RealPathName;   // Real path to the file; could be empty.
> >off_t Size; // File size in bytes.
> >time_t ModTime; // Modification time of file.
> >const DirectoryEntry *Dir;  // Directory file lives in.
> > @@ -82,6 +83,7 @@ public:
> >}
> >
> >const char *getName() const { return Name; }
> > +  StringRef tryGetRealPathName() const { return RealPathName; }
> >bool isValid() const { return IsValid; }
> >off_t getSize() const { return Size; }
> >unsigned getUID() const { return UID; }
> >
> > Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> > URL:
> 

Re: [PATCH] D18821: Add bugprone-bool-to-integer-conversion

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst:37
@@ +36,3 @@
+
+It turns out that the common bug is to have function returning only bools but 
having int as return type.
+If check finds case like this then it function return type to bool.

It may well not be a bug. It's definitely not a bug for `extern "C"` functions 
and functions in C code. We definitely don't need to change the function return 
type, since it's a rather involved change (and clang-tidy checks currently are 
simply not able to make such change correctly in case of a function with 
external linkage). So please remove this automated fix.


Comment at: docs/clang-tidy/checks/bugprone-bool-to-integer-conversion.rst:41
@@ +40,3 @@
+
+.. code-block:: C++
+  int fun() {

Please check that your documentation compiles.


Comment at: test/clang-tidy/bugprone-bool-to-integer-conversion.cpp:191
@@ +190,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function has return type 'int' 
but returns only bools
+  // CHECK-FIXES: bool yat2() {
+

That's a dangerous fix. It should either be removed or guarded by an option.


http://reviews.llvm.org/D18821



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


Re: [PATCH] D20942: [LockFileManager] Improve error output by adding error messages

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

Applied your suggestions and committed in r271755!

Thanks


http://reviews.llvm.org/D20942



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


r271754 - PR27989: only enqueue binary operators into the data recursive int expression

2016-06-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jun  3 19:22:31 2016
New Revision: 271754

URL: http://llvm.org/viewvc/llvm-project?rev=271754=rev
Log:
PR27989: only enqueue binary operators into the data recursive int expression
evaluator if they are actually int expressions.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=271754=271753=271754=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Jun  3 19:22:31 2016
@@ -7112,7 +7112,9 @@ public:
   static bool shouldEnqueue(const BinaryOperator *E) {
 return E->getOpcode() == BO_Comma ||
E->isLogicalOp() ||
-   (E->getLHS()->getType()->isIntegralOrEnumerationType() &&
+   (E->isRValue() &&
+E->getType()->isIntegralOrEnumerationType() &&
+E->getLHS()->getType()->isIntegralOrEnumerationType() &&
 E->getRHS()->getType()->isIntegralOrEnumerationType());
   }
 

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=271754=271753=271754=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Fri Jun  3 19:22:31 
2016
@@ -949,3 +949,11 @@ namespace SpeculativeEvalWrites {
 
   static_assert(!f(), "");
 }
+
+namespace PR27989 {
+  constexpr int f(int n) {
+int a = (n = 1, 0);
+return n;
+  }
+  static_assert(f(0) == 1, "");
+}


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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Bruno Cardoso Lopes via cfe-commits
I think this should be reverted until we figure out how to solve it.
Moreover, it looks expensive to check for each file if it's within a system
path. I would really like to measure compile time for this change before it
goes definitely in.

On Fri, Jun 3, 2016 at 4:53 PM, Justin Bogner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Taewook Oh via cfe-commits  writes:
> > Author: twoh
> > Date: Fri Jun  3 13:52:51 2016
> > New Revision: 271708
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
> > Log:
> > Use the name of the file on disk to issue a new diagnostic about
> > non-portable #include and #import paths.
> >
> > Differential Revision: http://reviews.llvm.org/D19843
> > Corresponding LLVM change: http://reviews.llvm.org/D19842
> >
> > Patch by Eric Niebler
> >
> >
> > Added:
> > cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> > cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> > cfe/trunk/test/Lexer/case-insensitive-include.c
> > Modified:
> > cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> > cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> > cfe/trunk/include/clang/Basic/FileManager.h
> > cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> > cfe/trunk/include/clang/Lex/DirectoryLookup.h
> > cfe/trunk/include/clang/Lex/HeaderSearch.h
> > cfe/trunk/lib/Basic/FileManager.cpp
> > cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> > cfe/trunk/lib/Lex/HeaderSearch.cpp
> > cfe/trunk/lib/Lex/PPDirectives.cpp
> > cfe/trunk/test/PCH/case-insensitive-include.c
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
> >
> ==
> >
> > --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3
> 13:52:51 2016
> > @@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
> >  def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
> >  def KeywordAsMacro : DiagGroup<"keyword-macro">;
> >  def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
> > +def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
> >
> >  // Just silence warnings about -Wstrict-aliasing for now.
> >  def : DiagGroup<"strict-aliasing=0">;
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708=271707=271708=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3
> 13:52:51 2016
> > @@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
> >"whitespace required after macro name">;
> >  def warn_missing_whitespace_after_macro_name : Warning<
> >"whitespace recommended after macro name">;
> > +def pp_nonportable_path : Warning<
> > +  "non-portable path to file '%0'; specified path differs in case from
> file"
> > +  " name on disk">,
> > +  InGroup;
> >
> >  def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
> >InGroup>;
> >
> > Modified: cfe/trunk/include/clang/Basic/FileManager.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708=271707=271708=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> > +++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
> > @@ -52,6 +52,7 @@ public:
> >  /// descriptor for the file.
> >  class FileEntry {
> >const char *Name;   // Name of the file.
> > +  std::string RealPathName;   // Real path to the file; could be empty.
> >off_t Size; // File size in bytes.
> >time_t ModTime; // Modification time of file.
> >const DirectoryEntry *Dir;  // Directory file lives in.
> > @@ -82,6 +83,7 @@ public:
> >}
> >
> >const char *getName() const { return Name; }
> > +  StringRef tryGetRealPathName() const { return RealPathName; }
> >bool isValid() const { return IsValid; }
> >off_t getSize() const { return Size; }
> >unsigned getUID() const { return UID; }
> >
> > Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708=271707=271708=diff
> >
> ==
> > --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
> > +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3
> 13:52:51 2016
> > @@ 

Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-03 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:4079
@@ +4078,3 @@
+  if (ValArg.isInvalid())
+return nullptr;
+

OK, so then we want an assert, not an if?


http://reviews.llvm.org/D20985



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Justin Bogner via cfe-commits
Taewook Oh via cfe-commits  writes:
> Author: twoh
> Date: Fri Jun  3 13:52:51 2016
> New Revision: 271708
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
> Log:
> Use the name of the file on disk to issue a new diagnostic about
> non-portable #include and #import paths.
>
> Differential Revision: http://reviews.llvm.org/D19843
> Corresponding LLVM change: http://reviews.llvm.org/D19842
>
> Patch by Eric Niebler
>
>
> Added:
> cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> cfe/trunk/test/Lexer/case-insensitive-include.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/FileManager.h
> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> cfe/trunk/include/clang/Lex/DirectoryLookup.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/test/PCH/case-insensitive-include.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
> ==
>
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51 2016
> @@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
>  def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
>  def KeywordAsMacro : DiagGroup<"keyword-macro">;
>  def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
> +def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
>  
>  // Just silence warnings about -Wstrict-aliasing for now.
>  def : DiagGroup<"strict-aliasing=0">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708=271707=271708=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3 13:52:51 
> 2016
> @@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
>"whitespace required after macro name">;
>  def warn_missing_whitespace_after_macro_name : Warning<
>"whitespace recommended after macro name">;
> +def pp_nonportable_path : Warning<
> +  "non-portable path to file '%0'; specified path differs in case from file"
> +  " name on disk">,
> +  InGroup;
>
>  def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
>InGroup>;
>
> Modified: cfe/trunk/include/clang/Basic/FileManager.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708=271707=271708=diff
> ==
> --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> +++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
> @@ -52,6 +52,7 @@ public:
>  /// descriptor for the file.
>  class FileEntry {
>const char *Name;   // Name of the file.
> +  std::string RealPathName;   // Real path to the file; could be empty.
>off_t Size; // File size in bytes.
>time_t ModTime; // Modification time of file.
>const DirectoryEntry *Dir;  // Directory file lives in.
> @@ -82,6 +83,7 @@ public:
>}
>  
>const char *getName() const { return Name; }
> +  StringRef tryGetRealPathName() const { return RealPathName; }
>bool isValid() const { return IsValid; }
>off_t getSize() const { return Size; }
>unsigned getUID() const { return UID; }
>
> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708=271707=271708=diff
> ==
> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3 13:52:51 2016
> @@ -91,6 +91,13 @@ public:
>virtual ~File();
>/// \brief Get the status of the file.
>virtual llvm::ErrorOr status() = 0;
> +  /// \brief Get the name of the file
> +  virtual llvm::ErrorOr getName() {
> +if (auto Status = status())
> +  return Status->getName();
> +else
> +  return Status.getError();
> +  }
>/// \brief Get the contents of the file as a \p MemoryBuffer.
>virtual llvm::ErrorOr
>getBuffer(const Twine , int64_t FileSize = -1,
>
> Modified: 

r271750 - CodeGen: correct assertion

2016-06-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jun  3 18:26:30 2016
New Revision: 271750

URL: http://llvm.org/viewvc/llvm-project?rev=271750=rev
Log:
CodeGen: correct assertion

The assertion added earlier was overly strict.  We need to strip the pointer
casts (as when constructing the GV).  Correct the types (Function or Variable).

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

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=271750=271749=271750=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Jun  3 18:26:30 2016
@@ -2294,8 +2294,9 @@ static void configureBlocksRuntimeObject
 TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl();
 DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
 
-assert((isa(C) || isa(C)) &&
-   "expected Function or GlobalValue");
+assert((isa(C->stripPointerCasts()) ||
+isa(C->stripPointerCasts())) &&
+   "expected Function or GlobalVariable");
 
 const NamedDecl *ND = nullptr;
 for (const auto  : DC->lookup())


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


r271747 - Bump libclang API minor version after r271351.

2016-06-03 Thread Manman Ren via cfe-commits
Author: mren
Date: Fri Jun  3 18:11:41 2016
New Revision: 271747

URL: http://llvm.org/viewvc/llvm-project?rev=271747=rev
Log:
Bump libclang API minor version after r271351.

Also use the next enum value for CXObjCPropertyAttr_class.

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=271747=271746=271747=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Jun  3 18:11:41 2016
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 34
+#define CINDEX_VERSION_MINOR 35
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3912,7 +3912,7 @@ typedef enum {
   CXObjCPropertyAttr_weak  = 0x200,
   CXObjCPropertyAttr_strong= 0x400,
   CXObjCPropertyAttr_unsafe_unretained = 0x800,
-  CXObjCPropertyAttr_class = 0x4000
+  CXObjCPropertyAttr_class = 0x1000
 } CXObjCPropertyAttrKind;
 
 /**


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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Eric Niebler via cfe-commits
On 6/3/16, 3:24 PM, "tha...@google.com on behalf of Nico Weber" 
 wrote:
> On Fri, Jun 3, 2016 at 6:14 PM, Eric Niebler  wrote:
>> I just checked, and warnings are not emitted from files in an -isystem path. 
>> I didn’t have to do anything special to get that behavior.
>> I don’t know about -imsvc. Is that a clang-cl thing? I can’t say at this 
>> point why the diagnostics system treats -isystem and –imsvc
>> differently.
>>
>> How about this: I can change the diagnostic to not warn about filenames if 
>> the file is found in a system include path, regardless of
>> the location of the #include directive.
>
> That sounds like a good idea to me!

On second thought, this warning isn’t living up to its potential if it doesn’t 
warn on `#include `. And if we don’t help people find misspellings of 
IOKIt, we haven’t done much good at all.

Once I sort out the -imsvc thing, how bad would it be to leave it alone? 
Probably pretty bad for folks in the Windows world, huh?

\e







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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Nico Weber via cfe-commits
On Fri, Jun 3, 2016 at 7:07 PM, Eric Niebler  wrote:

> On 6/3/16, 3:24 PM, "tha...@google.com on behalf of Nico Weber" <
> tha...@google.com on behalf of tha...@chromium.org> wrote:
> > On Fri, Jun 3, 2016 at 6:14 PM, Eric Niebler  wrote:
> >> I just checked, and warnings are not emitted from files in an -isystem
> path. I didn’t have to do anything special to get that behavior.
> >> I don’t know about -imsvc. Is that a clang-cl thing? I can’t say at
> this point why the diagnostics system treats -isystem and –imsvc
> >> differently.
> >>
> >> How about this: I can change the diagnostic to not warn about filenames
> if the file is found in a system include path, regardless of
> >> the location of the #include directive.
> >
> > That sounds like a good idea to me!
>
> On second thought, this warning isn’t living up to its potential if it
> doesn’t warn on `#include `. And if we don’t help people find
> misspellings of IOKIt, we haven’t done much good at all.
>
> Once I sort out the -imsvc thing, how bad would it be to leave it alone?
> Probably pretty bad for folks in the Windows world, huh?
>

Yes, the warning is completely unusable there atm.


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


Re: [PATCH] D19165: [clang-tidy] Add modernize-increment-bool check.

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

> -Wdeprecated-increment-bool does it. But what I see from SemaExpr.cpp in 
> CheckIncrementDecrementOperand, it doesn't have any fixits.


If an automated fix for this issue makes sense at all, it should be implemented 
in the Clang's diagnostic. BTW, have you seen this pattern in the real code? I 
haven't. Maybe it's so rare that implementing a fix-it suggestion for it just 
isn't worth the effort?


http://reviews.llvm.org/D19165



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


Re: [PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Removing from my dashboard until http://reviews.llvm.org/D20428 is submitted.


http://reviews.llvm.org/D20693



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


Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:31
@@ +30,3 @@
+MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus) return;
+

clang-format -style=file, please.


Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:66
@@ +65,3 @@
+
+Finder->addMatcher(WholeMatcher, this);
+Finder->addMatcher(exprWithCleanups(SurroundLoopMatcher,

Each additional matcher has a certain overhead, so it's usually beneficial to 
merge matchers, if they share common parts. In this case, matchers can be 
rearranged like this:

  Finder->addMatcher(exprWithCleanups(
hasAncestor(anyOf(cxxForRangeStmt(), whileStmt(), forStmt())),
anyOf(hasDescendant(AssingOperator), hasDescendant(PlusOperatorMatcher;

However, the really serious problem with these matchers is the liberal usage of 
`hasDescendant` matcher, which traverses the whole subtree. Nested 
`hasDescendant` matchers are even worse. Note that the subtree of a statement 
can be rather large, especially if you consider lambdas. Apart from performance 
issues, `hasDescendant` and `hasAncestor` can yield unexpected results, in 
particular, when lambdas or local classes are in play. It's always better to 
use `has`, if you only need to match direct children and specifically match 
intermediate nodes, if the descendant you're interested in is always on a fixed 
depths.

Please try running your check (and maybe a few others for comparison, you can 
use `clang-tidy -enable-check-profile` to get the run time) on a few large 
translation units to estimate its performance and measure the improvement after 
changing the code.


Comment at: 
docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst:6
@@ +5,3 @@
+
+The problem
+---

`The problem` subheader is the only one here. It doesn't seem like it helps 
making the document more structured.


Comment at: 
docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst:8
@@ +7,3 @@
+---
+This check is to warn about the performance overhead arising from 
concatenating strings, using the ``operator+``, for instance:
+

s/is to warn/warns/
s/strings,/strings/


Comment at: 
docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst:20
@@ +19,3 @@
+   std::string a("Foo"), b("Baz");
+   for(int i = 0; i < 2; ++i)
+   {

Please make the code snippets use LLVM formatting for consistency. In 
particular, add a space after `for` and remove the line break before the 
opening brace.


Comment at: 
docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst:39
@@ +38,3 @@
+  
+   void f(const std::string&){}
+   std::string a("Foo"), b("Baz");

Add a space before the opening brace.


http://reviews.llvm.org/D20196



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Nico Weber via cfe-commits
On Fri, Jun 3, 2016 at 6:14 PM, Eric Niebler  wrote:

> I just checked, and warnings are not emitted from files in an -isystem
> path. I didn’t have to do anything special to get that behavior. I don’t
> know about -imsvc. Is that a clang-cl thing? I can’t say at this point why
> the diagnostics system treats -isystem and -imsvc differently.
>
>
>
> How about this: I can change the diagnostic to not warn about filenames if
> the file is found in a system include path, regardless of the location of
> the #include directive.
>

That sounds like a good idea to me!


> Other than that, I can whitelist specific filenames, but that quickly
> becomes a game of whack-a-mole.
>
>
>
> Eric
>
>
>
>
>
> On 6/3/16, 3:01 PM, "tha...@google.com on behalf of Nico Weber" <
> tha...@google.com on behalf of tha...@chromium.org> wrote:
>
>
>
> It's not just windows.h, but windows sdk headers in general (#include
> , #include  #include  #include
>  etc). Here's what the warning does on the first few files in
> Chromium:
> https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/8155/steps/compile/logs/stdio
> 
> (We add /FIIntrin.h -- but it looks like MSVC's intrin.h is called intrin.h
> while clang's is called Intrin.h, which is probably a bug in clang).
>
>
> I think in general clang's philosophy is that warnings should be useful
> enough that they should be able to be on by default, so not having it on by
> default should be some last resort. Better to try and make it work well
> enough that it can be enabled :-)
>
>
>
>
>
>
>
>
>
> On Fri, Jun 3, 2016 at 5:54 PM, Eric Niebler  wrote:
>
> I can investigate the system header issue. And I could add a special
> exception for  if folks feel that that’s the right thing to do.
> If we’re really worried about how noisy this warning could be, the warning
> could be disabled by default. Thoughts?
>
>
>
> Eric
>
>
>
>
>
> On 6/3/16, 2:46 PM, "tha...@google.com on behalf of Nico Weber" <
> tha...@google.com on behalf of tha...@chromium.org> wrote:
>
>
>
> Also, once that is resolved, this warning tells people that #include
>  is wrong:
>
>
>
> ..\..\third_party\ffmpeg\compat/w32pthreads.h(39,10):  warning:
> non-portable path to file ''; specified path differs in case
> from file name on disk [-Wnonportable-include-path]
>
> #include 
>
>  ^~~
>
>  
>
>
>
> I don't think that's realistically fixable; about all the code in the
> world includes windows.h as windows.h...any ideas what the Windows story
> for this warning should be?
>
>
>
> On Fri, Jun 3, 2016 at 5:43 PM, Nico Weber  wrote:
>
> I'm getting lots of warnings like so:
>
>
>
> In file included from
> ..\..\tools\win\static_initializers\static_initializers.cc:5:
>
> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA
> SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"';
> specified path differs in case from file name on disk
> [-Werror,-Wnonportable-include-path]
>
> #include "windows.h"
>
>  ^~~
>
>  "Windows.h"
>
>
>
> dia2.h is a system include, and we include it in the search path via
> -imsvc. Normally warnings aren't emitted for system headers. Do you know
> why this is happening here?
>
>
>
> On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: twoh
> Date: Fri Jun  3 13:52:51 2016
> New Revision: 271708
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
> 
> Log:
> Use the name of the file on disk to issue a new diagnostic about
> non-portable #include and #import paths.
>
> Differential Revision: http://reviews.llvm.org/D19843
> 
> Corresponding LLVM change: http://reviews.llvm.org/D19842
> 
>
> Patch by Eric Niebler
>
>
> Added:
> cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> cfe/trunk/test/Lexer/case-insensitive-include.c
> Modified:
> 

Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-06-03 Thread don hinton via cfe-commits
hintonda abandoned this revision.
hintonda added a comment.

This revision is OBE.


http://reviews.llvm.org/D18575



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Eric Niebler via cfe-commits
I can investigate the system header issue. And I could add a special exception 
for  if folks feel that that’s the right thing to do. If we’re 
really worried about how noisy this warning could be, the warning could be 
disabled by default. Thoughts?

Eric


On 6/3/16, 2:46 PM, "tha...@google.com on behalf of 
Nico Weber"  on behalf of 
tha...@chromium.org> wrote:

Also, once that is resolved, this warning tells people that #include 
 is wrong:

..\..\third_party\ffmpeg\compat/w32pthreads.h(39,10):  warning: non-portable 
path to file ''; specified path differs in case from file name on 
disk [-Wnonportable-include-path]
#include 
 ^~~
 

I don't think that's realistically fixable; about all the code in the world 
includes windows.h as windows.h...any ideas what the Windows story for this 
warning should be?

On Fri, Jun 3, 2016 at 5:43 PM, Nico Weber 
> wrote:
I'm getting lots of warnings like so:

In file included from 
..\..\tools\win\static_initializers\static_initializers.cc:5:
C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA
 SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"'; 
specified path differs in case from file name on disk 
[-Werror,-Wnonportable-include-path]
#include "windows.h"
 ^~~
 "Windows.h"

dia2.h is a system include, and we include it in the search path via -imsvc. 
Normally warnings aren't emitted for system headers. Do you know why this is 
happening here?

On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits 
> wrote:
Author: twoh
Date: Fri Jun  3 13:52:51 2016
New Revision: 271708

URL: 
http://llvm.org/viewvc/llvm-project?rev=271708=rev
Log:
Use the name of the file on disk to issue a new diagnostic about non-portable 
#include and #import paths.

Differential Revision: 
http://reviews.llvm.org/D19843
Corresponding LLVM change: 
http://reviews.llvm.org/D19842

Patch by Eric Niebler


Added:
cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/PCH/case-insensitive-include.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51 2016
@@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
 def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
 def KeywordAsMacro : DiagGroup<"keyword-macro">;
 def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
+def NonportableIncludePath : DiagGroup<"nonportable-include-path">;

 // Just silence warnings about -Wstrict-aliasing for now.
 def : DiagGroup<"strict-aliasing=0">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 

Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Eric Niebler via cfe-commits
I just checked, and warnings are not emitted from files in an -isystem path. I 
didn’t have to do anything special to get that behavior. I don’t know about 
-imsvc. Is that a clang-cl thing? I can’t say at this point why the diagnostics 
system treats -isystem and -imsvc differently.

How about this: I can change the diagnostic to not warn about filenames if the 
file is found in a system include path, regardless of the location of the 
#include directive. Other than that, I can whitelist specific filenames, but 
that quickly becomes a game of whack-a-mole.

Eric


On 6/3/16, 3:01 PM, "tha...@google.com on behalf of 
Nico Weber"  on behalf of 
tha...@chromium.org> wrote:

It's not just windows.h, but windows sdk headers in general (#include 
, #include  #include  #include  
etc). Here's what the warning does on the first few files in Chromium: 
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/8155/steps/compile/logs/stdio
 (We add /FIIntrin.h -- but it looks like MSVC's intrin.h is called intrin.h 
while clang's is called Intrin.h, which is probably a bug in clang).

I think in general clang's philosophy is that warnings should be useful enough 
that they should be able to be on by default, so not having it on by default 
should be some last resort. Better to try and make it work well enough that it 
can be enabled :-)




On Fri, Jun 3, 2016 at 5:54 PM, Eric Niebler 
> wrote:
I can investigate the system header issue. And I could add a special exception 
for  if folks feel that that’s the right thing to do. If we’re 
really worried about how noisy this warning could be, the warning could be 
disabled by default. Thoughts?

Eric


On 6/3/16, 2:46 PM, "tha...@google.com on behalf of 
Nico Weber"  on behalf of 
tha...@chromium.org> wrote:

Also, once that is resolved, this warning tells people that #include 
 is wrong:

..\..\third_party\ffmpeg\compat/w32pthreads.h(39,10):  warning: non-portable 
path to file ''; specified path differs in case from file name on 
disk [-Wnonportable-include-path]
#include 
 ^~~
 

I don't think that's realistically fixable; about all the code in the world 
includes windows.h as windows.h...any ideas what the Windows story for this 
warning should be?

On Fri, Jun 3, 2016 at 5:43 PM, Nico Weber 
> wrote:
I'm getting lots of warnings like so:

In file included from 
..\..\tools\win\static_initializers\static_initializers.cc:5:
C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA
 SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"'; 
specified path differs in case from file name on disk 
[-Werror,-Wnonportable-include-path]
#include "windows.h"
 ^~~
 "Windows.h"

dia2.h is a system include, and we include it in the search path via -imsvc. 
Normally warnings aren't emitted for system headers. Do you know why this is 
happening here?

On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits 
> wrote:
Author: twoh
Date: Fri Jun  3 13:52:51 2016
New Revision: 271708

URL: 
http://llvm.org/viewvc/llvm-project?rev=271708=rev
Log:
Use the name of the file on disk to issue a new diagnostic about non-portable 
#include and #import paths.

Differential Revision: 
http://reviews.llvm.org/D19843
Corresponding LLVM change: 
http://reviews.llvm.org/D19842

Patch by Eric Niebler


Added:
cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
 

Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh resigned from this revision.
alexfh removed a reviewer: alexfh.
alexfh added a comment.

Cleaning up my Phab dashboard. If http://reviews.llvm.org/D20428 doesn't happen 
and we'll have to return to this implementation, please re-add me to the 
reviewers.


http://reviews.llvm.org/D18575



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


Re: [PATCH] D20689: [clang-tidy] Suspicious Call Argument checker

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

In http://reviews.llvm.org/D20689#443266, @varjujan wrote:

> Yes, I did. The results from running the checker on LLVM are in the attached 
> file. Sadly, I could'nt find any real mistakes but as I wrote in the summary, 
> false positives can still indicate bad naming convention for some variables.
>
> F1991684: result.txt 


It looks like the check doesn't meet the quality bar, at least, in its current 
form. "Bad naming convention" is a very arguable thing and I'm not sure we can 
claim that the pattern detected by the check is somehow an indication of a bad 
naming convention.


http://reviews.llvm.org/D20689



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Nico Weber via cfe-commits
It's not just windows.h, but windows sdk headers in general (#include
, #include  #include  #include
 etc). Here's what the warning does on the first few files in
Chromium:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin/builds/8155/steps/compile/logs/stdio
(We add /FIIntrin.h -- but it looks like MSVC's intrin.h is called intrin.h
while clang's is called Intrin.h, which is probably a bug in clang).

I think in general clang's philosophy is that warnings should be useful
enough that they should be able to be on by default, so not having it on by
default should be some last resort. Better to try and make it work well
enough that it can be enabled :-)




On Fri, Jun 3, 2016 at 5:54 PM, Eric Niebler  wrote:

> I can investigate the system header issue. And I could add a special
> exception for  if folks feel that that’s the right thing to do.
> If we’re really worried about how noisy this warning could be, the warning
> could be disabled by default. Thoughts?
>
>
>
> Eric
>
>
>
>
>
> On 6/3/16, 2:46 PM, "tha...@google.com on behalf of Nico Weber" <
> tha...@google.com on behalf of tha...@chromium.org> wrote:
>
>
>
> Also, once that is resolved, this warning tells people that #include
>  is wrong:
>
>
>
> ..\..\third_party\ffmpeg\compat/w32pthreads.h(39,10):  warning:
> non-portable path to file ''; specified path differs in case
> from file name on disk [-Wnonportable-include-path]
>
> #include 
>
>  ^~~
>
>  
>
>
>
> I don't think that's realistically fixable; about all the code in the
> world includes windows.h as windows.h...any ideas what the Windows story
> for this warning should be?
>
>
>
> On Fri, Jun 3, 2016 at 5:43 PM, Nico Weber  wrote:
>
> I'm getting lots of warnings like so:
>
>
>
> In file included from
> ..\..\tools\win\static_initializers\static_initializers.cc:5:
>
> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA
> SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"';
> specified path differs in case from file name on disk
> [-Werror,-Wnonportable-include-path]
>
> #include "windows.h"
>
>  ^~~
>
>  "Windows.h"
>
>
>
> dia2.h is a system include, and we include it in the search path via
> -imsvc. Normally warnings aren't emitted for system headers. Do you know
> why this is happening here?
>
>
>
> On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: twoh
> Date: Fri Jun  3 13:52:51 2016
> New Revision: 271708
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
> 
> Log:
> Use the name of the file on disk to issue a new diagnostic about
> non-portable #include and #import paths.
>
> Differential Revision: http://reviews.llvm.org/D19843
> 
> Corresponding LLVM change: http://reviews.llvm.org/D19842
> 
>
> Patch by Eric Niebler
>
>
> Added:
> cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> cfe/trunk/test/Lexer/case-insensitive-include.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/FileManager.h
> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> cfe/trunk/include/clang/Lex/DirectoryLookup.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/test/PCH/case-insensitive-include.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
> 
>
> ==
> --- 

Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-03 Thread Artem Belevich via cfe-commits
tra marked 3 inline comments as done.


Comment at: lib/Sema/SemaDeclAttr.cpp:4046
@@ +4045,3 @@
+// non-nullptr Expr result on success. Returns nullptr otherwise and
+// may output an error.
+static Expr *makeLaunchBoundsArgExpr(Sema , Expr *E,

jlebar wrote:
> Presumably it "returns nullptr and outputs an error" otherwise?  Like, we get 
> nullptr iff it outputs an error?
It returns nullptr without error message in case of unexpanded parameter pack.
Arguments for that case will be checked after template instantiation is done. 
See instantiateDependentCUDALaunchBoundsAttr() in 
SemaTemplateInstantiateDecl.cpp.


Comment at: lib/Sema/SemaDeclAttr.cpp:4079
@@ +4078,3 @@
+  if (ValArg.isInvalid())
+return nullptr;
+

jlebar wrote:
> Do we need to output an error here, or is does PerformCopyInitialization do 
> so for us?  In any case, is it covered by a test?
Actually, by this point we've verified that Expr is an ICE. I assume that 
PerformCopyInitialization() should always succeed for such an expression.




http://reviews.llvm.org/D20985



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


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-03 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 59631.
tra marked an inline comment as done.
tra added a comment.

Rephrased comments


http://reviews.llvm.org/D20985

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCUDA/launch-bounds.cu
  test/SemaCUDA/pr27778.cu

Index: test/SemaCUDA/pr27778.cu
===
--- /dev/null
+++ test/SemaCUDA/pr27778.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+#include "Inputs/cuda.h"
+
+const int constint = 512;
+__launch_bounds__(constint) void TestConstInt(void) {}
Index: test/CodeGenCUDA/launch-bounds.cu
===
--- test/CodeGenCUDA/launch-bounds.cu
+++ test/CodeGenCUDA/launch-bounds.cu
@@ -79,3 +79,8 @@
 }
 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"maxntidx",
 // CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"minctasm",
+
+const char constchar = 12;
+__global__ void __launch_bounds__(constint, constchar) Kernel8() {}
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"maxntidx", i32 100
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"minctasm", i32 12
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -28,6 +28,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/DelayedDiagnostic.h"
+#include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/StringExtras.h"
@@ -4039,48 +4040,60 @@
   return false;
 }
 
-// Checks whether an argument of launch_bounds attribute is acceptable
-// May output an error.
-static bool checkLaunchBoundsArgument(Sema , Expr *E,
-  const CUDALaunchBoundsAttr ,
-  const unsigned Idx) {
+// Checks whether an argument of launch_bounds attribute is
+// acceptable, performs implicit conversion to Rvalue, and returns
+// non-nullptr Expr result on success. Otherwise, it returns nullptr
+// and may output an error.
+static Expr *makeLaunchBoundsArgExpr(Sema , Expr *E,
+ const CUDALaunchBoundsAttr ,
+ const unsigned Idx) {
   if (S.DiagnoseUnexpandedParameterPack(E))
-return false;
+return nullptr;
 
   // Accept template arguments for now as they depend on something else.
   // We'll get to check them when they eventually get instantiated.
   if (E->isValueDependent())
-return true;
+return E;
 
   llvm::APSInt I(64);
   if (!E->isIntegerConstantExpr(I, S.Context)) {
 S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
 <<  << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
-return false;
+return nullptr;
   }
   // Make sure we can fit it in 32 bits.
   if (!I.isIntN(32)) {
 S.Diag(E->getExprLoc(), diag::err_ice_too_large) << I.toString(10, false)
  << 32 << /* Unsigned */ 1;
-return false;
+return nullptr;
   }
   if (I < 0)
 S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative)
 <<  << Idx << E->getSourceRange();
 
-  return true;
+  // We may need to perform implicit conversion of the argument.
+  InitializedEntity Entity = InitializedEntity::InitializeParameter(
+  S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false);
+  ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E);
+  if (ValArg.isInvalid())
+return nullptr;
+
+  return ValArg.getAs();
 }
 
 void Sema::AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
Expr *MinBlocks, unsigned SpellingListIndex) {
   CUDALaunchBoundsAttr TmpAttr(AttrRange, Context, MaxThreads, MinBlocks,
SpellingListIndex);
-
-  if (!checkLaunchBoundsArgument(*this, MaxThreads, TmpAttr, 0))
+  MaxThreads = makeLaunchBoundsArgExpr(*this, MaxThreads, TmpAttr, 0);
+  if (MaxThreads == nullptr)
 return;
 
-  if (MinBlocks && !checkLaunchBoundsArgument(*this, MinBlocks, TmpAttr, 1))
-return;
+  if (MinBlocks) {
+MinBlocks = makeLaunchBoundsArgExpr(*this, MinBlocks, TmpAttr, 1);
+if (MinBlocks == nullptr)
+  return;
+  }
 
   D->addAttr(::new (Context) CUDALaunchBoundsAttr(
   AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-06-03 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 59630.
yaxunl marked 10 inline comments as done.
yaxunl added a comment.

Add a sema test for mismatched type size. Fix codegen test.


http://reviews.llvm.org/D20133

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGenOpenCL/as_type.cl
  test/SemaOpenCL/as_type.cl

Index: test/SemaOpenCL/as_type.cl
===
--- /dev/null
+++ test/SemaOpenCL/as_type.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -verify -fsyntax-only
+
+typedef __attribute__(( ext_vector_type(3) )) char char3;
+typedef __attribute__(( ext_vector_type(16) )) char char16;
+
+char3 f1(char16 x) {
+  return  __builtin_astype(x, char3); // expected-error{{invalid reinterpretation: sizes of 'char3' (vector of 3 'char' values) and 'char16' (vector of 16 'char' values) must match}}
+}
+
+char16 f3(int x) {
+  return __builtin_astype(x, char16); // expected-error{{invalid reinterpretation: sizes of 'char16' (vector of 16 'char' values) and 'int' must match}}
+}
+
Index: test/CodeGenOpenCL/as_type.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/as_type.cl
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(3) )) char char3;
+typedef __attribute__(( ext_vector_type(4) )) char char4;
+typedef __attribute__(( ext_vector_type(16) )) char char16;
+typedef __attribute__(( ext_vector_type(3) )) int int3;
+
+//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x i32> 
+//CHECK: ret <3 x i8> %[[astype]]
+char3 f1(char4 x) {
+  return  __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func <4 x i8> @f2(<3 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> 
+//CHECK: ret <4 x i8> %[[astype]]
+char4 f2(char3 x) {
+  return __builtin_astype(x, char4);
+}
+
+//CHECK: define spir_func <3 x i8> @f3(i32 %[[x:.*]])
+//CHECK: %[[cast:.*]] = bitcast i32 %[[x]] to <4 x i8>
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[cast]], <4 x i8> undef, <3 x i32> 
+//CHECK: ret <3 x i8> %[[astype]]
+char3 f3(int x) {
+  return __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func <4 x i8> @f4(i32 %[[x:.*]])
+//CHECK: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
+//CHECK-NOT: shufflevector
+//CHECK: ret <4 x i8> %[[astype]]
+char4 f4(int x) {
+  return __builtin_astype(x, char4);
+}
+
+//CHECK: define spir_func i32 @f5(<3 x i8> %[[x:.*]])
+//CHECK: %[[shuffle:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> 
+//CHECK: %[[astype:.*]] = bitcast <4 x i8> %[[shuffle]] to i32
+//CHECK: ret i32 %[[astype]]
+int f5(char3 x) {
+  return __builtin_astype(x, int);
+}
+
+//CHECK: define spir_func i32 @f6(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype]] = bitcast <4 x i8> %[[x]] to i32
+//CHECK-NOT: shufflevector
+//CHECK: ret i32 %[[astype]]
+int f6(char4 x) {
+  return __builtin_astype(x, int);
+}
+
+//CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
+//CHECK-NOT: bitcast
+//CHECK-NOT: shufflevector
+//CHECK: ret <3 x i8> %[[x]]
+char3 f7(char3 x) {
+  return __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func <3 x i32> @f8(<16 x i8> %[[x:.*]])
+//CHECK: %[[cast:.*]] = bitcast <16 x i8> %[[x]] to <4 x i32>
+//CHECK: %[[astype:.*]] = shufflevector <4 x i32> %[[cast]], <4 x i32> undef, <3 x i32> 
+//CHECK: ret <3 x i32> %[[astype]]
+int3 f8(char16 x) {
+  return __builtin_astype(x, int3);
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3382,50 +3382,48 @@
   return CGF.EmitBlockLiteral(block);
 }
 
+// Convert a vec3 to vec4, or vice versa.
+static Value *ConvertVec3AndVec4(CGBuilderTy , CodeGenFunction ,
+ Value *Src, unsigned NumElementsDst) {
+  llvm::Value *UnV = llvm::UndefValue::get(Src->getType());
+  SmallVector Args;
+  Args.push_back(Builder.getInt32(0));
+  Args.push_back(Builder.getInt32(1));
+  Args.push_back(Builder.getInt32(2));
+  if (NumElementsDst == 4)
+Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
+  llvm::Constant *Mask = llvm::ConstantVector::get(Args);
+  return Builder.CreateShuffleVector(Src, UnV, Mask);
+}
+
 Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
   Value *Src  = CGF.EmitScalarExpr(E->getSrcExpr());
   llvm::Type *DstTy = ConvertType(E->getType());
 
-  // Going from vec4->vec3 or vec3->vec4 is a special case and requires
-  // a shuffle vector instead of a bitcast.
   llvm::Type *SrcTy = Src->getType();
-  if (isa(DstTy) && isa(SrcTy)) {
-unsigned numElementsDst = cast(DstTy)->getNumElements();
-unsigned numElementsSrc = cast(SrcTy)->getNumElements();
-if ((numElementsDst == 3 && 

Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.

2016-06-03 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/CodeGen/CGExprScalar.cpp:3394
@@ +3393,3 @@
+  if (NumElementsDst == 4)
+Args.push_back(llvm::UndefValue::get(CGF.Int32Ty));
+  llvm::Constant *Mask = llvm::ConstantVector::get(Args);

Anastasia wrote:
> should this be 3 unstead of undef?
3 or undef are both OK here since the 4th component is undefined. undef may be 
better since if optimizer checks mask first, it knows that the 4th component is 
undefined without further checking the second operand.


Comment at: test/CodeGenOpenCL/as_type.cl:8
@@ +7,3 @@
+
+//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x 
i32> 

Anastasia wrote:
> So what happens if the number of bytes don't match?
There will be compilation error and diag msg. I will add a sema test.


Comment at: test/CodeGenOpenCL/as_type.cl:46
@@ +45,3 @@
+//CHECK: define spir_func i32 @f6(<4 x i8> %[[x:.*]])
+//CHECK: %[[astype]] = bitcast <4 x i8> %[[x]] to i32
+//CHECK: ret i32 %[[astype]]

Anastasia wrote:
> Would it make sense to check that shufflevector is not generated?
will fix


Comment at: test/CodeGenOpenCL/as_type.cl:53
@@ +52,3 @@
+//CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]])
+//CHECK: ret <3 x i8> %[[x]]
+char3 f7(char3 x) {

Anastasia wrote:
> Could we add CHECK-NOT bitcast here?
will fix


http://reviews.llvm.org/D20133



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Nico Weber via cfe-commits
Also, once that is resolved, this warning tells people that #include
 is wrong:

..\..\third_party\ffmpeg\compat/w32pthreads.h(39,10):  warning:
non-portable path to file ''; specified path differs in case
from file name on disk [-Wnonportable-include-path]
#include 
 ^~~
 

I don't think that's realistically fixable; about all the code in the world
includes windows.h as windows.h...any ideas what the Windows story for this
warning should be?

On Fri, Jun 3, 2016 at 5:43 PM, Nico Weber  wrote:

> I'm getting lots of warnings like so:
>
> In file included from
> ..\..\tools\win\static_initializers\static_initializers.cc:5:
> C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA
> SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"';
> specified path differs in case from file name on disk
> [-Werror,-Wnonportable-include-path]
> #include "windows.h"
>  ^~~
>  "Windows.h"
>
> dia2.h is a system include, and we include it in the search path via
> -imsvc. Normally warnings aren't emitted for system headers. Do you know
> why this is happening here?
>
> On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: twoh
>> Date: Fri Jun  3 13:52:51 2016
>> New Revision: 271708
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
>> Log:
>> Use the name of the file on disk to issue a new diagnostic about
>> non-portable #include and #import paths.
>>
>> Differential Revision: http://reviews.llvm.org/D19843
>> Corresponding LLVM change: http://reviews.llvm.org/D19842
>>
>> Patch by Eric Niebler
>>
>>
>> Added:
>> cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
>> cfe/trunk/test/Lexer/case-insensitive-include-ms.c
>> cfe/trunk/test/Lexer/case-insensitive-include.c
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/include/clang/Basic/FileManager.h
>> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
>> cfe/trunk/include/clang/Lex/DirectoryLookup.h
>> cfe/trunk/include/clang/Lex/HeaderSearch.h
>> cfe/trunk/lib/Basic/FileManager.cpp
>> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>> cfe/trunk/lib/Lex/HeaderSearch.cpp
>> cfe/trunk/lib/Lex/PPDirectives.cpp
>> cfe/trunk/test/PCH/case-insensitive-include.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51
>> 2016
>> @@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
>>  def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
>>  def KeywordAsMacro : DiagGroup<"keyword-macro">;
>>  def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
>> +def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
>>
>>  // Just silence warnings about -Wstrict-aliasing for now.
>>  def : DiagGroup<"strict-aliasing=0">;
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708=271707=271708=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3
>> 13:52:51 2016
>> @@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
>>"whitespace required after macro name">;
>>  def warn_missing_whitespace_after_macro_name : Warning<
>>"whitespace recommended after macro name">;
>> +def pp_nonportable_path : Warning<
>> +  "non-portable path to file '%0'; specified path differs in case from
>> file"
>> +  " name on disk">,
>> +  InGroup;
>>
>>  def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
>>InGroup>;
>>
>> Modified: cfe/trunk/include/clang/Basic/FileManager.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708=271707=271708=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/FileManager.h (original)
>> +++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
>> @@ -52,6 +52,7 @@ public:
>>  /// descriptor for the file.
>>  class FileEntry {
>>const char *Name;   // Name of the file.
>> +  std::string RealPathName;   // Real path to the file; could be empty.
>>off_t Size; // File size in bytes.
>>time_t ModTime; // Modification time of file.
>>

Re: [PATCH] D20853: [clang-tidy] misc-macro-parentheses: Don't insert parentheses in variable declarations. Fixes bugzilla 26273

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

Looks good with a few style comments.



Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:82
@@ +81,3 @@
+
+  // If we see int/short/struct etc just assume this is a variable declaration
+  if (isVarDeclKeyword(*Tok))

Either `If we see int/short/struct/etc., ` or `If we see int, short, struct, 
etc., `.
Please also add a trailing period.  


Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:86
@@ +85,3 @@
+
+  // Variable declarations start with identifier or coloncolon
+  if (!Tok->isOneOf(tok::identifier, tok::raw_identifier, tok::coloncolon))

Trailing period, please.


Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:93
@@ +92,3 @@
+  Tok != MI->tokens_end() &&
+  (Tok->isOneOf(tok::identifier, tok::raw_identifier, tok::coloncolon,
+tok::star, tok::amp, tok::ampamp, tok::less, 
tok::greater)))

Please remove parentheses around the method call.


Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:97
@@ +96,3 @@
+
+  // Return true for possible variable declarations
+  return Tok == MI->tokens_end() ||

Trailing period.


Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:105
@@ -71,1 +104,3 @@
   const MacroInfo *MI) {
+  // Make sure macro replacement isn't a variable declaration
+  if (possibleVarDecl(MI, MI->tokens_begin()))

Trailing period.


Comment at: clang-tidy/misc/MacroParenthesesCheck.cpp:158
@@ +157,3 @@
+  
+  // Skip variable declaration
+  bool VarDecl = possibleVarDecl(MI, MI->tokens_begin());

ditto


Repository:
  rL LLVM

http://reviews.llvm.org/D20853



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


Re: r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Nico Weber via cfe-commits
I'm getting lots of warnings like so:

In file included from
..\..\tools\win\static_initializers\static_initializers.cc:5:
C:\b\depot_tools\win_toolchain\vs_files\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\DIA
SDK\include\dia2.h(30,10):  error: non-portable path to file '"Windows.h"';
specified path differs in case from file name on disk
[-Werror,-Wnonportable-include-path]
#include "windows.h"
 ^~~
 "Windows.h"

dia2.h is a system include, and we include it in the search path via
-imsvc. Normally warnings aren't emitted for system headers. Do you know
why this is happening here?

On Fri, Jun 3, 2016 at 2:52 PM, Taewook Oh via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: twoh
> Date: Fri Jun  3 13:52:51 2016
> New Revision: 271708
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
> Log:
> Use the name of the file on disk to issue a new diagnostic about
> non-portable #include and #import paths.
>
> Differential Revision: http://reviews.llvm.org/D19843
> Corresponding LLVM change: http://reviews.llvm.org/D19842
>
> Patch by Eric Niebler
>
>
> Added:
> cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
> cfe/trunk/test/Lexer/case-insensitive-include-ms.c
> cfe/trunk/test/Lexer/case-insensitive-include.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/include/clang/Basic/FileManager.h
> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> cfe/trunk/include/clang/Lex/DirectoryLookup.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/test/PCH/case-insensitive-include.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51
> 2016
> @@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
>  def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
>  def KeywordAsMacro : DiagGroup<"keyword-macro">;
>  def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
> +def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
>
>  // Just silence warnings about -Wstrict-aliasing for now.
>  def : DiagGroup<"strict-aliasing=0">;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708=271707=271708=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3
> 13:52:51 2016
> @@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
>"whitespace required after macro name">;
>  def warn_missing_whitespace_after_macro_name : Warning<
>"whitespace recommended after macro name">;
> +def pp_nonportable_path : Warning<
> +  "non-portable path to file '%0'; specified path differs in case from
> file"
> +  " name on disk">,
> +  InGroup;
>
>  def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
>InGroup>;
>
> Modified: cfe/trunk/include/clang/Basic/FileManager.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708=271707=271708=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/FileManager.h (original)
> +++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
> @@ -52,6 +52,7 @@ public:
>  /// descriptor for the file.
>  class FileEntry {
>const char *Name;   // Name of the file.
> +  std::string RealPathName;   // Real path to the file; could be empty.
>off_t Size; // File size in bytes.
>time_t ModTime; // Modification time of file.
>const DirectoryEntry *Dir;  // Directory file lives in.
> @@ -82,6 +83,7 @@ public:
>}
>
>const char *getName() const { return Name; }
> +  StringRef tryGetRealPathName() const { return RealPathName; }
>bool isValid() const { return IsValid; }
>off_t getSize() const { return Size; }
>unsigned getUID() const { return UID; }
>
> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708=271707=271708=diff
>
> ==
> --- 

Re: [PATCH] D20856: [clang-tidy] readability-identifier-naming - Support for Type Aliases

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

Looks good. Thank you for the patch! Do you need me to submit it?


http://reviews.llvm.org/D20856



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


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-03 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Sema/SemaDeclAttr.cpp:4044
@@ +4043,3 @@
+// Checks whether an argument of launch_bounds attribute is
+// acceptable, performs implicit conversion to Rvalue and returns
+// non-nullptr Expr result on success. Returns nullptr otherwise and

Nit, Oxford comma helps some here.


Comment at: lib/Sema/SemaDeclAttr.cpp:4046
@@ +4045,3 @@
+// non-nullptr Expr result on success. Returns nullptr otherwise and
+// may output an error.
+static Expr *makeLaunchBoundsArgExpr(Sema , Expr *E,

Presumably it "returns nullptr and outputs an error" otherwise?  Like, we get 
nullptr iff it outputs an error?


Comment at: lib/Sema/SemaDeclAttr.cpp:4079
@@ +4078,3 @@
+  if (ValArg.isInvalid())
+return nullptr;
+

Do we need to output an error here, or is does PerformCopyInitialization do so 
for us?  In any case, is it covered by a test?


http://reviews.llvm.org/D20985



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


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-03 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 59624.
tra added a comment.

Addressed Justin's comments.


http://reviews.llvm.org/D20985

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCUDA/launch-bounds.cu
  test/SemaCUDA/pr27778.cu

Index: test/SemaCUDA/pr27778.cu
===
--- /dev/null
+++ test/SemaCUDA/pr27778.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+#include "Inputs/cuda.h"
+
+const int constint = 512;
+__launch_bounds__(constint) void TestConstInt(void) {}
Index: test/CodeGenCUDA/launch-bounds.cu
===
--- test/CodeGenCUDA/launch-bounds.cu
+++ test/CodeGenCUDA/launch-bounds.cu
@@ -79,3 +79,8 @@
 }
 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"maxntidx",
 // CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"minctasm",
+
+const char constchar = 12;
+__global__ void __launch_bounds__(constint, constchar) Kernel8() {}
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"maxntidx", i32 100
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"minctasm", i32 12
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -28,6 +28,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/DelayedDiagnostic.h"
+#include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/StringExtras.h"
@@ -4039,48 +4040,60 @@
   return false;
 }
 
-// Checks whether an argument of launch_bounds attribute is acceptable
-// May output an error.
-static bool checkLaunchBoundsArgument(Sema , Expr *E,
-  const CUDALaunchBoundsAttr ,
-  const unsigned Idx) {
+// Checks whether an argument of launch_bounds attribute is
+// acceptable, performs implicit conversion to Rvalue and returns
+// non-nullptr Expr result on success. Returns nullptr otherwise and
+// may output an error.
+static Expr *makeLaunchBoundsArgExpr(Sema , Expr *E,
+ const CUDALaunchBoundsAttr ,
+ const unsigned Idx) {
   if (S.DiagnoseUnexpandedParameterPack(E))
-return false;
+return nullptr;
 
   // Accept template arguments for now as they depend on something else.
   // We'll get to check them when they eventually get instantiated.
   if (E->isValueDependent())
-return true;
+return E;
 
   llvm::APSInt I(64);
   if (!E->isIntegerConstantExpr(I, S.Context)) {
 S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
 <<  << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
-return false;
+return nullptr;
   }
   // Make sure we can fit it in 32 bits.
   if (!I.isIntN(32)) {
 S.Diag(E->getExprLoc(), diag::err_ice_too_large) << I.toString(10, false)
  << 32 << /* Unsigned */ 1;
-return false;
+return nullptr;
   }
   if (I < 0)
 S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative)
 <<  << Idx << E->getSourceRange();
 
-  return true;
+  // We may need to perform implicit conversion of the argument.
+  InitializedEntity Entity = InitializedEntity::InitializeParameter(
+  S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false);
+  ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E);
+  if (ValArg.isInvalid())
+return nullptr;
+
+  return ValArg.getAs();
 }
 
 void Sema::AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
Expr *MinBlocks, unsigned SpellingListIndex) {
   CUDALaunchBoundsAttr TmpAttr(AttrRange, Context, MaxThreads, MinBlocks,
SpellingListIndex);
-
-  if (!checkLaunchBoundsArgument(*this, MaxThreads, TmpAttr, 0))
+  MaxThreads = makeLaunchBoundsArgExpr(*this, MaxThreads, TmpAttr, 0);
+  if (MaxThreads == nullptr)
 return;
 
-  if (MinBlocks && !checkLaunchBoundsArgument(*this, MinBlocks, TmpAttr, 1))
-return;
+  if (MinBlocks) {
+MinBlocks = makeLaunchBoundsArgExpr(*this, MinBlocks, TmpAttr, 1);
+if (MinBlocks == nullptr)
+  return;
+  }
 
   D->addAttr(::new (Context) CUDALaunchBoundsAttr(
   AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271739: [clang-tidy] modernize-use-auto: don't remove stars 
by default (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D20917?vs=59599=59625#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20917

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
@@ -243,6 +243,14 @@
 
 } // namespace
 
+UseAutoCheck::UseAutoCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  RemoveStars(Options.get("RemoveStars", 0)) {}
+
+void UseAutoCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "RemoveStars", RemoveStars ? 1 : 0);
+}
+
 void UseAutoCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
@@ -311,7 +319,7 @@
 
   const QualType FirstDeclType = FirstDecl->getType().getCanonicalType();
 
-  std::vector StarLocations;
+  std::vector StarRemovals;
   for (const auto *Dec : D->decls()) {
 const auto *V = cast(Dec);
 // Ensure that every DeclStmt child is a VarDecl.
@@ -327,39 +335,44 @@
 if (!Context->hasSameUnqualifiedType(V->getType(), NewExpr->getType()))
   return;
 
-// Remove explicitly written '*' from declarations where there's more than
-// one declaration in the declaration list.
-if (Dec == *D->decl_begin())
-  continue;
-
-// All subsequent declarations should match the same non-decorated type.
+// All subsequent variables in this declaration should have the same
+// canonical type.  For example, we don't want to use `auto` in
+// `T *p = new T, **pp = new T*;`.
 if (FirstDeclType != V->getType().getCanonicalType())
   return;
 
-auto Q = V->getTypeSourceInfo()->getTypeLoc().getAs();
-while (!Q.isNull()) {
-  StarLocations.push_back(Q.getStarLoc());
-  Q = Q.getNextTypeLoc().getAs();
+if (RemoveStars) {
+  // Remove explicitly written '*' from declarations where there's more than
+  // one declaration in the declaration list.
+  if (Dec == *D->decl_begin())
+continue;
+
+  auto Q = V->getTypeSourceInfo()->getTypeLoc().getAs();
+  while (!Q.isNull()) {
+StarRemovals.push_back(FixItHint::CreateRemoval(Q.getStarLoc()));
+Q = Q.getNextTypeLoc().getAs();
+  }
 }
   }
 
   // FIXME: There is, however, one case we can address: when the VarDecl pointee
   // is the same as the initializer, just more CV-qualified. However, TypeLoc
   // information is not reliable where CV qualifiers are concerned so we can't
   // do anything about this case for now.
-  SourceRange Range(
-  FirstDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange());
+  TypeLoc Loc = FirstDecl->getTypeSourceInfo()->getTypeLoc();
+  if (!RemoveStars) {
+while (Loc.getTypeLocClass() == TypeLoc::Pointer ||
+   Loc.getTypeLocClass() == TypeLoc::Qualified)
+  Loc = Loc.getNextTypeLoc();
+  }
+  SourceRange Range(Loc.getSourceRange());
   auto Diag = diag(Range.getBegin(), "use auto when initializing with new"
  " to avoid duplicating the type name");
 
   // Space after 'auto' to handle cases where the '*' in the pointer type is
   // next to the identifier. This avoids changing 'int *p' into 'autop'.
-  Diag << FixItHint::CreateReplacement(Range, "auto ");
-
-  // Remove '*' from declarations using the saved star locations.
-  for (const auto  : StarLocations) {
-Diag << FixItHint::CreateReplacement(Loc, "");
-  }
+  Diag << FixItHint::CreateReplacement(Range, RemoveStars ? "auto " : "auto")
+   << StarRemovals;
 }
 
 void UseAutoCheck::check(const MatchFinder::MatchResult ) {
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
@@ -18,15 +18,16 @@
 
 class UseAutoCheck : public ClangTidyCheck {
 public:
-  UseAutoCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
-
+  UseAutoCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void 

[clang-tools-extra] r271739 - [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jun  3 16:22:58 2016
New Revision: 271739

URL: http://llvm.org/viewvc/llvm-project?rev=271739=rev
Log:
[clang-tidy] modernize-use-auto: don't remove stars by default

Summary:
By default, modernize-use-auto check will retain stars when replacing an 
explicit type with `auto`: `MyType *t = new MyType;` will be changed to `auto 
*t = new MyType;`, thus resulting in more consistency with the recommendations 
to use `auto *` for iterating over pointers in range-based for loops: 
http://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto

The new  `RemoveStars` option allows to revert to the old behavior: with the 
new option turned on the check will change `MyType *t = new MyType;` to `auto t 
= new MyType;`.

Reviewers: aaron.ballman, sbenza

Subscribers: Eugene.Zelenko, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
  - copied, changed from r271671, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=271739=271738=271739=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Fri Jun  3 
16:22:58 2016
@@ -243,6 +243,14 @@ StatementMatcher makeDeclWithNewMatcher(
 
 } // namespace
 
+UseAutoCheck::UseAutoCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  RemoveStars(Options.get("RemoveStars", 0)) {}
+
+void UseAutoCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "RemoveStars", RemoveStars ? 1 : 0);
+}
+
 void UseAutoCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
@@ -311,7 +319,7 @@ void UseAutoCheck::replaceNew(const Decl
 
   const QualType FirstDeclType = FirstDecl->getType().getCanonicalType();
 
-  std::vector StarLocations;
+  std::vector StarRemovals;
   for (const auto *Dec : D->decls()) {
 const auto *V = cast(Dec);
 // Ensure that every DeclStmt child is a VarDecl.
@@ -327,19 +335,23 @@ void UseAutoCheck::replaceNew(const Decl
 if (!Context->hasSameUnqualifiedType(V->getType(), NewExpr->getType()))
   return;
 
-// Remove explicitly written '*' from declarations where there's more than
-// one declaration in the declaration list.
-if (Dec == *D->decl_begin())
-  continue;
-
-// All subsequent declarations should match the same non-decorated type.
+// All subsequent variables in this declaration should have the same
+// canonical type.  For example, we don't want to use `auto` in
+// `T *p = new T, **pp = new T*;`.
 if (FirstDeclType != V->getType().getCanonicalType())
   return;
 
-auto Q = V->getTypeSourceInfo()->getTypeLoc().getAs();
-while (!Q.isNull()) {
-  StarLocations.push_back(Q.getStarLoc());
-  Q = Q.getNextTypeLoc().getAs();
+if (RemoveStars) {
+  // Remove explicitly written '*' from declarations where there's more 
than
+  // one declaration in the declaration list.
+  if (Dec == *D->decl_begin())
+continue;
+
+  auto Q = V->getTypeSourceInfo()->getTypeLoc().getAs();
+  while (!Q.isNull()) {
+StarRemovals.push_back(FixItHint::CreateRemoval(Q.getStarLoc()));
+Q = Q.getNextTypeLoc().getAs();
+  }
 }
   }
 
@@ -347,19 +359,20 @@ void UseAutoCheck::replaceNew(const Decl
   // is the same as the initializer, just more CV-qualified. However, TypeLoc
   // information is not reliable where CV qualifiers are concerned so we can't
   // do anything about this case for now.
-  SourceRange Range(
-  FirstDecl->getTypeSourceInfo()->getTypeLoc().getSourceRange());
+  TypeLoc Loc = FirstDecl->getTypeSourceInfo()->getTypeLoc();
+  if (!RemoveStars) {
+while (Loc.getTypeLocClass() == TypeLoc::Pointer ||
+   Loc.getTypeLocClass() == TypeLoc::Qualified)
+  Loc = Loc.getNextTypeLoc();
+  }
+  SourceRange Range(Loc.getSourceRange());
   auto Diag = diag(Range.getBegin(), "use auto when initializing with new"
  " to avoid duplicating the type name");
 
   // Space after 'auto' to handle cases where the '*' in the pointer type is
   // next to the identifier. This avoids changing 'int *p' into 'autop'.
-  Diag << 

[libunwind] r271737 - [libunwind] Remove unused code.

2016-06-03 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Jun  3 15:57:48 2016
New Revision: 271737

URL: http://llvm.org/viewvc/llvm-project?rev=271737=rev
Log:
[libunwind] Remove unused code.

The whole file is guarded with #if _LIBUNWIND_ARM_EHABI, and then in the
middle we have these two blocks, which render them pretty unused. An
artefact of a refactoring it seems.

NFC.

Modified:
libunwind/trunk/src/Unwind-EHABI.cpp

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=271737=271736=271737=diff
==
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Fri Jun  3 15:57:48 2016
@@ -450,23 +450,6 @@ unwind_phase1(unw_context_t *uc, unw_cur
   // Walk each frame looking for a place to stop.
   for (bool handlerNotFound = true; handlerNotFound;) {
 
-#if !_LIBUNWIND_ARM_EHABI
-// Ask libuwind to get next frame (skip over first which is
-// _Unwind_RaiseException).
-int stepResult = unw_step(cursor);
-if (stepResult == 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached 
"
- "bottom => _URC_END_OF_STACK\n",
- static_cast(exception_object));
-  return _URC_END_OF_STACK;
-} else if (stepResult < 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => 
"
- "_URC_FATAL_PHASE1_ERROR\n",
- static_cast(exception_object));
-  return _URC_FATAL_PHASE1_ERROR;
-}
-#endif
-
 // See if frame has code to run (has personality routine).
 unw_proc_info_t frameInfo;
 if (unw_get_proc_info(cursor, ) != UNW_ESUCCESS) {
@@ -583,21 +566,6 @@ static _Unwind_Reason_Code unwind_phase2
   resume = false;
 }
 
-#if !_LIBUNWIND_ARM_EHABI
-int stepResult = unw_step(cursor);
-if (stepResult == 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached 
"
- "bottom => _URC_END_OF_STACK\n",
- static_cast(exception_object));
-  return _URC_END_OF_STACK;
-} else if (stepResult < 0) {
-  _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => 
"
- "_URC_FATAL_PHASE1_ERROR\n",
- static_cast(exception_object));
-  return _URC_FATAL_PHASE2_ERROR;
-}
-#endif
-
 // Get info about this frame.
 unw_word_t sp;
 unw_proc_info_t frameInfo;


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


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

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

In http://reviews.llvm.org/D20985#448836, @tra wrote:

> In http://reviews.llvm.org/D20985#448822, @jlebar wrote:
>
> > How is this different from test/SemaCUDA/launch_bounds.cu:27-28?  It does
> >
> >   const int constint = 512;
> >   __launch_bounds__(constint) void TestConstInt(void);
> >   
> >
> > which looks verbatim the same as this testcase.
>
>
> Existing test is a declaration of the function which did not trigger the 
> crash.
>  Second issue is that -verify interferes with reproduction case -- the crash 
> does not happen if any //expect-* are seen before it.
>  Plus, the outcome of the failing test is a crash which would prevent reports 
> of other failures.
>  Separate test file makes the crash isolated and reliably reproducible.


Got it, thanks.

Should we have a test that passes a char or a short and ensures that we do the 
correct implicit conversion there?



Comment at: lib/Sema/SemaDeclAttr.cpp:4045
@@ -4043,4 +4044,3 @@
 // May output an error.
-static bool checkLaunchBoundsArgument(Sema , Expr *E,
-  const CUDALaunchBoundsAttr ,
-  const unsigned Idx) {
+static Expr *checkLaunchBoundsArgument(Sema , Expr *E,
+   const CUDALaunchBoundsAttr ,

Should we update this name and comment?


http://reviews.llvm.org/D20985



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


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

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

In http://reviews.llvm.org/D20985#448822, @jlebar wrote:

> How is this different from test/SemaCUDA/launch_bounds.cu:27-28?  It does
>
>   const int constint = 512;
>   __launch_bounds__(constint) void TestConstInt(void);
>   
>
> which looks verbatim the same as this testcase.


Existing test is a declaration of the function which did not trigger the crash.
Second issue is that -verify interferes with reproduction case -- the crash 
does not happen if any //expect-* are seen before it.
Plus, the outcome of the failing test is a crash which would prevent reports of 
other failures.
Separate test file makes the crash isolated and reliably reproducible.


http://reviews.llvm.org/D20985



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


Re: [PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

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

How is this different from test/SemaCUDA/launch_bounds.cu:27-28?  It does

  const int constint = 512;
  __launch_bounds__(constint) void TestConstInt(void);

which looks verbatim the same as this testcase.


http://reviews.llvm.org/D20985



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


[PATCH] D20985: [CUDA] Add implicit conversion of __launch_bounds__ arguments to rvalue.

2016-06-03 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: rsmith, jlebar.
tra added a subscriber: cfe-commits.

Fixes clang crash reported in PR27778.

http://reviews.llvm.org/D20985

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCUDA/launch-bounds.cu
  test/SemaCUDA/pr27778.cu

Index: test/SemaCUDA/pr27778.cu
===
--- /dev/null
+++ test/SemaCUDA/pr27778.cu
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+#include "Inputs/cuda.h"
+
+const int constint = 512;
+__launch_bounds__(constint) void TestConstInt(void) {}
Index: test/CodeGenCUDA/launch-bounds.cu
===
--- test/CodeGenCUDA/launch-bounds.cu
+++ test/CodeGenCUDA/launch-bounds.cu
@@ -79,3 +79,10 @@
 }
 // CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"maxntidx",
 // CHECK-NOT: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel7{{.*}}, !"minctasm",
+
+const int max_threads_per_block = 11;
+const int min_blocks_per_mp = 12;
+__global__ void __launch_bounds__(max_threads_per_block, min_blocks_per_mp)
+Kernel8() {}
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"maxntidx", i32 11
+// CHECK: !{{[0-9]+}} = !{void ()* @{{.*}}Kernel8{{.*}}, !"minctasm", i32 12
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -28,6 +28,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/DelayedDiagnostic.h"
+#include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Scope.h"
 #include "llvm/ADT/StringExtras.h"
@@ -4041,46 +4042,56 @@
 
 // Checks whether an argument of launch_bounds attribute is acceptable
 // May output an error.
-static bool checkLaunchBoundsArgument(Sema , Expr *E,
-  const CUDALaunchBoundsAttr ,
-  const unsigned Idx) {
+static Expr *checkLaunchBoundsArgument(Sema , Expr *E,
+   const CUDALaunchBoundsAttr ,
+   const unsigned Idx) {
   if (S.DiagnoseUnexpandedParameterPack(E))
-return false;
+return nullptr;
 
   // Accept template arguments for now as they depend on something else.
   // We'll get to check them when they eventually get instantiated.
   if (E->isValueDependent())
-return true;
+return E;
 
   llvm::APSInt I(64);
   if (!E->isIntegerConstantExpr(I, S.Context)) {
 S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
 <<  << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
-return false;
+return nullptr;
   }
   // Make sure we can fit it in 32 bits.
   if (!I.isIntN(32)) {
 S.Diag(E->getExprLoc(), diag::err_ice_too_large) << I.toString(10, false)
  << 32 << /* Unsigned */ 1;
-return false;
+return nullptr;
   }
   if (I < 0)
 S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative)
 <<  << Idx << E->getSourceRange();
 
-  return true;
+  // We may need to perform implicit conversion of the argument.
+  InitializedEntity Entity = InitializedEntity::InitializeParameter(
+  S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false);
+  ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E);
+  if (ValArg.isInvalid())
+return nullptr;
+
+  return ValArg.getAs();
 }
 
 void Sema::AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads,
Expr *MinBlocks, unsigned SpellingListIndex) {
   CUDALaunchBoundsAttr TmpAttr(AttrRange, Context, MaxThreads, MinBlocks,
SpellingListIndex);
-
-  if (!checkLaunchBoundsArgument(*this, MaxThreads, TmpAttr, 0))
+  MaxThreads = checkLaunchBoundsArgument(*this, MaxThreads, TmpAttr, 0);
+  if (MaxThreads == nullptr)
 return;
 
-  if (MinBlocks && !checkLaunchBoundsArgument(*this, MinBlocks, TmpAttr, 1))
-return;
+  if (MinBlocks) {
+MinBlocks = checkLaunchBoundsArgument(*this, MinBlocks, TmpAttr, 1);
+if (MinBlocks == nullptr)
+  return;
+  }
 
   D->addAttr(::new (Context) CUDALaunchBoundsAttr(
   AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:338
@@ -329,8 +337,3 @@
 
-// Remove explicitly written '*' from declarations where there's more than
-// one declaration in the declaration list.
-if (Dec == *D->decl_begin())
-  continue;
-
 // All subsequent declarations should match the same non-decorated type.
 if (FirstDeclType != V->getType().getCanonicalType())

alexfh wrote:
> Prazek wrote:
> > Can you change this comment to make it more clear, or tell me what it do? I 
> > don't quite understand it right now
> Will this be better?
> 
>   // All subsequent variables in this declaration should have the same 
> canonical type.
>   // For example, we don't want to use `auto` in `T *p = new T, **pp = new 
> T*;`.
Much better, thanks!


http://reviews.llvm.org/D20917



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


Re: r271692 - Don't pass --build-id to ld by default.

2016-06-03 Thread Ed Maste via cfe-commits
On 3 June 2016 at 15:53, Nico Weber via cfe-commits
 wrote:
> Can you add this to the release notes? It'll for example break chromium's
> crash server (we can fix this on our end by explicitly passing
> -Wl,--build-id for release builds, but we only saw this commit fly by by
> chance.)

Good point. The Debian, SUSE, Redhat and Ubuntu package maintainers
will also have to update their package build recipes and we want to
make sure they don't miss the change.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/UseAutoCheck.cpp:338
@@ -329,8 +337,3 @@
 
-// Remove explicitly written '*' from declarations where there's more than
-// one declaration in the declaration list.
-if (Dec == *D->decl_begin())
-  continue;
-
 // All subsequent declarations should match the same non-decorated type.
 if (FirstDeclType != V->getType().getCanonicalType())

Prazek wrote:
> Can you change this comment to make it more clear, or tell me what it do? I 
> don't quite understand it right now
Will this be better?

  // All subsequent variables in this declaration should have the same 
canonical type.
  // For example, we don't want to use `auto` in `T *p = new T, **pp = new T*;`.


http://reviews.llvm.org/D20917



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


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-03 Thread Raphael Isemann via cfe-commits
teemperor added a comment.

The previous stats were wrong (only applied this patch, not the patch using the 
code):

Release:
63311672 Byte -> 77212960 Byte (+22% or +13.8 MB)


http://reviews.llvm.org/D20382



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


Re: r271692 - Don't pass --build-id to ld by default.

2016-06-03 Thread Nico Weber via cfe-commits
Can you add this to the release notes? It'll for example break chromium's
crash server (we can fix this on our end by explicitly passing
-Wl,--build-id for release builds, but we only saw this commit fly by by
chance.)

On Fri, Jun 3, 2016 at 1:26 PM, Rafael Espindola via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rafael
> Date: Fri Jun  3 12:26:16 2016
> New Revision: 271692
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271692=rev
> Log:
> Don't pass --build-id to ld by default.
>
> We now have a cmake option to change the default: ENABLE_LINKER_BUILD_ID.
>
> The reason is that build-id is fairly expensive, so we shouldn't impose
> it in the regular edit/build cycle.
>
> This is similar to gcc, that has an off by default --enable-linker-build-id
> option.
>
> Modified:
> cfe/trunk/CMakeLists.txt
> cfe/trunk/include/clang/Config/config.h.cmake
> cfe/trunk/lib/Driver/ToolChains.cpp
>
> Modified: cfe/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=271692=271691=271692=diff
>
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Fri Jun  3 12:26:16 2016
> @@ -197,6 +197,8 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Di
>  set(DEFAULT_SYSROOT "" CACHE PATH
>"Default  to all compiler invocations for --sysroot=." )
>
> +set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
> +
>  set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
>"Default C++ stdlib to use (empty for architecture default,
> \"libstdc++\" or \"libc++\"")
>  if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
>
> Modified: cfe/trunk/include/clang/Config/config.h.cmake
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=271692=271691=271692=diff
>
> ==
> --- cfe/trunk/include/clang/Config/config.h.cmake (original)
> +++ cfe/trunk/include/clang/Config/config.h.cmake Fri Jun  3 12:26:16 2016
> @@ -38,4 +38,7 @@
>  /* Linker version detected at compile time. */
>  #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
>
> +/* pass --build-id to ld */
> +#cmakedefine ENABLE_LINKER_BUILD_ID
> +
>  #endif
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=271692=271691=271692=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jun  3 12:26:16 2016
> @@ -3978,10 +3978,9 @@ Linux::Linux(const Driver , const llvm
>if (IsRedhat(Distro) && Distro != RHEL5 && Distro != RHEL6)
>  ExtraOpts.push_back("--no-add-needed");
>
> -  if ((IsDebian(Distro) && Distro >= DebianSqueeze) || IsOpenSUSE(Distro)
> ||
> -  (IsRedhat(Distro) && Distro != RHEL5) ||
> -  (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
> -ExtraOpts.push_back("--build-id");
> +#ifdef ENABLE_LINKER_BUILD_ID
> +  ExtraOpts.push_back("--build-id");
> +#endif
>
>if (IsOpenSUSE(Distro))
>  ExtraOpts.push_back("--enable-new-dtags");
>
>
> ___
> 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] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: Prazek.
Prazek added a comment.

besides it lgtm



Comment at: clang-tidy/modernize/UseAutoCheck.cpp:338
@@ -329,8 +337,3 @@
 
-// Remove explicitly written '*' from declarations where there's more than
-// one declaration in the declaration list.
-if (Dec == *D->decl_begin())
-  continue;
-
 // All subsequent declarations should match the same non-decorated type.
 if (FirstDeclType != V->getType().getCanonicalType())

Can you change this comment to make it more clear, or tell me what it do? I 
don't quite understand it right now


http://reviews.llvm.org/D20917



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


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

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

In http://reviews.llvm.org/D20917#447046, @sbenza wrote:

> Is it a typo in the description when it says that when RemoveStar is on we 
> will write 'auto*' instead if 'auto'?


Yep, the whole patch description is a typo, fixed ;)


http://reviews.llvm.org/D20917



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


Re: [PATCH] D20917: [clang-tidy] modernize-use-auto: don't remove stars by default

2016-06-03 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 59599.
alexfh marked an inline comment as done.
alexfh added a comment.

- Updated formatting in the doc.


http://reviews.llvm.org/D20917

Files:
  clang-tidy/modernize/UseAutoCheck.cpp
  clang-tidy/modernize/UseAutoCheck.h
  docs/clang-tidy/checks/modernize-use-auto.rst
  test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
  test/clang-tidy/modernize-use-auto-new.cpp

Index: test/clang-tidy/modernize-use-auto-new.cpp
===
--- test/clang-tidy/modernize-use-auto-new.cpp
+++ test/clang-tidy/modernize-use-auto-new.cpp
@@ -9,11 +9,11 @@
 void auto_new() {
   MyType *a_new = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto a_new = new MyType();
+  // CHECK-FIXES: auto *a_new = new MyType();
 
   static MyType *a_static = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
-  // CHECK-FIXES: static auto a_static = new MyType();
+  // CHECK-FIXES: static auto *a_static = new MyType();
 
   MyType *derived = new MyDerivedType();
 
@@ -27,42 +27,42 @@
   // not "MyType * const".
   static MyType * const d_static = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
-  // CHECK-FIXES: static auto  const d_static = new MyType();
+  // CHECK-FIXES: static auto * const d_static = new MyType();
 
   MyType * const a_const = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto  const a_const = new MyType();
+  // CHECK-FIXES: auto * const a_const = new MyType();
 
   MyType * volatile vol = new MyType();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto  volatile vol = new MyType();
+  // CHECK-FIXES: auto * volatile vol = new MyType();
 
   struct SType {} *stype = new SType;
 
   int (**func)(int, int) = new (int(*[5])(int,int));
 
   int *array = new int[5];
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto array = new int[5];
+  // CHECK-FIXES: auto *array = new int[5];
 
   MyType *ptr(new MyType);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
-  // CHECK-FIXES: auto ptr(new MyType);
+  // CHECK-FIXES: auto *ptr(new MyType);
 
   MyType *ptr2{new MyType};
 
   {
 // Test for declaration lists.
 MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
+// CHECK-FIXES: auto *a = new MyType(), *b = new MyType(), *c = new MyType();
 
 // Non-initialized declaration should not be transformed.
 MyType *d = new MyType(), *e;
 
 MyType **f = new MyType*(), **g = new MyType*();
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
+// CHECK-FIXES: auto **f = new MyType*(), **g = new MyType*();
 
 // Mismatching types in declaration lists should not be transformed.
 MyType *h = new MyType(), **i = new MyType*();
@@ -75,25 +75,26 @@
   {
 // Test for typedefs.
 typedef int * int_p;
+// CHECK-FIXES: typedef int * int_p;
 
 int_p a = new int;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto  a = new int;
+// CHECK-FIXES: auto a = new int;
 int_p *b = new int*;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto b = new int*;
+// CHECK-FIXES: auto *b = new int*;
 
 // Test for typedefs in declarations lists.
 int_p c = new int, d = new int;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto  c = new int, d = new int;
+// CHECK-FIXES: auto c = new int, d = new int;
 
 // Different types should not be transformed.
 int_p e = new int, *f = new int_p;
 
 int_p *g = new int*, *h = new int_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
-// CHECK-FIXES: auto g = new int*, h = new int_p;
+// CHECK-FIXES: auto *g = new int*, *h = new int_p;
   }
 
   // Don't warn when 'auto' is already being used.
Index: test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
===
--- test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
+++ test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t
+// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}]}" \
+// RUN:   -- -std=c++11
 
 

Re: [PATCH] D19843: Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Taewook Oh via cfe-commits
twoh added a subscriber: twoh.
twoh closed this revision.
twoh added a comment.

I have commit in r271708: http://reviews.llvm.org/rL271708


http://reviews.llvm.org/D19843



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


r271708 - Use the name of the file on disk to issue a new diagnostic about non-portable #include and #import paths.

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 13:52:51 2016
New Revision: 271708

URL: http://llvm.org/viewvc/llvm-project?rev=271708=rev
Log:
Use the name of the file on disk to issue a new diagnostic about non-portable 
#include and #import paths.

Differential Revision: http://reviews.llvm.org/D19843
Corresponding LLVM change: http://reviews.llvm.org/D19842

Patch by Eric Niebler


Added:
cfe/trunk/test/Lexer/Inputs/case-insensitive-include.h
cfe/trunk/test/Lexer/case-insensitive-include-ms.c
cfe/trunk/test/Lexer/case-insensitive-include.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/include/clang/Lex/DirectoryLookup.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/PCH/case-insensitive-include.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=271708=271707=271708=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun  3 13:52:51 2016
@@ -390,6 +390,7 @@ def : DiagGroup<"sequence-point", [Unseq
 def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
 def KeywordAsMacro : DiagGroup<"keyword-macro">;
 def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
+def NonportableIncludePath : DiagGroup<"nonportable-include-path">;
 
 // Just silence warnings about -Wstrict-aliasing for now.
 def : DiagGroup<"strict-aliasing=0">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=271708=271707=271708=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Jun  3 13:52:51 2016
@@ -274,6 +274,10 @@ def ext_missing_whitespace_after_macro_n
   "whitespace required after macro name">;
 def warn_missing_whitespace_after_macro_name : Warning<
   "whitespace recommended after macro name">;
+def pp_nonportable_path : Warning<
+  "non-portable path to file '%0'; specified path differs in case from file"
+  " name on disk">,
+  InGroup;
   
 def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
   InGroup>;

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=271708=271707=271708=diff
==
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Fri Jun  3 13:52:51 2016
@@ -52,6 +52,7 @@ public:
 /// descriptor for the file.
 class FileEntry {
   const char *Name;   // Name of the file.
+  std::string RealPathName;   // Real path to the file; could be empty.
   off_t Size; // File size in bytes.
   time_t ModTime; // Modification time of file.
   const DirectoryEntry *Dir;  // Directory file lives in.
@@ -82,6 +83,7 @@ public:
   }
 
   const char *getName() const { return Name; }
+  StringRef tryGetRealPathName() const { return RealPathName; }
   bool isValid() const { return IsValid; }
   off_t getSize() const { return Size; }
   unsigned getUID() const { return UID; }

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=271708=271707=271708=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Fri Jun  3 13:52:51 2016
@@ -91,6 +91,13 @@ public:
   virtual ~File();
   /// \brief Get the status of the file.
   virtual llvm::ErrorOr status() = 0;
+  /// \brief Get the name of the file
+  virtual llvm::ErrorOr getName() {
+if (auto Status = status())
+  return Status->getName();
+else
+  return Status.getError();
+  }
   /// \brief Get the contents of the file as a \p MemoryBuffer.
   virtual llvm::ErrorOr
   getBuffer(const Twine , int64_t FileSize = -1,

Modified: cfe/trunk/include/clang/Lex/DirectoryLookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/DirectoryLookup.h?rev=271708=271707=271708=diff
==
--- cfe/trunk/include/clang/Lex/DirectoryLookup.h 

[PATCH] D20979: [OpenCL] Use function attribute/metadata to represent kernel attributes

2016-06-03 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader, pxli168.
yaxunl added subscribers: cfe-commits, tstellarAMD.

This patch attempts to use target-dependent function attribute to represent 
reqd_work_group_size, work_group_size_hint and vector_type_hint kernel 
attributes and use function metadata to represent kernel argument info.

This is to elicit further discussion about a better way to represent kernel 
attributes.

The cfe-dev discussion is at 
http://lists.llvm.org/pipermail/cfe-dev/2016-June/049223.html

http://reviews.llvm.org/D20979

Files:
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGenOpenCL/kernel-arg-info.cl
  test/CodeGenOpenCL/kernel-attributes.cl
  test/CodeGenOpenCL/kernel-metadata.cl

Index: test/CodeGenOpenCL/kernel-metadata.cl
===
--- test/CodeGenOpenCL/kernel-metadata.cl
+++ test/CodeGenOpenCL/kernel-metadata.cl
@@ -6,10 +6,5 @@
 __kernel void kernel_function() {
 }
 
-// CHECK: !opencl.kernels = !{!0}
-// CHECK: !0 = !{void ()* @kernel_function, !1, !2, !3, !4, !5}
-// CHECK: !1 = !{!"kernel_arg_addr_space"}
-// CHECK: !2 = !{!"kernel_arg_access_qual"}
-// CHECK: !3 = !{!"kernel_arg_type"}
-// CHECK: !4 = !{!"kernel_arg_base_type"}
-// CHECK: !5 = !{!"kernel_arg_type_qual"}
+// CHECK: define void @kernel_function() #{{[0-9]+}} !kernel_arg_addr_space ![[MD:[0-9]+]] !kernel_arg_access_qual ![[MD]] !kernel_arg_type ![[MD]] !kernel_arg_base_type ![[MD]] !kernel_arg_type_qual ![[MD]] {
+// CHECK: ![[MD]] = !{}
Index: test/CodeGenOpenCL/kernel-attributes.cl
===
--- test/CodeGenOpenCL/kernel-attributes.cl
+++ test/CodeGenOpenCL/kernel-attributes.cl
@@ -3,14 +3,14 @@
 typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
 
 kernel  __attribute__((vec_type_hint(int))) __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
+// CHECK: define void @kernel1(i32 %a) #[[AT1:[0-9]+]]
 
 kernel __attribute__((vec_type_hint(uint4))) __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {}
+// CHECK: define void @kernel2(i32 %a) #[[AT2:[0-9]+]]
 
-// CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]}
-
-// CHECK: [[MDNODE0]] = !{void (i32)* @kernel1, {{.*}} [[MDNODE1:![0-9]+]], [[MDNODE2:![0-9]+]]}
-// CHECK: [[MDNODE1]] = !{!"vec_type_hint", i32 undef, i32 1}
-// CHECK: [[MDNODE2]] = !{!"reqd_work_group_size", i32 1, i32 2, i32 4}
-// CHECK: [[MDNODE3]] = !{void (i32)* @kernel2, {{.*}} [[MDNODE4:![0-9]+]], [[MDNODE5:![0-9]+]]}
-// CHECK: [[MDNODE4]] = !{!"vec_type_hint", <4 x i32> undef, i32 0}
-// CHECK: [[MDNODE5]] = !{!"work_group_size_hint", i32 8, i32 16, i32 32}
+// CHECK: attributes #[[AT1]] = { 
+// CHECK-DAG: "reqd_work_group_size"="1 2 4"
+// CHECK-DAG: "vec_type_hint"="int"
+// CHECK: attributes #[[AT2]] = {
+// CHECK-DAG: "vec_type_hint"="uint4"
+// CHECK-DAG: "work_group_size_hint"="8 16 32"
Index: test/CodeGenOpenCL/kernel-arg-info.cl
===
--- test/CodeGenOpenCL/kernel-arg-info.cl
+++ test/CodeGenOpenCL/kernel-arg-info.cl
@@ -1,55 +1,88 @@
-// RUN: %clang_cc1 %s -cl-kernel-arg-info -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -check-prefix ARGINFO
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -check-prefix NO-ARGINFO
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
 
 kernel void foo(__global int * restrict X, const int Y, 
 volatile int anotherArg, __constant float * restrict Z) {
   *X = Y + anotherArg;
 }
-
-// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 0, i32 0, i32 2}
-// CHECK:  !{!"kernel_arg_access_qual", !"none", !"none", !"none", !"none"}
-// CHECK:  !{!"kernel_arg_type", !"int*", !"int", !"int", !"float*"}
-// CHECK:  !{!"kernel_arg_base_type", !"int*", !"int", !"int", !"float*"}
-// CHECK:  !{!"kernel_arg_type_qual", !"restrict", !"const", !"volatile", !"restrict const"}
-// ARGINFO: !{!"kernel_arg_name", !"X", !"Y", !"anotherArg", !"Z"}
-// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"X", !"Y", !"anotherArg", !"Z"}
+// CHECK: define spir_kernel void @foo{{[^!]+}}
+// CHECK: !kernel_arg_addr_space ![[MD11:[0-9]+]]
+// CHECK: !kernel_arg_access_qual ![[MD12:[0-9]+]]
+// CHECK: !kernel_arg_type ![[MD13:[0-9]+]]
+// CHECK: !kernel_arg_base_type ![[MD13]]
+// CHECK: !kernel_arg_type_qual ![[MD14:[0-9]+]]
+// CHECK-NOT: !kernel_arg_name
+// ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]]
 
 kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3) {
 }
-// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 1, i32 1}
-// CHECK:  !{!"kernel_arg_access_qual", !"read_only", !"read_only", !"write_only"}
-// CHECK:  !{!"kernel_arg_type", !"image1d_t", !"image2d_t", 

r271702 - [Title] Revert test commit

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 13:30:12 2016
New Revision: 271702

URL: http://llvm.org/viewvc/llvm-project?rev=271702=rev
Log:
[Title] Revert test commit

Summary: Revert test commit

Trac Bug: #

Blame Rev:

Reviewed By:

Test Plan:

Revert Plan:

Database Impact:

Memcache Impact:

Other Notes:

EImportant:

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -


Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=271702=271701=271702=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jun  3 13:30:12 2016
@@ -790,7 +790,6 @@ LIBBUILTIN(isxdigit, "ii", "fnU", "ctype
 LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 
-
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.


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


[RFC] Embedded bitcode and related upstream (Part II)

2016-06-03 Thread Steven Wu via cfe-commits
Hi everyone

I am still in the process of upstreaming some improvements to the embed bitcode 
option. If you want more background, you can read the previous RFC 
(http://lists.llvm.org/pipermail/llvm-dev/2016-February/094851.html 
). This is 
part II of the discussion. 

Current Status:
A basic version of -fembed-bitcode option is upstreamed and functioning.
You can use -fembed-bitcode={off, all, bitcode, marker} option to control what 
gets embedded in the final object file output:
off: default, nothing gets embedded.
all: optimized bitcode and command line options gets embedded in the object 
file.
bitcode: only optimized bitcode is embedded
marker: only put a marker in the object file

What needs to be improved:
1. Whitelist for command line options that can be used with bitcode:
Current trunk implementation embeds all the cc1 command line options (that 
includes header include paths, warning flags and other front-end options) in 
the command line section. That is lot of redundant information. To re-create 
the object file from the embedded optimized bitcode, most of these options are 
useless. On the other hand, they can leak information of the source code. One 
solution will be keeping a list of all the options that can affect code 
generation but not encoded in the bitcode. I have internally prototyped with 
disallowing these options explicitly and allowed only the reminder of the  
options to be embedded (http://reviews.llvm.org/D17394 
). A better solution might be encoding that 
information in "Options.td" as specific group.

2. Assembly input handling:
This is a workaround to allow source code written in assembly to work with 
"-fembed-bitcode" options. When compiling assembly source code with 
"-fembed-bitcode", clang-as creates an empty section "__LLVM, __asm" in the 
object file. That is just a way to distinguish object files compiled from 
assembly source from those compiled from higher level source code but forgot to 
use "-fembed-bitcode" options. Linker can use this section to diagnose if 
"-fembed-bitcode" is consistently used on all the object files participated in 
the linking.

3. Bitcode symbol hiding:
There was some concerns for leaking source code information when using bitcode 
feature. One approach to avoid the leak is to add a pass which renames all the 
globals and metadata strings. The also keeps a reverse map in case the original 
name needs to be recovered. The final bitcode should contain no more symbols or 
debug info than a stripped binary. To make sure modified bitcode can still be 
linked correctly, the renaming need to be consistent across all bitcode 
participated in the linking and everything that is external of the linkage unit 
need to be preserved. This means the pass can only be run during the linking 
and requires some LTO api.

4. Debug info strip to line-tables pass:
As the name suggested, this pass strip down the full debug info to line-tables 
only. This is also one of the steps we took to prevent the leak of source code 
information in bitcode.

Please let me know what do you think about the pieces above or if you have any 
concerns about the methodology. I will put up patches for review soon.

Thanks

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


r271701 - Test commit

2016-06-03 Thread Taewook Oh via cfe-commits
Author: twoh
Date: Fri Jun  3 13:27:39 2016
New Revision: 271701

URL: http://llvm.org/viewvc/llvm-project?rev=271701=rev
Log:
Test commit 


Modified:
cfe/trunk/include/clang/Basic/Builtins.def

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=271701=271700=271701=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Fri Jun  3 13:27:39 2016
@@ -790,6 +790,7 @@ LIBBUILTIN(isxdigit, "ii", "fnU", "ctype
 LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
 
+
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.


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


Re: [PATCH] D20602: Add .rgba syntax extension to ext_vector_type types

2016-06-03 Thread Pirama Arumuga Nainar via cfe-commits
pirama added a comment.

Friendly ping...


http://reviews.llvm.org/D20602



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

In http://reviews.llvm.org/D20964#448525, @Prazek wrote:

> In http://reviews.llvm.org/D20964#448455, @Eugene.Zelenko wrote:
>
> > I think will be good idea to try this check with LLVM STL too.
>
>
> You mean llvm::SmallVector stuff?


No, I meant to build example with -stdlib=libc++, -lc++, -lc++abi. Just to make 
sure, that hasName() is proper matcher.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D20964#448455, @Eugene.Zelenko wrote:

> I think will be good idea to try this check with LLVM STL too.


You mean llvm::SmallVector stuff?


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59580.
Prazek marked 4 inline comments as done.
Prazek added a comment.

- Review fixes


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args) {};
+};
+
+template 
+class list {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args) {};
+};
+
+template 
+class deque {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args) {};
+};
+
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair ) {};
+  template 
+  pair(pair &) {};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
+
+void testOtherCointainers() {
+  std::list l;
+  l.push_back(S(42, 41));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: l.emplace_back(42, 41);
+
+  std::deque d;
+  

RE: r271413 - Fixup list of available extensions

2016-06-03 Thread Anastasia Stulova via cfe-commits
No worries! Thanks!

Anastasia

-Original Message-
From: Jan Vesely [mailto:jv...@scarletmail.rutgers.edu] On Behalf Of Jan Vesely
Sent: 03 June 2016 18:35
To: Anastasia Stulova; cfe-commits@lists.llvm.org
Cc: nd
Subject: Re: r271413 - Fixup list of available extensions

of course. sorry about that. I didn't realize the patches had different title 
from phabricator.

Jan

On Fri, 2016-06-03 at 17:14 +, Anastasia Stulova wrote:
> Hi Jan,
> 
> In the future could you please keep "[OpenCL]" prefix for all commit 
> messages related to OpenCL. :)
> 
> Thanks,
> Anastasia
>  
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On 
> Behalf Of Jan Vesely via cfe-commits
> Sent: 01 June 2016 19:05
> To: cfe-commits@lists.llvm.org
> Subject: r271413 - Fixup list of available extensions
> 
> Author: jvesely
> Date: Wed Jun  1 13:04:50 2016
> New Revision: 271413
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=271413=rev
> Log:
> Fixup list of available extensions
> 
> Reviewers: Anastasia
> 
> Differential Revision: http://reviews.llvm.org/D20447
> 
> Added:
> cfe/trunk/test/SemaOpenCL/extension-version.cl
> Modified:
> cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> 
> Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basi
> c/OpenCLExtensions.def?rev=271413=271412=271413=diff
> =
> =
> --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
> +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1
> +++ 13:04:50 2016
> @@ -34,35 +34,39 @@
>  #endif // OPENCLEXT_INTERNAL
>  
>  // OpenCL 1.0.
> -OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
> +OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) // fprounding
> mode
> +is special since it is not mentioned beyond 1.0 
> +OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
>  OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_fp16, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_fp64, 100,
> 120)  OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100,
> 110) -OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_icd, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100,
> 110)
> +OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
>  
>  // OpenCL 1.1.
> -OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
>  
>  // OpenCL 1.2.
> +OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_depth_images, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
>  
>  // OpenCL 2.0.
>  OPENCLEXT_INTERNAL(cl_khr_egl_event, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U) 
> -OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_subgroups, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
> 
> Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/ex
> tension-version.cl?rev=271413=auto
> =
> =
> --- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1
> 13:04:50
> +++ 2016
> @@ -0,0 +1,225 @@
> +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple 
> +spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s
> -verify
> +-triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2
> %s
> +-verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl
> +-cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
> +
> +#if __OPENCL_C_VERSION__ >= 200
> +// expected-no-diagnostics
> +#endif
> +
> +// Extensions in all versions
> +#ifndef cl_clang_storage_class_specifiers #error "Missing 
> +cl_clang_storage_class_specifiers define"
> +#endif
> +#pragma OPENCL EXTENSION 

Re: r271413 - Fixup list of available extensions

2016-06-03 Thread Jan Vesely via cfe-commits
of course. sorry about that. I didn't realize the patches had different
title from phabricator.

Jan

On Fri, 2016-06-03 at 17:14 +, Anastasia Stulova wrote:
> Hi Jan,
> 
> In the future could you please keep "[OpenCL]" prefix for all commit
> messages related to OpenCL. :)
> 
> Thanks,
> Anastasia
>  
> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> Behalf Of Jan Vesely via cfe-commits
> Sent: 01 June 2016 19:05
> To: cfe-commits@lists.llvm.org
> Subject: r271413 - Fixup list of available extensions
> 
> Author: jvesely
> Date: Wed Jun  1 13:04:50 2016
> New Revision: 271413
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=271413=rev
> Log:
> Fixup list of available extensions
> 
> Reviewers: Anastasia
> 
> Differential Revision: http://reviews.llvm.org/D20447
> 
> Added:
> cfe/trunk/test/SemaOpenCL/extension-version.cl
> Modified:
> cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> 
> Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basi
> c/OpenCLExtensions.def?rev=271413=271412=271413=diff
> =
> =
> --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
> +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1 
> +++ 13:04:50 2016
> @@ -34,35 +34,39 @@
>  #endif // OPENCLEXT_INTERNAL
>  
>  // OpenCL 1.0.
> -OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
> +OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) // fprounding
> mode 
> +is special since it is not mentioned beyond 1.0 
> +OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
>  OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_fp16, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_fp64, 100,
> 120)  OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100,
> 110) -OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_icd, 100,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100,
> 110)  OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100,
> 110)
> +OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
>  
>  // OpenCL 1.1.
> -OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
>  
>  // OpenCL 1.2.
> +OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_depth_images, 120,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U) 
> +OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
> +OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
>  OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
>  
>  // OpenCL 2.0.
>  OPENCLEXT_INTERNAL(cl_khr_egl_event, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U)
> -OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_subgroups, 200,
> ~0U)  OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
> 
> Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/ex
> tension-version.cl?rev=271413=auto
> =
> =
> --- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1
> 13:04:50 
> +++ 2016
> @@ -0,0 +1,225 @@
> +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple 
> +spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s
> -verify 
> +-triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2
> %s 
> +-verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl 
> +-cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
> +
> +#if __OPENCL_C_VERSION__ >= 200
> +// expected-no-diagnostics
> +#endif
> +
> +// Extensions in all versions
> +#ifndef cl_clang_storage_class_specifiers #error "Missing 
> +cl_clang_storage_class_specifiers define"
> +#endif
> +#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
> +
> +#ifndef cl_khr_fp16
> +#error "Missing cl_khr_fp16 define"
> +#endif
> +#pragma OPENCL EXTENSION cl_khr_fp16: enable
> +
> +#ifndef cl_khr_int64_base_atomics
> +#error "Missing cl_khr_int64_base_atomics define"
> +#endif
> +#pragma OPENCL EXTENSION 

RE: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

2016-06-03 Thread Anastasia Stulova via cfe-commits
Hi Jeroen,

I am not quite sure what your question is about in (a).

Regarding (b) please see example in test/SemaOpenCL/extensions.cl from the 
commit r269670.

Please note that SPIR target supports all extensions but disables them by 
default (see commit r269670). The latter logic hasn't been modified from 
earlier revisions of Clang.
Each targets can set the supported extensions as required, if you look at the 
latest commits: http://reviews.llvm.org/D20389

Perhaps, you can give us some code examples of what you believe isn't compiled 
correctly in Clang now. 

Thanks,
Anastasia

-Original Message-
From: Jeroen Ketema [mailto:j.ket...@imperial.ac.uk] 
Sent: 31 May 2016 23:07
To: Liu, Yaxun (Sam)
Cc: Anastasia Stulova; Clang Commits; nd
Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target info.

Hi Sam,

> This commit does not change the initial state of the extensions. An extension 
> is supported is not the same as enabled. At the beginning all extensions are 
> disabled.

I do not see this reflected in the code at all. Could you please:

a. Point me to the location where this distinction is made.

b. Convince me that I cannot enable an extension for a target if that target 
does not support the extension?

Jeroen

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


Re: Don't pass --build-id by default.

2016-06-03 Thread Rafael Espíndola via cfe-commits
r271692, thanks.

Cheers,
Rafael


On 3 June 2016 at 10:19, Ed Maste  wrote:
> On 2 June 2016 at 21:19, Hal Finkel via cfe-commits
>  wrote:
>> - Original Message -
>>> From: "Rafael Espíndola" 
>>> To: "Hal Finkel" 
>>> Cc: "cfe-commits cfe" 
>>> Sent: Thursday, June 2, 2016 7:06:26 PM
>>> Subject: Re: Don't pass --build-id by default.
>>>
>>> > This is going to break a lot of my local rpm packaging scripts, and
>>> > I suspect the same is true for others. This is not a huge deal,
>>> > but I wonder if we should emulate GCC is this regard and provide
>>> > some CMake option to keep the current behavior?
>>>
>>> Yes, a cmake option is probably best.
>>>
>>> What do you think of the attached patch (still building).
>>
>> Seems reasonable to me.
>
> This sounds like the right approach to me too.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271692 - Don't pass --build-id to ld by default.

2016-06-03 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Jun  3 12:26:16 2016
New Revision: 271692

URL: http://llvm.org/viewvc/llvm-project?rev=271692=rev
Log:
Don't pass --build-id to ld by default.

We now have a cmake option to change the default: ENABLE_LINKER_BUILD_ID.

The reason is that build-id is fairly expensive, so we shouldn't impose
it in the regular edit/build cycle.

This is similar to gcc, that has an off by default --enable-linker-build-id
option.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=271692=271691=271692=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Jun  3 12:26:16 2016
@@ -197,6 +197,8 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Di
 set(DEFAULT_SYSROOT "" CACHE PATH
   "Default  to all compiler invocations for --sysroot=." )
 
+set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
+
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
   "Default C++ stdlib to use (empty for architecture default, \"libstdc++\" or 
\"libc++\"")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR

Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=271692=271691=271692=diff
==
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Fri Jun  3 12:26:16 2016
@@ -38,4 +38,7 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
+/* pass --build-id to ld */
+#cmakedefine ENABLE_LINKER_BUILD_ID
+
 #endif

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=271692=271691=271692=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jun  3 12:26:16 2016
@@ -3978,10 +3978,9 @@ Linux::Linux(const Driver , const llvm
   if (IsRedhat(Distro) && Distro != RHEL5 && Distro != RHEL6)
 ExtraOpts.push_back("--no-add-needed");
 
-  if ((IsDebian(Distro) && Distro >= DebianSqueeze) || IsOpenSUSE(Distro) ||
-  (IsRedhat(Distro) && Distro != RHEL5) ||
-  (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
-ExtraOpts.push_back("--build-id");
+#ifdef ENABLE_LINKER_BUILD_ID
+  ExtraOpts.push_back("--build-id");
+#endif
 
   if (IsOpenSUSE(Distro))
 ExtraOpts.push_back("--enable-new-dtags");


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


Re: [PATCH] D20338: [PCH] Fixed overridden files always invalidating preamble even when unchanged

2016-06-03 Thread Cameron via cfe-commits
cameron314 updated the summary for this revision.
cameron314 removed rL LLVM as the repository for this revision.
cameron314 updated this revision to Diff 59577.
cameron314 added a comment.

It took some modifications to the ASTUnit to support a virtual file system with 
a PCH parse/reparse (preliminary VFS support had already been added in 
http://reviews.llvm.org/rL249410 but it did not support initial parses using 
PCHs, nor reparses), but I was finally able to write a test that checks that 
the reparse actually uses the PCH with my fix, and rejects the PCH (rereading 
everything and failing the test) without it.


http://reviews.llvm.org/D20338

Files:
  include/clang/Basic/FileManager.h
  include/clang/Frontend/ASTUnit.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/PchPreambleTest.cpp

Index: unittests/Frontend/PchPreambleTest.cpp
===
--- /dev/null
+++ unittests/Frontend/PchPreambleTest.cpp
@@ -0,0 +1,155 @@
+//-- unittests/Frontend/PchPreambleTest.cpp - FrontendAction tests ---//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem
+{
+  std::map ReadCounts;
+
+public:
+  ErrorOr openFileForRead(const Twine ) override
+  {
+SmallVector PathVec;
+Path.toVector(PathVec);
+llvm::sys::path::remove_dots(PathVec, true);
+++ReadCounts[std::string(PathVec.begin(), PathVec.end())];
+return InMemoryFileSystem::openFileForRead(Path);
+  }
+
+  unsigned GetReadCount(const Twine ) const
+  {
+auto it = ReadCounts.find(Path.str());
+return it == ReadCounts.end() ? 0 : it->second;
+  }
+};
+
+class PchPreambleTest : public ::testing::Test {
+  IntrusiveRefCntPtr VFS;
+  StringMap RemappedFiles;
+  std::shared_ptr PCHContainerOpts;
+  FileSystemOptions FSOpts;
+
+public:
+  void SetUp() override {
+VFS = new ReadCountingInMemoryFileSystem();
+// We need the working directory to be set to something absolute,
+// otherwise it ends up being inadvertently set to the current
+// working directory in the real file system due to a series of
+// unfortunate conditions interacting badly.
+// What's more, this path *must* be absolute on all (real)
+// filesystems, so just '/' won't work (e.g. on Win32).
+VFS->setCurrentWorkingDirectory("//./");
+  }
+
+  void TearDown() override {
+  }
+
+  void AddFile(const std::string , const std::string ) {
+::time_t now;
+::time();
+VFS->addFile(Filename, now, MemoryBuffer::getMemBufferCopy(Contents, Filename));
+  }
+
+  void RemapFile(const std::string , const std::string ) {
+RemappedFiles[Filename] = Contents;
+  }
+
+  std::unique_ptr ParseAST(const std::string ) {
+PCHContainerOpts = std::make_shared();
+CompilerInvocation *CI = new CompilerInvocation;
+CI->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(EntryFile, FrontendOptions::getInputKindForExtension(
+llvm::sys::path::extension(EntryFile).substr(1;
+
+CI->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+
+CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles();
+
+PreprocessorOptions  = CI->getPreprocessorOpts();
+PPOpts.RemappedFilesKeepOriginalName = true;
+
+IntrusiveRefCntPtr
+  Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
+
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+
+std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
+  CI, PCHContainerOpts, Diags, FileMgr, false, false,
+  /*PrecompilePreambleAfterNParses=*/1);
+return AST;
+  }
+
+  bool ReparseAST(const std::unique_ptr ) {
+FileManager *FileMgr = new FileManager(FSOpts, VFS);
+bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), FileMgr);
+return reparseFailed;
+  }
+
+  unsigned GetFileReadCount(const std::string ) const {
+return VFS->GetReadCount(Filename);
+  }
+
+private:
+  std::vector>
+  GetRemappedFiles() const {
+std::vector> Remapped;
+for (const auto  : RemappedFiles) {
+  

Re: Don't pass --build-id by default.

2016-06-03 Thread Ed Maste via cfe-commits
On 2 June 2016 at 21:19, Hal Finkel via cfe-commits
 wrote:
> - Original Message -
>> From: "Rafael Espíndola" 
>> To: "Hal Finkel" 
>> Cc: "cfe-commits cfe" 
>> Sent: Thursday, June 2, 2016 7:06:26 PM
>> Subject: Re: Don't pass --build-id by default.
>>
>> > This is going to break a lot of my local rpm packaging scripts, and
>> > I suspect the same is true for others. This is not a huge deal,
>> > but I wonder if we should emulate GCC is this regard and provide
>> > some CMake option to keep the current behavior?
>>
>> Yes, a cmake option is probably best.
>>
>> What do you think of the attached patch (still building).
>
> Seems reasonable to me.

This sounds like the right approach to me too.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

I think will be good idea to try this check with LLVM STL too.



Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:47
@@ +46,3 @@
+
+In this case the calls of push_back won't be replaced.
+

Please highlight push_back with ``.


Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:55
@@ +54,3 @@
+
+This is because replacing it with emplace_back could cause a leak of this
+this pointer, if emplace_back would throw exception before emplacement

Please highlight emplace_back with ``. Same below.


Comment at: test/clang-tidy/modernize-use-emplace.cpp:12
@@ +11,3 @@
+  void emplace_back(Args &&... args);
+};
+template 

Please insert new line.


Comment at: test/clang-tidy/modernize-use-emplace.cpp:78
@@ +77,3 @@
+  operator S() { return S{}; }
+};
+struct Zoz {

Please insert new line.


http://reviews.llvm.org/D20964



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


RE: r271413 - Fixup list of available extensions

2016-06-03 Thread Anastasia Stulova via cfe-commits
Hi Jan,

In the future could you please keep "[OpenCL]" prefix for all commit messages 
related to OpenCL. :)

Thanks,
Anastasia
 
-Original Message-
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Jan 
Vesely via cfe-commits
Sent: 01 June 2016 19:05
To: cfe-commits@lists.llvm.org
Subject: r271413 - Fixup list of available extensions

Author: jvesely
Date: Wed Jun  1 13:04:50 2016
New Revision: 271413

URL: http://llvm.org/viewvc/llvm-project?rev=271413=rev
Log:
Fixup list of available extensions

Reviewers: Anastasia

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

Added:
cfe/trunk/test/SemaOpenCL/extension-version.cl
Modified:
cfe/trunk/include/clang/Basic/OpenCLExtensions.def

Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=271413=271412=271413=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Wed Jun  1 
+++ 13:04:50 2016
@@ -34,35 +34,39 @@
 #endif // OPENCLEXT_INTERNAL
 
 // OpenCL 1.0.
-OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120)
+OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) // fprounding mode 
+is special since it is not mentioned beyond 1.0 
+OPENCLEXT_INTERNAL(cl_khr_select_fprounding_mode, 100, 110)
 OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100, 110)  
OPENCLEXT_INTERNAL(cl_khr_fp16, 100, ~0U)  OPENCLEXT_INTERNAL(cl_khr_fp64, 100, 
120)  OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100, 110)  
OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100, 110) 
-OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100, 110)  
OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100, 110)
+OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U)
 
 // OpenCL 1.1.
-OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U)
 
 // OpenCL 1.2.
+OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_depth_images, 120, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_image2d_from_buffer, 120, ~0U) 
+OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
 
 // OpenCL 2.0.
 OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U) 
-OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)  
OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)

Added: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=271413=auto
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (added)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Jun  1 13:04:50 
+++ 2016
@@ -0,0 +1,225 @@
+// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple 
+spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify 
+-triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s 
+-verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl 
+-cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+
+#if __OPENCL_C_VERSION__ >= 200
+// expected-no-diagnostics
+#endif
+
+// Extensions in all versions
+#ifndef cl_clang_storage_class_specifiers #error "Missing 
+cl_clang_storage_class_specifiers define"
+#endif
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable
+
+#ifndef cl_khr_fp16
+#error "Missing cl_khr_fp16 define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_fp16: enable
+
+#ifndef cl_khr_int64_base_atomics
+#error "Missing cl_khr_int64_base_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable
+
+#ifndef cl_khr_int64_extended_atomics
+#error "Missing cl_khr_int64_extended_atomics define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable
+
+#ifndef cl_khr_gl_sharing
+#error "Missing cl_khr_gl_sharing define"
+#endif
+#pragma OPENCL EXTENSION cl_khr_gl_sharing: enable
+
+#ifndef cl_khr_icd
+#error "Missing cl_khr_icd define"
+#endif

Re: r271427 - [driver][arm] add armv7 and thumb include and lib paths

2016-06-03 Thread Ismail Donmez via cfe-commits
Fixed in r271689.

On Fri, Jun 3, 2016 at 9:55 AM, Ismail Donmez  wrote:
> This is due to lib vs lib64. Will fix. Sorry for the wrong diagnosis :)
>
> On Thu, Jun 2, 2016 at 8:24 PM, Chih-hung Hsieh  wrote:
>> Ismail,
>> I saw that android-ndk-standalone.cpp has already -stdlib=libstdc++.
>> Could you tell me or just go ahead and make the necessary change?
>> Thanks.
>>
>>
>> On Thu, Jun 2, 2016 at 9:52 AM, Ismail Donmez  wrote:
>>>
>>> Hi,
>>>
>>> On Wed, Jun 1, 2016 at 11:48 PM, Chih-Hung Hsieh via cfe-commits
>>>  wrote:
>>> > Author: chh
>>> > Date: Wed Jun  1 15:48:46 2016
>>> > New Revision: 271427
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=271427=rev
>>> > Log:
>>> > [driver][arm] add armv7 and thumb include and lib paths
>>> >
>>> > Add a new test android-ndk-standalone.cpp
>>> > with new Android NDK release tree structure.
>>> > Detect armv7 sub architecture and thumb mode,
>>> > to add system include and link search paths.
>>> >
>>> > Differential Revision: http://reviews.llvm.org/D20600
>>> >
>>>
>>> android-ndk-standalone.cpp needs -stdlib=libstdc++ to fix test on
>>> libc++ default systems.
>>>
>>> ismail
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271689 - Fix test for LLVM_LIBDIR_SUFFIX=64 case.

2016-06-03 Thread Ismail Donmez via cfe-commits
Author: ismail
Date: Fri Jun  3 12:06:52 2016
New Revision: 271689

URL: http://llvm.org/viewvc/llvm-project?rev=271689=rev
Log:
Fix test for LLVM_LIBDIR_SUFFIX=64 case.


Modified:
cfe/trunk/test/Driver/android-ndk-standalone.cpp

Modified: cfe/trunk/test/Driver/android-ndk-standalone.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-ndk-standalone.cpp?rev=271689=271688=271689=diff
==
--- cfe/trunk/test/Driver/android-ndk-standalone.cpp (original)
+++ cfe/trunk/test/Driver/android-ndk-standalone.cpp Fri Jun  3 12:06:52 2016
@@ -17,7 +17,7 @@
 // CHECK-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
 // CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -53,7 +53,7 @@
 // CHECK-ARMV7-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi"
 // CHECK-ARMV7: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK-ARMV7: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK-ARMV7: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK-ARMV7: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARMV7: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK-ARMV7: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -111,7 +111,7 @@
 // CHECK-THUMB-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi"
 // CHECK-THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK-THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK-THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK-THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK-THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -149,7 +149,7 @@
 // CHECK-ARMV7THUMB-NOT: "-internal-isystem" 
"{{.*}}/include/c++/4.9/arm-linux-androideabi"
 // CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
 // CHECK-ARMV7THUMB: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
-// CHECK-ARMV7THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(/|)}}clang{{(/|)[^"]+(/|)}}include"
+// CHECK-ARMV7THUMB: "-internal-isystem" 
"{{.*(/|)}}lib{{(64)?(/|)}}clang{{(/|)[^"]+(/|)}}include"
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/include"
 // CHECK-ARMV7THUMB: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
 // CHECK-ARMV7THUMB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"


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


Re: [PATCH] D20681: Add target-specific pre-linking passes to Clang

2016-06-03 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Do you think we could add any test for this change?



Comment at: lib/CodeGen/BackendUtil.cpp:657
@@ -627,2 +656,3 @@
 
+
 bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,

Remove the empty line please


Comment at: lib/CodeGen/CodeGenAction.cpp:169
@@ +168,3 @@
+  std::function
+LinkCallBack = [=](llvm::Module *M)->bool {
+// Link LinkModule into this module if present, preserving its 
validity.

Is there any reason for having this as a callback now?

Could we just add a call to prelink passes here above instead without modifying 
much the original flow?


http://reviews.llvm.org/D20681



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


r271688 - Obj-C: Fix assert-on-invalid (PR27822)

2016-06-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Jun  3 11:59:13 2016
New Revision: 271688

URL: http://llvm.org/viewvc/llvm-project?rev=271688=rev
Log:
Obj-C: Fix assert-on-invalid (PR27822)

Clang would assert when isObjCInstancetype() was called on a
tok::annot_cxxscope token.

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/test/SemaObjCXX/instancetype.mm

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=271688=271687=271688=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Jun  3 11:59:13 2016
@@ -647,6 +647,8 @@ private:
   /// Should only be used in Objective-C language modes.
   bool isObjCInstancetype() {
 assert(getLangOpts().ObjC1);
+if (Tok.isAnnotation())
+  return false;
 if (!Ident_instancetype)
   Ident_instancetype = PP.getIdentifierInfo("instancetype");
 return Tok.getIdentifierInfo() == Ident_instancetype;

Modified: cfe/trunk/test/SemaObjCXX/instancetype.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/instancetype.mm?rev=271688=271687=271688=diff
==
--- cfe/trunk/test/SemaObjCXX/instancetype.mm (original)
+++ cfe/trunk/test/SemaObjCXX/instancetype.mm Fri Jun  3 11:59:13 2016
@@ -214,3 +214,10 @@ void test_instancetype_inherited() {
   return 0;
 }
 @end
+
+// PR27822
+@class NSString;
+namespace pr27822 { }
+@interface AXPlatformNodeCocoa
++ (NSString*)nativeRoleFromAXRole:(pr27822::UndeclaredIdentifier)role; // 
expected-error {{expected a type}}
+@end


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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:40
@@ +39,3 @@
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(

Prazek wrote:
> sbarzowski wrote:
> > > Look at tests - the same thing happens when
> > 
> > Yeah. I meant looking for `new` in addition to blacklist.
> > 
> > > Not many custom classes take pointer in constructor. 
> > 
> > Obviously depends on codebase, but IMO it's quite common. However usually 
> > this classes aren't copy-constructible (or at least shouldn't be) anyway, 
> > making it impossible to use push_back, so maybe it's not such a big deal.
> > 
> > > If I will look for const pointers, then I will not be able to pass "abc" 
> > > into vector.
> > 
> > I wrote explicitly about only **non**-const pointers.
> It doesn't matter if it is const or not. Disabling any of them would disable 
> some cases where it would be good.
> I have to run it on llvm code base and see what happens
Of course there would be some false negatives. It's close to impossible to know 
for sure if it's safe, so we need some sort of heuristic. My concern is that 
the current "blacklist smart pointers" solution may lead to a lot of false 
positives. And false positives here are quite nasty - very subtle bugs, that 
are unlikely to be caught by the tests or quick code review. So I'm more 
comfortable with false negatives.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 2 inline comments as done.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:40
@@ +39,3 @@
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(

sbarzowski wrote:
> > Look at tests - the same thing happens when
> 
> Yeah. I meant looking for `new` in addition to blacklist.
> 
> > Not many custom classes take pointer in constructor. 
> 
> Obviously depends on codebase, but IMO it's quite common. However usually 
> this classes aren't copy-constructible (or at least shouldn't be) anyway, 
> making it impossible to use push_back, so maybe it's not such a big deal.
> 
> > If I will look for const pointers, then I will not be able to pass "abc" 
> > into vector.
> 
> I wrote explicitly about only **non**-const pointers.
It doesn't matter if it is const or not. Disabling any of them would disable 
some cases where it would be good.
I have to run it on llvm code base and see what happens


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20090: [OPENCL] Fix wrongly vla error for OpenCL array.

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

LGTM! Thanks!


http://reviews.llvm.org/D20090



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


Re: [PATCH] D20444: [OpenCL] Include opencl-c.h by default as a clang module

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


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7347
@@ -7346,3 +7346,3 @@
 def err_blocks_disable : Error<"blocks support disabled - compile with 
-fblocks"
-  " or pick a deployment target that supports them">;
+  " or %select{pick a deployment target that supports them|as OpenCL 2.0 or 
above}0">;
 def err_block_returning_array_function : Error<

-> for OpenCL version 2.0 or above


Comment at: test/Headers/opencl-c-header.cl:50
@@ +49,3 @@
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck %s
+// RUN: diff %t/1_0.pcm %t/opencl_c.pcm
+// RUN: rm %t/opencl_c.pcm

Sam, what was the aim of this test?

I was just wondering if we should instead check that the file is exactly the 
same i.e. hasn't been overwritten with exactly the same content?


Comment at: test/Headers/opencl-c-header.cl:53-54
@@ +52,4 @@
+
+// ===
+// Compile for OpenCL 2.0 for the first time. The module should change.
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -fdisable-module-hash %s | FileCheck 
--check-prefix=CHECK20 %s

Indeed PCH size is an issue. I don't quite get why it expands from the original 
source code size by a factor or 2. Something to look at!


Comment at: test/Headers/opencl-c-header.cl:70
@@ +69,3 @@
+// RUN: %clang_cc1 -cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck %s
+// RUN: %clang_cc1 -cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t %s | FileCheck --check-prefix=CHECK20 %s

This line seems exactly the same as line 67.


http://reviews.llvm.org/D20444



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:40
@@ +39,3 @@
+  // passed pointer because smart pointer won't be constructed
+  // (and destructed) as in push_back case.
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(

> Look at tests - the same thing happens when

Yeah. I meant looking for `new` in addition to blacklist.

> Not many custom classes take pointer in constructor. 

Obviously depends on codebase, but IMO it's quite common. However usually this 
classes aren't copy-constructible (or at least shouldn't be) anyway, making it 
impossible to use push_back, so maybe it's not such a big deal.

> If I will look for const pointers, then I will not be able to pass "abc" into 
> vector.

I wrote explicitly about only **non**-const pointers.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59568.
Prazek added a comment.

- Post review fix


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,189 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+template 
+class list {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+template 
+class deque {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair ){};
+  template 
+  pair(pair &){};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
+
+void testOtherCointainers() {
+  std::list l;
+  l.push_back(S(42, 41));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: l.emplace_back(42, 41);
+
+  std::deque d;
+  d.push_back(S(42));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:31
@@ +30,3 @@
+on(hasType(cxxRecordDecl(hasName(VectorName)
+  .bind("call");
+

ok, std::list works for me. I just don't want to spend much time on it right 
now, and I want to be sure it works.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:39
@@ +38,3 @@
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";
+

Look at tests - the same thing happens when

std::vector v;

const auto *p = new int;
v.push_back(p);

Not many custom classes take pointer in constructor. 
If I will look for const pointers, then I will not be able to pass "abc" into 
vector.

So I guess this solution seems to be the best idea. 


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20053: [clang-tidy] Add misc-unnecessary-mutable check.

2016-06-03 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:23
@@ +22,3 @@
+
+// Matcher checking if the declaration is non-macro existent mutable which is
+// not dependent on context.

add an anonymous namespace around this declaration.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:26
@@ +25,3 @@
+AST_MATCHER(FieldDecl, isSubstantialMutable) {
+  return Node.getDeclName() && Node.isMutable() &&
+ !Node.getLocation().isMacroID() &&

why getDeclName ?


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:42
@@ +41,3 @@
+
+class FieldUseVisitor : public RecursiveASTVisitor {
+public:

Please add a comment to describe the purpose of this class.
The code is the doc, and it will help readers.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:56
@@ +55,3 @@
+  bool VisitExpr(Expr *GenericExpr) {
+MemberExpr *Expression = dyn_cast(GenericExpr);
+if (!Expression || Expression->getMemberDecl() != SoughtField)

MemberExpr *Expression  -> const auto*


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:60
@@ +59,3 @@
+
+// Check if expr is a member of const thing.
+bool IsConstObj = false;

thing -> object


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:62
@@ +61,3 @@
+bool IsConstObj = false;
+for (const auto *ChildStmt : Expression->children()) {
+  const Expr *ChildExpr = dyn_cast(ChildStmt);

I think the child-expressions of MemberExpr can only be "member->getBase()" ?
In this case, no loop is needed.

```
child_range children() { return child_range(, +1); }
```

```
 Expr *getBase() const { return cast(Base); }
```


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:134
@@ +133,3 @@
+// All decls need their definitions in main file.
+if (!Declaration->hasBody() ||
+!SM.isInMainFile(Declaration->getBody()->getLocStart())) {

Watch out, Declaration->hasBody() is tricky with code when compile on windows 
(clang-cl).
hasBody() may return true, but the getBody() may be NULL.

This is why these tests exist:
```
cppcoreguidelines-pro-type-member-init-delayed.cpp
modernize-redundant-void-arg-delayed.cpp
modernize-use-default-delayed.cpp
performance-unnecessary-value-param-delayed.cpp
```
So this code may crash with delayed-template-parsing.



Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:213
@@ +212,3 @@
+  diag(FD->getLocation(), "'mutable' modifier is unnecessary for field %0")
+  << FD->getDeclName();
+

no need for ->getDeclName()
There is an overloaded operator for namedDecl.


Comment at: clang-tidy/misc/UnnecessaryMutableCheck.cpp:217
@@ +216,3 @@
+
+  if (CheckRemoval(SM, FD->getLocStart(), FD->getLocEnd(), Context,
+   RemovalRange)) {

You can change CheckRemoval to return the SourceRange.
If it's failing, you can call 'fixithint <<' and it won't be an issue.

This way, you do not need to declare Diag, and you can directly add the 
sourceRange to the expression to line 213.

```
 diag(FD->getLocation(), "'mutable' modifier is unnecessary for field %0")
  << FD
  << getSourceRangeOfMutableToken(FD);
```

WDYT?


http://reviews.llvm.org/D20053



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Stanisław Barzowski via cfe-commits
sbarzowski added inline comments.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:30
@@ +29,3 @@
+  cxxMemberCallExpr(hasDeclaration(functionDecl(hasName(PushBackName))),
+on(hasType(cxxRecordDecl(hasName(VectorName)
+  .bind("call");

Maybe it can work with some more types, with minimal changes... Like maybe 
std::list.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:38
@@ +37,3 @@
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+  ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+ "std::weak_ptr";

This argument really holds for _any_ class taking ownership of the created 
object.

Maybe it would be better to check if we pass a non-const pointer as an argument 
to the constructor, as a pretty good indicator of taking ownership.

Or maybe just look for `new` operator in the expression.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20963: [mips] The P5600 does not support N32/N64 since it's a 32-bit CPU.

2016-06-03 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20963



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


Re: [PATCH] D20961: [mips] Replace almost all Arch checks in MipsTargetInfo with ABI checks. NFC.

2016-06-03 Thread Simon Atanasyan via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D20961



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.
dblaikie added a comment.

Could you describe in more detail (ideally in the original patch review 
summary/description) what this transformation does? Under what conditions does 
it suggest emplace, etc.


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 2 inline comments as done.
Prazek added a comment.

http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 4 inline comments as done.


Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:29
@@ +28,3 @@
+  auto callPushBack =
+  cxxMemberCallExpr(hasDeclaration(functionDecl(hasName(PushBackName))),
+on(hasType(cxxRecordDecl(hasName(VectorName)

I don't think so. In all checks people use lowerCamelCase, because it looks 
like a real matchers


http://reviews.llvm.org/D20964



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


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59562.
Prazek added a comment.

Learning how to use arc


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tidy/modernize/UseEmplaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  test/clang-tidy/modernize-use-emplace.cpp

Index: test/clang-tidy/modernize-use-emplace.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-emplace.cpp
@@ -0,0 +1,157 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t
+
+namespace std {
+template 
+class vector {
+public:
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplace_back(Args &&... args);
+};
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair ){};
+  template 
+  pair(pair &){};
+};
+
+template 
+pair make_pair(T1, T2) {
+  return pair();
+};
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(T *) {}
+};
+} // namespace std
+
+void testInts() {
+  std::vector v;
+  v.push_back(42);
+  v.push_back(int(42));
+  v.push_back(int{42});
+  int z;
+  v.push_back(z);
+}
+
+struct S {
+  S(int a, int b = 41) {}
+  S() {}
+  void push_back(S);
+};
+
+struct Convertable {
+  operator S() { return S{}; }
+};
+struct Zoz {
+  Zoz(S s) {}
+};
+
+Zoz getZoz(S s) { return Zoz(s); }
+
+void test_S() {
+  std::vector v;
+
+  v.push_back(S(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(S());
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(S{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  v.push_back(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(42);
+
+  S temporary(42, 42);
+  temporary.push_back(temporary);
+  v.push_back(temporary);
+
+  v.push_back(Convertable());
+  v.push_back(Convertable{});
+  Convertable s;
+  v.push_back(s);
+}
+
+void test2() {
+  std::vector v;
+  v.push_back(Zoz(S(21, 37)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(S(21, 37));
+
+  v.push_back(getZoz(S(1, 2)));
+}
+
+void testPair() {
+  std::vector> v;
+  v.push_back(std::pair(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  std::vector> v2;
+  v2.push_back(std::pair(S(42, 42), Zoz(S(21, 37;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v2.emplace_back(S(42, 42), Zoz(S(21, 37)));
+}
+
+void testSpaces() {
+  std::vector v;
+
+  // clang-format off
+  v.push_back(S   (1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+  v.push_back(S   {1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back(1, 2);
+
+  v.push_back(  S {});
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+  // CHECK-FIXES: v.emplace_back();
+
+  // clang-format on
+}
+
+void testPointers() {
+  std::vector v;
+  v.push_back(new int(5));
+
+  std::vector v2;
+  v2.push_back(new int(42));
+  // This call can't be replaced with emplace_back.
+  // If emplacement will fail (not enough memory to add to vector)
+  // we will have leak of int because unique_ptr won't be constructed
+  // (and destructed) as in push_back case.
+
+  auto *ptr = new int;
+  v2.push_back(ptr);
+  // Same here
+}
+
+void testMakePair() {
+  std::vector> v;
+  // FIXME: add functionality to change calls of std::make_pair
+  v.push_back(std::make_pair(1, 2));
+}
Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -0,0 +1,60 @@
+.. title:: clang-tidy - modernize-use-emplace
+
+modernize-use-emplace
+=
+
+This check look for cases when inserting new element into an STL
+container, but the element is constructed temporarily.
+
+Before:
+
+.. code:: c++
+
+	std::vector v;
+	v.push_back(MyClass(21, 37));
+
+	std::vector > w;
+	w.push_back(std::make_pair(21, 

Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 59561.
Prazek marked an inline comment as done.
Prazek added a comment.

Fixed stuff


http://reviews.llvm.org/D20964

Files:
  clang-tidy/modernize/UseEmplaceCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst

Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- docs/clang-tidy/checks/modernize-use-emplace.rst
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -3,9 +3,8 @@
 modernize-use-emplace
 =
 
-This check would look for cases when inserting new element into an STL
-container, but the element is constructed temporarily or is constructed just
-to be moved. It would also work with std::pair.
+This check look for cases when inserting new element into an STL
+container, but the element is constructed temporarily.
 
 Before:
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -209,7 +209,7 @@
 - New `modernize-use-emplace
   `_ 
check
 
-  Finds calls that could be change to emplace.
+  Finds calls that could be changed to emplace.
 
 - New `performance-faster-string-find
   
`_
 check
Index: clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -54,16 +54,16 @@
   const auto *PushBackExpr = Result.Nodes.getNodeAs("push_back");
   const auto *InnerCtorCall = Result.Nodes.getNodeAs("ctor");
 
-  auto functionNameSourceRange = CharSourceRange::getCharRange(
+  auto FunctionNameSourceRange = CharSourceRange::getCharRange(
   PushBackExpr->getExprLoc(), Call->getArg(0)->getExprLoc());
 
   auto Diag =
   diag(PushBackExpr->getExprLoc(), "use emplace_back instead of 
push_back");
 
-  if (functionNameSourceRange.getBegin().isMacroID())
+  if (FunctionNameSourceRange.getBegin().isMacroID())
 return;
 
-  Diag << FixItHint::CreateReplacement(functionNameSourceRange,
+  Diag << FixItHint::CreateReplacement(FunctionNameSourceRange,
"emplace_back(");
 
   auto CallParensRange = InnerCtorCall->getParenOrBraceRange();


Index: docs/clang-tidy/checks/modernize-use-emplace.rst
===
--- docs/clang-tidy/checks/modernize-use-emplace.rst
+++ docs/clang-tidy/checks/modernize-use-emplace.rst
@@ -3,9 +3,8 @@
 modernize-use-emplace
 =
 
-This check would look for cases when inserting new element into an STL
-container, but the element is constructed temporarily or is constructed just
-to be moved. It would also work with std::pair.
+This check look for cases when inserting new element into an STL
+container, but the element is constructed temporarily.
 
 Before:
 
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -209,7 +209,7 @@
 - New `modernize-use-emplace
   `_ check
 
-  Finds calls that could be change to emplace.
+  Finds calls that could be changed to emplace.
 
 - New `performance-faster-string-find
   `_ check
Index: clang-tidy/modernize/UseEmplaceCheck.cpp
===
--- clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -54,16 +54,16 @@
   const auto *PushBackExpr = Result.Nodes.getNodeAs("push_back");
   const auto *InnerCtorCall = Result.Nodes.getNodeAs("ctor");
 
-  auto functionNameSourceRange = CharSourceRange::getCharRange(
+  auto FunctionNameSourceRange = CharSourceRange::getCharRange(
   PushBackExpr->getExprLoc(), Call->getArg(0)->getExprLoc());
 
   auto Diag =
   diag(PushBackExpr->getExprLoc(), "use emplace_back instead of push_back");
 
-  if (functionNameSourceRange.getBegin().isMacroID())
+  if (FunctionNameSourceRange.getBegin().isMacroID())
 return;
 
-  Diag << FixItHint::CreateReplacement(functionNameSourceRange,
+  Diag << FixItHint::CreateReplacement(FunctionNameSourceRange,
"emplace_back(");
 
   auto CallParensRange = InnerCtorCall->getParenOrBraceRange();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20964: [clang-tidy] Add modernize-use-emplace

2016-06-03 Thread Piotr Padlewski via cfe-commits
Prazek marked 4 inline comments as done.


Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:6
@@ +5,3 @@
+
+This check would look for cases when inserting new element into an STL
+container, but the element is constructed temporarily or is constructed just

sbarzowski wrote:
> Why "would"? Did you copy the description from the proposal? :-)
yep :D


http://reviews.llvm.org/D20964



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


[PATCH] D20966: [include-fixer] Add the missing header to the file where the unidentified symbol comes from.

2016-06-03 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added reviewers: bkramer, ioeric.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D20966

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/tool/ClangIncludeFixer.cpp
  include-fixer/tool/clang-include-fixer.py
  test/include-fixer/commandline_options.cpp
  test/include-fixer/insert_header_in_header.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -44,8 +44,6 @@
   llvm::MemoryBuffer::getMemBuffer("\n"));
   InMemoryFileSystem->addFile("dir/otherdir/qux.h", 0,
   llvm::MemoryBuffer::getMemBuffer("\n"));
-  InMemoryFileSystem->addFile("header.h", 0,
-  llvm::MemoryBuffer::getMemBuffer("bar b;"));
   return Invocation.run();
 }
 
@@ -188,11 +186,6 @@
 runIncludeFixer("int test = a::b::Green;\n"));
 }
 
-TEST(IncludeFixer, IgnoreSymbolFromHeader) {
-  std::string Code = "#include \"header.h\"";
-  EXPECT_EQ(Code, runIncludeFixer(Code));
-}
-
 // FIXME: add test cases for inserting and sorting multiple headers when
 // include-fixer supports multiple headers insertion.
 TEST(IncludeFixer, InsertAndSortSingleHeader) {
Index: test/include-fixer/insert_header_in_header.cpp
===
--- /dev/null
+++ test/include-fixer/insert_header_in_header.cpp
@@ -0,0 +1,10 @@
+// REQUIRES: shell
+// RUN: echo 'foo f;' > %T/main.h
+// RUN: sed -e 's#//.*$##' %s > %t.cpp
+// RUN: clang-include-fixer -db=yaml -input=%p/Inputs/fake_yaml_db.yaml %t.cpp --
+// RUN: FileCheck %s -input-file=%T/main.h
+
+// CHECK: #include "foo.h"
+// CHECK: foo f;
+
+#include "main.h"
Index: test/include-fixer/commandline_options.cpp
===
--- test/include-fixer/commandline_options.cpp
+++ test/include-fixer/commandline_options.cpp
@@ -1,7 +1,7 @@
 // REQUIRES: shell
 // RUN: sed -e 's#//.*$##' %s > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{SymbolIdentifier: foo, FilePath: %t.cpp, Headers: ["\"foo.h\""]}' %t.cpp | FileCheck %s -check-prefix=CHECK
 //
 // CHECK-HEADERS: "Headers": [ "\"foo.h\"", "\"bar.h\"" ]
 //
Index: include-fixer/tool/clang-include-fixer.py
===
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -49,11 +49,19 @@
   return p.communicate(input=text)
 
 
-def InsertHeaderToVimBuffer(header, text):
+def InsertHeaderToVimBuffer(header, code):
   command = [binary, "-stdin", "-insert-header="+json.dumps(header),
  vim.current.buffer.name]
-  stdout, stderr = execute(command, text)
+  stdout, stderr = execute(command, code)
+
   if stdout:
+# If the file being inserted is not the current one in vim buffer, just
+# overwrite it in filesystem.
+if header["FilePath"] != vim.current.buffer.name:
+  with open(header["FilePath"], "w") as f:
+f.write(stdout)
+  return
+
 lines = stdout.splitlines()
 sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines)
 for op in reversed(sequence.get_opcodes()):
@@ -72,19 +80,24 @@
 
   # Get the current text.
   buf = vim.current.buffer
-  text = '\n'.join(buf)
+  code = '\n'.join(buf)
 
   # Run command to get all headers.
   command = [binary, "-stdin", "-output-headers", "-db="+args.db,
  "-input="+args.input, vim.current.buffer.name]
-  stdout, stderr = execute(command, text)
+  stdout, stderr = execute(command, code)
   if stderr:
 print >> sys.stderr, "Error while running clang-include-fixer: " + stderr
 return
 
   include_fixer_context = json.loads(stdout)
   symbol = include_fixer_context["SymbolIdentifier"]
   headers = include_fixer_context["Headers"]
+  file_path = include_fixer_context["FilePath"]
+
+  if file_path != vim.current.buffer.name:
+with open(file_path, "r") as f:
+  code = f.read();
 
   if not symbol:
 print "The file is fine, no need to add a header.\n"
@@ -98,8 +111,11 @@
   # If there is only one suggested header, insert it directly.
   if len(headers) == 1 or maximum_suggested_headers == 1:
 InsertHeaderToVimBuffer({"SymbolIdentifier": symbol,
- "Headers":[headers[0]]}, text)
-print "Added #include {0} for {1}.\n".format(headers[0], symbol)
+ "Headers": [headers[0]],

  1   2   >