[PATCH] D44878: Adding fuzzer flags support to OpenBSD driver

2018-04-10 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329779: Adding fuzzer flags support to OpenBSD driver 
(authored by dberris, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D44878

Files:
  lib/Driver/ToolChains/OpenBSD.cpp


Index: lib/Driver/ToolChains/OpenBSD.cpp
===
--- lib/Driver/ToolChains/OpenBSD.cpp
+++ lib/Driver/ToolChains/OpenBSD.cpp
@@ -241,8 +241,11 @@
   // For future use, only UBsan at the moment
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
 
-  if (IsX86 || IsX86_64)
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
+  }
 
   return Res;
 }


Index: lib/Driver/ToolChains/OpenBSD.cpp
===
--- lib/Driver/ToolChains/OpenBSD.cpp
+++ lib/Driver/ToolChains/OpenBSD.cpp
@@ -241,8 +241,11 @@
   // For future use, only UBsan at the moment
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
 
-  if (IsX86 || IsX86_64)
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
+  }
 
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329779 - Adding fuzzer flags support to OpenBSD driver

2018-04-10 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Apr 10 22:40:47 2018
New Revision: 329779

URL: http://llvm.org/viewvc/llvm-project?rev=329779=rev
Log:
Adding fuzzer flags support to OpenBSD driver

Summary: - Following-up the sanitizer's part commit 
https://reviews.llvm.org/rCRT329631, we enable fuzzer flags.

Reviewers: brad, thakis, dberris

Reviewed By: dberris

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=329779=329778=329779=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Tue Apr 10 22:40:47 2018
@@ -241,8 +241,11 @@ SanitizerMask OpenBSD::getSupportedSanit
   // For future use, only UBsan at the moment
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
 
-  if (IsX86 || IsX86_64)
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Fuzzer;
+Res |= SanitizerKind::FuzzerNoLink;
+  }
 
   return Res;
 }


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


[PATCH] D45511: [CMake][Fuchsia] Don't specify libc++ ABI version for Fuchsia

2018-04-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, jakehehrlich, juliehockett.
Herald added subscribers: cfe-commits, mgorny.
Herald added a reviewer: EricWF.

This is now set automatically in libc++ config header.


Repository:
  rC Clang

https://reviews.llvm.org/D45511

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -73,7 +73,6 @@
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -73,7 +73,6 @@
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
-  set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
   set(RUNTIMES_${target}-fuchsia_LIBCXX_ENABLE_STATIC OFF CACHE BOOL "")
   set(RUNTIMES_${target}-fuchsia_SANITIZER_USE_COMPILER_RT ON CACHE BOOL "")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44878: Adding fuzzer flags support to OpenBSD driver

2018-04-10 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

ACK -- let me land now. :)


https://reviews.llvm.org/D44878



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


[PATCH] D44878: Adding fuzzer flags support to OpenBSD driver

2018-04-10 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

Hope it s good enough now :-)


https://reviews.llvm.org/D44878



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


r329777 - [X86] Fix typo in intrinsic header file __mask16->__mmask16 from r329775.

2018-04-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Apr 10 22:17:14 2018
New Revision: 329777

