[PATCH] D75010: [OpenMP] Adding InaccessibleMemOnly and InaccessibleMemOrArgMemOnly for runtime calls.

2020-03-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I always thought there was a test for this, turns out I never committed it.
Since I did now (1c9c23d60ea7656174ad3d76293c2a90dd25e24f 
) you need 
to rebase and adjust it, sorry.




Comment at: llvm/test/Transforms/OpenMP/parallel_deletion.ll:3
-; RUN: opt -S -attributor -openmpopt -attributor-disable=false < %s | 
FileCheck %s
-; RUN: opt -S -passes='attributor,cgscc(openmpopt)' -attributor-disable=false 
< %s | FileCheck %s
 ;

this test was created with `utils/update_test_checks.py --function-signatures` 
before the script was smart enough to encode that into the file directly. Can 
you rerun with the option please.



Comment at: llvm/test/Transforms/OpenMP/parallel_deletion.ll:204
 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
 
+; CHECK: Function Attrs: inaccessiblememonly nofree nosync nounwind readonly

Use `UTC_ARGS: -disable` here and `-enable` below to keep the check lines even 
when the update script is run :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75010/new/

https://reviews.llvm.org/D75010



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-03-12 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 250130.
logan-5 marked 3 inline comments as done.
logan-5 added a comment.

The check now suggests fixes for concrete (i.e. non-template) uses of ADL. 
Re-enabled the check for macros, and eliminated some false positives with 
arrays of dependent size. The check now ignores hidden friends. Added a 
namespace whitelist. Added some tests and ensured that 
"don't-ignore-overloaded-operators" mode works properly in templates.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72282/new/

https://reviews.llvm.org/D72282

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-unintended-adl.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl-generic-lambdas.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl-operators.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp
@@ -0,0 +1,329 @@
+// RUN: %check_clang_tidy %s bugprone-unintended-adl %t -- \
+// RUN: -config="{CheckOptions: [ \
+// RUN:   {key: bugprone-unintended-adl.AllowedNamespaces, value: 'ignore_me;also::ignore::me'}, \
+// RUN: ]}" --
+
+namespace aspace {
+struct A {};
+void func(const A &);
+} // namespace aspace
+
+namespace bspace {
+void func(int);
+void test() {
+  aspace::A a;
+  func(5);
+  func(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'aspace::func' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  aspace::func(a);{{$}}
+}
+} // namespace bspace
+
+namespace ops {
+
+struct Stream {
+} stream;
+Stream &operator<<(Stream &s, int) {
+  return s;
+}
+Stream &operator<<(Stream &s, aspace::A) {
+  return s;
+}
+template 
+IStream &operator>>(IStream &s, int) {
+  return s;
+}
+template 
+IStream &operator>>(IStream &s, aspace::A) {
+  return s;
+}
+void smooth_operator(Stream);
+
+} // namespace ops
+
+void ops_test() {
+  ops::stream << 5;
+  // no warning
+  operator<<(ops::stream, 5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::operator<<(ops::stream, 5);{{$}}
+  ops::stream << aspace::A();
+  // no warning
+  // CHECK-FIXES: {{^}}  ops::stream << aspace::A();{{$}}
+  operator<<(ops::stream, aspace::A());
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::operator<<(ops::stream, aspace::A());{{$}}
+
+  ops::stream >> aspace::A();
+  // no warning
+  // CHECK-FIXES: {{^}}  ops::stream >> aspace::A();{{$}}
+  operator>>(ops::stream, aspace::A());
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator>>' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::operator>>(ops::stream, aspace::A());{{$}}
+
+  smooth_operator(ops::stream);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::smooth_operator' through ADL [bugprone-unintended-adl]
+  // CHECK-FIXES: {{^}}  ops::smooth_operator(ops::stream);{{$}}
+}
+
+namespace std {
+// return types don't matter, returning 'void' everywhere for simplicity
+
+template 
+void swap(T &a, T &b);
+template 
+void make_error_code(T);
+template 
+void make_error_condition(T);
+template 
+void data(T);
+template 
+void begin(T);
+template 
+void end(T);
+template 
+void rbegin(T);
+template 
+void rend(T);
+template 
+void crbegin(T);
+template 
+void crend(T);
+template 
+void size(T);
+template 
+void ssize(T);
+template 
+void empty(T);
+
+template 
+void move(T &&);
+template 
+void forward(T &&);
+
+struct byte {};
+
+} // namespace std
+namespace ns {
+
+struct Swappable {};
+
+// whitelisted
+void swap(Swappable &a, Swappable &b);
+void make_error_code(Swappable);
+void make_error_condition(Swappable);
+void data(Swappable);
+void begin(Swappable);
+void end(Swappable);
+void rbegin(Swappable);
+void rend(Swappable);
+void crbegin(Swappable);
+void crend(Swappable);
+void size(Swappable);
+void ssize(Swappable);
+void empty(Swappable);
+
+// non-whitelisted
+void move(Swappable);
+void ref(Swappable);
+
+struct Swappable2 {};
+
+} // namespace ns
+struct {
+  template 
+  void operator()(T &&);
+} ref;
+
+void test2() {
+  // TODO add granularity for detecting functions that may always be called unqualified,
+  // versus those that can only be called through the 'using' 'two-step'
+  using namespace std;
+  ns::Swappable a, b;
+  swap(a, b);
+  mak

[Diffusion] rG825235c140e7: Revert "[Sema] Use the canonical type in function isVector"

2020-03-12 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In rG825235c140e7747f686bd7902cb0f9af77590841#909794 
, 
@SjoerdMeijer wrote:

> > I'm still not sure why __fp16, which is a storage-only type, is used for 
> > the element type of float16x4_t if we want to avoid promotion to a float 
> > vector type.
>
> About the types: `__fp16` this is the older, storage-only type. So, just 
> historically, I think this element type was used to describe the neon 
> vectors, which translates to vectors with elements of i16 or f16, which all 
> seems fine.
>
> > Was there a discussion on llvm-dev or phabricator?
>
> I don't think this is necessary, because this is how it's been from let's say 
> the beginning.
>
> > Can we change the element type of the vector to _Float16?
>
> I don't see a benefit of doing this, and making this perhaps intrusive change.
>
> > It seems that the original plan discussed on llvm-dev 
> > (http://lists.llvm.org/pipermail/cfe-dev/2017-May/053768.html) was to 
> > introduce _Float16 and use it instead of __fp16 for ARMv8.2-A, but the 
> > subsequent patches that were committed are making NeonEmitter.cpp emit 
> > typedefs of vectors that have __fp16 as the element type.
>
> Then `_Float16` came along, which is a proper half type (not a storage only 
> type), is defined in a C11 extension, and should be used for the ARMv8.2-A 
> native half instructions; the semantics of `__fp16` and `_Float16` are 
> different, and as a result using `__fp16` for the v8.2 half FP instructions 
> is not an option, so it is not a matter of using `_Float16` instead of 
> `__fp16`.


OK, I see. Looking at the history, the half precision vector types defined in 
arm_neon.h (e.g., `float16x4_t`) were introduced long before `_Float16` or 
ARMv8.2-A.

> As I said, your problem wasn't clear to me, so let's look at your example:
> 
>> For example, in vneg_f16, __p0 is promoted to a vector of float before it's 
>> negated.
>> 
>> __ai float16x4_t vneg_f16(float16x4_t __p0) {
>> 
>>   float16x4_t __ret;
>>__ret = -__p0;
>>return __ret;
>> 
>> }
> 
> when I compile this and emit llvm ir I get this:
> 
>   define dso_local <2 x i32> @vneg_f16(<2 x i32> %__p0.coerce) 
> local_unnamed_addr #0 {
>   entry:
> %0 = bitcast <2 x i32> %__p0.coerce to <4 x half>
> %fneg = fneg fast <4 x half> %0
> %1 = bitcast <4 x half> %fneg to <2 x i32>
> ret <2 x i32> %1
>   }
>
> 
> so far so good I think: this shows a fneg on vector of halfs.

Yes, I think this is what we want to see. We don't want to treat `__p0` as a 
strorage-only type and promote it to a vector of floats before negating it.

> Where and when do you see problems? Can you describe this, and also provide 
> your compile commands?

The problem is that, after I committed a patch (which was reverted later, see 
https://reviews.llvm.org/rGa6150b48cea00ab31e9335cc73770327acc4cb3a) to fix a 
bug in Sema, clang started to promote  `__p0` to a vector of floats because the 
element type of `float16x4_t` is `__fp16`.

  typedef __fp16 float16_t;
  typedef __attribute__((neon_vector_type(4))) float16_t float16x4_t;

The bug I'm trying to fix causes clang to generate different IR for `test0` and 
`test1` in the code below even though the only difference is that the element 
type of `half_vector1` is a typedef of `__fp16`. In `test1`, the two vectors 
are added without being promoted to vectors of floats first.

  typedef __fp16 FP16;
  typedef __fp16 half_vector0 __attribute__ ((vector_size (8)));
  typedef FP16 half_vector1 __attribute__ ((vector_size (8)));
  
  // 'a' and 'b' are promoted to vectors of floats before the addition.
  half_vector0 test0(half_vector0 a, half_vector0 b) {
return a + b;
  }
  
  // Currently 'a' and 'b' aren't promoted to vectors of floats before the 
addition.
  half_vector1 test1(half_vector1 a, half_vector1 b) {
return a + b;p
  }

After I fixed the bug, clang started to generate the same IR for `test0` and 
`test1`, but this had the unwanted side-effect of promoting `__p0` in 
`vneg_f16` to a vector of float as I explained before.

Just to be sure I'm understanding the semantics of the types defined in 
arm_neon.h, we don't want to treat `float16x4_t` as a storage-only type like 
`half_vector0` in the code above and promote it to vectors of floats in the 
front-end, right? If that is the case, it seems to me that `__fp16` isn't the 
right type as the element type, since that implies the vector of halves has to 
be promoted to vector of floats. But I also realize that changing the typedef 
of `float16x4_t` and using `_Float16` as the element type long after the 
typedef was introduced can break code that is currently working.

I think I'll leave the typedefs unchanged and just avoid promoting vectors of 
halves in Sema if they are neon vectors.


BRANCHES
  master, release/10.x

Users:
  ahatanak (Author)

https://reviews.llvm.org/rG825235c140e7




[PATCH] D76100: Debug Info: Store the SDK in the DICompileUnit.

2020-03-12 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Looks good to me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76100/new/

https://reviews.llvm.org/D76100



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-12 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 added a comment.

In D57497#1920097 , @apazos wrote:

> Thanks Shiva, I res-ynced and rebuilt the patch. It is working fine.
>
> I see there is a msmall-data-threshold flag used by Mips and Hexagon, and now 
> we are adding a new flag msmall-data-limit. Should't we reuse the flag?


Hi Ana, 
Thanks for trying the patch. msmall-data-limit is also a RISCV GCC flag, so I 
would recommend using the same flag as GCC.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57497/new/

https://reviews.llvm.org/D57497



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


[PATCH] D75169: [ARM] Enforcing calling convention for half-precision FP arguments and returns for big-endian AArch32

2020-03-12 Thread Chris Lattner via Phabricator via cfe-commits
lattner resigned from this revision.
lattner added a comment.

I'm not a qualified reviewer for this at this point.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75169/new/

https://reviews.llvm.org/D75169



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


[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-12 Thread Kan Shengchen via Phabricator via cfe-commits
skan abandoned this revision.
skan added a comment.

Reconsidered the advice of @rnk , we can use `-fms-extensions` to supported 
_BitScan* on linux.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75723/new/

https://reviews.llvm.org/D75723



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


[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-12 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

The timer linked list is an interesting complication.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76099/new/

https://reviews.llvm.org/D76099



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


[libunwind] 3758b85 - Only run frameheader_cache_test.pass.cpp on x86_64.

2020-03-12 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-03-12T18:14:22-07:00
New Revision: 3758b858ef3b39b3081bf9a567ead8bc69c9a208

URL: 
https://github.com/llvm/llvm-project/commit/3758b858ef3b39b3081bf9a567ead8bc69c9a208
DIFF: 
https://github.com/llvm/llvm-project/commit/3758b858ef3b39b3081bf9a567ead8bc69c9a208.diff

LOG: Only run frameheader_cache_test.pass.cpp on x86_64.

Although there is nothing architecturally specific, the
ifdef chains are too complicated otherwise.

Added: 


Modified: 
libunwind/test/frameheadercache_test.pass.cpp

Removed: 




diff  --git a/libunwind/test/frameheadercache_test.pass.cpp 
b/libunwind/test/frameheadercache_test.pass.cpp
index df0f926985d7..9397e70d66cb 100644
--- a/libunwind/test/frameheadercache_test.pass.cpp
+++ b/libunwind/test/frameheadercache_test.pass.cpp
@@ -3,6 +3,11 @@
 #include "../src/config.h"
 
 // Only run this test under supported configurations.
+// The frame header cache should work fine for other architectures,
+// but the #ifdefs end up being even more complicated than this.
+
+#ifdef __x86_64__
+
 // This #if chain is ugly, but see the comments in AddressSpace.hpp for
 // the reasoning.
 
@@ -82,3 +87,6 @@ int main() {
 #else
 int main() { return 0; }
 #endif
+#else
+int main() { return 0;}
+#endif



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


[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-12 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked 6 inline comments as done.
vabridgers added a comment.

I believe all comments have been addressed. Please let me know if there's 
anything else required. Thanks




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:519
+  // architectures, but not for others.
+  const RangeInt UCharMax = 
+  std::min(BVF.getMaxValue(ACtx.UnsignedCharTy).getLimitedValue(), IntMax);

NoQ wrote:
> Let's rename this constant then, so that we still had our `UCharMax` when we 
> actually need the real `UCHAR_MAX` in the summary.
Done, thanks Artem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75529/new/

https://reviews.llvm.org/D75529



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


[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-12 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 250109.
vabridgers marked 2 inline comments as not done.
vabridgers added a comment.

fix pre merge checkswq


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75529/new/

https://reviews.llvm.org/D75529

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -510,8 +510,14 @@
   const RangeInt LongMax = BVF.getMaxValue(LongTy).getLimitedValue();
   const RangeInt LongLongMax = BVF.getMaxValue(LongLongTy).getLimitedValue();
 
-  const RangeInt UCharMax =
-  BVF.getMaxValue(ACtx.UnsignedCharTy).getLimitedValue();
+  // Set UCharRangeMax to min of int or uchar maximum value.
+  // The C standard states that the arguments of functions like isalpha must
+  // be representable as an unsigned char. Their type is 'int', so the max
+  // value of the argument should be min(UCharMax, IntMax). This just happen
+  // to be true for commonly used and well tested instruction set
+  // architectures, but not for others.
+  const RangeInt UCharRangeMax = 
+  std::min(BVF.getMaxValue(ACtx.UnsignedCharTy).getLimitedValue(), IntMax);
 
   // The platform dependent value of EOF.
   // Try our best to parse this from the Preprocessor, otherwise fallback to -1.
@@ -573,8 +579,8 @@
   // Templates for summaries that are reused by many functions.
   auto Getc = [&]() {
 return Summary(ArgTypes{Irrelevant}, RetType{IntTy}, NoEvalCall)
-.Case(
-{ReturnValueCondition(WithinRange, {{EOFv, EOFv}, {0, UCharMax}})});
+.Case({ReturnValueCondition(WithinRange,
+{{EOFv, EOFv}, {0, UCharRangeMax}})});
   };
   auto Read = [&](RetType R, RangeInt Max) {
 return Summary(ArgTypes{Irrelevant, Irrelevant, SizeTy}, RetType{R},
@@ -609,12 +615,13 @@
   // The locale-specific range.
   // No post-condition. We are completely unaware of
   // locale-specific return values.
-  .Case({ArgumentCondition(0U, WithinRange, {{128, UCharMax}})})
+  .Case({ArgumentCondition(0U, WithinRange,
+   {{128, UCharRangeMax}})})
   .Case({ArgumentCondition(0U, OutOfRange,
{{'0', '9'},
 {'A', 'Z'},
 {'a', 'z'},
-{128, UCharMax}}),
+{128, UCharRangeMax}}),
  ReturnValueCondition(WithinRange, SingleValue(0))})},
   },
   {
@@ -625,10 +632,11 @@
{{'A', 'Z'}, {'a', 'z'}}),
  ReturnValueCondition(OutOfRange, SingleValue(0))})
   // The locale-specific range.
-  .Case({ArgumentCondition(0U, WithinRange, {{128, UCharMax}})})
+  .Case({ArgumentCondition(0U, WithinRange,
+   {{128, UCharRangeMax}})})
   .Case({ArgumentCondition(
  0U, OutOfRange,
- {{'A', 'Z'}, {'a', 'z'}, {128, UCharMax}}),
+ {{'A', 'Z'}, {'a', 'z'}, {128, UCharRangeMax}}),
  ReturnValueCondition(WithinRange, SingleValue(0))})},
   },
   {
@@ -692,9 +700,11 @@
  ArgumentCondition(0U, OutOfRange, Range('a', 'z')),
  ReturnValueCondition(WithinRange, SingleValue(0))})
   // The locale-specific range.
-  .Case({ArgumentCondition(0U, WithinRange, {{128, UCharMax}})})
+  .Case({ArgumentCondition(0U, WithinRange,
+   {{128, UCharRangeMax}})})
   // Is not an unsigned char.
-  .Case({ArgumentCondition(0U, OutOfRange, Range(0, UCharMax)),
+  .Case({ArgumentCondition(0U, OutOfRange,
+   Range(0, UCharRangeMax)),
  ReturnValueCondition(WithinRange, SingleValue(0))})},
   },
   {
@@ -728,10 +738,11 @@
{{9, 13}, {' ', ' '}}),
  ReturnValueCondition(OutOfRange, SingleValue(0))})
   // The locale-specific range.
