[clang] e59335e - [clang][DR] Add test for DR1227 and mark it as complete

2022-03-30 Thread Markus Böck via cfe-commits

Author: Markus Böck
Date: 2022-03-30T09:25:52+02:00
New Revision: e59335e891105d75ece5f7f4c40b5eaff6ce2f63

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

LOG: [clang][DR] Add test for DR1227 and mark it as complete

DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1227

This DR has been implemented in Clang as far back as I could check. This patch 
simply adds a test and comment to mark it as complete.

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

Added: 


Modified: 
clang/test/CXX/drs/dr12xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index 1bc4c39734435..dcc131104e7bd 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -27,6 +27,21 @@ namespace dr1213 { // dr1213: 7
 #endif
 }
 
+#if __cplusplus >= 201103L
+namespace dr1227 { // dr1227: yes
+template  struct A { using X = typename T::X; }; // expected-error 
{{type 'int' cannot be used prior to '::' because it has no members}}
+template  typename T::X f(typename A::X);
+template  void f(...) { }
+template  auto g(typename A::X) -> typename T::X; // expected-note 
{{in instantiation of template class 'dr1227::A' requested here}}
+template  void g(...) { }
+
+void h() {
+  f(0); // OK, substituting return type causes deduction to fail
+  g(0); // expected-note {{while substituting explicitly-specified 
template arguments into function template 'g'}}
+}
+}
+#endif
+
 namespace dr1250 { // dr1250: 3.9
 struct Incomplete;
 

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index e730d6088ebaf..ef131b9a71e67 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -7176,7 +7176,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg1227";>1227
 CD3
 Mixing immediate and non-immediate contexts in deduction failure
-Unknown
+Yes
   
   
 https://wg21.link/cwg1228";>1228



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


[PATCH] D122682: [clang][DR] Add test for DR1227 and mark it as complete

2022-03-30 Thread Markus Böck via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe59335e89110: [clang][DR] Add test for DR1227 and mark it as 
complete (authored by zero9178).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122682

Files:
  clang/test/CXX/drs/dr12xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7176,7 +7176,7 @@
 https://wg21.link/cwg1227";>1227
 CD3
 Mixing immediate and non-immediate contexts in deduction failure
-Unknown
+Yes
   
   
 https://wg21.link/cwg1228";>1228
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -27,6 +27,21 @@
 #endif
 }
 
+#if __cplusplus >= 201103L
+namespace dr1227 { // dr1227: yes
+template  struct A { using X = typename T::X; }; // expected-error 
{{type 'int' cannot be used prior to '::' because it has no members}}
+template  typename T::X f(typename A::X);
+template  void f(...) { }
+template  auto g(typename A::X) -> typename T::X; // expected-note 
{{in instantiation of template class 'dr1227::A' requested here}}
+template  void g(...) { }
+
+void h() {
+  f(0); // OK, substituting return type causes deduction to fail
+  g(0); // expected-note {{while substituting explicitly-specified 
template arguments into function template 'g'}}
+}
+}
+#endif
+
 namespace dr1250 { // dr1250: 3.9
 struct Incomplete;
 


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7176,7 +7176,7 @@
 https://wg21.link/cwg1227";>1227
 CD3
 Mixing immediate and non-immediate contexts in deduction failure
-Unknown
+Yes
   
   
 https://wg21.link/cwg1228";>1228
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -27,6 +27,21 @@
 #endif
 }
 
+#if __cplusplus >= 201103L
+namespace dr1227 { // dr1227: yes
+template  struct A { using X = typename T::X; }; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+template  typename T::X f(typename A::X);
+template  void f(...) { }
+template  auto g(typename A::X) -> typename T::X; // expected-note {{in instantiation of template class 'dr1227::A' requested here}}
+template  void g(...) { }
+
+void h() {
+  f(0); // OK, substituting return type causes deduction to fail
+  g(0); // expected-note {{while substituting explicitly-specified template arguments into function template 'g'}}
+}
+}
+#endif
+
 namespace dr1250 { // dr1250: 3.9
 struct Incomplete;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8a72391f609f: [IR] Require intrinsic struct return type to 
be anonymous (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D122471?vs=418812&id=419058#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

Files:
  clang/test/CodeGenCUDA/texture.cu
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Function.cpp
  llvm/test/Bitcode/intrinsics-struct-upgrade.ll
  llvm/test/Bitcode/intrinsics-struct-upgrade.ll.bc
  llvm/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
  llvm/test/CodeGen/X86/fast-isel-extract.ll

Index: llvm/test/CodeGen/X86/fast-isel-extract.ll
===
--- llvm/test/CodeGen/X86/fast-isel-extract.ll
+++ llvm/test/CodeGen/X86/fast-isel-extract.ll
@@ -1,7 +1,6 @@
 ; RUN: llc < %s -mtriple x86_64-apple-darwin11 -O0 -fast-isel-abort=1 | FileCheck %s
 
 %struct.x = type { i64, i64 }
-%addovf = type { i32, i1 }
 declare %struct.x @f()
 
 define void @test1(i64*) nounwind ssp {
@@ -28,13 +27,13 @@
 ; CHECK: addq $10, %rdx
 }
 
-declare %addovf @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
+declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
 
 define void @test3(i32 %x, i32 %y, i32* %z) {
-  %r = call %addovf @llvm.sadd.with.overflow.i32(i32 %x, i32 %y)
-  %sum = extractvalue %addovf %r, 0
+  %r = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %x, i32 %y)
+  %sum = extractvalue { i32, i1 } %r, 0
   %sum3 = mul i32 %sum, 3
-  %bit = extractvalue %addovf %r, 1
+  %bit = extractvalue { i32, i1 } %r, 1
   br i1 %bit, label %then, label %end
   
 then:
Index: llvm/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
===
--- llvm/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
+++ llvm/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
@@ -4,9 +4,8 @@
 ; RUN: llc < %s -O0 -mcpu=x86-64 -mattr=+avx512f | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
 target triple = "x86_64-apple-darwin10"
-	%0 = type { i32, i1 }		; type %0
 
-declare %0 @llvm.sadd.with.overflow.i32(i32, i32) nounwind
+declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind
 
 define fastcc i32 @test() nounwind {
 entry:
@@ -16,12 +15,12 @@
 ; CHECK-NEXT:addl $0, [[REG]]
 ; CHECK-NEXT:seto {{%[a-z]+l}}
 ; CHECK: jo LBB0_2
-	%tmp1 = call %0 @llvm.sadd.with.overflow.i32(i32 1, i32 0)
-	%tmp2 = extractvalue %0 %tmp1, 1
+	%tmp1 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 1, i32 0)
+	%tmp2 = extractvalue { i32, i1 } %tmp1, 1
 	br i1 %tmp2, label %.backedge, label %BB3
 
 BB3:
-	%tmp4 = extractvalue %0 %tmp1, 0
+	%tmp4 = extractvalue { i32, i1 } %tmp1, 0
 	br label %.backedge
 
 .backedge:
Index: llvm/test/Bitcode/intrinsics-struct-upgrade.ll
===
--- /dev/null
+++ llvm/test/Bitcode/intrinsics-struct-upgrade.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-dis < %s.bc | FileCheck %s
+
+%struct.__neon_int8x8x2_t = type { <8 x i8>, <8 x i8> }
+
+declare %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(i8*)
+
+; CHECK-LABEL: define %struct.__neon_int8x8x2_t @test_named_struct_return(i8* %A) {
+; CHECK:  %1 = call { <8 x i8>, <8 x i8> } @llvm.aarch64.neon.ld2.v8i8.p0i8(i8* %A)
+; CHECK:  %2 = extractvalue { <8 x i8>, <8 x i8> } %1, 0
+; CHECK:  %3 = insertvalue %struct.__neon_int8x8x2_t poison, <8 x i8> %2, 0
+; CHECK:  %4 = extractvalue { <8 x i8>, <8 x i8> } %1, 1
+; CHECK:  %5 = insertvalue %struct.__neon_int8x8x2_t %3, <8 x i8> %4, 1
+; CHECK:  ret %struct.__neon_int8x8x2_t %5
+
+define %struct.__neon_int8x8x2_t @test_named_struct_return(i8* %A) {
+  %val = call %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(i8* %A)
+  ret %struct.__neon_int8x8x2_t %val
+}
Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -1475,9 +1475,19 @@
   PointerType *PT = dyn_cast(Ty);
   if (!PT || PT->getAddressSpace() != D.Pointer_AddressSpace)
 return true;
-  if (!PT->isOpaque())
+  if (!PT->isOpaque()) {
+/* Manually consume a pointer to empty struct descriptor, which is
+ * used for externref. We don't want to enforce that the struct is
+ * anonymous in this case. (This renders externref intrinsics
+ * non-unique, but this will go away with opaque pointers anyway.) */
+if (Infos.front().Kind == IITDescriptor::Struct &&
+Infos.front().Struct_NumElements == 0) {
+  

[clang] 8a72391 - [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-30T09:51:24+02:00
New Revision: 8a72391f609f016b0aef17e728aca65027a80cc4

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

LOG: [IR] Require intrinsic struct return type to be anonymous

This is an alternative to D122376. Rather than working around the
problem, this patch requires that struct return types in intrinsics
are anonymous/literal and adds auto-upgrade code to convert
existing uses of intrinsics with named struct types.

This ensures that the mapping between intrinsic name and
intrinsic function type is actually bijective, as it is supposed
to be.

This also fixes https://github.com/llvm/llvm-project/issues/37891.

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

Added: 
llvm/test/Bitcode/intrinsics-struct-upgrade.ll
llvm/test/Bitcode/intrinsics-struct-upgrade.ll.bc

Modified: 
clang/test/CodeGenCUDA/texture.cu
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Function.cpp
llvm/test/CodeGen/X86/2009-04-12-FastIselOverflowCrash.ll
llvm/test/CodeGen/X86/fast-isel-extract.ll

Removed: 




diff  --git a/clang/test/CodeGenCUDA/texture.cu 
b/clang/test/CodeGenCUDA/texture.cu
index 031d238e507cc..f7ac5cc739d6f 100644
--- a/clang/test/CodeGenCUDA/texture.cu
+++ b/clang/test/CodeGenCUDA/texture.cu
@@ -5,6 +5,9 @@
 // RUN: echo "GPU binary would be here" > %t
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu 
-target-sdk-version=8.0 -fcuda-include-gpubinary %t -emit-llvm -o - %s | 
FileCheck --check-prefix=HOST %s
 
+// Accessing nvvm intrinsics in this way no longer works.
+// XFAIL: *
+
 struct textureReference {
   int desc;
 };

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index da01227a4c4a4..bf52b098d8d88 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -576,19 +576,6 @@ static bool UpgradeIntrinsicFunction1(Function *F, 
Function *&NewFn) {
 F->arg_begin()->getType());
   return true;
 }
-static const Regex 
vldRegex("^arm\\.neon\\.vld([1234]|[234]lane)\\.v[a-z0-9]*$");
-if (vldRegex.match(Name)) {
-  auto fArgs = F->getFunctionType()->params();
-  SmallVector Tys(fArgs.begin(), fArgs.end());
-  // Can't use Intrinsic::getDeclaration here as the return types might
-  // then only be structurally equal.
-  FunctionType* fType = FunctionType::get(F->getReturnType(), Tys, false);
-  StringRef Suffix =
-  F->getContext().supportsTypedPointers() ? "p0i8" : "p0";
-  NewFn = Function::Create(fType, F->getLinkage(), F->getAddressSpace(),
-   "llvm." + Name + "." + Suffix, F->getParent());
-  return true;
-}
 static const Regex 
vstRegex("^arm\\.neon\\.vst([1234]|[234]lane)\\.v[a-z0-9]*$");
 if (vstRegex.match(Name)) {
   static const Intrinsic::ID StoreInts[] = {Intrinsic::arm_neon_vst1,
@@ -1017,6 +1004,25 @@ static bool UpgradeIntrinsicFunction1(Function *F, 
Function *&NewFn) {
 if (UpgradeX86IntrinsicFunction(F, Name, NewFn))
   return true;
   }
+
+  if (auto *ST = dyn_cast(F->getReturnType())) {
+if (!ST->isLiteral() || ST->isPacked()) {
+  // Replace return type with literal non-packed struct.
+  auto *FT = F->getFunctionType();
+  auto *NewST = StructType::get(ST->getContext(), ST->elements());
+  auto *NewFT = FunctionType::get(NewST, FT->params(), FT->isVarArg());
+  std::string Name = F->getName().str();
+  rename(F);
+  NewFn = Function::Create(NewFT, F->getLinkage(), F->getAddressSpace(),
+   Name, F->getParent());
+
+  // The new function may also need remangling.
+  if (auto Result = llvm::Intrinsic::remangleIntrinsicFunction(F))
+NewFn = *Result;
+  return true;
+}
+  }
+
   // Remangle our intrinsic since we upgrade the mangling
   auto Result = llvm::Intrinsic::remangleIntrinsicFunction(F);
   if (Result != None) {
@@ -3784,12 +3790,33 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function 
*NewFn) {
 return;
   }
 
-  const auto &DefaultCase = [&NewFn, &CI]() -> void {
-// Handle generic mangling change, but nothing else
-assert(
-(CI->getCalledFunction()->getName() != NewFn->getName()) &&
-"Unknown function for CallBase upgrade and isn't just a name change");
-CI->setCalledFunction(NewFn);
+  const auto &DefaultCase = [&]() -> void {
+if (CI->getFunctionType() == NewFn->getFunctionType()) {
+  // Handle generic mangling change.
+  assert(
+  (CI->getCalledFunction()->getName() != NewFn->getName()) &&
+  "Unknown function for CallBase upgrade and isn't just a name 
change");
+  CI->setCalledFunction(NewFn);
+  return;
+}
+
+// This m

[PATCH] D122231: [clang][dataflow] Add support for `value_or` in a comparison.

2022-03-30 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:279
+ cast_or_null(Env.getValue(*ComparisonExprLoc))) {
+Env.setValue(*ComparisonExprLoc,
+ Env.makeAnd(*CurrentValue, ComparisonValue));

ymandel wrote:
> sgatev wrote:
> > ymandel wrote:
> > > ymandel wrote:
> > > > xazax.hun wrote:
> > > > > I am still wondering a bit about this case. 
> > > > > 
> > > > > We generate: `HasValueVal and ContentsNotEqX and CurrentValue`.'
> > > > > I wonder if we want: `HasValueVal  and (ContentsNotEqX  <=> 
> > > > > CurrentValue)` instead?  Or even `HasValueVal  and CurrentValue`?
> > > > I don't think that the iff version is right, but `HasValueVal  and 
> > > > CurrentValue` could be. My concern is that we're not guaranteed that 
> > > > `CurrentValue` is populated. And, even if we were, it doesn't feel 
> > > > quite right. Assuming its a high fidelity model, we get (logically): 
> > > > `HasValue(opt) and Ne(ValueOr(opt,X),X)`. Then, when negated (say, on 
> > > > an else branch) we get `not(HasValue(opt)) or 
> > > > not(Ne(ValueOr(opt,X),X))` which is equivalent to `not(HasValue(opt)) 
> > > > or Eq(ValueOr(opt,X),X)`. While  true, it seems redundant, since the 
> > > > first clause should be derivable from the second (assuming an 
> > > > interpretatable semantics to the `ValueOr` predicate).
> > > > 
> > > > Regardless, it might be better to step back and figure out how this 
> > > > should be done systematically. I'll try to come back with a proposal on 
> > > > that.
> > > > Regardless, it might be better to step back and figure out how this 
> > > > should be done systematically. I'll try to come back with a proposal on 
> > > > that.
> > > 
> > > Here's what I have: in general, we're aiming for all models to be a sound 
> > > (over) approximation of reality. That is what we're doing here as well. 
> > > Yet, that poses a problem for the interpretation of the boolean not 
> > > operator. If its operand is an overapproximation, then I believe the 
> > > naive approach gives you an under approximation. That's the problem we're 
> > > hitting when reasoning about the negation.
> > > 
> > > I'm not sure how to handle this. Stanislav -- have we dealt with this 
> > > issue before?
> > > 
> > > That said, if we go back to the previous approach, of adding the 
> > > information to the path condition, I think we avoid this problem, since 
> > > the path conditions don't get negated.  To Gabor's earlier point:
> > > > There is an implication in the reverse direction as well. In case we 
> > > > know the optional is empty, we can prune one of the branches from the 
> > > > analysis. Is it possible to implement that with the current status of 
> > > > the framework?
> > > I think is covered by the condition we're adding. Namely:
> > > ```
> > > ExprValue => has_value
> > > ```
> > > where `ExprValue` is the truth value of the boolean expression.
> > > 
> > > So, the implication in the reverse direction is:
> > > ```
> > > !has_value => !ExprValue
> > > ```
> > > that is, if we know the optional doesn't hold a value, then we know that 
> > > `opt.value_or(X) = X`
> > > 
> > > But, that implication is the contrapositive of our own, so I think it's 
> > > already implicitly covered by adding the single implication. Does that 
> > > sound right?
> > I'm not following where `Env.makeAnd(*CurrentValue, ComparisonValue)` comes 
> > from so I'd question whether it's sound or not. I would have expected to 
> > see something like `ExprValue => has_value` (which I believe was the case 
> > in the first iteration) and I see no issues with the contrapositive. If you 
> > have `x => y` and `not y` in the flow condition, you'll be able to infer 
> > that `not x` is true (assuming no other statements for `x`). How we use 
> > this to prune branches from the analysis is a question of its own.
> I think the new version resolves this?
Yes, modelling these using implications looks good to me!



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:275
+  State.Env.getValue(*ValueOrPredExpr, SkipPast::None));
+  if (ExprValue == nullptr) {
+auto &ExprLoc = State.Env.createStorageLocation(*ValueOrPredExpr);

Why do this conditionally? I think we should set a value regardless of whether 
another model has already done so.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:525
+  // opt.value_or(X) != X
+  .CaseOf(isValueOrCondition(), transferValueOrNotEqX)
+

Call this `isValueOrNotEqX` for consistency?



Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1720
+void target() {
+  $ns::$optional opt;
+  if (opt.value_or(nullptr) != nullptr) {

I sug

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/CMakeLists.txt:520
+   ON "${CMAKE_BUILD_TYPE} MATCHES Debug" OFF)
+if(CLANG_CRASH_SAVE_TEMPS)
+  add_definitions(-DCLANG_CRASH_SAVE_TEMPS)

Could you add this to the config.h header instead?



Comment at: clang/lib/Driver/Driver.cpp:1434
 StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
+#ifdef CLANG_CRASH_SAVE_TEMPS
+  constexpr bool SaveReproTemps = true;

This could be simplified with `#cmakedefine01` in the config header



Comment at: clang/test/Driver/crash-report-clang-cl.cpp:1
+// UNSUPPORTED: windows
+

I think it would be cleaner to add a new feature if tar is available in $PATH 
instead of ignoring all windows bots. Some might have tar installed.



Comment at: clang/test/Driver/crash-report-clang-cl.cpp:8
 // RUN: -fcrash-diagnostics-dir=%t -- %s 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-clang-cl-*.cpp | FileCheck --check-prefix=CHECKSRC 
%s
-// RUN: cat %t/crash-report-clang-cl-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-clang-cl-*.cpp" \
+// RUN: | FileCheck --check-prefix=CHECKSRC %s

Alternatively, if we had an env var/command line option to keep the cpp/sh, we 
could use that to avoid the dependency on tar in this test.



Comment at: clang/test/Driver/crash-report-save-temps.c:14
+
+// RUN: false

Is this line intentional?


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

https://reviews.llvm.org/D122335

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


[PATCH] D122659: [clang][preprocessor] Allow calling DumpToken() on annotation tokens

2022-03-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 419073.

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

https://reviews.llvm.org/D122659

Files:
  clang/lib/Lex/Preprocessor.cpp


Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -232,8 +232,10 @@
 }
 
 void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
-  llvm::errs() << tok::getTokenName(Tok.getKind()) << " '"
-   << getSpelling(Tok) << "'";
+  llvm::errs() << tok::getTokenName(Tok.getKind());
+
+  if (!Tok.isAnnotation())
+llvm::errs() << " '" << getSpelling(Tok) << "'";
 
   if (!DumpFlags) return;
 


Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -232,8 +232,10 @@
 }
 
 void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
-  llvm::errs() << tok::getTokenName(Tok.getKind()) << " '"
-   << getSpelling(Tok) << "'";
+  llvm::errs() << tok::getTokenName(Tok.getKind());
+
+  if (!Tok.isAnnotation())
+llvm::errs() << " '" << getSpelling(Tok) << "'";
 
   if (!DumpFlags) return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-30 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu updated this revision to Diff 419076.
zixuan-wu added a comment.
Herald added subscribers: StephenFan, dexonsmith, MaskRay.

Address comments.


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

https://reviews.llvm.org/D121445

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/CSKY.cpp
  clang/lib/Basic/Targets/CSKY.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Arch/CSKY.cpp
  clang/lib/Driver/ToolChains/Arch/CSKY.h
  clang/lib/Driver/ToolChains/CSKYToolChain.cpp
  clang/lib/Driver/ToolChains/CSKYToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/bin/ld
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/ck860v/lib/.keep
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/ck860v/usr/lib/crt1.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/lib/.keep
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/csky-linux-gnuabiv2/libc/usr/lib/crt1.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crtbegin.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crtend.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crti.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/ck860v/crtn.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crtend.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crti.o
  
clang/test/Driver/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/crtn.o
  clang/test/Driver/csky-arch-error.c
  clang/test/Driver/csky-arch.c
  clang/test/Driver/csky-cpus-error.c
  clang/test/Driver/csky-cpus.c
  clang/test/Driver/csky-toolchain.c
  clang/test/Preprocessor/csky-target-features.c
  clang/test/Preprocessor/init-csky.c
  llvm/lib/Support/CSKYTargetParser.cpp
  llvm/unittests/Support/CSKYTargetParserTest.cpp

Index: llvm/unittests/Support/CSKYTargetParserTest.cpp
===
--- llvm/unittests/Support/CSKYTargetParserTest.cpp
+++ llvm/unittests/Support/CSKYTargetParserTest.cpp
@@ -1061,18 +1061,11 @@
   EXPECT_FALSE(CSKY::getExtensionFeatures(CSKY::AEK_INVALID, Features));
 
   for (auto &E : Extensions) {
-// test +extension
-Features.clear();
 CSKY::getExtensionFeatures(E.first, Features);
 EXPECT_TRUE(llvm::is_contained(Features, E.second.at(0)));
-EXPECT_EQ(Extensions.size(), Features.size());
-
-// test -extension
-Features.clear();
-CSKY::getExtensionFeatures(~E.first, Features);
-EXPECT_TRUE(llvm::is_contained(Features, E.second.at(1)));
-EXPECT_EQ(Extensions.size(), Features.size());
   }
+
+  EXPECT_EQ(Extensions.size(), Features.size());
 }
 
 TEST(TargetParserTest, CSKYFPUFeatures) {
Index: llvm/lib/Support/CSKYTargetParser.cpp
===
--- llvm/lib/Support/CSKYTargetParser.cpp
+++ llvm/lib/Support/CSKYTargetParser.cpp
@@ -172,8 +172,6 @@
   for (const auto &AE : CSKYARCHExtNames) {
 if ((Extensions & AE.ID) == AE.ID && AE.Feature)
   Features.push_back(AE.Feature);
-else if (AE.NegFeature)
-  Features.push_back(AE.NegFeature);
   }
 
   return true;
Index: clang/test/Preprocessor/init-csky.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-csky.c
@@ -0,0 +1,211 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=csky < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=CSKY %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=csky-unknown-linux < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefixes=CSKY,CSKY-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=csky \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck -match-full-lines \
+// RUN: -check-prefixes=CSKY,CSKY-INT128 %s
+// CSKY: #define _ILP32 1
+// CSKY: #define __ATOMIC_ACQUIRE 2
+// CSKY: #define __ATOMIC_ACQ_REL 4
+// CSKY: #define __ATOMIC_CONSUME 1
+// CSKY: #define __ATOMIC_RELAXED 0
+// CSKY: #define __ATOMIC_RELEASE 3
+// CSKY: #define __ATOMIC_SEQ_CST 5
+// CSKY: #define __BIGGEST_ALIGNMENT__ 4
+// CSKY: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// CSKY: #define __CHAR16_TYPE__ unsigned short
+// CSKY: #define __CHAR32_TYPE__ unsigned int
+// CSKY: #define __CHAR_BIT__ 8
+// CSKY: #define __DBL_DECIMAL_DIG__ 17
+// CSKY: #define __DBL_DENORM_

[PATCH] D122404: [clang][AArc64][SVE] Add support for comparison operators on SVE types

2022-03-30 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm accepted this revision.
peterwaller-arm added a comment.
This revision is now accepted and ready to land.

LGTM, looks like the formatter might have hit some lines you didn't intend to 
change -- if it's not too invasive perhaps worth a seperate NFC patch to format 
the file?




Comment at: clang/lib/Sema/SemaExpr.cpp:13080-13086
+<< RHS.get()->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
 // Suggest replacing the logical operator with the bitwise version
 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
 << (Opc == BO_LAnd ? "&" : "|")
-<< FixItHint::CreateReplacement(SourceRange(
- Loc, 
getLocForEndOfToken(Loc)),
-Opc == BO_LAnd ? "&" : "|");
+<< FixItHint::CreateReplacement(
+   SourceRange(Loc, getLocForEndOfToken(Loc)),
+   Opc == BO_LAnd ? "&" : "|");

Unintended whitespace changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122404

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


[PATCH] D103094: [analyzer] Implemented RangeSet::Factory::castTo function to perform promotions, truncations and conversions

2022-03-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D103094#3403075 , @ASDenysPetrov 
wrote:

> Ping.

I am still interested in this! I am sorry for being inactive with it lately, I 
hope I'll have time soon to continue the review of this patch stack.


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

https://reviews.llvm.org/D103094

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


[PATCH] D122712: Make test case warning more specific for pattern match

2022-03-30 Thread Ranjeet Singh via Phabricator via cfe-commits
rs created this revision.
rs added a reviewer: benshi001.
Herald added subscribers: Jim, dylanmckay.
Herald added a project: All.
rs requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It's possible that other compilers based on llvm might produce other warnings. 
So I think it would be good if this warning was a bit more specific.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122712

Files:
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -39,7 +39,7 @@
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree 
-mmcu=atmega328 -S %s 2>&1 | FileCheck --check-prefix=NOWARN %s
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 -S %s 
2>&1 | FileCheck --check-prefix=NOWARN %s
-// NOWARN-NOT: warning:
+// NOWARN-NOT: warning: no target microcontroller specified on command line, 
cannot link standard libraries
 
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -S %s 2>&1 
| FileCheck --check-prefixes=NOMCU,LINKA %s
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -S %s 2>&1 | FileCheck 
--check-prefixes=NOMCU,LINKA %s


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -39,7 +39,7 @@
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -mmcu=atmega328 -S %s 2>&1 | FileCheck --check-prefix=NOWARN %s
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -mmcu=atmega328 -S %s 2>&1 | FileCheck --check-prefix=NOWARN %s
-// NOWARN-NOT: warning:
+// NOWARN-NOT: warning: no target microcontroller specified on command line, cannot link standard libraries
 
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -S %s 2>&1 | FileCheck --check-prefixes=NOMCU,LINKA %s
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/ -S %s 2>&1 | FileCheck --check-prefixes=NOMCU,LINKA %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121387: [analyzer] ClangSA should tablegen doc urls refering to the main doc page

2022-03-30 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

(Side note: you should avoid the list-expansion syntax in URLs because browsers 
do not understand them and result in links that are not leading anywhere.)

I like this. We should continue getting to the point where the documentation is 
having a uniform layout.


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

https://reviews.llvm.org/D121387

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


[PATCH] D122587: [clang][NFC] Extract the EmitAssemblyHelper::TargetTriple member

2022-03-30 Thread Pavel Samolysov via Phabricator via cfe-commits
psamolysov-intel added a comment.

Thank you @tejohnson for the approve. If there are no objections from someone 
could you (or another committer) help me with the landing, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122587

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


[PATCH] D120874: [C++20] [Modules] Use '-' as the separator of partitions when searching in filesystems

2022-03-30 Thread Alexandre Rames via Phabricator via cfe-commits
arames added a comment.

I was was asked to chime in to assess whether this patch could be a problem for
the prebuilt-implicit clang modules workflow. No problem here.
With prebuilt modules, the output file name has to be specified manually. So the
mapping does not change the existing requirement of managing the file names to
avoid collissions.
Even in the future with implicit modules - as noted by others - `:` and `-` are
not allowed in the clang module name in the `.modulemap`, so there cannot be any
conflict.

A couple comments on the way. Take them with a grain of salt, since I don't much
about how this is going to be used or what stage of the work this is.

I see the mapping is only applied on the "prebuilt" code path, and not the
"implicit" and "prebuilt implicit" code paths. I suppose at some point, module
generation will be implicit. So any particular handling of `ModuleName` to be
appended to the filesystem path will need to be done on different code paths. So
I would already abstract this away in a helper.

Without much of an informed opinion, I find @iains makes a valid point. Does
this kind of mapping (semantic module name to name being used for filesystem
search/storage) belong at a higher level ? Maybe that's to be answered or worked
on later as well.


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

https://reviews.llvm.org/D120874

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


[PATCH] D122713: [RISCV] [NFC] Add tests for vector load/store overloaded intrinsics of FP16

2022-03-30 Thread Chenbing.Zheng via Phabricator via cfe-commits
Chenbing.Zheng created this revision.
Chenbing.Zheng added reviewers: craig.topper, HsiangKai, frasercrmck, benshi001.
Chenbing.Zheng added a project: LLVM.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
Chenbing.Zheng requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, jacquesguan, 
MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122713

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxseg_mask.c

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


[PATCH] D122409: [libclang] Add missing CursorKind enums defined in Index.h.

2022-03-30 Thread Tao He via Phabricator via cfe-commits
sighingnow added a comment.

Ping @jdoerfert


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122409

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


[PATCH] D122712: Make test case warning more specific for pattern match

2022-03-30 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

I do not like this change, since

1. actually there may be many kinds of warnings emitted by the clang-driver-avr 
depending on different options, and this single line `// NOWARN-NOT: warning:` 
means non of these possible warnings will be emitted.

2. we may add/delete/modify warnings in the future, so we should not make it 
specific .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122712

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


[clang] cf4a67b - Don't diagnostic atomic object access as UB in an unevaluated context

2022-03-30 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-03-30T07:12:49-04:00
New Revision: cf4a67bcbbb109347b1e2d6cedf69bae142a182f

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

LOG: Don't diagnostic atomic object access as UB in an unevaluated context

We started diagnosing this situation with a more clear diagnostic
message, but it was pointed out that unevaluated contexts don't really
have the undefined behavior property as there is no runtime access
involved.

This augments the changes in https://reviews.llvm.org/D122656 to not
diagnose in an unevaluated context.

Added: 


Modified: 
clang/lib/Sema/SemaExprMember.cpp
clang/test/Sema/atomic-expr.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 152b39dabe361..cb95f70f445b6 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1298,7 +1298,8 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult 
&R,
   // lvalue. Because this is inherently unsafe as an atomic operation, the
   // warning defaults to an error.
   if (const auto *ATy = BaseType->getAs()) {
-S.Diag(OpLoc, diag::warn_atomic_member_access);
+S.DiagRuntimeBehavior(OpLoc, nullptr,
+  S.PDiag(diag::warn_atomic_member_access));
 BaseType = ATy->getValueType().getUnqualifiedType();
 BaseExpr = ImplicitCastExpr::Create(
 S.Context, IsArrow ? S.Context.getPointerType(BaseType) : BaseType,

diff  --git a/clang/test/Sema/atomic-expr.c b/clang/test/Sema/atomic-expr.c
index 86cd32ce338c8..6c6823c848722 100644
--- a/clang/test/Sema/atomic-expr.c
+++ b/clang/test/Sema/atomic-expr.c
@@ -102,4 +102,10 @@ void func_16(void) {
   _Atomic(struct { int val; }) z;
   z.val = 12;   // expected-error {{accessing a member of an atomic 
structure or union is undefined behavior}}
   int zval = z.val; // expected-error {{accessing a member of an atomic 
structure or union is undefined behavior}}
+
+  // Don't diagnose in an unevaluated context, however.
+  (void)sizeof(x.val);
+  (void)sizeof(xp->val);
+  (void)sizeof(y.ival);
+  (void)sizeof(yp->ival);
 }



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


[PATCH] D122681: Don't diagnostic atomic object access as UB in an unevaluated context

2022-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the reviews, I've commit in 
cf4a67bcbbb109347b1e2d6cedf69bae142a182f 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122681

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


[clang] cebbfd3 - [RISCV] Add index check for vset/vget

2022-03-30 Thread via cfe-commits

Author: wangpc
Date: 2022-03-30T19:29:13+08:00
New Revision: cebbfd3d22b48cb3681a326bcbd23aaca1ec

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

LOG: [RISCV] Add index check for vset/vget

Index of vset/vget must be a constant integer and be
located in right range.

Reviewed By: kito-cheng

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics/vget-index-out-of-range.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c

Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 14e82e54eacb3..7e73988c33b74 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4098,6 +4098,30 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const 
TargetInfo &TI,
   case RISCVVector::BI__builtin_rvv_vsetvlimax:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3) ||
CheckRISCVLMUL(TheCall, 1);
+  case RISCVVector::BI__builtin_rvv_vget_v: {
+ASTContext::BuiltinVectorTypeInfo ResVecInfo =
+Context.getBuiltinVectorTypeInfo(cast(
+TheCall->getType().getCanonicalType().getTypePtr()));
+ASTContext::BuiltinVectorTypeInfo VecInfo =
+Context.getBuiltinVectorTypeInfo(cast(
+TheCall->getArg(0)->getType().getCanonicalType().getTypePtr()));
+unsigned MaxIndex =
+(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
+(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
+  }
+  case RISCVVector::BI__builtin_rvv_vset_v: {
+ASTContext::BuiltinVectorTypeInfo ResVecInfo =
+Context.getBuiltinVectorTypeInfo(cast(
+TheCall->getType().getCanonicalType().getTypePtr()));
+ASTContext::BuiltinVectorTypeInfo VecInfo =
+Context.getBuiltinVectorTypeInfo(cast(
+TheCall->getArg(2)->getType().getCanonicalType().getTypePtr()));
+unsigned MaxIndex =
+(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
+(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
+  }
   // Check if byteselect is in [0, 3]
   case RISCV::BI__builtin_riscv_aes32dsi_32:
   case RISCV::BI__builtin_riscv_aes32dsmi_32:

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vget-index-out-of-range.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vget-index-out-of-range.c
new file mode 100644
index 0..c8c086686c42e
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vget-index-out-of-range.c
@@ -0,0 +1,341 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh -target-feature 
+experimental-zvfh \
+// RUN:   -fsyntax-only -verify %s
+
+#include 
+
+vint8m1_t test_vget_v_index_not_constant(vint8m2_t src, int index) {
+  // expected-error@+1 {{argument to 'vget_v_i8m2_i8m1' must be a constant 
integer}}
+  return vget_v_i8m2_i8m1(src, index);
+}
+
+vint8m1_t test_vget_v_i8m2_i8m1(vint8m2_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vget_v_i8m2_i8m1(src, 2);
+}
+
+vint8m1_t test_vget_v_i8m4_i8m1(vint8m4_t src) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vget_v_i8m4_i8m1(src, 4);
+}
+
+vint8m2_t test_vget_v_i8m4_i8m2(vint8m4_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vget_v_i8m4_i8m2(src, 2);
+}
+
+vint8m1_t test_vget_v_i8m8_i8m1(vint8m8_t src) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vget_v_i8m8_i8m1(src, 8);
+}
+
+vint8m2_t test_vget_v_i8m8_i8m2(vint8m8_t src) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vget_v_i8m8_i8m2(src, 4);
+}
+
+vint8m4_t test_vget_v_i8m8_i8m4(vint8m8_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vget_v_i8m8_i8m4(src, 2);
+}
+
+vint16m1_t test_vget_v_i16m2_i16m1(vint16m2_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vget_v_i16m2_i16m1(src, 2);
+}
+
+vint16m1_t test_vget_v_i16m4_i16m1(vint16m4_t src) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vget_v_i16m4_i16m1(src, 4);
+}
+
+vint16m2_t test_vget_v_i16m4_i16m2(vint16m4_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vget_v_i16m4_i16m2(src, 2);
+}
+
+vint16m1_t test_vget_v_i16m8_i16m1(vint16m8_t src) {
+  // expected-error@+1 {{ar

[PATCH] D122629: [RISCV] Add index check for vset/vget

2022-03-30 Thread Wang Pengcheng via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcebbfd3d2555: [RISCV] Add index check for vset/vget 
(authored by pcwang-thead).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122629

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics/vget-index-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vset-index-out-of-range.c
@@ -0,0 +1,341 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \
+// RUN:   -fsyntax-only -verify %s
+
+#include 
+
+vint8m1_t test_vset_v_index_not_constant(vint8m2_t dest, vint8m1_t val, int index) {
+  // expected-error@+1 {{argument to 'vset_v_i8m1_i8m2' must be a constant integer}}
+  return vset_v_i8m1_i8m2(dest, index, val);
+}
+
+vint8m2_t test_vset_v_i8m1_i8m2(vint8m2_t dest, vint8m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i8m1_i8m2(dest, 2, val);
+}
+
+vint8m4_t test_vset_v_i8m1_i8m4(vint8m4_t dest, vint8m1_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i8m1_i8m4(dest, 4, val);
+}
+
+vint8m4_t test_vset_v_i8m2_i8m4(vint8m4_t dest, vint8m2_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i8m2_i8m4(dest, 2, val);
+}
+
+vint8m8_t test_vset_v_i8m1_i8m8(vint8m8_t dest, vint8m1_t val) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vset_v_i8m1_i8m8(dest, 8, val);
+}
+
+vint8m8_t test_vset_v_i8m2_i8m8(vint8m8_t dest, vint8m2_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i8m2_i8m8(dest, 4, val);
+}
+
+vint8m8_t test_vset_v_i8m4_i8m8(vint8m8_t dest, vint8m4_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i8m4_i8m8(dest, 2, val);
+}
+
+vint16m2_t test_vset_v_i16m1_i16m2(vint16m2_t dest, vint16m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i16m1_i16m2(dest, 2, val);
+}
+
+vint16m4_t test_vset_v_i16m1_i16m4(vint16m4_t dest, vint16m1_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i16m1_i16m4(dest, 4, val);
+}
+
+vint16m4_t test_vset_v_i16m2_i16m4(vint16m4_t dest, vint16m2_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i16m2_i16m4(dest, 2, val);
+}
+
+vint16m8_t test_vset_v_i16m1_i16m8(vint16m8_t dest, vint16m1_t val) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vset_v_i16m1_i16m8(dest, 8, val);
+}
+
+vint16m8_t test_vset_v_i16m2_i16m8(vint16m8_t dest, vint16m2_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i16m2_i16m8(dest, 4, val);
+}
+
+vint16m8_t test_vset_v_i16m4_i16m8(vint16m8_t dest, vint16m4_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i16m4_i16m8(dest, 2, val);
+}
+
+vint32m2_t test_vset_v_i32m1_i32m2(vint32m2_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i32m1_i32m2(dest, 2, val);
+}
+
+vint32m4_t test_vset_v_i32m1_i32m4(vint32m4_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i32m1_i32m4(dest, 4, val);
+}
+
+vint32m4_t test_vset_v_i32m2_i32m4(vint32m4_t dest, vint32m2_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i32m2_i32m4(dest, 2, val);
+}
+
+vint32m8_t test_vset_v_i32m1_i32m8(vint32m8_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 8 is outside the valid range [0, 7]}}
+  return vset_v_i32m1_i32m8(dest, 8, val);
+}
+
+vint32m8_t test_vset_v_i32m2_i32m8(vint32m8_t dest, vint32m2_t val) {
+  // expected-error@+1 {{argument value 4 is outside the valid range [0, 3]}}
+  return vset_v_i32m2_i32m8(dest, 4, val);
+}
+
+vint32m8_t test_vset_v_i32m4_i32m8(vint32m8_t dest, vint32m4_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i32m4_i32m8(dest, 2, val);
+}
+
+vint64m2_t test_vset_v_i64m1_i64m2(vint64m2_t dest, vint64m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return vset_v_i64m1_i64m2(dest, 2, val

[PATCH] D120992: [analyzer] ReverseNull: New checker to warn for pointer value conditions, if the pointer value is unconditionally non-null

2022-03-30 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus abandoned this revision.
Szelethus added a comment.

Very well :) Let's abandon this in its current state, I share this sentiment:

In D120992#3368118 , @NoQ wrote:

> What I'm trying to say here is, I honestly think re-doing it as CFG-based 
> should be relatively easy. We couldn't make any progress at all without those 
> state splits but in this case it's much less of a fundamental issue so I 
> think it's not worth it to hard-commit to a flawed solution from the start.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120992

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


[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

2022-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaHLSL/num_threads.hlsl:48
+#endif
+
+

There are a few test cases that are missing here:

1) Writing the attribute on the wrong subject.
2) Passing no args to the attribute, passing too many args to the attribute.
3) Function merging where the redeclaration has attributes that don't match. 
e.g.,
```
[numthreads(1, 2, 3)] void func();
[numthreads(4, 5, 6)] void func() {}
```
4) Should the user be able to pick the values via NTTP or other constant 
expressions? e.g.,
```
template 
[numthreads(X, Y, Z)] void func();

constexpr int foo();
[numthreads(foo(), 2, 3)] void other_func();
```
5) Can you write this attribute on a member function? Can the member function 
be virtual?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122627

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


