[clang] 616613c - [Clang] [Sema] Fix a crash when a `friend` function is redefined as deleted (#135679)

2025-04-16 Thread via cfe-commits

Author: Sirraide
Date: 2025-04-16T14:08:59+02:00
New Revision: 616613c80b75614736d0781d12c0e1237d79738f

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

LOG: [Clang] [Sema] Fix a crash when a `friend` function is redefined as 
deleted (#135679)

NB: This only fixes the crash introduced in Clang 19; we still accept
this code even though we shouldn’t:
```c++
struct S {
friend int f() { return 3; }
friend int f() = delete;
};
```
I tried figuring out a way to diagnose this redeclaration, but it seems
tricky because I kept running into issues around defaulted comparison
operators. From my testing, however, this fix here would still be
required even once we do start diagnosing this.

Fixes #135506.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/cxx2c-delete-with-message.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5af4c08f64cd8..0891fd058bb57 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -425,6 +425,8 @@ Bug Fixes in This Version
 - Fixed a clang 20 regression where diagnostics attached to some calls to 
member functions
   using C++23 "deducing this" did not have a diagnostic location (#GH135522)
 
+- Fixed a crash when a ``friend`` function is redefined as deleted. (#GH135506)
+
 Bug Fixes to Compiler Builtins
 ^^
 

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5f811c824e11d..127c0a4500a43 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16199,16 +16199,11 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
 // This is meant to pop the context added in ActOnStartOfFunctionDef().
 ExitFunctionBodyRAII ExitRAII(*this, isLambdaCallOperator(FD));
 if (FD) {
-  // If this is called by Parser::ParseFunctionDefinition() after marking
-  // the declaration as deleted, and if the deleted-function-body contains
-  // a message (C++26), then a DefaultedOrDeletedInfo will have already 
been
-  // added to store that message; do not overwrite it in that case.
-  //
-  // Since this would always set the body to 'nullptr' in that case anyway,
-  // which is already done when the function decl is initially created,
-  // always skipping this irrespective of whether there is a delete message
-  // should not be a problem.
-  if (!FD->isDeletedAsWritten())
+  // The function body and the DefaultedOrDeletedInfo, if present, use
+  // the same storage; don't overwrite the latter if the former is null
+  // (the body is initialised to null anyway, so even if the latter isn't
+  // present, this would still be a no-op).
+  if (Body)
 FD->setBody(Body);
   FD->setWillHaveBody(false);
 

diff  --git a/clang/test/SemaCXX/cxx2c-delete-with-message.cpp 
b/clang/test/SemaCXX/cxx2c-delete-with-message.cpp
index 22e65d902ecd4..5609da18c05aa 100644
--- a/clang/test/SemaCXX/cxx2c-delete-with-message.cpp
+++ b/clang/test/SemaCXX/cxx2c-delete-with-message.cpp
@@ -271,3 +271,33 @@ void operators() {
   if (to_int_int) {} // expected-error {{attempt to use a deleted function: 
deleted (TO, operator bool)}}
   static_cast(to_int_int); // expected-error {{static_cast from 'TO' to 'bool' uses deleted function: deleted (TO, operator bool)}}
 };
+
+namespace gh135506 {
+struct a {
+  // FIXME: We currently don't diagnose these invalid redeclarations if the
+  // second declaration is defaulted or deleted. This probably needs to be
+  // handled in ParseCXXInlineMethodDef() after parsing the defaulted/deleted
+  // body.
+  friend consteval int f() { return 3; }
+  friend consteval int f() = delete("foo");
+
+  friend consteval int g() { return 3; }
+  friend consteval int g() = delete;
+
+  friend int h() { return 3; }
+  friend int h() = delete;
+
+  friend consteval int i() = delete; // expected-note {{previous definition is 
here}}
+  friend consteval int i() { return 3; } // expected-error {{redefinition of 
'i'}}
+};
+
+struct b {
+  friend consteval bool operator==(b, b) { return true; } // expected-note 
{{previous declaration is here}}
+  friend consteval bool operator==(b, b) = default; // expected-error 
{{defaulting this equality comparison operator is not allowed because it was 
already declared outside the class}}
+};
+
+struct c {
+  friend consteval bool operator==(c, c) = default; // expected-note 
{{previous definition is here}}
+  friend consteval bool operator==(c, c) { return true; } // expected-error 
{{redefinition of 'operator=='}}
+};
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.o

[clang] [Clang] [Sema] Fix a crash when a `friend` function is redefined as deleted (PR #135679)

2025-04-16 Thread via cfe-commits

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


[clang] [Clang] [Sema] Fix a crash when a `friend` function is redefined as deleted (PR #135679)

2025-04-16 Thread via cfe-commits


@@ -271,3 +271,33 @@ void operators() {
   if (to_int_int) {} // expected-error {{attempt to use a deleted function: 
deleted (TO, operator bool)}}
   static_cast(to_int_int); // expected-error {{static_cast from 'TO' to 'bool' uses deleted function: deleted (TO, operator bool)}}
 };
+
+namespace gh135506 {
+struct a {
+  // FIXME: We currently don't diagnose these invalid redeclarations if the
+  // second declaration is defaulted or deleted. This probably needs to be
+  // handled in ParseCXXInlineMethodDef() after parsing the defaulted/deleted
+  // body.
+  friend consteval int f() { return 3; }
+  friend consteval int f() = delete("foo");
+
+  friend consteval int g() { return 3; }
+  friend consteval int g() = delete;
+
+  friend int h() { return 3; }
+  friend int h() = delete;
+
+  friend consteval int i() = delete; // expected-note {{previous definition is 
here}}
+  friend consteval int i() { return 3; } // expected-error {{redefinition of 
'i'}}
+};
+
+struct b {
+  friend consteval bool operator==(b, b) { return true; } // expected-note 
{{previous declaration is here}}
+  friend consteval bool operator==(b, b) = default; // expected-error 
{{defaulting this equality comparison operator is not allowed because it was 
already declared outside the class}}

Sirraide wrote:

Actually... the wording in the standard around this is a bit unclear (obviously 
this is ill-formed but I’m talking about the case where the first declaration 
is not a definition). I’ll investigate this some more.

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 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 
`clang,llvm` at step 2 "annotate".

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


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:520:
 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:520:
 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:520:
 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:520:
 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:520:
 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:520:
 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:520:
 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: 90290 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90
FAIL: Clang :: Interpreter/global-dtor.cpp (53653 of 90290)
 TEST 'Clang :: Interpreter/global-dtor.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
cat 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
 | 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang-repl 
| /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
 # RUN: at line 6
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang-repl
+ cat 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
JIT session error: In graph incr_module_10-jitted-objectbuffer, section 
.text.startup: relocation target "__dso_handle" at address 0x7b55c562 is 
out of range of Delta32 fixup at 0x7755c460d02f ( @ 
0x7755c460d010 + 0x1f)
error: Failed to materialize symbols: { (main, { $.incr_module_10.__inits.0, 
__clang_call_terminate, DW.ref.__gxx_personality_v0, d, _ZN1DC2Ev, _ZN1DD2Ev, 
__orc_init_func.incr_module_10 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_10 
}) }
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp:11:11:
 error: CHECK: expected string not found in input
// CHECK: D[f=1.00, m=0x0]
  ^
:1:1: note: scanning from here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
clang-repl> 
^
:1:11: note: possible intended match here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
clang-repl> 
  ^

Input file: 
Check file: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp

-dump-input=help explains the following input dump.

Input was:
<<
1: clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
clang-repl> clang-repl>  
check:11'0 
X
 error: no match found
check:11'1   ?  
 

[clang] [llvm] [AARCH64] Add FEAT_SSVE_FEXPA and fix unsupported features list (PR #134368)

2025-04-16 Thread via cfe-commits


@@ -74,12 +74,11 @@ def SVEUnsupported : AArch64Unsupported {
 }
 
 let F = [HasSME2p2, HasSVE2p2_or_SME2p2, HasNonStreamingSVE_or_SME2p2,
- HasNonStreamingSVE2p2_or_SME2p2, HasNonStreamingSVE2_or_SSVE_BitPerm,
- HasSME_MOP4, HasSME_TMOP] in
+ HasNonStreamingSVE2p2_or_SME2p2] in
 def SME2p2Unsupported : AArch64Unsupported;
 
 def SME2p1Unsupported : AArch64Unsupported {
-  let F = !listconcat([HasSME2p1, HasSVE2p1_or_SME2p1, 
HasNonStreamingSVE2p1_or_SSVE_AES],
+  let F = !listconcat([HasSME2p1, HasSVE2p1_or_SME2p1, 
HasNonStreamingSVE2p1_or_SSVE_AES, HasSME_MOP4, HasSME_TMOP, 
HasNonStreamingSVE_or_SSVE_FEXPA, HasNonStreamingSVE2_or_SSVE_BitPerm],

CarolineConcatto wrote:

nit: align

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 Thread via cfe-commits

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


[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@mysterymath In the meantime, can you please help us test the Fuchsia CI with 
this patch? I appreciate your help :)

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 Thread via cfe-commits


@@ -3107,6 +3107,24 @@ let TargetPrefix = "aarch64" in {
 }
   }
 
+  class SME_OuterProduct_TMOP_Intrinsic
+ : DefaultAttrsIntrinsic<[],
+ [llvm_i32_ty,
+  llvm_anyvector_ty,
+  LLVMMatchType<0>,
+  LLVMMatchType<0>,
+  llvm_nxv16i8_ty,
+  llvm_i32_ty],
+ [ImmArg>, ImmArg>,
+  IntrInaccessibleMemOnly]>;
+
+  def int_aarch64_sme_tmopa_za16 : SME_OuterProduct_TMOP_Intrinsic;

CarolineConcatto wrote:

nit: Maybe we should change sme_tmopa to be sme_ftmopa. It is not needed, it 
will make clear that is only for floating point type size

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 Thread via cfe-commits


@@ -104,6 +104,16 @@ class sme_outer_product_pseudo
   let usesCustomInserter = 1;
 }
 
+class sme_sparse_outer_product_pseudo
+: Pseudo<(outs), (ins i32imm:$tile, zn_ty:$zn, zm_ty:$zm, ZK:$zk, 
i32imm:$idx), []>,
+  Sched<[]> {
+  // Translated to the actual instructions in AArch64ISelLowering.cpp
+  let SMEMatrixType = za_flag;
+  let usesCustomInserter = 1;
+  let mayLoad = 1;

CarolineConcatto wrote:

Why do we need this here?

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 Thread via cfe-commits

https://github.com/CarolineConcatto commented:

Thank you Jonathan for the changes, we are almost there.


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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 Thread via cfe-commits


@@ -0,0 +1,162 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc -force-streaming -verify-machineinstrs < %s | FileCheck %s
+
+target triple = "aarch64-linux"
+
+define void @stmopa_za32_s8( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: stmopa_za32_s8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:stmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.stmopa.za32.nxv16i8(i32 0,  
%zn1,  %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @utmopa_za32_u8( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: utmopa_za32_u8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:utmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.utmopa.za32.nxv16i8(i32 0,  
%zn1,  %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @ustmopa_za32_u8_s8( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: ustmopa_za32_u8_s8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ustmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.ustmopa.za32.nxv16i8(i32 0,  
%zn1,  %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @sutmopa_za32_s8_u8( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: sutmopa_za32_s8_u8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:sutmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.sutmopa.za32.nxv16i8(i32 0,  
%zn1,  %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @stmopa_za32_s16( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: stmopa_za32_s16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:stmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.stmopa.za32.nxv8i16(i32 0,  
%zn1,  %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @utmopa_za32_u16( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: utmopa_za32_u16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:utmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.utmopa.za32.nxv8i16(i32 0,  
%zn1,  %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @ftmopa_za32_f16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: ftmopa_za32_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.za32.nxv8f16(i32 0,  
%zn1,  %zn2,  %zm,  
%zk, i32 0)
+  ret void
+}
+
+define void @bftmopa_za32_bf16( %zn1,  %zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: bftmopa_za32_bf16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:bftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.za32.nxv8bf16(i32 0,  
%zn1,  %zn2,  %zm,  
%zk, i32 0)
+  ret void
+}
+
+define void @ftmopa_za32_f32( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: ftmopa_za32_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.s, z1.s }, z2.s, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.za32.nxv4f32(i32 0,  
%zn1,  %zn2,  %zm,  
%zk, i32 0)
+  ret void
+}
+
+define void @ftmopa_za16_f16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: ftmopa_za16_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.h, 

[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits


@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )

frasercrmck wrote:

I'd prefer `if( DARCH STREQUAL spirv )` which better fits the current style.

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits


@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
   set( opt_flags )
   set( spvflags --spirv-max-version=1.1 )
   set( MACRO_ARCH SPIRV32 )
   if( ARCH STREQUAL spirv64 )
 set( MACRO_ARCH SPIRV64 )
   endif()
-elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+elseif( ${DARCH} STREQUAL clspv )
+  # Refer to https://github.com/google/clspv for OpenCL version.
+  set( opencl_lang_std "CL3.0" )

frasercrmck wrote:

Does this look okay, @rjodinchr?

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits


@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
   set( opt_flags )
   set( spvflags --spirv-max-version=1.1 )
   set( MACRO_ARCH SPIRV32 )
   if( ARCH STREQUAL spirv64 )
 set( MACRO_ARCH SPIRV64 )
   endif()
-elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+elseif( ${DARCH} STREQUAL clspv )
+  # Refer to https://github.com/google/clspv for OpenCL version.
+  set( opencl_lang_std "CL3.0" )
   set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
   set( opt_flags -O3 )
   set( MACRO_ARCH CLSPV32 )
   if( ARCH STREQUAL clspv64 )
 set( MACRO_ARCH CLSPV64 )
   endif()
+elseif( ${DARCH} STREQUAL nvptx )
+  # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV 
implementation.
+  set( opencl_lang_std "CL3.0" )
+  set( build_flags )
+  set( opt_flags -O3 )
+  set( MACRO_ARCH ${ARCH} )
+elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa )
+  # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL 
version.
+  set( opencl_lang_std "CL2.0" )

frasercrmck wrote:

CC @arsenm

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits


@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
   set( opt_flags )
   set( spvflags --spirv-max-version=1.1 )
   set( MACRO_ARCH SPIRV32 )
   if( ARCH STREQUAL spirv64 )
 set( MACRO_ARCH SPIRV64 )
   endif()
-elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+elseif( ${DARCH} STREQUAL clspv )
+  # Refer to https://github.com/google/clspv for OpenCL version.
+  set( opencl_lang_std "CL3.0" )
   set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
   set( opt_flags -O3 )
   set( MACRO_ARCH CLSPV32 )
   if( ARCH STREQUAL clspv64 )
 set( MACRO_ARCH CLSPV64 )
   endif()
+elseif( ${DARCH} STREQUAL nvptx )
+  # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV 
implementation.

frasercrmck wrote:

I'm not sure who could verify this, or who even uses libclc built for nvptx.

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck commented:

Yes I think on reflection it's probably okay to compile for the highest 
supported OpenCL C version. I believe they're supersets of one another, so a 
3.0 builtins library would still contain all of the 1.2 builtins? I might be 
missing some of the nitty gritty here though.

Another question would be whether or not we should be advertising a 2.X or 3.X 
library if we don't have all the builtins? Is this a degradation? That might 
depend on downstream toolchains and if/how they react to versioning info in the 
LLVM IR.

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-16 Thread Fraser Cormack via cfe-commits


@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )

frasercrmck wrote:

Does this look okay to you, @airlied?

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


[clang] [clang][bytecode] Fix comparing zero-sized pointers (PR #135929)

2025-04-16 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/135929

Add the appropriate diagnostic and fix the d-d case.

>From 685749dcf6fbbb4905922ce002180217947ca8f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 16 Apr 2025 08:37:23 +0200
Subject: [PATCH] [clang][bytecode] Fix comparing zero-sized pointers

Add the appropriate diagnostic and fix the d-d case.
---
 clang/lib/AST/ByteCode/Interp.h| 30 --
 clang/lib/AST/ByteCode/Pointer.h   |  9 ++--
 clang/test/AST/ByteCode/arrays.cpp |  6 +-
 clang/test/AST/ByteCode/new-delete.cpp | 25 +
 4 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index b4e15b3ffbe68..88a011efe708e 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2141,12 +2141,25 @@ static inline bool DecPtr(InterpState &S, CodePtr OpPC) 
{
 
 /// 1) Pops a Pointer from the stack.
 /// 2) Pops another Pointer from the stack.
-/// 3) Pushes the different of the indices of the two pointers on the stack.
+/// 3) Pushes the difference of the indices of the two pointers on the stack.
 template ::T>
 inline bool SubPtr(InterpState &S, CodePtr OpPC) {
   const Pointer &LHS = S.Stk.pop();
   const Pointer &RHS = S.Stk.pop();
 
+  if (!Pointer::hasSameBase(LHS, RHS) && S.getLangOpts().CPlusPlus) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_pointer_arith_unspecified)
+<< LHS.toDiagnosticString(S.getASTContext())
+<< RHS.toDiagnosticString(S.getASTContext());
+return false;
+  }
+
+  if (LHS == RHS) {
+S.Stk.push();
+return true;
+  }
+
   for (const Pointer &P : {LHS, RHS}) {
 if (P.isZeroSizeArray()) {
   QualType PtrT = P.getType();
@@ -2163,21 +2176,6 @@ inline bool SubPtr(InterpState &S, CodePtr OpPC) {
 }
   }
 
-  if (RHS.isZero()) {
-S.Stk.push(T::from(LHS.getIndex()));
-return true;
-  }
-
-  if (!Pointer::hasSameBase(LHS, RHS) && S.getLangOpts().CPlusPlus) {
-// TODO: Diagnose.
-return false;
-  }
-
-  if (LHS.isZero() && RHS.isZero()) {
-S.Stk.push();
-return true;
-  }
-
   T A = LHS.isBlockPointer()
 ? (LHS.isElementPastEnd() ? T::from(LHS.getNumElems())
   : T::from(LHS.getIndex()))
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 5eef9d2e1885e..8ede706f2736f 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -129,12 +129,17 @@ class Pointer {
   return false;
 if (isIntegralPointer())
   return P.asIntPointer().Value == asIntPointer().Value &&
- Offset == P.Offset;
+ P.asIntPointer().Desc == asIntPointer().Desc && P.Offset == 
Offset;
+
+if (isFunctionPointer())
+  return P.asFunctionPointer().getFunction() ==
+ asFunctionPointer().getFunction() &&
+ P.Offset == Offset;
 
 assert(isBlockPointer());
 return P.asBlockPointer().Pointee == asBlockPointer().Pointee &&
P.asBlockPointer().Base == asBlockPointer().Base &&
-   Offset == P.Offset;
+   P.Offset == Offset;
   }
 
   bool operator!=(const Pointer &P) const { return !(P == *this); }
diff --git a/clang/test/AST/ByteCode/arrays.cpp 
b/clang/test/AST/ByteCode/arrays.cpp
index 8af82163fd815..f60cc19b09bd2 100644
--- a/clang/test/AST/ByteCode/arrays.cpp
+++ b/clang/test/AST/ByteCode/arrays.cpp
@@ -106,7 +106,8 @@ constexpr int k1 = &arr[1] - &arr[0];
 static_assert(k1 == 1, "");
 static_assert((&arr[0] - &arr[1]) == -1, "");
 
-constexpr int k2 = &arr2[1] - &arr[0]; // both-error {{must be initialized by 
a constant expression}}
+constexpr int k2 = &arr2[1] - &arr[0]; // both-error {{must be initialized by 
a constant expression}} \
+   // expected-note {{arithmetic involving 
unrelated objects}}
 
 static_assert((arr + 0) == arr, "");
 static_assert(&arr[0] == arr, "");
@@ -735,6 +736,9 @@ namespace ZeroSizeTypes {
 return &arr[3] - &arr[0]; // both-note {{subtraction of pointers to type 
'int[0]' of zero size}} \
   // both-warning {{subtraction of pointers to 
type 'int[0]' of zero size has undefined behavior}}
   }
+
+  constexpr int z[0]{};
+  static_assert((z - z) == 0);
 }
 
 namespace InvalidIndex {
diff --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index bd7351cbc3d4c..5ddd7070f6710 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -967,6 +967,31 @@ namespace PR45350 {
   static_assert(f(6) == 543210);
 }
 
+namespace ZeroSizeSub {
+  consteval unsigned ptr_diff1() {
+int *b = new int[0];
+unsigned d = 0;
+d = b - b;
+delete[] b;
+
+return d;
+  }
+  static_assert(ptr_diff1() == 0);
+
+
+  consteval unsigne

[clang] [Lex] Use llvm::make_second_range (NFC) (PR #135902)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-dap/memory/TestDAP_memory.py (1174 of 2954)
PASS: lldb-api :: tools/lldb-dap/optimized/TestDAP_optimized.py (1175 of 2954)
PASS: lldb-api :: tools/lldb-dap/output/TestDAP_output.py (1176 of 2954)
PASS: lldb-api :: tools/lldb-dap/evaluate/TestDAP_evaluate.py (1177 of 2954)
PASS: lldb-api :: tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py (1178 
of 2954)
PASS: lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py (1179 of 2954)
UNSUPPORTED: lldb-api :: 
tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py (1180 of 2954)
UNSUPPORTED: lldb-api :: tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
(1181 of 2954)
UNSUPPORTED: lldb-api :: tools/lldb-dap/save-core/TestDAP_save_core.py (1182 of 
2954)
UNRESOLVED: lldb-api :: tools/lldb-dap/module/TestDAP_module.py (1183 of 2954)
 TEST 'lldb-api :: tools/lldb-dap/module/TestDAP_module.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/module
 -p TestDAP_module.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
3d97d71e66036f51cf0b45cc7d5f3a0a14192eb4)
  clang revision 3d97d71e66036f51cf0b45cc7d5f3a0a14192eb4
  llvm revision 3d97d71e66036f51cf0b45cc7d5f3a0a14192eb4
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
= DEBUG ADAPTER PROTOCOL LOGS =
1744789923.479731560 --> (stdin/stdout) 
{"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1}
1744789923.485148668 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb 
version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
3d97d71e66036f51cf0b45cc7d5f3a0a14192eb4)\n  clang revision 
3d97d71e66036f51cf0b45cc7d5f3a0a14192eb4\n  llvm revision 
3d97d71e66036f51cf0b45cc7d5f3a0a14192eb4","completionTriggerCharacters":["."," 
","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++
 Catch"},{"default":false,"filter":"cpp_throw","label":"C++ 
Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C 
Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C 
Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsDisassembleRequest":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsInstructionBreakpoints":true,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsReadMemoryRequest":true,"supportsRestartRequest":true,"supportsSetVariable":true,"supportsStepInTargetsRequest":true,"supportsSteppingGranularity":true,"supportsValueFormattingOptions":true},"command":"initialize","request_seq":1,"seq":0,"success":true,"type":"response"}
17

[clang] [clang][bytecode] Fix comparing zero-sized pointers (PR #135929)

2025-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Add the appropriate diagnostic and fix the d-d case.

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


4 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.h (+14-16) 
- (modified) clang/lib/AST/ByteCode/Pointer.h (+7-2) 
- (modified) clang/test/AST/ByteCode/arrays.cpp (+5-1) 
- (modified) clang/test/AST/ByteCode/new-delete.cpp (+25) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index b4e15b3ffbe68..88a011efe708e 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2141,12 +2141,25 @@ static inline bool DecPtr(InterpState &S, CodePtr OpPC) 
{
 
 /// 1) Pops a Pointer from the stack.
 /// 2) Pops another Pointer from the stack.
-/// 3) Pushes the different of the indices of the two pointers on the stack.
+/// 3) Pushes the difference of the indices of the two pointers on the stack.
 template ::T>
 inline bool SubPtr(InterpState &S, CodePtr OpPC) {
   const Pointer &LHS = S.Stk.pop();
   const Pointer &RHS = S.Stk.pop();
 
+  if (!Pointer::hasSameBase(LHS, RHS) && S.getLangOpts().CPlusPlus) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_pointer_arith_unspecified)
+<< LHS.toDiagnosticString(S.getASTContext())
+<< RHS.toDiagnosticString(S.getASTContext());
+return false;
+  }
+
+  if (LHS == RHS) {
+S.Stk.push();
+return true;
+  }
+
   for (const Pointer &P : {LHS, RHS}) {
 if (P.isZeroSizeArray()) {
   QualType PtrT = P.getType();
@@ -2163,21 +2176,6 @@ inline bool SubPtr(InterpState &S, CodePtr OpPC) {
 }
   }
 
-  if (RHS.isZero()) {
-S.Stk.push(T::from(LHS.getIndex()));
-return true;
-  }
-
-  if (!Pointer::hasSameBase(LHS, RHS) && S.getLangOpts().CPlusPlus) {
-// TODO: Diagnose.
-return false;
-  }
-
-  if (LHS.isZero() && RHS.isZero()) {
-S.Stk.push();
-return true;
-  }
-
   T A = LHS.isBlockPointer()
 ? (LHS.isElementPastEnd() ? T::from(LHS.getNumElems())
   : T::from(LHS.getIndex()))
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index 5eef9d2e1885e..8ede706f2736f 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -129,12 +129,17 @@ class Pointer {
   return false;
 if (isIntegralPointer())
   return P.asIntPointer().Value == asIntPointer().Value &&
- Offset == P.Offset;
+ P.asIntPointer().Desc == asIntPointer().Desc && P.Offset == 
Offset;
+
+if (isFunctionPointer())
+  return P.asFunctionPointer().getFunction() ==
+ asFunctionPointer().getFunction() &&
+ P.Offset == Offset;
 
 assert(isBlockPointer());
 return P.asBlockPointer().Pointee == asBlockPointer().Pointee &&
P.asBlockPointer().Base == asBlockPointer().Base &&
-   Offset == P.Offset;
+   P.Offset == Offset;
   }
 
   bool operator!=(const Pointer &P) const { return !(P == *this); }
diff --git a/clang/test/AST/ByteCode/arrays.cpp 
b/clang/test/AST/ByteCode/arrays.cpp
index 8af82163fd815..f60cc19b09bd2 100644
--- a/clang/test/AST/ByteCode/arrays.cpp
+++ b/clang/test/AST/ByteCode/arrays.cpp
@@ -106,7 +106,8 @@ constexpr int k1 = &arr[1] - &arr[0];
 static_assert(k1 == 1, "");
 static_assert((&arr[0] - &arr[1]) == -1, "");
 
-constexpr int k2 = &arr2[1] - &arr[0]; // both-error {{must be initialized by 
a constant expression}}
+constexpr int k2 = &arr2[1] - &arr[0]; // both-error {{must be initialized by 
a constant expression}} \
+   // expected-note {{arithmetic involving 
unrelated objects}}
 
 static_assert((arr + 0) == arr, "");
 static_assert(&arr[0] == arr, "");
