[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning

2018-06-07 Thread Xing via Phabricator via cfe-commits
Higuoxing added a comment.

In https://reviews.llvm.org/D47687#1125926, @rnk wrote:

> @dexonsmith is there someone from Apple who can comment on rdar://8678458 and 
> the merits of disabling this warning in macros? I strongly suspect the 
> original report was dealing with code like `assert(x || y && "str");`, if so 
> we can go forward with this.
>
> @chandlerc I know you've hit this behavior difference vs. GCC before. Any 
> thoughts on the proposed change?




In https://reviews.llvm.org/D47687#1125964, @dexonsmith wrote:

> In https://reviews.llvm.org/D47687#1125926, @rnk wrote:
>
> > @dexonsmith is there someone from Apple who can comment on rdar://8678458 
> > and the merits of disabling this warning in macros? I strongly suspect the 
> > original report was dealing with code like `assert(x || y && "str");`, if 
> > so we can go forward with this.
>
>
> There were two commits with this radar: r119537 and r119540.  The main 
> motivation was a deeply nested macro that when "inlined" included the moral 
> equivalent of `#define DOUBLE_OP(OP1, OP2, X, Y, Z) (X OP1 Y OP2 Z)`.  There 
> was terrible note spew when the warning fired in this case, and the use case 
> for the macro made the warning un-actionable.  We decided to suppress the 
> warning entirely:
>
> > As a general comment, the warning seems to be useless for macros; I'll 
> > follow the example of warn_logical_instead_of_bitwise which doesn't trigger 
> > for macros and I'll make the warning not warn for macros.


Hi, Thank you,

I noticed that `warn_logical_instead_of_bitwise ` will also skip parentheses 
checking in macros... well, this patch seems not so necessary... both ok for me 
... depends on all of you :-)


https://reviews.llvm.org/D47687



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


r334264 - [X86] Fix some typecasts in intrinsic headers that I messed up in r334261.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 21:09:14 2018
New Revision: 334264

URL: http://llvm.org/viewvc/llvm-project?rev=334264=rev
Log:
[X86] Fix some typecasts in intrinsic headers that I messed up in r334261.

This was caught by the Header tests, but not the CodeGen tests.

Modified:
cfe/trunk/lib/Headers/avxintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=334264=334263=334264=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Thu Jun  7 21:09:14 2018
@@ -4689,8 +4689,8 @@ _mm256_zextsi128_si256(__m128i __a)
 ///result.
 /// \returns A 256-bit integer vector containing the interleaved values.
 #define _mm256_insertf128_si256(V1, V2, M) \
-  (__m256i)__builtin_ia32_vinsertf128_si256((__v4di)(__m256i)(V1), \
-(__v2di)(__m128i)(V2), (int)(M))
+  (__m256i)__builtin_ia32_vinsertf128_si256((__v8si)(__m256i)(V1), \
+(__v4si)(__m128i)(V2), (int)(M))
 
 /*
Vector extract.
@@ -4767,7 +4767,7 @@ _mm256_zextsi128_si256(__m128i __a)
 ///If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the 
result.
 /// \returns A 128-bit integer vector containing the extracted bits.
 #define _mm256_extractf128_si256(V, M) \
-  (__m128i)__builtin_ia32_vextractf128_si256((__v4di)(__m256i)(V), (int)(M))
+  (__m128i)__builtin_ia32_vextractf128_si256((__v8si)(__m256i)(V), (int)(M))
 
 /* SIMD load ops (unaligned) */
 /// Loads two 128-bit floating-point vectors of [4 x float] from


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


r334261 - [X86] Add subvector insert and extract builtins to enable target feature checking and immediate range checking.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 20:24:47 2018
New Revision: 334261

URL: http://llvm.org/viewvc/llvm-project?rev=334261=rev
Log:
[X86] Add subvector insert and extract builtins to enable target feature 
checking and immediate range checking.