URL: http://llvm.org/viewvc/llvm-project?rev=329777=rev
Log:
[X86] Fix typo in intrinsic header file __mask16->__mmask16 from r329775.

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

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=329777=329776=329777=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue Apr 10 22:17:14 2018
@@ -1101,14 +1101,14 @@ _mm512_madd_epi16(__m512i __A, __m512i _
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_mask_madd_epi16(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) {
-  return (__m512i)__builtin_ia32_selectd_512((__mask16)__U,
+  return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U,
(__v16si)_mm512_madd_epi16(__A, 
__B),
(__v16si)__W);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_maskz_madd_epi16(__mmask16 __U, __m512i __A, __m512i __B) {
-  return (__m512i)__builtin_ia32_selectd_512((__mask16)__U,
+  return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U,
(__v16si)_mm512_madd_epi16(__A, 
__B),
(__v16si)_mm512_setzero_si512());
 }


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


r329775 - [X86] Replace 512-bit masked pmaddubsw and pmaddwd intrinsic with unmasked intrinsic and a select.

2018-04-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Apr 10 21:55:10 2018
New Revision: 329775

URL: http://llvm.org/viewvc/llvm-project?rev=329775=rev
Log:
[X86] Replace 512-bit masked pmaddubsw and pmaddwd intrinsic with unmasked 
intrinsic and a select.

This makes it consistent with the 128/256-bit functions.

Someday maybe we'll have all the masking moved to selects.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/test/CodeGen/avx512bw-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=329775=329774=329775=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Apr 10 21:55:10 2018
@@ -1151,8 +1151,8 @@ TARGET_BUILTIN(__builtin_ia32_mulps512_m
 TARGET_BUILTIN(__builtin_ia32_subpd512_mask, "V8dV8dV8dV8dUcIi", "", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_subps512_mask, "V16fV16fV16fV16fUsIi", "", 
"avx512f")
 
-TARGET_BUILTIN(__builtin_ia32_pmaddubsw512_mask, "V32sV64cV64cV32sUi", "", 
"avx512bw")
-TARGET_BUILTIN(__builtin_ia32_pmaddwd512_mask, "V16iV32sV32sV16iUs", "", 
"avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pmaddubsw512, "V32sV64cV64c", "", "avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pmaddwd512, "V16iV32sV32s", "", "avx512bw")
 
 TARGET_BUILTIN(__builtin_ia32_addss_round_mask, "V4fV4fV4fV4fUcIi", "", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_divss_round_mask, "V4fV4fV4fV4fUcIi", "", 
"avx512f")

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=329775=329774=329775=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue Apr 10 21:55:10 2018
@@ -1075,53 +1075,42 @@ _mm512_maskz_mulhi_epu16 (__mmask32 __U,
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_maddubs_epi16 (__m512i __X, __m512i __Y) {
-  return (__m512i) __builtin_ia32_pmaddubsw512_mask ((__v64qi) __X,
- (__v64qi) __Y,
- (__v32hi) _mm512_setzero_hi(),
- (__mmask32) -1);
+_mm512_maddubs_epi16(__m512i __X, __m512i __Y) {
+  return (__m512i)__builtin_ia32_pmaddubsw512((__v64qi)__X, (__v64qi)__Y);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_mask_maddubs_epi16 (__m512i __W, __mmask32 __U, __m512i __X,
- __m512i __Y) {
-  return (__m512i) __builtin_ia32_pmaddubsw512_mask ((__v64qi) __X,
- (__v64qi) __Y,
- (__v32hi) __W,
- (__mmask32) __U);
+_mm512_mask_maddubs_epi16(__m512i __W, __mmask32 __U, __m512i __X,
+  __m512i __Y) {
+  return (__m512i)__builtin_ia32_selectw_512((__mmask32) __U,
+(__v32hi)_mm512_maddubs_epi16(__X, 
__Y),
+(__v32hi)__W);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_maskz_maddubs_epi16 (__mmask32 __U, __m512i __X, __m512i __Y) {
-  return (__m512i) __builtin_ia32_pmaddubsw512_mask ((__v64qi) __X,
- (__v64qi) __Y,
- (__v32hi) _mm512_setzero_hi(),
- (__mmask32) __U);
+_mm512_maskz_maddubs_epi16(__mmask32 __U, __m512i __X, __m512i __Y) {
+  return (__m512i)__builtin_ia32_selectw_512((__mmask32) __U,
+(__v32hi)_mm512_maddubs_epi16(__X, 
__Y),
+(__v32hi)_mm512_setzero_hi());
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_madd_epi16 (__m512i __A, __m512i __B) {
-  return (__m512i) __builtin_ia32_pmaddwd512_mask ((__v32hi) __A,
-   (__v32hi) __B,
-   (__v16si) _mm512_setzero_si512(),
-   (__mmask16) -1);
+_mm512_madd_epi16(__m512i __A, __m512i __B) {
+  return (__m512i)__builtin_ia32_pmaddwd512((__v32hi)__A, (__v32hi)__B);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_mask_madd_epi16 (__m512i __W, __mmask16 __U, __m512i __A,
-  __m512i __B) {
-  return (__m512i) __builtin_ia32_pmaddwd512_mask ((__v32hi) __A,
-   (__v32hi) __B,
-   (__v16si) __W,
-   (__mmask16) __U);
+_mm512_mask_madd_epi16(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) {
+  return (__m512i)__builtin_ia32_selectd_512((__mask16)__U,
+   (__v16si)_mm512_madd_epi16(__A, 
__B),
+   (__v16si)__W);
 }
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
-_mm512_maskz_madd_epi16 (__mmask16 __U, __m512i __A, __m512i __B) {
-  return (__m512i) __builtin_ia32_pmaddwd512_mask ((__v32hi) __A,
-   (__v32hi) __B,
-   (__v16si) _mm512_setzero_si512(),
-   (__mmask16) __U);

Re: [PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-10 Thread Zinovy Nis via cfe-commits
Roman, I see you've fixed them. Thanks a lot!
I did not face with these errors on MSVS'201 so  had no chance to fix early.


ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
revi...@reviews.llvm.org>:

> lebedev.ri added a comment.
>
> This change had two different problems.
> Please watch the bots?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D45405
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-10 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a subscriber: angelgarcia.
zinovy.nis added a comment.

Roman, I see you've fixed them. Thanks a lot!
I did not face with these errors on MSVS'201 so  had no chance to fix early.

ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
revi...@reviews.llvm.org>:

> lebedev.ri added a comment.
> 
> This change had two different problems.
>  Please watch the bots?
> 
> Repository:
> 
>   rL LLVM
> 
> https://reviews.llvm.org/D45405


Repository:
  rL LLVM

https://reviews.llvm.org/D45405



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/clang/AST/ComparisonCategories.h:155-158
+  const ComparisonCategoryInfo (ComparisonCategoryKind Kind) const {
+assert(HasData && "comparison category information not yet built");
+return Data[static_cast(Kind)];
+  }

aaron.ballman wrote:
> It seems like this method can be private rather than public.
`getInfo`? No that's used elsewhere.



Comment at: include/clang/AST/Expr.h:3020
+  // ordered comparison. Otherwise the comparison is an equality comparison.
+  unsigned IsCmpOrdered : 1;
+

aaron.ballman wrote:
> It's unfortunate that this means we're using 9 bits rather than the 8 we were 
> previously using, but I don't see a particularly good way to solve that.
It doesn't seem to be an actual problem. That is, it doesn't change the size of 
`BinaryOperator`. Even sinking the bits into a new Stmt bitfield class has no 
effect, even though there is room for them there.



Comment at: lib/CodeGen/CGExprAgg.cpp:925-929
+  } else if (ArgTy->isIntegralOrEnumerationType() || ArgTy->isPointerType()) {
+auto Inst =
+ArgTy->hasSignedIntegerRepresentation() ? InstInfo.SCmp : 
InstInfo.UCmp;
+return Builder.CreateICmp(Inst, LHS, RHS, "cmp");
+  } else if (ArgTy->isAnyComplexType()) {

aaron.ballman wrote:
> You can remove the `else` after a return and just turn these into `if` 
> statements.
I kind of like the  unimplemented cases being chained via `else if` to the 
implemented ones. It implies that "these are all the cases there are and 
they're mutually exclusive".


https://reviews.llvm.org/D45476



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


[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I mean, like, if we try to work with the existing AST then we're stuck with a 
prvalue expression that represents an lvalue and will be assigned a `Loc` 
value, which is pretty weird anyway. Getting rid of the ParentMap in favor of 
providing enough context (eg. in the CFG or in checker callbacks) whenever we 
might want to use it sounds like a much saner solution. There might be other 
"unknown unknowns" about rewriting the AST, but our current problem looks as 
safe as we'll ever get.


Repository:
  rC Clang

https://reviews.llvm.org/D45416



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


[PATCH] D41748: [libcxx] [test] Fix Xxx_scan tests using nonstandard things and MSVC++ warnings

2018-04-10 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal accepted this revision.
BillyONeal added a comment.
This revision is now accepted and ready to land.

It actually looks like I accidentally committed this back in January so I'm 
going to close this :)


https://reviews.llvm.org/D41748



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


r329773 - [XRay][clang] Only enable test for supported platforms

2018-04-10 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Apr 10 18:47:40 2018
New Revision: 329773

URL: http://llvm.org/viewvc/llvm-project?rev=329773=rev
Log:
[XRay][clang] Only enable test for supported platforms

This is a follow-up to D45474.

Modified:
cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp

Modified: cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp?rev=329773=329772=329773=diff
==
--- cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp (original)
+++ cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp Tue Apr 10 18:47:40 2018
@@ -19,3 +19,5 @@
 // FDR: libclang_rt.xray-fdr
 // NONE-NOT: libclang_rt.xray-basic
 // NONE-NOT: libclang_rt.xray-fdr
+// REQUIRES-ANY: linux, freebsd
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64


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


r329772 - [XRay][clang+compiler-rt] Support build-time mode selection

2018-04-10 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Apr 10 18:28:25 2018
New Revision: 329772

URL: http://llvm.org/viewvc/llvm-project?rev=329772=rev
Log:
[XRay][clang+compiler-rt] Support build-time mode selection

Summary:
This patch implements the `-fxray-modes=` flag which allows users
building with XRay instrumentation to decide which modes to pre-package
into the binary being linked. The default is the status quo, which will
link all the available modes.

For this to work we're also breaking apart the mode implementations
(xray-fdr and xray-basic) from the main xray runtime. This gives more
granular control of which modes are pre-packaged, and picked from
clang's invocation.

This fixes llvm.org/PR37066.

Note that in the future, we may change the default for clang to only
contain the profiling implementation under development in D44620, when
that implementation is ready.

Reviewers: echristo, eizan, chandlerc

Reviewed By: echristo

Subscribers: mgorny, mgrang, cfe-commits, llvm-commits

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

Added:
cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/XRayArgs.h
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329772=329771=329772=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 10 18:28:25 2018
@@ -1108,6 +1108,10 @@ def fxray_attr_list :
   JoinedOrSeparate<["-"], "fxray-attr-list=">,
   Group, Flags<[CC1Option]>,
   HelpText<"Filename defining the list of functions/types for imbuing XRay 
attributes.">;
+def fxray_modes :
+  JoinedOrSeparate<["-"], "fxray-modes=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"List of modes to link in by default into XRay instrumented 
binaries.">;
 
 def fxray_always_emit_customevents : Flag<["-"], 
"fxray-always-emit-customevents">, Group,
   Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Driver/XRayArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/XRayArgs.h?rev=329772=329771=329772=diff
==
--- cfe/trunk/include/clang/Driver/XRayArgs.h (original)
+++ cfe/trunk/include/clang/Driver/XRayArgs.h Tue Apr 10 18:28:25 2018
@@ -23,6 +23,7 @@ class XRayArgs {
   std::vector NeverInstrumentFiles;
   std::vector AttrListFiles;
   std::vector ExtraDeps;
+  std::vector Modes;
   bool XRayInstrument = false;
   int InstructionThreshold = 200;
   bool XRayAlwaysEmitCustomEvents = false;
@@ -35,6 +36,8 @@ public:
llvm::opt::ArgStringList , types::ID InputType) const;
 
   bool needsXRayRt() const { return XRayInstrument && XRayRT; }
+  llvm::ArrayRef modeList() const { return Modes; }
+
 };
 
 } // namespace driver

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=329772=329771=329772=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Apr 10 18:28:25 2018
@@ -713,6 +713,8 @@ bool tools::addXRayRuntime(const ToolCha
   if (TC.getXRayArgs().needsXRayRt()) {
 CmdArgs.push_back("-whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+for (const auto  : TC.getXRayArgs().modeList())
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode, false));
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=329772=329771=329772=diff
==
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Tue Apr 10 18:28:25 2018
@@ -27,6 +27,7 @@ namespace {
 constexpr char XRayInstrumentOption[] = "-fxray-instrument";
 constexpr char XRayInstructionThresholdOption[] =
 "-fxray-instruction-threshold=";
+constexpr const char *const XRaySupportedModes[] = {"xray-fdr", "xray-basic"};
 } // namespace
 
 XRayArgs::XRayArgs(const ToolChain , const ArgList ) {
@@ -51,13 +52,14 @@ XRayArgs::XRayArgs(const ToolChain ,
   }
 } else if (Triple.getOS() == llvm::Triple::FreeBSD ||
Triple.getOS() == llvm::Triple::OpenBSD) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
-  D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
-}
+  if (Triple.getArch() != llvm::Triple::x86_64) {
+

[PATCH] D45474: [XRay][clang+compiler-rt] Support build-time mode selection

2018-04-10 Thread Dean Michael Berris via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329772: [XRay][clang+compiler-rt] Support build-time mode 
selection (authored by dberris, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D45474?vs=141940=141941#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45474

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/XRayArgs.h
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/XRayArgs.cpp
  cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
  compiler-rt/trunk/lib/xray/CMakeLists.txt
  compiler-rt/trunk/lib/xray/tests/CMakeLists.txt

Index: cfe/trunk/include/clang/Driver/XRayArgs.h
===
--- cfe/trunk/include/clang/Driver/XRayArgs.h
+++ cfe/trunk/include/clang/Driver/XRayArgs.h
@@ -23,6 +23,7 @@
   std::vector NeverInstrumentFiles;
   std::vector AttrListFiles;
   std::vector ExtraDeps;
+  std::vector Modes;
   bool XRayInstrument = false;
   int InstructionThreshold = 200;
   bool XRayAlwaysEmitCustomEvents = false;
@@ -35,6 +36,8 @@
llvm::opt::ArgStringList , types::ID InputType) const;
 
   bool needsXRayRt() const { return XRayInstrument && XRayRT; }
+  llvm::ArrayRef modeList() const { return Modes; }
+
 };
 
 } // namespace driver
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1108,6 +1108,10 @@
   JoinedOrSeparate<["-"], "fxray-attr-list=">,
   Group, Flags<[CC1Option]>,
   HelpText<"Filename defining the list of functions/types for imbuing XRay attributes.">;
+def fxray_modes :
+  JoinedOrSeparate<["-"], "fxray-modes=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"List of modes to link in by default into XRay instrumented binaries.">;
 
 def fxray_always_emit_customevents : Flag<["-"], "fxray-always-emit-customevents">, Group,
   Flags<[CC1Option]>,
Index: cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
===
--- cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
+++ cfe/trunk/test/Driver/XRay/xray-mode-flags.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=xray-fdr %s -### \
+// RUN: 2>&1 | FileCheck --check-prefix FDR %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=xray-basic %s \
+// RUN: -### 2>&1 | FileCheck --check-prefix BASIC %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=all -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
+// RUN: %clang -v -o /dev/null -fxray-instrument \
+// RUN: -fxray-modes=xray-fdr,xray-basic -### %s 2>&1 | \
+// RUN: FileCheck --check-prefixes FDR,BASIC %s
+// RUN: %clang -v -o /dev/null -fxray-instrument \
+// RUN: -fxray-modes=xray-fdr -fxray-modes=xray-basic -### %s 2>&1 | \
+// RUN: FileCheck --check-prefixes FDR,BASIC %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes NONE %s
+
+// BASIC: libclang_rt.xray-basic
+// FDR: libclang_rt.xray-fdr
+// NONE-NOT: libclang_rt.xray-basic
+// NONE-NOT: libclang_rt.xray-fdr
Index: cfe/trunk/lib/Driver/XRayArgs.cpp
===
--- cfe/trunk/lib/Driver/XRayArgs.cpp
+++ cfe/trunk/lib/Driver/XRayArgs.cpp
@@ -27,6 +27,7 @@
 constexpr char XRayInstrumentOption[] = "-fxray-instrument";
 constexpr char XRayInstructionThresholdOption[] =
 "-fxray-instruction-threshold=";
+constexpr const char *const XRaySupportedModes[] = {"xray-fdr", "xray-basic"};
 } // namespace
 
 XRayArgs::XRayArgs(const ToolChain , const ArgList ) {
@@ -51,13 +52,14 @@
   }
 } else if (Triple.getOS() == llvm::Triple::FreeBSD ||
Triple.getOS() == llvm::Triple::OpenBSD) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
-  D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
-}
+  if (Triple.getArch() != llvm::Triple::x86_64) {
+D.Diag(diag::err_drv_clang_unsupported)
+<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
+  }
 } else {
   D.Diag(diag::err_drv_clang_unsupported)
-  << (std::string(XRayInstrumentOption) + " on non-supported target OS");
+  << (std::string(XRayInstrumentOption) +
+  " on non-supported target OS");
 }
 XRayInstrument = true;
 if (const Arg *A =
@@ -108,6 +110,33 @@
   } else
 D.Diag(clang::diag::err_drv_no_such_file) << Filename;
 }
+
+// Get the list of modes we want to support.
+auto 

[PATCH] D45474: [XRay][clang+compiler-rt] Support build-time mode selection

2018-04-10 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 141940.
dberris marked an inline comment as done.
dberris added a comment.

Revert unnecessary one-liner change.


https://reviews.llvm.org/D45474

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-mode-flags.cpp
  compiler-rt/lib/xray/CMakeLists.txt
  compiler-rt/lib/xray/tests/CMakeLists.txt

Index: compiler-rt/lib/xray/tests/CMakeLists.txt
===
--- compiler-rt/lib/xray/tests/CMakeLists.txt
+++ compiler-rt/lib/xray/tests/CMakeLists.txt
@@ -17,6 +17,22 @@
   -I${COMPILER_RT_SOURCE_DIR}/lib/xray
   -I${COMPILER_RT_SOURCE_DIR}/lib)
 
+macro(add_xray_lib library)
+  add_library(${library} STATIC ${ARGN})
+  set_target_properties(${library} PROPERTIES
+ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+FOLDER "Compiler-RT Runtime tests")
+endmacro()
+
+function(get_xray_lib_for_arch arch lib)
+  if(APPLE)
+set(tgt_name "RTXRay.test.osx")
+  else()
+set(tgt_name "RTXRay.test.${arch}")
+  endif()
+  set(${lib} "${tgt_name}" PARENT_SCOPE)
+endfunction()
+
 set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})
 macro(add_xray_unittest testname)
   cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})
@@ -27,25 +43,34 @@
 endforeach()
 foreach(arch ${XRAY_TEST_ARCH})
   set(TEST_OBJECTS)
+  get_xray_lib_for_arch(${arch} XRAY_RUNTIME_LIBS)
   generate_compiler_rt_tests(TEST_OBJECTS
 XRayUnitTests "${testname}-${arch}-Test" "${arch}"
 SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
 # Note that any change in the implementations will cause all the unit
 # tests to be re-built. This is by design, but may be cumbersome during
 # the build/test cycle.
 COMPILE_DEPS ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
 ${XRAY_HEADERS} ${XRAY_IMPL_FILES}
-DEPS gtest xray llvm-xray
+RUNTIME "${XRAY_RUNTIME_LIBS}"
+DEPS gtest xray
 CFLAGS ${XRAY_UNITTEST_CFLAGS}
-LINK_FLAGS -fxray-instrument
-  ${TARGET_LINK_FLAGS}
+LINK_FLAGS ${TARGET_LINK_FLAGS}
   -lstdc++ -lm ${CMAKE_THREAD_LIBS_INIT}
   ${CMAKE_DL_LIBS_INIT} -lrt)
-  set_target_properties(XRayUnitTests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+  set_target_properties(XRayUnitTests
+PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 endforeach()
   endif()
 endmacro()
 
 if(COMPILER_RT_CAN_EXECUTE_TESTS)
+  foreach(arch ${XRAY_SUPPORTED_ARCH})
+add_xray_lib("RTXRay.test.${arch}"
+  $
+  $
+  $
+  $)
+  endforeach()
   add_subdirectory(unit)
 endif()
Index: compiler-rt/lib/xray/CMakeLists.txt
===
--- compiler-rt/lib/xray/CMakeLists.txt
+++ compiler-rt/lib/xray/CMakeLists.txt
@@ -2,15 +2,20 @@
 
 # XRay runtime library implementation files.
 set(XRAY_SOURCES
-  xray_inmemory_log.cc
   xray_init.cc
   xray_flags.cc
   xray_interface.cc
-  xray_buffer_queue.cc
   xray_log_interface.cc
-  xray_fdr_logging.cc
   xray_utils.cc)
 
+# XRay mode implementation files.
+set(XRAY_FDR_MODE_SOURCES
+  xray_buffer_queue.cc
+  xray_fdr_logging.cc)
+
+set(XRAY_BASIC_MODE_SOURCES
+  xray_inmemory_log.cc)
+
 set(x86_64_SOURCES
 xray_x86_64.cc
 xray_trampoline_x86_64.S)
@@ -60,7 +65,6 @@
 add_compiler_rt_component(xray)
 
 set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
-RTXray
 RTSanitizerCommon
 RTSanitizerCommonLibc)
 
@@ -77,6 +81,18 @@
 SOURCES ${x86_64_SOURCES}
 CFLAGS ${XRAY_CFLAGS}
 DEFS ${XRAY_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTXrayFDR
+OS ${XRAY_SUPPORTED_OS}
+ARCHS ${XRAY_SUPPORTED_ARCH}
+SOURCES ${XRAY_FDR_MODE_SOURCES}
+CFLAGS ${XRAY_CFLAGS}
+DEFS ${XRAY_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTXrayBASIC
+OS ${XRAY_SUPPORTED_OS}
+ARCHS ${XRAY_SUPPORTED_ARCH}
+SOURCES ${XRAY_BASIC_MODE_SOURCES}
+CFLAGS ${XRAY_CFLAGS}
+DEFS ${XRAY_COMMON_DEFINITIONS})
 
   # We only support running on osx for now.
   add_compiler_rt_runtime(clang_rt.xray
@@ -91,20 +107,64 @@
 LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
 LINK_LIBS ${XRAY_LINK_LIBS}
 PARENT_TARGET xray)
+  add_compiler_rt_runtime(clang_rt.xray-fdr
+STATIC
+OS ${XRAY_SUPPORTED_OS}
+ARCHS ${XRAY_SUPPORTED_ARCH}
+OBJECT_LIBS RTXrayFDR
+CFLAGS ${XRAY_CFLAGS}
+DEFS ${XRAY_COMMON_DEFINITIONS}
+LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
+LINK_LIBS ${XRAY_LINK_LIBS}
+PARENT_TARGET xray)
+  add_compiler_rt_runtime(clang_rt.xray-basic
+STATIC
+OS 

[PATCH] D44970: [XRay][clang] Add flag to choose instrumentation bundles

2018-04-10 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: clang/include/clang/Frontend/CodeGenOptions.h:110
 
+  enum XRayInstrumentationPointBundle {
+XRay_All, // Always emit all the instrumentation points.

dberris wrote:
> pelikan wrote:
> > To me, this feels like a bitfield would be a better match.
> > All = Function | Custom
> > None = 0
> Thought about that, but the ergonomics from the user-side isn't as good. 
> Having to know about which kinds of sleds specifically to enable seems much 
> harder to explain. Using bundles that we control from the beginning keeps 
> this much simpler.
I dunno, I think I agree with the other commenter. This feels awkward.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3245
+
+using XRayBundles = CodeGenOptions::XRayInstrumentationPointBundle;
+auto Bundle = CGM.getCodeGenOpts().getXRayInstrumentationBundle();

Break this out into some sort of function to determine which one we want? We do 
this a couple times.


https://reviews.llvm.org/D44970



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


[PATCH] D45474: [XRay][clang+compiler-rt] Support build-time mode selection

2018-04-10 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Sure.




Comment at: clang/lib/Driver/XRayArgs.cpp:168
 
-  for (const auto : AttrListFiles) {
+  for (const auto  : AttrListFiles) {
 SmallString<64> AttrListFileOpt("-fxray-attr-list=");

Technically separate commit.


https://reviews.llvm.org/D45474



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


[PATCH] D45304: [libcxx] Set ABI version 2 as default for Fuchsia

2018-04-10 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329770: [libcxx] Set ABI version 2 as default for Fuchsia 
(authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45304?vs=141935=141939#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45304

Files:
  libcxx/trunk/include/__config


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -36,7 +36,11 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
-#define _LIBCPP_ABI_VERSION 1
+#  ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#  else
+#define _LIBCPP_ABI_VERSION 1
+#  endif
 #endif
 
 #if defined(__ELF__)


Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -36,7 +36,11 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
-#define _LIBCPP_ABI_VERSION 1
+#  ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#  else
+#define _LIBCPP_ABI_VERSION 1
+#  endif
 #endif
 
 #if defined(__ELF__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r329770 - [libcxx] Set ABI version 2 as default for Fuchsia

2018-04-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Apr 10 18:06:28 2018
New Revision: 329770

URL: http://llvm.org/viewvc/llvm-project?rev=329770=rev
Log:
[libcxx] Set ABI version 2 as default for Fuchsia

This avoids the need for a custom generated config file which is desired
because the custom config files differs per-target which means we cannot
reuse headers across different targets.

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

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=329770=329769=329770=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Apr 10 18:06:28 2018
@@ -36,7 +36,11 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
-#define _LIBCPP_ABI_VERSION 1
+#  ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#  else
+#define _LIBCPP_ABI_VERSION 1
+#  endif
 #endif
 
 #if defined(__ELF__)


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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-10 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

How about doing same for //objc-property-declaration//?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-10 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added a comment.

In https://reviews.llvm.org/D45392#1063164, @alexfh wrote:

> In https://reviews.llvm.org/D45392#1061960, @Wizard wrote:
>
> > In https://reviews.llvm.org/D45392#1061433, @alexfh wrote:
> >
> > > I wonder whether the readability-identifier-naming check could be 
> > > extended to support this use case instead of adding a new check 
> > > specifically for underscores in ivar names?
> >
> >
> > Hmm readability-identifier-naming is a C++ check but this one is only for 
> > ObjC. I prefer putting them in separate places unless they work for both 
> > languages.
>
>
> I see no reasons why this check can't work for ObjC, if the handling of 
> ObjC-specific AST nodes is added to it.
>
> > Moreover, readability-identifier-naming always runs all matchers and apply 
> > the same checks on all identifiers.
>
> It has some sort of a hierarchical structure of rules that allow it to only 
> touch a certain subset of identifiers. E.g. configure different naming styles 
> for local variables and local constants. What it's lacking is a good 
> documentation for all of these options =\
>
> > We have to change at least part of the structure to make it applicable for 
> > this check.
>
> Yes, the existing check may need some modifications to do what this check 
> needs to do, but I'd expect these modifications to be quite small, and we 
> would potentially get a much more useful and generic tool instead of "one 
> check per type of named entity per naming style" situation.
>
> > And readability-identifier-naming is not in google default clang-tidy check 
> > list yet. We will even need more work to import it.
>
> IIUC, it can be configured to only verify certain kinds of named entities. 
> Thus there's no requirement to make it work with every aspect of our naming 
> rules.
>
> > So I think creating a new simple ObjC-specific check is a better way here.
>
> I'll respectfully disagree here. I would prefer to have a generic solution, 
> if it's feasible. And so far, it looks like it is.


Done. Yes it is very small changes to integrate this into it. I like it. The 
only annoying part was the doc is not that good and I spent a lot of time 
understanding the whole structure. Just one question, when we enable it in 
google by default, do we need to take care of the flags in the tests like 
-I%S/Inputs/readability-identifier-naming and -isystem 
%S/Inputs/readability-identifier-naming/system?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-10 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 141938.
Wizard added a comment.

move check to readability-identifier-naming


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming-objc.m


Index: test/clang-tidy/readability-identifier-naming-objc.m
===
--- /dev/null
+++ test/clang-tidy/readability-identifier-naming-objc.m
@@ -0,0 +1,20 @@
+// Remove UNSUPPORTED for powerpc64le when the problem introduced by
+// r288563 is resolved.
+// UNSUPPORTED: powerpc64le
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}, \
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
+
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc 
ivar 'barWithoutPrefix' [readability-identifier-naming]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -109,6 +109,7 @@
 m(TemplateParameter) \
 m(TypeAlias) \
 m(MacroDefinition) \
+m(ObjcIvar) \
 
 enum StyleKind {
 #define ENUMERATE(v) SK_ ## v,
@@ -384,6 +385,9 @@
 const NamedDecl *D,
 const std::vector
 ) {
+  if (isa(D) && NamingStyles[SK_ObjcIvar])
+return SK_ObjcIvar;
+
   if (isa(D) && NamingStyles[SK_Typedef])
 return SK_Typedef;
 


Index: test/clang-tidy/readability-identifier-naming-objc.m
===
--- /dev/null
+++ test/clang-tidy/readability-identifier-naming-objc.m
@@ -0,0 +1,20 @@
+// Remove UNSUPPORTED for powerpc64le when the problem introduced by
+// r288563 is resolved.
+// UNSUPPORTED: powerpc64le
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}, \
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
+
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -109,6 +109,7 @@
 m(TemplateParameter) \
 m(TypeAlias) \
 m(MacroDefinition) \
+m(ObjcIvar) \
 
 enum StyleKind {
 #define ENUMERATE(v) SK_ ## v,
@@ -384,6 +385,9 @@
 const NamedDecl *D,
 const std::vector
 ) {
+  if (isa(D) && NamingStyles[SK_ObjcIvar])
+return SK_ObjcIvar;
+
   if (isa(D) && NamingStyles[SK_Typedef])
 return SK_Typedef;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45304: [libcxx] Set ABI version 2 as default for Fuchsia

2018-04-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 141935.
phosek marked an inline comment as done.

Repository:
  rCXX libc++

https://reviews.llvm.org/D45304

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -36,7 +36,11 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
-#define _LIBCPP_ABI_VERSION 1
+#  ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#  else
+#define _LIBCPP_ABI_VERSION 1
+#  endif
 #endif
 
 #if defined(__ELF__)


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -36,7 +36,11 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
-#define _LIBCPP_ABI_VERSION 1
+#  ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#  else
+#define _LIBCPP_ABI_VERSION 1
+#  endif
 #endif
 
 #if defined(__ELF__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45061: [NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.

2018-04-10 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.

Guessing that SM_60 (etc) are defines?

Anyhow LGTM. I'm not sure you can split up the satom part of the patch, but if 
you can that'd be great.

-eric


https://reviews.llvm.org/D45061



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


[PATCH] D45304: [libcxx] Set ABI version 2 as default for Fuchsia

2018-04-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: libcxx/include/__config:39
 #ifndef _LIBCPP_ABI_VERSION
+#ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2

Please indent these nested `#ifdef`s.


Repository:
  rCXX libc++

https://reviews.llvm.org/D45304



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


[PATCH] D45060: Allow target to handle required features for TARGET_BUILTINs.

2018-04-10 Thread Artem Belevich via Phabricator via cfe-commits
tra abandoned this revision.
tra marked an inline comment as done.
tra added a comment.

I've figured out a manageable way to enforce constraints without this change.


https://reviews.llvm.org/D45060



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


[PATCH] D45061: [NVPTX, CUDA] Use custom feature detection to handle NVPTX target builtins.

2018-04-10 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 141932.
tra added a comment.

@echristo convinced me that this functionality can be implemented without 
growing a target-specific hook for custom interpretation of constraints used in 
TARGET_BUILTIN. Instead, we can hide unwieldy feature lists behind a macro.


https://reviews.llvm.org/D45061

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/test/CodeGen/builtins-nvptx-ptx50.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/lib/Target/NVPTX/NVPTX.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h

Index: llvm/lib/Target/NVPTX/NVPTXSubtarget.h
===
--- llvm/lib/Target/NVPTX/NVPTXSubtarget.h
+++ llvm/lib/Target/NVPTX/NVPTXSubtarget.h
@@ -48,10 +48,6 @@
   // FrameLowering class because TargetFrameLowering is abstract.
   NVPTXFrameLowering FrameLowering;
 
-protected:
-  // Processor supports scoped atomic operations.
-  bool HasAtomScope;
-
 public:
   /// This constructor initializes the data members to match that
   /// of the specified module.
@@ -74,7 +70,7 @@
   }
 
   bool hasAtomAddF64() const { return SmVersion >= 60; }
-  bool hasAtomScope() const { return HasAtomScope; }
+  bool hasAtomScope() const { return SmVersion >= 60; }
   bool hasAtomBitwise64() const { return SmVersion >= 32; }
   bool hasAtomMinMax64() const { return SmVersion >= 32; }
   bool hasLDG() const { return SmVersion >= 32; }
Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -53,9 +53,6 @@
 def SM70 : SubtargetFeature<"sm_70", "SmVersion", "70",
  "Target SM 7.0">;
 
-def SATOM : SubtargetFeature<"satom", "HasAtomScope", "true",
- "Atomic operations with scope">;
-
 // PTX Versions
 def PTX32 : SubtargetFeature<"ptx32", "PTXVersion", "32",
  "Use PTX version 3.2">;
@@ -88,10 +85,10 @@
 def : Proc<"sm_50", [SM50, PTX40]>;
 def : Proc<"sm_52", [SM52, PTX41]>;
 def : Proc<"sm_53", [SM53, PTX42]>;
-def : Proc<"sm_60", [SM60, PTX50, SATOM]>;
-def : Proc<"sm_61", [SM61, PTX50, SATOM]>;
-def : Proc<"sm_62", [SM62, PTX50, SATOM]>;
-def : Proc<"sm_70", [SM70, PTX60, SATOM]>;
+def : Proc<"sm_60", [SM60, PTX50]>;
+def : Proc<"sm_61", [SM61, PTX50]>;
+def : Proc<"sm_62", [SM62, PTX50]>;
+def : Proc<"sm_70", [SM70, PTX60]>;
 
 def NVPTXInstrInfo : InstrInfo {
 }
Index: clang/test/CodeGen/builtins-nvptx.c
===
--- clang/test/CodeGen/builtins-nvptx.c
+++ clang/test/CodeGen/builtins-nvptx.c
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_60 \
 // RUN:-fcuda-is-device -S -emit-llvm -o - -x cuda %s \
 // RUN:   | FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_61 \
+// RUN:-fcuda-is-device -S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 \
 // RUN:   -DERROR_CHECK -fcuda-is-device -S -o /dev/null -x cuda -verify %s
 
@@ -292,245 +295,245 @@
 #if ERROR_CHECK || __CUDA_ARCH__ >= 600
 
   // CHECK: call i32 @llvm.nvvm.atomic.add.gen.i.cta.i32.p0i32
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_i' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_i' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_i(ip, i);
   // LP32: call i32 @llvm.nvvm.atomic.add.gen.i.cta.i32.p0i32
   // LP64: call i64 @llvm.nvvm.atomic.add.gen.i.cta.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_l' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_l' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_l(, l);
   // CHECK: call i64 @llvm.nvvm.atomic.add.gen.i.cta.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_ll' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_ll' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_ll(, ll);
   // CHECK: call i32 @llvm.nvvm.atomic.add.gen.i.sys.i32.p0i32
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_i' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_i' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_i(ip, i);
   // LP32: call i32 @llvm.nvvm.atomic.add.gen.i.sys.i32.p0i32
   // LP64: call i64 @llvm.nvvm.atomic.add.gen.i.sys.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_l' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_l' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_l(, l);
   // CHECK: call i64 @llvm.nvvm.atomic.add.gen.i.sys.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_ll' needs target feature satom}}
+  // 

[PATCH] D45304: [libcxx] Set ABI version 2 as default for Fuchsia

2018-04-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 141933.
phosek marked an inline comment as done.

Repository:
  rCXX libc++

https://reviews.llvm.org/D45304

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -36,8 +36,12 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
+#ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#else
 #define _LIBCPP_ABI_VERSION 1
 #endif
+#endif
 
 #if defined(__ELF__)
 #  define _LIBCPP_OBJECT_FORMAT_ELF   1


Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -36,8 +36,12 @@
 #define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
+#ifdef __Fuchsia__
+#define _LIBCPP_ABI_VERSION 2
+#else
 #define _LIBCPP_ABI_VERSION 1
 #endif
+#endif
 
 #if defined(__ELF__)
 #  define _LIBCPP_OBJECT_FORMAT_ELF   1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45304: [libcxx] Set ABI version 2 as default for Fuchsia

2018-04-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: libcxx/CMakeLists.txt:100
 "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)

I don't think this part of the change is needed. Won't setting 
ABI_VERSION_DEFAULT to 2 result in a site config header being generated?


Repository:
  rCXX libc++

https://reviews.llvm.org/D45304



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


r329766 - [AST] Fix some Clang-tidy modernize-use-auto and Include What You Use warnings; other minor fixes (NFC).

2018-04-10 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Apr 10 15:54:42 2018
New Revision: 329766

URL: http://llvm.org/viewvc/llvm-project?rev=329766=rev
Log:
[AST] Fix some Clang-tidy modernize-use-auto and Include What You Use warnings; 
other minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/TypePrinter.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=329766=329765=329766=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Apr 10 15:54:42 2018
@@ -715,7 +715,7 @@ public:
   child_range children() {
 if (isTypeOperand())
   return child_range(child_iterator(), child_iterator());
-Stmt **begin = reinterpret_cast();
+auto **begin = reinterpret_cast();
 return child_range(begin, begin + 1);
   }
 };
@@ -925,7 +925,7 @@ public:
   child_range children() {
 if (isTypeOperand())
   return child_range(child_iterator(), child_iterator());
-Stmt **begin = reinterpret_cast();
+auto **begin = reinterpret_cast();
 return child_range(begin, begin + 1);
   }
 };
@@ -2621,7 +2621,7 @@ public:
 if (isa(E)) {
   assert(cast(E)->getOpcode() == UO_AddrOf);
   E = cast(E)->getSubExpr();
-  OverloadExpr *Ovl = cast(E->IgnoreParens());
+  auto *Ovl = cast(E->IgnoreParens());
 
   Result.HasFormOfMemberPointer = (E == Ovl && Ovl->getQualifier());
   Result.IsAddressOfOperand = true;
@@ -3190,7 +3190,7 @@ public:
 
   // Iterators
   child_range children() {
-Stmt **begin = reinterpret_cast(arg_begin());
+auto **begin = reinterpret_cast(arg_begin());
 return child_range(begin, begin + NumArgs);
   }
 };
@@ -3768,7 +3768,7 @@ class SizeOfPackExpr final
 Length(Length ? *Length : PartialArgs.size()), Pack(Pack) {
 assert((!Length || PartialArgs.empty()) &&
"have partial args for non-dependent sizeof... expression");
-TemplateArgument *Args = getTrailingObjects();
+auto *Args = getTrailingObjects();
 std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
   }
 
@@ -3819,7 +3819,7 @@ public:
   /// \brief Get
   ArrayRef getPartialArguments() const {
 assert(isPartiallySubstituted());
-const TemplateArgument *Args = getTrailingObjects();
+const auto *Args = getTrailingObjects();
 return llvm::makeArrayRef(Args, Args + Length);
   }
 

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=329766=329765=329766=diff
==
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Apr 10 15:54:42 2018
@@ -181,7 +181,7 @@ QualType CXXDeleteExpr::getDestroyedType
   // For a destroying operator delete, we may have implicitly converted the
   // pointer type to the type of the parameter of the 'operator delete'
   // function.
-  while (auto *ICE = dyn_cast(Arg)) {
+  while (const auto *ICE = dyn_cast(Arg)) {
 if (ICE->getCastKind() == CK_DerivedToBase ||
 ICE->getCastKind() == CK_UncheckedDerivedToBase ||
 ICE->getCastKind() == CK_NoOp) {
@@ -290,7 +290,7 @@ UnresolvedLookupExpr::CreateEmpty(const
   totalSizeToAlloc(
   HasTemplateKWAndArgsInfo, NumTemplateArgs);
   void *Mem = C.Allocate(Size, alignof(UnresolvedLookupExpr));
-  UnresolvedLookupExpr *E = new (Mem) UnresolvedLookupExpr(EmptyShell());
+  auto *E = new (Mem) UnresolvedLookupExpr(EmptyShell());
   E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
   return E;
 }
@@ -442,8 +442,8 @@ DependentScopeDeclRefExpr::CreateEmpty(c
   totalSizeToAlloc(
   HasTemplateKWAndArgsInfo, NumTemplateArgs);
   void *Mem = C.Allocate(Size);
-  DependentScopeDeclRefExpr *E
-= new (Mem) DependentScopeDeclRefExpr(QualType(), NestedNameSpecifierLoc(),
+  auto *E =
+  new (Mem) DependentScopeDeclRefExpr(QualType(), NestedNameSpecifierLoc(),
   SourceLocation(),
   DeclarationNameInfo(), nullptr);
   E->HasTemplateKWAndArgsInfo = HasTemplateKWAndArgsInfo;
@@ -504,9 +504,9 @@ SourceRange CXXOperatorCallExpr::getSour
 
 Expr *CXXMemberCallExpr::getImplicitObjectArgument() const {
   const Expr *Callee = getCallee()->IgnoreParens();
-  if (const MemberExpr *MemExpr = dyn_cast(Callee))
+  if (const auto *MemExpr = dyn_cast(Callee))
 return MemExpr->getBase();
-  if (const BinaryOperator *BO = dyn_cast(Callee))
+  if (const auto *BO = dyn_cast(Callee))
 if (BO->getOpcode() == BO_PtrMemD || 

[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-10 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

If we use the unit test case, call `__gcov_flush` from the main function,
and dump static variables in GCDAProfiling.c, we can see that `__gcov_flush`
is resolved to the same copy for func.shared, func2.shared, and main.
However, when `__gcov_flush` is called from main and from f1_flush and f2_flush,
they use different copies of static variables defined in GCDAProfiling.c.
The "flush_fn_head" and its flush functions are different, so 3 calls of
`__gcov_flush` will flush to 3 different output files:

  instrprof-dlopen-func.gcda
  instrprof-dlopen-func2.gcda
  instrprof-dlopen-dlclose-main.gcda

This keeps current Android use cases working as before `__gcov_flush` is hidden.
Is there other use case that could be broken by this change?


https://reviews.llvm.org/D45454



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-04-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:3889
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {

Why is this warning dependent on the ABI? GCC has a similar warning:
https://godbolt.org/g/3E4NZ1



Comment at: lib/Sema/SemaDeclAttr.cpp:3892
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }

I'd actually rather not ignore the attribute. Clang shouldn't be making 
decisions about what LLVM is and isn't capable of inlining. It's not too crazy 
to imagine eventually implementing inlining of variadic function calls.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D44093#1063658, @paulsemel wrote:

> Sorry about it, I also have the warning on my machine, but not the error you 
> get...
>  Those test are actually working on my different linux machines, that's 
> really weird.
>  This one is actually really weird, because I could find manually the missing 
> pattern in your output.. I just don't get what is happening.


I think the issue has to do with bit-width. From unit5():

  // Your test
  
// CHECK: call i32 (i8*, ...) @printf(
// CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U5A, 
%struct.U5A* %a, i32 0, i32 0
// CHECK: call i32 (i8*, ...) @printf(
// CHECK: [[LOAD1:%[0-9]+]] = load i64, i64* [[RES1]],
// CHECK: call i32 (i8*, ...) @printf({{.*}}, i64 [[LOAD1]])
// CHECK: call i32 (i8*, ...) @printf(
  
  // My results
  
  ; Function Attrs: noinline nounwind optnone
  define dso_local void @unit5() #0 {
  entry:
  
%a = alloca %struct.U5A, align 4
%0 = bitcast %struct.U5A* %a to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %0, i8* align 4 bitcast 
(%struct.U5A* @unit5.a to i8*), i64 4, i1 false)
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 
x i8]* @16, i32 0, i32 0))
%2 = getelementptr inbounds %struct.U5A, %struct.U5A* %a, i32 0, i32 0
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 
x i8]* @17, i32 0, i32 0))
%4 = add i32 %1, %3
%5 = load i32, i32* %2, align 4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x 
i8]* @18, i32 0, i32 0), i32 %5)
%7 = add i32 %4, %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x 
i8]* @19, i32 0, i32 0))
%9 = add i32 %7, %8
ret void
  }

You are testing that the load is an i64 but in my results it's an i32. An 
explicit target triple on the RUN line solves the issue.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 141920.
paulsemel added a comment.

Added triple option to CodeGen test so that it matches with the correct 
architecture


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/dump-struct-builtin.c
  test/Sema/builtin-dump-struct.c

Index: test/Sema/builtin-dump-struct.c
===
--- /dev/null
+++ test/Sema/builtin-dump-struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
+
+void invalid_uses() {
+  struct A {
+  };
+  struct A a;
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);
+  int (*badfunc2)(int, ...);
+  void (*badfunc3)(const char *, ...);
+  int (*badfunc4)(char *, ...);
+  int (*badfunc5)(void);
+
+  __builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}}
+  __builtin_dump_struct(1);// expected-error {{too few arguments to function call, expected 2, have 1}}
+  __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(a, goodfunc);  // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
+}
+
+void valid_uses() {
+  struct A {
+  };
+  union B {
+  };
+
+  int (*goodfunc)(const char *, ...);
+  int (*goodfunc2)();
+  struct A a;
+  union B b;
+
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc2);
+}
Index: test/CodeGen/dump-struct-builtin.c
===
--- /dev/null
+++ test/CodeGen/dump-struct-builtin.c
@@ -0,0 +1,391 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/stdio.h"
+
+int printf(const char *fmt, ...) {
+return 0;
+}
+
+void unit1() {
+  struct U1A {
+short a;
+  };
+
+  struct U1A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U1A, %struct.U1A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit2() {
+  struct U2A {
+unsigned short a;
+  };
+
+  struct U2A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U2A, %struct.U2A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit3() {
+  struct U3A {
+int a;
+  };
+
+  struct U3A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U3A, %struct.U3A* %a, i32 

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I see we all found the solution at the same time. Yay teamwork! :-D

I've committed (with the test fixed up) in r329762.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


r329762 - Introduce a new builtin, __builtin_dump_struct, that is useful for dumping structure contents at runtime in circumstances where debuggers may not be easily available (such as in kernel work)

2018-04-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Apr 10 14:58:13 2018
New Revision: 329762

URL: http://llvm.org/viewvc/llvm-project?rev=329762=rev
Log:
Introduce a new builtin, __builtin_dump_struct, that is useful for dumping 
structure contents at runtime in circumstances where debuggers may not be 
easily available (such as in kernel work).

Patch by Paul Semel.

Added:
cfe/trunk/test/CodeGen/dump-struct-builtin.c
cfe/trunk/test/Sema/builtin-dump-struct.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=329762=329761=329762=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 10 14:58:13 2018
@@ -1374,6 +1374,7 @@ BUILTIN(__builtin_addressof, "v*v&", "nc
 BUILTIN(__builtin_operator_new, "v*z", "tc")
 BUILTIN(__builtin_operator_delete, "vv*", "tn")
 BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
+BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
 
 // Safestack builtins
 BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=329762=329761=329762=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Apr 10 14:58:13 2018
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenCLRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
@@ -930,6 +931,93 @@ EmitCheckedMixedSignMultiply(CodeGenFunc
   return RValue::get(Overflow);
 }
 
+static llvm::Value *dumpRecord(CodeGenFunction , QualType RType,
+   Value *, CharUnits Align, Value *Func,
+   int Lvl) {
+  const auto *RT = RType->getAs();
+  ASTContext  = CGF.getContext();
+  RecordDecl *RD = RT->getDecl()->getDefinition();
+  ASTContext  = RD->getASTContext();
+  const ASTRecordLayout  = Ctx.getASTRecordLayout(RD);
+  std::string Pad = std::string(Lvl * 4, ' ');
+
+  Value *GString =
+  CGF.Builder.CreateGlobalStringPtr(RType.getAsString() + " {\n");
+  Value *Res = CGF.Builder.CreateCall(Func, {GString});
+
+  static llvm::DenseMap Types;
+  if (Types.empty()) {
+Types[Context.CharTy] = "%c";
+Types[Context.BoolTy] = "%d";
+Types[Context.IntTy] = "%d";
+Types[Context.UnsignedIntTy] = "%u";
+Types[Context.LongTy] = "%ld";
+Types[Context.UnsignedLongTy] = "%lu";
+Types[Context.LongLongTy] = "%lld";
+Types[Context.UnsignedLongLongTy] = "%llu";
+Types[Context.ShortTy] = "%hd";
+Types[Context.UnsignedShortTy] = "%hu";
+Types[Context.VoidPtrTy] = "%p";
+Types[Context.FloatTy] = "%f";
+Types[Context.DoubleTy] = "%f";
+Types[Context.LongDoubleTy] = "%Lf";
+Types[Context.getPointerType(Context.CharTy)] = "%s";
+  }
+
+  for (const auto *FD : RD->fields()) {
+uint64_t Off = RL.getFieldOffset(FD->getFieldIndex());
+Off = Ctx.toCharUnitsFromBits(Off).getQuantity();
+
+Value *FieldPtr = RecordPtr;
+if (RD->isUnion())
+  FieldPtr = CGF.Builder.CreatePointerCast(
+  FieldPtr, CGF.ConvertType(Context.getPointerType(FD->getType(;
+else
+  FieldPtr = CGF.Builder.CreateStructGEP(CGF.ConvertType(RType), FieldPtr,
+ FD->getFieldIndex());
+
+GString = CGF.Builder.CreateGlobalStringPtr(
+llvm::Twine(Pad)
+.concat(FD->getType().getAsString())
+.concat(llvm::Twine(' '))
+.concat(FD->getNameAsString())
+.concat(" : ")
+.str());
+Value *TmpRes = CGF.Builder.CreateCall(Func, {GString});
+Res = CGF.Builder.CreateAdd(Res, TmpRes);
+
+QualType CanonicalType =
+FD->getType().getUnqualifiedType().getCanonicalType();
+
+// We check whether we are in a recursive type
+if (CanonicalType->isRecordType()) {
+  Value *TmpRes =
+  dumpRecord(CGF, CanonicalType, FieldPtr, Align, Func, Lvl + 1);
+  Res = CGF.Builder.CreateAdd(TmpRes, Res);
+  continue;
+}
+
+// We try to determine the best format to print the current field
+llvm::Twine Format = Types.find(CanonicalType) == Types.end()
+ ? Types[Context.VoidPtrTy]
+ : Types[CanonicalType];
+
+Address FieldAddress = Address(FieldPtr, Align);
+FieldPtr = CGF.Builder.CreateLoad(FieldAddress);
+
+// FIXME Need to handle bitfield here
+GString = CGF.Builder.CreateGlobalStringPtr(
+

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

Thanks a lot for your help, updating the patch !


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D45500: [MinGW] Look for libc++ headers in a triplet prefixed path as well

2018-04-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/Driver/ToolChains/MinGW.cpp:459
 addSystemInclude(DriverArgs, CC1Args,
+ Base + Arch + llvm::sys::path::get_separator() +
+ "include" + llvm::sys::path::get_separator() +

Holy cow, this is long. =/ Maybe make a local variable `Slash` and use it?


Repository:
  rC Clang

https://reviews.llvm.org/D45500



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In https://reviews.llvm.org/D44093#1063679, @paulsemel wrote:

> Ok, I found the problem. In fact the size of `long` is 4 bytes on your 
> machine, but 8 bytes on mine.
>  This makes this `// CHECK: [[LOAD1:%[0-9]+]] = load i64, i64* [[RES1]],` 
> fail.
>  Do you know a smart way to do it without dealing with type sizes ?


You should probably run the test with `-triple=x86_64-unknown-linux` (or 
whatever the triple for your host machine happens to be). Otherwise they depend 
on the default clang triple which could have a different size long.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In https://reviews.llvm.org/D44093#1063679, @paulsemel wrote:

> Ok, I found the problem. In fact the size of `long` is 4 bytes on your 
> machine, but 8 bytes on mine.
>  This makes this `// CHECK: [[LOAD1:%[0-9]+]] = load i64, i64* [[RES1]],` 
> fail.
>  Do you know a smart way to do it without dealing with type sizes ?


You should probably run the test with `-triple=x86_64-unknown-linux` (or 
whatever the triple for your host machine happens to be). Otherwise they depend 
on the default clang triple which could have a different size long.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/CodeGen/dump-struct-builtin.c:1
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+

This should be 
```
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
```
or something


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

Ok, I found the problem. In fact the size of `long` is 4 bytes on your machine, 
but 8 bytes on mine.
This makes this `// CHECK: [[LOAD1:%[0-9]+]] = load i64, i64* [[RES1]],` fail.
Do you know a smart way to do it without dealing with type sizes ?


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


r329760 - Revert "Handle the default case"

2018-04-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Apr 10 14:29:18 2018
New Revision: 329760

URL: http://llvm.org/viewvc/llvm-project?rev=329760=rev
Log:
Revert "Handle the default case"

This reverts commit r329758.

Modified:
cfe/trunk/lib/Driver/ToolChains/NaCl.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NaCl.cpp?rev=329760=329759=329760=diff
==
--- cfe/trunk/lib/Driver/ToolChains/NaCl.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NaCl.cpp Tue Apr 10 14:29:18 2018
@@ -334,8 +334,6 @@ void NaClToolChain::addLibCxxIncludePath
 llvm::sys::path::append(P, "mipsel-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());
 break;
-  default:
-break;
   }
 }
 


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


[PATCH] D45059: [clang-tidy] Add check to catch comparisons in TEMP_FAILURE_RETRY

2018-04-10 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329759: [clang-tidy] Add a 
`android-comparison-in-temp-failure-retry` check (authored by gbiv, committed 
by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D45059?vs=141768=141914#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45059

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/android-comparison-in-temp-failure-retry.c

Index: clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
@@ -0,0 +1,84 @@
+//===--- ComparisonInTempFailureRetryCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../utils/Matchers.h"
+#include "ComparisonInTempFailureRetryCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+namespace {
+AST_MATCHER(BinaryOperator, isRHSATempFailureRetryArg) {
+  if (!Node.getLocStart().isMacroID())
+return false;
+
+  const SourceManager  = Finder->getASTContext().getSourceManager();
+  if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getLocStart()))
+return false;
+
+  const LangOptions  = Finder->getASTContext().getLangOpts();
+  SourceLocation LocStart = Node.getLocStart();
+  while (LocStart.isMacroID()) {
+SourceLocation Invocation = SM.getImmediateMacroCallerLoc(LocStart);
+Token Tok;
+if (!Lexer::getRawToken(SM.getSpellingLoc(Invocation), Tok, SM, Opts,
+/*IgnoreWhiteSpace=*/true)) {
+  if (Tok.getKind() == tok::raw_identifier &&
+  Tok.getRawIdentifier() == "TEMP_FAILURE_RETRY")
+return true;
+}
+
+LocStart = Invocation;
+  }
+  return false;
+}
+} // namespace
+
+void ComparisonInTempFailureRetryCheck::registerMatchers(MatchFinder *Finder) {
+  // Both glibc's and Bionic's TEMP_FAILURE_RETRY macros structurally look like:
+  //
+  // #define TEMP_FAILURE_RETRY(x) ({ \
+  //typeof(x) y; \
+  //do y = (x); \
+  //while (y == -1 && errno == EINTR); \
+  //y; \
+  // })
+  //
+  // (glibc uses `long int` instead of `typeof(x)` for the type of y).
+  //
+  // It's unclear how to walk up the AST from inside the expansion of `x`, and
+  // we need to not complain about things like TEMP_FAILURE_RETRY(foo(x == 1)),
+  // so we just match the assignment of `y = (x)` and inspect `x` from there.
+  Finder->addMatcher(
+  binaryOperator(
+  hasOperatorName("="),
+  hasRHS(ignoringParenCasts(
+  binaryOperator(matchers::isComparisonOperator()).bind("binop"))),
+  isRHSATempFailureRetryArg()),
+  this);
+}
+
+void ComparisonInTempFailureRetryCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto  = *Result.Nodes.getNodeAs("binop");
+  diag(BinOp.getOperatorLoc(), "top-level comparison in TEMP_FAILURE_RETRY");
+
+  // FIXME: FixIts would be nice, but potentially nontrivial when nested macros
+  // happen, e.g. `TEMP_FAILURE_RETRY(IS_ZERO(foo()))`
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -22,6 +22,7 @@
 #include "CloexecMemfdCreateCheck.h"
 #include "CloexecOpenCheck.h"
 #include "CloexecSocketCheck.h"
+#include "ComparisonInTempFailureRetryCheck.h"
 
 using namespace clang::ast_matchers;
 
@@ -50,6 +51,8 @@
 "android-cloexec-memfd-create");
 CheckFactories.registerCheck("android-cloexec-open");
 CheckFactories.registerCheck("android-cloexec-socket");
+CheckFactories.registerCheck(
+"android-comparison-in-temp-failure-retry");
   }
 };
 
Index: 

[clang-tools-extra] r329759 - [clang-tidy] Add a `android-comparison-in-temp-failure-retry` check

2018-04-10 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Apr 10 14:22:22 2018
New Revision: 329759

URL: http://llvm.org/viewvc/llvm-project?rev=329759=rev
Log:
[clang-tidy] Add a `android-comparison-in-temp-failure-retry` check

This check attempts to catch buggy uses of the `TEMP_FAILURE_RETRY`
macro, which is provided by both Bionic and glibc.

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

Added:

clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp

clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst

clang-tools-extra/trunk/test/clang-tidy/android-comparison-in-temp-failure-retry.c
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=329759=329758=329759=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Tue Apr 10 
14:22:22 2018
@@ -22,6 +22,7 @@
 #include "CloexecMemfdCreateCheck.h"
 #include "CloexecOpenCheck.h"
 #include "CloexecSocketCheck.h"
+#include "ComparisonInTempFailureRetryCheck.h"
 
 using namespace clang::ast_matchers;
 
@@ -50,6 +51,8 @@ public:
 "android-cloexec-memfd-create");
 CheckFactories.registerCheck("android-cloexec-open");
 CheckFactories.registerCheck("android-cloexec-socket");
+CheckFactories.registerCheck(
+"android-comparison-in-temp-failure-retry");
   }
 };
 

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=329759=329758=329759=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Tue Apr 10 
14:22:22 2018
@@ -15,6 +15,7 @@ add_clang_library(clangTidyAndroidModule
   CloexecMemfdCreateCheck.cpp
   CloexecOpenCheck.cpp
   CloexecSocketCheck.cpp
+  ComparisonInTempFailureRetryCheck.cpp
 
   LINK_LIBS
   clangAST

Added: 
clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp?rev=329759=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
 Tue Apr 10 14:22:22 2018
@@ -0,0 +1,84 @@
+//===--- ComparisonInTempFailureRetryCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../utils/Matchers.h"
+#include "ComparisonInTempFailureRetryCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+namespace {
+AST_MATCHER(BinaryOperator, isRHSATempFailureRetryArg) {
+  if (!Node.getLocStart().isMacroID())
+return false;
+
+  const SourceManager  = Finder->getASTContext().getSourceManager();
+  if 
(!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getLocStart()))
+return false;
+
+  const LangOptions  = Finder->getASTContext().getLangOpts();
+  SourceLocation LocStart = Node.getLocStart();
+  while (LocStart.isMacroID()) {
+SourceLocation Invocation = SM.getImmediateMacroCallerLoc(LocStart);
+Token Tok;
+if (!Lexer::getRawToken(SM.getSpellingLoc(Invocation), Tok, SM, Opts,
+/*IgnoreWhiteSpace=*/true)) {
+  if (Tok.getKind() == tok::raw_identifier &&
+  Tok.getRawIdentifier() == "TEMP_FAILURE_RETRY")
+return true;
+}
+
+LocStart = Invocation;
+  }
+  return false;
+}
+} // namespace
+
+void ComparisonInTempFailureRetryCheck::registerMatchers(MatchFinder *Finder) {
+  // Both glibc's and Bionic's TEMP_FAILURE_RETRY macros structurally look 
like:
+  //
+  // #define TEMP_FAILURE_RETRY(x) ({ \
+  //typeof(x) y; \
+  //do y = (x); \
+  //while (y == -1 && errno == EINTR); \
+  //y; \
+  // })
+  //
+  

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 141913.
paulsemel added a comment.

Fixed printf warning generated in tests/CodeGen.


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/dump-struct-builtin.c
  test/Sema/builtin-dump-struct.c

Index: test/Sema/builtin-dump-struct.c
===
--- /dev/null
+++ test/Sema/builtin-dump-struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
+
+void invalid_uses() {
+  struct A {
+  };
+  struct A a;
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);
+  int (*badfunc2)(int, ...);
+  void (*badfunc3)(const char *, ...);
+  int (*badfunc4)(char *, ...);
+  int (*badfunc5)(void);
+
+  __builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}}
+  __builtin_dump_struct(1);// expected-error {{too few arguments to function call, expected 2, have 1}}
+  __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(a, goodfunc);  // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
+}
+
+void valid_uses() {
+  struct A {
+  };
+  union B {
+  };
+
+  int (*goodfunc)(const char *, ...);
+  int (*goodfunc2)();
+  struct A a;
+  union B b;
+
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc2);
+}
Index: test/CodeGen/dump-struct-builtin.c
===
--- /dev/null
+++ test/CodeGen/dump-struct-builtin.c
@@ -0,0 +1,391 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/stdio.h"
+
+int printf(const char *fmt, ...) {
+return 0;
+}
+
+void unit1() {
+  struct U1A {
+short a;
+  };
+
+  struct U1A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U1A, %struct.U1A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit2() {
+  struct U2A {
+unsigned short a;
+  };
+
+  struct U2A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U2A, %struct.U2A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit3() {
+  struct U3A {
+int a;
+  };
+
+  struct U3A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U3A, %struct.U3A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: 

r329758 - Handle the default case

2018-04-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Apr 10 14:19:05 2018
New Revision: 329758

URL: http://llvm.org/viewvc/llvm-project?rev=329758=rev
Log:
Handle the default case

This was omitted in D45422 resulting in a warning.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/NaCl.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NaCl.cpp?rev=329758=329757=329758=diff
==
--- cfe/trunk/lib/Driver/ToolChains/NaCl.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NaCl.cpp Tue Apr 10 14:19:05 2018
@@ -334,6 +334,8 @@ void NaClToolChain::addLibCxxIncludePath
 llvm::sys::path::append(P, "mipsel-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());
 break;
+  default:
+break;
   }
 }
 


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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

Sorry about it, I also have the warning on my machine, but not the error you 
get...
Those test are actually working on my different linux machines, that's really 
weird.
This one is actually really weird, because I could find manually the missing 
pattern in your output.. I just don't get what is happening.


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-04-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 141912.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

- Update
- Ignore GNU Statement Expressions too.
- Slightly reword docs.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-function-size.rst
  test/clang-tidy/readability-function-size-variables-c++17.cpp
  test/clang-tidy/readability-function-size.cpp

Index: test/clang-tidy/readability-function-size.cpp
===
--- test/clang-tidy/readability-function-size.cpp
+++ test/clang-tidy/readability-function-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}]}' -- -std=c++11
+// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}, {key: readability-function-size.VariableThreshold, value: 1}]}' -- -std=c++11
 
 // Bad formatting is intentional, don't run clang-format over the whole file!
 