[PATCH] D122699: [HLSL] Add Semantic syntax, and SV_GroupIndex

2022-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You should also add parsing test coverage as this is parsing new syntax.




Comment at: clang/include/clang/Basic/AttrDocs.td:6386
+  let Content = [{
+The `SV_GroupIndex` semantic when applied to an input parameter specifies a 
data
+binding to map the group index to the specified parameter. This attribute is

MaskRay wrote:
> 




Comment at: clang/include/clang/Parse/Parser.h:2785-2792
+  void MaybeParseHLSLSemantics(ParsedAttributes &attrs,
+   SourceLocation *endLoc = nullptr) {
+if (getLangOpts().HLSL && Tok.is(tok::colon))
+  ParseHLSLSemantics(attrs, endLoc);
+  }
+
+  void ParseHLSLSemantics(ParsedAttributes &attrs,





Comment at: clang/lib/Parse/ParseDecl.cpp:6965-6966
 // Parse GNU attributes, if present.
 MaybeParseGNUAttributes(ParmDeclarator);
+MaybeParseHLSLSemantics(DS.getAttributes());
 

This means the order is very specific -- should this be using 
`MaybeParseAttributes()` so that the syntaxes can be intermingled?

This reminds me, I don't see a change to `ParseAttrKindMask`, but perhaps we 
want that for both the microsoft and HLSL semantic attributes?



Comment at: clang/lib/Parse/ParseHLSL.cpp:30-33
+  if (AttrKind == ParsedAttr::UnknownAttribute ||
+  AttrKind == ParsedAttr::IgnoredAttribute) {
+ConsumeToken();
+return;

I think we should issue a diagnostic about ignoring an unused attribute here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122699

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


[PATCH] D122659: [clang][preprocessor] Allow calling DumpToken() on annotation tokens

2022-03-30 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! I don't think there's a particularly strong need to add test coverage for 
this as the dump method is a debugging aid.


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

https://reviews.llvm.org/D122659

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 419120.
cor3ntin added a comment.

- Add a commebt to clarify which diagnostic message is being printed,

as per Aaron suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx2a %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wno-c++2b-extensions
 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wpre-c++2b-compat
 
-struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}}
+struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}} \
+// cxx2b-note 2{{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
@@ -96,7 +97,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +165,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,7 +229,7 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
+constexpr auto dependent_var_def_lambda() {
   return [](bool b) { // cxx2a-note {{declared here}}
 if (!b)
   T t;
@@ -237,4 +239,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -25,17 +25,18 @@
 label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
-struct NonLiteral {
+struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,10 +1901,15 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_

[PATCH] D122698: [clangd] Add support to extract method for ExtractFunction Tweak

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for doing this, it looks great!

A few comments on:

- a few on cases that I think aren't handled quite right
- structure of the new code
- structure of the *old* code: names etc that no longer fit after these changes

There's also the ugliness around merging edits/tweak effects - this has come up 
in a couple of other checks and we should have a nicer way to do it, sorry it's 
not there yet :-)




Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:398
 
+std::string NewFunction::renderAttributes() const {
+  std::string Attributes;

nit: these are *specifiers* rather than attributes



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:412
+
+std::string NewFunction::renderAttributesAfter() const {
+  std::string Attributes;

and these are *qualifiers* rather than attributes



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:422
+
+std::string NewFunction::renderNamespaceAndClass() const {
+  std::string NamespaceClass;

this isn't actually rendering namespaces, right? just classes



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:426
+  if (ParentContext) {
+NamespaceClass = ParentContext.getValue()->getNameAsString();
+NamespaceClass += "::";

What if this class is nested?
e.g.

```
class Foo { class Bar { int baz(); }; };
int Foo::Bar::baz() { ... }
```

we need to produce `void Foo::Bar::extracted() { ... }`

I think the easiest thing here is just to save the NestedNameSpecifier* from 
the original out-of-line definition (getQualifier()), this represents the 
syntax `Foo::Bar::` as written. Then you can just print() it.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:440
 
+std::string NewFunction::renderInlineDefinition(const SourceManager &SM) const 
{
+  return std::string(

the naming of this family of functions, and the irregular reuse between them 
doesn't sit quite right with me, especially the way it suggests "inline 
definition" is a special case (when for plain functions it's the only case).

What about `renderDeclaration(FunctionDeclKind K, DeclContext &Enclosing, const 
SourceManager &SM);`

with `enum FunctionDeclKind { InlineDefinition, ForwardDeclaration, 
OutOfLineDefinition }`?, 



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:447
+  return std::string(llvm::formatv("{0} {1}{2}({3}){4} {\n{5}\n}\n",
+   printType(ReturnType, 
*EnclosingFuncContext),
+   renderNamespaceAndClass(), Name,

here you're excluding the specifiers, which is correct for `static` but 
incorrect for `constexpr` :-(



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:455
+  return std::string(llvm::formatv("{0}{1} {2}({3}){4}", renderAttributes(),
+   printType(ReturnType, 
*EnclosingFuncContext),
+   Name, renderParametersForDefinition(),

For out-of-line defined methods, this is the wrong DC, which may lead to the 
type being incorrectly qualified. The DC should rather be the enclosing class.

Similarly, renderParametersForDefinition uses EnclosingFuncContext too - 
instead it should take the EnclosingFuncContext as a parameter. (And be renamed 
`renderParametersForDeclaration`, since it's no longer just for definitions)



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:730
+
+  if (isa(ExtZone.EnclosingFunction)) {
+const auto *Method =

Maybe a high-level comment:

For methods defined out-of-line, the extracted method will also be out-of-line. 
The new declaration/definition will each be next to the existing ones.
Methods defined inline are treated very similarly to plain functions.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:737
+ExtractedFunc.Static = Method->isStatic();
+ExtractedFunc.Constexpr = Method->isConstexpr();
+ExtractedFunc.ContextConst = Method->isConst();

may want to propagate consteval too
maybe instead of `bool Constexpr`, store `ConstexprSpecKind Constexpr = 
Method->getConstexprKind()`?



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:738
+ExtractedFunc.Constexpr = Method->isConstexpr();
+ExtractedFunc.ContextConst = Method->isConst();
+

nit: why is this called ContextConst rather than just const? We can already 
decide at this point that the new function will be const.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:743
+
+ExtractedFunc.ParentContext = Method->getParent();
+E

[PATCH] D116635: Add warning to detect when calls passing arguments are made to functions without prototypes.

2022-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

FWIW, now that 
https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c 
has reached a conclusion, I think this patch may be worth resurrecting, if 
you're interested.

https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c/60521/38
 has most of the conclusion which includes a diagnostic option roughly similar 
to what you have in this patch, though there was a request for the diagnostic 
in this patch to be named `-Wstrict-uses-without-prototype` so that it can 
encompass other cases like function pointer assignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116635

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


[PATCH] D109688: [AMDGPU] ASan Patches for OpenMP

2022-03-30 Thread Amit Kumar Pandey via Phabricator via cfe-commits
ampandey-AMD abandoned this revision.
ampandey-AMD added a comment.
Herald added a subscriber: MaskRay.
Herald added a project: All.

The changes proposed here require hostrpc to be upstreamed first which may not 
be available for the time begin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109688

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


[PATCH] D122712: Make test case warning more specific for pattern match

2022-03-30 Thread Ranjeet Singh via Phabricator via cfe-commits
rs added a comment.

In D122712#3416238 , @benshi001 wrote:

> I do not like this change, since
>
> 1. actually there may be many kinds of warnings emitted by the 
> clang-driver-avr depending on different options, and this single line `// 
> NOWARN-NOT: warning:` means non of these possible warnings will be emitted.
>
> 2. we may add/delete/modify warnings in the future, so we should not make it 
> specific .

ok fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122712

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


[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-30 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

I just applied this to a recent HEAD and got a few warnings. Please make sure 
there are no new warnings on changes / new files.

  
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/CSKYInstrFormats.td:658:62:
 warning: unused template argument: R_Z_2:pattern
  class R_Z_2 sop, bits<5> pcode, string op, list pattern>
   ^



  In file included from 
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/CSKYFrameLowering.cpp:14:
  
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/CSKYMachineFunctionInfo.h:21:20:
 warning: private field 'MF' is not used [-Wunused-private-field]
MachineFunction &MF;
 ^



  
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/CSKYInstrInfo.cpp:480:24:
 warning: unused variable 'MRI' [-Wunused-variable]
MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo();
 ^



  
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/Disassembler/CSKYDisassembler.cpp:169:21:
 warning: unused function 'DecodesFPR128RegisterClass' [-Wunused-function]
  static DecodeStatus DecodesFPR128RegisterClass(MCInst &Inst, uint64_t RegNo,
  ^
  
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/Disassembler/CSKYDisassembler.cpp:199:21:
 warning: unused function 'DecodeGPRSPRegisterClass' [-Wunused-function]
  static DecodeStatus DecodeGPRSPRegisterClass(MCInst &Inst, uint64_t RegNo,
  ^
  
/home/rengolin/devel/llvm-project/llvm/lib/Target/CSKY/Disassembler/CSKYDisassembler.cpp:36:16:
 warning: private field 'inDataRegion' is not used [-Wunused-private-field]
mutable bool inDataRegion = false;
 ^

etc.

There is also a test error:

   TEST 'Clang :: Driver/csky-toolchain.c' FAILED 

  ...
  /home/rengolin/devel/llvm-project/clang/test/Driver/csky-toolchain.c:16:24: 
error: C-CSKY-LINUX-MULTI: expected string not found in input
  // C-CSKY-LINUX-MULTI: 
"{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/bin{{/|}}ld"
 ^

I'm guessing this is the path of a local sysroot you have on your machine?

If possible, try to get a new environment (container, VM, alternative machine) 
and make sure a clean build still passes the tests.


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

https://reviews.llvm.org/D121445

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


[PATCH] D122589: Additionally set f32 mode with denormal-fp-math

2022-03-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I think my intent here was to not emit denormal-fp-math-f32 at all if it wasn't 
specified (i.e. denormal-fp-math-f32 is a special override only really used for 
AMDGPU)

The interaction between the two and the default is supposed to be handled by 
the backend interpretation of the attributes. Does this fix an observable 
problem for you?


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

https://reviews.llvm.org/D122589

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


[PATCH] D121637: [PowerPC] Fix EmitPPCBuiltinExpr to emit arguments once

2022-03-30 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 419126.
quinnp added a comment.

Moving testcases that require code generation from 
`clang/test/Sema/ppc-pair-mma-types.c` to 
`clang/test/CodeGen/PowerPC/ppc-mma-types.c` and 
`clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma-types.c`. This is because 
some of these tests use the line 
`Ops.push_back(EmitArrayToPointerDecay(E->getArg(i)).getPointer());` which I 
initially removed from EmitPPCbuiltinExpr. I have added this back in the switch 
statement where it is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121637

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-fastmath.c
  clang/test/CodeGen/PowerPC/builtins-ppc-int128.c
  clang/test/CodeGen/PowerPC/builtins-ppc-pair-mma-types.c
  clang/test/CodeGen/PowerPC/builtins-ppc-vsx.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-cas.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-fetch.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-fp.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-rotate.c
  clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
  clang/test/CodeGen/PowerPC/ppc-mma-types.c
  clang/test/Sema/ppc-pair-mma-types.c

Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -12,11 +12,6 @@
 
 // typedef
 typedef __vector_quad vq_t;
-void testVQTypedef(int *inp, int *outp) {
-  vq_t *vqin = (vq_t *)inp;
-  vq_t *vqout = (vq_t *)outp;
-  *vqout = *vqin;
-}
 
 // function argument
 void testVQArg1(__vector_quad vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
@@ -29,57 +24,22 @@
   *vqp = vq;
 }
 
-void testVQArg3(__vector_quad *vq, int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  *vqp = *vq;
-}
-
-void testVQArg4(const __vector_quad *const vq, int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  *vqp = *vq;
-}
-
-void testVQArg5(__vector_quad vqa[], int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  *vqp = vqa[0];
-}
-
 void testVQArg6(const vq_t vq, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
   __vector_quad *vqp = (__vector_quad *)ptr;
   *vqp = vq;
 }
 
-void testVQArg7(const vq_t *vq, int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  *vqp = *vq;
-}
-
 // function return
 __vector_quad testVQRet1(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
   __vector_quad *vqp = (__vector_quad *)ptr;
   return *vqp; // expected-error {{invalid use of PPC MMA type}}
 }
 
-__vector_quad *testVQRet2(int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  return vqp + 2;
-}
-
-const __vector_quad *testVQRet3(int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  return vqp + 2;
-}
-
 const vq_t testVQRet4(int *ptr) { // expected-error {{invalid use of PPC MMA type}}
   __vector_quad *vqp = (__vector_quad *)ptr;
   return *vqp; // expected-error {{invalid use of PPC MMA type}}
 }
 
-const vq_t *testVQRet5(int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  return vqp + 2;
-}
-
 // global
 __vector_quad globalvq;// expected-error {{invalid use of PPC MMA type}}
 const __vector_quad globalvq2; // expected-error {{invalid use of PPC MMA type}}
@@ -87,16 +47,6 @@
 const __vector_quad *const globalvqp2;
 vq_t globalvq_t; // expected-error {{invalid use of PPC MMA type}}
 
-// local
-void testVQLocal(int *ptr, vector unsigned char vc) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  __vector_quad vq1 = *vqp;
-  __vector_quad vq2;
-  __builtin_mma_xxsetaccz(&vq2);
-  __vector_quad vq3;
-  __builtin_mma_xvi4ger8(&vq3, vc, vc);
-  *vqp = vq3;
-}
 
 // struct field
 struct TestVQStruct {
@@ -106,17 +56,6 @@
   __vector_quad *vq;
 };
 
-// sizeof / alignof
-int testVQSizeofAlignof(int *ptr) {
-  __vector_quad *vqp = (__vector_quad *)ptr;
-  __vector_quad vq = *vqp;
-  unsigned sizet = sizeof(__vector_quad);
-  unsigned alignt = __alignof__(__vector_quad);
-  unsigned sizev = sizeof(vq);
-  unsigned alignv = __alignof__(vq);
-  return sizet + alignt + sizev + alignv;
-}
-
 // operators
 int testVQOperators1(int *ptr) {
   __vector_quad *vqp = (__vector_quad *)ptr;
@@ -168,11 +107,6 @@
 
 // typedef
 typedef __vector_pair vp_t;
-void testVPTypedef(int *inp, int *outp) {
-  vp_t *vpin = (vp_t *)inp;
-  vp_t *vpout = (vp_t *)outp;
-  *vpout = *vpin;
-}
 
 // function argument
 void testVPArg1(__vector_pair vp, int *ptr) { // expected-error {{invalid use of PPC MMA type}}
@@ -185,57 +119,22 @@
   *vpp = vp;
 }
 
-void testVPArg3(__vector_pair *vp, int *ptr) {
-  __vector_pair *vpp = (__vector_pair *)ptr;
-  *vpp = *vp;
-}
-
-void testVPArg4(const __vector_pair *const vp, int *ptr) {
-  __vector_pair *vpp = (__vector_pair *)ptr;
-  *vpp = *vp;
-}
-
-void testVPArg5(__vector_pair v

[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hello,

No idea what is happening yet but I've seen some pretty nasty memory 
consumption by opt that I bisected to this patch.

Any idea what could be going on?

I'll see if I can see if I can extract some reproducer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

2022-03-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/test/SemaHLSL/num_threads.hlsl:48
+#endif
+
+

aaron.ballman wrote:
> There are a few test cases that are missing here:
> 
> 1) Writing the attribute on the wrong subject.
> 2) Passing no args to the attribute, passing too many args to the attribute.
> 3) Function merging where the redeclaration has attributes that don't match. 
> e.g.,
> ```
> [numthreads(1, 2, 3)] void func();
> [numthreads(4, 5, 6)] void func() {}
> ```
> 4) Should the user be able to pick the values via NTTP or other constant 
> expressions? e.g.,
> ```
> template 
> [numthreads(X, Y, Z)] void func();
> 
> constexpr int foo();
> [numthreads(foo(), 2, 3)] void other_func();
> ```
> 5) Can you write this attribute on a member function? Can the member function 
> be virtual?
Great catches!

1-3 are definitely missing coverage. I'll add additional coverage. I also 
should add a test case where a value is a preprocessor macro.

For 4 & 5, the short answer is that HLSL doesn't support those situations, but 
I think there are two related diagnostics that I should be emitting:

1) Applying the numthreads attribute on a template function should warn (It 
won't work anyways, but better to issue the diagnostic)
2) Applying the numthreads attribute on a member function should 

The point by point explanation is:

4) Constexpr isn't supported at all, and user-defined templates are new to HLSL 
2021, can't be used as entry functions. This _could_ be relaxed in the future, 
but we would need to force instantiation, which probably means some form of 
extern template support, which we don't have in the language yet.
5) Member functions also can't be used as entry functions, and HLSL doesn't 
support anything virtual.

I'll update the tests and diagnostics today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122627

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


[PATCH] D121637: [PowerPC] Fix EmitPPCBuiltinExpr to emit arguments once

2022-03-30 Thread Quinn Pham via Phabricator via cfe-commits
quinnp marked an inline comment as done.
quinnp added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15208
-  for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
-if (E->getArg(i)->getType()->isArrayType())
-  Ops.push_back(EmitArrayToPointerDecay(E->getArg(i)).getPointer());

quinnp wrote:
> amyk wrote:
> > A question I have is do we not need to consider 
> > this/`EmitArrayToPointerDecay()` anymore? Was this not used for anything?
> Thanks for your comment! I could not find any builtins that used this case in 
> the loop for emitting their arguments and did not see any failures when I 
> removed it. I am going to look into this now and verify whether or not this 
> is needed.
I've updated the patch to include `EmitArrayToPointerDecay()` where it is 
needed and add code generation testcases to test this functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121637

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


[PATCH] D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members

2022-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This seems fine to me.  I won't likely have time to commit this for a while, 
but you should be able to apply for commit-rights now and do it yourself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122704

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


[PATCH] D122699: [HLSL] Add Semantic syntax, and SV_GroupIndex

2022-03-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Will try to update today. Thank you!




Comment at: clang/lib/Parse/ParseDecl.cpp:6965-6966
 // Parse GNU attributes, if present.
 MaybeParseGNUAttributes(ParmDeclarator);
+MaybeParseHLSLSemantics(DS.getAttributes());
 

aaron.ballman wrote:
> This means the order is very specific -- should this be using 
> `MaybeParseAttributes()` so that the syntaxes can be intermingled?
> 
> This reminds me, I don't see a change to `ParseAttrKindMask`, but perhaps we 
> want that for both the microsoft and HLSL semantic attributes?
This is kinda 6 one way half dozen the other. GNU attribute syntax isn't 
supported in HLSL, I just haven't gotten around to disabling it yet.

If you have a preferred implementation I'm happy to go whatever way you suggest.

The HLSL language doesn't support Semantics or Microsoft-style attributes in 
all that many places in code. MS attributes are only used on functions, and 
semantics are restricted to input/output data (which is a little more 
complicated than it sounds, but basically is function parameters, returns, 
global variables and struct members).



Comment at: clang/lib/Parse/ParseHLSL.cpp:30-33
+  if (AttrKind == ParsedAttr::UnknownAttribute ||
+  AttrKind == ParsedAttr::IgnoredAttribute) {
+ConsumeToken();
+return;

aaron.ballman wrote:
> I think we should issue a diagnostic about ignoring an unused attribute here.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122699

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


[PATCH] D116597: [analyzer] Don't track function calls as control dependencies

2022-03-30 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 419132.
Szelethus marked an inline comment as done.
Szelethus added a comment.
Herald added a project: All.

Fixes according to reviewer comments.


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

https://reviews.llvm.org/D116597

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/return-value-guaranteed.cpp
  clang/test/Analysis/track-control-dependency-conditions.cpp

Index: clang/test/Analysis/track-control-dependency-conditions.cpp
===
--- clang/test/Analysis/track-control-dependency-conditions.cpp
+++ clang/test/Analysis/track-control-dependency-conditions.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_analyze_cc1 %s -std=c++14 \
+// RUN: %clang_analyze_cc1 %s -std=c++17 \
 // RUN:   -verify=expected,tracking \
 // RUN:   -analyzer-config track-conditions=true \
 // RUN:   -analyzer-output=text \
 // RUN:   -analyzer-checker=core
 
-// RUN: not %clang_analyze_cc1 -std=c++14 -verify %s \
+// RUN: not %clang_analyze_cc1 -std=c++17 -verify %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-config track-conditions=false \
 // RUN:   -analyzer-config track-conditions-debug=true \
@@ -14,14 +14,14 @@
 // CHECK-INVALID-DEBUG-SAME:'track-conditions-debug', that expects
 // CHECK-INVALID-DEBUG-SAME:'track-conditions' to also be enabled
 //
-// RUN: %clang_analyze_cc1 %s -std=c++14 \
+// RUN: %clang_analyze_cc1 %s -std=c++17 \
 // RUN:   -verify=expected,tracking,debug \
 // RUN:   -analyzer-config track-conditions=true \
 // RUN:   -analyzer-config track-conditions-debug=true \
 // RUN:   -analyzer-output=text \
 // RUN:   -analyzer-checker=core
 
-// RUN: %clang_analyze_cc1 %s -std=c++14 -verify \
+// RUN: %clang_analyze_cc1 %s -std=c++17 -verify \
 // RUN:   -analyzer-output=text \
 // RUN:   -analyzer-config track-conditions=false \
 // RUN:   -analyzer-checker=core
@@ -38,7 +38,7 @@
   int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
   flag = 1;
 
-  foo(); // TODO: Add nodes here about flag's value being invalidated.
+  foo();// TODO: Add nodes here about flag's value being invalidated.
   if (flag) // expected-note-re   ^}}Assuming 'flag' is 0{{$
 // expected-note-re@-1^}}Taking false branch{{$
 x = new int;
@@ -105,9 +105,9 @@
   foo(); // tracking-note-re^}}Calling 'foo'{{$
  // tracking-note-re@-1^}}Returning from 'foo'{{$
 
-  if (bar) // expected-note-re   ^}}Assuming 'bar' is not equal to 0{{$
-   // expected-note-re@-1^}}Taking true branch{{$
-   // debug-note-re@-2^}}Tracking condition 'bar'{{$
+  if (bar)// expected-note-re   ^}}Assuming 'bar' is not equal to 0{{$
+  // expected-note-re@-1^}}Taking true branch{{$
+  // debug-note-re@-2^}}Tracking condition 'bar'{{$
 if (flag) // expected-note-re   ^}}Assuming 'flag' is not equal to 0{{$
   // expected-note-re@-1^}}Taking true branch{{$
   // debug-note-re@-2^}}Tracking condition 'flag'{{$
@@ -149,14 +149,13 @@
   int *x = 0; // expected-note-re^}}'x' initialized to a null pointer value{{$
 
   if (ConvertsToBool())
-// debug-note-re@-1^}}Tracking condition 'ConvertsToBool()'{{$
-// expected-note-re@-2^}}Assuming the condition is true{{$
-// expected-note-re@-3^}}Taking true branch{{$
+// expected-note-re@-1^}}Assuming the condition is true{{$
+// expected-note-re@-2^}}Taking true branch{{$
 *x = 5; // expected-warning{{Dereference of null pointer}}
 // expected-note@-1{{Dereference of null pointer}}
 }
 
-} // end of namespace variable_declaration_in_condition
+} // namespace conversion_to_bool
 
 namespace note_from_different_but_not_nested_stackframe {
 
@@ -186,14 +185,13 @@
 int *getIntPtr();
 
 void storeValue(int **i) {
-  *i = getIntPtr(); // tracking-note-re^}}Value assigned to 'i', which participates in a condition later{{$
+  *i = getIntPtr();
 }
 
 int *conjurePointer() {
   int *i;
-  storeValue(&i); // tracking-note-re^}}Calling 'storeValue'{{$
-  // tracking-note-re@-1^}}Returning from 'storeValue'{{$
-  return i; // tracking-note-re^}}Returning pointer (loaded from 'i'), which participates in a condition later{{$
+  storeValue(&i);
+  return i;
 }
 
 void f(int *ptr) {
@@ -201,11 +199,8 @@
// expected-note-re@-1^}}Taking false branch{{$
 ;
   if (!conjurePointer())
-// tracking-note-re@-1^}}Calling 'conjurePointer'{{$
-// tracking-note-re@-2^}}Returning from 'conjurePointer'{{$
-// debug-note-re@-3^}}Tracking condition '!conjurePointer()'{{$
-// expected-note-re@-4^}}Assuming the condition is true{{$
-// expected-note-

[PATCH] D116597: [analyzer] Don't track function calls as control dependencies

2022-03-30 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: clang/lib/Analysis/CFG.cpp:5908-5909
 
+void CFG::dump(bool ShowColors) const { dump(LangOptions{}, ShowColors); }
+
 /// print - A simple pretty printer of a CFG that outputs to an ostream.

steakhal wrote:
> How are these `dump()` changes related?
I'll commit them in a separate patch.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1968
+static const Expr *peelOffOuterExpr(const Expr *Ex, const ExplodedNode *N) {
+
   Ex = Ex->IgnoreParenCasts();

steakhal wrote:
> extra blank line
That is intentional -- I think it makes the code more readable. Separates the 
function signature from the implementation.



Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:1036
+  x = nullptr;// expected-note {{Null pointer value stored to 'x'}}
+  if (!alwaysFalse()) // expected-note {{Taking true branch}}
+*x = 5;   // expected-warning {{Dereference of null pointer 
(loaded from variable 'x') [core.NullDereference]}}

steakhal wrote:
> What if this expression is enclosed by a logical operator such as `&&`?
For each of those operators, a different CFGBlock would be created:

```
if (A && B) 
  C;
D;

  C
/   \
  B--->
 / \
A-> D
```

This means that operands of || and && is retrievable through 
`CFGBlock::getLastCondition()`, so I shouldn't need to tear the AST apart to 
that extent. Though, I admit, you likely don't need to go very far to fool my 
implementation for realizing whether the condition boils down to a function 
call.


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

https://reviews.llvm.org/D116597

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

This LGTM (with minor comment). Please wait for Aaron to respond re: the 
handling of template instantiations.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1912-1913
+   diag::err_constexpr_local_var_non_literal_type,
+   isa(Dcl)))
   return false;
 if (!VD->getType()->isDependentType() &&

Minor nit: The coding standards were updated (some time ago now) to recommend 
keeping if-else chains consistently braced or not-braced.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (!VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),

cor3ntin wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > cor3ntin wrote:
> > > > hubert.reinterpretcast wrote:
> > > > > This seems to trigger even when the type is dependent:
> > > > > ```
> > > > > :1:36: warning: definition of a variable of non-literal type 
> > > > > in a constexpr function is incompatible with C++ standards before 
> > > > > C++2b [-Wpre-c++2b-compat]
> > > > > auto qq = [](auto x) { decltype(x) n; };
> > > > >^
> > > > > 1 warning generated.
> > > > > ```
> > > > > 
> > > > > This also seems to emit even when `Kind` is not 
> > > > > `Sema::CheckConstexprKind::Diagnose` (unlike the 
> > > > > `static`/`thread_local` case above). Is the `CheckLiteralType` logic 
> > > > > not reusable for this?
> > > > You are right, thanks for noticing that, it was rather bogus.
> > > > The reason I'm not using CheckLiteralType is to avoid duplicating a 
> > > > diagnostics message, as CheckLiteralType doesn't allow us to pass 
> > > > parameter to the diagnostic message.
> > > > 
> > > > It leaves us with an uncovered scenario though: We do not emit the 
> > > > warning on template instantiation, and I don't think there is an  easy 
> > > > way to do that.
> > > > The reason I'm not using CheckLiteralType is to avoid duplicating a 
> > > > diagnostics message, as CheckLiteralType doesn't allow us to pass 
> > > > parameter to the diagnostic message.
> > > 
> > > Huh?
> > > 
> > > ```
> > > static bool CheckLiteralType(Sema &SemaRef, Sema::CheckConstexprKind Kind,
> > >  SourceLocation Loc, QualType T, unsigned 
> > > DiagID,
> > >  Ts &&...DiagArgs) {
> > >   ...
> > > }
> > > ```
> > > I would hope `DiagArgs` should do exactly that? :-)
> > > It leaves us with an uncovered scenario though: We do not emit the 
> > > warning on template instantiation, and I don't think there is an easy way 
> > > to do that.
> > 
> > I believe the code paths that lead us here all come from 
> > `Sema::CheckConstexprFunctionDefinition()` which is called from 
> > `Sema::ActOnFinishFunctionBody()` which seems to be called when 
> > instantiating templates in `Sema::InstantiateFunctionDefinition()`, so 
> > perhaps some more investigation is needed as to why we're not reaching this 
> > for template instantiations.
> We could add something in addition of `Sema::CheckConstexprKind::CheckValid` 
> and `Sema::CheckConstexprKind::Diagnose`, but 
> 
> * not for implicit lambdas, because we should not warn on lambdas that won't 
> be constexpr
> * for explicit constexpr lambdas / functions, it would force us to call 
> CheckConstexprFunctionDefinition  on instanciation, which we currently don't 
> do, and is not free for that one warning - and we would have to not-reemit 
> the other warnings. It seems like quite a fair amount of work for a 
> diagnostic not enabled by default.
> so perhaps some more investigation is needed as to why we're not reaching 
> this for template instantiations.

@aaron.ballman, do you have any position on whether we want this investigation 
before moving forward with this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D122471#3416528 , @uabelho wrote:

> Hello,
>
> No idea what is happening yet but I've seen some pretty nasty memory 
> consumption by opt that I bisected to this patch.
>
> Any idea what could be going on?
>
> I'll see if I can see if I can extract some reproducer.

It seems like it's the actual reading of the input file that hangs and just 
eats more and more memory. So

  opt foo.bc -o foo.opt.bc

hangs, and this happens when the input contains a call to an intrinsic we've 
added downstream that returns a named struct type-
Do we need to update our intrinsic definitions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D122728: [OpenCL] opencl-c.h: Add const to get_image_num_samples

2022-03-30 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: azabaznov.
svenvh added a project: clang.
Herald added subscribers: Naghasan, ldrumm, yaxunl.
Herald added a project: All.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Align with the `-fdeclare-opencl-builtins` option and other
get_image_* builtins which have the const attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122728

Files:
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -16118,21 +16118,21 @@
 * Return the number of samples associated with image
 */
 #if defined(cl_khr_gl_msaa_sharing)
-int __ovld get_image_num_samples(read_only image2d_msaa_t);
-int __ovld get_image_num_samples(read_only image2d_msaa_depth_t);
-int __ovld get_image_num_samples(read_only image2d_array_msaa_t);
-int __ovld get_image_num_samples(read_only image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_depth_t);
 
-int __ovld get_image_num_samples(write_only image2d_msaa_t);
-int __ovld get_image_num_samples(write_only image2d_msaa_depth_t);
-int __ovld get_image_num_samples(write_only image2d_array_msaa_t);
-int __ovld get_image_num_samples(write_only image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_depth_t);
 
 #if defined(__opencl_c_read_write_images)
-int __ovld get_image_num_samples(read_write image2d_msaa_t);
-int __ovld get_image_num_samples(read_write image2d_msaa_depth_t);
-int __ovld get_image_num_samples(read_write image2d_array_msaa_t);
-int __ovld get_image_num_samples(read_write image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_depth_t);
 #endif //defined(__opencl_c_read_write_images)
 #endif
 


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -16118,21 +16118,21 @@
 * Return the number of samples associated with image
 */
 #if defined(cl_khr_gl_msaa_sharing)
-int __ovld get_image_num_samples(read_only image2d_msaa_t);
-int __ovld get_image_num_samples(read_only image2d_msaa_depth_t);
-int __ovld get_image_num_samples(read_only image2d_array_msaa_t);
-int __ovld get_image_num_samples(read_only image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_depth_t);
 
-int __ovld get_image_num_samples(write_only image2d_msaa_t);
-int __ovld get_image_num_samples(write_only image2d_msaa_depth_t);
-int __ovld get_image_num_samples(write_only image2d_array_msaa_t);
-int __ovld get_image_num_samples(write_only image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_depth_t);
 
 #if defined(__opencl_c_read_write_images)
-int __ovld get_image_num_samples(read_write image2d_msaa_t);
-int __ovld get_image_num_samples(read_write image2d_msaa_depth_t);
-int __ovld get_image_num_samples(read_write image2d_array_msaa_t);
-int __ovld get_image_num_samples(read_write image2d_array_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_depth_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_t);
+int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_depth_t);
 #endif //defined(__opencl_c_read_write_images)
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5b38292 - [NFC] Use range based loop.

2022-03-30 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-03-30T22:44:34+08:00
New Revision: 5b38292d5d776439b54e7cc02c7a20c58717f3d2

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

LOG: [NFC] Use range based loop.

Signed-off-by: Jun Zhang 

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

Added: 


Modified: 
clang/lib/AST/ASTDiagnostic.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 0c27c0d14519d..28269ec219e4c 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -270,9 +270,9 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType 
Ty,
   std::string S = Ty.getAsString(Context.getPrintingPolicy());
   std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
 
-  for (unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
+  for (const intptr_t &QualTypeVal : QualTypeVals) {
 QualType CompareTy =
-QualType::getFromOpaquePtr(reinterpret_cast(QualTypeVals[I]));
+QualType::getFromOpaquePtr(reinterpret_cast(QualTypeVal));
 if (CompareTy.isNull())
   continue;
 if (CompareTy == Ty)
@@ -302,11 +302,11 @@ ConvertTypeToDiagnosticString(ASTContext &Context, 
QualType Ty,
   // Check to see if we already desugared this type in this
   // diagnostic.  If so, don't do it again.
   bool Repeated = false;
-  for (unsigned i = 0, e = PrevArgs.size(); i != e; ++i) {
+  for (const auto &PrevArg : PrevArgs) {
 // TODO: Handle ak_declcontext case.
-if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) {
-  void *Ptr = (void*)PrevArgs[i].second;
-  QualType PrevTy(QualType::getFromOpaquePtr(Ptr));
+if (PrevArg.first == DiagnosticsEngine::ak_qualtype) {
+  QualType PrevTy(
+  QualType::getFromOpaquePtr(reinterpret_cast(PrevArg.second)));
   if (PrevTy == Ty) {
 Repeated = true;
 break;



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


[PATCH] D122657: [NFC] Use range based loop.

2022-03-30 Thread Jun Zhang via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b38292d5d77: [NFC] Use range based loop. (authored by 
junaire).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122657

Files:
  clang/lib/AST/ASTDiagnostic.cpp


Index: clang/lib/AST/ASTDiagnostic.cpp
===
--- clang/lib/AST/ASTDiagnostic.cpp
+++ clang/lib/AST/ASTDiagnostic.cpp
@@ -270,9 +270,9 @@
   std::string S = Ty.getAsString(Context.getPrintingPolicy());
   std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
 
-  for (unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
+  for (const intptr_t &QualTypeVal : QualTypeVals) {
 QualType CompareTy =
-QualType::getFromOpaquePtr(reinterpret_cast(QualTypeVals[I]));
+QualType::getFromOpaquePtr(reinterpret_cast(QualTypeVal));
 if (CompareTy.isNull())
   continue;
 if (CompareTy == Ty)
@@ -302,11 +302,11 @@
   // Check to see if we already desugared this type in this
   // diagnostic.  If so, don't do it again.
   bool Repeated = false;
-  for (unsigned i = 0, e = PrevArgs.size(); i != e; ++i) {
+  for (const auto &PrevArg : PrevArgs) {
 // TODO: Handle ak_declcontext case.
-if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) {
-  void *Ptr = (void*)PrevArgs[i].second;
-  QualType PrevTy(QualType::getFromOpaquePtr(Ptr));
+if (PrevArg.first == DiagnosticsEngine::ak_qualtype) {
+  QualType PrevTy(
+  QualType::getFromOpaquePtr(reinterpret_cast(PrevArg.second)));
   if (PrevTy == Ty) {
 Repeated = true;
 break;


Index: clang/lib/AST/ASTDiagnostic.cpp
===
--- clang/lib/AST/ASTDiagnostic.cpp
+++ clang/lib/AST/ASTDiagnostic.cpp
@@ -270,9 +270,9 @@
   std::string S = Ty.getAsString(Context.getPrintingPolicy());
   std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
 
-  for (unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
+  for (const intptr_t &QualTypeVal : QualTypeVals) {
 QualType CompareTy =
-QualType::getFromOpaquePtr(reinterpret_cast(QualTypeVals[I]));
+QualType::getFromOpaquePtr(reinterpret_cast(QualTypeVal));
 if (CompareTy.isNull())
   continue;
 if (CompareTy == Ty)
@@ -302,11 +302,11 @@
   // Check to see if we already desugared this type in this
   // diagnostic.  If so, don't do it again.
   bool Repeated = false;
-  for (unsigned i = 0, e = PrevArgs.size(); i != e; ++i) {
+  for (const auto &PrevArg : PrevArgs) {
 // TODO: Handle ak_declcontext case.
-if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) {
-  void *Ptr = (void*)PrevArgs[i].second;
-  QualType PrevTy(QualType::getFromOpaquePtr(Ptr));
+if (PrevArg.first == DiagnosticsEngine::ak_qualtype) {
+  QualType PrevTy(
+  QualType::getFromOpaquePtr(reinterpret_cast(PrevArg.second)));
   if (PrevTy == Ty) {
 Repeated = true;
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members

2022-03-30 Thread Wang Yihan via Phabricator via cfe-commits
yihanaa added a comment.

In D122704#3416538 , @erichkeane 
wrote:

> This seems fine to me.  I won't likely have time to commit this for a while, 
> but you should be able to apply for commit-rights now and do it yourself.

Sorry for taking so long to reply to you, thank you very much for your review 
and suggestions, and i have tried to apply for commit access from Chris and am 
waiting for a reply.😊


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122704

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


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

@uabelho You shouldn't need to update intrinsic definitions (though you might 
want to update how you codegen the intrinsics). It sounds like the auto-upgrade 
code is going into an infinite loop in your case, but it's not really obvious 
to me how/why that would happen (or why it would happen only for bitcode but 
not IR).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Oh wait, do I see correctly that your intrinsic returns an overloaded type that 
happens to be a struct, rather than returning a struct defined in the intrinsic 
definition? I hadn't considered that case, and it's possible the auto-upgrade 
code is broken for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D121165: [pseudo] Add crude heuristics to choose taken preprocessor branches.

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 6 inline comments as done.
sammccall added inline comments.



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:210
+namespace {
+class BranchChooser {
+public:

hokein wrote:
> We evaluate each conditional directive *independently*, I wonder whether it 
> is important to use any low-hanging tricks to ensure consistent choices are 
> made among different conditional directives. (my gut feeling is that it is 
> nice to have, but we should not worry too much about it at the moment).
> 
> For example,
> 
> ```
> #ifdef __cplusplus
> extern "C" {
> #endif
> 
> #ifdef __cplusplus
> }
> #endif
> ```
> 
> If we enable the first #if, and the second one should be enabled as well. 
> (this example is a trivial and common pattern, it has been handled by the 
> existing code).
Added a comment describing this case, I don't think we should tackle this now.



Comment at: clang/lib/Tooling/Syntax/Pseudo/DirectiveMap.cpp:305
+  // false if the branch is never taken, and None otherwise.
+  llvm::Optional isTriviallyTaken(const DirectiveMap::Directive &Dir) {
+switch (Dir.Kind) {

hokein wrote:
> nit: instead of using `trivially`, I think `confidently` fits better what the 
> method does.
You're right this is a bad name, but also because returning false doesn't mean 
it's not trivially/confidently taken, but rather that it's 
trivially/confidently *not* taken.
I think removing the adverb actually makes this clearer.

Also this case is confusing
```
#if foo
#else // is this "always taken"?
#bar
```

Renamed to `isTakenWhenReached`, wdyt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121165

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


[PATCH] D121165: [pseudo] Add crude heuristics to choose taken preprocessor branches.

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419142.
sammccall marked 2 inline comments as done.
sammccall added a comment.
Herald added a project: clang-tools-extra.

Rebase and address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121165

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/DirectiveMap.h
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/DirectiveMap.cpp
  clang-tools-extra/pseudo/test/lex.c
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp

Index: clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
===
--- clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
+++ clang-tools-extra/pseudo/unittests/DirectiveMapTest.cpp
@@ -145,6 +145,162 @@
   EXPECT_EQ(0u, X.End.Tokens.size());
 }
 
+TEST(DirectiveMap, ChooseBranches) {
+  LangOptions Opts;
+  const std::string Cases[] = {
+  R"cpp(
+// Branches with no alternatives are taken
+#if COND // TAKEN
+int x;
+#endif
+  )cpp",
+
+  R"cpp(
+// Empty branches are better than nothing
+#if COND // TAKEN
+#endif
+  )cpp",
+
+  R"cpp(
+// Trivially false branches are not taken, even with no alternatives.
+#if 0
+int x;
+#endif
+  )cpp",
+
+  R"cpp(
+// Longer branches are preferred over shorter branches
+#if COND // TAKEN
+int x = 1;
+#else
+int x;
+#endif
+
+#if COND
+int x;
+#else // TAKEN
+int x = 1;
+#endif
+  )cpp",
+
+  R"cpp(
+// Trivially true branches are taken if previous branches are trivial.
+#if 1 // TAKEN
+#else
+  int x = 1;
+#endif
+
+#if 0
+  int x = 1;
+#elif 0
+  int x = 2;
+#elif 1 // TAKEN
+  int x;
+#endif
+
+#if 0
+  int x = 1;
+#elif FOO // TAKEN
+  int x = 2;
+#elif 1
+  int x;
+#endif
+  )cpp",
+
+  R"cpp(
+// #else is a trivially true branch
+#if 0
+  int x = 1;
+#elif 0
+  int x = 2;
+#else // TAKEN
+  int x;
+#endif
+  )cpp",
+
+  R"cpp(
+// Directives break ties, but nondirective text is more important.
+#if FOO
+  #define A 1 2 3
+#else // TAKEN
+  #define B 4 5 6
+  #define C 7 8 9
+#endif
+
+#if FOO // TAKEN
+  ;
+  #define A 1 2 3
+#else
+  #define B 4 5 6
+  #define C 7 8 9
+#endif
+  )cpp",
+
+  R"cpp(
+// Avoid #error directives.
+#if FOO
+  int x = 42;
+  #error This branch is no good
+#else // TAKEN
+#endif
+
+#if FOO
+  // All paths here lead to errors.
+  int x = 42;
+  #if 1 // TAKEN
+#if COND // TAKEN
+  #error This branch is no good
+#else
+  #error This one is no good either
+#endif
+  #endif
+#else // TAKEN
+#endif
+  )cpp",
+
+  R"cpp(
+// Populate taken branches recursively.
+#if FOO // TAKEN
+  int x = 42;
+  #if BAR
+;
+  #else // TAKEN
+int y = 43;
+  #endif
+#else
+  int x;
+  #if BAR // TAKEN
+int y;
+  #else
+;
+  #endif
+#endif
+  )cpp",
+  };
+  for (const auto &Code : Cases) {
+TokenStream S = cook(lex(Code, Opts), Opts);
+
+std::function Verify =
+[&](const DirectiveMap &M) {
+  for (const auto &C : M.Chunks) {
+if (C.kind() != DirectiveMap::Chunk::K_Conditional)
+  continue;
+const DirectiveMap::Conditional &Cond(C);
+for (unsigned I = 0; I < Cond.Branches.size(); ++I) {
+  auto Directive = S.tokens(Cond.Branches[I].first.Tokens);
+  EXPECT_EQ(I == Cond.Taken, Directive.back().text() == "// TAKEN")
+  << "At line " << Directive.front().Line << " of: " << Code;
+  Verify(Cond.Branches[I].second);
+}
+  }
+};
+
+DirectiveMap Map = DirectiveMap::parse(S);
+chooseConditionalBranches(Map, S);
+Verify(Map);
+  }
+}
+
 } // namespace
 } // namespace pseudo
 } // namespace clang
Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -75,6 +75,7 @@
 clang::LangOptions LangOpts; // FIXME: use real options.
 auto Stream = clang::pseudo::lex(Text, La

[PATCH] D122069: [Object] Add binary format for bundling offloading metadata

2022-03-30 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Hey @jhuber6 , as discussed in multi-company meeting, I think that we will need 
at least an arch field somewhere in this. We would like to create multi-arch 
binaries so that runtime can load the compatible one on its own.
You may even consider using TargetID Format 
 to store the 
list of archs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122069

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


[PATCH] D116597: [analyzer] Don't track function calls as control dependencies

2022-03-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

I'm convinced!




Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1968
+static const Expr *peelOffOuterExpr(const Expr *Ex, const ExplodedNode *N) {
+
   Ex = Ex->IgnoreParenCasts();

Szelethus wrote:
> steakhal wrote:
> > extra blank line
> That is intentional -- I think it makes the code more readable. Separates the 
> function signature from the implementation.
Okay.



Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:41
 
-  foo(); // TODO: Add nodes here about flag's value being invalidated.
+  foo();// TODO: Add nodes here about flag's value being invalidated.
   if (flag) // expected-note-re   ^}}Assuming 'flag' is 0{{$

Some of these hunks are unrelated to the parts you actually changed.
Strictly peaking I don't mind them, just pointing out.
`clang-format-diff.py` would format only the changed lines.



Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:202-203
   if (!conjurePointer())
-// tracking-note-re@-1^}}Calling 'conjurePointer'{{$
-// tracking-note-re@-2^}}Returning from 'conjurePointer'{{$
-// debug-note-re@-3^}}Tracking condition '!conjurePointer()'{{$
-// expected-note-re@-4^}}Assuming the condition is true{{$
-// expected-note-re@-5^}}Taking true branch{{$
+// expected-note-re@-1^}}Assuming the condition is true{{$
+// expected-note-re@-2^}}Taking true branch{{$
 *ptr = 5; // expected-warning{{Dereference of null pointer}}

For the record, I never understood why we have two notes about the same thing: 
//we are taking that branch//.
Maybe we should keep simplifying these notes in the future as well.



Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:1036
+  x = nullptr;// expected-note {{Null pointer value stored to 'x'}}
+  if (!alwaysFalse()) // expected-note {{Taking true branch}}
+*x = 5;   // expected-warning {{Dereference of null pointer 
(loaded from variable 'x') [core.NullDereference]}}

Szelethus wrote:
> steakhal wrote:
> > What if this expression is enclosed by a logical operator such as `&&`?
> For each of those operators, a different CFGBlock would be created:
> 
> ```
> if (A && B) 
>   C;
> D;
> 
>   C
> /   \
>   B--->
>  / \
> A-> D
> ```
> 
> This means that operands of || and && is retrievable through 
> `CFGBlock::getLastCondition()`, so I shouldn't need to tear the AST apart to 
> that extent. Though, I admit, you likely don't need to go very far to fool my 
> implementation for realizing whether the condition boils down to a function 
> call.
I see, thanks.


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

https://reviews.llvm.org/D116597

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


[PATCH] D122069: [Object] Add binary format for bundling offloading metadata

2022-03-30 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D122069#3416694 , @saiislam wrote:

> Hey @jhuber6 , as discussed in multi-company meeting, I think that we will 
> need at least an arch field somewhere in this. We would like to create 
> multi-arch binaries so that runtime can load the compatible one on its own.
> You may even consider using TargetID Format 
>  to store the 
> list of archs.

The binary format contains a string map along with some integer fields. I have 
the `getArch()` function in the binary that just extracts the value get the 
`"arch"` key. This makes it easy to add some arbitrary data so I was planning 
on simply adding a `"features"` key as well. Then we can extract the associated 
image features and decide what to do with the image. I haven't thought of a 
good solution for allowing multiple compatible architectures, maybe a comma 
separated list of architectures. You can see the proposed usage right now in 
D122683  but more will be added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122069

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


[PATCH] D122732: [Clang][AArch64][SVE] Allow subscript operator for SVE types

2022-03-30 Thread David Truby via Phabricator via cfe-commits
DavidTruby created this revision.
Herald added subscribers: psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: All.
DavidTruby requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Undefined behaviour is just passed on to extract_element when the
index is out of bounds. Subscript on svbool_t is not allowed as
this doesn't really have meaningful semantics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122732

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/aarch64-sve-vector-subscript-ops.c
  clang/test/Sema/aarch64-sve-vector-subscript-ops.c

Index: clang/test/Sema/aarch64-sve-vector-subscript-ops.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-vector-subscript-ops.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -verify -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+
+void subscript(svint8_t i8, svint16_t i16, svint32_t i32, svint64_t i64,
+   svuint8_t u8, svuint16_t u16, svuint32_t u32, svuint64_t u64,
+   svfloat16_t f16, svfloat32_t f32, svfloat64_t f64,
+   svbool_t b) {
+  (void)b[0];// expected-error{{subscript of svbool_t is not allowed}}
+  (void)b[0.f];  // expected-error{{subscript of svbool_t is not allowed}}
+  (void)b[0.];   // expected-error{{subscript of svbool_t is not allowed}}
+
+  (void)i8[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)i8[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)u8[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)u8[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)i16[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)i16[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)u16[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)u16[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)i32[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)i32[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)u32[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)u32[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)i64[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)i64[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)u64[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)u64[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)f16[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)f16[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)f32[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)f32[0.];  // expected-error{{array subscript is not an integer}}
+
+  (void)f64[0.f]; // expected-error{{array subscript is not an integer}}
+  (void)f64[0.];  // expected-error{{array subscript is not an integer}}
+}
Index: clang/test/CodeGen/aarch64-sve-vector-subscript-ops.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-vector-subscript-ops.c
@@ -0,0 +1,90 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN: -fallow-half-arguments-and-returns -disable-O0-optnone \
+// RUN:  -emit-llvm -o - %s | opt -S -sroa | FileCheck %s
+
+// REQUIRES: aarch64-registered-target
+
+#include 
+#include 
+
+// CHECK-LABEL: @subscript_int16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECEXT:%.*]] = extractelement  [[A:%.*]], i64 [[B:%.*]]
+// CHECK-NEXT:ret i16 [[VECEXT]]
+//
+int16_t subscript_int16(svint16_t a, size_t b) {
+  return a[b];
+}
+
+// CHECK-LABEL: @subscript_uint16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECEXT:%.*]] = extractelement  [[A:%.*]], i64 [[B:%.*]]
+// CHECK-NEXT:ret i16 [[VECEXT]]
+//
+uint16_t subscript_uint16(svuint16_t a, size_t b) {
+  return a[b];
+}
+
+// CHECK-LABEL: @subscript_int32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECEXT:%.*]] = extractelement  [[A:%.*]], i64 [[B:%.*]]
+// CHECK-NEXT:ret i32 [[VECEXT]]
+//
+int32_t subscript_int32(svint32_t a, size_t b) {
+  return a[b];
+}
+
+// CHECK-LABEL: @subscript_uint32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECEXT:%.*]] = extractelement  [[A:%.*]], i64 [[B:%.*]]
+// CHECK-NEXT:ret i32 [[VECEXT]]
+//
+uint32_t subscript_uint32(svuint32_t a, size_t b) {
+  return a[b];
+}
+
+// CHECK-LABEL: @subscript_int64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECEXT:%.*]] = extractelement

[PATCH] D122608: Fix behavior of ifuncs with 'used' extern "C" static functions

2022-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 419143.
erichkeane added a comment.

Going through @tahonermann 's comments to attempt to allow multiple ifunc 
references, I ended up down the rabbit hole.

Turns out there are ways for there to be a ConstantExpr bitcast in the way that 
needs to be corrected (the 'first' one is never created this way, as the type 
is derived directly from the ifunc's type).  I did a significant refactor to 
attempt to make this as clean as possible.

Note that the diagnostics for ifuncs are still bad, but I make no attempts to 
fix that here.


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

https://reviews.llvm.org/D122608

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
  clang/test/SemaCXX/externc-ifunc-resolver.cpp

Index: clang/test/SemaCXX/externc-ifunc-resolver.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/externc-ifunc-resolver.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+extern "C" {
+  __attribute__((used)) static void *resolve_foo() { return 0; }
+  namespace NS {
+__attribute__((used)) static void *resolve_foo() { return 0; }
+  }
+
+  // FIXME: This diagnostic is pretty confusing, the issue is that the existence
+  // of the two functions suppresses the 'alias' creation, and thus the ifunc
+  // resolution via the alias as well. In the future we should probably find
+  // some way to improve this diagnostic (likely by diagnosing when we decide
+  // this case suppresses alias creation).
+  __attribute__((ifunc("resolve_foo"))) void foo(); // expected-error{{ifunc must point to a defined function}}
+}
+
Index: clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+extern "C" {
+  __attribute__((used)) static void *resolve_foo() { return 0; }
+  __attribute__((ifunc("resolve_foo"))) char *foo();
+  __attribute__((ifunc("resolve_foo"))) void foo2(int);
+  __attribute__((ifunc("resolve_foo"))) char foo3(float);
+  __attribute__((ifunc("resolve_foo"))) char foo4(float);
+}
+
+// CHECK: @resolve_foo = internal alias i8* (), i8* ()* @_ZL11resolve_foov
+// CHECK: @foo = ifunc i8* (), bitcast (i8* ()* @_ZL11resolve_foov to i8* ()* ()*)
+// CHECK: @foo2 = ifunc void (i32), bitcast (i8* ()* @_ZL11resolve_foov to void (i32)* ()*)
+// CHECK: @foo3 = ifunc i8 (float), bitcast (i8* ()* @_ZL11resolve_foov to i8 (float)* ()*)
+// CHECK: @foo4 = ifunc i8 (float), bitcast (i8* ()* @_ZL11resolve_foov to i8 (float)* ()*)
+// CHECK: define internal noundef i8* @_ZL11resolve_foov()
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1570,6 +1570,13 @@
   /// Emit the link options introduced by imported modules.
   void EmitModuleLinkOptions();
 
+  /// Helper function for EmitStaticExternCAliases that clears the uses of
+  /// 'Elem' if it is used exclusively by ifunc resolvers. Returns 'true' if it
+  /// was successful erases Elem.
+  bool CheckAndReplaceExternCIFuncs(llvm::GlobalValue *Elem,
+IdentifierInfo *Name,
+llvm::GlobalValue *CppFunc);
+
   /// Emit aliases for internal-linkage declarations inside "C" language
   /// linkage specifications, giving them the "expected" name where possible.
   void EmitStaticExternCAliases();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -507,7 +507,6 @@
   EmitVTablesOpportunistically();
   applyGlobalValReplacements();
   applyReplacements();
-  checkAliases();
   emitMultiVersionFunctions();
   EmitCXXGlobalInitFunc();
   EmitCXXGlobalCleanUpFunc();
@@ -539,6 +538,7 @@
   EmitCtorList(GlobalDtors, "llvm.global_dtors");
   EmitGlobalAnnotations();
   EmitStaticExternCAliases();
+  checkAliases();
   EmitDeferredUnusedCoverageMappings();
   CodeGenPGO(*this).setValueProfilingFlag(getModule());
   if (CoverageMapping)
@@ -6315,6 +6315,68 @@
   GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
 }
 
+bool CodeGenModule::CheckAndReplaceExternCIFuncs(
+llvm::GlobalValue *Elem, IdentifierInfo *Name,
+llvm::GlobalValue *CppFunc) {
+  // Store the list of ifuncs we need to replace uses in.
+  llvm::SmallVector IFuncs;
+  // List of ConstantExprs that we should be able to delete when we're done
+  // here.
+  llvm::SmallVector CEs;
+
+  // First make sure that all users of this are ifuncs (or ifuncs via a
+  // bitcast), and collect the list of ifuncs and CEs 

[PATCH] D122734: [HIP] Fix mangling number for local struct

2022-03-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
Herald added a project: All.
yaxunl requested review of this revision.

MSVC and Itanium mangling use different mangling numbers
for function-scope structs, which causes inconsistent
mangled kernel names in device and host compilations.

This patch uses Itanium mangling number for structs
in HIP host compilation on Windows to fix this issue.


https://reviews.llvm.org/D122734

Files:
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/test/CodeGenCUDA/struct-mangling-number.cu


Index: clang/test/CodeGenCUDA/struct-mangling-number.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/struct-mangling-number.cu
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-pc-windows-msvc \
+// RUN:   -fms-extensions -aux-triple amdgcn-amd-amdhsa \
+// RUN:   -aux-target-cpu gfx1030 -x hip %s | FileCheck %s
+ 
+#include "Inputs/cuda.h"
+
+// Check local struct 'Op' uses Itanium mangling number instead of MSVC 
mangling
+// number.
+
+// CHECK: @{{.*}} = {{.*}}c"_Z6kernelIZN4TestIiE3runEvE2OpEvv\00"
+// CHECK-NOT: @{{.*}} = {{.*}}c"_Z6kernelIZN4TestIiE3runEvE2Op_1Evv\00"
+template
+__attribute__((global)) void kernel()
+{
+}
+
+template 
+class Test {
+public:
+  void run()
+  {
+struct Op 
+{
+};
+kernel<<<1, 1>>>();
+  }
+};
+
+int main() {
+  Test A;
+  A.run();
+}
Index: clang/lib/AST/MicrosoftCXXABI.cpp
===
--- clang/lib/AST/MicrosoftCXXABI.cpp
+++ clang/lib/AST/MicrosoftCXXABI.cpp
@@ -76,6 +76,11 @@
   unsigned getDeviceManglingNumber(const CXXMethodDecl *CallOperator) override 
{
 return DeviceCtx->getManglingNumber(CallOperator);
   }
+
+  unsigned getManglingNumber(const TagDecl *TD,
+ unsigned MSLocalManglingNumber) override {
+return DeviceCtx->getManglingNumber(TD, MSLocalManglingNumber);
+  }
 };
 
 class MSSYCLNumberingContext : public MicrosoftNumberingContext {


Index: clang/test/CodeGenCUDA/struct-mangling-number.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/struct-mangling-number.cu
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-pc-windows-msvc \
+// RUN:   -fms-extensions -aux-triple amdgcn-amd-amdhsa \
+// RUN:   -aux-target-cpu gfx1030 -x hip %s | FileCheck %s
+ 
+#include "Inputs/cuda.h"
+
+// Check local struct 'Op' uses Itanium mangling number instead of MSVC mangling
+// number.
+
+// CHECK: @{{.*}} = {{.*}}c"_Z6kernelIZN4TestIiE3runEvE2OpEvv\00"
+// CHECK-NOT: @{{.*}} = {{.*}}c"_Z6kernelIZN4TestIiE3runEvE2Op_1Evv\00"
+template
+__attribute__((global)) void kernel()
+{
+}
+
+template 
+class Test {
+public:
+  void run()
+  {
+struct Op 
+{
+};
+kernel<<<1, 1>>>();
+  }
+};
+
+int main() {
+  Test A;
+  A.run();
+}
Index: clang/lib/AST/MicrosoftCXXABI.cpp
===
--- clang/lib/AST/MicrosoftCXXABI.cpp
+++ clang/lib/AST/MicrosoftCXXABI.cpp
@@ -76,6 +76,11 @@
   unsigned getDeviceManglingNumber(const CXXMethodDecl *CallOperator) override {
 return DeviceCtx->getManglingNumber(CallOperator);
   }
+
+  unsigned getManglingNumber(const TagDecl *TD,
+ unsigned MSLocalManglingNumber) override {
+return DeviceCtx->getManglingNumber(TD, MSLocalManglingNumber);
+  }
 };
 
 class MSSYCLNumberingContext : public MicrosoftNumberingContext {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

@uabelho Can you please check whether 
https://github.com/llvm/llvm-project/commit/d6887256c2cae1b1b721bd47459be6d86003db6f
 fixes the problem you're seeing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 419158.
cor3ntin added a comment.

Add braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx2a %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wno-c++2b-extensions
 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wpre-c++2b-compat
 
-struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}}
+struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}} \
+// cxx2b-note 2{{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
@@ -96,7 +97,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +165,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,7 +229,7 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
+constexpr auto dependent_var_def_lambda() {
   return [](bool b) { // cxx2a-note {{declared here}}
 if (!b)
   T t;
@@ -237,4 +239,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -25,17 +25,18 @@
 label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
-struct NonLiteral {
+struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,11 +1901,17 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_non_literal_type,
- isa(Dcl)))
+if (SemaRef.LangO

[PATCH] D120874: [C++20] [Modules] Use '-' as the separator of partitions when searching in filesystems

2022-03-30 Thread Iain Sandoe via Phabricator via cfe-commits
iains accepted this revision.
iains added a comment.
This revision is now accepted and ready to land.

In D120874#3416130 , @arames wrote:

> I was was asked to chime in to assess whether this patch could be a problem 
> for
> the prebuilt-implicit clang modules workflow. No problem here.
> With prebuilt modules, the output file name has to be specified manually. So 
> the
> mapping does not change the existing requirement of managing the file names to
> avoid collissions.
> Even in the future with implicit modules - as noted by others - `:` and `-` 
> are
> not allowed in the clang module name in the `.modulemap`, so there cannot be 
> any
> conflict.

great.

> A couple comments on the way. Take them with a grain of salt, since I don't 
> much
> about how this is going to be used or what stage of the work this is.
>
> I see the mapping is only applied on the "prebuilt" code path, and not the
> "implicit" and "prebuilt implicit" code paths. I suppose at some point, module
> generation will be implicit. So any particular handling of `ModuleName` to be
> appended to the filesystem path will need to be done on different code paths. 
> So
> I would already abstract this away in a helper.

At this time I do not think that the 'implicit' pathways are in use for 'C++ 
standard'
modules, (and it might be some time before we get to that point)

> Without much of an informed opinion, I find @iains makes a valid point. Does
> this kind of mapping (semantic module name to name being used for filesystem
> search/storage) belong at a higher level ? Maybe that's to be answered or 
> worked
> on later as well.

Yes, the generalisation is in the short-is queue for things to be applied (it 
is a precursor
to support for P1184 ).

However, I think that this patch can go ahead in the mean time, to help 
short-term
workflows.

So this LGTM as it is.


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

https://reviews.llvm.org/D120874

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 419165.
abrachet marked 2 inline comments as done.
abrachet added a comment.

- Define `CLANG_CRASH_SAVE_TEMPS` in config.h and not with `add_definitions`
- Add `CLANG_CRASH_SAVE_TEMPS` env var to force emitting individual 
preprocessed sources


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

https://reviews.llvm.org/D122335

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-save-temps.c
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"   \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include 
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===

[clang] ae4dce8 - [clang][ABI] New C++20 module mangling scheme

2022-03-30 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2022-03-30T08:51:27-07:00
New Revision: ae4dce8659f313ca2034782583d31993212fa8bd

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

LOG: [clang][ABI] New C++20 module mangling scheme

Implement a demangleable strong ownership symbol mangling.

 * The original module symbol mangling scheme turned out to be
undemangleable.

 * The hoped-for C++17 compatibility of weak ownership turns out to be
fragile

* C++20 now has better ways of controlling C++17 compatibility

The issue is captured on the ABI list at:
  https://github.com/itanium-cxx-abi/cxx-abi/issues/134

GCC implements this new mangling.

The old mangling is unceremoniously dropped.  No backwards
compatibility, no deprectated old-mangling flag.  It was always
labelled experimental.  (Old and new manglings cannot be confused.)

Reviewed By: dblaikie

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

Added: 
clang/test/CodeGenCXX/Inputs/cxx20-module-impl-1a.cpp
clang/test/CodeGenCXX/Inputs/cxx20-module-std-subst-2a.cpp
clang/test/CodeGenCXX/cxx20-module-decomp-1.cpp
clang/test/CodeGenCXX/cxx20-module-extern-1.cppm
clang/test/CodeGenCXX/cxx20-module-impl-1a.cpp
clang/test/CodeGenCXX/cxx20-module-nested-1.cppm
clang/test/CodeGenCXX/cxx20-module-nested-2.cppm
clang/test/CodeGenCXX/cxx20-module-part-1a.cpp
clang/test/CodeGenCXX/cxx20-module-part-1b.cpp
clang/test/CodeGenCXX/cxx20-module-part-1c.cpp
clang/test/CodeGenCXX/cxx20-module-std-subst-1.cppm
clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm

Modified: 
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
clang/test/CXX/modules-ts/basic/basic.link/p3.cppm
clang/test/CXX/modules-ts/codegen-basics.cppm

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 9b8585bbe3128..46c888430bb07 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1547,6 +1547,11 @@ LinkageInfo 
LinkageComputer::getDeclLinkageAndVisibility(const NamedDecl *D) {
 }
 
 Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
+  if (isa(this))
+// Namespaces never have module linkage.  It is the entities within them
+// that [may] do.
+return nullptr;
+
   Module *M = getOwningModule();
   if (!M)
 return nullptr;

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 96716f6ce0e31..fb76fa7b896fc 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -438,6 +438,7 @@ class CXXNameMangler {
   void mangleType(QualType T);
   void mangleNameOrStandardSubstitution(const NamedDecl *ND);
   void mangleLambdaSig(const CXXRecordDecl *Lambda);
+  void mangleModuleNamePrefix(StringRef Name);
 
 private:
 
@@ -473,22 +474,21 @@ class CXXNameMangler {
 
   void mangleNameWithAbiTags(GlobalDecl GD,
  const AbiTagList *AdditionalAbiTags);
-  void mangleModuleName(const Module *M);
-  void mangleModuleNamePrefix(StringRef Name);
+  void mangleModuleName(const NamedDecl *ND);
   void mangleTemplateName(const TemplateDecl *TD,
   const TemplateArgument *TemplateArgs,
   unsigned NumTemplateArgs);
-  void mangleUnqualifiedName(GlobalDecl GD,
+  void mangleUnqualifiedName(GlobalDecl GD, const DeclContext *DC,
  const AbiTagList *AdditionalAbiTags) {
-mangleUnqualifiedName(GD, cast(GD.getDecl())->getDeclName(), 
UnknownArity,
-  AdditionalAbiTags);
+mangleUnqualifiedName(GD, cast(GD.getDecl())->getDeclName(), DC,
+  UnknownArity, AdditionalAbiTags);
   }
   void mangleUnqualifiedName(GlobalDecl GD, DeclarationName Name,
- unsigned KnownArity,
+ const DeclContext *DC, unsigned KnownArity,
  const AbiTagList *AdditionalAbiTags);
-  void mangleUnscopedName(GlobalDecl GD,
+  void mangleUnscopedName(GlobalDecl GD, const DeclContext *DC,
   const AbiTagList *AdditionalAbiTags);
-  void mangleUnscopedTemplateName(GlobalDecl GD,
+  void mangleUnscopedTemplateName(GlobalDecl GD, const DeclContext *DC,
   const AbiTagList *AdditionalAbiTags);
   void mangleSourceName(const IdentifierInfo *II);
   void mangleRegCallName(c

[PATCH] D122256: [clang][ABI] New C++20 module mangling scheme

2022-03-30 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae4dce8659f3: [clang][ABI] New C++20 module mangling scheme 
(authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D122256?vs=418180&id=419169#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122256

Files:
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
  clang/test/CXX/modules-ts/basic/basic.link/p3.cppm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CodeGenCXX/Inputs/cxx20-module-impl-1a.cpp
  clang/test/CodeGenCXX/Inputs/cxx20-module-std-subst-2a.cpp
  clang/test/CodeGenCXX/cxx20-module-decomp-1.cpp
  clang/test/CodeGenCXX/cxx20-module-extern-1.cppm
  clang/test/CodeGenCXX/cxx20-module-impl-1a.cpp
  clang/test/CodeGenCXX/cxx20-module-nested-1.cppm
  clang/test/CodeGenCXX/cxx20-module-nested-2.cppm
  clang/test/CodeGenCXX/cxx20-module-part-1a.cpp
  clang/test/CodeGenCXX/cxx20-module-part-1b.cpp
  clang/test/CodeGenCXX/cxx20-module-part-1c.cpp
  clang/test/CodeGenCXX/cxx20-module-std-subst-1.cppm
  clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
  clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
  clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
  clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
  clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm

Index: clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+export module FOO;
+
+class One;
+class Two;
+
+export template struct TPL
+{
+void M (T *);
+template void N (T *, U*);
+};
+
+template
+void TPL::M (T *) {}
+
+template template void TPL::N (T *, U*) {}
+
+// CHECK-DAG: void @_ZNW3FOO3TPLIS_3OneE1MEPS1_(
+template void TPL::M (One *);
+// CHECK-DAG: void @_ZNW3FOO3TPLIS_3OneE1NIS_3TwoEEvPS1_PT_(
+template void TPL::N (One *, Two *);
+
+namespace NMS {
+class One;
+class Two;
+
+export template struct TPL
+{
+void M (T *);
+template void N (T *, U*);
+};
+
+template
+void TPL::M (T *) {}
+
+template template void TPL::N (T *, U*) {}
+
+// CHECK-DAG: void @_ZN3NMSW3FOO3TPLINS_S0_3OneEE1MEPS2_(
+template void TPL::M (One *);
+// CHECK-DAG: void @_ZN3NMSW3FOO3TPLINS_S0_3OneEE1NINS_S0_3TwoEEEvPS2_PT_
+template void TPL::N (One *, Two *);
+}
Index: clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %S/cxx20-module-sub-1a.cppm -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+
+export module FOO.BAZ;
+import FOO.BAR;
+
+namespace Bob {
+
+// CHECK-DAG: void @_ZN3BobW3FOOW3BAZ3FooEPS0_W3BAR1APNS_S2_1BE(
+void Foo (A *, B*) {
+}
+}
+
+// CHECK-DAG: void @_ZW3FOOW3BAZ3BarPS_W3BAR1APN3BobS1_1BE(
+void Bar (A *, Bob::B*) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+export module FOO.BAR;
+export class A;
+namespace Bob {
+export class B;
+
+// CHECK-DAG: void @_ZN3BobW3FOOW3BAR3BarEPS1_1APNS_S1_1BE(
+export void Bar (A *, B*) {
+}
+}
+
+// CHECK-DAG: void @_ZW3FOOW3BAR3FooPS0_1APN3BobS0_1BE(
+export void Foo (A *, Bob::B*) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %S/Inputs/cxx20-module-std-subst-2a.cpp -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+module;
+# 5 __FILE__ 1
+namespace std {
+template  struct char_traits {};
+} // namespace std
+# 9 "" 2
+export module Bar;
+import RenameString;
+
+// Use Ss as this is global-module std::char_traits
+// CHECK-DAG: void @_ZW3Bar1gRSs(
+void g(str> &s) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %S/Inputs/cxx20-module-std-subst-2a.cpp -

[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alex Brachet via Phabricator via cfe-commits
abrachet marked 2 inline comments as done.
abrachet added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:1434
 StringRef AdditionalInformation, CompilationDiagnosticReport *Report) {
+#ifdef CLANG_CRASH_SAVE_TEMPS
+  constexpr bool SaveReproTemps = true;

arichardson wrote:
> This could be simplified with `#cmakedefine01` in the config header
Thanks I like that a lot better.



Comment at: clang/test/Driver/crash-report-clang-cl.cpp:1
+// UNSUPPORTED: windows
+

arichardson wrote:
> I think it would be cleaner to add a new feature if tar is available in $PATH 
> instead of ignoring all windows bots. Some might have tar installed.
It's not clear to me what the Windows builders don't like. `tar(1)` is used in 
some lld tests. My guess is that the tar shipped on Windows doesn't support 
`--wildcards` which is seemingly necessary here because the tar file will have 
a random name, and it's member files are prefixed with that name. I don't have 
easy access to a Windows machine to test that theory though.

I've gone with your suggestion to have an env var. Do you think I should remove 
`UNSUPPORTED: windows` on all tests or just this one?



Comment at: clang/test/Driver/crash-report-clang-cl.cpp:8
 // RUN: -fcrash-diagnostics-dir=%t -- %s 2>&1 | FileCheck %s
-// RUN: cat %t/crash-report-clang-cl-*.cpp | FileCheck --check-prefix=CHECKSRC 
%s
-// RUN: cat %t/crash-report-clang-cl-*.sh | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-report-clang-cl-*.cpp" \
+// RUN: | FileCheck --check-prefix=CHECKSRC %s

arichardson wrote:
> Alternatively, if we had an env var/command line option to keep the cpp/sh, 
> we could use that to avoid the dependency on tar in this test.
Sure.



Comment at: clang/test/Driver/crash-report-save-temps.c:14
+
+// RUN: false

arichardson wrote:
> Is this line intentional?
Nope, thanks.


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

https://reviews.llvm.org/D122335

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


[PATCH] D122335: [clang] Emit crash reproduction as a single tar file

2022-03-30 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 419170.
abrachet marked 2 inline comments as done.
abrachet added a comment.

reabase


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

https://reviews.llvm.org/D122335

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-save-temps.c
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Index/create-libclang-completion-reproducer.c
  clang/test/Index/create-libclang-parsing-reproducer.c
  clang/test/Modules/crash-vfs-path-emptydir-entries.m
  clang/test/Modules/crash-vfs-path-symlink-component.m
  clang/test/Modules/crash-vfs-path-symlink-topheader.m
  clang/test/Modules/crash-vfs-path-traversal.m
  clang/test/Modules/crash-vfs-relative-overlay.m
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -14,14 +14,12 @@
 // RUN: -F %/t/i/Frameworks -fmodules \
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "B.framework/Headers/B.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml" \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKYAML:  'type': 'directory',
 // CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
@@ -39,6 +37,8 @@
 // CHECKYAML-NEXT:  'name': "B.h",
 // CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
 
+// CHECKTAR: B.framework/Headers/B.h
+
 @import I;
 
 // Run the reproducer script - regular exit code is enough to test it works. The
@@ -51,5 +51,6 @@
 // RUN: cd %t
 // RUN: rm -rf i
 // RUN: rm -rf crash-vfs-umbrella-*.cache/modules/*
-// RUN: chmod 755 crash-vfs-*.sh
-// RUN: ./crash-vfs-*.sh
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh" > repro.sh
+// RUN: chmod 755 repro.sh
+// RUN: ./repro.sh
Index: clang/test/Modules/crash-vfs-relative-overlay.m
===
--- clang/test/Modules/crash-vfs-relative-overlay.m
+++ clang/test/Modules/crash-vfs-relative-overlay.m
@@ -11,18 +11,18 @@
 // RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
 // RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
 
-// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
-// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
-// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
-// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
-// RUN: find %t/crash-vfs-*.cache/vfs | \
-// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/crash-vfs-*.m"  \
+// RUN:  | FileCheck --check-prefix=CHECKSRC %s
+// RUN: tar xOf %t/*.tar --wildcards "*/repro.sh"   \
+// RUN:  | FileCheck --check-prefix=CHECKSH %s
+// RUN: tar xOf %t/*.tar --wildcards "*/tmp/vfs/vfs.yaml"   \
+// RUN:  | FileCheck --check-prefix=CHECKYAML %s
+// RUN: tar tf %t/*.tar | FileCheck --check-prefix=CHECKTAR %s
 
 #include 
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.tar
 
 // CHECKSRC: #pragma clang module import cstd.stdio
 
@@ -49,6 +49,8 @@
 // CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
 // CHECKYAML-NEXT:   },
 
+// CHECKTAR: Inputs/crash-recovery/usr/include/stdio.h
+
 // Test that reading the YAML file will yield the correct path after
 // the overlay dir is prefixed to access headers in .cache/vfs directory.
 
Index: clang/test/Modules/crash-vfs-path-traversal.m
===
--- clang/test/Modules/crash-vfs-path-traversal.m
+++ clang/test/Modules/crash-vfs-path-traversal.

[PATCH] D121271: [C++20] [Modules] Don't generate strong function of a partition in importing modules

2022-03-30 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

it looks like the first part of the C++20 mangling was just landed, so perhaps 
you can revisit this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121271

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


[clang] 6e33e45 - [ASTMatchers] Output currently matching node on crash

2022-03-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2022-03-30T17:14:00+01:00
New Revision: 6e33e45b943061f79ab6de1b60d04d4c6f32f8f9

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

LOG: [ASTMatchers] Output currently matching node on crash

Extend D120185 to also log the node being matched on in case of a crash.
This can help if a matcher is causing a crash or there are not enough 
interesting nodes bound.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 70598460151ae..e4141232d1c6f 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -761,53 +761,166 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
 D);
   }
 
+private:
+  bool TraversingASTNodeNotSpelledInSource = false;
+  bool TraversingASTNodeNotAsIs = false;
+  bool TraversingASTChildrenNotSpelledInSource = false;
+
+  class CurMatchData {
+  public:
+CurMatchData() = default;
+
+template 
+void SetCallbackAndRawNode(const MatchCallback *CB, const NodeType &N) {
+  assertEmpty();
+  Callback = CB;
+  MatchingNode = &N;
+}
+
+const MatchCallback *getCallback() const { return Callback; }
+
+void SetBoundNodes(const BoundNodes &BN) {
+  assertHoldsState();
+  BNodes = &BN;
+}
+
+void clearBoundNodes() {
+  assertHoldsState();
+  BNodes = nullptr;
+}
+
+template  const T *getNode() const {
+  assertHoldsState();
+  return MatchingNode.dyn_cast();
+}
+
+const BoundNodes *getBoundNodes() const {
+  assertHoldsState();
+  return BNodes;
+}
+
+void reset() {
+  assertHoldsState();
+  Callback = nullptr;
+  MatchingNode = nullptr;
+}
+
+  private:
+void assertHoldsState() const {
+  assert(Callback != nullptr && !MatchingNode.isNull());
+}
+
+void assertEmpty() const {
+  assert(Callback == nullptr && MatchingNode.isNull() && BNodes == 
nullptr);
+}
+
+const MatchCallback *Callback = nullptr;
+const BoundNodes *BNodes = nullptr;
+
+llvm::PointerUnion<
+const QualType *, const TypeLoc *, const NestedNameSpecifier *,
+const NestedNameSpecifierLoc *, const CXXCtorInitializer *,
+const TemplateArgumentLoc *, const Attr *, const DynTypedNode *>
+MatchingNode;
+  } CurMatchState;
+
+  struct CurMatchRAII {
+template 
+CurMatchRAII(MatchASTVisitor &MV, const MatchCallback *CB,
+ const NodeType &NT)
+: MV(MV) {
+  MV.CurMatchState.SetCallbackAndRawNode(CB, NT);
+}
+
+~CurMatchRAII() { MV.CurMatchState.reset(); }
+
+  private:
+MatchASTVisitor &MV;
+  };
+
+public:
   class TraceReporter : llvm::PrettyStackTraceEntry {
+static void dumpNode(const ASTContext &Ctx, const DynTypedNode &Node,
+ raw_ostream &OS) {
+  if (const auto *D = Node.get()) {
+OS << D->getDeclKindName() << "Decl ";
+if (const auto *ND = dyn_cast(D)) {
+  ND->printQualifiedName(OS);
+  OS << " : ";
+} else
+  OS << ": ";
+D->getSourceRange().print(OS, Ctx.getSourceManager());
+  } else if (const auto *S = Node.get()) {
+OS << S->getStmtClassName() << " : ";
+S->getSourceRange().print(OS, Ctx.getSourceManager());
+  } else if (const auto *T = Node.get()) {
+OS << T->getTypeClassName() << "Type : ";
+QualType(T, 0).print(OS, Ctx.getPrintingPolicy());
+  } else if (const auto *QT = Node.get()) {
+OS << "QualType : ";
+QT->print(OS, Ctx.getPrintingPolicy());
+  } else {
+OS << Node.getNodeKind().asStringRef() << " : ";
+Node.getSourceRange().print(OS, Ctx.getSourceManager());
+  }
+}
+
+static void dumpNodeFromState(const ASTContext &Ctx,
+  const CurMatchData &State, raw_ostream &OS) {
+  if (const DynTypedNode *MatchNode = State.getNode()) {
+dumpNode(Ctx, *MatchNode, OS);
+  } else if (const auto *QT = State.getNode()) {
+dumpNode(Ctx, DynTypedNode::create(*QT), OS);
+  } else if (const auto *TL = State.getNode()) {
+dumpNode(Ctx, DynTypedNode::create(*TL), OS);
+  } else if (const auto *NNS = State.getNode()) {
+dumpNode(Ctx, DynTypedNode::create(*NNS), OS);
+  } else if (const auto *NNSL = State.getNode()) {
+dumpNode(Ctx, DynTypedNode::create(*NNSL), OS);
+  } else if (const auto *CtorInit = State.getNode()) {
+dumpNode(Ctx, DynTypedNode::create(*

[PATCH] D122529: [ASTMatchers] Output currently matching node on crash

2022-03-30 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e33e45b9430: [ASTMatchers] Output currently matching node 
on crash (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D122529?vs=418473&id=419178#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122529

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -39,10 +39,24 @@
 // FIXME: Figure out why back traces aren't being generated on clang builds on
 // windows.
 #if ENABLE_BACKTRACES && (!defined(_MSC_VER) || !defined(__clang__))
+
+AST_MATCHER(Decl, causeCrash) {
+  abort();
+  return true;
+}
+
+TEST(MatcherCrashDeathTest, CrashOnMatcherDump) {
+  llvm::EnablePrettyStackTrace();
+  auto Matcher = testing::HasSubstr(
+  "ASTMatcher: Matching '' against:\n\tFunctionDecl foo : "
+  "");
+  ASSERT_DEATH(matches("void foo();", functionDecl(causeCrash())), Matcher);
+}
+
 template 
 static void crashTestNodeDump(MatcherT Matcher,
   ArrayRef MatchedNodes,
-  StringRef Code) {
+  StringRef Against, StringRef Code) {
   llvm::EnablePrettyStackTrace();
   MatchFinder Finder;
 
@@ -58,7 +72,9 @@
 ASSERT_DEATH(tooling::runToolOnCode(
  newFrontendActionFactory(&Finder)->create(), Code),
  testing::HasSubstr(
- "ASTMatcher: Processing 'CrashTester'\nNo bound nodes"));
+ ("ASTMatcher: Processing 'CrashTester' against:\n\t" +
+  Against + "\nNo bound nodes")
+ .str()));
   } else {
 std::vector>>
@@ -69,7 +85,9 @@
 }
 auto CrashMatcher = testing::AllOf(
 testing::HasSubstr(
-"ASTMatcher: Processing 'CrashTester'\n--- Bound Nodes Begin ---"),
+("ASTMatcher: Processing 'CrashTester' against:\n\t" + Against +
+ "\n--- Bound Nodes Begin ---")
+.str()),
 testing::HasSubstr("--- Bound Nodes End ---"),
 testing::AllOfArray(Matchers));
 
@@ -79,7 +97,8 @@
   }
 }
 TEST(MatcherCrashDeathTest, CrashOnCallbackDump) {
-  crashTestNodeDump(forStmt(), {}, "void foo() { for(;;); }");
+  crashTestNodeDump(forStmt(), {}, "ForStmt : ",
+"void foo() { for(;;); }");
   crashTestNodeDump(
   forStmt(hasLoopInit(declStmt(hasSingleDecl(
varDecl(hasType(qualType().bind("QT")),
@@ -94,6 +113,7 @@
"IL - { IntegerLiteral :  }", "QT - { QualType : int }",
"T - { BuiltinType : int }",
"VD - { VarDecl I :  }"},
+  "ForStmt : ",
   R"cpp(
   void foo() {
 for (int I = 0; I < 5; ++I) {
@@ -106,12 +126,14 @@
   {"Unnamed - { CXXRecordDecl (anonymous) :  }",
"Op+ - { CXXMethodDecl (anonymous struct)::operator+ :  }"},
+  "CXXRecordDecl (anonymous) : ",
   "struct { int operator+(int) const; } Unnamed;");
   crashTestNodeDump(
   cxxRecordDecl(hasMethod(cxxConstructorDecl(isDefaulted()).bind("Ctor")),
 hasMethod(cxxDestructorDecl(isDefaulted()).bind("Dtor"))),
   {"Ctor - { CXXConstructorDecl Foo::Foo :  }",
"Dtor - { CXXDestructorDecl Foo::~Foo :  }"},
+  "CXXRecordDecl Foo : ",
   "struct Foo { Foo() = default; ~Foo() = default; };");
 }
 #endif // ENABLE_BACKTRACES
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -761,53 +761,166 @@
 D);
   }
 
+private:
+  bool TraversingASTNodeNotSpelledInSource = false;
+  bool TraversingASTNodeNotAsIs = false;
+  bool TraversingASTChildrenNotSpelledInSource = false;
+
+  class CurMatchData {
+  public:
+CurMatchData() = default;
+
+template 
+void SetCallbackAndRawNode(const MatchCallback *CB, const NodeType &N) {
+  assertEmpty();
+  Callback = CB;
+  MatchingNode = &N;
+}
+
+const MatchCallback *getCallback() const { return Callback; }
+
+void SetBoundNodes(const BoundNodes &BN) {
+  assertHoldsState();
+  BNodes = &BN;
+}
+
+void clearBoundNodes() {
+  assertHoldsState();
+  BNodes = nullptr;
+}
+
+template  const T *getNode() const {
+  assertHoldsState();
+  return MatchingNode.dyn_cast();
+}
+
+const BoundNodes *getBoundNodes() const {
+  assertHoldsState();
+  return BNodes;
+}
+
+void reset() {
+  assertHoldsState();
+  Callback = nullptr;
+  MatchingNode = nu

[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-30 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 419181.
paulkirth added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

Files:
  clang/docs/MisExpect.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/index.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch-unpredictable.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/docs/MisExpect.rst
  llvm/docs/UserGuides.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-threshold.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,285 @@
+; Test misexpect diagnostics handle swich statements, and report source locations correctly
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:30: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:30: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; BOTH-DAG: warning: misexpect-switch.c:26:30: 0.00%
+; BOTH-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; DISABLED-NOT: warning: misexpect-switch.c:26:30: 0.00%
+; DISABLED-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from us

[PATCH] D122713: [RISCV] [NFC] Add tests for vector load/store overloaded intrinsics of FP16

2022-03-30 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

These tests files are already too long and have been timing out in phabricator. 
@4vtomat has a patch D122370  to split them 
up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122713

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


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D122471#3416797 , @nikic wrote:

> @uabelho Can you please check whether 
> https://github.com/llvm/llvm-project/commit/d6887256c2cae1b1b721bd47459be6d86003db6f
>  fixes the problem you're seeing?

Hi @nikic

Yes, that patch solves the problem. Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D122589: Additionally set f32 mode with denormal-fp-math

2022-03-30 Thread David Candler via Phabricator via cfe-commits
dcandler added a comment.

The issue I found was trying to use getDefaultDenormalModeForType during 
constant folding to account for denormals (https://reviews.llvm.org/D116952). 
Setting denormal-fp-math to a non-IEEE mode without specifying 
denormal-fp-math-f32 still results in the denormal-fp-math-f32 attribute being 
present (even if unsued elsewhere), which leads to the wrong result for targets 
that do not support denormal-fp-math-f32.

Only emitting denormal-fp-math-f32 when specified makes sense, but the current 
default effectively always specifies it as IEEE. One alternative would be to 
simply change the default.


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

https://reviews.llvm.org/D122589

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


[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 419197.
dang marked 2 inline comments as done.
dang added a comment.

Rebase on top of latest changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122648

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/macro_undefined.c
  clang/test/ExtractAPI/macros.c

Index: clang/test/ExtractAPI/macros.c
===
--- /dev/null
+++ clang/test/ExtractAPI/macros.c
@@ -0,0 +1,344 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=Macros -target arm64-apple-macosx \
+// RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+#define HELLO 1
+#define WORLD 2
+#define MACRO_FUN(x) x x
+#define FUN(x, y, z) x + y + z
+#define FUNC99(x, ...)
+#define FUNGNU(x...)
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "Macros",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "HELLO"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@8@macro@HELLO"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 1,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "HELLO"
+  }
+],
+"title": "HELLO"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "WORLD"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@24@macro@WORLD"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 2,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "WORLD"
+  }
+],
+"title": "WORLD"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "MACRO_FUN"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@40@macro@MACRO_FUN"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "MACRO_FUN"
+  }
+],
+"title": "MACRO_FUN"
+  }
+},
+{
+  "declarationFragments": [
+{
+ 

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

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

LGTM




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (!VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),

hubert.reinterpretcast wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > cor3ntin wrote:
> > > > > hubert.reinterpretcast wrote:
> > > > > > This seems to trigger even when the type is dependent:
> > > > > > ```
> > > > > > :1:36: warning: definition of a variable of non-literal type 
> > > > > > in a constexpr function is incompatible with C++ standards before 
> > > > > > C++2b [-Wpre-c++2b-compat]
> > > > > > auto qq = [](auto x) { decltype(x) n; };
> > > > > >^
> > > > > > 1 warning generated.
> > > > > > ```
> > > > > > 
> > > > > > This also seems to emit even when `Kind` is not 
> > > > > > `Sema::CheckConstexprKind::Diagnose` (unlike the 
> > > > > > `static`/`thread_local` case above). Is the `CheckLiteralType` 
> > > > > > logic not reusable for this?
> > > > > You are right, thanks for noticing that, it was rather bogus.
> > > > > The reason I'm not using CheckLiteralType is to avoid duplicating a 
> > > > > diagnostics message, as CheckLiteralType doesn't allow us to pass 
> > > > > parameter to the diagnostic message.
> > > > > 
> > > > > It leaves us with an uncovered scenario though: We do not emit the 
> > > > > warning on template instantiation, and I don't think there is an  
> > > > > easy way to do that.
> > > > > The reason I'm not using CheckLiteralType is to avoid duplicating a 
> > > > > diagnostics message, as CheckLiteralType doesn't allow us to pass 
> > > > > parameter to the diagnostic message.
> > > > 
> > > > Huh?
> > > > 
> > > > ```
> > > > static bool CheckLiteralType(Sema &SemaRef, Sema::CheckConstexprKind 
> > > > Kind,
> > > >  SourceLocation Loc, QualType T, unsigned 
> > > > DiagID,
> > > >  Ts &&...DiagArgs) {
> > > >   ...
> > > > }
> > > > ```
> > > > I would hope `DiagArgs` should do exactly that? :-)
> > > > It leaves us with an uncovered scenario though: We do not emit the 
> > > > warning on template instantiation, and I don't think there is an easy 
> > > > way to do that.
> > > 
> > > I believe the code paths that lead us here all come from 
> > > `Sema::CheckConstexprFunctionDefinition()` which is called from 
> > > `Sema::ActOnFinishFunctionBody()` which seems to be called when 
> > > instantiating templates in `Sema::InstantiateFunctionDefinition()`, so 
> > > perhaps some more investigation is needed as to why we're not reaching 
> > > this for template instantiations.
> > We could add something in addition of 
> > `Sema::CheckConstexprKind::CheckValid` and 
> > `Sema::CheckConstexprKind::Diagnose`, but 
> > 
> > * not for implicit lambdas, because we should not warn on lambdas that 
> > won't be constexpr
> > * for explicit constexpr lambdas / functions, it would force us to call 
> > CheckConstexprFunctionDefinition  on instanciation, which we currently 
> > don't do, and is not free for that one warning - and we would have to 
> > not-reemit the other warnings. It seems like quite a fair amount of work 
> > for a diagnostic not enabled by default.
> > so perhaps some more investigation is needed as to why we're not reaching 
> > this for template instantiations.
> 
> @aaron.ballman, do you have any position on whether we want this 
> investigation before moving forward with this patch?
>>so perhaps some more investigation is needed as to why we're not reaching 
>>this for template instantiations.
> @aaron.ballman, do you have any position on whether we want this 
> investigation before moving forward with this patch?

@hubert.reinterpretcast -- I think @cor3ntin did that investigation and found 
that we don't make it to this code path because of 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaDecl.cpp#L14961.

I think this is incremental progress, and we can handle the template 
instantiation cases in a follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[clang] 61d67c8 - Revert "[ASTMatchers] Output currently matching node on crash"

2022-03-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2022-03-30T18:10:48+01:00
New Revision: 61d67c8eecd2547bc690f9a6bba61b9ba814c71b

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

LOG: Revert "[ASTMatchers] Output currently matching node on crash"

This reverts commit 6e33e45b943061f79ab6de1b60d04d4c6f32f8f9.

Fails to build on 32bit machines due to PointerUnion limitations

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index e4141232d1c6f..70598460151ae 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -761,166 +761,53 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
 D);
   }
 
-private:
-  bool TraversingASTNodeNotSpelledInSource = false;
-  bool TraversingASTNodeNotAsIs = false;
-  bool TraversingASTChildrenNotSpelledInSource = false;
-
-  class CurMatchData {
-  public:
-CurMatchData() = default;
-
-template 
-void SetCallbackAndRawNode(const MatchCallback *CB, const NodeType &N) {
-  assertEmpty();
-  Callback = CB;
-  MatchingNode = &N;
-}
-
-const MatchCallback *getCallback() const { return Callback; }
-
-void SetBoundNodes(const BoundNodes &BN) {
-  assertHoldsState();
-  BNodes = &BN;
-}
-
-void clearBoundNodes() {
-  assertHoldsState();
-  BNodes = nullptr;
-}
-
-template  const T *getNode() const {
-  assertHoldsState();
-  return MatchingNode.dyn_cast();
-}
-
-const BoundNodes *getBoundNodes() const {
-  assertHoldsState();
-  return BNodes;
-}
-
-void reset() {
-  assertHoldsState();
-  Callback = nullptr;
-  MatchingNode = nullptr;
-}
-
-  private:
-void assertHoldsState() const {
-  assert(Callback != nullptr && !MatchingNode.isNull());
-}
-
-void assertEmpty() const {
-  assert(Callback == nullptr && MatchingNode.isNull() && BNodes == 
nullptr);
-}
-
-const MatchCallback *Callback = nullptr;
-const BoundNodes *BNodes = nullptr;
-
-llvm::PointerUnion<
-const QualType *, const TypeLoc *, const NestedNameSpecifier *,
-const NestedNameSpecifierLoc *, const CXXCtorInitializer *,
-const TemplateArgumentLoc *, const Attr *, const DynTypedNode *>
-MatchingNode;
-  } CurMatchState;
-
-  struct CurMatchRAII {
-template 
-CurMatchRAII(MatchASTVisitor &MV, const MatchCallback *CB,
- const NodeType &NT)
-: MV(MV) {
-  MV.CurMatchState.SetCallbackAndRawNode(CB, NT);
-}
-
-~CurMatchRAII() { MV.CurMatchState.reset(); }
-
-  private:
-MatchASTVisitor &MV;
-  };
-
-public:
   class TraceReporter : llvm::PrettyStackTraceEntry {
-static void dumpNode(const ASTContext &Ctx, const DynTypedNode &Node,
- raw_ostream &OS) {
-  if (const auto *D = Node.get()) {
-OS << D->getDeclKindName() << "Decl ";
-if (const auto *ND = dyn_cast(D)) {
-  ND->printQualifiedName(OS);
-  OS << " : ";
-} else
-  OS << ": ";
-D->getSourceRange().print(OS, Ctx.getSourceManager());
-  } else if (const auto *S = Node.get()) {
-OS << S->getStmtClassName() << " : ";
-S->getSourceRange().print(OS, Ctx.getSourceManager());
-  } else if (const auto *T = Node.get()) {
-OS << T->getTypeClassName() << "Type : ";
-QualType(T, 0).print(OS, Ctx.getPrintingPolicy());
-  } else if (const auto *QT = Node.get()) {
-OS << "QualType : ";
-QT->print(OS, Ctx.getPrintingPolicy());
-  } else {
-OS << Node.getNodeKind().asStringRef() << " : ";
-Node.getSourceRange().print(OS, Ctx.getSourceManager());
-  }
-}
-
-static void dumpNodeFromState(const ASTContext &Ctx,
-  const CurMatchData &State, raw_ostream &OS) {
-  if (const DynTypedNode *MatchNode = State.getNode()) {
-dumpNode(Ctx, *MatchNode, OS);
-  } else if (const auto *QT = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*QT), OS);
-  } else if (const auto *TL = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*TL), OS);
-  } else if (const auto *NNS = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*NNS), OS);
-  } else if (const auto *NNSL = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*NNSL), OS);
-  } else if (const auto *CtorInit = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*CtorInit), OS);
-  } else if (const auto *TAL = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*T

[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 419202.
lenary added a comment.

- Rewrite pass in terms of ReachingDefAnalysis
- Split tests into separate commit, for ease of review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-fix-cortex-a57-aes-1742098.c
  llvm/lib/CodeGen/RDFGraph.cpp
  llvm/lib/Target/ARM/ARM.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMFixCortexA57AES1742098Pass.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/ARM/aes-erratum-fix.ll

Index: llvm/test/CodeGen/ARM/aes-erratum-fix.ll
===
--- llvm/test/CodeGen/ARM/aes-erratum-fix.ll
+++ llvm/test/CodeGen/ARM/aes-erratum-fix.ll
@@ -24,6 +24,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r0]
 ; CHECK-FIX-NEXT:vmov.i32 q9, #0x0
+; CHECK-FIX-NEXT:vorr q9, q9, q9
 ; CHECK-FIX-NEXT:aese.8 q9, q8
 ; CHECK-FIX-NEXT:aesmc.8 q8, q9
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r0]
@@ -55,6 +56,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_once_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_once_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q0, q1
 ; CHECK-FIX-NEXT:bx lr
@@ -91,6 +94,9 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_twice_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_twice_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q1
 ; CHECK-FIX-NEXT:aese.8 q8, q0
@@ -154,6 +160,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_loop_via_val(i32 %0, <16 x i8> %1, <16 x i8> %2) nounwind {
 ; CHECK-FIX-LABEL: aese_loop_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB6_2
 ; CHECK-FIX-NEXT:  .LBB6_1: @ =>This Inner Loop Header: Depth=1
@@ -186,6 +194,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r0]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -202,8 +211,10 @@
 define arm_aapcs_vfpcc void @aese_set8_via_val(i8 zeroext %0, <16 x i8> %1, <16 x i8>* %2) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r0
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -225,6 +236,7 @@
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:  .LBB9_2:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -248,12 +260,14 @@
 define arm_aapcs_vfpcc void @aese_set8_cond_via_val(i1 zeroext %0, i8 zeroext %1, <16 x i8> %2, <16 x i8>* %3) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_cond_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB10_2
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r1
 ; CHECK-FIX-NEXT:  .LBB10_2: @ %select.end
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -276,6 +290,7 @@
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB11_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -318,6 +333,7 @@
 ; CHECK-FIX-NEXT:vmov.8 d0[0], r1
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB12_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -355,6 +371,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.16 {d0[0]}, [r0:16]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:ae

[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary removed a reviewer: kparzysz.
lenary added a comment.

@kparzysz I have rewritten this to avoid using RDFGraph, so I don't think this 
needs you to review it any more.




Comment at: llvm/test/CodeGen/ARM/aes-erratum-fix.ll:49
+
+define <16 x i8> @aese_once_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
+; CHECK-FIX-NOSCHED-LABEL: aese_once_via_val:

dmgreen wrote:
> Adding arm_aapcs_vfpcc will make the function "hardfp", which might be useful 
> for testing inputs from argument that don't need to be passed via gpr regs.
Yeah, seems I was too zealous with removing some of these attributes. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

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


[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary planned changes to this revision.
lenary added inline comments.



Comment at: llvm/lib/CodeGen/RDFGraph.cpp:1096
 RegisterRef RR = PDA.Addr->getRegRef(*this);
-#ifndef NDEBUG
-// Assert if the register is defined in two or more unrelated defs.
-// This could happen if there are two or more def operands defining it.
-if (!Defined.insert(RR.Reg).second) {
-  MachineInstr *MI = NodeAddr(IA).Addr->getCode();
-  dbgs() << "Multiple definitions of register: "
- << Print(RR, *this) << " in\n  " << *MI << "in "
- << printMBBReference(*MI->getParent()) << '\n';
-  llvm_unreachable(nullptr);
-}
-#endif
+// #ifndef NDEBUG
+// // Assert if the register is defined in two or more unrelated defs.

I forgot to remove these comments, will update shortly.



Comment at: llvm/lib/Target/ARM/ARMSubtarget.h:543
   unsigned getGPRAllocationOrder(const MachineFunction &MF) const;
+
 };

I missed this, will update again shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I thing to support the template case, we would have to modify 
`TemplateDeclInstantiator::VisitVarDecl` - which seems the best way to have a 
diagnostic without running through the whole function AST twice.
However, there is currently no check of any sort there so it would be a bit 
novel and odd!

Thank you both for the review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[clang] 0550601 - [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-03-30T19:18:53+02:00
New Revision: 0550601d180111a1c48baf170c2e7e9c7fac28c2

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

LOG: [Clang] Add a compatibiliy warning for non-literals in constexpr.

Reviewed By: aaron.ballman, hubert.reinterpretcast

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
clang/test/SemaCXX/constant-expression-cxx2b.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d3055fed20828..a272cb741270f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2721,9 +2721,9 @@ def ext_constexpr_static_var : ExtWarn<
   "definition of a %select{static|thread_local}1 variable "
   "in a constexpr %select{function|constructor}0 "
   "is a C++2b extension">, InGroup;
-def warn_cxx20_compat_constexpr_static_var : Warning<
-  "definition of a %select{static|thread_local}1 variable "
-  "in a constexpr %select{function|constructor}0 "
+def warn_cxx20_compat_constexpr_var : Warning<
+  "definition of a %select{static variable|thread_local variable|variable "
+  "of non-literal type}1 in a constexpr %select{function|constructor}0 "
   "is incompatible with C++ standards before C++2b">,
   InGroup, DefaultIgnore;
 def err_constexpr_local_var_non_literal_type : Error<

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 48fb642ad15e1..0f56e6024f332 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const 
FunctionDecl *Dcl,
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,11 +1901,17 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const 
FunctionDecl *Dcl,
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_non_literal_type,
- isa(Dcl)))
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::warn_cxx20_compat_constexpr_var,
+   isa(Dcl),
+   /*variable of non-literal type*/ 2);
+} else if (CheckLiteralType(
+   SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::err_constexpr_local_var_non_literal_type,
+   isa(Dcl))) {
   return false;
+}
 if (!VD->getType()->isDependentType() &&
 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
   if (Kind == Sema::CheckConstexprKind::Diagnose) {

diff  --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
index 671895b278bdf..3ba5cbba79ce2 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -25,17 +25,18 @@ constexpr void h() {
 label:; // expected-warning {{use of this statement in a constexpr function is 
incompatible with C++ standards before C++2b}}
 }
 
-struct NonLiteral {
+struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never 
produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 
'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 
'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable 
of non-literal type in a constexpr function is incompatible with C++ standards 
before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of 
non-literal type in a constexpr function is incompatible with C++

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0550601d1801: [Clang] Add a compatibiliy warning for 
non-literals in constexpr. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx2a %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wno-c++2b-extensions
 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wpre-c++2b-compat
 
-struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}}
+struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}} \
+// cxx2b-note 2{{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
@@ -96,7 +97,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +165,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,7 +229,7 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
+constexpr auto dependent_var_def_lambda() {
   return [](bool b) { // cxx2a-note {{declared here}}
 if (!b)
   T t;
@@ -237,4 +239,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -25,17 +25,18 @@
 label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
-struct NonLiteral {
+struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,11 +1901,17 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLoca

[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 419205.
dang added a comment.

Update using the correct patch this time around.


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

https://reviews.llvm.org/D122648

Files:
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp

Index: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
===
--- clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -41,8 +41,8 @@
 /// information.
 class ExtractAPIVisitor : public RecursiveASTVisitor {
 public:
-  ExtractAPIVisitor(ASTContext &Context, Language Lang)
-  : Context(Context), API(Context.getTargetInfo().getTriple(), Lang) {}
+  ExtractAPIVisitor(ASTContext &Context, APISet &API)
+  : Context(Context), API(API) {}
 
   const APISet &getAPI() const { return API; }
 
@@ -489,43 +489,40 @@
   }
 
   ASTContext &Context;
-  APISet API;
+  APISet &API;
 };
 
 class ExtractAPIConsumer : public ASTConsumer {
 public:
-  ExtractAPIConsumer(ASTContext &Context, StringRef ProductName, Language Lang,
- std::unique_ptr OS)
-  : Visitor(Context, Lang), ProductName(ProductName), OS(std::move(OS)) {}
+  ExtractAPIConsumer(ASTContext &Context, APISet &API)
+  : Visitor(Context, API) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
 // Use ExtractAPIVisitor to traverse symbol declarations in the context.
 Visitor.TraverseDecl(Context.getTranslationUnitDecl());
-
-// Setup a SymbolGraphSerializer to write out collected API information in
-// the Symbol Graph format.
-// FIXME: Make the kind of APISerializer configurable.
-SymbolGraphSerializer SGSerializer(Visitor.getAPI(), ProductName);
-SGSerializer.serialize(*OS);
   }
 
 private:
   ExtractAPIVisitor Visitor;
-  std::string ProductName;
-  std::unique_ptr OS;
 };
 
 } // namespace
 
 std::unique_ptr
 ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
-  std::unique_ptr OS = CreateOutputFile(CI, InFile);
+  OS = CreateOutputFile(CI, InFile);
   if (!OS)
 return nullptr;
-  return std::make_unique(
-  CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
-  CI.getFrontendOpts().Inputs.back().getKind().getLanguage(),
-  std::move(OS));
+
+  ProductName = CI.getFrontendOpts().ProductName;
+
+  // Now that we have enough information about the language options and the
+  // target triple, let's create the APISet before anyone uses it.
+  API = std::make_unique(
+  CI.getTarget().getTriple(),
+  CI.getFrontendOpts().Inputs.back().getKind().getLanguage());
+
+  return std::make_unique(CI.getASTContext(), *API);
 }
 
 bool ExtractAPIAction::PrepareToExecuteAction(CompilerInstance &CI) {
@@ -557,6 +554,18 @@
   return true;
 }
 
+void ExtractAPIAction::EndSourceFileAction() {
+  if (!OS)
+return;
+
+  // Setup a SymbolGraphSerializer to write out collected API information in
+  // the Symbol Graph format.
+  // FIXME: Make the kind of APISerializer configurable.
+  SymbolGraphSerializer SGSerializer(*API, ProductName);
+  SGSerializer.serialize(*OS);
+  OS->flush();
+}
+
 std::unique_ptr
 ExtractAPIAction::CreateOutputFile(CompilerInstance &CI, StringRef InFile) {
   std::unique_ptr OS =
Index: clang/include/clang/ExtractAPI/FrontendActions.h
===
--- clang/include/clang/ExtractAPI/FrontendActions.h
+++ clang/include/clang/ExtractAPI/FrontendActions.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 #define LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 
+#include "clang/ExtractAPI/API.h"
 #include "clang/Frontend/FrontendAction.h"
 
 namespace clang {
@@ -25,11 +26,19 @@
  StringRef InFile) override;
 
 private:
+  /// A representation of the APIs this action extracts.
+  std::unique_ptr API;
+
+  /// A stream to the output file of this action.
+  std::unique_ptr OS;
+
+  /// The product this action is extracting API information for.
+  std::string ProductName;
+
   /// The synthesized input buffer that contains all the provided input header
   /// files.
   std::unique_ptr Buffer;
 
-public:
   /// Prepare to execute the action on the given CompilerInstance.
   ///
   /// This is called before executing the action on any inputs. This generates a
@@ -37,8 +46,15 @@
   /// list with it before actually executing the action.
   bool PrepareToExecuteAction(CompilerInstance &CI) override;
 
+  /// Called after executing the action on the synthesized input buffer.
+  ///
+  /// Note: Now that we have gathered all the API definitions to surface we can
+  /// emit them in this callback.
+  void EndSourceFileAction() override;
+
   static std::unique_ptr
   CreateOutputFile(CompilerInstance &CI, StringRef InFile);
+
   static StringRef getInputBufferName() { return ""; }
 };
 

[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/include/clang/ExtractAPI/FrontendActions.h:42-58
   /// Prepare to execute the action on the given CompilerInstance.
   ///
   /// This is called before executing the action on any inputs. This generates 
a
   /// single header that includes all of CI's inputs and replaces CI's input
   /// list with it before actually executing the action.
   bool PrepareToExecuteAction(CompilerInstance &CI) override;
 

zixuw wrote:
> Should these methods be private?
Yes I checked and existing frontend actions mark these as private.


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

https://reviews.llvm.org/D122648

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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 419207.
dang marked 3 inline comments as done.
dang added a comment.

Update with code review feedback and the rebased code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/macro_undefined.c
  clang/test/ExtractAPI/macros.c

Index: clang/test/ExtractAPI/macros.c
===
--- /dev/null
+++ clang/test/ExtractAPI/macros.c
@@ -0,0 +1,344 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=Macros -target arm64-apple-macosx \
+// RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+#define HELLO 1
+#define WORLD 2
+#define MACRO_FUN(x) x x
+#define FUN(x, y, z) x + y + z
+#define FUNC99(x, ...)
+#define FUNGNU(x...)
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "Macros",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "HELLO"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@8@macro@HELLO"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 1,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "HELLO"
+  }
+],
+"title": "HELLO"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "WORLD"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@24@macro@WORLD"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 2,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "WORLD"
+  }
+],
+"title": "WORLD"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "MACRO_FUN"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@40@macro@MACRO_FUN"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "MACRO_FUN"
+  }
+],
+"title": "MACRO_FUN"
+  }
+},
+{
+  "declarationFrag

[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 419208.
lenary added a comment.

- Remove whitespace change in ARMSubtarget
- Remove commented-out debug lines in RDFGraph


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-fix-cortex-a57-aes-1742098.c
  llvm/lib/Target/ARM/ARM.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMFixCortexA57AES1742098Pass.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/ARM/aes-erratum-fix.ll

Index: llvm/test/CodeGen/ARM/aes-erratum-fix.ll
===
--- llvm/test/CodeGen/ARM/aes-erratum-fix.ll
+++ llvm/test/CodeGen/ARM/aes-erratum-fix.ll
@@ -24,6 +24,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r0]
 ; CHECK-FIX-NEXT:vmov.i32 q9, #0x0
+; CHECK-FIX-NEXT:vorr q9, q9, q9
 ; CHECK-FIX-NEXT:aese.8 q9, q8
 ; CHECK-FIX-NEXT:aesmc.8 q8, q9
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r0]
@@ -55,6 +56,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_once_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_once_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q0, q1
 ; CHECK-FIX-NEXT:bx lr
@@ -91,6 +94,9 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_twice_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_twice_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q1
 ; CHECK-FIX-NEXT:aese.8 q8, q0
@@ -154,6 +160,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_loop_via_val(i32 %0, <16 x i8> %1, <16 x i8> %2) nounwind {
 ; CHECK-FIX-LABEL: aese_loop_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB6_2
 ; CHECK-FIX-NEXT:  .LBB6_1: @ =>This Inner Loop Header: Depth=1
@@ -186,6 +194,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r0]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -202,8 +211,10 @@
 define arm_aapcs_vfpcc void @aese_set8_via_val(i8 zeroext %0, <16 x i8> %1, <16 x i8>* %2) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r0
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -225,6 +236,7 @@
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:  .LBB9_2:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -248,12 +260,14 @@
 define arm_aapcs_vfpcc void @aese_set8_cond_via_val(i1 zeroext %0, i8 zeroext %1, <16 x i8> %2, <16 x i8>* %3) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_cond_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB10_2
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r1
 ; CHECK-FIX-NEXT:  .LBB10_2: @ %select.end
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -276,6 +290,7 @@
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB11_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -318,6 +333,7 @@
 ; CHECK-FIX-NEXT:vmov.8 d0[0], r1
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB12_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -355,6 +371,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.16 {d0[0]}, [r0:16]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d1

[PATCH] D122748: [Sema] Don't check bounds for function pointer

2022-03-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
ArcsinX added reviewers: aaron.ballman, erichkeane, abhinavgaba, 
chrish_ericsson_atx.
Herald added a project: All.
ArcsinX requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, clang crashes with i386 target on the following code:

  void f() {
f + 0xdeadUL;
  }

This problem is similar to the problem fixed in D104424 
, but that fix can't handle function pointer 
case, because `getTypeSizeInCharsIfKnown()` says that size is known and equal 
to 0 for function type.

This patch prevents bounds checking for function pointer, thus fixes the crash.

Fixes https://github.com/llvm/llvm-project/issues/50463


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122748

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/unbounded-array-bounds.c


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15447,7 +15447,7 @@
   const Type *BaseType =
   ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
   bool IsUnboundedArray = (BaseType == nullptr);
-  if (EffectiveType->isDependentType() ||
+  if (EffectiveType->isDependentType() || EffectiveType->isFunctionType() ||
   (!IsUnboundedArray && BaseType->isDependentType()))
 return;
 


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15447,7 +15447,7 @@
   const Type *BaseType =
   ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
   bool IsUnboundedArray = (BaseType == nullptr);
-  if (EffectiveType->isDependentType() ||
+  if (EffectiveType->isDependentType() || EffectiveType->isFunctionType() ||
   (!IsUnboundedArray && BaseType->isDependentType()))
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Zixu Wang via Phabricator via cfe-commits
zixuw accepted this revision.
zixuw added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D122648

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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Zixu Wang via Phabricator via cfe-commits
zixuw accepted this revision.
zixuw 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/D122611/new/

https://reviews.llvm.org/D122611

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


[clang] a9909d2 - [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-03-30T18:32:58+01:00
New Revision: a9909d23e9bb8c4649cba1c14d479c28df4ca185

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

LOG: [clang][extractapi] Tie API and serialization to the FrontendAction

Make the API records a property of the action instead of the ASTVisitor
so that it can be accessed outside the AST visitation and push back
serialization to the end of the frontend action.

This will allow accessing and modifying the API records outside of the
ASTVisitor, which is a prerequisite for supporting macros.

Added: 


Modified: 
clang/include/clang/ExtractAPI/FrontendActions.h
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/FrontendActions.h 
b/clang/include/clang/ExtractAPI/FrontendActions.h
index 4c9449fe73a92..2bdb61dc6994d 100644
--- a/clang/include/clang/ExtractAPI/FrontendActions.h
+++ b/clang/include/clang/ExtractAPI/FrontendActions.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 #define LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 
+#include "clang/ExtractAPI/API.h"
 #include "clang/Frontend/FrontendAction.h"
 
 namespace clang {
@@ -25,11 +26,19 @@ class ExtractAPIAction : public ASTFrontendAction {
  StringRef InFile) override;
 
 private:
+  /// A representation of the APIs this action extracts.
+  std::unique_ptr API;
+
+  /// A stream to the output file of this action.
+  std::unique_ptr OS;
+
+  /// The product this action is extracting API information for.
+  std::string ProductName;
+
   /// The synthesized input buffer that contains all the provided input header
   /// files.
   std::unique_ptr Buffer;
 
-public:
   /// Prepare to execute the action on the given CompilerInstance.
   ///
   /// This is called before executing the action on any inputs. This generates 
a
@@ -37,8 +46,15 @@ class ExtractAPIAction : public ASTFrontendAction {
   /// list with it before actually executing the action.
   bool PrepareToExecuteAction(CompilerInstance &CI) override;
 
+  /// Called after executing the action on the synthesized input buffer.
+  ///
+  /// Note: Now that we have gathered all the API definitions to surface we can
+  /// emit them in this callback.
+  void EndSourceFileAction() override;
+
   static std::unique_ptr
   CreateOutputFile(CompilerInstance &CI, StringRef InFile);
+
   static StringRef getInputBufferName() { return ""; }
 };
 

diff  --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp 
b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index bcc01dbd710d8..10b28873611e9 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -41,8 +41,8 @@ namespace {
 /// information.
 class ExtractAPIVisitor : public RecursiveASTVisitor {
 public:
-  ExtractAPIVisitor(ASTContext &Context, Language Lang)
-  : Context(Context), API(Context.getTargetInfo().getTriple(), Lang) {}
+  ExtractAPIVisitor(ASTContext &Context, APISet &API)
+  : Context(Context), API(API) {}
 
   const APISet &getAPI() const { return API; }
 
@@ -489,43 +489,40 @@ class ExtractAPIVisitor : public 
RecursiveASTVisitor {
   }
 
   ASTContext &Context;
-  APISet API;
+  APISet &API;
 };
 
 class ExtractAPIConsumer : public ASTConsumer {
 public:
-  ExtractAPIConsumer(ASTContext &Context, StringRef ProductName, Language Lang,
- std::unique_ptr OS)
-  : Visitor(Context, Lang), ProductName(ProductName), OS(std::move(OS)) {}
+  ExtractAPIConsumer(ASTContext &Context, APISet &API)
+  : Visitor(Context, API) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
 // Use ExtractAPIVisitor to traverse symbol declarations in the context.
 Visitor.TraverseDecl(Context.getTranslationUnitDecl());
-
-// Setup a SymbolGraphSerializer to write out collected API information in
-// the Symbol Graph format.
-// FIXME: Make the kind of APISerializer configurable.
-SymbolGraphSerializer SGSerializer(Visitor.getAPI(), ProductName);
-SGSerializer.serialize(*OS);
   }
 
 private:
   ExtractAPIVisitor Visitor;
-  std::string ProductName;
-  std::unique_ptr OS;
 };
 
 } // namespace
 
 std::unique_ptr
 ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
-  std::unique_ptr OS = CreateOutputFile(CI, InFile);
+  OS = CreateOutputFile(CI, InFile);
   if (!OS)
 return nullptr;
-  return std::make_unique(
-  CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
-  CI.getFrontendOpts().Inputs.back().getKind().getLanguage(),
-  std::move(OS));
+
+  ProductName = CI.getFrontendOpts().ProductName;
+
+  // Now that we have enough information about the language options and the
+  // 

[clang] 529a057 - [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-03-30T18:33:10+01:00
New Revision: 529a0570f7e8c5144bd3ad057e43f00e3af58d1b

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

LOG: [clang][extract-api] Add support for macros

To achieve this we hook into the preprocessor during the
ExtractAPIAction and record definitions for macros that don't get
undefined during preprocessing.

Added: 
clang/test/ExtractAPI/macro_undefined.c
clang/test/ExtractAPI/macros.c

Modified: 
clang/include/clang/ExtractAPI/API.h
clang/include/clang/ExtractAPI/DeclarationFragments.h
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 57397e7c256ea..142dd7a45de47 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -30,6 +30,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include 
+#include 
 
 namespace clang {
 namespace extractapi {
@@ -49,6 +50,9 @@ namespace extractapi {
 /// \endcode
 using DocComment = std::vector;
 
+// Classes deriving from APIRecord need to have Name be the first constructor
+// argument. This is so that they are compatible with `addTopLevelRecord`
+// defined in API.cpp
 /// The base representation of an API record. Holds common symbol information.
 struct APIRecord {
   StringRef Name;
@@ -83,6 +87,7 @@ struct APIRecord {
 RK_ObjCMethod,
 RK_ObjCInterface,
 RK_ObjCProtocol,
+RK_MacroDefinition,
   };
 
 private:
@@ -119,10 +124,11 @@ struct GlobalRecord : APIRecord {
   /// The function signature of the record if it is a function.
   FunctionSignature Signature;
 
-  GlobalRecord(GVKind Kind, StringRef Name, StringRef USR, PresumedLoc Loc,
+  GlobalRecord(StringRef Name, StringRef USR, PresumedLoc Loc,
const AvailabilityInfo &Availability, LinkageInfo Linkage,
const DocComment &Comment, DeclarationFragments Declaration,
-   DeclarationFragments SubHeading, FunctionSignature Signature)
+   DeclarationFragments SubHeading, GVKind Kind,
+   FunctionSignature Signature)
   : APIRecord(RK_Global, Name, USR, Loc, Availability, Linkage, Comment,
   Declaration, SubHeading),
 GlobalKind(Kind), Signature(Signature) {}
@@ -374,6 +380,21 @@ struct ObjCProtocolRecord : ObjCContainerRecord {
   virtual void anchor();
 };
 
+struct MacroDefinitionRecord : APIRecord {
+  MacroDefinitionRecord(StringRef Name, StringRef USR, PresumedLoc Loc,
+DeclarationFragments Declaration,
+DeclarationFragments SubHeading)
+  : APIRecord(RK_MacroDefinition, Name, USR, Loc, AvailabilityInfo(),
+  LinkageInfo(), {}, Declaration, SubHeading) {}
+
+  static bool classof(const APIRecord *Record) {
+return Record->getKind() == RK_MacroDefinition;
+  }
+
+private:
+  virtual void anchor();
+};
+
 /// APISet holds the set of API records collected from given inputs.
 class APISet {
 public:
@@ -530,29 +551,24 @@ class APISet {
   DeclarationFragments Declaration,
   DeclarationFragments SubHeading);
 
-  /// A map to store the set of GlobalRecord%s with the declaration name as the
-  /// key.
-  using GlobalRecordMap =
-  llvm::MapVector>;
-
-  /// A map to store the set of EnumRecord%s with the declaration name as the
-  /// key.
-  using EnumRecordMap = llvm::MapVector>;
-
-  /// A map to store the set of StructRecord%s with the declaration name as the
-  /// key.
-  using StructRecordMap =
-  llvm::MapVector>;
-
-  /// A map to store the set of ObjCInterfaceRecord%s with the declaration name
-  /// as the key.
-  using ObjCInterfaceRecordMap =
-  llvm::MapVector>;
-
-  /// A map to store the set of ObjCProtocolRecord%s with the declaration name
-  /// as the key.
-  using ObjCProtocolRecordMap =
-  llvm::MapVector>;
+  /// Create a macro definition record into the API set.
+  ///
+  /// Note: the caller is responsible for keeping the StringRef \p Name and
+  /// \p USR alive. APISet::copyString provides a way to copy strings into
+  /// APISet itself, and APISet::recordUSRForMacro(StringRef Name,
+  /// SourceLocation SL, const SourceManager &SM) is a helper method to 
generate
+  /// the USR for the macro and keep it alive in APISet.
+  MacroDefinitionRecord *addMacroDefinition(StringRef Name, StringRef USR,
+Pre

[PATCH] D122748: [Sema] Don't check bounds for function pointer

2022-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

It seems like this entire section of code was added here: 
https://github.com/llvm/llvm-project/commit/ce44fe199bbfd4b5a44764b678c431fdc117116a

@chrish_ericsson_atx should probably take a look at this.  That said, we might 
not want to early-exist here, I think we can just skip the `IsUnboundedArray` 
branch?  This example worked correctly in the 12.0 branch, so I think it was 
fine before then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122748

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


[PATCH] D116490: [clangd] Code action to declare missing move/copy constructor/assignment

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419213.
sammccall marked 3 inline comments as done.
sammccall added a comment.
Herald added a project: All.

Oops, this never got landed!

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116490

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
  clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
@@ -0,0 +1,47 @@
+//===-- SpecialMembersTests.cpp ---===//
+//
+// 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 "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(SpecialMembers);
+
+TEST_F(SpecialMembersTest, Test) {
+  EXPECT_AVAILABLE("struct ^S {};");
+  EXPECT_UNAVAILABLE("struct S { ^ };");
+  EXPECT_UNAVAILABLE("union ^U {};");
+  EXPECT_AVAILABLE("struct ^S { S(const S&); S(S&&); };");
+  EXPECT_UNAVAILABLE("struct ^S {"
+ "S(const S&); S(S&&);"
+ "S &operator=(S&&); S &operator=(const S&);"
+ "};");
+
+  const char *Output = R"cpp(struct S{S(const S &) = default;
+  S(S &&) = default;
+  S &operator=(const S &) = default;
+  S &operator=(S &&) = default;
+};)cpp";
+  EXPECT_EQ(apply("struct ^S{};"), Output);
+
+  Output = R"cpp(struct S{S(const S &) = default;
+S(S &&) = default;
+S &operator=(const S &) = delete;
+S &operator=(S &&) = delete;
+int& ref;};)cpp";
+  EXPECT_EQ(apply("struct ^S{int& ref;};"), Output);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
@@ -0,0 +1,153 @@
+//===--- SpecialMembers.cpp - Generate C++ special member functions ---===//
+//
+// 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 "ParsedAST.h"
+#include "refactor/InsertionPoint.h"
+#include "refactor/Tweak.h"
+#include "support/Logger.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Returns code to declare missing copy/move constructors/assignment operators.
+// They will be deleted or defaulted to match the class's current state.
+std::string buildSpecialMemberDeclarations(const CXXRecordDecl &Class) {
+  struct Members {
+const CXXMethodDecl *Copy = nullptr;
+const CXXMethodDecl *Move = nullptr;
+  } Ctor, Assign;
+
+  for (const auto &M : Class.methods()) {
+if (M->isCopyAssignmentOperator())
+  Assign.Copy = M;
+else if (M->isMoveAssignmentOperator())
+  Assign.Move = M;
+if (const auto *C = llvm::dyn_cast(M)) {
+  if (C->isCopyConstructor())
+Ctor.Copy = C;
+  else if (C->isMoveConstructor())
+Ctor.Move = C;
+}
+  }
+
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+
+  auto PrintMember = [&](const CXXMethodDecl *D, const char *MemberPattern,
+ const char *ParmPattern) {
+if (D && !D->isImplicit())
+  return;
+bool Delete = !D || D->isDeleted();
+OS << llvm::formatv(
+"{0} = {1};\n",
+llvm::formatv(MemberPattern, Class.getName(),
+  llvm::formatv(ParmPattern, Class.getName())),
+Delete ? "delete" : "default");
+  };
+  auto PrintMembers = [&](const Members &M, const char *MemberPattern) {
+PrintMember(M.Copy, MemberPattern, /*ParmPattern=*/"const {0}&");
+PrintMember(M.Move, MemberPattern, /*ParmPattern=*/"{0}&&");
+  };
+  PrintMembers(Ctor, /*MemberPattern=*/"{0}({1})");
+  PrintMembers(Assign, /*MemberPattern=*/"{0} &operator=({1})");
+
+  return S;
+}
+
+// A tweak that adds missing declarations of 

[clang] 73ab5fd - [clang] Fix shared build. NFC.

2022-03-30 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2022-03-30T14:05:14-04:00
New Revision: 73ab5fd17b5726543554621410124ebae953dc6b

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

LOG: [clang] Fix shared build. NFC.

Added: 


Modified: 
clang/lib/ExtractAPI/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/ExtractAPI/CMakeLists.txt 
b/clang/lib/ExtractAPI/CMakeLists.txt
index 044caa0922483..f194ae342c20f 100644
--- a/clang/lib/ExtractAPI/CMakeLists.txt
+++ b/clang/lib/ExtractAPI/CMakeLists.txt
@@ -14,4 +14,5 @@ add_clang_library(clangExtractAPI
   clangBasic
   clangFrontend
   clangIndex
+  clangLex
   )



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


[PATCH] D119996: [safestack] Support safestack in stack size diagnostics

2022-03-30 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 419222.
paulkirth added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119996

Files:
  clang/test/Frontend/stack-usage-safestack.c
  llvm/include/llvm/CodeGen/MachineFrameInfo.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/test/Transforms/SafeStack/ARM/debug.ll

Index: llvm/test/Transforms/SafeStack/ARM/debug.ll
===
--- llvm/test/Transforms/SafeStack/ARM/debug.ll
+++ llvm/test/Transforms/SafeStack/ARM/debug.ll
@@ -10,8 +10,8 @@
 ; void Capture(char*x);
 ; void f() { char c[16]; Capture(c); }
 
-; CHECK: !35 = !DILocation(line: 3, column: 11, scope: !17, inlinedAt: !36)
-; CHECK: !36 = distinct !DILocation(line: 6, scope: !27)
+; CHECK: !36 = !DILocation(line: 3, column: 11, scope: !17, inlinedAt: !37)
+; CHECK: !37 = distinct !DILocation(line: 6, scope: !27)
 
 @addr = common local_unnamed_addr global i8*** null, align 4, !dbg !0
 
Index: llvm/lib/CodeGen/SafeStack.cpp
===
--- llvm/lib/CodeGen/SafeStack.cpp
+++ llvm/lib/CodeGen/SafeStack.cpp
@@ -48,6 +48,7 @@
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Use.h"
@@ -642,6 +643,13 @@
   // FIXME: no need to update BasePointer in leaf functions.
   unsigned FrameSize = alignTo(SSL.getFrameSize(), StackAlignment);
 
+  MDBuilder MDB(F.getContext());
+  SmallVector Data;
+  Data.push_back(MDB.createString("unsafe-stack-size"));
+  Data.push_back(MDB.createConstant(ConstantInt::get(Int32Ty, FrameSize)));
+  MDNode *MD = MDTuple::get(F.getContext(), Data);
+  F.setMetadata(LLVMContext::MD_annotation, MD);
+
   // Update shadow stack pointer in the function epilogue.
   IRB.SetInsertPoint(BasePointer->getNextNode());
 
Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp
===
--- llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -283,6 +283,9 @@
 assert(!Failed && "Invalid warn-stack-size fn attr value");
 (void)Failed;
   }
+  if (MF.getFunction().hasFnAttribute(Attribute::SafeStack)) {
+StackSize += MFI.getUnsafeStackSize();
+  }
   if (StackSize > Threshold) {
 DiagnosticInfoStackSize DiagStackSize(F, StackSize, Threshold, DS_Warning);
 F.getContext().diagnose(DiagStackSize);
Index: llvm/lib/CodeGen/MachineFunction.cpp
===
--- llvm/lib/CodeGen/MachineFunction.cpp
+++ llvm/lib/CodeGen/MachineFunction.cpp
@@ -107,6 +107,27 @@
   llvm_unreachable("Invalid machine function property");
 }
 
+void setUnsafeStackSize(const Function &F, MachineFrameInfo &FrameInfo) {
+  if (!F.hasFnAttribute(Attribute::SafeStack))
+return;
+
+  auto *Existing =
+  dyn_cast_or_null(F.getMetadata(LLVMContext::MD_annotation));
+
+  if (!Existing || Existing->getNumOperands() != 2)
+return;
+
+  auto *MetadataName = "unsafe-stack-size";
+  if (auto &N = Existing->getOperand(0)) {
+if (cast(N.get())->getString() == MetadataName) {
+  if (auto &Op = Existing->getOperand(1)) {
+auto Val = mdconst::extract(Op)->getZExtValue();
+FrameInfo.setUnsafeStackSize(Val);
+  }
+}
+  }
+}
+
 // Pin the vtable to this file.
 void MachineFunction::Delegate::anchor() {}
 
@@ -175,6 +196,8 @@
   /*ForcedRealign=*/CanRealignSP &&
   F.hasFnAttribute(Attribute::StackAlignment));
 
+  setUnsafeStackSize(F, *FrameInfo);
+
   if (F.hasFnAttribute(Attribute::StackAlignment))
 FrameInfo->ensureMaxAlignment(*F.getFnStackAlign());
 
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1186,7 +1186,8 @@
   OutStreamer->SwitchSection(StackSizeSection);
 
   const MCSymbol *FunctionSymbol = getFunctionBegin();
-  uint64_t StackSize = FrameInfo.getStackSize();
+  uint64_t StackSize =
+  FrameInfo.getStackSize() + FrameInfo.getUnsafeStackSize();
   OutStreamer->emitSymbolValue(FunctionSymbol, TM.getProgramPointerSize());
   OutStreamer->emitULEB128IntValue(StackSize);
 
@@ -1201,7 +1202,8 @@
 return;
 
   const MachineFrameInfo &FrameInfo = MF.getFrameInfo();
-  uint64_t StackSize = FrameInfo.getStackSize();
+  uint64_t StackSize =
+  FrameInfo.getStackSize() + FrameInfo.getUnsafeStackSize();
 
   if (StackUsageStream == nullptr) {
 std::error_code EC;
Index: llvm/include/llvm/CodeGen/MachineFrameInfo.h

[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith 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/D122549/new/

https://reviews.llvm.org/D122549

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: Fznamznon, erichkeane.
erichkeane added a comment.

Attn: @Fznamznon


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D116514: [clangd] Add code action to generate a constructor for a C++ class

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419225.
sammccall marked 10 inline comments as done.
sammccall added a comment.
Herald added a project: All.

address comments
(sorry for long turnaround)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116514

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/MemberwiseConstructorTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/MemberwiseConstructorTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/MemberwiseConstructorTests.cpp
@@ -0,0 +1,99 @@
+//===-- MemberwiseConstructorTests.cpp ===//
+//
+// 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 "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using testing::AllOf;
+using testing::Eq;
+using testing::HasSubstr;
+using testing::Not;
+
+TWEAK_TEST(MemberwiseConstructor);
+
+TEST_F(MemberwiseConstructorTest, Availability) {
+  EXPECT_AVAILABLE("^struct ^S ^{ int x, y; };");
+  EXPECT_UNAVAILABLE("struct S { ^int ^x, y; }; struct ^S;");
+  EXPECT_UNAVAILABLE("struct ^S {};");
+  EXPECT_UNAVAILABLE("union ^S { int x; };");
+  EXPECT_UNAVAILABLE("struct ^S { int x = 0; };");
+  EXPECT_UNAVAILABLE("struct ^S { struct { int x; }; };");
+  EXPECT_UNAVAILABLE("struct ^{ int x; } e;");
+}
+
+TEST_F(MemberwiseConstructorTest, Edits) {
+  Header = R"cpp(
+struct Move {
+  Move(Move&&) = default;
+  Move(const Move&) = delete;
+};
+struct Copy {
+  Copy(Copy&&) = delete;
+  Copy(const Copy&);
+};
+  )cpp";
+  EXPECT_EQ(apply("struct ^S{Move M; Copy C; int I; int J=4;};"),
+"struct S{"
+"S(Move M, const Copy &C, int I) : M(std::move(M)), C(C), I(I) {}\n"
+"Move M; Copy C; int I; int J=4;};");
+}
+
+TEST_F(MemberwiseConstructorTest, FieldTreatment) {
+  Header = R"cpp(
+struct MoveOnly {
+  MoveOnly(MoveOnly&&) = default;
+  MoveOnly(const MoveOnly&) = delete;
+};
+struct CopyOnly {
+  CopyOnly(CopyOnly&&) = delete;
+  CopyOnly(const CopyOnly&);
+};
+struct CopyTrivial {
+  CopyTrivial(CopyTrivial&&) = default;
+  CopyTrivial(const CopyTrivial&) = default;
+};
+struct Immovable {
+  Immovable(Immovable&&) = delete;
+  Immovable(const Immovable&) = delete;
+};
+template 
+struct Traits { using Type = typename T::Type; };
+using IntAlias = int;
+  )cpp";
+
+  auto Fail = Eq("unavailable");
+  auto Move = HasSubstr(": Member(std::move(Member))");
+  auto CopyRef = AllOf(HasSubstr("S(const "), HasSubstr(": Member(Member)"));
+  auto Copy = AllOf(Not(HasSubstr("S(const ")), HasSubstr(": Member(Member)"));
+  auto With = [](llvm::StringRef Type) {
+return ("struct ^S { " + Type + " Member; };").str();
+  };
+
+  EXPECT_THAT(apply(With("Immovable")), Fail);
+  EXPECT_THAT(apply(With("MoveOnly")), Move);
+  EXPECT_THAT(apply(With("CopyOnly")), CopyRef);
+  EXPECT_THAT(apply(With("CopyTrivial")), Copy);
+  EXPECT_THAT(apply(With("int")), Copy);
+  EXPECT_THAT(apply(With("IntAlias")), Copy);
+  EXPECT_THAT(apply(With("Immovable*")), Copy);
+  EXPECT_THAT(apply(With("Immovable&")), Copy);
+
+  EXPECT_THAT(apply("template " + With("T")), Move);
+  EXPECT_THAT(apply("template " + With("typename Traits::Type")),
+  Move);
+  EXPECT_THAT(apply("template " + With("T*")), Copy);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -117,6 +117,7 @@
   tweaks/ExpandMacroTests.cpp
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
+  tweaks/MemberwiseConstructorTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
   tweaks/ObjCMemberwiseInitializerTests.cpp
   tweaks/PopulateSwitchTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
@@ -0,0 +1,267 @@
+//===--- MemberwiseConstructor.cpp - Generate C++ constructor -===//
+//
+/

[PATCH] D122732: [Clang][AArch64][SVE] Allow subscript operator for SVE types

2022-03-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Subscript on svbool_t is not allowed as this doesn't really have meaningful 
> semantics.

Not sure what you mean by this; LLVM supports extractelement on `` vectors.  I guess the fact that it's a "vscale x 16" element vector might 
not be intuitive?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122732

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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

This change is causing 9 test failures on a buildbot, can you please take a 
look and revert if you need time to investigate?

https://lab.llvm.org/buildbot/#/builders/139/builds/19441


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage NFC

2022-03-30 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

I cannot view the diff between the last two revisions:

> Unhandled Exception ("Exception")
> Found unknown intradiff source line, expected a line beginning with "+", "-", 
> or " " (space): \ No newline at end of file
> .




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121754

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


[clang] 3fda0ed - [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-30 Thread Ben Barham via cfe-commits

Author: Ben Barham
Date: 2022-03-30T11:52:41-07:00
New Revision: 3fda0edc51fd68192a30e302d45db081bb02d7f9

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

LOG: [VFS] RedirectingFileSystem only replace path if not already mapped

If the `ExternalFS` has already remapped a path then the
`RedirectingFileSystem` should not change it to the originally provided
path. This fixes the original path always being used if multiple VFS
overlays were provided and the path wasn't found in the highest (ie.
first in the chain).

This also renames `IsVFSMapped` to `ExposesExternalVFSPath` and only
sets it if `UseExternalName` is true. This flag then represents that the
`Status` has an external path that's different from its virtual path.
Right now the contained path is still the external path, but further PRs
will change this to *always* be the virtual path. Clients that need the
external can then request it specifically.

Note that even though `ExposesExternalVFSPath` isn't set for all
VFS-mapped paths, `IsVFSMapped` was only being used by a hack in
`FileManager` that was specific to module searching. In that case
`UseExternalNames` is always `true` and so that hack still applies.

Resolves rdar://90578880 and llvm-project#53306.

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

Added: 
clang/test/VFS/external-names-multi-overlay.c

Modified: 
clang/lib/Basic/FileManager.cpp
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f4cf27848d7d9..d30a5f72b9836 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -270,12 +270,15 @@ FileManager::getFileRef(StringRef Filename, bool 
openFile, bool CacheFailure) {
   // This occurs when one dir is symlinked to another, for example.
   FileEntry &UFE = UniqueRealFiles[Status.getUniqueID()];
 
+  // FIXME: This should just check `!Status.ExposesExternalVFSPath`, but the
+  // else branch also ends up fixing up relative paths to be the actually
+  // looked up absolute path. This isn't necessarily desired, but does seem to
+  // be relied on in some clients.
   if (Status.getName() == Filename) {
 // The name matches. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(UFE, DirInfo);
   } else {
-// Name mismatch. We need a redirect. First grab the actual entry we want
-// to return.
+// We need a redirect. First grab the actual entry we want to return.
 //
 // This redirection logic intentionally leaks the external name of a
 // redirected file that uses 'use-external-name' in \a
@@ -285,9 +288,11 @@ FileManager::getFileRef(StringRef Filename, bool openFile, 
bool CacheFailure) {
 //
 // FIXME: This is pretty complicated. It's also inconsistent with how
 // "real" filesystems behave and confuses parts of clang expect to see the
-// name-as-accessed on the \a FileEntryRef. Maybe the returned \a
-// FileEntryRef::getName() could return the accessed name unmodified, but
-// make the external name available via a separate API.
+// name-as-accessed on the \a FileEntryRef. To remove this we should
+// implement the FIXME on `ExposesExternalVFSPath`, ie. update the
+// `FileEntryRef::getName()` path to *always* be the virtual path and have
+// clients request the external path only when required through a separate
+// API.
 auto &Redirection =
 *SeenFileEntries
  .insert({Status.getName(), FileEntryRef::MapValue(UFE, DirInfo)})
@@ -308,13 +313,16 @@ FileManager::getFileRef(StringRef Filename, bool 
openFile, bool CacheFailure) {
   FileEntryRef ReturnedRef(*NamedFileEnt);
   if (UFE.isValid()) { // Already have an entry with this inode, return it.
 
-// FIXME: this hack ensures that if we look up a file by a virtual path in
-// the VFS that the getDir() will have the virtual path, even if we found
-// the file by a 'real' path first. This is required in order to find a
-// module's structure when its headers/module map are mapped in the VFS.
-// We should remove this as soon as we can properly support a file having
-// multiple names.
-if (&DirInfo.getDirEntry() != UFE.Dir && Status.IsVFSMapped)
+// FIXME: This hack ensures that `getDir()` will use the path that was
+// used to lookup this file, even if we found a file by 
diff erent path
+// first. This is required in order to find a module's structure when its
+// headers/module map are mapped in the VFS.
+//
+// This should be removed once `HeaderSearch` is updated to use `*Ref`s
+// *and* the redirection hack 

  1   2   >