-  .Case({ArgumentCondition(0U, WithinRange, {{128, UCharMax}})})
+  .Case({ArgumentCondition(0U, WithinRange,
+   {{128, UCharRangeMax}})})
   .Case({ArgumentCondition(
   

[PATCH] D35732: Update system_error tests for more platforms.

2020-03-12 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa9740ff1585a: Update system_error tests for more platforms. 
(authored by danalbert).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D35732/new/

https://reviews.llvm.org/D35732

Files:
  
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
  
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp


Index: 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
===
--- 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
+++ 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::system_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 
Index: 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
===
--- 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
+++ 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::generic_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 


Index: libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
===
--- libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
+++ libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::system_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 
Index: libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
===
--- libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
+++ libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::generic_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-03-12 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Done with `private` `firstprivate` `copyin` - working on modifying the clang 
test, and fixing some bugs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591



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


[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:53-55
+ast_matchers::internal::Matcher
+hasAnyListedName(std::vector Names);
+

We could change all checks to use the other overload and drop this one (and the 
utils::options::parseStringList() call in each check's constructor). WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75911/new/

https://reviews.llvm.org/D75911



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think the code that disables constant evaluation for C is just 
https://github.com/llvm/llvm-project/blob/dcaf13a4048df3dad55f1a28cde7cefc99ccc057/clang/lib/AST/ExprConstant.cpp#L13918
 and 
https://github.com/llvm/llvm-project/blob/dcaf13a4048df3dad55f1a28cde7cefc99ccc057/clang/lib/AST/ExprConstant.cpp#L13744
 .  The performance implications of deleting those lines is the complicated 
part.




Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

efriedma wrote:
> nickdesaulniers wrote:
> > efriedma wrote:
> > > nickdesaulniers wrote:
> > > > nickdesaulniers wrote:
> > > > > Interesting, playing with this more in godbolt, it looks like the 
> > > > > struct doesn't even have to be const qualified.
> > > > Or, rather, behaves differently between C and C++ mode;
> > > > 
> > > > C -> const required
> > > > C++ -> const not required
> > > In C++, global variable initializers don't have to be constant 
> > > expressions at all.
> > > 
> > > Do we really need to check GNUMode here? We try to avoid it except for 
> > > cases where we would otherwise reject valid code.
> > > 
> > > Do we need to worry about arrays here?
> > > In C++, global variable initializers don't have to be constant 
> > > expressions at all.
> > 
> > It looks like my test cases are supported already in Clang today, in C++ 
> > mode only and not C.  Maybe there's some alternative code path that I 
> > should be looking to reuse?
> > 
> > > Do we really need to check GNUMode here?
> > 
> > Maybe a `-Wpedantic` diag would be more appropriate otherwise? (GCC does 
> > not warn for these cases with `-Wpedantic`.  If the answer to your question 
> > is `no`, then that means supporting these regardless of language mode.  
> > (I'm ok with that, was just being maybe overly cautious with `GNUMode`, but 
> > maybe folks with better knowledge of the language standards have better 
> > thoughts?)
> > 
> > > Do we need to worry about arrays here?
> > 
> > I don't think arrays are supported: https://godbolt.org/z/RiZPpM
> Also, do we need to check that we actually have a definition for the variable?
The C++ standard is substantially different from C.  C++ global initializers 
can be evaluated at runtime.  So we don't call this code at all in C++.

Independent of that, we do have pretty complete support for constant evaluation 
of structs in C++ to support constexpr, and we should be able to leverage that.



For arrays, I was thinking of something like this:

```
const int foo[3] = { 0, 1, 2 };
int bar = foo[0];
```



We generally don't generate pedantic warnings unless the user uses an extension 
that's disallowed by the C standard.  (The idea is that clang with -pedantic 
should generate a diagnostic every place the C standard requires a diagnostic.  
It's not a catch-all for extensions.)

We could separately generate some sort of portability warning, but not sure 
anyone would care to enable it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

nickdesaulniers wrote:
> efriedma wrote:
> > nickdesaulniers wrote:
> > > nickdesaulniers wrote:
> > > > Interesting, playing with this more in godbolt, it looks like the 
> > > > struct doesn't even have to be const qualified.
> > > Or, rather, behaves differently between C and C++ mode;
> > > 
> > > C -> const required
> > > C++ -> const not required
> > In C++, global variable initializers don't have to be constant expressions 
> > at all.
> > 
> > Do we really need to check GNUMode here? We try to avoid it except for 
> > cases where we would otherwise reject valid code.
> > 
> > Do we need to worry about arrays here?
> > In C++, global variable initializers don't have to be constant expressions 
> > at all.
> 
> It looks like my test cases are supported already in Clang today, in C++ mode 
> only and not C.  Maybe there's some alternative code path that I should be 
> looking to reuse?
> 
> > Do we really need to check GNUMode here?
> 
> Maybe a `-Wpedantic` diag would be more appropriate otherwise? (GCC does not 
> warn for these cases with `-Wpedantic`.  If the answer to your question is 
> `no`, then that means supporting these regardless of language mode.  (I'm ok 
> with that, was just being maybe overly cautious with `GNUMode`, but maybe 
> folks with better knowledge of the language standards have better thoughts?)
> 
> > Do we need to worry about arrays here?
> 
> I don't think arrays are supported: https://godbolt.org/z/RiZPpM
Also, do we need to check that we actually have a definition for the variable?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096



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


[clang] 461566b - Add a test triple to avoid failure under MS ABI.

2020-03-12 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-12T16:44:09-07:00
New Revision: 461566b0465c57793c70b0daff87f071d9e5906a

URL: 
https://github.com/llvm/llvm-project/commit/461566b0465c57793c70b0daff87f071d9e5906a
DIFF: 
https://github.com/llvm/llvm-project/commit/461566b0465c57793c70b0daff87f071d9e5906a.diff

LOG: Add a test triple to avoid failure under MS ABI.

MS ABI has slightly different rules for when destructors are implicitly
defined and when the 'delete this' is checked that are out of scope for
the intent of this test.

Added: 


Modified: 
clang/test/CXX/special/class.dtor/p5-0x.cpp

Removed: 




diff  --git a/clang/test/CXX/special/class.dtor/p5-0x.cpp 
b/clang/test/CXX/special/class.dtor/p5-0x.cpp
index 66d965864f2c..ac8ce3466cb5 100644
--- a/clang/test/CXX/special/class.dtor/p5-0x.cpp
+++ b/clang/test/CXX/special/class.dtor/p5-0x.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -std=c++11 %s -Wno-defaulted-function-deleted
+// RUN: %clang_cc1 -verify -std=c++11 %s -Wno-defaulted-function-deleted 
-triple x86_64-linux-gnu
 
 struct NonTrivDtor {
   ~NonTrivDtor();



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


[PATCH] D76103: [clangd] Extend findTarget()'s dependent name heuristic to handle enumerators

2020-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks! Just a couple of Qs...




Comment at: clang-tools-extra/clangd/FindTarget.cpp:105
+  if (auto *ET = T->getAs()) {
+LookupInDecl = ET->getDecl();
+  } else {

Is this the bit that "breaks" the dependence? getDecl() works even if the type 
might ultimately correspond to a different decl?

It's not obvious to me where the magic happens, so wherever it is, maybe add a 
comment :-)



Comment at: clang-tools-extra/clangd/FindTarget.cpp:105
+  if (auto *ET = T->getAs()) {
+LookupInDecl = ET->getDecl();
+  } else {

sammccall wrote:
> Is this the bit that "breaks" the dependence? getDecl() works even if the 
> type might ultimately correspond to a different decl?
> 
> It's not obvious to me where the magic happens, so wherever it is, maybe add 
> a comment :-)
The actual lookup doesn't do anything subtle in this case (no dependent base 
lookup, failing to match IsArrow isn't possible).

What do you think about just calling Decl->lookup() here and early returning, 
not bothering with the generalization of lookupDependentName? (I find the mix 
of behavior in that function a little hard to get my head around)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76103/new/

https://reviews.llvm.org/D76103



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


[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Please upload diffs with full context. If you are using `git diff` to generate 
the patch, pass the flag `-U99`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76083/new/

https://reviews.llvm.org/D76083



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done and an inline comment as not 
done.
nickdesaulniers added a comment.

In D76096#1920477 , @efriedma wrote:

> But that's probably a larger project than you really want to mess with.


Maybe with some coaching; but if this is already supported today in C++, maybe 
it's just a small incision to support this in C?




Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

efriedma wrote:
> nickdesaulniers wrote:
> > nickdesaulniers wrote:
> > > Interesting, playing with this more in godbolt, it looks like the struct 
> > > doesn't even have to be const qualified.
> > Or, rather, behaves differently between C and C++ mode;
> > 
> > C -> const required
> > C++ -> const not required
> In C++, global variable initializers don't have to be constant expressions at 
> all.
> 
> Do we really need to check GNUMode here? We try to avoid it except for cases 
> where we would otherwise reject valid code.
> 
> Do we need to worry about arrays here?
> In C++, global variable initializers don't have to be constant expressions at 
> all.

It looks like my test cases are supported already in Clang today, in C++ mode 
only and not C.  Maybe there's some alternative code path that I should be 
looking to reuse?

> Do we really need to check GNUMode here?

Maybe a `-Wpedantic` diag would be more appropriate otherwise? (GCC does not 
warn for these cases with `-Wpedantic`.  If the answer to your question is 
`no`, then that means supporting these regardless of language mode.  (I'm ok 
with that, was just being maybe overly cautious with `GNUMode`, but maybe folks 
with better knowledge of the language standards have better thoughts?)

> Do we need to worry about arrays here?

I don't think arrays are supported: https://godbolt.org/z/RiZPpM



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1013
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;

efriedma wrote:
> You need to be more careful here; we can call ConstExprEmitter for arbitrary 
> expressions.
"Be more careful" how?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: libcxx/include/new:240
   return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#elif defined(_LIBCPP_CXX03_LANG)
+  return __align > alignment_of<__libcpp_max_align_t>::value;

So, IIUC what you're saying, `__STDCPP_DEFAULT_NEW_ALIGNMENT__` is provided by 
recent Clangs in C++03 mode? I tested it and it does seem to be correct. (side 
note: I tend to think we should be more aggressive to remove old compiler 
support, since most people don't upgrade their stdlib without upgrading their 
compiler anyway).

So if we don't care about supporting old compilers that don't provide that 
macro, we could just get rid of this `#elif`, and such compilers would error 
out when trying to use `max_align_t` in the `#else` below. That appears 
reasonable to me.

We'd still leave the `#if TEST_STD_VER >= 11` in the tests below, since in 
C++03 we wouldn't provide `std::max_align_t`, however testing that we use 
overaligned new in the same conditions in C++03 and C++11 becomes trivial, 
because it's the same code path.

Did I get what you meant correctly? If so, that sounds like a viable path 
forward to me, since we're simplifying the code. We're also improving on our 
C++03 conformance, which isn't considered good but is certainly not considered 
bad either.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73245/new/

https://reviews.llvm.org/D73245



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-12 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG246398ece711: [clang][Parse] properly parse asm-qualifiers, 
asm inline (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75563/new/

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1529,13 +1529,13 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation 

[PATCH] D76086: [Sema][SVE] Reject arithmetic on pointers to sizeless types

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

People are going to want to iterate over arrays in memory to write simple 
intrinsic loops.  If we don't allow `p + i` to work, people will be forced to 
write `(__SVInt8_t*)((char*)p + i * svcntb())`.  Which is the same thing, just 
a lot uglier.  And it wouldn't really be that crazy to support 
`sizeof(__SVInt8_t)`.  I mean, it's effectively just a different way of 
spelling `svcntb()`.  I guess we can always relax it later, though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76086/new/

https://reviews.llvm.org/D76086



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


[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

Fine for me. Fixes newline bug in https://bugs.llvm.org/show_bug.cgi?id=45150.
However I don't have "review privileges" here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76037/new/

https://reviews.llvm.org/D76037



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


[PATCH] D76054: [clang-apply-replacements] No longer deduplucates replacements from the same TU

2020-03-12 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

Unfortunately I cannot say whether the code is good, but the fix works and 
certainly helps readability-braces-around-statements which can sometimes add 
multiple } at the same offset to close several scopes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76054/new/

https://reviews.llvm.org/D76054



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


[PATCH] D76087: [Sema][SVE] Reject sizeless types in exception specs

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

In theory, we actually could allow throwing sizeless types; as far as I know, 
nothing in the ABI actually blocks it.  But probably not worth the work to 
implement it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76087/new/

https://reviews.llvm.org/D76087



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


[PATCH] D76103: [clangd] Extend findTarget()'s dependent name heuristic to handle enumerators

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76103

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -520,6 +520,14 @@
 void test(unique_ptr>& V) {
   V->fo^o();
 }
+  )cpp",
+
+  R"cpp(// Heuristic resolution of dependent enumerator
+template 
+struct Foo {
+  enum class E { [[A]], B };
+  E e = E::A^;
+};
   )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -57,6 +57,30 @@
   return S;
 }
 
+// This is similar to CXXRecordDecl::lookupDependentName(), but extended
+// to handle certain other kinds of decls (currently, EnumDecl) as well.
+std::vector
+lookupDependentName(TagDecl *TD, DeclarationName Name,
+llvm::function_ref Filter) {
+  if (TagDecl *Def = TD->getDefinition()) {
+TD = Def;
+  }
+
+  if (auto *RD = dyn_cast_or_null(TD)) {
+return RD->lookupDependentName(Name, Filter);
+  }
+  if (auto *ED = dyn_cast_or_null(TD)) {
+std::vector Result;
+for (const auto *Decl : ED->lookup(Name)) {
+  if (Filter(Decl)) {
+Result.push_back(Decl);
+  }
+}
+return Result;
+  }
+  return {};
+}
+
 // Given a dependent type and a member name, heuristically resolve the
 // name to one or more declarations.
 // The current heuristic is simply to look up the name in the primary
@@ -76,22 +100,24 @@
 bool IsNonstaticMember) {
   if (!T)
 return {};
-  if (auto *ICNT = T->getAs()) {
-T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+  TagDecl *LookupInDecl = nullptr;
+  if (auto *ET = T->getAs()) {
+LookupInDecl = ET->getDecl();
+  } else {
+if (auto *ICNT = T->getAs()) {
+  T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
+}
+auto *TST = T->getAs();
+if (!TST)
+  return {};
+const ClassTemplateDecl *TempD = dyn_cast_or_null(
+TST->getTemplateName().getAsTemplateDecl());
+if (!TempD)
+  return {};
+LookupInDecl = TempD->getTemplatedDecl();
   }
-  auto *TST = T->getAs();
-  if (!TST)
-return {};
-  const ClassTemplateDecl *TD = dyn_cast_or_null(
-  TST->getTemplateName().getAsTemplateDecl());
-  if (!TD)
-return {};
-  CXXRecordDecl *RD = TD->getTemplatedDecl();
-  if (!RD->hasDefinition())
-return {};
-  RD = RD->getDefinition();
-  DeclarationName Name = NameFactory(RD->getASTContext());
-  return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
+  DeclarationName Name = NameFactory(LookupInDecl->getASTContext());
+  return lookupDependentName(LookupInDecl, Name, [=](const NamedDecl *D) {
 return IsNonstaticMember ? D->isCXXInstanceMember()
  : !D->isCXXInstanceMember();
   });


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -520,6 +520,14 @@
 void test(unique_ptr>& V) {
   V->fo^o();
 }
+  )cpp",
+
+  R"cpp(// Heuristic resolution of dependent enumerator
+template 
+struct Foo {
+  enum class E { [[A]], B };
+  E e = E::A^;
+};
   )cpp"};
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -57,6 +57,30 @@
   return S;
 }
 
+// This is similar to CXXRecordDecl::lookupDependentName(), but extended
+// to handle certain other kinds of decls (currently, EnumDecl) as well.
+std::vector
+lookupDependentName(TagDecl *TD, DeclarationName Name,
+llvm::function_ref Filter) {
+  if (TagDecl *Def = TD->getDefinition()) {
+TD = Def;
+  }
+
+  if (auto *RD = dyn_cast_or_null(TD)) {
+return RD->lookupDependentName(Name, Filter);
+  }
+  if (auto *ED = dyn_cast_or_null(TD)) {
+std::vector Result;
+for (const auto *Decl : ED->lookup(Name)) {
+  if (Filter(Decl)) {
+Result.push_back(Decl);
+  }
+}
+return Result;
+  }
+  return {};
+}
+
 // Given a dependent type and a member name, heuristically resolve the
 // name to one or more declarat

[PATCH] D76088: [Sema][SVE] Don't allow sizeless objects to be thrown

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76088/new/

https://reviews.llvm.org/D76088



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


[clang] 246398e - [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-12 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-03-12T15:13:59-07:00
New Revision: 246398ece7115b57a02dbe7876d86ae8e72406ef

URL: 
https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef
DIFF: 
https://github.com/llvm/llvm-project/commit/246398ece7115b57a02dbe7876d86ae8e72406ef.diff

LOG: [clang][Parse] properly parse asm-qualifiers, asm inline

Summary:
The parsing of GNU C extended asm statements was a little brittle and
had a few issues:
- It was using Parse::ParseTypeQualifierListOpt to parse the `volatile`
  qualifier.  That parser is really meant for TypeQualifiers; an asm
  statement doesn't really have a type qualifier. This is still maybe
  nice to have, but not necessary. We now can check for the `volatile`
  token by properly expanding the grammer, rather than abusing
  Parse::ParseTypeQualifierListOpt.
- The parsing of `goto` was position dependent, so `asm goto volatile`
  wouldn't parse. The qualifiers should be position independent to one
  another. Now they are.
- We would warn on duplicate `volatile`, but the parse error for
  duplicate `goto` was a generic parse error and wasn't clear.
- We need to add support for the recent GNU C extension `asm inline`.
  Adding support to the parser with the above issues highlighted the
  need for this refactoring.

Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: aheejin, jfb, nathanchance, cfe-commits, echristo, efriedma, 
rsmith, chandlerc, craig.topper, erichkeane, jyu2, void, srhines

Tags: #clang

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

Added: 
clang/test/Parser/asm-qualifiers.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmtAsm.cpp
clang/lib/Parse/Parser.cpp
clang/test/CodeGen/inline-asm-mixed-style.c
clang/test/Parser/asm.c
clang/test/Sema/asm.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 664ae4e4167c..710f005985da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -91,6 +91,13 @@ Modified Compiler Flags
   of a variable in a header file. In some cases, no specific translation unit
   provides a definition of the variable. The previous behavior can be restored 
by
   specifying ``-fcommon``.
+- -Wasm-ignored-qualifier (ex. `asm const ("")`) has been removed and replaced
+  with an error (this matches a recent change in GCC-9).
+- -Wasm-file-asm-volatile (ex. `asm volatile ("")` at global scope) has been
+  removed and replaced with an error (this matches GCC's behavior).
+- Duplicate qualifiers on asm statements (ex. `asm volatile volatile ("")`) no
+  longer produces a warning via -Wduplicate-decl-specifier, but now an error
+  (this matches GCC's behavior).
 
 New Pragmas in Clang
 
@@ -111,6 +118,9 @@ C Language Changes in Clang
 - The default C language standard used when `-std=` is not specified has been
   upgraded from gnu11 to gnu17.
 
+- Clang now supports the GNU C extension `asm inline`; it won't do anything
+  *yet*, but it will be parsed.
+
 - ...
 
 C++ Language Changes in Clang

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2b11298bfcfa..2c28789aac1d 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1090,9 +1090,8 @@ def ObjCSignedCharBool : 
DiagGroup<"objc-signed-char-bool",
 
 // Inline ASM warnings.
 def ASMOperandWidths : DiagGroup<"asm-operand-widths">;
-def ASMIgnoredQualifier : DiagGroup<"asm-ignored-qualifier">;
 def ASM : DiagGroup<"asm", [
-ASMOperandWidths, ASMIgnoredQualifier
+ASMOperandWidths
   ]>;
 
 // OpenMP warnings.

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index ec33a0fcfdc7..f22d3a18d254 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -12,11 +12,10 @@
 
 let Component = "Parse" in {
 
-def warn_asm_qualifier_ignored : Warning<
-  "ignored %0 qualifier on asm">, CatInlineAsm, InGroup;
-def warn_file_asm_volatile : Warning<
-  "meaningless 'volatile' on asm outside function">, CatInlineAsm,
-  InGroup;
+def err_asm_qualifier_ignored : Error<
+  "expected 'volatile', 'inline', 'goto', or '('">, CatInlineAsm;
+def err_global_asm_qualifier_ignored : Error<
+  "meaningless '%0' on asm outside function">, CatInlineAsm;
 
 let CategoryName = "Inline Assembly Issue" in {
 def err_asm_empty : Error<"__asm used with no assembly instructions">;
@@ -29,6 +28,7 @@ def err_gnu_inline_asm_disabled : Error<
   "GNU-style inline assembly is disabled">;
 def err_asm_got

[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I would like to kill off all the code you're modifying, and let ExprConstant be 
the final arbiter of whether a constant is in fact constant.  But that's 
probably a larger project than you really want to mess with.  The big missing 
piece of that is that we currently don't allow ExprConstant to evaluate 
structs/arrays in C, for the sake of compile-time performance. (Not sure what 
the performance impact for large arrays looks like at the moment.)




Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > Interesting, playing with this more in godbolt, it looks like the struct 
> > doesn't even have to be const qualified.
> Or, rather, behaves differently between C and C++ mode;
> 
> C -> const required
> C++ -> const not required
In C++, global variable initializers don't have to be constant expressions at 
all.

Do we really need to check GNUMode here? We try to avoid it except for cases 
where we would otherwise reject valid code.

Do we need to worry about arrays here?



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1013
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;

You need to be more careful here; we can call ConstExprEmitter for arbitrary 
expressions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096



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


[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2020-03-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I believe folks are in agreement about this direction, but I'm waiting for 
someone to mark the revision accepted. Let me know if that's not the case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65543/new/

https://reviews.llvm.org/D65543



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


[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2020-03-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 250068.
rnk added a comment.

- rebase, ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65543/new/

https://reviews.llvm.org/D65543

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/sanitizer-ld.c
  llvm/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -880,6 +880,27 @@
   endif()
 endif()
 
+# When using clang-cl with an instrumentation-based tool, add clang's library
+# resource directory to the library search path. Because cmake invokes the
+# linker directly, it isn't sufficient to pass -fsanitize=* to the linker.
+if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
+  execute_process(
+COMMAND ${CMAKE_CXX_COMPILER} /clang:-print-resource-dir
+OUTPUT_VARIABLE clang_resource_dir
+ERROR_VARIABLE clang_cl_stderr
+OUTPUT_STRIP_TRAILING_WHITESPACE
+ERROR_STRIP_TRAILING_WHITESPACE
+RESULT_VARIABLE clang_cl_exit_code)
+  if (NOT "${clang_cl_exit_code}" STREQUAL "0")
+message(FATAL_ERROR
+  "Unable to invoke clang-cl to find resource dir: ${clang_cl_stderr}")
+  endif()
+  file(TO_CMAKE_PATH "${clang_resource_dir}" clang_resource_dir)
+  append("/libpath:${clang_resource_dir}/lib/windows"
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
+
 if(LLVM_PROFDATA_FILE AND EXISTS ${LLVM_PROFDATA_FILE})
   if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
 append("-fprofile-instr-use=\"${LLVM_PROFDATA_FILE}\""
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -656,16 +656,16 @@
 // RUN: -target x86_64-pc-windows \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN64 %s
-// CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats_client-x86_64.lib"
-// CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats-x86_64.lib"
+// CHECK-CFI-STATS-WIN64: "--dependent-lib=clang_rt.stats_client-x86_64.lib"
+// CHECK-CFI-STATS-WIN64: "--dependent-lib=clang_rt.stats-x86_64.lib"
 // CHECK-CFI-STATS-WIN64: "--linker-option=/include:__sanitizer_stats_register"
 
 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
 // RUN: -target i686-pc-windows \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN32 %s
-// CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats_client-i386.lib"
-// CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats-i386.lib"
+// CHECK-CFI-STATS-WIN32: "--dependent-lib=clang_rt.stats_client-i386.lib"
+// CHECK-CFI-STATS-WIN32: "--dependent-lib=clang_rt.stats-i386.lib"
 // CHECK-CFI-STATS-WIN32: "--linker-option=/include:___sanitizer_stats_register"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -67,11 +67,11 @@
 
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
-// CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+// CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib=clang_rt.profile-{{[^"]*}}.lib"
 // CHECK-PROFILE-INSTR-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 
 // RUN: %clang_cl -### /FA -fprofile-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib=clang_rt.profile-{{[^"]*}}.lib"
 
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -350,6 +350,16 @@
   Args.MakeArgString(std::stri

[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-03-12 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp:57
+   "::std::map::lower_bound;"
+   "::std::move;"
+   "::std::multimap::equal_range;"

This will also affect "the other std::move" 
(https://en.cppreference.com/w/cpp/algorithm/move).



Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp:98
+   "::access;"
+   "::bind;"
+   "::connect;"

bind has a side effect and returns a success status. Thus, the result being 
unused isn't necessarily a bug. Same for `connect`. And probably for `setjmp` 
as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76083/new/

https://reviews.llvm.org/D76083



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


[PATCH] D76088: [Sema][SVE] Don't allow sizeless objects to be thrown

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

In D76088#1920241 , @efriedma wrote:

> We already have a special case for void* here; it's trivial to extend that to 
> also check for sizeless types. I don't want to add weird semantic 
> restrictions just to save a few characters in the compiler.


OK, I've done that in v2.  It didn't feel right to add a `Ty->isSizelessType()` 
check alongside the existing `Ty->isVoidType()` check because sizelessness is 
IMO logically orthogonal to whether we have a fully fleshed-out definition or 
not.  E.g. an earlier version of the extension allowed sizeless structures, and 
although they are no longer supported, the principle still holds that forward 
declarations of sizeless types make just as much conceptual sense as forward 
declarations of sized types.  We'd then want to treat pointers to 
incompletely-defined sizeless types in the same as pointers to 
incompletely-defined sized types.  The patch therefore checks for a sizeless 
type after `RequireCompleteType` instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76088/new/

https://reviews.llvm.org/D76088



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

In D72675#1920309 , @lebedev.ri wrote:

> I may be wrong, but i suspect those failures aren't actually due to the fact
>  that we pessimize optimizations with this change, but that the whole 
> execution
>  just fails. Can you try running test-suite locally? Do tests themselves 
> actually pass,
>  ignoring the question of their performance?


I find the LNT output very hard to decipher, but I thought that all of the 
failures on the Broadwell (x86) LNT bot were just performance regressions. 
There were many perf improvements and also many regressions. I investigated the 
top regression and found that the loop unroller made a different decision when 
the llvm.fmuladd intrinsic was used than it did for separate mul and add 
operations. The central loop of the test was unrolled eight times rather than 
four. Broadwell gets less benefit from FMA than either Haswell or Skylake, so 
any other factors that might drop performance are less likely to be mitigated 
by having fused these operations. In a more general sense, I don't see any 
reason apart from secondary changes in compiler behavior like this that 
allowing FMA would cause performance to drop.

At least one other target had execution failures caused by Melanie's change, 
but I understood it to be simply exposing a latent problem in the 
target-specific code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72675/new/

https://reviews.llvm.org/D72675



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


[PATCH] D76088: [Sema][SVE] Don't allow sizeless objects to be thrown

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 250066.
rsandifo-arm added a comment.

Allow pointers to sizeless types to be thrown.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76088/new/

https://reviews.llvm.org/D76088

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -395,6 +395,9 @@
   local_int16 = static_cast(local_int8); // expected-error 
{{static_cast from 'svint8_t' (aka '__SVInt8_t') to 'svint16_t' (aka 
'__SVInt16_t') is not allowed}}
   sel = static_cast(local_int8);   // expected-error 
{{static_cast from 'svint8_t' (aka '__SVInt8_t') to 'int' is not allowed}}
 
+  throw local_int8; // expected-error {{cannot throw object of sizeless type 
'svint8_t'}}
+  throw global_int8_ptr;
+
   local_int8.~__SVInt8_t(); // expected-error {{object expression of 
non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a 
pseudo-destructor expression}}
 
   (void)svint8_t();
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -956,6 +956,11 @@
 E->getSourceRange()))
   return true;
 
+if (!isPointer && Ty->isSizelessType()) {
+  Diag(ThrowLoc, diag::err_throw_sizeless) << Ty << E->getSourceRange();
+  return true;
+}
+
 if (RequireNonAbstractType(ThrowLoc, ExceptionObjectTy,
diag::err_throw_abstract_type, E))
   return true;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7117,6 +7117,8 @@
   "cannot throw object of incomplete type %0">;
 def err_throw_incomplete_ptr : Error<
   "cannot throw pointer to object of incomplete type %0">;
+def err_throw_sizeless : Error<
+  "cannot throw object of sizeless type %0">;
 def warn_throw_underaligned_obj : Warning<
   "underaligned exception object thrown">,
   InGroup;


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -395,6 +395,9 @@
   local_int16 = static_cast(local_int8); // expected-error {{static_cast from 'svint8_t' (aka '__SVInt8_t') to 'svint16_t' (aka '__SVInt16_t') is not allowed}}
   sel = static_cast(local_int8);   // expected-error {{static_cast from 'svint8_t' (aka '__SVInt8_t') to 'int' is not allowed}}
 
+  throw local_int8; // expected-error {{cannot throw object of sizeless type 'svint8_t'}}
+  throw global_int8_ptr;
+
   local_int8.~__SVInt8_t(); // expected-error {{object expression of non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a pseudo-destructor expression}}
 
   (void)svint8_t();
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -956,6 +956,11 @@
 E->getSourceRange()))
   return true;
 
+if (!isPointer && Ty->isSizelessType()) {
+  Diag(ThrowLoc, diag::err_throw_sizeless) << Ty << E->getSourceRange();
+  return true;
+}
+
 if (RequireNonAbstractType(ThrowLoc, ExceptionObjectTy,
diag::err_throw_abstract_type, E))
   return true;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7117,6 +7117,8 @@
   "cannot throw object of incomplete type %0">;
 def err_throw_incomplete_ptr : Error<
   "cannot throw pointer to object of incomplete type %0">;
+def err_throw_sizeless : Error<
+  "cannot throw object of sizeless type %0">;
 def warn_throw_underaligned_obj : Warning<
   "underaligned exception object thrown">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76087: [Sema][SVE] Reject sizeless types in exception specs

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm updated this revision to Diff 250062.
rsandifo-arm added a comment.

Allow pointers to sizeless types to be thrown.

In response to Eli's comments in D76088 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76087/new/

https://reviews.llvm.org/D76087

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -345,6 +345,12 @@
 constexpr int ce_taking_int8(svint8_t) { return 1; } // expected-error 
{{constexpr function's 1st parameter type 'svint8_t' (aka '__SVInt8_t') is not 
a literal type}}
 #endif
 
+#if __cplusplus < 201703L
+void throwing_func() throw(svint8_t); // expected-error {{sizeless type 
'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+void throwing_pointer_func() throw(svint8_t *);
+void throwing_reference_func() throw(svint8_t &); // expected-error 
{{reference to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in 
exception specification}}
+#endif
+
 template 
 void template_fn_direct(T) {}
 template 
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -167,6 +167,14 @@
   RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range))
 return ReturnValueOnError;
 
+  // The MSVC compatibility mode doesn't extend to sizeless types,
+  // so diagnose them separately.
+  if (PointeeT->isSizelessType() && Kind != 1) {
+Diag(Range.getBegin(), diag::err_sizeless_in_exception_spec)
+<< (Kind == 2 ? 1 : 0) << PointeeT << Range;
+return true;
+  }
+
   return false;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1534,6 +1534,9 @@
 def err_incomplete_in_exception_spec : Error<
   "%select{|pointer to |reference to }0incomplete type %1 is not allowed "
   "in exception specification">;
+def err_sizeless_in_exception_spec : Error<
+  "%select{|reference to }0sizeless type %1 is not allowed "
+  "in exception specification">;
 def ext_incomplete_in_exception_spec : 
ExtWarn,
   InGroup;
 def err_rref_in_exception_spec : Error<


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -345,6 +345,12 @@
 constexpr int ce_taking_int8(svint8_t) { return 1; } // expected-error {{constexpr function's 1st parameter type 'svint8_t' (aka '__SVInt8_t') is not a literal type}}
 #endif
 
+#if __cplusplus < 201703L
+void throwing_func() throw(svint8_t); // expected-error {{sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+void throwing_pointer_func() throw(svint8_t *);
+void throwing_reference_func() throw(svint8_t &); // expected-error {{reference to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+#endif
+
 template 
 void template_fn_direct(T) {}
 template 
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -167,6 +167,14 @@
   RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range))
 return ReturnValueOnError;
 
+  // The MSVC compatibility mode doesn't extend to sizeless types,
+  // so diagnose them separately.
+  if (PointeeT->isSizelessType() && Kind != 1) {
+Diag(Range.getBegin(), diag::err_sizeless_in_exception_spec)
+<< (Kind == 2 ? 1 : 0) << PointeeT << Range;
+return true;
+  }
+
   return false;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1534,6 +1534,9 @@
 def err_incomplete_in_exception_spec : Error<
   "%select{|pointer to |reference to }0incomplete type %1 is not allowed "
   "in exception specification">;
+def err_sizeless_in_exception_spec : Error<
+  "%select{|reference to }0sizeless type %1 is not allowed "
+  "in exception specification">;
 def ext_incomplete_in_exception_spec : ExtWarn,
   InGroup;
 def err_rref_in_exception_spec : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75901: [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D75901#1916119 , @tetsuo-cpp wrote:

> @njames93 @MaskRay 
>  Thanks for helping me with testing. I'll remember this for next time.
>
> I also saw this pattern of retrieving `LangOptions` from an `ASTContext` in 
> some other checks (`RedundantExpressionCheck` and `StaticAssertCheck`) but I 
> didn't change them to use `getLangOpts` since the `ASTContext` is used for 
> other stuff.


Its also not a good idea to change unrelated code in a review


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75901/new/

https://reviews.llvm.org/D75901



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


[PATCH] D76100: Debug Info: Store the SDK in the DICompileUnit.

2020-03-12 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.
aprantl added reviewers: davide, shafik, teemperor, JDevlieghere.
aprantl added a project: debug-info.
Herald added a subscriber: ormris.

This is another intermediate step for PR44213 
(https://bugs.llvm.org/show_bug.cgi?id=44213).

  

This stores the SDK *name* in the debug info, to make it possible to 
`-fdebug-prefix-map`-replace the sysroot with a recognizable string and 
allowing the debugger to find a fitting SDK relative to itself, not the machine 
the executable was compiled on.

  

rdar://problem/51645582


https://reviews.llvm.org/D76100

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-sysroot-sdk.c
  clang/test/CodeGen/debug-info-sysroot.c


Index: clang/test/CodeGen/debug-info-sysroot.c
===
--- clang/test/CodeGen/debug-info-sysroot.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -isysroot /CLANG_SYSROOT -emit-llvm -o - \
-// RUN:   -debugger-tuning=lldb | FileCheck %s --check-prefix=LLDB
-// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -isysroot /CLANG_SYSROOT -emit-llvm -o - \
-// RUN:   -debugger-tuning=gdb | FileCheck %s --check-prefix=GDB
-
-void foo() {}
-
-// The sysroot is an LLDB-tuning-specific attribute.
-
-// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT"
-// GDB: distinct !DICompileUnit(
-// GDB-NOT: sysroot: "/CLANG_SYSROOT"
-
Index: clang/test/CodeGen/debug-info-sysroot-sdk.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-sysroot-sdk.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -isysroot /CLANG_SYSROOT/MacOSX.sdk -emit-llvm -o - \
+// RUN:   -debugger-tuning=lldb | FileCheck %s --check-prefix=LLDB
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -isysroot /CLANG_SYSROOT/MacOSX.sdk -emit-llvm -o - \
+// RUN:   -debugger-tuning=gdb | FileCheck %s --check-prefix=GDB
+
+void foo() {}
+
+// The sysroot and sdk are a LLDB-tuning-specific attributes.
+
+// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT/MacOSX.sdk",
+// LLDB-SAME:  sdk: "MacOSX.sdk"
+// GDB: distinct !DICompileUnit(
+// GDB-NOT: sysroot: "/CLANG_SYSROOT/MacOSX.sdk"
+// GDB-NOT: sdk: "MacOSX.sdk"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -611,9 +611,15 @@
   remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
   getSource(SM, SM.getMainFileID()));
 
-  StringRef Sysroot;
-  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB)
+  StringRef Sysroot, SDK;
+  if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {
 Sysroot = CGM.getHeaderSearchOpts().Sysroot;
+auto B = llvm::sys::path::rbegin(Sysroot);
+auto E = llvm::sys::path::rend(Sysroot);
+auto It = std::find_if(B, E, [](auto SDK) { return SDK.endswith(".sdk"); 
});
+if (It != E)
+  SDK = *It;
+  }
 
   // Create new compile unit.
   TheCU = DBuilder.createCompileUnit(
@@ -625,7 +631,7 @@
   ? llvm::DICompileUnit::DebugNameTableKind::None
   : static_cast(
 CGOpts.DebugNameTable),
-  CGOpts.DebugRangesBaseAddress, Sysroot);
+  CGOpts.DebugRangesBaseAddress, Sysroot, SDK);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {


Index: clang/test/CodeGen/debug-info-sysroot.c
===
--- clang/test/CodeGen/debug-info-sysroot.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -isysroot /CLANG_SYSROOT -emit-llvm -o - \
-// RUN:   -debugger-tuning=lldb | FileCheck %s --check-prefix=LLDB
-// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
-// RUN:   %s -isysroot /CLANG_SYSROOT -emit-llvm -o - \
-// RUN:   -debugger-tuning=gdb | FileCheck %s --check-prefix=GDB
-
-void foo() {}
-
-// The sysroot is an LLDB-tuning-specific attribute.
-
-// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT"
-// GDB: distinct !DICompileUnit(
-// GDB-NOT: sysroot: "/CLANG_SYSROOT"
-
Index: clang/test/CodeGen/debug-info-sysroot-sdk.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-sysroot-sdk.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -isysroot /CLANG_SYSROOT/MacOSX.sdk -emit-llvm -o - \
+// RUN:   -debugger-tuning=lldb | FileCheck %s --check-prefix=LLDB
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   %s -isysroot /CLANG_SYS

[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75563/new/

https://reviews.llvm.org/D75563



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


[PATCH] D72872: [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2020-03-12 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72872/new/

https://reviews.llvm.org/D72872



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


[PATCH] D76099: [Clang][Driver] In -fintegrated-cc1 mode, avoid crashing on exit after a compiler crash

2020-03-12 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: rnk, hans, hubert.reinterpretcast, daltenty.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

As reported here: https://reviews.llvm.org/D69825#1916865 and in PR45164, in 
case of a compiler crash, Clang now reports a second crash related to 
TimerGroups. The crash is caused by the TimerGroup's internal linked list which 
still points to already freed stack frames, which were unwind by `longjmp()` 
(or SEH on Windows) after the first compiler crash.

There's a second crash, not seen in PR45164, which happens when `llvm_shutdown` 
is called: the static `DefaultTimerGroup` object is destroyed which causes more 
iterating through the TimerGroups.

With this patch, we now 'steal' the `TimeGroup` instance from 
`DefaultTimerGroup` and prevent any further iteration of the timers after the 
initial crash.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76099

Files:
  clang/lib/Lex/Pragma.cpp
  clang/tools/driver/driver.cpp
  llvm/include/llvm/Support/ManagedStatic.h
  llvm/include/llvm/Support/Timer.h
  llvm/lib/Support/Timer.cpp

Index: llvm/lib/Support/Timer.cpp
===
--- llvm/lib/Support/Timer.cpp
+++ llvm/lib/Support/Timer.cpp
@@ -442,3 +442,7 @@
 void TimerGroup::ConstructTimerLists() {
   (void)*NamedGroupedTimers;
 }
+
+std::unique_ptr TimerGroup::aquireDefaultGroup() {
+  return std::unique_ptr(DefaultTimerGroup.claim());
+}
Index: llvm/include/llvm/Support/Timer.h
===
--- llvm/include/llvm/Support/Timer.h
+++ llvm/include/llvm/Support/Timer.h
@@ -230,6 +230,11 @@
   /// used by the Statistic code to influence the construction and destruction
   /// order of the global timer lists.
   static void ConstructTimerLists();
+
+  /// This makes the default group unmanaged, and lets the user manage the
+  /// group's lifetime.
+  static std::unique_ptr aquireDefaultGroup();
+
 private:
   friend class Timer;
   friend void PrintStatisticsJSON(raw_ostream &OS);
Index: llvm/include/llvm/Support/ManagedStatic.h
===
--- llvm/include/llvm/Support/ManagedStatic.h
+++ llvm/include/llvm/Support/ManagedStatic.h
@@ -102,6 +102,12 @@
   }
 
   const C *operator->() const { return &**this; }
+
+  // Extract the instance, leaving the ManagedStatic uninitialized. The
+  // user is then responsible for the lifetime of the returned instance.
+  C *claim() {
+return static_cast(Ptr.exchange(nullptr));
+  }
 };
 
 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -491,6 +492,7 @@
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
   int Res = 1;
+  bool IsCrash = false;
   if (C && !C->containsError()) {
 SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
@@ -517,11 +519,11 @@
   // If result status is 70, then the driver command reported a fatal error.
   // On Windows, abort will return an exit code of 3.  In these cases,
   // generate additional diagnostic information if possible.
-  bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+  IsCrash = CommandRes < 0 || CommandRes == 70;
 #ifdef _WIN32
-  DiagnoseCrash |= CommandRes == 3;
+  IsCrash |= CommandRes == 3;
 #endif
-  if (DiagnoseCrash) {
+  if (IsCrash) {
 TheDriver.generateCompilationDiagnostics(*C, *FailingCommand);
 break;
   }
@@ -530,10 +532,16 @@
 
   Diags.getClient()->finish();
 
-  // If any timers were active but haven't been destroyed yet, print their
-  // results now.  This happens in -disable-free mode.
-  llvm::TimerGroup::printAll(llvm::errs());
-  llvm::TimerGroup::clearAll();
+  if (!UseNewCC1Process && IsCrash) {
+// When crashing in -fintegrated-cc1 mode, bury the timer pointers, because
+// the internal linked list might point to already released stack frames.
+llvm::BuryPointer(llvm::TimerGroup::aquireDefaultGroup());
+  } else {
+// If any timers were active but haven't been destroyed yet, print their
+// results now.  This happens in -disable-free mode.
+llvm::TimerGroup::printAll(llvm::errs());
+llvm::TimerGroup::clearAll();
+  }
 
 #ifdef _WIN32
   // Exit status should not be negative on Win32, unless abnormal termination.
Index: clang/lib/Lex/Pragma.cpp
=

[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-12 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! Do you need someone to commit on your behalf?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70265/new/

https://reviews.llvm.org/D70265



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


[PATCH] D76098: [WIP] [clangd] Do not trigger go-to-def textual fallback inside string literals

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

This is my attempt to avoid triggering the textual fallback for string 
literals, as per the discussion in the issue 
.

To classify tokens into the categories discussed in the issue, I resurrected 
and modified the `getTokenFlavor()` function that was removed in D75176 
.

However, it does not seem to be working as I expect -- `Lexer::getRawToken()` 
is returning `TokenKind::raw_identifier` inside the string literal rather than 
`TokenKind::string_literal`.

Am I misunderstanding how this API is supposed to work? I thought "raw" meant 
"no preprocessor", and things like string literals would still be recognized in 
raw mode.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76098/new/

https://reviews.llvm.org/D76098



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


[PATCH] D76054: [clang-apply-replacements] No longer deduplucates replacements from the same TU

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 250054.
njames93 added a comment.

- Added test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76054/new/

https://reviews.llvm.org/D76054

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/file1.yaml
  clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/file2.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/identical2.cpp
  clang-tools-extra/test/clang-apply-replacements/identical2.cpp

Index: clang-tools-extra/test/clang-apply-replacements/identical2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/identical2.cpp
@@ -0,0 +1,10 @@
+// RUN: mkdir -p %T/Inputs/identical2
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/identical2/identical2.cpp > %T/Inputs/identical2/identical2.cpp
+// RUN: sed "s#\$(path)#%/T/Inputs/identical2#" %S/Inputs/identical2/file1.yaml > %T/Inputs/identical2/file1.yaml
+// RUN: sed "s#\$(path)#%/T/Inputs/identical2#" %S/Inputs/identical2/file2.yaml > %T/Inputs/identical2/file2.yaml
+// RUN: clang-apply-replacements %T/Inputs/identical2
+// RUN: FileCheck -input-file=%T/Inputs/identical2/identical2.cpp %S/Inputs/identical2/identical2.cpp
+
+// Similar to identical test but each yaml file contains the same fix twice. 
+// This check ensures that only the duplicated replacements in a single yaml 
+// file are applied twice. Addresses PR45150.
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/identical2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/identical2.cpp
@@ -0,0 +1,2 @@
+class MyType {};
+// CHECK: class MyType00 {};
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/file2.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/file2.yaml
@@ -0,0 +1,19 @@
+---
+MainSourceFile: identical2.cpp
+Diagnostics:
+  - DiagnosticName: test-identical-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/identical2.cpp
+  FileOffset: 12
+  Replacements:
+- FilePath:$(path)/identical2.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+- FilePath:$(path)/identical2.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+...
+
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/file1.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/identical2/file1.yaml
@@ -0,0 +1,19 @@
+---
+MainSourceFile: identical2.cpp
+Diagnostics:
+  - DiagnosticName: test-identical-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/identical2.cpp
+  FileOffset: 12
+  Replacements:
+- FilePath:$(path)/identical2.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+- FilePath:$(path)/identical2.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+...
+
Index: clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -145,16 +145,21 @@
 
   // Deduplicate identical replacements in diagnostics.
   // FIXME: Find an efficient way to deduplicate on diagnostics level.
-  llvm::DenseMap>
+  llvm::DenseMap>
   DiagReplacements;
 
-  auto AddToGroup = [&](const tooling::Replacement &R, bool FromDiag) {
+  auto AddToGroup = [&](const tooling::Replacement &R,
+const tooling::TranslationUnitDiagnostics *FromTU) {
 // Use the file manager to deduplicate paths. FileEntries are
 // automatically canonicalized.
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
-  if (FromDiag) {
+  if (FromTU) {
 auto &Replaces = DiagReplacements[*Entry];
-if (!Replaces.insert(R).second)
+if (Replaces.find(R) == Replaces.end())
+  Replaces.emplace(R, FromTU);
+else if (Replaces.at(R) != FromTU)
   return;
   }
   GroupedReplacements[*Entry].push_back(R);
@@ -166,14 +171,14 @@
 
   for (const auto &TU : TUs)
 for (const tooling::Replacement &R : TU.Replacements)
-  AddToGroup(R, false);
+  AddToGroup(R, nullptr);
 
   for (const auto &TU : TUDs)
 for (const auto &D : TU.Diagnos

[PATCH] D75542: [Sema] Prevent UB for uninitialized `IsSurrogate`

2020-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Sorry for the delay in review, but I believe this was already fixed in the 
meantime: 
https://github.com/llvm/llvm-project/commit/a5704f92b835d1810d83a223f70dfe6c92a34c03


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75542/new/

https://reviews.llvm.org/D75542



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-12 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka added a comment.

LGTM
I was able to build with these changes successfully on the local builder host.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74347/new/

https://reviews.llvm.org/D74347



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


[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 250053.
njames93 marked 6 inline comments as done.
njames93 added a comment.

- Extend tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76037/new/

https://reviews.llvm.org/D76037

Files:
  clang-tools-extra/clang-apply-replacements/CMakeLists.txt
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/ReplacementsYaml.cpp
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,34 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\ \a \b \f \n \r \t \v");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_FALSE(IYAML.error());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  for (auto DocR = Doc.Replacements.begin(),
+NewDocR = NewDoc.Replacements.begin(),
+DocE = Doc.Replacements.end();
+   DocR != DocE; DocR++, NewDocR++) {
+ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
@@ -120,3 +126,53 @@
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
   ASSERT_EQ("replacement", DocActual.Replacements[0].getReplacementText());
 }
+
+TEST(ReplacementsYamlTest, deserializesEscapedReplacements) {
+  StringRef YamlContent =
+  "---\n"
+  "MainSourceFile:  /path/to/source.cpp\n"
+  "Replacements:\n"
+  "  - FilePath:/path/to/file1.h\n"
+  "Offset:  232\n"
+  "Length:  56\n"
+  "ReplacementText: ' \\a \\b \\f \\n \\r \\t \\v'\n"
+  "...\n";
+  TranslationUnitReplacements DocActual;
+  yaml::Input YAML(YamlContent);
+  YAML >> DocActual;
+  ASSERT_FALSE(YAML.error());
+  ASSERT_EQ(1u, DocActual.Replacements.size());
+  ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
+  ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
+  ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
+  ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
+  ASSERT_EQ("\\ \a \b \f \n \r \t \v",
+DocActual.Replacements[0].getReplacementText());
+}
+
+TEST(ReplacementsYamlTest, serializesEscapingReplacements) {
+
+  TranslationUnitReplacements Doc;
+
+  Doc.MainSourceFile = "/path/to/source.cpp";
+  Doc.Replacements.emplace_back("/path/to/file1.h", 232, 56,
+"\\ \a \b \f \n \r \t \v");
+
+  SmallString<256> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
+
+  yaml::Output YAML(YamlContentStream);
+  YAML << Doc;
+
+  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
+  ASSERT_EQ(
+  StringRef("---\n"
+"MainSourceFile:  '/path/to/source.cpp'\n"
+"Replacements:\n"
+"  - FilePath:'/path/to/file1.h'\n"
+"Offset:  232\n"
+"Length:  56\n"
+"ReplacementText: ' \\a \\b \\f \\n \\r \\t \\v'\n"
+"...\n"),
+  YamlContentStream.str());
+}
Index: clang/lib/Tooling/ReplacementsYaml.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ReplacementsYaml.cpp
@@ -0,0 +1,7

[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/lib/Tooling/ReplacementsYaml.cpp:22
+static constexpr Escapes EscapeChars[] = {
+{'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+

AlexanderLanin wrote:
> Just so I have asked ;-)
> Escaping every \ would be incorrect? Basically duplicate every '\'.
You need to escape the escape character to avoid ambiguity when unescaping later

Say the code has the raw string which is `\` followed by `n`. it would be 
escaped as `\n`.
Then when it comes to unescape it will read `\n` as a newline.
Escaping the `\` leads to the output being `\\n` which will be read back as a 
`\` followed by `n`.



Comment at: clang/unittests/Tooling/ReplacementsYamlTest.cpp:55
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 

AlexanderLanin wrote:
> I think it would be worthwhile to test other characters as well.
> 50% of that would be purely for documentation purposes. What would happen 
> when you escape \x and unescape \\x?
I have added all the c++ escape characters apart from `\'` as that is handled 
in the yaml string parser anyway and `\"` as that seems to be ignore anyway



Comment at: clang/unittests/Tooling/ReplacementsYamlTest.cpp:76
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}

AlexanderLanin wrote:
> I assume this kind of test would have been green even without your change? Or 
> would it fail?
> You are testing that it is reconstructed correctly (which is indeed the main 
> point), but not the escaping and unescaping.
> You should probably test a concrete example with(escaped text, expected 
> escaped test).
Yes this should've passed before however the issue was one more of readability. 
Things like the old double newline just look confusing whereas every programmer 
knows that '\n' is code for newline.
I have planned to add that in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76037/new/

https://reviews.llvm.org/D76037



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


[PATCH] D76098: [WIP] [clangd] Do not trigger go-to-def textual fallback inside string literals

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76098

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -624,11 +624,12 @@
 TEST(LocateSymbol, Textual) {
   const char *Tests[] = {
   R"cpp(// Comment
-struct [[MyClass]] {};
-// Comment mentioning M^yClass
-  )cpp",
+  struct [[MyClass]] {};
+  // Comment mentioning M^yClass
+)cpp",
   R"cpp(// String
-struct [[MyClass]] {};
+struct MyClass {};
+// Not triggered for string literal tokens.
 const char* s = "String literal mentioning M^yClass";
   )cpp",
   R"cpp(// Ifdef'ed out code
@@ -680,7 +681,7 @@
   EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
 }
   }
-}
+} // namespace
 
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -355,6 +355,20 @@
   return !WordExpandedTokens.empty();
 }
 
+enum TokenFlavor { Identifier, Comment, Other };
+
+TokenFlavor getTokenFlavor(SourceLocation Loc, const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  Token Tok;
+  if (Lexer::getRawToken(Loc, Tok, SM, LangOpts))
+return Other;
+  if (Tok.is(tok::TokenKind::raw_identifier))
+return Identifier;
+  if (Tok.is(tok::TokenKind::comment))
+return Comment;
+  return Other;
+}
+
 } // namespace
 
 std::vector
@@ -363,6 +377,11 @@
  const std::string &MainFilePath) {
   const auto &SM = AST.getSourceManager();
 
+  TokenFlavor Flavor = getTokenFlavor(Loc, SM, AST.getLangOpts());
+  // Only consider comment and (raw) identifier tokens.
+  if (!(Flavor == TokenFlavor::Comment || Flavor == TokenFlavor::Identifier))
+return {};
+
   // Get the raw word at the specified location.
   unsigned Pos;
   FileID File;
@@ -374,12 +393,14 @@
   unsigned WordOffset = Word.data() - Code.data();
   SourceLocation WordStart = SM.getComposedLoc(File, WordOffset);
 
-  // Do not consider tokens that survived preprocessing.
-  // We are erring on the safe side here, as a user may expect to get
-  // accurate (as opposed to textual-heuristic) results for such tokens.
+  // If this is an identifier token, do not consider if it it survived
+  // preprocessing. We are erring on the safe side here, as a user may expect 
to
+  // get accurate (as opposed to textual-heuristic) results for such tokens.
   // FIXME: Relax this for dependent code.
-  if (tokenSurvivedPreprocessing(WordStart, AST.getTokens()))
+  if (Flavor == TokenFlavor::Identifier &&
+  tokenSurvivedPreprocessing(WordStart, AST.getTokens())) {
 return {};
+  }
 
   // Additionally filter for signals that the word is likely to be an
   // identifier. This avoids triggering on e.g. random words in a comment.


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -624,11 +624,12 @@
 TEST(LocateSymbol, Textual) {
   const char *Tests[] = {
   R"cpp(// Comment
-struct [[MyClass]] {};
-// Comment mentioning M^yClass
-  )cpp",
+  struct [[MyClass]] {};
+  // Comment mentioning M^yClass
+)cpp",
   R"cpp(// String
-struct [[MyClass]] {};
+struct MyClass {};
+// Not triggered for string literal tokens.
 const char* s = "String literal mentioning M^yClass";
   )cpp",
   R"cpp(// Ifdef'ed out code
@@ -680,7 +681,7 @@
   EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
 }
   }
-}
+} // namespace
 
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -355,6 +355,20 @@
   return !WordExpandedTokens.empty();
 }
 
+enum TokenFlavor { Identifier, Comment, Other };
+
+TokenFlavor getTokenFlavor(SourceLocation Loc, const SourceManager &SM,
+   const LangOptions &LangOpts) {
+  Token Tok;
+  if (Lexer::getRawToken(Loc, Tok, SM, LangOpts))
+return Other;
+  if (Tok.is(tok::TokenKind::raw_identifier))
+return Identifier;
+  if (Tok.is(tok::TokenKind::comment))

[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-12 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.

Aside from the diagnostic wording, I think this LG to me. However, I'd 
appreciate if @rjmccall would also sign off.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5344
+def err_loader_uninitialized_extern_decl : Error<
+  "external declaration of variable cannot have the 'loader_uninitialized' 
attribute">;
 def err_block_extern_cant_init : Error<

How would you feel about: `"variable %0 cannot be declared both 'extern' and 
with the 'loader_uninitialized' attribute"` (or something along those lines) to 
clarify "external declaration"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74361/new/

https://reviews.llvm.org/D74361



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


[PATCH] D76097: improve performance of getSDKName()

2020-03-12 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.
aprantl added a reviewer: arphaman.
Herald added a subscriber: dexonsmith.

The ".sdk" component is usually the last one in the -isysroot, so it makes more 
sense to scan from the back. Also, technically, someone could install Xcode 
into a directory ending with .sdk, which would break this heuristic.


https://reviews.llvm.org/D76097

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


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1068,8 +1068,8 @@
 
 StringRef Darwin::getSDKName(StringRef isysroot) {
   // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
-  auto BeginSDK = llvm::sys::path::begin(isysroot);
-  auto EndSDK = llvm::sys::path::end(isysroot);
+  auto BeginSDK = llvm::sys::path::rbegin(isysroot);
+  auto EndSDK = llvm::sys::path::rend(isysroot);
   for (auto IT = BeginSDK; IT != EndSDK; ++IT) {
 StringRef SDK = *IT;
 if (SDK.endswith(".sdk"))


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1068,8 +1068,8 @@
 
 StringRef Darwin::getSDKName(StringRef isysroot) {
   // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
-  auto BeginSDK = llvm::sys::path::begin(isysroot);
-  auto EndSDK = llvm::sys::path::end(isysroot);
+  auto BeginSDK = llvm::sys::path::rbegin(isysroot);
+  auto EndSDK = llvm::sys::path::rend(isysroot);
   for (auto IT = BeginSDK; IT != EndSDK; ++IT) {
 StringRef SDK = *IT;
 if (SDK.endswith(".sdk"))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I may be wrong, but i suspect those failures aren't actually due to the fact
that we pessimize optimizations with this change, but that the whole execution
just fails. Can you try running test-suite locally? Do tests themselves 
actually pass,
ignoring the question of their performance?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72675/new/

https://reviews.llvm.org/D72675



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

Interesting, playing with this more in godbolt, it looks like the struct 
doesn't even have to be const qualified.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 250046.
nickdesaulniers added a comment.

- add 2 missing CHECKs


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/const-init.c
  clang/test/Sema/init.c


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -160,3 +160,22 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // 
expected-error {{initializer element is not a compile-time constant}}
+
+// PR45157
+struct PR4517_foo {};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {};
+struct PR4517_bar my_bar = {
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar3 = {
+my_foo, // no-warning
+};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){
+my_foo // no-warning
+};
Index: clang/test/CodeGen/const-init.c
===
--- clang/test/CodeGen/const-init.c
+++ clang/test/CodeGen/const-init.c
@@ -181,3 +181,20 @@
 #pragma pack()
   // CHECK: @g31.a = internal global %struct.anon.2 { i16 23122, i32 
-12312731, i16 -312 }, align 4
 }
+
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {.foo = my_foo};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){.foo = my_foo};
+struct PR4517_bar my_bar3 = {my_foo};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){my_foo};
+// CHECK: @my_foo = constant %struct.PR4517_foo { i32 42 }, align 4
+// CHECK: @my_bar = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar2 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar3 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar4 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1007,6 +1007,13 @@
 return Visit(PE->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitDeclRefExpr(DeclRefExpr *DRE, QualType T) {
+if (VarDecl *V = dyn_cast(DRE->getDecl()))
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;
+  }
+
   llvm::Constant *
   VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *PE,
 QualType T) {
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3158,6 +3158,13 @@
 
   switch (getStmtClass()) {
   default: break;
+  case DeclRefExprClass:
+if (!Ctx.getLangOpts().CPlusPlus && Ctx.getLangOpts().GNUMode) {
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;
+}
+break;
   case StringLiteralClass:
   case ObjCEncodeExprClass:
 return true;


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -160,3 +160,22 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // expected-error {{initializer element is not a compile-time constant}}
+
+// PR45157
+struct PR4517_foo {};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {};
+struct PR4517_bar my_bar = {
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar3 = {
+my_foo, // no-warning
+};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){
+my_foo // no-warning
+};
Index: clang/test/CodeGen/const-init.c
===
--- clang/test/CodeGen/const-init.c
+++ clang/test/CodeGen/const-init.c
@@ -181,3 +181,20 @@
 #pragma pack()
   // CHECK: @g31.a = internal global %struct.anon.2 { i16 23122, i32 -12312731, i16 -312 }, align 4
 }
+
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {.foo = my_foo};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){.foo = my_foo};
+struct PR4517_bar my_bar3 = {my_foo};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){my_foo};
+// CHECK: @my_foo = constant %struct.PR4517_foo { i32 42 }, align 4
+// CHECK: @my_bar 

[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as not done.
nickdesaulniers added inline comments.



Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

nickdesaulniers wrote:
> Interesting, playing with this more in godbolt, it looks like the struct 
> doesn't even have to be const qualified.
Or, rather, behaves differently between C and C++ mode;

C -> const required
C++ -> const not required


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76096/new/

https://reviews.llvm.org/D76096



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


[PATCH] D76096: [clang] allow const structs to be constant expressions in initializer lists

2020-03-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: eli.friedman, aaron.ballman, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nickdesaulniers updated this revision to Diff 250046.
nickdesaulniers added a comment.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added subscribers: void, jyknight.
nickdesaulniers marked an inline comment as not done.

- add 2 missing CHECKs




Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

Interesting, playing with this more in godbolt, it looks like the struct 
doesn't even have to be const qualified.



Comment at: clang/lib/AST/Expr.cpp:3164
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;

nickdesaulniers wrote:
> Interesting, playing with this more in godbolt, it looks like the struct 
> doesn't even have to be const qualified.
Or, rather, behaves differently between C and C++ mode;

C -> const required
C++ -> const not required


This seems to be an undocumented GNU C extension.

For code like:
struct foo { ... };
struct bar { struct foo foo; };
struct foo my_foo = { ... };
struct bar my_bar = { .foo = my_foo };

during CodeGen of LLVM IR, copy the initializer of `my_foo` into the
initializer of `my_bar` recursively.

Eli Friedman points out the relevant part of the C standard seems to
have some flexibility in what is considered a constant expression:

6.6 paragraph 10:
An implementation may accept other forms of constant expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76096

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/const-init.c
  clang/test/Sema/init.c


Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -160,3 +160,22 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // 
expected-error {{initializer element is not a compile-time constant}}
+
+// PR45157
+struct PR4517_foo {};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {};
+struct PR4517_bar my_bar = {
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar3 = {
+my_foo, // no-warning
+};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){
+my_foo // no-warning
+};
Index: clang/test/CodeGen/const-init.c
===
--- clang/test/CodeGen/const-init.c
+++ clang/test/CodeGen/const-init.c
@@ -181,3 +181,20 @@
 #pragma pack()
   // CHECK: @g31.a = internal global %struct.anon.2 { i16 23122, i32 
-12312731, i16 -312 }, align 4
 }
+
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {.foo = my_foo};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){.foo = my_foo};
+struct PR4517_bar my_bar3 = {my_foo};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){my_foo};
+// CHECK: @my_foo = constant %struct.PR4517_foo { i32 42 }, align 4
+// CHECK: @my_bar = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar2 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar3 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar4 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1007,6 +1007,13 @@
 return Visit(PE->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitDeclRefExpr(DeclRefExpr *DRE, QualType T) {
+if (VarDecl *V = dyn_cast(DRE->getDecl()))
+  if (V->hasInit())
+return Visit(V->getInit(), V->getType());
+return nullptr;
+  }
+
   llvm::Constant *
   VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *PE,
 QualType T) {
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3158,6 +3158,13 @@
 
   switch (getStmtClass()) {
   default: break;
+  case DeclRefExprClass:
+if (!Ctx.getLangOpts().CPlusPlus && Ctx.getLangOpts().GNUMode) {
+  const QualType &QT = cast(this)->getDecl()->getType();
+  if (QT->isStructureType() && QT.isConstQualified())
+return true;
+}
+break;
   case StringLiteralClass:
   c

[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc4cd43904df: [clangd] Add a textual fallback for 
go-to-definition (authored by sammccall, committed by nridge).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -38,6 +38,7 @@
 namespace {
 
 using ::testing::ElementsAre;
+using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAreArray;
@@ -353,7 +354,7 @@
   R"cpp(// Symbol concatenated inside macro (not supported)
int *pi;
#define POINTER(X) p ## X;
-   int i = *POINTER(^i);
+   int x = *POINTER(^i);
   )cpp",
 
   R"cpp(// Forward class declaration
@@ -606,6 +607,81 @@
   }
 }
 
+TEST(LocateSymbol, TextualSmoke) {
+  auto T = Annotations(
+  R"cpp(
+struct [[MyClass]] {};
+// Comment mentioning M^yClass
+  )cpp");
+
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
+  ElementsAre(Sym("MyClass", T.range(;
+}
+
+TEST(LocateSymbol, Textual) {
+  const char *Tests[] = {
+  R"cpp(// Comment
+struct [[MyClass]] {};
+// Comment mentioning M^yClass
+  )cpp",
+  R"cpp(// String
+struct [[MyClass]] {};
+const char* s = "String literal mentioning M^yClass";
+  )cpp",
+  R"cpp(// Ifdef'ed out code
+struct [[MyClass]] {};
+#ifdef WALDO
+  M^yClass var;
+#endif
+  )cpp",
+  R"cpp(// Macro definition
+struct [[MyClass]] {};
+#define DECLARE_MYCLASS_OBJ(name) M^yClass name;
+  )cpp",
+  R"cpp(// Invalid code
+/*error-ok*/
+int myFunction(int);
+// Not triggered for token which survived preprocessing.
+int var = m^yFunction();
+  )cpp",
+  R"cpp(// Dependent type
+struct Foo {
+  void uniqueMethodName();
+};
+template 
+void f(T t) {
+  // Not triggered for token which survived preprocessing.
+  t->u^niqueMethodName();
+}
+  )cpp"};
+
+  for (const char *Test : Tests) {
+Annotations T(Test);
+llvm::Optional WantDecl;
+if (!T.ranges().empty())
+  WantDecl = T.range();
+
+auto TU = TestTU::withCode(T.code());
+
+auto AST = TU.build();
+auto Index = TU.index();
+auto Results = locateSymbolNamedTextuallyAt(
+AST, Index.get(),
+cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
+testPath(TU.Filename));
+
+if (!WantDecl) {
+  EXPECT_THAT(Results, IsEmpty()) << Test;
+} else {
+  ASSERT_THAT(Results, ::testing::SizeIs(1)) << Test;
+  EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
+}
+  }
+}
+
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
 struct Foo {
@@ -680,6 +756,30 @@
Sym("baz", T.range("StaticOverload2";
 }
 
+TEST(LocateSymbol, TextualAmbiguous) {
+  auto T = Annotations(R"cpp(
+struct Foo {
+  void $FooLoc[[uniqueMethodName]]();
+};
+struct Bar {
+  void $BarLoc[[uniqueMethodName]]();
+};
+// Will call u^niqueMethodName() on t.
+template 
+void f(T t);
+  )cpp");
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  auto Results = locateSymbolNamedTextuallyAt(
+  AST, Index.get(),
+  cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
+  testPath(TU.Filename));
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
+   Sym("uniqueMethodName", T.range("BarLoc";
+}
+
 TEST(LocateSymbol, TemplateTypedefs) {
   auto T = Annotations(R"cpp(
 template  struct function {};
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -49,6 +49,21 @@
 std::vector locateSymbolAt(ParsedAST &AST, Position Pos,
   const SymbolIndex *Index = nullptr);
 
+// Tries to provide a textual fallback for locating a symbol referenced at
+// a location, by looking up the word under the cursor as a symbol name in the
+// index. The aim is to p

[PATCH] D74386: [SVE] Update API ConstantVector::getSplat() to use ElementCount.

2020-03-12 Thread Huihui Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG118abf201738: [SVE] Update API ConstantVector::getSplat() to 
use ElementCount. (authored by huihuiz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74386/new/

https://reviews.llvm.org/D74386

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/Analysis/Utils/Local.h
  llvm/include/llvm/IR/Constants.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/CodeGen/AArch64/scalable-vector-promotion.ll
  llvm/test/Transforms/InstSimplify/gep.ll
  llvm/unittests/FuzzMutate/OperationsTest.cpp
  llvm/unittests/IR/VerifierTest.cpp

Index: llvm/unittests/IR/VerifierTest.cpp
===
--- llvm/unittests/IR/VerifierTest.cpp
+++ llvm/unittests/IR/VerifierTest.cpp
@@ -57,7 +57,7 @@
   ConstantInt *CI = ConstantInt::get(ITy, 0);
 
   // Valid type : freeze(<2 x i32>)
-  Constant *CV = ConstantVector::getSplat(2, CI);
+  Constant *CV = ConstantVector::getSplat({2, false}, CI);
   FreezeInst *FI_vec = new FreezeInst(CV);
   FI_vec->insertBefore(RI);
 
Index: llvm/unittests/FuzzMutate/OperationsTest.cpp
===
--- llvm/unittests/FuzzMutate/OperationsTest.cpp
+++ llvm/unittests/FuzzMutate/OperationsTest.cpp
@@ -92,8 +92,8 @@
   ConstantStruct::get(StructType::create(Ctx, "OpaqueStruct"));
   Constant *a =
   ConstantArray::get(ArrayType::get(i32->getType(), 2), {i32, i32});
-  Constant *v8i8 = ConstantVector::getSplat(8, i8);
-  Constant *v4f16 = ConstantVector::getSplat(4, f16);
+  Constant *v8i8 = ConstantVector::getSplat({8, false}, i8);
+  Constant *v4f16 = ConstantVector::getSplat({4, false}, f16);
   Constant *p0i32 =
   ConstantPointerNull::get(PointerType::get(i32->getType(), 0));
 
Index: llvm/test/Transforms/InstSimplify/gep.ll
===
--- llvm/test/Transforms/InstSimplify/gep.ll
+++ llvm/test/Transforms/InstSimplify/gep.ll
@@ -103,3 +103,69 @@
   ret <8 x i64*> %el
 }
 
+; Check ConstantExpr::getGetElementPtr() using ElementCount for size queries - begin.
+
+; Constant ptr
+
+define i32* @ptr_idx_scalar() {
+; CHECK-LABEL: @ptr_idx_scalar(
+; CHECK-NEXT:ret i32* inttoptr (i64 4 to i32*)
+;
+  %gep = getelementptr <4 x i32>, <4 x i32>* null, i64 0, i64 1
+  ret i32* %gep
+}
+
+define <2 x i32*> @ptr_idx_vector() {
+; CHECK-LABEL: @ptr_idx_vector(
+; CHECK-NEXT:ret <2 x i32*> getelementptr (i32, i32* null, <2 x i64> )
+;
+  %gep = getelementptr i32, i32* null, <2 x i64> 
+  ret <2 x i32*> %gep
+}
+
+define <4 x i32*> @ptr_idx_mix_scalar_vector(){
+; CHECK-LABEL: @ptr_idx_mix_scalar_vector(
+; CHECK-NEXT:ret <4 x i32*> getelementptr ([42 x [3 x i32]], [42 x [3 x i32]]* null, <4 x i64> zeroinitializer, <4 x i64> , <4 x i64> zeroinitializer)
+;
+  %gep = getelementptr [42 x [3 x i32]], [42 x [3 x i32]]* null, i64 0, <4 x i64> , i64 0
+  ret <4 x i32*> %gep
+}
+
+; Constant vector
+
+define <4 x i32*> @vector_idx_scalar() {
+; CHECK-LABEL: @vector_idx_scalar(
+; CHECK-NEXT:ret <4 x i32*> getelementptr (i32, <4 x i32*> zeroinitializer, <4 x i64> )
+;
+  %gep = getelementptr i32, <4 x i32*> zeroinitializer, i64 1
+  ret <4 x i32*> %gep
+}
+
+define <4 x i32*> @vector_idx_vector() {
+; CHECK-LABEL: @vector_idx_vector(
+; CHECK-NEXT:ret <4 x i32*> getelementptr (i32, <4 x i32*> zeroinitializer, <4 x i64> )
+;
+  %gep = getelementptr i32, <4 x i32*> zeroinitializer, <4 x i64> 
+  ret <4 x i32*> %gep
+}
+
+%struct = type { double, float }
+define <4 x float*> @vector_idx_mix_scalar_vector() {
+; CHECK-LABEL: @vector_idx_mix_scalar_vector(
+; CHECK-NEXT:ret <4 x float*> getelementptr (%struct, <4 x %struct*> zeroinitializer, <4 x i64> zeroinitializer, <4 x i32> )
+;
+  %gep = getelementptr %struct, <4 x %struct*> zeroinitializer, i32 0, <4 x i32> 
+  ret <4 x float*> %gep
+}
+
+; Constant scalable
+
+define  @scalable_idx_scalar() {
+; CHECK-LABEL: @scalable_idx_scalar(
+; CHECK-NEXT:ret  getelementptr (i32,  zeroinitializer,  shufflevector ( insertelement ( undef, i64 1, i32 0),  undef,  zeroinitializer))
+;
+  %gep = getelementptr i32,  zeroinitializer, i64 1
+  ret  %gep
+}
+
+; Check ConstantExpr::getGetElementPtr() using ElementCount for size queries - end.
Index: llvm/test/CodeGen/AArch64/scalable-vector-promotion.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/scalable-vector-promotion.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=aarch64 -codegenprepare -S < %s |

[PATCH] D76076: [HIP] Mark kernels with uniform-work-group-size=true

2020-03-12 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec accepted this revision.
rampitec added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76076/new/

https://reviews.llvm.org/D76076



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


[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 250038.
njames93 added a comment.

- Fix another broken dependency


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76037/new/

https://reviews.llvm.org/D76037

Files:
  clang-tools-extra/clang-apply-replacements/CMakeLists.txt
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/ReplacementsYaml.cpp
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,36 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_FALSE(IYAML.error());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() == NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),
+  NewDocR = NewDoc.Replacements.begin(),
+  DocE = Doc.Replacements.end();
+ DocR != DocE; DocR++, NewDocR++) {
+  ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+  ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
Index: clang/lib/Tooling/ReplacementsYaml.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ReplacementsYaml.cpp
@@ -0,0 +1,74 @@
+//===-- ReplacementsYaml.cpp -- Serialiazation for Replacements ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsYaml.h"
+
+namespace llvm {
+namespace yaml {
+
+namespace {
+struct Escapes {
+  char EscapeChar;
+  char WrittenChar;
+};
+} // namespace
+
+static constexpr Escapes EscapeChars[] = {
+{'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+
+std::string
+MappingTraits::NormalizedReplacement::escape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  for (char C : Str) {
+if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+  if (C == Escape.EscapeChar) {
+Builder << '\\' << Escape.WrittenChar;
+return true;
+  }
+  return false;
+})) {
+  Builder << C;
+}
+  }
+  return Res;
+}
+
+std::string
+MappingTraits::NormalizedReplacement::unescape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  while (!Str.empty()) {
+if (Str.consume_front("\\")) {
+  if (Str.empty()) {
+Builder << '\\';
+break;
+  }
+  char C = Str.front();
+  Str = Str.drop_front();
+  if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+if (C == Escape.WrittenChar) {
+  Builder << Escape.EscapeChar;
+  return true;
+}
+return false;
+  })) {
+Builder << '\\' << C;
+  }
+  continue;
+}
+Builder << Str.front();
+Str = Str.drop_front();
+  }
+  return Res;
+}
+
+} // namespace yaml
+} // namespace llvm
Index: clang/lib/Tooling/Refactoring/CMakeLists.txt

[PATCH] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

2020-03-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 3 inline comments as done.
jdoerfert added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:1621
   case BuiltinType::LongDouble:
-if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
   return AuxTarget->getLongDoubleFormat();

These AuxTarget changes can be split off. I observed a segfault while testing 
stuff.



Comment at: clang/lib/Headers/CMakeLists.txt:146
   openmp_wrappers/new
 )
 

the math_declares above will provide all `C` math functions so we do not need 
`math.h` anymore here.



Comment at: clang/lib/Headers/__clang_cuda_cmath.h:306
 
+#ifndef _OPENMP
 // We need to define these overloads in exactly the namespace our standard

when this is included with OpenMP it is actually following the system `` 
and these using declarations are neither needed nor helpful (afaict)



Comment at: clang/lib/Headers/__clang_cuda_math_forward_declares.h:42-43
 __DEVICE__ long long abs(long long);
-__DEVICE__ double abs(double);
-__DEVICE__ float abs(float);
-#endif

tra wrote:
> Shouldn't float and double abs variants be preserved?
yes, thx! I make so many errors modifying these files, it is ridicules...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75788/new/

https://reviews.llvm.org/D75788



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


[PATCH] D76086: [Sema][SVE] Reject arithmetic on pointers to sizeless types

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

In D76086#1920096 , @efriedma wrote:

> Do we really want to forbid this?  The expected semantics are clear, and the 
> obvious lowering to getelementptr just works.


The problem is that pointer arithmetic is really a form of sizeof() operation.  
I.e. it only makes sense to move pointers past N objects if you know how big 
they are.

One corner-case that behaves strangely without the patch is:

  void f() {
int x;
constexpr int y = (&x + 1) - &x;
  }
  
  void g() {
__SVInt8_t x;
constexpr int y = (&x + 1) - &x;
  }

f() seems to be valid code, but g() produces:

  warning: subtraction of pointers to type '__SVInt8_t' of zero size has 
undefined behavior [-Wpointer-arith]

So if we were to allow pointer arithmetic, I think in practice we'd need some 
rules to make sizeof effectively variable, but limited to that context.

In practice I don't think a more relaxed rule wil be useful because it isn't 
possible to create arrays of sizeless type.  So the simplest approach seems to 
be to inherit the normal rules for incomplete types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76086/new/

https://reviews.llvm.org/D76086



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


[PATCH] D76088: [Sema][SVE] Don't allow sizeless objects to be thrown

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

We already have a special case for void* here; it's trivial to extend that to 
also check for sizeless types. I don't want to add weird semantic restrictions 
just to save a few characters in the compiler.

I agree that most people won't run into it either way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76088/new/

https://reviews.llvm.org/D76088



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


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

(Also just to clarify: while I said on Discord that I already implemented 
exclusion of string literals, I actually ended up deferring that part to a 
follow-up because it wasn't working as I expected.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874



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


[clang-tools-extra] dc4cd43 - [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via cfe-commits

Author: Sam McCall
Date: 2020-03-12T16:33:08-04:00
New Revision: dc4cd43904df92565dbacaa501db98eb9683551b

URL: 
https://github.com/llvm/llvm-project/commit/dc4cd43904df92565dbacaa501db98eb9683551b
DIFF: 
https://github.com/llvm/llvm-project/commit/dc4cd43904df92565dbacaa501db98eb9683551b.diff

LOG: [clangd] Add a textual fallback for go-to-definition

Summary:
This facilitates performing go-to-definition in contexts where AST-based
resolution does not work, such as comments, string literals, preprocessor
disabled regions, and macro definitions, based on textual lookup in the index.

Partially fixes https://github.com/clangd/clangd/issues/241

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/FindSymbols.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.cpp
index ee6e256ae1bc..06c124c0b35b 100644
--- a/clang-tools-extra/clangd/FindSymbols.cpp
+++ b/clang-tools-extra/clangd/FindSymbols.cpp
@@ -18,6 +18,7 @@
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Index/IndexingAction.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
@@ -39,30 +40,33 @@ struct ScoredSymbolGreater {
 
 } // namespace
 
-llvm::Expected symbolToLocation(const Symbol &Sym,
-  llvm::StringRef HintPath) {
-  // Prefer the definition over e.g. a function declaration in a header
-  auto &CD = Sym.Definition ? Sym.Definition : Sym.CanonicalDeclaration;
-  auto Path = URI::resolve(CD.FileURI, HintPath);
+llvm::Expected indexToLSPLocation(const SymbolLocation &Loc,
+llvm::StringRef TUPath) {
+  auto Path = URI::resolve(Loc.FileURI, TUPath);
   if (!Path) {
 return llvm::make_error(
-formatv("Could not resolve path for symbol '{0}': {1}",
-Sym.Name, llvm::toString(Path.takeError())),
+llvm::formatv("Could not resolve path for file '{0}': {1}", 
Loc.FileURI,
+  llvm::toString(Path.takeError())),
 llvm::inconvertibleErrorCode());
   }
   Location L;
-  // Use HintPath as TUPath since there is no TU associated with this
-  // request.
-  L.uri = URIForFile::canonicalize(*Path, HintPath);
+  L.uri = URIForFile::canonicalize(*Path, TUPath);
   Position Start, End;
-  Start.line = CD.Start.line();
-  Start.character = CD.Start.column();
-  End.line = CD.End.line();
-  End.character = CD.End.column();
+  Start.line = Loc.Start.line();
+  Start.character = Loc.Start.column();
+  End.line = Loc.End.line();
+  End.character = Loc.End.column();
   L.range = {Start, End};
   return L;
 }
 
+llvm::Expected symbolToLocation(const Symbol &Sym,
+  llvm::StringRef TUPath) {
+  // Prefer the definition over e.g. a function declaration in a header
+  return indexToLSPLocation(
+  Sym.Definition ? Sym.Definition : Sym.CanonicalDeclaration, TUPath);
+}
+
 llvm::Expected>
 getWorkspaceSymbols(llvm::StringRef Query, int Limit,
 const SymbolIndex *const Index, llvm::StringRef HintPath) {

diff  --git a/clang-tools-extra/clangd/FindSymbols.h 
b/clang-tools-extra/clangd/FindSymbols.h
index b474ed135321..5110e8bdd3a9 100644
--- a/clang-tools-extra/clangd/FindSymbols.h
+++ b/clang-tools-extra/clangd/FindSymbols.h
@@ -21,9 +21,13 @@ namespace clangd {
 class ParsedAST;
 class SymbolIndex;
 
+/// Helper function for deriving an LSP Location from an index SymbolLocation.
+llvm::Expected indexToLSPLocation(const SymbolLocation &Loc,
+llvm::StringRef TUPath);
+
 /// Helper function for deriving an LSP Location for a Symbol.
 llvm::Expected symbolToLocation(const Symbol &Sym,
-  llvm::StringRef HintPath);
+  llvm::StringRef TUPath);
 
 /// Searches for the symbols matching \p Query. The syntax of \p Query can be
 /// the non-qualified name or fully qualified of a symbol. For example,

diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 67f7bda6a5e6..acf9f6df8281 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -13,6 +13,7 @@
 #include "Logger.h"
 #include "ParsedAST.h"
 #include "Protocol.h"
+#include "Quality.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "URI.h"
@@ -28,6 +29,7 @@
 #include "clang/AST/D

[clang] 118abf2 - [SVE] Update API ConstantVector::getSplat() to use ElementCount.

2020-03-12 Thread Huihui Zhang via cfe-commits

Author: Huihui Zhang
Date: 2020-03-12T13:22:41-07:00
New Revision: 118abf20173899e9e1667db1a9c850dc5570b6ae

URL: 
https://github.com/llvm/llvm-project/commit/118abf20173899e9e1667db1a9c850dc5570b6ae
DIFF: 
https://github.com/llvm/llvm-project/commit/118abf20173899e9e1667db1a9c850dc5570b6ae.diff

LOG: [SVE] Update API ConstantVector::getSplat() to use ElementCount.

Summary:
Support ConstantInt::get() and Constant::getAllOnesValue() for scalable
vector type, this requires ConstantVector::getSplat() to take in 'ElementCount',
instead of 'unsigned' number of element count.

This change is needed for D73753.

Reviewers: sdesmalen, efriedma, apazos, spatel, huntergr, willlovett

Reviewed By: efriedma

Subscribers: tschuett, hiraditya, rkruppe, psnobl, cfe-commits, llvm-commits

Tags: #llvm

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

Added: 
llvm/test/CodeGen/AArch64/scalable-vector-promotion.ll

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/Analysis/Utils/Local.h
llvm/include/llvm/IR/Constants.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/InstSimplify/gep.ll
llvm/unittests/FuzzMutate/OperationsTest.cpp
llvm/unittests/IR/VerifierTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e2cd0f8814cc..436084ef23cb 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4496,8 +4496,8 @@ static llvm::VectorType *GetFloatNeonType(CodeGenFunction 
*CGF,
 }
 
 Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) {
-  unsigned nElts = V->getType()->getVectorNumElements();
-  Value* SV = llvm::ConstantVector::getSplat(nElts, C);
+  ElementCount EC = V->getType()->getVectorElementCount();
+  Value *SV = llvm::ConstantVector::getSplat(EC, C);
   return Builder.CreateShuffleVector(V, V, SV, "lane");
 }
 
@@ -8701,7 +8701,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
   llvm::VectorType::get(VTy->getElementType(), VTy->getNumElements() / 2) :
   VTy;
 llvm::Constant *cst = cast(Ops[3]);
-Value *SV = llvm::ConstantVector::getSplat(VTy->getNumElements(), cst);
+Value *SV = llvm::ConstantVector::getSplat(VTy->getElementCount(), cst);
 Ops[1] = Builder.CreateBitCast(Ops[1], SourceTy);
 Ops[1] = Builder.CreateShuffleVector(Ops[1], Ops[1], SV, "lane");
 
@@ -8730,7 +8730,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
 llvm::Type *STy = llvm::VectorType::get(VTy->getElementType(),
 VTy->getNumElements() * 2);
 Ops[2] = Builder.CreateBitCast(Ops[2], STy);
-Value* SV = llvm::ConstantVector::getSplat(VTy->getNumElements(),
+Value *SV = llvm::ConstantVector::getSplat(VTy->getElementCount(),
cast(Ops[3]));
 Ops[2] = Builder.CreateShuffleVector(Ops[2], Ops[2], SV, "lane");
 

diff  --git a/llvm/include/llvm/Analysis/Utils/Local.h 
b/llvm/include/llvm/Analysis/Utils/Local.h
index ca505960cbeb..84e884e46d0b 100644
--- a/llvm/include/llvm/Analysis/Utils/Local.h
+++ b/llvm/include/llvm/Analysis/Utils/Local.h
@@ -63,7 +63,7 @@ Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout 
&DL, User *GEP,
 
   // Splat the constant if needed.
   if (IntIdxTy->isVectorTy() && !OpC->getType()->isVectorTy())
-OpC = ConstantVector::getSplat(IntIdxTy->getVectorNumElements(), OpC);
+OpC = ConstantVector::getSplat(IntIdxTy->getVectorElementCount(), OpC);
 
   Constant *Scale = ConstantInt::get(IntIdxTy, Size);
   Constant *OC = ConstantExpr::getIntegerCast(OpC, IntIdxTy, true 
/*SExt*/);

diff  --git a/llvm/include/llvm/IR/Constants.h 
b/llvm/include/llvm/IR/Constants.h
index 90bf22bd4344..e6d8c0eb4d92 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -517,7 +517,7 @@ class ConstantVector final : public ConstantAggregate {
 
 public:
   /// Return a ConstantVector with the specified constant in each element.
-  static Constant *getSplat(unsigned NumElts, Constant *Elt);
+  static Constant *getSplat(ElementCount EC, Constant *Elt);
 
   /// Specialize the getType() method to always return a VectorType,
   /// which reduces the amount of casting needed in parts of the compiler.

diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp 
b/llvm/lib/Analysis/InstructionSimplify.cpp
index de7310623e84..bc9ae5ebffb0 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -707,9 +707,8 @@ static Constant *stripAndComputeConstantOffset

[clang] 9975dc3 - Defer checking for mismatches between the deletedness of and overriding

2020-03-12 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-12T13:07:22-07:00
New Revision: 9975dc38bf734b4d86eab61269080ca231379d23

URL: 
https://github.com/llvm/llvm-project/commit/9975dc38bf734b4d86eab61269080ca231379d23
DIFF: 
https://github.com/llvm/llvm-project/commit/9975dc38bf734b4d86eab61269080ca231379d23.diff

LOG: Defer checking for mismatches between the deletedness of and overriding
function and an overridden function until we know whether the overriding
function is deleted.

We previously did these checks when we first built the declaration,
which was too soon in some cases. We now defer all these checks to the
end of the class.

Also add missing check that a consteval function cannot override a
non-consteval function and vice versa.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/class.derived/class.abstract/p16.cpp
clang/test/CXX/special/class.dtor/p5-0x.cpp
clang/test/SemaCXX/PR9572.cpp
clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp
clang/test/SemaCXX/virtual-base-used.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5312c1987f56..52bc4077bbc2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1509,9 +1509,12 @@ def err_deleted_decl_not_first : Error<
 
 def err_deleted_override : Error<
   "deleted function %0 cannot override a non-deleted function">;
-
 def err_non_deleted_override : Error<
   "non-deleted function %0 cannot override a deleted function">;
+def err_consteval_override : Error<
+  "consteval function %0 cannot override a non-consteval function">;
+def err_non_consteval_override : Error<
+  "non-consteval function %0 cannot override a consteval function">;
 
 def warn_weak_vtable : Warning<
   "%0 has no out-of-line virtual method definitions; its vtable will be "

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7d56109b7338..d31e2747f65c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8032,30 +8032,8 @@ struct FindOverriddenMethod {
 return false;
   }
 };
-
-enum OverrideErrorKind { OEK_All, OEK_NonDeleted, OEK_Deleted };
 } // end anonymous namespace
 
-/// Report an error regarding overriding, along with any relevant
-/// overridden methods.
-///
-/// \param DiagID the primary error to report.
-/// \param MD the overriding method.
-/// \param OEK which overrides to include as notes.
-static void ReportOverrides(Sema& S, unsigned DiagID, const CXXMethodDecl *MD,
-OverrideErrorKind OEK = OEK_All) {
-  S.Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-  for (const CXXMethodDecl *O : MD->overridden_methods()) {
-// This check (& the OEK parameter) could be replaced by a predicate, but
-// without lambdas that would be overkill. This is still nicer than writing
-// out the diag loop 3 times.
-if ((OEK == OEK_All) ||
-(OEK == OEK_NonDeleted && !O->isDeleted()) ||
-(OEK == OEK_Deleted && O->isDeleted()))
-  S.Diag(O->getLocation(), diag::note_overridden_virtual_function);
-  }
-}
-
 /// AddOverriddenMethods - See if a method overrides any in the base classes,
 /// and if so, check that it's a valid override and remember it.
 bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
@@ -8064,8 +8042,6 @@ bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, 
CXXMethodDecl *MD) {
   FindOverriddenMethod FOM;
   FOM.Method = MD;
   FOM.S = this;
-  bool hasDeletedOverridenMethods = false;
-  bool hasNonDeletedOverridenMethods = false;
   bool AddedAny = false;
   if (DC->lookupInBases(FOM, Paths)) {
 for (auto *I : Paths.found_decls()) {
@@ -8075,21 +8051,12 @@ bool Sema::AddOverriddenMethods(CXXRecordDecl *DC, 
CXXMethodDecl *MD) {
 !CheckOverridingFunctionAttributes(MD, OldMD) &&
 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
-  hasDeletedOverridenMethods |= OldMD->isDeleted();
-  hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
   AddedAny = true;
 }
   }
 }
   }
 
-  if (hasDeletedOverridenMethods && !MD->isDeleted()) {
-ReportOverrides(*this, diag::err_non_deleted_override, MD, OEK_Deleted);
-  }
-  if (hasNonDeletedOverridenMethods && MD->isDeleted()) {
-ReportOverrides(*this, diag::err_deleted_override, MD, OEK_NonDeleted);
-  }
-
   return AddedAny;
 }
 
@@ -9095,8 +9062,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
 }
 
 // If a function is defined as defaulted or deleted, mark it as such now.
-// FIXME: Does this ever happen? ActOnStart

Re: [clang] d052a57 - [c++2a] Allow comparison functions to be explicitly defaulted.

2020-03-12 Thread Richard Smith via cfe-commits
I believe the case you're describing is one like this:

struct A { virtual void f() = delete; };
template struct B : A { virtual void f() = delete; };
B b;

Fixed in llvmorg-11-init-5618-g9975dc38bf7.

On Tue, 10 Mar 2020 at 18:01, Hubert Tong via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Mar 10, 2020 at 7:35 PM Richard Smith 
> wrote:
>
>> Should be fixed in llvmorg-11-init-5426-g4cba668ac13.
>>
> Thanks. We're also seeing a failure on valid code where a template class
> explicitly deletes a function that is an override of an explicitly deleted
> virtual function in a (non-templated) base class.
>
> :7:16: error: non-deleted function 'f' cannot override a deleted
> function
>   virtual void f() = delete;
>^
> :10:8: note: in instantiation of template class 'B' requested
> here
> B b() { return {}; }
>^
> :2:16: note: overridden virtual function is here
>   virtual void f() = delete;
>^
> 1 error generated.
>
>
>>
>> On Sat, 7 Mar 2020 at 08:05, Hubert Tong via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Following this commit, the error recovery for invalid cases that
>>> explicitly define (out-of-line) a member function template as deleted and
>>> attempts to instantiate said function appears broken.
>>>
>>> :4:35: error: deleted definition must be first declaration
>>> template  void A::f() = delete;
>>>   ^
>>> :2:35: note: previous declaration is here
>>>   template  static void f();
>>>   ^
>>> clang:
>>> /src_d052a578de58cbbb638cbe2dba05242d1ff443b9/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4288:
>>> void clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
>>> clang::FunctionDecl *, bool, bool, bool): Assertion `(Pattern ||
>>> PatternDecl->isDefaulted() || PatternDecl->hasSkippedBody()) && "unexpected
>>> kind of function template definition"' failed.
>>> Stack dump:
>>> 0.  Program arguments:
>>> /build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/clang -cc1 -std=c++11
>>> -xc++ -
>>> 1.  :5:26: current parser token ';'
>>>  #0 0x3fff7fe6a024 PrintStackTraceSignalHandler(void*)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1ea024)
>>>  #1 0x3fff7fe670c8 llvm::sys::RunSignalHandlers()
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1e70c8)
>>>  #2 0x3fff7fe6a49c SignalHandler(int)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/libLLVMSupport.so.10svn+0x1ea49c)
>>>  #3 0x3fff82030478  0x478 abort
>>>  #4 0x3fff82030478
>>>  #5 0x3fff82030478 __assert_fail_base (+0x478)
>>>  #6 0x3fff7e0a1f94 __assert_fail (/lib64/libc.so.6+0x41f94)
>>>  #7 0x3fff7e0955d4
>>> clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
>>> clang::FunctionDecl*, bool, bool, bool) (/lib64/libc.so.6+0x355d4)
>>>  #8 0x3fff7e0956c4
>>> clang::Sema::ActOnExplicitInstantiation(clang::Scope*,
>>> clang::SourceLocation, clang::SourceLocation, clang::Declarator&)
>>> (/lib64/libc.so.6+0x356c4)
>>>  #9 0x3fff7c28d604
>>> clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
>>> clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangSema.so.10svn+0x8ad604)
>>> #10 0x3fff7c15c2b0
>>> clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&,
>>> clang::Parser::ParsedTemplateInfo const&)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangSema.so.10svn+0x77c2b0)
>>> #11 0x3fff7c4cc8f8
>>> clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
>>> clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
>>> clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x4c8f8)
>>> #12 0x3fff7c4cdf48
>>> clang::Parser::ParseExplicitInstantiation(clang::DeclaratorContext,
>>> clang::SourceLocation, clang::SourceLocation, clang::SourceLocation&,
>>> clang::ParsedAttributes&, clang::AccessSpecifier)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0x4df48)
>>> #13 0x3fff7c57c1f0
>>> clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
>>> clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfc1f0)
>>> #14 0x3fff7c57a6c0
>>> clang::Parser::ParseDeclaration(clang::DeclaratorContext,
>>> clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
>>> clang::SourceLocation*)
>>> (/build_d052a578de58cbbb638cbe2dba05242d1ff443b9/bin/../lib/../lib/libclangParse.so.10svn+0xfa6c0)
>>> #15 0x3fff7c57a4f8
>>> clang::Parser::ParseEx

[PATCH] D75298: [Clang][SVE] Parse builtin type string for scalable vectors

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:86
+  OS << "#ifndef  __cplusplus\n";
+  OS << "#include \n";
+  OS << "#endif\n\n";

I'd prefer to avoid depending on stdbool if it isn't necessary.



Comment at: clang/utils/TableGen/SveEmitter.cpp:92
+  OS << "typedef double float64_t;\n";
+  OS << "typedef bool bool_t;\n\n";
+

The ACLE documentation doesn't say anything about float16_t etc.?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75298/new/

https://reviews.llvm.org/D75298



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


[PATCH] D74541: [Analyzer] Use note tags to track iterator increments and decrements

2020-03-12 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 4 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:519-520
+const NoteTag *IteratorModeling::getChangeTag(CheckerContext &C, StringRef 
Text,
+  const Expr *ItE, SVal It1,
+  int64_t Amount, SVal It2) const {
+  StringRef Name;

Szelethus wrote:
> Szelethus wrote:
> > Are `It1` and `It2` used? Why do we default the latter to `UndefinedVal`?
> Ah, okay, we use it in a followup patch. Still, we shouldn't use 
> `UndefinedVal`, as discussed in D75514.
I completely removed them from this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74541/new/

https://reviews.llvm.org/D74541



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


[PATCH] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

2020-03-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 250035.
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

Adjust to new scheme, tested locally with some math functions, seems to work


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75788/new/

https://reviews.llvm.org/D75788

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/OpenMP/target_nvptx_math_complex.c
  clang/test/OpenMP/target_nvptx_math_fp_macro.cpp
  clang/test/OpenMP/target_nvptx_math_sin.c

Index: clang/test/OpenMP/target_nvptx_math_sin.c
===
--- /dev/null
+++ clang/test/OpenMP/target_nvptx_math_sin.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -internal-isystem %S -verify -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S -include openmp_wrappers/__clang_openmp_math_declares.h -verify -fopenmp -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -aux-triple powerpc64le-unknown-unknown -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+
+double math(float f, double d, long double ld) {
+  double r = 0;
+  r += sin(f);
+  r += sin(d);
+  return r;
+}
+
+long double foo(float f, double d, long double ld) {
+  double r = ld;
+  r += math(f, d, ld);
+#pragma omp target map(r)
+  { r += math(f, d, ld); }
+  return r;
+}
Index: clang/test/OpenMP/target_nvptx_math_fp_macro.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_nvptx_math_fp_macro.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -x c++ -emit-llvm %s -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+// TODO: How to include a "mock systme cmath" here for testing?
+
+int main() {
+  double a(0);
+  return (std::fpclassify(a) != FP_ZERO);
+}
Index: clang/test/OpenMP/target_nvptx_math_complex.c
===
--- /dev/null
+++ clang/test/OpenMP/target_nvptx_math_complex.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-DAG: call { float, float } @__divsc3(
+// CHECK-DAG: call { float, float } @__mulsc3(
+void test_scmplx(float _Complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
+
+
+// CHECK-DAG: call { double, double } @__divdc3(
+// CHECK-DAG: call { double, double } @__muldc3(
+void test_dcmplx(double _Complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
Index: clang/test/Headers/nvptx_device_cmath_functions.c
===
--- clang/test/Headers/nvptx_device_cmath_functions.c
+++ clang/test/Headers/nvptx_device_cmath_functions.c
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: clang/lib/Headers/openmp_wrappers/math.h
===
--- clang/lib/Headers/openmp_wrappers/math.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*===- math.h - Alternative math.h header --===
- *
- 

[PATCH] D76079: [Hexagon] Enable init_arrays when target is linux-musl

2020-03-12 Thread Sid Manning via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6174fddbe3d4: [Hexagon] Enable init_arrays when target is 
linux-musl (authored by sidneym).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76079/new/

https://reviews.llvm.org/D76079

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/hexagon-toolchain-elf.c


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -664,3 +664,13 @@
 // CHECK089:   "/hexagon{{/|}}lib{{/|}}crt1.o"
 // CHECK089-NOT:   -lclang_rt.builtins-hexagon
 // CHECK089-NOT:   -lc
+// 
-
+// Not Passing -fno-use-init-array when musl is selected
+// 
-
+// RUN: %clang -### -target hexagon-unknown-linux-musl \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK090 %s
+// CHECK090-NOT:  -fno-use-init-array
+// 
-
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -544,7 +544,8 @@
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
-  bool UseInitArrayDefault = false;
+
+  bool UseInitArrayDefault = getTriple().isMusl();
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array,


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -664,3 +664,13 @@
 // CHECK089:   "/hexagon{{/|}}lib{{/|}}crt1.o"
 // CHECK089-NOT:   -lclang_rt.builtins-hexagon
 // CHECK089-NOT:   -lc
+// -
+// Not Passing -fno-use-init-array when musl is selected
+// -
+// RUN: %clang -### -target hexagon-unknown-linux-musl \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK090 %s
+// CHECK090-NOT:  -fno-use-init-array
+// -
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -544,7 +544,8 @@
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
-  bool UseInitArrayDefault = false;
+
+  bool UseInitArrayDefault = getTriple().isMusl();
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I should mention that in my local usage, I've found the restriction on no more 
than 3 results (even if they're not in the current file) to be somewhat 
limiting. For example, a comment can easily reference the name of a function 
which has more than 3 overloads.

But we can start by landing this, and consider relaxing the limit (either in 
general, or in specific cases such as the overload set case) in follow-ups.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874



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


[PATCH] D75210: [Attr] Allow ParsedAttr to be constructor for any Attribute

2020-03-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert planned changes to this revision.
jdoerfert added a comment.

The reason for this patch is not there anymore. I'm fine with postponing this 
patch until there is a user again, thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75210/new/

https://reviews.llvm.org/D75210



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


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:436
+if (ScoredResults.size() >= 3) {
+  // Assume we don't have results from the current file, otherwise the
+  // findNearbyIdentifier() mechanism would have handled them.

nridge wrote:
> Oh whoops, this assumption is another dependency on `findNearbyIdentifier()`
For now, I just had it restrict to 3 results in general (even if they're in the 
same file).

Once `findNearbyIdentifier()` lands, the behaviour will automatically become 
what we intended.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874



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


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 250031.
nridge added a comment.

Tweak a comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -38,6 +38,7 @@
 namespace {
 
 using ::testing::ElementsAre;
+using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAreArray;
@@ -353,7 +354,7 @@
   R"cpp(// Symbol concatenated inside macro (not supported)
int *pi;
#define POINTER(X) p ## X;
-   int i = *POINTER(^i);
+   int x = *POINTER(^i);
   )cpp",
 
   R"cpp(// Forward class declaration
@@ -606,6 +607,81 @@
   }
 }
 
+TEST(LocateSymbol, TextualSmoke) {
+  auto T = Annotations(
+  R"cpp(
+struct [[MyClass]] {};
+// Comment mentioning M^yClass
+  )cpp");
+
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
+  ElementsAre(Sym("MyClass", T.range(;
+}
+
+TEST(LocateSymbol, Textual) {
+  const char *Tests[] = {
+  R"cpp(// Comment
+struct [[MyClass]] {};
+// Comment mentioning M^yClass
+  )cpp",
+  R"cpp(// String
+struct [[MyClass]] {};
+const char* s = "String literal mentioning M^yClass";
+  )cpp",
+  R"cpp(// Ifdef'ed out code
+struct [[MyClass]] {};
+#ifdef WALDO
+  M^yClass var;
+#endif
+  )cpp",
+  R"cpp(// Macro definition
+struct [[MyClass]] {};
+#define DECLARE_MYCLASS_OBJ(name) M^yClass name;
+  )cpp",
+  R"cpp(// Invalid code
+/*error-ok*/
+int myFunction(int);
+// Not triggered for token which survived preprocessing.
+int var = m^yFunction();
+  )cpp",
+  R"cpp(// Dependent type
+struct Foo {
+  void uniqueMethodName();
+};
+template 
+void f(T t) {
+  // Not triggered for token which survived preprocessing.
+  t->u^niqueMethodName();
+}
+  )cpp"};
+
+  for (const char *Test : Tests) {
+Annotations T(Test);
+llvm::Optional WantDecl;
+if (!T.ranges().empty())
+  WantDecl = T.range();
+
+auto TU = TestTU::withCode(T.code());
+
+auto AST = TU.build();
+auto Index = TU.index();
+auto Results = locateSymbolNamedTextuallyAt(
+AST, Index.get(),
+cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
+testPath(TU.Filename));
+
+if (!WantDecl) {
+  EXPECT_THAT(Results, IsEmpty()) << Test;
+} else {
+  ASSERT_THAT(Results, ::testing::SizeIs(1)) << Test;
+  EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
+}
+  }
+}
+
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
 struct Foo {
@@ -680,6 +756,30 @@
Sym("baz", T.range("StaticOverload2";
 }
 
+TEST(LocateSymbol, TextualAmbiguous) {
+  auto T = Annotations(R"cpp(
+struct Foo {
+  void $FooLoc[[uniqueMethodName]]();
+};
+struct Bar {
+  void $BarLoc[[uniqueMethodName]]();
+};
+// Will call u^niqueMethodName() on t.
+template 
+void f(T t);
+  )cpp");
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  auto Results = locateSymbolNamedTextuallyAt(
+  AST, Index.get(),
+  cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
+  testPath(TU.Filename));
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
+   Sym("uniqueMethodName", T.range("BarLoc";
+}
+
 TEST(LocateSymbol, TemplateTypedefs) {
   auto T = Annotations(R"cpp(
 template  struct function {};
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -49,6 +49,21 @@
 std::vector locateSymbolAt(ParsedAST &AST, Position Pos,
   const SymbolIndex *Index = nullptr);
 
+// Tries to provide a textual fallback for locating a symbol referenced at
+// a location, by looking up the word under the cursor as a symbol name in the
+// index. The aim is to pick up references to symbols in contexts where
+// AST-based resolution does not work, such as comments, strings, and PP

[PATCH] D76088: [Sema][SVE] Don't allow sizeless objects to be thrown

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

In D76088#1920070 , @efriedma wrote:

> Why is throwing an `svint8_t *` an error?  I don't see any obvious reason to 
> forbid that.


Yeah, I agree there's no obvious reason why it wouldn't work.  The same 
reasoning applies here as for D76086 :

> (In practice, throwing pointers to sizeless types could probably
>  be handled without problems. It would be an odd thing to do though,
>  and so it didn't seem worth treating as a special case.)

I.e. once sizeless types are treated as incomplete types (which happens towards 
the end of the series), we'd have to create a new rule to allow sizeless types 
only for the pointer case.  But since no-one will hopefully want to throw such 
a thing, it seemed better to keep it simple and leave the rule unchanged.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76088/new/

https://reviews.llvm.org/D76088



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


[PATCH] D76078: [AArch64][SVE] Add a pass for SVE intrinsic optimisations

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:441
+  // Expand any SVE vector library calls that we can't code generate directly.
+  bool ExpandToOptimize = (TM->getOptLevel() != CodeGenOpt::None);
+  if (EnableSVEIntrinsicOpts && TM->getOptLevel() == CodeGenOpt::Aggressive)

unused bool?



Comment at: llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp:56
+
+  static bool processPhiNode(Instruction *I);
+

`processPhiNode(IntrinsicInst *I)`?



Comment at: llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp:109
+
+  auto *PN = dyn_cast(X->getOperand(0));
+  if (!PN)

Please use getArgOperand() to get the arguments of calls.



Comment at: llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp:234
+  DT = &getAnalysis().getDomTree();
+  bool Changed = false;
+

You might want to check whether the module actually declares any of the SVE 
intrinsics before you iterate over the whole function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76078/new/

https://reviews.llvm.org/D76078



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


[PATCH] D76094: [clangd] Change line break behaviour for hoverinfo

2020-03-12 Thread Lorenz Junglas via Phabricator via cfe-commits
lolleko created this revision.
lolleko added a reviewer: sammccall.
lolleko added a project: clang.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.

`convertLineBreaks` retains hard line breaks and removes soft line breaks.
Wether a line break is hard or soft is determined by the following rules (some 
of which have been discussed in https://github.com/clangd/clangd/issues/95):

- Hard Markdown line breaks (https://github.github.com/gfm/#hard-line-breaks) 
are retained
- Line breaks that are preceded by a punctuation are retained
- Line breaks that are followed by "interesting characters" (e.g. Markdown 
syntax, doxygen commands) are retained
- All other line breaks are removed

Even though markdown doc comments in cpp are still rare, I removed the markdown 
escaping.
I think the chance that markdown constructs are introduced by accident is 
fairly low especially with proper line breaks.
That means that doc comments which use markdown are now supported and should be 
rendered properly (in supported editors).

In addition `canonicalizeSpaces` has been removed.
`canonicalizeSpaces` removed duplicate whitespaces anywhere in a string. Now 
only (duplicate) whitespaces before and after a line break are trimmed.

Since this is my first contribution feel free to be extra thorough.

Fixes https://github.com/clangd/clangd/issues/301, Potentially resolves 
https://github.com/clangd/clangd/issues/95


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76094

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1905,7 +1905,7 @@
   llvm::StringRef ExpectedMarkdown = R"md(### variable `foo`  
 
 ---
-Value \= `val`  
+Value = `val`  
 
 ---
 ```cpp
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -20,19 +20,6 @@
 TEST(Render, Escaping) {
   // Check some ASCII punctuation
   Paragraph P;
-  P.appendText("*!`");
-  EXPECT_EQ(P.asMarkdown(), "\\*\\!\\`");
-
-  // Check all ASCII punctuation.
-  P = Paragraph();
-  std::string Punctuation = R"txt(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)txt";
-  // Same text, with each character escaped.
-  std::string EscapedPunctuation;
-  EscapedPunctuation.reserve(2 * Punctuation.size());
-  for (char C : Punctuation)
-EscapedPunctuation += std::string("\\") + C;
-  P.appendText(Punctuation);
-  EXPECT_EQ(P.asMarkdown(), EscapedPunctuation);
 
   // In code blocks we don't need to escape ASCII punctuation.
   P = Paragraph();
@@ -98,7 +85,7 @@
 }
 
 TEST(Paragraph, ExtraSpaces) {
-  // Make sure spaces inside chunks are dropped.
+  // Make sure spaces after linebreaks are dropped.
   Paragraph P;
   P.appendText("foo\n   \t   baz");
   P.appendCode(" bar\n");
@@ -106,15 +93,92 @@
   EXPECT_EQ(P.asPlainText(), "foo baz bar");
 }
 
-TEST(Paragraph, NewLines) {
+TEST(Paragraph, LineBreakTrim) {
   // New lines before and after chunks are dropped.
   Paragraph P;
   P.appendText(" \n foo\nbar\n ");
   P.appendCode(" \n foo\nbar \n ");
-  EXPECT_EQ(P.asMarkdown(), "foo bar `foo bar`");
+  EXPECT_EQ(P.asMarkdown(), "foo bar `foo\nbar`");
   EXPECT_EQ(P.asPlainText(), "foo bar foo bar");
 }
 
+TEST(Paragraph, LineBreakConversionParagraphs) {
+  // Paragraphs are eindicated by double linebreaks
+  // additional linebreaks and spaces should be dropped
+  constexpr auto Expected = "foo\n\nbar";
+
+  Paragraph P1;
+  P1.appendText("foo\n\n\n\nbar");
+  EXPECT_EQ(P1.asMarkdown(), Expected);
+  EXPECT_EQ(P1.asPlainText(), Expected);
+
+  Paragraph P2;
+  P2.appendText("foo\n\n\n\tbar");
+  EXPECT_EQ(P2.asMarkdown(), Expected);
+  EXPECT_EQ(P2.asPlainText(), Expected);
+
+  Paragraph P3;
+  P3.appendText("foo\n\n\n bar");
+  EXPECT_EQ(P3.asMarkdown(), Expected);
+  EXPECT_EQ(P3.asPlainText(), Expected);
+}
+
+TEST(Paragraph, LineBreakConversionPunctuation) {
+  // Keep linebreaks after punctuation
+  constexpr llvm::StringLiteral Punctuation = R"txt(.:,;!?)txt";
+
+  for (auto Char : Punctuation) {
+const auto TestString = std::string("foo") + Char + "\nbar";
+const auto MarkdownExpected = std::string("foo") + Char + "  \nbar";
+
+Paragraph P;
+P.appendText(TestString);
+EXPECT_EQ(P.asMarkdown(), MarkdownExpected);
+EXPECT_EQ(P.asPlainText(), TestString);
+  }
+}
+
+TEST(Paragraph, LineBreakConversionIndicator) {
+  // Keep linebreaks before interesting characters
+  constexpr llvm::StringLiteral LinbreakIdenticators = R"txt(-*@\>#`)txt";
+
+  for (au

[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@David.Bolvansky told me “https://lnt.llvm.org/ -> Test suite nts -> watch for

> LNT-Broadwell-AVX2-O3__clang_PROD__x86_64:1364”

The fails were seen on aarch too and a couple other arch.  AFAIK the old 
results are no longer availble.  i scraped the list of fails, pasting here:
home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/sandbox/build/report.simple.csv
Importing 'report.json'
Import succeeded.

- Tested: 2560 tests --

FAIL: MultiSource/Applications/oggenc/oggenc.execution_time (513 of 2560)
FAIL: MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/CLAMR.execution_time (514 
of 2560)
FAIL: MultiSource/Benchmarks/DOE-ProxyApps-C++/HPCCG/HPCCG.execution_time (515 
of 2560)
FAIL: MultiSource/Benchmarks/DOE-ProxyApps-C++/miniFE/miniFE.execution_time 
(516 of 2560)
FAIL: SingleSource/Benchmarks/Linpack/linpack-pc.execution_time (517 of 2560)
FAIL: SingleSource/Benchmarks/Misc-C++/Large/sphereflake.execution_time (518 of 
2560)
FAIL: 
SingleSource/Benchmarks/Polybench/datamining/correlation/correlation.execution_time
 (519 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/datamining/covariance/covariance.execution_time
 (520 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/2mm/2mm.execution_time 
(521 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/3mm/3mm.execution_time 
(522 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/atax/atax.execution_time
 (523 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/bicg/bicg.execution_time
 (524 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/gemver/gemver.execution_time
 (525 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/gesummv/gesummv.execution_time
 (526 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/symm/symm.execution_time
 (527 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/trisolv/trisolv.execution_time
 (528 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/kernels/trmm/trmm.execution_time
 (529 of 2560)
FAIL: 
SingleSource/Benchmarks/Polybench/linear-algebra/solvers/gramschmidt/gramschmidt.execution_time
 (530 of 2560)
FAIL: SingleSource/Benchmarks/Polybench/stencils/adi/adi.execution_time (531 of 
2560)
FAIL: SingleSource/UnitTests/Vector/SSE/sse_expandfft.execution_time (532 of 
2560)
FAIL: SingleSource/UnitTests/Vector/SSE/sse_stepfft.execution_time (533 of 2560)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72675/new/

https://reviews.llvm.org/D72675



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


[clang] 6174fdd - [Hexagon] Enable init_arrays when target is linux-musl

2020-03-12 Thread Sid Manning via cfe-commits

Author: Sid Manning
Date: 2020-03-12T15:00:15-05:00
New Revision: 6174fddbe3d40972d97f63d9bf6bb1c4236de0e3

URL: 
https://github.com/llvm/llvm-project/commit/6174fddbe3d40972d97f63d9bf6bb1c4236de0e3
DIFF: 
https://github.com/llvm/llvm-project/commit/6174fddbe3d40972d97f63d9bf6bb1c4236de0e3.diff

LOG: [Hexagon] Enable init_arrays when target is linux-musl

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 1e2e7c84b006..4a5e8254dfa0 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -544,7 +544,8 @@ unsigned HexagonToolChain::getOptimizationLevel(
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
-  bool UseInitArrayDefault = false;
+
+  bool UseInitArrayDefault = getTriple().isMusl();
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array,

diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index 93c9da2250f5..fba1a891a361 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -664,3 +664,13 @@
 // CHECK089:   "/hexagon{{/|}}lib{{/|}}crt1.o"
 // CHECK089-NOT:   -lclang_rt.builtins-hexagon
 // CHECK089-NOT:   -lc
+// 
-
+// Not Passing -fno-use-init-array when musl is selected
+// 
-
+// RUN: %clang -### -target hexagon-unknown-linux-musl \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK090 %s
+// CHECK090-NOT:  -fno-use-init-array
+// 
-



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


[PATCH] D73521: [analyzer] add-new-checker.py: Introduction

2020-03-12 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:24
 def CoreBuiltin : Package<"builtin">, ParentPackage, Hidden;
-def CoreUninitialized  : Package<"uninitialized">, ParentPackage;
+def CoreUninitialized : Package<"uninitialized">, ParentPackage;
 def CoreAlpha : Package<"core">, ParentPackage;

The script is allergic to human issues. The followup will be to normalize the 
necessary files.



Comment at: clang/utils/analyzer/add-new-checker.py:79-81
+data = subprocess.check_output(['llvm-tblgen', '-dump-json',
+checkers_path,
+'-I=' + checkers_include_path])

NoQ wrote:
> `llvm-tblgen` needs to be in the `PATH`, right? What if LLVM isn't installed 
> on the host system or has the wrong version?
> 
> We might have to either tell the user to specify it explicitly in the 
> invocation (and then update the LIT substitution to explicitly use the right 
> binary), or, ideally, try to get the script installed into the build 
> directory so that it could find the freshly built `llvm-tblgen` binary 
> relative to itself.
Hm, I am not a magician, so my assumption one has the llvm/clang therefore the 
llvm-tblgen available. If not, it warns you and you need to specify. May if you 
want to make sure it "just works" please adjust it later.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73521/new/

https://reviews.llvm.org/D73521



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


[PATCH] D75737: [Sema][SVE] Don't allow fields to have sizeless type

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Sema/SemaLambda.cpp:1633
+if (RequireCompleteSizedType(Loc, FieldType,
+ diag::err_field_incomplete_or_sizeless)) {
   RD->setInvalidDecl();

rsandifo-arm wrote:
> efriedma wrote:
> > Can BuildCaptureField actually print an error?  If it can, do you have a 
> > testcase?
> Thanks for the reviews!
> 
> The only test I could find that triggered this was:
> 
> `auto bad_init_4 = [a(void_fn())] {}; // expected-error {{has incomplete type 
> 'void'}}`
> 
> from CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp.  This might not be the 
> optimal way to report the problem though.
> 
> I've added a corresponding test for the sizeless case.
Makes sense.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75737/new/

https://reviews.llvm.org/D75737



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


[PATCH] D74386: [SVE] Update API ConstantVector::getSplat() to use ElementCount.

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74386/new/

https://reviews.llvm.org/D74386



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


[PATCH] D73521: [analyzer] add-new-checker.py: Introduction

2020-03-12 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 250020.
Charusso marked 3 inline comments as done.
Charusso retitled this revision from "[analyzer][WIP] add-new-checker.py: 
Introduction" to "[analyzer] add-new-checker.py: Introduction".
Charusso added a comment.
Herald added a subscriber: mgorny.

- Try to invoke TableGen, if that fails the user need to specify the path to it.
- The script actually creates a real world (hidden) checker.
  - This checker always made with the build invocation.
  - Its test file always made with the build invocation.
  - Everything else remain as is.
- (calculated: DummyChecker.cpp (100 lines))


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73521/new/

https://reviews.llvm.org/D73521

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/DummyChecker.cpp
  clang/test/Analysis/add-new-checker/add-main-package.rst
  clang/test/Analysis/add-new-checker/add-main-package.td
  clang/test/Analysis/add-new-checker/add-multiple-packages.rst
  clang/test/Analysis/add-new-checker/add-multiple-packages.td
  clang/test/Analysis/add-new-checker/add-new-checker.test
  clang/test/Analysis/add-new-checker/check-add-new-checker.py
  clang/test/Analysis/add-new-checker/checker-name.rst
  clang/test/Analysis/add-new-checker/checker-name.td
  clang/test/Analysis/add-new-checker/flow-package-exist-checker.rst
  clang/test/Analysis/add-new-checker/flow-package-exist-checker.td
  clang/test/Analysis/add-new-checker/flow-package-not-exist-layering.rst
  clang/test/Analysis/add-new-checker/flow-package-not-exist-layering.td
  clang/test/Analysis/add-new-checker/flow-package-not-exist.rst
  clang/test/Analysis/add-new-checker/flow-package-not-exist.td
  clang/test/Analysis/add-new-checker/lit.local.cfg.py
  clang/test/Analysis/dummy-checker.cpp
  clang/utils/analyzer/add-new-checker.py

Index: clang/utils/analyzer/add-new-checker.py
===
--- /dev/null
+++ clang/utils/analyzer/add-new-checker.py
@@ -0,0 +1,775 @@
+#!/usr/bin/env python
+#
+#===- add-new-checker.py - Creates a Static Analyzer checker --*- python -*-===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#======#
+#
+# Example usage: python add-new-checker.py alpha.package.Foo
+#
+#======#
+
+import argparse
+import json
+import os
+import re
+import subprocess
+
+
+class Checker:
+def __init__(self, packages, name):
+self.packages = packages
+self.name = name
+
+def name(self):
+return self.name
+
+def packages(self):
+return self.packages
+
+def __str__(self):
+return '.'.join(self.packages) + '.' + self.name
+
+
+# Obtain the longest known package-chain of the 'packages' chain. For example
+# the checker creation of 'alpha.core.a.Checker' would return ['alpha', 'core'].
+def get_best_package_match(packages, known_packages):
+best_package_match = []
+for i in range(len(packages)):
+temp_packages = packages[:i + 1]
+package_name = '.'.join(temp_packages)
+if package_name in known_packages:
+best_package_match = temp_packages
+return best_package_match
+
+
+# Put every additional package and the checker into an increasing size jagged
+# array. For example the checker creation of 'core.a.Checker' would return
+# '[['core', 'a'], ['core', 'a', 'Checker']]'.
+def get_addition(packages, name, best_package_match):
+addition = []
+match_count = len(best_package_match)
+for i, package in enumerate(packages):
+if i < match_count:
+continue
+addition.append(best_package_match + packages[match_count : i + 1])
+addition.append(packages + [name])
+return addition
+
+
+def add_checkers_entry(clang_path, checker, args):
+checkers_include_path = os.path.join(clang_path, 
+'include', 'clang', 'StaticAnalyzer', 'Checkers')
+checkers_path = os.path.join(checkers_include_path, 'Checkers.td')
+
+# This only could test '.td'.
+if args.is_test:
+checkers_path = args.test_path
+if not checkers_path.endswith('.td.tmp'):
+return
+
+packages = checker.packages
+name = checker.name
+
+# See if TableGen is found.
+try:
+devnull = open(os.devnull)
+subprocess.Popen([args.tblgen_path, '-h'], stdout=devnull,
+ stderr=devnull).communicate()
+except OSError as e:
+print('[error] llvm-tblgen is not found, specify it explicitly.')
+exit()
+
+# Load the checkers' TableGen.
+data = None
+try:
+data = subprocess.check_output([a

[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-03-12 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

In D73245#1918287 , @ldionne wrote:

> In D73245#1918148 , @EricWF wrote:
>
> > I've already stated my disapproval of this patch. Libc++ has never and will 
> > never provide nor value C++03 conformance.
> >  Moving backwards to C++03 is inconsistent with the libraries general 
> > direction.
>
>
> @EricWF makes a point here, we want to move away from C++03.


Removing or breaking C++03 compatibility is actively harmful for that. Speaking 
as a system integrator, a STL implementation that can't deal in a reasonable 
way with the existing C++03 code base is useless. It's a nice ivory tower 
assumption that old code will just disappear if you wish for it enough, but it 
doesn't reflect well on the reality. Especially given the various ways can and 
does fail when compiled for C++11 or later. Having to switch between different 
STL implementations doesn't help anyone in the process of modernizing a code 
base, especially when interacting with code that needs large semi-intrusive 
changes to work in C++11 mode. As a most basic issue, it makes it much harder 
to separate issues with the STL implementation (i.e. depending on 
implementation-defined behavior) from semantic changes in the core language 
(i.e. noexcept dtors, auto) and mechanical changes (e.g. UDL)

>> This patch disables tests, which could hide bugs, including serious ABI 
>> differences between dialects.
>> 
>> I would like to unbreak compilation on NetBSD. But all that's needed there 
>> is to provide our own correct declaration of max_align_t.
>>  I don't see why C++03 conformance is a necessary condition.
> 
> Is there anything that can be done on the NetBSD side to solve this? 
> Basically, just imagine that libc++ doesn't provide a C++03 mode at all -- 
> what would you do then? I think that's the right mindset to solve this 
> specific problem.

Can you both please go back to look at the core of the issue? The current 
behavior of libc++ is at best an ODR violation on ALL platforms. This is not a 
problem specific to NetBSD at all, it has just been exposed as a different 
error on NetBSD. The documented behavior of libc++ is to provide C++03 
compatibility as much as possible when it doesn't conflict with C++11 and the 
compiler (clang) supports the necessary language feature. max_align_t is not 
provided by clang in C++03 nor is it provided by GCC.  Now there are different 
options for fixes, but it is very frustrating to me that the primary feedback 
so far is "Don't use C++03" and therefore not helpful at all.  As I said 
before, libc++ cares about max_align_t exactly for one purpose: whether 
overaligned types need special allocators. Now C++03 normally can't depend on 
the implementation to do something useful in this case, simply because the 
environment doesn't have the necessary means. So it all boils down to what is 
the least intrusive and potentially most well testable mechanism. The core of 
the patch provides one answer for that. If the compiler supports telling us the 
default alignment for new, use it just like we would in C++11 mode. A 
constructive feedback would now be an answer to the question of whether we care 
about libc++ use with compilers that do not provide that macro for C++03 mode. 
I don't know how useful libc++ in C++03 mode is for any compiler except clang 
and as I wrote, we document the primary target being clang. As such the primary 
question is whether we care about compatibility with older versions of clang 
and modern libc++.  If we don't, the change to `` becomes much simpler as 
it can just bail out and the corresponding testing becomes easier as well, 
since it would only have to assert that max_align_t is aligned less strictly 
than the platform allocator. It would solve the core issue that we provide a 
max_align_t when we don't know what it should be and actively disagree with the 
max_align_t we provide for the other dialects.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73245/new/

https://reviews.llvm.org/D73245



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-12 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Thanks Shiva, I res-ynced and rebuilt the patch. It is working fine.

I see there is a msmall-data-threshold flag used by Mips and Hexagon, and now 
we are adding a new flag msmall-data-limit. Should't we reuse the flag?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57497/new/

https://reviews.llvm.org/D57497



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


[PATCH] D76084: [Sema][SVE] Reject subscripts on pointers to sizeless types

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not sure we actually want to reject this; let's discuss on the review for 
D76086 , since subscripting is sort of a 
special case of arithmetic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76084/new/

https://reviews.llvm.org/D76084



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


[PATCH] D76061: [Sema] Fix location of star ('*') inside MemberPointerTypeLoc

2020-03-12 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko updated this revision to Diff 250024.
hlopko added a comment.
Herald added a subscriber: mgorny.

[Sema] Fix location of star ('*') inside MemberPointerTypeLoc

Copy of https://reviews.llvm.org/D72073?id=235842, submitting with 
ilya-biryukov's permission.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76061/new/

https://reviews.llvm.org/D76061

Files:
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/SourceLocationTest.cpp

Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -21,6 +21,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
+#include "llvm/Testing/Support/Annotations.h"
 
 namespace clang {
 namespace ast_matchers {
@@ -843,4 +844,25 @@
 }
 
 } // end namespace ast_matchers
+
+namespace decls {
+
+TEST(Decl, MemberPointerStarLoc) {
+  llvm::Annotations Example(R"cpp(
+struct X {};
+int X::$star^* a;
+  )cpp");
+  auto AST = tooling::buildASTFromCode(Example.code());
+  SourceManager &SM = AST->getSourceManager();
+
+  SmallVector Decls;
+  AST->findFileRegionDecls(SM.getMainFileID(), Example.point("star"), 0, Decls);
+  ASSERT_TRUE(Decls.size() == 2);
+
+  VarDecl *D = cast(Decls[1]);
+  auto TL = D->getTypeSourceInfo()->getTypeLoc().castAs();
+  ASSERT_EQ(SM.getFileOffset(TL.getStarLoc()), Example.point("star"));
+}
+
+} // end namespace decls
 } // end namespace clang
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -42,4 +42,5 @@
   clangFrontend
   clangSerialization
   clangTooling
+  LLVMTestingSupport
   )
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5840,7 +5840,7 @@
   }
 
   // Finally fill in MemberPointerLocInfo fields.
-  TL.setStarLoc(Chunk.Loc);
+  TL.setStarLoc(SourceLocation::getFromRawEncoding(Chunk.Mem.StarLoc));
   TL.setClassTInfo(ClsTInfo);
 }
 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5643,8 +5643,8 @@
 return;
   }
 
-  SourceLocation Loc = ConsumeToken();
-  D.SetRangeEnd(Loc);
+  SourceLocation StarLoc = ConsumeToken();
+  D.SetRangeEnd(StarLoc);
   DeclSpec DS(AttrFactory);
   ParseTypeQualifierListOpt(DS);
   D.ExtendWithDeclSpec(DS);
@@ -5655,7 +5655,7 @@
   // Sema will have to catch (syntactically invalid) pointers into global
   // scope. It has to catch pointers into namespace scope anyway.
   D.AddTypeInfo(DeclaratorChunk::getMemberPointer(
-SS, DS.getTypeQualifiers(), DS.getEndLoc()),
+SS, DS.getTypeQualifiers(), StarLoc, DS.getEndLoc()),
 std::move(DS.getAttributes()),
 /* Don't replace range end. */ SourceLocation());
   return;
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -1518,6 +1518,8 @@
   struct MemberPointerTypeInfo {
 /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
 unsigned TypeQuals : 5;
+/// Location of the '*' token.
+unsigned StarLoc;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
@@ -1660,11 +1662,13 @@
 
   static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS,
   unsigned TypeQuals,
-  SourceLocation Loc) {
+  SourceLocation StarLoc,
+  SourceLocation EndLoc) {
 DeclaratorChunk I;
 I.Kind  = MemberPointer;
 I.Loc   = SS.getBeginLoc();
-I.EndLoc= Loc;
+I.EndLoc= EndLoc;
+I.Mem.StarLoc   = StarLoc.getRawEncoding();
 I.Mem.TypeQuals = TypeQuals;
 new (I.Mem.ScopeMem) CXXScopeSpec(SS);
 return I;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 2 inline comments as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:436
+if (ScoredResults.size() >= 3) {
+  // Assume we don't have results from the current file, otherwise the
+  // findNearbyIdentifier() mechanism would have handled them.

Oh whoops, this assumption is another dependency on `findNearbyIdentifier()`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874



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


[PATCH] D76086: [Sema][SVE] Reject arithmetic on pointers to sizeless types

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Do we really want to forbid this?  The expected semantics are clear, and the 
obvious lowering to getelementptr just works.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76086/new/

https://reviews.llvm.org/D76086



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


[PATCH] D76082: [Sema][SVE] Reject arrays of sizeless types

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

It might be reasonable to support this at some point, but sure, I'm fine 
rejecting it for now.  LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76082/new/

https://reviews.llvm.org/D76082



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


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 250018.
nridge marked 9 inline comments as done.
nridge added a comment.
Herald added a subscriber: mgrang.

- Remove fuzzy matching
- Rebase to apply to head, taking only the parts from D75479 
 that I need for index-based lookup (such as 
wordTouching())
- Revise tests so they exercise locateSymbolNamedTextuallyAt() directly, except 
for one smoke test
- Add tests that verify that we do not trigger on dependent or broken code


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindSymbols.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -38,6 +38,7 @@
 namespace {
 
 using ::testing::ElementsAre;
+using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAreArray;
@@ -353,7 +354,7 @@
   R"cpp(// Symbol concatenated inside macro (not supported)
int *pi;
#define POINTER(X) p ## X;
-   int i = *POINTER(^i);
+   int x = *POINTER(^i);
   )cpp",
 
   R"cpp(// Forward class declaration
@@ -606,6 +607,81 @@
   }
 }
 
+TEST(LocateSymbol, TextualSmoke) {
+  auto T = Annotations(
+  R"cpp(
+struct [[MyClass]] {};
+// Comment mentioning M^yClass
+  )cpp");
+
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  EXPECT_THAT(locateSymbolAt(AST, T.point(), Index.get()),
+  ElementsAre(Sym("MyClass", T.range(;
+}
+
+TEST(LocateSymbol, Textual) {
+  const char *Tests[] = {
+  R"cpp(// Comment
+struct [[MyClass]] {};
+// Comment mentioning M^yClass
+  )cpp",
+  R"cpp(// String
+struct [[MyClass]] {};
+const char* s = "String literal mentioning M^yClass";
+  )cpp",
+  R"cpp(// Ifdef'ed out code
+struct [[MyClass]] {};
+#ifdef WALDO
+  M^yClass var;
+#endif
+  )cpp",
+  R"cpp(// Macro definition
+struct [[MyClass]] {};
+#define DECLARE_MYCLASS_OBJ(name) M^yClass name;
+  )cpp",
+  R"cpp(// Invalid code
+/*error-ok*/
+int myFunction(int);
+// Not triggered for token which survived preprocessing.
+int var = m^yFunction();
+  )cpp",
+  R"cpp(// Dependent type
+struct Foo {
+  void uniqueMethodName();
+};
+template 
+void f(T t) {
+  // Not triggered for token which survived preprocessing.
+  t->u^niqueMethodName();
+}
+  )cpp"};
+
+  for (const char *Test : Tests) {
+Annotations T(Test);
+llvm::Optional WantDecl;
+if (!T.ranges().empty())
+  WantDecl = T.range();
+
+auto TU = TestTU::withCode(T.code());
+
+auto AST = TU.build();
+auto Index = TU.index();
+auto Results = locateSymbolNamedTextuallyAt(
+AST, Index.get(),
+cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
+testPath(TU.Filename));
+
+if (!WantDecl) {
+  EXPECT_THAT(Results, IsEmpty()) << Test;
+} else {
+  ASSERT_THAT(Results, ::testing::SizeIs(1)) << Test;
+  EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
+}
+  }
+}
+
 TEST(LocateSymbol, Ambiguous) {
   auto T = Annotations(R"cpp(
 struct Foo {
@@ -680,6 +756,30 @@
Sym("baz", T.range("StaticOverload2";
 }
 
+TEST(LocateSymbol, TextualAmbiguous) {
+  auto T = Annotations(R"cpp(
+struct Foo {
+  void $FooLoc[[uniqueMethodName]]();
+};
+struct Bar {
+  void $BarLoc[[uniqueMethodName]]();
+};
+// Will call u^niqueMethodName() on t.
+template 
+void f(T t);
+  )cpp");
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+  auto Results = locateSymbolNamedTextuallyAt(
+  AST, Index.get(),
+  cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
+  testPath(TU.Filename));
+  EXPECT_THAT(Results,
+  UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
+   Sym("uniqueMethodName", T.range("BarLoc";
+}
+
 TEST(LocateSymbol, TemplateTypedefs) {
   auto T = Annotations(R"cpp(
 template  struct function {};
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -49,6 +49,21 @@
 std::vector locateSymbolA

[PATCH] D76090: [Sema][SVE] Don't allow sizeless types to be caught

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a project: clang.
rsandifo-arm added a parent revision: D76088: [Sema][SVE] Don't allow sizeless 
objects to be thrown.

The same rules for throwing and catching incomplete types also apply
to sizeless types.  This patch enforces that for try-catch statements.
It also makes sure that we use "sizeless type" rather "incomplete type"
in the associated message.  (Both are correct, but "sizeless type" is
more specific and hopefully more user-friendly.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76090

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -399,6 +399,19 @@
   throw local_int8;  // expected-error {{cannot throw object of sizeless 
type 'svint8_t'}}
   throw global_int8_ptr; // expected-error {{cannot throw pointer to object of 
sizeless type 'svint8_t'}}
 
+  try {
+  } catch (int) {
+  }
+  try {
+  } catch (svint8_t) { // expected-error {{cannot catch sizeless type 
'svint8_t'}}
+  }
+  try {
+  } catch (svint8_t *) { // expected-error {{cannot catch pointer to sizeless 
type 'svint8_t'}}
+  }
+  try {
+  } catch (svint8_t &) { // expected-error {{cannot catch reference to 
sizeless type 'svint8_t'}}
+  }
+
   local_int8.~__SVInt8_t(); // expected-error {{object expression of 
non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a 
pseudo-destructor expression}}
 
   (void)svint8_t();
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15472,19 +15472,18 @@
 
   QualType BaseType = ExDeclType;
   int Mode = 0; // 0 for direct type, 1 for pointer, 2 for reference
-  unsigned DK = diag::err_catch_incomplete;
   if (const PointerType *Ptr = BaseType->getAs()) {
 BaseType = Ptr->getPointeeType();
 Mode = 1;
-DK = diag::err_catch_incomplete_ptr;
   } else if (const ReferenceType *Ref = BaseType->getAs()) {
 // For the purpose of error recovery, we treat rvalue refs like lvalue 
refs.
 BaseType = Ref->getPointeeType();
 Mode = 2;
-DK = diag::err_catch_incomplete_ref;
   }
   if (!Invalid && (Mode == 0 || !BaseType->isVoidType()) &&
-  !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
+  !BaseType->isDependentType() &&
+  RequireCompleteSizedType(Loc, BaseType,
+   diag::err_catch_incomplete_or_sizeless, Mode))
 Invalid = true;
 
   if (!Invalid && !ExDeclType->isDependentType() &&
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7007,11 +7007,9 @@
   "volatile qualifier in structured binding declaration is deprecated">,
   InGroup;
 
-def err_catch_incomplete_ptr : Error<
-  "cannot catch pointer to incomplete type %0">;
-def err_catch_incomplete_ref : Error<
-  "cannot catch reference to incomplete type %0">;
-def err_catch_incomplete : Error<"cannot catch incomplete type %0">;
+def err_catch_incomplete_or_sizeless : Error<
+  "cannot catch %select{|pointer to |reference to }0"
+  "%select{incomplete|sizeless}1 type %2">;
 def err_catch_rvalue_ref : Error<"cannot catch exceptions by rvalue 
reference">;
 def err_catch_variably_modified : Error<
   "cannot catch variably modified type %0">;


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -399,6 +399,19 @@
   throw local_int8;  // expected-error {{cannot throw object of sizeless type 'svint8_t'}}
   throw global_int8_ptr; // expected-error {{cannot throw pointer to object of sizeless type 'svint8_t'}}
 
+  try {
+  } catch (int) {
+  }
+  try {
+  } catch (svint8_t) { // expected-error {{cannot catch sizeless type 'svint8_t'}}
+  }
+  try {
+  } catch (svint8_t *) { // expected-error {{cannot catch pointer to sizeless type 'svint8_t'}}
+  }
+  try {
+  } catch (svint8_t &) { // expected-error {{cannot catch reference to sizeless type 'svint8_t'}}
+  }
+
   local_int8.~__SVInt8_t(); // expected-error {{object expression of non-scalar type 'svint8_t' (aka '__SVInt8_t') cannot be used in a pseudo-destructor expression}}
 
   (void)svint8_t();
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15472,19 +15472,1

[PATCH] D76088: [Sema][SVE] Don't allow sizeless objects to be thrown

2020-03-12 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Why is throwing an `svint8_t *` an error?  I don't see any obvious reason to 
forbid that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76088/new/

https://reviews.llvm.org/D76088



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-12 Thread Paula Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb41cc619866: [clang-tidy] Add module for llvm-libc and 
restrict-system-libc-header-check. (authored by PaulkaToast).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75332/new/

https://reviews.llvm.org/D75332

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/resource/include/stdatomic.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/resource/include/stddef.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/math.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/stdio.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/stdlib.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/system/string.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t \
+// RUN:   -- -- -isystem %S/Inputs/llvmlibc/system \
+// RUN:   -resource-dir %S/Inputs/llvmlibc/resource
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdio.h not allowed
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header stdlib.h not allowed
+#include "string.h"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: system libc header string.h not allowed
+#include "stdatomic.h"
+#include 
+// Compiler provided headers should not throw warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers-transitive.cpp
@@ -0,0 +1,8 @@
+// RUN: %check_clang_tidy %s llvmlibc-restrict-system-libc-headers %t \
+// RUN:   -- -header-filter=.* \
+// RUN:   -- -I %S/Inputs/llvmlibc \
+// RUN:   -isystem %S/Inputs/llvmlibc/system \
+// RUN:   -resource-dir %S/Inputs/llvmlibc/resource
+
+#include "transitive.h"
+// CHECK-MESSAGES: :1:1: warning: system libc header math.h not allowed, transitively included from {{.*}}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/llvmlibc/transitive.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -68,6 +68,7 @@
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
+``llvmlibc-``  Checks related to the LLVM-libc coding standards.
 ``misc-``  Checks that we didn't have a better category for.
 ``modernize-`` Checks that advocate usage of modern (currently "modern"
means "C++11") language constructs.
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc-restrict-system-libc-headers.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - llvmlibc-restrict-system-libc-headers
+
+llvmlibc-restrict-system-libc-headers
+=
+
+Finds includes of system libc headers not provided by the compiler within
+llvm-libc implementations.
+
+.. code-block:: c++
+
+   #include // Not allowed because it is part of system libc.
+   #include// Allowed because it is provided by the compiler.
+   #include "internal/stdio.h"   // Allowed because it is NOT part o

[PATCH] D74386: [SVE] Update API ConstantVector::getSplat() to use ElementCount.

2020-03-12 Thread Huihui Zhang via Phabricator via cfe-commits
huihuiz added inline comments.



Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:6542
 
-unsigned End = getTransitionType()->getVectorNumElements();
+auto EC = getTransitionType()->getVectorElementCount();
 if (UseSplat)

efriedma wrote:
> Please write out the type ElementCount.
> 
> This is unfortunately turning the explicit assertion if the type is scalable 
> into a later verifier failure in the case where it isn't a splat.  Please 
> either fix it properly, or change it so the non-splat codepath still asserts.
Good catch! Thanks Eli!

Going with assert for non-splat codepath for scalable vector.

We should implement like:

```
UndefValue *UndefVal = UndefValue::get(getTransitionType());
Type *I32Ty = Type::getInt32Ty(getTransitionType()->getContext());
return ConstantExpr::getInsertElement(UndefVal, Val, ConstantInt::get(I32Ty, 
ExtractIdx));
```

But current target lowering will reject scalable vector earlier while checking 
isTypeLegal(EVT VT). 

I am adding a test to check this. So we get assert once target lowering is 
ready. Then I can bring in this implementation and check for its correctness.

```
define void @simpleOneInstructionPromotion(* %addr1, i32* 
%dest) {
  %in1 = load , * %addr1, align 8
  %extract = extractelement  %in1, i32 1
  %out = or i32 %extract, 1
  store i32 %out, i32* %dest, align 4
  ret void
}

```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74386/new/

https://reviews.llvm.org/D74386



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


[PATCH] D75655: [Docs] Document -lto-whole-program-visibility

2020-03-12 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added a comment.

@pcc

> That case seems somewhat questionable to me. If the symbols are being 
> exported, it is presumably for the purpose of allowing the symbols to be used 
> outside of the defining DSO. But LTO visibility based optimizations could 
> make any such use of the symbols unsafe. For example with WPD it's unsafe to 
> derive outside of the defining DSO and with dead virtual function elimination 
> it's unsafe to call virtual functions outside of the defining DSO.

True, but still direct (cross DSO) calls and globals accesses are possible and 
do not require explicitly setting visibility everywhere. That was my point.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75655/new/

https://reviews.llvm.org/D75655



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


[PATCH] D76087: [Sema][SVE] Reject sizeless types in exception specs

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a project: clang.
rsandifo-arm added a parent revision: D76086: [Sema][SVE] Reject arithmetic on 
pointers to sizeless types.

The same rules for throwing and catching incomplete types also
apply to sizeless types.  This patch enforces that for explicit
exception specs.

(In practice, throwing pointers to sizeless types could probably
be handled without problems.  It would be an odd thing to do though,
and so it didn't seem worth treating as a special case.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76087

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -345,6 +345,12 @@
 constexpr int ce_taking_int8(svint8_t) { return 1; } // expected-error 
{{constexpr function's 1st parameter type 'svint8_t' (aka '__SVInt8_t') is not 
a literal type}}
 #endif
 
+#if __cplusplus < 201703L
+void throwing_func() throw(svint8_t); // expected-error {{sizeless 
type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+void throwing_pointer_func() throw(svint8_t *);   // expected-error {{pointer 
to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception 
specification}}
+void throwing_reference_func() throw(svint8_t &); // expected-error 
{{reference to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in 
exception specification}}
+#endif
+
 template 
 void template_fn_direct(T) {}
 template 
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -167,6 +167,14 @@
   RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range))
 return ReturnValueOnError;
 
+  // The MSVC compatibility mode doesn't extend to sizeless types,
+  // so diagnose them separately.
+  if (PointeeT->isSizelessType()) {
+Diag(Range.getBegin(), diag::err_sizeless_in_exception_spec)
+<< Kind << PointeeT << Range;
+return true;
+  }
+
   return false;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1534,6 +1534,9 @@
 def err_incomplete_in_exception_spec : Error<
   "%select{|pointer to |reference to }0incomplete type %1 is not allowed "
   "in exception specification">;
+def err_sizeless_in_exception_spec : Error<
+  "%select{|pointer to |reference to }0sizeless type %1 is not allowed "
+  "in exception specification">;
 def ext_incomplete_in_exception_spec : 
ExtWarn,
   InGroup;
 def err_rref_in_exception_spec : Error<


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -345,6 +345,12 @@
 constexpr int ce_taking_int8(svint8_t) { return 1; } // expected-error {{constexpr function's 1st parameter type 'svint8_t' (aka '__SVInt8_t') is not a literal type}}
 #endif
 
+#if __cplusplus < 201703L
+void throwing_func() throw(svint8_t); // expected-error {{sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+void throwing_pointer_func() throw(svint8_t *);   // expected-error {{pointer to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+void throwing_reference_func() throw(svint8_t &); // expected-error {{reference to sizeless type 'svint8_t' (aka '__SVInt8_t') is not allowed in exception specification}}
+#endif
+
 template 
 void template_fn_direct(T) {}
 template 
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -167,6 +167,14 @@
   RequireCompleteType(Range.getBegin(), PointeeT, DiagID, Kind, Range))
 return ReturnValueOnError;
 
+  // The MSVC compatibility mode doesn't extend to sizeless types,
+  // so diagnose them separately.
+  if (PointeeT->isSizelessType()) {
+Diag(Range.getBegin(), diag::err_sizeless_in_exception_spec)
+<< Kind << PointeeT << Range;
+return true;
+  }
+
   return false;
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1534,6 +1534,9 @@
 def err_incomplete_in_exception

  1   2   3   >