@@ -64,7 +64,7 @@
 
 void baz0() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 28 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
@@ -87,14 +87,15 @@
 }
   }
   macro()
-// CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
+  // CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-27]]:6: note: 6 variables (threshold 1)
 }
 
 // check that nested if's are not reported. this was broken initially
 void nesting_if() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
   if (true) { // 2
@@ -114,12 +115,13 @@
   } else if (true) { // 2
  int j;
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
 }
 
 // however this should warn
 void bad_if_nesting() { // 1
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
   if (true) {// 2
@@ -139,4 +141,160 @@
   }
 }
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 4 variables (threshold 1)
 }
+
+void variables_0() {
+  int i;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_0' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_1(int i) {
+  int j;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_1' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_2(int i, int j) {
+  ;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_2' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 

[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-04-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:31
+!(isa(VD) || isa(VD)) &&
+!VD->getLocation().isMacroID())
+  Info.Variables++;

aaron.ballman wrote:
> This isn't the restriction I was envisioning. I was thinking more along the 
> lines of:
> ```
> bool VisitStmtExpr(StmtExpr *SE) override {
>   ++StructNesting;
>   Base::VisitStmtExpr(SE);
>   --StructNesting;
>   return true;
> }
> ```
> Basically -- treat a statement expression the same as an inner struct or 
> lambda because the variables declared within it are scoped *only* to the 
> statement expression.
> 
> You could argue that we should also add: `if (!SE->getLocation.isMacroID()) { 
> Base::VisitStmtExpr(SE); }` to the top of the function so that you only treat 
> statement expressions that are themselves in a macro expansion get this 
> special treatment. e.g.,
> ```
> void one_var() {
>   (void)({int a = 12; a;});
> }
> 
> #define M ({int a = 12; a;})
> void zero_var() {
>   (void)M;
> }
> ```
> I don't have strong opinions on this, but weakly lean towards treating all 
> statement expressions the same way.
Ah, i did not really knew about `GNU Statement Expression`, so i did not ignore 
them.
Test added, and ignored.



Comment at: test/clang-tidy/readability-function-size.cpp:207-212
+void variables_8() {
+  int a, b;
+  struct A {
+A(int c, int d);
+  };
+}

aaron.ballman wrote:
> JonasToth wrote:
> > lebedev.ri wrote:
> > > aaron.ballman wrote:
> > > > lebedev.ri wrote:
> > > > > aaron.ballman wrote:
> > > > > > JonasToth wrote:
> > > > > > > lebedev.ri wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > lebedev.ri wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > lebedev.ri wrote:
> > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > lebedev.ri wrote:
> > > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > > I think the current behavior here is correct and 
> > > > > > > > > > > > > > > the previous behavior was incorrect. However, it 
> > > > > > > > > > > > > > > brings up an interesting question about what to 
> > > > > > > > > > > > > > > do here:
> > > > > > > > > > > > > > > ```
> > > > > > > > > > > > > > > void f() {
> > > > > > > > > > > > > > >   struct S {
> > > > > > > > > > > > > > > void bar() {
> > > > > > > > > > > > > > >   int a, b;
> > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > >   };
> > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > ```
> > > > > > > > > > > > > > > Does `f()` contain zero variables or two? I would 
> > > > > > > > > > > > > > > contend that it has no variables because S::bar() 
> > > > > > > > > > > > > > > is a different scope than f(). But I can see a 
> > > > > > > > > > > > > > > case being made about the complexity of f() being 
> > > > > > > > > > > > > > > increased by the presence of the local class 
> > > > > > > > > > > > > > > definition. Perhaps this is a different facet of 
> > > > > > > > > > > > > > > the test about number of types?
> > > > > > > > > > > > > > As previously briefly discussed in IRC, i 
> > > > > > > > > > > > > > **strongly** believe that the current behavior is 
> > > > > > > > > > > > > > correct, and `readability-function-size`
> > > > > > > > > > > > > > should analyze/diagnose the function as a whole, 
> > > > > > > > > > > > > > including all sub-classes/sub-functions.
> > > > > > > > > > > > > Do you know of any coding standards related to this 
> > > > > > > > > > > > > check that weigh in on this?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > What do you think about this:
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > #define SWAP(x, y) ({__typeof__(x) temp = x; x = y; y 
> > > > > > > > > > > > > = x;})
> > > > > > > > > > > > > 
> > > > > > > > > > > > > void f() {
> > > > > > > > > > > > >   int a = 10, b = 12;
> > > > > > > > > > > > >   SWAP(a, b);
> > > > > > > > > > > > > }
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > Does f() have two variables or three? Should presence 
> > > > > > > > > > > > > of the `SWAP` macro cause this code to be more 
> > > > > > > > > > > > > complex due to having too many variables?
> > > > > > > > > > > > Datapoint: the doc 
> > > > > > > > > > > > (`docs/clang-tidy/checks/readability-function-size.rst`)
> > > > > > > > > > > >  actually already states that macros *are* counted.
> > > > > > > > > > > > 
> > > > > > > > > > > > ```
> > > > > > > > > > > > .. option:: StatementThreshold
> > > > > > > > > > > > 
> > > > > > > > > > > >Flag functions exceeding this number of statements. 
> > > > > > > > > > > > This may differ
> > > > > > > > > > > >significantly from the number of lines for 
> > > > > > > > > > > > macro-heavy code. The default is
> > > > > > > > > > > >`800`.
> > > > > > > > > > > > ```
> > > > > > > > > > > > ```
> > > > > > > > > > > 

[PATCH] D45504: [MinGW] Look for a cross sysroot relative to the clang binary

2018-04-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 141909.
mstorsjo added a comment.

Fixed the hardcoded triplet suffix, previously I erroneously had a "-gcc" 
suffix there.


https://reviews.llvm.org/D45504

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


Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -96,6 +96,7 @@
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
   llvm::ErrorOr findGcc();
+  llvm::ErrorOr findClangRelativeSysroot();
 };
 
 } // end namespace toolchains
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -275,7 +275,8 @@
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = Archs[0].str();
+  if (Arch.empty())
+Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
@@ -302,13 +303,34 @@
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
+llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() {
+  llvm::SmallVector, 2> Subdirs;
+  Subdirs.emplace_back(getTriple().str());
+  Subdirs.emplace_back(getTriple().getArchName());
+  Subdirs[1] += "-w64-mingw32";
+  Twine ClangRoot = 
llvm::sys::path::parent_path(getDriver().getInstalledDir()) +
+llvm::sys::path::get_separator();
+  for (StringRef CandidateSubdir : Subdirs) {
+Twine Subdir = ClangRoot + CandidateSubdir;
+if (llvm::sys::fs::is_directory(Subdir)) {
+  Arch = CandidateSubdir;
+  return Subdir.str();
+}
+  }
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
+  // Look for /../; if found, use /.. as the
+  // base as it could still be a base for a gcc setup with libgcc.
+  else if (llvm::ErrorOr TargetSubdir = 
findClangRelativeSysroot())
+Base = llvm::sys::path::parent_path(TargetSubdir.get());
   else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));


Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -96,6 +96,7 @@
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
   llvm::ErrorOr findGcc();
+  llvm::ErrorOr findClangRelativeSysroot();
 };
 
 } // end namespace toolchains
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -275,7 +275,8 @@
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = Archs[0].str();
+  if (Arch.empty())
+Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
@@ -302,13 +303,34 @@
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
+llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() {
+  llvm::SmallVector, 2> Subdirs;
+  Subdirs.emplace_back(getTriple().str());
+  Subdirs.emplace_back(getTriple().getArchName());
+  Subdirs[1] += "-w64-mingw32";
+  Twine ClangRoot = llvm::sys::path::parent_path(getDriver().getInstalledDir()) +
+llvm::sys::path::get_separator();
+  for (StringRef CandidateSubdir : Subdirs) {
+Twine Subdir = ClangRoot + CandidateSubdir;
+if (llvm::sys::fs::is_directory(Subdir)) {
+  Arch = CandidateSubdir;
+  return Subdir.str();
+}
+  }
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
+  // Look for /../; if found, use /.. as the
+  // base as it could still be a base for a gcc setup with libgcc.
+  else if (llvm::ErrorOr TargetSubdir = findClangRelativeSysroot())
+Base = llvm::sys::path::parent_path(TargetSubdir.get());
   else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));
___
cfe-commits mailing list

[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This change had two different problems.
Please watch the bots?


Repository:
  rL LLVM

https://reviews.llvm.org/D45405



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


[clang-tools-extra] r329756 - [clang-tidy] Unbreak run-clang-tidy.cpp test (modernize-use-auto.MinTypeNameLength)

2018-04-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Apr 10 13:59:27 2018
New Revision: 329756

URL: http://llvm.org/viewvc/llvm-project?rev=329756=rev
Log:
[clang-tidy] Unbreak run-clang-tidy.cpp test 
(modernize-use-auto.MinTypeNameLength)

Again, refs. D45405, rL329730.

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

Modified: clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp?rev=329756=329755=329756=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp Tue Apr 10 
13:59:27 2018
@@ -3,6 +3,9 @@
 // RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
 // RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
 // RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: echo "CheckOptions:" >> %t/.clang-tidy
+// RUN: echo "  - key: modernize-use-auto.MinTypeNameLength" >> 
%t/.clang-tidy
+// RUN: echo "value:   '0'" >> %t/.clang-tidy
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: cd "%t"
 // RUN: not %run_clang_tidy "%t/test.cpp"


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


[PATCH] D45505: [WIP] [GCC] Match a GCC version with a patch suffix without a third version component

2018-04-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: chandlerc, martell, ismail, rnk, compnerd, mati865, 
yaron.keren.

Previously it would only accept a string as a GCC version if it had either two 
components and no suffix, or three components with an optional suffix.

Debian and ubuntu provided mingw compilers have lib/gcc/target entries like 
"5.3-posix" and "5.3-win32". This doesn't try to make any specific preference 
between them (other than lexical sorting of the suffix).

Tests are missing though; I guess the neatest thing for this would be a unit 
test? Is the ToolChains internal header Gnu.h testable from the unittests 
directory? OTOH I could just do a simple driver based test with a dummy 
directory structure.


Repository:
  rC Clang

https://reviews.llvm.org/D45505

Files:
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1615,21 +1615,29 @@
   GoodVersion.MajorStr = First.first.str();
   if (First.second.empty())
 return GoodVersion;
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 
0)
+  StringRef MinorStr = Second.first;
+  if (Second.second.empty()) {
+if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
+  GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+  MinorStr = MinorStr.slice(0, EndNumber);
+}
+  }
+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  GoodVersion.MinorStr = MinorStr.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
   //   5(handled above)
   //   4.4
+  //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
+  StringRef PatchText = Second.second.str();
   if (!PatchText.empty()) {
 if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
   // Try to parse the number and any suffix.


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1615,21 +1615,29 @@
   GoodVersion.MajorStr = First.first.str();
   if (First.second.empty())
 return GoodVersion;
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
+  StringRef MinorStr = Second.first;
+  if (Second.second.empty()) {
+if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
+  GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
+  MinorStr = MinorStr.slice(0, EndNumber);
+}
+  }
+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  GoodVersion.MinorStr = MinorStr.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
   //   5(handled above)
   //   4.4
+  //   4.4-patched
   //   4.4.0
   //   4.4.x
   //   4.4.2-rc4
   //   4.4.x-patched
   // And retains any patch number it finds.
-  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
+  StringRef PatchText = Second.second.str();
   if (!PatchText.empty()) {
 if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
   // Try to parse the number and any suffix.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-04-10 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:188
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

Not related to this patch, but does IcelakeServer have SGX? The adding 
icelake-server patch and removing sgx from skylakeserver intersected here.


https://reviews.llvm.org/D43817



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for rebasing, but the patch does not pass tests locally for me. I get 
the following results (testing on Windows x64 with MSVC 2017 in a Debug build):

63> TEST 'Clang :: CodeGen/dump-struct-builtin.c' FAILED 

63>Script:
63>--
63>d:\build\debug\bin\clang.EXE -cc1 -internal-isystem 
d:\build\debug\lib\clang\7.0.0\include -nostdsysteminc -emit-llvm 
D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c -o - | 
D:\build\Debug\bin\FileCheck.EXE 
D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c
63>--
63>Exit Code: 1
63>
63>Command Output (stdout):
63>--
63>$ "d:\build\debug\bin\clang.EXE" "-cc1" "-internal-isystem" 
"d:\build\debug\lib\clang\7.0.0\include" "-nostdsysteminc" "-emit-llvm" 
"D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c" "-o" "-"
63># command stderr:
63>D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c(20,30): warning 
G4AB12AC8: implicitly declaring library function 'printf' with type 'int (const 
char *, ...)'
63>
63>  __builtin_dump_struct(, );
63>
63> ^
63>
63>D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c:20:30: note: include 
the header  or explicitly provide a declaration for 'printf'
63>
63>1 warning generated.
63>
63>
63>$ "D:\build\Debug\bin\FileCheck.EXE" 
"D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c"
63># command stderr:
63>D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c(105,12): error 
G8E235623: expected string not found in input
63>
63> // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U6A, 
%struct.U6A* %a, i32 0, i32 0
63>
63>   ^
63>
63>:290:35: note: scanning from here
63>
63> %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 
x i8]* @28, i32 0, i32 0))
63>
63>  ^
63>
63>:291:2: note: possible intended match here
63>
63> %2 = getelementptr inbounds %struct.U8A, %struct.U8A* %a, i32 0, i32 0
63>
63> ^
63>
63>
63>CUSTOMBUILD : error : command failed with exit status: 1
63>
63>--
63>
63>

The output from the test on my machine is:

C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Professional>d:\build\debug\bin\clang.EXE -cc1 -internal-isystem 
d:\build\debug\lib\clang\7.0.0\include -nostdsysteminc -emit-llvm 
D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c -o -
D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c:20:30: warning: 
implicitly declaring library function 'printf' with type 'int (const char *, 
...)'

  __builtin_dump_struct(, );
 ^

D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c:20:30: note: include the 
header  or explicitly provide a declaration for 'printf'
; ModuleID = 'D:\llvm\tools\clang\test\CodeGen\dump-struct-builtin.c'
source_filename = 
"D:\5Cllvm\5Ctools\5Cclang\5Ctest\5CCodeGen\5Cdump-struct-builtin.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

%struct.U1A = type { i16 }
%struct.U2A = type { i16 }
%struct.U3A = type { i32 }
%struct.U4A = type { i32 }
%struct.U5A = type { i32 }
%struct.U6A = type { i32 }
%struct.U7A = type { i64 }
%struct.U8A = type { i64 }
%struct.U9A = type { i8 }
%struct.U10A = type { i8* }
%struct.U11A = type { i8* }
%struct.U12A = type { i8* }
%struct.U13A = type { i8* }
%struct.U14A = type { double }
%struct.U15A = type { [3 x i32] }
%struct.T1A = type { i32, i8* }
%struct.T2B = type { i32, %struct.T2A }
%struct.T2A = type { i32 }
%struct.T3A = type { %union.anon }
%union.anon = type { i32 }
%struct.T4A = type { %union.anon.0 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { i8* }
%struct.anon.1 = type { i32 }

$"??_C@_03OMINOMMP@LSE?$AA@" = comdat any

@unit1.a = private unnamed_addr constant %struct.U1A { i16 12 }, align 2
@0 = private unnamed_addr constant [14 x i8] c"struct U1A {\0A\00"
@1 = private unnamed_addr constant [11 x i8] c"short a : \00"
@2 = private unnamed_addr constant [5 x i8] c"%hd\0A\00"
@3 = private unnamed_addr constant [3 x i8] c"}\0A\00"
@unit2.a = private unnamed_addr constant %struct.U2A { i16 12 }, align 2
@4 = private unnamed_addr constant [14 x i8] c"struct U2A {\0A\00"
@5 = private unnamed_addr constant [20 x i8] c"unsigned short a : \00"
@6 = private unnamed_addr constant [5 x i8] c"%hu\0A\00"
@7 = private unnamed_addr constant [3 x i8] c"}\0A\00"
@unit3.a = private unnamed_addr constant %struct.U3A { i32 12 }, align 4
@8 = private unnamed_addr constant [14 x i8] c"struct U3A {\0A\00"
@9 = private unnamed_addr constant [9 x i8] c"int a : \00"
@10 = private unnamed_addr constant [4 x i8] c"%d\0A\00"
@11 = private unnamed_addr constant [3 x i8] c"}\0A\00"
@unit4.a = private unnamed_addr constant %struct.U4A { i32 12 }, align 4
@12 = private unnamed_addr constant [14 x i8] c"struct U4A {\0A\00"
@13 = private unnamed_addr constant [18 x i8] c"unsigned int a : \00"
@14 = private unnamed_addr constant [4 x i8] c"%u\0A\00"
@15 = private 

[PATCH] D45504: [MinGW] Look for a cross sysroot relative to the clang binary

2018-04-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: martell, rnk, compnerd, mati865, ismail, yaron.keren.

If found, prefer this over looking for a similar gcc later in the system path.

This implements what @martell suggested in https://reviews.llvm.org/D45152 in a 
much neater way.

Tests still are TBD, but posting this early to see if there's comments. (How do 
I easily do a test that checks something relative to the clang binary, since I 
don't control the location of the tested binary when running tests?)


Repository:
  rC Clang

https://reviews.llvm.org/D45504

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


Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -96,6 +96,7 @@
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
   llvm::ErrorOr findGcc();
+  llvm::ErrorOr findClangRelativeSysroot();
 };
 
 } // end namespace toolchains
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -275,7 +275,8 @@
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = Archs[0].str();
+  if (Arch.empty())
+Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
@@ -302,13 +303,34 @@
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
+llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() {
+  llvm::SmallVector, 2> Subdirs;
+  Subdirs.emplace_back(getTriple().str());
+  Subdirs.emplace_back(getTriple().getArchName());
+  Subdirs[1] += "-w64-mingw32-gcc";
+  Twine ClangRoot = 
llvm::sys::path::parent_path(getDriver().getInstalledDir()) +
+llvm::sys::path::get_separator();
+  for (StringRef CandidateSubdir : Subdirs) {
+Twine Subdir = ClangRoot + CandidateSubdir;
+if (llvm::sys::fs::is_directory(Subdir)) {
+  Arch = CandidateSubdir;
+  return Subdir.str();
+}
+  }
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
+  // Look for /../; if found, use /.. as the
+  // base as it could still be a base for a gcc setup with libgcc.
+  else if (llvm::ErrorOr TargetSubdir = 
findClangRelativeSysroot())
+Base = llvm::sys::path::parent_path(TargetSubdir.get());
   else if (llvm::ErrorOr GPPName = findGcc())
 Base = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(GPPName.get()));


Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -96,6 +96,7 @@
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
   llvm::ErrorOr findGcc();
+  llvm::ErrorOr findClangRelativeSysroot();
 };
 
 } // end namespace toolchains
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -275,7 +275,8 @@
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = Archs[0].str();
+  if (Arch.empty())
+Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
@@ -302,13 +303,34 @@
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
+llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() {
+  llvm::SmallVector, 2> Subdirs;
+  Subdirs.emplace_back(getTriple().str());
+  Subdirs.emplace_back(getTriple().getArchName());
+  Subdirs[1] += "-w64-mingw32-gcc";
+  Twine ClangRoot = llvm::sys::path::parent_path(getDriver().getInstalledDir()) +
+llvm::sys::path::get_separator();
+  for (StringRef CandidateSubdir : Subdirs) {
+Twine Subdir = ClangRoot + CandidateSubdir;
+if (llvm::sys::fs::is_directory(Subdir)) {
+  Arch = CandidateSubdir;
+  return Subdir.str();
+}
+  }
+  return make_error_code(std::errc::no_such_file_or_directory);
+}
+
 toolchains::MinGW::MinGW(const Driver , const llvm::Triple ,
  const ArgList )
 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
+  // Look for /../; if found, use /.. as the
+  // base as it could still be a base 

[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-04-10 Thread Gabor Buella via Phabricator via cfe-commits
GBuella updated this revision to Diff 141904.
GBuella added a comment.

Rebased the patch.


https://reviews.llvm.org/D43817

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cpuid.h
  lib/Headers/wbnoinvdintrin.h
  lib/Headers/x86intrin.h
  test/CodeGen/builtin-wbnoinvd.c
  test/CodeGen/builtins-x86.c
  test/Driver/x86-target-features.c
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1100,6 +1100,7 @@
 // CHECK_ICL_M32: #define __SSSE3__ 1
 // CHECK_ICL_M32: #define __VAES__ 1
 // CHECK_ICL_M32: #define __VPCLMULQDQ__ 1
+// CHECK_ICL_M32-NOT: #define __WBNOINVD__ 1
 // CHECK_ICL_M32: #define __XSAVEC__ 1
 // CHECK_ICL_M32: #define __XSAVEOPT__ 1
 // CHECK_ICL_M32: #define __XSAVES__ 1
@@ -1156,6 +1157,7 @@
 // CHECK_ICL_M64: #define __SSSE3__ 1
 // CHECK_ICL_M64: #define __VAES__ 1
 // CHECK_ICL_M64: #define __VPCLMULQDQ__ 1
+// CHECK_ICL_M64-NOT: #define __WBNOINVD__ 1
 // CHECK_ICL_M64: #define __XSAVEC__ 1
 // CHECK_ICL_M64: #define __XSAVEOPT__ 1
 // CHECK_ICL_M64: #define __XSAVES__ 1
@@ -1213,6 +1215,7 @@
 // CHECK_ICX_M32: #define __SSSE3__ 1
 // CHECK_ICX_M32: #define __VAES__ 1
 // CHECK_ICX_M32: #define __VPCLMULQDQ__ 1
+// CHECK_ICX_M32: #define __WBNOINVD__ 1
 // CHECK_ICX_M32: #define __XSAVEC__ 1
 // CHECK_ICX_M32: #define __XSAVEOPT__ 1
 // CHECK_ICX_M32: #define __XSAVES__ 1
@@ -1269,6 +1272,7 @@
 // CHECK_ICX_M64: #define __SSSE3__ 1
 // CHECK_ICX_M64: #define __VAES__ 1
 // CHECK_ICX_M64: #define __VPCLMULQDQ__ 1
+// CHECK_ICX_M64: #define __WBNOINVD__ 1
 // CHECK_ICX_M64: #define __XSAVEC__ 1
 // CHECK_ICX_M64: #define __XSAVEOPT__ 1
 // CHECK_ICX_M64: #define __XSAVES__ 1
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -60,6 +60,11 @@
 // CLWB: "-target-feature" "+clwb"
 // NO-CLWB: "-target-feature" "-clwb"
 
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mwbnoinvd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WBNOINVD %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-wbnoinvd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WBNOINVD %s
+// WBNOINVD: "-target-feature" "+wbnoinvd"
+// NO-WBNOINVD: "-target-feature" "-wbnoinvd"
+
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmovbe %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MOVBE %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movbe %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVBE %s
 // MOVBE: "-target-feature" "+movbe"
Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-feature +ibt -target-feature +shstk -emit-llvm -o %t %s
-// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +ibt -target-feature +shstk -target-feature +clzero -fsyntax-only -o %t %s
+// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-feature +ibt -target-feature +shstk -target-feature +wbnoinvd -emit-llvm -o %t %s
+// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +ibt -target-feature +shstk -target-feature +clzero -target-feature +wbnoinvd -fsyntax-only -o %t %s
 
 #ifdef USE_ALL
 #define USE_3DNOW
@@ -305,6 +305,7 @@
   tmp_i = __rdtsc();
   tmp_i = __builtin_ia32_rdtscp(_Ui);
   tmp_LLi = __builtin_ia32_rdpmc(tmp_i);
+  __builtin_ia32_wbnoinvd();
 #ifdef USE_64
   tmp_LLi = __builtin_ia32_cvtss2si64(tmp_V4f);
   tmp_LLi = __builtin_ia32_cvttss2si64(tmp_V4f);
Index: test/CodeGen/builtin-wbnoinvd.c
===
--- /dev/null
+++ test/CodeGen/builtin-wbnoinvd.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +wbnoinvd -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_wbnoinvd(void) {
+  

[PATCH] D45383: Limit types of builtins that can be redeclared.

2018-04-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 141900.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Restrict overloads as well.


https://reviews.llvm.org/D45383

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Basic/Builtins.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/builtin-redecl.cpp
  test/SemaCXX/microsoft-varargs.cpp

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -7244,6 +7244,10 @@
   return BuiltinMSVaListDecl;
 }
 
+bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const {
+  return BuiltinInfo.canBeRedeclared(FD->getBuiltinID());
+}
+
 void ASTContext::setObjCConstantStringInterface(ObjCInterfaceDecl *Decl) {
   assert(ObjCConstantStringType.isNull() &&
  "'NSConstantString' type already set!");
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -998,6 +998,13 @@
 Match = *I;
 return Ovl_Match;
   }
+
+  // Builtins that have custom typechecking or have a reference should
+  // not be overloadable or redeclarable.
+  if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
+Match = *I;
+return Ovl_NonFunction;
+  }
 } else if (isa(OldD) || isa(OldD)) {
   // We can overload with these, which can show up when doing
   // redeclaration checks for UsingDecls.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3014,6 +3014,14 @@
   if (Old->isInvalidDecl())
 return true;
 
+  // Disallow redeclaration of some builtins.
+  if (!getASTContext().canBuiltinBeRedeclared(Old)) {
+Diag(New->getLocation(), diag::err_builtin_redeclare) << Old->getDeclName();
+Diag(Old->getLocation(), diag::note_previous_builtin_declaration)
+<< Old << Old->getType();
+return true;
+  }
+
   diag::kind PrevDiag;
   SourceLocation OldLocation;
   std::tie(PrevDiag, OldLocation) =
Index: lib/Basic/Builtins.cpp
===
--- lib/Basic/Builtins.cpp
+++ lib/Basic/Builtins.cpp
@@ -139,3 +139,9 @@
bool ) {
   return isLike(ID, FormatIdx, HasVAListArg, "sS");
 }
+
+bool Builtin::Context::canBeRedeclared(unsigned ID) const {
+  return ID == Builtin::NotBuiltin ||
+ (!hasReferenceArgsOrResult(ID) &&
+  !hasCustomTypechecking(ID));
+}
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -1881,6 +1881,10 @@
 return getTypeDeclType(getBuiltinMSVaListDecl());
   }
 
+  /// Return whether a declaration to a builtin is allowed to be
+  /// overloaded/redeclared.
+  bool canBuiltinBeRedeclared(const FunctionDecl *) const;
+
   /// \brief Return a type with additional \c const, \c volatile, or
   /// \c restrict qualifiers.
   QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -602,6 +602,7 @@
   "incompatible redeclaration of library function %0">,
   InGroup>;
 def err_builtin_definition : Error<"definition of builtin function %0">;
+def err_builtin_redeclare : Error<"cannot redeclare builtin function %0">;
 def err_arm_invalid_specialreg : Error<"invalid special register for builtin">;
 def err_invalid_cpu_supports : Error<"invalid cpu feature string for builtin">;
 def err_invalid_cpu_is : Error<"invalid cpu name for builtin">;
Index: include/clang/Basic/Builtins.h
===
--- include/clang/Basic/Builtins.h
+++ include/clang/Basic/Builtins.h
@@ -167,6 +167,13 @@
 return strchr(getRecord(ID).Type, '*') != nullptr;
   }
 
+  /// \brief Return true if this builtin has a result or any arguments which are
+  /// reference types.
+  bool hasReferenceArgsOrResult(unsigned ID) const {
+return strchr(getRecord(ID).Type, '&') != nullptr ||
+   strchr(getRecord(ID).Type, 'A') != nullptr;
+  }
+
   /// \brief Completely forget that the given ID was ever considered a builtin,
   /// e.g., because the user provided a conflicting signature.
   void forgetBuiltin(unsigned ID, IdentifierTable );
@@ -212,6 +219,10 @@
   /// prefix.
   static bool isBuiltinFunc(const char *Name);
 
+  /// Returns true if this is a builtin that can be redeclared.  Returns true
+  /// for 

[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this!




Comment at: include/clang/AST/ComparisonCategories.h:78
+  const DeclRefExpr *getResultValue(ComparisonCategoryResult ValueKind) const {
+const auto *DR = getResultValueUnsafe(ValueKind);
+assert(DR &&

Avoid `auto` when the type is not explicitly spelled out in the initialization.



Comment at: include/clang/AST/ComparisonCategories.h:155-158
+  const ComparisonCategoryInfo (ComparisonCategoryKind Kind) const {
+assert(HasData && "comparison category information not yet built");
+return Data[static_cast(Kind)];
+  }

It seems like this method can be private rather than public.



Comment at: include/clang/AST/ComparisonCategories.h:170
+
+  /// \brief Return the comparison category kind coorisponding to the specified
+  ///   type. 'Ty' is expected to refer to the type of one of the comparison

s/coorisponding/corresponding



Comment at: include/clang/AST/ComparisonCategories.h:176-177
+  /// \brief returns true if the comparison category data has already been
+  /// built,
+  ///and false otherwise.
+  bool hasData() const { return HasData; }

Did this get re-flowed in a strange manner?



Comment at: include/clang/AST/ComparisonCategories.h:180
+
+public: // private
+  using InfoList =

The comment here seems incorrect.



Comment at: include/clang/AST/Expr.h:3020
+  // ordered comparison. Otherwise the comparison is an equality comparison.
+  unsigned IsCmpOrdered : 1;
+

It's unfortunate that this means we're using 9 bits rather than the 8 we were 
previously using, but I don't see a particularly good way to solve that.



Comment at: include/clang/AST/Expr.h:3028
   BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
- ExprValueKind VK, ExprObjectKind OK,
- SourceLocation opLoc, FPOptions FPFeatures)
+ ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc,
+ FPOptions FPFeatures)

s/opLoc/OpLoc



Comment at: include/clang/AST/Expr.h:3167
 
+  void setIsCmpOrdered(bool Val = true) { IsCmpOrdered = Val; }
+  bool getIsCmpOrdered() const { return IsCmpOrdered; }

Both calls to this function are explicit with the argument, so I think you can 
drop the default argument value.



Comment at: include/clang/Sema/Sema.h:4547
+  /// results are cached in ASTContext so they are accessible outside of Sema.
+  /// An error is emitted  if the types are not found or another error occurs.
+  ///

Extra whitespace between emitted and if.



Comment at: lib/AST/ComparisonCategories.cpp:1
+//===- ComparisonCategories.h - Three Way Comparison Data ---*- C++ 
-*-===//
+//

.cpp instead of .h



Comment at: lib/AST/ComparisonCategories.cpp:38
+ComparisonCategories::getInfoForType(QualType Ty) const {
+  auto OptKind = getCategoryForType(Ty);
+  assert(OptKind &&

Don't use `auto` here.



Comment at: lib/AST/ExprConstant.cpp:5084
+
+  BinOpEvaluatorBase(EvalInfo , ComparisonCategoryResult *CmpRes = 
nullptr)
+: ExprEvaluatorBaseTy(info), CmpResult(CmpRes) {

s/info/Info



Comment at: lib/AST/ExprConstant.cpp:6301
+  using CCR = ComparisonCategoryResult;
+  auto  = Info.Ctx.CompCategories.getInfoForType(E->getType());
+

Don't use `auto` here.



Comment at: lib/AST/ExprConstant.cpp:8589
+  bool IsSpaceship = E->getOpcode() == BO_Cmp;
+  auto  = this->Info;
   // We don't call noteFailure immediately because the assignment happens after

Don't use `auto` here. Also, perhaps the two variables can be sunk closer to 
where they're used?



Comment at: lib/AST/ExprConstant.cpp:8930
   if (LHSTy->isMemberPointerType()) {
-assert(E->isEqualityOp() && "unexpected member pointer operation");
+assert((E->isEqualityOp()) && "unexpected member pointer operation");
 assert(RHSTy->isMemberPointerType() && "invalid comparison");

Spurious parens?



Comment at: lib/AST/ExprConstant.cpp:10814
+// Check that all of the references to the result objects are ICE.
+auto  = Ctx.CompCategories.getInfoForType(Exp->getType());
+ICEDiag RetDiag(IK_ICE, E->getLocStart());

Don't use `auto` here.



Comment at: lib/AST/ExprConstant.cpp:10816
+ICEDiag RetDiag(IK_ICE, E->getLocStart());
+for (auto  : CmpInfo.Objects)
+  RetDiag = Worst(RetDiag, CheckICE(KV.second, Ctx));

`const auto &`?



Comment at: lib/CodeGen/CGExprAgg.cpp:892
+  QualType ArgTy = 

[PATCH] D45499: [Driver] Handle the default case

2018-04-10 Thread Chad Rosier via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329754: [Driver] Handle the default case missed in r329748. 
(authored by mcrosier, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45499?vs=141893=141899#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45499

Files:
  lib/Driver/ToolChains/NaCl.cpp


Index: lib/Driver/ToolChains/NaCl.cpp
===
--- lib/Driver/ToolChains/NaCl.cpp
+++ lib/Driver/ToolChains/NaCl.cpp
@@ -316,6 +316,8 @@
 
   SmallString<128> P(D.Dir + "/../");
   switch (getTriple().getArch()) {
+  default:
+break;
   case llvm::Triple::arm:
 llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());


Index: lib/Driver/ToolChains/NaCl.cpp
===
--- lib/Driver/ToolChains/NaCl.cpp
+++ lib/Driver/ToolChains/NaCl.cpp
@@ -316,6 +316,8 @@
 
   SmallString<128> P(D.Dir + "/../");
   switch (getTriple().getArch()) {
+  default:
+break;
   case llvm::Triple::arm:
 llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329754 - [Driver] Handle the default case missed in r329748.

2018-04-10 Thread Chad Rosier via cfe-commits
Author: mcrosier
Date: Tue Apr 10 13:30:16 2018
New Revision: 329754

URL: http://llvm.org/viewvc/llvm-project?rev=329754=rev
Log:
[Driver] Handle the default case missed in r329748.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/NaCl.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NaCl.cpp?rev=329754=329753=329754=diff
==
--- cfe/trunk/lib/Driver/ToolChains/NaCl.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NaCl.cpp Tue Apr 10 13:30:16 2018
@@ -316,6 +316,8 @@ void NaClToolChain::addLibCxxIncludePath
 
   SmallString<128> P(D.Dir + "/../");
   switch (getTriple().getArch()) {
+  default:
+break;
   case llvm::Triple::arm:
 llvm::sys::path::append(P, "arm-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());


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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-10 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Hi @efriedma – Sorry about that. I haven't directly used `svn` in years thanks 
to the `git svn` bridge.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D45500: [MinGW] Look for libc++ headers in a triplet prefixed path as well

2018-04-10 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: martell, rnk, compnerd, mati865.
Herald added a reviewer: EricWF.

This makes it consistent with libstdc++ and the other default include 
directories.

If these headers are found in both locations and one isn't a symlink to the 
other, this will cause errors due to libc++ headers having wrapper headers for 
some standard C headers, wrappers that do #include_next the actual one.

If the same libc++ standard C wrapper header exists in more than one include 
directory before the real system one, the header include guard will stop it 
from doing another #include_next to pick up the real one, breaking things.

As this is a rather uncommon situation, this should be acceptable and toolchain 
maintainers can adapt accordingly if necessary.


Repository:
  rC Clang

https://reviews.llvm.org/D45500

Files:
  lib/Driver/ToolChains/MinGW.cpp
  test/Driver/mingw.cpp


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -3,6 +3,10 @@
 // CHECK_MINGW_CLANG_TREE: 
"{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
 
 
+// RUN: %clang -target i686-windows-gnu -rtlib=platform -stdlib=libc++ -c -### 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_CLANG_TREE_LIBCXX %s
+// CHECK_MINGW_CLANG_TREE_LIBCXX: 
"{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}v1"
+
+
 // RUN: %clang -target i686-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ 
-c -### --sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_ORG_TREE %s
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -456,6 +456,10 @@
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx:
 addSystemInclude(DriverArgs, CC1Args,
+ Base + Arch + llvm::sys::path::get_separator() +
+ "include" + llvm::sys::path::get_separator() +
+ "c++" + llvm::sys::path::get_separator() + "v1");
+addSystemInclude(DriverArgs, CC1Args,
  Base + "include" + llvm::sys::path::get_separator() +
  "c++" + llvm::sys::path::get_separator() + "v1");
 break;


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -3,6 +3,10 @@
 // CHECK_MINGW_CLANG_TREE: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
 
 
+// RUN: %clang -target i686-windows-gnu -rtlib=platform -stdlib=libc++ -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE_LIBCXX %s
+// CHECK_MINGW_CLANG_TREE_LIBCXX: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}v1"
+
+
 // RUN: %clang -target i686-pc-windows-gnu -rtlib=platform -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_ORG_TREE %s
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -456,6 +456,10 @@
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx:
 addSystemInclude(DriverArgs, CC1Args,
+ Base + Arch + llvm::sys::path::get_separator() +
+ "include" + llvm::sys::path::get_separator() +
+ "c++" + llvm::sys::path::get_separator() + "v1");
+addSystemInclude(DriverArgs, CC1Args,
  Base + "include" + llvm::sys::path::get_separator() +
  "c++" + llvm::sys::path::get_separator() + "v1");
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329751 - [OPENMP] Additional attributes for the pointer parameters.

2018-04-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Apr 10 13:10:53 2018
New Revision: 329751

URL: http://llvm.org/viewvc/llvm-project?rev=329751=rev
Log:
[OPENMP] Additional attributes for the pointer parameters.

Added attributes for better optimization of the OpenMP code.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/OpenMP/target_enter_data_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_exit_data_depend_codegen.cpp
cfe/trunk/test/OpenMP/target_update_depend_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=329751=329750=329751=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Apr 10 13:10:53 2018
@@ -2982,6 +2982,7 @@ static llvm::Value *emitCopyprivateCopyF
   CGM.getTypes().GetFunctionType(CGFI), llvm::GlobalValue::InternalLinkage,
   ".omp.copyprivate.copy_func", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, CGFI);
+  Fn->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, CGFI, Args, Loc, Loc);
   // Dest = (void*[n])(LHSArg);
@@ -4211,6 +4212,7 @@ emitProxyTaskFunction(CodeGenModule 
   llvm::Function::Create(TaskEntryTy, llvm::GlobalValue::InternalLinkage,
  ".omp_task_entry.", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), TaskEntry, TaskEntryFnInfo);
+  TaskEntry->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), KmpInt32Ty, TaskEntry, TaskEntryFnInfo, Args,
 Loc, Loc);
@@ -4312,6 +4314,7 @@ static llvm::Value *emitDestructorsFunct
  ".omp_task_destructor.", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), DestructorFn,
 DestructorFnInfo);
+  DestructorFn->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), KmpInt32Ty, DestructorFn, DestructorFnInfo,
 Args, Loc, Loc);
@@ -4589,6 +4592,7 @@ emitTaskDupFunction(CodeGenModule ,
   llvm::Function::Create(TaskDupTy, llvm::GlobalValue::InternalLinkage,
  ".omp_task_dup.", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), TaskDup, TaskDupFnInfo);
+  TaskDup->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, TaskDup, TaskDupFnInfo, Args, Loc,
 Loc);
@@ -5231,6 +5235,7 @@ llvm::Value *CGOpenMPRuntime::emitReduct
   CGM.getTypes().GetFunctionType(CGFI), llvm::GlobalValue::InternalLinkage,
   ".omp.reduction.reduction_func", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, CGFI);
+  Fn->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, CGFI, Args, Loc, Loc);
 
@@ -5653,6 +5658,7 @@ static llvm::Value *emitReduceInitFuncti
   auto *Fn = llvm::Function::Create(FnTy, llvm::GlobalValue::InternalLinkage,
 ".red_init.", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FnInfo);
+  Fn->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
   Address PrivateAddr = CGF.EmitLoadOfPointer(
@@ -5728,6 +5734,7 @@ static llvm::Value *emitReduceCombFuncti
   auto *Fn = llvm::Function::Create(FnTy, llvm::GlobalValue::InternalLinkage,
 ".red_comb.", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FnInfo);
+  Fn->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
   llvm::Value *Size = nullptr;
@@ -5796,6 +5803,7 @@ static llvm::Value *emitReduceFiniFuncti
   auto *Fn = llvm::Function::Create(FnTy, llvm::GlobalValue::InternalLinkage,
 ".red_fini.", ());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FnInfo);
+  Fn->setDoesNotRecurse();
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
   Address PrivateAddr = CGF.EmitLoadOfPointer(

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=329751=329750=329751=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Apr 10 13:10:53 2018
@@ -566,6 +566,7 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
   CGM.getTypes().GetFunctionType(*CGFI), 
llvm::GlobalValue::InternalLinkage,
   

[clang-tools-extra] r329750 - [clang-tidy][modernize]: don't forget to actually link to Tooling.

2018-04-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Apr 10 13:07:06 2018
New Revision: 329750

URL: http://llvm.org/viewvc/llvm-project?rev=329750=rev
Log:
[clang-tidy][modernize]: don't forget to actually link to Tooling.

Fixes build for me:

[1/5] Linking CXX shared library lib/libclangTidyModernizeModule.so.7svn
FAILED: lib/libclangTidyModernizeModule.so.7svn
<...>
/usr/local/bin/ld.lld: error: undefined symbol: 
clang::tooling::fixit::internal::getText(clang::SourceRange, clang::ASTContext 
const&)
>>> referenced by UseAutoCheck.cpp
>>>   
>>> tools/clang/tools/extra/clang-tidy/modernize/CMakeFiles/clangTidyModernizeModule.dir/UseAutoCheck.cpp.o:(clang::tidy::modernize::UseAutoCheck::replaceExpr(clang::DeclStmt
>>>  const*, clang::ASTContext*, llvm::function_ref>> (clang::Expr const*)>, llvm::StringRef))


Refs. D45405, rL329730.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=329750=329749=329750=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Apr 10 
13:07:06 2018
@@ -38,4 +38,5 @@ add_clang_library(clangTidyModernizeModu
   clangTidy
   clangTidyReadabilityModule
   clangTidyUtils
+  clangTooling
   )


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


[clang-tools-extra] r329749 - [clang-tidy][Fuchsia]: don't forget to actually link to Google Module.

2018-04-10 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Tue Apr 10 13:07:02 2018
New Revision: 329749

URL: http://llvm.org/viewvc/llvm-project?rev=329749=rev
Log:
[clang-tidy][Fuchsia]: don't forget to actually link to Google Module.

Fixes build for me:

[1/7] Linking CXX shared library lib/libclangTidyFuchsiaModule.so.7svn
FAILED: lib/libclangTidyFuchsiaModule.so.7svn
<...>
/usr/local/bin/ld.lld: error: undefined symbol: 
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::UnnamedNamespaceInHeaderCheck(llvm::StringRef,
 clang::tidy::ClangTidyContext*)
>>> referenced by FuchsiaTidyModule.cpp
>>>   
>>> tools/clang/tools/extra/clang-tidy/fuchsia/CMakeFiles/clangTidyFuchsiaModule.dir/FuchsiaTidyModule.cpp.o:(std::_Function_handler>>  (llvm::StringRef, clang::tidy::ClangTidyContext*), void 
>>> clang::tidy::ClangTidyCheckFactories::registerCheck(llvm::StringRef)::'lambda'(llvm::StringRef,
>>>  clang::tidy::ClangTidyContext*)>::_M_invoke(std::_Any_data const&, 
>>> llvm::StringRef&&, clang::tidy::ClangTidyContext*&&))

Refs. D45447, rCTE329720

Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt?rev=329749=329748=329749=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt Tue Apr 10 
13:07:02 2018
@@ -15,5 +15,6 @@ add_clang_library(clangTidyFuchsiaModule
   clangBasic
   clangLex
   clangTidy
+  clangTidyGoogleModule
   clangTidyUtils
   )


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


[PATCH] D45499: [Driver] Handle the default case

2018-04-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: rnk, rsmith, dlj.
Herald added a subscriber: cfe-commits.

This was omitted in https://reviews.llvm.org/D45422 resulting in a warning.


Repository:
  rC Clang

https://reviews.llvm.org/D45499

Files:
  clang/lib/Driver/ToolChains/NaCl.cpp


Index: clang/lib/Driver/ToolChains/NaCl.cpp
===
--- clang/lib/Driver/ToolChains/NaCl.cpp
+++ clang/lib/Driver/ToolChains/NaCl.cpp
@@ -332,6 +332,8 @@
 llvm::sys::path::append(P, "mipsel-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());
 break;
+  default:
+break;
   }
 }
 


Index: clang/lib/Driver/ToolChains/NaCl.cpp
===
--- clang/lib/Driver/ToolChains/NaCl.cpp
+++ clang/lib/Driver/ToolChains/NaCl.cpp
@@ -332,6 +332,8 @@
 llvm::sys::path::append(P, "mipsel-nacl/include/c++/v1");
 addSystemInclude(DriverArgs, CC1Args, P.str());
 break;
+  default:
+break;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45422: [Driver] Allow drivers to add multiple libc++ include paths

2018-04-10 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329748: [Driver] Allow drivers to add multiple libc++ 
include paths (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45422?vs=141579=141892#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45422

Files:
  cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp
  cfe/trunk/lib/Driver/ToolChains/BareMetal.h
  cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp
  cfe/trunk/lib/Driver/ToolChains/CloudABI.h
  cfe/trunk/lib/Driver/ToolChains/Contiki.h
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/lib/Driver/ToolChains/Gnu.h
  cfe/trunk/lib/Driver/ToolChains/Haiku.cpp
  cfe/trunk/lib/Driver/ToolChains/Haiku.h
  cfe/trunk/lib/Driver/ToolChains/Lanai.h
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.h
  cfe/trunk/lib/Driver/ToolChains/MipsLinux.cpp
  cfe/trunk/lib/Driver/ToolChains/MipsLinux.h
  cfe/trunk/lib/Driver/ToolChains/Myriad.cpp
  cfe/trunk/lib/Driver/ToolChains/Myriad.h
  cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
  cfe/trunk/lib/Driver/ToolChains/NaCl.h
  cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
  cfe/trunk/lib/Driver/ToolChains/NetBSD.h
  cfe/trunk/lib/Driver/ToolChains/PS4CPU.h

Index: cfe/trunk/lib/Driver/ToolChains/BareMetal.h
===
--- cfe/trunk/lib/Driver/ToolChains/BareMetal.h
+++ cfe/trunk/lib/Driver/ToolChains/BareMetal.h
@@ -53,7 +53,6 @@
   void addClangTargetOptions(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ,
  Action::OffloadKind DeviceOffloadKind) const override;
-  std::string findLibCxxIncludePath(ToolChain::CXXStdlibType LibType) const;
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -775,7 +775,8 @@
   return MaxVersion ? (base + "/" + MaxVersionString).str() : "";
 }
 
-std::string Linux::findLibCxxIncludePath() const {
+void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const {
   const std::string LibCXXIncludePathCandidates[] = {
   DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
@@ -787,9 +788,9 @@
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;
 // Use the first candidate that exists.
-return IncludePath;
+addSystemInclude(DriverArgs, CC1Args, IncludePath);
+return;
   }
-  return "";
 }
 
 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.h
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.h
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.h
@@ -316,7 +316,9 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
 
-  virtual std::string findLibCxxIncludePath() const;
+  virtual void
+  addLibCxxIncludePaths(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const;
   virtual void
   addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const;
Index: cfe/trunk/lib/Driver/ToolChains/MipsLinux.h
===
--- cfe/trunk/lib/Driver/ToolChains/MipsLinux.h
+++ cfe/trunk/lib/Driver/ToolChains/MipsLinux.h
@@ -31,7 +31,9 @@
 
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const override;
 
-  std::string findLibCxxIncludePath() const override;
+  void addLibCxxIncludePaths(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
 
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
Index: cfe/trunk/lib/Driver/ToolChains/Myriad.h
===
--- cfe/trunk/lib/Driver/ToolChains/Myriad.h
+++ cfe/trunk/lib/Driver/ToolChains/Myriad.h
@@ -76,7 +76,9 @@
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
-  std::string findLibCxxIncludePath() const override;
+  void addLibCxxIncludePaths(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
Index: cfe/trunk/lib/Driver/ToolChains/Lanai.h
===
--- cfe/trunk/lib/Driver/ToolChains/Lanai.h
+++ 

r329748 - [Driver] Allow drivers to add multiple libc++ include paths

2018-04-10 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Apr 10 12:55:55 2018
New Revision: 329748

URL: http://llvm.org/viewvc/llvm-project?rev=329748=rev
Log:
[Driver] Allow drivers to add multiple libc++ include paths

This allows toolchain drivers to add multiple libc++ include paths akin
to libstdc++. This is useful in multiarch setup when some headers might
be in target specific include directory. There should be no functional
change.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp
cfe/trunk/lib/Driver/ToolChains/BareMetal.h
cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp
cfe/trunk/lib/Driver/ToolChains/CloudABI.h
cfe/trunk/lib/Driver/ToolChains/Contiki.h
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.h
cfe/trunk/lib/Driver/ToolChains/Haiku.cpp
cfe/trunk/lib/Driver/ToolChains/Haiku.h
cfe/trunk/lib/Driver/ToolChains/Lanai.h
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.h
cfe/trunk/lib/Driver/ToolChains/MipsLinux.cpp
cfe/trunk/lib/Driver/ToolChains/MipsLinux.h
cfe/trunk/lib/Driver/ToolChains/Myriad.cpp
cfe/trunk/lib/Driver/ToolChains/Myriad.h
cfe/trunk/lib/Driver/ToolChains/NaCl.cpp
cfe/trunk/lib/Driver/ToolChains/NaCl.h
cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
cfe/trunk/lib/Driver/ToolChains/NetBSD.h
cfe/trunk/lib/Driver/ToolChains/PS4CPU.h

Modified: cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp?rev=329748=329747=329748=diff
==
--- cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp Tue Apr 10 12:55:55 2018
@@ -95,16 +95,23 @@ void BareMetal::addClangTargetOptions(co
   CC1Args.push_back("-nostdsysteminc");
 }
 
-std::string BareMetal::findLibCxxIncludePath(CXXStdlibType LibType) const {
+void BareMetal::AddClangCXXStdlibIncludeArgs(
+const ArgList , ArgStringList ) const {
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+  DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  DriverArgs.hasArg(options::OPT_nostdincxx))
+return;
+
   StringRef SysRoot = getDriver().SysRoot;
   if (SysRoot.empty())
-return "";
+return;
 
-  switch (LibType) {
+  switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
 SmallString<128> Dir(SysRoot);
 llvm::sys::path::append(Dir, "include", "c++", "v1");
-return Dir.str();
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+break;
   }
   case ToolChain::CST_Libstdcxx: {
 SmallString<128> Dir(SysRoot);
@@ -124,24 +131,12 @@ std::string BareMetal::findLibCxxInclude
   Version = CandidateVersion;
 }
 if (Version.Major == -1)
-  return "";
+  return;
 llvm::sys::path::append(Dir, Version.Text);
-return Dir.str();
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+break;
   }
   }
-  llvm_unreachable("unhandled LibType");
-}
-
-void BareMetal::AddClangCXXStdlibIncludeArgs(
-const ArgList , ArgStringList ) const {
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-  DriverArgs.hasArg(options::OPT_nostdlibinc) ||
-  DriverArgs.hasArg(options::OPT_nostdincxx))
-return;
-
-  std::string Path = findLibCxxIncludePath(GetCXXStdlibType(DriverArgs));
-  if (!Path.empty())
-addSystemInclude(DriverArgs, CC1Args, Path);
 }
 
 void BareMetal::AddCXXStdlibLibArgs(const ArgList ,

Modified: cfe/trunk/lib/Driver/ToolChains/BareMetal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/BareMetal.h?rev=329748=329747=329748=diff
==
--- cfe/trunk/lib/Driver/ToolChains/BareMetal.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/BareMetal.h Tue Apr 10 12:55:55 2018
@@ -53,7 +53,6 @@ public:
   void addClangTargetOptions(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ,
  Action::OffloadKind DeviceOffloadKind) const 
override;
-  std::string findLibCxxIncludePath(ToolChain::CXXStdlibType LibType) const;
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;

Modified: cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp?rev=329748=329747=329748=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CloudABI.cpp Tue Apr 10 12:55:55 2018
@@ -104,10 +104,11 @@ CloudABI::CloudABI(const Driver , cons
   getFilePaths().push_back(P.str());
 }
 
-std::string CloudABI::findLibCxxIncludePath() const {
+void CloudABI::addLibCxxIncludePaths(const llvm::opt::ArgList ,
+   

[PATCH] D45498: [clang-format] Don't insert space between ObjC class and lightweight generic

2018-04-10 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: djasper, jolesiak.
Herald added subscribers: cfe-commits, klimek.

In https://reviews.llvm.org/D45185, I added clang-format parser support for 
Objective-C
generics. However, I didn't touch the whitespace logic, so they
got the same space logic as Objective-C protocol lists.

In every example in the Apple SDK and in the documentation,
there is no space between the class name and the opening `<`
for the lightweight generic specification, so this diff
removes the space and updates the tests.

Test Plan: Tests updated. Ran tests with:

  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D45498

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


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -299,13 +299,13 @@
"+ (id)init;\n"
"@end");
 
-  verifyFormat("@interface Foo  : Bar  {\n"
+  verifyFormat("@interface Foo : Bar  {\n"
"  int _i;\n"
"}\n"
"+ (id)init;\n"
"@end");
 
-  verifyFormat("@interface Foo > : Xyzzy  {\n"
+  verifyFormat("@interface Foo> : Xyzzy  {\n"
"  int _i;\n"
"}\n"
"+ (id)init;\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2349,9 +2349,15 @@
: Style.SpacesInParentheses;
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;
-  if (Right.is(tok::less) && Line.Type == LT_ObjCDecl &&
-  Style.ObjCSpaceBeforeProtocolList)
-return true;
+  if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) {
+if (Right.MatchingParen && Right.MatchingParen->Next &&
+Right.MatchingParen->Next->is(tok::colon))
+  // Lightweight generic -> no space. @interface Foo : Bar 
+  return false;
+else
+  // Protocol list -> space if configured. @interface Foo : Bar 
+  return Style.ObjCSpaceBeforeProtocolList;
+  }
   if (Right.is(tok::less) && Left.is(tok::kw_template))
 return Style.SpaceAfterTemplateKeyword;
   if (Left.isOneOf(tok::exclaim, tok::tilde))


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -299,13 +299,13 @@
"+ (id)init;\n"
"@end");
 
-  verifyFormat("@interface Foo  : Bar  {\n"
+  verifyFormat("@interface Foo : Bar  {\n"
"  int _i;\n"
"}\n"
"+ (id)init;\n"
"@end");
 
-  verifyFormat("@interface Foo > : Xyzzy  {\n"
+  verifyFormat("@interface Foo> : Xyzzy  {\n"
"  int _i;\n"
"}\n"
"+ (id)init;\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2349,9 +2349,15 @@
: Style.SpacesInParentheses;
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;
-  if (Right.is(tok::less) && Line.Type == LT_ObjCDecl &&
-  Style.ObjCSpaceBeforeProtocolList)
-return true;
+  if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) {
+if (Right.MatchingParen && Right.MatchingParen->Next &&
+Right.MatchingParen->Next->is(tok::colon))
+  // Lightweight generic -> no space. @interface Foo : Bar 
+  return false;
+else
+  // Protocol list -> space if configured. @interface Foo : Bar 
+  return Style.ObjCSpaceBeforeProtocolList;
+  }
   if (Right.is(tok::less) && Left.is(tok::kw_template))
 return Style.SpaceAfterTemplateKeyword;
   if (Left.isOneOf(tok::exclaim, tok::tilde))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329741 - [X86] Split up -march=icelake to -client & -server

2018-04-10 Thread Gabor Buella via cfe-commits
Author: gbuella
Date: Tue Apr 10 11:58:26 2018
New Revision: 329741

URL: http://llvm.org/viewvc/llvm-project?rev=329741=rev
Log:
[X86] Split up -march=icelake to -client & -server

Reviewers: craig.topper, zvi, echristo

Reviewed By: craig.topper

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


Modified:
cfe/trunk/include/clang/Basic/X86Target.def
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/test/Driver/x86-march.c
cfe/trunk/test/Frontend/x86-target-cpu.c
cfe/trunk/test/Misc/target-invalid-cpu-note.c
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/include/clang/Basic/X86Target.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/X86Target.def?rev=329741=329740=329741=diff
==
--- cfe/trunk/include/clang/Basic/X86Target.def (original)
+++ cfe/trunk/include/clang/Basic/X86Target.def Tue Apr 10 11:58:26 2018
@@ -149,7 +149,11 @@ PROC_WITH_FEAT(Cannonlake, "cannonlake",
 
 /// \name Icelake Client
 /// Icelake client microarchitecture based processors.
-PROC(Icelake, "icelake", PROC_64_BIT)
+PROC(IcelakeClient, "icelake-client", PROC_64_BIT)
+
+/// \name Icelake Server
+/// Icelake server microarchitecture based processors.
+PROC(IcelakeServer, "icelake-server", PROC_64_BIT)
 
 /// \name Knights Landing
 /// Knights Landing processor.

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=329741=329740=329741=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Tue Apr 10 11:58:26 2018
@@ -153,7 +153,8 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "mmx", true);
 break;
 
-  case CK_Icelake:
+  case CK_IcelakeServer:
+  case CK_IcelakeClient:
 setFeatureEnabledImpl(Features, "vaes", true);
 setFeatureEnabledImpl(Features, "gfni", true);
 setFeatureEnabledImpl(Features, "vpclmulqdq", true);
@@ -932,7 +933,8 @@ void X86TargetInfo::getTargetDefines(con
   case CK_SkylakeClient:
   case CK_SkylakeServer:
   case CK_Cannonlake:
-  case CK_Icelake:
+  case CK_IcelakeClient:
+  case CK_IcelakeServer:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.

Modified: cfe/trunk/test/Driver/x86-march.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/x86-march.c?rev=329741=329740=329741=diff
==
--- cfe/trunk/test/Driver/x86-march.c (original)
+++ cfe/trunk/test/Driver/x86-march.c Tue Apr 10 11:58:26 2018
@@ -60,9 +60,13 @@
 // RUN:   | FileCheck %s -check-prefix=cannonlake
 // cannonlake: "-target-cpu" "cannonlake"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake 2>&1 \
-// RUN:   | FileCheck %s -check-prefix=icelake
-// icelake: "-target-cpu" "icelake"
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake-client 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=icelake-client
+// icelake-client: "-target-cpu" "icelake-client"
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake-server 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=icelake-server
+// icelake-server: "-target-cpu" "icelake-server"
 //
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont

Modified: cfe/trunk/test/Frontend/x86-target-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/x86-target-cpu.c?rev=329741=329740=329741=diff
==
--- cfe/trunk/test/Frontend/x86-target-cpu.c (original)
+++ cfe/trunk/test/Frontend/x86-target-cpu.c Tue Apr 10 11:58:26 2018
@@ -13,7 +13,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu skylake-avx512 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu skx -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu cannonlake 
-verify %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake -verify 
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake-client 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake-server 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knl -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knm -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu bonnell -verify 
%s

Modified: cfe/trunk/test/Misc/target-invalid-cpu-note.c
URL: 

[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel updated this revision to Diff 141890.
paulsemel added a comment.

Patch rebased.
Minor fix for single quotes escaping.


Repository:
  rC Clang

https://reviews.llvm.org/D44093

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/dump-struct-builtin.c
  test/Sema/builtin-dump-struct.c

Index: test/Sema/builtin-dump-struct.c
===
--- /dev/null
+++ test/Sema/builtin-dump-struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -fno-spell-checking -verify %s
+
+void invalid_uses() {
+  struct A {
+  };
+  struct A a;
+  void *b;
+  int (*goodfunc)(const char *, ...);
+  int (*badfunc1)(const char *);
+  int (*badfunc2)(int, ...);
+  void (*badfunc3)(const char *, ...);
+  int (*badfunc4)(char *, ...);
+  int (*badfunc5)(void);
+
+  __builtin_dump_struct(); // expected-error {{too few arguments to function call, expected 2, have 0}}
+  __builtin_dump_struct(1);// expected-error {{too few arguments to function call, expected 2, have 1}}
+  __builtin_dump_struct(1, 2); // expected-error {{passing 'int' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('int' vs structure pointer)}}
+  __builtin_dump_struct(, 2);// expected-error {{passing 'int' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(b, goodfunc); // expected-error {{passing 'void *' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('void *' vs structure pointer)}}
+  __builtin_dump_struct(, badfunc1); // expected-error {{passing 'int (*)(const char *)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(const char *)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc2); // expected-error {{passing 'int (*)(int, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(int, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc3); // expected-error {{passing 'void (*)(const char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('void (*)(const char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc4); // expected-error {{passing 'int (*)(char *, ...)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(char *, ...)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(, badfunc5); // expected-error {{passing 'int (*)(void)' to parameter of incompatible type 'int (*)(const char *, ...)': type mismatch at 2nd parameter ('int (*)(void)' vs 'int (*)(const char *, ...)')}}
+  __builtin_dump_struct(a, goodfunc);  // expected-error {{passing 'struct A' to parameter of incompatible type structure pointer: type mismatch at 1st parameter ('struct A' vs structure pointer)}}
+}
+
+void valid_uses() {
+  struct A {
+  };
+  union B {
+  };
+
+  int (*goodfunc)(const char *, ...);
+  int (*goodfunc2)();
+  struct A a;
+  union B b;
+
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc);
+  __builtin_dump_struct(, goodfunc2);
+}
Index: test/CodeGen/dump-struct-builtin.c
===
--- /dev/null
+++ test/CodeGen/dump-struct-builtin.c
@@ -0,0 +1,387 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+#include "Inputs/stdio.h"
+
+void unit1() {
+  struct U1A {
+short a;
+  };
+
+  struct U1A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U1A, %struct.U1A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit2() {
+  struct U2A {
+unsigned short a;
+  };
+
+  struct U2A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U2A, %struct.U2A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i16, i16* [[RES1]],
+  // CHECK: call i32 (i8*, ...) @printf({{.*}}, i16 [[LOAD1]])
+  // CHECK: call i32 (i8*, ...) @printf(
+  __builtin_dump_struct(, );
+}
+
+void unit3() {
+  struct U3A {
+int a;
+  };
+
+  struct U3A a = {
+  .a = 12,
+  };
+
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[RES1:%[0-9]+]] = getelementptr inbounds %struct.U3A, %struct.U3A* %a, i32 0, i32 0
+  // CHECK: call i32 (i8*, ...) @printf(
+  // CHECK: [[LOAD1:%[0-9]+]] = load i32, i32* [[RES1]],
+  // CHECK: 

[PATCH] D45403: Make [[maybe_unused]] work with static data members

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D45403



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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-10 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D43578#1063462, @thakis wrote:

> Reverted:


Many thanks for your help!


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D45056: [X86] Split up -march=icelake to -client & -server

2018-04-10 Thread Gabor Buella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329741: [X86] Split up -march=icelake to -client  
-server (authored by GBuella, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45056?vs=140911=141888#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45056

Files:
  cfe/trunk/include/clang/Basic/X86Target.def
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/test/Driver/x86-march.c
  cfe/trunk/test/Frontend/x86-target-cpu.c
  cfe/trunk/test/Misc/target-invalid-cpu-note.c
  cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Index: cfe/trunk/test/Driver/x86-march.c
===
--- cfe/trunk/test/Driver/x86-march.c
+++ cfe/trunk/test/Driver/x86-march.c
@@ -60,9 +60,13 @@
 // RUN:   | FileCheck %s -check-prefix=cannonlake
 // cannonlake: "-target-cpu" "cannonlake"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake 2>&1 \
-// RUN:   | FileCheck %s -check-prefix=icelake
-// icelake: "-target-cpu" "icelake"
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake-client 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=icelake-client
+// icelake-client: "-target-cpu" "icelake-client"
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=icelake-server 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=icelake-server
+// icelake-server: "-target-cpu" "icelake-server"
 //
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
Index: cfe/trunk/test/Frontend/x86-target-cpu.c
===
--- cfe/trunk/test/Frontend/x86-target-cpu.c
+++ cfe/trunk/test/Frontend/x86-target-cpu.c
@@ -13,7 +13,8 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu skylake-avx512 -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu skx -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu cannonlake -verify %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake-client -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu icelake-server -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knl -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu knm -verify %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-cpu bonnell -verify %s
Index: cfe/trunk/test/Misc/target-invalid-cpu-note.c
===
--- cfe/trunk/test/Misc/target-invalid-cpu-note.c
+++ cfe/trunk/test/Misc/target-invalid-cpu-note.c
@@ -16,7 +16,7 @@
 // X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont,
 // X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
 // X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
-// X86-SAME: skx, cannonlake, icelake, knl, knm, lakemont, k6, k6-2, k6-3,
+// X86-SAME: skx, cannonlake, icelake-client, icelake-server, knl, knm, lakemont, k6, k6-2, k6-3,
 // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
 // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
 // X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1,
@@ -28,7 +28,7 @@
 // X86_64-SAME: atom, silvermont, slm, goldmont, nehalem, corei7, westmere,
 // X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
 // X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cannonlake,
-// X86_64-SAME: icelake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
+// X86_64-SAME: icelake-client, icelake-server, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
 // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
 // X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, x86-64
 
Index: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
===
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c
@@ -1055,7 +1055,7 @@
 // CHECK_CNL_M64: #define __x86_64 1
 // CHECK_CNL_M64: #define __x86_64__ 1
 
-// RUN: %clang -march=icelake -m32 -E -dM %s -o - 2>&1 \
+// RUN: %clang -march=icelake-client -m32 -E -dM %s -o - 2>&1 \
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_ICL_M32
 // CHECK_ICL_M32: #define __AES__ 1
@@ -1110,8 +1110,8 @@
 // CHECK_ICL_M32: #define __i386__ 1
 // CHECK_ICL_M32: #define __tune_corei7__ 1
 // CHECK_ICL_M32: #define i386 1
-//
-// RUN: %clang -march=icelake -m64 -E -dM %s -o - 2>&1 \
+
+// RUN: %clang -march=icelake-client -m64 -E -dM %s -o - 2>&1 \
 // RUN: -target 

[clang-tools-extra] r329740 - [clang-tidy] [modernize-use-auto] Fix members initialization order

2018-04-10 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Tue Apr 10 11:56:29 2018
New Revision: 329740

URL: http://llvm.org/viewvc/llvm-project?rev=329740=rev
Log:
[clang-tidy] [modernize-use-auto] Fix members initialization order


Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=329740=329739=329740=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Tue Apr 10 
11:56:29 2018
@@ -287,8 +287,9 @@ StatementMatcher makeCombinedMatcher() {
 } // namespace
 
 UseAutoCheck::UseAutoCheck(StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), RemoveStars(Options.get("RemoveStars", 
0)),
-  MinTypeNameLength(Options.get("MinTypeNameLength", 5)) {}
+: ClangTidyCheck(Name, Context),
+  MinTypeNameLength(Options.get("MinTypeNameLength", 5)),
+  RemoveStars(Options.get("RemoveStars", 0)) {}
 
 void UseAutoCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "MinTypeNameLength", MinTypeNameLength);


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


r329739 - Revert r329684 (and follow-ups 329693, 329714). See discussion on https://reviews.llvm.org/D43578.

2018-04-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Apr 10 11:53:28 2018
New Revision: 329739

URL: http://llvm.org/viewvc/llvm-project?rev=329739=rev
Log:
Revert r329684 (and follow-ups 329693, 329714). See discussion on 
https://reviews.llvm.org/D43578.

Modified:
cfe/trunk/include/clang/Frontend/FrontendAction.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/ASTMerge.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=329739=329738=329739=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Tue Apr 10 11:53:28 2018
@@ -45,9 +45,6 @@ private:
 StringRef InFile);
 
 protected:
-  static constexpr const char *GroupName = "factions";
-  static constexpr const char *GroupDescription =
-  "= Frontend Actions =";
   /// @name Implementation Action Interface
   /// @{
 

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=329739=329738=329739=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Apr 10 11:53:28 2018
@@ -21,10 +21,9 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/Timer.h"
 #include 
 #include 
 #include 
@@ -32,9 +31,6 @@
 #include 
 #include 
 
-static const char *const IncGroupName = "includefiles";
-static const char *const IncGroupDescription = "= Include Files =";
-
 namespace clang {
 
 class DiagnosticsEngine;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=329739=329738=329739=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Apr 10 11:53:28 2018
@@ -2851,6 +2851,4 @@ private:
 
 }  // end namespace clang
 
-static const char *const GroupName = "clangparser";
-static const char *const GroupDescription = "= Clang Parser =";
 #endif

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=329739=329738=329739=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Apr 10 11:53:28 2018
@@ -304,9 +304,6 @@ class Sema {
   bool shouldLinkPossiblyHiddenDecl(LookupResult , const NamedDecl *New);
 
 public:
-  static constexpr const char *GroupName = "sema";
-  static constexpr const char *GroupDescription = "= Sema =";
-
   typedef OpaquePtr DeclGroupPtrTy;
   typedef OpaquePtr TemplateTy;
   typedef OpaquePtr TypeTy;

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=329739=329738=329739=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Apr 10 11:53:28 2018
@@ -23,7 +23,6 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Lex/Preprocessor.h"
-#include "clang/Rewrite/Frontend/FrontendActions.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
 #include "llvm/IR/DebugInfo.h"
@@ -52,7 +51,7 @@ namespace clang {
   public:
 ClangDiagnosticHandler(const CodeGenOptions , BackendConsumer *BCon)
 : CodeGenOpts(CGOpts), BackendCon(BCon) {}
-
+  
 bool handleDiagnostics(const DiagnosticInfo ) override;
 
 bool isAnalysisRemarkEnabled(StringRef PassName) const override {
@@ -91,8 +90,9 @@ namespace clang {
 const LangOptions 

[PATCH] D43578: -ftime-report switch support in Clang

2018-04-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted:

$ svn merge -c -329714 .

- Reverse-merging r329714 into '.':

Atest/Frontend/ftime-report-template-decl.cpp

- Recording mergeinfo for reverse merge of r329714 into '.': U   .

$ svn merge -c -329693 .

- Reverse-merging r329693 into '.':

Utest/Frontend/ftime-report-template-decl.cpp

- Recording mergeinfo for reverse merge of r329693 into '.': U   .

$ svn merge -c -329684 .

- Reverse-merging r329684 into '.':

Dtest/Frontend/ftime-report-template-decl.cpp
Uinclude/clang/Frontend/FrontendAction.h
Ulib/Parse/ParseTemplate.cpp
Ulib/Frontend/FrontendAction.cpp
Ulib/Lex/Pragma.cpp
Ulib/CodeGen/CodeGenAction.cpp
Uinclude/clang/Parse/Parser.h
Uinclude/clang/Sema/Sema.h
Uinclude/clang/Lex/HeaderSearch.h
Ulib/Parse/Parser.cpp
Ulib/Frontend/ASTMerge.cpp
Ulib/Frontend/FrontendActions.cpp
Ulib/Frontend/CompilerInstance.cpp
Ulib/Sema/SemaChecking.cpp
Ulib/Sema/SemaExpr.cpp
Ulib/Sema/Sema.cpp
Ulib/Sema/SemaDecl.cpp
Ulib/Sema/SemaTemplate.cpp
Ulib/Lex/PPMacroExpansion.cpp
Ulib/Lex/HeaderSearch.cpp

- Recording mergeinfo for reverse merge of r329684 into '.': U   .

$ svn commit -m 'Revert r329684 (and follow-ups 329693, 329714). See discussion 
on https://reviews.llvm.org/D43578.'
Sendinginclude/clang/Frontend/FrontendAction.h
Sendinginclude/clang/Lex/HeaderSearch.h
Sendinginclude/clang/Parse/Parser.h
Sendinginclude/clang/Sema/Sema.h
Sendinglib/CodeGen/CodeGenAction.cpp
Sendinglib/Frontend/ASTMerge.cpp
Sendinglib/Frontend/CompilerInstance.cpp
Sendinglib/Frontend/FrontendAction.cpp
Sendinglib/Frontend/FrontendActions.cpp
Sendinglib/Lex/HeaderSearch.cpp
Sendinglib/Lex/PPMacroExpansion.cpp
Sendinglib/Lex/Pragma.cpp
Sendinglib/Parse/ParseTemplate.cpp
Sendinglib/Parse/Parser.cpp
Sendinglib/Sema/Sema.cpp
Sendinglib/Sema/SemaChecking.cpp
Sendinglib/Sema/SemaDecl.cpp
Sendinglib/Sema/SemaExpr.cpp
Sendinglib/Sema/SemaTemplate.cpp
Transmitting file data ...done
Committing transaction...
Committed revision 329739.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you rebase the patch? The patch did not apply cleanly for me against trunk 
(the contents of the check function are appearing in 
`CheckARMBuiltinExclusiveCall()`).

(Also, one tiny nit about escaped characters that can be fixed at the same 
time.)




Comment at: lib/Sema/SemaChecking.cpp:1133
+  Diag(FnPtrArg->getLocStart(), diag::err_typecheck_convert_incompatible)
+  << FnPtrArgType << "\'int (*)(const char *, ...)\'" << 1 << 0 << 3
+  << 2 << FnPtrArgType << "\'int (*)(const char *, ...)\'";

Minor nit: can you remove the escape character for the single quotes (here and 
elsewhere in the patch), as there's no need to escape that character?


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for working on this check!




Comment at: clang-tidy/cppcoreguidelines/ConstCheck.h:60
+
+  std::unordered_map ValueCanBeConst;
+  std::unordered_map HandleCanBeConst;

I'm guessing these should be `llvm::DenseMap`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444



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


r329738 - [X86] Add test case for llvm change r329734

2018-04-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Apr 10 11:43:44 2018
New Revision: 329738

URL: http://llvm.org/viewvc/llvm-project?rev=329738=rev
Log:
[X86] Add test case for llvm change r329734

This test ensures the popfd instruction in MS inline assembly can properly find 
a clobber name for the dirflag register. Previously the register was named 
'DF', but it needs to be named 'dirflag' to match the name in the GCC register 
name list.

Modified:
cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=329738=329737=329738=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Apr 10 11:43:44 2018
@@ -754,6 +754,13 @@ void mxcsr() {
 // CHECK-LABEL: define void @mxcsr
 // CHECK: call void asm sideeffect inteldialect "fxrstor $0", 
"=*m,~{dirflag},~{fpsr},~{flags}"
 
+// Make sure we can find the register for the dirflag for popfd
+void dirflag() {
+  __asm popfd
+}
+// CHECK-LABEL: define void @dirflag
+// CHECK: call void asm sideeffect inteldialect "popfd", 
"~{dirflag},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}"
+
 typedef union _LARGE_INTEGER {
   struct {
 unsigned int LowPart;


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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> while both git and svn have revert subcommands

This is kind of misleading; yes, both git and svn have subcommands named 
"revert", but "svn revert" doesn't have the right meaning.  You have to use 
"svn merge" to revert a committed change.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


r329737 - [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

2018-04-10 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Apr 10 11:38:22 2018
New Revision: 329737

URL: http://llvm.org/viewvc/llvm-project?rev=329737=rev
Log:
[CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

Currently we always include PTX into the fatbin along
with the GPU code.It about doubles the size of the GPU binary
we need to carry in the executable. These options allow control
inclusion of PTX into GPU binary.

This patch does not change the defaults, though we may consider
making no-PTX the default in the future.

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

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/cuda-options.cu

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=329737=329736=329737=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Apr 10 11:38:22 2018
@@ -144,6 +144,10 @@ Compile CUDA code for device only
 
 CUDA GPU architecture (e.g. sm\_35).  May be specified more than once.
 
+.. option:: --cuda-include-ptx=, --no-cuda-include-ptx=
+
+Include (or not) PTX along with CUDA GPU binary for the given architecture 
(e.g. sm\_35). Argument may be 'all'. The option may be specified more than 
once. Default: --cuda-include-ptx=all
+
 .. option:: --cuda-host-only
 
 Compile CUDA code for host only.  Has no effect on non-CUDA compilations.

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329737=329736=329737=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 10 11:38:22 2018
@@ -546,6 +546,10 @@ def cuda_host_only : Flag<["--"], "cuda-
 def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">,
   HelpText<"Compile CUDA code for both host and device (default).  Has no "
"effect on non-CUDA compilations.">;
+def cuda_include_ptx_EQ : Joined<["--"], "cuda-include-ptx=">, 
Flags<[DriverOption]>,
+  HelpText<"Include PTX for the follwing GPU architecture (e.g. sm_35) or 
'all'. May be specified more than once.">;
+def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, 
Flags<[DriverOption]>,
+  HelpText<"Do not include PTX for the follwing GPU architecture (e.g. sm_35) 
or 'all'. May be specified more than once.">;
 def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than 
once.">;
 def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, 
Flags<[DriverOption]>,

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=329737=329736=329737=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Tue Apr 10 11:38:22 2018
@@ -377,6 +377,22 @@ void NVPTX::Assembler::ConstructJob(Comp
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool shouldIncludePTX(const ArgList , const char *gpu_arch) {
+  bool includePTX = true;
+  for (Arg *A : Args) {
+if (!(A->getOption().matches(options::OPT_cuda_include_ptx_EQ) ||
+  A->getOption().matches(options::OPT_no_cuda_include_ptx_EQ)))
+  continue;
+A->claim();
+const StringRef ArchStr = A->getValue();
+if (ArchStr == "all" || ArchStr == gpu_arch) {
+  includePTX = A->getOption().matches(options::OPT_cuda_include_ptx_EQ);
+  continue;
+}
+  }
+  return includePTX;
+}
+
 // All inputs to this linker must be from CudaDeviceActions, as we need to look
 // at the Inputs' Actions in order to figure out which GPU architecture they
 // correspond to.
@@ -404,6 +420,9 @@ void NVPTX::Linker::ConstructJob(Compila
"Device action expected to have associated a GPU architecture!");
 CudaArch gpu_arch = StringToCudaArch(gpu_arch_str);
 
+if (II.getType() == types::TY_PP_Asm &&
+!shouldIncludePTX(Args, gpu_arch_str))
+  continue;
 // We need to pass an Arch of the form "sm_XX" for cubin files and
 // "compute_XX" for ptx.
 const char *Arch =

Modified: cfe/trunk/test/Driver/cuda-options.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-options.cu?rev=329737=329736=329737=diff
==
--- cfe/trunk/test/Driver/cuda-options.cu (original)
+++ cfe/trunk/test/Driver/cuda-options.cu Tue Apr 10 11:38:22 2018
@@ -142,6 +142,48 @@
 // RUN:   -c %s 2>&1 

[PATCH] D45495: [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

2018-04-10 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329737: [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all 
option. (authored by tra, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45495?vs=141882=141887#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45495

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/cuda-options.cu

Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -377,6 +377,22 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool shouldIncludePTX(const ArgList , const char *gpu_arch) {
+  bool includePTX = true;
+  for (Arg *A : Args) {
+if (!(A->getOption().matches(options::OPT_cuda_include_ptx_EQ) ||
+  A->getOption().matches(options::OPT_no_cuda_include_ptx_EQ)))
+  continue;
+A->claim();
+const StringRef ArchStr = A->getValue();
+if (ArchStr == "all" || ArchStr == gpu_arch) {
+  includePTX = A->getOption().matches(options::OPT_cuda_include_ptx_EQ);
+  continue;
+}
+  }
+  return includePTX;
+}
+
 // All inputs to this linker must be from CudaDeviceActions, as we need to look
 // at the Inputs' Actions in order to figure out which GPU architecture they
 // correspond to.
@@ -404,6 +420,9 @@
"Device action expected to have associated a GPU architecture!");
 CudaArch gpu_arch = StringToCudaArch(gpu_arch_str);
 
+if (II.getType() == types::TY_PP_Asm &&
+!shouldIncludePTX(Args, gpu_arch_str))
+  continue;
 // We need to pass an Arch of the form "sm_XX" for cubin files and
 // "compute_XX" for ptx.
 const char *Arch =
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -144,6 +144,10 @@
 
 CUDA GPU architecture (e.g. sm\_35).  May be specified more than once.
 
+.. option:: --cuda-include-ptx=, --no-cuda-include-ptx=
+
+Include (or not) PTX along with CUDA GPU binary for the given architecture (e.g. sm\_35). Argument may be 'all'. The option may be specified more than once. Default: --cuda-include-ptx=all
+
 .. option:: --cuda-host-only
 
 Compile CUDA code for host only.  Has no effect on non-CUDA compilations.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -546,6 +546,10 @@
 def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">,
   HelpText<"Compile CUDA code for both host and device (default).  Has no "
"effect on non-CUDA compilations.">;
+def cuda_include_ptx_EQ : Joined<["--"], "cuda-include-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Include PTX for the follwing GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">;
+def no_cuda_include_ptx_EQ : Joined<["--"], "no-cuda-include-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Do not include PTX for the follwing GPU architecture (e.g. sm_35) or 'all'. May be specified more than once.">;
 def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than once.">;
 def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, Flags<[DriverOption]>,
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -142,6 +142,48 @@
 // RUN:   -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCHALLERROR %s
 
+
+// Verify that --[no-]cuda-include-ptx arguments are handled correctly.
+// a) by default we're including PTX for all GPUs.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,PTX-SM35,PTX-SM30 %s
+
+// b) --no-cuda-include-ptx=all disables PTX inclusion for all GPUs
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=all \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,NOPTX-SM35,NOPTX-SM30 %s
+
+// c) --no-cuda-include-ptx=sm_XX disables PTX inclusion for that GPU only.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,NOPTX-SM35,PTX-SM30 %s
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck 

Re: [PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-10 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Nico!

On Tue, Apr 10, 2018 at 6:39 AM, Nico Weber via Phabricator
 wrote:
> thakis added a comment.
>
> r329698, thanks!
>
>
> https://reviews.llvm.org/D45165
>
>
>



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


[PATCH] D44093: [BUILTINS] structure pretty printer

2018-04-10 Thread Paul Semel via Phabricator via cfe-commits
paulsemel added a comment.

In https://reviews.llvm.org/D44093#1063348, @aaron.ballman wrote:

> In https://reviews.llvm.org/D44093#1063340, @paulsemel wrote:
>
> > I don't really know what's the procedure right now.. What should I do once 
> > you both accepted the patch ? :)
>
>
> You're good to commit the patch and address the concerns raised by 
> @arichardson in a follow-up patch. Do you need someone to commit on your 
> behalf?


Thanks! Yes please, I don't think I have the right accesses to do it myself


Repository:
  rC Clang

https://reviews.llvm.org/D44093



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


[PATCH] D44449: [Parser] Fix assertion-on-invalid for unexpected typename.

2018-04-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329735: [Parser] Fix assertion-on-invalid for unexpected 
typename. (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D9?vs=141448=141885#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D9

Files:
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/test/Parser/cxx-decl.cpp


Index: cfe/trunk/test/Parser/cxx-decl.cpp
===
--- cfe/trunk/test/Parser/cxx-decl.cpp
+++ cfe/trunk/test/Parser/cxx-decl.cpp
@@ -298,6 +298,11 @@
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 
'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration 
specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all 
declarations}}
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -3804,7 +3804,8 @@
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  // After an error the next token can be an annotation token.
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }


Index: cfe/trunk/test/Parser/cxx-decl.cpp
===
--- cfe/trunk/test/Parser/cxx-decl.cpp
+++ cfe/trunk/test/Parser/cxx-decl.cpp
@@ -298,6 +298,11 @@
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all declarations}}
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -3804,7 +3804,8 @@
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  // After an error the next token can be an annotation token.
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329735 - [Parser] Fix assertion-on-invalid for unexpected typename.

2018-04-10 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue Apr 10 11:29:47 2018
New Revision: 329735

URL: http://llvm.org/viewvc/llvm-project?rev=329735=rev
Log:
[Parser] Fix assertion-on-invalid for unexpected typename.

In `ParseDeclarationSpecifiers` for the code

class A typename A;

we were able to annotate token `kw_typename` because it refers to
existing type. But later during processing token `annot_typename` we
failed to `SetTypeSpecType` and exited switch statement leaving
annotation token unconsumed. The code after the switch statement failed
because it didn't expect a special token.

The fix is not to assume that switch statement consumes all special
tokens and consume any token, not just non-special.

rdar://problem/37099386

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: jkorous-apple, cfe-commits

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


Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/cxx-decl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=329735=329734=329735=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Apr 10 11:29:47 2018
@@ -3804,7 +3804,8 @@ void Parser::ParseDeclarationSpecifiers(
 
 DS.SetRangeEnd(Tok.getLocation());
 if (DiagID != diag::err_bool_redeclaration)
-  ConsumeToken();
+  // After an error the next token can be an annotation token.
+  ConsumeAnyToken();
 
 AttrsLastTime = false;
   }

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=329735=329734=329735=diff
==
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Tue Apr 10 11:29:47 2018
@@ -298,6 +298,11 @@ inline namespace ParensAroundFriend { //
   }
 }
 
+namespace rdar37099386 {
+  class A typename A; // expected-error {{expected a qualified name after 
'typename'}}
+  // expected-error@-1 {{cannot combine with previous 'class' declaration 
specifier}}
+}
+
 // PR8380
 extern ""  // expected-error {{unknown linkage language}}
 test6a { ;// expected-error {{C++ requires a type specifier for all 
declarations}}


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


[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1024-1027
+  // 'this' pointer is not an lvalue, we should not invalidate it.
+  if (CXXThisRegion::classof(baseR))
+return;
+

I don't think this run-time check belongs here. The fix should be isolated in 
loop widening because everything else is already known to work correctly. The 
invalidation worker is not to be blamed for other entities throwing incorrect 
stuff into it.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2057-2060
+  assert((!CXXThisRegion::classof(R) ||
+  CXXThisRegion::classof(R) && !B.lookup(R)) &&
+ "'this' pointer is not an l-value and is not assignable");
+

This assertion is great to have.

Please use `!isa(R)` instead of `CXXThisRegion::classof(R)`. The 
left argument of `&&` is always true, so you can omit it.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2062
   // Clear out bindings that may overlap with this binding.
-  RegionBindingsRef NewB = removeSubRegionBindings(B, cast(R));
+  RegionBindingsRef NewB = removeSubRegionBindings(B, cast(R));  
   return NewB.addBinding(BindingKey::Make(R, BindingKey::Direct), V);

An accidental whitespace change here.


Repository:
  rC Clang

https://reviews.llvm.org/D45491



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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-10 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D43578#1063365, @davezarzycki wrote:

> A revert in practice just means undoing the changes. For example, while both 
> `git` and `svn` have `revert` subcommands, you can also just take the 
> original diff/patch, pipe it into `patch -R`, and if there are no conflicts, 
> commit the result.


Unfortunately, revert does not work with committed changes:

revert: Restore pristine working copy state (undo local changes).
usage: revert PATH...

  Revert changes in the working copy at or within PATH, and remove
  conflict markers as well, if any.

- This subcommand does not revert already committed changes.**

But I'll try with patch -R. Tnx.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D43750: Allow writing calling convention attributes on function types

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping.


https://reviews.llvm.org/D43750



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


[PATCH] D44155: Fix support for try_acquire_capability

2018-04-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping.


https://reviews.llvm.org/D44155



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


[PATCH] D45403: Make [[maybe_unused]] work with static data members

2018-04-10 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner updated this revision to Diff 141880.
cpplearner added a comment.

Removed `ExpectedForMaybeUnused` from AttributeList.h, and removed the entry 
for `ExpectedForMaybeUnused` from the `warn_attribute_wrong_decl_type` table 
definition.


https://reviews.llvm.org/D45403

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/AttributeList.h
  lib/Sema/SemaDeclAttr.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp


Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp
@@ -2,7 +2,7 @@
 
 struct [[maybe_unused]] S {
   int I [[maybe_unused]];
-  static int SI [[maybe_unused]]; // expected-warning {{'maybe_unused' 
attribute only applies to variables, functions, methods, types, enumerations, 
enumerators, labels, and non-static data members}}
+  static int SI [[maybe_unused]];
 };
 
 enum [[maybe_unused]] E1 {
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2042,16 +2042,6 @@
 static void handleUnusedAttr(Sema , Decl *D, const AttributeList ) {
   bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName();
 
-  if (IsCXX17Attr && isa(D)) {
-// The C++17 spelling of this attribute cannot be applied to a static data
-// member per [dcl.attr.unused]p2.
-if (cast(D)->isStaticDataMember()) {
-  S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << AL.getName() << ExpectedForMaybeUnused;
-  return;
-}
-  }
-
   // If this is spelled as the standard C++17 attribute, but not in C++17, warn
   // about using it as an extension.
   if (!S.getLangOpts().CPlusPlus17 && IsCXX17Attr)
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -928,7 +928,6 @@
   ExpectedFunctionVariableOrClass,
   ExpectedKernelFunction,
   ExpectedFunctionWithProtoType,
-  ExpectedForMaybeUnused,
 };
 
 } // namespace clang
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2834,8 +2834,7 @@
   "|types and namespaces"
   "|variables, functions and classes"
   "|kernel functions"
-  "|non-K functions"
-  "|variables, functions, methods, types, enumerations, enumerators, labels, 
and non-static data members}1">,
+  "|non-K functions}1">,
   InGroup;
 def err_attribute_wrong_decl_type : Error;
 def warn_type_attribute_wrong_type : Warning<


Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp
@@ -2,7 +2,7 @@
 
 struct [[maybe_unused]] S {
   int I [[maybe_unused]];
-  static int SI [[maybe_unused]]; // expected-warning {{'maybe_unused' attribute only applies to variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members}}
+  static int SI [[maybe_unused]];
 };
 
 enum [[maybe_unused]] E1 {
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2042,16 +2042,6 @@
 static void handleUnusedAttr(Sema , Decl *D, const AttributeList ) {
   bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName();
 
-  if (IsCXX17Attr && isa(D)) {
-// The C++17 spelling of this attribute cannot be applied to a static data
-// member per [dcl.attr.unused]p2.
-if (cast(D)->isStaticDataMember()) {
-  S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
-  << AL.getName() << ExpectedForMaybeUnused;
-  return;
-}
-  }
-
   // If this is spelled as the standard C++17 attribute, but not in C++17, warn
   // about using it as an extension.
   if (!S.getLangOpts().CPlusPlus17 && IsCXX17Attr)
Index: include/clang/Sema/AttributeList.h
===
--- include/clang/Sema/AttributeList.h
+++ include/clang/Sema/AttributeList.h
@@ -928,7 +928,6 @@
   ExpectedFunctionVariableOrClass,
   ExpectedKernelFunction,
   ExpectedFunctionWithProtoType,
-  ExpectedForMaybeUnused,
 };
 
 } // namespace clang
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2834,8 +2834,7 @@
   "|types and namespaces"
   "|variables, functions and classes"
   "|kernel functions"
-  "|non-K functions"
-  "|variables, functions, methods, types, enumerations, enumerators, 

[PATCH] D45495: [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

2018-04-10 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

lgtm!


https://reviews.llvm.org/D45495



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


[PATCH] D45495: [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

2018-04-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D45495#1063370, @jlebar wrote:

> Where do we document the default values for these flags?  Like, how is a user 
> supposed to figure out whether the default is to include ptx or not?


I've updated docs/ClangCommandLineReference.rst.


https://reviews.llvm.org/D45495



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


[PATCH] D45495: [CUDA] Added --[no-]cuda-include-ptx=sm_XX|all option.

2018-04-10 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 141882.
tra added a comment.

Documented new options in ClangCommandLineReference.rst


https://reviews.llvm.org/D45495

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/cuda-options.cu

Index: clang/test/Driver/cuda-options.cu
===
--- clang/test/Driver/cuda-options.cu
+++ clang/test/Driver/cuda-options.cu
@@ -142,6 +142,48 @@
 // RUN:   -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCHALLERROR %s
 
+
+// Verify that --[no-]cuda-include-ptx arguments are handled correctly.
+// a) by default we're including PTX for all GPUs.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,PTX-SM35,PTX-SM30 %s
+
+// b) --no-cuda-include-ptx=all disables PTX inclusion for all GPUs
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=all \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,NOPTX-SM35,NOPTX-SM30 %s
+
+// c) --no-cuda-include-ptx=sm_XX disables PTX inclusion for that GPU only.
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,NOPTX-SM35,PTX-SM30 %s
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,PTX-SM35,NOPTX-SM30 %s
+
+// d) --cuda-include-ptx=all overrides preceding --no-cuda-include-ptx=all
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=all --cuda-include-ptx=all \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,PTX-SM35,PTX-SM30 %s
+
+// e) --cuda-include-ptx=all overrides preceding --no-cuda-include-ptx=sm_XX
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-include-ptx=sm_30 --cuda-include-ptx=all \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes FATBIN-COMMON,PTX-SM35,PTX-SM30 %s
+
+
 // ARCH-SM20: "-cc1"{{.*}}"-target-cpu" "sm_20"
 // NOARCH-SM20-NOT: "-cc1"{{.*}}"-target-cpu" "sm_20"
 // ARCH-SM30: "-cc1"{{.*}}"-target-cpu" "sm_30"
@@ -236,3 +278,12 @@
 
 // Match no linker.
 // NOLINK-NOT: "{{.*}}{{ld|link}}{{(.exe)?}}"
+
+// FATBIN-COMMON:fatbinary
+// FATBIN-COMMON: "--create" "[[FATBINARY:[^"]*]]"
+// FATBIN-COMMON: "--image=profile=sm_30,file=
+// PTX-SM30: "--image=profile=compute_30,file=
+// NOPTX-SM30-NOT: "--image=profile=compute_30,file=
+// FATBIN-COMMON: "--image=profile=sm_35,file=
+// PTX-SM35: "--image=profile=compute_35,file=
+// NOPTX-SM35-NOT: "--image=profile=compute_35,file=
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -377,6 +377,22 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+static bool shouldIncludePTX(const ArgList , const char *gpu_arch) {
+  bool includePTX = true;
+  for (Arg *A : Args) {
+if (!(A->getOption().matches(options::OPT_cuda_include_ptx_EQ) ||
+  A->getOption().matches(options::OPT_no_cuda_include_ptx_EQ)))
+  continue;
+A->claim();
+const StringRef ArchStr = A->getValue();
+if (ArchStr == "all" || ArchStr == gpu_arch) {
+  includePTX = A->getOption().matches(options::OPT_cuda_include_ptx_EQ);
+  continue;
+}
+  }
+  return includePTX;
+}
+
 // All inputs to this linker must be from CudaDeviceActions, as we need to look
 // at the Inputs' Actions in order to figure out which GPU architecture they
 // correspond to.
@@ -404,6 +420,9 @@
"Device action expected to have associated a GPU architecture!");
 CudaArch gpu_arch = StringToCudaArch(gpu_arch_str);
 
+if (II.getType() == types::TY_PP_Asm &&
+!shouldIncludePTX(Args, gpu_arch_str))
+  continue;
 // We need to pass an Arch of the form "sm_XX" for cubin files and
 // "compute_XX" for ptx.
 const char *Arch =
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -546,6 +546,10 @@
 def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">,
   HelpText<"Compile CUDA code for both host and device (default).  Has no "
"effect on non-CUDA compilations.">;
+def cuda_include_ptx_EQ : Joined<["--"], 

[PATCH] D45416: [analyzer] ExprEngine: model GCC inline asm rvalue cast outputs

2018-04-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D45416#1062901, @a.sidorin wrote:

> > The ultimate solution would probably be to add a fake cloned asm statement 
> > to the CFG (instead of the real asm statement) that would point to the 
> > correct output child-expression(s) that are untouched themselves but simply 
> > have their noop casts removed.
>
> I have some concerns about this solution. It will result in difference 
> between AST nodes and nodes that user will receive during analysis and I'm 
> not sure that it is good. What is even worse here is that a lot of AST stuff 
> won't work properly - ParentMap, for example.


Yep. But i'd rather avoid using the `ParentMap`. Also we already do this for 
`DeclStmt`s that declare more than one `VarDecl` (split them up into 
single-decl statements), and the practical effect of such simplification is 
barely noticeable even though `DeclStmt`s are so much more common.

>> Or we could try
> 
> Looks like something is missed here :)

Whoops sry nvm. And and and mmm you didn't include the diff context :p

In https://reviews.llvm.org/D45416#1063366, @a.sidorin wrote:

> Maybe we should just remove the condition and leave a FIXME?


The fix is already there and it's valid and it makes things better overall, why 
not keep it around. We still need a FIXME though.


Repository:
  rC Clang

https://reviews.llvm.org/D45416



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


[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386

2018-04-10 Thread Julien Ramseier via Phabricator via cfe-commits
elram added a comment.
Herald added subscribers: llvm-commits, delcypher.

This patch breaks cross-compiling the builtins for i686, with 
COMPILER_RT_DEFAULT_TARGET_ONLY=YES.
CC is set to

  clang -target i686-linux-musl -m32 -march=i686

But no supported target is detected by cmake and nothing gets built.

  -- Builtin supported architectures:


Repository:
  rL LLVM

https://reviews.llvm.org/D26764



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


  1   2   3   >