[clang] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-10 Thread Michael Park via cfe-commits


@@ -10475,6 +10468,12 @@ void ASTReader::finishPendingActions() {
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // For each decl chain that we wanted to complete while deserializing, mark
+  // it as "still needs to be completed".
+  for (Decl *D : PendingIncompleteDeclChains)
+markIncompleteDeclChain(D);
+  PendingIncompleteDeclChains.clear();

mpark wrote:

> Sorry, I've been away from this code for a long time and have forgotten a lot 
> about how it's supposed to work.

Not a problem at all. In trying to dig through some of the history, I've seen 
that a bunch of this code is from 2015 😄

> We're just marking the chains as incomplete here, not actually completing 
> them, and we won't do the work to complete them until someone actually calls 
> `redecls()` or similar.

What I'm uncertain about is the expectation of the parts **within** 
`finishPendingActions` that call `redecls()` or similar. Because for those, we 
**still** won't do the work to complete them. More specifically, the parts 
within `finishPendingActions` that say "we require the redecl chain to be fully 
wired" seem to me like they wouldn't have the requirement guaranteed to be 
satisfied.

> I would expect that when we do go and wire up the redecl chains, we're 
> propagating the `Definition` value along the chain. Also, when chains aren't 
> wired up properly, each declaration still does correctly point to its 
> canonical declaration, so we will still detect things like multiple 
> definitions for an entity because each of those will try to update the 
> canonical declaration to have a different definition.

Ah, I see! This is great. Thanks for sharing. It's exactly this kind of 
high-level architectural understanding is what I'm needing more of.

> Moving the marking of pending incomplete decl chains as incomplete to the end 
> of the function makes sense to me.

This is exactly what I had done in #121245, but unfortunately it caused #126973 
so it got reverted. The reduced test case of #126973 is 
[pr129982.cpp](https://github.com/llvm/llvm-project/pull/129982/files#diff-972832d26c9b2be8952ac137e86510a1eaf0197f98df6245688b1c3b5303ad65).

My gathering of that situation so far is that `RD->addedMember(MD);` (near the 
end of `finishPendingActions`) effectively calls `RD->data()` which calls 
`RD->getMostRecentDecl()`. Anyway, for some reason leaving the `RD` in 
`PendingIncompleteDeclChains` as before is okay, but marking it incomplete 
caused another issue. The other issue in short:
1. There is a call to `getMostRecentDecl()` which calls `CompleteRedeclChain` 
which calls `DC->lookup(Name)`. During this process, the definition of `Name` 
is not found. 
[`Lookups[DC].Table[Name]`](https://github.com/llvm/llvm-project/blob/c6d95c441a29a45782ff72d6cb82839b86fd0e4a/clang/lib/Serialization/ASTReader.cpp#L8494-L8501)
 doesn't have the definition ID.
2. A pending update record populates `Lookups[DC].Table[Name]` with the 
definition ID.
3. Another call to `getMostRecentDecl()` which, if it were to call 
`CompleteRedeclChain` would call `DC->lookup(Name)` and find the definition. 
However, we updated the lazy ptr generation number in step (1), so we do not 
invoke `CompleteRedeclChain`, and we can't find the definition.

> Can we also add an assert that all of the other "pending" lists are still 
> empty at that point? (Or do we already have an assert for that somewhere?)

Yes, I can certainly do that. No, we don't have that assertion currently.

https://github.com/llvm/llvm-project/pull/129982
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-10 Thread Michael Park via cfe-commits

https://github.com/mpark edited https://github.com/llvm/llvm-project/pull/129982
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-10 Thread Helena Kotas via cfe-commits
Nathan =?utf-8?q?Gauër?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x 
-emit-llvm -o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -triple spirv-pc-vulkan1.3-compute -std=hlsl202x -emit-llvm 
-o - -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK
+
+struct S {
+  static int Value;
+};
+
+int S::Value = 1;
+// CHECK: @_ZN1S5ValueE = global i32 1, align 4
+
+[shader("compute")]
+[numthreads(1,1,1)]
+void main() {
+  S s;
+  int value1, value2;
+// CHECK:  %s = alloca %struct.S, align 1
+// CHECK: %value1 = alloca i32, align 4
+// CHECK: %value2 = alloca i32, align 4
+
+// CHECK: [[tmp:%.*]] = load i32, ptr @_ZN1S5ValueE, align 4
+// CHECK: store i32 [[tmp]], ptr %value1, align 4
+  value1 = S::Value;
+
+// CHECK: [[tmp:%.*]] = load i32, ptr @_ZN1S5ValueE, align 4

hekota wrote:

Why is this testing the same thing twice?

https://github.com/llvm/llvm-project/pull/122103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix darwin-related tests' REQUIRES annotation (PR #130138)

2025-03-10 Thread Cyndy Ishida via cfe-commits

cyndyishida wrote:

> This approach becomes a problem when trying to run such tests on a
cross-compiling build of clang on a darwin platform. When no darwin
targets are included in the build, the tests will still run on a darwin
host and fail spuriously because of the missing target.

This doesn't happen for tests with `target=-apple` 
right? It's not clear to me why the tests that explicitly pass an alternative 
way to set the target triple (e.g. with env vars or with `mtargetos`) fail. It 
would be good to diagnose that first.

> Can you confirm my understanding of -mtargetos?
This option should set the darwin target triple.  It's the generic equivalent 
of 
```
  -macosx_version_min 
   -ios_version_min 
   -watchos_version_min 
   -tvos_version_min 
```

https://github.com/llvm/llvm-project/pull/130138
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-10 Thread Helena Kotas via cfe-commits
Nathan =?utf-8?q?Gau=C3=ABr?= 
Message-ID:
In-Reply-To: 


https://github.com/hekota approved this pull request.

LGTM with one question.

https://github.com/llvm/llvm-project/pull/122103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [flang/clang] Adding use of Clang's diagnostics in Flang (PR #130593)

2025-03-10 Thread David Truby via cfe-commits

DavidTruby wrote:

Some extra context: there was a discussion quite some time ago about moving 
lots of the driver/diagnostic code from `clang` to a separate top-level LLVM 
project, and I believe it was generally agreed that this would be a good idea: 
https://discourse.llvm.org/t/rfc-refactor-clang-move-frontend-driver-diagnostics-code-to-llvm/55498/8

As I recall; @banach-space and I (separately) both had a go at doing this and 
it proved to be quite complex, so we ran out of time. It's still something I'd 
like to see one day though!

I think until such a thing is done we wouldn't want to couple even more things 
in `clang/` into flang though, so I'd be concerned about doing this for now.

https://github.com/llvm/llvm-project/pull/130593
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-10 Thread Helena Kotas via cfe-commits
Nathan =?utf-8?q?Gauër?= 
Message-ID:
In-Reply-To: 


https://github.com/hekota edited 
https://github.com/llvm/llvm-project/pull/122103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [HLSL] Implement explicit layout for default constant buffer ($Globals) (PR #128991)

2025-03-10 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/128991

>From 9faff902639aece87b72ed5235d71b8b68533074 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Wed, 26 Feb 2025 17:39:16 -0800
Subject: [PATCH 1/6] Add resource binding attribute on $Globals numeric
 constants

---
 clang/lib/Sema/SemaHLSL.cpp   | 10 +--
 .../test/AST/HLSL/resource_binding_attr.hlsl  | 67 ---
 2 files changed, 47 insertions(+), 30 deletions(-)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 283a9801fc707..ffc3ac1b65854 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -1446,18 +1446,20 @@ static bool DiagnoseLocalRegisterBinding(Sema &S, 
SourceLocation &ArgLoc,
 Ty = Ty->getArrayElementTypeNoTypeQual();
 
   // Basic types
-  if (Ty->isArithmeticType()) {
+  if (Ty->isArithmeticType() || Ty->isVectorType()) {
 bool DeclaredInCOrTBuffer = isa(D->getDeclContext());
 if (SpecifiedSpace && !DeclaredInCOrTBuffer)
   S.Diag(ArgLoc, diag::err_hlsl_space_on_global_constant);
 
-if (!DeclaredInCOrTBuffer &&
-(Ty->isIntegralType(S.getASTContext()) || Ty->isFloatingType())) {
-  // Default Globals
+if (!DeclaredInCOrTBuffer && (Ty->isIntegralType(S.getASTContext()) ||
+  Ty->isFloatingType() || Ty->isVectorType())) 
{
+  // Register annotation on default constant buffer declaration ($Globals)
   if (RegType == RegisterType::CBuffer)
 S.Diag(ArgLoc, diag::warn_hlsl_deprecated_register_type_b);
   else if (RegType != RegisterType::C)
 S.Diag(ArgLoc, diag::err_hlsl_binding_type_mismatch) << RegTypeNum;
+  else
+return true;
 } else {
   if (RegType == RegisterType::C)
 S.Diag(ArgLoc, diag::warn_hlsl_register_type_c_packoffset);
diff --git a/clang/test/AST/HLSL/resource_binding_attr.hlsl 
b/clang/test/AST/HLSL/resource_binding_attr.hlsl
index 6fac903f75e18..7ba4f0f60e83c 100644
--- a/clang/test/AST/HLSL/resource_binding_attr.hlsl
+++ b/clang/test/AST/HLSL/resource_binding_attr.hlsl
@@ -1,41 +1,56 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o 
- %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -ast-dump -o - %s | FileCheck %s
 
-// CHECK:HLSLBufferDecl 0x[[CB:[0-9a-f]+]] {{.*}} line:8:9 cbuffer CB
-// CHECK-NEXT:HLSLResourceClassAttr 0x[[CB:[0-9a-f]+]] {{.*}} Implicit CBuffer
-// CHECK-NEXT:HLSLResourceAttr 0x[[CB:[0-9a-f]+]] {{.*}} Implicit CBuffer
-// CHECK-NEXT:HLSLResourceBindingAttr 0x{{[0-9a-f]+}}  "b3" "space2"
-// CHECK-NEXT:VarDecl 0x[[A:[0-9a-f]+]] {{.*}} col:9 used a 'hlsl_constant 
float'
+// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 5]]:9 cbuffer CB
+// CHECK-NEXT: HLSLResourceClassAttr {{.*}} Implicit CBuffer
+// CHECK-NEXT: HLSLResourceAttr {{.*}} Implicit CBuffer
+// CHECK-NEXT: HLSLResourceBindingAttr {{.*}} "b3" "space2"
+// CHECK-NEXT: VarDecl {{.*}} used a 'hlsl_constant float'
 cbuffer CB : register(b3, space2) {
   float a;
 }
 
-// CHECK:HLSLBufferDecl 0x[[TB:[0-9a-f]+]] {{.*}} line:17:9 tbuffer TB
-// CHECK-NEXT:HLSLResourceClassAttr 0x[[CB:[0-9a-f]+]] {{.*}} Implicit SRV
-// CHECK-NEXT:HLSLResourceAttr 0x[[CB:[0-9a-f]+]] {{.*}} Implicit TBuffer
-// CHECK-NEXT:HLSLResourceBindingAttr 0x{{[0-9a-f]+}}  "t2" "space1"
-// CHECK-NEXT:VarDecl 0x[[B:[0-9a-f]+]] {{.*}} col:9 used b 'hlsl_constant 
float'
+// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 5]]:9 tbuffer TB
+// CHECK-NEXT: HLSLResourceClassAttr {{.*}} Implicit SRV
+// CHECK-NEXT: HLSLResourceAttr {{.*}} Implicit TBuffer
+// CHECK-NEXT: HLSLResourceBindingAttr {{.*}} "t2" "space1"
+// CHECK-NEXT: VarDecl {{.*}} used b 'hlsl_constant float'
 tbuffer TB : register(t2, space1) {
   float b;
 }
 
-float foo() {
-// CHECK: BinaryOperator 0x{{[0-9a-f]+}}  'float' '+'
-// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-f]+}}  'float' 

-// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}}  'hlsl_constant float' 
lvalue Var 0x[[A]] 'a' 'hlsl_constant float'
-// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-f]+}}  'float' 

-// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-f]+}}  'hlsl_constant float' 
lvalue Var 0x[[B]] 'b' 'hlsl_constant float'
+export float foo() {
   return a + b;
 }
 
-// CHECK: VarDecl 0x{{[0-9a-f]+}} <{{.*}}> col:17 UAV 
'RWBuffer':'hlsl::RWBuffer' callinit
-// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}}  
'RWBuffer':'hlsl::RWBuffer' 'void ()'
-// CHECK-NEXT:-HLSLResourceBindingAttr 0x{{[0-9a-f]+}}  "u3" "space0"
+// CHECK: VarDecl {{.*}} UAV 'RWBuffer':'hlsl::RWBuffer'
+// CHECK: HLSLResourceBindingAttr {{.*}} "u3" "space0"
 RWBuffer UAV : register(u3);
 
-// CHECK: -VarDecl 0x{{[0-9a-f]+}} <{{.*}}> col:17 UAV1 
'RWBuffer':'hlsl::RWBuffer' callinit
-// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}}  
'RWBuffer':'hlsl::RWBuffer' 'void ()'
-// CHECK-NEXT:-HLSLResourceBindingAttr 0x{{[0-9a-f]+}}  "u2" "space0"
-// CHECK-NEXT:-VarDecl 0x{{[0-9a-f]+}}  col:38 UAV2

[clang] [clang][Analysis][NFC] Let isConfigurationValue take Expr (PR #116266)

2025-03-10 Thread Aaron Puchert via cfe-commits

aaronpuchert wrote:

Ping. Or is this not interesting enough for a review?

https://github.com/llvm/llvm-project/pull/116266
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [alpha.webkit.UnretainedCallArgsChecker] Add a checker for NS or CF type call arguments. (PR #128586)

2025-03-10 Thread Ryosuke Niwa via cfe-commits


@@ -141,6 +158,42 @@ class RawPtrRefCallArgsChecker
 }
   }
 
+  void visitObjCMessageExpr(const ObjCMessageExpr *E, const Decl *D) const {
+if (BR->getSourceManager().isInSystemHeader(E->getExprLoc()))
+  return;
+
+auto Selector = E->getSelector();
+if (auto *Receiver = E->getInstanceReceiver()->IgnoreParenCasts()) {
+  std::optional IsUnsafe = isUnsafePtr(E->getReceiverType());
+  if (IsUnsafe && *IsUnsafe && !isPtrOriginSafe(Receiver)) {
+if (auto *InnerMsg = dyn_cast(Receiver)) {
+  auto InnerSelector = InnerMsg->getSelector();
+  if (InnerSelector.getNameForSlot(0) == "alloc" &&
+  Selector.getNameForSlot(0).starts_with("init"))

rniwa wrote:

I don't think so. As far as I know, "init" is never capitalized.

https://github.com/llvm/llvm-project/pull/128586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Use global TimerGroups for both new pass manager and old pass manager timers (PR #130375)

2025-03-10 Thread Fangrui Song via cfe-commits


@@ -71,11 +72,16 @@ class TimePassesHandler {
   bool PerRun;
 
 public:
+  static constexpr StringRef PassGroupName = "pass";
+  static constexpr StringRef AnalysisGroupName = "analysis";
+  static constexpr StringRef PassGroupDesc = "Pass execution timing report";
+  static constexpr StringRef AnalysisGroupDesc =
+  "Analysis execution timing report";
+
   TimePassesHandler();
   TimePassesHandler(bool Enabled, bool PerRun = false);
 
-  /// Destructor handles the print action if it has not been handled before.
-  ~TimePassesHandler() { print(); }
+  ~TimePassesHandler() = default;

MaskRay wrote:

just delete it.

https://github.com/llvm/llvm-project/pull/130375
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix error recovery while PTU cleanup (PR #127467)

2025-03-10 Thread Anutosh Bhat via cfe-commits

https://github.com/anutosh491 updated 
https://github.com/llvm/llvm-project/pull/127467

>From 6ff448ed506e0ef75db2c9974a628a965e85df2f Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Mon, 17 Feb 2025 15:33:20 +0530
Subject: [PATCH 1/4] Fix error recovery while PTU cleanup

---
 clang/lib/Interpreter/IncrementalParser.cpp | 4 ++--
 clang/unittests/Interpreter/InterpreterTest.cpp | 7 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index e43cea1baf43a..1ebef0e434b3d 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -178,8 +178,8 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
 if (!ND)
   continue;
 // Check if we need to clean up the IdResolver chain.
-if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
-!D->getLangOpts().CPlusPlus)
+if (!ND->getDeclName().isEmpty() && ND->getDeclName().getFETokenInfo() &&
+!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
   S.IdResolver.RemoveDecl(ND);
   }
 }
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 578f1d4c0eac6..56ab155ebf5a4 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -114,6 +114,13 @@ TEST_F(InterpreterTest, Errors) {
 
   RecoverErr = Interp->Parse("var1 = 424;");
   EXPECT_TRUE(!!RecoverErr);
+
+  Err = Interp->Parse("int x = 5; auto capture = [&]() { return x * 2; 
};").takeError();
+  EXPECT_THAT(DiagnosticOutput, HasSubstr("error: non-local lambda expression 
cannot have a capture-default"));
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+
+  RecoverErr = Interp->Parse("int validVar = 10;");
+  EXPECT_TRUE(!!RecoverErr);
 }
 
 // Here we test whether the user can mix declarations and statements. The

>From 8b9a112721c45662374fd9995af6da4031507c89 Mon Sep 17 00:00:00 2001
From: Anutosh Bhat 
Date: Wed, 26 Feb 2025 16:55:31 +0530
Subject: [PATCH 2/4] Update IncrementalParser.cpp

---
 clang/lib/Interpreter/IncrementalParser.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index 1ebef0e434b3d..774219d9fc9ab 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -175,11 +175,11 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
 auto *ND = dyn_cast(D);
-if (!ND)
+if (!ND || ND->getDeclName().isEmpty()) 
   continue;
 // Check if we need to clean up the IdResolver chain.
-if (!ND->getDeclName().isEmpty() && ND->getDeclName().getFETokenInfo() &&
-!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
+if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
+!D->getLangOpts().CPlusPlus)
   S.IdResolver.RemoveDecl(ND);
   }
 }

>From dae6ca63f0d443a6ec0df12e1abef183203c12de Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Tue, 11 Mar 2025 11:29:32 +0530
Subject: [PATCH 3/4] Add tests in lambda.cpp

---
 clang/test/Interpreter/lambda.cpp   | 11 +--
 clang/unittests/Interpreter/InterpreterTest.cpp |  7 ---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/test/Interpreter/lambda.cpp 
b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..135f5fe604ae5 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,8 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +15,10 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error@+1 {{non-local lambda expression cannot have a 
capture-default}}
+auto capture = [&]() { return x * 2; };
+
+%quit
\ No newline at end of file
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 56ab155ebf5a4..578f1d4c0eac6 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -114,13 +114,6 @@ TEST_F(InterpreterTest, Errors) {
 
   RecoverErr = Interp->Parse("var1 = 424;");
   EXPECT_TRUE(!!RecoverErr);
-
-  Err = Interp->Parse("int x = 5; auto capture = [&]() { return x * 2; 
};").takeError();
-  EXPECT_THAT(DiagnosticOutput, HasSubstr("error: non-local lambda expression 
cannot ha

[clang] [llvm] Use global TimerGroups for both new pass manager and old pass manager timers (PR #130375)

2025-03-10 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay approved this pull request.


https://github.com/llvm/llvm-project/pull/130375
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [alpha.webkit.UnretainedCallArgsChecker] Add a checker for NS or CF type call arguments. (PR #128586)

2025-03-10 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

Let me close this and create a new PR with the corrected commit message.

https://github.com/llvm/llvm-project/pull/128586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-03-10 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Perfect, do one more test, compare findings before and after from for example 
llvm, if they catch same thing. As for a change, I will try to review it this 
week.

https://github.com/llvm/llvm-project/pull/130369
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [alpha.webkit.UnretainedCallArgsChecker] Add a checker for NS or CF type call arguments. (PR #128586)

2025-03-10 Thread Ryosuke Niwa via cfe-commits


@@ -28,6 +29,15 @@ bool tryToFindPtrOrigin(
 std::function isSafePtrType,
 std::function callback) {
   while (E) {
+if (auto *DRE = dyn_cast(E)) {
+  auto *ValDecl = DRE->getDecl();
+  auto QT = ValDecl->getType();
+  auto ValName = ValDecl->getName();
+  if (ValDecl && (ValName.starts_with('k') || ValName.starts_with("_k")) &&

rniwa wrote:

They need to be treated as safe. Will add a comment.

https://github.com/llvm/llvm-project/pull/128586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 75f76d4 - [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (#121291)

2025-03-10 Thread via cfe-commits

Author: Baranov Victor
Date: 2025-03-11T07:22:15+01:00
New Revision: 75f76d482cc24162d5e3fdae0f0acd4c8f9cec6b

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

LOG: [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (#121291)

Add new clang-tidy check that finds potentially erroneous calls to
``reset()`` method on smart pointers when
the pointee type also has a ``reset()`` method.

It's easy to make typo and delete object because the difference between
``.`` and ``->`` is really small.

Sometimes IDE's autocomplete will change ``->`` to ``.`` automatically.
For example, developer wrote ``ptr->res`` but after pressing _Tab_ it
became ``ptr.reset()``.

Fixes #120908

Added: 
clang-tools-extra/clang-tidy/readability/AmbiguousSmartptrResetCallCheck.cpp
clang-tools-extra/clang-tidy/readability/AmbiguousSmartptrResetCallCheck.h

clang-tools-extra/docs/clang-tidy/checks/readability/ambiguous-smartptr-reset-call.rst

clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call-custom-pointers.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/AmbiguousSmartptrResetCallCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/AmbiguousSmartptrResetCallCheck.cpp
new file mode 100644
index 0..5f36c3976fc69
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/readability/AmbiguousSmartptrResetCallCheck.cpp
@@ -0,0 +1,126 @@
+//===--- AmbiguousSmartptrResetCallCheck.cpp - clang-tidy 
-===//
+//
+// 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 "AmbiguousSmartptrResetCallCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultParameters) {
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+
+  return true;
+}
+
+const auto DefaultSmartPointers = "::std::shared_ptr;::std::unique_ptr;"
+  "::boost::shared_ptr";
+} // namespace
+
+AmbiguousSmartptrResetCallCheck::AmbiguousSmartptrResetCallCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SmartPointers(utils::options::parseStringList(
+  Options.get("SmartPointers", DefaultSmartPointers))) {}
+
+void AmbiguousSmartptrResetCallCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "SmartPointers",
+utils::options::serializeStringList(SmartPointers));
+}
+
+void AmbiguousSmartptrResetCallCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IsSmartptr = hasAnyName(SmartPointers);
+
+  const auto ResetMethod =
+  cxxMethodDecl(hasName("reset"), hasOnlyDefaultParameters());
+
+  const auto TypeWithReset =
+  anyOf(cxxRecordDecl(
+anyOf(hasMethod(ResetMethod),
+  isDerivedFrom(cxxRecordDecl(hasMethod(ResetMethod),
+classTemplateSpecializationDecl(
+hasSpecializedTemplate(classTemplateDecl(has(ResetMethod);
+
+  const auto SmartptrWithReset = expr(hasType(hasUnqualifiedDesugaredType(
+  recordType(hasDeclaration(classTemplateSpecializationDecl(
+  IsSmartptr,
+  hasTemplateArgument(
+  0, templateArgument(refersToType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(TypeWithReset;
+
+  Finder->addMatcher(
+  cxxMemberCallExpr(
+  callee(ResetMethod),
+  unless(hasAnyArgument(expr(unless(cxxDefaultArgExpr(),
+  anyOf(on(cxxOperatorCallExpr(hasOverloadedOperatorName("->"),
+   hasArgument(0, SmartptrWithReset))
+   .bind("ArrowOp")),
+on(SmartptrWithReset)))
+  .bind("MemberCall"),
+  this);
+}
+
+void AmbiguousSmartptrResetCallCheck::check(
+const MatchFinder::MatchResult &Result) {
+  const auto *MemberCall =
+  Result.Nodes.getNodeAs("Memb

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2025-03-10 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL closed 
https://github.com/llvm/llvm-project/pull/121291
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix error recovery while PTU cleanup (PR #127467)

2025-03-10 Thread Anutosh Bhat via cfe-commits

https://github.com/anutosh491 updated 
https://github.com/llvm/llvm-project/pull/127467

>From bd1b0b2a14afeb73755db3a7deb6bffd4f50778c Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Mon, 17 Feb 2025 15:33:20 +0530
Subject: [PATCH] Fix error recovery while PTU cleanup

---
 clang/lib/Interpreter/IncrementalParser.cpp |  2 +-
 clang/test/Interpreter/lambda.cpp   | 11 +--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index 41d6304bd5f65..6343f17ed822a 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -176,7 +176,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
 auto *ND = dyn_cast(D);
-if (!ND)
+if (!ND || ND->getDeclName().isEmpty())
   continue;
 // Check if we need to clean up the IdResolver chain.
 if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
diff --git a/clang/test/Interpreter/lambda.cpp 
b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..8f49f870fddb6 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,8 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify -Xcc -O2 | FileCheck 
%s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +15,10 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error@+1 {{non-local lambda expression cannot have a 
capture-default}}
+auto capture = [&]() { return x * 2; };
+
+%quit
\ No newline at end of file

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


[clang] [HLSL] Add bounds checks for the hlsl vector arguments and return types (PR #130724)

2025-03-10 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl created 
https://github.com/llvm/llvm-project/pull/130724

fixes #129003
- fix up sema tests
- fix up templates for scalar and vector HLSL intrinsic overloads

>From 80f6687b461c6256aa5bacb3bbd080a58e37573b Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Mon, 10 Mar 2025 21:03:49 -0400
Subject: [PATCH] [HLSL] Add bounds checks for the hlsl vector arguments and
 return types

fixes #129003
- fix up sema tests
- fix up templates for scalar and vector HLSL intrinsic overloads
---
 clang/lib/Headers/hlsl/hlsl_detail.h  |  4 ++
 .../lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 14 +
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 54 +
 .../SemaHLSL/BuiltIns/distance-errors.hlsl| 44 ++
 .../test/SemaHLSL/BuiltIns/length-errors.hlsl | 60 ++-
 .../SemaHLSL/BuiltIns/reflect-errors.hlsl | 44 ++
 6 files changed, 161 insertions(+), 59 deletions(-)

diff --git a/clang/lib/Headers/hlsl/hlsl_detail.h 
b/clang/lib/Headers/hlsl/hlsl_detail.h
index c691d85283de4..80c4900121dfb 100644
--- a/clang/lib/Headers/hlsl/hlsl_detail.h
+++ b/clang/lib/Headers/hlsl/hlsl_detail.h
@@ -45,6 +45,10 @@ template  struct is_arithmetic {
   static const bool Value = __is_arithmetic(T);
 };
 
+template 
+using HLSL_FIXED_VECTOR =
+vector<__detail::enable_if_t<(N > 1 && N <= 4), T>, N>;
+
 } // namespace __detail
 } // namespace hlsl
 #endif //_HLSL_HLSL_DETAILS_H_
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 6783e23f6346d..87b52792447f6 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -23,11 +23,7 @@ constexpr vector 
d3d_color_to_ubyte4_impl(vector V) {
   return V.zyxw * 255.001953f;
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-length_impl(T X) {
-  return abs(X);
-}
+template  constexpr T length_impl(T X) { return abs(X); }
 
 template 
 constexpr enable_if_t::value || is_same::value, T>
@@ -39,9 +35,7 @@ length_vec_impl(vector X) {
 #endif
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-distance_impl(T X, T Y) {
+template  constexpr T distance_impl(T X, T Y) {
   return length_impl(X - Y);
 }
 
@@ -51,9 +45,7 @@ distance_vec_impl(vector X, vector Y) {
   return length_vec_impl(X - Y);
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-reflect_impl(T I, T N) {
+template  constexpr T reflect_impl(T I, T N) {
   return I - 2 * N * I * N;
 }
 
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index cd6d836578787..3fadd45ecabb7 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -89,23 +89,31 @@ void asuint(double4, out uint4, out uint4);
 /// \param X The X input value.
 /// \param Y The Y input value.
 
+template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(half X, half Y) {
+const inline __detail::enable_if_t<
+__detail::is_arithmetic::Value &&
+__detail::is_same::value> distance(T X, T Y) {
   return __detail::distance_impl(X, Y);
 }
 
-const inline float distance(float X, float Y) {
+template 
+const inline __detail::enable_if_t<__detail::is_arithmetic::Value &&
+   __detail::is_same::value>
+distance(T X, T Y) {
   return __detail::distance_impl(X, Y);
 }
 
 template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(vector X, vector Y) {
+const inline half distance(__detail::HLSL_FIXED_VECTOR X,
+   __detail::HLSL_FIXED_VECTOR Y) {
   return __detail::distance_vec_impl(X, Y);
 }
 
 template 
-const inline float distance(vector X, vector Y) {
+const inline float distance(__detail::HLSL_FIXED_VECTOR X,
+__detail::HLSL_FIXED_VECTOR Y) {
   return __detail::distance_vec_impl(X, Y);
 }
 
@@ -119,17 +127,29 @@ const inline float distance(vector X, 
vector Y) {
 ///
 /// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
 
+template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(half X) { return __detail::length_impl(X); }
-const inline float length(float X) { return __detail::length_impl(X); }
+const inline __detail::enable_if_t<
+__detail::is_arithmetic::Value &&
+__detail::is_same::value> length(T X) {
+  return __detail::length_impl(X);
+}
+
+template 
+const inline __detail::enable_if_t<__detail::is_arithmetic::Value &&
+   __detail::is_same::value>
+length(T X) {
+  return __detail::length_impl(X);
+}
 
 template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(vector X) {
+const inline half length(__detail::HLSL_FIXED_VECTOR X) {
   return __detail::length_vec_impl(X);
 }
 
-template  const inline float length(vector X) {
+template 
+const inline float length(__detail::HLSL_FIXED_VECTOR

[clang] [HLSL] Add bounds checks for the hlsl vector arguments and return types (PR #130724)

2025-03-10 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl converted_to_draft 
https://github.com/llvm/llvm-project/pull/130724
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Add bounds checks for the hlsl vector arguments and return types (PR #130724)

2025-03-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Farzon Lotfi (farzonl)


Changes

fixes #129003
- fix up sema tests
- fix up templates for scalar and vector HLSL intrinsic overloads

---

Patch is 24.37 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/130724.diff


6 Files Affected:

- (modified) clang/lib/Headers/hlsl/hlsl_detail.h (+4) 
- (modified) clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h (+3-11) 
- (modified) clang/lib/Headers/hlsl/hlsl_intrinsics.h (+42-12) 
- (modified) clang/test/SemaHLSL/BuiltIns/distance-errors.hlsl (+34-10) 
- (modified) clang/test/SemaHLSL/BuiltIns/length-errors.hlsl (+44-16) 
- (modified) clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl (+34-10) 


``diff
diff --git a/clang/lib/Headers/hlsl/hlsl_detail.h 
b/clang/lib/Headers/hlsl/hlsl_detail.h
index c691d85283de4..80c4900121dfb 100644
--- a/clang/lib/Headers/hlsl/hlsl_detail.h
+++ b/clang/lib/Headers/hlsl/hlsl_detail.h
@@ -45,6 +45,10 @@ template  struct is_arithmetic {
   static const bool Value = __is_arithmetic(T);
 };
 
+template 
+using HLSL_FIXED_VECTOR =
+vector<__detail::enable_if_t<(N > 1 && N <= 4), T>, N>;
+
 } // namespace __detail
 } // namespace hlsl
 #endif //_HLSL_HLSL_DETAILS_H_
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 6783e23f6346d..87b52792447f6 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -23,11 +23,7 @@ constexpr vector 
d3d_color_to_ubyte4_impl(vector V) {
   return V.zyxw * 255.001953f;
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-length_impl(T X) {
-  return abs(X);
-}
+template  constexpr T length_impl(T X) { return abs(X); }
 
 template 
 constexpr enable_if_t::value || is_same::value, T>
@@ -39,9 +35,7 @@ length_vec_impl(vector X) {
 #endif
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-distance_impl(T X, T Y) {
+template  constexpr T distance_impl(T X, T Y) {
   return length_impl(X - Y);
 }
 
@@ -51,9 +45,7 @@ distance_vec_impl(vector X, vector Y) {
   return length_vec_impl(X - Y);
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-reflect_impl(T I, T N) {
+template  constexpr T reflect_impl(T I, T N) {
   return I - 2 * N * I * N;
 }
 
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index cd6d836578787..3fadd45ecabb7 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -89,23 +89,31 @@ void asuint(double4, out uint4, out uint4);
 /// \param X The X input value.
 /// \param Y The Y input value.
 
+template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(half X, half Y) {
+const inline __detail::enable_if_t<
+__detail::is_arithmetic::Value &&
+__detail::is_same::value> distance(T X, T Y) {
   return __detail::distance_impl(X, Y);
 }
 
-const inline float distance(float X, float Y) {
+template 
+const inline __detail::enable_if_t<__detail::is_arithmetic::Value &&
+   __detail::is_same::value>
+distance(T X, T Y) {
   return __detail::distance_impl(X, Y);
 }
 
 template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(vector X, vector Y) {
+const inline half distance(__detail::HLSL_FIXED_VECTOR X,
+   __detail::HLSL_FIXED_VECTOR Y) {
   return __detail::distance_vec_impl(X, Y);
 }
 
 template 
-const inline float distance(vector X, vector Y) {
+const inline float distance(__detail::HLSL_FIXED_VECTOR X,
+__detail::HLSL_FIXED_VECTOR Y) {
   return __detail::distance_vec_impl(X, Y);
 }
 
@@ -119,17 +127,29 @@ const inline float distance(vector X, 
vector Y) {
 ///
 /// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
 
+template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(half X) { return __detail::length_impl(X); }
-const inline float length(float X) { return __detail::length_impl(X); }
+const inline __detail::enable_if_t<
+__detail::is_arithmetic::Value &&
+__detail::is_same::value> length(T X) {
+  return __detail::length_impl(X);
+}
+
+template 
+const inline __detail::enable_if_t<__detail::is_arithmetic::Value &&
+   __detail::is_same::value>
+length(T X) {
+  return __detail::length_impl(X);
+}
 
 template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(vector X) {
+const inline half length(__detail::HLSL_FIXED_VECTOR X) {
   return __detail::length_vec_impl(X);
 }
 
-template  const inline float length(vector X) {
+template 
+const inline float length(__detail::HLSL_FIXED_VECTOR X) {
   return __detail::length_vec_impl(X);
 }
 
@@ -173,23 +193,33 @@ constexpr vector D3DCOLORtoUBYTE4(vector V) {
 ///
 /// Result type and the type of all operands must be the same type

[clang] [llvm] [ARM] Save floating point registers and status registers with save_fp function attribute (PR #89654)

2025-03-10 Thread Benson Chu via cfe-commits

https://github.com/pestctrl updated 
https://github.com/llvm/llvm-project/pull/89654

>From 6186aad4de8a25bfeb389163068950d1e2e7fa1f Mon Sep 17 00:00:00 2001
From: Jake Vossen 
Date: Wed, 30 Jun 2021 15:13:13 -0500
Subject: [PATCH 1/3] [ARM] Save floating point registers with save_fp function
 attribute

[ARM] and interrupt_save_fp attribute

interupt_save_fp update name; fix bugs

[ARM] fix typos and register class name

used better push / pop instructions

change epilog emitting order

WIP with FPSCR

save just d regs

cleaned up docs and ARMRegisterInfo td

change m3 to m4

fix reg tests

Minor format changes on top of Jake Vossen's support for
interrupt_save_fp function attribute which preserves VFP D
registers at the moment. FPSCR and FPEXC registers to follow.
---
 clang/include/clang/Basic/Attr.td |  16 ++
 clang/include/clang/Basic/AttrDocs.td |  14 ++
 .../clang/Basic/DiagnosticSemaKinds.td|   8 +-
 clang/lib/CodeGen/Targets/ARM.cpp |   6 +
 clang/lib/Sema/SemaARM.cpp|   8 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  17 ++
 .../test/CodeGen/arm-interrupt-save-fp-attr.c |  39 
 clang/test/Sema/arm-interrupt-attr.c  |   2 +-
 clang/test/Sema/arm-interrupt-save-fp-attr.c  |  59 ++
 llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp   |  34 +++-
 llvm/lib/Target/ARM/ARMCallingConv.td |  28 +++
 .../CodeGen/ARM/interrupt-save-fp-attr.ll | 171 ++
 12 files changed, 392 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/CodeGen/arm-interrupt-save-fp-attr.c
 create mode 100644 clang/test/Sema/arm-interrupt-save-fp-attr.c
 create mode 100644 llvm/test/CodeGen/ARM/interrupt-save-fp-attr.ll

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4b4337cf460f3..0b42ed8f03117 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -994,6 +994,22 @@ def ARMInterrupt : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [ARMInterruptDocs];
 }
 
+def ARMInterruptSaveFP : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [GNU<"interrupt_save_fp">];
+  let Args = [EnumArgument<"Interrupt", "InterruptType", /*is_string=*/true,
+   ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
+   ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
+   1>];
+  let HasCustomParsing = 0;
+  let Documentation = [ARMInterruptSaveFPDocs];
+}
+
+def ARMSaveFP : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [InternalOnly];
+}
+
 def AVRInterrupt : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"interrupt">];
   let Subjects = SubjectList<[Function]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 1f2f02a4453fc..942d3be3ce58e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2662,6 +2662,20 @@ The semantics are as follows:
   }];
 }
 
+def ARMInterruptSaveFPDocs : Documentation {
+let Category = DocCatFunction;
+  let Heading = "interrupt_save_fp (ARM)";
+  let Content = [{
+Clang supports the GNU style ``__attribute__((interrupt_save_fp("TYPE")))``
+on ARM targets. This attribute behaves the same way as the ARM interrupt
+attribute, except the general purpose floating point registers are also saved. 
+If the FPEXC or FPSCR are needed, that state must be saved manually. Note, 
even 
+on M-class CPUs, where the floating point context can be automatically saved 
+depending on the FPCCR, the general purpose floating point registers will be 
+saved.
+  }];
+}
+
 def BPFPreserveAccessIndexDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b73ac2933b1ca..dd5a71e2bddb5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -346,8 +346,14 @@ def warn_anyx86_excessive_regsave : Warning<
   InGroup>;
 def warn_arm_interrupt_vfp_clobber : Warning<
   "interrupt service routine with vfp enabled may clobber the "
-  "interruptee's vfp state">,
+  "interruptee's vfp state; "
+  "consider using the `interrupt_save_fp` attribute to prevent this behavior">,
   InGroup>;
+def warn_arm_interrupt_save_fp_without_vfp_unit : Warning<
+   "`interrupt_save_fp` only applies to targets that have a VFP unit enabled "
+   "for this compilation; this will be treated as a regular `interrupt` "
+   "attribute">,
+   InGroup>;
 def err_arm_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
 def warn_interrupt_signal_attribute_invalid : Warning<
diff --git a/clang/lib/CodeGen/Targets/ARM.cpp 
b/clang/lib/CodeGen/Targets/ARM.cpp
index a6d9a5549355c..dddf51a827159 100644

[clang] [clang][AST] Remove HasFirstArg assertion in CallExpr::getBeginLoc() (PR #130725)

2025-03-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nathan Ridge (HighCommander4)


Changes

There are cases where the assertion legitimately does not hold (e.g. 
CallExpr::CreateTemporary()), and there's no readily available way to tell such 
cases apart.

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

---
Full diff: https://github.com/llvm/llvm-project/pull/130725.diff


2 Files Affected:

- (modified) clang/lib/AST/Expr.cpp (+5-3) 
- (modified) clang/test/AST/ast-dump-cxx2b-deducing-this.cpp (+9) 


``diff
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ccfec7fda0cbc..1dde64f193dbd 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1656,9 +1656,11 @@ SourceLocation CallExpr::getBeginLoc() const {
 if (const auto *Method =
 dyn_cast_if_present(getCalleeDecl());
 Method && Method->isExplicitObjectMemberFunction()) {
-  bool HasFirstArg = getNumArgs() > 0 && getArg(0);
-  assert(HasFirstArg);
-  if (HasFirstArg)
+  // Note: while we typically expect the call to have a first argument
+  // here, we can't assert it because in some cases it does not, e.g.
+  // calls created with CallExpr::CreateTemporary() during overload
+  // resolution.
+  if (getNumArgs() > 0 && getArg(0))
 return getArg(0)->getBeginLoc();
 }
   }
diff --git a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp 
b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
index abe9d6a5b5bc6..fc86aeb3e5ec3 100644
--- a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
+++ b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
@@ -26,3 +26,12 @@ struct S {
   // CHECK-NEXT:   `-DeclRefExpr 0x{{[^ ]*}}  'S' lvalue ParmVar 
0x{{[^ ]*}} 's' 'S'
 };
 }
+
+namespace GH130272 {
+struct A {};
+struct B {
+  operator A(this B);
+};
+A a = A(B{});
+// CHECK: CallExpr 0x{{[^ ]*}}  'A':'GH130272::A'
+}

``




https://github.com/llvm/llvm-project/pull/130725
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AST] Remove HasFirstArg assertion in CallExpr::getBeginLoc() (PR #130725)

2025-03-10 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@cor3ntin I would appreciate it if you can take a look too

https://github.com/llvm/llvm-project/pull/130725
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AST] Remove HasFirstArg assertion in CallExpr::getBeginLoc() (PR #130725)

2025-03-10 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/130725
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AST] Remove HasFirstArg assertion in CallExpr::getBeginLoc() (PR #130725)

2025-03-10 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 created 
https://github.com/llvm/llvm-project/pull/130725

There are cases where the assertion legitimately does not hold (e.g. 
CallExpr::CreateTemporary()), and there's no readily available way to tell such 
cases apart.

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

>From 6a4f6cfd0dee5d2af33f40787f81eeafad27090d Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Tue, 11 Mar 2025 02:34:51 -0400
Subject: [PATCH] [clang][AST] Remove HasFirstArg assertion in
 CallExpr::getBeginLoc()

There are cases where the assertion legitimately does not hold
(e.g. CallExpr::CreateTemporary()), and there's no readily available
way to tell such cases apart.

Fixes https://github.com/llvm/llvm-project/issues/130272
---
 clang/lib/AST/Expr.cpp  | 8 +---
 clang/test/AST/ast-dump-cxx2b-deducing-this.cpp | 9 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ccfec7fda0cbc..1dde64f193dbd 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1656,9 +1656,11 @@ SourceLocation CallExpr::getBeginLoc() const {
 if (const auto *Method =
 dyn_cast_if_present(getCalleeDecl());
 Method && Method->isExplicitObjectMemberFunction()) {
-  bool HasFirstArg = getNumArgs() > 0 && getArg(0);
-  assert(HasFirstArg);
-  if (HasFirstArg)
+  // Note: while we typically expect the call to have a first argument
+  // here, we can't assert it because in some cases it does not, e.g.
+  // calls created with CallExpr::CreateTemporary() during overload
+  // resolution.
+  if (getNumArgs() > 0 && getArg(0))
 return getArg(0)->getBeginLoc();
 }
   }
diff --git a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp 
b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
index abe9d6a5b5bc6..fc86aeb3e5ec3 100644
--- a/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
+++ b/clang/test/AST/ast-dump-cxx2b-deducing-this.cpp
@@ -26,3 +26,12 @@ struct S {
   // CHECK-NEXT:   `-DeclRefExpr 0x{{[^ ]*}}  'S' lvalue ParmVar 
0x{{[^ ]*}} 's' 'S'
 };
 }
+
+namespace GH130272 {
+struct A {};
+struct B {
+  operator A(this B);
+};
+A a = A(B{});
+// CHECK: CallExpr 0x{{[^ ]*}}  'A':'GH130272::A'
+}

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


[clang] [HLSL][Driver] Use temporary files correctly (PR #130436)

2025-03-10 Thread Chris B via cfe-commits

https://github.com/llvm-beanz closed 
https://github.com/llvm/llvm-project/pull/130436
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot4` while building 
`llvm` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/169/builds/9289


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 89493 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: LLVM-Unit :: Support/./SupportTests/30/95 (89333 of 89493)
 TEST 'LLVM-Unit :: Support/./SupportTests/30/95' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/Support/./SupportTests-LLVM-Unit-400259-30-95.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=30 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/Support/./SupportTests
--


Note: This is test shard 31 of 95.
[==] Running 16 tests from 16 test suites.
[--] Global test environment set-up.
[--] 1 test from AllocatorTest
[ RUN  ] AllocatorTest.TestZero
[   OK ] AllocatorTest.TestZero (0 ms)
[--] 1 test from AllocatorTest (0 ms total)

[--] 1 test from CachePruningPolicyParser
[ RUN  ] CachePruningPolicyParser.MaxSizePercentageOfAvailableSpace
[   OK ] CachePruningPolicyParser.MaxSizePercentageOfAvailableSpace (0 ms)
[--] 1 test from CachePruningPolicyParser (0 ms total)

[--] 1 test from CommandLineTest
[ RUN  ] CommandLineTest.OptionErrorMessageSuggest
[   OK ] CommandLineTest.OptionErrorMessageSuggest (0 ms)
[--] 1 test from CommandLineTest (0 ms total)

[--] 1 test from Endian
[ RUN  ] Endian.WriteBitAligned
[   OK ] Endian.WriteBitAligned (0 ms)
[--] 1 test from Endian (0 ms total)

[--] 1 test from FormatVariadicTest
[ RUN  ] FormatVariadicTest.BigTest
[   OK ] FormatVariadicTest.BigTest (0 ms)
[--] 1 test from FormatVariadicTest (0 ms total)

[--] 1 test from HashBuilderTest/5, where TypeParam = 
[ RUN  ] HashBuilderTest/5.AddRangeElements
[   OK ] HashBuilderTest/5.AddRangeElements (0 ms)
Step 10 (stage2/asan_ubsan check) failure: stage2/asan_ubsan check (failure)
...
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:512:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitize

[clang-tools-extra] [clang-tidy] Fix invalid fixit from modernize-use-ranges for nullptr used with std::unique_ptr (PR #127162)

2025-03-10 Thread via cfe-commits

Andrewyuan34 wrote:

> Thanks for you contributions!
> 
> Some tips:
> 
> 1. run git-clang-format -f before commit change
> 2. actually you don't need to rebase often. but in past several weeks we have 
> a major release and it causes release notes are cleared. in this case, rebase 
> is needed.
> 3. After several successfully land, you can request write access. then you 
> can merge it by yourself.

I really appreciate all of the suggestions! Will take those in mind. Looking 
forward to the day I have write access.

https://github.com/llvm/llvm-project/pull/127162
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ObjC] Check entire chain of superclasses to see if class layout is statically known (PR #81335)

2025-03-10 Thread via cfe-commits

AZero13 wrote:

> @AZero13 Do you have any news or plans regarding LTO support? We have several 
> projects with substantial existing Objective-C code, and the performance 
> benefits of LTO support could be significant. I would be interested in taking 
> on a portion or the entirety of this work if it is not currently on your 
> priority list.

If you can do it, go for it!



https://github.com/llvm/llvm-project/pull/81335
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [flang] [llvm] Reland 'Update llvm::Registry to work for LLVM shared library builds on windows' (#109024) (PR #112640)

2025-03-10 Thread Mike Hommey via cfe-commits

glandium wrote:

Ironically, this and later changes related to LLVM_BUILD_LLVM_DYLIB for Windows 
broke  LLVM_EXPORT_SYMBOLS_FOR_PLUGINS, which is a currently working way to use 
clang plugins on Windows, while LLVM_BUILD_LLVM_DYLIB doesn't work yet.

https://github.com/llvm/llvm-project/pull/112640
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on 
`as-worker-93` while building `llvm` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/146/builds/2461


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests.exe/91/94' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-17424-91-94.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=94 GTEST_SHARD_INDEX=91 
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe 
--gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): 
error: Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): 
error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied







```



https://github.com/llvm/llvm-project/pull/105893
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebKit checkers] Don't treat virtual functions as safe. (PR #129632)

2025-03-10 Thread Rashmi Mudduluru via cfe-commits

https://github.com/t-rasmud approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/129632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3ce43c8 - [WebKit checkers] Don't treat virtual functions as safe. (#129632)

2025-03-10 Thread via cfe-commits

Author: Ryosuke Niwa
Date: 2025-03-10T21:01:39-07:00
New Revision: 3ce43c8b16a6aefe79ce976b1340ccd493cf533a

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

LOG: [WebKit checkers] Don't treat virtual functions as safe. (#129632)

Prior to this PR, WebKit checkers erroneously treated functions to be
safe if it has a trivial body even if it was marked as virtual. In the
case of a virtual function, it can have an override which does not pass
the triviality check so we must not make such an assumption.

This PR also restricts the allowed operator overloading while finding
the pointer origin to just operators on smart pointer types: Ref,
RefPtr, CheckedRef, CheckedPtr, RetainPtr, WeakPtr, WeakRef, unique_ptr,
and UniqueRef.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index c8151e932997e..5e67cb29d08e4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -91,9 +91,17 @@ bool tryToFindPtrOrigin(
   }
 
   if (auto *operatorCall = dyn_cast(E)) {
-if (operatorCall->getNumArgs() == 1) {
-  E = operatorCall->getArg(0);
-  continue;
+if (auto *Callee = operatorCall->getDirectCallee()) {
+  auto ClsName = safeGetName(Callee->getParent());
+  if (isRefType(ClsName) || isCheckedPtr(ClsName) ||
+  isRetainPtr(ClsName) || ClsName == "unique_ptr" ||
+  ClsName == "UniqueRef" || ClsName == "WeakPtr" ||
+  ClsName == "WeakRef") {
+if (operatorCall->getNumArgs() == 1) {
+  E = operatorCall->getArg(0);
+  continue;
+}
+  }
 }
   }
 
@@ -215,7 +223,7 @@ bool EnsureFunctionAnalysis::isACallToEnsureFn(const 
clang::Expr *E) const {
   if (!Callee)
 return false;
   auto *Body = Callee->getBody();
-  if (!Body)
+  if (!Body || Callee->isVirtualAsWritten())
 return false;
   auto [CacheIt, IsNew] = Cache.insert(std::make_pair(Callee, false));
   if (IsNew)

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 8a304a07296fc..419d9c2325412 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -480,6 +480,10 @@ class TrivialFunctionAnalysisVisitor
   TrivialFunctionAnalysisVisitor(CacheTy &Cache) : Cache(Cache) {}
 
   bool IsFunctionTrivial(const Decl *D) {
+if (auto *FnDecl = dyn_cast(D)) {
+  if (FnDecl->isVirtualAsWritten())
+return false;
+}
 return WithCachedResult(D, [&]() {
   if (auto *CtorDecl = dyn_cast(D)) {
 for (auto *CtorInit : CtorDecl->inits()) {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index fcc1a41dba78b..323d473665888 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -131,6 +131,9 @@ bool isRefType(const std::string &Name);
 /// \returns true if \p Name is CheckedRef or CheckedPtr, false if not.
 bool isCheckedPtr(const std::string &Name);
 
+/// \returns true if \p Name is RetainPtr or its variant, false if not.
+bool isRetainPtr(const std::string &Name);
+
 /// \returns true if \p M is getter of a ref-counted class, false if not.
 std::optional isGetterOfSafePtr(const clang::CXXMethodDecl *Method);
 

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
index d633fbcbd798b..9d07c65da88af 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
@@ -172,7 +172,7 @@ class RawPtrRefCallArgsChecker
 if (BR->getSourceManager().isInSystemHeader(CE->getExprLoc()))
   return true;
 
-if (Callee && TFA.isTrivial(Callee))
+if (Callee && TFA.isTrivial(Callee) && !Callee->isVirtualAsWritten())
   return true;
 
 if (CE->getNumArgs() == 0)

diff  --git a/clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp 
b/clang/te

[clang] [clang][test] Don't require specific alignment in test case (PR #130589)

2025-03-10 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/130589

https://github.com/llvm/llvm-project/pull/129952 / 
42d49a77241df73a17cb442973702fc460e7fb90 added this test which is failing on 
32-bit ARM because the alignment chosen is 4 not 8. Which would make sense if 
this is a 32/64 bit difference

https://lab.llvm.org/buildbot/#/builders/154/builds/13059

:34:30: note: scanning from here
define dso_local void @_Z1fv(ptr dead_on_unwind noalias writable 
sret(%struct.B) align 4 %agg.result) #0 {
 ^
:38:2: note: possible intended match here
 %0 = load ptr, ptr @x, align 4
 ^

The other test does not check alignment, so I'm assuming that it is not 
important here.

>From e72fa81e587099b30b8c21e97b88ca08200c9b35 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 10 Mar 2025 12:03:57 +
Subject: [PATCH] [clang][test] Don't require specific alignment in test case

https://github.com/llvm/llvm-project/pull/129952 / 
42d49a77241df73a17cb442973702fc460e7fb90
added this test which is failing on 32-bit ARM because the alignment
chosen is 4 not 8. Which would make sense if this is a 32/64 bit difference

https://lab.llvm.org/buildbot/#/builders/154/builds/13059

:34:30: note: scanning from here
define dso_local void @_Z1fv(ptr dead_on_unwind noalias writable 
sret(%struct.B) align 4 %agg.result) #0 {
 ^
:38:2: note: possible intended match here
 %0 = load ptr, ptr @x, align 4
 ^

The other test does not check alignment, so I'm assuming that it is
not important here.
---
 clang/test/CodeGenCXX/cxx23-p2280r4.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/CodeGenCXX/cxx23-p2280r4.cpp 
b/clang/test/CodeGenCXX/cxx23-p2280r4.cpp
index b62c68c66f0fa..53b00695d9d6d 100644
--- a/clang/test/CodeGenCXX/cxx23-p2280r4.cpp
+++ b/clang/test/CodeGenCXX/cxx23-p2280r4.cpp
@@ -15,11 +15,11 @@ int& test() {
 }
 
 // CHECK-LABEL: @_Z1fv(
-// CHECK: [[X1:%.*]] = load ptr, ptr @x, align 8
+// CHECK: [[X1:%.*]] = load ptr, ptr @x, align {{.*}}
 // CHECK-NEXT: store ptr [[X1]]
-// CHECK: [[X2:%.*]] = load ptr, ptr @x, align 8
+// CHECK: [[X2:%.*]] = load ptr, ptr @x, align {{.*}}
 // CHECK-NEXT: store ptr [[X2]]
-// CHECK: [[X3:%.*]] = load ptr, ptr @x, align 8
+// CHECK: [[X3:%.*]] = load ptr, ptr @x, align {{.*}}
 // CHECK-NEXT: store ptr [[X3]]
 int &ff();
 int &x = ff();

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


[clang] [clang][analyzer] Add support for C++23 container methods releated to iterator in ContainerModeling (PR #129719)

2025-03-10 Thread via cfe-commits

https://github.com/flovent updated 
https://github.com/llvm/llvm-project/pull/129719

>From 90da509c1955afb925f880db2e3cbfdac0311095 Mon Sep 17 00:00:00 2001
From: flovent 
Date: Tue, 4 Mar 2025 22:54:10 +0800
Subject: [PATCH 1/2] [clang][analyzer] Add support for C++23 container methods
 releated to iterator in ContainerModeling

---
 .../Checkers/ContainerModeling.cpp|   6 +
 .../Inputs/system-header-simulator-cxx.h  |  42 ++
 clang/test/Analysis/iterator-modeling.cpp | 480 +-
 3 files changed, 527 insertions(+), 1 deletion(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
index 55ed809bfed6c..04e7696ed5b9d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
@@ -74,19 +74,25 @@ class ContainerModeling
   CallDescriptionMap NoIterParamFunctions = {
   {{CDM::CXXMethod, {"clear"}, 0}, &ContainerModeling::handleClear},
   {{CDM::CXXMethod, {"assign"}, 2}, &ContainerModeling::handleAssign},
+  {{CDM::CXXMethod, {"assign_range"}, 1}, 
&ContainerModeling::handleAssign},
   {{CDM::CXXMethod, {"push_back"}, 1}, &ContainerModeling::handlePushBack},
   {{CDM::CXXMethod, {"emplace_back"}, 1},
&ContainerModeling::handlePushBack},
+  {{CDM::CXXMethod, {"append_range"}, 1},
+   &ContainerModeling::handlePushBack},
   {{CDM::CXXMethod, {"pop_back"}, 0}, &ContainerModeling::handlePopBack},
   {{CDM::CXXMethod, {"push_front"}, 1},
&ContainerModeling::handlePushFront},
   {{CDM::CXXMethod, {"emplace_front"}, 1},
&ContainerModeling::handlePushFront},
+  {{CDM::CXXMethod, {"prepend_range"}, 1},
+   &ContainerModeling::handlePushFront},
   {{CDM::CXXMethod, {"pop_front"}, 0}, &ContainerModeling::handlePopFront},
   };
 
   CallDescriptionMap OneIterParamFunctions = {
   {{CDM::CXXMethod, {"insert"}, 2}, &ContainerModeling::handleInsert},
+  {{CDM::CXXMethod, {"insert_range"}, 2}, 
&ContainerModeling::handleInsert},
   {{CDM::CXXMethod, {"emplace"}, 2}, &ContainerModeling::handleInsert},
   {{CDM::CXXMethod, {"erase"}, 1}, &ContainerModeling::handleErase},
   {{CDM::CXXMethod, {"erase_after"}, 1},
diff --git a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h 
b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
index a379a47515668..5a42a952cca85 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -336,6 +336,15 @@ namespace std {
 iterator erase(const_iterator position);
 iterator erase(const_iterator first, const_iterator last);
 
+template
+void assign_range(R&& rg);
+
+template
+iterator insert_range(const_iterator position, R&& rg);
+
+template
+void append_range(R&& rg);
+
 T &operator[](size_t n) {
   return _start[n];
 }
@@ -414,6 +423,18 @@ namespace std {
 iterator erase(const_iterator position);
 iterator erase(const_iterator first, const_iterator last);
 
+template
+void assign_range(R&& rg);
+
+template
+iterator insert_range(const_iterator position, R&& rg);
+
+template
+void append_range(R&& rg);
+
+template
+void prepend_range(R&& rg);
+
 iterator begin() { return iterator(_start); }
 const_iterator begin() const { return const_iterator(_start); }
 const_iterator cbegin() const { return const_iterator(_start); }
@@ -488,6 +509,18 @@ namespace std {
 iterator erase(const_iterator position);
 iterator erase(const_iterator first, const_iterator last);
 
+template
+void assign_range(R&& rg);
+
+template
+iterator insert_range(const_iterator position, R&& rg);
+
+template
+void append_range(R&& rg);
+
+template
+void prepend_range(R&& rg);
+
 T &operator[](size_t n) {
   return _start[n];
 }
@@ -561,6 +594,15 @@ namespace std {
 iterator erase_after(const_iterator position);
 iterator erase_after(const_iterator first, const_iterator last);
 
+template
+void assign_range(R&& rg);
+
+template
+void prepend_range(R&& rg);
+
+template
+iterator insert_range_after(const_iterator pos, R&& rg);
+
 iterator begin() { return iterator(_start); }
 const_iterator begin() const { return const_iterator(_start); }
 const_iterator cbegin() const { return const_iterator(_start); }
diff --git a/clang/test/Analysis/iterator-modeling.cpp 
b/clang/test/Analysis/iterator-modeling.cpp
index 78882da4431fd..a5be1666f1bed 100644
--- a/clang/test/Analysis/iterator-modeling.cpp
+++ b/clang/test/Analysis/iterator-modeling.cpp
@@ -482,6 +482,39 @@ void forward_list_assign(std::forward_list &FL, int 
n) {
   clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); 
//expected-warning{{FALSE}}
 }
 
+/// assign_range()
+///
+/// - Invalidates all iterators, including the pa

[clang] [flang] [flang/clang] Adding use of Clang's diagnostics in Flang (PR #130593)

2025-03-10 Thread Jean-Didier PAILLEUX via cfe-commits

https://github.com/JDPailleux converted_to_draft 
https://github.com/llvm/llvm-project/pull/130593
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix missing diagnostic of declaration use when accessing TypeDecls through typename access (PR #129681)

2025-03-10 Thread Hans Wennborg via cfe-commits

zmodem wrote:

We're seeing new -Wunguarded-availability warnings after this. A reduced 
example:

```
$ cat /tmp/x.cc
template struct remove_cv { typedef T type; };

struct __attribute__((__availability__(android, introduced = 29))) 
AAudioStreamWrapper { };

template  struct Foo {
  T *p;
};

template  struct Bar {
  typename remove_cv::type *p;
};


struct __attribute__((__availability__(android, introduced = 29))) User {
  AAudioStreamWrapper a; // okay
  Foo b; // okay

  Bar c; // not okay?
};

$ build/bin/clang -c -target aarch64-linux-android26 -Wunguarded-availability 
/tmp/x.cc
/tmp/x.cc:10:26: warning: 'AAudioStreamWrapper' is only available on Android 29 
or newer [-Wunguarded-availability]
   10 |   typename remove_cv::type *p;
  |  ^
/tmp/x.cc:18:28: note: in instantiation of template class 
'Bar' requested here
   18 |   Bar c; // not okay?
  |^
/tmp/x.cc:3:68: note: 'AAudioStreamWrapper' has been marked as being introduced 
in Android 29 here, but the deployment target is Android 26
3 | struct __attribute__((__availability__(android, introduced = 29))) 
AAudioStreamWrapper { };
  |^
/tmp/x.cc:9:30: note: annotate 'Bar' with an availability 
attribute to silence this warning
9 | template  struct Bar {
  |  ^
1 warning generated.
```

I believe the new warning is not correct, since `c` (like the other members) is 
in fact guarded by the availability attribute.

I'll revert to green for now until this can be investigated.

https://github.com/llvm/llvm-project/pull/129681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Forbid co_await and co_yield in invalid expr contexts (PR #130455)

2025-03-10 Thread via cfe-commits

NewSigma wrote:

Done

https://github.com/llvm/llvm-project/pull/130455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] AMDGPU: Implement bitcode autoupgrade for old style enqueue blocks (PR #128520)

2025-03-10 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited 
https://github.com/llvm/llvm-project/pull/128520
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] AMDGPU: Move enqueued block handling into clang (PR #128519)

2025-03-10 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm closed 
https://github.com/llvm/llvm-project/pull/128519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Implement instantiation context note for checking template parameters (PR #126088)

2025-03-10 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

Correction, I was thinking of a different PR.

I did not test this PR on compile-time-tracker, as we didn't anticipate an 
impact.

https://github.com/llvm/llvm-project/pull/126088
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-03-10 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify 
-fptrauth-intrinsics -std=c++11 %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify 
-fptrauth-intrinsics -std=c++11 %s
+
+template  struct G {
+  T __ptrauth(0,0,1234) test;
+  // expected-error@-1 2 {{type '__ptrauth(0,0,1234) T' is already 
__ptrauth-qualified}}
+};
+
+template  struct Indirect {
+  G layers;
+  // expected-note@-1{{in instantiation of template class 'G' requested here}}
+  // expected-note@-2{{in instantiation of template class 'G' requested here}}
+};
+
+void f3() {
+  Indirect one;
+  // expected-note@-1{{in instantiation of template class 'Indirect' requested here}}
+  Indirect two;
+  // expected-note@-1{{in instantiation of template class 'Indirect' requested here}}
+  Indirect three;
+}

AaronBallman wrote:

> and __ptrauth can't be used on function parameters.

See comments elsewhere, we either have a bug or a misunderstanding.

https://github.com/llvm/llvm-project/pull/100830
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-03-10 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,142 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11  -fptrauth-calls 
-fptrauth-intrinsics -verify -fsyntax-only %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11  -fptrauth-calls 
-fptrauth-intrinsics -verify -fsyntax-only %s
+
+#define AQ __ptrauth(1,1,50)
+#define AQ2 __ptrauth(1,1,51)
+#define IQ __ptrauth(1,0,50)
+
+struct __attribute__((trivial_abi)) AddrDisc { // expected-warning 
{{'trivial_abi' cannot be applied to 'AddrDisc'}} expected-note {{'trivial_abi' 
is disallowed on 'AddrDisc' because it has an address-discriminated '__ptrauth' 
field}}
+  int * AQ m0;
+};
+
+struct __attribute__((trivial_abi)) NoAddrDisc {
+  int * IQ m0;
+};
+
+namespace test_union {
+
+  union U0 {
+int * AQ f0; // expected-note 4 {{'U0' is implicitly deleted because 
variant field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+
+// ptrauth fields that don't have an address-discriminated qualifier don't
+// delete the special functions.
+int * IQ f1;
+  };
+
+  union U1 {
+int * AQ f0; // expected-note 8 {{'U1' is implicitly deleted because 
variant field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+U1() = default;
+~U1() = default;
+U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy 
constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted 
function was implicitly deleted here}} expected-note{{replace 'default'}}
+U1(U1 &&) = default; // expected-warning {{explicitly defaulted move 
constructor is implicitly deleted}} expected-note{{replace 'default'}}
+U1 & operator=(const U1 &) = default; // expected-warning {{explicitly 
defaulted copy assignment operator is implicitly deleted}} expected-note 2 
{{explicitly defaulted function was implicitly deleted here}} 
expected-note{{replace 'default'}}
+U1 & operator=(U1 &&) = default; // expected-warning {{explicitly 
defaulted move assignment operator is implicitly deleted}} 
expected-note{{replace 'default'}}
+  };
+
+  // It's fine if the user has explicitly defined the special functions.
+  union U2 {
+int * AQ f0;
+U2() = default;
+~U2() = default;
+U2(const U2 &);
+U2(U2 &&);
+U2 & operator=(const U2 &);
+U2 & operator=(U2 &&);
+  };
+
+  // Address-discriminated ptrauth fields in anonymous union fields delete the
+  // defaulted copy/move constructors/assignment operators of the containing
+  // class.
+  struct S0 {
+union {
+  int * AQ f0; // expected-note 4 {{' is implicitly deleted because 
variant field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+  char f1;
+};
+  };
+
+  struct S1 {
+union {
+  union {
+int * AQ f0; // expected-note 4 {{implicitly deleted because variant 
field 'f0' has an address-discriminated '__ptrauth' qualifier}}
+char f1;
+  } u; // expected-note 4 {{'S1' is implicitly deleted because field 'u' 
has a deleted}}
+  int f2;
+};
+  };
+
+  U0 *x0;
+  U1 *x1;
+  U2 *x2;
+  S0 *x3;
+  S1 *x4;
+
+  // No diagnostics since constructors/destructors of the unions aren't 
deleted by default.
+  void testDefaultConstructor() {
+U0 u0;
+U1 u1;
+U2 u2;
+S0 s0;
+S1 s1;
+  }
+
+  // No diagnostics since destructors of the unions aren't deleted by default.
+  void testDestructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+delete u0;
+delete u1;
+delete u2;
+delete s0;
+delete s1;
+  }
+
+  void testCopyConstructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+U0 t0(*u0); // expected-error {{call to implicitly-deleted copy 
constructor}}
+U1 t1(*u1); // expected-error {{call to implicitly-deleted copy 
constructor}}
+U2 t2(*u2);
+S0 t3(*s0); // expected-error {{call to implicitly-deleted copy 
constructor}}
+S1 t4(*s1); // expected-error {{call to implicitly-deleted copy 
constructor}}
+  }
+
+  void testCopyAssignment(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+*x0 = *u0; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+*x1 = *u1; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+*x2 = *u2;
+*x3 = *s0; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+*x4 = *s1; // expected-error {{cannot be assigned because its copy 
assignment operator is implicitly deleted}}
+  }
+
+  void testMoveConstructor(U0 *u0, U1 *u1, U2 *u2, S0 *s0, S1 *s1) {
+U0 t0(static_cast(*u0)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+U1 t1(static_cast(*u1)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+U2 t2(static_cast(*u2));
+S0 t3(static_cast(*s0)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+S1 t4(static_cast(*s1)); // expected-error {{call to 
implicitly-deleted copy constructor}}
+  }
+
+  void testMoveAssignme

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-03-10 Thread Aaron Ballman via cfe-commits


@@ -104,6 +104,7 @@ FEATURE(thread_sanitizer, 
LangOpts.Sanitize.has(SanitizerKind::Thread))
 FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
 FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
 FEATURE(ptrauth_intrinsics, LangOpts.PointerAuthIntrinsics)
+FEATURE(ptrauth_qualifier, LangOpts.PointerAuthIntrinsics)

AaronBallman wrote:

It does not, see the top of `Features.def`:
```
// FEATURE(...) should be used to advertise support for standard language
// features, whereas EXTENSION(...) should be used for clang extensions. Note
// that many of the identifiers in this file don't follow this rule for backward
// compatibility reasons.
```
Those backwards compatibility reasons are from a time when we only had one way 
to feature test macros. I think those internal projects should migrate to the 
correct usage instead of adding this as `FEATURE` for all uses moving forward.

https://github.com/llvm/llvm-project/pull/100830
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Forbid co_await and co_yield in invalid expr contexts (PR #130455)

2025-03-10 Thread via cfe-commits

https://github.com/NewSigma updated 
https://github.com/llvm/llvm-project/pull/130455

>From 85a40587375533ac8fcd842395c923895c5debaf Mon Sep 17 00:00:00 2001
From: NewSigma 
Date: Sun, 9 Mar 2025 10:27:24 +0800
Subject: [PATCH 1/3] Fobbid co_await in invalid expr context

---
 clang/lib/Sema/SemaCoroutine.cpp | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 0e4f3b20c78cd..53536b0d14037 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -788,7 +788,11 @@ static bool checkSuspensionContext(Sema &S, SourceLocation 
Loc,
   // First emphasis of [expr.await]p2: must be a potentially evaluated context.
   // That is, 'co_await' and 'co_yield' cannot appear in subexpressions of
   // \c sizeof.
-  if (S.isUnevaluatedContext()) {
+  const auto ExprContext = S.currentEvaluationContext().ExprContext;
+  const bool BadContext =
+  S.isUnevaluatedContext() ||
+  ExprContext != Sema::ExpressionEvaluationContextRecord::EK_Other;
+  if (BadContext) {
 S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
 return false;
   }
@@ -798,7 +802,6 @@ static bool checkSuspensionContext(Sema &S, SourceLocation 
Loc,
 S.Diag(Loc, diag::err_coroutine_within_handler) << Keyword;
 return false;
   }
-
   return true;
 }
 

>From eeb51f2775739390596b69a33eeae17ecf069148 Mon Sep 17 00:00:00 2001
From: NewSigma 
Date: Sun, 9 Mar 2025 19:35:16 +0800
Subject: [PATCH 2/3] Add test for unevaluate context

---
 .../{coroutine-decltype.cpp => coroutine-unevaluate.cpp}  | 8 
 1 file changed, 8 insertions(+)
 rename clang/test/SemaCXX/{coroutine-decltype.cpp => coroutine-unevaluate.cpp} 
(78%)

diff --git a/clang/test/SemaCXX/coroutine-decltype.cpp 
b/clang/test/SemaCXX/coroutine-unevaluate.cpp
similarity index 78%
rename from clang/test/SemaCXX/coroutine-decltype.cpp
rename to clang/test/SemaCXX/coroutine-unevaluate.cpp
index 7cbe6688d4155..164caed2836a1 100644
--- a/clang/test/SemaCXX/coroutine-decltype.cpp
+++ b/clang/test/SemaCXX/coroutine-unevaluate.cpp
@@ -32,3 +32,11 @@ MyTask DoAnotherthing() {
   static_assert(__is_same(void, decltype(co_yield 0))); // expected-error 
{{'co_yield' cannot be used in an unevaluated context}}
   co_return;
 }
+
+template
+struct Task {};
+
+void BracedInitListCXX26() {
+  []() -> Task<{ co_await 1 }> {}; // expected-error {{'co_await' cannot be 
used in an unevaluated context}}
+  []() -> Task<{ co_yield 1 }> {}; // expected-error {{'co_yield' cannot be 
used in an unevaluated context}}
+}

>From 5d124731e21ff4be9fa0a091c3e3e5a8b3d31782 Mon Sep 17 00:00:00 2001
From: NewSigma 
Date: Mon, 10 Mar 2025 19:20:20 +0800
Subject: [PATCH 3/3] Add release note for pr130455

---
 clang/docs/ReleaseNotes.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7859871b0493a..cd3f5344f2d9a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -294,6 +294,8 @@ Bug Fixes to C++ Support
   direct-list-initialized from an array is corrected to direct-initialization.
 - Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. 
(#GH127327)
 - Clang now uses the parameter location for abbreviated function templates in 
``extern "C"``. (#GH46386)
+- Clang will emit an error instead of crash when use co_await or co_yield in
+  C++26 braced-init-list template parameter initialization. (#GH78426)
 
 Improvements to C++ diagnostics
 ^^^

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


[clang] 28fa1fc - Revert "[clang] Fix missing diagnostic of declaration use when accessing TypeDecls through typename access (#129681)"

2025-03-10 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2025-03-10T14:02:04+01:00
New Revision: 28fa1fcf55b973e13018ac115fcbb357b4c0baad

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

LOG: Revert "[clang] Fix missing diagnostic of declaration use when accessing 
TypeDecls through typename access (#129681)"

This caused incorrect -Wunguarded-availability warnings. See comment on
the pull request.

> We were missing a call to DiagnoseUseOfDecl when performing typename
> access.
>
> This refactors the code so that TypeDecl lookups funnel through a helper
> which performs all the necessary checks, removing some related
> duplication on the way.
>
> Fixes #58547
>
> Differential Revision: https://reviews.llvm.org/D136533

This reverts commit 4c4fd6b03149348cf11af245ad2603d24144a9d5.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f8cb7ed34f041..7b254b371e5fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -35,9 +35,6 @@ Potentially Breaking Changes
 
 
 - The Objective-C ARC migrator (ARCMigrate) has been removed.
-- Fix missing diagnostics for uses of declarations when performing typename 
access,
-  such as when performing member access on a '[[deprecated]]' type alias.
-  (#GH58547)
 
 C/C++ Language Potentially Breaking Changes
 ---

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index fecc870945ac5..159c908a1b26c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3168,13 +3168,6 @@ class Sema final : public SemaBase {
 
   DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
 
-  enum class DiagCtorKind { None, Implicit, Typename };
-  /// Returns the TypeDeclType for the given type declaration,
-  /// as ASTContext::getTypeDeclType would, but
-  /// performs the required semantic checks for name lookup of said entity.
-  QualType getTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK,
-   TypeDecl *TD, SourceLocation NameLoc);
-
   /// If the identifier refers to a type name within this scope,
   /// return the declaration of that type.
   ///

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5ae3e58e4088d..9d102abb17c19 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -139,26 +139,6 @@ class TypeNameValidatorCCC final : public 
CorrectionCandidateCallback {
 
 } // end anonymous namespace
 
-QualType Sema::getTypeDeclType(DeclContext *LookupCtx, DiagCtorKind DCK,
-   TypeDecl *TD, SourceLocation NameLoc) {
-  auto *LookupRD = dyn_cast_or_null(LookupCtx);
-  auto *FoundRD = dyn_cast(TD);
-  if (DCK != DiagCtorKind::None && LookupRD && FoundRD &&
-  FoundRD->isInjectedClassName() &&
-  declaresSameEntity(LookupRD, cast(FoundRD->getParent( {
-Diag(NameLoc,
- DCK == DiagCtorKind::Typename
- ? diag::ext_out_of_line_qualified_id_type_names_constructor
- : diag::err_out_of_line_qualified_id_type_names_constructor)
-<< TD->getIdentifier() << /*Type=*/1
-<< 0 /*if any keyword was present, it was 'typename'*/;
-  }
-
-  DiagnoseUseOfDecl(TD, NameLoc);
-  MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
-  return Context.getTypeDeclType(TD);
-}
-
 namespace {
 enum class UnqualifiedTypeNameLookupResult {
   NotFound,
@@ -315,11 +295,10 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, 
SourceLocation NameLoc,
  bool IsClassTemplateDeductionContext,
  ImplicitTypenameContext AllowImplicitTypename,
  IdentifierInfo **CorrectedII) {
-  bool IsImplicitTypename = !isClassName && !IsCtorOrDtorName;
   // FIXME: Consider allowing this outside C++1z mode as an extension.
   bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
-  getLangOpts().CPlusPlus17 && IsImplicitTypename 
&&
-  !HasTrailingDot;
+  getLangOpts().CPlusPlus17 && !IsCtorOrDtorName &&
+  !isClassName && !HasTrailingDot;
 
   // Determine where we will perform name lookup.
   DeclContext *LookupCtx = nullptr;
@@ -343,9 +322,11 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, 
SourceLocation NameLoc,
 // refer to a member of an unknown specialization.
 // In C++2a, in several contexts a '

[clang] Reland: [clang] Implement evaluation context for checking template parameters (PR #130603)

2025-03-10 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

Keeping in draft form while I investigate the performance regression reported 
here: https://github.com/llvm/llvm-project/pull/126088#issuecomment-2704874202

https://github.com/llvm/llvm-project/pull/130603
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0d2c55c - AMDGPU: Move enqueued block handling into clang (#128519)

2025-03-10 Thread via cfe-commits

Author: Matt Arsenault
Date: 2025-03-10T19:54:04+07:00
New Revision: 0d2c55cb9682dc589949fb6767e50c4efb538f2d

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

LOG: AMDGPU: Move enqueued block handling into clang (#128519)

The previous implementation wasn't maintaining a faithful IR
representation of how this really works. The value returned by
createEnqueuedBlockKernel wasn't actually used as a function, and
hacked up later to be a pointer to the runtime handle global
variable. In reality, the enqueued block is a struct where the first
field is a pointer to the kernel descriptor, not the kernel itself. We
were also relying on passing around a reference to a global using a
string attribute containing its name. It's better to base this on a
proper IR symbol reference during final emission.

This now avoids using a function attribute on kernels and avoids using
the additional "runtime-handle" attribute to populate the final
metadata. Instead, associate the runtime handle reference to the
kernel with the !associated global metadata. We can then get a final,
correctly mangled name at the end.

I couldn't figure out how to get rename-with-external-symbol behavior
using a combination of comdats and aliases, so leaves an IR pass to
externalize the runtime handles for codegen. If anything breaks, it's
most likely this, so leave avoiding this for a later step. Use a
special section name to enable this behavior. This also means it's
possible to declare enqueuable kernels in source without going through
the dedicated block syntax or other dedicated compiler support.

We could move towards initializing the runtime handle in the
compiler/linker. I have a working patch where the linker sets up the
first field of the handle, avoiding the need to export the block
kernel symbol for the runtime. We would need new relocations to get
the private and group sizes, but that would avoid the runtime's
special case handling that requires the device_enqueue_symbol metadata
field.

https://reviews.llvm.org/D141700

Added: 
clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel-linking.cl
llvm/lib/Target/AMDGPU/AMDGPUExportKernelRuntimeHandles.cpp
llvm/lib/Target/AMDGPU/AMDGPUExportKernelRuntimeHandles.h
llvm/test/CodeGen/AMDGPU/amdgpu-export-kernel-runtime-handles.ll

Modified: 
clang/lib/CodeGen/Targets/AMDGPU.cpp
clang/test/CMakeLists.txt
clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl
llvm/docs/AMDGPUUsage.rst
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.h
llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/AMDGPU/CMakeLists.txt
llvm/test/CodeGen/AMDGPU/hsa-metadata-from-llvm-ir-full.ll
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll

Removed: 
llvm/lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUOpenCLEnqueuedBlockLowering.h
llvm/test/CodeGen/AMDGPU/enqueue-kernel.ll



diff  --git a/clang/lib/CodeGen/Targets/AMDGPU.cpp 
b/clang/lib/CodeGen/Targets/AMDGPU.cpp
index 9d29f31c77881..7d84310ba0bf5 100644
--- a/clang/lib/CodeGen/Targets/AMDGPU.cpp
+++ b/clang/lib/CodeGen/Targets/AMDGPU.cpp
@@ -614,6 +614,20 @@ void 
AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention(
   FT, FT->getExtInfo().withCallingConv(CC_OpenCLKernel));
 }
 
+/// Return IR struct type for rtinfo struct in rocm-device-libs used for device
+/// enqueue.
+///
+/// ptr addrspace(1) kernel_object, i32 private_segment_size,
+/// i32 group_segment_size
+
+static llvm::StructType *
+getAMDGPURuntimeHandleType(llvm::LLVMContext &C,
+   llvm::Type *KernelDescriptorPtrTy) {
+  llvm::Type *Int32 = llvm::Type::getInt32Ty(C);
+  return llvm::StructType::create(C, {KernelDescriptorPtrTy, Int32, Int32},
+  "block.runtime.handle.t");
+}
+
 /// Create an OpenCL kernel for an enqueued block.
 ///
 /// The type of the first argument (the block literal) is the struct type
@@ -653,23 +667,29 @@ llvm::Value 
*AMDGPUTargetCodeGenInfo::createEnqueuedBlockKernel(
 ArgNames.push_back(
 llvm::MDString::get(C, (Twine("local_arg") + Twine(I)).str()));
   }
-  std::string Name = Invoke->getName().str() + "_kernel";
+
+  llvm::Module &Mod = CGF.CGM.getModule();
+  const llvm::DataLayout &DL = Mod.getDataLayout();
+
+  llvm::Twine Name = Invoke->getName() + "_kernel";
   auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(C), ArgTys, false);
+
+  // The kernel itself can be internal, the runtime does not directly access 
the
+  // kernel address (only the kernel descriptor).
   auto *F = llvm::Function::Create(FT, llvm::GlobalValue::InternalLinkage, 
Name,

[clang] [llvm] [analysis] Software Bill of Mitigations (PR #130103)

2025-03-10 Thread Matthew Levy via cfe-commits

https://github.com/matthewlevy97 updated 
https://github.com/llvm/llvm-project/pull/130103

>From fb04b7bf5f2b668bf354632fc53e7521f44880c9 Mon Sep 17 00:00:00 2001
From: Matt Levy 
Date: Wed, 5 Mar 2025 12:36:02 -0500
Subject: [PATCH 1/3] [clang][CodeGen] Software Bill of Mitigations Metadata

The goal of this stack is to create a high fidelity mapping of mitigations to 
their possible insertion points and their actual insertion points. This would 
let us track where we do and don't have mitigations rather than the current 
approach of tracking where we have the flag.

There are some challenges posed by this like:
- Some mitigations are not emitted by the compiler, but the preprocessor
- Some mitigations are lowered later during IR -> MIR (stack cookies)
---
 clang/include/clang/Basic/CodeGenOptions.def |  1 +
 clang/include/clang/Driver/Options.td|  6 ++
 clang/lib/CodeGen/CGBuiltin.cpp  | 10 +++
 clang/lib/CodeGen/CGClass.cpp|  3 +
 clang/lib/CodeGen/CGDecl.cpp |  4 +
 clang/lib/CodeGen/CGExpr.cpp |  5 ++
 clang/lib/CodeGen/CGExprCXX.cpp  |  6 ++
 clang/lib/CodeGen/CMakeLists.txt |  1 +
 clang/lib/CodeGen/CodeGenModule.cpp  | 22 +
 clang/lib/CodeGen/MitigationTagging.cpp  | 84 
 clang/lib/CodeGen/MitigationTagging.h| 45 +++
 clang/lib/Driver/ToolChains/Clang.cpp|  3 +
 12 files changed, 190 insertions(+)
 create mode 100644 clang/lib/CodeGen/MitigationTagging.cpp
 create mode 100644 clang/lib/CodeGen/MitigationTagging.h

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index a7f5f1abbb825..76a46ac3e592b 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -191,6 +191,7 @@ CODEGENOPT(NoTypeCheck   , 1, 0) ///< Set when 
-Wa,--no-type-check is enable
 CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is enabled
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
 CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
+CODEGENOPT(MitigationAnalysis, 1, 0) ///< Set when -fmitigation-analysis is 
enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
 CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0) ///< 
-cl-fp32-correctly-rounded-divide-sqrt
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d0414aba35209..e50bb5c1c2cb4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3891,6 +3891,12 @@ defm split_stack : BoolFOption<"split-stack",
   CodeGenOpts<"EnableSegmentedStacks">, DefaultFalse,
   NegFlag,
   PosFlag>;
+defm mitigation_analysis : BoolFOption<"mitigation-analysis",
+  CodeGenOpts<"MitigationAnalysis">, DefaultFalse,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], [ClangOption], " mitigation analysis">>,
+  DocBrief<"Instrument mitigations (CFI, Stack Protectors, Auto-Var-Init, 
StackClashProtection) to analyze their coverage">;
 def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group,
   HelpText<"Enable stack protectors for all functions">;
 defm stack_clash_protection : BoolFOption<"stack-clash-protection",
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ab8f19b25fa66..4e180bb1a87cf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -21,6 +21,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "MitigationTagging.h"
 #include "PatternInit.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
@@ -83,6 +84,8 @@ static void initializeAlloca(CodeGenFunction &CGF, AllocaInst 
*AI, Value *Size,
   switch (CGF.getLangOpts().getTrivialAutoVarInit()) {
   case LangOptions::TrivialAutoVarInitKind::Uninitialized:
 // Nothing to initialize.
+AttachMitigationMetadataToFunction(CGF, MitigationKey::AUTO_VAR_INIT,
+   false);
 return;
   case LangOptions::TrivialAutoVarInitKind::Zero:
 Byte = CGF.Builder.getInt8(0x00);
@@ -94,6 +97,7 @@ static void initializeAlloca(CodeGenFunction &CGF, AllocaInst 
*AI, Value *Size,
 break;
   }
   }
+  AttachMitigationMetadataToFunction(CGF, MitigationKey::AUTO_VAR_INIT, true);
   if (CGF.CGM.stopAutoInit())
 return;
   auto *I = CGF.Builder.CreateMemSet(AI, Byte, Size, AlignmentInBytes);
@@ -4642,6 +4646,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 AI->setAlignment(SuitableAlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_uninitialized)
   initializeAlloca(*this, AI, Size, SuitableAlignmentInBytes);
+else
+  AttachMitigationMetadataToFunction(*t

[clang] [llvm] [OpenMP] Remove 'libomptarget.devicertl.a' fatbinary and use static library (PR #126143)

2025-03-10 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/126143

>From 952c2b4a49eb2d8e2ffa00dd94032d37b0d4302b Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Thu, 6 Feb 2025 15:54:19 -0600
Subject: [PATCH] [OpenMP] Remove 'libomptarget.devicertl.a' fatbinary and use
 static library

Summary:
Currently, we build a single `libomptarget.devicertl.a` which is a
fatbinary. It is a host object file that contains the embedded archive
files for both the NVIDIA and AMDGPU targets. This was done primarily as
a convenience due to naming conflicts. Now that the clang driver for the
GPU targets can appropriate link via the per-target runtime-dir, we can
just make two separate static libraries and remove the indirection.

This patch creates two new static libraries that get installed into
```
/lib/amdgcn-amd-amdhsa/libomp.a
/lib/nvptx64-nvidia-cuda/libomp.a
```
for AMDGPU and NVPTX respectively. The link job created by the linker
wrapper now simply needs to do `-lomp` and it will search those
directories and link those static libraries. This requires far less
special handling.

This patch is a precursor to changing the build system entirely to be a
runtimes based one. Soon this target will be a standard `add_library`
and done through the GPU runtime targets.

NOTE that this actually does remove an additional optimization step.
Previously we merged all of the files into a single bitcode object and
forcibly internalized some definitions. This, instead, just treats them
like a normal static library. This may possibly affect performance for
some files, but I think it's better overall to use static library
semantics because it allows us to have an 'include-what-you-use'
relationship with the library.

Performance testing will be required. If we really need the merged blob
then we can simply pack that into a new static library.

omp -> omptarget
---
 clang/lib/Driver/ToolChains/Clang.cpp  |   5 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp |   4 -
 clang/test/Driver/openmp-offload-gpu.c |   6 +-
 offload/DeviceRTL/CMakeLists.txt   | 158 +
 offload/DeviceRTL/src/exports  |  19 ---
 offload/test/lit.cfg   |  36 ++---
 6 files changed, 65 insertions(+), 163 deletions(-)
 delete mode 100644 offload/DeviceRTL/src/exports

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4ebbd241d2f0b..ee582608e999e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9258,6 +9258,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
   A->render(Args, LinkerArgs);
   }
 
+  // If this is OpenMP the device linker will need `-lompdevice`.
+  if (Kind == Action::OFK_OpenMP && !Args.hasArg(OPT_no_offloadlib) &&
+  (TC->getTriple().isAMDGPU() || TC->getTriple().isNVPTX()))
+LinkerArgs.emplace_back("-lompdevice");
+
   // Forward all of these to the appropriate toolchain.
   for (StringRef Arg : CompilerArgs)
 CmdArgs.push_back(Args.MakeArgString(
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b43472a52038b..2e23f9e3f7397 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1296,10 +1296,6 @@ bool tools::addOpenMPRuntime(const Compilation &C, 
ArgStringList &CmdArgs,
   if (IsOffloadingHost)
 CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost &&
-  Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true))
-CmdArgs.push_back("-lomptarget.devicertl");
-
   addArchSpecificRPath(TC, Args, CmdArgs);
 
   addOpenMPRuntimeLibraryPath(TC, Args, CmdArgs);
diff --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index 1f7e2996068c4..807ea2c6e5f86 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -324,18 +324,18 @@
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
 // RUN: -foffload-lto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBRARY 
%s
 
-// CHECK-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+// CHECK-LTO-LIBRARY: --device-linker={{.*}}=-lomp{{.*}}-lomptarget{{.*}}
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
 // RUN: 
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc 
%s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-LTO-LIBRARY %s
 
-// CHECK-NO-LTO-LIBRARY: {{.*}}-lomptarget{{.*}}-lomptarget.devicertl
+// CHECK-NO-LTO-LIBRARY: --device-linker={{.*}}=-lomp{{.*}}-lomptarget{{.*}}
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
--offload-arch=sm_52 -nogpulib \
 // RUN: -foffload-lto %s

[clang] [llvm] [analysis] Software Bill of Mitigations (PR #130103)

2025-03-10 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 15edf8725a8044e5cb681a5773e0ada1249690cb 
f0baa6fe14e67f53291ef6423ef6ea67903031ab --extensions cpp,h -- 
clang/lib/CodeGen/MitigationTagging.cpp clang/lib/CodeGen/MitigationTagging.h 
clang/unittests/CodeGen/MitigationTaggingTest.cpp 
llvm/include/llvm/Analysis/MitigationAnalysis.h 
llvm/lib/Analysis/MitigationAnalysis.cpp clang/lib/CodeGen/CGBuiltin.cpp 
clang/lib/CodeGen/CGClass.cpp clang/lib/CodeGen/CGDecl.cpp 
clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGExprCXX.cpp 
clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/Clang.cpp 
llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/PassBuilderPipelines.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/MitigationTagging.cpp 
b/clang/lib/CodeGen/MitigationTagging.cpp
index 82a56ac87e..2f6f4c4a0d 100644
--- a/clang/lib/CodeGen/MitigationTagging.cpp
+++ b/clang/lib/CodeGen/MitigationTagging.cpp
@@ -77,15 +77,15 @@ void AttachMitigationMetadataToFunction(llvm::Function &F,
 llvm::MDNode *CombinedMD = llvm::MDNode::get(Context, MDs);
 F.setMetadata(kindID, CombinedMD);
   } else {
-F.setMetadata(kindID,
-  llvm::MDNode::get(Context, std::vector {NewMD}));
+F.setMetadata(kindID, llvm::MDNode::get(
+  Context, std::vector{NewMD}));
   }
 }
 
 void AttachMitigationMetadataToFunction(CodeGenFunction &CGF,
 enum MitigationKey key, bool enabled) {
-  AttachMitigationMetadataToFunction(*(CGF.CurFn), key, enabled,
-CGF.CGM.getCodeGenOpts().MitigationAnalysis);
+  AttachMitigationMetadataToFunction(
+  *(CGF.CurFn), key, enabled, CGF.CGM.getCodeGenOpts().MitigationAnalysis);
 }
 
 } // namespace CodeGen
diff --git a/clang/unittests/CodeGen/MitigationTaggingTest.cpp 
b/clang/unittests/CodeGen/MitigationTaggingTest.cpp
index 1e31b00c4e..7325cc0d64 100644
--- a/clang/unittests/CodeGen/MitigationTaggingTest.cpp
+++ b/clang/unittests/CodeGen/MitigationTaggingTest.cpp
@@ -20,13 +20,12 @@ using namespace clang;
 namespace {
 
 TEST(MitigationTaggingTest, FlagDisabled) {
-  const char TestProgram[] =
-"void HasStackProtector(int x, int y) "
-"{"
-"   char buf[x];  "
-"   while(y)  "
-"  buf[y--] = 0;  "
-"}";
+  const char TestProgram[] = "void HasStackProtector(int x, int y) "
+ "{"
+ "   char buf[x];  "
+ "   while(y)  "
+ "  buf[y--] = 0;  "
+ "}";
 
   clang::LangOptions LO;
   LO.CPlusPlus = 1;
@@ -39,7 +38,8 @@ TEST(MitigationTaggingTest, FlagDisabled) {
 
   clang::ParseAST(Compiler.compiler.getSema(), false, false);
   auto M =
-
static_cast(Compiler.compiler.getASTConsumer()).GetModule();
+  static_cast(Compiler.compiler.getASTConsumer())
+  .GetModule();
   auto FuncPtr = M->begin();
 
   auto *MD = FuncPtr->getMetadata("security_mitigations");
@@ -47,13 +47,12 @@ TEST(MitigationTaggingTest, FlagDisabled) {
 }
 
 TEST(MitigationTaggingTest, MetadataEnabledOnly) {
-  const char TestProgram[] =
-"void HasStackProtector(int x, int y) "
-"{"
-"   char buf[x];  "
-"   while(y)  "
-"  buf[y--] = 0;  "
-"}";
+  const char TestProgram[] = "void HasStackProtector(int x, int y) "
+ "{"
+ "   char buf[x];  "
+ "   while(y)  "
+ "  buf[y--] = 0;  "
+ "}";
 
   clang::CodeGenOptions CGO;
   CGO.MitigationAnalysis = true;
@@ -67,7 +66,8 @@ TEST(MitigationTaggingTest, MetadataEnabledOnly) {
 
   clang::ParseAST(Compiler.compiler.getSema(), false, false);
   auto M =
-
static_cast(Compiler.compiler.getASTConsumer()).GetModule();
+  static_cast(Compiler.compiler.getASTConsumer())
+  .GetModule();
   auto FuncPtr = M->begin();
 
   auto *MD = FuncPtr->getMetadata("security_mitigations");
@@ -76,7 +76,8 @@ TEST(MitigationTaggingTest, MetadataEnabledOnly) {
   // Get All Enabled Mitigations
   std::unordered_map MDs;
   for (unsigned i = 0, n = MD->getNumOperands(); i != n; ++i) {
-if (MD->getOperand(i) == nullptr) continue;

[clang] [clang] NNS: don't print trailing scope resolution operator in diagnostics (PR #130529)

2025-03-10 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov closed 
https://github.com/llvm/llvm-project/pull/130529
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Implement P0963R3 "Structured binding declaration as a condition" (PR #130228)

2025-03-10 Thread via cfe-commits

cor3ntin wrote:

Hum, do we want to add tests for 
https://cplusplus.github.io/CWG/issues/2867.html at the same time?

https://github.com/llvm/llvm-project/pull/130228
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [analysis] Software Bill of Mitigations (PR #130103)

2025-03-10 Thread Matthew Levy via cfe-commits

https://github.com/matthewlevy97 edited 
https://github.com/llvm/llvm-project/pull/130103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Implement the `fmod` intrinsic (PR #130320)

2025-03-10 Thread Farzon Lotfi via cfe-commits


@@ -22,56 +22,136 @@
 //
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
-// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
+// RUN:   -emit-llvm -o - | FileCheck %s \
 // RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTYPE=half
 
 //
 // -- No Native Half support test ---
 //
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
+// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm \
 // RUN:   -o - | FileCheck %s \
 // RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTYPE=float
 
 
 
+// DXCHECK: define [[FNATTRS]] [[TYPE]] @
+// DXCHECK: %div1.i = fdiv reassoc nnan ninf nsz arcp afn [[TYPE]] %4, %5
+// DXCHECK: %fneg.i = fneg reassoc nnan ninf nsz arcp afn [[TYPE]] %7
+// DXCHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn oge [[TYPE]] %6, 
%fneg.i
+// DXCHECK: %elt.abs.i = call reassoc nnan ninf nsz arcp afn [[TYPE]] 
@llvm.fabs.[[INT_TYPE]]([[TYPE]] %8)
+// DXCHECK: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn [[TYPE]] 
@llvm.dx.frac.[[INT_TYPE]]([[TYPE]] %elt.abs.i)
+// DXCHECK: %fneg2.i = fneg reassoc nnan ninf nsz arcp afn [[TYPE]] %11
+// DXCHECK: %hlsl.select.i = select reassoc nnan ninf nsz arcp afn i1 
%loadedv.i, [[TYPE]] %10, [[TYPE]] %fneg2.i
+// DXCHECK: %mul.i = fmul reassoc nnan ninf nsz arcp afn [[TYPE]] 
%hlsl.select.i, %12
+// DXCHECK: ret [[TYPE]] %mul.i

farzonl wrote:

As to the `%4, %5, %6, %7` @Icohedron. I'd be fine  just wild carding them out 
if you are happy with that. they point to allocas and other nonsense not 
relevant to the fmod algorithm. If they didn't map back to the inputs in the 
function arguments we would have bigger problems. the type check @kmpeng is 
doing seems good enough to me.

https://github.com/llvm/llvm-project/pull/130320
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add builtins for `add` with `nuw` and/or `nsw` (PR #130354)

2025-03-10 Thread via cfe-commits

macurtis-amd wrote:

> I'm not sure what the motivation is here

We are trying to resolve a specific optimization problem where code like 
[this](https://github.com/llvm/llvm-project/blob/5757da1480691eb6e452c0aaa6036d03c1660817/offload/DeviceRTL/src/Workshare.cpp#L717)
 trips up ScalarEvolution because it thinks the add might wrap, even though we 
have knowledge that it will not.

> Needs RFC

Does the above change your thoughts on this? I think this is solving a very 
different problem, is much more surgical in nature, and could coexist with such 
a feature without confusion/harm.



https://github.com/llvm/llvm-project/pull/130354
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-03-10 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify 
-fptrauth-intrinsics -std=c++11 %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify 
-fptrauth-intrinsics -std=c++11 %s
+
+template  struct G {
+  T __ptrauth(0,0,1234) test;
+  // expected-error@-1 2 {{type '__ptrauth(0,0,1234) T' is already 
__ptrauth-qualified}}
+};
+
+template  struct Indirect {
+  G layers;
+  // expected-note@-1{{in instantiation of template class 'G' requested here}}
+  // expected-note@-2{{in instantiation of template class 'G' requested here}}
+};
+
+void f3() {
+  Indirect one;
+  // expected-note@-1{{in instantiation of template class 'Indirect' requested here}}
+  Indirect two;
+  // expected-note@-1{{in instantiation of template class 'Indirect' requested here}}
+  Indirect three;
+}

AaronBallman wrote:

> > > and __ptrauth can't be used on function parameters.
> > 
> > 
> > See comments elsewhere, we either have a bug or a misunderstanding.
> 
> Sorry, I meant the `__ptrauth` qualifiers currently cannot be used as a 
> top-level qualifier of function parameters.
> 
> ```
> int func1(void * __ptrauth(1, 0, 100) ptr); // error: parameter types may not 
> be qualified with __ptrauth; type is 'void *__ptrauth(1,0,100)'
> int func2(void * __ptrauth(1, 0, 100) * ptr); // OK
> ```

Ah, thanks! Then we can test the behavior of overloading.

https://github.com/llvm/llvm-project/pull/100830
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add partial-inlining options (PR #129024)

2025-03-10 Thread Jan Svoboda via cfe-commits


@@ -3394,6 +3394,10 @@ def fno_inline_functions : Flag<["-"], 
"fno-inline-functions">, Group;
 def fno_inline : Flag<["-"], "fno-inline">, Group,
   Visibility<[ClangOption, CC1Option]>;
+def fpartial_inlining : Flag<["-"], "fpartial-inlining">, Group,

jansvoboda11 wrote:

The `BoolFOption` infrastructure maps frontend arguments onto 
`CompilerInvocation`. The intent of this PR seems to be to add driver arguments 
that map to the `-mllvm` frontend argument (which already does map to 
`CompilerInvocation`). I think these should not be `CC1Option`, otherwise LGTM.

https://github.com/llvm/llvm-project/pull/129024
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Implement the `fmod` intrinsic (PR #130320)

2025-03-10 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl edited 
https://github.com/llvm/llvm-project/pull/130320
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Support] Return `LockFileManager` errors right away (PR #130627)

2025-03-10 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/130627

>From 88b5bbd1303480dc40db3ea76d0f831a69ff1957 Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Sat, 8 Mar 2025 21:51:51 -0800
Subject: [PATCH 1/5] [Support] Return `LockFileManager` errors right away

---
 clang/lib/Frontend/CompilerInstance.cpp   | 23 +++--
 clang/lib/Serialization/GlobalModuleIndex.cpp | 17 ++--
 llvm/include/llvm/Support/LockFileManager.h   | 33 +--
 llvm/lib/Support/LockFileManager.cpp  | 91 ++-
 llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp  | 20 ++--
 5 files changed, 59 insertions(+), 125 deletions(-)

diff --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index c11c857ea0606..fe351e6b41342 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1477,29 +1477,28 @@ static bool compileModuleAndReadASTBehindLock(
   llvm::sys::fs::create_directories(Dir);
 
   while (true) {
-llvm::LockFileManager Locked(ModuleFileName);
-switch (Locked) {
-case llvm::LockFileManager::LFS_Error:
+llvm::LockFileManager Lock(ModuleFileName);
+bool Owned;
+if (llvm::Error Err = Lock.tryLock().moveInto(Owned)) {
   // ModuleCache takes care of correctness and locks are only necessary for
   // performance. Fallback to building the module in case of any lock
   // related errors.
   Diags.Report(ModuleNameLoc, diag::remark_module_lock_failure)
-  << Module->Name << Locked.getErrorMessage();
+  << Module->Name << toString(std::move(Err));
   // Clear out any potential leftover.
-  Locked.unsafeRemoveLockFile();
-  [[fallthrough]];
-case llvm::LockFileManager::LFS_Owned:
+  Lock.unsafeRemoveLockFile();
+  return compileModuleAndReadASTImpl(ImportingInstance, ImportLoc,
+ModuleNameLoc, Module, ModuleFileName);
+}
+if (Owned) {
   // We're responsible for building the module ourselves.
   return compileModuleAndReadASTImpl(ImportingInstance, ImportLoc,
  ModuleNameLoc, Module, 
ModuleFileName);
-
-case llvm::LockFileManager::LFS_Shared:
-  break; // The interesting case.
 }
 
 // Someone else is responsible for building the module. Wait for them to
 // finish.
-switch (Locked.waitForUnlock()) {
+switch (Lock.waitForUnlock()) {
 case llvm::LockFileManager::Res_Success:
   break; // The interesting case.
 case llvm::LockFileManager::Res_OwnerDied:
@@ -1511,7 +1510,7 @@ static bool compileModuleAndReadASTBehindLock(
   Diags.Report(ModuleNameLoc, diag::remark_module_lock_timeout)
   << Module->Name;
   // Clear the lock file so that future invocations can make progress.
-  Locked.unsafeRemoveLockFile();
+  Lock.unsafeRemoveLockFile();
   continue;
 }
 
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index 4b920fccecac3..1e2272c48bd04 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -849,22 +849,21 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr,
 
   // Coordinate building the global index file with other processes that might
   // try to do the same.
-  llvm::LockFileManager Locked(IndexPath);
-  switch (Locked) {
-  case llvm::LockFileManager::LFS_Error:
+  llvm::LockFileManager Lock(IndexPath);
+  bool Owned;
+  if (llvm::Error Err = Lock.tryLock().moveInto(Owned)) {
+llvm::consumeError(std::move(Err));
 return llvm::createStringError(std::errc::io_error, "LFS error");
-
-  case llvm::LockFileManager::LFS_Owned:
-// We're responsible for building the index ourselves. Do so below.
-break;
-
-  case llvm::LockFileManager::LFS_Shared:
+  }
+  if (!Owned) {
 // Someone else is responsible for building the index. We don't care
 // when they finish, so we're done.
 return llvm::createStringError(std::errc::device_or_resource_busy,
"someone else is building the index");
   }
 
+  // We're responsible for building the index ourselves.
+
   // The module index builder.
   GlobalModuleIndexBuilder Builder(FileMgr, PCHContainerRdr);
 
diff --git a/llvm/include/llvm/Support/LockFileManager.h 
b/llvm/include/llvm/Support/LockFileManager.h
index 92c7ceed6a929..e687f3b1dfa53 100644
--- a/llvm/include/llvm/Support/LockFileManager.h
+++ b/llvm/include/llvm/Support/LockFileManager.h
@@ -9,6 +9,7 @@
 #define LLVM_SUPPORT_LOCKFILEMANAGER_H
 
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Error.h"
 #include 
 #include 
 #include  // for std::pair
@@ -26,19 +27,6 @@ class StringRef;
 /// operation.
 class LockFileManager {
 public:
-  /// Describes the state of a lock file.
-  enum LockFileState {
-/// The lock file has been created and is owned by this instance
-/// o

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `llvm` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/186/builds/7204


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[341/5429] Building CXX object 
third-party/benchmark/src/CMakeFiles/benchmark.dir/statistics.cc.o
[342/5429] Building CXX object 
third-party/benchmark/src/CMakeFiles/benchmark.dir/string_util.cc.o
[343/5429] Building CXX object 
third-party/benchmark/src/CMakeFiles/benchmark.dir/sysinfo.cc.o
[344/5429] Building CXX object 
third-party/benchmark/src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o
[345/5429] Building CXX object 
third-party/benchmark/src/CMakeFiles/benchmark.dir/timers.cc.o
[346/5429] Linking CXX static library lib/libbenchmark.a
[347/5429] Linking CXX static library lib/libbenchmark_main.a
[348/5429] Linking CXX shared module 
unittests/Support/DynamicLibrary/SecondLib.so
[349/5429] Linking CXX shared module 
unittests/Support/DynamicLibrary/PipSqueak.so
[350/5429] Building CXX object 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/lib/Support
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Werror=global-constructors -O3 -DNDEBUG 
-std=c++17 -UNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -c 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp:278:27:
 error: moving a temporary object prevents copy elision 
[-Werror,-Wpessimizing-move]
  278 | NextToken.TokenBody = std::move(NextTokenBody.substr(2).str());
  |   ^
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp:278:27:
 note: remove std::move call here
  278 | NextToken.TokenBody = std::move(NextTokenBody.substr(2).str());
  |   ^~ ~
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp:280:27:
 error: moving a temporary object prevents copy elision 
[-Werror,-Wpessimizing-move]
  280 | NextToken.TokenBody = std::move(NextTokenBody.substr(1).str());
  |   ^
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp:280:27:
 note: remove std::move call here
  280 | NextToken.TokenBody = std::move(NextTokenBody.substr(1).str());
  |   ^~ ~
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp:298:27:
 error: moving a temporary object prevents copy elision 
[-Werror,-Wpessimizing-move]
  298 | PrevToken.TokenBody = std::move(Unindented.str());
  |   ^
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/lib/Support/Mustache.cpp:298:27:
 note: remove std::move call here
  298 | PrevToken.TokenBody = std::move(Unindented.str());
  |   ^~~
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-androi

[clang] [clang-format] Add support for absl nullability macros (PR #130346)

2025-03-10 Thread Jan Voung via cfe-commits

jvoung wrote:

> I wish they had not been added to the default but can't take them off the 
> lists for backward compatibility. I don't think we should add more. The 
> reason is that people wouldn't be able to turn off the special meaning if 
> they wanted to use e.g. `absl_nonnull` as a regular identifier.

What if this is limited to the Google style? +cc some folks involved in the 
Google style @ilya-biryukov 
It is not yet in the style guide, but we are working on getting the style guide 
updated.

The chance of using `absl_nonnull` as a regular identifier at the same time as 
using the Google style is likely lower.

> Can you log an issue for `std::vector y;`? It's a bug IMO 
> and can be easily fixed.

filed https://github.com/llvm/llvm-project/issues/130602 but I think there are 
still cases it wouldn't cover, right? (like `ContainerWithSize fixed_array;`)

> Abseil itself doesn't even define them in their .clang-format file.

We're working toward getting it in the google style guide, so it will be 
covered by `BasedOnStyle:  Google` (which is the main thing in the Abseil 
.clang-format file), so that folks don't need to specify this individually (and 
less risk of forgetting to set it and diverging from the style).


https://github.com/llvm/llvm-project/pull/130346
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Implement the `fmod` intrinsic (PR #130320)

2025-03-10 Thread Farzon Lotfi via cfe-commits


@@ -22,56 +22,136 @@
 //
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
-// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTYPE=half
+// RUN:   -emit-llvm -o - | FileCheck %s \
+// RUN:   -DTYPE=half --check-prefixes=CHECK,SPVCHECK
 
 //
 // -- No Native Half support test ---
 //
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
+// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm \
 // RUN:   -o - | FileCheck %s \
-// RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTYPE=float
+// RUN:   -DTYPE=float --check-prefixes=CHECK,SPVCHECK
 
 
 
-// CHECK: define [[FNATTRS]] [[TYPE]] @
-// CHECK: %fmod = frem reassoc nnan ninf nsz arcp afn [[TYPE]]
-// CHECK: ret [[TYPE]] %fmod
+// CHECK-LABEL: test_fmod_half
+// DXCHECK: %div1.i = fdiv reassoc nnan ninf nsz arcp afn [[TYPE]] [[X:%.*]], 
[[Y:%.*]]
+// DXCHECK: %fneg.i = fneg reassoc nnan ninf nsz arcp afn [[TYPE]] 
[[DIV1_I:%.*]]
+// DXCHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn oge [[TYPE]] 
[[DIV1_I_2:%.*]], %fneg.i
+// DXNATIVE_HALF: %elt.abs.i = call reassoc nnan ninf nsz arcp afn [[TYPE]] 
@llvm.fabs.f16([[TYPE]] [[DIV1_I_3:%.*]])
+// DXNO_HALF: %elt.abs.i = call reassoc nnan ninf nsz arcp afn [[TYPE]] 
@llvm.fabs.f32([[TYPE]] [[DIV1_I_3:%.*]])
+// DXNATIVE_HALF: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn [[TYPE]] 
@llvm.dx.frac.f16([[TYPE]] %elt.abs.i)
+// DXNO_HALF: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn [[TYPE]] 
@llvm.dx.frac.f32([[TYPE]] %elt.abs.i)
+// DXCHECK: %fneg2.i = fneg reassoc nnan ninf nsz arcp afn [[TYPE]] 
[[HLSL_FRAC_I:%.*]]
+// DXCHECK: %hlsl.select.i = select reassoc nnan ninf nsz arcp afn i1 
[[CMP_I:%.*]], [[TYPE]] [[HLSL_FRAC_I_2:%.*]], [[TYPE]] %fneg2.i
+// DXCHECK: %mul.i = fmul reassoc nnan ninf nsz arcp afn [[TYPE]] 
%hlsl.select.i, [[Y_2:%.*]]
+// DXCHECK: ret [[TYPE]] %mul.i
+// SPVCHECK: %fmod.i = frem reassoc nnan ninf nsz arcp afn [[TYPE]] [[X:%.*]], 
[[Y:%.*]]
+// SPVCHECK: ret [[TYPE]] %fmod.i
 half test_fmod_half(half p0, half p1) { return fmod(p0, p1); }
 
-// CHECK: define [[FNATTRS]] <2 x [[TYPE]]> @
-// CHECK: %fmod = frem reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]>
-// CHECK: ret <2 x [[TYPE]]> %fmod
+// CHECK-LABEL: test_fmod_half2
+// DXCHECK: %div1.i = fdiv reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]> 
[[X:%.*]], [[Y:%.*]]
+// DXCHECK: %fneg.i = fneg reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]> 
[[DIV1_I:%.*]]
+// DXCHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn oge <2 x [[TYPE]]> 
[[DIV1_I_2:%.*]], %fneg.i
+// DXNATIVE_HALF: %elt.abs.i = call reassoc nnan ninf nsz arcp afn <2 x 
[[TYPE]]> @llvm.fabs.v2f16(<2 x [[TYPE]]> [[DIV1_I_3:%.*]])
+// DXNO_HALF: %elt.abs.i = call reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]> 
@llvm.fabs.v2f32(<2 x [[TYPE]]> [[DIV1_I_3:%.*]])
+// DXNATIVE_HALF: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn <2 x 
[[TYPE]]> @llvm.dx.frac.v2f16(<2 x [[TYPE]]> %elt.abs.i)
+// DXNO_HALF: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn <2 x 
[[TYPE]]> @llvm.dx.frac.v2f32(<2 x [[TYPE]]> %elt.abs.i)
+// DXCHECK: %fneg2.i = fneg reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]> 
[[HLSL_FRAC_I:%.*]]
+// DXCHECK: %hlsl.select.i = select reassoc nnan ninf nsz arcp afn <2 x i1> 
[[CMP_I:%.*]], <2 x [[TYPE]]> [[HLSL_FRAC_I_2:%.*]], <2 x [[TYPE]]> %fneg2.i
+// DXCHECK: %mul.i = fmul reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]> 
%hlsl.select.i, [[Y_2:%.*]]
+// DXCHECK: ret <2 x [[TYPE]]> %mul.i
+// SPVCHECK: %fmod.i = frem reassoc nnan ninf nsz arcp afn <2 x [[TYPE]]> 
[[X:%.*]], [[Y:%.*]]
+// SPVCHECK: ret <2 x [[TYPE]]> %fmod.i
 half2 test_fmod_half2(half2 p0, half2 p1) { return fmod(p0, p1); }
 
-// CHECK: define [[FNATTRS]] <3 x [[TYPE]]> @
-// CHECK: %fmod = frem reassoc nnan ninf nsz arcp afn <3 x [[TYPE]]>
-// CHECK: ret <3 x [[TYPE]]> %fmod
+// CHECK-LABEL: test_fmod_half3
+// DXCHECK: %div1.i = fdiv reassoc nnan ninf nsz arcp afn <3 x [[TYPE]]> 
[[X:%.*]], [[Y:%.*]]
+// DXCHECK: %fneg.i = fneg reassoc nnan ninf nsz arcp afn <3 x [[TYPE]]> 
[[DIV1_I:%.*]]
+// DXCHECK: %cmp.i = fcmp reassoc nnan ninf nsz arcp afn oge <3 x [[TYPE]]> 
[[DIV1_I_2:%.*]], %fneg.i
+// DXNATIVE_HALF: %elt.abs.i = call reassoc nnan ninf nsz arcp afn <3 x 
[[TYPE]]> @llvm.fabs.v3f16(<3 x [[TYPE]]> [[DIV1_I_3:%.*]])
+// DXNO_HALF: %elt.abs.i = call reassoc nnan ninf nsz arcp afn <3 x [[TYPE]]> 
@llvm.fabs.v3f32(<3 x [[TYPE]]> [[DIV1_I_3:%.*]])
+// DXNATIVE_HALF: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn <3 x 
[[TYPE]]> @llvm.dx.frac.v3f16(<3 x [[TYPE]]> %elt.abs.i)
+// DXNO_HALF: %hlsl.frac.i = call reassoc nnan ninf nsz arcp afn <3 x 
[[TYPE]]> @llvm.dx.frac.v3f32(<3 x [[TYPE]]> %elt.abs.i)
+// DXCHECK: %fneg2.i = fneg reassoc nnan ninf nsz arcp afn <3 x [[TYPE]]> 
[[HLSL_FRAC_I:%.*]]
+// DXC

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`polly-x86_64-linux-noassert` running on `polly-x86_64-gce1` while building 
`llvm` at step 5 "build".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/28/builds/7453


Here is the relevant piece of the build log for the reference

```
Step 5 (build) failure: 'ninja' (failure)
...
[417/4171] Copying clang's avxifmaintrin.h...
[418/4171] Copying clang's avxneconvertintrin.h...
[419/4171] Copying clang's avxvnniint16intrin.h...
[420/4171] Copying clang's hlsl/hlsl_intrinsics.h...
[421/4171] Copying clang's avxintrin.h...
[422/4171] Copying clang's avxvnniint8intrin.h...
[423/4171] Copying clang's bmiintrin.h...
[424/4171] Copying clang's avxvnniintrin.h...
[425/4171] Copying clang's bmi2intrin.h...
[426/4171] Building CXX object 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o 
ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/lib/Support 
-I/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support
 -I/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.obj/include 
-I/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/include 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -fno-exceptions 
-funwind-tables -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -c 
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp:109:12:
 error: declaration of ‘{anonymous}::Accessor llvm::mustache::Token::Accessor’ 
changes meaning of ‘Accessor’ [-fpermissive]
  109 |   Accessor Accessor;
  |^~~~
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp:19:7:
 note: ‘Accessor’ declared here as ‘using Accessor = class 
llvm::SmallVector >’
   19 | using Accessor = SmallVector;
  |   ^~~~
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp:186:18:
 error: declaration of ‘const Accessor llvm::mustache::ASTNode::Accessor’ 
changes meaning of ‘Accessor’ [-fpermissive]
  186 |   const Accessor Accessor;
  |  ^~~~
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp:19:7:
 note: ‘Accessor’ declared here as ‘using Accessor = class 
llvm::SmallVector >’
   19 | using Accessor = SmallVector;
  |   ^~~~
In file included from 
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp:8:
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/include/llvm/Support/Mustache.h:
 In constructor 
‘llvm::mustache::Template::Template(llvm::mustache::Template&&)’:
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/include/llvm/Support/Mustache.h:123:12:
 warning: ‘llvm::mustache::Template::Tree’ will be initialized after [-Wreorder]
  123 |   ASTNode *Tree;
  |^~~~
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/include/llvm/Support/Mustache.h:120:26:
 warning:   ‘llvm::BumpPtrAllocator llvm::mustache::Template::AstAllocator’ 
[-Wreorder]
  120 |   llvm::BumpPtrAllocator AstAllocator;
  |  ^~~~
/home/worker/buildbot-workers/polly-x86_64-gce1/rundir/llvm.src/llvm/lib/Support/Mustache.cpp:769:1:
 warning:   when initialized here [-Wreorder]
  769 | Template::Template(Template &&Other) noexcept
  | ^~~~
[427/4171] Copying clang's cldemoteintrin.h...
[428/4171] Copying clang's cetintrin.h...
[429/4171] Copying clang's clflushoptintrin.h...
[430/4171] Copying clang's clwbintrin.h...
[431/4171] Copying clang's clzerointrin.h...
ninja: build stopped: subcommand failed.

```



https://github.com/llvm/llvm-project/pull/105893
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20][Modules] Do not update the declaration generation number if the redeclaration chain completion was delayed. (PR #129982)

2025-03-10 Thread Michael Park via cfe-commits

https://github.com/mpark edited https://github.com/llvm/llvm-project/pull/129982
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [alpha.webkit.UnretainedCallArgsChecker] Add a checker for NS or CF type call arguments. (PR #128586)

2025-03-10 Thread Rashmi Mudduluru via cfe-commits


@@ -141,6 +158,42 @@ class RawPtrRefCallArgsChecker
 }
   }
 
+  void visitObjCMessageExpr(const ObjCMessageExpr *E, const Decl *D) const {
+if (BR->getSourceManager().isInSystemHeader(E->getExprLoc()))
+  return;
+
+auto Selector = E->getSelector();
+if (auto *Receiver = E->getInstanceReceiver()->IgnoreParenCasts()) {
+  std::optional IsUnsafe = isUnsafePtr(E->getReceiverType());
+  if (IsUnsafe && *IsUnsafe && !isPtrOriginSafe(Receiver)) {
+if (auto *InnerMsg = dyn_cast(Receiver)) {
+  auto InnerSelector = InnerMsg->getSelector();
+  if (InnerSelector.getNameForSlot(0) == "alloc" &&
+  Selector.getNameForSlot(0).starts_with("init"))
+return;
+}
+reportBugOnReceiver(Receiver, D);
+  }
+}
+
+auto *MethodDecl = E->getMethodDecl();
+if (!MethodDecl)
+  return;
+
+auto ArgCount = E->getNumArgs();
+for (unsigned i = 0; i < ArgCount && i < MethodDecl->param_size(); ++i) {

t-rasmud wrote:

Do we have a test case for variable length params?

https://github.com/llvm/llvm-project/pull/128586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix heap-use-after-free in TryAnnotateTypeOrScopeTokenAfterScopeSpec (PR #124521)

2025-03-10 Thread via cfe-commits

Shivam7-1 wrote:

Hii @Endilll @cor3ntin Thanks for Response Can you provide steps so i can do it 
?

https://github.com/llvm/llvm-project/pull/124521
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [SPARC][Driver] Set correct IAS mode defaults for Linux and Free/OpenBSD (PR #130108)

2025-03-10 Thread Brad Smith via cfe-commits

brad0 wrote:

@s-barannikov 

https://github.com/llvm/llvm-project/pull/130108
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 74868cf - Reland Fix amdgpu-arch for dll name on Windows (#130624)

2025-03-10 Thread via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2025-03-10T13:53:04-04:00
New Revision: 74868cf0d14e59c553518d516e19937de46e23bb

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

LOG: Reland Fix amdgpu-arch for dll name on Windows (#130624)

Reload aba3005a after fixing build failure.

Recently HIP runtime changed dll name to amdhip64_n.dll on Windows,
where n is ROCm major version number.

Fix amdgpu-arch to search for amdhip64_n.dll on Windows.

Added: 


Modified: 
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp

Removed: 




diff  --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp 
b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
index 6c10cbc5c46a8..86f3e31f47bbc 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -21,6 +21,9 @@ static cl::opt Help("h", cl::desc("Alias for -help"), 
cl::Hidden);
 // Mark all our options with this category.
 static cl::OptionCategory AMDGPUArchCategory("amdgpu-arch options");
 
+cl::opt Verbose("verbose", cl::desc("Enable verbose output"),
+  cl::init(false), cl::cat(AMDGPUArchCategory));
+
 static void PrintVersion(raw_ostream &OS) {
   OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n';
 }

diff  --git a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp 
b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
index 7338872dbf32f..4803f83f55ac7 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
@@ -11,9 +11,24 @@
 //
 
//===--===//
 
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+#include 
+#include 
+
+#ifdef _WIN32
+#include 
+#endif
 
 using namespace llvm;
 
@@ -31,16 +46,124 @@ typedef hipError_t (*hipGetDeviceCount_t)(int *);
 typedef hipError_t (*hipDeviceGet_t)(int *, int);
 typedef hipError_t (*hipGetDeviceProperties_t)(hipDeviceProp_t *, int);
 
-int printGPUsByHIP() {
+extern cl::opt Verbose;
+
 #ifdef _WIN32
-  constexpr const char *DynamicHIPPath = "amdhip64.dll";
+static std::vector getSearchPaths() {
+  std::vector Paths;
+
+  // Get the directory of the current executable
+  if (auto MainExe = sys::fs::getMainExecutable(nullptr, nullptr);
+  !MainExe.empty())
+Paths.push_back(sys::path::parent_path(MainExe).str());
+
+  // Get the system directory
+  wchar_t SystemDirectory[MAX_PATH];
+  if (GetSystemDirectoryW(SystemDirectory, MAX_PATH) > 0) {
+std::string Utf8SystemDir;
+if (convertUTF16ToUTF8String(
+ArrayRef(reinterpret_cast(SystemDirectory),
+wcslen(SystemDirectory)),
+Utf8SystemDir))
+  Paths.push_back(Utf8SystemDir);
+  }
+
+  // Get the Windows directory
+  wchar_t WindowsDirectory[MAX_PATH];
+  if (GetWindowsDirectoryW(WindowsDirectory, MAX_PATH) > 0) {
+std::string Utf8WindowsDir;
+if (convertUTF16ToUTF8String(
+ArrayRef(reinterpret_cast(WindowsDirectory),
+wcslen(WindowsDirectory)),
+Utf8WindowsDir))
+  Paths.push_back(Utf8WindowsDir);
+  }
+
+  // Get the current working directory
+  SmallVector CWD;
+  if (sys::fs::current_path(CWD))
+Paths.push_back(std::string(CWD.begin(), CWD.end()));
+
+  // Get the PATH environment variable
+  if (std::optional PathEnv = sys::Process::GetEnv("PATH")) {
+SmallVector PathList;
+StringRef(*PathEnv).split(PathList, sys::EnvPathSeparator);
+for (auto &Path : PathList)
+  Paths.push_back(Path.str());
+  }
+
+  return Paths;
+}
+
+// Custom comparison function for dll name
+static bool compareVersions(StringRef A, StringRef B) {
+  auto ParseVersion = [](StringRef S) -> VersionTuple {
+unsigned Pos = S.find_last_of('_');
+StringRef VerStr = (Pos == StringRef::npos) ? S : S.substr(Pos + 1);
+VersionTuple Vt;
+(void)Vt.tryParse(VerStr);
+return Vt;
+  };
+
+  VersionTuple VtA = ParseVersion(A);
+  VersionTuple VtB = ParseVersion(B);
+  return VtA > VtB;
+}
+#endif
+
+// On Windows, prefer amdhip64_n.dll where n is ROCm major version and greater
+// value of n takes precedence. If amdhip64_n.dll is not found, fall back to
+// amdhip64.dll. The reason is that a normal driver installation only has
+// amdhip64_n.dll but we do not know what n is since this program may be used
+// with a future version of HIP runtime.
+//
+// On Linux, always use default libamd

[clang] [llvm] [RISCV] Update to Xqciint v0.4 (PR #130219)

2025-03-10 Thread via cfe-commits

https://github.com/hchandel approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/130219
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebKit checkers] Don't treat virtual functions as safe. (PR #129632)

2025-03-10 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

Thanks for the review!

https://github.com/llvm/llvm-project/pull/129632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AstMatcher][NFC]fix doc gen for ast matchers (PR #130726)

2025-03-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Congcong Cai (HerrCai0907)


Changes

1. dump-ast-matchers.py does not depend on pwd
2. fix some warning in python3


---

Patch is 21.54 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/130726.diff


3 Files Affected:

- (modified) clang/docs/LibASTMatchersReference.html (+134-59) 
- (modified) clang/docs/tools/dump_ast_matchers.py (+3-3) 
- (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+2-1) 


``diff
diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 48dfd9cac0033..2a01d6cda6bed 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1842,12 +1842,6 @@ Node Matchers
   if (x) {}
 
 
-MatcherStmt>dependentScopeDeclRefExprMatcherDependentScopeDeclRefExpr>...
-Matches 
expressions that refer to dependent scope declarations.
-
-Example matches T::v
-   template  class X : T { void f() { T::v; } };
-
 
 MatcherStmt>declStmtMatcherDeclStmt>...
 Matches declaration 
statements.
@@ -1874,6 +1868,14 @@ Node Matchers
 
 
 
+MatcherStmt>dependentScopeDeclRefExprMatcherDependentScopeDeclRefExpr>...
+Matches 
expressions that refer to dependent scope declarations.
+
+example matches T::v;
+ template  class X : T { void f() { T::v; } };
+
+
+
 MatcherStmt>designatedInitExprMatcherDesignatedInitExpr>...
 Matches C99 
designated initializer expressions [C99 6.7.8].
 
@@ -1931,7 +1933,24 @@ Node Matchers
 
 
 MatcherStmt>fixedPointLiteralMatcherFixedPointLiteral>...
-Matches fixed 
point literals
+Matches 
fixed-point literals eg.
+0.5r, 0.5hr, 0.5lr, 0.5uhr, 0.5ur, 0.5ulr
+1.0k, 1.0hk, 1.0lk, 1.0uhk, 1.0uk, 1.0ulk
+Exponents 1.0e10k
+Hexadecimal numbers 0x0.2p2r
+
+Does not match implicit conversions such as first two lines:
+   short _Accum sa = 2;
+   _Accum a = 12.5;
+   _Accum b = 1.25hk;
+   _Fract c = 0.25hr;
+   _Fract v = 0.35uhr;
+   _Accum g = 1.45uhk;
+   _Accum decexp1 = 1.575e1k;
+
+The matcher matches
+but does not
+match and from the code block.
 
 
 
@@ -2536,26 +2555,6 @@ Node Matchers
   matches "decltype(i + j)"
 
 
-MatcherType>dependentNameTypeMatcherDependentNameType>...
-Matches a 
dependent name type.
-
-Example matches T::type
-
-  template  struct declToImport {
-typedef typename T::type dependent_name;
-  };
-
-
-MatcherType>dependentTemplateSpecializationTypeMatcherDependentTemplateSpecializationType>...
-Matches a dependent template 
specialization type.
-
-Example matches A::template B
-
-  template struct A;
-  template struct declToImport {
-typename A::template B a;
-  };
-
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class
@@ -2571,6 +2570,16 @@ Node Matchers
 
 
 
+MatcherType>dependentNameTypeMatcherDependentNameType>...
+Matches a 
dependent name type
+
+Example matches T::type
+ template  struct declToImport {
+   typedef typename T::type dependent_name;
+ };
+
+
+
 MatcherType>dependentSizedArrayTypeMatcherDependentSizedArrayType>...
 Matches C++ 
arrays whose size is a value-dependent expression.
 
@@ -2598,6 +2607,17 @@ Node Matchers
 
 
 
+MatcherType>dependentTemplateSpecializationTypeMatcherDependentTemplateSpecializationType>...
+Matches a dependent template 
specialization type
+
+Example matches A::template B
+  template struct A;
+  template

[clang] [HLSL] Add bounds checks for the hlsl vector arguments and return types (PR #130724)

2025-03-10 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl updated 
https://github.com/llvm/llvm-project/pull/130724

>From 17386ba9cb12c08a4325cc34449ae57cfdd65636 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Mon, 10 Mar 2025 21:03:49 -0400
Subject: [PATCH] [HLSL] Add bounds checks for the hlsl vector arguments and
 return types

fixes #129003
- fix up sema tests
- fix up templates for scalar and vector HLSL intrinsic overloads
---
 clang/lib/Headers/hlsl/hlsl_detail.h  |  4 ++
 .../lib/Headers/hlsl/hlsl_intrinsic_helpers.h | 14 +
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 54 +
 .../SemaHLSL/BuiltIns/distance-errors.hlsl| 44 ++
 .../test/SemaHLSL/BuiltIns/length-errors.hlsl | 60 ++-
 .../SemaHLSL/BuiltIns/reflect-errors.hlsl | 44 ++
 6 files changed, 161 insertions(+), 59 deletions(-)

diff --git a/clang/lib/Headers/hlsl/hlsl_detail.h 
b/clang/lib/Headers/hlsl/hlsl_detail.h
index c691d85283de4..80c4900121dfb 100644
--- a/clang/lib/Headers/hlsl/hlsl_detail.h
+++ b/clang/lib/Headers/hlsl/hlsl_detail.h
@@ -45,6 +45,10 @@ template  struct is_arithmetic {
   static const bool Value = __is_arithmetic(T);
 };
 
+template 
+using HLSL_FIXED_VECTOR =
+vector<__detail::enable_if_t<(N > 1 && N <= 4), T>, N>;
+
 } // namespace __detail
 } // namespace hlsl
 #endif //_HLSL_HLSL_DETAILS_H_
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 6783e23f6346d..87b52792447f6 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -23,11 +23,7 @@ constexpr vector 
d3d_color_to_ubyte4_impl(vector V) {
   return V.zyxw * 255.001953f;
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-length_impl(T X) {
-  return abs(X);
-}
+template  constexpr T length_impl(T X) { return abs(X); }
 
 template 
 constexpr enable_if_t::value || is_same::value, T>
@@ -39,9 +35,7 @@ length_vec_impl(vector X) {
 #endif
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-distance_impl(T X, T Y) {
+template  constexpr T distance_impl(T X, T Y) {
   return length_impl(X - Y);
 }
 
@@ -51,9 +45,7 @@ distance_vec_impl(vector X, vector Y) {
   return length_vec_impl(X - Y);
 }
 
-template 
-constexpr enable_if_t::value || is_same::value, T>
-reflect_impl(T I, T N) {
+template  constexpr T reflect_impl(T I, T N) {
   return I - 2 * N * I * N;
 }
 
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index cd6d836578787..47a7066b2b3e1 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -89,23 +89,31 @@ void asuint(double4, out uint4, out uint4);
 /// \param X The X input value.
 /// \param Y The Y input value.
 
+template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(half X, half Y) {
+const inline __detail::enable_if_t<__detail::is_arithmetic::Value &&
+   __detail::is_same::value,
+   T> distance(T X, T Y) {
   return __detail::distance_impl(X, Y);
 }
 
-const inline float distance(float X, float Y) {
+template 
+const inline __detail::enable_if_t<
+__detail::is_arithmetic::Value && __detail::is_same::value, T>
+distance(T X, T Y) {
   return __detail::distance_impl(X, Y);
 }
 
 template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half distance(vector X, vector Y) {
+const inline half distance(__detail::HLSL_FIXED_VECTOR X,
+   __detail::HLSL_FIXED_VECTOR Y) {
   return __detail::distance_vec_impl(X, Y);
 }
 
 template 
-const inline float distance(vector X, vector Y) {
+const inline float distance(__detail::HLSL_FIXED_VECTOR X,
+__detail::HLSL_FIXED_VECTOR Y) {
   return __detail::distance_vec_impl(X, Y);
 }
 
@@ -119,17 +127,29 @@ const inline float distance(vector X, 
vector Y) {
 ///
 /// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
 
+template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(half X) { return __detail::length_impl(X); }
-const inline float length(float X) { return __detail::length_impl(X); }
+const inline __detail::enable_if_t<__detail::is_arithmetic::Value &&
+   __detail::is_same::value,
+   T> length(T X) {
+  return __detail::length_impl(X);
+}
+
+template 
+const inline __detail::enable_if_t<
+__detail::is_arithmetic::Value && __detail::is_same::value, T>
+length(T X) {
+  return __detail::length_impl(X);
+}
 
 template 
 _HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
-const inline half length(vector X) {
+const inline half length(__detail::HLSL_FIXED_VECTOR X) {
   return __detail::length_vec_impl(X);
 }
 
-template  const inline float length(vector X) {
+template 
+const inline float length(__detail::HLSL_FIXED_VECTOR X) {
   return __d

[clang-tools-extra] [clang-tidy][NFC]clean ConstCorrectnessCheck (PR #130493)

2025-03-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 closed 
https://github.com/llvm/llvm-project/pull/130493
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] support pointee mutation check in misc-const-correctness (PR #130494)

2025-03-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 edited 
https://github.com/llvm/llvm-project/pull/130494
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] support pointee mutation check in misc-const-correctness (PR #130494)

2025-03-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/130494

>From 353f538f425ead9ee10ca6c046a6517b9e157db4 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Sun, 9 Mar 2025 15:43:37 +
Subject: [PATCH] [clang-tidy] support pointee mutation check in
 misc-const-correctness

---
 .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 156 --
 .../clang-tidy/misc/ConstCorrectnessCheck.h   |   3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   3 +-
 .../checks/misc/const-correctness.rst |  44 +
 .../const-correctness-pointer-as-pointers.cpp |  50 ++
 .../const-correctness-transform-values.cpp|   1 +
 .../const-correctness-values-before-cxx23.cpp |   1 +
 .../misc/const-correctness-values.cpp |   1 +
 .../misc/const-correctness-wrong-config.cpp   |   7 +-
 9 files changed, 207 insertions(+), 59 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp

diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
index dbe59233df699..023c834d5700f 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -13,6 +13,8 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "llvm/Support/Casting.h"
+#include 
 
 using namespace clang::ast_matchers;
 
@@ -39,34 +41,47 @@ ConstCorrectnessCheck::ConstCorrectnessCheck(StringRef Name,
 : ClangTidyCheck(Name, Context),
   AnalyzeValues(Options.get("AnalyzeValues", true)),
   AnalyzeReferences(Options.get("AnalyzeReferences", true)),
+  AnalyzePointers(Options.get("AnalyzePointers", true)),
   WarnPointersAsValues(Options.get("WarnPointersAsValues", false)),
+  WarnPointersAsPointers(Options.get("WarnPointersAsPointers", true)),
   TransformValues(Options.get("TransformValues", true)),
   TransformReferences(Options.get("TransformReferences", true)),
   TransformPointersAsValues(
   Options.get("TransformPointersAsValues", false)),
+  TransformPointersAsPointers(
+  Options.get("TransformPointersAsPointers", true)),
   AllowedTypes(
   utils::options::parseStringList(Options.get("AllowedTypes", ""))) {
-  if (AnalyzeValues == false && AnalyzeReferences == false)
+  if (AnalyzeValues == false && AnalyzeReferences == false &&
+  AnalyzePointers == false)
 this->configurationDiag(
 "The check 'misc-const-correctness' will not "
-"perform any analysis because both 'AnalyzeValues' and "
-"'AnalyzeReferences' are false.");
+"perform any analysis because both 'AnalyzeValues', "
+"'AnalyzeReferences' and 'AnalyzePointers' are false.");
 }
 
 void ConstCorrectnessCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "AnalyzeValues", AnalyzeValues);
   Options.store(Opts, "AnalyzeReferences", AnalyzeReferences);
+  Options.store(Opts, "AnalyzePointers", AnalyzePointers);
   Options.store(Opts, "WarnPointersAsValues", WarnPointersAsValues);
+  Options.store(Opts, "WarnPointersAsPointers", WarnPointersAsPointers);
 
   Options.store(Opts, "TransformValues", TransformValues);
   Options.store(Opts, "TransformReferences", TransformReferences);
   Options.store(Opts, "TransformPointersAsValues", TransformPointersAsValues);
+  Options.store(Opts, "TransformPointersAsPointers",
+TransformPointersAsPointers);
   Options.store(Opts, "AllowedTypes",
 utils::options::serializeStringList(AllowedTypes));
 }
 
 void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) {
-  const auto ConstType = hasType(isConstQualified());
+  const auto ConstType = hasType(
+  qualType(isConstQualified(),
+   // pointee check will check the const pointer and const array
+   unless(pointerType()), unless(arrayType(;
+
   const auto ConstReference = hasType(references(isConstQualified()));
   const auto RValueReference = hasType(
   referenceType(anyOf(rValueReferenceType(), 
unless(isSpelledAsLValue();
@@ -124,6 +139,11 @@ void ConstCorrectnessCheck::check(const 
MatchFinder::MatchResult &Result) {
   const auto *LocalScope = Result.Nodes.getNodeAs("scope");
   const auto *Variable = Result.Nodes.getNodeAs("local-value");
   const auto *Function = Result.Nodes.getNodeAs("function-decl");
+  const auto *VarDeclStmt = Result.Nodes.getNodeAs("decl-stmt");
+  // It can not be guaranteed that the variable is declared isolated,
+  // therefore a transformation might effect the other variables as well and
+  // be incorrect.
+  const bool CanBeFixIt = VarDeclStmt != nullptr && 
VarDeclStmt->isSingleDecl();
 
   /// If the variable was declared in a template it might be analyzed multiple
   /// times. Only one of those instant

[clang] [AstMatcher][NFC]fix doc gen for ast matchers (PR #130726)

2025-03-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/130726

1. dump-ast-matchers.py does not depend on pwd
2. fix some warning in python3


>From 9f4c377bb1e1bf4808dc0adf4380e55dba7560dd Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Tue, 11 Mar 2025 14:49:19 +0800
Subject: [PATCH] [AstMatcher][NFC]fix doc gen for ast matchers

1. dump-ast-matchers.py does not depend on pwd
2. fix some warning in python3
---
 clang/docs/LibASTMatchersReference.html   | 193 --
 clang/docs/tools/dump_ast_matchers.py |   6 +-
 clang/include/clang/ASTMatchers/ASTMatchers.h |   3 +-
 3 files changed, 139 insertions(+), 63 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 48dfd9cac0033..2a01d6cda6bed 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1842,12 +1842,6 @@ Node Matchers
   if (x) {}
 
 
-MatcherStmt>dependentScopeDeclRefExprMatcherDependentScopeDeclRefExpr>...
-Matches 
expressions that refer to dependent scope declarations.
-
-Example matches T::v
-   template  class X : T { void f() { T::v; } };
-
 
 MatcherStmt>declStmtMatcherDeclStmt>...
 Matches declaration 
statements.
@@ -1874,6 +1868,14 @@ Node Matchers
 
 
 
+MatcherStmt>dependentScopeDeclRefExprMatcherDependentScopeDeclRefExpr>...
+Matches 
expressions that refer to dependent scope declarations.
+
+example matches T::v;
+ template  class X : T { void f() { T::v; } };
+
+
+
 MatcherStmt>designatedInitExprMatcherDesignatedInitExpr>...
 Matches C99 
designated initializer expressions [C99 6.7.8].
 
@@ -1931,7 +1933,24 @@ Node Matchers
 
 
 MatcherStmt>fixedPointLiteralMatcherFixedPointLiteral>...
-Matches fixed 
point literals
+Matches 
fixed-point literals eg.
+0.5r, 0.5hr, 0.5lr, 0.5uhr, 0.5ur, 0.5ulr
+1.0k, 1.0hk, 1.0lk, 1.0uhk, 1.0uk, 1.0ulk
+Exponents 1.0e10k
+Hexadecimal numbers 0x0.2p2r
+
+Does not match implicit conversions such as first two lines:
+   short _Accum sa = 2;
+   _Accum a = 12.5;
+   _Accum b = 1.25hk;
+   _Fract c = 0.25hr;
+   _Fract v = 0.35uhr;
+   _Accum g = 1.45uhk;
+   _Accum decexp1 = 1.575e1k;
+
+The matcher matches
+but does not
+match and from the code block.
 
 
 
@@ -2536,26 +2555,6 @@ Node Matchers
   matches "decltype(i + j)"
 
 
-MatcherType>dependentNameTypeMatcherDependentNameType>...
-Matches a 
dependent name type.
-
-Example matches T::type
-
-  template  struct declToImport {
-typedef typename T::type dependent_name;
-  };
-
-
-MatcherType>dependentTemplateSpecializationTypeMatcherDependentTemplateSpecializationType>...
-Matches a dependent template 
specialization type.
-
-Example matches A::template B
-
-  template struct A;
-  template struct declToImport {
-typename A::template B a;
-  };
-
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class
@@ -2571,6 +2570,16 @@ Node Matchers
 
 
 
+MatcherType>dependentNameTypeMatcherDependentNameType>...
+Matches a 
dependent name type
+
+Example matches T::type
+ template  struct declToImport {
+   typedef typename T::type dependent_name;
+ };
+
+
+
 MatcherType>dependentSizedArrayTypeMatcherDependentSizedArrayType>...
 Matches C++ 
arrays whose size is a value-dependent expression.
 
@@ -2598,6 +2607,17 @@ Node Matchers
 
 
 
+MatcherType>dependentTemplateSpecializationTypeMatcherDependentTemplateS

[clang-tools-extra] [clang-tidy][NFC]refactor matcher for bugprone-optional-value-conversion (PR #130415)

2025-03-10 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 closed 
https://github.com/llvm/llvm-project/pull/130415
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 318bef9 - [clang-tidy][NFC]refactor matcher for bugprone-optional-value-conversion (#130415)

2025-03-10 Thread via cfe-commits

Author: Congcong Cai
Date: 2025-03-11T14:52:18+08:00
New Revision: 318bef91eafb7e01be707b9919c36ef424840041

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

LOG: [clang-tidy][NFC]refactor matcher for bugprone-optional-value-conversion 
(#130415)

The old `constructFrom` has hidden requirement which TypeMatcher must be used 
before ArgumentMatcher because there are bind inside.
Inlining this function to make it more intuitive.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
index 55ca4809f058a..33e823ac07490 100644
--- a/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
@@ -27,28 +27,11 @@ AST_MATCHER_P(QualType, hasCleanType, Matcher, 
InnerMatcher) {
   Finder, Builder);
 }
 
-constexpr std::array NameList{
+constexpr std::array MakeSmartPtrList{
 "::std::make_unique",
 "::std::make_shared",
 };
 
-Matcher constructFrom(Matcher TypeMatcher,
-Matcher ArgumentMatcher) {
-  return expr(
-  anyOf(
-  // construct optional
-  cxxConstructExpr(argumentCountIs(1U), hasType(TypeMatcher),
-   hasArgument(0U, ArgumentMatcher)),
-  // known template methods in std
-  callExpr(argumentCountIs(1),
-   callee(functionDecl(
-   matchers::matchesAnyListedName(NameList),
-   hasTemplateArgument(0, refersToType(TypeMatcher,
-   hasArgument(0, ArgumentMatcher))),
-  unless(anyOf(hasAncestor(typeLoc()),
-   hasAncestor(expr(matchers::hasUnevaluatedContext());
-}
-
 } // namespace
 
 OptionalValueConversionCheck::OptionalValueConversionCheck(
@@ -74,7 +57,7 @@ void 
OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
   auto EqualsBoundOptionalType =
   qualType(hasCleanType(equalsBoundNode("optional-type")));
 
-  auto OptionalDereferenceMatcher = callExpr(
+  auto OptionalDerefMatcherImpl = callExpr(
   anyOf(
   cxxOperatorCallExpr(hasOverloadedOperatorName("*"),
   
hasUnaryOperand(hasType(EqualsBoundOptionalType)))
@@ -88,11 +71,24 @@ void 
OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
 
   auto StdMoveCallMatcher =
   callExpr(argumentCountIs(1), 
callee(functionDecl(hasName("::std::move"))),
-   hasArgument(0, ignoringImpCasts(OptionalDereferenceMatcher)));
+   hasArgument(0, ignoringImpCasts(OptionalDerefMatcherImpl)));
+  auto OptionalDerefMatcher =
+  ignoringImpCasts(anyOf(OptionalDerefMatcherImpl, StdMoveCallMatcher));
+
   Finder->addMatcher(
-  expr(constructFrom(BindOptionalType,
- ignoringImpCasts(anyOf(OptionalDereferenceMatcher,
-StdMoveCallMatcher
+  expr(anyOf(
+   // construct optional
+   cxxConstructExpr(argumentCountIs(1), hasType(BindOptionalType),
+hasArgument(0, OptionalDerefMatcher)),
+   // known template methods in std
+   callExpr(
+   argumentCountIs(1),
+   callee(functionDecl(
+   matchers::matchesAnyListedName(MakeSmartPtrList),
+   hasTemplateArgument(0, 
refersToType(BindOptionalType,
+   hasArgument(0, OptionalDerefMatcher))),
+   unless(anyOf(hasAncestor(typeLoc()),
+hasAncestor(expr(matchers::hasUnevaluatedContext())
   .bind("expr"),
   this);
 }



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


[clang-tools-extra] [clang-tidy][NFC]refactor matcher for bugprone-optional-value-conversion (PR #130415)

2025-03-10 Thread Congcong Cai via cfe-commits

HerrCai0907 wrote:

### Merge activity

* **Mar 11, 2:50 AM EDT**: A user started a stack merge that includes this pull 
request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/130415).


https://github.com/llvm/llvm-project/pull/130415
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2025-03-10 Thread via cfe-commits

github-actions[bot] wrote:



@vbvictor Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/121291
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] AMDGPU: Move enqueued block handling into clang (PR #128519)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on 
`as-worker-93` while building `clang,llvm` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/146/builds/2459


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests.exe/38/87' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-22964-38-87.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=38 
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe 
--gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): 
error: Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): 
error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied







```



https://github.com/llvm/llvm-project/pull/128519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[clang] Lower modf builtin using `llvm.modf` intrinsic" (PR #129885)

2025-03-10 Thread Nico Weber via cfe-commits

nico wrote:

Here are a few ideas for possible paths forward: 
https://issues.chromium.org/issues/401571943#comment9

…actually, let me inline them:

`if (Builder.getIsFPConstrained())` -> `if (Builder.getIsFPConstrained() && 
!isTargetingWin32())`?

Alternatively, we could put an actual symbol in compiler-rt that calls modff 
from the CRT, which puts an available symbol into compiler-rt. (…can 
compiler-rt depend on CRT?)

There's probably nothing that guarantees that the symbol isn't inline on other 
platforms either. …but we do have the inline symbol. Maybe LLVM doesn't know to 
mark the inline as used when it's called through the intrinsic? That could be a 
third idea to look into.

https://github.com/llvm/llvm-project/pull/129885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-10 Thread Chris B via cfe-commits
Nathan =?utf-8?q?Gauër?= 
Message-ID:
In-Reply-To: 


llvm-beanz wrote:

Is there a reason we can't do this in Sema? It would probably be ideal to have 
the AST represent the address spaces of values accurately.

https://github.com/llvm/llvm-project/pull/122103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix false negative `modernize-use-ranges` when using getter function (PR #127377)

2025-03-10 Thread via cfe-commits

Andrewyuan34 wrote:

ping... 

https://github.com/llvm/llvm-project/pull/127377
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] support different precisions (PR #130540)

2025-03-10 Thread Tommy Chen via cfe-commits

https://github.com/dl8sd11 updated 
https://github.com/llvm/llvm-project/pull/130540

>From 092135bbb3536167f0cad11e7320e52886c022cc Mon Sep 17 00:00:00 2001
From: dl8sd11 
Date: Mon, 10 Mar 2025 02:56:14 +
Subject: [PATCH 1/3] [clang-tidy] support different precisions

Support float and long double versions of the math functions for
UseStdNumbersCheck. For example, after this commit the check is
able to catch `sqrtf(2)` and `expl(1)`.
---
 .../modernize/UseStdNumbersCheck.cpp  |  6 +-
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 +
 .../checkers/modernize/use-std-numbers.cpp| 21 +++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
index 1548fc454cfb3..32645e31e8899 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
@@ -91,8 +91,12 @@ struct MatchBuilder {
 
   auto matchMathCall(const StringRef FunctionName,
  const Matcher ArgumentMatcher) const {
+auto HasAnyPrecisionName =
+anyOf(hasName(FunctionName), hasName((FunctionName + "l").str()),
+  hasName((FunctionName + "f")
+  .str())); // Support long double(l) and float(f).
 return expr(ignoreParenAndFloatingCasting(
-callExpr(callee(functionDecl(hasName(FunctionName),
+callExpr(callee(functionDecl(HasAnyPrecisionName,
  hasParameter(0, 
hasType(isArithmetic(),
  hasArgument(0, ArgumentMatcher;
   }
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 7d37a4b03222c..2f7ff2ec41f4b 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -165,6 +165,11 @@ Changes in existing checks
   ` check to support replacing
   member function calls too.
 
+- Improved :doc:`modernize-use-std-numbers
+  ` check to support math 
functions
+  of different precisions.
+
+
 - Improved :doc:`misc-unconventional-assign-operator
   ` check to avoid
   false positive for C++23 deducing this.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-numbers.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-numbers.cpp
index 6c5762da5e2e8..11121ae6d8e93 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-numbers.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-numbers.cpp
@@ -9,12 +9,17 @@ namespace bar {
 template 
 auto sqrt(T val) { return sqrt(static_cast(val)); }
 
+float sqrtf(float Arg);
+long double sqrtl(long double Arg);
+
 static constexpr double e = 
2.718281828459045235360287471352662497757247093;
 // CHECK-MESSAGES-ALL: :[[@LINE-1]]:33: warning: prefer 'std::numbers::e' 
to this literal, differs by '0.00e+00' [modernize-use-std-numbers]
 // CHECK-FIXES-ALL: static constexpr double e = std::numbers::e;
 }
 
+float expf(float Arg);
 double exp(double Arg);
+long double expl(long double Arg);
 double log(double Arg);
 
 double log2(double Arg);
@@ -110,6 +115,14 @@ void foo(){
 // CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 
'std::numbers::sqrt2_v'  to this formula [modernize-use-std-numbers]
 // CHECK-FIXES-ALL: std::numbers::sqrt2_v;
 
+bar::sqrtf(2.0F);
+// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 
'std::numbers::sqrt2_v'  to this formula [modernize-use-std-numbers]
+// CHECK-FIXES-ALL: std::numbers::sqrt2_v;
+
+bar::sqrtl(2.0);
+// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 
'std::numbers::sqrt2_v'  to this formula 
[modernize-use-std-numbers]
+// CHECK-FIXES-ALL: std::numbers::sqrt2_v;
+
 sink(MY_PI);
 // CHECK-MESSAGES-ALL: :[[@LINE-1]]:10: warning: prefer 'std::numbers::pi' 
to this macro, differs by '5.36e-08' [modernize-use-std-numbers]
 // CHECK-FIXES-ALL: sink(std::numbers::pi);
@@ -155,6 +168,14 @@ void foo(){
 // CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::e' 
to this formula [modernize-use-std-numbers]
 // CHECK-FIXES-ALL: std::numbers::e;
 
+expf(1);
+// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 
'std::numbers::e_v' to this formula [modernize-use-std-numbers]
+// CHECK-FIXES-ALL: std::numbers::e_v;
+
+expl(1);
+// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 
'std::numbers::e_v' to this formula [modernize-use-std-numbers]
+// CHECK-FIXES-ALL: std::numbers::e_v;
+
 log2(exp(1));
 // CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 
'std::numbers::log2e' to this formula [modernize-use-std-numbers]
 // CHECK-MESSAGES-ALL: :[[@LINE-2]]:10: warning: prefer 'std::numbers::e' 
to this formula [modernize-use-std-numbers]

>From 9797852645f5e0d58de20139887e9edbcd06fe44 Mon Sep 17 00:00:00

[clang] disable unary, vector mask (PR #130400)

2025-03-10 Thread Timm Baeder via cfe-commits

tbaederr wrote:

You can see two test failures in the CI output above.

https://github.com/llvm/llvm-project/pull/130400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-s390x-linux-lnt` 
running on `systemz-1` while building `llvm` at step 6 "build stage 1".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/136/builds/3100


Here is the relevant piece of the build log for the reference

```
Step 6 (build stage 1) failure: 'ninja -j4' (failure)
...
[317/6002] Copying clang-doc-default-stylesheet.css to 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/./bin/../share/clang-doc
[318/6002] Generating ../../../../share/scan-view/startfile.py
[319/6002] Copying index.js to 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/./bin/../share/clang-doc
[320/6002] Building CXX object 
tools/clang/tools/extra/clang-tidy/misc/ConfusableTable/CMakeFiles/clang-tidy-confusable-chars-gen.dir/BuildConfusableTable.cpp.o
[321/6002] Building CXX object 
tools/llvm-undname/CMakeFiles/llvm-undname.dir/llvm-undname.cpp.o
[322/6002] Building CXX object 
tools/reduce-chunk-list/CMakeFiles/reduce-chunk-list.dir/reduce-chunk-list.cpp.o
[323/6002] Building CXX object 
unittests/Support/DynamicLibrary/CMakeFiles/DynamicLibraryLib.dir/ExportedFuncs.cpp.o
[324/6002] Building CXX object 
unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/PipSqueak.cpp.o
[325/6002] Creating export file for Remarks
[326/6002] Building CXX object 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/c++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/lib/Support 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/include 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -UNDEBUG -std=c++17  
-fno-exceptions -funwind-tables -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -c 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp:109:12:
 error: declaration of '{anonymous}::Accessor llvm::mustache::Token::Accessor' 
changes meaning of 'Accessor' [-fpermissive]
  109 |   Accessor Accessor;
  |^~~~
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp:19:7:
 note: 'Accessor' declared here as 'using Accessor = class 
llvm::SmallVector >'
   19 | using Accessor = SmallVector;
  |   ^~~~
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp:186:18:
 error: declaration of 'const Accessor llvm::mustache::ASTNode::Accessor' 
changes meaning of 'Accessor' [-fpermissive]
  186 |   const Accessor Accessor;
  |  ^~~~
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp:19:7:
 note: 'Accessor' declared here as 'using Accessor = class 
llvm::SmallVector >'
   19 | using Accessor = SmallVector;
  |   ^~~~
In file included from 
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp:8:
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/Support/Mustache.h:
 In constructor 
'llvm::mustache::Template::Template(llvm::mustache::Template&&)':
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/Support/Mustache.h:123:12:
 warning: 'llvm::mustache::Template::Tree' will be initialized after [-Wreorder]
  123 |   ASTNode *Tree;
  |^~~~
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/include/llvm/Support/Mustache.h:120:26:
 warning:   'llvm::BumpPtrAllocator llvm::mustache::Template::AstAllocator' 
[-Wreorder]
  120 |   llvm::BumpPtrAllocator AstAllocator;
  |  ^~~~
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/llvm/lib/Support/Mustache.cpp:769:1:
 warning:   when initialized here [-Wreorder]
  769 | Template::Template(Template &&Other) noexcept
  | ^~~~
[327/6002] Linking CXX static library lib/libDynami

[clang] [clang-repl] Fix error recovery while PTU cleanup (PR #127467)

2025-03-10 Thread Anutosh Bhat via cfe-commits

https://github.com/anutosh491 updated 
https://github.com/llvm/llvm-project/pull/127467

>From 6ff448ed506e0ef75db2c9974a628a965e85df2f Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Mon, 17 Feb 2025 15:33:20 +0530
Subject: [PATCH 1/3] Fix error recovery while PTU cleanup

---
 clang/lib/Interpreter/IncrementalParser.cpp | 4 ++--
 clang/unittests/Interpreter/InterpreterTest.cpp | 7 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index e43cea1baf43a..1ebef0e434b3d 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -178,8 +178,8 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
 if (!ND)
   continue;
 // Check if we need to clean up the IdResolver chain.
-if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
-!D->getLangOpts().CPlusPlus)
+if (!ND->getDeclName().isEmpty() && ND->getDeclName().getFETokenInfo() &&
+!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
   S.IdResolver.RemoveDecl(ND);
   }
 }
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 578f1d4c0eac6..56ab155ebf5a4 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -114,6 +114,13 @@ TEST_F(InterpreterTest, Errors) {
 
   RecoverErr = Interp->Parse("var1 = 424;");
   EXPECT_TRUE(!!RecoverErr);
+
+  Err = Interp->Parse("int x = 5; auto capture = [&]() { return x * 2; 
};").takeError();
+  EXPECT_THAT(DiagnosticOutput, HasSubstr("error: non-local lambda expression 
cannot have a capture-default"));
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+
+  RecoverErr = Interp->Parse("int validVar = 10;");
+  EXPECT_TRUE(!!RecoverErr);
 }
 
 // Here we test whether the user can mix declarations and statements. The

>From 8b9a112721c45662374fd9995af6da4031507c89 Mon Sep 17 00:00:00 2001
From: Anutosh Bhat 
Date: Wed, 26 Feb 2025 16:55:31 +0530
Subject: [PATCH 2/3] Update IncrementalParser.cpp

---
 clang/lib/Interpreter/IncrementalParser.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index 1ebef0e434b3d..774219d9fc9ab 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -175,11 +175,11 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
 auto *ND = dyn_cast(D);
-if (!ND)
+if (!ND || ND->getDeclName().isEmpty()) 
   continue;
 // Check if we need to clean up the IdResolver chain.
-if (!ND->getDeclName().isEmpty() && ND->getDeclName().getFETokenInfo() &&
-!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
+if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
+!D->getLangOpts().CPlusPlus)
   S.IdResolver.RemoveDecl(ND);
   }
 }

>From dae6ca63f0d443a6ec0df12e1abef183203c12de Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Tue, 11 Mar 2025 11:29:32 +0530
Subject: [PATCH 3/3] Add tests in lambda.cpp

---
 clang/test/Interpreter/lambda.cpp   | 11 +--
 clang/unittests/Interpreter/InterpreterTest.cpp |  7 ---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/test/Interpreter/lambda.cpp 
b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..135f5fe604ae5 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,8 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +15,10 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error@+1 {{non-local lambda expression cannot have a 
capture-default}}
+auto capture = [&]() { return x * 2; };
+
+%quit
\ No newline at end of file
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 56ab155ebf5a4..578f1d4c0eac6 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -114,13 +114,6 @@ TEST_F(InterpreterTest, Errors) {
 
   RecoverErr = Interp->Parse("var1 = 424;");
   EXPECT_TRUE(!!RecoverErr);
-
-  Err = Interp->Parse("int x = 5; auto capture = [&]() { return x * 2; 
};").takeError();
-  EXPECT_THAT(DiagnosticOutput, HasSubstr("error: non-local lambda expression 
cannot ha

[clang] [clang-repl] Fix error recovery while PTU cleanup (PR #127467)

2025-03-10 Thread Anutosh Bhat via cfe-commits

https://github.com/anutosh491 updated 
https://github.com/llvm/llvm-project/pull/127467

>From 6ff448ed506e0ef75db2c9974a628a965e85df2f Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Mon, 17 Feb 2025 15:33:20 +0530
Subject: [PATCH 1/3] Fix error recovery while PTU cleanup

---
 clang/lib/Interpreter/IncrementalParser.cpp | 4 ++--
 clang/unittests/Interpreter/InterpreterTest.cpp | 7 +++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index e43cea1baf43a..1ebef0e434b3d 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -178,8 +178,8 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
 if (!ND)
   continue;
 // Check if we need to clean up the IdResolver chain.
-if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
-!D->getLangOpts().CPlusPlus)
+if (!ND->getDeclName().isEmpty() && ND->getDeclName().getFETokenInfo() &&
+!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
   S.IdResolver.RemoveDecl(ND);
   }
 }
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 578f1d4c0eac6..56ab155ebf5a4 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -114,6 +114,13 @@ TEST_F(InterpreterTest, Errors) {
 
   RecoverErr = Interp->Parse("var1 = 424;");
   EXPECT_TRUE(!!RecoverErr);
+
+  Err = Interp->Parse("int x = 5; auto capture = [&]() { return x * 2; 
};").takeError();
+  EXPECT_THAT(DiagnosticOutput, HasSubstr("error: non-local lambda expression 
cannot have a capture-default"));
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+
+  RecoverErr = Interp->Parse("int validVar = 10;");
+  EXPECT_TRUE(!!RecoverErr);
 }
 
 // Here we test whether the user can mix declarations and statements. The

>From 8b9a112721c45662374fd9995af6da4031507c89 Mon Sep 17 00:00:00 2001
From: Anutosh Bhat 
Date: Wed, 26 Feb 2025 16:55:31 +0530
Subject: [PATCH 2/3] Update IncrementalParser.cpp

---
 clang/lib/Interpreter/IncrementalParser.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index 1ebef0e434b3d..774219d9fc9ab 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -175,11 +175,11 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
 auto *ND = dyn_cast(D);
-if (!ND)
+if (!ND || ND->getDeclName().isEmpty()) 
   continue;
 // Check if we need to clean up the IdResolver chain.
-if (!ND->getDeclName().isEmpty() && ND->getDeclName().getFETokenInfo() &&
-!D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
+if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
+!D->getLangOpts().CPlusPlus)
   S.IdResolver.RemoveDecl(ND);
   }
 }

>From dae6ca63f0d443a6ec0df12e1abef183203c12de Mon Sep 17 00:00:00 2001
From: anutosh491 
Date: Tue, 11 Mar 2025 11:29:32 +0530
Subject: [PATCH 3/3] Add tests in lambda.cpp

---
 clang/test/Interpreter/lambda.cpp   | 11 +--
 clang/unittests/Interpreter/InterpreterTest.cpp |  7 ---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/test/Interpreter/lambda.cpp 
b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..135f5fe604ae5 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,8 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +15,10 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error@+1 {{non-local lambda expression cannot have a 
capture-default}}
+auto capture = [&]() { return x * 2; };
+
+%quit
\ No newline at end of file
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 56ab155ebf5a4..578f1d4c0eac6 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -114,13 +114,6 @@ TEST_F(InterpreterTest, Errors) {
 
   RecoverErr = Interp->Parse("var1 = 424;");
   EXPECT_TRUE(!!RecoverErr);
-
-  Err = Interp->Parse("int x = 5; auto capture = [&]() { return x * 2; 
};").takeError();
-  EXPECT_THAT(DiagnosticOutput, HasSubstr("error: non-local lambda expression 
cannot ha

[clang] [HLSL][SPIR-V] Add hlsl_private address space for HLSL/SPIR-V (PR #122103)

2025-03-10 Thread Helena Kotas via cfe-commits
Nathan =?utf-8?q?Gauër?= 
Message-ID:
In-Reply-To: 



@@ -5386,6 +5386,23 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const 
VarDecl *D) {
 if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS))
   return AS;
   }
+
+  if (LangOpts.HLSL) {
+if (D == nullptr)
+  return LangAS::hlsl_private;
+
+// Except resources (Uniform, UniformConstant) & instanglble (handles)

hekota wrote:

```suggestion
// Except resources (Uniform, UniformConstant) & intangible (handles)
```

https://github.com/llvm/llvm-project/pull/122103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [HLSL][NFC] Update resource metadata tests to not use obsolete annotations (PR #130222)

2025-03-10 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/130222

>From 99539251dcf58aab9a88973f9162156ae6f1aa77 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Thu, 6 Mar 2025 18:22:07 -0800
Subject: [PATCH 1/3] [HLSL][NFC] Update resource metadata tests to not use
 obsolete metadata annotations

---
 clang/test/CodeGenHLSL/cbuffer.hlsl   |  78 +-
 .../DirectX/Metadata/cbuffer_metadata.ll  |  80 +++
 .../CodeGen/DirectX/Metadata/srv_metadata.ll  | 103 +
 .../CodeGen/DirectX/Metadata/uav_metadata.ll  | 135 ++
 llvm/test/CodeGen/DirectX/UAVMetadata.ll  |  77 --
 llvm/test/CodeGen/DirectX/cbuf.ll |  37 -
 .../CodeGen/DirectX/legacy_cb_layout_0.ll |  14 --
 .../CodeGen/DirectX/legacy_cb_layout_1.ll |  37 -
 .../CodeGen/DirectX/legacy_cb_layout_2.ll |  51 ---
 .../CodeGen/DirectX/legacy_cb_layout_3.ll |  81 ---
 10 files changed, 394 insertions(+), 299 deletions(-)
 create mode 100644 llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
 create mode 100644 llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
 create mode 100644 llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
 delete mode 100644 llvm/test/CodeGen/DirectX/UAVMetadata.ll
 delete mode 100644 llvm/test/CodeGen/DirectX/cbuf.ll
 delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_0.ll
 delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_1.ll
 delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_2.ll
 delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_3.ll

diff --git a/clang/test/CodeGenHLSL/cbuffer.hlsl 
b/clang/test/CodeGenHLSL/cbuffer.hlsl
index 38093c6dfacd7..b5e435619438f 100644
--- a/clang/test/CodeGenHLSL/cbuffer.hlsl
+++ b/clang/test/CodeGenHLSL/cbuffer.hlsl
@@ -20,6 +20,14 @@
 // CHECK: %anon = type <{ float }>
 // CHECK: %anon.0 = type <{ <2 x i32> }>
 
+// CHECK: %__cblayout_CB_A = type <{ [2 x double], [3 x <3 x float>], float, 
[3 x double], half, [1 x <2 x double>], float, [2 x <3 x half>], <3 x half> }>
+// CHECK: %__cblayout_CB_B = type <{ [3 x <3 x double>], <3 x half> }>
+// CHECK: %__cblayout_CB_C = type <{ i32, target("dx.Layout", %F, 96, 0, 16, 
28, 32, 56, 64, 80, 84, 90), half, target("dx.Layout", %G, 258, 0, 48, 64, 
256), double }>
+
+// CHECK: %F = type <{ double, <3 x float>, float, <3 x double>, half, <2 x 
double>, float, <3 x half>, <3 x half> }>
+// CHECK: %G = type <{ target("dx.Layout", %E, 36, 0, 8, 16, 20, 22, 24, 32), 
[1 x float], [2 x target("dx.Layout", %F, 96, 0, 16, 28, 32, 56, 64, 80, 84, 
90)], half }>
+// CHECK: %E = type <{ float, double, float, half, i16, i64, i32 }>
+
 cbuffer CBScalars : register(b1, space5) {
   float a1;
   double a2;
@@ -155,6 +163,64 @@ cbuffer CBMix {
 uint16_t f9;
 };  
 
+// CHECK: @CB_A.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CB_A, 188, 0, 32, 76, 80, 120, 128, 144, 160, 
182))
+
+cbuffer CB_A {
+  double B0[2];
+  float3 B1[3];
+  float B2;
+  double B3[3];
+  half B4;
+  double2 B5[1];
+  float B6;
+  half3 B7[2];
+  half3 B8;
+}
+
+// CHECK: @CB_B.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CB_B, 94, 0, 88))
+cbuffer CB_B {
+  double3 B9[3];
+  half3 B10;
+}
+
+struct E {
+  float A0;
+  double A1;
+  float A2;
+  half A3;
+  int16_t A4;
+  int64_t A5;
+  int A6;
+};
+
+struct F {
+  double B0;
+  float3 B1;
+  float B2;
+  double3 B3;
+  half B4;
+  double2 B5;
+  float B6;
+  half3 B7;
+  half3 B8;
+};
+
+struct G {
+  E C0;
+  float C1[1];
+  F C2[2];
+  half C3;
+};
+
+// CHECK: @CB_C.cb = external constant target("dx.CBuffer", 
target("dx.Layout", %__cblayout_CB_C, 400, 0, 16, 112, 128, 392))
+cbuffer CB_C {
+  int D0;
+  F D1;
+  half D2;
+  G D3;
+  double D4;
+}
+
 // CHECK: define internal void @_init_resource_CBScalars.cb()
 // CHECK-NEXT: entry:
 // CHECK-NEXT: %[[HANDLE1:.*]] = call target("dx.CBuffer", target("dx.Layout", 
%__cblayout_CBScalars, 56, 0, 8, 16, 24, 32, 36, 40, 48))
@@ -171,7 +237,7 @@ RWBuffer Buf;
 
 [numthreads(4,1,1)]
 void main() {
-  Buf[0] = a1 + b1.z + c1[2] + a.f1.y + f1;
+  Buf[0] = a1 + b1.z + c1[2] + a.f1.y + f1 + B1[0].x + B10.z + D1.B2;
 }
 
 // CHECK: define internal void @_GLOBAL__sub_I_cbuffer.hlsl()
@@ -179,7 +245,8 @@ void main() {
 // CHECK-NEXT: call void @_init_resource_CBScalars.cb()
 // CHECK-NEXT: call void @_init_resource_CBArrays.cb()
 
-// CHECK: !hlsl.cbs = !{![[CBSCALARS:[0-9]+]], ![[CBVECTORS:[0-9]+]], 
![[CBARRAYS:[0-9]+]], ![[CBSTRUCTS:[0-9]+]], ![[CBMIX:[0-9]+]]}
+// CHECK: !hlsl.cbs = !{![[CBSCALARS:[0-9]+]], ![[CBVECTORS:[0-9]+]], 
![[CBARRAYS:[0-9]+]], ![[CBSTRUCTS:[0-9]+]], ![[CBMIX:[0-9]+]],
+// CHECK-SAME: ![[CB_A:[0-9]+]], ![[CB_B:[0-9]+]], ![[CB_C:[0-9]+]]}
 
 // CHECK: ![[CBSCALARS]] = !{ptr @CBScalars.cb, ptr addrspace(2) @a1, ptr 
addrspace(2) @a2, ptr addrspace(2) @a3, ptr addrspace(2) @a4,
 // CHECK-SAME: ptr addrspace(2) @a5, ptr addrspace(2) @a6, ptr

[clang] [CIR] Upstream initial support for CIR flattening (PR #130648)

2025-03-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)


Changes

The ClangIR CFG has to be flat before it can be lowered to LLVM IR. That is, 
there can be no nested regions and all blocks in a region must belong to the 
parent region. Currently only cir.scope operations violate these rules, so the 
initial implementation of the cir-flatten-cfg pass only has to transform scope 
operations.

---

Patch is 25.64 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/130648.diff


18 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/CMakeLists.txt (+6) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+40) 
- (added) clang/include/clang/CIR/Dialect/Passes.h (+39) 
- (added) clang/include/clang/CIR/Dialect/Passes.td (+28) 
- (modified) clang/include/clang/CIR/MissingFeatures.h (+1) 
- (modified) clang/lib/CIR/Dialect/CMakeLists.txt (+1) 
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+13) 
- (modified) clang/lib/CIR/Dialect/IR/CMakeLists.txt (+1) 
- (added) clang/lib/CIR/Dialect/Transforms/CMakeLists.txt (+18) 
- (added) clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp (+114) 
- (added) clang/lib/CIR/Dialect/Transforms/PassDetail.h (+29) 
- (added) clang/lib/CIR/Lowering/CIRPasses.cpp (+24) 
- (modified) clang/lib/CIR/Lowering/CMakeLists.txt (+19) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt (+3-1) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+99-3) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.h (+18) 
- (added) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp (+77) 
- (modified) clang/test/CIR/Lowering/func-simple.cpp (+20) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/CMakeLists.txt 
b/clang/include/clang/CIR/Dialect/CMakeLists.txt
index f33061b2d87cf..3d4e6586e1c62 100644
--- a/clang/include/clang/CIR/Dialect/CMakeLists.txt
+++ b/clang/include/clang/CIR/Dialect/CMakeLists.txt
@@ -1 +1,7 @@
 add_subdirectory(IR)
+
+set(LLVM_TARGET_DEFINITIONS Passes.td)
+mlir_tablegen(Passes.h.inc -gen-pass-decls -name CIR)
+mlir_tablegen(Passes.capi.h.inc -gen-pass-capi-header --prefix CIR)
+mlir_tablegen(Passes.capi.cpp.inc -gen-pass-capi-impl --prefix CIR)
+add_public_tablegen_target(MLIRCIRPassIncGen)
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index e2ab50c78ec2d..77c43e5ace64a 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -428,6 +428,46 @@ def ScopeOp : CIR_Op<"scope", [
   ];
 }
 
+//===--===//
+// BrOp
+//===--===//
+
+def BrOp : CIR_Op<"br",
+  [DeclareOpInterfaceMethods,
+ Pure, Terminator]> {
+  let summary = "Unconditional branch";
+  let description = [{
+The `cir.br` branches unconditionally to a block. Used to represent C/C++
+goto's and general block branching.
+
+Note that for source level `goto`'s crossing scope boundaries, those are
+usually represented with the "symbolic" `cir.goto` operation.
+
+Example:
+
+```mlir
+  ...
+cir.br ^bb3
+  ^bb3:
+cir.return
+```
+  }];
+
+  let builders = [
+OpBuilder<(ins "mlir::Block *":$dest,
+  CArg<"mlir::ValueRange", "{}">:$destOperands), [{
+  $_state.addSuccessors(dest);
+  $_state.addOperands(destOperands);
+}]>
+  ];
+
+  let arguments = (ins Variadic:$destOperands);
+  let successors = (successor AnySuccessor:$dest);
+  let assemblyFormat = [{
+$dest (`(` $destOperands^ `:` type($destOperands) `)`)? attr-dict
+  }];
+}
+
 
//===--===//
 // GlobalOp
 
//===--===//
diff --git a/clang/include/clang/CIR/Dialect/Passes.h 
b/clang/include/clang/CIR/Dialect/Passes.h
new file mode 100644
index 0..b691849dfc563
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/Passes.h
@@ -0,0 +1,39 @@
+//===- Passes.h - CIR pass entry points -*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+//
+// This header file defines prototypes that expose pass constructors.
+//
+//===--===//
+
+#ifndef CLANG_CIR_DIALECT_PASSES_H
+#define CLANG_CIR_DIALECT_PASSES_H
+
+#include "mlir/Pass/Pass.h"
+
+namespace clang {
+class ASTContext;
+}
+namespace mlir {
+
+std::unique_ptr createCIRFlattenCFGPass();
+
+void populateCIRPreLoweringPasses(mlir::OpPassManager &pm);
+
+//===---

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2025-03-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `bolt-x86_64-ubuntu-nfc` 
running on `bolt-worker` while building `llvm` at step 7 "build-bolt".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/92/builds/15078


Here is the relevant piece of the build log for the reference

```
Step 7 (build-bolt) failure: build (failure)
...
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for include file elf.h
-- Looking for include file elf.h - found
-- Configuring done
-- Generating done
-- Build files have been written to: 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/tools/bolt/bolt_rt-bins
0.991 [1824/2/250] Building CXX object 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o 
ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/lib/Support 
-I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support
 -I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/build/include 
-I/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -UNDEBUG -std=c++17  
-fno-exceptions -funwind-tables -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/Mustache.cpp.o -c 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp:109:12:
 error: declaration of ‘{anonymous}::Accessor llvm::mustache::Token::Accessor’ 
changes meaning of ‘Accessor’ [-fpermissive]
  109 |   Accessor Accessor;
  |^~~~
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp:19:7:
 note: ‘Accessor’ declared here as ‘using Accessor = class 
llvm::SmallVector >’
   19 | using Accessor = SmallVector;
  |   ^~~~
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp:186:18:
 error: declaration of ‘const Accessor llvm::mustache::ASTNode::Accessor’ 
changes meaning of ‘Accessor’ [-fpermissive]
  186 |   const Accessor Accessor;
  |  ^~~~
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp:19:7:
 note: ‘Accessor’ declared here as ‘using Accessor = class 
llvm::SmallVector >’
   19 | using Accessor = SmallVector;
  |   ^~~~
In file included from 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp:8:
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include/llvm/Support/Mustache.h:
 In constructor 
‘llvm::mustache::Template::Template(llvm::mustache::Template&&)’:
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include/llvm/Support/Mustache.h:123:12:
 warning: ‘llvm::mustache::Template::Tree’ will be initialized after [-Wreorder]
  123 |   ASTNode *Tree;
  |^~~~
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/include/llvm/Support/Mustache.h:120:26:
 warning:   ‘llvm::BumpPtrAllocator llvm::mustache::Template::AstAllocator’ 
[-Wreorder]
  120 |   llvm::BumpPtrAllocator AstAllocator;
  |  ^~~~
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-nfc/llvm-project/llvm/lib/Support/Mustache.cpp:769:1:
 warning:   when initialized here [-Wreorder]
  769 | Template::Template(Template &&Other) noexcept
  | ^~~~
1.183 [1824/1/251] Performing build step for 'bolt_rt'
0.070 [2/2/1] Building CXX object CMakeFiles/bolt_rt_hugify.dir/hugify.cpp.o
0.114 [1/2/2] Linking CXX static library lib/libbolt_rt_hugify.a
0.648 [1/1/3] Building CXX object CMakeFiles/bolt_rt_instr.dir/instr.cpp.o
0.688 [0/1/4] Linking CXX static library lib/libbolt_rt_instr.a
ninja: build stopped: subcommand failed.

```



https://github.com/llvm/llvm-project/pull/105893
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Don't remove parentheses separated from ellipsis by comma (PR #130471)

2025-03-10 Thread Owen Pan via cfe-commits

owenca wrote:

/cherry-pick 7d4d8509cbec7eecd8aaf2510015b54bc5c173e1

https://github.com/llvm/llvm-project/pull/130471
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Don't remove parentheses separated from ellipsis by comma (PR #130471)

2025-03-10 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#130702

https://github.com/llvm/llvm-project/pull/130471
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [alpha.webkit.UnretainedCallArgsChecker] Add a checker for NS or CF type call arguments. (PR #128586)

2025-03-10 Thread Rashmi Mudduluru via cfe-commits

t-rasmud wrote:

> This PR adds alpha.webkit.UnretainedCallArgsChecker by generalizing 
> RawPtrRefLocalVarsChecker.
Do you mean `RawPtrRefCallArgsChecker`?



https://github.com/llvm/llvm-project/pull/128586
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream initial support for CIR flattening (PR #130648)

2025-03-10 Thread Bruno Cardoso Lopes via cfe-commits

https://github.com/bcardosolopes edited 
https://github.com/llvm/llvm-project/pull/130648
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >