[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Zixuan Wu via Phabricator via cfe-commits
wuzish marked 2 inline comments as done.
wuzish added a comment.

The updated patch now extended the scope and can include the case.


https://reviews.llvm.org/D53417



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


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Zixuan Wu via Phabricator via cfe-commits
wuzish updated this revision to Diff 173276.
wuzish added a comment.

Extend the scope to all vector type as one comment suggested.

> a conversion sequence that bitcasts a vector should be ranked worse than one 
> that does not, regardless of the kind of vector in use.

Which is also made code clearly and consistently, the effect is to update some 
tests expected behavior.


https://reviews.llvm.org/D53417

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGen/altivec-generic-overload.c
  clang/test/Sema/altivec-generic-overload.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -17,14 +17,14 @@
   f0(ll16e);
 }
 
-int (char16); // expected-note 2{{candidate function}}
-float (longlong16); // expected-note 2{{candidate function}}
+int (char16);
+float (longlong16);
 
 void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
   int  = f1(c16);
   float  = f1(ll16);
-  f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
-  f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
+  f1(c16e);
+  f1(ll16e);
 }
 
 void f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) for 1st argument}} \
Index: clang/test/Sema/altivec-generic-overload.c
===
--- /dev/null
+++ clang/test/Sema/altivec-generic-overload.c
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only
+
+typedef signed char __v16sc __attribute__((__vector_size__(16)));
+typedef unsigned char __v16uc __attribute__((__vector_size__(16)));
+typedef signed short __v8ss __attribute__((__vector_size__(16)));
+typedef unsigned short __v8us __attribute__((__vector_size__(16)));
+typedef signed int __v4si __attribute__((__vector_size__(16)));
+typedef unsigned int __v4ui __attribute__((__vector_size__(16)));
+typedef signed long long __v2sll __attribute__((__vector_size__(16)));
+typedef unsigned long long __v2ull __attribute__((__vector_size__(16)));
+typedef signed __int128 __v1slll __attribute__((__vector_size__(16)));
+typedef unsigned __int128 __v1ulll __attribute__((__vector_size__(16)));
+typedef float __v4f __attribute__((__vector_size__(16)));
+typedef double __v2d __attribute__((__vector_size__(16)));
+
+void __attribute__((__overloadable__)) convert1(vector signed char);
+void __attribute__((__overloadable__)) convert1(vector unsigned char);
+void __attribute__((__overloadable__)) convert1(vector signed short);
+void __attribute__((__overloadable__)) convert1(vector unsigned short);
+void __attribute__((__overloadable__)) convert1(vector signed int);
+void __attribute__((__overloadable__)) convert1(vector unsigned int);
+void __attribute__((__overloadable__)) convert1(vector signed long long);
+void __attribute__((__overloadable__)) convert1(vector unsigned long long);
+void __attribute__((__overloadable__)) convert1(vector signed __int128);
+void __attribute__((__overloadable__)) convert1(vector unsigned __int128);
+void __attribute__((__overloadable__)) convert1(vector float);
+void __attribute__((__overloadable__)) convert1(vector double);
+void __attribute__((__overloadable__)) convert1(vector bool int);
+void __attribute__((__overloadable__)) convert1(vector pixel short);
+void __attribute__((__overloadable__)) convert2(__v16sc);
+void __attribute__((__overloadable__)) convert2(__v16uc);
+void __attribute__((__overloadable__)) convert2(__v8ss);
+void __attribute__((__overloadable__)) convert2(__v8us);
+void __attribute__((__overloadable__)) convert2(__v4si);
+void __attribute__((__overloadable__)) convert2(__v4ui);
+void __attribute__((__overloadable__)) convert2(__v2sll);
+void __attribute__((__overloadable__)) convert2(__v2ull);
+void __attribute__((__overloadable__)) convert2(__v1slll);
+void __attribute__((__overloadable__)) convert2(__v1ulll);
+void __attribute__((__overloadable__)) convert2(__v4f);
+void __attribute__((__overloadable__)) convert2(__v2d);
+
+void test()
+{
+  __v16sc gv1;
+  __v16uc gv2;
+  __v8ss gv3;
+  __v8us gv4;
+  __v4si gv5;
+  __v4ui gv6;
+  __v2sll gv7;
+  __v2ull gv8;
+  __v1slll gv9;
+  __v1ulll gv10;
+  __v4f gv11;
+  __v2d  gv12;
+
+  vector signed char av1;
+  vector unsigned char av2;
+  vector signed short av3;
+  vector unsigned short av4;
+  vector signed int av5;
+  vector unsigned int av6;
+  vector signed long long av7;
+  vector unsigned long long av8;
+  vector signed __int128 av9;
+  vector unsigned __int128 av10;
+  vector float av11;
+  vector double av12;
+  vector bool int av13;
+  vector pixel short av14;
+
+  convert1(gv1);
+  convert1(gv2);
+  convert1(gv3);
+  convert1(gv4);
+  convert1(gv5);
+  convert1(gv6);
+  

Re: [clang-tools-extra] r346461 - Ignore implicit things like ConstantExpr.

2018-11-08 Thread Roman Lebedev via cfe-commits
Test?

On Fri, Nov 9, 2018 at 4:34 AM Bill Wendling via cfe-commits
 wrote:
>
> Author: void
> Date: Thu Nov  8 17:32:30 2018
> New Revision: 346461
>
> URL: http://llvm.org/viewvc/llvm-project?rev=346461=rev
> Log:
> Ignore implicit things like ConstantExpr.
>
> Modified:
> 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
>
> Modified: 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp?rev=346461=346460=346461=diff
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
>  Thu Nov  8 17:32:30 2018
> @@ -58,7 +58,8 @@ void NoexceptMoveConstructorCheck::check
>  // where expr evaluates to false.
>  if (ProtoType->canThrow() == CT_Can) {
>Expr *E = ProtoType->getNoexceptExpr();
> -  if (!isa(ProtoType->getNoexceptExpr())) {
> +  E = E->IgnoreImplicit();
> +  if (!isa(E)) {
>  diag(E->getExprLoc(),
>   "noexcept specifier on the move %0 evaluates to 'false'")
>  << MethodType;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Zixuan Wu via Phabricator via cfe-commits
wuzish added a comment.

In https://reviews.llvm.org/D53417#1292404, @rsmith wrote:

> I like the direction here, and I'd like to see this applied generally: a 
> conversion sequence that bitcasts a vector should be ranked worse than one 
> that does not, regardless of the kind of vector in use.


I also would like to make the direction more aggressive.


https://reviews.llvm.org/D53417



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


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

> some test points check the error report for ambiguous call because of too 
> many implicit cast choices from ext_vector_type to vector type.

It appears the answer is to update these tests and remove the restriction on 
the type class.


https://reviews.llvm.org/D53417



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


r346471 - [PowerPC] [Clang] [AltiVec] The second parameter of vec_sr function should be modulo the number of bits in the element

2018-11-08 Thread Zi Xuan Wu via cfe-commits
Author: wuzish
Date: Thu Nov  8 19:35:32 2018
New Revision: 346471

URL: http://llvm.org/viewvc/llvm-project?rev=346471=rev
Log:
[PowerPC] [Clang] [AltiVec] The second parameter of vec_sr function should be 
modulo the number of bits in the element

The second parameter of vec_sr function is representing shift bits and it 
should be modulo the number of bits in the element like what vec_sl does now. 
This is actually required by the ABI:

Each element of the result vector is the result of logically right shifting the 
corresponding
element of ARG1 by the number of bits specified by the value of the 
corresponding
element of ARG2, modulo the number of bits in the element. The bits that are 
shifted out
are replaced by zeros.

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


Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=346471=346470=346471=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Thu Nov  8 19:35:32 2018
@@ -9492,49 +9492,51 @@ vec_splat_u32(signed char __a) {
 
 /* vec_sr */
 
-static __inline__ vector signed char __ATTRS_o_ai
-vec_sr(vector signed char __a, vector unsigned char __b) {
-  vector unsigned char __res = (vector unsigned char)__a >> __b;
-  return (vector signed char)__res;
-}
-
+// vec_sr does modulo arithmetic on __b first, so __b is allowed to be more
+// than the length of __a.
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_sr(vector unsigned char __a, vector unsigned char __b) {
-  return __a >> __b;
+  return __a >>
+ (__b % (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__));
 }
 
-static __inline__ vector signed short __ATTRS_o_ai
-vec_sr(vector signed short __a, vector unsigned short __b) {
-  vector unsigned short __res = (vector unsigned short)__a >> __b;
-  return (vector signed short)__res;
+static __inline__ vector signed char __ATTRS_o_ai
+vec_sr(vector signed char __a, vector unsigned char __b) {
+  return (vector signed char)vec_sr((vector unsigned char)__a, __b);
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_sr(vector unsigned short __a, vector unsigned short __b) {
-  return __a >> __b;
+  return __a >>
+ (__b % (vector unsigned short)(sizeof(unsigned short) * 
__CHAR_BIT__));
 }
 
-static __inline__ vector signed int __ATTRS_o_ai
-vec_sr(vector signed int __a, vector unsigned int __b) {
-  vector unsigned int __res = (vector unsigned int)__a >> __b;
-  return (vector signed int)__res;
+static __inline__ vector short __ATTRS_o_ai vec_sr(vector short __a,
+   vector unsigned short __b) {
+  return (vector short)vec_sr((vector unsigned short)__a, __b);
 }
 
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_sr(vector unsigned int __a, vector unsigned int __b) {
-  return __a >> __b;
+  return __a >>
+ (__b % (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__));
 }
 
-#ifdef __POWER8_VECTOR__
-static __inline__ vector signed long long __ATTRS_o_ai
-vec_sr(vector signed long long __a, vector unsigned long long __b) {
-  vector unsigned long long __res = (vector unsigned long long)__a >> __b;
-  return (vector signed long long)__res;
+static __inline__ vector int __ATTRS_o_ai vec_sr(vector int __a,
+ vector unsigned int __b) {
+  return (vector int)vec_sr((vector unsigned int)__a, __b);
 }
 
+#ifdef __POWER8_VECTOR__
 static __inline__ vector unsigned long long __ATTRS_o_ai
 vec_sr(vector unsigned long long __a, vector unsigned long long __b) {
-  return __a >> __b;
+  return __a >> (__b % (vector unsigned long long)(sizeof(unsigned long long) *
+   __CHAR_BIT__));
+}
+
+static __inline__ vector long long __ATTRS_o_ai
+vec_sr(vector long long __a, vector unsigned long long __b) {
+  return (vector long long)vec_sr((vector unsigned long long)__a, __b);
 }
 #endif
 
@@ -9544,12 +9546,12 @@ vec_sr(vector unsigned long long __a, ve
 
 static __inline__ vector signed char __ATTRS_o_ai
 vec_vsrb(vector signed char __a, vector unsigned char __b) {
-  return __a >> (vector signed char)__b;
+  return vec_sr(__a, __b);
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_vsrb(vector unsigned char __a, vector unsigned char __b) {
-  return __a >> __b;
+  return vec_sr(__a, __b);
 }
 
 /* vec_vsrh */
@@ -9558,12 +9560,12 @@ vec_vsrb(vector unsigned char __a, vecto
 
 static __inline__ vector short __ATTRS_o_ai
 vec_vsrh(vector short __a, vector unsigned short __b) {
-  return __a >> (vector short)__b;
+  return vec_sr(__a, __b);
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_vsrh(vector unsigned 

[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I like the direction here, and I'd like to see this applied generally: a 
conversion sequence that bitcasts a vector should be ranked worse than one that 
does not, regardless of the kind of vector in use.


https://reviews.llvm.org/D53417



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


[PATCH] D54087: [PowerPC] [Clang] [AltiVec] The second parameter of vec_sr function should be modulo the number of bits in the element

2018-11-08 Thread Zixuan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346471: [PowerPC] [Clang] [AltiVec] The second parameter of 
vec_sr function should be… (authored by wuzish, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54087?vs=172538=173263#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54087

Files:
  cfe/trunk/lib/Headers/altivec.h
  cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
  cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c

Index: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
===
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
@@ -4256,52 +4256,76 @@
 
   /* vec_sr */
   res_vsc = vec_sr(vsc, vuc);
-// CHECK: lshr <16 x i8>
-// CHECK-LE: lshr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_sr(vuc, vuc);
-// CHECK: lshr <16 x i8>
-// CHECK-LE: lshr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vs  = vec_sr(vs, vus);
-// CHECK: lshr <8 x i16>
-// CHECK-LE: lshr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vus = vec_sr(vus, vus);
-// CHECK: lshr <8 x i16>
-// CHECK-LE: lshr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vi  = vec_sr(vi, vui);
-// CHECK: lshr <4 x i32>
-// CHECK-LE: lshr <4 x i32>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vui = vec_sr(vui, vui);
-// CHECK: lshr <4 x i32>
-// CHECK-LE: lshr <4 x i32>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vsc = vec_vsrb(vsc, vuc);
-// CHECK: shr <16 x i8>
-// CHECK-LE: shr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_vsrb(vuc, vuc);
-// CHECK: shr <16 x i8>
-// CHECK-LE: shr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vs  = vec_vsrh(vs, vus);
-// CHECK: shr <8 x i16>
-// CHECK-LE: shr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vus = vec_vsrh(vus, vus);
-// CHECK: shr <8 x i16>
-// CHECK-LE: shr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vi  = vec_vsrw(vi, vui);
-// CHECK: shr <4 x i32>
-// CHECK-LE: shr <4 x i32>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vui = vec_vsrw(vui, vui);
-// CHECK: shr <4 x i32>
-// CHECK-LE: shr <4 x i32>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   

[PATCH] D54087: [PowerPC] [Clang] [AltiVec] The second parameter of vec_sr function should be modulo the number of bits in the element

2018-11-08 Thread Zixuan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346471: [PowerPC] [Clang] [AltiVec] The second parameter of 
vec_sr function should be… (authored by wuzish, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54087?vs=172538=173262#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54087

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-p8vector.c

Index: test/CodeGen/builtins-ppc-p8vector.c
===
--- test/CodeGen/builtins-ppc-p8vector.c
+++ test/CodeGen/builtins-ppc-p8vector.c
@@ -1066,13 +1066,17 @@
 
   /* vec_sr */
   res_vsll = vec_sr(vsll, vull);
-// CHECK: lshr <2 x i64>
-// CHECK-LE: lshr <2 x i64>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <2 x i64> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <2 x i64> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <2 x i64> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <2 x i64> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 // CHECK-PPC: error: call to 'vec_sr' is ambiguous
 
   res_vull = vec_sr(vull, vull);
-// CHECK: lshr <2 x i64>
-// CHECK-LE: lshr <2 x i64>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <2 x i64> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <2 x i64> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <2 x i64> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <2 x i64> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 // CHECK-PPC: error: call to 'vec_sr' is ambiguous
 
   /* vec_sra */
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -4256,52 +4256,76 @@
 
   /* vec_sr */
   res_vsc = vec_sr(vsc, vuc);
-// CHECK: lshr <16 x i8>
-// CHECK-LE: lshr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_sr(vuc, vuc);
-// CHECK: lshr <16 x i8>
-// CHECK-LE: lshr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vs  = vec_sr(vs, vus);
-// CHECK: lshr <8 x i16>
-// CHECK-LE: lshr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vus = vec_sr(vus, vus);
-// CHECK: lshr <8 x i16>
-// CHECK-LE: lshr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vi  = vec_sr(vi, vui);
-// CHECK: lshr <4 x i32>
-// CHECK-LE: lshr <4 x i32>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vui = vec_sr(vui, vui);
-// CHECK: lshr <4 x i32>
-// CHECK-LE: lshr <4 x i32>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <4 x i32> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <4 x i32> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vsc = vec_vsrb(vsc, vuc);
-// CHECK: shr <16 x i8>
-// CHECK-LE: shr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vuc = vec_vsrb(vuc, vuc);
-// CHECK: shr <16 x i8>
-// CHECK-LE: shr <16 x i8>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <16 x i8> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <16 x i8> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vs  = vec_vsrh(vs, vus);
-// CHECK: shr <8 x i16>
-// CHECK-LE: shr <8 x i16>
+// CHECK: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
+// CHECK-LE: [[UREM:[0-9a-zA-Z%.]+]] = urem <8 x i16> {{[0-9a-zA-Z%.]+}}, 
+// CHECK-LE: lshr <8 x i16> {{[0-9a-zA-Z%.]+}}, [[UREM]]
 
   res_vus = vec_vsrh(vus, vus);
-// CHECK: shr <8 x i16>
-// CHECK-LE: shr <8 x i16>
+// 

[PATCH] D53263: Fix places where the return type of a FunctionDecl was being used in place of the function type

2018-11-08 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D53263



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


[PATCH] D54288: Fix ClangFormat issue of recognizing ObjC subscript as C++ attributes when message target is a result of a C-style method.

2018-11-08 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 173258.
Wizard added a comment.

remove blank lines


Repository:
  rC Clang

https://reviews.llvm.org/D54288

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6472,6 +6472,8 @@
   // Make sure we do not mistake attributes for array subscripts.
   verifyFormat("int a() {}\n"
"[[unused]] int b() {}\n");
+  verifyFormat("NSArray *arr;\n"
+   "arr[[Foo() bar]];");
 
   // On the other hand, we still need to correctly find array subscripts.
   verifyFormat("int a = std::vector{1, 2, 3}[0];");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -366,7 +366,8 @@
   // specifier parameter, although this is technically valid:
   // [[foo(:)]]
   if (AttrTok->is(tok::colon) ||
-  AttrTok->startsSequence(tok::identifier, tok::identifier))
+  AttrTok->startsSequence(tok::identifier, tok::identifier) || 
+  AttrTok->startsSequence(tok::r_paren, tok::identifier))
 return false;
   if (AttrTok->is(tok::ellipsis))
 return true;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6472,6 +6472,8 @@
   // Make sure we do not mistake attributes for array subscripts.
   verifyFormat("int a() {}\n"
"[[unused]] int b() {}\n");
+  verifyFormat("NSArray *arr;\n"
+   "arr[[Foo() bar]];");
 
   // On the other hand, we still need to correctly find array subscripts.
   verifyFormat("int a = std::vector{1, 2, 3}[0];");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -366,7 +366,8 @@
   // specifier parameter, although this is technically valid:
   // [[foo(:)]]
   if (AttrTok->is(tok::colon) ||
-  AttrTok->startsSequence(tok::identifier, tok::identifier))
+  AttrTok->startsSequence(tok::identifier, tok::identifier) || 
+  AttrTok->startsSequence(tok::r_paren, tok::identifier))
 return false;
   if (AttrTok->is(tok::ellipsis))
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346468 - Fix test from r346439 to also work on Windows due to path separator differences.

2018-11-08 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Thu Nov  8 18:44:07 2018
New Revision: 346468

URL: http://llvm.org/viewvc/llvm-project?rev=346468=rev
Log:
Fix test from r346439 to also work on Windows due to path separator differences.

Modified:
cfe/trunk/test/Modules/mismatch-diagnostics.cpp

Modified: cfe/trunk/test/Modules/mismatch-diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/mismatch-diagnostics.cpp?rev=346468=346467=346468=diff
==
--- cfe/trunk/test/Modules/mismatch-diagnostics.cpp (original)
+++ cfe/trunk/test/Modules/mismatch-diagnostics.cpp Thu Nov  8 18:44:07 2018
@@ -17,6 +17,6 @@ export module mismatching_module;
 #ifdef CHECK_MISMATCH
 import mismatching_module;
 // CHECK: error: POSIX thread support was enabled in PCH file but is currently 
disabled
-// CHECK-NEXT: module file {{.*}}/mismatching_module.pcm cannot be loaded due 
to a configuration mismatch with the current compilation
+// CHECK-NEXT: module file {{.*[/|]}}mismatching_module.pcm cannot be 
loaded due to a configuration mismatch with the current compilation
 #endif
 


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


[PATCH] D51554: [CUDA][OPENMP][NVPTX]Improve logic of the debug info support.

2018-11-08 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

The llvm backend patch here has discussion around debug info kinds that we 
should iron out first.




Comment at: lib/Driver/ToolChains/Cuda.cpp:292
+  bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
+Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+ options::OPT_no_cuda_noopt_device_debug,

Is this an nvcc compatibility flag?


Repository:
  rC Clang

https://reviews.llvm.org/D51554



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


[PATCH] D54288: Fix ClangFormat issue of recognizing ObjC subscription as C++ attributes when message target is a result of a C-style method.

2018-11-08 Thread Yan Zhang via Phabricator via cfe-commits
Wizard created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D54288

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6472,6 +6472,8 @@
   // Make sure we do not mistake attributes for array subscripts.
   verifyFormat("int a() {}\n"
"[[unused]] int b() {}\n");
+  verifyFormat("NSArray *arr;\n"
+   "arr[[Foo() bar]];");
 
   // On the other hand, we still need to correctly find array subscripts.
   verifyFormat("int a = std::vector{1, 2, 3}[0];");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -352,6 +352,7 @@
   bool isCpp11AttributeSpecifier(const FormatToken ) {
 if (!Style.isCpp() || !Tok.startsSequence(tok::l_square, tok::l_square))
   return false;
+
 const FormatToken *AttrTok = Tok.Next->Next;
 if (!AttrTok)
   return false;
@@ -366,7 +367,8 @@
   // specifier parameter, although this is technically valid:
   // [[foo(:)]]
   if (AttrTok->is(tok::colon) ||
-  AttrTok->startsSequence(tok::identifier, tok::identifier))
+  AttrTok->startsSequence(tok::identifier, tok::identifier) || 
+  AttrTok->startsSequence(tok::r_paren, tok::identifier))
 return false;
   if (AttrTok->is(tok::ellipsis))
 return true;
@@ -2489,6 +2491,7 @@
 LSquareTok.endsSequence(tok::l_square, tok::colon,
 TT_SelectorName));
   };
+
   if (Left.is(tok::l_square))
 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) 
&&
 SpaceRequiredForArrayInitializerLSquare(Left, Style)) ||


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6472,6 +6472,8 @@
   // Make sure we do not mistake attributes for array subscripts.
   verifyFormat("int a() {}\n"
"[[unused]] int b() {}\n");
+  verifyFormat("NSArray *arr;\n"
+   "arr[[Foo() bar]];");
 
   // On the other hand, we still need to correctly find array subscripts.
   verifyFormat("int a = std::vector{1, 2, 3}[0];");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -352,6 +352,7 @@
   bool isCpp11AttributeSpecifier(const FormatToken ) {
 if (!Style.isCpp() || !Tok.startsSequence(tok::l_square, tok::l_square))
   return false;
+
 const FormatToken *AttrTok = Tok.Next->Next;
 if (!AttrTok)
   return false;
@@ -366,7 +367,8 @@
   // specifier parameter, although this is technically valid:
   // [[foo(:)]]
   if (AttrTok->is(tok::colon) ||
-  AttrTok->startsSequence(tok::identifier, tok::identifier))
+  AttrTok->startsSequence(tok::identifier, tok::identifier) || 
+  AttrTok->startsSequence(tok::r_paren, tok::identifier))
 return false;
   if (AttrTok->is(tok::ellipsis))
 return true;
@@ -2489,6 +2491,7 @@
 LSquareTok.endsSequence(tok::l_square, tok::colon,
 TT_SelectorName));
   };
+
   if (Left.is(tok::l_square))
 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
 SpaceRequiredForArrayInitializerLSquare(Left, Style)) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r346467 - Remove unused c'tor.

2018-11-08 Thread Bill Wendling via cfe-commits
Author: void
Date: Thu Nov  8 18:03:24 2018
New Revision: 346467

URL: http://llvm.org/viewvc/llvm-project?rev=346467=rev
Log:
Remove unused c'tor.

Modified:
clang-tools-extra/trunk/modularize/ModuleAssistant.cpp

Modified: clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModuleAssistant.cpp?rev=346467=346466=346467=diff
==
--- clang-tools-extra/trunk/modularize/ModuleAssistant.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModuleAssistant.cpp Thu Nov  8 18:03:24 
2018
@@ -46,7 +46,6 @@ namespace {
 class Module {
 public:
   Module(llvm::StringRef Name, bool Problem);
-  Module();
   ~Module();
   bool output(llvm::raw_fd_ostream , int Indent);
   Module *findSubModule(llvm::StringRef SubName);
@@ -65,7 +64,6 @@ public:
 // Constructors.
 Module::Module(llvm::StringRef Name, bool Problem)
   : Name(Name), IsProblem(Problem) {}
-Module::Module() : IsProblem(false) {}
 
 // Destructor.
 Module::~Module() {


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


[PATCH] D53675: [WebAssembly] Lower select for vectors

2018-11-08 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346462: [WebAssembly] Lower select for vectors (authored by 
tlively, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D53675

Files:
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/trunk/test/CodeGen/WebAssembly/simd-select.ll
  llvm/trunk/test/CodeGen/WebAssembly/simd-vselect.ll

Index: llvm/trunk/test/CodeGen/WebAssembly/simd-select.ll
===
--- llvm/trunk/test/CodeGen/WebAssembly/simd-select.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/simd-select.ll
@@ -0,0 +1,463 @@
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-unimplemented-simd -mattr=+simd128,+sign-ext | FileCheck %s
+
+; Test that vector selects of various varieties lower correctly to bitselects.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+; ==
+; 16 x i8
+; ==
+; CHECK-LABEL: vselect_v16i8:
+; CHECK-NEXT: .param v128, v128, v128{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 7{{$}}
+; CHECK-NEXT: i8x16.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
+; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 7{{$}}
+; CHECK-NEXT: i8x16.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
+; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @vselect_v16i8(<16 x i1> %c, <16 x i8> %x, <16 x i8> %y) {
+  %res = select <16 x i1> %c, <16 x i8> %x, <16 x i8> %y
+  ret <16 x i8> %res
+}
+
+; CHECK-LABEL: select_v16i8:
+; CHECK-NEXT: .param i32, v128, v128{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
+; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
+; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
+; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
+; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @select_v16i8(i1 %c, <16 x i8> %x, <16 x i8> %y) {
+  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
+  ret <16 x i8> %res
+}
+
+; CHECK-LABEL: select_cmp_v16i8:
+; CHECK-NEXT: .param i32, v128, v128{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31
+; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
+; CHECK-NEXT: i8x16.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
+; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @select_cmp_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
+  %c = icmp slt i32 %i, 0
+  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
+  ret <16 x i8> %res
+}
+
+; CHECK-LABEL: select_ne_v16i8:
+; CHECK-NEXT: .param i32, v128, v128{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
+; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
+; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
+; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
+; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @select_ne_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
+  %c = icmp ne i32 %i, 0
+  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
+  ret <16 x i8> %res
+}
+
+; CHECK-LABEL: select_eq_v16i8:
+; CHECK-NEXT: .param i32, v128, v128{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
+; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
+; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
+; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
+; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define <16 x i8> @select_eq_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
+  %c = icmp eq i32 %i, 0
+  %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
+  ret <16 x i8> %res
+}
+
+; ==
+; 8 x i16
+; ==
+; CHECK-LABEL: vselect_v8i16:
+; CHECK-NEXT: .param v128, v128, v128{{$}}
+; CHECK-NEXT: .result v128{{$}}
+; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 15{{$}}
+; CHECK-NEXT: i16x8.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
+; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 15{{$}}
+; CHECK-NEXT: i16x8.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
+; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define <8 x 

[clang-tools-extra] r346461 - Ignore implicit things like ConstantExpr.

2018-11-08 Thread Bill Wendling via cfe-commits
Author: void
Date: Thu Nov  8 17:32:30 2018
New Revision: 346461

URL: http://llvm.org/viewvc/llvm-project?rev=346461=rev
Log:
Ignore implicit things like ConstantExpr.

Modified:

clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp?rev=346461=346460=346461=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp 
Thu Nov  8 17:32:30 2018
@@ -58,7 +58,8 @@ void NoexceptMoveConstructorCheck::check
 // where expr evaluates to false.
 if (ProtoType->canThrow() == CT_Can) {
   Expr *E = ProtoType->getNoexceptExpr();
-  if (!isa(ProtoType->getNoexceptExpr())) {
+  E = E->IgnoreImplicit();
+  if (!isa(E)) {
 diag(E->getExprLoc(),
  "noexcept specifier on the move %0 evaluates to 'false'")
 << MethodType;


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


r346458 - Use correct parameter name in comment.

2018-11-08 Thread Bill Wendling via cfe-commits
Author: void
Date: Thu Nov  8 17:04:05 2018
New Revision: 346458

URL: http://llvm.org/viewvc/llvm-project?rev=346458=rev
Log:
Use correct parameter name in comment.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=346458=346457=346458=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Thu Nov  8 
17:04:05 2018
@@ -234,7 +234,7 @@ private:
   /// Query an option's string value.
   ///
   /// If an option value is not provided, returns the given \p DefaultVal.
-  /// @param [in] Name Name for option to retrieve.
+  /// @param [in] OptionName Name for option to retrieve.
   /// @param [in] DefaultVal Default value returned if no such option was
   /// specified.
   StringRef getStringOption(StringRef OptionName, StringRef DefaultVal);


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


[PATCH] D54243: DebugInfo: Add a driver flag for DWARF debug_ranges base address specifier use.

2018-11-08 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

I have no other bikeshed colors here. :)


Repository:
  rC Clang

https://reviews.llvm.org/D54243



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


[PATCH] D53921: Compound literals, enums, et al require const expr

2018-11-08 Thread Bill Wendling via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346455: Compound literals, enums, et al require const expr 
(authored by void, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53921?vs=172313=173248#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53921

Files:
  include/clang/AST/Expr.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Import/switch-stmt/test.cpp
  test/Misc/ast-dump-attr.cpp
  test/Misc/ast-dump-c-attr.c
  test/Misc/ast-dump-color.cpp
  test/Misc/ast-dump-decl.c
  test/Misc/ast-dump-decl.cpp
  test/SemaCXX/compound-literal.cpp
  test/Tooling/clang-check-ast-dump.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -3024,8 +3024,7 @@
 private:
   ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
unsigned BasePathLength, ExprValueKind VK)
-: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) {
-  }
+: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { }
 
   /// Construct an empty implicit cast.
   explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize)
@@ -3068,8 +3067,13 @@
 
 inline Expr *Expr::IgnoreImpCasts() {
   Expr *e = this;
-  while (ImplicitCastExpr *ice = dyn_cast(e))
-e = ice->getSubExpr();
+  while (true)
+if (ImplicitCastExpr *ice = dyn_cast(e))
+  e = ice->getSubExpr();
+else if (ConstantExpr *ce = dyn_cast(e))
+  e = ce->getSubExpr();
+else
+  break;
   return e;
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1574,6 +1574,18 @@
UnresolvedUsingTypenameDecl>
 unresolvedUsingTypenameDecl;
 
+/// Matches a constant expression wrapper.
+///
+/// Example matches the constant in the case statement:
+/// (matcher = constantExpr())
+/// \code
+///   switch (a) {
+///   case 37: break;
+///   }
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+constantExpr;
+
 /// Matches parentheses used in expressions.
 ///
 /// Example matches (foo() + 1)
Index: test/Misc/ast-dump-color.cpp
===
--- test/Misc/ast-dump-color.cpp
+++ test/Misc/ast-dump-color.cpp
@@ -49,12 +49,14 @@
 //CHECK: {{^}}[[Blue]]| |   |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:11[[RESET]]> [[Green]]'int'[[RESET]][[Cyan:.\[0;36m]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| |   `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:14[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:3[[RESET]], [[Yellow]]line:12:27[[RESET]]>{{$}}
-//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[MAGENTA]]ConstantExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]| | | | `-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]AttributedStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:12:5[[RESET]], [[Yellow]]col:27[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |   |-[[RESET]][[BLUE]]FallThroughAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:7[[RESET]], [[Yellow]]col:14[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |   `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:27[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 

[PATCH] D53921: Compound literals, enums, et al require const expr

2018-11-08 Thread Bill Wendling via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346455: Compound literals, enums, et al require const expr 
(authored by void, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53921?vs=172313=173249#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53921

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/lib/Analysis/CFG.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprComplex.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Import/switch-stmt/test.cpp
  cfe/trunk/test/Misc/ast-dump-attr.cpp
  cfe/trunk/test/Misc/ast-dump-c-attr.c
  cfe/trunk/test/Misc/ast-dump-color.cpp
  cfe/trunk/test/Misc/ast-dump-decl.c
  cfe/trunk/test/Misc/ast-dump-decl.cpp
  cfe/trunk/test/SemaCXX/compound-literal.cpp
  cfe/trunk/test/Tooling/clang-check-ast-dump.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -1260,6 +1260,8 @@
 return EmitVAArgExprLValue(cast(E));
   case Expr::DeclRefExprClass:
 return EmitDeclRefLValue(cast(E));
+  case Expr::ConstantExprClass:
+return EmitLValue(cast(E)->getSubExpr());
   case Expr::ParenExprClass:
 return EmitLValue(cast(E)->getSubExpr());
   case Expr::GenericSelectionExprClass:
Index: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp
@@ -125,6 +125,10 @@
 return Visit(E->getReplacement());
   }
 
+  void VisitConstantExpr(ConstantExpr *E) {
+return Visit(E->getSubExpr());
+  }
+
   // l-values.
   void VisitDeclRefExpr(DeclRefExpr *E) { EmitAggLoadOfLValue(E); }
   void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -723,6 +723,10 @@
 return nullptr;
   }
 
+  llvm::Constant *VisitConstantExpr(ConstantExpr *CE, QualType T) {
+return Visit(CE->getSubExpr(), T);
+  }
+
   llvm::Constant *VisitParenExpr(ParenExpr *PE, QualType T) {
 return Visit(PE->getSubExpr(), T);
   }
@@ -1601,6 +1605,7 @@
   ConstantLValue tryEmitBase(const APValue::LValueBase );
 
   ConstantLValue VisitStmt(const Stmt *S) { return nullptr; }
+  ConstantLValue VisitConstantExpr(const ConstantExpr *E);
   ConstantLValue VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   ConstantLValue VisitStringLiteral(const StringLiteral *E);
   ConstantLValue VisitObjCEncodeExpr(const ObjCEncodeExpr *E);
@@ -1756,6 +1761,11 @@
 }
 
 ConstantLValue
+ConstantLValueEmitter::VisitConstantExpr(const ConstantExpr *E) {
+  return Visit(E->getSubExpr());
+}
+
+ConstantLValue
 ConstantLValueEmitter::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
   return tryEmitGlobalCompoundLiteral(CGM, Emitter.CGF, E);
 }
Index: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp
@@ -101,6 +101,9 @@
 llvm_unreachable("Stmt can't have complex result type!");
   }
   ComplexPairTy VisitExpr(Expr *S);
+  ComplexPairTy VisitConstantExpr(ConstantExpr *E) {
+return Visit(E->getSubExpr());
+  }
   ComplexPairTy VisitParenExpr(ParenExpr *PE) { return Visit(PE->getSubExpr());}
   ComplexPairTy VisitGenericSelectionExpr(GenericSelectionExpr *GE) {
 return Visit(GE->getResultExpr());
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -398,6 +398,9 @@
   }
   Value *VisitExpr(Expr *S);
 
+  Value *VisitConstantExpr(ConstantExpr *E) {
+return Visit(E->getSubExpr());
+  }
   Value *VisitParenExpr(ParenExpr *PE) {
 return Visit(PE->getSubExpr());
   }
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

r346455 - Compound literals, enums, et al require const expr

2018-11-08 Thread Bill Wendling via cfe-commits
Author: void
Date: Thu Nov  8 16:41:36 2018
New Revision: 346455

URL: http://llvm.org/viewvc/llvm-project?rev=346455=rev
Log:
Compound literals, enums, et al require const expr

Summary:
Compound literals,  enums, file-scoped arrays, etc. require their
initializers and size specifiers to be constant. Wrap the initializer
expressions in a ConstantExpr so that we can easily check for this later
on.

Reviewers: rsmith, shafik

Reviewed By: rsmith

Subscribers: cfe-commits, jyknight, nickdesaulniers

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

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Import/switch-stmt/test.cpp
cfe/trunk/test/Misc/ast-dump-attr.cpp
cfe/trunk/test/Misc/ast-dump-c-attr.c
cfe/trunk/test/Misc/ast-dump-color.cpp
cfe/trunk/test/Misc/ast-dump-decl.c
cfe/trunk/test/Misc/ast-dump-decl.cpp
cfe/trunk/test/SemaCXX/compound-literal.cpp
cfe/trunk/test/Tooling/clang-check-ast-dump.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=346455=346454=346455=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Nov  8 16:41:36 2018
@@ -3024,8 +3024,7 @@ class ImplicitCastExpr final
 private:
   ImplicitCastExpr(QualType ty, CastKind kind, Expr *op,
unsigned BasePathLength, ExprValueKind VK)
-: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) {
-  }
+: CastExpr(ImplicitCastExprClass, ty, VK, kind, op, BasePathLength) { }
 
   /// Construct an empty implicit cast.
   explicit ImplicitCastExpr(EmptyShell Shell, unsigned PathSize)
@@ -3068,8 +3067,13 @@ public:
 
 inline Expr *Expr::IgnoreImpCasts() {
   Expr *e = this;
-  while (ImplicitCastExpr *ice = dyn_cast(e))
-e = ice->getSubExpr();
+  while (true)
+if (ImplicitCastExpr *ice = dyn_cast(e))
+  e = ice->getSubExpr();
+else if (ConstantExpr *ce = dyn_cast(e))
+  e = ce->getSubExpr();
+else
+  break;
   return e;
 }
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=346455=346454=346455=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Nov  8 16:41:36 2018
@@ -1574,6 +1574,18 @@ extern const internal::VariadicDynCastAl
UnresolvedUsingTypenameDecl>
 unresolvedUsingTypenameDecl;
 
+/// Matches a constant expression wrapper.
+///
+/// Example matches the constant in the case statement:
+/// (matcher = constantExpr())
+/// \code
+///   switch (a) {
+///   case 37: break;
+///   }
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+constantExpr;
+
 /// Matches parentheses used in expressions.
 ///
 /// Example matches (foo() + 1)

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=346455=346454=346455=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Nov  8 16:41:36 2018
@@ -579,6 +579,7 @@ namespace clang {
 ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
 ExpectedStmt VisitAtomicExpr(AtomicExpr *E);
 ExpectedStmt VisitAddrLabelExpr(AddrLabelExpr *E);
+ExpectedStmt VisitConstantExpr(ConstantExpr *E);
 ExpectedStmt VisitParenExpr(ParenExpr *E);
 ExpectedStmt VisitParenListExpr(ParenListExpr *E);
 ExpectedStmt VisitStmtExpr(StmtExpr *E);
@@ -6366,6 +6367,17 @@ ExpectedStmt ASTNodeImporter::VisitAddrL
   ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
 }
 
+ExpectedStmt ASTNodeImporter::VisitConstantExpr(ConstantExpr *E) {
+  auto Imp = 

[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-11-08 Thread Nikita Astafev via Phabricator via cfe-commits
nastafev added a comment.

Thanks, I agree with @andrew.w.kaylor and his interpretation.
I was trying to convey the message that the programmer operating with 
intrinsics relies on the semantics they carry because there's no other way to 
express that semantics. Re-optimizing what's already optimized (hand-written 
code with intrinsics) may be nice, but not critical in his (my) view, whereas 
violating semantics defeats the purpose - I could have written that same loop 
around generic compare myself if that was enough for my purposes. I would not 
insist on the way you resolve this, this is not urgent, but I do believe this 
is a regression and it deserves a fix.


Repository:
  rC Clang

https://reviews.llvm.org/D45616



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


r346454 - Fix a use-after-free introduced by r344915.

2018-11-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Nov  8 16:26:15 2018
New Revision: 346454

URL: http://llvm.org/viewvc/llvm-project?rev=346454=rev
Log:
Fix a use-after-free introduced by r344915.

r344915 added a call to ApplyDebugLocation to the sanitizer check
function emitter. Some of the sanitizers are emitted in the function
epilogue though and the LexicalScopeStack is emptied out before. By
detecting this situation and early-exiting from ApplyDebugLocation the
fallback location is used, which is equivalent to the return location.

rdar://problem/45859802

Added:
cfe/trunk/test/CodeGen/ubsan-debuglog-return.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=346454=346453=346454=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Nov  8 16:26:15 2018
@@ -3538,7 +3538,7 @@ void CGDebugInfo::EmitLocation(CGBuilder
   // Update our current location
   setLocation(Loc);
 
-  if (CurLoc.isInvalid() || CurLoc.isMacroID())
+  if (CurLoc.isInvalid() || CurLoc.isMacroID() || LexicalBlockStack.empty())
 return;
 
   llvm::MDNode *Scope = LexicalBlockStack.back();

Added: cfe/trunk/test/CodeGen/ubsan-debuglog-return.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-debuglog-return.c?rev=346454=auto
==
--- cfe/trunk/test/CodeGen/ubsan-debuglog-return.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-debuglog-return.c Thu Nov  8 16:26:15 2018
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=line-tables-only -emit-llvm 
-fsanitize=returns-nonnull-attribute -o - %s | FileCheck %s
+// The UBSAN function call in the epilogue needs to have a debug location.
+
+__attribute__((returns_nonnull)) void *allocate() {}
+
+// CHECK: define nonnull i8* @allocate(){{.*}} !dbg
+// CHECK: call void @__ubsan_handle_nonnull_return_v1_abort
+// CHECK-SAME:  !dbg ![[LOC:[0-9]+]]
+// CHECK: ret i8*
+// CHECK-SAME:  !dbg ![[LOC]]


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


[PATCH] D53921: Compound literals, enums, et al require const expr

2018-11-08 Thread Bill Wendling via Phabricator via cfe-commits
void marked an inline comment as done.
void added a comment.

I'm using "arcanist" for the first time, and I don't want to mess things up. 
I'll address the comments here in the next patch.


Repository:
  rC Clang

https://reviews.llvm.org/D53921



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


[PATCH] D51575: [clang-tidy/checks] Implement a clang-tidy check to verify Google Objective-C function naming conventions 

2018-11-08 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added inline comments.



Comment at: docs/clang-tidy/checks/google-objc-function-naming.rst:20
+  static bool is_positive(int i) { return i > 0; }
+  bool IsNegative(int i) { return i < 0; }
+

benhamilton wrote:
> This is not actually handled by the check, right? (You even have a test which 
> confirms this.)
> 
> As far as I can tell, this check essentially looks for at least one capital 
> letter and no `_` in function names, right?
It does flag this declaration because it's missing an appropriate prefix.

It looks like I neglected to add a test case for that. I have done so now.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51575



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


[PATCH] D53700: Support _Clang as a scoped attribute identifier

2018-11-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Let's do it. The diagnostic and fix-it is awesome ;)


https://reviews.llvm.org/D53700



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


[PATCH] D51575: [clang-tidy/checks] Implement a clang-tidy check to verify Google Objective-C function naming conventions 

2018-11-08 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 173244.
stephanemoore marked an inline comment as done.
stephanemoore added a comment.

Added a test case for an extern function without an appropriate prefix 
(`IsPrime`).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51575

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/FunctionNamingCheck.cpp
  clang-tidy/google/FunctionNamingCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-function-naming.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-objc-function-naming.m

Index: test/clang-tidy/google-objc-function-naming.m
===
--- /dev/null
+++ test/clang-tidy/google-objc-function-naming.m
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s google-objc-function-naming %t
+
+typedef _Bool bool;
+
+static bool ispositive(int a) { return a > 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function name 'ispositive' not using function naming conventions described by Google Objective-C style guide
+// CHECK-FIXES: static bool Ispositive(int a) { return a > 0; }
+
+static bool is_positive(int a) { return a > 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function name 'is_positive' not using function naming conventions described by Google Objective-C style guide
+// CHECK-FIXES: static bool IsPositive(int a) { return a > 0; }
+
+static bool isPositive(int a) { return a > 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function name 'isPositive' not using function naming conventions described by Google Objective-C style guide
+// CHECK-FIXES: static bool IsPositive(int a) { return a > 0; }
+
+static bool Is_Positive(int a) { return a > 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function name 'Is_Positive' not using function naming conventions described by Google Objective-C style guide
+// CHECK-FIXES: static bool IsPositive(int a) { return a > 0; }
+
+static bool IsPositive(int a) { return a > 0; }
+
+bool ispalindrome(const char *str);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function name 'ispalindrome' not using function naming conventions described by Google Objective-C style guide
+
+static const char *md5(const char *str) { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: function name 'md5' not using function naming conventions described by Google Objective-C style guide
+// CHECK-FIXES: static const char *Md5(const char *str) { return 0; }
+
+static const char *MD5(const char *str) { return 0; }
+
+static const char *URL(void) { return "https://clang.llvm.org/;; }
+
+static const char *DEFURL(void) { return "https://clang.llvm.org/;; }
+
+static const char *DEFFooURL(void) { return "https://clang.llvm.org/;; }
+
+static const char *StringFromNSString(id str) { return ""; }
+
+void ABLog_String(const char *str);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function name 'ABLog_String' not using function naming conventions described by Google Objective-C style guide
+
+void ABLogString(const char *str);
+
+bool IsPrime(int a);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function name 'IsPrime' not using function naming conventions described by Google Objective-C style guide
+
+const char *ABURL(void) { return "https://clang.llvm.org/;; }
+
+const char *ABFooURL(void) { return "https://clang.llvm.org/;; }
+
+int main(int argc, const char **argv) { return 0; }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -120,6 +120,7 @@
google-explicit-constructor
google-global-names-in-headers
google-objc-avoid-throwing-exception
+   google-objc-function-naming
google-objc-global-variable-declaration
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: docs/clang-tidy/checks/google-objc-function-naming.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-objc-function-naming.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - google-objc-function-naming
+
+google-objc-function-naming
+===
+
+Finds function declarations in Objective-C files that do not follow the pattern
+described in the Google Objective-C Style Guide.
+
+The corresponding style guide rule can be found here:
+https://google.github.io/styleguide/objcguide.html#function-names
+
+All function names should be in upper camel case. Functions whose storage class
+is not static should have an appropriate prefix.
+
+The following code sample does not follow this pattern:
+
+.. code-block:: objc
+
+  static bool is_positive(int i) { return i > 0; }
+  bool IsNegative(int i) { return i < 0; }
+
+The sample above might be corrected to the following code:
+
+.. code-block:: objc
+
+  static bool IsPositive(int i) { 

[PATCH] D54281: [clang-tidy] fix PR39583 - ignoring ParenCast for string-literals in pro-bounds-array-to-pointer-decay

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:65
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParenCasts(stringLiteral()
   .bind("cast"),

JonasToth wrote:
> aaron.ballman wrote:
> > I think you want `ignoringParens()` instead, no?
> That doesn't seem to compile, it only applies to `QualType`. There is 
> `ignoringParenCasts` and `ignoringParenImpCasts` that match on everything. 
> Ignoring the imp-casts is not what we want.
Neither is ignoring the paren casts because that covers actual casts like 
reinterpret_cast. There is an `Expr::IgnoreParens()`, so I'm betting that the 
`ignoringParens()` matcher just needs an overload for `Expr`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54281



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


[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clangd/index/Background.cpp:29
 #include 
+#include 
+#include 

Please run Clang-format. Headers in sections should be in alphabetical order.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269



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


[PATCH] D54281: [clang-tidy] fix PR39583 - ignoring ParenCast for string-literals in pro-bounds-array-to-pointer-decay

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: 
clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:65
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParenCasts(stringLiteral()
   .bind("cast"),

aaron.ballman wrote:
> I think you want `ignoringParens()` instead, no?
That doesn't seem to compile, it only applies to `QualType`. There is 
`ignoringParenCasts` and `ignoringParenImpCasts` that match on everything. 
Ignoring the imp-casts is not what we want.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54281



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


[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-11-08 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

Agreed. Reverting this patch wouldn't move us forward on constrained FP 
handling. What I'm saying (and what I think @nastafev  is saying) is that this 
patch is taking a built-in that allows the user to express specific signalling 
behavior and throwing away that aspect of its semantics. Granted we do say that 
FP environment access is unsupported, so technically unmasking FP exceptions or 
even reading the status flag is undefined behavior. But it seems like there's a 
pretty big difference between using that claim to justify enabling some 
optimization that might do constant folding in a way that assumes the default 
rounding mode versus using that claim to disregard part of the semantics of a 
built-in that is modeling a target-specific instruction.

I'm not insisting that we have to revert this patch or anything like that. I'm 
just saying that we should think about it. My personal preference would 
actually be to have this code re-implemented using the new constrained fcmp 
intrinsic when it lands. That still leaves the masking part of this unsettled, 
but as you say that's probably not a priority right now.

BTW, here's a link to the constrained fcmp review: 
https://reviews.llvm.org/D54121


Repository:
  rC Clang

https://reviews.llvm.org/D45616



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


[PATCH] D54281: [clang-tidy] fix PR39583 - ignoring ParenCast for string-literals in pro-bounds-array-to-pointer-decay

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:65
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParenCasts(stringLiteral()
   .bind("cast"),

I think you want `ignoringParens()` instead, no?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54281



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


[PATCH] D53700: Support _Clang as a scoped attribute identifier

2018-11-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

I'm fine with `_Clang` or anything else too. Thanks for doing this!




Comment at: lib/Basic/Attributes.cpp:18
   if (ScopeName == "__gnu__")
-ScopeName = ScopeName.slice(2, ScopeName.size() - 2);
 

That was a complicated way of doing something simple.


https://reviews.llvm.org/D53700



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


[PATCH] D54281: [clang-tidy] fix PR39583 - ignoring ParenCast for string-literals in pro-bounds-array-to-pointer-decay

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, alexfh, hokein.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.

The fix to the issue that `const char* p = ("foo")` is diagnosed as decay
is to ignored the ParenCast.
Resolves PR39583


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54281

Files:
  clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp


Index: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -30,6 +30,7 @@
   arrayviewfun(av); // OK
 
   int i = a[0];  // OK
+  int j = a[(1 + 2)];// OK
   pointerfun([0]); // OK
 
   for (auto  : a) // OK, iteration internally decays array to pointer
@@ -39,6 +40,9 @@
 const char *g() {
   return "clang"; // OK, decay string literal to pointer
 }
+const char *g2() {
+return ("clang"); // OK, ParenCast hides the literal-pointer decay
+}
 
 void f2(void *const *);
 void bug25362() {
Index: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -58,10 +58,11 @@
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
-  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
-   unless(hasParentIgnoringImpCasts(explicitCastExpr())),
-   unless(isInsideOfRangeBeginEndStmt()),
-   unless(hasSourceExpression(stringLiteral(
+  implicitCastExpr(
+  unless(hasParent(arraySubscriptExpr())),
+  unless(hasParentIgnoringImpCasts(explicitCastExpr())),
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParenCasts(stringLiteral()
   .bind("cast"),
   this);
 }


Index: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -30,6 +30,7 @@
   arrayviewfun(av); // OK
 
   int i = a[0];  // OK
+  int j = a[(1 + 2)];// OK
   pointerfun([0]); // OK
 
   for (auto  : a) // OK, iteration internally decays array to pointer
@@ -39,6 +40,9 @@
 const char *g() {
   return "clang"; // OK, decay string literal to pointer
 }
+const char *g2() {
+return ("clang"); // OK, ParenCast hides the literal-pointer decay
+}
 
 void f2(void *const *);
 void bug25362() {
Index: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -58,10 +58,11 @@
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
-  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
-   unless(hasParentIgnoringImpCasts(explicitCastExpr())),
-   unless(isInsideOfRangeBeginEndStmt()),
-   unless(hasSourceExpression(stringLiteral(
+  implicitCastExpr(
+  unless(hasParent(arraySubscriptExpr())),
+  unless(hasParentIgnoringImpCasts(explicitCastExpr())),
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParenCasts(stringLiteral()
   .bind("cast"),
   this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: docs/clang-tidy/checks/llvm-problematic-statics.rst:7
+
+Looks for functions defined in "public" headers that return the address of a 
static local. These are not guaranteed to have the addresss across shared 
libraries and could be problematic for plugins.
+

Eugene.Zelenko wrote:
> static local variable? Probably //Looks for// should be replaced with 
> //Detects//. Please also wrap with 80 characters.
to have the address -> to have the same address


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54222



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


[PATCH] D53921: Compound literals, enums, et al require const expr

2018-11-08 Thread Bill Wendling via Phabricator via cfe-commits
void marked 2 inline comments as done.
void added inline comments.



Comment at: include/clang/AST/Expr.h:3073-3074
+  e = ice->getSubExpr();
+else if (ConstantExpr *ce = dyn_cast(e))
+  e = ce->getSubExpr();
+else

rsmith wrote:
> Should we skip an arbitrary `FullExpr` here (and in the other `Ignore` 
> functions below)?
Sure. That seems reasonable.



Comment at: lib/Sema/SemaType.cpp:2236-2238
+  if (ArraySize && !CurContext->isFunctionOrMethod())
+// A file-scoped array must have a constant array size.
+ArraySize = new (Context) ConstantExpr(ArraySize);

rsmith wrote:
> As noted above, I'd prefer for `VerifyIntegerConstantExpression` to create 
> this. But if we need to do it here, we should do it on the code path that 
> creates a `ConstantArrayType`, not based on whether the array type appears at 
> file scope.
I think my next patch takes care of this (moves it to 
`VerifyIntegerConstantExpression`). There may be conflicts between the two 
patches though, so I'd like to move this there in the follow-up patch.


Repository:
  rC Clang

https://reviews.llvm.org/D53921



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


[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/llvm/ProblematicStaticsCheck.cpp:33
+  const auto *VD = Result.Nodes.getNodeAs("var");
+  const auto *Return = Result.Nodes.getNodeAs("return");
+  diag(Return->getBeginLoc(), "address of static local variable %0 may not "

aaron.ballman wrote:
> JonasToth wrote:
> > aaron.ballman wrote:
> > > JonasToth wrote:
> > > > Please `assert` on `VD` and `Return`
> > > > Please assert on VD and Return
> > > Why?
> > because the matcher might evolve over time. Right now this can not be 
> > triggered, that is correct. Asking for it was  inappropriate but having it 
> > doesn't hurt.
> All checks may evolve over time -- this isn't a pattern I'd like to see used 
> in this sort of case, personally.
I don't insist.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54222



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


[PATCH] D54257: [clang-tidy] **Prototype** use AllTUsExecutors

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Very interesting. As I am not very familiar with all the internals I do have a 
few questions :)

Right now notes seem not be closely attached to their related warning. But 
within the there is a check, that a note is emitted after an error. Would it 
make sense to group these errors and notes together?
How would the dedup happen for static-analyzer diagnostics? Right now its only 
from the source-location, but as mentionend in the other review there might be 
many paths that lead to the same diagnostics, with the difference in the notes.

Did you check with TSAN if you get some hints on what could be the problem on 
parallel execution? Would you do the synchronization within `ClangTidyContext` 
or are there other places as well that lead to race-conditions?




Comment at: clang-tidy/ClangTidy.cpp:566
+  std::sort(Results.begin(), Results.end());
+  Results.erase(std::unique(Results.begin(), Results.end()), 
Results.end());
+}

is this deduplication, or the other place (or both? and if yes why at two 
places?)



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:652
+  std::sort(Errors.begin(), Errors.end());
+  Errors.erase(std::unique(Errors.begin(), Errors.end()), Errors.end());
   if (RemoveIncompatibleErrors)

Or this dedup?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54257



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


[PATCH] D53263: Fix places where the return type of a FunctionDecl was being used in place of the function type

2018-11-08 Thread Ben via Phabricator via cfe-commits
bobsayshilol added a reviewer: rjmccall.
bobsayshilol added a comment.

Ping.


https://reviews.llvm.org/D53263



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


[PATCH] D53921: Compound literals, enums, et al require const expr

2018-11-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, other than the compound literal part I think this is all fine. I'm 
happy for you to go ahead with this as-is; we can rearrange how we handle 
compound literals as a later change if you prefer.




Comment at: include/clang/AST/Expr.h:3073-3074
+  e = ice->getSubExpr();
+else if (ConstantExpr *ce = dyn_cast(e))
+  e = ce->getSubExpr();
+else

Should we skip an arbitrary `FullExpr` here (and in the other `Ignore` 
functions below)?



Comment at: lib/Sema/SemaDecl.cpp:16086-16094
   CheckConvertedConstantExpression(Val, EltTy, EnumVal,
CCEK_Enumerator);
 if (Converted.isInvalid())
   Val = nullptr;
 else
   Val = Converted.get();
   } else if (!Val->isValueDependent() &&

void wrote:
> rsmith wrote:
> > I think it would make sense to create the `ConstantExpr` wrapper node in 
> > `CheckConvertedConstantExpr` / `VerifyIntegerConstantExpr`. (That's also 
> > where it'd make sense to cache the evaluated value on the wrapper node once 
> > we start doing so.)
> I thought the purpose of `ConstantExpr` is to specify those places where a 
> constant expression is required. I.e., we can't have something like:
> 
> ```
> int z;
> foo y = (foo){z + 2};
> ```
> 
> In this case, `z + 2` would be wrapped by the `ConstantExpr` class. But in a 
> function or module scope, then it would be fine:
> 
> ```
> void x(int z) {
>   foo y = (foo){z + 2};
> }
> ```
> 
> So `z + 2` wouldn't be wrapped. If I perform the wrapping in 
> `CheckConvertedConstantExpr`, et al, then it doesn't seem like I have the 
> context to say that it's a) a compound literal, and b) in file scope. So how 
> can I correctly wrap it?
In the above example, I think we should have a `ConstantExpr` wrapping the 
entire initializer of `y`, because the whole thing is required to be a constant 
expression. Eg,

```
int z = 123;
```

... would *also* have a `ConstantExpr` wrapped around it -- indeed, in C, there 
should be a `ConstantExpr` around the initializer of all global variables, 
because they're all required to be initialized by constant expressions. So 
that's why I think the compound-literal part is a red herring.



Comment at: lib/Sema/SemaType.cpp:2236-2238
+  if (ArraySize && !CurContext->isFunctionOrMethod())
+// A file-scoped array must have a constant array size.
+ArraySize = new (Context) ConstantExpr(ArraySize);

As noted above, I'd prefer for `VerifyIntegerConstantExpression` to create 
this. But if we need to do it here, we should do it on the code path that 
creates a `ConstantArrayType`, not based on whether the array type appears at 
file scope.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:1286-1288
+  // Handled due to it being a wrapper class.
+  break;
+

Maybe just share the code for the two `FullExpr` cases?


Repository:
  rC Clang

https://reviews.llvm.org/D53921



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


[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/llvm/ProblematicStaticsCheck.cpp:33
+  const auto *VD = Result.Nodes.getNodeAs("var");
+  const auto *Return = Result.Nodes.getNodeAs("return");
+  diag(Return->getBeginLoc(), "address of static local variable %0 may not "

JonasToth wrote:
> aaron.ballman wrote:
> > JonasToth wrote:
> > > Please `assert` on `VD` and `Return`
> > > Please assert on VD and Return
> > Why?
> because the matcher might evolve over time. Right now this can not be 
> triggered, that is correct. Asking for it was  inappropriate but having it 
> doesn't hurt.
All checks may evolve over time -- this isn't a pattern I'd like to see used in 
this sort of case, personally.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54222



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


[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-11-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Yes, in constrained-fp mode we might need intrinsics, at least short-term.  I 
assume you'll probably add target-independent constrained masked fp vector 
operations at some point, but that's probably not a priority.  But that still 
leaves two problems.  One, clang doesn't currently have any flag that actually 
makes sense to control this.  (I assume it will be added soon, but it doesn't 
exist yet.)  I mean, it's technically possible to gate it under one of the 
fast-math flags, like @nastafev suggested, but that's not semantically correct. 
 And two, the removed intrinsics didn't have the right semantics for 
constrained-fp mode anyway: they were marked readnone.  So we need new 
intrinsics anyway.

So yes, it's possible we could revert this patch, and that might fix 
@nastafev's code for the next few months, but it doesn't help us at all in 
terms of making constrained fp work correctly in general.


Repository:
  rC Clang

https://reviews.llvm.org/D45616



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


[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/llvm/ProblematicStaticsCheck.cpp:33
+  const auto *VD = Result.Nodes.getNodeAs("var");
+  const auto *Return = Result.Nodes.getNodeAs("return");
+  diag(Return->getBeginLoc(), "address of static local variable %0 may not "

aaron.ballman wrote:
> JonasToth wrote:
> > Please `assert` on `VD` and `Return`
> > Please assert on VD and Return
> Why?
because the matcher might evolve over time. Right now this can not be 
triggered, that is correct. Asking for it was  inappropriate but having it 
doesn't hurt.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54222



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


[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:178
+  return;
+// Conversions to unsigned integer are well defined and follow modulo 2
+// arithmetic.

gchatelet wrote:
> JonasToth wrote:
> > I am surprised by `following modulo 2 arithmetic` and think it's a bit 
> > misleading. Writing just `module arithmetic` is probably better, as `module 
> > 2` somewhat implies there a only 2 valid values (0, 1).
> > 
> > Is this the `int` -> `unsigned int` case path? That seems worth diagnosing 
> > too.
> Yes, thx for noticing. I updated the comment, I think it's better now.
> 
> Indeed this is the `int` -> `unsigned int` case path. Warning here would lead 
> to a lot of noise for everybody doing bitwise operations since `-1` is a 
> compact way to represent the maximum value. Since the semantic is valid and 
> well defined by the standard I'm unsure it's worth the pain. I'm open to 
> suggestions though.
> 
> Maybe a good way to figure out is what would be the correct fix for say 
> `unsigned long AllBits = -1;`
Comment is fine :)

I though that we have check that diagnoses `unsigned i = -1;` but I don't find 
it right now (maybe its still in review or so, i belive it was related to 
introducing `std::numeric_limits<>`).
As its well defined and not narrowing and not mentionend by the CPPCG in that 
section its ok, maybe worth an option in the future?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2018-11-08 Thread Richard Membarth via Phabricator via cfe-commits
richardmembarth added a comment.

I think it's not so easy to provide such tests for CUDA.
CUDA memory space specifiers are implemented via attributes, e.g. `#define 
__shared__ __attribute__((shared))`.
As a result of this, they are pretty-printed via a different code path.
In my example, I call `Ctx.getAddrSpaceQualType(QT, LangAS::cuda_shared)`, 
which is then pretty-printed via the code above.
Any hints how to provide tests for this one?


Repository:
  rC Clang

https://reviews.llvm.org/D54258



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


[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

LG from my side. Please wait for feedback from @aaron.ballman or @alexfh before 
committing.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53974



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


[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-11-08 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

In https://reviews.llvm.org/D45616#1290897, @nastafev wrote:

> >   can trigger arbitrary floating-point exceptions anywhere in your code
>
> I believe this statement reflects the current state of many compilers on the 
> market, I guess I just don't see the reason why making things worse. It seems 
> the original intent of the commit was to add support for masked compares, and 
> that could have been achieved without breaking what already worked.
>
> I hope the patch is ultimately helping some performance optimization, but it 
> is breaking the original intent of some legitimate programs that worked 
> before, and introduces correctness regression. So to me it must be at least 
> guarded by a flip-switch.
>
> The reference to constrained floating-point intrinsics work is relevant, but 
> it will obviously take time and extra effort to enable and then to unbreak 
> all the cases that are made broken here. Instead one could postpone lowering 
> of the particular instructions until it was possible without violation of the 
> semantics...


That seems like a legitimate concern to me.

I believe this patch was part of a larger effort to get rid of the dependence 
on intrinsics. We have a very broad preference for expressing things using 
native IR whenever possible because (among other reasons) intrinsics block most 
optimizations and we don't want to teach optimizations to reason about 
target-specific intrinsics. In this particular case we may have overreached 
because it isn't strictly possible to express all the semantics of this 
built-in accurately using native IR.

There is a patch currently active to add constrained fcmp intrinsics, but it 
doesn't have a masked variant.


Repository:
  rC Clang

https://reviews.llvm.org/D45616



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


[PATCH] D54275: [HIP] Remove useless sections in linked files

2018-11-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.

clang-offload-bundler creates `__CLANG_OFFLOAD_BUNDLE__*` sections in the 
bundles,
which get into the linked files. These sections are useless after linking. They 
waste disk
space and cause confusion for clang when directly linked with other object 
files, therefore
should be removed.


https://reviews.llvm.org/D54275

Files:
  lib/Driver/ToolChains/CommonArgs.cpp


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1436,6 +1436,10 @@
   LksStream << "PROVIDE_HIDDEN(__hip_fatbin = .);\n";
   LksStream << "" << BundleFileName << "\n";
   LksStream << "  }\n";
+  LksStream << "  /DISCARD/ :\n";
+  LksStream << "  {\n";
+  LksStream << "* ( __CLANG_OFFLOAD_BUNDLE__* )\n";
+  LksStream << "  }\n";
   LksStream << "}\n";
   LksStream << "INSERT BEFORE .data\n";
   LksStream.flush();


Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -1436,6 +1436,10 @@
   LksStream << "PROVIDE_HIDDEN(__hip_fatbin = .);\n";
   LksStream << "" << BundleFileName << "\n";
   LksStream << "  }\n";
+  LksStream << "  /DISCARD/ :\n";
+  LksStream << "  {\n";
+  LksStream << "* ( __CLANG_OFFLOAD_BUNDLE__* )\n";
+  LksStream << "  }\n";
   LksStream << "}\n";
   LksStream << "INSERT BEFORE .data\n";
   LksStream.flush();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346439 - [Frontend/Modules] Show diagnostics on prebuilt module configuration mismatch too

2018-11-08 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Nov  8 12:47:30 2018
New Revision: 346439

URL: http://llvm.org/viewvc/llvm-project?rev=346439=rev
Log:
[Frontend/Modules] Show diagnostics on prebuilt module configuration mismatch 
too

The current version only emits  the below error for a module (attempted to be 
loaded) from the `prebuilt-module-path`:

```
error: module file blabla.pcm cannot be loaded due to a configuration mismatch 
with the current compilation [-Wmodule-file-config-mismatch]
```

With this change, if the prebuilt module is used, we allow the proper 
diagnostic behind the configuration mismatch to be shown.

```
error: POSIX thread support was disabled in PCH file but is currently enabled
error: module file blabla.pcm cannot be loaded due to a configuration mismatch 
with the current compilation [-Wmodule-file-config-mismatch]
```

(A few lines later an error is emitted anyways, so there is no reason not to 
complain for configuration mismatches if a config mismatch is found and kills 
the build.)

Reviewed By: dblaikie

Tags: #clang

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

Added:
cfe/trunk/test/Modules/mismatch-diagnostics.cpp
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=346439=346438=346439=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Nov  8 12:47:30 2018
@@ -1727,7 +1727,9 @@ CompilerInstance::loadModule(SourceLocat
 // module cache, we don't know how to rebuild modules.
 unsigned ARRFlags = Source == ModuleCache ?
 ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing :
-ASTReader::ARR_ConfigurationMismatch;
+Source == PrebuiltModulePath ?
+0 :
+ASTReader::ARR_ConfigurationMismatch;
 switch (ModuleManager->ReadAST(ModuleFileName,
Source == PrebuiltModulePath
? serialization::MK_PrebuiltModule

Added: cfe/trunk/test/Modules/mismatch-diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/mismatch-diagnostics.cpp?rev=346439=auto
==
--- cfe/trunk/test/Modules/mismatch-diagnostics.cpp (added)
+++ cfe/trunk/test/Modules/mismatch-diagnostics.cpp Thu Nov  8 12:47:30 2018
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/prebuilt_modules
+//
+// RUN: %clang_cc1 -triple %itanium_abi_triple  \
+// RUN: -fmodules-ts -fprebuilt-module-path=%t/prebuilt-modules \
+// RUN: -emit-module-interface -pthread -DBUILD_MODULE  \
+// RUN: %s -o %t/prebuilt_modules/mismatching_module.pcm
+//
+// RUN: not %clang_cc1 -triple %itanium_abi_triple -fmodules-ts \
+// RUN: -fprebuilt-module-path=%t/prebuilt_modules -DCHECK_MISMATCH \
+// RUN: %s 2>&1 | FileCheck %s
+
+#ifdef BUILD_MODULE
+export module mismatching_module;
+#endif
+
+#ifdef CHECK_MISMATCH
+import mismatching_module;
+// CHECK: error: POSIX thread support was enabled in PCH file but is currently 
disabled
+// CHECK-NEXT: module file {{.*}}/mismatching_module.pcm cannot be loaded due 
to a configuration mismatch with the current compilation
+#endif
+


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


[PATCH] D53334: [Frontend/Modules] Show diagnostics on prebuilt module configuration mismatch too

2018-11-08 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346439: [Frontend/Modules] Show diagnostics on prebuilt 
module configuration mismatch… (authored by dblaikie, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53334?vs=173124=173212#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53334

Files:
  cfe/trunk/lib/Frontend/CompilerInstance.cpp
  cfe/trunk/test/Modules/mismatch-diagnostics.cpp


Index: cfe/trunk/lib/Frontend/CompilerInstance.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp
@@ -1727,7 +1727,9 @@
 // module cache, we don't know how to rebuild modules.
 unsigned ARRFlags = Source == ModuleCache ?
 ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing :
-ASTReader::ARR_ConfigurationMismatch;
+Source == PrebuiltModulePath ?
+0 :
+ASTReader::ARR_ConfigurationMismatch;
 switch (ModuleManager->ReadAST(ModuleFileName,
Source == PrebuiltModulePath
? serialization::MK_PrebuiltModule
Index: cfe/trunk/test/Modules/mismatch-diagnostics.cpp
===
--- cfe/trunk/test/Modules/mismatch-diagnostics.cpp
+++ cfe/trunk/test/Modules/mismatch-diagnostics.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/prebuilt_modules
+//
+// RUN: %clang_cc1 -triple %itanium_abi_triple  \
+// RUN: -fmodules-ts -fprebuilt-module-path=%t/prebuilt-modules \
+// RUN: -emit-module-interface -pthread -DBUILD_MODULE  \
+// RUN: %s -o %t/prebuilt_modules/mismatching_module.pcm
+//
+// RUN: not %clang_cc1 -triple %itanium_abi_triple -fmodules-ts \
+// RUN: -fprebuilt-module-path=%t/prebuilt_modules -DCHECK_MISMATCH \
+// RUN: %s 2>&1 | FileCheck %s
+
+#ifdef BUILD_MODULE
+export module mismatching_module;
+#endif
+
+#ifdef CHECK_MISMATCH
+import mismatching_module;
+// CHECK: error: POSIX thread support was enabled in PCH file but is currently 
disabled
+// CHECK-NEXT: module file {{.*}}/mismatching_module.pcm cannot be loaded due 
to a configuration mismatch with the current compilation
+#endif
+


Index: cfe/trunk/lib/Frontend/CompilerInstance.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp
@@ -1727,7 +1727,9 @@
 // module cache, we don't know how to rebuild modules.
 unsigned ARRFlags = Source == ModuleCache ?
 ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing :
-ASTReader::ARR_ConfigurationMismatch;
+Source == PrebuiltModulePath ?
+0 :
+ASTReader::ARR_ConfigurationMismatch;
 switch (ModuleManager->ReadAST(ModuleFileName,
Source == PrebuiltModulePath
? serialization::MK_PrebuiltModule
Index: cfe/trunk/test/Modules/mismatch-diagnostics.cpp
===
--- cfe/trunk/test/Modules/mismatch-diagnostics.cpp
+++ cfe/trunk/test/Modules/mismatch-diagnostics.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/prebuilt_modules
+//
+// RUN: %clang_cc1 -triple %itanium_abi_triple  \
+// RUN: -fmodules-ts -fprebuilt-module-path=%t/prebuilt-modules \
+// RUN: -emit-module-interface -pthread -DBUILD_MODULE  \
+// RUN: %s -o %t/prebuilt_modules/mismatching_module.pcm
+//
+// RUN: not %clang_cc1 -triple %itanium_abi_triple -fmodules-ts \
+// RUN: -fprebuilt-module-path=%t/prebuilt_modules -DCHECK_MISMATCH \
+// RUN: %s 2>&1 | FileCheck %s
+
+#ifdef BUILD_MODULE
+export module mismatching_module;
+#endif
+
+#ifdef CHECK_MISMATCH
+import mismatching_module;
+// CHECK: error: POSIX thread support was enabled in PCH file but is currently disabled
+// CHECK-NEXT: module file {{.*}}/mismatching_module.pcm cannot be loaded due to a configuration mismatch with the current compilation
+#endif
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54195: Fix linker option for -fprofile-arcs -ftest-coverage

2018-11-08 Thread Jessica Han via Phabricator via cfe-commits
jessicah updated this revision to Diff 173209.
jessicah added a comment.

Updated diff with additional context upon review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D54195

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -85,6 +85,9 @@
 // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
 // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
 
+// RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck 
-check-prefix=CHECK-u %s
+// CHECK-u-NOT: "-u{{.*}}"
+
 // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE-DIR %s
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -1016,7 +1016,7 @@
 
   // Add linker option -u__llvm_runtime_variable to cause runtime
   // initialization module to be linked in.
-  if (!Args.hasArg(options::OPT_coverage))
+  if ((!Args.hasArg(options::OPT_coverage)) && 
(!Args.hasArg(options::OPT_ftest_coverage)))
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -85,6 +85,9 @@
 // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc
 // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused
 
+// RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s
+// CHECK-u-NOT: "-u{{.*}}"
+
 // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s
 // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
 // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -1016,7 +1016,7 @@
 
   // Add linker option -u__llvm_runtime_variable to cause runtime
   // initialization module to be linked in.
-  if (!Args.hasArg(options::OPT_coverage))
+  if ((!Args.hasArg(options::OPT_coverage)) && (!Args.hasArg(options::OPT_ftest_coverage)))
 CmdArgs.push_back(Args.MakeArgString(
 Twine("-u", llvm::getInstrProfRuntimeHookVarName(;
   ToolChain::addProfileRTLibs(Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54245: [VFS] Implement `RedirectingFileSystem::getRealPath`.

2018-11-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D54245#1292008, @bruno wrote:

> Hi Volodymyr. Does this behavior changed after your VFS fallback change?


https://reviews.llvm.org/D50539 didn't change `RedirectingFileSystem` behavior 
regarding real paths. But for `-ivfsoverlay` it started using nested 
`RedirectingFileSystem` instead of `OverlayFileSystem`. And `OverlayFileSystem` 
implements `getRealPath` 
.


https://reviews.llvm.org/D54245



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


[PATCH] D54245: [VFS] Implement `RedirectingFileSystem::getRealPath`.

2018-11-08 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi Volodymyr. Does this behavior changed after your VFS fallback change?


https://reviews.llvm.org/D54245



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


[PATCH] D54195: Fix linker option for -fprofile-arcs -ftest-coverage

2018-11-08 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thanks for the patch. Would you mind uploading a diff with additional context 
(e.g. git diff -U1)? Phab doesn't render it.


Repository:
  rC Clang

https://reviews.llvm.org/D54195



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-08 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In https://reviews.llvm.org/D53157#1291978, @cameron.mcinally wrote:

> In https://reviews.llvm.org/D53157#1291964, @kpn wrote:
>
> > I don't expect anyone would need to switch between constrained and regular 
> > floating point at an instruction level of granularity.
>
>
> The Standard allows for this (to some degree). E.g. FENV_ACCESS can be 
> toggled between nested compound statements.


Yes, but I'm not worried about what sort of code is input to a compiler. I'm 
worried about what is right for the compiler itself. Also, since we're in LLVM 
here, we have to think about all languages that use LLVM as a backend.


https://reviews.llvm.org/D53157



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


[PATCH] D52296: [Clang] - Add -fdwarf-fission=split,single option.

2018-11-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:5889
   const llvm::Triple  = getToolChain().getTriple();
-  if (Args.hasArg(options::OPT_gsplit_dwarf) &&
+  if ((getDebugFissionKind(D, Args) == DwarfFissionKind::Split) &&
   (T.isOSLinux() || T.isOSFuchsia())) {

grimar wrote:
> dblaikie wrote:
> > Could having more than one call to getDebugFissionKind lead to the error 
> > message (for -fdwarf-fission=garbage) being printed multiple times? Or is 
> > this call on a distinct/mutually exclusive codepath to the other?
> I think it should not be possible. Currently, there are 2 inclusions of the 
> `getDebugFissionKind `. One is used for construction clang job,
> and one is here, it is used to construct an assembler tool job. I do not see 
> a way how it can be printed multiple times.
> 
> For example, the following invocation will print it only once:
> 
> ```
> clang main.c -o out.s -S -fdwarf-fission=foo
> clang-8: error: unsupported argument 'foo' to option 'fdwarf-fission='
> ```
The example you give here will not create an assembler job. Try
`clang main.c -fdwarf-fission=foo -fno-integrated-as` which I think will 
exercise the path David is asking about.


https://reviews.llvm.org/D52296



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-08 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally added a comment.

In https://reviews.llvm.org/D53157#1291964, @kpn wrote:

> I don't expect anyone would need to switch between constrained and regular 
> floating point at an instruction level of granularity.


The Standard allows for this (to some degree). E.g. FENV_ACCESS can be toggled 
between nested compound statements.

Also, some AVX512 hardware instructions have explicit SAE and RM operands.


https://reviews.llvm.org/D53157



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-08 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

Craig Topper also raised some concerns with me (in person, his desk is right by 
mine) about the potential effect this might have on code size. He tells me that 
IRBuilder calls are intended to always be inlined and if we grow the 
implementation of these functions too much it could lead to noticeable bloat. 
It still seems to me like it might be worthwhile for the simplification it 
would allow in the front end, but I'm not really a front end guy so I 
definitely agree that we should get some input from front end people about what 
they want.


https://reviews.llvm.org/D53157



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


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:3913
+for (auto Type : Types) {
+  if (S.Context.getCanonicalType(Type)->getTypeClass() != Type::Vector)
+return false;

wuzish wrote:
> hubert.reinterpretcast wrote:
> > wuzish wrote:
> > > hubert.reinterpretcast wrote:
> > > > wuzish wrote:
> > > > > hubert.reinterpretcast wrote:
> > > > > > hubert.reinterpretcast wrote:
> > > > > > > wuzish wrote:
> > > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > > wuzish wrote:
> > > > > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > > > > wuzish wrote:
> > > > > > > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > > > > > > Considering that this is a local lambda called in one 
> > > > > > > > > > > > > place, are we expecting cases where the canonical 
> > > > > > > > > > > > > type is not something on which we can call 
> > > > > > > > > > > > > getVectorKind()? If not, then we do not need this 
> > > > > > > > > > > > > `if`.
> > > > > > > > > > > > Well, that's for ExtVectorType. I encounter some 
> > > > > > > > > > > > testcase failure because of that. So I just narrow the 
> > > > > > > > > > > > condition to only handle Type::Vector.
> > > > > > > > > > > > 
> > > > > > > > > > > > As the following comment said, so I treat it separately.
> > > > > > > > > > > > 
> > > > > > > > > > > > /// ExtVectorType - Extended vector type. This type is 
> > > > > > > > > > > > created using
> > > > > > > > > > > > /// __attribute__((ext_vector_type(n)), where "n" is 
> > > > > > > > > > > > the number of elements.
> > > > > > > > > > > > /// Unlike vector_size, ext_vector_type is only allowed 
> > > > > > > > > > > > on typedef's. This
> > > > > > > > > > > > /// class enables syntactic extensions, like Vector 
> > > > > > > > > > > > Components for accessing
> > > > > > > > > > > > /// points (as .xyzw), colors (as .rgba), and textures 
> > > > > > > > > > > > (modeled after OpenGL
> > > > > > > > > > > > /// Shading Language).
> > > > > > > > > > > An ExtVectorType is a VectorType, so what sort of 
> > > > > > > > > > > failures are you hitting?
> > > > > > > > > > Yes. But the TypeClass of ExtVectorType is ExtVector.
> > > > > > > > > > 
> > > > > > > > > > some test points check the error report for ambiguous call 
> > > > > > > > > > because of too many implicit cast choices from 
> > > > > > > > > > ext_vector_type to vector type. Such as blow.
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > typedef char char16 __attribute__ ((__vector_size__ (16)));
> > > > > > > > > > typedef long long longlong16 __attribute__ 
> > > > > > > > > > ((__vector_size__ (16)));
> > > > > > > > > > typedef char char16_e __attribute__ ((__ext_vector_type__ 
> > > > > > > > > > (16)));
> > > > > > > > > > typedef long long longlong16_e __attribute__ 
> > > > > > > > > > ((__ext_vector_type__ (2)));
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > void f1_test(char16 c16, longlong16 ll16, char16_e c16e, 
> > > > > > > > > > longlong16_e ll16e) {
> > > > > > > > > >   int  = f1(c16);
> > > > > > > > > >   float  = f1(ll16);
> > > > > > > > > >   f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
> > > > > > > > > >   f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
> > > > > > > > > > }
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > If we are gonna widen the condition, we can make a 
> > > > > > > > > > follow-up patch. Or we need include this condition and do 
> > > > > > > > > > this together in this patch?
> > > > > > > > > The widening that has occurred is in allowing the scope of 
> > > > > > > > > the change to encompass cases where AltiVec vectors are not 
> > > > > > > > > sufficiently involved. The change in behaviour makes sense, 
> > > > > > > > > and perhaps the community may want to pursue it; however, the 
> > > > > > > > > mandate to make that level of change has not been given.
> > > > > > > > > 
> > > > > > > > > I do not believe that requiring that the TypeClass be 
> > > > > > > > > VectorType is the correct narrowing of the scope. Instead, we 
> > > > > > > > > may want to consider requiring that for each `SCS` in { 
> > > > > > > > > `SCS1`, `SCS2` }, there is one AltiVec type and one generic 
> > > > > > > > > vector type in { `SCS.getFromType()`, `SCS.getToType(2)` }.
> > > > > > > > > 
> > > > > > > > The key point is that ExtVector is a kind of typeclass, **and** 
> > > > > > > > its vector kind is generic vector type.
> > > > > > > > 
> > > > > > > > So you think we should encompass ext_vector cases as a part of 
> > > > > > > > the scope of this patch? And modify the above cases' expected 
> > > > > > > > behavior (remove the **expected-error**)?
> > > > > > > I gave a concrete suggested narrowing of the scope that does not 
> > > > > > > exclude ExtVectorType or other derived types of VectorType. It 
> 

[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2018-11-08 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In https://reviews.llvm.org/D53157#1290364, @andrew.w.kaylor wrote:

> Rather than having separate methods to create the constrained versions of the 
> intrinsics, why not have a way to set the constrained state in the IR builder 
> and have the regular CreateFAdd et. al. functions use that to automatically 
> create the constrained intrinsic versions? This would correspond to how fast 
> math flags are handled.


Well, yes and no. There is the default fast math flags that get picked up by, 
eg, CreateFAdd(). There's also a default MDNode. But CreateFAdd() and the 
others let you specify a different MDNode, and the Create*FMF() functions let 
you specify different fast math flags. So the existing practice isn't strongly 
pointing in either direction.

Having CreateConstrained*() functions means front ends can key off its own flag 
and not have to notify the IRBuilder when that flag goes out of scope. Then 
again, having a IRBuilder-instance-global flag means probably fewer places in 
the front end have to be touched, but it would have to notify the IRBuilder 
when its own strictness flag goes out of scope. So I don't know what is better.

I suspect you are correct and we should just stick with the existing calls. I 
don't expect anyone would need to switch between constrained and regular 
floating point at an instruction level of granularity. But we need to do what 
is best for users of the IRBuilder, and I'm not 100% sold either way.

Can we get some input from someone who maintains front ends?


https://reviews.llvm.org/D53157



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


[PATCH] D49863: [istream] Fix error flags and exceptions propagated from input stream operations

2018-11-08 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray accepted this revision.
lichray added inline comments.
This revision is now accepted and ready to land.
Herald added a subscriber: libcxx-commits.



Comment at: libcxx/include/istream:365
 __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-try
+ios_base::iostate __state = ios_base::goodbit;
+typename basic_istream<_CharT, _Traits>::sentry __s(__is);

I like `auto` just FYI :)



Comment at: libcxx/include/istream:1005
 default:
-read(__s, _VSTD::min(__c, __n));
 break;

LOL


Repository:
  rCXX libc++

https://reviews.llvm.org/D49863



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


[PATCH] D54262: [clang-tidy] Add `delete this` bugprone check (PR38741)

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/bugprone/DeleteThisCheck.cpp:23
+  cxxDeleteExpr(
+  has(ignoringParenImpCasts(cxxThisExpr(
+  .bind("DeleteThis"),

Will this catch too much? e.g.,
```
struct S {
  int *Foo;

  ~S() { delete this->Foo; }
};
```



Comment at: clang-tidy/bugprone/DeleteThisCheck.cpp:30
+  const auto *E = Result.Nodes.getNodeAs("DeleteThis");
+  diag(E->getBeginLoc(), "usage of 'delete this' is suspicious");
+}

Why is it suspicious? It's a valid coding construct that does get used -- 
looking over LLVM's source, we have a half dozen instances of this construct 
outside of testing code.

I think this check is likely to have an extremely high false-positive rate 
unless you add some heuristics to cover common usage patterns that are safe.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54262



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


[PATCH] D53488: [clang-tidy] Improving narrowing conversions

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:17
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Mutex.h"
+

Is this include needed?



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:60
+static const BuiltinType *getBuiltinType(const Expr *E) {
+  if (const Type *T = E->getType().getCanonicalType().getTypePtrOrNull())
+return T->getAs();

Is there a case where you expect the QualType to be invalid? If not, drop the 
`OrNull` bit.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:69-70
+  bool Contains(const IntegerRange ) const {
+return (llvm::APSInt::compareValues(Lower, From.Lower) <= 0) &&
+   (llvm::APSInt::compareValues(Upper, From.Upper) >= 0);
+  }

Spurious parens.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:74
+  bool Contains(const llvm::APSInt ) const {
+return (llvm::APSInt::compareValues(Lower, Value) <= 0) &&
+   (llvm::APSInt::compareValues(Upper, Value) >= 0);

Spurious parens.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:86
+   const BuiltinType *T) {
+  assert(T && "T must not be nullptr");
+  if (T->isFloatingPoint()) {

Then T should be passed in as a reference type instead of using this assertion.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:109
+llvm::APSInt::getMaxValue(Context.getTypeSize(T), false)};
+  if (T->isUnsignedInteger())
+return {llvm::APSInt::getMinValue(Context.getTypeSize(T), true),

Perhaps a better approach is to assert this is true and then unilaterally 
return.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:113-114
+
+  llvm::errs() << "Unhandled type " << T->getName(Context.getPrintingPolicy())
+   << "\n";
+  llvm_unreachable("Unhandled type");

This seems like debugging code that should be removed.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:133
+
+static QualType getUnqualifiedType(const Expr *Expr) {
+  return Expr->getType().getUnqualifiedType();

Please rename the identifier to not conflict with a type name.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:175-176
+// 
https://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-conversion.html
+if ((ToType->getKind() == BuiltinType::Bool) ||
+(FromType->getKind() == BuiltinType::Bool))
   return;

Spurious parens.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:208-210
+  llvm::errs() << "Unhandled from type "
+   << FromType->getName(Context.getPrintingPolicy()) << "or to 
type"
+   << ToType->getName(Context.getPrintingPolicy()) << "\n";

Debugging code. Assert above and unilaterally return.



Comment at: clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp:309
+  Cast->getExprLoc(), Cast, Cast->getSubExpr());
+  llvm_unreachable("must be binary operator or cast expression");
 }

Assert the above condition and unconditionally return.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


[PATCH] D54262: [clang-tidy] Add `delete this` bugprone check (PR38741)

2018-11-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please also add regression test case. Is should also cover standalone function 
with this variable.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54262



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


[PATCH] D54262: [clang-tidy] Add `delete this` bugprone check (PR38741)

2018-11-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).




Comment at: docs/clang-tidy/checks/bugprone-delete-this.rst:8
+
+Said statement generates multiple problems, such as enforcing allocating the 
object via ``new``, or not allowing any
+usage of instance members (neither fields nor methods) after the execution of 
it, nor touching ``this`` pointer

Please use 80 characters limit.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54262



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


[PATCH] D53900: [CodeComplete] Penalize inherited ObjC properties for auto-completion

2018-11-08 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

Since I don't have commit access, sammccall will land this


Repository:
  rC Clang

https://reviews.llvm.org/D53900



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36
+GetScaleForFactory(llvm::StringRef FactoryName) {
+  static const auto *ScaleMap =
+  new std::unordered_map(

hwright wrote:
> Eugene.Zelenko wrote:
> > This will cause memory leaks, so may be unique_ptr should be used to hold 
> > pointer? May be LLVM ADT has better container?
> This is a tradeoff between leaking a small amount of known memory for the 
> duration of the program, and constructing this map every time this function 
> is invoked.  Since I expect the latter to occur frequently, that's a tradeoff 
> I think is acceptable.   (Ideally, this would be a compile-time constant, but 
> sadly we don't yet have a `constexpr` dictionary type.)
> 
> Of course, if there is a more typical way of doing that here, I'm happy to 
> use it.
Why did you not use a static value type?


https://reviews.llvm.org/D54246



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:88
+  Checks for cases where arguments to ``absl::Duration`` factory functions are
+  scaled internally and could be changed to a different factory function.  This
+  check also looks for arguements with a zero value and suggests using

hwright wrote:
> Eugene.Zelenko wrote:
> > Second statement belongs to documentation.
> It already is in the user-facing documentation, are saying it should be 
> removed from here?
Release Notes are for brief descriptions. Documentation is for details.


https://reviews.llvm.org/D54246



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


[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you add tests for this change? We typically have these in Misc by passing 
`-ast-print`.


Repository:
  rC Clang

https://reviews.llvm.org/D54258



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


[PATCH] D54033: [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC

2018-11-08 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE346418: [clang-tidy] Untangle layering in 
ClangTidyDiagnosticConsumer somewhat. NFC (authored by sammccall, committed by 
).

Changed prior to commit:
  https://reviews.llvm.org/D54033?vs=172339=173184#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54033

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/plugin/ClangTidyPlugin.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -83,6 +83,9 @@
   ClangTidyContext Context(llvm::make_unique(
   ClangTidyGlobalOptions(), Options));
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
+  DiagnosticsEngine DE(new DiagnosticIDs(), new DiagnosticOptions,
+   , false);
+  Context.setDiagnosticsEngine();
 
   std::vector Args(1, "clang-tidy");
   Args.push_back("-fsyntax-only");
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -267,13 +267,7 @@
 ClangTidyContext , bool RemoveIncompatibleErrors)
 : Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
   LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
-  LastErrorWasIgnored(false) {
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  Diags = llvm::make_unique(
-  IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
-  /*ShouldOwnClient=*/false);
-  Context.DiagEngine = Diags.get();
-}
+  LastErrorWasIgnored(false) {}
 
 void ClangTidyDiagnosticConsumer::finalizeLastError() {
   if (!Errors.empty()) {
@@ -391,7 +385,7 @@
 
   if (Info.getLocation().isValid() && DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
-  LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(),
+  LineIsMarkedWithNOLINTinMacro(Info.getSourceManager(),
 Info.getLocation(), Info.getID(),
 Context)) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
@@ -453,14 +447,14 @@
   Errors.back());
   SmallString<100> Message;
   Info.FormatDiagnostic(Message);
-  FullSourceLoc Loc =
-  (Info.getLocation().isInvalid())
-  ? FullSourceLoc()
-  : FullSourceLoc(Info.getLocation(), Info.getSourceManager());
+  FullSourceLoc Loc;
+  if (Info.getLocation().isValid() && Info.hasSourceManager())
+Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
   Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
Info.getFixItHints());
 
-  checkFilters(Info.getLocation());
+  if (Info.hasSourceManager())
+checkFilters(Info.getLocation(), Info.getSourceManager());
 }
 
 bool ClangTidyDiagnosticConsumer::passesLineFilter(StringRef FileName,
@@ -481,15 +475,15 @@
   return false;
 }
 
-void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location) {
+void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
+   const SourceManager ) {
   // Invalid location may mean a diagnostic in a command line, don't skip these.
   if (!Location.isValid()) {
 LastErrorRelatesToUserCode = true;
 LastErrorPassesLineFilter = true;
 return;
   }
 
-  const SourceManager  = Diags->getSourceManager();
   if (!*Context.getOptions().SystemHeaders &&
   Sources.isInSystemHeader(Location))
 return;
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -551,7 +551,9 @@
   Context.setProfileStoragePrefix(StoreCheckProfile);
 
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
-
+  DiagnosticsEngine DE(new DiagnosticIDs(), new DiagnosticOptions(),
+   , /*ShouldOwnClient=*/false);
+  Context.setDiagnosticsEngine();
   Tool.setDiagnosticConsumer();
 
   class ActionFactory : public FrontendActionFactory {
Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -35,7 +35,7 @@
   std::unique_ptr CreateASTConsumer(CompilerInstance ,
  StringRef File) override {
 // Insert the current diagnostics engine.
-Context->DiagEngine = ();
+Context->setDiagnosticsEngine(());
 
 // Create the AST consumer.
 ClangTidyASTConsumerFactory Factory(*Context);
Index: clang-tidy/ClangTidyDiagnosticConsumer.h

[PATCH] D54269: Introduce shard storage to auto-index.

2018-11-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, ioeric.
Herald added subscribers: cfe-commits, arphaman, jkorous, ilya-biryukov.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54269

Files:
  clangd/index/Background.cpp
  clangd/index/Background.h
  unittests/clangd/BackgroundIndexTests.cpp

Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -76,5 +76,79 @@
FileURI("unittest:///root/B.cc")}));
 }
 
+TEST(BackgroundIndexTest, ShardStorageTest) {
+  class MemoryShardStorage : public ShardStorage {
+mutable std::mutex StorageMu;
+llvm::StringMap 
+size_t& CacheHits;
+
+  public:
+MemoryShardStorage(llvm::StringMap , size_t )
+: Storage(Storage), CacheHits(CacheHits) {}
+
+bool storeShard(llvm::StringRef ShardIdentifier, IndexFileOut Shard) const {
+  std::lock_guard Lock(StorageMu);
+  std::string  = Storage[ShardIdentifier];
+  llvm::raw_string_ostream OS(str);
+  OS << Shard;
+  OS.flush();
+  return true;
+}
+llvm::Expected retrieveShard(llvm::StringRef ShardIdentifier,
+  FileDigest Hash) const {
+  std::lock_guard Lock(StorageMu);
+  if (Storage.find(ShardIdentifier) == Storage.end())
+return llvm::make_error(
+"Shard not found.", llvm::inconvertibleErrorCode());
+  auto IndexFile = readIndexFile(Storage[ShardIdentifier]);
+  if(!IndexFile)
+return IndexFile;
+  CacheHits++;
+  return IndexFile;
+}
+bool initialize(llvm::StringRef Directory) { return true; }
+  };
+  MockFSProvider FS;
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  )cpp";
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }";
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  {
+BackgroundIndex Idx(
+Context::empty(), "", FS, /*URISchemes=*/{"unittest"},
+/*IndexShardStorage=*/
+llvm::make_unique(Storage, CacheHits));
+Idx.enqueue(testPath("root"), Cmd);
+Idx.blockUntilIdleForTest();
+  }
+  EXPECT_EQ(CacheHits, 0U);
+  EXPECT_EQ(Storage.size(), 2U);
+  EXPECT_NE(Storage.find(testPath("root/A.h")), Storage.end());
+  EXPECT_NE(Storage.find(testPath("root/A.cc")), Storage.end());
+
+  {
+BackgroundIndex Idx(
+Context::empty(), "", FS, /*URISchemes=*/{"unittest"},
+/*IndexShardStorage=*/
+llvm::make_unique(Storage, CacheHits));
+Idx.enqueue(testPath("root"), Cmd);
+Idx.blockUntilIdleForTest();
+  }
+  EXPECT_EQ(CacheHits, 1U);
+  EXPECT_EQ(Storage.size(), 2U);
+  EXPECT_NE(Storage.find(testPath("root/A.h")), Storage.end());
+  EXPECT_NE(Storage.find(testPath("root/A.cc")), Storage.end());
+  // B_CC is dropped as we don't collect symbols from A.h in this compilation.
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/index/Background.h
===
--- clangd/index/Background.h
+++ clangd/index/Background.h
@@ -14,6 +14,7 @@
 #include "FSProvider.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
+#include "index/Serialization.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/SHA1.h"
@@ -27,15 +28,27 @@
 namespace clang {
 namespace clangd {
 
+// Base class for Shard Storage operations. See DiskShardStorage for more info.
+class ShardStorage {
+public:
+  using FileDigest = decltype(llvm::SHA1::hash({}));
+  virtual bool storeShard(llvm::StringRef ShardIdentifier,
+  IndexFileOut Shard) const = 0;
+  virtual llvm::Expected
+  retrieveShard(llvm::StringRef ShardIdentifier, FileDigest Hash) const = 0;
+  virtual bool initialize(llvm::StringRef Directory) = 0;
+};
+
 // Builds an in-memory index by by running the static indexer action over
 // all commands in a compilation database. Indexing happens in the background.
 // FIXME: it should also persist its state on disk for fast start.
 // FIXME: it should watch for changes to files on disk.
 class BackgroundIndex : public SwapIndex {
 public:
   // FIXME: resource-dir injection should be hoisted somewhere common.
-  BackgroundIndex(Context BackgroundContext, StringRef ResourceDir,
+  BackgroundIndex(Context BackgroundContext, llvm::StringRef ResourceDir,
   const FileSystemProvider &, ArrayRef URISchemes,
+  std::unique_ptr IndexShardStorage = nullptr,
   size_t ThreadPoolSize = llvm::hardware_concurrency());
   ~BackgroundIndex(); // Blocks while the current task 

[clang-tools-extra] r346418 - [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC

2018-11-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov  8 09:42:16 2018
New Revision: 346418

URL: http://llvm.org/viewvc/llvm-project?rev=346418=rev
Log:
[clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC

Summary:
Clang's hierarchy is CompilerInstance -> DiagnosticsEngine -> 
DiagnosticConsumer.
(Ownership is optional/shared, but this structure is fairly clear).

Currently ClangTidyDiagnosticConsumer *owns* the DiagnosticsEngine:
 - this inverts the hierarchy, which is confusing
 - this means ClangTidyDiagnosticConsumer() mutates the passed-in context, which
   is both surprising and limits flexibility
 - it's not possible to use a different DiagnosticsEngine with ClangTidy

This means a little bit more code in the places ClangTidy is used standalone,
but more flexibility in using ClangTidy with other diagnostics configurations.

Reviewers: hokein

Subscribers: xazax.hun, cfe-commits

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

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
clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.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=346418=346417=346418=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Nov  8 09:42:16 2018
@@ -551,7 +551,9 @@ runClangTidy(clang::tidy::ClangTidyConte
   Context.setProfileStoragePrefix(StoreCheckProfile);
 
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
-
+  DiagnosticsEngine DE(new DiagnosticIDs(), new DiagnosticOptions(),
+   , /*ShouldOwnClient=*/false);
+  Context.setDiagnosticsEngine();
   Tool.setDiagnosticConsumer();
 
   class ActionFactory : public FrontendActionFactory {

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=346418=346417=346418=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Thu Nov  
8 09:42:16 2018
@@ -267,13 +267,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDi
 ClangTidyContext , bool RemoveIncompatibleErrors)
 : Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
   LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
-  LastErrorWasIgnored(false) {
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  Diags = llvm::make_unique(
-  IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
-  /*ShouldOwnClient=*/false);
-  Context.DiagEngine = Diags.get();
-}
+  LastErrorWasIgnored(false) {}
 
 void ClangTidyDiagnosticConsumer::finalizeLastError() {
   if (!Errors.empty()) {
@@ -391,7 +385,7 @@ void ClangTidyDiagnosticConsumer::Handle
 
   if (Info.getLocation().isValid() && DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
-  LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(),
+  LineIsMarkedWithNOLINTinMacro(Info.getSourceManager(),
 Info.getLocation(), Info.getID(),
 Context)) {
 ++Context.Stats.ErrorsIgnoredNOLINT;
@@ -453,14 +447,14 @@ void ClangTidyDiagnosticConsumer::Handle
   Errors.back());
   SmallString<100> Message;
   Info.FormatDiagnostic(Message);
-  FullSourceLoc Loc =
-  (Info.getLocation().isInvalid())
-  ? FullSourceLoc()
-  : FullSourceLoc(Info.getLocation(), Info.getSourceManager());
+  FullSourceLoc Loc;
+  if (Info.getLocation().isValid() && Info.hasSourceManager())
+Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
   Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
Info.getFixItHints());
 
-  checkFilters(Info.getLocation());
+  if (Info.hasSourceManager())
+checkFilters(Info.getLocation(), Info.getSourceManager());
 }
 
 bool ClangTidyDiagnosticConsumer::passesLineFilter(StringRef FileName,
@@ -481,7 +475,8 @@ bool ClangTidyDiagnosticConsumer::passes
   return false;
 }
 
-void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location) {
+void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
+   const SourceManager ) {
   // Invalid location may mean a diagnostic in a command line, don't skip 
these.
   if (!Location.isValid()) {
 LastErrorRelatesToUserCode = true;
@@ -489,7 

[PATCH] D53850: Declares __cpu_model as dso local

2018-11-08 Thread Haibo Huang via Phabricator via cfe-commits
hhb added a comment.

Ping..


Repository:
  rC Clang

https://reviews.llvm.org/D53850



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


[clang-tools-extra] r346415 - [clang-tidy] fix test after r346414

2018-11-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov  8 09:10:31 2018
New Revision: 346415

URL: http://llvm.org/viewvc/llvm-project?rev=346415=rev
Log:
[clang-tidy] fix test after r346414

Modified:
clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp?rev=346415=346414=346415=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp Thu Nov  8 09:10:31 
2018
@@ -24,7 +24,9 @@
 // RUN: not clang-tidy 
-checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%T/diagnostics/input.cpp 2>&1 | FileCheck -check-prefix=CHECK5 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: not clang-tidy -checks='-*,modernize-use-override' 
%T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck 
-check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
 
-// CHECK1: error: error reading '{{.*}}nonexistent.cpp' 
[clang-diagnostic-error]
+// CHECK1: error: no input files [clang-diagnostic-error]
+// CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' 
[clang-diagnostic-error]
+// CHECK1: error: unable to handle compilation{{.*}} [clang-diagnostic-error]
 // CHECK2: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
 // CHECK3: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
 // CHECK5: error: unknown argument: '-fan-option-from-compilation-database' 
[clang-diagnostic-error]


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


[PATCH] D53958: [Tooling] Produce diagnostics for missing input files.

2018-11-08 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346414: [Tooling] Produce diagnostics for missing input 
files. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53958?vs=172052=173180#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53958

Files:
  lib/Driver/Driver.cpp
  lib/Tooling/Tooling.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1972,7 +1972,7 @@
 }
   }
 
-  if (llvm::sys::fs::exists(Twine(Path)))
+  if (D.getVFS().exists(Path))
 return true;
 
   if (D.IsCLMode()) {
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -303,8 +303,6 @@
 
   const std::unique_ptr Driver(
   newDriver(, BinaryName, Files->getVirtualFileSystem()));
-  // Since the input might only be virtual, don't check whether it exists.
-  Driver->setCheckInputsExist(false);
   const std::unique_ptr Compilation(
   Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
   if (!Compilation)


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1972,7 +1972,7 @@
 }
   }
 
-  if (llvm::sys::fs::exists(Twine(Path)))
+  if (D.getVFS().exists(Path))
 return true;
 
   if (D.IsCLMode()) {
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -303,8 +303,6 @@
 
   const std::unique_ptr Driver(
   newDriver(, BinaryName, Files->getVirtualFileSystem()));
-  // Since the input might only be virtual, don't check whether it exists.
-  Driver->setCheckInputsExist(false);
   const std::unique_ptr Compilation(
   Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
   if (!Compilation)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r346414 - [Tooling] Produce diagnostics for missing input files.

2018-11-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov  8 08:57:01 2018
New Revision: 346414

URL: http://llvm.org/viewvc/llvm-project?rev=346414=rev
Log:
[Tooling] Produce diagnostics for missing input files.

Summary:
This was disabled way back in 2011, in the dark times before Driver was 
VFS-aware.

Also, make driver more VFS-aware :-)

This breaks one ClangTidy test (we improved the error message), will fix when
submitting.

Reviewers: ioeric

Subscribers: cfe-commits, alexfh

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

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=346414=346413=346414=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Nov  8 08:57:01 2018
@@ -1972,7 +1972,7 @@ static bool DiagnoseInputExistence(const
 }
   }
 
-  if (llvm::sys::fs::exists(Twine(Path)))
+  if (D.getVFS().exists(Path))
 return true;
 
   if (D.IsCLMode()) {

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=346414=346413=346414=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Nov  8 08:57:01 2018
@@ -303,8 +303,6 @@ bool ToolInvocation::run() {
 
   const std::unique_ptr Driver(
   newDriver(, BinaryName, Files->getVirtualFileSystem()));
-  // Since the input might only be virtual, don't check whether it exists.
-  Driver->setCheckInputsExist(false);
   const std::unique_ptr Compilation(
   Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
   if (!Compilation)


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


[PATCH] D53780: Fix bitcast to address space cast for coerced load/stores

2018-11-08 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346413: Fix bitcast to address space cast for coerced 
load/stores  (authored by yaxunl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53780?vs=172673=173179#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53780

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenCXX/address-space-cast-coerce.cpp


Index: test/CodeGenCXX/address-space-cast-coerce.cpp
===
--- test/CodeGenCXX/address-space-cast-coerce.cpp
+++ test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int mane() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to 
%{{[^ ]+}} 
+
+char1 f3 = f1 + f2;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1253,8 +1253,8 @@
 
   // Otherwise do coercion through memory. This is stupid, but simple.
   Address Tmp = CreateTempAllocaForCoercion(CGF, Ty, Src.getAlignment());
-  Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-  Address SrcCasted = CGF.Builder.CreateBitCast(Src, CGF.AllocaInt8PtrTy);
+  Address Casted = CGF.Builder.CreateElementBitCast(Tmp,CGF.Int8Ty);
+  Address SrcCasted = CGF.Builder.CreateElementBitCast(Src,CGF.Int8Ty);
   CGF.Builder.CreateMemCpy(Casted, SrcCasted,
   llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize),
   false);
@@ -1335,8 +1335,8 @@
 // to that information.
 Address Tmp = CreateTempAllocaForCoercion(CGF, SrcTy, Dst.getAlignment());
 CGF.Builder.CreateStore(Src, Tmp);
-Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-Address DstCasted = CGF.Builder.CreateBitCast(Dst, CGF.AllocaInt8PtrTy);
+Address Casted = CGF.Builder.CreateElementBitCast(Tmp,CGF.Int8Ty);
+Address DstCasted = CGF.Builder.CreateElementBitCast(Dst,CGF.Int8Ty);
 CGF.Builder.CreateMemCpy(DstCasted, Casted,
 llvm::ConstantInt::get(CGF.IntPtrTy, DstSize),
 false);


Index: test/CodeGenCXX/address-space-cast-coerce.cpp
===
--- test/CodeGenCXX/address-space-cast-coerce.cpp
+++ test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int mane() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to %{{[^ ]+}} 
+
+char1 f3 = f1 + f2;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1253,8 +1253,8 @@
 
   // Otherwise do 

r346413 - Fix bitcast to address space cast for coerced load/stores

2018-11-08 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Nov  8 08:55:46 2018
New Revision: 346413

URL: http://llvm.org/viewvc/llvm-project?rev=346413=rev
Log:
Fix bitcast to address space cast for coerced load/stores 

Coerced load/stores through memory do not take into account potential
address space differences when it creates its bitcasts.

Patch by David Salinas.

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

Added:
cfe/trunk/test/CodeGenCXX/address-space-cast-coerce.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=346413=346412=346413=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Nov  8 08:55:46 2018
@@ -1253,8 +1253,8 @@ static llvm::Value *CreateCoercedLoad(Ad
 
   // Otherwise do coercion through memory. This is stupid, but simple.
   Address Tmp = CreateTempAllocaForCoercion(CGF, Ty, Src.getAlignment());
-  Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-  Address SrcCasted = CGF.Builder.CreateBitCast(Src, CGF.AllocaInt8PtrTy);
+  Address Casted = CGF.Builder.CreateElementBitCast(Tmp,CGF.Int8Ty);
+  Address SrcCasted = CGF.Builder.CreateElementBitCast(Src,CGF.Int8Ty);
   CGF.Builder.CreateMemCpy(Casted, SrcCasted,
   llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize),
   false);
@@ -1335,8 +1335,8 @@ static void CreateCoercedStore(llvm::Val
 // to that information.
 Address Tmp = CreateTempAllocaForCoercion(CGF, SrcTy, Dst.getAlignment());
 CGF.Builder.CreateStore(Src, Tmp);
-Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-Address DstCasted = CGF.Builder.CreateBitCast(Dst, CGF.AllocaInt8PtrTy);
+Address Casted = CGF.Builder.CreateElementBitCast(Tmp,CGF.Int8Ty);
+Address DstCasted = CGF.Builder.CreateElementBitCast(Dst,CGF.Int8Ty);
 CGF.Builder.CreateMemCpy(DstCasted, Casted,
 llvm::ConstantInt::get(CGF.IntPtrTy, DstSize),
 false);

Added: cfe/trunk/test/CodeGenCXX/address-space-cast-coerce.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/address-space-cast-coerce.cpp?rev=346413=auto
==
--- cfe/trunk/test/CodeGenCXX/address-space-cast-coerce.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/address-space-cast-coerce.cpp Thu Nov  8 08:55:46 
2018
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int mane() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to 
%{{[^ ]+}} 
+
+char1 f3 = f1 + f2;
+}


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


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-08 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

@hubert.reinterpretcast Have your comments been addressed adequately in the 
latest version of the patch? Do you have an opinion on adding the test case I 
proposed?




Comment at: clang/test/Sema/altivec-generic-overload.c:1
+// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature 
+altivec -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic 
-fsyntax-only
+

Do we perhaps want a test case that actually tests which overload was chosen to 
make sure this doesn't change with any potential future changes to overload 
resolution?


https://reviews.llvm.org/D53417



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


[PATCH] D53488: [clang-tidy] Catching narrowing from double to float.

2018-11-08 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

Is this good enough to go? @JonasToth


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53488



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


[PATCH] D54087: [PowerPC] [Clang] [AltiVec] The second parameter of vec_sr function should be modulo the number of bits in the element

2018-11-08 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

Just for clarification (and please add the text to the commit message), this is 
actually required by the ABI:

  Each element of the result vector is the result of logically right shifting 
the corresponding
  element of ARG1 by the number of bits specified by the value of the 
corresponding
  element of ARG2, modulo the number of bits in the element. The bits that are 
shifted out
  are replaced by zeros.


Repository:
  rC Clang

https://reviews.llvm.org/D54087



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


[PATCH] D46403: [CFI] Force LLVM to die if the implicit blacklist files cannot be found.

2018-11-08 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment.

Sorry to ressurect this review, but I have a few questions:

- What kind of functions fail?
- Are there bugzillas to track these?
- How can a compiler expect to have blacklists for "all" its CFI clients? (I'm 
ok with having a default for "most-used, well-known, problematic functions", 
e.g: functions in libstdc++ or libc++)
- clang/compiler-rt don't seem to have a default blacklist, what should the 
contents be? This patch seems to be saying "There are some well-known functions 
that should never be instrumented with CFI, I'll provide a list of names", 
which doesn't really seem possible to do in general, for "most" CFI-toolchain 
clients. As I see it, each client will need to have their own blacklist, and 
provide it as an argument if needed. Which brings us to:
- If I pass `-fsanitize-blacklist=my_blacklist.txt` I still get an error. This 
is not ideal, as I might be working on the blacklist to include in my 
toolchain/program.

I don't think we should have an error that is default enabled for this issue. 
At most a warning (+ `-Werror`) if there was no blacklist passed in nor found 
in the toolchain resource directory.

Thank you,
Filipe

P.S: Sorry for only noticing this so much later.


Repository:
  rC Clang

https://reviews.llvm.org/D46403



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


r346408 - [OPENMP]Make lambda mapping follow reqs for PTR_AND_OBJ mapping.

2018-11-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov  8 07:47:39 2018
New Revision: 346408

URL: http://llvm.org/viewvc/llvm-project?rev=346408=rev
Log:
[OPENMP]Make lambda mapping follow reqs for PTR_AND_OBJ mapping.

The base pointer for the lambda mapping must point to the lambda capture
placement and pointer must point to the captured variable itself. Patch
fixes this problem.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=346408=346407=346408=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Nov  8 07:47:39 2018
@@ -7550,11 +7550,11 @@ public:
   }
 
   /// Emit capture info for lambdas for variables captured by reference.
-  void generateInfoForLambdaCaptures(const ValueDecl *VD, llvm::Value *Arg,
- MapBaseValuesArrayTy ,
- MapValuesArrayTy ,
- MapValuesArrayTy ,
- MapFlagsArrayTy ) const {
+  void generateInfoForLambdaCaptures(
+  const ValueDecl *VD, llvm::Value *Arg, MapBaseValuesArrayTy 
,
+  MapValuesArrayTy , MapValuesArrayTy ,
+  MapFlagsArrayTy ,
+  llvm::DenseMap ) const {
 const auto *RD = VD->getType()
  .getCanonicalType()
  .getNonReferenceType()
@@ -7570,8 +7570,10 @@ public:
 if (ThisCapture) {
   LValue ThisLVal =
   CGF.EmitLValueForFieldInitialization(VDLVal, ThisCapture);
-  BasePointers.push_back(VDLVal.getPointer());
-  Pointers.push_back(ThisLVal.getPointer());
+  LValue ThisLValVal = CGF.EmitLValueForField(VDLVal, ThisCapture);
+  LambdaPointers.try_emplace(ThisLVal.getPointer(), VDLVal.getPointer());
+  BasePointers.push_back(ThisLVal.getPointer());
+  Pointers.push_back(ThisLValVal.getPointer());
   Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
   Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
   OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT);
@@ -7583,8 +7585,10 @@ public:
   auto It = Captures.find(VD);
   assert(It != Captures.end() && "Found lambda capture without field.");
   LValue VarLVal = CGF.EmitLValueForFieldInitialization(VDLVal, 
It->second);
-  BasePointers.push_back(VDLVal.getPointer());
-  Pointers.push_back(VarLVal.getPointer());
+  LValue VarLValVal = CGF.EmitLValueForField(VDLVal, It->second);
+  LambdaPointers.try_emplace(VarLVal.getPointer(), VDLVal.getPointer());
+  BasePointers.push_back(VarLVal.getPointer());
+  Pointers.push_back(VarLValVal.getPointer());
   Sizes.push_back(CGF.getTypeSize(
   VD->getType().getCanonicalType().getNonReferenceType()));
   Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
@@ -7593,15 +7597,17 @@ public:
   }
 
   /// Set correct indices for lambdas captures.
-  void adjustMemberOfForLambdaCaptures(MapBaseValuesArrayTy ,
-   MapValuesArrayTy ,
-   MapFlagsArrayTy ) const {
+  void adjustMemberOfForLambdaCaptures(
+  const llvm::DenseMap ,
+  MapBaseValuesArrayTy , MapValuesArrayTy ,
+  MapFlagsArrayTy ) const {
 for (unsigned I = 0, E = Types.size(); I < E; ++I) {
   // Set correct member_of idx for all implicit lambda captures.
   if (Types[I] != (OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT))
 continue;
-  llvm::Value *BasePtr = *BasePointers[I];
+  llvm::Value *BasePtr = LambdaPointers.lookup(*BasePointers[I]);
+  assert(BasePtr && "Unable to find base lambda address.");
   int TgtIdx = -1;
   for (unsigned J = I; J > 0; --J) {
 unsigned Idx = J - 1;
@@ -8191,6 +8197,7 @@ void CGOpenMPRuntime::emitTargetCall(Cod
 
 // Get mappable expression information.
 MappableExprsHandler MEHandler(D, CGF);
+llvm::DenseMap LambdaPointers;
 
 auto RI = CS.getCapturedRecordDecl()->field_begin();
 auto CV = CapturedVars.begin();
@@ -8223,9 +8230,9 @@ void CGOpenMPRuntime::emitTargetCall(Cod
 // Generate correct mapping for variables captured by reference in
 // lambdas.
 if (CI->capturesVariable())
-  MEHandler.generateInfoForLambdaCaptures(CI->getCapturedVar(), *CV,
-  CurBasePointers, CurPointers,
-  CurSizes, CurMapTypes);
+  MEHandler.generateInfoForLambdaCaptures(
+  CI->getCapturedVar(), *CV, CurBasePointers, CurPointers, 
CurSizes,
+  CurMapTypes, LambdaPointers);
   }
   // We expect to have at 

[PATCH] D54262: [clang-tidy] Add `delete this` bugprone check (PR38741)

2018-11-08 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

It's best to use `clang-tidy/add_new_check.py` tool.
You also need tests, and a note in releasenotes.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54262



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36
+GetScaleForFactory(llvm::StringRef FactoryName) {
+  static const auto *ScaleMap =
+  new std::unordered_map(

Eugene.Zelenko wrote:
> This will cause memory leaks, so may be unique_ptr should be used to hold 
> pointer? May be LLVM ADT has better container?
This is a tradeoff between leaking a small amount of known memory for the 
duration of the program, and constructing this map every time this function is 
invoked.  Since I expect the latter to occur frequently, that's a tradeoff I 
think is acceptable.   (Ideally, this would be a compile-time constant, but 
sadly we don't yet have a `constexpr` dictionary type.)

Of course, if there is a more typical way of doing that here, I'm happy to use 
it.



Comment at: docs/ReleaseNotes.rst:88
+  Checks for cases where arguments to ``absl::Duration`` factory functions are
+  scaled internally and could be changed to a different factory function.  This
+  check also looks for arguements with a zero value and suggests using

Eugene.Zelenko wrote:
> Second statement belongs to documentation.
It already is in the user-facing documentation, are saying it should be removed 
from here?


https://reviews.llvm.org/D54246



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


[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 173166.
hwright marked 4 inline comments as done.
hwright added a comment.

Address reviewer comments


https://reviews.llvm.org/D54246

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tidy/abseil/DurationFactoryScaleCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-factory-scale.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-factory-scale.cpp

Index: test/clang-tidy/abseil-duration-factory-scale.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-factory-scale.cpp
@@ -0,0 +1,101 @@
+// RUN: %check_clang_tidy %s abseil-duration-factory-scale %t
+
+// Mimic the implementation of absl::Duration
+namespace absl {
+
+class Duration {};
+
+Duration Nanoseconds(long long);
+Duration Microseconds(long long);
+Duration Milliseconds(long long);
+Duration Seconds(long long);
+Duration Minutes(long long);
+Duration Hours(long long);
+
+#define GENERATE_DURATION_FACTORY_OVERLOADS(NAME) \
+  Duration NAME(float n); \
+  Duration NAME(double n);\
+  template\
+  Duration NAME(T n);
+
+GENERATE_DURATION_FACTORY_OVERLOADS(Nanoseconds);
+GENERATE_DURATION_FACTORY_OVERLOADS(Microseconds);
+GENERATE_DURATION_FACTORY_OVERLOADS(Milliseconds);
+GENERATE_DURATION_FACTORY_OVERLOADS(Seconds);
+GENERATE_DURATION_FACTORY_OVERLOADS(Minutes);
+GENERATE_DURATION_FACTORY_OVERLOADS(Hours);
+#undef GENERATE_DURATION_FACTORY_OVERLOADS
+
+}  // namespace absl
+
+void ScaleTest() {
+  absl::Duration d;
+
+  // Zeroes
+  d = absl::Hours(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Minutes(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Milliseconds(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Microseconds(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Nanoseconds(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(0.0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+
+  // Fold seconds into minutes
+  d = absl::Seconds(30 * 60);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Minutes(30);
+  d = absl::Seconds(60 * 30);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Minutes(30);
+
+  // Try a few more exotic multiplications
+  d = absl::Seconds(60 * 30 * 60);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Minutes(60 * 30);
+  d = absl::Seconds(1e-3 * 30);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Milliseconds(30);
+  d = absl::Milliseconds(30 * 1000);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Seconds(30);
+  d = absl::Milliseconds(30 * 0.001);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Microseconds(30);
+
+  // Division
+  d = absl::Hours(30 / 60.);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Minutes(30);
+  d = absl::Seconds(30 / 1000.);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Milliseconds(30);
+  d = absl::Milliseconds(30 / 1e3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::Microseconds(30);
+
+  // None of these should trigger 

[PATCH] D54262: [clang-tidy] Add `delete this` bugprone check (PR38741)

2018-11-08 Thread Mateusz Maćkowski via Phabricator via cfe-commits
m4tx created this revision.
m4tx added reviewers: alexfh, hokein.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

Add a bugprone check to clang-tidy that detects the usages of `delete this`. 
The warning is shown even when `delete this` is the last line in the method (as 
there is no guarantee that it won't be called from another method, or the 
pointer won't be used in any way afterwards).

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


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54262

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/DeleteThisCheck.cpp
  clang-tidy/bugprone/DeleteThisCheck.h
  docs/clang-tidy/checks/bugprone-delete-this.rst

Index: docs/clang-tidy/checks/bugprone-delete-this.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/bugprone-delete-this.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - bugprone-delete-this
+
+bugprone-delete-this
+
+
+Detects the usages of ``delete this``.
+
+Said statement generates multiple problems, such as enforcing allocating the object via ``new``, or not allowing any
+usage of instance members (neither fields nor methods) after the execution of it, nor touching ``this`` pointer
+in any way.
+
+Example:
+
+.. code-block:: c++
+
+  class A {
+void foo() {
+  delete this;
+  // warning: usage of 'delete this' is suspicious [bugprone-delete-this]
+}
+  }
Index: clang-tidy/bugprone/DeleteThisCheck.h
===
--- /dev/null
+++ clang-tidy/bugprone/DeleteThisCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteThisCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DELETE_THIS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DELETE_THIS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Detects the usages of `delete this`.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-delete-this.html
+class DeleteThisCheck : public ClangTidyCheck {
+public:
+  DeleteThisCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DELETE_THIS_H
Index: clang-tidy/bugprone/DeleteThisCheck.cpp
===
--- /dev/null
+++ clang-tidy/bugprone/DeleteThisCheck.cpp
@@ -0,0 +1,35 @@
+//===--- DeleteThisCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DeleteThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void DeleteThisCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxDeleteExpr(
+  has(ignoringParenImpCasts(cxxThisExpr(
+  .bind("DeleteThis"),
+  this);
+}
+
+void DeleteThisCheck::check(const MatchFinder::MatchResult ) {
+  const auto *E = Result.Nodes.getNodeAs("DeleteThis");
+  diag(E->getBeginLoc(), "usage of 'delete this' is suspicious");
+}
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/bugprone/CMakeLists.txt
===
--- clang-tidy/bugprone/CMakeLists.txt
+++ clang-tidy/bugprone/CMakeLists.txt
@@ -7,6 +7,7 @@
   BugproneTidyModule.cpp
   CopyConstructorInitCheck.cpp
   DanglingHandleCheck.cpp
+  DeleteThisCheck.cpp
   ExceptionEscapeCheck.cpp
   FoldInitTypeCheck.cpp
   ForwardDeclarationNamespaceCheck.cpp
Index: clang-tidy/bugprone/BugproneTidyModule.cpp
===
--- clang-tidy/bugprone/BugproneTidyModule.cpp
+++ clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -16,6 +16,7 @@
 #include "BoolPointerImplicitConversionCheck.h"
 #include "CopyConstructorInitCheck.h"
 #include "DanglingHandleCheck.h"
+#include "DeleteThisCheck.h"
 #include "ExceptionEscapeCheck.h"
 #include "FoldInitTypeCheck.h"
 #include 

[PATCH] D54261: [clangd] proof-of-concept: clang-tidy only runs over main-file

2018-11-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov, kbarton, nemanjai.

based on https://reviews.llvm.org/D54259, with API updates to make everything 
build again.

Not ready for review, probably won't become ready in this explicit form.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54261

Files:
  clang-query/Query.cpp
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
  clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp
  clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
  clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
  clang-tidy/bugprone/UnusedRaiiCheck.cpp
  clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/ForRangeCopyCheck.h
  clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tidy/readability/ImplicitBoolConversionCheck.h
  clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.h
  clang-tidy/readability/RedundantDeclarationCheck.cpp
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/ExprSequence.cpp
  clang-tidy/utils/ExprSequence.h
  clang-tidy/utils/NamespaceAliaser.cpp
  clang-tidy/utils/NamespaceAliaser.h
  clang-tidy/utils/UsingInserter.cpp
  clang-tidy/utils/UsingInserter.h
  clangd/ClangdUnit.cpp
  clangd/CodeComplete.cpp
  unittests/clang-tidy/NamespaceAliaserTest.cpp
  unittests/clang-tidy/UsingInserterTest.cpp

Index: unittests/clang-tidy/UsingInserterTest.cpp
===
--- unittests/clang-tidy/UsingInserterTest.cpp
+++ unittests/clang-tidy/UsingInserterTest.cpp
@@ -35,16 +35,17 @@
 
 const auto *Call = Result.Nodes.getNodeAs("foo");
 assert(Call != nullptr && "Did not find node \"foo\"");
-auto Hint =
-Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");
+auto Hint = Inserter->createUsingDeclaration(
+*Result.Context, *Result.Bounds, *Call, "::foo::func");
 
 if (Hint.hasValue())
   diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
 
 diag(Call->getBeginLoc(), "insert call")
 << clang::FixItHint::CreateReplacement(
Call->getCallee()->getSourceRange(),
-   Inserter->getShortName(*Result.Context, *Call, "::foo::func"));
+   Inserter->getShortName(*Result.Context, *Result.Bounds, *Call,
+  "::foo::func"));
   }
 
 private:
Index: unittests/clang-tidy/NamespaceAliaserTest.cpp
===
--- unittests/clang-tidy/NamespaceAliaserTest.cpp
+++ unittests/clang-tidy/NamespaceAliaserTest.cpp
@@ -33,14 +33,16 @@
 
 const auto *Call = Result.Nodes.getNodeAs("foo");
 assert(Call != nullptr && "Did not find node \"foo\"");
-auto Hint = Aliaser->createAlias(*Result.Context, *Call, "::foo::bar",
- {"b", "some_alias"});
+auto Hint = Aliaser->createAlias(*Result.Context, *Result.Bounds, *Call,
+ "::foo::bar", {"b", "some_alias"});
 if (Hint.hasValue())
   diag(Call->getBeginLoc(), "Fix for testing") << Hint.getValue();
 
 diag(Call->getBeginLoc(), "insert call") << FixItHint::CreateInsertion(
 Call->getBeginLoc(),
-Aliaser->getNamespaceName(*Result.Context, *Call, "::foo::bar") + "::");
+Aliaser->getNamespaceName(*Result.Context, *Result.Bounds, *Call,
+  "::foo::bar") +
+"::");
   }
 
 private:
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -36,7 +36,6 @@
 #include "index/Index.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Format/Format.h"
@@ 

[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2018-11-08 Thread Richard Membarth via Phabricator via cfe-commits
richardmembarth created this revision.
richardmembarth added reviewers: Anastasia, aaron.ballman.
Herald added a subscriber: cfe-commits.

The current pretty-printer emits OpenCL-style memory spaces specifiers: 
__device, __constant, and __shared.
The correct CUDA memory space specifiers are: __device__, __constant__, and 
__shared__:
https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#variable-memory-space-specifiers


Repository:
  rC Clang

https://reviews.llvm.org/D54258

Files:
  lib/AST/TypePrinter.cpp


Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1738,17 +1738,19 @@
   case LangAS::opencl_private:
 break;
   case LangAS::opencl_constant:
-  case LangAS::cuda_constant:
 OS << "__constant";
 break;
   case LangAS::opencl_generic:
 OS << "__generic";
 break;
   case LangAS::cuda_device:
-OS << "__device";
+OS << "__device__";
+break;
+  case LangAS::cuda_constant:
+OS << "__constant__";
 break;
   case LangAS::cuda_shared:
-OS << "__shared";
+OS << "__shared__";
 break;
   default:
 OS << "__attribute__((address_space(";


Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1738,17 +1738,19 @@
   case LangAS::opencl_private:
 break;
   case LangAS::opencl_constant:
-  case LangAS::cuda_constant:
 OS << "__constant";
 break;
   case LangAS::opencl_generic:
 OS << "__generic";
 break;
   case LangAS::cuda_device:
-OS << "__device";
+OS << "__device__";
+break;
+  case LangAS::cuda_constant:
+OS << "__constant__";
 break;
   case LangAS::cuda_shared:
-OS << "__shared";
+OS << "__shared__";
 break;
   default:
 OS << "__attribute__((address_space(";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54257: [clang-tidy] **Prototype** use AllTUsExecutors

2018-11-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: cfe-commits, mgrang, xazax.hun.

Only works on StandaloneToolExecutor, crashes happen when running
AllTUsExecutors with multithreads (I believe it is because
ClangTidyContext is not threadsafe).

  // Restrict thread to 1.
  ./bin/clang-tidy -executor=all-TUs -filter=".*/extra/*" 
-checks="-*,readability-braces-around-statements" -execute-concurrency=1 
-export-fixes="/tmp/fixes.yaml" .


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54257

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp

Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -18,6 +18,7 @@
 #include "../ClangTidy.h"
 #include "clang/Config/config.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Execution.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/TargetSelect.h"
 
@@ -328,8 +329,14 @@
 }
 
 static int clangTidyMain(int argc, const char **argv) {
-  CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
-cl::ZeroOrMore);
+  // CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
+  //   cl::ZeroOrMore);
+  auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
+  argc, argv, ClangTidyCategory);
+  if (!Executor) {
+llvm::errs() << llvm::toString(Executor.takeError()) << "\n";
+return 1;
+  }
   llvm::IntrusiveRefCntPtr BaseFS(
   VfsOverlay.empty() ? vfs::getRealFileSystem()
  : getVfsOverlayFromFile(VfsOverlay));
@@ -355,10 +362,10 @@
   SmallString<256> ProfilePrefix = MakeAbsolute(StoreCheckProfile);
 
   StringRef FileName("dummy");
-  auto PathList = OptionsParser.getSourcePathList();
-  if (!PathList.empty()) {
-FileName = PathList.front();
-  }
+  // auto PathList = OptionsParser.getSourcePathList();
+  // if (!PathList.empty()) {
+  //   FileName = PathList.front();
+  // }
 
   SmallString<256> FilePath = MakeAbsolute(FileName);
 
@@ -410,21 +417,20 @@
 return 1;
   }
 
-  if (PathList.empty()) {
-llvm::errs() << "Error: no input files specified.\n";
-llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
-return 1;
-  }
+  // if (PathList.empty()) {
+  //   llvm::errs() << "Error: no input files specified.\n";
+  //   llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
+  //   return 1;
+  // }
 
   llvm::InitializeAllTargetInfos();
   llvm::InitializeAllTargetMCs();
   llvm::InitializeAllAsmParsers();
 
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
-  std::vector Errors =
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
-   EnableCheckProfile, ProfilePrefix);
+  std::vector Errors = runClangTidy(
+  Context, std::move(*Executor), BaseFS, EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError ) {
return E.DiagLevel == ClangTidyError::Error;
  }) != Errors.end();
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -47,6 +47,20 @@
 
   bool IsWarningAsError;
 };
+inline bool operator<(const ClangTidyError , const ClangTidyError ) {
+  const tooling::DiagnosticMessage  = LHS.Message;
+  const tooling::DiagnosticMessage  = RHS.Message;
+
+  return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
+ std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+};
+inline bool operator==(const ClangTidyError , const ClangTidyError ) {
+  const tooling::DiagnosticMessage  = LHS.Message;
+  const tooling::DiagnosticMessage  = RHS.Message;
+
+  return std::tie(M1.FilePath, M1.FileOffset, M1.Message) ==
+ std::tie(M2.FilePath, M2.FileOffset, M2.Message);
+}
 
 /// \brief Read-only set of strings represented as a list of positive and
 /// negative globs. Positive globs add all matched strings to the set, negative
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -645,30 +645,11 @@
   }
 }
 
-namespace {
-struct LessClangTidyError {
-  bool operator()(const ClangTidyError , const ClangTidyError ) const {
-const tooling::DiagnosticMessage  = LHS.Message;
-const tooling::DiagnosticMessage  = RHS.Message;
-
-return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
-   std::tie(M2.FilePath, M2.FileOffset, 

[PATCH] D53934: [clangd] Improve code completion for ObjC methods

2018-11-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this!




Comment at: unittests/clangd/CodeCompleteTests.cpp:2195
+TEST(CompletionTest, ObjectiveCMethodNoArguments) {
+  std::string Context = R"objc(
+@interface Foo

"Context" is an odd name for this.



Comment at: unittests/clangd/CodeCompleteTests.cpp:2202
+
+  auto A = completions(Context, {}, {}, "Foo.m").Completions.front();
+  EXPECT_EQ(A.Name, "value");

this will crash if there aren't any completions, and do something unpredictable 
if there are multiple.
either grab the completions and then `ASSERT_THAT(completions, ElementsAre(_))` 
or write a getOnlyCompletion() helper that does the needed logging.
(Note an assertion on size isn't as good, as it only prints the size on failure)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53934



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


[PATCH] D54141: [clang-tidy] add deduplication support for run-clang-tidy.py

2018-11-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

> Could you please explain your motivation of catching clang-tidy stdout? 
> `--export-fixes` emits everything of `diagnostic` to YAML even the 
> `diagnostic` doesn't have fixes. I guess the reason is that you want code 
> snippets that you could show to users? If so, I think this is a separate UX 
> problem, since we have everything in the emitted YAML, and we could construct 
> whatever messages we want from it.

A bit for pragmatic reasons and a bit precaution.

- You are right with the code-snippet. I want to check for false-positives in 
new clang-tidy checks, if I can just scroll through and see the code-snippet in 
question it is just practical.
- diagnostics in template-code might emit multiple warnings at the same 
code-position. There is a realistic chance that `warning: xy happened here` 
will be the same for all template-instantiations, and only the `note: type 'XY' 
does not match` gives the differentiating hint. If dedup happens _ONLY_ on the 
first warning I fear we might loose valid diagnostics! I did re-evaluate and it 
seems that the emitted yaml does not include the notes. That is an issues, for 
example the CSA output relies on the emitted `notes` that explain the path to 
the bug.
- I originally implemented it for my buildbot which parses the check-name, 
location and so on and then gives an ordered output for each check in a module 
and so on. I extracted the essence for deduplication. `-export-fixes` still 
emits the clang-tidy diagnostics, so for my concrete use-case YAML based 
de-duplication brings no value in its current form, as my BB still struggles 
with the amount of stdout.

> 1. run clang-tidy in parallel on whole project, and emits a deduplicated 
> result (`fixes.yaml`).
> 2. run a postprocessing in your buildbot that constructs diagnostic messages 
> from `fixes.yaml`, and store it somewhere.
> 3. do whatever you want with output from 1) and 2).
> 
>   Step 1 could be done in upstream, probably via `AllTUsExecutor`, and 
> deduplication can be done on the fly based on 
> ``; we still need 
> `clang-apply-replacement` to deduplicate replacements; I'm happy to help with 
> this. Step 2 could be done by your own, just a simple script.
> 
>> At the moment clang-apply-replacements is called at the end of an clang-tidy 
>> run in run-clang-tidy.py That means we produce ~GBs of Yaml first, to then 
>> emit ~10MBs worth of it.
> 
> That's why I suggest using some sort of other space-efficient formats to 
> store the fixes. My intuition is that the final deduplicated result shouldn't 
> be too large (even for YAML), because 1) no duplication 2) these are **actual 
> diagnostics** in code, a healthy codebase shouldn't contain lots of problem 
> 3) you have mentioned that you use it for small projects :)

To 3) I do use it for all kinds of projects, LLVM and Blender are currently the 
biggest ones. I want to go for LibreOffice, Chromium and so on as well. But 
right now the amount of noise is the biggest obstacle. My goal is not to check 
if the project is healthy/provide a service for the project, but check if _we_ 
have bugs in our checks and if code-transformation is correct, false positives, 
too much output, misleading messages, ...

To 2) LLVM is very chatty as well, I don't consider LLVM to be a bad code-base. 
Take `readability-braces-around-statements` for example. I want to test if the 
check transform all possible places correctly, LLVM does not follow this style 
and LLVM has a lot of big headers that implement functionality that are 
transitively included a lot. LLVM is the one that overflowed my 32GB of RAM :)

To 1) I do agree and the data presented support that. I suspect that 
Yaml-to-stdout Ratio is maybe 2/3:1? So in the analyzed case we end up with 
10-15MB of data instead of ~600MB(all Yaml). Space optimization is something we 
can tackle after-wards as it does not seem to be pathological after 
deduplication.

In general: I somewhat consider this patch as rejected, I will still use it 
locally for my BB, but I think this revision should be closed. We could move 
the discussion here to the mailing-list if you want. It is ok to continue here 
as well, as we already started to make plans :)
My opinion is, that we should put as much of the deduplication into clang-tidy 
itself and not rely on tools like `run-clang-tidy.py` if we can.

So for me step 1. would be providing `AllTUsExecutor` in clang-tidy and make it 
parallel itself. For dedup we need hook the diagnostics. CSA has the 
`BugReport` class that could be hashed. clang-tidy currently doesn't have this, 
maybe a similar approach (or the same?) would help us out.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54141



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


[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-11-08 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

Committed in r346392.


Repository:
  rC Clang

https://reviews.llvm.org/D51484



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


[PATCH] D53457: clang-cl: Add "/clang:" pass-through arg support.

2018-11-08 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346393: clang-cl: Add /clang: pass-through arg 
support. (authored by hans, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D53457

Files:
  docs/UsersManual.rst
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/cl-options.c

Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -321,6 +321,8 @@
 def _SLASH_volatile_ms  : Option<["/", "-"], "volatile:ms", KIND_FLAG>,
   Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>,
   HelpText<"Volatile loads and stores have acquire and release semantics">;
+def _SLASH_clang : CLJoined<"clang:">,
+  HelpText<"Pass  to the clang driver">, MetaVarName<"">;
 def _SLASH_Zl : CLFlag<"Zl">,
   HelpText<"Don't mention any default libraries in the object file">;
 
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -362,6 +362,7 @@
   /// ParseArgStrings - Parse the given list of strings into an
   /// ArgList.
   llvm::opt::InputArgList ParseArgStrings(ArrayRef Args,
+  bool IsClCompatMode,
   bool );
 
   /// BuildInputs - Construct the list of inputs and their types from
@@ -552,7 +553,7 @@
 
   /// Get bitmasks for which option flags to include and exclude based on
   /// the driver mode.
-  std::pair getIncludeExcludeOptionFlagMasks() const;
+  std::pair getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const;
 
   /// Helper used in BuildJobsForAction.  Doesn't use the cache when building
   /// jobs specifically for the given action, but will use the cache when
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -619,5 +619,19 @@
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 
+// Accept clang options under the /clang: flag.
+// The first test case ensures that the SLP vectorizer is on by default and that
+// it's being turned off by the /clang:-fno-slp-vectorize flag.
+
+// RUN: %clang_cl -O2 -### -- %s 2>&1 | FileCheck -check-prefix=NOCLANG %s
+// NOCLANG: "--dependent-lib=libcmt"
+// NOCLANG-SAME: "-vectorize-slp"
+// NOCLANG-NOT: "--dependent-lib=msvcrt"
+
+// RUN: %clang_cl -O2 -MD /clang:-fno-slp-vectorize /clang:-MD /clang:-MF /clang:my_dependency_file.dep -### -- %s 2>&1 | FileCheck -check-prefix=CLANG %s
+// CLANG: "--dependent-lib=msvcrt"
+// CLANG-SAME: "-dependency-file" "my_dependency_file.dep"
+// CLANG-NOT: "--dependent-lib=libcmt"
+// CLANG-NOT: "-vectorize-slp"
 
 void f() { }
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -166,14 +166,15 @@
 }
 
 InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings,
+ bool IsClCompatMode,
  bool ) {
   llvm::PrettyStackTraceString CrashInfo("Command line argument parsing");
   ContainsError = false;
 
   unsigned IncludedFlagsBitmask;
   unsigned ExcludedFlagsBitmask;
   std::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) =
-  getIncludeExcludeOptionFlagMasks();
+  getIncludeExcludeOptionFlagMasks(IsClCompatMode);
 
   unsigned MissingArgIndex, MissingArgCount;
   InputArgList Args =
@@ -730,7 +731,7 @@
   ConfigFile = CfgFileName.str();
   bool ContainErrors;
   CfgOptions = llvm::make_unique(
-  ParseArgStrings(NewCfgArgs, ContainErrors));
+  ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
   if (ContainErrors) {
 CfgOptions.reset();
 return true;
@@ -924,7 +925,7 @@
   // Arguments specified in command line.
   bool ContainsError;
   CLOptions = llvm::make_unique(
-  ParseArgStrings(ArgList.slice(1), ContainsError));
+  ParseArgStrings(ArgList.slice(1), IsCLMode(), ContainsError));
 
   // Try parsing configuration file.
   if (!ContainsError)
@@ -934,21 +935,47 @@
   // All arguments, from both config file and command line.
   InputArgList Args = std::move(HasConfigFile ? std::move(*CfgOptions)
   : std::move(*CLOptions));
-  if (HasConfigFile)
-for (auto *Opt : *CLOptions) {
-  if (Opt->getOption().matches(options::OPT_config))
-continue;
+
+  auto appendOneArg = [](const Arg *Opt, const Arg *BaseArg) {
   unsigned Index = Args.MakeIndex(Opt->getSpelling());
-  const Arg *BaseArg = >getBaseArg();
-  if (BaseArg == Opt)
-BaseArg = nullptr;
   Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Opt->getSpelling(),
  Index, 

r346393 - clang-cl: Add "/clang:" pass-through arg support.

2018-11-08 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Nov  8 03:27:04 2018
New Revision: 346393

URL: http://llvm.org/viewvc/llvm-project?rev=346393=rev
Log:
clang-cl: Add "/clang:" pass-through arg support.

The clang-cl driver disables access to command line options outside of the
"Core" and "CLOption" sets of command line arguments. This filtering makes it
impossible to pass arguments that are interpreted by the clang driver and not
by either 'cc1' (the frontend) or one of the other tools invoked by the driver.

An example driver-level flag is the '-fno-slp-vectorize' flag, which is
processed by the driver in Clang::ConstructJob and used to set the cc1 flag
"-vectorize-slp". There is no negative cc1 flag or -mllvm flag, so it is not
currently possible to disable the SLP vectorizer from the clang-cl driver.

This change introduces the "/clang:" argument that is available when the
driver mode is set to CL compatibility. This option works similarly to the
"-Xclang" option, except that the option values are processed by the clang
driver rather than by 'cc1'. An example usage is:

  clang-cl /clang:-fno-slp-vectorize /O2 test.c

Another example shows how "/clang:" can be used to pass a flag where there is
a conflict between a clang-cl compat option and an overlapping clang driver
option:

  clang-cl /MD /clang:-MD /clang:-MF /clang:test_dep_file.dep test.c

In the previous example, the unprefixed /MD selects the DLL version of the msvc
CRT, while the prefixed -MD flag and the -MF flags are used to create a make
dependency file for included headers.

One note about flag ordering: the /clang: flags are concatenated to the end of
the argument list, so in cases where the last flag wins, the /clang: flags
will be chosen regardless of their order relative to other flags on the driver
command line.

Patch by Neeraj K. Singh!

Differential revision: https://reviews.llvm.org/D53457

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=346393=346392=346393=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Nov  8 03:27:04 2018
@@ -2849,6 +2849,7 @@ Execute ``clang-cl /?`` to see a list of
   /arch:   Set architecture for code generation
   /Brepro-Emit an object file which cannot be reproduced 
over time
   /Brepro Emit an object file which can be reproduced over 
time
+  /clang:Pass  to the clang driver
   /C  Don't discard comments when preprocessing
   /c  Compile only
   /d1PP   Retain macro definitions in /E mode
@@ -3084,6 +3085,17 @@ Execute ``clang-cl /?`` to see a list of
   -W Enable the specified warning
   -XclangPass  to the clang compiler
 
+The /clang: Option
+^^
+
+When clang-cl is run with a set of ``/clang:`` options, it will gather all
+of the  arguments and process them as if they were passed to the clang
+driver. This mechanism allows you to pass flags that are not exposed in the
+clang-cl options or flags that have a different meaning when passed to the 
clang
+driver. Regardless of where they appear in the command line, the ``/clang:``
+arguments are treated as if they were passed at the end of the clang-cl command
+line.
+
 The /fallback Option
 
 

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=346393=346392=346393=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Nov  8 03:27:04 2018
@@ -321,6 +321,8 @@ def _SLASH_vmv : CLFlag<"vmv">,
 def _SLASH_volatile_ms  : Option<["/", "-"], "volatile:ms", KIND_FLAG>,
   Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>,
   HelpText<"Volatile loads and stores have acquire and release semantics">;
+def _SLASH_clang : CLJoined<"clang:">,
+  HelpText<"Pass  to the clang driver">, MetaVarName<"">;
 def _SLASH_Zl : CLFlag<"Zl">,
   HelpText<"Don't mention any default libraries in the object file">;
 

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=346393=346392=346393=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Thu Nov  8 03:27:04 2018
@@ -362,6 +362,7 @@ public:
   /// ParseArgStrings - Parse 

r346392 - [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-11-08 Thread Andrew Savonichev via cfe-commits
Author: asavonic
Date: Thu Nov  8 03:25:41 2018
New Revision: 346392

URL: http://llvm.org/viewvc/llvm-project?rev=346392=rev
Log:
[OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

Summary:
Documentation can be found at 
https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_device_side_avc_motion_estimation.txt

Patch by Kristina Bessonova


Reviewers: Anastasia, yaxunl, shafik

Reviewed By: Anastasia

Subscribers: arphaman, sidorovd, AlexeySotkin, krisb, bader, asavonic, 
cfe-commits

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

Added:
cfe/trunk/include/clang/Basic/OpenCLExtensionTypes.def
cfe/trunk/test/CodeGenOpenCL/intel-subgroups-avc-ext-types.cl
cfe/trunk/test/SemaOpenCL/intel-subgroup-avc-ext-types.cl
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/OpenCLExtensions.def
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/PrintfFormatString.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Headers/opencl-c-header.cl
cfe/trunk/test/Index/opencl-types.cl
cfe/trunk/test/SemaOpenCL/extension-version.cl
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=346392=346391=346392=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Nov  8 03:25:41 2018
@@ -3297,7 +3297,21 @@ enum CXTypeKind {
 
   CXType_ObjCObject = 161,
   CXType_ObjCTypeParam = 162,
-  CXType_Attributed = 163
+  CXType_Attributed = 163,
+
+  CXType_OCLIntelSubgroupAVCMcePayload = 164,
+  CXType_OCLIntelSubgroupAVCImePayload = 165,
+  CXType_OCLIntelSubgroupAVCRefPayload = 166,
+  CXType_OCLIntelSubgroupAVCSicPayload = 167,
+  CXType_OCLIntelSubgroupAVCMceResult = 168,
+  CXType_OCLIntelSubgroupAVCImeResult = 169,
+  CXType_OCLIntelSubgroupAVCRefResult = 170,
+  CXType_OCLIntelSubgroupAVCSicResult = 171,
+  CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
+  CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
+  CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,
+
+  CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
 };
 
 /**

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=346392=346391=346392=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Nov  8 03:25:41 2018
@@ -1062,6 +1062,9 @@ public:
   CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
   CanQualType OCLQueueTy, OCLReserveIDTy;
   CanQualType OMPArraySectionTy;
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+  CanQualType Id##Ty;
+#include "clang/Basic/OpenCLExtensionTypes.def"
 
   // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
   mutable QualType AutoDeductTy; // Deduction against 'auto'.

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=346392=346391=346392=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Nov  8 03:25:41 2018
@@ -2046,6 +2046,13 @@ public:
   bool isQueueT() const;// OpenCL queue_t
   bool isReserveIDT() const;// OpenCL reserve_id_t
 
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+  bool is##Id##Type() const;
+#include "clang/Basic/OpenCLExtensionTypes.def"
+  // Type defined in cl_intel_device_side_avc_motion_estimation OpenCL 
extension
+  bool isOCLIntelSubgroupAVCType() const;
+  bool isOCLExtOpaqueType() const;  // Any OpenCL extension type
+
   bool 

[PATCH] D53457: clang-cl: Add "/clang:" pass-through arg support.

2018-11-08 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D53457#1291020, @neerajksingh wrote:

> Reid, Hans, or someone else with commit access. If the revision looks good, 
> could you please submit to SVN?
>
> Any particular testing I should run beforehand? I ran the clang tests locally 
> on Windows.


I'll run the tests on Linux and commit.


https://reviews.llvm.org/D53457



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


[PATCH] D54253: [OpenCL][NFC] Improve test coverage of test/Index/opencl-types.cl

2018-11-08 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D54253



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


[PATCH] D54253: [OpenCL][NFC] Improve test coverage of test/Index/opencl-types.cl

2018-11-08 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov created this revision.
AlexeySachkov added reviewers: Anastasia, asavonic.
Herald added subscribers: arphaman, yaxunl.

The problem here is that test only checks default target. I recently
introduced regression which wasn't detected by local testing: I missed that
some declarations might be '(invalid)' on different platforms.


Repository:
  rC Clang

https://reviews.llvm.org/D54253

Files:
  test/Index/opencl-types.cl

Index: test/Index/opencl-types.cl
===
--- test/Index/opencl-types.cl
+++ test/Index/opencl-types.cl
@@ -1,4 +1,6 @@
 // RUN: c-index-test -test-print-type %s -cl-std=CL2.0 | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 --target=ppc64le | FileCheck %s
+// RUN: c-index-test -test-print-type %s -cl-std=CL2.0 --target=arm | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
@@ -16,12 +18,12 @@
   double4 vectorDouble;
 }
 
-// CHECK: VarDecl=scalarHalf:11:8 (Definition){{( \(invalid\))?}} [type=half] [typekind=Half] [isPOD=1]
-// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] [canonicaltype=half __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
-// CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] [isPOD=1]
-// CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] [typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
-// CHECK: VarDecl=scalarDouble:15:10 (Definition){{( \(invalid\))?}} [type=double] [typekind=Double] [isPOD=1]
-// CHECK: VarDecl=vectorDouble:16:11 (Definition){{( \(invalid\))?}} [type=double4] [typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarHalf:13:8 (Definition){{( \(invalid\))?}} [type=half] [typekind=Half] [isPOD=1]
+// CHECK: VarDecl=vectorHalf:14:9 (Definition) [type=half4] [typekind=Typedef] [canonicaltype=half __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarFloat:15:9 (Definition) [type=float] [typekind=Float] [isPOD=1]
+// CHECK: VarDecl=vectorFloat:16:10 (Definition) [type=float4] [typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarDouble:17:10 (Definition){{( \(invalid\))?}} [type=double] [typekind=Double] [isPOD=1]
+// CHECK: VarDecl=vectorDouble:18:11 (Definition){{( \(invalid\))?}} [type=double4] [typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
 
 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
 
@@ -38,18 +40,18 @@
 void kernel OCLImage2dArrayMSAADepthROTest(read_only image2d_array_msaa_depth_t scalarOCLImage2dArrayMSAADepthRO);
 void kernel OCLImage3dROTest(read_only image3d_t scalarOCLImage3dRO);
 
-// CHECK: ParmDecl=scalarOCLImage1dRO:28:50 (Definition) [type=__read_only image1d_t] [typekind=OCLImage1dRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage1dArrayRO:29:61 (Definition) [type=__read_only image1d_array_t] [typekind=OCLImage1dArrayRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage1dBufferRO:30:63 (Definition) [type=__read_only image1d_buffer_t] [typekind=OCLImage1dBufferRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dRO:31:50 (Definition) [type=__read_only image2d_t] [typekind=OCLImage2dRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dArrayRO:32:61 (Definition) [type=__read_only image2d_array_t] [typekind=OCLImage2dArrayRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dDepthRO:33:61 (Definition) [type=__read_only image2d_depth_t] [typekind=OCLImage2dDepthRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dArrayDepthRO:34:72 (Definition) [type=__read_only image2d_array_depth_t] [typekind=OCLImage2dArrayDepthRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dMSAARO:35:59 (Definition){{( \(invalid\))?}} [type=__read_only image2d_msaa_t] [typekind=OCLImage2dMSAARO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dArrayMSAARO:36:70 (Definition){{( \(invalid\))?}} [type=__read_only image2d_array_msaa_t] [typekind=OCLImage2dArrayMSAARO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dMSAADepthRO:37:70 (Definition){{( \(invalid\))?}} [type=__read_only image2d_msaa_depth_t] [typekind=OCLImage2dMSAADepthRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage2dArrayMSAADepthRO:38:81 (Definition){{( \(invalid\))?}} [type=__read_only image2d_array_msaa_depth_t] [typekind=OCLImage2dArrayMSAADepthRO] [isPOD=1]
-// CHECK: ParmDecl=scalarOCLImage3dRO:39:50 (Definition) [type=__read_only image3d_t] [typekind=OCLImage3dRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage1dRO:30:50 (Definition) [type=__read_only image1d_t] [typekind=OCLImage1dRO] [isPOD=1]
+// CHECK: ParmDecl=scalarOCLImage1dArrayRO:31:61 (Definition) [type=__read_only image1d_array_t] 

  1   2   >