@@ -735,6 +736,9 @@ namespace ZeroSizeTypes {
 return &arr[3] - &arr[0]; // both-note {{subtraction of pointers to type 
'int[0]' of zero size}} \
   // both-warning {{subtraction of pointers to 
type 'int[0]' of zero size has undefined behavior}}
   }
+
+  constexpr int z[0]{};
+  static_assert((z - z) == 0);
 }
 
 namespace InvalidIndex {
diff --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index bd7351cbc3d4c..5ddd7070f6710 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -967,6 +967,31 @@ namespace PR45350 {
   static_assert(f(6) == 543210);
 }
 
+namespace ZeroSizeSub {
+  consteval unsigned ptr_diff1() {
+int *b = new int[0];
+unsigned d = 0;
+d = b - b;
+delete[] b;
+
+return d;
+  }
+  static_assert(ptr_diff1() == 0);
+
+
+  consteval unsigned ptr_diff2() { // both-error {{never produces a constant 
expression}}
+int *a = new int[0];
+int *b = new int[0];
+
+unsigned d = a - b; // both-note 2{{arithmetic involving unrelated 
objects}}
+delete[] b;
+delete[]

[clang] [clang] fix unresolved dependent template specialization mangling (PR #135111)

2025-04-16 Thread Utkarsh Saxena via cfe-commits

usx95 wrote:

https://godbolt.org/z/sY44dG6Ya is the reproducer. It is not super small but 
still should give an idea as the stack is quite similar to stuff touched by 
this PR.

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


[clang] 3d7e56f - [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (#135145)

2025-04-16 Thread via cfe-commits

Author: Jonathan Thackray
Date: 2025-04-16T10:59:07+01:00
New Revision: 3d7e56fd28cd2195e7f330f933d491530e274401

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

LOG: [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) 
intrinsics (#135145)

Implement all {BF/F/S/U/SU/US}TMOP intrinsics in clang and llvm
following the ACLE in https://github.com/ARM-software/acle/pull/380/files

Added: 
clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c
clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_tmop.cpp
llvm/test/CodeGen/AArch64/sme2-intrinsics-tmop.ll

Modified: 
clang/include/clang/Basic/arm_sme.td
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64RegisterInfo.td
llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
llvm/lib/Target/AArch64/SMEInstrFormats.td
llvm/test/CodeGen/AArch64/GlobalISel/regbank-inlineasm.mir
llvm/test/CodeGen/AArch64/emit_fneg_with_non_register_operand.mir
llvm/test/CodeGen/AArch64/peephole-insvigpr.mir

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 1bfcf4c31d552..3647fc7a27d83 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -907,6 +907,33 @@ let SMETargetGuard = "sme-f16f16" in {
 }
 
 
+
+// SME2 - TMOP, SUTMOP, USTMOP
+
+let SMETargetGuard = "sme2,sme-tmop" in {
+  def SVTMOPA_ZA32   : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "hbf",  
MergeNone, "aarch64_sme_ftmopa_za32",  [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>;
+  def SVSTMOPA_ZA32  : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "cs",   
MergeNone, "aarch64_sme_stmopa_za32",  [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>;
+  def SVUTMOPA_ZA32  : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2d[i", "UcUs", 
MergeNone, "aarch64_sme_utmopa_za32",  [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>;
+  def SVSUTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{3}]", "vi2u[i", "c",
MergeNone, "aarch64_sme_sutmopa_za32", [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>;
+  def SVUSTMOPA_ZA32 : Inst<"svtmopa_lane_za32[_{d}_{3}]", "vi2x[i", "Uc",   
MergeNone, "aarch64_sme_ustmopa_za32", [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>;
+}
+
+let SMETargetGuard = "sme2,sme-tmop,sme-f16f16" in {
+  def SVTMOPA_F16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "h", 
MergeNone, "aarch64_sme_ftmopa_za16", [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_1>, ImmCheck<4, ImmCheck0_3>]>;
+}
+
+let SMETargetGuard = "sme2,sme-tmop,sme-b16b16" in {
+  def SVTMOPA_BF16 : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2d[i", "b", 
MergeNone, "aarch64_sme_ftmopa_za16", [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_1>, ImmCheck<4, ImmCheck0_3>]>;
+}
+
+let SMETargetGuard = "sme2,sme-tmop,sme-f8f16" in {
+  def SVTMOPA_ZA16_FPM : Inst<"svtmopa_lane_za16[_{d}_{d}]", "vi2.dd[i>", "m", 
MergeNone, "aarch64_sme_ftmopa_za16", [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_1>, ImmCheck<4, ImmCheck0_3>]>;
+}
+
+let SMETargetGuard = "sme2,sme-tmop,sme-f8f32" in {
+  def SVTMOPA_ZA32_FPM : Inst<"svtmopa_lane_za32[_{d}_{d}]", "vi2.dd[i>", "m", 
MergeNone, "aarch64_sme_ftmopa_za32", [IsStreaming, IsInOutZA], [ImmCheck<0, 
ImmCheck0_3>, ImmCheck<4, ImmCheck0_3>]>;
+}
+
 multiclass ZAReadz ch> {
   let SMETargetGuard = "sme2p1" in {
 def NAME # _H : SInst<"svreadz_hor_" # n_suffix # "_{d}_vg" # vg_num, 
vg_num # "im", t,

diff  --git a/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c 
b/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c
new file mode 100644
index 0..55d0074663bc9
--- /dev/null
+++ b/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_tmop.c
@@ -0,0 +1,202 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sme-tmop -target-feature 
+sme-f16f16 -target-feature +sme-f8f32 -target-feature +sme-b16b16 
-target-feature +sme-f8f16 -target-feature +sme -target-feature +sme2 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sme-tmop -target-feature 
+sme-f16f16 -target-feature +sme-f8f32 -target-feature +sme-b16b16 
-target-feature +sme-f8f16 -target-feature +sme -target-feature +sme2 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK

[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-16 Thread Jonathan Thackray via cfe-commits

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


[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-16 Thread via cfe-commits

R-Goc wrote:

It appears that gcc only disallows '&' in identifiers in C++26 mode. Not sure 
how relevant that is to clang. 
[bugzilla](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110343)

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


[clang] [llvm] Reland: [llvm][clang] Allocate a new stack instead of spawning a new thread to get more stack space (PR #136046)

2025-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Michael Spencer (Bigcheese)


Changes

Reland https://github.com/llvm/llvm-project/pull/133173. This changes the 
assembly code to use `.cfi_{start,end}proc` directly in a file scope asm 
statement and restricts enabling it to MachO to help ensure that the assembly 
is only used where it's valid. The previous code had issues with the 
`-fno-asynchronous-unwind-tables -g0` configuration due to naked functions 
being responsible for emitting `.cfi_{start,end}proc`. There's not a good way 
to detect if CFI is enabled in general, so we always emit it. Removing CFI is 
only done as a size optimization, so having it for one function is fine.

GCC actually does have `__GCC_HAVE_DWARF2_CFI_ASM` when it's emitting CFI 
directives, but Clang does not. compiler-rt just always emits CFI directives 
when built using Clang.

This also includes the other follow up fixes for GCC compatibility and fixing 
thread.h

---

Clang spawns a new thread to avoid running out of stack space. This can make 
debugging and performance analysis more difficult as how the threads are 
connected is difficult to recover.

This patch introduces `runOnNewStack` and applies it in Clang. On platforms 
that have good support for it this allocates a new stack and moves to it using 
assembly. Doing split stacks like this actually runs on most platforms, but 
many debuggers and unwinders reject the large or backwards stack offsets that 
occur. Apple platforms and tools are known to support this, so this only 
enables it there for now.

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


12 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4) 
- (modified) clang/include/clang/Basic/Stack.h (+4-1) 
- (modified) clang/lib/Basic/Stack.cpp (+12-28) 
- (modified) clang/lib/Frontend/CompilerInstance.cpp (+1-1) 
- (modified) llvm/include/llvm/Support/CrashRecoveryContext.h (+3) 
- (added) llvm/include/llvm/Support/ProgramStack.h (+63) 
- (modified) llvm/include/llvm/Support/thread.h (+1) 
- (modified) llvm/lib/Support/CMakeLists.txt (+1) 
- (modified) llvm/lib/Support/CrashRecoveryContext.cpp (+11) 
- (added) llvm/lib/Support/ProgramStack.cpp (+127) 
- (modified) llvm/unittests/Support/CMakeLists.txt (+1) 
- (added) llvm/unittests/Support/ProgramStackTest.cpp (+35) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 07ff1251fc1ad..7d714d93ce854 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -195,6 +195,10 @@ Non-comprehensive list of changes in this release
 - Added `__builtin_elementwise_exp10`.
 - For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the 
`v_cvt_off_f32_i4` instruction.
 - Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
+- Clang itself now uses split stacks instead of threads for allocating more
+  stack space when running on Apple AArch64 based platforms. This means that
+  stack traces of Clang from debuggers, crashes, and profilers may look
+  different than before.
 
 New Compiler Flags
 --
diff --git a/clang/include/clang/Basic/Stack.h 
b/clang/include/clang/Basic/Stack.h
index 30ebd94aedd1f..9674b9d9b62c3 100644
--- a/clang/include/clang/Basic/Stack.h
+++ b/clang/include/clang/Basic/Stack.h
@@ -27,7 +27,10 @@ namespace clang {
 
   /// Call this once on each thread, as soon after starting the thread as
   /// feasible, to note the approximate address of the bottom of the stack.
-  void noteBottomOfStack();
+  ///
+  /// \param ForceSet set to true if you know the call is near the bottom of a
+  /// new stack. Used for split stacks.
+  void noteBottomOfStack(bool ForceSet = false);
 
   /// Determine whether the stack is nearly exhausted.
   bool isStackNearlyExhausted();
diff --git a/clang/lib/Basic/Stack.cpp b/clang/lib/Basic/Stack.cpp
index aa15d8e66950f..8cbb84943f8d3 100644
--- a/clang/lib/Basic/Stack.cpp
+++ b/clang/lib/Basic/Stack.cpp
@@ -13,33 +13,13 @@
 
 #include "clang/Basic/Stack.h"
 #include "llvm/Support/CrashRecoveryContext.h"
+#include "llvm/Support/ProgramStack.h"
 
-#ifdef _MSC_VER
-#include   // for _AddressOfReturnAddress
-#endif
+static LLVM_THREAD_LOCAL uintptr_t BottomOfStack = 0;
 
-static LLVM_THREAD_LOCAL void *BottomOfStack = nullptr;
-
-static void *getStackPointer() {
-#if __GNUC__ || __has_builtin(__builtin_frame_address)
-  return __builtin_frame_address(0);
-#elif defined(_MSC_VER)
-  return _AddressOfReturnAddress();
-#else
-  char CharOnStack = 0;
-  // The volatile store here is intended to escape the local variable, to
-  // prevent the compiler from optimizing CharOnStack into anything other
-  // than a char on the stack.
-  //
-  // Tested on: MSVC 2015 - 2019, GCC 4.9 - 9, Clang 3.2 - 9, ICC 13 - 19.
-  char *volatile Ptr = &CharOnStack;
-  return Ptr;
-#endif
-}
-
-void clang::noteBottomOfStack() {
-  if (!BottomOfStack)
-BottomOfStack = getStackPointer();
+void 

[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

2025-04-16 Thread Theo de Magalhaes via cfe-commits

https://github.com/theomagellan created 
https://github.com/llvm/llvm-project/pull/136062

Aims to fix #131647.

>From 842f0fbed0043ad0aa1679d8a30bc13d64eb25cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20de=20Magalhaes?= 
Date: Thu, 17 Apr 2025 01:45:12 +0200
Subject: [PATCH] fix(ms_struct): bitfield padding warning presents padding to
 exact bit count

---
 clang/lib/AST/RecordLayoutBuilder.cpp   |  4 +++-
 clang/test/SemaCXX/windows-Wpadded-bitfield.cpp | 15 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index ea353f88a8aec..ca08e186f4ff2 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,6 +1538,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
   bool AlignIsRequired = FieldInfo.isAlignRequired();
+  unsigned char PaddingInLastUnit = 0;
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1610,6 +1611,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   if (!LastBitfieldStorageUnitSize && !FieldSize)
 FieldAlign = 1;
 
+  PaddingInLastUnit = UnfilledBitsInLastUnit;
   UnfilledBitsInLastUnit = 0;
   LastBitfieldStorageUnitSize = 0;
 }
@@ -1706,7 +1708,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   // For purposes of diagnostics, we're going to simultaneously
   // compute the field offsets that we would have used if we weren't
   // adding any alignment padding or if the field weren't packed.
-  uint64_t UnpaddedFieldOffset = FieldOffset;
+  uint64_t UnpaddedFieldOffset = FieldOffset - PaddingInLastUnit;
   uint64_t UnpackedFieldOffset = FieldOffset;
 
   // Check if we need to add padding to fit the bitfield within an
diff --git a/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp 
b/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
index ee5a57124eca5..0b88b4c170617 100644
--- a/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
+++ b/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -Wpadded 
%s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -Wpadded %s
 
 struct __attribute__((ms_struct)) BitfieldStruct { // expected-warning 
{{padding size of 'BitfieldStruct' with 3 bytes to alignment boundary}}
   char c : 1;
@@ -24,9 +25,23 @@ struct __attribute__((ms_struct)) DifferentUnitSizeBitfield 
{ // expected-warnin
   char i; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' 
with 31 bits to align 'i'}}
 };
 
+struct __attribute__((ms_struct)) Foo { // expected-warning {{padding size of 
'Foo' with 63 bits to alignment boundary}}
+  long long x;
+  char a : 1;
+  long long b : 1; // expected-warning {{padding struct 'Foo' with 63 bits to 
align 'b'}}
+};
+
+struct __attribute__((ms_struct)) SameUnitSizeMultiple { // expected-warning 
{{padding size of 'SameUnitSizeMultiple' with 2 bits to alignment boundary}}
+  char c : 1;
+  char cc : 2;
+  char ccc : 3;
+};
+
 int main() {
   BitfieldStruct b;
   SevenBitfieldStruct s;
   SameUnitSizeBitfield su;
   DifferentUnitSizeBitfield du;
+  Foo f;
+  SameUnitSizeMultiple susm;
 }

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


[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

2025-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Theo de Magalhaes (theomagellan)


Changes

Aims to fix #131647.

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


2 Files Affected:

- (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+3-1) 
- (modified) clang/test/SemaCXX/windows-Wpadded-bitfield.cpp (+15) 


``diff
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index ea353f88a8aec..ca08e186f4ff2 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,6 +1538,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
   bool AlignIsRequired = FieldInfo.isAlignRequired();
+  unsigned char PaddingInLastUnit = 0;
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1610,6 +1611,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   if (!LastBitfieldStorageUnitSize && !FieldSize)
 FieldAlign = 1;
 
+  PaddingInLastUnit = UnfilledBitsInLastUnit;
   UnfilledBitsInLastUnit = 0;
   LastBitfieldStorageUnitSize = 0;
 }
@@ -1706,7 +1708,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   // For purposes of diagnostics, we're going to simultaneously
   // compute the field offsets that we would have used if we weren't
   // adding any alignment padding or if the field weren't packed.
-  uint64_t UnpaddedFieldOffset = FieldOffset;
+  uint64_t UnpaddedFieldOffset = FieldOffset - PaddingInLastUnit;
   uint64_t UnpackedFieldOffset = FieldOffset;
 
   // Check if we need to add padding to fit the bitfield within an
diff --git a/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp 
b/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
index ee5a57124eca5..0b88b4c170617 100644
--- a/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
+++ b/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -Wpadded 
%s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -Wpadded %s
 
 struct __attribute__((ms_struct)) BitfieldStruct { // expected-warning 
{{padding size of 'BitfieldStruct' with 3 bytes to alignment boundary}}
   char c : 1;
@@ -24,9 +25,23 @@ struct __attribute__((ms_struct)) DifferentUnitSizeBitfield 
{ // expected-warnin
   char i; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' 
with 31 bits to align 'i'}}
 };
 
+struct __attribute__((ms_struct)) Foo { // expected-warning {{padding size of 
'Foo' with 63 bits to alignment boundary}}
+  long long x;
+  char a : 1;
+  long long b : 1; // expected-warning {{padding struct 'Foo' with 63 bits to 
align 'b'}}
+};
+
+struct __attribute__((ms_struct)) SameUnitSizeMultiple { // expected-warning 
{{padding size of 'SameUnitSizeMultiple' with 2 bits to alignment boundary}}
+  char c : 1;
+  char cc : 2;
+  char ccc : 3;
+};
+
 int main() {
   BitfieldStruct b;
   SevenBitfieldStruct s;
   SameUnitSizeBitfield su;
   DifferentUnitSizeBitfield du;
+  Foo f;
+  SameUnitSizeMultiple susm;
 }

``




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


[clang] Mark the file opened by DeserializedDeclsSourceRangePrinter as a text file (PR #135842)

2025-04-16 Thread Zibi Sarbinowski via cfe-commits

https://github.com/zibi2 updated 
https://github.com/llvm/llvm-project/pull/135842

>From b162b0476058c40b2fcbf7ef397696caead11a7f Mon Sep 17 00:00:00 2001
From: Zibi Sarbinowski 
Date: Tue, 15 Apr 2025 19:10:02 +
Subject: [PATCH 1/3] Mark the file opened by
 DeserializedDeclsSourceRangePrinter as a text file

---
 clang/lib/Frontend/FrontendAction.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index bd084aa94fc37..1c4dec08575d1 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -312,7 +312,7 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
&CI,
 std::error_code ErrorCode;
 auto FileStream = std::make_unique(
 DumpDeserializedDeclarationRangesPath, ErrorCode,
-llvm::sys::fs::OF_None);
+llvm::sys::fs::OF_TextWithCRLF);
 if (!ErrorCode) {
   
Consumers.push_back(std::make_unique(
   CI.getSourceManager(), std::move(FileStream)));

>From d4cfd87c1c363488c6eb2410e5b01d88ac283a4e Mon Sep 17 00:00:00 2001
From: Zibi Sarbinowski 
Date: Wed, 16 Apr 2025 21:21:42 +
Subject: [PATCH 2/3] rerun checks


>From 81a1df41f46df706b6acc2dfe87d75e584cdb064 Mon Sep 17 00:00:00 2001
From: Zibi Sarbinowski 
Date: Thu, 17 Apr 2025 00:01:25 +
Subject: [PATCH 3/3] Testing with OF_Text

---
 clang/lib/Frontend/FrontendAction.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 1c4dec08575d1..58d20cbb5ebd8 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -312,7 +312,7 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
&CI,
 std::error_code ErrorCode;
 auto FileStream = std::make_unique(
 DumpDeserializedDeclarationRangesPath, ErrorCode,
-llvm::sys::fs::OF_TextWithCRLF);
+llvm::sys::fs::OF_Text);
 if (!ErrorCode) {
   
Consumers.push_back(std::make_unique(
   CI.getSourceManager(), std::move(FileStream)));

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


[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

2025-04-16 Thread Theo de Magalhaes via cfe-commits

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


[clang-tools-extra] eef9782 - [clang-doc][NFC] clean unused variable in HTML generator (#135505)

2025-04-16 Thread via cfe-commits

Author: Mohamed Emad
Date: 2025-04-16T17:16:12-07:00
New Revision: eef978290ccb847c67bf0431e5fdd1dc4c7d408d

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

LOG:  [clang-doc][NFC] clean unused variable in HTML generator  (#135505)

While reading the code, I found some dead variables that are not used
anymore but it still declared without removing them.

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index cb10f16804024..aceb83e8c4c57 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -716,7 +716,6 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
 
   maybeWriteSourceFileRef(Out, CDCtx, I.DefLoc);
 
-  std::string Description;
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
@@ -759,7 +758,6 @@ genHTML(const FunctionInfo &I, const ClangDocContext &CDCtx,
 
   maybeWriteSourceFileRef(Out, CDCtx, I.DefLoc);
 
-  std::string Description;
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
@@ -777,7 +775,6 @@ genHTML(const NamespaceInfo &I, Index &InfoIndex, const 
ClangDocContext &CDCtx,
 
   Out.emplace_back(std::make_unique(HTMLTag::TAG_H1, InfoTitle));
 
-  std::string Description;
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 
@@ -820,7 +817,6 @@ genHTML(const RecordInfo &I, Index &InfoIndex, const 
ClangDocContext &CDCtx,
 
   maybeWriteSourceFileRef(Out, CDCtx, I.DefLoc);
 
-  std::string Description;
   if (!I.Description.empty())
 Out.emplace_back(genHTML(I.Description));
 



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


[clang] [llvm] [SYCL] Add clang-linker-wrapper changes to call clang-sycl-linker for SYCL offloads (PR #135683)

2025-04-16 Thread Arvind Sudarsanam via cfe-commits

https://github.com/asudarsa updated 
https://github.com/llvm/llvm-project/pull/135683

>From 597fda606efbcf10304fed4adc5dd85da34b3de3 Mon Sep 17 00:00:00 2001
From: Arvind Sudarsanam 
Date: Mon, 14 Apr 2025 14:16:05 -0700
Subject: [PATCH 1/6] [SYCL] Add clang-linker-wrapper changes to call
 clang-sycl-linker for SYCL offloads

Device code linking happens inside clang-linker-wrapper. In the current
implementation, clang-linker-wrapper does the following:

1. Extracts device code. Input_1, Input_2,.
2. Group device code according to target devices
Inputs[triple_1] = 
Inputs[triple_2] = 
3. For each group, i.e. Inputs[triple_i],
   a. Gather all the offload kinds found inside those inputs in
  ActiveOffloadKinds
   b. Link all images inside Inputs[triple_i] by calling
  clang --target=triple_i 
   c. Create a copy of that linked image for each offload kind and add it to
  Output[Kind] list.

In SYCL compilation flow, there is a deviation in Step 3b. We call device code
splitting inside the 'clang --target=triple_i ' call and the output is now
a 'packaged' file containing multiple device images. This deviation requires us
to capture the OffloadKind during the linking stage and pass it along to the
linking function (clang), so that clang can be called with a unique option
'--sycl-link' that will help us to call 'clang-sycl-linker' under the hood
(clang-sycl-linker will do SYCL specific linking).

Our current objective is to implement an end-to-end SYCL offloading flow and
get it working. We will eventually merge our approach with the community flow.

Signed-off-by: Arvind Sudarsanam 
---
 clang/docs/ClangOffloadPackager.rst   |  2 +
 clang/test/Driver/linker-wrapper.c| 10 +++
 .../ClangLinkerWrapper.cpp| 58 -
 .../clang-sycl-linker/ClangSYCLLinker.cpp | 84 ++-
 llvm/lib/Object/OffloadBinary.cpp |  3 +
 5 files changed, 134 insertions(+), 23 deletions(-)

diff --git a/clang/docs/ClangOffloadPackager.rst 
b/clang/docs/ClangOffloadPackager.rst
index 2b985e260e302..481069b5e4235 100644
--- a/clang/docs/ClangOffloadPackager.rst
+++ b/clang/docs/ClangOffloadPackager.rst
@@ -112,6 +112,8 @@ the following values for the :ref:`offload 
kind` and the
 ++---+---+
 | OFK_HIP| 0x03  | The producer was HIP  |
 ++---+---+
+| OFK_SYCL   | 0x04  | The producer was SYCL |
+++---+---+
 
 The flags are used to signify certain conditions, such as the presence of
 debugging information or whether or not LTO was used. The string entry table is
diff --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 0c77c2b34216a..921c9a11d2d32 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -2,6 +2,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
+// REQUIRES: spirv-registered-target
 
 // An externally visible variable so static libraries extract.
 __attribute__((visibility("protected"), used)) int x;
@@ -9,6 +10,7 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 // RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.bc
 // RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -o %t.amdgpu.bc
+// RUN: %clang -cc1 %s -triple spirv64-unknown-unknown -emit-llvm-bc -o 
%t.spirv.bc
 
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
@@ -49,6 +51,14 @@ __attribute__((visibility("protected"), used)) int x;
 
 // AMDGPU-LTO-TEMPS: clang{{.*}} --target=amdgcn-amd-amdhsa -mcpu=gfx1030 
-flto {{.*}}-save-temps
 
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%t.spirv.bc,kind=sycl,triple=spirv64-unknown-unknown,arch=generic
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=SPIRV-LINK
+
+// SPIRV-LINK: clang{{.*}} -o {{.*}}.img --target=spirv64-unknown-unknown 
{{.*}}.o --sycl-link -Xlinker -triple=spirv64-unknown-unknown -Xlinker -arch=
+
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
 // RUN:   --image=file=%t.elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 082355e6c716f..51bb274770a96 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-16 Thread James Y Knight via cfe-commits

jyknight wrote:

> It appears that gcc only disallows '$' in identifiers in C++26 mode. Not sure 
> how relevant that is to clang. 
> [bugzilla](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110343) Or am I 
> misreading that thread?

As far as I can tell, GCC has _not_ disallowed '$' in identifiers at all (both 
by testing and by inspection of that patch).

I'm not sure it really makes sense to do this change in Clang, either.

Firstly, it seems entirely unclear if the C++ proposal really _intended_ to 
require this. The proposal explicitly noted that the change would break using a 
_UCN_ for dollar-sign in an identifier -- which is pretty suggestive that the 
authors did not expect it to forbid spelling the identifier with the actual 
dollar-sign character in implementations supporting that extension ("For 
extensions that allow, for example, $ in identifiers, no one outside of 
compiler test suites, is likely to use a UCN to spell that.")

Also, I note that C was repaired to re-permit "$" as an implementation-defined 
identifier character extension, via "It is implementation-defined if a $ 
(U+0024, DOLLAR SIGN) may be used as a nondigit character." from 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3145.pdf -- that document 
seems to indicate that they felt the removal of the permission for this 
implementation-extension was an unintended defect in the original change.

So, I wonder if this may be C++ defect? That C++ should be re-harmonized with 
C, and permit implementations to allow $ as an identifier character. And, thus, 
that we should await such a DR fix, and make no change to Clang's behavior.

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


[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread Daniel Thornburgh via cfe-commits

mysterymath wrote:

> @mysterymath In the meantime, can you please help us test the Fuchsia CI with 
> this patch? I appreciate your help :)

We're not really set up to run the full Fuchsia CI with specific upstream 
patches, and it's a bit too flaky and expensive to be much good for that 
anyway. For now, it's better as post-submit than pre-submit, I'm afraid.

So long as this fixes the issue in the reproducer, and the LLVM tests pass, 
that should be good enough to go in.

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


[clang] [Clang] Bypass TAD during overload resolution if a perfect match exists (PR #136018)

2025-04-16 Thread via cfe-commits


@@ -96,6 +96,12 @@ C++ Language Changes
   asm((std::string_view("nop")) ::: (std::string_view("memory")));
 }
 
+- Clang now implements the changes to overload resolution proposed by section 
1 and 2 of
+  `P3606 `_. If a non-template candidate exists in 
an overload set that is
+  a perfect match (all conversion sequences are identity conversions) template 
candiates are not instantiated.

h-vetinari wrote:

```suggestion
  a perfect match (all conversion sequences are identity conversions) template 
candidates are not instantiated.
```

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


[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)

2025-04-16 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,35 @@
+// Regression test for https://github.com/llvm/llvm-project/issues/59819
+
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md 
--check-prefix=MD-MYCLASS-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS
+
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MYCLASS-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MYCLASS
+
+#define DECLARE_METHODS   \
+/**  \
+ * @brief Declare a method to calculate the sum of two numbers\
+ */   \
+int Add(int a, int b) {   \
+return a + b; \
+}
+
+// MD-MYCLASS: ### Add
+// MD-MYCLASS: *public int Add(int a, int b)*
+// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
+
+// HTML-MYCLASS: public int Add(int a, int b)
+// HTML-MYCLASS: brief
+// HTML-MYCLASS:  Declare a method to calculate the sum of two numbers
+
+
+class MyClass {
+public:
+// MD-MYCLASS-LINE: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp#[[@LINE+2]]*
+// HTML-MYCLASS-LINE: Defined at line [[@LINE+1]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp

ilovepi wrote:

I understand how the relative line number works in the check line. I'm asking 
if this test passes when you run the test. So does `ninja 
check-clang-extra-clang-doc` pass w/ your changes? I think the line number 
reported is the line that defines the class, not where you wrote the macro that 
got expanded.

> Do we need it to generate completely correct Markdown/HTML codes and pass the 
> test? Or can it have some harmless errors and pass the test?

Well, its a test, so it needs to be correct w.r.t. the thing you're testing, 
and shouldn't be broken overall (or at least not broken in a new way). 

That said, if there's an issue where the line number is not reported correctly, 
and that is a new/unrelated issue, then I'm OK if there is a corresponding 
tracking bug, and we have a TODO in the test referring to that bug.


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


[clang-tools-extra] [clang-doc] Add Start and End Line Numbers (PR #135081)

2025-04-16 Thread Paul Kirth via cfe-commits

ilovepi wrote:

any progress here?

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


[clang] [llvm] [HLSL] Implement the `faceforward` intrinsic (PR #135878)

2025-04-16 Thread Kaitlin Peng via cfe-commits

https://github.com/kmpeng updated 
https://github.com/llvm/llvm-project/pull/135878

>From 69aee464d31dcf585c355808053b0c4d1c7d7f3c Mon Sep 17 00:00:00 2001
From: kmpeng 
Date: Mon, 7 Apr 2025 14:46:07 -0700
Subject: [PATCH 1/3] create int_spv_faceforward intrinsic, create faceforward
 lowering & map to int_spv_faceforward, create SPIR-V backend test case

---
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  1 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp |  2 ++
 .../SPIRV/hlsl-intrinsics/faceforward.ll  | 35 +++
 3 files changed, 38 insertions(+)
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/faceforward.ll

diff --git a/llvm/include/llvm/IR/IntrinsicsSPIRV.td 
b/llvm/include/llvm/IR/IntrinsicsSPIRV.td
index 4389b86745d7f..77cca0a58424f 100644
--- a/llvm/include/llvm/IR/IntrinsicsSPIRV.td
+++ b/llvm/include/llvm/IR/IntrinsicsSPIRV.td
@@ -67,6 +67,7 @@ let TargetPrefix = "spv" in {
   def int_spv_cross : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 
[LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
   def int_spv_degrees : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty], [IntrNoMem]>;
   def int_spv_distance : DefaultAttrsIntrinsic<[LLVMVectorElementType<0>], 
[llvm_anyfloat_ty, LLVMMatchType<0>], [IntrNoMem]>;
+  def int_spv_faceforward : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>;
   def int_spv_frac : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty], [IntrNoMem]>;
   def int_spv_lerp : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty, LLVMMatchType<0>,LLVMMatchType<0>],
 [IntrNoMem] >;
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp 
b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index 79f6b43f3aded..8304077f049a3 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -3083,6 +3083,8 @@ bool SPIRVInstructionSelector::selectIntrinsic(Register 
ResVReg,
 return selectExtInst(ResVReg, ResType, I, CL::length, GL::Length);
   case Intrinsic::spv_degrees:
 return selectExtInst(ResVReg, ResType, I, CL::degrees, GL::Degrees);
+  case Intrinsic::spv_faceforward:
+return selectExtInst(ResVReg, ResType, I, GL::FaceForward);
   case Intrinsic::spv_frac:
 return selectExtInst(ResVReg, ResType, I, CL::fract, GL::Fract);
   case Intrinsic::spv_normalize:
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/faceforward.ll 
b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/faceforward.ll
new file mode 100644
index 0..4b34adc88c0f2
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/hlsl-intrinsics/faceforward.ll
@@ -0,0 +1,35 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | 
FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - 
-filetype=obj | spirv-val --target-env vulkan1.3 %}
+
+; Make sure SPIRV operation function calls for faceforward are lowered 
correctly.
+
+; CHECK-DAG: %[[#op_ext_glsl:]] = OpExtInstImport "GLSL.std.450"
+; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16
+; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4
+; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32
+; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4
+
+define noundef <4 x half> @faceforward_half4(<4 x half> noundef %a, <4 x half> 
noundef %b, <4 x half> noundef %c) {
+entry:
+  ; CHECK: %[[#]] = OpFunction %[[#vec4_float_16]] None %[[#]]
+  ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_16]]
+  ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_16]]
+  ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#vec4_float_16]]
+  ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_16]] %[[#op_ext_glsl]] 
FaceForward %[[#arg0]] %[[#arg1]] %[[#arg2]]
+  %spv.faceforward = call <4 x half> @llvm.spv.faceforward.f16(<4 x half> %a, 
<4 x half> %b, <4 x half> %c)
+  ret <4 x half> %spv.faceforward
+}
+
+define noundef <4 x float> @faceforward_float4(<4 x float> noundef %a, <4 x 
float> noundef %b, <4 x float> noundef %c) {
+entry:
+  ; CHECK: %[[#]] = OpFunction %[[#vec4_float_32]] None %[[#]]
+  ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#vec4_float_32]]
+  ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#vec4_float_32]]
+  ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#vec4_float_32]]
+  ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_32]] %[[#op_ext_glsl]] 
FaceForward %[[#arg0]] %[[#arg1]] %[[#arg2]]
+  %spv.faceforward = call <4 x float> @llvm.spv.faceforward.f32(<4 x float> 
%a, <4 x float> %b, <4 x float> %c)
+  ret <4 x float> %spv.faceforward
+}
+
+declare <4 x half> @llvm.spv.faceforward.f16(<4 x half>, <4 x half>, <4 x 
half>)
+declare <4 x float> @llvm.spv.faceforward.f32(<4 x float>, <4 x float>, <4 x 
float>)

>From 06324ca82d3c593c801bf602b8f58683d13e738f Mon Sep 17 00:00:00 2001
From: kmpeng 
Date: Thu, 10 Apr 2025 14:55:17 -0700
Subject: [PATCH 2/3] implemented `faceforward` in `hlsl.Intrinsics.h` an

[clang] [llvm] [MTE] decide whether to tag global in AsmPrinter (PR #135891)

2025-04-16 Thread Florian Mayer via cfe-commits

fmayer wrote:

> 
Should we add AsmPrinter tests to replace the ones we're removing from Clang?


We have memtag-globals-asm.cpp

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


[clang] [llvm] [SYCL] Add clang-linker-wrapper changes to call clang-sycl-linker for SYCL offloads (PR #135683)

2025-04-16 Thread Arvind Sudarsanam via cfe-commits

asudarsa wrote:

Hi @jhuber6 

I added a constraint that Images of SYCL offloading kind cannot be linked with 
images of other kind. This is a valid constraint in the current state of SYCL 
upstreaming effort. We will aim to remove this constraint soon.

This makes the clang-linker-wrapper code changes manageable.

Hope this is an agreeable resolution.

Thanks for driving me towards this.


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


[clang] [llvm] [SYCL] Add clang-linker-wrapper changes to call clang-sycl-linker for SYCL offloads (PR #135683)

2025-04-16 Thread Arvind Sudarsanam via cfe-commits

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


[clang] [llvm] [HLSL][RootSignature] Add infastructure to parse parameters (PR #133800)

2025-04-16 Thread Justin Bogner via cfe-commits

bogner wrote:

I'm not entirely convinced the generic `ParsedParamState` is the right level of 
abstraction. In some ways the declarative nature is nice, but I think it's 
quite a bit more complex than a simple recursive descent here. 

Warning - lots of untested and never compiled code follows. Consider an API 
like so:

```c++
  struct ParsedParam {
std::optional Register;
std::optional Space;
  };
  std::optional parseParameter(TokenKind RegType);
```

This could then be used in `parseDescriptorClause for the various parameter 
kinds:
```c++
  DescriptorTableClause Clause;
  std::optional P;
  switch (ParamKind) {
  default:
llvm_unreachable("Switch for consumed token was not provided");
  case TokenKind::kw_CBV:
Clause.Type = ClauseType::CBuffer;
P = parseParameter(TokenKind::bReg);
break;
  // ...
  }
  if (!P.has_value())
// diagnose
  // otherwise we have a parameter!
```

then parseParameter can just can follow the same pattern and just recurse into 
the various members:
```c++
std::optional parseParameter(TokenKind RegType) {
  if (consumeExpectedToken(TokenKind::pu_l_paren, diag::err_expected_after,
   ParamKind))
return std::nullopt;

  ParsedParam Result;

  do {
if (tryConsumeExpectedToken(RegType)) {
  if (Result.Register.has_value()) {
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
<< CurToken.TokKind;
return true;
  }
  if (auto Register = parseRegister(Params.Register))
Result.Register = *Register;
}
if (tryConsumeExpectedToken(RootSignatureToken::Kind::kw_space)) {
  if (Result.Space.has_value()) {
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
<< CurToken.TokKind;
return true;
  }
  if (auto Space = parseUIntParam())
Result.Register = *Register;
}

  } while (tryConsumeExpectedToken(TokenKind::pu_comma));

  if (!consumeExpectedToken(TokenKind::pu_r_paren,
diag::err_hlsl_unexpected_end_of_params,
/*param of=*/ParamKind))
return std::nullopt;

  if (!Result.Register.has_value()) {
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_missing_param)
<< ExpectedRegister;
return std::nullopt;
  }

  return Result;
```

This also makes the functions match the shape of the grammar formulations in 
the EBNF notation. I suspect that any code duplication we find by doing it this 
way would be fairly easy to clean up with a few helper functions here and 
there, and since the functions should stay relatively short I think it keeps it 
reasonably simple.

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


[clang] [llvm] [WIP] Correct lowering of `fp128` intrinsics (PR #76558)

2025-04-16 Thread Trevor Gross via cfe-commits


@@ -0,0 +1,331 @@
+; RUN: llc < %s -mtriple=aarch64-unknown-none -verify-machineinstrs | 
FileCheck %s --check-prefix=CHECK-USELD
+; RUN: llc < %s -mtriple=i686-unknown -verify-machineinstrs | FileCheck %s 
--check-prefix=CHECK-NOTLD
+; RUN: llc < %s -mtriple=powerpc-unknown -verify-machineinstrs | FileCheck %s 
--check-prefix=CHECK-NOTLD
+; RUN: llc < %s -mtriple=powerpc64-unknown -verify-machineinstrs | FileCheck 
%s --check-prefix=CHECK-NOTLD
+; RUN: llc < %s -mtriple=riscv32 -verify-machineinstrs | FileCheck %s 
--check-prefix=CHECK-NOTLD
+; RUN: llc < %s -mtriple=s390x-unknown -verify-machineinstrs | FileCheck %s 
--check-prefix=CHECK-S390X
+; RUN: llc < %s -mtriple=x86_64-unknown -verify-machineinstrs | FileCheck %s 
--check-prefix=CHECK-NOTLD
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs | 
FileCheck %s --check-prefix=CHECK-NOTLD
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-musl -verify-machineinstrs | 
FileCheck %s --check-prefix=CHECK-NOTLD
+;
+; REQUIRES: aarch64-registered-target
+; REQUIRES: powerpc-registered-target
+; REQUIRES: riscv-registered-target
+; REQUIRES: systemz-registered-target
+; REQUIRES: x86-registered-target

tgross35 wrote:

Todo: replace this with `%if` somehow so this test still runs if only a subset 
of architectures is available https://llvm.org/docs/TestingGuide.html

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


[clang] [llvm] [SYCL] Add clang-linker-wrapper changes to call clang-sycl-linker for SYCL offloads (PR #135683)

2025-04-16 Thread Joseph Huber via cfe-commits

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


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


[clang-tools-extra] [clang-doc][NFC] clean unused variable in HTML generator (PR #135505)

2025-04-16 Thread Paul Kirth via cfe-commits

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


[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

2025-04-16 Thread Michele Scandale via cfe-commits


@@ -8623,6 +8624,13 @@ inline bool Type::isIntegralOrEnumerationType() const {
 inline bool Type::isBooleanType() const {
   if (const auto *BT = dyn_cast(CanonicalType))
 return BT->getKind() == BuiltinType::Bool;
+  if (const EnumType *ET = dyn_cast(CanonicalType)) {

michele-scandale wrote:

This is to match `isIntegerType` that is used by `hasIntegerRepresentation`.
I'm not entirely sure it makes sense to handle enums here (given also the FIXME 
comment).
I'll try to see what breaks by removing this.

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


[clang] [Clang] Bypass TAD during overload resolution if a perfect match exists (PR #136018)

2025-04-16 Thread via cfe-commits

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


[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

2025-04-16 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,compiler-rt,llvm` at step 7 
"test-build-unified-tree-check-all".

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


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/86/95' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-1916-86-95.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=86 
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/109164
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] Test "Revert "[CI] monolithic-linux improvements"" (PR #136078)

2025-04-16 Thread Aiden Grossman via cfe-commits

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


[clang] [lldb] [llvm] Test "Revert "[CI] monolithic-linux improvements"" (PR #136078)

2025-04-16 Thread Aiden Grossman via cfe-commits

boomanaiden154 wrote:

Subsumed by 1fd7e4c517141ddfb527e7560e02fd5856244971.

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


[clang-tools-extra] [clangd] Store documentation when indexing standard library (PR #133681)

2025-04-16 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

The described options seem a bit more involved than necessary to fix this bug, 
given that it's just the value of the `StoreAllDocumentation` flag that's a 
problem.

I revised the patch to add a new parameter to `createStaticIndexingAction()` 
(now called `createIndexingAction()`) and set the flag based on that -- does 
this address your concern about callers having to decide whether they want 
`StoreAllDocumentation`?

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


[clang] [Clang][CodeGen][OpenCL] Add `-fno-delete-null-pointer-checks` to avoid UB. NFC. (PR #135602)

2025-04-16 Thread Yingwei Zheng via cfe-commits

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


[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

> We're not really set up to run the full Fuchsia CI with specific upstream 
> patches, and it's a bit too flaky and expensive to be much good for that 
> anyway. For now, it's better as post-submit than pre-submit, I'm afraid.
> 
> So long as this fixes the issue in the reproducer, and the LLVM tests pass, 
> that should be good enough to go in IMO.

I tested the reproducer locally and it passed with this patch.

Now that the CI is green, I'll go ahead and merge it - post-commit reviews are 
welcome



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


[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/135914

>From 7d39d1a66c171bc6e44742c0baea5bcab777bacd Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 16 Apr 2025 13:27:54 +0800
Subject: [PATCH 1/3] Reapply "[Clang] Fix dependent local class instantiation
 bugs"

---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  3 -
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  | 56 +++-
 .../CodeGenCXX/local-class-instantiation.cpp  | 64 +++
 4 files changed, 120 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/local-class-instantiation.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 84ad253c1ec4f..87c2f72d20a46 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -458,6 +458,7 @@ Bug Fixes to C++ Support
   by template argument deduction.
 - Clang is now better at instantiating the function definition after its use 
inside
   of a constexpr lambda. (#GH125747)
+- Fixed a local class member function instantiation bug inside dependent 
lambdas. (#GH59734), (#GH132208)
 - Clang no longer crashes when trying to unify the types of arrays with
   certain differences in qualifiers (this could happen during template argument
   deduction or when building a ternary operator). (#GH97005)
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index d2408a94ad0ab..0e81804f8c1e7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4126,9 +4126,6 @@ Sema::InstantiateClassMembers(SourceLocation 
PointOfInstantiation,
   if (FunctionDecl *Pattern =
   Function->getInstantiatedFromMemberFunction()) {
 
-if (Function->isIneligibleOrNotSelected())
-  continue;
-
 if (Function->getTrailingRequiresClause()) {
   ConstraintSatisfaction Satisfaction;
   if (CheckFunctionConstraints(Function, Satisfaction) ||
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5c80077f294c6..bf5a882ba4f12 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5597,7 +5597,61 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
   Function->setLocation(PatternDecl->getLocation());
   Function->setInnerLocStart(PatternDecl->getInnerLocStart());
   Function->setRangeEnd(PatternDecl->getEndLoc());
-  Function->setDeclarationNameLoc(PatternDecl->getNameInfo().getInfo());
+  // Let the instantiation use the Pattern's DeclarationNameLoc, due to the
+  // following awkwardness:
+  //
+  //   1. There are out-of-tree users of getNameInfo().getSourceRange(), who
+  //   expect the source range of the instantiated declaration to be set to
+  //   point to the definition.
+  //
+  //   2. That getNameInfo().getSourceRange() might return the TypeLocInfo's
+  //   location it tracked.
+  //
+  //   3. Function might come from an (implicit) declaration, while the pattern
+  //   comes from a definition. In these cases, we need the PatternDecl's 
source
+  //   location.
+  //
+  // To that end, we need to more or less tweak the DeclarationNameLoc. 
However,
+  // we can't blindly copy the DeclarationNameLoc from the PatternDecl to the
+  // function, since it contains associated TypeLocs that should have already
+  // been transformed. So, we rebuild the TypeLoc for that purpose. 
Technically,
+  // we should create a new function declaration and assign everything we need,
+  // but InstantiateFunctionDefinition updates the declaration in place.
+  auto NameLocPointsToPattern = [&] {
+DeclarationNameInfo PatternName = PatternDecl->getNameInfo();
+DeclarationNameLoc PatternNameLoc = PatternName.getInfo();
+switch (PatternName.getName().getNameKind()) {
+case DeclarationName::CXXConstructorName:
+case DeclarationName::CXXDestructorName:
+case DeclarationName::CXXConversionFunctionName:
+  break;
+default:
+  // Cases where DeclarationNameLoc doesn't matter, as it merely contains a
+  // source range.
+  return PatternNameLoc;
+}
+
+TypeSourceInfo *TSI = Function->getNameInfo().getNamedTypeInfo();
+// TSI might be null if the function is named by a constructor template id.
+// E.g. S() {} for class template S with a template parameter T.
+if (!TSI) {
+  // We don't care about the DeclarationName of the instantiated function,
+  // but only the DeclarationNameLoc. So if the TypeLoc is absent, we do
+  // nothing.
+  return PatternNameLoc;
+}
+
+QualType InstT = TSI->getType();
+// We want to use a TypeLoc that reflects the transformed type while
+// preserving the source location from the pattern.
+TypeLocBuilder TLB;
+TLB.pushTrivial(
+Context, InstT,
+

[clang] [clang] convergent attribute does not require "all threads" (PR #135803)

2025-04-16 Thread Sameer Sahasrabuddhe via cfe-commits

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


[clang] 377ec36 - [Clang] Bypass TAD during overload resolution if a perfect match exists (#136018)

2025-04-16 Thread via cfe-commits

Author: cor3ntin
Date: 2025-04-17T08:09:55+02:00
New Revision: 377ec36b323ea99ca316cb5cf79c0a0c93eebc37

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

LOG: [Clang] Bypass TAD during overload resolution if a perfect match exists 
(#136018)

This implements the same overload resolution behavior as GCC,
as described in https://wg21.link/p3606 (section 1-2, not 3)

If during overload resolution, there is a non-template candidate
that would be always be picked - because each of the argument
is a perfect match (ie the source and target types are the same),
we do not perform deduction for any template candidate
that might exists.

The goal is to be able to merge
https://github.com/llvm/llvm-project/pull/122423 without being too
disruptive.

This change means that the selection of the best viable candidate and
template argument deduction become interleaved.

To avoid rewriting half of Clang we store in `OverloadCandidateSet`
enough information to be able to deduce template candidates from
`OverloadCandidateSet::BestViableFunction`. Which means
the lifetime of any object used by template argument must outlive
a call to `Add*Template*Candidate`.

This two phase resolution is not performed for some initialization
as there are cases where template candidate are better match
in these cases per the standard. It's also bypassed for code completion.

The change has a nice impact on compile times

https://llvm-compile-time-tracker.com/compare.php?from=719b029c16eeb1035da522fd641dfcc4cee6be74&to=bf7041045c9408490c395230047c5461de72fc39&stat=instructions%3Au

Fixes https://github.com/llvm/llvm-project/issues/62096
Fixes https://github.com/llvm/llvm-project/issues/74581

Reapplies #133426

Added: 
clang/test/SemaCXX/overload-resolution-deferred-templates.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp

clang/test/CXX/temp/temp.constr/temp.constr.atomic/constrant-satisfaction-conversions.cpp
clang/test/SemaCUDA/function-overload.cu
clang/test/SemaCXX/implicit-member-functions.cpp
clang/test/SemaTemplate/instantiate-function-params.cpp
clang/test/Templight/templight-empty-entries-fix.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0bf5e07ec5dfd..2bc7054e3c794 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -96,6 +96,12 @@ C++ Language Changes
   asm((std::string_view("nop")) ::: (std::string_view("memory")));
 }
 
+- Clang now implements the changes to overload resolution proposed by section 
1 and 2 of
+  `P3606 `_. If a non-template candidate exists in 
an overload set that is
+  a perfect match (all conversion sequences are identity conversions) template 
candidates are not instantiated.
+  Diagnostics that would have resulted from the instantiation of these 
template candidates are no longer
+  produced. This aligns Clang closer to the behavior of GCC, and fixes 
(#GH62096), (#GH74581), and (#GH74581).
+
 C++2c Feature Support
 ^
 

diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 6e08762dcc6d7..e667147bfac7e 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -407,6 +407,26 @@ class Sema;
  Third == ICK_Identity;
 }
 
+/// A conversion sequence is perfect if it is an identity conversion and
+/// the type of the source is the same as the type of the target.
+bool isPerfect(const ASTContext &C) const {
+  if (!isIdentityConversion())
+return false;
+  // If we are not performing a reference binding, we can skip comparing
+  // the types, which has a noticeable performance impact.
+  if (!ReferenceBinding) {
+// The types might 
diff er if there is an array-to-pointer conversion
+// or lvalue-to-rvalue conversion.
+assert(First || C.hasSameUnqualifiedType(getFromType(), getToType(2)));
+return true;
+  }
+  if (!C.hasSameType(getFromType(), getToType(2)))
+return false;
+  if (BindsToRvalue && IsLvalueReference)
+return false;
+  return true;
+}
+
 ImplicitConversionRank getRank() const;
 NarrowingKind
 getNarrowingKind(ASTContext &Context, const Expr *Converted,
@@ -743,6 +763,12 @@ class Sema;
   Standard.setAllToTypes(T);
 }
 
+/// A conversion sequence is perfect if it is an identity conversion and
+/// the type of the source is the same as the type of the target.
+bool isPerfect(const ASTContext &C) const {
+  ret

[clang] [llvm] [mlir] [NVPTX] Add support for Shared Cluster Memory address space. (PR #135444)

2025-04-16 Thread Artem Belevich via cfe-commits


@@ -982,8 +982,9 @@ void NVPTXDAGToDAGISel::SelectAddrSpaceCast(SDNode *N) {
 case ADDRESS_SPACE_SHARED:
   Opc = TM.is64Bit() ? NVPTX::cvta_shared_64 : NVPTX::cvta_shared;
   break;
-case ADDRESS_SPACE_DSHARED:
-  Opc = TM.is64Bit() ? NVPTX::cvta_dshared_64 : NVPTX::cvta_dshared;
+case ADDRESS_SPACE_SHARED_CLUSTER:
+  Opc = TM.is64Bit() ? NVPTX::cvta_shared_cluster_64
+ : NVPTX::cvta_shared_cluster;

Artem-B wrote:

> I think throwing the error in ISel is a good place to fail.

It's a convenient place for LLVM developer. It's problematic for the end user. 
In general, if we're diagnosing a user error, it must be in a way that's 
actionable for the *user*, not for the compiler developer. Diagnostic by 
compiler crash is not the best UI.

Granted, producing an invalid instruction and relying on ptxas to diagnose it 
is only marginally better.

I think the missing bit of the puzzle here is that we still support 32-bit 
compilation on sm_90+. If we make it impossible to do it in principle, then it 
makes the whole point moot, and we no longer have to bother with 32-bit generic 
pointers for the instructions that are available on newer GPUs only.

This is something to be addressed separately. For this patch, I'm fine with 
proceeding with the assumption that 32-bit compilation never happens.


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


[clang] Revert "[NFC][CFI] Dump test output to debug llvm-clang-win-x-aarch64 failure" (PR #136029)

2025-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Vitaly Buka (vitalybuka)


Changes

Reverts llvm/llvm-project#136002

Not needed any more.

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


1 Files Affected:

- (modified) clang/test/Driver/sanitizer-ld.c (-8) 


``diff
diff --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c
index c04831171bba9..a00ec029d3d46 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -839,14 +839,6 @@
 // CHECK-CFI-PREREQ-LINUX: '-fsanitize=cfi' only allowed with '-flto'
 // CHECK-CFI-PREREQ-LINUX: '-fsanitize=cfi' only allowed with '-fvisibility='
 
-// CFI by itself does not link runtime libraries.
-// RUN: %clang -fsanitize=cfi \
-// RUN: -flto -fvisibility=hidden \
-// RUN: --target=x86_64-unknown-linux -fuse-ld=ld -rtlib=platform \
-// RUN: -resource-dir=%S/Inputs/resource_dir \
-// RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: -### %s
-
 // CFI by itself does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi \
 // RUN: -flto -fvisibility=hidden \

``




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


[clang] d1a80de - Reapply "[Clang] Fix dependent local class instantiation bugs" (#135914)

2025-04-16 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-04-17T14:34:32+08:00
New Revision: d1a80deae674300d1011ccb6d6ee7030eaf8e713

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

LOG: Reapply "[Clang] Fix dependent local class instantiation bugs" (#135914)

This reapplies #134038

Since the last patch, this fixes a null pointer dereference where the
TSI of the destructor wasn't properly propagated into the
DeclarationNameInfo. We now construct a LocInfoType for dependent cases,
as done elsewhere in getDestructorName, such that GetTypeFromParser can
correctly obtain the TSI.

---

This patch fixes two long-standing bugs that prevent Clang from
instantiating local class members inside a dependent context. These bugs
were introduced in commits
https://github.com/llvm/llvm-project/commit/21eb1af469c3257606aec2270d544e0e8ecf77b2
and
https://github.com/llvm/llvm-project/commit/919df9d75ac2a721a8072327c803f34486884571.


https://github.com/llvm/llvm-project/commit/21eb1af469c3257606aec2270d544e0e8ecf77b2
introduced a concept called eligible methods such that it did an attempt
to skip past ineligible method instantiation when instantiating class
members. Unfortunately, this broke the instantiation chain for local
classes - getTemplateInstantiationPattern() would fail to find the
correct definition pattern if the class was defined within a partially
transformed dependent context.


https://github.com/llvm/llvm-project/commit/919df9d75ac2a721a8072327c803f34486884571
introduced a separate issue by incorrectly copying the
DeclarationNameInfo during function definition instantiation from the
template pattern, even though that DNI might contain a transformed
TypeSourceInfo. Since that TSI was already updated when the declaration
was instantiated, this led to inconsistencies. As a result, the final
instantiated function could lose track of the transformed declarations,
hence we crash: https://compiler-explorer.com/z/vjvoG76Tf.

This PR corrects them by

1. Removing the bypass logic for method instantiation. The eligible flag
is independent of instantiation and can be updated properly afterward,
so skipping instantiation is unnecessary.

2. Carefully handling TypeSourceInfo by creating a new instance that
preserves the pattern's source location while using the already
transformed type.

Added: 
clang/test/CodeGenCXX/local-class-instantiation.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/instantiate-local-class.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2bc7054e3c794..fc36962b317e8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -474,6 +474,7 @@ Bug Fixes to C++ Support
   by template argument deduction.
 - Clang is now better at instantiating the function definition after its use 
inside
   of a constexpr lambda. (#GH125747)
+- Fixed a local class member function instantiation bug inside dependent 
lambdas. (#GH59734), (#GH132208)
 - Clang no longer crashes when trying to unify the types of arrays with
   certain 
diff erences in qualifiers (this could happen during template argument
   deduction or when building a ternary operator). (#GH97005)

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8df590fa624cf..394e56c465c24 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -344,10 +344,12 @@ ParsedType Sema::getDestructorName(const IdentifierInfo 
&II,
 // We didn't find our type, but that's OK: it's dependent anyway.
 
 // FIXME: What if we have no nested-name-specifier?
+TypeSourceInfo *TSI = nullptr;
 QualType T =
 CheckTypenameType(ElaboratedTypeKeyword::None, SourceLocation(),
-  SS.getWithLocInContext(Context), II, NameLoc);
-return ParsedType::make(T);
+  SS.getWithLocInContext(Context), II, NameLoc, &TSI,
+  /*DeducedTSTContext=*/true);
+return CreateParsedType(T, TSI);
   }
 
   // The remaining cases are all non-standard extensions imitating the behavior

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index d2408a94ad0ab..0e81804f8c1e7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4126,9 +4126,6 @@ Sema::InstantiateClassMembers(SourceLocation 
PointOfInstantiation,
   if (FunctionDecl *Pattern =
   Function->getInstantiatedFromMemberFunction()) {
 
-if (Function->isIneligibleOrNotSelected())
-  continue;
-
 if (Function->getTrailingRequiresCl

[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)

2025-04-16 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/135573

>From 27e98b9fbfb808ab19cf688d48d688801d9647c1 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Thu, 17 Apr 2025 00:40:34 +0300
Subject: [PATCH] [Clang] enhance loop analysis to handle variable changes
 inside lambdas

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Sema/SemaStmt.cpp   | 23 +--
 clang/test/SemaCXX/warn-loop-analysis.cpp | 15 +++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 07ff1251fc1ad..e08cf382dcc9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -379,6 +379,8 @@ Improvements to Clang's diagnostics
 
   Fixes #GH131127
 
+- The ``-Wloop-analysis`` warning now handles variable modifications inside 
lambda expressions (#GH132038).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 39c2e157591df..1a6d4c23c8570 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2002,9 +2002,28 @@ namespace {
 }
 
 void VisitDeclRefExpr(DeclRefExpr *E) {
-  if (VarDecl *VD = dyn_cast(E->getDecl()))
+  if (VarDecl *VD = dyn_cast(E->getDecl())) {
 if (Decls.count(VD))
   FoundDecl = true;
+  } else if (CXXMethodDecl *MD = dyn_cast(E->getDecl());
+ MD && isLambdaCallOperator(MD)) {
+for (const auto &Capture : MD->getParent()->captures()) {
+  if (!Capture.capturesVariable())
+continue;
+
+  if (VarDecl *VD = dyn_cast(Capture.getCapturedVar())) {
+if (Decls.count(VD))
+  FoundDecl = true;
+  }
+}
+  }
+}
+
+void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+  Visit(E->getCallee());
+
+  for (auto *Arg : E->arguments())
+Visit(Arg->IgnoreParenImpCasts());
 }
 
 void VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
@@ -2021,7 +2040,7 @@ namespace {
 
 bool FoundDeclInUse() { return FoundDecl; }
 
-  };  // end class DeclMatcher
+  }; // end class DeclMatcher
 
   void CheckForLoopConditionalStatement(Sema &S, Expr *Second,
 Expr *Third, Stmt *Body) {
diff --git a/clang/test/SemaCXX/warn-loop-analysis.cpp 
b/clang/test/SemaCXX/warn-loop-analysis.cpp
index 324dd386292ac..4f7c70f65677b 100644
--- a/clang/test/SemaCXX/warn-loop-analysis.cpp
+++ b/clang/test/SemaCXX/warn-loop-analysis.cpp
@@ -299,3 +299,18 @@ void test10() {
   for (auto[i, j, k] = arr; i < a; ++i) { }
   for (auto[i, j, k] = arr; i < a; ++arr[0]) { }
 };
+
+extern void foo(int);
+void test11() {
+  int a = 0;
+  auto incr_a = [&a]() { ++a; };
+
+  for (int b = 10; a <= b; incr_a())
+foo(a);
+
+  for (int b = 10; a <= b;)
+incr_a();
+
+  for (int b = 10; a <= b; [&a]() { ++a; }()) { }
+  for (int b = 10; a <= b; [&a]() { }()) { }
+}

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


[clang] 8e67d8f - [Clang][CodeGen][OpenCL] Add `-fno-delete-null-pointer-checks` to avoid UB. NFC. (#135602)

2025-04-16 Thread via cfe-commits

Author: Yingwei Zheng
Date: 2025-04-17T14:29:09+08:00
New Revision: 8e67d8fdf3a31b42f52ec12d995490f866b4449b

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

LOG: [Clang][CodeGen][OpenCL] Add `-fno-delete-null-pointer-checks` to avoid 
UB. NFC. (#135602)

Needed by https://github.com/llvm/llvm-project/pull/130742.

Added: 


Modified: 
clang/test/CodeGenOpenCL/spir32_target.cl
clang/test/CodeGenOpenCL/spir64_target.cl
clang/test/CodeGenOpenCL/spirv_target.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/spir32_target.cl 
b/clang/test/CodeGenOpenCL/spir32_target.cl
index 924b2c12f5537..cccdf3635ea63 100644
--- a/clang/test/CodeGenOpenCL/spir32_target.cl
+++ b/clang/test/CodeGenOpenCL/spir32_target.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" 
-fno-delete-null-pointer-checks -emit-llvm -o - | FileCheck %s
 
 // CHECK: target triple = "spir-unknown-unknown"
 

diff  --git a/clang/test/CodeGenOpenCL/spir64_target.cl 
b/clang/test/CodeGenOpenCL/spir64_target.cl
index ba4a66d7158fd..67880f47adb34 100644
--- a/clang/test/CodeGenOpenCL/spir64_target.cl
+++ b/clang/test/CodeGenOpenCL/spir64_target.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm 
-fno-delete-null-pointer-checks -o - | FileCheck %s
 
 // CHECK: target triple = "spir64-unknown-unknown"
 

diff  --git a/clang/test/CodeGenOpenCL/spirv_target.cl 
b/clang/test/CodeGenOpenCL/spirv_target.cl
index 2aeed195449a8..f9e92a79d5617 100644
--- a/clang/test/CodeGenOpenCL/spirv_target.cl
+++ b/clang/test/CodeGenOpenCL/spirv_target.cl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple "spirv32-unknown-unknown" -verify -emit-llvm -o 
- | FileCheck %s -check-prefix=SPIRV32
-// RUN: %clang_cc1 %s -triple "spirv64-unknown-unknown" -verify -emit-llvm -o 
- | FileCheck %s -check-prefix=SPIRV64
+// RUN: %clang_cc1 %s -triple "spirv32-unknown-unknown" 
-fno-delete-null-pointer-checks -verify -emit-llvm -o - | FileCheck %s 
-check-prefix=SPIRV32
+// RUN: %clang_cc1 %s -triple "spirv64-unknown-unknown" 
-fno-delete-null-pointer-checks -verify -emit-llvm -o - | FileCheck %s 
-check-prefix=SPIRV64
 
 // SPIRV32: target triple = "spirv32-unknown-unknown"
 // SPIRV64: target triple = "spirv64-unknown-unknown"



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


[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `clang` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAttach.py (1201 of 2125)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteFork.py (1202 of 2125)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteForkResume.py (1203 of 
2125)
UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteForkNonStop.py (1204 of 
2125)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteCompletion.py (1205 of 2125)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteExitCode.py (1206 of 2125)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteHostInfo.py (1207 of 2125)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteModuleInfo.py (1208 of 2125)
PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAuxvSupport.py (1209 of 2125)
UNRESOLVED: lldb-api :: tools/lldb-dap/variables/TestDAP_variables.py (1210 of 
2125)
 TEST 'lldb-api :: 
tools/lldb-dap/variables/TestDAP_variables.py' FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables
 -p TestDAP_variables.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
d1a80deae674300d1011ccb6d6ee7030eaf8e713)
  clang revision d1a80deae674300d1011ccb6d6ee7030eaf8e713
  llvm revision d1a80deae674300d1011ccb6d6ee7030eaf8e713
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_darwin_dwarf_missing_obj (TestDAP_variables.TestDAP_variables) (requires 
one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, 
watchsimulator, appletvsimulator) 
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled 
(TestDAP_variables.TestDAP_variables) (requires one of macosx, darwin, ios, 
tvos, watchos, bridgeos, iphonesimulator, watchsimulator, appletvsimulator) 
= DEBUG ADAPTER PROTOCOL LOGS =
1744872623.301907063 --> (stdin/stdout) 
{"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1}
1744872623.303959846 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb 
version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
d1a80deae674300d1011ccb6d6ee7030eaf8e713)\n  clang revision 
d1a80deae674300d1011ccb6d6ee7030eaf8e713\n  llvm revision 
d1a80deae674300d1011ccb6d6ee7030eaf8e713","completionTriggerCharacters":["."," 
","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++
 Catch"},{"default":false,"filter":"cpp_throw","label":"C++ 
Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C 
Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C 
Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataB

[clang-tools-extra] [NFC][clang-tidy] Remove {{^}} clauses in some tests (3/N) (PR #135826)

2025-04-16 Thread Carlos Galvez via cfe-commits

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

LGTM!

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


[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

2025-04-16 Thread Timm Baeder via cfe-commits


@@ -5238,6 +5238,14 @@ inline bool IsEnumDeclScoped(EnumDecl *ED) {
   return ED->isScoped();
 }
 
+/// Return the integer type corresponding to the given decl.
+///
+/// We use this function to break a cycle between the inline definitions in
+/// Type.h and Decl.h.
+inline QualType GetEnumDeclIntegerType(EnumDecl *ED) {

tbaederr wrote:

Can we make the parameter const?

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


[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)

2025-04-16 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/135573

>From f3a021b0acbb028b647e5fab02ff053ad88b Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Wed, 16 Apr 2025 01:08:55 +0300
Subject: [PATCH] [Clang] enhance loop analysis to handle variable changes
 inside lambdas

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Sema/SemaStmt.cpp   | 25 +--
 clang/test/SemaCXX/warn-loop-analysis.cpp | 15 ++
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 166f26921cb71..3e83041a9cd9c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,8 @@ Improvements to Clang's diagnostics
 
 - An error is now emitted when a ``musttail`` call is made to a function 
marked with the ``not_tail_called`` attribute. (#GH133509).
 
+- The ``-Wloop-analysis`` warning now handles variable modifications inside 
lambda expressions (#GH132038).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 39c2e157591df..b7571d474f134 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2002,9 +2002,30 @@ namespace {
 }
 
 void VisitDeclRefExpr(DeclRefExpr *E) {
-  if (VarDecl *VD = dyn_cast(E->getDecl()))
+  if (VarDecl *VD = dyn_cast(E->getDecl())) {
 if (Decls.count(VD))
   FoundDecl = true;
+  } else if (CXXMethodDecl *MD = dyn_cast(E->getDecl());
+ MD && isLambdaCallOperator(MD)) {
+for (const auto &Capture : MD->getParent()->captures()) {
+  if (!Capture.capturesVariable())
+continue;
+
+  if (VarDecl *VD = dyn_cast(Capture.getCapturedVar())) {
+if (Decls.count(VD))
+  FoundDecl = true;
+  }
+}
+  }
+}
+
+void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+  Expr *Callee = E->getCallee();
+  if (Callee) {
+Visit(E->getCallee());
+for (auto *Arg : E->arguments())
+  Visit(Arg->IgnoreParenImpCasts());
+  }
 }
 
 void VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
@@ -2021,7 +2042,7 @@ namespace {
 
 bool FoundDeclInUse() { return FoundDecl; }
 
-  };  // end class DeclMatcher
+  }; // end class DeclMatcher
 
   void CheckForLoopConditionalStatement(Sema &S, Expr *Second,
 Expr *Third, Stmt *Body) {
diff --git a/clang/test/SemaCXX/warn-loop-analysis.cpp 
b/clang/test/SemaCXX/warn-loop-analysis.cpp
index 324dd386292ac..4f7c70f65677b 100644
--- a/clang/test/SemaCXX/warn-loop-analysis.cpp
+++ b/clang/test/SemaCXX/warn-loop-analysis.cpp
@@ -299,3 +299,18 @@ void test10() {
   for (auto[i, j, k] = arr; i < a; ++i) { }
   for (auto[i, j, k] = arr; i < a; ++arr[0]) { }
 };
+
+extern void foo(int);
+void test11() {
+  int a = 0;
+  auto incr_a = [&a]() { ++a; };
+
+  for (int b = 10; a <= b; incr_a())
+foo(a);
+
+  for (int b = 10; a <= b;)
+incr_a();
+
+  for (int b = 10; a <= b; [&a]() { ++a; }()) { }
+  for (int b = 10; a <= b; [&a]() { }()) { }
+}

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


[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `clang-tools-extra,clang` at 
step 4 "build".

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


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

```
Step 4 (build) failure: build (failure)
...
152.022 [57/72/884] Linking CXX executable bin/llvm-readtapi
152.023 [56/72/885] Generating ../../bin/llvm-ml64
152.072 [55/72/886] Linking CXX executable bin/llvm-sim
152.089 [54/72/887] Copying llvm-locstats into 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin
152.104 [54/71/888] Building CXX object 
tools/clang/tools/clang-repl/CMakeFiles/clang-repl.dir/ClangRepl.cpp.o
152.111 [54/70/889] Linking CXX executable bin/llvm-readobj
152.127 [53/70/890] Generating ../../bin/llvm-readelf
152.211 [53/69/891] Linking CXX executable bin/llvm-size
152.220 [53/68/892] Building CXX object 
tools/lldb/source/Plugins/Platform/AIX/CMakeFiles/lldbPluginPlatformAIX.dir/PlatformAIX.cpp.o
152.242 [53/67/893] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
FAILED: 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/ExpressionParser/Clang
 -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include 
-I/usr/include/python3.11 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/../clang/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/../clang/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/source -isystem 
/usr/include/libxml2 -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -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 -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
 -MF 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o.d
 -o 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
 -c 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:360:49:
 error: no viable conversion from 'std::pair' to 'clang::ModuleIdPath' (aka 
'ArrayRef')
  clang::Module *top_level_module = DoGetModule(clang_path.front(), false);
^~
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40:
 note: candidate constructor (the implicit copy constructor) not viable: no 
known conversion from 'std::pair' to 'const llvm::ArrayRef &' for 
1st argument
  class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
   ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40:
 note: candidate constructor (the implicit move constructor) not viable: no 
known conversion from 'std::pair' to 'llvm::ArrayRef &&' for 1st 
argument
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18:
 note: candidate constructor not viable: no known conversion from 
'std::pair' to 'std::nullopt_t' 
for 1st argument
/*implicit*/ ArrayRef(std::nullopt_t) {}
 ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:73:18:
 note: candidate constructor not viable: no known conversion from 
'std::pair' to 'const 
clang::IdentifierLoc &' for 1st argument
/*implicit*/ ArrayRef(const T &OneElt LLVM_

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-16 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> > This patch adds support for GCC bound member functions extension: 
> > https://gcc.gnu.org/onlinedocs/gcc/Bound-member-functions.html
> > Related issue: #22495 Closes #82727
> 
> I think this requires an RFC justifying carrying the extension. It's a 
> non-conforming extension that we previously decided we would not implement 
> (#22495 was closed as `WONTFIX`), and there's no real motivation for the 
> feature request listed in #82727.
> 
> (Personally, I think #82727 should be closed as a duplicate of #22495 unless 
> there's a very strong justification for carrying the extension.)

#82727 was filed because this extension is used by topling-zip: 
https://github.com/topling/topling-zip/blob/4c57da837bf1a1612a1524ddf8d258a69f1c3874/src/terark/zbs/blob_store.hpp#L56-L68

I decided to implement this feature after I read the post by @rockeet 
:https://zhuanlan.zhihu.com/p/683534962 (in Chinese). TBH I don't think this 
feature is useful as modern compilers should be smart enough to optimize out 
redundant vtable lookups.

cc @rockeet Are you willing to propose an RFC in https://discourse.llvm.org/ to 
demonstrate its real-world usefulness in ToplingDB?




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


[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-ubuntu` 
running on `as-builder-9` while building `clang-tools-extra,clang` at step 7 
"build-default".

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


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

```
Step 7 (build-default) failure: cmake (failure)
...
262.757 [227/52/5047] Building CXX object 
tools/lldb/source/Plugins/Language/ObjC/CMakeFiles/lldbPluginObjCLanguage.dir/NSSet.cpp.o
262.894 [227/51/5048] Building CXX object 
tools/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeFiles/lldbPluginAppleObjCRuntime.dir/AppleObjCRuntimeV1.cpp.o
262.900 [227/50/5049] Building CXX object 
tools/lldb/source/Plugins/LanguageRuntime/ObjC/GNUstepObjCRuntime/CMakeFiles/lldbPluginGNUstepObjCRuntime.dir/GNUstepObjCRuntime.cpp.o
262.925 [227/49/5050] Building CXX object 
tools/lldb/source/Plugins/Language/CPlusPlus/CMakeFiles/lldbPluginCPlusPlusLanguage.dir/BlockPointer.cpp.o
262.984 [227/48/5051] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangASTImporter.cpp.o
263.230 [227/47/5052] Building CXX object 
tools/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeFiles/lldbPluginAppleObjCRuntime.dir/AppleObjCDeclVendor.cpp.o
263.477 [227/46/5053] Building CXX object 
tools/lldb/source/Plugins/Platform/AIX/CMakeFiles/lldbPluginPlatformAIX.dir/PlatformAIX.cpp.o
263.602 [227/45/5054] Building CXX object 
tools/lldb/source/Plugins/LanguageRuntime/ObjC/CMakeFiles/lldbPluginObjCRuntime.dir/ObjCLanguageRuntime.cpp.o
263.606 [227/44/5055] Building CXX object 
tools/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeFiles/lldbPluginCXXItaniumABI.dir/ItaniumABILanguageRuntime.cpp.o
263.650 [227/43/5056] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
FAILED: 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 
ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include
 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/include
 -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/llvm/include
 -I/usr/include/python3.12 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/llvm/../clang/include
 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/../clang/include
 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source
 
-I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/source
 -D__OPTIMIZE__ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-maybe-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 -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-stringop-truncation -O3 -DNDEBUG -std=c++17  -fno-exceptions 
-funwind-tables -fno-rtti -UNDEBUG -MD -MT 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -MF 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o.d
 -o 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -c 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:
 In member function ‘virtual void 
lldb_private::ClangExpressionParser::LLDBPreprocessorCallbacks::moduleImport(clang::SourceLocation,
 clang::ModuleIdPath, const clang::Module*)’:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:138:73:
 error: i

[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

2025-04-16 Thread Reid Kleckner via cfe-commits

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

Is this ready to go? I can't recall if we ultimately accepted the RFC.

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


[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-16 Thread Mariya Podchishchaeva via cfe-commits


@@ -136,3 +136,43 @@ constexpr struct HasChar c = {
 c-error {{constexpr initializer evaluates to 
255 which is not exactly representable in type 'signed char'}}
 
 };
+
+#if __cplusplus
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+template  class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  constexpr initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b), __size_(__s) {}
+
+public:
+  constexpr initializer_list() : __begin_(nullptr), __size_(0) {}
+};
+} // namespace std
+
+class S2 {
+public:
+  constexpr S2(std::initializer_list)  { // cxx-error {{constexpr 
constructor never produces a constant expression}}
+1/0; // cxx-warning {{division by zero is undefined}}
+ // cxx-warning@-1 {{unused}}
+ // cxx-note@-2 4{{division by zero}}
+  }
+};
+
+
+constexpr S2 s2 { // cxx-error {{must be initialized by a constant expression}}
+  // cxx-note-re@-1 {{in call to 'S2{{.*}} #embed }}
+#embed  prefix(0x2c, 0x20, )limit(5)
+};
+constexpr S2 s3 {1, // cxx-error {{must be initialized by a constant 
expression}}
+// cxx-note-re@-1 {{in call to 'S2{{.*}} #embed "jk.txt"}}
+#embed "jk.txt"
+};
+constexpr S2 s4 { // cxx-error {{must be initialized by a constant expression}}
+  // cxx-note-re@-1 {{in call to 'S2{{.*}}"jk"}}

Fznamznon wrote:

Note, no #embed here because it falls into the fast path and we use a 
stringliteral directly to initialize.

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


[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread via cfe-commits

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


[clang] [Clang] enhance loop analysis to handle variable changes inside lambdas (PR #135573)

2025-04-16 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/135573

>From 6a4bfc48c306928cc0fb516cd340e06fa83d54e8 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Wed, 16 Apr 2025 15:57:00 +0300
Subject: [PATCH] [Clang] enhance loop analysis to handle variable changes
 inside lambdas

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Sema/SemaStmt.cpp   | 25 +--
 clang/test/SemaCXX/warn-loop-analysis.cpp | 15 ++
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0891fd058bb57..6ad62370c51ff 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -379,6 +379,8 @@ Improvements to Clang's diagnostics
 
   Fixes #GH131127
 
+- The ``-Wloop-analysis`` warning now handles variable modifications inside 
lambda expressions (#GH132038).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 39c2e157591df..b7571d474f134 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2002,9 +2002,30 @@ namespace {
 }
 
 void VisitDeclRefExpr(DeclRefExpr *E) {
-  if (VarDecl *VD = dyn_cast(E->getDecl()))
+  if (VarDecl *VD = dyn_cast(E->getDecl())) {
 if (Decls.count(VD))
   FoundDecl = true;
+  } else if (CXXMethodDecl *MD = dyn_cast(E->getDecl());
+ MD && isLambdaCallOperator(MD)) {
+for (const auto &Capture : MD->getParent()->captures()) {
+  if (!Capture.capturesVariable())
+continue;
+
+  if (VarDecl *VD = dyn_cast(Capture.getCapturedVar())) {
+if (Decls.count(VD))
+  FoundDecl = true;
+  }
+}
+  }
+}
+
+void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
+  Expr *Callee = E->getCallee();
+  if (Callee) {
+Visit(E->getCallee());
+for (auto *Arg : E->arguments())
+  Visit(Arg->IgnoreParenImpCasts());
+  }
 }
 
 void VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
@@ -2021,7 +2042,7 @@ namespace {
 
 bool FoundDeclInUse() { return FoundDecl; }
 
-  };  // end class DeclMatcher
+  }; // end class DeclMatcher
 
   void CheckForLoopConditionalStatement(Sema &S, Expr *Second,
 Expr *Third, Stmt *Body) {
diff --git a/clang/test/SemaCXX/warn-loop-analysis.cpp 
b/clang/test/SemaCXX/warn-loop-analysis.cpp
index 324dd386292ac..4f7c70f65677b 100644
--- a/clang/test/SemaCXX/warn-loop-analysis.cpp
+++ b/clang/test/SemaCXX/warn-loop-analysis.cpp
@@ -299,3 +299,18 @@ void test10() {
   for (auto[i, j, k] = arr; i < a; ++i) { }
   for (auto[i, j, k] = arr; i < a; ++arr[0]) { }
 };
+
+extern void foo(int);
+void test11() {
+  int a = 0;
+  auto incr_a = [&a]() { ++a; };
+
+  for (int b = 10; a <= b; incr_a())
+foo(a);
+
+  for (int b = 10; a <= b;)
+incr_a();
+
+  for (int b = 10; a <= b; [&a]() { ++a; }()) { }
+  for (int b = 10; a <= b; [&a]() { }()) { }
+}

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-16 Thread Erich Keane via cfe-commits

erichkeane wrote:

I too don't think this is an extension that we really want.  It is a pretty 
awful extension that does some pretty awful things to the language (and isn't 
implemented in a way that 'works right' in GCC anyway).  Unless there is a 
REALLY important workload that we absolutely need to compile, I'd prefer we 
don't.

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


[clang] [HLSL] Use hlsl_device address space for getpointer. (PR #127675)

2025-04-16 Thread Steven Perron via cfe-commits

s-perron wrote:

@hekota Do you have any more things that need to be fixed?

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


[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mariya Podchishchaeva (Fznamznon)


Changes

Tries to avoid memory leaks caused by saving filename earlier by allocating 
memory in the preprocessor.

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

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


8 Files Affected:

- (modified) clang/include/clang/AST/Expr.h (+4) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+2-1) 
- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/lib/AST/StmtPrinter.cpp (+5-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+11-2) 
- (modified) clang/lib/Parse/ParseInit.cpp (+2-1) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+3-1) 
- (modified) clang/test/Preprocessor/embed_weird.cpp (+40) 


``diff
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 529c6228bfa19..a83320a7ddec2 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4961,6 +4961,9 @@ class SourceLocExpr final : public Expr {
 /// Stores data related to a single #embed directive.
 struct EmbedDataStorage {
   StringLiteral *BinaryData;
+  // FileName string already includes braces, i.e. it is  for a
+  // directive #embed .
+  StringRef FileName;
   size_t getDataElementCount() const { return BinaryData->getByteLength(); }
 };
 
@@ -5007,6 +5010,7 @@ class EmbedExpr final : public Expr {
   SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
 
   StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
+  StringRef getFileName() const { return Data->FileName; }
   EmbedDataStorage *getData() const { return Data; }
 
   unsigned getStartingElementPos() const { return Begin; }
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index f8f2f567f9171..10260c61bdf11 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2761,7 +2761,7 @@ class Preprocessor {
 const FileEntry *LookupFromFile = nullptr);
   void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
 const LexEmbedParametersResult &Params,
-StringRef BinaryContents);
+StringRef BinaryContents, StringRef FileName);
 
   // File inclusion.
   void HandleIncludeDirective(SourceLocation HashLoc, Token &Tok,
@@ -3065,6 +3065,7 @@ class EmptylineHandler {
 /// preprocessor to the parser through an annotation token.
 struct EmbedAnnotationData {
   StringRef BinaryData;
+  StringRef FileName;
 };
 
 /// Registry of pragma handlers added by plugins
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1f23b754a69cb..a757f4c6430ae 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7256,7 +7256,7 @@ class Sema final : public SemaBase {
 
   // #embed
   ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-StringLiteral *BinaryData);
+StringLiteral *BinaryData, StringRef FileName);
 
   // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index aae10fd3bd885..2993d7d0ee865 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1284,7 +1284,11 @@ void StmtPrinter::VisitSourceLocExpr(SourceLocExpr 
*Node) {
 }
 
 void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
-  llvm::report_fatal_error("Not implemented");
+  // Embed parameters are not reflected in the AST, so there is no way to print
+  // them yet.
+  OS << "#embed ";
+  OS << Node->getFileName();
+  OS << NL;
 }
 
 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 21ec83b437ef4..cd90dfd885007 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3909,7 +3909,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool 
ForHasEmbed) {
 
 void Preprocessor::HandleEmbedDirectiveImpl(
 SourceLocation HashLoc, const LexEmbedParametersResult &Params,
-StringRef BinaryContents) {
+StringRef BinaryContents, StringRef FileName) {
   if (BinaryContents.empty()) {
 // If we have no binary contents, the only thing we need to emit are the
 // if_empty tokens, if any.
@@ -3940,6 +3940,7 @@ void Preprocessor::HandleEmbedDirectiveImpl(
 
   EmbedAnnotationData *Data = new (BP) EmbedAnnotationData;
   Data->BinaryData = BinaryContents;
+  Data->FileName = FileName;
 
   Toks[CurIdx].startToken();
   Toks[CurIdx].setKind(tok::annot_embed);
@@ -4049,5 +4050,13 @@ void Preprocessor::HandleEmbedDirective(SourceLocation 
HashLoc, Token &EmbedTok,
   if (Callbacks)
 Callbacks->EmbedDirective(HashLoc, Filename, isAngled, MaybeFileRef,

[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-16 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon created 
https://github.com/llvm/llvm-project/pull/135957

Tries to avoid memory leaks caused by saving filename earlier by allocating 
memory in the preprocessor.

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

>From b194133f44768a61a7af6486dc40deae2de73f9a Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Wed, 16 Apr 2025 05:59:24 -0700
Subject: [PATCH] [clang] Implement StmtPrinter for EmbedExpr

Tries to avoid memory leaks caused by saving filename earlier by
allocating memory in the preprocessor.

Fixes https://github.com/llvm/llvm-project/issues/132641
---
 clang/include/clang/AST/Expr.h  |  4 +++
 clang/include/clang/Lex/Preprocessor.h  |  3 +-
 clang/include/clang/Sema/Sema.h |  2 +-
 clang/lib/AST/StmtPrinter.cpp   |  6 +++-
 clang/lib/Lex/PPDirectives.cpp  | 13 ++--
 clang/lib/Parse/ParseInit.cpp   |  3 +-
 clang/lib/Sema/SemaExpr.cpp |  4 ++-
 clang/test/Preprocessor/embed_weird.cpp | 40 +
 8 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 529c6228bfa19..a83320a7ddec2 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4961,6 +4961,9 @@ class SourceLocExpr final : public Expr {
 /// Stores data related to a single #embed directive.
 struct EmbedDataStorage {
   StringLiteral *BinaryData;
+  // FileName string already includes braces, i.e. it is  for a
+  // directive #embed .
+  StringRef FileName;
   size_t getDataElementCount() const { return BinaryData->getByteLength(); }
 };
 
@@ -5007,6 +5010,7 @@ class EmbedExpr final : public Expr {
   SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
 
   StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
+  StringRef getFileName() const { return Data->FileName; }
   EmbedDataStorage *getData() const { return Data; }
 
   unsigned getStartingElementPos() const { return Begin; }
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index f8f2f567f9171..10260c61bdf11 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2761,7 +2761,7 @@ class Preprocessor {
 const FileEntry *LookupFromFile = nullptr);
   void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
 const LexEmbedParametersResult &Params,
-StringRef BinaryContents);
+StringRef BinaryContents, StringRef FileName);
 
   // File inclusion.
   void HandleIncludeDirective(SourceLocation HashLoc, Token &Tok,
@@ -3065,6 +3065,7 @@ class EmptylineHandler {
 /// preprocessor to the parser through an annotation token.
 struct EmbedAnnotationData {
   StringRef BinaryData;
+  StringRef FileName;
 };
 
 /// Registry of pragma handlers added by plugins
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1f23b754a69cb..a757f4c6430ae 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7256,7 +7256,7 @@ class Sema final : public SemaBase {
 
   // #embed
   ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-StringLiteral *BinaryData);
+StringLiteral *BinaryData, StringRef FileName);
 
   // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index aae10fd3bd885..2993d7d0ee865 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1284,7 +1284,11 @@ void StmtPrinter::VisitSourceLocExpr(SourceLocExpr 
*Node) {
 }
 
 void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
-  llvm::report_fatal_error("Not implemented");
+  // Embed parameters are not reflected in the AST, so there is no way to print
+  // them yet.
+  OS << "#embed ";
+  OS << Node->getFileName();
+  OS << NL;
 }
 
 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 21ec83b437ef4..cd90dfd885007 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3909,7 +3909,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool 
ForHasEmbed) {
 
 void Preprocessor::HandleEmbedDirectiveImpl(
 SourceLocation HashLoc, const LexEmbedParametersResult &Params,
-StringRef BinaryContents) {
+StringRef BinaryContents, StringRef FileName) {
   if (BinaryContents.empty()) {
 // If we have no binary contents, the only thing we need to emit are the
 // if_empty tokens, if any.
@@ -3940,6 +3940,7 @@ void Preprocessor::HandleEmbedDirectiveImpl(
 
   EmbedAnnotationData *Data = new (BP) EmbedAnnotationData;
   Data->BinaryData = BinaryContents;
+  Data->File

[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-win` 
running on `as-builder-10` while building `clang-tools-extra,clang` at step 8 
"build-default".

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


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

```
Step 8 (build-default) failure: cmake (failure)
...
462.558 [198/59/5171]Building CXX object 
tools\lldb\source\Plugins\LanguageRuntime\ObjC\AppleObjCRuntime\CMakeFiles\lldbPluginAppleObjCRuntime.dir\AppleObjCRuntime.cpp.obj
462.568 [198/58/5172]Building CXX object 
tools\lldb\source\Plugins\SystemRuntime\MacOSX\CMakeFiles\lldbPluginSystemRuntimeMacOSX.dir\AppleGetThreadItemInfoHandler.cpp.obj
462.654 [198/57/5173]Building CXX object 
tools\lldb\source\Plugins\Platform\NetBSD\CMakeFiles\lldbPluginPlatformNetBSD.dir\PlatformNetBSD.cpp.obj
462.756 [198/56/5174]Building CXX object 
tools\lldb\source\Plugins\LanguageRuntime\ObjC\GNUstepObjCRuntime\CMakeFiles\lldbPluginGNUstepObjCRuntime.dir\GNUstepObjCRuntime.cpp.obj
463.209 [198/55/5175]Building CXX object 
tools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\ASTResultSynthesizer.cpp.obj
463.237 [198/54/5176]Building CXX object 
tools\lldb\source\Plugins\LanguageRuntime\ObjC\CMakeFiles\lldbPluginObjCRuntime.dir\ObjCLanguageRuntime.cpp.obj
463.265 [198/53/5177]Building CXX object 
tools\lldb\source\Plugins\SystemRuntime\MacOSX\CMakeFiles\lldbPluginSystemRuntimeMacOSX.dir\AppleGetQueuesHandler.cpp.obj
463.318 [198/52/5178]Building CXX object 
tools\lldb\source\Plugins\Platform\Linux\CMakeFiles\lldbPluginPlatformLinux.dir\PlatformLinux.cpp.obj
463.726 [198/51/5179]Building CXX object 
tools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\ASTStructExtractor.cpp.obj
463.754 [198/50/5180]Building CXX object 
tools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\ClangModulesDeclVendor.cpp.obj
FAILED: 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.obj
 
ccache 
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe
  /nologo /TP -DCLANG_BUILD_STATIC -DGTEST_HAS_RTTI=0 -DUNICODE 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\source\Plugins\ExpressionParser\Clang
 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\ExpressionParser\Clang
 -IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\include 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\include 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\build\include 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\include 
-IC:\Python312\include 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\llvm\..\clang\include 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\..\clang\include 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source 
-IC:\buildbot\as-builder-10\lldb-x-aarch64\build\tools\lldb\source 
-D__OPTIMIZE__ /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj 
/permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 
-wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 
-wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 
-wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 
-wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD   -wd4018 -wd4068 -wd4150 -wd4201 
-wd4251 -wd4521 -wd4530 -wd4589  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes 
/Fotools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\ClangModulesDeclVendor.cpp.obj
 
/Fdtools\lldb\source\Plugins\ExpressionParser\Clang\CMakeFiles\lldbPluginExpressionParserClang.dir\lldbPluginExpressionParserClang.pdb
 /FS -c 
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangModulesDeclVendor.cpp
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangModulesDeclVendor.cpp(360):
 error C2664: 'clang::ModuleLoadResult 
`anonymous-namespace'::ClangModulesDeclVendorImpl::DoGetModule(clang::ModuleIdPath,bool)':
 cannot convert argument 1 from 'T' to 'clang::ModuleIdPath'
with
[
T=std::pair
]
C:\buildbot\as-builder-10\lldb-x-aarch64\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangModulesDeclVendor.cpp(360):
 note: No user-defined-conversion operator available that can perform this 
conversion, or the operator c

[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-16 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 HEAD~1 HEAD --extensions h,cpp -- 
clang/include/clang/AST/Expr.h clang/include/clang/Lex/Preprocessor.h 
clang/include/clang/Sema/Sema.h clang/lib/AST/StmtPrinter.cpp 
clang/lib/Lex/PPDirectives.cpp clang/lib/Parse/ParseInit.cpp 
clang/lib/Sema/SemaExpr.cpp clang/test/Preprocessor/embed_weird.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ae7b3fedd..01117e778 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16903,8 +16903,7 @@ ExprResult Sema::BuildSourceLocExpr(SourceLocIdentKind 
Kind, QualType ResultTy,
 }
 
 ExprResult Sema::ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-StringLiteral *BinaryData,
-StringRef FileName) {
+StringLiteral *BinaryData, StringRef FileName) 
{
   EmbedDataStorage *Data = new (Context) EmbedDataStorage;
   Data->BinaryData = BinaryData;
   Data->FileName = FileName;

``




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


[clang] [NFC][Clang] Introduce type aliases to replace use of auto in clang/lib/CodeGen/CGCall.cpp. (PR #135861)

2025-04-16 Thread Erich Keane via cfe-commits

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


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


[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang-tools-extra,clang` at step 4 
"build".

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


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

```
Step 4 (build) failure: build (failure)
...
296.098 [159/88/6366] Building CXX object 
tools/llvm-objcopy/CMakeFiles/llvm-objcopy.dir/llvm-objcopy-driver.cpp.o
296.109 [158/88/6367] Linking CXX executable bin/llvm-yaml-numeric-parser-fuzzer
296.146 [158/87/6368] Linking CXX executable bin/llvm-pdbutil
296.168 [158/86/6369] Linking CXX executable bin/llvm-rust-demangle-fuzzer
296.181 [158/85/6370] Building CXX object 
tools/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeFiles/lldbPluginAppleObjCRuntime.dir/AppleObjCTrampolineHandler.cpp.o
296.197 [158/84/6371] Linking CXX executable bin/llvm-yaml-parser-fuzzer
296.291 [158/83/6372] Building CXX object 
tools/lldb/source/Plugins/Language/CPlusPlus/CMakeFiles/lldbPluginCPlusPlusLanguage.dir/GenericBitset.cpp.o
296.326 [158/82/6373] Linking CXX executable bin/llvm-dwarfdump
296.330 [157/82/6374] Linking CXX executable bin/llvm-stress
296.333 [157/81/6375] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
FAILED: 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG 
-D_FILE_OFFSET_BITS=64 -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_LARGEFILE_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang
 -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/include 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/include 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/llvm/include 
-I/usr/include/python3.10 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/llvm/../clang/include 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/../clang/include 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/source 
-I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/source -isystem 
/usr/include/libxml2 -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -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 -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-vla-extension -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -MF 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o.d
 -o 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -c 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
../llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:138:61:
 error: no viable conversion from 'const value_type' (aka 'const 
clang::IdentifierLoc') to 'const std::pair'
  138 | for (const std::pair &component : 
path)
  | ^ ~
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../../include/c++/11/bits/stl_pair.h:314:17:
 note: candidate constructor not viable: no known conversion from 'const 
value_type' (aka 'const clang::IdentifierLoc') to 'const pair &' for 1st argument
  314 |   constexpr pair(const pair&) = default;///< Copy constructor
  | ^~~~
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../../include/c++/11/bits/stl_pair.h:315:17:
 note: candidate constructor not viable: no known conversion from 'const 
value_type' (aka 'const clang::IdentifierLoc') to 'pair &&' for 1st argument
  315 |   constexpr pair(pair&&) = default; ///< Move constructor
  | ^~~
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../../include/c++/11/bits/stl_pair.h:300:19:
 note: candidate template ignored: could not match 'const pair<_U1, _U

[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-16 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

This might also fix https://github.com/llvm/llvm-project/issues/107869 since a 
similar fix was proposed earlier to fix it. I don't have any experience with 
clangd to verify though. 

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


[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`cross-project-tests-sie-ubuntu` running on `doug-worker-1a` while building 
`clang-tools-extra,clang` at step 5 "build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
1484.031 [162/8/833] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangASTSource.cpp.o
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:
 In member function ‘clang::TagDecl* 
lldb_private::ClangASTSource::FindCompleteType(const clang::TagDecl*)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:237:63:
 warning: cast from type ‘const clang::TagDecl*’ to type ‘void*’ casts away 
qualifiers [-Wcast-qual]
  237 | TypeQuery query(CompilerDecl(m_clang_ast_context, (void *)decl));
  |   ^~~~
1485.682 [161/8/834] Linking CXX executable bin/clang-scan-deps
1487.396 [160/8/835] Linking CXX executable bin/clang-sycl-linker
1489.830 [159/8/836] Linking CXX executable bin/clang-installapi
1494.424 [158/8/837] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangUtil.cpp.o
1494.847 [157/8/838] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
FAILED: 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/include
 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/include 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include
 -I/usr/include/python3.8 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/../clang/include
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source
 
-I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/source
 -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -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 -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -std=c++17 -MD -MT 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -MF 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o.d
 -o 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -c 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:
 In member function ‘virtual void 
lldb_private::ClangExpressionParser::LLDBPreprocessorCallbacks::moduleImport(clang::SourceLocation,
 clang::ModuleIdPath, const clang::Module*)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:138:73:
 error: invalid initialization of reference of type ‘const 
std::pair&’ from expression of 
type ‘const value_type’ {aka ‘const clang::IdentifierLoc’}
  138 | for (const std::pair &component : 
path)
  | 
^~~~
1494.

[clang] [SYCL] Basic code generation for SYCL kernel caller offload entry point functions. (PR #133030)

2025-04-16 Thread Erich Keane via cfe-commits


@@ -14794,9 +14803,36 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   }
 }
 
-static SYCLKernelInfo BuildSYCLKernelInfo(CanQualType KernelNameType,
+static SYCLKernelInfo BuildSYCLKernelInfo(ASTContext &Context,
+  CanQualType KernelNameType,
   const FunctionDecl *FD) {
-  return {KernelNameType, FD};
+  // Host and device compilation may use different ABIs and different ABIs
+  // may allocate name mangling discriminators differently. A discriminator
+  // override is used to ensure consistent discriminator allocation across
+  // host and device compilation.
+  auto DeviceDiscriminatorOverrider =
+  [](ASTContext &Ctx, const NamedDecl *ND) -> std::optional {
+if (const auto *RD = dyn_cast(ND))
+  if (RD->isLambda())

erichkeane wrote:

>I modified the test included with this PR to use a generic lambda as the 
>kernel name type.

Is this what you're referring to?

```
  auto lambda = [=](auto) { (void) capture; };
  kernel_single_task(lambda);

// CHECK-HOST-LINUX:  define internal void 
@_Z18kernel_single_taskIZ4mainEUlT_E_S1_EvT0_(i32 %kernelFunc.coerce) 
#{{[0-9]+}} {
// CHECK-HOST-WINDOWS:  define internal void 
@"??$kernel_single_task@V@?0??main@@9@V1?0??2@9@@@YAXV@?0??main@@9@@Z"(i32
 %kernelFunc.coerce) #{{[0-9]+}} {
```
If so, I think that does.  

> I'll need a theoretical explanation for why the capture type of a generic 
> lambda would be mangled any differently than for a non-generic lambda in 
> order to make progress. I can't think of any reason for mangling differences.

The concern here is that you're using `DeviceLambdaManglingNumber`, which, at 
one point when I checked, wasn't actually set for non-instantiated generic 
lambdas.  So the attempt to mangle them would always result in the 'same' 
mangling number, which doesn't really work.  In addition to the above, can you 
test the following, and make sure it results in proper looking names?
```
  kernel_single_task();
  kernel_single_task();
```
I would expect those two to be different lambdas with different manglings.  You 
MIGHT have to extract those out into a `using` of the type if you have to use 
the same lambda for the call(which I don't think you do?)

>I can't think of any reason for mangling differences.

Depending on how types are mangled in some situations we actually mangle the 
arguments of the lambda, which results in `auto` being used as the mangling, 
though my memory on when that happens is vague ATM.

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


[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building 
`clang-tools-extra,clang` at step 4 "build".

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


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

```
Step 4 (build) failure: build (failure)
...
1512.669 [1224/5/5384] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangDeclVendor.cpp.o
1512.697 [1218/10/5385] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionUtil.cpp.o
1512.709 [1217/10/5386] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionSourceCode.cpp.o
1512.917 [1216/10/5387] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangASTImporter.cpp.o
1512.938 [1215/10/5388] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangHost.cpp.o
1518.645 [1215/9/5389] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionVariable.cpp.o
1518.880 [1215/8/5390] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangASTSource.cpp.o
1519.827 [1214/8/5391] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExternalASTSourceCallbacks.cpp.o
1521.910 [1214/7/5392] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionDeclMap.cpp.o
1522.632 [1214/6/5393] Building CXX object 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
FAILED: 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/source/Plugins/ExpressionParser/Clang
 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang
 -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/include 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/include 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/llvm/include 
-I/usr/include/python3.10 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/llvm/../clang/include
 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/../clang/include
 -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/source 
-I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/source 
-isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -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 -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-vla-extension -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -MF 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o.d
 -o 
tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
 -c 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
../llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:138:61:
 error: no viable conversion from 'const value_type' (aka 'const 
clang::IdentifierLoc') to 'const std::pair'
  138 | for (const std::pair &component : 
path)
  | ^ ~
/usr/lib/gcc/aarch64-linux-gnu/11/../../../../include/c++/11/bits/stl_pair.h:314:17:
 note: candidate constructor not viable: no known conversion from 'const 
value_type' (aka 'const clang::IdentifierLoc') to 'const pair &' 

[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-16 Thread Erich Keane via cfe-commits

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


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


[clang] [llvm] [AARCH64] Add FEAT_SSVE_FEXPA and fix unsupported features list (PR #134368)

2025-04-16 Thread via cfe-commits

https://github.com/Lukacma updated 
https://github.com/llvm/llvm-project/pull/134368

>From c1d652f7bb3f6ff272eca6dabc762b9504d7126a Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Fri, 4 Apr 2025 11:18:23 +
Subject: [PATCH 1/2] [AARCH64] Add support for FEAT_SSVE_FEXPA extension and
 update fix unsopported features list

---
 clang/include/clang/Basic/arm_sve.td   |  6 --
 .../CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c | 14 +++---
 .../Driver/print-supported-extensions-aarch64.c|  1 +
 llvm/lib/Target/AArch64/AArch64.td |  5 ++---
 llvm/lib/Target/AArch64/AArch64Features.td |  4 +++-
 llvm/lib/Target/AArch64/AArch64InstrInfo.td|  4 
 llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td |  2 +-
 llvm/test/CodeGen/AArch64/sve-intrinsics-fexpa.ll  |  2 +-
 llvm/test/MC/AArch64/SVE/fexpa.s   |  8 
 9 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 35263541b67ae..f09f40ce9202e 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -836,9 +836,11 @@ defm SVRINTP : SInstZPZ<"svrintp", "hfd", 
"aarch64_sve_frintp">;
 defm SVRINTX : SInstZPZ<"svrintx", "hfd", "aarch64_sve_frintx">;
 defm SVRINTZ : SInstZPZ<"svrintz", "hfd", "aarch64_sve_frintz">;
 defm SVSQRT  : SInstZPZ<"svsqrt",  "hfd", "aarch64_sve_fsqrt">;
-
+def SVEXPA  : SInst<"svexpa[_{d}]",  "du",   "hfd", MergeNone, 
"aarch64_sve_fexpa_x", [VerifyRuntimeMode]>{
+   let SVETargetGuard = "sve";
+   let SMETargetGuard = "sme2,ssve-fexpa";
+}
 let SVETargetGuard = "sve", SMETargetGuard = InvalidMode in {
-def SVEXPA  : SInst<"svexpa[_{d}]",  "du",   "hfd", MergeNone, 
"aarch64_sve_fexpa_x">;
 def SVTMAD  : SInst<"svtmad[_{d}]",  "dddi", "hfd", MergeNone, 
"aarch64_sve_ftmad_x", [], [ImmCheck<2, ImmCheck0_7>]>;
 def SVTSMUL : SInst<"svtsmul[_{d}]", "ddu",  "hfd", MergeNone, 
"aarch64_sve_ftsmul_x">;
 def SVTSSEL : SInst<"svtssel[_{d}]", "ddu",  "hfd", MergeNone, 
"aarch64_sve_ftssel_x">;
diff --git a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c 
b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c
index 52b6822a833f7..8c34017b7750b 100644
--- a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c
+++ b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c
@@ -1,10 +1,12 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone 
-Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature 
+sme2 -target-feature +sme -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s 
| opt -S -passes=mem2reg,tailcallelim | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone 
-Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -passes=mem2reg,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S 
-passes=mem2reg,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
 // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -S -disable-O0-optnone 
-Werror -Wall -o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature 
+sme2 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
 #include 
 
 #ifdef SVE_OVERLOADED_FORMS
@@ -14,6 +16,12 @@
 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
 #endif
 
+#ifdef __ARM_FEATURE_SME
+#define STREAMING __arm_streaming
+#else
+#define STREAMING
+#endif
+
 // CHECK-LABEL: @test_svexpa_f16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]])
@@ -24,7 +32,7 @@
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat16_t test_svexpa_f16(svuint16_t op)
+svfloat16_t test_svexpa_f16(svuint16_t op) STREAMING
 {
   return SVE_ACLE_FUNC(svexpa,_f16,,)(op);
 }
@@ -39,7 +47,7 @@ svfloat16_t test_svexpa_f16(svuint16_t op)
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fexpa.x.nxv4f32( [[OP:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
-svfloat32_t test_svexpa_f32(svuint32_t op)
+svfloat32_t test_svexpa_f32(svuint32_t op) STREAMING
 {
   return SVE_ACLE_FUNC(svexpa,_f32,,)(op);
 }
@@ -54,7 +62,7 @@ svfloat32_t test_svexpa_f32(svuint32_t op)
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fexpa.x.nxv2f64( [[OP:%.*]])
 // CPP-CHECK-NEXT:   

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-16 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman requested changes to this pull request.

> This patch adds support for GCC bound member functions extension: 
> https://gcc.gnu.org/onlinedocs/gcc/Bound-member-functions.html
> 
> Related issue: #22495 Closes #82727

I think this requires an RFC justifying carrying the extension. It's a 
non-conforming extension that we previously decided we would not implement 
(#22495 was closed as `WONTFIX`), and there's no real motivation for the 
feature request listed in #82727.

(Personally, I think #82727 should be closed as a duplicate of #22495 unless 
there's a very strong justification for carrying the extension.)

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


[clang] [Clang] [Sema] Fix a crash when a `friend` function is redefined as deleted (PR #135679)

2025-04-16 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-5` while building `clang` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'lit :: shtest-external-shell-kill.py' FAILED 

Exit Code: 1

Command Output (stdout):
--
# RUN: at line 23
env -u FILECHECK_OPTS 
"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9"
 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit.py 
-j1 --order=lexical -a Inputs/shtest-external-shell-kill | grep -v 'bash.exe: 
warning: could not find /tmp, please create!' | FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py
# executed command: env -u FILECHECK_OPTS 
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9
 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/utils/lit/lit.py 
-j1 --order=lexical -a Inputs/shtest-external-shell-kill
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
# executed command: grep -v 'bash.exe: warning: could not find /tmp, please 
create!'
# executed command: FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py
# .---command stderr
# | 
/Users/buildbot/buildbot-root/aarch64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py:29:15:
 error: CHECK-NEXT: is not on the line after the previous 
match
# | # CHECK-NEXT: end
# |   ^
# | :22:6: note: 'next' match 
was here
# | echo end # RUN: at line 5
# |  ^
# | :8:6: note: previous match 
ended here
# | start
# |  ^
# | :9:1: note: non-matching 
line after previous match is here
# | 
# | ^
# | 
# | Input file: 
# | Check file: 
/Users/buildbot/buildbot-root/aarch64-darwin/build/utils/lit/tests/shtest-external-shell-kill.py
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<
# |   1: -- Testing: 1 tests, 1 
workers -- 
# |   2: FAIL: shtest-external-shell-kill :: 
test.txt (1 of 1) 
# |   3:  TEST 
'shtest-external-shell-kill :: test.txt' FAILED  
# |   4: Exit Code: 1 
# |   5:  
# |   6: Command Output 
(stdout): 
# | check:26 ^~~~
# |   7: -- 
# | next:27  ^~
# |   8: start 

# | next:28  ^
# |   9:  
# |  10: -- 
# |  11: Command Output (stderr): 
# |  12: -- 
# |  13: echo start # RUN: at line 1 
# |  14: + echo start 
...

```



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


[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-16 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/135407

>From c7e0132617ab01c12b393876b39381171996b793 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 11 Apr 2025 13:03:07 -0400
Subject: [PATCH 1/5] Disable -fdollars-in-identifiers by default

Clang used to enable -fdollars-in-identifiers by default for
compatibility with GCC. However, this is no longer a conforming
extension after WG21 P2558R2 and WG14 N2701.

So this disables the dialect by default, which is a potentially
breaking change for users.

Note: some inline assembly constructs may use dollars in identifiers.
We cannot enable the dialect mode automatically based on the user
passing -fasm-blocks because that flag is implied by -fms-extensions
which is enabled by default on Windows, and thus would mean we'd be
enabling a non-conforming language extension by default on that
platform.

Users impacted by the change should explicitly add
-fdollars-in-identifiers to their build scripts.

Partially addresses #128939
---
 clang/docs/ReleaseNotes.rst |  5 +
 clang/include/clang/Basic/LangOptions.def   |  2 +-
 clang/include/clang/Driver/Options.td   |  2 +-
 clang/test/AST/ByteCode/codegen.m   |  2 +-
 clang/test/C/drs/dr0xx.c| 12 ++--
 clang/test/CodeGen/ms-inline-asm.c  |  2 +-
 clang/test/CodeGenObjC/extern-void-class-decl.m |  2 +-
 clang/test/Lexer/dollar-idents.c|  2 +-
 clang/test/Lexer/gh128939.cpp   | 17 +
 clang/test/Preprocessor/c90.c   |  2 +-
 10 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 clang/test/Lexer/gh128939.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9c45965dc4d82..fe51de6fd5b7c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -48,6 +48,11 @@ C/C++ Language Potentially Breaking Changes
   ensure they are not caught by these optimizations.  It is also possible to 
use
   ``-fwrapv-pointer`` or   ``-fno-delete-null-pointer-checks`` to make pointer 
arithmetic
   on null pointers well-defined. (#GH130734, #GH130742, #GH130952)
+- Use of the dollar sign (``$``) in an identifier is no longer a conforming
+  extension in either C or C++, so ``-fdollars-in-identifiers`` is no longer
+  enabled by default. Use of the dollar sign in an identifier will now be
+  diagnosed as an error unless ``-fdollars-in-identifiers`` is explicitly
+  enabled.
 
 C++ Specific Potentially Breaking Changes
 -
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 3879cc7942877..f08e179a38067 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -119,7 +119,7 @@ LANGOPT(WChar , 1, 0, "wchar_t keyword")
 LANGOPT(Char8 , 1, 0, "char8_t keyword")
 LANGOPT(IEEE128   , 1, 0, "__ieee128 keyword")
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
-BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
+BENIGN_LANGOPT(DollarIdents   , 1, 0, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
 LANGOPT(GNUMode   , 1, 1, "GNU extensions")
 LANGOPT(GNUKeywords   , 1, 1, "GNU keywords")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c1020b234b136..38eb332f40d27 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2088,7 +2088,7 @@ def fno_discard_value_names : Flag<["-"], 
"fno-discard-value-names">,
   Group, Visibility<[ClangOption, DXCOption]>,
   HelpText<"Do not discard value names in LLVM IR">;
 defm dollars_in_identifiers : BoolFOption<"dollars-in-identifiers",
-  LangOpts<"DollarIdents">, Default,
+  LangOpts<"DollarIdents">, DefaultFalse,
   PosFlag,
   NegFlag,
   BothFlags<[], [ClangOption, CC1Option], " '$' in identifiers">>;
diff --git a/clang/test/AST/ByteCode/codegen.m 
b/clang/test/AST/ByteCode/codegen.m
index 6139596c6337a..a7b3a100165eb 100644
--- a/clang/test/AST/ByteCode/codegen.m
+++ b/clang/test/AST/ByteCode/codegen.m
@@ -3,7 +3,7 @@
 /// See test/CodeGenObjC/constant-strings.m
 /// Test that we let the APValue we create for ObjCStringLiterals point to the 
right expression.
 
-// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -o %t %s 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-macho -fdollars-in-identifiers  -emit-llvm 
-o %t %s -fexperimental-new-constant-interpreter
 // RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
 
 // Check that we set alignment 1 on the string.
diff --git a/clang/test/C/drs/dr0xx.c b/clang/test/C/drs/dr0xx.c
index 5fe023deaece9..ffcd63b0cc9a7 100644
--- a/clang/test/C/drs/dr0xx.c
+++ b/clang/test/C/drs/dr0xx.c
@@ -1,9 +1,9 @@
-/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify=expe

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-16 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> If you don't want to do anything fancy, can you just add a warning in 
> Lexer::LexTokenInternal if we see a '$' (where we set the token type to 
> tok::unknown)? That should be easy to implement, and have zero impact on 
> lexer performance.

Okay, that's pretty reasonable. Note, we only emit the diagnostic when finding 
`$` at the *start* of an identifier, not as a continuation character. Otherwise 
we'd issue two diagnostics for `foo$bar`, one for finding the continuation 
character and one for finding the start of the next token. I added test 
coverage to be sure we caught `$a`, `a$`, and `a$b` correctly.

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


[clang] [llvm] [clang][OpenMP][SPIR-V] Fix AS of globals and set the default AS to 4 (PR #135251)

2025-04-16 Thread Nick Sarnie via cfe-commits

sarnex wrote:

Ping on this one @jhuber6 @AlexVlx, thanks!

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


[clang] [llvm] [OpenACC] Switch Clang to use the Flang 'appertainment' rules for cla… (PR #135372)

2025-04-16 Thread Erich Keane via cfe-commits

erichkeane wrote:

We're in agreement on all of the 'standards discussion needed' part, and we've 
filed bugs for them, so i've removed them.  So now we're down to 3 differences, 
which I will spawn email threads for between us and the OpenACC chair.

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


[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-16 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/135957

>From b194133f44768a61a7af6486dc40deae2de73f9a Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Wed, 16 Apr 2025 05:59:24 -0700
Subject: [PATCH 1/2] [clang] Implement StmtPrinter for EmbedExpr

Tries to avoid memory leaks caused by saving filename earlier by
allocating memory in the preprocessor.

Fixes https://github.com/llvm/llvm-project/issues/132641
---
 clang/include/clang/AST/Expr.h  |  4 +++
 clang/include/clang/Lex/Preprocessor.h  |  3 +-
 clang/include/clang/Sema/Sema.h |  2 +-
 clang/lib/AST/StmtPrinter.cpp   |  6 +++-
 clang/lib/Lex/PPDirectives.cpp  | 13 ++--
 clang/lib/Parse/ParseInit.cpp   |  3 +-
 clang/lib/Sema/SemaExpr.cpp |  4 ++-
 clang/test/Preprocessor/embed_weird.cpp | 40 +
 8 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 529c6228bfa19..a83320a7ddec2 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4961,6 +4961,9 @@ class SourceLocExpr final : public Expr {
 /// Stores data related to a single #embed directive.
 struct EmbedDataStorage {
   StringLiteral *BinaryData;
+  // FileName string already includes braces, i.e. it is  for a
+  // directive #embed .
+  StringRef FileName;
   size_t getDataElementCount() const { return BinaryData->getByteLength(); }
 };
 
@@ -5007,6 +5010,7 @@ class EmbedExpr final : public Expr {
   SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
 
   StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
+  StringRef getFileName() const { return Data->FileName; }
   EmbedDataStorage *getData() const { return Data; }
 
   unsigned getStartingElementPos() const { return Begin; }
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index f8f2f567f9171..10260c61bdf11 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2761,7 +2761,7 @@ class Preprocessor {
 const FileEntry *LookupFromFile = nullptr);
   void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
 const LexEmbedParametersResult &Params,
-StringRef BinaryContents);
+StringRef BinaryContents, StringRef FileName);
 
   // File inclusion.
   void HandleIncludeDirective(SourceLocation HashLoc, Token &Tok,
@@ -3065,6 +3065,7 @@ class EmptylineHandler {
 /// preprocessor to the parser through an annotation token.
 struct EmbedAnnotationData {
   StringRef BinaryData;
+  StringRef FileName;
 };
 
 /// Registry of pragma handlers added by plugins
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1f23b754a69cb..a757f4c6430ae 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7256,7 +7256,7 @@ class Sema final : public SemaBase {
 
   // #embed
   ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-StringLiteral *BinaryData);
+StringLiteral *BinaryData, StringRef FileName);
 
   // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index aae10fd3bd885..2993d7d0ee865 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1284,7 +1284,11 @@ void StmtPrinter::VisitSourceLocExpr(SourceLocExpr 
*Node) {
 }
 
 void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
-  llvm::report_fatal_error("Not implemented");
+  // Embed parameters are not reflected in the AST, so there is no way to print
+  // them yet.
+  OS << "#embed ";
+  OS << Node->getFileName();
+  OS << NL;
 }
 
 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 21ec83b437ef4..cd90dfd885007 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3909,7 +3909,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool 
ForHasEmbed) {
 
 void Preprocessor::HandleEmbedDirectiveImpl(
 SourceLocation HashLoc, const LexEmbedParametersResult &Params,
-StringRef BinaryContents) {
+StringRef BinaryContents, StringRef FileName) {
   if (BinaryContents.empty()) {
 // If we have no binary contents, the only thing we need to emit are the
 // if_empty tokens, if any.
@@ -3940,6 +3940,7 @@ void Preprocessor::HandleEmbedDirectiveImpl(
 
   EmbedAnnotationData *Data = new (BP) EmbedAnnotationData;
   Data->BinaryData = BinaryContents;
+  Data->FileName = FileName;
 
   Toks[CurIdx].startToken();
   Toks[CurIdx].setKind(tok::annot_embed);
@@ -4049,5 +4050,13 @@ void Preprocessor::HandleEmbedDirective(Sourc

[clang] ab7e0c0 - [clang][bytecode] Implement __builtin_wmem{cpy,move} (#135969)

2025-04-16 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-04-16T17:08:10+02:00
New Revision: ab7e0c0fc00b2c0ccae735cb0def103831d15b3b

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

LOG: [clang][bytecode] Implement __builtin_wmem{cpy,move} (#135969)

Added: 


Modified: 
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/test/AST/ByteCode/builtin-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index d06941bf10fe0..b694a34e47ee0 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1788,14 +1788,18 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
   Pointer DestPtr = getParam(Frame, 0);
   const ASTContext &ASTCtx = S.getASTContext();
   const Pointer &SrcPtr = getParam(Frame, 1);
-  const APSInt &Size =
-  peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2)));
+  APSInt Size = peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2)));
   assert(!Size.isSigned() && "memcpy and friends take an unsigned size");
 
   if (ID == Builtin::BImemcpy || ID == Builtin::BImemmove)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
-  bool Move = (ID == Builtin::BI__builtin_memmove || ID == Builtin::BImemmove);
+  bool Move =
+  (ID == Builtin::BI__builtin_memmove || ID == Builtin::BImemmove ||
+   ID == Builtin::BI__builtin_wmemmove || ID == Builtin::BIwmemmove);
+  bool WChar = ID == Builtin::BIwmemcpy || ID == Builtin::BIwmemmove ||
+   ID == Builtin::BI__builtin_wmemcpy ||
+   ID == Builtin::BI__builtin_wmemmove;
 
   // If the size is zero, we treat this as always being a valid no-op.
   if (Size.isZero()) {
@@ -1806,7 +1810,7 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
   if (SrcPtr.isZero() || DestPtr.isZero()) {
 Pointer DiagPtr = (SrcPtr.isZero() ? SrcPtr : DestPtr);
 S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_memcpy_null)
-<< /*IsMove=*/Move << /*IsWchar=*/false << !SrcPtr.isZero()
+<< /*IsMove=*/Move << /*IsWchar=*/WChar << !SrcPtr.isZero()
 << DiagPtr.toDiagnosticString(ASTCtx);
 return false;
   }
@@ -1818,7 +1822,7 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
? std::to_string(SrcPtr.getIntegerRepresentation())
: std::to_string(DestPtr.getIntegerRepresentation());
 S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_memcpy_null)
-<< Move << false << DestPtr.isIntegralPointer() << DiagVal;
+<< Move << WChar << DestPtr.isIntegralPointer() << DiagVal;
 return false;
   }
 
@@ -1837,11 +1841,17 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
   }
   unsigned DestElemSize = 
ASTCtx.getTypeSizeInChars(DestElemType).getQuantity();
 
+  if (WChar) {
+uint64_t WCharSize =
+ASTCtx.getTypeSizeInChars(ASTCtx.getWCharType()).getQuantity();
+Size *= APSInt(APInt(Size.getBitWidth(), WCharSize, /*IsSigned=*/false),
+   /*IsUnsigend=*/true);
+  }
+
   if (Size.urem(DestElemSize) != 0) {
 S.FFDiag(S.Current->getSource(OpPC),
  diag::note_constexpr_memcpy_unsupported)
-<< Move << /*IsWchar=*/false << 0 << DestElemType << Size
-<< DestElemSize;
+<< Move << WChar << 0 << DestElemType << Size << DestElemSize;
 return false;
   }
 
@@ -1869,7 +1879,7 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
 APInt N = Size.udiv(DestElemSize);
 S.FFDiag(S.Current->getSource(OpPC),
  diag::note_constexpr_memcpy_unsupported)
-<< Move << /*IsWChar*/ false << (Size.ugt(RemainingSrcBytes) ? 1 : 2)
+<< Move << WChar << (Size.ugt(RemainingSrcBytes) ? 1 : 2)
 << DestElemType << toString(N, 10, /*Signed=*/false);
 return false;
   }
@@ -2587,8 +2597,12 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const Function *F,
 
   case Builtin::BI__builtin_memcpy:
   case Builtin::BImemcpy:
+  case Builtin::BI__builtin_wmemcpy:
+  case Builtin::BIwmemcpy:
   case Builtin::BI__builtin_memmove:
   case Builtin::BImemmove:
+  case Builtin::BI__builtin_wmemmove:
+  case Builtin::BIwmemmove:
 if (!interp__builtin_memcpy(S, OpPC, Frame, F, Call))
   return false;
 break;

diff  --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 40f7a18119751..a57b4530d2264 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -30,6 +30,7 @@ extern "C" {
   extern wchar_t *wcschr(const wchar_t *s, wchar_t c);
   extern int wcscmp(const wchar_t *s1, const wchar_t *s2);
   extern int wcsncmp(const wchar_t *s1, const w

[clang] [clang][bytecode] Implement __builtin_wmem{cpy, move} (PR #135969)

2025-04-16 Thread Timm Baeder via cfe-commits

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


[clang] [NFC][Driver][CFI] Update boolean expression (PR #135881)

2025-04-16 Thread Vitaly Buka via cfe-commits

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


[clang] [clang-tools-extra] Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc`" (PR #135974)

2025-04-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Michael Buch (Michael137)


Changes

Reverts llvm/llvm-project#135808

Example from the LLDB macOS CI: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/24084/execution/node/54/log/?consoleFull
```
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:360:49:
 error: no viable conversion from 'std::pair' to 'clang::ModuleIdPath' (aka 
'ArrayRef')
  clang::Module *top_level_module = DoGetModule(clang_path.front(), false);
^~
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40:
 note: candidate constructor (the implicit copy constructor) not viable: no 
known conversion from 'std::pair' to 'const llvm::ArrayRef 
&' for 1st argument
  class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
   ^
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40:
 note: candidate constructor (the implicit move constructor) not viable: no 
known conversion from 'std::pair' to 'llvm::ArrayRef 
&&' for 1st argument
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18:
 note: candidate constructor not viable: no known conversion from 
'std::pair' to 
'std::nullopt_t' for 1st argument
/*implicit*/ ArrayRef(std::nullopt_t) {}
```

---

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


45 Files Affected:

- (modified) clang-tools-extra/pp-trace/PPCallbacksTracker.cpp (+2-2) 
- (modified) clang/include/clang/AST/OpenACCClause.h (+10-10) 
- (modified) clang/include/clang/Basic/IdentifierTable.h (+3-23) 
- (modified) clang/include/clang/Lex/ModuleLoader.h (+1-2) 
- (modified) clang/include/clang/Lex/PPCallbacks.h (-1) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+5-4) 
- (modified) clang/include/clang/Parse/LoopHint.h (+1-1) 
- (modified) clang/include/clang/Parse/Parser.h (+8-5) 
- (modified) clang/include/clang/Sema/ParsedAttr.h (+10) 
- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/include/clang/Sema/SemaCodeCompletion.h (+2-1) 
- (modified) clang/include/clang/Sema/SemaObjC.h (+2-2) 
- (modified) clang/include/clang/Sema/SemaOpenACC.h (+1-1) 
- (modified) clang/lib/AST/OpenACCClause.cpp (+2-2) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+2-2) 
- (modified) clang/lib/Frontend/CompilerInstance.cpp (+25-28) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+2-2) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+11-11) 
- (modified) clang/lib/Lex/PPLexerChange.cpp (+3-3) 
- (modified) clang/lib/Lex/Pragma.cpp (+38-35) 
- (modified) clang/lib/Lex/Preprocessor.cpp (+8-8) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+14-14) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+3-4) 
- (modified) clang/lib/Parse/ParseHLSL.cpp (+1-1) 
- (modified) clang/lib/Parse/ParseObjc.cpp (+20-18) 
- (modified) clang/lib/Parse/ParseOpenACC.cpp (+5-7) 
- (modified) clang/lib/Parse/ParsePragma.cpp (+8-7) 
- (modified) clang/lib/Parse/ParseStmt.cpp (+3-3) 
- (modified) clang/lib/Parse/Parser.cpp (+10-9) 
- (modified) clang/lib/Sema/ParsedAttr.cpp (+8) 
- (modified) clang/lib/Sema/SemaARM.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+4-4) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+59-65) 
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (+16-19) 
- (modified) clang/lib/Sema/SemaHLSL.cpp (+6-6) 
- (modified) clang/lib/Sema/SemaModule.cpp (+19-23) 
- (modified) clang/lib/Sema/SemaObjC.cpp (+22-23) 
- (modified) clang/lib/Sema/SemaOpenACCClause.cpp (+5-6) 
- (modified) clang/lib/Sema/SemaStmtAttr.cpp (+13-16) 
- (modified) clang/lib/Sema/SemaSwift.cpp (+12-12) 
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+5-5) 
- (modified) clang/lib/Sema/SemaType.cpp (+7-6) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+4-4) 
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+1-1) 


``diff
diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp 
b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
index 4c916fa30685b..3bb30fd15b2e1 100644
--- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
+++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
@@ -547,8 +547,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, 
ModuleIdPath Value) {
 if (I)
   SS << ", ";
 SS << "{"
-   << "Name: " << Value[I].getIdentifierInfo()->getName() << ", "
-   << "Lo

[clang] [clang-tools-extra] [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #135808)

2025-04-16 Thread Michael Buch via cfe-commits

Michael137 wrote:

Reverted in https://github.com/llvm/llvm-project/pull/135974 since it's 
breaking the LLDB build. Let me know if you need help reproducing

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


[clang] [clang-tools-extra] Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc`" (PR #135974)

2025-04-16 Thread Michael Buch via cfe-commits

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


  1   2   3   4   5   >