Test changes are due to differences in how we generate undef elements now. We 
also changed the types used for extractf128_si256/insertf128_si256 to match the 
signature of the builtin that previously existed which this patch resurrects. 
This also matches gcc.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx-shuffle-builtins.c
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334261=334260=334261=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun  7 20:24:47 2018
@@ -491,6 +491,9 @@ TARGET_BUILTIN(__builtin_ia32_cmpps, "V4
 TARGET_BUILTIN(__builtin_ia32_cmpps256, "V8fV8fV8fIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmpsd, "V2dV2dV2dIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmpss, "V4fV4fV4fIc", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vextractf128_pd256, "V2dV4dIc", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vextractf128_ps256, "V4fV8fIc", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vextractf128_si256, "V4iV8iIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8f", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq256, "V4iV4d", "nc", "avx")
@@ -503,6 +506,9 @@ TARGET_BUILTIN(__builtin_ia32_vpermilpd,
 TARGET_BUILTIN(__builtin_ia32_vpermilps, "V4fV4fIi", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_vpermilpd256, "V4dV4dIi", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_vpermilps256, "V8fV8fIi", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vinsertf128_pd256, "V4dV4dV2dIc", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vinsertf128_ps256, "V8fV8fV4fIc", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vinsertf128_si256, "V8iV8iV4iIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_sqrtpd256, "V4dV4d", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_sqrtps256, "V8fV8f", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_rsqrtps256, "V8fV8f", "nc", "avx")
@@ -618,6 +624,8 @@ TARGET_BUILTIN(__builtin_ia32_pblendd256
 TARGET_BUILTIN(__builtin_ia32_permvarsi256, "V8iV8iV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permvarsf256, "V8fV8fV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permti256, "V4LLiV4LLiV4LLiIc", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_extract128i256, "V2LLiV4LLiIc", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_insert128i256, "V4LLiV4LLiV2LLiIc", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_maskloadd256, "V8iV8iC*V8i", "n", "avx2")
 TARGET_BUILTIN(__builtin_ia32_maskloadq256, "V4LLiV4LLiC*V4LLi", "n", "avx2")
 TARGET_BUILTIN(__builtin_ia32_maskloadd, "V4iV4iC*V4i", "n", "avx2")
@@ -927,6 +935,8 @@ TARGET_BUILTIN(__builtin_ia32_alignd128,
 TARGET_BUILTIN(__builtin_ia32_alignd256, "V8iV8iV8iIi", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_alignq128, "V2LLiV2LLiV2LLiIi", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_alignq256, "V4LLiV4LLiV4LLiIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_extractf64x4, "V4dV8dIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_extractf32x4, "V4fV16fIi", "nc", "avx512f")
 
 TARGET_BUILTIN(__builtin_ia32_vpdpbusd128, "V4iV4iV4iV4i", "nc", 
"avx512vl,avx512vnni")
 TARGET_BUILTIN(__builtin_ia32_vpdpbusd256, "V8iV8iV8iV8i", "nc", 
"avx512vl,avx512vnni")
@@ -1646,6 +1656,28 @@ TARGET_BUILTIN(__builtin_ia32_pmovqw128_
 TARGET_BUILTIN(__builtin_ia32_pmovqw128mem_mask, "vV8s*V2LLiUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovqw256_mask, "V8sV4LLiV8sUc", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovqw256mem_mask, "vV8s*V4LLiUc", "n", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_extractf32x8, "V8fV16fIi", "nc", "avx512dq")
+TARGET_BUILTIN(__builtin_ia32_extractf64x2_512, "V2dV8dIi", "nc", "avx512dq")
+TARGET_BUILTIN(__builtin_ia32_extracti32x8, "V8iV16iIi", "nc", "avx512dq")
+TARGET_BUILTIN(__builtin_ia32_extracti64x2_512, "V2LLiV8LLiIi", "nc", 
"avx512dq")
+TARGET_BUILTIN(__builtin_ia32_extracti32x4, "V4iV16iIi", "nc", "avx512f")

[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning

2018-06-07 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In https://reviews.llvm.org/D47687#1125926, @rnk wrote:

> @dexonsmith is there someone from Apple who can comment on rdar://8678458 and 
> the merits of disabling this warning in macros? I strongly suspect the 
> original report was dealing with code like `assert(x || y && "str");`, if so 
> we can go forward with this.


There were two commits with this radar: r119537 and r119540.  The main 
motivation was a deeply nested macro that when "inlined" included the moral 
equivalent of `#define DOUBLE_OP(OP1, OP2, X, Y, Z) (X OP1 Y OP2 Z)`.  There 
was terrible note spew when the warning fired in this case, and the use case 
for the macro made the warning un-actionable.  We decided to suppress the 
warning entirely:

> As a general comment, the warning seems to be useless for macros; I'll follow 
> the example of warn_logical_instead_of_bitwise which doesn't trigger for 
> macros and I'll make the warning not warn for macros.


https://reviews.llvm.org/D47687



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


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D47894#1125728, @jyknight wrote:

> In https://reviews.llvm.org/D47894#1125653, @efriedma wrote:
>
> > The problem would come from propagating nonnull-ness from something which 
> > isn't inherently nonnull.  For example, strlen has a nonnull argument, so 
> > `strlen(NULL)` is UB, therefore given `int z = strlen(x); if (x) {...}`, we 
> > can remove the null check.  (Not sure we actually do this transform at the 
> > moment, but it's something we could do in the future.)
>
>
> I think the question there is actually whether we need to, in addition to 
> supporting null pointer dereference, also cause all 
> `__attribute__((nonnull))` annotations at the C/C++ level to be ignored.
>
> And, yes, I believe we should.


Is that what the kernel community actually wants though? There are certainly 
others who want a way to strip `__attribute__((nonnull))` completely, which 
seems a bit orthogonal to the removal of null checks in general. I think it 
would be good to support such a flag, but the presence of `nonnull` inside 
kernel sources leads me to believe they want those cases to be treated 
specially.


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


r334256 - [X86] Add builtins for vpermilps/pd instructions to enable target feature checking.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 17:59:27 2018
New Revision: 334256

URL: http://llvm.org/viewvc/llvm-project?rev=334256=rev
Log:
[X86] Add builtins for vpermilps/pd instructions to enable target feature 
checking.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334256=334255=334256=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun  7 17:59:27 2018
@@ -499,6 +499,10 @@ TARGET_BUILTIN(__builtin_ia32_cvttps2dq2
 TARGET_BUILTIN(__builtin_ia32_vperm2f128_pd256, "V4dV4dV4dIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_vperm2f128_ps256, "V8fV8fV8fIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_vperm2f128_si256, "V8iV8iV8iIc", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vpermilpd, "V2dV2dIi", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vpermilps, "V4fV4fIi", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vpermilpd256, "V4dV4dIi", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_vpermilps256, "V8fV8fIi", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_sqrtpd256, "V4dV4d", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_sqrtps256, "V8fV8f", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_rsqrtps256, "V8fV8f", "nc", "avx")
@@ -1470,6 +1474,8 @@ TARGET_BUILTIN(__builtin_ia32_vcvttsd2si
 TARGET_BUILTIN(__builtin_ia32_vcvttsd2usi32, "UiV2dIi", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvttss2si32, "iV4fIi", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvttss2usi32, "UiV4fIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilpd512, "V8dV8dIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilps512, "V16fV16fIi", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vpermilvarpd512, "V8dV8dV8LLi", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vpermilvarps512, "V16fV16fV16i", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_rndscalesd_round_mask, "V2dV2dV2dV2dUcIiIi", 
"nc", "avx512f")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334256=334255=334256=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  7 17:59:27 2018
@@ -9256,6 +9256,33 @@ Value *CodeGenFunction::EmitX86BuiltinEx
makeArrayRef(Indices, NumElts),
"blend");
   }
+  case X86::BI__builtin_ia32_vpermilpd:
+  case X86::BI__builtin_ia32_vpermilps:
+  case X86::BI__builtin_ia32_vpermilpd256:
+  case X86::BI__builtin_ia32_vpermilps256:
+  case X86::BI__builtin_ia32_vpermilpd512:
+  case X86::BI__builtin_ia32_vpermilps512: {
+uint32_t Imm = cast(Ops[1])->getZExtValue();
+llvm::Type *Ty = Ops[0]->getType();
+unsigned NumElts = Ty->getVectorNumElements();
+unsigned NumLanes = Ty->getPrimitiveSizeInBits() / 128;
+unsigned NumLaneElts = NumElts / NumLanes;
+
+// Splat the 8-bits of immediate 4 times to help the loop wrap around.
+Imm = (Imm & 0xff) * 0x01010101;
+
+uint32_t Indices[16];
+for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
+  for (unsigned i = 0; i != NumLaneElts; ++i) {
+Indices[i + l] = (Imm % NumLaneElts) + l;
+Imm /= NumLaneElts;
+  }
+}
+
+return Builder.CreateShuffleVector(Ops[0], UndefValue::get(Ty),
+   makeArrayRef(Indices, NumElts),
+   "permil");
+  }
   case X86::BI__builtin_ia32_palignr128:
   case X86::BI__builtin_ia32_palignr256:
   case X86::BI__builtin_ia32_palignr512: {

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=334256=334255=334256=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jun  7 17:59:27 2018
@@ -6302,16 +6302,7 @@ _mm_cvttss_u64 (__m128 __A)
 #endif
 
 #define _mm512_permute_pd(X, C) \
-  (__m512d)__builtin_shufflevector((__v8df)(__m512d)(X), \
-   (__v8df)_mm512_undefined_pd(), \
-   0 + (((C) >> 0) & 0x1), \
-   0 + (((C) >> 1) & 0x1), \
-   2 + (((C) >> 2) & 0x1), \
-   2 + (((C) >> 3) & 0x1), \
- 

[PATCH] D47862: [CodeGen] Always use MSVC personality for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334253: [CodeGen] Always use MSVC personality for 
windows-msvc targets (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47862?vs=150243=150437#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47862

Files:
  lib/CodeGen/CGException.cpp
  test/CodeGenObjC/personality.m
  test/CodeGenObjCXX/personality.mm

Index: test/CodeGenObjC/personality.m
===
--- test/CodeGenObjC/personality.m
+++ test/CodeGenObjC/personality.m
@@ -11,14 +11,14 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fseh-exceptions -fobjc-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW-SEH
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fsjlj-exceptions -fobjc-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW-SJLJ
 
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=ios -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=watchos -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-1.7 -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-GNUSTEP-1_7
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-GNUSTEP
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-GCC
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=ios -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=watchos -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-1.7 -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MSVC
 
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions -fobjc-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MACOSX-FRAGILE
 // RUN: %clang_cc1 -triple i686-unknown-windows-gnu -fexceptions -fdwarf-exceptions -fobjc-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MACOSX-FRAGILE-MINGW-DWARF
@@ -49,8 +49,7 @@
 // CHECK-OBJFW-SEH: personality i8* bitcast (i32 (...)* @__gnu_objc_personality_seh0 to i8*)
 // CHECK-OBJFW-SJLJ: personality i8* bitcast (i32 (...)* @__gnu_objc_personality_sj0 to i8*)
 
-// CHECK-WIN-MACOSX-FRAGILE: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*)
-// CHECK-WIN-NS: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3  to i8*)
+// CHECK-WIN-MSVC: personality i8* bitcast (i32 (...)* @__CxxFrameHandler3  to i8*)
 
 // CHECK-MACOSX-FRAGILE-MINGW-DWARF: personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
 // CHECK-MACOSX-FRAGILE-MINGW-SEH: personality i8* bitcast (i32 (...)* @__gcc_personality_seh0 to i8*)
Index: test/CodeGenObjCXX/personality.mm
===

r334253 - [CodeGen] Always use MSVC personality for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jun  7 17:41:01 2018
New Revision: 334253

URL: http://llvm.org/viewvc/llvm-project?rev=334253=rev
Log:
[CodeGen] Always use MSVC personality for windows-msvc targets

The windows-msvc target is meant to be ABI compatible with MSVC,
including the exception handling. Ensure that a windows-msvc triple
always equates to the MSVC personality being used.

This mostly affects the GNUStep and ObjFW Obj-C runtimes. To the best of
my knowledge, those are normally not used with windows-msvc triples. I
believe WinObjC is based on GNUStep (or it at least uses libobjc2), but
that also takes the approach of wrapping Obj-C exceptions in C++
exceptions, so the MSVC personality function is the right one to use
there as well.

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

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenObjC/personality.m
cfe/trunk/test/CodeGenObjCXX/personality.mm

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=334253=334252=334253=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Jun  7 17:41:01 2018
@@ -117,12 +117,12 @@ EHPersonality::GNU_Wasm_CPlusPlus = { "_
 static const EHPersonality (const TargetInfo ,
 const LangOptions ) {
   const llvm::Triple  = Target.getTriple();
+  if (T.isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SjLjExceptions)
 return EHPersonality::GNU_C_SJLJ;
   if (L.DWARFExceptions)
 return EHPersonality::GNU_C;
-  if (T.isWindowsMSVCEnvironment())
-return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
 return EHPersonality::GNU_C_SEH;
   return EHPersonality::GNU_C;
@@ -131,14 +131,15 @@ static const EHPersonality 
 static const EHPersonality (const TargetInfo ,
const LangOptions ) {
   const llvm::Triple  = Target.getTriple();
+  if (T.isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
+
   switch (L.ObjCRuntime.getKind()) {
   case ObjCRuntime::FragileMacOSX:
 return getCPersonality(Target, L);
   case ObjCRuntime::MacOSX:
   case ObjCRuntime::iOS:
   case ObjCRuntime::WatchOS:
-if (T.isWindowsMSVCEnvironment())
-  return EHPersonality::MSVC_CxxFrameHandler3;
 return EHPersonality::NeXT_ObjC;
   case ObjCRuntime::GNUstep:
 if (L.ObjCRuntime.getVersion() >= VersionTuple(1, 7))
@@ -158,12 +159,12 @@ static const EHPersonality 
 static const EHPersonality (const TargetInfo ,
   const LangOptions ) {
   const llvm::Triple  = Target.getTriple();
+  if (T.isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SjLjExceptions)
 return EHPersonality::GNU_CPlusPlus_SJLJ;
   if (L.DWARFExceptions)
 return EHPersonality::GNU_CPlusPlus;
-  if (T.isWindowsMSVCEnvironment())
-return EHPersonality::MSVC_CxxFrameHandler3;
   if (L.SEHExceptions)
 return EHPersonality::GNU_CPlusPlus_SEH;
   // Wasm EH is a non-MVP feature for now.
@@ -178,6 +179,9 @@ static const EHPersonality 
 /// and Objective-C exceptions are being caught.
 static const EHPersonality (const TargetInfo ,
  const LangOptions ) {
+  if (Target.getTriple().isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
+
   switch (L.ObjCRuntime.getKind()) {
   // In the fragile ABI, just use C++ exception handling and hope
   // they're not doing crazy exception mixing.

Modified: cfe/trunk/test/CodeGenObjC/personality.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/personality.m?rev=334253=334252=334253=diff
==
--- cfe/trunk/test/CodeGenObjC/personality.m (original)
+++ cfe/trunk/test/CodeGenObjC/personality.m Thu Jun  7 17:41:01 2018
@@ -11,14 +11,14 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions 
-fseh-exceptions -fobjc-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | 
FileCheck %s -check-prefix CHECK-OBJFW-SEH
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions 
-fsjlj-exceptions -fobjc-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - 
| FileCheck %s -check-prefix CHECK-OBJFW-SJLJ
 
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions 
-fobjc-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | 
FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions 
-fobjc-exceptions -fobjc-runtime=ios -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions 
-fobjc-exceptions -fobjc-runtime=macosx 

[PATCH] D47920: Made loop_proto more "vectorizable"

2018-06-07 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC334252: [clang-fuzzer] Made loop_proto more 
vectorizable. (authored by morehouse, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47920?vs=150435=150436#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47920

Files:
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -7,10 +7,13 @@
 //
 //===--===//
 //
-// Implements functions for converting between protobufs and C++. Extends
+// Implements functions for converting between protobufs and C++. Differs from
 // proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
 // loop. Also coutputs a different function signature that includes a
-// size_t parameter for the loop to use.
+// size_t parameter for the loop to use. The C++ code generated is meant to
+// stress the LLVM loop vectorizer.
+//
+// Still a work in progress.
 //
 //===--===//
 
@@ -33,19 +36,7 @@
 std::ostream <<(std::ostream , const Const ) {
   return os << "(" << x.val() << ")";
 }
-std::ostream <<(std::ostream , const VarRef ) {
-  if (x.is_loop_var()) {
-return os << "a[loop_ctr]";
-  } else {
-return os << "a[" << static_cast(x.varnum()) << " % s]";
-  }
-}
-std::ostream <<(std::ostream , const Lvalue ) {
-  return os << x.varref();
-}
 std::ostream <<(std::ostream , const Rvalue ) {
-  if (x.has_varref())
-return os << x.varref();
   if (x.has_cons())
 return os << x.cons();
   if (x.has_binop())
@@ -101,23 +92,18 @@
   return os << x.right() << ")";
 }
 std::ostream <<(std::ostream , const AssignmentStatement ) {
-  return os << x.lvalue() << "=" << x.rvalue();
+  return os << "a[i]=" << x.rvalue();
 }
 std::ostream <<(std::ostream , const IfElse ) {
   return os << "if (" << x.cond() << "){\n"
 << x.if_body() << "} else { \n"
 << x.else_body() << "}\n";
 }
-std::ostream <<(std::ostream , const While ) {
-  return os << "while (" << x.cond() << "){\n" << x.body() << "}\n";
-}
 std::ostream <<(std::ostream , const Statement ) {
   if (x.has_assignment())
 return os << x.assignment() << ";\n";
   if (x.has_ifelse())
 return os << x.ifelse();
-  if (x.has_while_loop())
-return os << x.while_loop();
   return os << "(void)0;\n";
 }
 std::ostream <<(std::ostream , const StatementSeq ) {
@@ -127,7 +113,7 @@
 }
 std::ostream <<(std::ostream , const LoopFunction ) {
   return os << "void foo(int *a, size_t s) {\n"
-<< "for (int loop_ctr = 0; loop_ctr < s; loop_ctr++){\n"
+<< "for (int i=0; i___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r334252 - [clang-fuzzer] Made loop_proto more "vectorizable".

2018-06-07 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Thu Jun  7 17:33:35 2018
New Revision: 334252

URL: http://llvm.org/viewvc/llvm-project?rev=334252=rev
Log:
[clang-fuzzer] Made loop_proto more "vectorizable".

Edited loop_proto and its converter to make more "vectorizable" code
according to kcc's comment in D47666
  - Removed all while loops
  - Can only index into array with induction variable

Patch By: emmettneyman

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

Modified:
cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp

Modified: cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto?rev=334252=334251=334252=diff
==
--- cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto (original)
+++ cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto Thu Jun  7 17:33:35 2018
@@ -10,23 +10,14 @@
 /// \file
 ///  This file describes a subset of C++ as a protobuf. It is used to
 ///  more easily find interesting inputs for fuzzing Clang. This subset
-///  extends the one defined in cxx_proto.proto by adding the option that
-///  a VarRef can use the for loop's counter variable.
+///  differs from the one defined in cxx_proto.proto by eliminating while
+///  loops and Lvalues. The goal is that the C++ code generated will be
+///  more likely to stress the LLVM loop vectorizer.
 ///
 
//===--===//
 
-
 syntax = "proto2";
 
-message VarRef {
-  required int32 varnum = 1;
-  required bool is_loop_var = 2;
-}
-
-message Lvalue {
-  required VarRef varref = 1;
-}
-
 message Const {
   required int32 val = 1;
 }
@@ -55,34 +46,25 @@ message BinaryOp {
 
 message Rvalue {
   oneof rvalue_oneof {
-VarRef varref = 1;
-Const cons = 2;
-BinaryOp binop = 3;
+Const cons = 1;
+BinaryOp binop = 2;
   }
 }
 
 message AssignmentStatement {
-  required Lvalue lvalue = 1;
   required Rvalue rvalue = 2;
 }
 
-
 message IfElse {
   required Rvalue cond = 1;
   required StatementSeq if_body = 2;
   required StatementSeq else_body = 3;
 }
 
-message While {
-  required Rvalue cond = 1;
-  required StatementSeq body = 2;
-}
-
 message Statement {
   oneof stmt_oneof {
 AssignmentStatement assignment = 1;
 IfElse  ifelse = 2;
-While   while_loop = 3;
   }
 }
 

Modified: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp?rev=334252=334251=334252=diff
==
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp Thu Jun  7 
17:33:35 2018
@@ -7,10 +7,13 @@
 //
 
//===--===//
 //
-// Implements functions for converting between protobufs and C++. Extends
+// Implements functions for converting between protobufs and C++. Differs from
 // proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
 // loop. Also coutputs a different function signature that includes a
-// size_t parameter for the loop to use.
+// size_t parameter for the loop to use. The C++ code generated is meant to
+// stress the LLVM loop vectorizer.
+//
+// Still a work in progress.
 //
 
//===--===//
 
@@ -33,19 +36,7 @@ std::ostream <<(std::ostream 
 std::ostream <<(std::ostream , const Const ) {
   return os << "(" << x.val() << ")";
 }
-std::ostream <<(std::ostream , const VarRef ) {
-  if (x.is_loop_var()) {
-return os << "a[loop_ctr]";
-  } else {
-return os << "a[" << static_cast(x.varnum()) << " % s]";
-  }
-}
-std::ostream <<(std::ostream , const Lvalue ) {
-  return os << x.varref();
-}
 std::ostream <<(std::ostream , const Rvalue ) {
-  if (x.has_varref())
-return os << x.varref();
   if (x.has_cons())
 return os << x.cons();
   if (x.has_binop())
@@ -101,23 +92,18 @@ std::ostream <<(std::ostream 
   return os << x.right() << ")";
 }
 std::ostream <<(std::ostream , const AssignmentStatement ) {
-  return os << x.lvalue() << "=" << x.rvalue();
+  return os << "a[i]=" << x.rvalue();
 }
 std::ostream <<(std::ostream , const IfElse ) {
   return os << "if (" << x.cond() << "){\n"
 << x.if_body() << "} else { \n"
 << x.else_body() << "}\n";
 }
-std::ostream <<(std::ostream , const While ) {
-  return os << "while (" << x.cond() << "){\n" << x.body() << "}\n";
-}
 std::ostream <<(std::ostream , const Statement ) {
   if (x.has_assignment())
 return os << x.assignment() << ";\n";
   if (x.has_ifelse())
 return os << x.ifelse();
-  if (x.has_while_loop())
-return os 

r334251 - Reapply "[Parse] Use CapturedStmt for @finally on MSVC"

2018-06-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jun  7 17:30:00 2018
New Revision: 334251

URL: http://llvm.org/viewvc/llvm-project?rev=334251=rev
Log:
Reapply "[Parse] Use CapturedStmt for @finally on MSVC"

This reapplies r334224 and adds explicit triples to some tests to fix
them on Windows (where otherwise they would have run with the default
windows-msvc triple, which I'm changing the behavior for).

Original commit message:
The body of a `@finally` needs to be executed on both exceptional and
non-exceptional paths. On landingpad platforms, this is straightforward:
the `@finally` body is emitted as a normal (non-exceptional) cleanup,
and then a catch-all is emitted which branches to that cleanup (the
cleanup has code to conditionally re-throw based on a flag which is set
by the catch-all).

Unfortunately, we can't use the same approach for MSVC exceptions, where
the catch-all will be emitted as a catchpad. We can't just branch to the
cleanup from within the catchpad, since we can only exit it via a
catchret, at which point the exception is destroyed and we can't
rethrow. We could potentially emit the finally body inside the catchpad
and have the normal cleanup path somehow branch into it, but that would
require some new IR construct that could branch into a catchpad.

Instead, after discussing it with Reid Kleckner, we decided that
frontend outlining was the best approach, similar to how SEH `__finally`
works today. We decided to use CapturedStmt (which was also suggested by
Reid) rather than CaptureFinder (which is what `__finally` uses) since
the latter doesn't handle a lot of cases we care about, e.g. self
accesses, property accesses, block captures, etc. Extending
CaptureFinder to handle those additional cases proved unwieldy, whereas
CapturedStmt already took care of all of those.  In theory `__finally`
could also be moved over to CapturedStmt, which would remove some
existing limitations (e.g. the inability to capture this), although
CaptureFinder would still be needed for SEH filters.

The one case supported by `@finally` but not CapturedStmt (or
CaptureFinder for that matter) is arbitrary control flow out of the
`@finally`, e.g. having a return statement inside a `@finally`. We can
add that support as a follow-up, but in practice we've found it to be
used very rarely anyway.

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

Added:
cfe/trunk/test/SemaObjC/finally-msvc.m
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/CapturedStmt.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/Coverage/ast-printing.m
cfe/trunk/test/PCH/objc_stmts.m
cfe/trunk/test/Parser/objc-try-catch-1.m
cfe/trunk/test/Rewriter/rewrite-modern-try-finally.m
cfe/trunk/test/SemaObjC/scope-check.m

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=334251=334250=334251=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun  7 17:30:00 2018
@@ -2133,7 +2133,7 @@ private:
 
   /// The pointer part is the implicit the outlined function and the 
   /// int part is the captured region kind, 'CR_Default' etc.
-  llvm::PointerIntPair CapDeclAndKind;
+  llvm::PointerIntPair CapDeclAndKind;
 
   /// The record for captured variables, a RecordDecl or CXXRecordDecl.
   RecordDecl *TheRecordDecl = nullptr;

Modified: cfe/trunk/include/clang/Basic/CapturedStmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CapturedStmt.h?rev=334251=334250=334251=diff
==
--- cfe/trunk/include/clang/Basic/CapturedStmt.h (original)
+++ cfe/trunk/include/clang/Basic/CapturedStmt.h Thu Jun  7 17:30:00 2018
@@ -16,6 +16,7 @@ namespace clang {
 /// The different kinds of captured statement.
 enum CapturedRegionKind {
   CR_Default,
+  CR_ObjCAtFinally,
   CR_OpenMP
 };
 

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=334251=334250=334251=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Jun  7 17:30:00 2018
@@ -748,6 +748,8 @@ public:
 switch (CapRegionKind) {
 case CR_Default:
   return "default captured statement";
+case CR_ObjCAtFinally:
+  return "Objective-C @finally statement";
 case CR_OpenMP:
   return "OpenMP region";
 }

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=334251=334250=334251=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ 

[PATCH] D47920: Made loop_proto more "vectorizable"

2018-06-07 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.
This revision is now accepted and ready to land.

Looks like a good start.


Repository:
  rC Clang

https://reviews.llvm.org/D47920



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


[PATCH] D47862: [CodeGen] Always use MSVC personality for windows-msvc targets

2018-06-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/CodeGen/CGException.cpp:134-135
   const llvm::Triple  = Target.getTriple();
+  if (T.isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
+

smeenai wrote:
> rnk wrote:
> > I guess previously we carefully arranged to go to whatever the regular objc 
> > personality would be, but we're not doing that now with funclet windows eh.
> > Maybe we could drastically simplify this by checking for an msvc 
> > environment and seh before checking each language?
> I gave this a shot. EHPersonality::get already has code to make SEH functions 
> always get the SEH personality (line 223 below), so I added another condition 
> below to make an MSVC triple always get the MSVC personality, and then 
> removed all those conditionals from the individual get*Personality functions. 
> Unfortunately, there's also code below (in SimplifyPersonality) that calls 
> getCXXPersonality directly, so we still need to leave the MSVC check in 
> there, and having the check in there but not any of the other get*Personality 
> functions seems really ugly. The other option is to adjust 
> SimplifyPersonality instead, which ends up looking like P8086; do you think 
> that's worth it? Or did you mean something else entirely?
That's what I meant, but I see how it ends up inconsistent. Let's go with this.


Repository:
  rC Clang

https://reviews.llvm.org/D47862



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


[PATCH] D47687: fix: [Bug 18971] - Missing -Wparentheses warning

2018-06-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: dexonsmith, chandlerc.
rnk added a comment.

@dexonsmith is there someone from Apple who can comment on rdar://8678458 and 
the merits of disabling this warning in macros? I strongly suspect the original 
report was dealing with code like `assert(x || y && "str");`, if so we can go 
forward with this.

@chandlerc I know you've hit this behavior difference vs. GCC before. Any 
thoughts on the proposed change?


https://reviews.llvm.org/D47687



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


[PATCH] D47920: Made loop_proto more "vectorizable"

2018-06-07 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman created this revision.
emmettneyman added reviewers: kcc, vitalybuka, morehouse.
Herald added a subscriber: cfe-commits.

Edited loop_proto and its converter to make more "vectorizable" code

- Removed all while loops
- Can only index into array with induction variable


Repository:
  rC Clang

https://reviews.llvm.org/D47920

Files:
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp

Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -7,10 +7,13 @@
 //
 //===--===//
 //
-// Implements functions for converting between protobufs and C++. Extends
+// Implements functions for converting between protobufs and C++. Differs from
 // proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
 // loop. Also coutputs a different function signature that includes a
-// size_t parameter for the loop to use.
+// size_t parameter for the loop to use. The C++ code generated is meant to
+// stress the LLVM loop vectorizer.
+//
+// Still a work in progress.
 //
 //===--===//
 
@@ -33,19 +36,7 @@
 std::ostream <<(std::ostream , const Const ) {
   return os << "(" << x.val() << ")";
 }
-std::ostream <<(std::ostream , const VarRef ) {
-  if (x.is_loop_var()) {
-return os << "a[loop_ctr]";
-  } else {
-return os << "a[" << static_cast(x.varnum()) << " % s]";
-  }
-}
-std::ostream <<(std::ostream , const Lvalue ) {
-  return os << x.varref();
-}
 std::ostream <<(std::ostream , const Rvalue ) {
-  if (x.has_varref())
-return os << x.varref();
   if (x.has_cons())
 return os << x.cons();
   if (x.has_binop())
@@ -101,23 +92,18 @@
   return os << x.right() << ")";
 }
 std::ostream <<(std::ostream , const AssignmentStatement ) {
-  return os << x.lvalue() << "=" << x.rvalue();
+  return os << "a[i]=" << x.rvalue();
 }
 std::ostream <<(std::ostream , const IfElse ) {
   return os << "if (" << x.cond() << "){\n"
 << x.if_body() << "} else { \n"
 << x.else_body() << "}\n";
 }
-std::ostream <<(std::ostream , const While ) {
-  return os << "while (" << x.cond() << "){\n" << x.body() << "}\n";
-}
 std::ostream <<(std::ostream , const Statement ) {
   if (x.has_assignment())
 return os << x.assignment() << ";\n";
   if (x.has_ifelse())
 return os << x.ifelse();
-  if (x.has_while_loop())
-return os << x.while_loop();
   return os << "(void)0;\n";
 }
 std::ostream <<(std::ostream , const StatementSeq ) {
@@ -127,7 +113,7 @@
 }
 std::ostream <<(std::ostream , const LoopFunction ) {
   return os << "void foo(int *a, size_t s) {\n"
-<< "for (int loop_ctr = 0; loop_ctr < s; loop_ctr++){\n"
+<< "for (int i=0; i___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47862: [CodeGen] Always use MSVC personality for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: lib/CodeGen/CGException.cpp:134-135
   const llvm::Triple  = Target.getTriple();
+  if (T.isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
+

rnk wrote:
> I guess previously we carefully arranged to go to whatever the regular objc 
> personality would be, but we're not doing that now with funclet windows eh.
> Maybe we could drastically simplify this by checking for an msvc environment 
> and seh before checking each language?
I gave this a shot. EHPersonality::get already has code to make SEH functions 
always get the SEH personality (line 223 below), so I added another condition 
below to make an MSVC triple always get the MSVC personality, and then removed 
all those conditionals from the individual get*Personality functions. 
Unfortunately, there's also code below (in SimplifyPersonality) that calls 
getCXXPersonality directly, so we still need to leave the MSVC check in there, 
and having the check in there but not any of the other get*Personality 
functions seems really ugly. The other option is to adjust SimplifyPersonality 
instead, which ends up looking like P8086; do you think that's worth it? Or did 
you mean something else entirely?


Repository:
  rC Clang

https://reviews.llvm.org/D47862



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


r334249 - [X86] Add builtins for blend with immediate control to enforce target feature requirements and check immediate range.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 17:00:21 2018
New Revision: 334249

URL: http://llvm.org/viewvc/llvm-project?rev=334249=rev
Log:
[X86] Add builtins for blend with immediate control to enforce target feature 
requirements and check immediate range.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/smmintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334249=334248=334249=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun  7 17:00:21 2018
@@ -369,6 +369,9 @@ TARGET_BUILTIN(__builtin_ia32_palignr128
 
 TARGET_BUILTIN(__builtin_ia32_insertps128, "V4fV4fV4fIc", "nc", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_pblendvb128, "V16cV16cV16cV16c", "nc", "sse4.1")
+TARGET_BUILTIN(__builtin_ia32_pblendw128, "V8sV8sV8sIi", "nc", "sse4.1")
+TARGET_BUILTIN(__builtin_ia32_blendpd, "V2dV2dV2dIi", "nc", "sse4.1")
+TARGET_BUILTIN(__builtin_ia32_blendps, "V4fV4fV4fIi", "nc", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_blendvpd, "V2dV2dV2dV2d", "nc", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_blendvps, "V4fV4fV4fV4f", "nc", "sse4.1")
 TARGET_BUILTIN(__builtin_ia32_packusdw128, "V8sV4iV4i", "nc", "sse4.1")
@@ -477,6 +480,8 @@ TARGET_BUILTIN(__builtin_ia32_vpermilvar
 TARGET_BUILTIN(__builtin_ia32_vpermilvarps, "V4fV4fV4i", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_vpermilvarpd256, "V4dV4dV4LLi", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_vpermilvarps256, "V8fV8fV8i", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_blendpd256, "V4dV4dV4dIi", "nc", "avx")
+TARGET_BUILTIN(__builtin_ia32_blendps256, "V8fV8fV8fIi", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_blendvpd256, "V4dV4dV4dV4d", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_blendvps256, "V8fV8fV8fV8f", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_dpps256, "V8fV8fV8fIc", "nc", "avx")
@@ -554,6 +559,7 @@ TARGET_BUILTIN(__builtin_ia32_psubusb256
 TARGET_BUILTIN(__builtin_ia32_psubusw256, "V16sV16sV16s", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_palignr256, "V32cV32cV32cIi", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pblendvb256, "V32cV32cV32cV32c", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pblendw256, "V16sV16sV16sIi", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddw256, "V16sV16sV16s", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddd256, "V8iV8iV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_phaddsw256, "V16sV16sV16s", "nc", "avx2")
@@ -603,6 +609,8 @@ TARGET_BUILTIN(__builtin_ia32_psrldi256,
 TARGET_BUILTIN(__builtin_ia32_psrld256, "V8iV8iV4i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlqi256, "V4LLiV4LLii", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlq256, "V4LLiV4LLiV2LLi", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pblendd128, "V4iV4iV4iIi", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pblendd256, "V8iV8iV8iIi", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permvarsi256, "V8iV8iV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permvarsf256, "V8fV8fV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_permti256, "V4LLiV4LLiV4LLiIc", "nc", "avx2")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334249=334248=334249=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  7 17:00:21 2018
@@ -9235,6 +9235,27 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops[0] = Builder.CreateBitCast(Ops[0], PtrTy);
 return Builder.CreateDefaultAlignedStore(Ops[1], Ops[0]);
   }
+  case X86::BI__builtin_ia32_pblendw128:
+  case X86::BI__builtin_ia32_blendpd:
+  case X86::BI__builtin_ia32_blendps:
+  case X86::BI__builtin_ia32_blendpd256:
+  case X86::BI__builtin_ia32_blendps256:
+  case X86::BI__builtin_ia32_pblendw256:
+  case X86::BI__builtin_ia32_pblendd128:
+  case X86::BI__builtin_ia32_pblendd256: {
+unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
+unsigned Imm = cast(Ops[2])->getZExtValue();
+
+uint32_t Indices[16];
+// If there are more than 8 elements, the immediate is used twice so make
+// sure we handle that.
+for (unsigned i = 0; i != NumElts; ++i)
+  Indices[i] = ((Imm >> (i % 8)) & 0x1) ? NumElts + i : i;
+
+return Builder.CreateShuffleVector(Ops[1], Ops[0],
+   makeArrayRef(Indices, NumElts),
+   "blend");
+  }
   case X86::BI__builtin_ia32_palignr128:
   case X86::BI__builtin_ia32_palignr256:
   case 

r334244 - [X86] Add builtins for shuff32x4/shuff64x2/shufi32x4/shuff64x2 to enable target feature checking and immediate range checking.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 16:03:08 2018
New Revision: 334244

URL: http://llvm.org/viewvc/llvm-project?rev=334244=rev
Log:
[X86] Add builtins for shuff32x4/shuff64x2/shufi32x4/shuff64x2 to enable target 
feature checking and immediate range checking.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334244=334243=334244=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun  7 16:03:08 2018
@@ -1500,6 +1500,14 @@ TARGET_BUILTIN(__builtin_ia32_pternlogq1
 TARGET_BUILTIN(__builtin_ia32_pternlogq128_maskz, "V2LLiV2LLiV2LLiV2LLiIiUc", 
"nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pternlogq256_mask, "V4LLiV4LLiV4LLiV4LLiIiUc", 
"nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pternlogq256_maskz, "V4LLiV4LLiV4LLiV4LLiIiUc", 
"nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_shuf_f32x4, "V16fV16fV16fIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_shuf_f64x2, "V8dV8dV8dIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_shuf_i32x4, "V16iV16iV16iIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_shuf_i64x2, "V8LLiV8LLiV8LLiIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_shuf_f32x4_256, "V8fV8fV8fIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_shuf_f64x2_256, "V4dV4dV4dIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_shuf_i32x4_256, "V8iV8iV8iIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_shuf_i64x2_256, "V4LLiV4LLiV4LLiIi", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_sqrtsd_round_mask, "V2dV2dV2dV2dUcIi", "nc", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_sqrtss_round_mask, "V4fV4fV4fV4fUcIi", "nc", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_rsqrt14pd128_mask, "V2dV2dV2dUc", "nc", 
"avx512vl")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334244=334243=334244=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  7 16:03:08 2018
@@ -9291,6 +9291,35 @@ Value *CodeGenFunction::EmitX86BuiltinEx
makeArrayRef(Indices, NumElts),
"valign");
   }
+  case X86::BI__builtin_ia32_shuf_f32x4_256:
+  case X86::BI__builtin_ia32_shuf_f64x2_256:
+  case X86::BI__builtin_ia32_shuf_i32x4_256:
+  case X86::BI__builtin_ia32_shuf_i64x2_256:
+  case X86::BI__builtin_ia32_shuf_f32x4:
+  case X86::BI__builtin_ia32_shuf_f64x2:
+  case X86::BI__builtin_ia32_shuf_i32x4:
+  case X86::BI__builtin_ia32_shuf_i64x2: {
+unsigned Imm = cast(Ops[2])->getZExtValue();
+llvm::Type *Ty = Ops[0]->getType();
+unsigned NumElts = Ty->getVectorNumElements();
+unsigned NumLanes = Ty->getPrimitiveSizeInBits() == 512 ? 4 : 2;
+unsigned NumLaneElts = NumElts / NumLanes;
+
+uint32_t Indices[16];
+for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
+  unsigned Index = (Imm % NumLanes) * NumLaneElts;
+  Imm /= NumLanes; // Discard the bits we just used.
+  if (l >= (NumElts / 2))
+Index += NumElts; // Switch to other source.
+  for (unsigned i = 0; i != NumLaneElts; ++i) {
+Indices[l + i] = Index + i;
+  }
+}
+
+return Builder.CreateShuffleVector(Ops[0], Ops[1],
+   makeArrayRef(Indices, NumElts),
+   "shuf");
+  }
 
   case X86::BI__builtin_ia32_vperm2f128_pd256:
   case X86::BI__builtin_ia32_vperm2f128_ps256:

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=334244=334243=334244=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jun  7 16:03:08 2018
@@ -6829,24 +6829,8 @@ _mm512_maskz_srai_epi64(__mmask8 __U, __
 }
 
 #define _mm512_shuffle_f32x4(A, B, imm) \
-  (__m512)__builtin_shufflevector((__v16sf)(__m512)(A), \
-  (__v16sf)(__m512)(B), \
-  0 + imm) >> 0) & 0x3) * 4), \
-  1 + imm) >> 0) & 0x3) * 4), \
-  2 + imm) >> 0) & 0x3) * 4), \
-  3 + imm) >> 0) & 0x3) * 4), \
-  0 + imm) >> 2) & 0x3) * 4), \
- 

[PATCH] D47853: [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334243: [Frontend] Disallow non-MSVC exception models for 
windows-msvc targets (authored by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47853

Files:
  cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/personality.c
  cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp
  cfe/trunk/test/CodeGenCXX/personality.cpp
  cfe/trunk/test/CodeGenObjC/personality.m
  cfe/trunk/test/CodeGenObjCXX/personality.mm
  cfe/trunk/test/Frontend/windows-exceptions.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -118,6 +118,8 @@
 "invalid value '%1' in '%0'; alignment must be a power of 2">;
 def err_fe_invalid_wchar_type
 : Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 'int'">;
+def err_fe_invalid_exception_model
+   : Error<"invalid exception model '%0' for target '%1'">;
 
 def warn_fe_serialized_diag_merge_failure : Warning<
 "unable to merge a subprocess's serialized diagnostics">,
Index: cfe/trunk/test/Frontend/windows-exceptions.cpp
===
--- cfe/trunk/test/Frontend/windows-exceptions.cpp
+++ cfe/trunk/test/Frontend/windows-exceptions.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fsyntax-only %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-DWARF %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SEH %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SJLJ %s
+
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-DWARF %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SEH %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SJLJ %s
+
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fdwarf-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fseh-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fdwarf-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fseh-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+
+// MSVC-X86-DWARF: error: invalid exception model 'fdwarf-exceptions' for target 'i686--windows-msvc'
+// MSVC-X86-SEH: error: invalid exception model 'fseh-exceptions' for target 'i686--windows-msvc'
+// MSVC-X86-SJLJ: error: invalid exception model 'fsjlj-exceptions' for target 'i686--windows-msvc'
+
+// MSVC-X64-DWARF: error: invalid exception model 'fdwarf-exceptions' for target 'x86_64--windows-msvc'
+// MSVC-X64-SEH: error: invalid exception model 'fseh-exceptions' for target 'x86_64--windows-msvc'
+// MSVC-X64-SJLJ: error: invalid exception model 'fsjlj-exceptions' for target 'x86_64--windows-msvc'
Index: cfe/trunk/test/CodeGen/personality.c
===
--- cfe/trunk/test/CodeGen/personality.c
+++ cfe/trunk/test/CodeGen/personality.c
@@ -4,13 +4,13 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fsjlj-exceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-SJLJ
 
 // RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fdwarf-exceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-DWARF
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -D __SEH_EXCEPTIONS__ -fms-extensions -fexceptions -fblocks -fseh-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-SEH -check-prefix CHECK-WIN-SEH-X86
-// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -D __SEH_EXCEPTIONS__ -fms-extensions -fexceptions -fblocks -fseh-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-SEH -check-prefix CHECK-WIN-SEH-X64
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fblocks 

r334243 - [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jun  7 15:54:54 2018
New Revision: 334243

URL: http://llvm.org/viewvc/llvm-project?rev=334243=rev
Log:
[Frontend] Disallow non-MSVC exception models for windows-msvc targets

The windows-msvc target is used for MSVC ABI compatibility, including
the exceptions model. It doesn't make sense to pair a windows-msvc
target with a non-MSVC exception model. This would previously cause an
assertion failure; explicitly error out for it in the frontend instead.
This also allows us to reduce the matrix of target/exception models a
bit (see the modified tests), and we can possibly simplify some of the
personality code in a follow-up.

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

Added:
cfe/trunk/test/Frontend/windows-exceptions.cpp
Removed:
cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/personality.c
cfe/trunk/test/CodeGenCXX/personality.cpp
cfe/trunk/test/CodeGenObjC/personality.m
cfe/trunk/test/CodeGenObjCXX/personality.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=334243=334242=334243=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Jun  7 
15:54:54 2018
@@ -118,6 +118,8 @@ def err_fe_invalid_alignment : Error<
 "invalid value '%1' in '%0'; alignment must be a power of 2">;
 def err_fe_invalid_wchar_type
 : Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 
'int'">;
+def err_fe_invalid_exception_model
+   : Error<"invalid exception model '%0' for target '%1'">;
 
 def warn_fe_serialized_diag_merge_failure : Warning<
 "unable to merge a subprocess's serialized diagnostics">,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=334243=334242=334243=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun  7 15:54:54 2018
@@ -2344,6 +2344,11 @@ static void ParseLangArgs(LangOptions 
options::OPT_fdwarf_exceptions);
   if (A) {
 const Option  = A->getOption();
+llvm::Triple T(TargetOpts.Triple);
+if (T.isWindowsMSVCEnvironment())
+  Diags.Report(diag::err_fe_invalid_exception_model)
+  << Opt.getName() << T.str();
+
 Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
 Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
 Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);

Modified: cfe/trunk/test/CodeGen/personality.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/personality.c?rev=334243=334242=334243=diff
==
--- cfe/trunk/test/CodeGen/personality.c (original)
+++ cfe/trunk/test/CodeGen/personality.c Thu Jun  7 15:54:54 2018
@@ -4,13 +4,13 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions 
-fsjlj-exceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s -check-prefix 
CHECK-SJLJ
 
 // RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fblocks -S 
-emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions 
-fdwarf-exceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s -check-prefix 
CHECK-WIN-DWARF
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fblocks -fseh-exceptions -S -emit-llvm %s -o - | 
FileCheck %s -check-prefix CHECK-WIN-SEH -check-prefix CHECK-WIN-SEH-X86
-// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fblocks -fseh-exceptions -S -emit-llvm %s -o - | 
FileCheck %s -check-prefix CHECK-WIN-SEH -check-prefix CHECK-WIN-SEH-X64
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fblocks 
-fsjlj-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix 
CHECK-WIN-SJLJ
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-WIN-SEH-X86
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fblocks -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-WIN-SEH-X64
 
-// RUN: %clang_cc1 -triple i686-unknown-windows-gnu -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fblocks -fseh-exceptions -S -emit-llvm %s -o - | 
FileCheck %s -check-prefix 

[PATCH] D47862: [CodeGen] Always use MSVC personality for windows-msvc targets

2018-06-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/CGException.cpp:134-135
   const llvm::Triple  = Target.getTriple();
+  if (T.isWindowsMSVCEnvironment())
+return EHPersonality::MSVC_CxxFrameHandler3;
+

I guess previously we carefully arranged to go to whatever the regular objc 
personality would be, but we're not doing that now with funclet windows eh.
Maybe we could drastically simplify this by checking for an msvc environment 
and seh before checking each language?


Repository:
  rC Clang

https://reviews.llvm.org/D47862



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


[PATCH] D47853: [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D47853



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


[PATCH] D47912: [CMake] Consider LLVM_APPEND_VC_REV when generating SVNVersion.inc

2018-06-07 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added a comment.

In https://reviews.llvm.org/D47912#1125803, @smeenai wrote:

> I believe LLVM_APPEND_VC_REV controls whether the revision is appended to 
> LLVM version string (e.g. the output of `llvm-config --version`), whereas the 
> SVNRevision.inc file (which is what's causing the relink after amending) is 
> used for e.g. the `clang --version` output, so I'm not sure this is the right 
> thing to do. I would also love for an option to disable the SVNRevision stuff 
> entirely though.


Right, that is why I added the word "quickfix".
Perhaps we can add a `CLANG_APPEND_VC_REV` CMake option?


Repository:
  rC Clang

https://reviews.llvm.org/D47912



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


[PATCH] D44788: Add an option to support debug fission on implicit ThinLTO.

2018-06-07 Thread Yunlian Jiang via Phabricator via cfe-commits
yunlian updated this revision to Diff 150419.
yunlian added a comment.

Makes the default value to  /path/to/binary_dwo, when DWO_DIR is provided, make 
the path to DWO_DIR/path/to/binary_dwo


https://reviews.llvm.org/D44788

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/lto-dwo.c


Index: test/Driver/lto-dwo.c
===
--- /dev/null
+++ test/Driver/lto-dwo.c
@@ -0,0 +1,12 @@
+// Confirm that -gsplit-dwarf=DIR is passed to linker
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin 
-gsplit-dwarf=DIR -o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR{{.*}}a.out_dwo"
+//
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf 
-o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+//
+// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -416,6 +416,23 @@
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+StringRef Dwo_Dir = A->getValue();
+SmallString<1024> DwoDir;
+llvm::sys::path::native(Dwo_Dir, DwoDir);
+llvm::sys::path::append(DwoDir, Twine(Output.getFilename()) + "_dwo");
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DwoDir));
+  }
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf)) {
+if (!Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") +
+  Output.getFilename() + "_dwo"));
+}
+  }
+
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1781,6 +1781,7 @@
 def gcolumn_info : Flag<["-"], "gcolumn-info">, Group, 
Flags<[CoreOption]>;
 def gno_column_info : Flag<["-"], "gno-column-info">, Group, 
Flags<[CoreOption]>;
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
+def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, 
Flags<[CC1Option]>;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
 def gmodules : Flag <["-"], "gmodules">, Group,


Index: test/Driver/lto-dwo.c
===
--- /dev/null
+++ test/Driver/lto-dwo.c
@@ -0,0 +1,12 @@
+// Confirm that -gsplit-dwarf=DIR is passed to linker
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf=DIR -o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s
+//
+// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR{{.*}}a.out_dwo"
+//
+
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -gsplit-dwarf -o a.out 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR-DEFAULT < %t %s
+//
+// CHECK-LINK-DWO-DIR-DEFAULT: "-plugin-opt=dwo_dir=a.out_dwo"
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -416,6 +416,23 @@
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+StringRef Dwo_Dir = A->getValue();
+SmallString<1024> DwoDir;
+llvm::sys::path::native(Dwo_Dir, DwoDir);
+llvm::sys::path::append(DwoDir, Twine(Output.getFilename()) + "_dwo");
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DwoDir));
+  }
+
+  if (Args.hasArg(options::OPT_gsplit_dwarf)) {
+if (!Args.getLastArg(options::OPT_gsplit_dwarf_EQ)) {
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") +
+  Output.getFilename() + "_dwo"));
+}
+  }
+
   if (IsThinLTO)
 CmdArgs.push_back("-plugin-opt=thinlto");
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1781,6 +1781,7 @@
 def gcolumn_info : Flag<["-"], "gcolumn-info">, Group, Flags<[CoreOption]>;
 def gno_column_info : Flag<["-"], "gno-column-info">, Group, Flags<[CoreOption]>;
 def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
+def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group;
 def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, Flags<[CC1Option]>;
 def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group;
 def gmodules : Flag <["-"], "gmodules">, Group,

[PATCH] D47912: [CMake] Consider LLVM_APPEND_VC_REV when generating SVNVersion.inc

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I believe LLVM_APPEND_VC_REV controls whether the revision is appended to LLVM 
version string (e.g. the output of `llvm-config --version`), whereas the 
SVNRevision.inc file (which is what's causing the relink after amending) is 
used for e.g. the `clang --version` output, so I'm not sure this is the right 
thing to do. I would also love for an option to disable the SVNRevision stuff 
entirely though.


Repository:
  rC Clang

https://reviews.llvm.org/D47912



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


r334240 - Revert "[Parse] Use CapturedStmt for @finally on MSVC"

2018-06-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jun  7 15:24:20 2018
New Revision: 334240

URL: http://llvm.org/viewvc/llvm-project?rev=334240=rev
Log:
Revert "[Parse] Use CapturedStmt for @finally on MSVC"

This reverts commit r334224.

This is causing buildbot failures on Windows, presumably because some
tests don't specify a triple. I'll test this on Windows locally and
recommit with the tests fixed.

Removed:
cfe/trunk/test/SemaObjC/finally-msvc.m
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/CapturedStmt.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=334240=334239=334240=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun  7 15:24:20 2018
@@ -2133,7 +2133,7 @@ private:
 
   /// The pointer part is the implicit the outlined function and the 
   /// int part is the captured region kind, 'CR_Default' etc.
-  llvm::PointerIntPair CapDeclAndKind;
+  llvm::PointerIntPair CapDeclAndKind;
 
   /// The record for captured variables, a RecordDecl or CXXRecordDecl.
   RecordDecl *TheRecordDecl = nullptr;

Modified: cfe/trunk/include/clang/Basic/CapturedStmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CapturedStmt.h?rev=334240=334239=334240=diff
==
--- cfe/trunk/include/clang/Basic/CapturedStmt.h (original)
+++ cfe/trunk/include/clang/Basic/CapturedStmt.h Thu Jun  7 15:24:20 2018
@@ -16,7 +16,6 @@ namespace clang {
 /// The different kinds of captured statement.
 enum CapturedRegionKind {
   CR_Default,
-  CR_ObjCAtFinally,
   CR_OpenMP
 };
 

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=334240=334239=334240=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Jun  7 15:24:20 2018
@@ -748,8 +748,6 @@ public:
 switch (CapRegionKind) {
 case CR_Default:
   return "default captured statement";
-case CR_ObjCAtFinally:
-  return "Objective-C @finally statement";
 case CR_OpenMP:
   return "OpenMP region";
 }

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=334240=334239=334240=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jun  7 15:24:20 2018
@@ -2585,26 +2585,13 @@ StmtResult Parser::ParseObjCTryStmt(Sour
   ParseScope FinallyScope(this,
   Scope::DeclScope | Scope::CompoundStmtScope);
 
-  bool ShouldCapture =
-  getTargetInfo().getTriple().isWindowsMSVCEnvironment();
-  if (ShouldCapture)
-Actions.ActOnCapturedRegionStart(Tok.getLocation(), getCurScope(),
- CR_ObjCAtFinally, 1);
-
   StmtResult FinallyBody(true);
   if (Tok.is(tok::l_brace))
 FinallyBody = ParseCompoundStatementBody();
   else
 Diag(Tok, diag::err_expected) << tok::l_brace;
-
-  if (FinallyBody.isInvalid()) {
+  if (FinallyBody.isInvalid())
 FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
-if (ShouldCapture)
-  Actions.ActOnCapturedRegionError();
-  } else if (ShouldCapture) {
-FinallyBody = Actions.ActOnCapturedRegionEnd(FinallyBody.get());
-  }
-
   FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
FinallyBody.get());
   catch_or_finally_seen = true;

Removed: cfe/trunk/test/SemaObjC/finally-msvc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/finally-msvc.m?rev=334239=auto
==
--- cfe/trunk/test/SemaObjC/finally-msvc.m (original)
+++ cfe/trunk/test/SemaObjC/finally-msvc.m (removed)
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -triple i686--windows-msvc -fexceptions -fobjc-exceptions 
-ast-dump %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64--windows-msvc -fexceptions -fobjc-exceptions 
-ast-dump %s 2>&1 | FileCheck %s
-
-void f() {
-  @try {
-  } @finally {
-  }
-}
-
-// CHECK:  ObjCAtFinallyStmt
-// CHECK-NEXT:   CapturedStmt
-// CHECK-NEXT: CapturedDecl
-// CHECK-NEXT:   CompoundStmt
-// CHECK-NEXT:   ImplicitParamDecl


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


[PATCH] D47912: [CMake] Consider LLVM_APPEND_VC_REV when generating SVNVersion.inc

2018-06-07 Thread Gabor Buella via Phabricator via cfe-commits
GBuella created this revision.
GBuella added reviewers: beanz, bogner, hintonda.
Herald added subscribers: cfe-commits, mgorny.

This is merely a quickfix, due to being fustrated with waiting
for ~70 objects to be linked each time following `git commit --amend`.
When toggling LLVM_APPEND_VC_REV between ON and OFF, the
version inc file is still updated. Still, this is arguable
an improvement.


Repository:
  rC Clang

https://reviews.llvm.org/D47912

Files:
  lib/Basic/CMakeLists.txt


Index: lib/Basic/CMakeLists.txt
===
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -12,7 +12,7 @@
 
 set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake")
 
-if(DEFINED llvm_vc AND DEFINED clang_vc)
+if(DEFINED llvm_vc AND DEFINED clang_vc AND LLVM_APPEND_VC_REV)
   # Create custom target to generate the VC revision include.
   add_custom_command(OUTPUT "${version_inc}"
 DEPENDS "${llvm_vc}" "${clang_vc}" "${get_svn_script}"


Index: lib/Basic/CMakeLists.txt
===
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -12,7 +12,7 @@
 
 set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake")
 
-if(DEFINED llvm_vc AND DEFINED clang_vc)
+if(DEFINED llvm_vc AND DEFINED clang_vc AND LLVM_APPEND_VC_REV)
   # Create custom target to generate the VC revision include.
   add_custom_command(OUTPUT "${version_inc}"
 DEPENDS "${llvm_vc}" "${clang_vc}" "${get_svn_script}"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

For potential transforms based on nonnull, see https://reviews.llvm.org/D36656, 
I think?


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In https://reviews.llvm.org/D47894#1125653, @efriedma wrote:

> The problem would come from propagating nonnull-ness from something which 
> isn't inherently nonnull.  For example, strlen has a nonnull argument, so 
> `strlen(NULL)` is UB, therefore given `int z = strlen(x); if (x) {...}`, we 
> can remove the null check.  (Not sure we actually do this transform at the 
> moment, but it's something we could do in the future.)


This is interesting. Extra pass for such transformation? or any better place 
for it?


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


[PATCH] D47666: Refactored clang-fuzzer and added new (copy) files

2018-06-07 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Some feedback on the generated code:

  while (1){

let's not have the while loops inside the for loops for now. 
If the initial goal is to stress the loop optimizations (e.g. vectorizer), 
loops likes this are just a distraction

  for (int loop_ctr = 0

too verbose. Use 'i'm 'j', 'k'
also, alternate int, unsigned, size_t, long (later).

  a[436863498 % s]=1;

this is good for keeping the code UB-free, but it will render the tests 
non-vectorizable. 
need more tests that won't use `% s`

  void foo(int *a, size_t s) {

ok for a starter, but will need a more rich signature in the future versions.


Repository:
  rL LLVM

https://reviews.llvm.org/D47666



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


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

In https://reviews.llvm.org/D47894#1125653, @efriedma wrote:

> The problem would come from propagating nonnull-ness from something which 
> isn't inherently nonnull.  For example, strlen has a nonnull argument, so 
> `strlen(NULL)` is UB, therefore given `int z = strlen(x); if (x) {...}`, we 
> can remove the null check.  (Not sure we actually do this transform at the 
> moment, but it's something we could do in the future.)


I think the question there is actually whether we need to, in addition to 
supporting null pointer dereference, also cause all __attribute__((nonnull)) 
annotations at the C/C++ level to be ignored.

And, yes, I believe we should.


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


[PATCH] D46922: [checks/property-decls] Fix comment in clang-tidy/objc/PropertyDeclarationCheck.cpp ✍️

2018-06-07 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

In https://reviews.llvm.org/D46922#1125689, @benhamilton wrote:

> > Is it possible to get someone to land this for me? I don't believe I have 
> > access to land it myself.
>
> Done.


Thank you, kind sir 


Repository:
  rL LLVM

https://reviews.llvm.org/D46922



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


Re: r333978 - Reimplement the bittest intrinsic family as builtins with inline asm

2018-06-07 Thread Reid Kleckner via cfe-commits
This should be fixed now with r334239. In for a penny, in for a pound.

On Wed, Jun 6, 2018 at 6:09 PM Grang, Mandeep Singh 
wrote:

> @rnk I tried building spec2000/eon for Windows ARM64 and ran into these
> errors:
>
> use of undeclared identifier '_interlockedbittestandset_acq'
> use of undeclared identifier '_interlockedbittestandset_rel'
> use of undeclared identifier '_interlockedbittestandset_nf'
>
> I see that you have removed them in your patch. Apparently they are needed
> (at least for ARM64 Win).
>
> --Mandeep
>
> On 6/5/2018 11:01 AM, Reid Kleckner via cfe-commits wrote:
>
> On Tue, Jun 5, 2018 at 2:33 AM Martin Storsjö  wrote:
>
>> > // Many of MSVC builtins are on both x64 and ARM; to avoid repeating
>> code, we
>> > // handle them here.
>>
>> This doesn't seem thought through wrt non-x86 architectures. I'm not sure
>> if there's any similar suitable instruction to use on ARM/AArch64, but we
>> should at the very least fall back to doing whatever we did before this
>> change for anything not x86.
>>
>
>  I'll go back and take a look, but I'm not convinced that what we did
> before was correct for ARM either. I'm installing the Visual C++ aarch64
> compiler now so I can make sure we get it right.
>
>
> ___
> cfe-commits mailing 
> listcfe-comm...@lists.llvm.orghttp://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] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

For the kernel, specifically, strlen() isn't an issue because it builds with 
-fno-builtin, but the kernel uses explicit nonnull attributes in a few places.  
But I guess we can assume they know what they're doing if nonnull is explicitly 
specified. 
 We probably want to call this out in the users manual, though.

We add nonnull attributes to the LLVM IR in a few other places which don't 
involve the C nonnull attribute: we assume C++ references are always non-null, 
and we use the "static" array modifier to assume arrays are non-null.  We 
probably shouldn't add those attributes if fno-delete-null-pointer-checks is 
specified.


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


r334239 - [MS] Re-add support for the ARM interlocked bittest intrinscs

2018-06-07 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Jun  7 14:39:04 2018
New Revision: 334239

URL: http://llvm.org/viewvc/llvm-project?rev=334239=rev
Log:
[MS] Re-add support for the ARM interlocked bittest intrinscs

Adds support for these intrinsics, which are ARM and ARM64 only:
  _interlockedbittestandreset_acq
  _interlockedbittestandreset_rel
  _interlockedbittestandreset_nf
  _interlockedbittestandset_acq
  _interlockedbittestandset_rel
  _interlockedbittestandset_nf

Refactor the bittest intrinsic handling to decompose each intrinsic into
its action, its width, and its atomicity.

Added:
cfe/trunk/test/Sema/bittest-intrinsics.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/bittest-intrin.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=334239=334238=334239=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Thu Jun  7 14:39:04 2018
@@ -791,10 +791,16 @@ LANGBUILTIN(_InterlockedOr,   "NiNiD*Ni"
 LANGBUILTIN(_InterlockedXor8,  "ccD*c",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor16, "ssD*s",   "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedXor,   "NiNiD*Ni","n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_interlockedbittestandreset,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_interlockedbittestandreset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_interlockedbittestandset,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset64,   "UcWiD*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset_acq, "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset_nf,  "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandreset_rel, "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset_acq,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset_nf,"UcNiD*Ni", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_interlockedbittestandset_rel,   "UcNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__noop,   "i.",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES)
 LANGBUILTIN(__popcnt,   "UiUi", "nc", ALL_MS_LANGUAGES)

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=334239=334238=334239=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun  7 14:39:04 
2018
@@ -8154,6 +8154,8 @@ def err_x86_builtin_invalid_rounding : E
   "invalid rounding argument">;
 def err_x86_builtin_invalid_scale : Error<
   "scale argument must be 1, 2, 4, or 8">;
+def err_builtin_target_unsupported : Error<
+  "builtin is not supported on this target">;
 
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334239=334238=334239=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  7 14:39:04 2018
@@ -484,58 +484,99 @@ CodeGenFunction::emitBuiltinObjectSize(c
   return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown});
 }
 
-// Get properties of an X86 BT* assembly instruction. The first returned value
-// is the action character code, which can be for complement, reset, or set. 
The
-// second is the size suffix which our assembler needs. The last is whether to
-// add the lock prefix.
-static std::tuple
-getBitTestActionSizeAndLocking(unsigned BuiltinID) {
+namespace {
+/// A struct to generically desribe a bit test intrinsic.
+struct BitTest {
+  enum ActionKind : uint8_t { TestOnly, Complement, Reset, Set };
+  enum InterlockingKind : uint8_t {
+Unlocked,
+Sequential,
+Acquire,
+Release,
+NoFence
+  };
+
+  ActionKind Action;
+  InterlockingKind Interlocking;
+  bool Is64Bit;
+
+  static BitTest decodeBitTestBuiltin(unsigned BuiltinID);
+};
+} // namespace
+
+BitTest BitTest::decodeBitTestBuiltin(unsigned BuiltinID) {
   switch (BuiltinID) {
+

[PATCH] D46922: [checks/property-decls] Fix comment in clang-tidy/objc/PropertyDeclarationCheck.cpp ✍️

2018-06-07 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334238: [checks/property-decls] Fix comment in 
clang-tidy/objc/PropertyDeclarationCheck. (authored by benhamilton, committed 
by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46922?vs=146981=150409#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46922

Files:
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp


Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -34,7 +34,7 @@
   CategoryProperty = 2,
 };
 
-/// The acronyms are from
+/// The acronyms are aggregated from multiple sources including
 /// 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
 ///
 /// Keep this list sorted.


Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -34,7 +34,7 @@
   CategoryProperty = 2,
 };
 
-/// The acronyms are from
+/// The acronyms are aggregated from multiple sources including
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
 ///
 /// Keep this list sorted.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46922: [checks/property-decls] Fix comment in clang-tidy/objc/PropertyDeclarationCheck.cpp ✍️

2018-06-07 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

> Is it possible to get someone to land this for me? I don't believe I have 
> access to land it myself.

Done.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46922



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


r334237 - [X86] Add builtins for VALIGNQ/VALIGND to enable proper target feature checking.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 14:27:41 2018
New Revision: 334237

URL: http://llvm.org/viewvc/llvm-project?rev=334237=rev
Log:
[X86] Add builtins for VALIGNQ/VALIGND to enable proper target feature checking.

We still emit shufflevector instructions we just do it from CGBuiltin.cpp now. 
This ensures the intrinsics that use this are only available on CPUs that 
support the feature.

I also added range checking to the immediate, but only checked it is 8 bits or 
smaller. We should maybe be stricter since we never use all 8 bits, but gcc 
doesn't seem to do that.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334237=334236=334237=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun  7 14:27:41 2018
@@ -909,6 +909,12 @@ TARGET_BUILTIN(__builtin_ia32_storeupd51
 TARGET_BUILTIN(__builtin_ia32_storeapd512_mask, "vV8d*V8dUc", "n", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeups512_mask, "vf*V16fUs", "n", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeaps512_mask, "vV16f*V16fUs", "n", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_alignq512, "V8LLiV8LLiV8LLiIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_alignd512, "V16iV16iV16iIi", "nc", "avx512f")
+TARGET_BUILTIN(__builtin_ia32_alignd128, "V4iV4iV4iIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_alignd256, "V8iV8iV8iIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_alignq128, "V2LLiV2LLiV2LLiIi", "nc", "avx512vl")
+TARGET_BUILTIN(__builtin_ia32_alignq256, "V4LLiV4LLiV4LLiIi", "nc", "avx512vl")
 
 TARGET_BUILTIN(__builtin_ia32_vpdpbusd128, "V4iV4iV4iV4i", "nc", 
"avx512vl,avx512vnni")
 TARGET_BUILTIN(__builtin_ia32_vpdpbusd256, "V8iV8iV8iV8i", "nc", 
"avx512vl,avx512vnni")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334237=334236=334237=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  7 14:27:41 2018
@@ -9222,6 +9222,26 @@ Value *CodeGenFunction::EmitX86BuiltinEx
makeArrayRef(Indices, NumElts),
"palignr");
   }
+  case X86::BI__builtin_ia32_alignd128:
+  case X86::BI__builtin_ia32_alignd256:
+  case X86::BI__builtin_ia32_alignd512:
+  case X86::BI__builtin_ia32_alignq128:
+  case X86::BI__builtin_ia32_alignq256:
+  case X86::BI__builtin_ia32_alignq512: {
+unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
+unsigned ShiftVal = cast(Ops[2])->getZExtValue();
+
+// Mask the shift amount to width of two vectors.
+ShiftVal &= (2 * NumElts) - 1;
+
+uint32_t Indices[16];
+for (unsigned i = 0; i != NumElts; ++i)
+  Indices[i] = i + ShiftVal;
+
+return Builder.CreateShuffleVector(Ops[1], Ops[0],
+   makeArrayRef(Indices, NumElts),
+   "valign");
+  }
 
   case X86::BI__builtin_ia32_vperm2f128_pd256:
   case X86::BI__builtin_ia32_vperm2f128_ps256:

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=334237=334236=334237=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Thu Jun  7 14:27:41 2018
@@ -3465,16 +3465,8 @@ _mm512_maskz_permutex2var_epi64(__mmask8
 }
 
 #define _mm512_alignr_epi64(A, B, I) \
-  (__m512i)__builtin_shufflevector((__v8di)(__m512i)(B), \
-   (__v8di)(__m512i)(A), \
-   ((int)(I) & 0x7) + 0, \
-   ((int)(I) & 0x7) + 1, \
-   ((int)(I) & 0x7) + 2, \
-   ((int)(I) & 0x7) + 3, \
-   ((int)(I) & 0x7) + 4, \
-   ((int)(I) & 0x7) + 5, \
-   ((int)(I) & 0x7) + 6, \
-   ((int)(I) & 0x7) + 7)
+  (__m512i)__builtin_ia32_alignq512((__v8di)(__m512i)(A), \
+(__v8di)(__m512i)(B), (int)(I))
 
 #define _mm512_mask_alignr_epi64(W, U, A, B, imm) \
   (__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \
@@ -3487,24 +3479,8 @@ _mm512_maskz_permutex2var_epi64(__mmask8
  (__v8di)_mm512_setzero_si512())
 
 #define 

[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The problem would come from propagating nonnull-ness from something which isn't 
inherently nonnull.  For example, strlen has a nonnull argument, so 
`strlen(NULL)` is UB, therefore given `int z = strlen(x); if (x) {...}`, we can 
remove the null check.  (Not sure we actually do this transform at the moment, 
but it's something we could do in the future.)


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In https://reviews.llvm.org/D47894#1125406, @efriedma wrote:

> Does IR generation need any special handling for this?  We add nonnull 
> attributes in various places.


My interpretation is adding nonnull attributes is fine as long is it is not 
derived from a pointer dereference. 
E.g. addresses from alloca can be treated non-null.


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


[PATCH] D46922: [checks/property-decls] Fix comment in clang-tidy/objc/PropertyDeclarationCheck.cpp ✍️

2018-06-07 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

Is it possible to get someone to land this for me? I don't believe I have 
access to land it myself.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46922



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


[PATCH] D47906: [ThinLTO] Add testing of summary index parsing to a couple CFI tests

2018-06-07 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: pcc, dexonsmith, mehdi_amini.
Herald added subscribers: steven_wu, eraman, inglorion.

Changes to some clang side tests to go with the summary parsing patch.

Depends on https://reviews.llvm.org/D47905.


Repository:
  rC Clang

https://reviews.llvm.org/D47906

Files:
  test/CodeGen/thinlto-distributed-cfi-devirt.ll
  test/CodeGen/thinlto-distributed-cfi.ll


Index: test/CodeGen/thinlto-distributed-cfi.ll
===
--- test/CodeGen/thinlto-distributed-cfi.ll
+++ test/CodeGen/thinlto-distributed-cfi.ll
@@ -21,6 +21,8 @@
 ; CHECK-LABEL: Index: test/CodeGen/thinlto-distributed-cfi.ll
===
--- test/CodeGen/thinlto-distributed-cfi.ll
+++ test/CodeGen/thinlto-distributed-cfi.ll
@@ -21,6 +21,8 @@
 ; CHECK-LABEL: ___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] r334227 - r600/fmax: Flush denormals before calling builtin.

2018-06-07 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun  7 13:27:56 2018
New Revision: 334227

URL: http://llvm.org/viewvc/llvm-project?rev=334227=rev
Log:
r600/fmax: Flush denormals before calling builtin.

Same reason as amdgcn.
Fixes fmax, maxmag CTS on turks.
Reviewer: Tom Stellard 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/r600/lib/math/fmax.cl
Modified:
libclc/trunk/r600/lib/SOURCES

Modified: libclc/trunk/r600/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=334227=334226=334227=diff
==
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Thu Jun  7 13:27:56 2018
@@ -1,3 +1,4 @@
+math/fmax.cl
 synchronization/barrier_impl.ll
 workitem/get_global_offset.cl
 workitem/get_group_id.cl

Added: libclc/trunk/r600/lib/math/fmax.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/math/fmax.cl?rev=334227=auto
==
--- libclc/trunk/r600/lib/math/fmax.cl (added)
+++ libclc/trunk/r600/lib/math/fmax.cl Thu Jun  7 13:27:56 2018
@@ -0,0 +1,29 @@
+#include 
+
+#include "../../../generic/lib/clcmacro.h"
+#include "../../../generic/lib/math/math.h"
+
+_CLC_DEF _CLC_OVERLOAD float fmax(float x, float y)
+{
+   /* Flush denormals if not enabled. Otherwise fmax instruction flushes
+* the values for comparison, but outputs original denormal */
+   x = __clc_flush_denormal_if_not_supported(x);
+   y = __clc_flush_denormal_if_not_supported(y);
+   return __builtin_fmaxf(x, y);
+}
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, fmax, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEF _CLC_OVERLOAD double fmax(double x, double y)
+{
+   return __builtin_fmax(x, y);
+}
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmax, double, double)
+
+#endif
+
+#define __CLC_BODY <../../../generic/lib/math/fmax.inc>
+#include 


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


[libclc] r334228 - r600/fmin: Flush denormals before calling builtin.

2018-06-07 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun  7 13:27:58 2018
New Revision: 334228

URL: http://llvm.org/viewvc/llvm-project?rev=334228=rev
Log:
r600/fmin: Flush denormals before calling builtin.

Same reason as amdgcn.
Fixes fmin, minmag CTS on turks.
Reviewer: Tom Stellard 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/r600/lib/math/fmin.cl
Modified:
libclc/trunk/r600/lib/SOURCES

Modified: libclc/trunk/r600/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=334228=334227=334228=diff
==
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Thu Jun  7 13:27:58 2018
@@ -1,4 +1,5 @@
 math/fmax.cl
+math/fmin.cl
 synchronization/barrier_impl.ll
 workitem/get_global_offset.cl
 workitem/get_group_id.cl

Added: libclc/trunk/r600/lib/math/fmin.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/math/fmin.cl?rev=334228=auto
==
--- libclc/trunk/r600/lib/math/fmin.cl (added)
+++ libclc/trunk/r600/lib/math/fmin.cl Thu Jun  7 13:27:58 2018
@@ -0,0 +1,30 @@
+#include 
+
+#include "../../../generic/lib/clcmacro.h"
+#include "../../../generic/lib/math/math.h"
+
+_CLC_DEF _CLC_OVERLOAD float fmin(float x, float y)
+{
+   /* fcanonicalize removes sNaNs and flushes denormals if not enabled.
+* Otherwise fmin instruction flushes the values for comparison,
+* but outputs original denormal */
+   x = __clc_flush_denormal_if_not_supported(x);
+   y = __clc_flush_denormal_if_not_supported(y);
+   return __builtin_fminf(x, y);
+}
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, fmin, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEF _CLC_OVERLOAD double fmin(double x, double y)
+{
+   return __builtin_fmin(x, y);
+}
+_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmin, double, double)
+
+#endif
+
+#define __CLC_BODY <../../../generic/lib/math/fmin.inc>
+#include 


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


[libclc] r334226 - math/fma: Add fp32 software implementation

2018-06-07 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Thu Jun  7 13:27:43 2018
New Revision: 334226

URL: http://llvm.org/viewvc/llvm-project?rev=334226=rev
Log:
math/fma: Add fp32 software implementation

Passes CTS on carrizo (when forced to use sw fma) and turks.
Reviewer: Tom Stellard 
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/include/clc/math/ternary_decl.inc
libclc/trunk/generic/include/math/clc_fma.h
libclc/trunk/generic/lib/math/clc_fma.cl
libclc/trunk/generic/lib/math/fma.cl
libclc/trunk/generic/lib/math/fma.inc
Modified:
libclc/trunk/generic/include/clc/math/fma.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/generic/include/clc/math/fma.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fma.h?rev=334226=334225=334226=diff
==
--- libclc/trunk/generic/include/clc/math/fma.h (original)
+++ libclc/trunk/generic/include/clc/math/fma.h Thu Jun  7 13:27:43 2018
@@ -1,6 +1,7 @@
-#undef fma
-#define fma __clc_fma
+#define __CLC_BODY 
+#define __CLC_FUNCTION fma
 
-#define __CLC_FUNCTION __clc_fma
-#define __CLC_INTRINSIC "llvm.fma"
-#include 
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION

Added: libclc/trunk/generic/include/clc/math/ternary_decl.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/ternary_decl.inc?rev=334226=auto
==
--- libclc/trunk/generic/include/clc/math/ternary_decl.inc (added)
+++ libclc/trunk/generic/include/clc/math/ternary_decl.inc Thu Jun  7 13:27:43 
2018
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE a, 
__CLC_GENTYPE b, __CLC_GENTYPE c);

Added: libclc/trunk/generic/include/math/clc_fma.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/clc_fma.h?rev=334226=auto
==
--- libclc/trunk/generic/include/math/clc_fma.h (added)
+++ libclc/trunk/generic/include/math/clc_fma.h Thu Jun  7 13:27:43 2018
@@ -0,0 +1,11 @@
+#define __CLC_FUNCTION __clc_fma
+#define __CLC_INTRINSIC "llvm.fma"
+#include 
+
+#define __FLOAT_ONLY
+#define __CLC_FUNCTION __clc_sw_fma
+#define __CLC_BODY 
+#include 
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+#undef __FLOAT_ONLY

Modified: libclc/trunk/generic/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=334226=334225=334226=diff
==
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Thu Jun  7 13:27:43 2018
@@ -101,6 +101,8 @@ math/exp2.cl
 math/clc_exp10.cl
 math/exp10.cl
 math/fdim.cl
+math/clc_fma.cl
+math/fma.cl
 math/fmax.cl
 math/fmin.cl
 math/clc_fmod.cl

Added: libclc/trunk/generic/lib/math/clc_fma.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/clc_fma.cl?rev=334226=auto
==
--- libclc/trunk/generic/lib/math/clc_fma.cl (added)
+++ libclc/trunk/generic/lib/math/clc_fma.cl Thu Jun  7 13:27:43 2018
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+
+#include "config.h"
+#include "math.h"
+#include "../clcmacro.h"
+
+struct fp {
+   ulong mantissa;
+   int exponent;
+   uint sign;
+};
+
+_CLC_DEF _CLC_OVERLOAD float __clc_sw_fma(float a, float b, float c)
+{
+   /* special cases */
+   if (isnan(a) || isnan(b) || isnan(c) || isinf(a) || isinf(b))
+   return mad(a, b, c);
+
+   /* If only c is inf, and both a,b are regular numbers, the result is c*/
+   if (isinf(c))
+   return c;
+
+   a = __clc_flush_denormal_if_not_supported(a);
+   b = 

[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping @rjmccall


Repository:
  rC Clang

https://reviews.llvm.org/D47233



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


[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 150399.
smeenai added a comment.

Address objc_exception attribute case


Repository:
  rC Clang

https://reviews.llvm.org/D47233

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenObjC/dllstorage.m
  test/CodeGenObjC/exceptions-msvc.m

Index: test/CodeGenObjC/exceptions-msvc.m
===
--- /dev/null
+++ test/CodeGenObjC/exceptions-msvc.m
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fobjc-runtime=ios-6.0 -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -triple i686--windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fobjc-runtime=ios-6.0 -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X64 %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X64 %s
+
+#if __has_feature(objc_arc)
+#define WEAK __weak
+#else
+#define WEAK
+#endif
+
+// CHECK-DAG: $OBJC_EHTYPE_id = comdat any
+// X86-DAG: @OBJC_EHTYPE_id = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [18 x i8] c".PAUobjc_object@@\00" }, comdat
+// X64-DAG: @OBJC_EHTYPE_id = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [19 x i8] c".PEAUobjc_object@@\00" }, comdat
+
+@class I;
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_I" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_I" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUI@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_I" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUI@@\00" }, comdat
+
+@class J;
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_J" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_J" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUJ@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_J" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUJ@@\00" }, comdat
+
+// The EHType shouldn't be exported
+__declspec(dllexport)
+__attribute__((objc_root_class))
+@interface K
+@end
+
+@implementation K
+@end
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_K" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_K" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUK@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_K" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUK@@\00" }, comdat
+
+__attribute__((objc_root_class))
+__attribute__((objc_runtime_name("NotL")))
+@interface L
+@end
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_NotL" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_NotL" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUL@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_NotL" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUL@@\00" }, comdat
+
+@class M;
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_M" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_M" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUM@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_M" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUM@@\00" }, comdat
+
+// The EHType shouldn't be generated for this definition, since it's not referenced.
+__attribute__((objc_root_class))
+__attribute__((objc_exception))
+@interface N
+@end
+
+@implementation N
+@end
+
+// CHECK-NOT: @"OBJC_EHTYPE_$_N"
+
+@protocol P;
+
+void f(void);
+
+void g() {
+  @try {
+f();
+  } @catch (I *) {
+  } @catch (J *) {
+  } @catch (K *) {
+  } @catch (L *) {
+  } @catch (M *WEAK) {
+  } @catch (id) {
+  }
+}
Index: test/CodeGenObjC/dllstorage.m
===
--- test/CodeGenObjC/dllstorage.m
+++ test/CodeGenObjC/dllstorage.m
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fdeclspec -fobjc-runtime=ios -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR %s
-// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=macosx -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR %s
+// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=macosx -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR -check-prefix CHECK-ITANIUM %s
 // RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=objfw -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-FW %s
 
 // CHECK-IR-DAG: @_objc_empty_cache = external dllimport global %struct._objc_cache

[PATCH] D47564: [Parse] Use CapturedStmt for @finally on MSVC

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334224: [Parse] Use CapturedStmt for @finally on MSVC 
(authored by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47564

Files:
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/Basic/CapturedStmt.h
  cfe/trunk/include/clang/Sema/ScopeInfo.h
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/test/SemaObjC/finally-msvc.m


Index: cfe/trunk/test/SemaObjC/finally-msvc.m
===
--- cfe/trunk/test/SemaObjC/finally-msvc.m
+++ cfe/trunk/test/SemaObjC/finally-msvc.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fexceptions -fobjc-exceptions 
-ast-dump %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fexceptions -fobjc-exceptions 
-ast-dump %s 2>&1 | FileCheck %s
+
+void f() {
+  @try {
+  } @finally {
+  }
+}
+
+// CHECK:  ObjCAtFinallyStmt
+// CHECK-NEXT:   CapturedStmt
+// CHECK-NEXT: CapturedDecl
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT:   ImplicitParamDecl
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -2585,13 +2585,26 @@
   ParseScope FinallyScope(this,
   Scope::DeclScope | Scope::CompoundStmtScope);
 
+  bool ShouldCapture =
+  getTargetInfo().getTriple().isWindowsMSVCEnvironment();
+  if (ShouldCapture)
+Actions.ActOnCapturedRegionStart(Tok.getLocation(), getCurScope(),
+ CR_ObjCAtFinally, 1);
+
   StmtResult FinallyBody(true);
   if (Tok.is(tok::l_brace))
 FinallyBody = ParseCompoundStatementBody();
   else
 Diag(Tok, diag::err_expected) << tok::l_brace;
-  if (FinallyBody.isInvalid())
+
+  if (FinallyBody.isInvalid()) {
 FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
+if (ShouldCapture)
+  Actions.ActOnCapturedRegionError();
+  } else if (ShouldCapture) {
+FinallyBody = Actions.ActOnCapturedRegionEnd(FinallyBody.get());
+  }
+
   FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
FinallyBody.get());
   catch_or_finally_seen = true;
Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -2133,7 +2133,7 @@
 
   /// The pointer part is the implicit the outlined function and the 
   /// int part is the captured region kind, 'CR_Default' etc.
-  llvm::PointerIntPair CapDeclAndKind;
+  llvm::PointerIntPair CapDeclAndKind;
 
   /// The record for captured variables, a RecordDecl or CXXRecordDecl.
   RecordDecl *TheRecordDecl = nullptr;
Index: cfe/trunk/include/clang/Sema/ScopeInfo.h
===
--- cfe/trunk/include/clang/Sema/ScopeInfo.h
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h
@@ -748,6 +748,8 @@
 switch (CapRegionKind) {
 case CR_Default:
   return "default captured statement";
+case CR_ObjCAtFinally:
+  return "Objective-C @finally statement";
 case CR_OpenMP:
   return "OpenMP region";
 }
Index: cfe/trunk/include/clang/Basic/CapturedStmt.h
===
--- cfe/trunk/include/clang/Basic/CapturedStmt.h
+++ cfe/trunk/include/clang/Basic/CapturedStmt.h
@@ -16,6 +16,7 @@
 /// The different kinds of captured statement.
 enum CapturedRegionKind {
   CR_Default,
+  CR_ObjCAtFinally,
   CR_OpenMP
 };
 


Index: cfe/trunk/test/SemaObjC/finally-msvc.m
===
--- cfe/trunk/test/SemaObjC/finally-msvc.m
+++ cfe/trunk/test/SemaObjC/finally-msvc.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fexceptions -fobjc-exceptions -ast-dump %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fexceptions -fobjc-exceptions -ast-dump %s 2>&1 | FileCheck %s
+
+void f() {
+  @try {
+  } @finally {
+  }
+}
+
+// CHECK:  ObjCAtFinallyStmt
+// CHECK-NEXT:   CapturedStmt
+// CHECK-NEXT: CapturedDecl
+// CHECK-NEXT:   CompoundStmt
+// CHECK-NEXT:   ImplicitParamDecl
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -2585,13 +2585,26 @@
   ParseScope FinallyScope(this,
   Scope::DeclScope | Scope::CompoundStmtScope);
 
+  bool ShouldCapture =
+  getTargetInfo().getTriple().isWindowsMSVCEnvironment();
+  if (ShouldCapture)
+Actions.ActOnCapturedRegionStart(Tok.getLocation(), 

r334224 - [Parse] Use CapturedStmt for @finally on MSVC

2018-06-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jun  7 13:07:52 2018
New Revision: 334224

URL: http://llvm.org/viewvc/llvm-project?rev=334224=rev
Log:
[Parse] Use CapturedStmt for @finally on MSVC

The body of a `@finally` needs to be executed on both exceptional and
non-exceptional paths. On landingpad platforms, this is straightforward:
the `@finally` body is emitted as a normal (non-exceptional) cleanup,
and then a catch-all is emitted which branches to that cleanup (the
cleanup has code to conditionally re-throw based on a flag which is set
by the catch-all).

Unfortunately, we can't use the same approach for MSVC exceptions, where
the catch-all will be emitted as a catchpad. We can't just branch to the
cleanup from within the catchpad, since we can only exit it via a
catchret, at which point the exception is destroyed and we can't
rethrow. We could potentially emit the finally body inside the catchpad
and have the normal cleanup path somehow branch into it, but that would
require some new IR construct that could branch into a catchpad.

Instead, after discussing it with Reid Kleckner, we decided that
frontend outlining was the best approach, similar to how SEH `__finally`
works today. We decided to use CapturedStmt (which was also suggested by
Reid) rather than CaptureFinder (which is what `__finally` uses) since
the latter doesn't handle a lot of cases we care about, e.g. self
accesses, property accesses, block captures, etc. Extending
CaptureFinder to handle those additional cases proved unwieldy, whereas
CapturedStmt already took care of all of those.  In theory `__finally`
could also be moved over to CapturedStmt, which would remove some
existing limitations (e.g. the inability to capture this), although
CaptureFinder would still be needed for SEH filters.

The one case supported by `@finally` but not CapturedStmt (or
CaptureFinder for that matter) is arbitrary control flow out of the
`@finally`, e.g. having a return statement inside a `@finally`. We can
add that support as a follow-up, but in practice we've found it to be
used very rarely anyway.

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

Added:
cfe/trunk/test/SemaObjC/finally-msvc.m
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/CapturedStmt.h
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=334224=334223=334224=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun  7 13:07:52 2018
@@ -2133,7 +2133,7 @@ private:
 
   /// The pointer part is the implicit the outlined function and the 
   /// int part is the captured region kind, 'CR_Default' etc.
-  llvm::PointerIntPair CapDeclAndKind;
+  llvm::PointerIntPair CapDeclAndKind;
 
   /// The record for captured variables, a RecordDecl or CXXRecordDecl.
   RecordDecl *TheRecordDecl = nullptr;

Modified: cfe/trunk/include/clang/Basic/CapturedStmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CapturedStmt.h?rev=334224=334223=334224=diff
==
--- cfe/trunk/include/clang/Basic/CapturedStmt.h (original)
+++ cfe/trunk/include/clang/Basic/CapturedStmt.h Thu Jun  7 13:07:52 2018
@@ -16,6 +16,7 @@ namespace clang {
 /// The different kinds of captured statement.
 enum CapturedRegionKind {
   CR_Default,
+  CR_ObjCAtFinally,
   CR_OpenMP
 };
 

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=334224=334223=334224=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Jun  7 13:07:52 2018
@@ -748,6 +748,8 @@ public:
 switch (CapRegionKind) {
 case CR_Default:
   return "default captured statement";
+case CR_ObjCAtFinally:
+  return "Objective-C @finally statement";
 case CR_OpenMP:
   return "OpenMP region";
 }

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=334224=334223=334224=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Jun  7 13:07:52 2018
@@ -2585,13 +2585,26 @@ StmtResult Parser::ParseObjCTryStmt(Sour
   ParseScope FinallyScope(this,
   Scope::DeclScope | Scope::CompoundStmtScope);
 
+  bool ShouldCapture =
+  getTargetInfo().getTriple().isWindowsMSVCEnvironment();
+  if (ShouldCapture)
+Actions.ActOnCapturedRegionStart(Tok.getLocation(), getCurScope(),
+ 

[PATCH] D47853: [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: test/CodeGenCXX/personality.cpp:9
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions 
-fseh-exceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-WIN-SEH
-// %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fsjlj-exceptions 
-fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix 
CHECK-WIN-SJLJ
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fseh-exceptions -fcxx-exceptions -S -emit-llvm %s 
-o - | FileCheck %s -check-prefix CHECK-WIN-SEH-X86

smeenai wrote:
> mstorsjo wrote:
> > Same here, please keep the existing tests but retarget them to gnu/mingw.
> This should all be covered by the group of RUN lines right below this one.
Oh, right.


Repository:
  rC Clang

https://reviews.llvm.org/D47853



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


[clang-tools-extra] r334221 - [FileSystem] Split up the OpenFlags enumeration.

2018-06-07 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Jun  7 12:58:58 2018
New Revision: 334221

URL: http://llvm.org/viewvc/llvm-project?rev=334221=rev
Log:
[FileSystem] Split up the OpenFlags enumeration.

This breaks the OpenFlags enumeration into two separate
enumerations: OpenFlags and CreationDisposition.  The first
controls the behavior of the API depending on whether or not
the target file already exists, and is not a flags-based
enum.  The second controls more flags-like values.

This yields a more easy to understand API, while also allowing
flags to be passed to the openForRead api, where most of the
values didn't make sense before.  This also makes the apis more
testable as it becomes easy to enumerate all the configurations
which make sense, so I've added many new tests to exercise all
the different values.

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=334221=334220=334221=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Thu Jun  7 
12:58:58 2018
@@ -30,8 +30,8 @@ namespace {
 
 std::error_code CreateNewFile(const llvm::Twine ) {
   int fd = 0;
-  if (std::error_code ec =
-  llvm::sys::fs::openFileForWrite(path, fd, llvm::sys::fs::F_Text))
+  if (std::error_code ec = llvm::sys::fs::openFileForWrite(
+  path, fd, llvm::sys::fs::CD_CreateAlways, llvm::sys::fs::F_Text))
 return ec;
 
   return llvm::sys::Process::SafelyCloseFileDescriptor(fd);

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=334221=334220=334221=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Thu Jun  7 12:58:58 2018
@@ -159,7 +159,8 @@ int main(int argc, char *argv[]) {
   llvm::Optional InputMirrorStream;
   if (!InputMirrorFile.empty()) {
 std::error_code EC;
-InputMirrorStream.emplace(InputMirrorFile, /*ref*/ EC, 
llvm::sys::fs::F_RW);
+InputMirrorStream.emplace(InputMirrorFile, /*ref*/ EC,
+  llvm::sys::fs::FA_Read | 
llvm::sys::fs::FA_Write);
 if (EC) {
   InputMirrorStream.reset();
   llvm::errs() << "Error while opening an input mirror file: "
@@ -174,7 +175,8 @@ int main(int argc, char *argv[]) {
   std::unique_ptr Tracer;
   if (auto *TraceFile = getenv("CLANGD_TRACE")) {
 std::error_code EC;
-TraceStream.emplace(TraceFile, /*ref*/ EC, llvm::sys::fs::F_RW);
+TraceStream.emplace(TraceFile, /*ref*/ EC,
+llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
 if (EC) {
   TraceStream.reset();
   llvm::errs() << "Error while opening trace file " << TraceFile << ": "


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


r334221 - [FileSystem] Split up the OpenFlags enumeration.

2018-06-07 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Thu Jun  7 12:58:58 2018
New Revision: 334221

URL: http://llvm.org/viewvc/llvm-project?rev=334221=rev
Log:
[FileSystem] Split up the OpenFlags enumeration.

This breaks the OpenFlags enumeration into two separate
enumerations: OpenFlags and CreationDisposition.  The first
controls the behavior of the API depending on whether or not
the target file already exists, and is not a flags-based
enum.  The second controls more flags-like values.

This yields a more easy to understand API, while also allowing
flags to be passed to the openForRead api, where most of the
values didn't make sense before.  This also makes the apis more
testable as it becomes easy to enumerate all the configurations
which make sense, so I've added many new tests to exercise all
the different values.

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=334221=334220=334221=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Jun  7 12:58:58 2018
@@ -258,7 +258,8 @@ ErrorOr>
 RealFileSystem::openFileForRead(const Twine ) {
   int FD;
   SmallString<256> RealName;
-  if (std::error_code EC = sys::fs::openFileForRead(Name, FD, ))
+  if (std::error_code EC =
+  sys::fs::openFileForRead(Name, FD, sys::fs::OF_None, ))
 return EC;
   return std::unique_ptr(new RealFile(FD, Name.str(), RealName.str()));
 }

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=334221=334220=334221=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Jun  7 12:58:58 2018
@@ -1293,7 +1293,7 @@ void Driver::generateCompilationDiagnost
 
   std::string Script = CrashInfo.Filename.rsplit('.').first.str() + ".sh";
   std::error_code EC;
-  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::F_Excl);
+  llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
 << "Error generating run script: " + Script + " " + EC.message();

Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=334221=334220=334221=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Thu Jun  7 12:58:58 
2018
@@ -238,10 +238,8 @@ void HTMLDiagnostics::ReportDiag(const P
<< "-" << i << ".html";
   llvm::sys::path::append(Model, Directory,
   filename.str());
-  EC = llvm::sys::fs::openFileForWrite(Model,
-   FD,
-   llvm::sys::fs::F_RW |
-   llvm::sys::fs::F_Excl);
+  EC = llvm::sys::fs::openFileForReadWrite(
+  Model, FD, llvm::sys::fs::CD_CreateNew, llvm::sys::fs::OF_None);
   if (EC && EC != llvm::errc::file_exists) {
   llvm::errs() << "warning: could not create file '" << Model
<< "': " << EC.message() << '\n';


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


[PATCH] D47853: [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 150394.
smeenai marked 2 inline comments as done.
smeenai added a comment.

Add back missing MinGW coverage


Repository:
  rC Clang

https://reviews.llvm.org/D47853

Files:
  include/clang/Basic/DiagnosticFrontendKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/personality.c
  test/CodeGenCXX/ms-eh-personality.cpp
  test/CodeGenCXX/personality.cpp
  test/CodeGenObjC/personality.m
  test/CodeGenObjCXX/personality.mm
  test/Frontend/windows-exceptions.cpp

Index: test/Frontend/windows-exceptions.cpp
===
--- /dev/null
+++ test/Frontend/windows-exceptions.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fsyntax-only %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-DWARF %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SEH %s
+// RUN: not %clang_cc1 -triple i686--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X86-SJLJ %s
+
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fdwarf-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-DWARF %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fseh-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SEH %s
+// RUN: not %clang_cc1 -triple x86_64--windows-msvc -fsyntax-only -fsjlj-exceptions %s 2>&1 | FileCheck -check-prefix=MSVC-X64-SJLJ %s
+
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fdwarf-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fseh-exceptions %s
+// RUN: %clang_cc1 -triple i686--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fdwarf-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fseh-exceptions %s
+// RUN: %clang_cc1 -triple x86_64--windows-gnu -fsyntax-only -fsjlj-exceptions %s
+
+// MSVC-X86-DWARF: error: invalid exception model 'fdwarf-exceptions' for target 'i686--windows-msvc'
+// MSVC-X86-SEH: error: invalid exception model 'fseh-exceptions' for target 'i686--windows-msvc'
+// MSVC-X86-SJLJ: error: invalid exception model 'fsjlj-exceptions' for target 'i686--windows-msvc'
+
+// MSVC-X64-DWARF: error: invalid exception model 'fdwarf-exceptions' for target 'x86_64--windows-msvc'
+// MSVC-X64-SEH: error: invalid exception model 'fseh-exceptions' for target 'x86_64--windows-msvc'
+// MSVC-X64-SJLJ: error: invalid exception model 'fsjlj-exceptions' for target 'x86_64--windows-msvc'
Index: test/CodeGenObjCXX/personality.mm
===
--- test/CodeGenObjCXX/personality.mm
+++ test/CodeGenObjCXX/personality.mm
@@ -26,31 +26,13 @@
 // RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fexceptions -fsjlj-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=objfw -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-OBJFW-SJLJ
 
 // RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fdwarf-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE-DWARF
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fseh-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE-SEH
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fsjlj-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx-fragile -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-MACOSX-FRAGILE-SJLJ
 // RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fdwarf-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS-DWARF
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fseh-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-WIN-NS
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fsjlj-exceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime=macosx -S -emit-llvm %s -o - | FileCheck %s -check-prefix 

[PATCH] D47853: [Frontend] Disallow non-MSVC exception models for windows-msvc targets

2018-06-07 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai marked 2 inline comments as done.
smeenai added inline comments.



Comment at: test/CodeGen/personality.c:10
-// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fblocks -fseh-exceptions -S -emit-llvm %s -o - | 
FileCheck %s -check-prefix CHECK-WIN-SEH -check-prefix CHECK-WIN-SEH-X64
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fblocks 
-fsjlj-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix 
CHECK-WIN-SJLJ
 

mstorsjo wrote:
> I'd prefer if you didn't remove these tests, but instead retarget them to use 
> a `-gnu` triplet, to keep testing where you can explicitly choose between 
> sjlj/dwarf/seh for mingw setups.
I'll re-add those back; I didnt' realize they weren't already covered. I'm 
gonna drop the __SEH_EXCEPTIONS__ thing for MinGW, since AFAIK SEH 
`__try`/`__finally` doesn't work there.



Comment at: test/CodeGenCXX/personality.cpp:9
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions 
-fseh-exceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s 
-check-prefix CHECK-WIN-SEH
-// %clang_cc1 -triple i686-unknown-windows-msvc -fexceptions -fsjlj-exceptions 
-fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix 
CHECK-WIN-SJLJ
-// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -D __SEH_EXCEPTIONS__ 
-fms-extensions -fexceptions -fseh-exceptions -fcxx-exceptions -S -emit-llvm %s 
-o - | FileCheck %s -check-prefix CHECK-WIN-SEH-X86

mstorsjo wrote:
> Same here, please keep the existing tests but retarget them to gnu/mingw.
This should all be covered by the group of RUN lines right below this one.


Repository:
  rC Clang

https://reviews.llvm.org/D47853



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


[PATCH] D47578: Do not enforce absolute path argv0 in windows

2018-06-07 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: llvm/lib/Support/Windows/Process.inc:240
+  Filename.assign(Base.begin(), Base.end());
+  return ec;
 }

The intention of the code is to return a success, so it is less confusing if 
you directly return a success (i.e. std::error_code())



Comment at: llvm/lib/Support/Windows/Process.inc:262
 
-  LocalFree(UnicodeCommandLine);
+  SmallVector Arg0(Args[0], Args[0] + strlen(Args[0])), 
Filename;
+  sys::path::remove_filename(Arg0);

Looks like defining a variable on at a time is more common than defining two 
variables in one line.


https://reviews.llvm.org/D47578



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


[PATCH] D47902: [CUDA] Fix emission of constant strings in sections

2018-06-07 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added a reviewer: tra.
Herald added a subscriber: cfe-commits.

CGM.GetAddrOfConstantCString() sets the adress of the created GlobalValue
to unnamed. When emitting the object file LLVM will mark the surrounding
section as SHF_MERGE iff the string is nul-terminated and contains no
other nuls (see IsNullTerminatedString). This results in problems when
saving temporaries because LLVM doesn't set an EntrySize, so reading in
the serialized assembly file fails.
This never happened for the GPU binaries because they usually contain
a nul-character somewhere. Instead this only affected the module ID
when compiling relocatable device code.

However, this points to a potentially larger problem: If we put a
constant string into a named section, we really want the data to end
up in that section in the object file. To avoid LLVM merging sections
this patch unmarks the GlobalVariable's address as unnamed which also
fixes the problem of invalid serialized assembly files when saving
temporaries.


Repository:
  rC Clang

https://reviews.llvm.org/D47902

Files:
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/device-stub.cu


Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -65,7 +65,7 @@
 // ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
 // HIP: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin"
-// CUDA: @[[FATBIN:.*]] = private unnamed_addr constant{{.*GPU binary would be 
here.*}}\00",
+// CUDA: @[[FATBIN:.*]] = private constant{{.*GPU binary would be here.*}}\00",
 // CUDANORDC-SAME: section ".nv_fatbin", align 8
 // CUDARDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
@@ -81,7 +81,7 @@
 // * variable to save GPU binary handle after initialization
 // NORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
 // * constant unnamed string with NVModuleID
-// RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant
+// RDC: [[MODULE_ID_GLOBAL:@.*]] = private constant
 // CUDARDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
 // HIPRDC-SAME: c"[[MODULE_ID:.+]]\00", section "__hip_module_id", align 32
 // * Make sure our constructor was added to global ctor list.
@@ -141,7 +141,7 @@
 // There should be no __[[PREFIX]]_register_globals if we have no
 // device-side globals, but we still need to register GPU binary.
 // Skip GPU binary string first.
-// CUDANOGLOBALS: @{{.*}} = private unnamed_addr constant{{.*}}
+// CUDANOGLOBALS: @{{.*}} = private constant{{.*}}
 // HIPNOGLOBALS: @{{.*}} = external constant{{.*}}
 // NOGLOBALS-NOT: define internal void @__{{.*}}_register_globals
 // NOGLOBALS: define internal void @__[[PREFIX:cuda|hip]]_module_ctor
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -75,8 +75,12 @@
 auto ConstStr = CGM.GetAddrOfConstantCString(Str, Name.c_str());
 llvm::GlobalVariable *GV =
 cast(ConstStr.getPointer());
-if (!SectionName.empty())
+if (!SectionName.empty()) {
   GV->setSection(SectionName);
+  // Mark the address as used which make sure that this section isn't
+  // merged and we will really have it in the object file.
+  GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::None);
+}
 if (Alignment)
   GV->setAlignment(Alignment);
 


Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -65,7 +65,7 @@
 // ALL: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
 // * constant unnamed string with GPU binary
 // HIP: @[[FATBIN:__hip_fatbin]] = external constant i8, section ".hip_fatbin"
-// CUDA: @[[FATBIN:.*]] = private unnamed_addr constant{{.*GPU binary would be here.*}}\00",
+// CUDA: @[[FATBIN:.*]] = private constant{{.*GPU binary would be here.*}}\00",
 // CUDANORDC-SAME: section ".nv_fatbin", align 8
 // CUDARDC-SAME: section "__nv_relfatbin", align 8
 // * constant struct that wraps GPU binary
@@ -81,7 +81,7 @@
 // * variable to save GPU binary handle after initialization
 // NORDC: @__[[PREFIX]]_gpubin_handle = internal global i8** null
 // * constant unnamed string with NVModuleID
-// RDC: [[MODULE_ID_GLOBAL:@.*]] = private unnamed_addr constant
+// RDC: [[MODULE_ID_GLOBAL:@.*]] = private constant
 // CUDARDC-SAME: c"[[MODULE_ID:.+]]\00", section "__nv_module_id", align 32
 // HIPRDC-SAME: c"[[MODULE_ID:.+]]\00", section "__hip_module_id", align 32
 // * Make sure our constructor was added to global ctor list.
@@ -141,7 +141,7 @@
 // There should be no __[[PREFIX]]_register_globals if we have no
 // device-side globals, but we still need to register GPU binary.
 // Skip GPU binary 

[PATCH] D34156: [LTO] Enable module summary emission by default for regular LTO

2018-06-07 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added a comment.
Herald added a subscriber: steven_wu.

Hi Tobias, I tracked down the failure self-hosting LLVM with LTO with this 
revision to https://bugs.llvm.org/show_bug.cgi?id=37684#c2 and have a fix under 
review in https://reviews.llvm.org/D47898. This revision needs to be updated to 
include the following trivial EmitSummaryIndex->PrepareForThinLTO renames to 
build:

  --- a/lib/CodeGen/BackendUtil.cpp
  +++ b/lib/CodeGen/BackendUtil.cpp
  @@ -944,7 +944,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 ModulePassManager MPM(CodeGenOpts.DebugPassManager);
   
 if (!CodeGenOpts.DisableLLVMPasses) {
  -bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
  +bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
   bool IsLTO = CodeGenOpts.PrepareForLTO;
   
   if (CodeGenOpts.OptimizationLevel == 0) {
  diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
  index db6a82b415..91f80e5739 100644
  --- a/lib/CodeGen/CGDebugInfo.cpp
  +++ b/lib/CodeGen/CGDebugInfo.cpp
  @@ -578,7 +578,7 @@ void CGDebugInfo::CreateCompileUnit() {
 CSInfo,
 getSource(SM, SM.getMainFileID())),
 CGOpts.EmitVersionIdentMetadata ? Producer : "",
  -  LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
  +  LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
 CGOpts.DwarfDebugFlags, RuntimeVers,
 CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,
 0 /* DWOid */, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling,

Are you still interested in landing this?


https://reviews.llvm.org/D34156



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


[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-07 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334216: Introducing single for loop into clang_proto_fuzzer 
(authored by vitalybuka, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D47843

Files:
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
  cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h

Index: cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
@@ -0,0 +1,30 @@
+//===-- ExampleClangLoopProtoFuzzer.cpp - Fuzz Clang --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+///  This file implements a function that runs Clang on a single
+///  input and uses libprotobuf-mutator to find new inputs. This function is
+///  then linked into the Fuzzer library. This file differs from
+///  ExampleClangProtoFuzzer in that it uses the new protobuf that includes
+///  C++ code with a single for loop.
+///
+//===--===//
+
+#include "cxx_loop_proto.pb.h"
+#include "fuzzer-initialize/fuzzer_initialize.h"
+#include "handle-cxx/handle_cxx.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_macro.h"
+
+using namespace clang_fuzzer;
+
+DEFINE_BINARY_PROTO_FUZZER(const LoopFunction ) {
+  auto S = LoopFunctionToString(input);
+  HandleCXX(S, GetCLArgs());
+}
Index: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -17,6 +17,10 @@
 
 namespace clang_fuzzer {
 class Function;
+class LoopFunction;
+
 std::string FunctionToString(const Function );
 std::string ProtoToCxx(const uint8_t *data, size_t size);
+std::string LoopFunctionToString(const LoopFunction );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
 }
Index: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
@@ -2,12 +2,21 @@
 set(CMAKE_CXX_FLAGS ${CXX_FLAGS_NOFUZZ})
 
 # Needed by LLVM's CMake checks because this file defines multiple targets.
-set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp)
+set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp
+  loop_proto_to_cxx.cpp loop_proto_to_cxx_main.cpp)
 
 add_clang_library(clangProtoToCXX proto_to_cxx.cpp
   DEPENDS clangCXXProto
   LINK_LIBS clangCXXProto ${PROTOBUF_LIBRARIES}
   )
 
+add_clang_library(clangLoopProtoToCXX loop_proto_to_cxx.cpp
+  DEPENDS clangCXXLoopProto
+  LINK_LIBS clangCXXLoopProto ${PROTOBUF_LIBRARIES}
+  )
+
 add_clang_executable(clang-proto-to-cxx proto_to_cxx_main.cpp)
+add_clang_executable(clang-loop-proto-to-cxx loop_proto_to_cxx_main.cpp)
+
 target_link_libraries(clang-proto-to-cxx PRIVATE clangProtoToCXX)
+target_link_libraries(clang-loop-proto-to-cxx PRIVATE clangLoopProtoToCXX)
Index: cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
+++ cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,32 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+

r334216 - Introducing single for loop into clang_proto_fuzzer

2018-06-07 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jun  7 12:17:46 2018
New Revision: 334216

URL: http://llvm.org/viewvc/llvm-project?rev=334216=rev
Log:
Introducing single for loop into clang_proto_fuzzer

Summary:
Created a new protobuf and protobuf-to-C++ "converter" that wraps the entire 
C++ code in a single for loop.
  - Slightly changed cxx_proto.proto -> cxx_loop_proto.proto
  - Made some changes to proto_to_cxx files to handle the new kind of protobuf
  - Created ExampleClangLoopProtoFuzzer to test new protobuf and "converter"

Patch by Emmett Neyman

Reviewers: kcc, vitalybuka, morehouse

Reviewed By: vitalybuka, morehouse

Subscribers: mgorny, llvm-commits, cfe-commits

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

Added:
cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=334216=334215=334216=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Thu Jun  7 12:17:46 2018
@@ -14,6 +14,7 @@ set(LLVM_OPTIONAL_SOURCES
   ClangFuzzer.cpp
   DummyClangFuzzer.cpp
   ExampleClangProtoFuzzer.cpp
+  ExampleClangLoopProtoFuzzer.cpp
   )
 
 if(CLANG_ENABLE_PROTO_FUZZER)
@@ -24,6 +25,7 @@ if(CLANG_ENABLE_PROTO_FUZZER)
   include_directories(${PROTOBUF_INCLUDE_DIRS})
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  protobuf_generate_cpp(LOOP_PROTO_SRCS LOOP_PROTO_HDRS cxx_loop_proto.proto)
   set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
   add_clang_library(clangCXXProto
 ${PROTO_SRCS}
@@ -33,13 +35,21 @@ if(CLANG_ENABLE_PROTO_FUZZER)
 ${PROTOBUF_LIBRARIES}
 )
 
+  add_clang_library(clangCXXLoopProto
+${LOOP_PROTO_SRCS}
+${LOOP_PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
+
   # Build and include libprotobuf-mutator
   include(ProtobufMutator)
   include_directories(${ProtobufMutator_INCLUDE_DIRS})
 
   # Build the protobuf->C++ translation library and driver.
   add_clang_subdirectory(proto-to-cxx)
-
+  
   # Build the fuzzer initialization library.
   add_clang_subdirectory(fuzzer-initialize)
 
@@ -49,16 +59,32 @@ if(CLANG_ENABLE_PROTO_FUZZER)
 ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-proto-fuzzer
-PRIVATE
+  # Build the loop protobuf fuzzer
+  add_clang_executable(clang-loop-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangLoopProtoFuzzer.cpp
+)
+
+  set(COMMON_PROTO_FUZZ_LIBRARIES
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
 ${LLVM_LIB_FUZZING_ENGINE}
-clangCXXProto
 clangFuzzerInitialize
 clangHandleCXX
+)
+
+  target_link_libraries(clang-proto-fuzzer
+PRIVATE
+${COMMON_PROTO_FUZZ_LIBRARIES}
+clangCXXProto
 clangProtoToCXX
 )
+  target_link_libraries(clang-loop-proto-fuzzer
+PRIVATE
+${COMMON_PROTO_FUZZ_LIBRARIES}
+clangCXXLoopProto
+clangLoopProtoToCXX
+)
 endif()
 
 add_clang_subdirectory(handle-cxx)

Added: cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp?rev=334216=auto
==
--- cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp (added)
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp Thu Jun  7 
12:17:46 2018
@@ -0,0 +1,30 @@
+//===-- ExampleClangLoopProtoFuzzer.cpp - Fuzz Clang 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+///  This file implements a function that runs Clang on a single
+///  input and uses libprotobuf-mutator to find new inputs. This function is
+///  then linked into the Fuzzer library. This file differs from
+///  ExampleClangProtoFuzzer in that it uses the new protobuf that includes
+///  C++ code with a single for loop.
+///
+//===--===//
+
+#include "cxx_loop_proto.pb.h"
+#include "fuzzer-initialize/fuzzer_initialize.h"
+#include "handle-cxx/handle_cxx.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_macro.h"
+
+using 

[PATCH] D47864: [python] Fix most Python binding unittests on Windows

2018-06-07 Thread Ethan via Phabricator via cfe-commits
ethanhs added a comment.

In https://reviews.llvm.org/D47864#1124948, @bkramer wrote:

> I don't know much about the python bindings, but this is probably fine.


Yeah I wasn't really sure who to add so I looked at the commit history. Thank 
you for adding the right people.


Repository:
  rC Clang

https://reviews.llvm.org/D47864



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


[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 150380.
vitalybuka added a comment.

git clang-format -f --style=file HEAD^


Repository:
  rC Clang

https://reviews.llvm.org/D47843

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
  tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h

Index: tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
+++ tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -17,6 +17,10 @@
 
 namespace clang_fuzzer {
 class Function;
+class LoopFunction;
+
 std::string FunctionToString(const Function );
 std::string ProtoToCxx(const uint8_t *data, size_t size);
+std::string LoopFunctionToString(const LoopFunction );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
 }
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,32 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::LoopProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -0,0 +1,148 @@
+//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++. Extends
+// proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
+// loop. Also coutputs a different function signature that includes a
+// size_t parameter for the loop to use.
+//
+//===--===//
+
+#include "cxx_loop_proto.pb.h"
+#include "proto_to_cxx.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  if (x.is_loop_var()) {
+return os << "a[loop_ctr]";
+  } else {
+return os << "a[" << static_cast(x.varnum()) << " % s]";
+  }
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+  if (x.has_varref())
+return os << x.varref();
+  if (x.has_cons())
+return os << x.cons();
+  if (x.has_binop())
+return os << x.binop();
+  return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+  case BinaryOp::PLUS:
+os << "+";
+break;
+  case BinaryOp::MINUS:
+os << "-";
+break;
+  case BinaryOp::MUL:
+os << "*";
+break;
+  case BinaryOp::DIV:
+os << "/";
+break;
+  case BinaryOp::MOD:
+os << "%";
+break;
+  case BinaryOp::XOR:
+os << "^";
+break;
+  case BinaryOp::AND:
+os << "&";
+break;
+  case BinaryOp::OR:
+os << "|";
+break;
+  case BinaryOp::EQ:
+os << "==";
+break;
+  case BinaryOp::NE:
+os << "!=";
+break;
+  case BinaryOp::LE:
+os << "<=";
+break;
+  case BinaryOp::GE:
+os << ">=";
+break;
+  case BinaryOp::LT:
+os << "<";
+break;
+  case BinaryOp::GT:
+os << ">";
+break;
+  }
+  

[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.

2018-06-07 Thread Matthew Voss via Phabricator via cfe-commits
ormris updated this revision to Diff 150377.
ormris added a comment.

Use AST matchers to select references for preservation


Repository:
  rC Clang

https://reviews.llvm.org/D47044

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/LoopWidening.cpp
  test/Analysis/loop-widening-invalid-type.cpp

Index: test/Analysis/loop-widening-invalid-type.cpp
===
--- /dev/null
+++ test/Analysis/loop-widening-invalid-type.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s
+
+struct A {
+  ~A() {}
+};
+struct B : public A {};
+
+void invalid_type_region_access() { // expected-no-diagnostics
+  const A  = B();
+  for(int i = 0; i < 10; ++i) {}
+}
Index: lib/StaticAnalyzer/Core/LoopWidening.cpp
===
--- lib/StaticAnalyzer/Core/LoopWidening.cpp
+++ lib/StaticAnalyzer/Core/LoopWidening.cpp
@@ -15,9 +15,15 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h"
+#include "clang/AST/AST.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
+#include "llvm/ADT/SmallSet.h"
 
 using namespace clang;
 using namespace ento;
+using namespace clang::ast_matchers;
 
 /// Return the loops condition Stmt or NULL if LoopStmt is not a loop
 static const Expr *getLoopCondition(const Stmt *LoopStmt) {
@@ -33,10 +39,27 @@
   }
 }
 
+struct Callback : public MatchFinder::MatchCallback {
+  const LocationContext *LCtx;
+  MemRegionManager 
+  RegionAndSymbolInvalidationTraits 
+  explicit Callback(const LocationContext *LCtx_,
+MemRegionManager _,
+RegionAndSymbolInvalidationTraits _) : LCtx(LCtx_),
+   MRMgr(MRMgr_),
+   ITraits(ITraits_) {}
+  virtual void run(const MatchFinder::MatchResult ) override {
+const VarDecl *VD = Result.Nodes.getNodeAs("match");
+const VarRegion *VarMem = MRMgr.getVarRegion(VD, LCtx);
+ITraits.setTrait(VarMem,
+ RegionAndSymbolInvalidationTraits::TK_PreserveContents);
+  }
+};
+
 namespace clang {
 namespace ento {
 
-ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState,
+ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState, ASTContext ,
 const LocationContext *LCtx,
 unsigned BlockCount, const Stmt *LoopStmt) {
 
@@ -60,6 +83,12 @@
  RegionAndSymbolInvalidationTraits::TK_EntireMemSpace);
   }
 
+  //References should not be invalidated.
+  MatchFinder Finder;
+  Finder.addMatcher(varDecl(hasType(referenceType())).bind("match"), new Callback(LCtx, MRMgr, ITraits));
+  Finder.matchAST(ASTCtx);
+
+
   // 'this' pointer is not an lvalue, we should not invalidate it. If the loop
   // is located in a method, constructor or destructor, the value of 'this'
   // pointer shoule remain unchanged.
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1855,7 +1855,7 @@
 // Widen.
 const LocationContext *LCtx = Pred->getLocationContext();
 ProgramStateRef WidenedState =
-getWidenedLoopState(Pred->getState(), LCtx, BlockCount, Term);
+getWidenedLoopState(Pred->getState(), AMgr.getASTContext(), LCtx, BlockCount, Term);
 nodeBuilder.generateNode(WidenedState, Pred);
 return;
   }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h
@@ -26,7 +26,7 @@
 ///
 /// Widen the loop by invalidating anything that might be modified
 /// by the loop body in any iteration.
-ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState,
+ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState, ASTContext ,
 const LocationContext *LCtx,
 unsigned BlockCount, const Stmt *LoopStmt);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Does IR generation need any special handling for this?  We add nonnull 
attributes in various places.


Repository:
  rC Clang

https://reviews.llvm.org/D47894



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


[PATCH] D47896: [CodeComplete] suppress define X X macros

2018-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added a subscriber: cfe-commits.

In particular, stderr etc where the equivalent symbols exist in the global
namespace. Having the symbol instead of the macro helps with ranking, and avoids
the current duplicate stderr suggestions.

@ilya-biryukov: think this is the right way to fix the duplicate completions?
Hiding the shadowed decl might be more correct, but it'd be hard *and* give
unfortunate ranking.


Repository:
  rC Clang

https://reviews.llvm.org/D47896

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-macros.c


Index: test/Index/complete-macros.c
===
--- test/Index/complete-macros.c
+++ test/Index/complete-macros.c
@@ -25,6 +25,12 @@
   
 }
 
+int shadow;
+#define shadow shadow
+void test_shadow() {
+
+}
+
 // RUN: c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck 
-check-prefix=CHECK-CC0 %s
 // CHECK-CC0-NOT: FOO
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC1 %s
@@ -45,3 +51,7 @@
 
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:15:5 %s -I%S | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4-NOT: COMPLETE_MACROS_H_GUARD
+
+// RUN: c-index-test -code-completion-at=%s:31:1 %s -I%S | FileCheck 
-check-prefix=CHECK-SHADOW %s
+// CHECK-SHADOW: FunctionDecl:{ResultType void}{TypedText g}
+// CHECK-SHADOW-NOT: macro definition:{TypedText shadow}
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3308,9 +3308,18 @@
M != MEnd; ++M) {
 auto MD = PP.getMacroDefinition(M->first);
 if (IncludeUndefined || MD) {
-  if (MacroInfo *MI = MD.getMacroInfo())
+  if (MacroInfo *MI = MD.getMacroInfo()) {
 if (MI->isUsedForHeaderGuard())
   continue;
+// Some standard libraries e.g. #define stderr stderr, the underlying
+// decl is more useful.
+if (MI->getNumTokens() == 1 && MI->isObjectLike()) {
+  const Token  = MI->getReplacementToken(0);
+  if (Tok.is(tok::identifier) &&
+  Tok.getIdentifierInfo()->getName() == M->first->getName())
+continue;
+}
+  }
 
   Results.AddResult(Result(M->first,
  getMacroUsagePriority(M->first->getName(),


Index: test/Index/complete-macros.c
===
--- test/Index/complete-macros.c
+++ test/Index/complete-macros.c
@@ -25,6 +25,12 @@
   
 }
 
+int shadow;
+#define shadow shadow
+void test_shadow() {
+
+}
+
 // RUN: c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC0 %s
 // CHECK-CC0-NOT: FOO
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 %s -I%S | FileCheck -check-prefix=CHECK-CC1 %s
@@ -45,3 +51,7 @@
 
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:5 %s -I%S | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4-NOT: COMPLETE_MACROS_H_GUARD
+
+// RUN: c-index-test -code-completion-at=%s:31:1 %s -I%S | FileCheck -check-prefix=CHECK-SHADOW %s
+// CHECK-SHADOW: FunctionDecl:{ResultType void}{TypedText g}
+// CHECK-SHADOW-NOT: macro definition:{TypedText shadow}
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -3308,9 +3308,18 @@
M != MEnd; ++M) {
 auto MD = PP.getMacroDefinition(M->first);
 if (IncludeUndefined || MD) {
-  if (MacroInfo *MI = MD.getMacroInfo())
+  if (MacroInfo *MI = MD.getMacroInfo()) {
 if (MI->isUsedForHeaderGuard())
   continue;
+// Some standard libraries e.g. #define stderr stderr, the underlying
+// decl is more useful.
+if (MI->getNumTokens() == 1 && MI->isObjectLike()) {
+  const Token  = MI->getReplacementToken(0);
+  if (Tok.is(tok::identifier) &&
+  Tok.getIdentifierInfo()->getName() == M->first->getName())
+continue;
+}
+  }
 
   Results.AddResult(Result(M->first,
  getMacroUsagePriority(M->first->getName(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47894: [clang]: Add support for "-fno-delete-null-pointer-checks"

2018-06-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, 
srhines, void.

Support for this option is needed for building Linux kernel.
This is a very frequently requested feature by kernel developers.

More details : https://lkml.org/lkml/2018/4/4/601

GCC option description for -fdelete-null-pointer-checks:
This Assume that programs cannot safely dereference null pointers,
and that no code or data element resides at address zero.

-fno-delete-null-pointer-checks is the inverse of this implying that
null pointer dereferencing is not undefined.

This feature is implemented in as the function attribute
"null-pointer-is-valid"="true".
This CL only adds the attribute on the function. Another corresponding LLVM
change updates the optimizations to not treat null pointer dereferencing
as undefined if the attribute is present.


Repository:
  rC Clang

https://reviews.llvm.org/D47894

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/delete-null-pointer-checks.c
  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
@@ -348,7 +348,6 @@
 // RUN: -fwhole-program   \
 // RUN: -fcaller-saves\
 // RUN: -freorder-blocks  \
-// RUN: -fdelete-null-pointer-checks  \
 // RUN: -ffat-lto-objects \
 // RUN: -fmerge-constants \
 // RUN: -finline-small-functions  \
@@ -414,7 +413,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
-// CHECK-WARNING-DAG: optimization flag '-fdelete-null-pointer-checks' is not supported
 // CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported
 // CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported
@@ -526,3 +524,10 @@
 // RUN: %clang -### -S -fno-merge-all-constants -fmerge-all-constants %s 2>&1 | FileCheck -check-prefix=CHECK-MERGE-ALL-CONSTANTS %s
 // CHECK-NO-MERGE-ALL-CONSTANTS-NOT: "-fmerge-all-constants"
 // CHECK-MERGE-ALL-CONSTANTS: "-fmerge-all-constants"
+
+// RUN: %clang -### -S -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s
+// RUN: %clang -### -S -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s
+// RUN: %clang -### -S -fdelete-null-pointer-checks -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s
+// RUN: %clang -### -S -fno-delete-null-pointer-checks -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s
+// CHECK-NO-NULL-POINTER-CHECKS: "-fno-delete-null-pointer-checks"
+// CHECK-NULL-POINTER-CHECKS-NOT: "-fno-delete-null-pointer-checks"
Index: test/CodeGen/delete-null-pointer-checks.c
===
--- /dev/null
+++ test/CodeGen/delete-null-pointer-checks.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=NULL-POINTER-INVALID  %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -fno-delete-null-pointer-checks | FileCheck -check-prefix=NULL-POINTER-VALID  %s
+
+int test1(int a) {
+  return a;
+}
+
+// NULL-POINTER-INVALID-NOT: attributes #0 = {{.*}} "null-pointer-is-valid"="true"
+// NULL-POINTER-VALID: attributes #0 = {{.*}} "null-pointer-is-valid"="true"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -742,6 +742,7 @@
  OPT_fno_unique_section_names, true);
 
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
+  Opts.NullPointerIsValid = Args.hasArg(OPT_fno_delete_null_pointer_checks);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3382,6 +3382,10 @@
options::OPT_fno_merge_all_constants, false))
 CmdArgs.push_back("-fmerge-all-constants");
 
+  if (Args.hasFlag(options::OPT_fno_delete_null_pointer_checks,
+   

[PATCH] D47843: Introducing single for loop into clang_proto_fuzzer

2018-06-07 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 150365.
emmettneyman added a comment.

- refactored cmake and deleted header file


Repository:
  rC Clang

https://reviews.llvm.org/D47843

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
  tools/clang-fuzzer/cxx_loop_proto.proto
  tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
  tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
  tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h

Index: tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
+++ tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -17,6 +17,10 @@
 
 namespace clang_fuzzer {
 class Function;
+class LoopFunction;
+
 std::string FunctionToString(const Function );
 std::string ProtoToCxx(const uint8_t *data, size_t size);
+std::string LoopFunctionToString(const LoopFunction );
+std::string LoopProtoToCxx(const uint8_t *data, size_t size);
 }
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
@@ -0,0 +1,33 @@
+//==-- loop_proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf with loops.
+//
+//===--===//
+
+// This is a copy and will be updated later to introduce changes
+
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::LoopProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
@@ -0,0 +1,115 @@
+//==-- loop_proto_to_cxx.cpp - Protobuf-C++ conversion -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++. Extends
+// proto_to_cxx.cpp by wrapping all the generated C++ code in a single for
+// loop. Also coutputs a different function signature that includes a 
+// size_t parameter for the loop to use.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_loop_proto.pb.h"
+
+// The following is needed to convert protos in human-readable form
+#include 
+
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  if (x.is_loop_var()) {
+return os << "a[loop_ctr]";
+  } else {
+return os << "a[" << static_cast(x.varnum()) << " % s]";
+  }
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+case BinaryOp::PLUS: os << "+"; break;
+case BinaryOp::MINUS: os << "-"; break;
+case BinaryOp::MUL: os << "*"; break;
+case BinaryOp::DIV: os << "/"; break;
+case BinaryOp::MOD: os << "%"; break;
+case BinaryOp::XOR: os << "^"; break;
+case BinaryOp::AND: os << "&"; break;
+case BinaryOp::OR: os << "|"; break;
+case BinaryOp::EQ: os << "=="; break;
+case BinaryOp::NE: os << "!="; break;
+case BinaryOp::LE: os << "<="; break;
+case BinaryOp::GE: os << ">="; break;
+case BinaryOp::LT: os << "<"; break;
+case BinaryOp::GT: os << ">"; break;
+  }
+  return os << x.right() << ")";
+}
+std::ostream <<(std::ostream , const AssignmentStatement ) {
+  return 

[PATCH] D47707: [clangd] Downrank symbols with reserved names (score *= 0.1)

2018-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@ilya-biryukov Ping, anything left for me to do here?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47707



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


r334208 - [X86] Add back builtins for _mm_slli_si128/_mm_srli_si128 and similar intrinsics.

2018-06-07 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Thu Jun  7 10:28:03 2018
New Revision: 334208

URL: http://llvm.org/viewvc/llvm-project?rev=334208=rev
Log:
[X86] Add back builtins for  _mm_slli_si128/_mm_srli_si128 and similar 
intrinsics.

We still lower them to native shuffle IR, but we do it in CGBuiltin.cpp now. 
This allows us to check the target feature and ensure the immediate fits in 8 
bits.

This also improves our -O0 codegen slightly because we're able to see the 
zeroinitializer in the shuffle. It looks like it got lost behind a store+load 
previously.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx2intrin.h
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/avx2-builtins.c
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=334208=334207=334208=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun  7 10:28:03 2018
@@ -358,6 +358,8 @@ TARGET_BUILTIN(__builtin_ia32_psrlqi128,
 TARGET_BUILTIN(__builtin_ia32_psrawi128, "V8sV8si", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psradi128, "V4iV4ii", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_pmaddwd128, "V4iV8sV8s", "nc", "sse2")
+TARGET_BUILTIN(__builtin_ia32_pslldqi128, "V2LLiV2LLiIi", "nc", "sse2")
+TARGET_BUILTIN(__builtin_ia32_psrldqi128, "V2LLiV2LLiIi", "nc", "sse2")
 
 TARGET_BUILTIN(__builtin_ia32_monitor, "vv*UiUi", "n", "sse3")
 TARGET_BUILTIN(__builtin_ia32_mwait, "vUiUi", "n", "sse3")
@@ -585,6 +587,7 @@ TARGET_BUILTIN(__builtin_ia32_psignw256,
 TARGET_BUILTIN(__builtin_ia32_psignd256, "V8iV8iV8i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psllwi256, "V16sV16si", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psllw256, "V16sV16sV8s", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_pslldqi256, "V4LLiV4LLiIi", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pslldi256, "V8iV8ii", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_pslld256, "V8iV8iV4i", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psllqi256, "V4LLiV4LLii", "nc", "avx2")
@@ -593,6 +596,7 @@ TARGET_BUILTIN(__builtin_ia32_psrawi256,
 TARGET_BUILTIN(__builtin_ia32_psraw256, "V16sV16sV8s", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psradi256, "V8iV8ii", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrad256, "V8iV8iV4i", "nc", "avx2")
+TARGET_BUILTIN(__builtin_ia32_psrldqi256, "V4LLiV4LLiIi", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlwi256, "V16sV16si", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrlw256, "V16sV16sV8s", "nc", "avx2")
 TARGET_BUILTIN(__builtin_ia32_psrldi256, "V8iV8ii", "nc", "avx2")
@@ -1352,6 +1356,8 @@ TARGET_BUILTIN(__builtin_ia32_psraw512,
 TARGET_BUILTIN(__builtin_ia32_psrawi512, "V32sV32si", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlw512, "V32sV32sV8s", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlwi512, "V32sV32si", "nc", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pslldqi512, "V8LLiV8LLiIi", "nc", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psrldqi512, "V8LLiV8LLiIi", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load128_mask, "V4iV4i*V4iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load256_mask, "V8iV8i*V8iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load512_mask, "V16iV16iC*V16iUs", "n", 
"avx512f")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=334208=334207=334208=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jun  7 10:28:03 2018
@@ -9262,6 +9262,68 @@ Value *CodeGenFunction::EmitX86BuiltinEx
"vperm");
   }
 
+  case X86::BI__builtin_ia32_pslldqi128:
+  case X86::BI__builtin_ia32_pslldqi256:
+  case X86::BI__builtin_ia32_pslldqi512: {
+// Shift value is in bits so divide by 8.
+unsigned ShiftVal = cast(Ops[1])->getZExtValue() >> 3;
+llvm::Type *ResultType = Ops[0]->getType();
+// Builtin type is vXi64 so multiply by 8 to get bytes.
+unsigned NumElts = ResultType->getVectorNumElements() * 8;
+
+// If pslldq is shifting the vector more than 15 bytes, emit zero.
+if (ShiftVal >= 16)
+  return llvm::Constant::getNullValue(ResultType);
+
+uint32_t Indices[64];
+// 256/512-bit pslldq operates on 128-bit lanes so we need to handle that
+for (unsigned l = 0; l != NumElts; l += 16) {
+  for (unsigned i = 0; i != 16; ++i) {
+unsigned Idx = NumElts + i - ShiftVal;
+if (Idx < NumElts) Idx -= NumElts - 16; // 

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-06-07 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D47849#1124638, @Hahnfeld wrote:

> IMO this goes into the right direction, we should use the fast implementation 
> in libdevice. If LLVM doesn't lower these calls in the NVPTX backend, I think 
> it's ok to use header wrappers as CUDA already does.


Using wrapper headers may be OK solution for now. Ideally we should grow our 
own equivalent of device-side libm so we don't have to rely on libdevice 
bitcode.

> Two questions:
> 
> 1. Can you explain where this is important for "correctness"? Yesterday I 
> compiled a code using `sqrt` and it seems to spit out the correct results. 
> Maybe that's relevant for other functions?
> 2. Incidentally I ran into a closely related problem: I can't `#include 
> ` in translation units compiled for offloading, Clang complains about 
> inline assembly for x86 (see below). Does that work for you?
> 
>   ``` In file included from /usr/include/math.h:413: 
> /usr/include/bits/mathinline.h:131:43: error: invalid input constraint 'x' in 
> asm __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x)); ^ 
> /usr/include/bits/mathinline.h:143:43: error: invalid input constraint 'x' in 
> asm __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x)); ^ 2 errors generated. 
> ```

Avoiding conflicts between host and device implementations of the same 
functions in C++ requires use of attribute-based overloading 
(https://goo.gl/EXnymm). For CUDA compilation, we provide device-side overloads 
with __device__ attributes but otherwise identical signatures. We may need to 
extend it to work in C mode, too. Clang already has 
__attribute__((overloadable)), so basic overloading mechanisms should be there 
already.




Comment at: lib/Headers/__clang_cuda_device_functions.h:1153-1155
+__DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); }
 #if defined(__LP64__)
 __DEVICE__ long labs(long __a) { return llabs(__a); };

I think it should've been `return __nv_llabs(__a)` here and the definition of 
`long long llabs()` should remain back  where it was.


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D47097: [DebugInfo] Preserve scope in auto generated StoreInst

2018-06-07 Thread Anastasis via Phabricator via cfe-commits
gramanas updated this revision to Diff 150357.
gramanas added a comment.

Make more elaborate comment.


Repository:
  rC Clang

https://reviews.llvm.org/D47097

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGen/debug-info-preserve-scope.c


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -O1 -debug-info-kind=limited -emit-llvm -mllvm \
+// RUN: -opt-bisect-limit=2 -o - %s 2> /dev/null | FileCheck %s \
+// RUN: --check-prefix PHI
+
+extern int map[];
+// PHI-LABEL: define void @test1
+void test1(int a, int n) {
+  for (int i = 0; i < n; ++i)
+a = map[a];
+}
+
+// PHI: for.cond:
+// PHI-NEXT: {{.*}} = phi i32 {{.*}} !dbg ![[test1DbgLoc:[0-9]+]]
+
+// PHI: ![[test1DbgLoc]] = !DILocation(line: 0
+
+
+static int i;
+// CHECK-LABEL: define void @test2
+void test2(int b) {
+  i = b;
+}
+
+// CHECK: store i32 {{.*}} !dbg ![[test2DbgLoc:[0-9]+]]
+
+// CHECK: ![[test2DbgLoc]] = !DILocation(line: 0
+
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1946,6 +1946,10 @@
 }
   }
 
+  // Set artificial debug location to preserve the scope. This is later
+  // used by mem2reg to assign DL at the phi's it generates.
+  auto DL = ApplyDebugLocation::CreateArtificial(*this);
+
   Address DeclPtr = Address::invalid();
   bool DoStore = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -O1 -debug-info-kind=limited -emit-llvm -mllvm \
+// RUN: -opt-bisect-limit=2 -o - %s 2> /dev/null | FileCheck %s \
+// RUN: --check-prefix PHI
+
+extern int map[];
+// PHI-LABEL: define void @test1
+void test1(int a, int n) {
+  for (int i = 0; i < n; ++i)
+a = map[a];
+}
+
+// PHI: for.cond:
+// PHI-NEXT: {{.*}} = phi i32 {{.*}} !dbg ![[test1DbgLoc:[0-9]+]]
+
+// PHI: ![[test1DbgLoc]] = !DILocation(line: 0
+
+
+static int i;
+// CHECK-LABEL: define void @test2
+void test2(int b) {
+  i = b;
+}
+
+// CHECK: store i32 {{.*}} !dbg ![[test2DbgLoc:[0-9]+]]
+
+// CHECK: ![[test2DbgLoc]] = !DILocation(line: 0
+
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1946,6 +1946,10 @@
 }
   }
 
+  // Set artificial debug location to preserve the scope. This is later
+  // used by mem2reg to assign DL at the phi's it generates.
+  auto DL = ApplyDebugLocation::CreateArtificial(*this);
+
   Address DeclPtr = Address::invalid();
   bool DoStore = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47630: [Sema] Allow creating types with multiple of the same addrspace.

2018-06-07 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: test/Sema/address_spaces.c:17
   int *_AS1 _AS2 *Z;  // expected-error {{multiple address spaces specified 
for type}}
+  int *_AS1 _AS1 *M;
 

ebevhan wrote:
> Anastasia wrote:
> > ebevhan wrote:
> > > bader wrote:
> > > > I think it might be valuable to give a warning or remark to user. 
> > > > Using the same address space qualifier multiple times is not something 
> > > > OpenCL C developers are supposed to do.
> > > > 
> > > The test is obviously a bit contrived, but it could happen by mistake, or 
> > > as a result of some typedef or macro combination. It also cannot go 
> > > wrong, so there's no harm in it happening.
> > > 
> > > I see your point, though. A warning feels like a bit much, so I'm not 
> > > sure what else to use. A note?
> > Just checked for const qualifier we get a warning:
> >   warning: duplicate 'const' declaration specifier 
> > [-Wduplicate-decl-specifier]
> > 
> > We could do the same... not sure if we could try to share the diagnostic as 
> > well.
> I have a patch ready that adds a warning in the same warning group and uses 
> that. I'm not sure about reusing the other one since address spaces don't 
> have to be declaration specifiers.
> 
> The warning is 'multiple identical address spaces specified for type', 
> similar to the error. Is that acceptable?
Sounds good to me. Could you share your patch, please?


Repository:
  rC Clang

https://reviews.llvm.org/D47630



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


[PATCH] D47887: Move VersionTuple from clang/Basic to llvm/Support, llvm part

2018-06-07 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

Yea, one day I'll have to try that out. I'm just putting it off cause it would 
nuke all my branches and build folders :/

FWIW, the llvm part can actually be committed without breaking clang or anyone.


Repository:
  rL LLVM

https://reviews.llvm.org/D47887



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


[PATCH] D47887: Move VersionTuple from clang/Basic to llvm/Support, llvm part

2018-06-07 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

It would be better if you're using a monorepo, that way both parts can just be 
one single patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D47887



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


[PATCH] D47887: Move VersionTuple from clang/Basic to llvm/Support, llvm part

2018-06-07 Thread Pavel Labath via Phabricator via cfe-commits
labath created this revision.
labath added reviewers: zturner, erik.pilkington.
Herald added a subscriber: mgorny.

This kind of functionality is useful to other project apart from clang.
LLDB works with version numbers a lot, but it does not have a convenient
abstraction for this. Moving this class to a lower level library allows
it to be freely used within LLDB.

The code is an identical copy of the version from clang (apart from
namespace change and re-clang-formatting).

I didn't find any tests specific for this class, so I wrote a couple of
quick ones for the more interesting bits of functionality.


Repository:
  rL LLVM

https://reviews.llvm.org/D47887

Files:
  include/llvm/Support/VersionTuple.h
  lib/Support/CMakeLists.txt
  lib/Support/VersionTuple.cpp
  unittests/Support/CMakeLists.txt
  unittests/Support/VersionTupleTest.cpp

Index: unittests/Support/VersionTupleTest.cpp
===
--- /dev/null
+++ unittests/Support/VersionTupleTest.cpp
@@ -0,0 +1,50 @@
+//===- VersionTupleTests.cpp - Version Number Handling Tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "llvm/Support/VersionTuple.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+TEST(VersionTuple, getAsString) {
+  EXPECT_EQ("0", VersionTuple().getAsString());
+  EXPECT_EQ("1", VersionTuple(1).getAsString());
+  EXPECT_EQ("1.2", VersionTuple(1, 2).getAsString());
+  EXPECT_EQ("1.2.3", VersionTuple(1, 2, 3).getAsString());
+  EXPECT_EQ("1.2.3.4", VersionTuple(1, 2, 3, 4).getAsString());
+}
+
+TEST(VersionTuple, tryParse) {
+  VersionTuple VT;
+
+  EXPECT_FALSE(VT.tryParse("1"));
+  EXPECT_EQ("1", VT.getAsString());
+
+  EXPECT_FALSE(VT.tryParse("1.2"));
+  EXPECT_EQ("1.2", VT.getAsString());
+
+  EXPECT_FALSE(VT.tryParse("1.2.3"));
+  EXPECT_EQ("1.2.3", VT.getAsString());
+
+  EXPECT_FALSE(VT.tryParse("1.2.3.4"));
+  EXPECT_EQ("1.2.3.4", VT.getAsString());
+
+  EXPECT_TRUE(VT.tryParse(""));
+  EXPECT_TRUE(VT.tryParse("1."));
+  EXPECT_TRUE(VT.tryParse("1.2."));
+  EXPECT_TRUE(VT.tryParse("1.2.3."));
+  EXPECT_TRUE(VT.tryParse("1.2.3.4."));
+  EXPECT_TRUE(VT.tryParse("1.2.3.4.5"));
+  EXPECT_TRUE(VT.tryParse("1-2"));
+  EXPECT_TRUE(VT.tryParse("1+2"));
+  EXPECT_TRUE(VT.tryParse(".1"));
+  EXPECT_TRUE(VT.tryParse(" 1"));
+  EXPECT_TRUE(VT.tryParse("1 "));
+  EXPECT_TRUE(VT.tryParse("."));
+}
Index: unittests/Support/CMakeLists.txt
===
--- unittests/Support/CMakeLists.txt
+++ unittests/Support/CMakeLists.txt
@@ -61,6 +61,7 @@
   TrailingObjectsTest.cpp
   TrigramIndexTest.cpp
   UnicodeTest.cpp
+  VersionTupleTest.cpp
   YAMLIOTest.cpp
   YAMLParserTest.cpp
   formatted_raw_ostream_test.cpp
Index: lib/Support/VersionTuple.cpp
===
--- /dev/null
+++ lib/Support/VersionTuple.cpp
@@ -0,0 +1,110 @@
+//===- VersionTuple.cpp - Version Number Handling ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file implements the VersionTuple class, which represents a version in
+// the form major[.minor[.subminor]].
+//
+//===--===//
+#include "llvm/Support/VersionTuple.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+std::string VersionTuple::getAsString() const {
+  std::string Result;
+  {
+llvm::raw_string_ostream Out(Result);
+Out << *this;
+  }
+  return Result;
+}
+
+raw_ostream ::operator<<(raw_ostream , const VersionTuple ) {
+  Out << V.getMajor();
+  if (Optional Minor = V.getMinor())
+Out << '.' << *Minor;
+  if (Optional Subminor = V.getSubminor())
+Out << '.' << *Subminor;
+  if (Optional Build = V.getBuild())
+Out << '.' << *Build;
+  return Out;
+}
+
+static bool parseInt(StringRef , unsigned ) {
+  assert(value == 0);
+  if (input.empty())
+return true;
+
+  char next = input[0];
+  input = input.substr(1);
+  if (next < '0' || next > '9')
+return true;
+  value = (unsigned)(next - '0');
+
+  while (!input.empty()) {
+next = input[0];
+if (next < '0' || next > '9')
+  return false;
+input = input.substr(1);
+value = value * 10 + (unsigned)(next - '0');
+  }
+
+  return false;
+}
+
+bool VersionTuple::tryParse(StringRef input) {
+  unsigned major = 0, minor = 0, micro = 0, build = 0;
+
+  // Parse the major version, [0-9]+
+  if (parseInt(input, major))
+return true;
+
+  if (input.empty()) {
+*this = 

[PATCH] D47886: Move VersionTuple from clang/Basic to llvm/Support, clang part

2018-06-07 Thread Pavel Labath via Phabricator via cfe-commits
labath created this revision.
labath added reviewers: erik.pilkington, zturner.
Herald added a subscriber: mgorny.

This kind of functionality is useful to other project apart from clang.
LLDB works with version numbers a lot, but it does not have a convenient
abstraction for this. Moving this class to a lower level library allows
it to be freely used within LLDB.

Since this class is used in a lot of places, and it used to be in the
clang namespace, it seemed appropriate to add it to the list of adopted
classes in LLVM.h to avoid prefixing all uses with "llvm::".


Repository:
  rC Clang

https://reviews.llvm.org/D47886

Files:
  include/clang/AST/Attr.h
  include/clang/AST/Availability.h
  include/clang/AST/DeclBase.h
  include/clang/AST/ExprObjC.h
  include/clang/Basic/AlignedAllocation.h
  include/clang/Basic/LLVM.h
  include/clang/Basic/ObjCRuntime.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/VersionTuple.h
  include/clang/Driver/ToolChain.h
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  lib/AST/DeclBase.cpp
  lib/Basic/CMakeLists.txt
  lib/Basic/ObjCRuntime.cpp
  lib/Basic/VersionTuple.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -53,7 +53,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/Version.h"
-#include "clang/Basic/VersionTuple.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/MacroInfo.h"
@@ -97,6 +96,7 @@
 #include "llvm/Support/OnDiskHashTable.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SHA1.h"
+#include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -61,7 +61,6 @@
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Basic/Version.h"
-#include "clang/Basic/VersionTuple.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
@@ -104,8 +103,8 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/Compression.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/DJB.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Error.h"
@@ -115,6 +114,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/Timer.h"
+#include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -23,7 +23,6 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/Version.h"
-#include "clang/Basic/VersionTuple.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Basic/Visibility.h"
 #include "clang/Basic/XRayInstr.h"
@@ -76,6 +75,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetOptions.h"
 #include 
Index: lib/Driver/ToolChains/Cuda.h
===
--- lib/Driver/ToolChains/Cuda.h
+++ lib/Driver/ToolChains/Cuda.h
@@ -11,14 +11,14 @@
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_CUDA_H
 
 #include "clang/Basic/Cuda.h"
-#include "clang/Basic/VersionTuple.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Multilib.h"
-#include "clang/Driver/ToolChain.h"
 #include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/VersionTuple.h"
 #include 
 #include 
 
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -13,7 +13,6 @@
 #include "ToolChains/Clang.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Sanitizers.h"
-#include "clang/Basic/VersionTuple.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
@@ -29,16 +28,17 @@
 #include 

[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-06-07 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: include/clang/Sema/DeclSpec.h:670
const PrintingPolicy );
+  bool SetTypeSpecSat(SourceLocation Loc, const char *,
+  unsigned );

leonardchan wrote:
> ebevhan wrote:
> > This should take a PrintingPolicy like the others.
> I think the PrintingPolicy may not be necessary because it's only used for 
> getting the name of the current TypeSpecType. More specifically, for just 
> differentiating vetween "bool" and "_Bool" for `TST_bool`. It also seems that 
> other setters that don't touch TypeSpecType use PrintingPolicy, like 
> `SetTypeSpecComplex` or `SetTypeSpecSign`
You are correct, the ones that don't need it don't take it. I'm just being 
selfish since I need it downstream to disambiguate `__sat` and `_Sat`.

It's fine the way it is.



Comment at: lib/Sema/SemaType.cpp:1612
+  // Only fixed point types can be saturated
+  if (DS.isTypeSpecSat() && !IsFixedPointType)
+S.Diag(DS.getTypeSpecSatLoc(), diag::err_invalid_saturation_spec)

leonardchan wrote:
> ebevhan wrote:
> > Also, this does not seem to invalidate the declarator.
> How so? I have tests under `test/Frontend/fixed_point_errors.c` that check 
> for an error thrown if `_Sat` is used with non-fixed point types.
Hm, that is true. We don't have it downstream either. I'm not sure what the 
purpose of doing it is, but other invalid specifiers do 
`declarator.setInvalidType(true);`

I guess it isn't needed, just curious as to why it's done for some other ones.


Repository:
  rC Clang

https://reviews.llvm.org/D46911



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


[PATCH] D47135: [analyzer] A checker for dangling internal buffer pointers in C++

2018-06-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Ping


https://reviews.llvm.org/D47135



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


[PATCH] D46190: For a referenced declaration, mark any associated usings as referenced.

2018-06-07 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

@rsmith anything else needed here?


https://reviews.llvm.org/D46190



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


[PATCH] D47875: [MS ABI] Mangle unnamed empty enums (PR37723)

2018-06-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks!




Comment at: lib/AST/MicrosoftMangle.cpp:888-891
 auto EnumeratorI = ED->enumerator_begin();
-assert(EnumeratorI != ED->enumerator_end());
-Name += "getName();
+if (EnumeratorI == ED->enumerator_end()) {
+  Name += " Thinking about it some more, it'd be better if we handled this like the else 
> case:
>   Name += "   Name += llvm::utostr(Context.getAnonymousStructId(TD) + 1);
> 
> Reason being that something like:
>   struct S {
> enum {};
> enum {};
>   };
> 
> Would otherwise end up with two identical mangles.
> 
> This would also make us more consistent with other mangles, for example:
>   enum {} x;
>   struct {} y;
> 
> These are mangled as:  and .
Okay, yeah that makes sense.

I just checked

struct S {
  enum {};
  enum {};
};

with MSVC, and they seem to give them identical mangling.

I have to head out, but will update the patch tomorrow morning unless you're 
keen to do it :-)


https://reviews.llvm.org/D47875



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


[PATCH] D46911: [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents

2018-06-07 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: include/clang/Sema/DeclSpec.h:670
const PrintingPolicy );
+  bool SetTypeSpecSat(SourceLocation Loc, const char *,
+  unsigned );

ebevhan wrote:
> This should take a PrintingPolicy like the others.
I think the PrintingPolicy may not be necessary because it's only used for 
getting the name of the current TypeSpecType. More specifically, for just 
differentiating vetween "bool" and "_Bool" for `TST_bool`. It also seems that 
other setters that don't touch TypeSpecType use PrintingPolicy, like 
`SetTypeSpecComplex` or `SetTypeSpecSign`



Comment at: lib/Sema/SemaType.cpp:1612
+  // Only fixed point types can be saturated
+  if (DS.isTypeSpecSat() && !IsFixedPointType)
+S.Diag(DS.getTypeSpecSatLoc(), diag::err_invalid_saturation_spec)

ebevhan wrote:
> Also, this does not seem to invalidate the declarator.
How so? I have tests under `test/Frontend/fixed_point_errors.c` that check for 
an error thrown if `_Sat` is used with non-fixed point types.


Repository:
  rC Clang

https://reviews.llvm.org/D46911



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


Re: [PATCH] D47875: [MS ABI] Mangle unnamed empty enums (PR37723)

2018-06-07 Thread Hans Wennborg via cfe-commits
On Thu, Jun 7, 2018 at 4:05 PM, Richard Smith via cfe-commits
 wrote:
>
> struct S { enum {} e; };
>
> ... then do something with decltype(S::e). What happens if there are two
> such types in the class?

The bug doesn't reproduce if the enumeration has a name, which is why
it's hard to reference :-)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47875: [MS ABI] Mangle unnamed empty enums (PR37723)

2018-06-07 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/AST/MicrosoftMangle.cpp:888-891
 auto EnumeratorI = ED->enumerator_begin();
-assert(EnumeratorI != ED->enumerator_end());
-Name += "getName();
+if (EnumeratorI == ED->enumerator_end()) {
+  Name += " and .


https://reviews.llvm.org/D47875



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


[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-06-07 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D47849#1125019, @gtbercea wrote:

> It's precisely the issue which you report here. Since you don't use device 
> specific math functions, you can run into the problem where you may end up 
> calling assembly instructions for a different architecture. I may have 
> mis-classified this as a correctness issue.


I think the issue is slightly different, the assembly is not necessarily in the 
called functions, as I said `sqrt` seems to work fine. Clang just errors 
because they are included via the header.

This is because `clang::InitializePreprocessor` has this:

  // FIXME: This will create multiple definitions for most of the predefined
  // macros. This is not the right way to handle this.
  if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo())
InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts,
   Builder);

So we will end up with all host defines (including `__SSE2_MATH__` as @hfinkel 
wrote) during target compilation :-(


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-06-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D47290#1124991, @hans wrote:

> In https://reviews.llvm.org/D47290#1124964, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D47290#1124956, @hans wrote:
> >
> > > In https://reviews.llvm.org/D47290#1124933, @aaron.ballman wrote:
> > >
> > > > In https://reviews.llvm.org/D47290#1124866, @hans wrote:
> > > >
> > > > > If we really want to special-case NSInteger, and given that you're 
> > > > > targeting a specific wide-spread pattern maybe that's the right thing 
> > > > > to do, I think we should make -Wformat accept (move the warning 
> > > > > behind -Wformat-pedantic I suppose) printing NSInteger with *any* 
> > > > > integral type of the right size, not just size_t.
> > > >
> > > >
> > > > Would you be similarly okay with %ld and %d on Windows platforms when 
> > > > mixing up int and long?
> > >
> > >
> > > No, I'm against a general relaxation of -Wformat, but to solve JF's 
> > > problem I think special-casing NSInteger might be reasonable.
> >
> >
> > How is JF's problem different?
>
>
> It concerns a vendor-specific type. Of course I personally think it would be 
> better if the code could be fixed, but it doesn't sound like that's an option 
> so then I think special-casing for NSInteger is an acceptable solution.


Okay, that's fair, but the vendor-specific type for my Windows example is 
spelled `DWORD`. I'm really worried that this special case will become a 
precedent and we'll wind up with -Wformat being relaxed for everything based on 
the same rationale. If that's how the community wants -Wformat to work, cool, 
but I'd like to know if we're intending to change (what I see as) the design of 
this warning.


Repository:
  rC Clang

https://reviews.llvm.org/D47290



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


[PATCH] D47577: [clang-format] Separate block comments with CRLF correctly

2018-06-07 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a reviewer: djasper.
alexfh added inline comments.



Comment at: lib/Format/BreakableToken.cpp:327
+  TokenText.substr(2, TokenText.size() - 4)
+  .split(Lines, TokenText.count('\r') > 0 ? "\r\n" : "\n");
 

FYI, there's a global UseCRLF flag in WhitespaceManager. It may make sense to 
use it everywhere instead of deciding for each comment. But I'll let actual 
clang-format maintainers decide on pros and cons of this.


Repository:
  rC Clang

https://reviews.llvm.org/D47577



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


[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-06-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D47849#1124638, @Hahnfeld wrote:

> IMO this goes into the right direction, we should use the fast implementation 
> in libdevice. If LLVM doesn't lower these calls in the NVPTX backend, I think 
> it's ok to use header wrappers as CUDA already does.
>
> Two questions:
>
> 1. Can you explain where this is important for "correctness"? Yesterday I 
> compiled a code using `sqrt` and it seems to spit out the correct results. 
> Maybe that's relevant for other functions?
> 2. Incidentally I ran into a closely related problem: I can't `#include 
> ` in translation units compiled for offloading, Clang complains about 
> inline assembly for x86 (see below). Does that work for you?
>
>   ``` In file included from /usr/include/math.h:413: 
> /usr/include/bits/mathinline.h:131:43: error: invalid input constraint 'x' in 
> asm __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x)); ^ 
> /usr/include/bits/mathinline.h:143:43: error: invalid input constraint 'x' in 
> asm __asm ("pmovmskb %1, %0" : "=r" (__m) : "x" (__x)); ^ 2 errors generated. 
> ```


It's precisely the issue which you report here. Since you don't use device 
specific math functions, you can run into the problem where you may end up 
calling assembly instructions for a different architecture. I may have 
mis-classified this as a correctness issue.


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D47704: [clang-tidy] Improve string type matcher for abseil-string-find-starts-with check.

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

LG


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47704



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


[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2018-06-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:65
 }
+#if defined(__cplusplus)
 __DEVICE__ void __brkpt() { asm volatile("brkpt;"); }

Hahnfeld wrote:
> Why is that only valid for C++?
C does not support overloading of functions.


Repository:
  rC Clang

https://reviews.llvm.org/D47849



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


[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-06-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D47290#1124964, @aaron.ballman wrote:

> In https://reviews.llvm.org/D47290#1124956, @hans wrote:
>
> > In https://reviews.llvm.org/D47290#1124933, @aaron.ballman wrote:
> >
> > > In https://reviews.llvm.org/D47290#1124866, @hans wrote:
> > >
> > > > If we really want to special-case NSInteger, and given that you're 
> > > > targeting a specific wide-spread pattern maybe that's the right thing 
> > > > to do, I think we should make -Wformat accept (move the warning behind 
> > > > -Wformat-pedantic I suppose) printing NSInteger with *any* integral 
> > > > type of the right size, not just size_t.
> > >
> > >
> > > Would you be similarly okay with %ld and %d on Windows platforms when 
> > > mixing up int and long?
> >
> >
> > No, I'm against a general relaxation of -Wformat, but to solve JF's problem 
> > I think special-casing NSInteger might be reasonable.
>
>
> How is JF's problem different?


It concerns a vendor-specific type. Of course I personally think it would be 
better if the code could be fixed, but it doesn't sound like that's an option 
so then I think special-casing for NSInteger is an acceptable solution.


Repository:
  rC Clang

https://reviews.llvm.org/D47290



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


Re: [PATCH] D47875: [MS ABI] Mangle unnamed empty enums (PR37723)

2018-06-07 Thread Richard Smith via cfe-commits
On Thu, 7 Jun 2018, 13:54 Hans Wennborg via Phabricator via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> hans added a comment.
>
> Please take a look.
>
> I couldn't figure out a way to get a mangled name for this without using
> debug info. Do you have any ideas?
>

struct S { enum {} e; };

... then do something with decltype(S::e). What happens if there are two
such types in the class?

https://reviews.llvm.org/D47875
>
>
>
> ___
> 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] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-06-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D47290#1124956, @hans wrote:

> In https://reviews.llvm.org/D47290#1124933, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D47290#1124866, @hans wrote:
> >
> > > If we really want to special-case NSInteger, and given that you're 
> > > targeting a specific wide-spread pattern maybe that's the right thing to 
> > > do, I think we should make -Wformat accept (move the warning behind 
> > > -Wformat-pedantic I suppose) printing NSInteger with *any* integral type 
> > > of the right size, not just size_t.
> >
> >
> > Would you be similarly okay with %ld and %d on Windows platforms when 
> > mixing up int and long?
>
>
> No, I'm against a general relaxation of -Wformat, but to solve JF's problem I 
> think special-casing NSInteger might be reasonable.


How is JF's problem different?


Repository:
  rC Clang

https://reviews.llvm.org/D47290



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


[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-06-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D47290#1124933, @aaron.ballman wrote:

> In https://reviews.llvm.org/D47290#1124866, @hans wrote:
>
> > If we really want to special-case NSInteger, and given that you're 
> > targeting a specific wide-spread pattern maybe that's the right thing to 
> > do, I think we should make -Wformat accept (move the warning behind 
> > -Wformat-pedantic I suppose) printing NSInteger with *any* integral type of 
> > the right size, not just size_t.
>
>
> Would you be similarly okay with %ld and %d on Windows platforms when mixing 
> up int and long?


No, I'm against a general relaxation of -Wformat, but to solve JF's problem I 
think special-casing NSInteger might be reasonable.


Repository:
  rC Clang

https://reviews.llvm.org/D47290



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


[PATCH] D47864: [python] Fix most Python binding unittests on Windows

2018-06-07 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

I don't know much about the python bindings, but this is probably fine.


Repository:
  rC Clang

https://reviews.llvm.org/D47864



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


[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-06-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D47290#1124866, @hans wrote:

> If we really want to special-case NSInteger, and given that you're targeting 
> a specific wide-spread pattern maybe that's the right thing to do, I think we 
> should make -Wformat accept (move the warning behind -Wformat-pedantic I 
> suppose) printing NSInteger with *any* integral type of the right size, not 
> just size_t.


Would you be similarly okay with %ld and %d on Windows platforms when mixing up 
int and long?


Repository:
  rC Clang

https://reviews.llvm.org/D47290



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


[PATCH] D46757: [clang-format] Break inside submessages containing a submessage and something else

2018-06-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 150320.
krasimir added a comment.

- Add comments tests


Repository:
  rC Clang

https://reviews.llvm.org/D46757

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestRawStrings.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -171,17 +171,48 @@
   verifyFormat("msg_field < field_a < field_b <> > >");
   verifyFormat("msg_field: < field_a < field_b: <> > >");
   verifyFormat("msg_field < field_a: OK, field_b: \"OK\" >");
-  verifyFormat("msg_field < field_a: OK field_b: <>, field_c: OK >");
-  verifyFormat("msg_field < field_a { field_b: 1 }, field_c: < f_d: 2 > >");
   verifyFormat("msg_field: < field_a: OK, field_b: \"OK\" >");
-  verifyFormat("msg_field: < field_a: OK field_b: <>, field_c: OK >");
-  verifyFormat("msg_field: < field_a { field_b: 1 }, field_c: < fd_d: 2 > >");
-  verifyFormat("field_a: \"OK\", msg_field: < field_b: 123 >, field_c: {}");
-  verifyFormat("field_a < field_b: 1 >, msg_fid: < fiel_b: 123 >, field_c <>");
-  verifyFormat("field_a < field_b: 1 > msg_fied: < field_b: 123 > field_c <>");
-  verifyFormat("field < field < field: <> >, field <> > field: < field: 1 >");
-
   // Multiple lines tests
+  verifyFormat("msg_field <\n"
+   "  field_a: OK\n"
+   "  field_b: <>,\n"
+   "  field_c: OK\n"
+   ">");
+
+  verifyFormat("msg_field <\n"
+   "  field_a { field_b: 1 },\n"
+   "  field_c: < f_d: 2 >\n"
+   ">");
+
+  verifyFormat("msg_field: <\n"
+   "  field_a: OK\n"
+   "  field_b: <>,\n"
+   "  field_c: OK\n"
+   ">");
+
+  verifyFormat("msg_field: <\n"
+   "  field_a { field_b: 1 },\n"
+   "  field_c: < fd_d: 2 >\n"
+   ">");
+
+  verifyFormat("field_a: \"OK\",\n"
+   "msg_field: < field_b: 123 >,\n"
+   "field_c: {}");
+
+  verifyFormat("field_a < field_b: 1 >,\n"
+   "msg_fid: < fiel_b: 123 >,\n" 
+   "field_c <>");
+
+  verifyFormat("field_a < field_b: 1 >\n"
+   "msg_fied: < field_b: 123 >\n"
+   "field_c <>");
+
+  verifyFormat("field <\n"
+   "  field < field: <> >,\n"
+   "  field <>\n"
+   ">\n"
+   "field: < field: 1 >");
+
   verifyFormat("msg_field <\n"
"  field_a: OK\n"
"  field_b: \"OK\"\n"
@@ -242,7 +273,10 @@
"  field_d: ok\n"
"}");
 
-  verifyFormat("field_a: < f1: 1, f2: <> >\n"
+  verifyFormat("field_a: <\n"
+   "  f1: 1,\n"
+   "  f2: <>\n"
+   ">\n"
"field_b <\n"
"  field_b1: <>\n"
"  field_b2: ok,\n"
@@ -507,5 +541,112 @@
">");
 }
 
+TEST_F(FormatTestTextProto, BreaksEntriesOfSubmessagesContainingSubmessages) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+  Style.ColumnLimit = 60;
+  // The column limit allows for the keys submessage to be put on 1 line, but we
+  // break it since it contains a submessage an another entry.
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: ''\n"
+   "  sub <>\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: ''\n"
+   "  sub {}\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub {}\n"
+   "  sub: <>\n"
+   "  sub: []\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub { msg: 1 }\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub: { msg: 1 }\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub < msg: 1 >\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub: [ msg: 1 ]\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: <\n"
+   "  item: 'aaa'\n"
+   "  sub: [ 1, 2 ]\n"
+   ">");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub {}\n"
+   "  item: ''\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub: []\n"
+

[PATCH] D46757: [clang-format] Break inside submessages containing a submessage and something else

2018-06-07 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 150317.
krasimir added a comment.

- Update comments


Repository:
  rC Clang

https://reviews.llvm.org/D46757

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp
  unittests/Format/FormatTestRawStrings.cpp
  unittests/Format/FormatTestTextProto.cpp

Index: unittests/Format/FormatTestTextProto.cpp
===
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -171,17 +171,48 @@
   verifyFormat("msg_field < field_a < field_b <> > >");
   verifyFormat("msg_field: < field_a < field_b: <> > >");
   verifyFormat("msg_field < field_a: OK, field_b: \"OK\" >");
-  verifyFormat("msg_field < field_a: OK field_b: <>, field_c: OK >");
-  verifyFormat("msg_field < field_a { field_b: 1 }, field_c: < f_d: 2 > >");
   verifyFormat("msg_field: < field_a: OK, field_b: \"OK\" >");
-  verifyFormat("msg_field: < field_a: OK field_b: <>, field_c: OK >");
-  verifyFormat("msg_field: < field_a { field_b: 1 }, field_c: < fd_d: 2 > >");
-  verifyFormat("field_a: \"OK\", msg_field: < field_b: 123 >, field_c: {}");
-  verifyFormat("field_a < field_b: 1 >, msg_fid: < fiel_b: 123 >, field_c <>");
-  verifyFormat("field_a < field_b: 1 > msg_fied: < field_b: 123 > field_c <>");
-  verifyFormat("field < field < field: <> >, field <> > field: < field: 1 >");
-
   // Multiple lines tests
+  verifyFormat("msg_field <\n"
+   "  field_a: OK\n"
+   "  field_b: <>,\n"
+   "  field_c: OK\n"
+   ">");
+
+  verifyFormat("msg_field <\n"
+   "  field_a { field_b: 1 },\n"
+   "  field_c: < f_d: 2 >\n"
+   ">");
+
+  verifyFormat("msg_field: <\n"
+   "  field_a: OK\n"
+   "  field_b: <>,\n"
+   "  field_c: OK\n"
+   ">");
+
+  verifyFormat("msg_field: <\n"
+   "  field_a { field_b: 1 },\n"
+   "  field_c: < fd_d: 2 >\n"
+   ">");
+
+  verifyFormat("field_a: \"OK\",\n"
+   "msg_field: < field_b: 123 >,\n"
+   "field_c: {}");
+
+  verifyFormat("field_a < field_b: 1 >,\n"
+   "msg_fid: < fiel_b: 123 >,\n" 
+   "field_c <>");
+
+  verifyFormat("field_a < field_b: 1 >\n"
+   "msg_fied: < field_b: 123 >\n"
+   "field_c <>");
+
+  verifyFormat("field <\n"
+   "  field < field: <> >,\n"
+   "  field <>\n"
+   ">\n"
+   "field: < field: 1 >");
+
   verifyFormat("msg_field <\n"
"  field_a: OK\n"
"  field_b: \"OK\"\n"
@@ -242,7 +273,10 @@
"  field_d: ok\n"
"}");
 
-  verifyFormat("field_a: < f1: 1, f2: <> >\n"
+  verifyFormat("field_a: <\n"
+   "  f1: 1,\n"
+   "  f2: <>\n"
+   ">\n"
"field_b <\n"
"  field_b1: <>\n"
"  field_b2: ok,\n"
@@ -507,5 +541,107 @@
">");
 }
 
+TEST_F(FormatTestTextProto, BreaksEntriesOfSubmessagesContainingSubmessages) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+  Style.ColumnLimit = 60;
+  // The column limit allows for the keys submessage to be put on 1 line, but we
+  // break it since it contains a submessage an another entry.
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: ''\n"
+   "  sub <>\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: ''\n"
+   "  sub {}\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub {}\n"
+   "  sub: <>\n"
+   "  sub: []\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub { msg: 1 }\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub: { msg: 1 }\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub < msg: 1 >\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  item: 'aaa'\n"
+   "  sub: [ msg: 1 ]\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: <\n"
+   "  item: 'aaa'\n"
+   "  sub: [ 1, 2 ]\n"
+   ">");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub {}\n"
+   "  item: ''\n"
+   "}");
+  verifyFormat("key: valu\n"
+   "keys: {\n"
+   "  sub: []\n"
+   

[PATCH] D47871: [clangd] Code completion: drop explicit injected names/operators, ignore Sema priority

2018-06-07 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334192: [clangd] Code completion: drop explicit injected 
names/operators, ignore Sema… (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47871

Files:
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Quality.cpp
  clang-tools-extra/trunk/clangd/Quality.h
  clang-tools-extra/trunk/test/clangd/completion.test
  clang-tools-extra/trunk/test/clangd/protocol.test
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
  clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp

Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -18,8 +18,8 @@
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "a",
 # CHECK-NEXT:  "sortText": "{{.*}}a"
-# CHECK-NEXT:},
-#  CHECK:  ]
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
 ---
 # Update the source file and check for completions again.
 {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp","version":2},"contentChanges":[{"text":"struct S { int b; };\nint main() {\nS().\n}"}]}}
@@ -38,7 +38,7 @@
 # CHECK-NEXT:  "kind": 5,
 # CHECK-NEXT:  "label": "b",
 # CHECK-NEXT:  "sortText": "{{.*}}b"
-# CHECK-NEXT:},
-#  CHECK:  ]
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
 ---
 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
Index: clang-tools-extra/trunk/test/clangd/protocol.test
===
--- clang-tools-extra/trunk/test/clangd/protocol.test
+++ clang-tools-extra/trunk/test/clangd/protocol.test
@@ -34,11 +34,11 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"isIncomplete": false,
 # CHECK-NEXT:"items": [
-#  CHECK:"filterText": "fake",
-# CHECK-NEXT:"insertText": "fake",
+#  CHECK:"filterText": "a",
+# CHECK-NEXT:"insertText": "a",
 # CHECK-NEXT:"insertTextFormat": 1,
-# CHECK-NEXT:"kind": 7,
-# CHECK-NEXT:"label": "fake",
+# CHECK-NEXT:"kind": 5,
+# CHECK-NEXT:"label": "a",
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -63,11 +63,11 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"isIncomplete": false,
 # CHECK-NEXT:"items": [
-#  CHECK:"filterText": "fake",
-# CHECK-NEXT:"insertText": "fake",
+#  CHECK:"filterText": "a",
+# CHECK-NEXT:"insertText": "a",
 # CHECK-NEXT:"insertTextFormat": 1,
-# CHECK-NEXT:"kind": 7,
-# CHECK-NEXT:"label": "fake",
+# CHECK-NEXT:"kind": 5,
+# CHECK-NEXT:"label": "a",
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
@@ -92,11 +92,11 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"isIncomplete": false,
 # CHECK-NEXT:"items": [
-#  CHECK:"filterText": "fake",
-# CHECK-NEXT:"insertText": "fake",
+#  CHECK:"filterText": "a",
+# CHECK-NEXT:"insertText": "a",
 # CHECK-NEXT:"insertTextFormat": 1,
-# CHECK-NEXT:"kind": 7,
-# CHECK-NEXT:"label": "fake",
+# CHECK-NEXT:"kind": 5,
+# CHECK-NEXT:"label": "a",
 # CHECK-NEXT:"sortText": "{{.*}}"
 #  CHECK:]
 # CHECK-NEXT:  }
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -207,9 +207,6 @@
   EXPECT_THAT(completions(Body + "int main() { S().FR^ }").items,
   AllOf(Has("FooBar"), Not(Has("FooBaz")), Not(Has("Qux";
 
-  EXPECT_THAT(completions(Body + "int main() { S().opr^ }").items,
-  Has("operator="));
-
   EXPECT_THAT(completions(Body + "int main() { aaa^ }").items,
   AllOf(Has("Abracadabra"), Has("Alakazam")));
 
@@ -250,9 +247,10 @@
 
   // Class members. The only items that must be present in after-dot
   // completion.
-  EXPECT_THAT(
-  Results.items,
-  AllOf(Has(Opts.EnableSnippets ? "method()" : "method"), Has("field")));
+  EXPECT_THAT(Results.items,
+  AllOf(Has(Opts.EnableSnippets ? "method()" : "method"),
+Has("field"), Not(Has("ClassWithMembers")),
+Not(Has("operator=")), Not(Has("~ClassWithMembers";
   EXPECT_IFF(Opts.IncludeIneligibleResults, Results.items,
  Has("private_field"));
   // Global items.
@@ -379,6 +377,25 @@
   EXPECT_THAT(Results.items, Not(Contains(Labeled("foo() const"; // private
 }
 
+TEST(CompletionTest, InjectedTypename) {
+  // These are suppressed when accessed as a 

[clang-tools-extra] r334192 - [clangd] Code completion: drop explicit injected names/operators, ignore Sema priority

2018-06-07 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jun  7 05:49:17 2018
New Revision: 334192

URL: http://llvm.org/viewvc/llvm-project?rev=334192=rev
Log:
[clangd] Code completion: drop explicit injected names/operators, ignore Sema 
priority

Summary:
Now we have most of Sema's code completion signals incorporated in Quality,
which will allow us to give consistent ranking to sema/index results.

Therefore we can/should stop using Sema priority as an explicit signal.
This fixes some issues like namespaces always having a terrible score.

The most important missing signals are:
 - Really dumb/rarely useful completions like:
SomeStruct().^SomeStruct
SomeStruct().^operator=
SomeStruct().~SomeStruct()
   We already filter out destructors, this patch adds injected names and
   operators to that list.
 - type matching the expression context.
   Ilya has a plan to add this in a way that's compatible with indexes
   (design doc should be shared real soon now!)

Reviewers: ioeric

Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Quality.cpp
clang-tools-extra/trunk/clangd/Quality.h
clang-tools-extra/trunk/test/clangd/completion.test
clang-tools-extra/trunk/test/clangd/protocol.test
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=334192=334191=334192=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jun  7 05:49:17 2018
@@ -467,6 +467,25 @@ bool contextAllowsIndex(enum CodeComplet
   llvm_unreachable("unknown code completion context");
 }
 
+// Some member calls are blacklisted because they're so rarely useful.
+static bool isBlacklistedMember(const NamedDecl ) {
+  // Destructor completion is rarely useful, and works inconsistently.
+  // (s.^ completes ~string, but s.~st^ is an error).
+  if (D.getKind() == Decl::CXXDestructor)
+return true;
+  // Injected name may be useful for A::foo(), but who writes A::A::foo()?
+  if (auto *R = dyn_cast_or_null())
+if (R->isInjectedClassName())
+  return true;
+  // Explicit calls to operators are also rare.
+  auto NameKind = D.getDeclName().getNameKind();
+  if (NameKind == DeclarationName::CXXOperatorName ||
+  NameKind == DeclarationName::CXXLiteralOperatorName ||
+  NameKind == DeclarationName::CXXConversionFunctionName)
+return true;
+  return false;
+}
+
 // The CompletionRecorder captures Sema code-complete output, including 
context.
 // It filters out ignored results (but doesn't apply fuzzy-filtering yet).
 // It doesn't do scoring or conversion to CompletionItem yet, as we want to
@@ -520,9 +539,9 @@ struct CompletionRecorder : public CodeC
   (Result.Availability == CXAvailability_NotAvailable ||
Result.Availability == CXAvailability_NotAccessible))
 continue;
-  // Destructor completion is rarely useful, and works inconsistently.
-  // (s.^ completes ~string, but s.~st^ is an error).
-  if (dyn_cast_or_null(Result.Declaration))
+  if (Result.Declaration &&
+  !Context.getBaseType().isNull() // is this a member-access context?
+  && isBlacklistedMember(*Result.Declaration))
 continue;
   // We choose to never append '::' to completion results in clangd.
   Result.StartsNestedNameSpecifier = false;

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=334192=334191=334192=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Thu Jun  7 05:49:17 2018
@@ -94,7 +94,6 @@ categorize(const index::SymbolInfo ) {
 }
 
 void SymbolQualitySignals::merge(const CodeCompletionResult ) {
-  SemaCCPriority = SemaCCResult.Priority;
   if (SemaCCResult.Availability == CXAvailability_Deprecated)
 Deprecated = true;
 
@@ -117,11 +116,6 @@ float SymbolQualitySignals::evaluate() c
   if (References >= 3)
 Score *= std::log(References);
 
-  if (SemaCCPriority)
-// Map onto a 0-2 interval, so we don't reward/penalize non-Sema results.
-// Priority 80 is a really bad score.
-Score *= 2 - std::min(80, SemaCCPriority) / 40;
-
   if (Deprecated)
 Score *= 0.1f;
 
@@ -146,8 +140,6 @@ float SymbolQualitySignals::evaluate() c
 
 raw_ostream <<(raw_ostream , const SymbolQualitySignals ) {
   OS << formatv("=== Symbol quality: {0}\n", S.evaluate());
-  if (S.SemaCCPriority)
-OS << formatv("\tSemaCCPriority: 

[PATCH] D47871: [clangd] Code completion: drop explicit injected names/operators, ignore Sema priority

2018-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added a comment.

Added explicit tests for this feature.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47871



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


[PATCH] D47871: [clangd] Code completion: drop explicit injected names/operators, ignore Sema priority

2018-06-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 150307.
sammccall added a comment.

Added tests and comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47871

Files:
  clangd/CodeComplete.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  test/clangd/completion.test
  test/clangd/protocol.test
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/QualityTests.cpp

Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -39,23 +39,20 @@
   SymbolQualitySignals Quality;
   Quality.merge(findSymbol(Symbols, "x"));
   EXPECT_FALSE(Quality.Deprecated);
-  EXPECT_EQ(Quality.SemaCCPriority, SymbolQualitySignals().SemaCCPriority);
   EXPECT_EQ(Quality.References, SymbolQualitySignals().References);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Variable);
 
   Symbol F = findSymbol(Symbols, "f");
   F.References = 24; // TestTU doesn't count references, so fake it.
   Quality = {};
   Quality.merge(F);
   EXPECT_FALSE(Quality.Deprecated); // FIXME: Include deprecated bit in index.
-  EXPECT_EQ(Quality.SemaCCPriority, SymbolQualitySignals().SemaCCPriority);
   EXPECT_EQ(Quality.References, 24u);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
 
   Quality = {};
   Quality.merge(CodeCompletionResult((AST, "f"), /*Priority=*/42));
   EXPECT_TRUE(Quality.Deprecated);
-  EXPECT_EQ(Quality.SemaCCPriority, 42u);
   EXPECT_EQ(Quality.References, SymbolQualitySignals().References);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
 }
@@ -121,12 +118,6 @@
   EXPECT_GT(WithReferences.evaluate(), Default.evaluate());
   EXPECT_GT(ManyReferences.evaluate(), WithReferences.evaluate());
 
-  SymbolQualitySignals LowPriority, HighPriority;
-  LowPriority.SemaCCPriority = 60;
-  HighPriority.SemaCCPriority = 20;
-  EXPECT_GT(HighPriority.evaluate(), Default.evaluate());
-  EXPECT_LT(LowPriority.evaluate(), Default.evaluate());
-
   SymbolQualitySignals Variable, Macro;
   Variable.Category = SymbolQualitySignals::Variable;
   Macro.Category = SymbolQualitySignals::Macro;
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -207,9 +207,6 @@
   EXPECT_THAT(completions(Body + "int main() { S().FR^ }").items,
   AllOf(Has("FooBar"), Not(Has("FooBaz")), Not(Has("Qux";
 
-  EXPECT_THAT(completions(Body + "int main() { S().opr^ }").items,
-  Has("operator="));
-
   EXPECT_THAT(completions(Body + "int main() { aaa^ }").items,
   AllOf(Has("Abracadabra"), Has("Alakazam")));
 
@@ -250,9 +247,10 @@
 
   // Class members. The only items that must be present in after-dot
   // completion.
-  EXPECT_THAT(
-  Results.items,
-  AllOf(Has(Opts.EnableSnippets ? "method()" : "method"), Has("field")));
+  EXPECT_THAT(Results.items,
+  AllOf(Has(Opts.EnableSnippets ? "method()" : "method"),
+Has("field"), Not(Has("ClassWithMembers")),
+Not(Has("operator=")), Not(Has("~ClassWithMembers";
   EXPECT_IFF(Opts.IncludeIneligibleResults, Results.items,
  Has("private_field"));
   // Global items.
@@ -379,6 +377,25 @@
   EXPECT_THAT(Results.items, Not(Contains(Labeled("foo() const"; // private
 }
 
+TEST(CompletionTest, InjectedTypename) {
+  // These are suppressed when accessed as a member...
+  EXPECT_THAT(completions("struct X{}; void foo(){ X().^ }").items,
+  Not(Has("X")));
+  EXPECT_THAT(completions("struct X{ void foo(){ this->^ } };").items,
+  Not(Has("X")));
+  // ...but accessible in other, more useful cases.
+  EXPECT_THAT(completions("struct X{ void foo(){ ^ } };").items, Has("X"));
+  EXPECT_THAT(completions("struct Y{}; struct X:Y{ void foo(){ ^ } };").items,
+  Has("Y"));
+  EXPECT_THAT(
+  completions(
+  "template struct Y{}; struct X:Y{ void foo(){ ^ } };")
+  .items,
+  Has("Y"));
+  // This case is marginal (`using X::X` is useful), we allow it for now.
+  EXPECT_THAT(completions("struct X{}; void foo(){ X::^ }").items, Has("X"));
+}
+
 TEST(CompletionTest, Snippets) {
   clangd::CodeCompleteOptions Opts;
   Opts.EnableSnippets = true;
Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -34,11 +34,11 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"isIncomplete": false,
 # CHECK-NEXT:"items": [
-#  CHECK:"filterText": "fake",
-# CHECK-NEXT:"insertText": "fake",
+#  CHECK:"filterText": "a",
+# CHECK-NEXT:"insertText": "a",
 # CHECK-NEXT:"insertTextFormat": 1,
-# CHECK-NEXT:"kind": 7,
-# CHECK-NEXT:"label": "fake",
+# CHECK-NEXT:"kind": 5,
+# 

  1   2   >