[clang-tools-extra] [clang-tidy] Fix broken fix-its with `bugprone-not-null-terminated-result` on Windows (PR #162874)

2025-10-14 Thread Victor Chernyakin via cfe-commits

https://github.com/localspook edited 
https://github.com/llvm/llvm-project/pull/162874
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[HLSL][NFC] Refactor structured buffer methods tests (#161908)" (PR #163472)

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

https://github.com/hekota closed 
https://github.com/llvm/llvm-project/pull/163472
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX512 mask broadcast intrinsics to be used in constexpr (PR #163475)

2025-10-14 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 origin/main HEAD --extensions h,c -- 
clang/lib/Headers/avx512cdintrin.h clang/lib/Headers/avx512vlcdintrin.h 
clang/test/CodeGen/X86/avx512cd-builtins.c 
clang/test/CodeGen/X86/avx512vlcd-builtins.c --diff_from_common_commit
``

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Headers/avx512cdintrin.h 
b/clang/lib/Headers/avx512cdintrin.h
index b5a45cf67..b16144044 100644
--- a/clang/lib/Headers/avx512cdintrin.h
+++ b/clang/lib/Headers/avx512cdintrin.h
@@ -116,7 +116,7 @@ _mm512_broadcastmb_epi64(__mmask8 __A) {
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS_CONSTEXPR
 _mm512_broadcastmw_epi32(__mmask16 __A) {
-  return (__m512i) _mm512_set1_epi32((int) __A);
+  return (__m512i)_mm512_set1_epi32((int)__A);
 }
 
 #undef __DEFAULT_FN_ATTRS

``




https://github.com/llvm/llvm-project/pull/163475
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebKit Checkers] Treat a NS/CF global defined in a system header as a safe pointer origin (PR #161146)

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

https://github.com/rniwa closed https://github.com/llvm/llvm-project/pull/161146
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Support Zvfbfa codegen and C intrinsics (PR #161158)

2025-10-14 Thread Craig Topper via cfe-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/161158
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Add Aggregate Expression LValue Visitors (PR #163410)

2025-10-14 Thread Andy Kaylor via cfe-commits

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

Looks good, except a possibly missing test case

https://github.com/llvm/llvm-project/pull/163410
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] ThrowOp with Complex type as Subexpr (PR #163078)

2025-10-14 Thread Andy Kaylor via cfe-commits

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

lgtm

https://github.com/llvm/llvm-project/pull/163078
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][PAC] Add ptrauth.h helpers for computing type discriminators (PR #163456)

2025-10-14 Thread Daniil Kovalev via cfe-commits

https://github.com/kovdan01 edited 
https://github.com/llvm/llvm-project/pull/163456
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][PAC] Add ptrauth.h helpers for computing type discriminators (PR #163456)

2025-10-14 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

> @ojhunt Thanks for introducing this! It's probably worth applying the 
> auto-formatting suggestion before merging the PR

Oh yeah, du, copying code while forgetting that we have reformatted a lot 
over time :D

https://github.com/llvm/llvm-project/pull/163456
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Fix typos in option names (PR #163482)

2025-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: KAWASHIMA Takahiro (kawashima-fj)


Changes

If you type option names in the currnet Clang Compiler User's Manual, you'll 
see:

```console
$ clang -fnobasic-block-address-map -fnounique-internal-linkage-names 
-f-split-lto-unit test.c 
clang: error: unknown argument '-fnobasic-block-address-map'; did you mean 
'-fno-basic-block-address-map'?
clang: error: unknown argument '-fnounique-internal-linkage-names'; did you 
mean '-fno-unique-internal-linkage-names'?
clang: error: unknown argument '-f-split-lto-unit'; did you mean 
'-fsplit-lto-unit'?
```


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


1 Files Affected:

- (modified) clang/docs/UsersManual.rst (+3-3) 


``diff
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 01f0b27846f0b..e82b16f24c73f 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2325,7 +2325,7 @@ are listed below.
devirtualization and virtual constant propagation, for classes with
:doc:`hidden LTO visibility `. Requires ``-flto``.
 
-.. option:: -f[no]split-lto-unit
+.. option:: -f[no-]split-lto-unit
 
Controls splitting the :doc:`LTO unit ` into regular LTO and
:doc:`ThinLTO` portions, when compiling with -flto=thin. Defaults to false
@@ -2518,7 +2518,7 @@ are listed below.
 
 .. _funique_internal_linkage_names:
 
-.. option:: -f[no]-unique-internal-linkage-names
+.. option:: -f[no-]unique-internal-linkage-names
 
Controls whether Clang emits a unique (best-effort) symbol name for internal
linkage symbols.  When this option is set, compiler hashes the main source
@@ -2539,7 +2539,7 @@ are listed below.
  $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
  $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o
 
-.. option:: -f[no]-basic-block-address-map:
+.. option:: -f[no-]basic-block-address-map:
   Emits a ``SHT_LLVM_BB_ADDR_MAP`` section which includes address offsets for 
each
   basic block in the program, relative to the parent function address.
 

``




https://github.com/llvm/llvm-project/pull/163482
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 23848e6 - [clang][PAC] Add ptrauth.h helpers for computing type discriminators (#163456)

2025-10-14 Thread via cfe-commits

Author: Oliver Hunt
Date: 2025-10-15T01:15:35Z
New Revision: 23848e606baea5c8e5239d56b032399811f54b77

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

LOG: [clang][PAC] Add ptrauth.h helpers for computing type discriminators 
(#163456)

Adds an additional helper that had not been upstreamed, and adds
documentation for both `ptrauth_type_discriminator` and
`ptrauth_function_pointer_type_discriminator`

Added: 


Modified: 
clang/docs/PointerAuthentication.rst
clang/lib/Headers/ptrauth.h

Removed: 




diff  --git a/clang/docs/PointerAuthentication.rst 
b/clang/docs/PointerAuthentication.rst
index 96eb498bc48b6..7e65f4b1b4915 100644
--- a/clang/docs/PointerAuthentication.rst
+++ b/clang/docs/PointerAuthentication.rst
@@ -592,6 +592,36 @@ The result value is never zero and always within range for 
both the
 
 This can be used in constant expressions.
 
+``ptrauth_type_discriminator``
+^^
+
+.. code-block:: c
+
+  ptrauth_type_discriminator(type)
+
+Compute the constant discriminator derived from the given type, as is computed
+for automatically type diversified schemas.
+
+``type`` must be a type. The result has the type ``ptrauth_extra_data_t``.
+
+This can be used in constant expressions.
+
+``ptrauth_function_pointer_type_discriminator``
+^^^
+
+.. code-block:: c
+
+  ptrauth_function_pointer_type_discriminator(function_type)
+
+Compute the constant discriminator derived from the provided function type, for
+use in contexts where the default function authentication schema. If function
+pointer type diversity is enabled, this is equivalent to
+`ptrauth_type_discriminator(function_type)`, if it is not enabled this is `0`.
+
+``function_type`` must be a function type. The result has the type 
``ptrauth_extra_data_t``.
+
+This can be used in constant expressions.
+
 ``ptrauth_strip``
 ^
 

diff  --git a/clang/lib/Headers/ptrauth.h b/clang/lib/Headers/ptrauth.h
index f902ca1e3bbd3..ad28f06f0930c 100644
--- a/clang/lib/Headers/ptrauth.h
+++ b/clang/lib/Headers/ptrauth.h
@@ -241,6 +241,18 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
 #define ptrauth_type_discriminator(__type) 
\
   __builtin_ptrauth_type_discriminator(__type)
 
+/* Compute the constant discriminator used by Clang to sign pointers with the
+   given C function pointer type.
+
+   A call to this function is an integer constant expression. */
+#if __has_feature(ptrauth_function_pointer_type_discrimination)
+#define ptrauth_function_pointer_type_discriminator(__type)
\
+  __builtin_ptrauth_type_discriminator(__type)
+#else
+#define ptrauth_function_pointer_type_discriminator(__type)
\
+  ((ptrauth_extra_data_t)0)
+#endif
+
 /* Compute a signature for the given pair of pointer-sized values.
The order of the arguments is significant.
 
@@ -372,6 +384,8 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
   })
 
 #define ptrauth_type_discriminator(__type) ((ptrauth_extra_data_t)0)
+#define ptrauth_function_pointer_type_discriminator(__type)
\
+  ((ptrauth_extra_data_t)0)
 
 #define ptrauth_sign_generic_data(__value, __data) 
\
   ({   
\



___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Revert incorrect LazyCoumpoundVal changes (PR #163461)

2025-10-14 Thread Marco Borgeaud via cfe-commits

https://github.com/marco-antognini-sonarsource created 
https://github.com/llvm/llvm-project/pull/163461

Reverts #115917 and its follow up #116840.
Fixes #153782 and introduces regression tests.
Reopens #114270.

>From 1775b58ffd43828691ef4b6d2c0c8160f96d5caf Mon Sep 17 00:00:00 2001
From: Marco Borgeaud 
Date: Tue, 14 Oct 2025 22:18:46 +0200
Subject: [PATCH 1/4] Revert "[analyzer] Avoid creating LazyCompoundVal when
 possible (#116840)"

This reverts commit 9b2ec87f5bce57cc900cf52a99f805d999716053.

Resolved conflicts in:
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/test/Analysis/ctor-trivial-copy.cpp
clang/test/Analysis/explain-svals.cpp
---
 clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 23 +--
 clang/test/Analysis/ctor-trivial-copy.cpp | 21 +
 clang/test/Analysis/explain-svals.cpp |  2 +-
 clang/test/Analysis/iterator-modeling.cpp |  2 --
 ...-modeling-aggressive-std-find-modeling.cpp | 10 
 .../test/Analysis/stl-algorithm-modeling.cpp  | 10 
 .../test/Analysis/template-param-objects.cpp  |  2 +-
 7 files changed, 20 insertions(+), 50 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index af0ef52334bd7..4d9a8c54112de 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -714,8 +714,6 @@ class RegionStoreManager : public StoreManager {
 return getBinding(getRegionBindings(S), L, T);
   }
 
-  std::optional getUniqueDefaultBinding(RegionBindingsConstRef B,
-  const TypedValueRegion *R) const;
   std::optional
   getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const;
 
@@ -2465,11 +2463,6 @@ SVal 
RegionStoreManager::getBindingForStruct(RegionBindingsConstRef B,
   // behavior doesn't depend on the struct layout.
   // This way even an empty struct can carry taint, no matter if creduce drops
   // the last field member or not.
-
-  // Try to avoid creating a LCV if it would anyways just refer to a single
-  // default binding.
-  if (std::optional Val = getUniqueDefaultBinding(B, R))
-return *Val;
   return createLazyBinding(B, R);
 }
 
@@ -2758,12 +2751,14 @@ 
RegionStoreManager::bindVector(LimitedRegionBindingsConstRef B,
 }
 
 std::optional
-RegionStoreManager::getUniqueDefaultBinding(RegionBindingsConstRef B,
-const TypedValueRegion *R) const {
-  if (R != R->getBaseRegion())
+RegionStoreManager::getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const 
{
+  const MemRegion *BaseR = LCV.getRegion();
+
+  // We only handle base regions.
+  if (BaseR != BaseR->getBaseRegion())
 return std::nullopt;
 
-  const auto *Cluster = B.lookup(R);
+  const auto *Cluster = getRegionBindings(LCV.getStore()).lookup(BaseR);
   if (!Cluster || !llvm::hasSingleElement(*Cluster))
 return std::nullopt;
 
@@ -2771,12 +2766,6 @@ 
RegionStoreManager::getUniqueDefaultBinding(RegionBindingsConstRef B,
   return Key.isDirect() ? std::optional{} : Value;
 }
 
-std::optional
-RegionStoreManager::getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const 
{
-  auto B = getRegionBindings(LCV.getStore());
-  return getUniqueDefaultBinding(B, LCV.getRegion());
-}
-
 std::optional RegionStoreManager::tryBindSmallStruct(
 LimitedRegionBindingsConstRef B, const TypedValueRegion *R,
 const RecordDecl *RD, nonloc::LazyCompoundVal LCV) {
diff --git a/clang/test/Analysis/ctor-trivial-copy.cpp 
b/clang/test/Analysis/ctor-trivial-copy.cpp
index 940ff9ba3ed9c..db67876f80442 100644
--- a/clang/test/Analysis/ctor-trivial-copy.cpp
+++ b/clang/test/Analysis/ctor-trivial-copy.cpp
@@ -5,8 +5,6 @@
 void clang_analyzer_printState();
 template  void clang_analyzer_dump_lref(T& param);
 template  void clang_analyzer_dump_val(T param);
-template  void clang_analyzer_denote(T param, const char *name);
-template  void clang_analyzer_express(T param);
 template  T conjure();
 template  void nop(const Ts &... args) {}
 
@@ -42,10 +40,16 @@ void test_assign_return() {
 namespace trivial_struct_copy {
 
 void _01_empty_structs() {
-  clang_analyzer_dump_val(conjure()); // expected-warning {{conj_$}}
+  clang_analyzer_dump_val(conjure()); // expected-warning 
{{lazyCompoundVal}}
   empty Empty = conjure();
   empty Empty2 = Empty;
   empty Empty3 = Empty2;
+  // All of these should refer to the exact same LCV, because all of
+  // these trivial copies refer to the original conjured value.
+  // There were Unknown before:
+  clang_analyzer_dump_val(Empty);  // expected-warning {{lazyCompoundVal}}
+  clang_analyzer_dump_val(Empty2); // expected-warning {{lazyCompoundVal}}
+  clang_analyzer_dump_val(Empty3); // expected-warning {{lazyCompoundVal}}
 
   // We only have binding for the original Empty object, because copying empty
   // objects is a no-op in the performTrivialCopy. This is fine, because empty
@@ -67,16 +71

[clang] [HLSL][NFC] Refactor structured buffer methods tests (PR #161908)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` 
running on `suse-gary-m68k-cross` while building `clang` at step 5 "ninja check 
1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: 
CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl' FAILED 

Exit Code: 1

Command Output (stderr):
--
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/clang
 -cc1 -internal-isystem 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/lib/clang/22/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
 | llvm-cxxfilt | 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck
 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
 --check-prefixes=CHECK,DXIL # RUN: at line 1
+ 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/clang
 -cc1 -internal-isystem 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/lib/clang/22/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.3-library 
-finclude-default-header -emit-llvm -disable-llvm-passes -o - 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
+ 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck
 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
 --check-prefixes=CHECK,DXIL
+ llvm-cxxfilt
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl:29:15:
 error: DXIL-NEXT: expected string not found in input
// DXIL-NEXT: %[[COUNTER:.*]] = call i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %[[HANDLE]], i8 1)
  ^
:336:62: note: scanning from here
 %0 = load target("dx.RawBuffer", float, 1, 0), ptr %__handle, align 4
 ^
:336:62: note: with "HANDLE" equal to "0"
 %0 = load target("dx.RawBuffer", float, 1, 0), ptr %__handle, align 4
 ^
:338:2: note: possible intended match here
 %2 = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %0, i32 %1)
 ^

Input file: 
Check file: 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl

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

Input was:
<<
   .
   .
   .
 331:  %Index.addr = alloca i32, align 4 
 332:  store ptr %this, ptr %this.addr, align 4 
 333:  store i32 %Index, ptr %Index.addr, align 4 
 334:  %this1 = load ptr, ptr %this.addr, align 4 
 335:  %__handle = getelementptr inbounds nuw 
%"class.hlsl::RWStructuredBuffer", ptr %this1, i32 0, i32 0 
 336:  %0 = load target("dx.RawBuffer", float, 1, 0), ptr %__handle, 
align 4 
next:29'0  
X~ error: no match found
next:29'1   
  with "HANDLE" equal to "0"
 337:  %1 = load i32, ptr %Index.addr, align 4 
next:29'0 ~
 338:  %2 = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %0, i32 %1) 
next:29'0 
~~
next:29'2  ?
 possible intended match
 339:  %3 = load float, ptr %2, align 4 
next:29'0 ~~
 340:  ret float %3 
next:29'0 ~~
 341: } 
...

```



https://github.com/llvm/llvm-project/pull/161908
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][PAC] Add ptrauth.h helpers for computing type discriminators (PR #163456)

2025-10-14 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt edited 
https://github.com/llvm/llvm-project/pull/163456
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][NFC] Refactor structured buffer methods tests (PR #161908)

2025-10-14 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/29046


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: 
CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl' FAILED 

Exit Code: 1

Command Output (stderr):
--
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -triple dxil-pc-shadermodel6.3-library -finclude-default-header 
-emit-llvm -disable-llvm-passes -o - 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
 | llvm-cxxfilt | 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
 --check-prefixes=CHECK,DXIL # RUN: at line 1
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -triple dxil-pc-shadermodel6.3-library -finclude-default-header 
-emit-llvm -disable-llvm-passes -o - 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
+ llvm-cxxfilt
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl
 --check-prefixes=CHECK,DXIL
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl:29:15:
 error: DXIL-NEXT: expected string not found in input
// DXIL-NEXT: %[[COUNTER:.*]] = call i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %[[HANDLE]], i8 1)
  ^
:336:62: note: scanning from here
 %0 = load target("dx.RawBuffer", float, 1, 0), ptr %__handle, align 4
 ^
:336:62: note: with "HANDLE" equal to "0"
 %0 = load target("dx.RawBuffer", float, 1, 0), ptr %__handle, align 4
 ^
:338:2: note: possible intended match here
 %2 = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %0, i32 %1)
 ^

Input file: 
Check file: 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-lib.hlsl

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

Input was:
<<
   .
   .
   .
 331:  %Index.addr = alloca i32, align 4 
 332:  store ptr %this, ptr %this.addr, align 4 
 333:  store i32 %Index, ptr %Index.addr, align 4 
 334:  %this1 = load ptr, ptr %this.addr, align 4 
 335:  %__handle = getelementptr inbounds nuw 
%"class.hlsl::RWStructuredBuffer", ptr %this1, i32 0, i32 0 
 336:  %0 = load target("dx.RawBuffer", float, 1, 0), ptr %__handle, 
align 4 
next:29'0  
X~ error: no match found
next:29'1   
  with "HANDLE" equal to "0"
 337:  %1 = load i32, ptr %Index.addr, align 4 
next:29'0 ~
 338:  %2 = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0) %0, i32 %1) 
next:29'0 
~~
next:29'2  ?
 possible intended match
 339:  %3 = load float, ptr %2, align 4 
next:29'0 ~~
 340:  ret float %3 
next:29'0 ~~
 341: } 
...

```



https://github.com/llvm/llvm-project/pull/161908
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream pointer subtraction handling (PR #163306)

2025-10-14 Thread Andy Kaylor via cfe-commits


@@ -1734,9 +1734,9 @@ mlir::Value ScalarExprEmitter::emitSub(const BinOpInfo 
&ops) {
   // LLVM we shall take VLA's, division by element size, etc.
   //
   // See more in `EmitSub` in CGExprScalar.cpp.
-  assert(!cir::MissingFeatures::ptrDiffOp());
-  cgf.cgm.errorNYI("ptrdiff");
-  return {};
+  assert(!cir::MissingFeatures::llvmLoweringPtrDiffConsidersPointee());
+  return builder.create(cgf.getLoc(ops.loc), cgf.PtrDiffTy,
+ops.lhs, ops.rhs);

andykaylor wrote:

```suggestion
  return cir::PtrDiffOp::create(builder, cgf.getLoc(ops.loc), cgf.PtrDiffTy,
ops.lhs, ops.rhs);
```
This is a change to the preferred operation creation idiom that hasn't yet been 
implemented in all the incubator code.

https://github.com/llvm/llvm-project/pull/163306
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector extraction intrinsics to be used in constexpr #157712 (PR #162836)

2025-10-14 Thread via cfe-commits


@@ -2858,6 +2858,92 @@ static bool interp__builtin_elementwise_triop(
   return true;
 }
 
+static bool interp__builtin_x86_extract_vector(InterpState &S, CodePtr OpPC,
+ const CallExpr *Call,
+ unsigned ID) {
+  assert(Call->getNumArgs() == 2);
+
+  APSInt ImmAPS = popToAPSInt(S, Call->getArg(1));
+  uint64_t Index = ImmAPS.getZExtValue();
+
+  const Pointer &Src = S.Stk.pop();
+  if (!Src.getFieldDesc()->isPrimitiveArray())
+return false;
+
+  const Pointer &Dst = S.Stk.peek();
+  if (!Dst.getFieldDesc()->isPrimitiveArray())
+return false;
+
+  unsigned SrcElems = Src.getNumElems();
+  unsigned DstElems = Dst.getNumElems();
+
+  if (SrcElems == 0 || DstElems == 0 || (SrcElems % DstElems) != 0)
+return false;

SeongjaeP wrote:

You’re right, the vector lengths are fixed by definition, so this check isn’t 
needed. Thanks for catching that!

https://github.com/llvm/llvm-project/pull/162836
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][NFC] Refactor structured buffer methods tests (PR #161908)

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

hekota wrote:

> Hi, this PR breaks many bots. Could you please fix it or revert if it needs 
> more investigation? Thanks!

Thanks! I'll revert it.


https://github.com/llvm/llvm-project/pull/161908
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][SPIR-V] Add `-fspv-enable-maximal-reconvergence` flag to clang dxc. (PR #163474)

2025-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Lucie Choi (luciechoi)


Changes

Implement the frontend change to support maximal reconvergence feature.

The next work is to generate the corresponding SPIR-V instructions 
(`OpExtension` and `OpExecutionMode`) based on the llvm ir added in this CL 
`"enable-maximal-reconvergence"="true"`.


Addresses https://github.com/llvm/llvm-project/issues/136930

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


5 Files Affected:

- (modified) clang/include/clang/Basic/LangOptions.def (+1) 
- (modified) clang/include/clang/Driver/Options.td (+9) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+4) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-1) 
- (added) clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl (+17) 


``diff
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 9e850089ad87f..d32fecdb96f32 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -243,6 +243,7 @@ ENUM_LANGOPT(HLSLVersion, HLSLLangStd, 16, HLSL_Unset, 
NotCompatible, "HLSL Vers
 LANGOPT(HLSLStrictAvailability, 1, 0, NotCompatible,
 "Strict availability diagnostic mode for HLSL built-in functions.")
 LANGOPT(HLSLSpvUseUnknownImageFormat, 1, 0, NotCompatible, "For storage images 
and texel buffers, sets the default format to 'Unknown' when not specified via 
the `vk::image_format` attribute. If this option is not used, the format is 
inferred from the resource's data type.")
+LANGOPT(HLSLSpvEnableMaximalReconvergence, 1, 0, NotCompatible, "Enables 
maximal reconvergence for SPIR-V codegen. This ensures that all control flow 
merges at the nearest possible merge point as defined by the Vulkan spec.")
 
 LANGOPT(CUDAIsDevice  , 1, 0, NotCompatible, "compiling for CUDA device")
 LANGOPT(CUDAHostDeviceConstexpr, 1, 1, NotCompatible, "treating unattributed 
constexpr functions as __host__ __device__")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 60c4ad408ee43..a6f7c6e12 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -9573,6 +9573,15 @@ def fhlsl_spv_use_unknown_image_format
"from the resource's data type.">,
   MarshallingInfoFlag>;
 
+def fhlsl_spv_enable_maximal_reconvergence
+: Flag<["-"], "fspv-enable-maximal-reconvergence">,
+  Group,
+  Visibility<[CC1Option, DXCOption]>,
+  HelpText<"Enables maximal reconvergence for SPIR-V codegen. This ensures 
"
+   "that all control flow merges at the nearest possible merge 
point "
+   "as defined by the Vulkan spec.">,
+  MarshallingInfoFlag>;
+
 def no_wasm_opt : Flag<["--"], "no-wasm-opt">,
   Group,
   HelpText<"Disable the wasm-opt optimizer">,
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index ede1780592bf5..37c35a4768098 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -509,6 +509,10 @@ void clang::CodeGen::CGHLSLRuntime::setHLSLEntryAttributes(
   if (CGM.getCodeGenOpts().OptimizationLevel == 0)
 Fn->addFnAttr(llvm::Attribute::OptimizeNone);
   Fn->addFnAttr(llvm::Attribute::NoInline);
+
+  if (CGM.getLangOpts().HLSLSpvEnableMaximalReconvergence) {
+Fn->addFnAttr("enable-maximal-reconvergence", "true");
+  }
 }
 
 static Value *buildVectorInput(IRBuilder<> &B, Function *F, llvm::Type *Ty) {
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 107b9ffd439a3..1e794250d9d22 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3755,7 +3755,8 @@ static void RenderHLSLOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
   options::OPT_hlsl_entrypoint,
   options::OPT_fdx_rootsignature_define,
   options::OPT_fdx_rootsignature_version,
-  options::OPT_fhlsl_spv_use_unknown_image_format};
+  options::OPT_fhlsl_spv_use_unknown_image_format,
+  options::OPT_fhlsl_spv_enable_maximal_reconvergence};
   if (!types::isHLSL(InputType))
 return;
   for (const auto &Arg : ForwardedArguments)
diff --git a/clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl 
b/clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl
new file mode 100644
index 0..870fbabaac1bf
--- /dev/null
+++ b/clang/test/CodeGenHLSL/vk-features/maximal_reconvergence.hlsl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple spirv1.6-unknown-vulkan1.3-compute 
-fspv-enable-maximal-reconvergence -emit-llvm -o - -O0 %s | FileCheck %s 
--check-prefixes=CHECK
+// RUN: %clang_cc1 -triple spirv1.6-unknown-vulkan1.3-compute -hlsl-entry test 
-fspv-enable-maximal-reconvergence -emit-llvm -o - -O0 %s | FileCheck %s 
--check-prefixes=CHECK-ENTRY
+
+[numthreads(1,1,1)]
+void main() {
+// CHECK: define void @main() [[attributeNum

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow SSE41 phminposuw intrinsic to be used in constexp (PR #163041)

2025-10-14 Thread Shawn K via cfe-commits


@@ -2899,6 +2899,45 @@ static bool 
interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_ia32_phminposuw(InterpState &S, CodePtr OpPC,
+const CallExpr *Call) {
+  assert(Call->getNumArgs() == 1);
+
+  const Pointer &Source = S.Stk.pop();
+  const Pointer &Dest = S.Stk.peek();
+
+  unsigned SourceLen = Source.getNumElems();
+  QualType ElemQT = getElemType(Source);
+  OptPrimType ElemT = S.getContext().classify(ElemQT);
+  unsigned LaneBitWidth = S.getASTContext().getTypeSize(ElemQT);

kimsh02 wrote:

Okay, I misunderstood "lane" then 

https://github.com/llvm/llvm-project/pull/163041
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [ADT] Mark StringSwitch Cases with 6+ arguments as deprecated. NFC. (PR #163405)

2025-10-14 Thread Sam Elliott via cfe-commits

lenary wrote:

That seems reasonable, can you document the reasoning in the commit message 
please?

https://github.com/llvm/llvm-project/pull/163405
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [ADT] Mark StringSwitch Cases with 6+ arguments as deprecated. NFC. (PR #163405)

2025-10-14 Thread Jakub Kuderski via cfe-commits

kuhar wrote:

> That seems reasonable, can you document the reasoning in the commit message 
> please?

done

https://github.com/llvm/llvm-project/pull/163405
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Mac release fix (PR #163026)

2025-10-14 Thread Tom Stellard via cfe-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/163026

>From b2f00eb013f5174b1ab5199bb7cc4cab6d5ed059 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 11 Oct 2025 17:39:12 -0700
Subject: [PATCH 1/6] [Darwin][Driver] Prefer linking with toolchain's libc++
 instead of system

Fixes #77653
---
 clang/lib/Driver/ToolChains/Darwin.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index d2356ebdfa86c..7e2d62a6bfc94 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -667,6 +667,10 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   Args.addAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, 
options::OPT_t,
 options::OPT_Z_Flag, options::OPT_u_Group});
 
+  // Add local file paths to ensure the toolchain's libc++ is used instead of
+  // the system's.
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+
   // Forward -ObjC when either -ObjC or -ObjC++ is used, to force loading
   // members of static archive libraries which implement Objective-C classes or
   // categories.

>From 91ccb95e699b47ceb93c873454685fe180a2f975 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 11 Oct 2025 17:40:31 -0700
Subject: [PATCH 2/6] XXX: testrelease builds which also hit this bug

---
 .github/workflows/release-binaries.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/release-binaries.yml 
b/.github/workflows/release-binaries.yml
index 83969b5490685..955a31aff9c14 100644
--- a/.github/workflows/release-binaries.yml
+++ b/.github/workflows/release-binaries.yml
@@ -1,5 +1,5 @@
 name: Release Binaries
-
+# TEST
 on:
   workflow_dispatch:
 inputs:

>From a0bb37c324b6dcaff28aff35bf39e2ebbf879bb7 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 11 Oct 2025 21:17:27 -0700
Subject: [PATCH 3/6] Fix build failure

---
 clang/lib/Driver/ToolChains/Darwin.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 7e2d62a6bfc94..2c869d260211d 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -669,7 +669,7 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   // Add local file paths to ensure the toolchain's libc++ is used instead of
   // the system's.
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
   // Forward -ObjC when either -ObjC or -ObjC++ is used, to force loading
   // members of static archive libraries which implement Objective-C classes or

>From 19b27bb6a76188b58f4b1c8420bd04c7040a06e6 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 13 Oct 2025 16:57:08 -0700
Subject: [PATCH 4/6] XX: debug

---
 .github/workflows/release-binaries-all.yml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/.github/workflows/release-binaries-all.yml 
b/.github/workflows/release-binaries-all.yml
index 0b52a08202f1a..7e408497d1819 100644
--- a/.github/workflows/release-binaries-all.yml
+++ b/.github/workflows/release-binaries-all.yml
@@ -88,9 +88,6 @@ jobs:
 # We use ubuntu-22.04 rather than the latest version to make the built
 # binaries more portable (eg functional aginast older glibc).
 runs-on:
-  - ubuntu-22.04
-  - ubuntu-22.04-arm
-  - macos-13
   - macos-14
 
 uses: ./.github/workflows/release-binaries.yml

>From ff8bd1fe008a0d05dd61147fcb7a5bed2335ba30 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Mon, 13 Oct 2025 17:01:57 -0700
Subject: [PATCH 5/6] Debug

---
 .github/workflows/release-binaries.yml | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/release-binaries.yml 
b/.github/workflows/release-binaries.yml
index 955a31aff9c14..9884027af5dc7 100644
--- a/.github/workflows/release-binaries.yml
+++ b/.github/workflows/release-binaries.yml
@@ -239,7 +239,15 @@ jobs:
 ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build 
stage2-package
 release_dir=`find ${{ steps.setup-stage.outputs.build-prefix }}/build 
-iname 'stage2-bins'`
 mv $release_dir/${{ needs.prepare.outputs.release-binary-filename }} .
-
+
+- name: Debug
+  shell: bash
+  if: always()
+  run: |
+echo "int main(int argc, char** argv) { return 0; }" >> test.cpp
+${{ steps.setup-stage.outputs.build-prefix }}/build/bin/clang++ -### 
-fuse-ld=lld -stdlib=libc++ -Wl,--verbose test.cpp
+ls -ltr  ${{ steps.setup-stage.outputs.build-prefix }}/build/lib/*
+
 - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 
v4.6.2
   with:
 name: ${{ runner.os }}-${{ runner.arch }}-release-binary

>From 6d91fcd5583670d5045985976903854fdd68bb88 Mon Sep 1

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - Allow AVX512 conflict intrinsics to be used in constexpr (PR #163293)

2025-10-14 Thread NagaChaitanya Vellanki via cfe-commits

https://github.com/chaitanyav ready_for_review 
https://github.com/llvm/llvm-project/pull/163293
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [Clang] Add support for the C `defer` TS (PR #162848)

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

AaronBallman wrote:

We talked about this PR a bit in my office hours yesterday and one thing which 
came up for feedback to WG14 is that this should be spelled `_Defer` and not 
`defer` if the committee is serious about the feature (which I believe they 
are). It's going into a TS, and so users have to opt-in for `defer` to become a 
keyword which may break their code. That's fine and we can live with it. But 
when `defer` is rolled into the IS, that makes for a harder migration path. But 
more importantly, we like this feature -- we want to expose it as a conforming 
extension in other language modes; that's not possible with the keyword spelled 
`defer` because that'd be a non-conforming extension. And from looking at 
available open source code, the identifier `defer` is used quite frequently.

https://github.com/llvm/llvm-project/pull/162848
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][doc] Simplify Sampling-PGO use example (PR #162588)

2025-10-14 Thread Haohai Wen via cfe-commits

https://github.com/HaohaiWen edited 
https://github.com/llvm/llvm-project/pull/162588
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][NFC] Add test coverage for `Buffer` (PR #161909)

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

https://github.com/hekota closed 
https://github.com/llvm/llvm-project/pull/161909
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [WIP][SPARC] Properly handle CC for long double on sparc32 (PR #162226)

2025-10-14 Thread via cfe-commits

https://github.com/koachan updated 
https://github.com/llvm/llvm-project/pull/162226

>From 99cd21841c3b325d3335af5b4110414a49ad9bb3 Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Tue, 7 Oct 2025 12:55:39 +0700
Subject: [PATCH 1/4] [WIP][SPARC] Properly handle CC for long double on
 sparc32

Pass and return `long double`s indirectly, as specified in the psABI.
This continues the patch at https://reviews.llvm.org/D89130.

This should fix the issue at https://github.com/llvm/llvm-project/issues/41838.
---
 clang/lib/Basic/Targets/Sparc.h |  7 +
 clang/lib/CodeGen/Targets/Sparc.cpp | 30 ++---
 compiler-rt/lib/builtins/CMakeLists.txt |  4 +--
 compiler-rt/test/builtins/CMakeLists.txt|  2 +-
 llvm/lib/Target/Sparc/SparcCallingConv.td   |  4 +--
 llvm/lib/Target/Sparc/SparcISelLowering.cpp | 19 ++---
 6 files changed, 48 insertions(+), 18 deletions(-)

diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 3215e648ba6c3..acc27194c38ea 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -166,6 +166,13 @@ class LLVM_LIBRARY_VISIBILITY SparcV8TargetInfo : public 
SparcTargetInfo {
   PtrDiffType = SignedLong;
   break;
 }
+
+// The SPARCv8 System V ABI has long double 128-bits in size, but 64-bit
+// aligned.
+LongDoubleWidth = 128;
+LongDoubleAlign = 64;
+LongDoubleFormat = &llvm::APFloat::IEEEquad();
+
 // Up to 32 bits (V8) or 64 bits (V9) are lock-free atomic, but we're
 // willing to do atomic ops on up to 64 bits.
 MaxAtomicPromoteWidth = 64;
diff --git a/clang/lib/CodeGen/Targets/Sparc.cpp 
b/clang/lib/CodeGen/Targets/Sparc.cpp
index 38dbebdec2429..4259c8bbfdcae 100644
--- a/clang/lib/CodeGen/Targets/Sparc.cpp
+++ b/clang/lib/CodeGen/Targets/Sparc.cpp
@@ -26,6 +26,7 @@ class SparcV8ABIInfo : public DefaultABIInfo {
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType Ty) const;
   void computeInfo(CGFunctionInfo &FI) const override;
 };
 } // end anonymous namespace
@@ -33,12 +34,33 @@ class SparcV8ABIInfo : public DefaultABIInfo {
 
 ABIArgInfo
 SparcV8ABIInfo::classifyReturnType(QualType Ty) const {
+  if (Ty->isRealFloatingType() && getContext().getTypeSize(Ty) == 128)
+return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
+
   if (Ty->isAnyComplexType()) {
-return ABIArgInfo::getDirect();
-  }
-  else {
-return DefaultABIInfo::classifyReturnType(Ty);
+auto AI = ABIArgInfo::getDirect();
+AI.setInReg(true);
+return AI;
   }
+
+  return DefaultABIInfo::classifyReturnType(Ty);
+}
+
+ABIArgInfo SparcV8ABIInfo::classifyArgumentType(QualType Ty) const {
+  const BuiltinType *BT = Ty->getAs();
+  bool IsF128 = false;
+
+  if (Ty->isRealFloatingType() && getContext().getTypeSize(Ty) == 128)
+IsF128 = true;
+
+  // FIXME not sure if redundant
+  if (BT && BT->getKind() == BuiltinType::LongDouble)
+IsF128 = true;
+
+  if (IsF128)
+return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace());
+
+  return DefaultABIInfo::classifyArgumentType(Ty);
 }
 
 void SparcV8ABIInfo::computeInfo(CGFunctionInfo &FI) const {
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index 6c226aa7d2d48..790bf5758f4a2 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -960,9 +960,9 @@ else ()
 list(APPEND BUILTIN_CFLAGS_${arch} -fomit-frame-pointer 
-DCOMPILER_RT_ARMHF_TARGET)
   endif()
 
-  # For RISCV32, we must force enable int128 for compiling long
+  # For RISCV32 and 32-bit SPARC, we must force enable int128 for 
compiling long
   # double routines.
-  if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32")
+  if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" MATCHES 
"riscv32|sparc$" AND NOT CMAKE_COMPILER_IS_GNUCC)
 list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
   endif()
 
diff --git a/compiler-rt/test/builtins/CMakeLists.txt 
b/compiler-rt/test/builtins/CMakeLists.txt
index 63f4c94605c90..5643bfc51ea81 100644
--- a/compiler-rt/test/builtins/CMakeLists.txt
+++ b/compiler-rt/test/builtins/CMakeLists.txt
@@ -44,7 +44,7 @@ foreach(arch ${BUILTIN_TEST_ARCH})
 string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS 
"${BUILTINS_TEST_TARGET_CFLAGS}")
   endif()
 
-  if (COMPILER_RT_ENABLE_SOFTWARE_INT128 OR ${arch} STREQUAL "riscv32")
+  if (COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" MATCHES "riscv32|sparc$" 
AND NOT CMAKE_COMPILER_IS_GNUCC)
 list(APPEND BUILTINS_TEST_TARGET_CFLAGS -fforce-enable-int128)
 string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS 
"${BUILTINS_TEST_TARGET_CFLAGS}")
   endif()
diff --git a/llvm/lib/Target/Sparc/SparcCallingConv.td 
b/llvm/lib/Target/Sparc/SparcCallingConv.td
index 8afd0a7fc09ad..55be696c14a78 100644
--- a/llvm/lib/Target/Sparc/Sparc

[clang] [ByteCode] Remove a redundant call to std::unique_ptr::get (NFC) (PR #163512)

2025-10-14 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/163512

None

>From 57c5789859c278d78e18ba38d2a9425f74c270aa Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 12 Oct 2025 17:17:10 -0700
Subject: [PATCH] [ByteCode] Remove a redundant call to std::unique_ptr::get
 (NFC)

---
 clang/lib/AST/ByteCode/InterpState.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpState.h 
b/clang/lib/AST/ByteCode/InterpState.h
index a13244bf383ae..e2e4d5c985f93 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -114,7 +114,7 @@ class InterpState final : public State, public SourceMapper 
{
   Alloc = std::make_unique();
 }
 
-return *Alloc.get();
+return *Alloc;
   }
 
   /// Diagnose any dynamic allocations that haven't been freed yet.

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][docs] Fix typos in option names (PR #163482)

2025-10-14 Thread Jim Lin via cfe-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/163482
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream pointer subtraction handling (PR #163306)

2025-10-14 Thread Andy Kaylor via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir 
-emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+
+typedef unsigned long size_type;
+
+size_type size(unsigned long *_start, unsigned long *_finish) {
+  // CIR-LABEL: cir.func dso_local @_Z4sizePmS_
+  // CIR: %[[D:.*]] = cir.ptr_diff {{.*}} : !cir.ptr -> !s64i
+  // CIR: %[[U:.*]] = cir.cast integral %[[D]] : !s64i -> !u64i
+  // CIR: cir.return {{.*}} : !u64i
+
+  return static_cast(_finish - _start);
+}

andykaylor wrote:

Please add LLVM and OGCG checks.

https://github.com/llvm/llvm-project/pull/163306
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CIR] Upstream pointer subtraction handling (PR #163306)

2025-10-14 Thread Andy Kaylor via cfe-commits


@@ -1499,6 +1499,48 @@ mlir::LogicalResult 
CIRToLLVMConstantOpLowering::matchAndRewrite(
   return mlir::success();
 }
 
+static uint64_t getTypeSize(mlir::Type type, mlir::Operation &op) {
+  mlir::DataLayout layout(op.getParentOfType());
+  // For LLVM purposes we treat void as u8.
+  if (isa(type))
+type = cir::IntType::get(type.getContext(), 8, /*isSigned=*/false);
+  return llvm::divideCeil(layout.getTypeSizeInBits(type), 8);
+}
+
+mlir::LogicalResult CIRToLLVMPtrDiffOpLowering::matchAndRewrite(
+cir::PtrDiffOp op, OpAdaptor adaptor,
+mlir::ConversionPatternRewriter &rewriter) const {
+  auto dstTy = mlir::cast(op.getType());
+  auto llvmDstTy = getTypeConverter()->convertType(dstTy);
+
+  auto lhs = rewriter.create(op.getLoc(), llvmDstTy,

andykaylor wrote:

This use of `auto` and those on the next two lines are fine because the type is 
the template argument.

https://github.com/llvm/llvm-project/pull/163306
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add __builtin_bswapg (PR #162433)

2025-10-14 Thread via cfe-commits

https://github.com/clingfei updated 
https://github.com/llvm/llvm-project/pull/162433

>From 92466f3789ce1849ebee8a405efd42e191c591f5 Mon Sep 17 00:00:00 2001
From: clingfei <[email protected]>
Date: Wed, 8 Oct 2025 15:05:44 +0800
Subject: [PATCH 1/7] [Clang] Add __builtin_bswapg

---
 clang/include/clang/Basic/Builtins.td |  6 
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 10 ++-
 clang/lib/AST/ExprConstant.cpp| 11 
 clang/lib/CodeGen/CGBuiltin.cpp   |  1 +
 clang/lib/Sema/SemaChecking.cpp   | 28 +++
 clang/test/AST/ByteCode/builtin-functions.cpp |  4 +++
 clang/test/CodeGen/builtins.c |  2 +-
 clang/test/Sema/constant-builtins-2.c |  4 +++
 clang/test/Sema/constant-builtins.c   |  5 +++-
 9 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 468121f7d20ab..e65ed2f20be97 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -755,6 +755,12 @@ def BSwap : Builtin, Template<["unsigned short", 
"uint32_t", "uint64_t"],
   let Prototype = "T(T)";
 }
 
+def BSwapg : Builtin {
+  let Spellings = ["__builtin_bswapg"];
+  let Attributes = [NoThrow, Const, Constexpr, CustomTypeChecking];
+  let Prototype = "int(...)";
+}
+
 def Bitreverse : BitInt8_16_32_64BuiltinsTemplate, Builtin {
   let Spellings = ["__builtin_bitreverse"];
   let Attributes = [NoThrow, Const, Constexpr];
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1eea813b8c556..b8d17fbce6d4e 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -3288,7 +3288,15 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
   case Builtin::BI__builtin_elementwise_ctzg:
 return interp__builtin_elementwise_countzeroes(S, OpPC, Frame, Call,
BuiltinID);
-
+  case Builtin::BI__builtin_bswapg: {
+const APSInt &Val = popToAPSInt(S, Call->getArg(0));
+  assert(Val.getActiveBits() <= 64);
+if (Val.getBitWidth() == 8)
+pushInteger(S, Val, Call->getType());
+else
+pushInteger(S, Val.byteSwap(), Call->getType());
+return true;
+  }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64:
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 618e1636e9e53..058905e7fd3c0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -13982,6 +13982,17 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 
 return Success(Val.reverseBits(), E);
   }
+  case Builtin::BI__builtin_bswapg: {
+APSInt Val;
+if (!EvaluateInteger(E->getArg(0), Val, Info))
+  return false;
+if (Val.getBitWidth() == 8) {
+bool ret =  Success(Val, E);
+return ret;
+}
+
+return Success(Val.byteSwap(), E);
+  }
 
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9ee810c9d5775..7733f4dc15f5d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3622,6 +3622,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   Builder.CreateArithmeticFence(ArgValue, ConvertType(ArgType)));
 return RValue::get(ArgValue);
   }
+  case Builtin::BI__builtin_bswapg:
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64:
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 063db05665af1..362b53676feaa 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2200,6 +2200,30 @@ static bool BuiltinCpu(Sema &S, const TargetInfo &TI, 
CallExpr *TheCall,
   return false;
 }
 
+/// Checks that __builtin_bswapg was called with a single argument, which is an
+/// unsigned integer, and overrides the return value type to the integer type.
+static bool BuiltinBswapg(Sema &S, CallExpr *TheCall) {
+  if (S.checkArgCount(TheCall, 1))
+return true;
+  ExprResult ArgRes = S.DefaultLvalueConversion(TheCall->getArg(0));
+  if (ArgRes.isInvalid())
+return true;
+
+  Expr *Arg = ArgRes.get();
+  TheCall->setArg(0, Arg);
+
+  QualType ArgTy = Arg->getType();
+
+  if (!ArgTy->isIntegerType()) {
+S.Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+<< 1 << /* scalar */ 1 << /* unsigned integer ty */ 1 << /* no fp */ 0
+<< ArgTy;
+return true;
+  }
+  TheCall->setType(ArgTy);
+  return false;
+}
+
 /// Checks that __builtin_popcountg was called with a single argument, which is
 /// an unsigned integer.
 static bool BuiltinPopcountg(Sema &S, CallExpr *TheCall) {
@@ -3448

[clang] [WebKit checkers] Add support for ns_returns_autoreleased (PR #161236)

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

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

LGTM!

https://github.com/llvm/llvm-project/pull/161236
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Emit debug info with original source location for tokens from macros … (PR #163190)

2025-10-14 Thread via cfe-commits

https://github.com/SergejSalnikov updated 
https://github.com/llvm/llvm-project/pull/163190

>From aabe21c59d9feca85cc08e22720452970b0700ab Mon Sep 17 00:00:00 2001
From: skill 
Date: Mon, 13 Oct 2025 14:12:09 +0200
Subject: [PATCH 1/9] Emit debug info with original source location for tokens
 from macros arguments.

---
 clang/lib/CodeGen/CGDebugInfo.cpp | 42 ++-
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 9fe9a13610296..4b1c299eb99d5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -110,6 +110,34 @@ static bool IsArtificial(VarDecl const *VD) {
   cast(VD->getDeclContext())->isImplicit());
 }
 
+/// If the given source location resides in a macro argument, this function
+/// recursively resolves through macro argument expansions to return a source
+/// location that points to where the argument was spelled in the macro
+/// invocation. This is necessary for generating correct debug information for
+/// code inside macro arguments, as we want to point to user-written code.
+static SourceLocation resolveSpellingLocation(SourceManager &SM,
+  SourceLocation Loc) {
+  SourceLocation ParentLoc = Loc;
+
+  while (SM.isMacroArgExpansion(ParentLoc)) {
+ParentLoc = SM.getImmediateMacroCallerLoc(ParentLoc);
+  }
+
+  if (ParentLoc.isMacroID()) {
+return ParentLoc;
+  }
+  return SM.getSpellingLoc(Loc);
+}
+
+/// Returns the presumed location for a given source location, resolving
+/// through macro arguments first. This ensures that file, line, and column
+/// information points to where a macro argument was spelled, rather than where
+/// it was expanded.
+static PresumedLoc getPresumedSpellingLoc(SourceManager &SM,
+  SourceLocation Loc) {
+  return SM.getPresumedLoc(resolveSpellingLocation(SM, Loc));
+}
+
 CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
@@ -318,7 +346,8 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
   if (Loc.isInvalid())
 return;
 
-  CurLoc = CGM.getContext().getSourceManager().getExpansionLoc(Loc);
+  SourceManager &SM = CGM.getContext().getSourceManager();
+  CurLoc = SM.getExpansionLoc(resolveSpellingLocation(SM, Loc));
 
   // If we've changed files in the middle of a lexical scope go ahead
   // and create a new lexical scope with file node if it's different
@@ -326,7 +355,6 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
   if (LexicalBlockStack.empty())
 return;
 
-  SourceManager &SM = CGM.getContext().getSourceManager();
   auto *Scope = cast(LexicalBlockStack.back());
   PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
   if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
@@ -545,7 +573,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation 
Loc) {
 FileName = TheCU->getFile()->getFilename();
 CSInfo = TheCU->getFile()->getChecksum();
   } else {
-PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+PresumedLoc PLoc = getPresumedSpellingLoc(SM, Loc);
 FileName = PLoc.getFilename();
 
 if (FileName.empty()) {
@@ -627,7 +655,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
   if (Loc.isInvalid())
 return 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
-  return SM.getPresumedLoc(Loc).getLine();
+  return getPresumedSpellingLoc(SM, Loc).getLine();
 }
 
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -639,7 +667,8 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, 
bool Force) {
   if (Loc.isInvalid() && CurLoc.isInvalid())
 return 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
-  PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
+  PresumedLoc PLoc = Loc.isValid() ? getPresumedSpellingLoc(SM, Loc)
+   : SM.getPresumedLoc(CurLoc);
   return PLoc.isValid() ? PLoc.getColumn() : 0;
 }
 
@@ -6183,7 +6212,8 @@ void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue 
*GV,
 void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
 const StringLiteral *S) {
   SourceLocation Loc = S->getStrTokenLoc(0);
-  PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
+  PresumedLoc PLoc =
+  getPresumedSpellingLoc(CGM.getContext().getSourceManager(), Loc);
   if (!PLoc.isValid())
 return;
 

>From cf8a150a49970895a6efae45e7b65a16360ddf2f Mon Sep 17 00:00:00 2001
From: skill 
Date: Tue, 14 Oct 2025 12:03:12 +0200
Subject: [PATCH 2/9] Add getRefinedSpellingLoc to SourceManager.

The method preserves source locations for macro arguments.
---
 clang/include/clang/Basic/SourceManager.h | 16 +
 clang/lib/Bas

[clang] [CIR] Upstream pointer subtraction handling (PR #163306)

2025-10-14 Thread Shawn K via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir 
-emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+
+typedef unsigned long size_type;
+
+size_type size(unsigned long *_start, unsigned long *_finish) {
+  // CIR-LABEL: cir.func dso_local @_Z4sizePmS_
+  // CIR: %[[D:.*]] = cir.ptr_diff {{.*}} : !cir.ptr -> !s64i
+  // CIR: %[[U:.*]] = cir.cast integral %[[D]] : !s64i -> !u64i
+  // CIR: cir.return {{.*}} : !u64i
+
+  return static_cast(_finish - _start);
+}

kimsh02 wrote:

Incubator file didn't have LLVM checks

https://github.com/llvm/llvm-project/pull/163306
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] disallow constexpr with auto and explicit type in C23 (PR #163469)

2025-10-14 Thread Oleksandr T. via cfe-commits

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

>From 3856379ddbb59c6dcd813765571a67f635034a3c Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Wed, 15 Oct 2025 01:42:15 +0300
Subject: [PATCH] [Clang] disallow constexpr with auto and explicit type in C23

---
 clang/docs/ReleaseNotes.rst  | 2 ++
 clang/lib/Sema/DeclSpec.cpp  | 2 +-
 clang/test/Parser/c2x-auto.c | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index edb872c1f388d..de745e54a0cbd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -269,6 +269,8 @@ Non-comprehensive list of changes in this release
   allocation functions with a token ID can be enabled via the
   ``-fsanitize=alloc-token`` flag.
 
+- Clang now rejects the invalid use of ``constexpr`` with ``auto`` and an 
explicit type. (#GH163090)
+
 New Compiler Flags
 --
 - New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting 
trap reasons into the debug info when compiling with trapping UBSan (e.g. 
``-fsanitize-trap=undefined``).
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 184d31ecd1e40..482cb1fe703fe 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -1369,7 +1369,7 @@ void DeclSpec::Finish(Sema &S, const PrintingPolicy 
&Policy) {
 
   if (S.getLangOpts().C23 &&
   getConstexprSpecifier() == ConstexprSpecKind::Constexpr &&
-  StorageClassSpec == SCS_extern) {
+  (StorageClassSpec == SCS_extern || StorageClassSpec == SCS_auto)) {
 S.Diag(ConstexprLoc, diag::err_invalid_decl_spec_combination)
 << DeclSpec::getSpecifierName(getStorageClassSpec())
 << SourceRange(getStorageClassSpecLoc());
diff --git a/clang/test/Parser/c2x-auto.c b/clang/test/Parser/c2x-auto.c
index b878a5b7c42d4..b33b267841132 100644
--- a/clang/test/Parser/c2x-auto.c
+++ b/clang/test/Parser/c2x-auto.c
@@ -62,6 +62,8 @@ auto basic_usage(auto auto) {   // c23-error {{'auto' not 
allowed in function pr
 
   int auto_cxx_decl = auto(0);  // expected-error {{expected expression}}
 
+  constexpr auto int x = 0; // c23-error {{cannot combine with previous 'auto' 
declaration specifier}} \
+   c17-error {{use of undeclared identifier 
'constexpr'}}
   return c;
 }
 

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL][NFC] Refactor structured buffer methods tests (PR #161908)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-amdgpu-runtime-2` running on `rocm-worker-hw-02` while building 
`clang` at step 7 "Add check check-clang".

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


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

```
Step 7 (Add check check-clang) failure: test (failure)
 TEST 'Clang :: 
CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl' FAILED 

Exit Code: 1

Command Output (stderr):
--
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/clang 
-cc1 -internal-isystem 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/lib/clang/22/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.3-pixel -finclude-default-header 
-emit-llvm -disable-llvm-passes -o - 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl
 | llvm-cxxfilt | 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/FileCheck 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl
 --check-prefixes=CHECK,DXIL # RUN: at line 1
+ llvm-cxxfilt
+ /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/clang 
-cc1 -internal-isystem 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/lib/clang/22/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.3-pixel -finclude-default-header 
-emit-llvm -disable-llvm-passes -o - 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl
+ 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/FileCheck 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl
 --check-prefixes=CHECK,DXIL
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl:26:15:
 error: DXIL-NEXT: expected string not found in input
// DXIL-NEXT: %[[VAL:.*]] = call i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1) %[[HANDLE]], i8 1)
  ^
:165:62: note: scanning from here
 %0 = load target("dx.RawBuffer", float, 1, 1), ptr %__handle, align 4
 ^
:165:62: note: with "HANDLE" equal to "0"
 %0 = load target("dx.RawBuffer", float, 1, 1), ptr %__handle, align 4
 ^
:167:2: note: possible intended match here
 %2 = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1) %0, i32 %1)
 ^

Input file: 
Check file: 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/CodeGenHLSL/resources/StructuredBuffers-methods-ps.hlsl

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

Input was:
<<
   .
   .
   .
 160:  %Index.addr = alloca i32, align 4 
 161:  store ptr %this, ptr %this.addr, align 4 
 162:  store i32 %Index, ptr %Index.addr, align 4 
 163:  %this1 = load ptr, ptr %this.addr, align 4 
 164:  %__handle = getelementptr inbounds nuw 
%"class.hlsl::RasterizerOrderedStructuredBuffer", ptr %this1, i32 0, i32 0 
 165:  %0 = load target("dx.RawBuffer", float, 1, 1), ptr %__handle, 
align 4 
next:26'0  
X~ error: no match found
next:26'1   
  with "HANDLE" equal to "0"
 166:  %1 = load i32, ptr %Index.addr, align 4 
next:26'0 ~
 167:  %2 = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1) %0, i32 %1) 
next:26'0 
~~
next:26'2  ?
 possible intended match
 168:  %3 = load float, ptr %2, align 4 
next:26'0 ~~
 169:  ret float %3 
next:26'0 ~~
 170: } 
...

```



https://github.com/llvm/llvm-project/pull/161908
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][LTO] Fix use of funified-lto and save-temps flags together (PR #162763)

2025-10-14 Thread Alexey Bader via cfe-commits


@@ -0,0 +1,11 @@
+; Test that we do not duplicate the UnifiedLTO module flag.
+;
+; RUN: %clang_cc1 -emit-llvm -flto=full -funified-lto -o - %s | FileCheck %s

bader wrote:

That's right.

https://github.com/llvm/llvm-project/pull/162763
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix a broken fix-it provided by `modernize-use-integer-sign-comparison` (PR #163488)

2025-10-14 Thread Victor Chernyakin via cfe-commits


@@ -152,6 +152,8 @@ void UseIntegerSignComparisonCheck::check(
   if (const auto *RHSCast = llvm::dyn_cast(RHS)) {
 SubExprRHS = RHSCast->getSubExpr();
 R2.setEnd(SubExprRHS->getBeginLoc().getLocWithOffset(-1));
+R3.setBegin(Lexer::getLocForEndOfToken(
+SubExprRHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));

localspook wrote:

Notice how (before this change) this branch and the one before it were 
asymmetric: the previous branch adjusted two ranges (`R1` and `R2`), while this 
one only adjusted one range (`R2`).

https://github.com/llvm/llvm-project/pull/163488
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix a broken fix-it provided by `modernize-use-integer-sign-comparison` (PR #163488)

2025-10-14 Thread Victor Chernyakin via cfe-commits

https://github.com/localspook edited 
https://github.com/llvm/llvm-project/pull/163488
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [X86] Add support for Wildcat Lake (PR #163214)

2025-10-14 Thread Phoebe Wang via cfe-commits

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

LGTM.

https://github.com/llvm/llvm-project/pull/163214
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix a broken fix-it provided by `modernize-use-integer-sign-comparison` (PR #163488)

2025-10-14 Thread Victor Chernyakin via cfe-commits

https://github.com/localspook updated 
https://github.com/llvm/llvm-project/pull/163488

>From e34928f07504a4b0abf09b37c9c523cc9c44a9e8 Mon Sep 17 00:00:00 2001
From: Victor Chernyakin 
Date: Tue, 14 Oct 2025 19:54:06 -0700
Subject: [PATCH 1/2] [clang-tidy] Fix a broken fix-it provided by
 `modernize-use-integer-sign-comparison`

---
 .../modernize/UseIntegerSignComparisonCheck.cpp   | 2 ++
 clang-tools-extra/docs/ReleaseNotes.rst   | 4 
 .../checkers/modernize/use-integer-sign-comparison-qt.cpp | 8 ++--
 .../checkers/modernize/use-integer-sign-comparison.cpp| 8 ++--
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index 0003429c62890..77262ebdcf772 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -152,6 +152,8 @@ void UseIntegerSignComparisonCheck::check(
   if (const auto *RHSCast = llvm::dyn_cast(RHS)) {
 SubExprRHS = RHSCast->getSubExpr();
 R2.setEnd(SubExprRHS->getBeginLoc().getLocWithOffset(-1));
+R3.setBegin(Lexer::getLocForEndOfToken(
+SubExprRHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
   }
   DiagnosticBuilder Diag =
   diag(BinaryOp->getBeginLoc(),
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 33cc401bcb78f..59be94ae36933 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -359,6 +359,10 @@ Changes in existing checks
   ` check to
   suggest using designated initializers for aliased aggregate types.
 
+- Improved :doc:`modernize-use-integer-sign-comparison
+  ` by providing
+  correct fix-its when the RHS of a comparison contains a non-C-style cast.
+
 - Improved :doc:`modernize-use-nullptr
   ` check by fixing a crash
   on Windows when the check was enabled with a 32-bit :program:`clang-tidy`
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison-qt.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison-qt.cpp
index 1f26ff34a4d04..31a3677c2bbd0 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison-qt.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison-qt.cpp
@@ -92,8 +92,7 @@ int AllComparisons() {
 if (static_cast(uArray[2]) < static_cast(sArray[2]))
 return 0;
 // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
-// CHECK-FIXES: if (q20::cmp_less(uArray[2],sArray[2])))
-// FIXME: There should only be 2 closing braces. The fix-it inserts an 
unbalanced one.
+// CHECK-FIXES: if (q20::cmp_less(uArray[2],sArray[2]))
 
 if ((unsigned int)uArray[3] < (int)sArray[3])
 return 0;
@@ -116,6 +115,11 @@ int AllComparisons() {
 // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
 // CHECK-FIXES: if (q20::cmp_greater(uArray[6] , VALUE))
 
+if (unsigned(uArray[7]) >= int(sArray[7]))
+return 0;
+// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
+// CHECK-FIXES: if (q20::cmp_greater_equal(uArray[7],sArray[7]))
+
 
 FuncParameters(uVar);
 TemplateFuncParameter(sVar);
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
index 628cee0bb0de7..e7981a6d41883 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
@@ -91,8 +91,7 @@ int AllComparisons() {
 if (static_cast(uArray[2]) < static_cast(sArray[2]))
 return 0;
 // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
-// CHECK-FIXES: if (std::cmp_less(uArray[2],sArray[2])))
-// FIXME: There should only be 2 closing braces. The fix-it inserts an 
unbalanced one.
+// CHECK-FIXES: if (std::cmp_less(uArray[2],sArray[2]))
 
 if ((unsigned int)uArray[3] < (int)sArray[3])
 return 0;
@@ -115,6 +114,11 @@ int AllComparisons() {
 // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
 // CHECK-FIXES: if (std::cmp_greater(uArray[6] , VALUE))
 
+if (unsigned(uArray[7]) >= int(sArray[7]))
+return 0;
+// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 
'unsigned' integers [mode

[clang] [clang] fix parsing of late parsed attributes with delayed template parsing (PR #163483)

2025-10-14 Thread Erich Keane via cfe-commits


@@ -1272,7 +1272,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator 
&D,
   // tokens and store them for late parsing at the end of the translation unit.
   if (getLangOpts().DelayedTemplateParsing && Tok.isNot(tok::equal) &&
   TemplateInfo.Kind == ParsedTemplateKind::Template &&
-  Actions.canDelayFunctionBody(D)) {
+  LateParsedAttrs->empty() && Actions.canDelayFunctionBody(D)) {

erichkeane wrote:

I'm not as up on late parsed attributes as I wish I was, I would like 
@AaronBallman to make sure we're not doing anything silly here.  

https://github.com/llvm/llvm-project/pull/163483
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] [ADT] Mark StringSwitch Cases with 6+ arguments as deprecated. NFC. (PR #163405)

2025-10-14 Thread Sam Elliott via cfe-commits

lenary wrote:

Can I ask why? And why 6+?

Have particular issues been seen with these?

https://github.com/llvm/llvm-project/pull/163405
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers][X86] Allow MMX/SSE/AVX MOVMSK intrinsics to be used in constexpr (PR #161914)

2025-10-14 Thread Shawn K via cfe-commits

https://github.com/kimsh02 updated 
https://github.com/llvm/llvm-project/pull/161914

>From ccc7f4ed8640f8bc4726dac5d91e044bd8cc533b Mon Sep 17 00:00:00 2001
From: kimsh02 
Date: Tue, 14 Oct 2025 11:07:32 -0700
Subject: [PATCH] Squash

---
 clang/include/clang/Basic/BuiltinsX86.td | 18 -
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 49 
 clang/lib/AST/ExprConstant.cpp   | 38 ++
 clang/lib/Headers/avx2intrin.h   |  5 +--
 clang/lib/Headers/avxintrin.h| 10 ++---
 clang/lib/Headers/emmintrin.h|  6 ++-
 clang/lib/Headers/xmmintrin.h|  4 +-
 clang/test/CodeGen/X86/avx-builtins.c|  4 ++
 clang/test/CodeGen/X86/avx2-builtins.c   |  3 ++
 clang/test/CodeGen/X86/mmx-builtins.c|  4 ++
 clang/test/CodeGen/X86/sse-builtins.c|  2 +
 clang/test/CodeGen/X86/sse2-builtins.c   |  5 +++
 12 files changed, 123 insertions(+), 25 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index 006a45347ff1a..39beab1fe0c15 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -185,7 +185,8 @@ let Features = "sse", Attributes = [NoThrow, Const, 
RequiredVectorWidth<128>] in
   def cvttss2si : X86Builtin<"int(_Vector<4, float>)">;
 }
 
-let Features = "sse", Attributes = [NoThrow, RequiredVectorWidth<128>] in {
+let Features = "sse",
+Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
   def movmskps : X86Builtin<"int(_Vector<4, float>)">;
 }
 
@@ -211,11 +212,6 @@ let Features = "sse2", Attributes = [NoThrow, 
RequiredVectorWidth<128>] in {
   def maskmovdqu : X86Builtin<"void(_Vector<16, char>, _Vector<16, char>, char 
*)">;
 }
 
-let Features = "sse2", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] 
in {
-  def movmskpd : X86Builtin<"int(_Vector<2, double>)">;
-  def pmovmskb128 : X86Builtin<"int(_Vector<16, char>)">;
-}
-
 let Features = "sse2", Attributes = [NoThrow] in {
   def movnti : X86Builtin<"void(int *, int)">;
 }
@@ -224,6 +220,8 @@ let Features = "sse2", Attributes = [NoThrow, Const, 
Constexpr, RequiredVectorWi
   def pshuflw : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Constant 
int)">;
   def pshufd : X86Builtin<"_Vector<4, int>(_Vector<4, int>, _Constant int)">;
   def pshufhw : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Constant 
int)">;
+  def movmskpd : X86Builtin<"int(_Vector<2, double>)">;
+  def pmovmskb128 : X86Builtin<"int(_Vector<16, char>)">;
 }
 
 let Features = "sse2", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] 
in {
@@ -562,11 +560,8 @@ let Features = "avx",
   def vtestnzcps256 : X86Builtin<"int(_Vector<8, float>, _Vector<8, float>)">;
   def ptestz256 : X86Builtin<"int(_Vector<4, long long int>, _Vector<4, long 
long int>)">;
   def ptestc256 : X86Builtin<"int(_Vector<4, long long int>, _Vector<4, long 
long int>)">;
-  def ptestnzc256 : X86Builtin<"int(_Vector<4, long long int>, _Vector<4, long 
long int>)">;
-}
-
-let Features = "avx",
-Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
+  def ptestnzc256
+  : X86Builtin<"int(_Vector<4, long long int>, _Vector<4, long long 
int>)">;
   def movmskpd256 : X86Builtin<"int(_Vector<4, double>)">;
   def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
 }
@@ -634,6 +629,7 @@ let Features = "avx2", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] i
 
 
 let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, 
RequiredVectorWidth<256>] in {
+  def pmovmskb256 : X86Builtin<"int(_Vector<32, char>)">;
   def pavgb256 : X86Builtin<"_Vector<32, unsigned char>(_Vector<32, unsigned 
char>, _Vector<32, unsigned char>)">;
   def pavgw256 : X86Builtin<"_Vector<16, unsigned short>(_Vector<16, unsigned 
short>, _Vector<16, unsigned short>)">;
 
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2d3cb6a68d7e2..ca655e6a3504f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2871,6 +2871,46 @@ static bool interp__builtin_ia32_test_op(
   return true;
 }
 
+static bool interp__builtin_ia32_movmsk_op(InterpState &S, CodePtr OpPC,
+   const CallExpr *Call) {
+  assert(Call->getNumArgs() == 1);
+
+  const Pointer &Source = S.Stk.pop();
+
+  unsigned SourceLen = Source.getNumElems();
+  QualType ElemQT = getElemType(Source);
+  OptPrimType ElemPT = S.getContext().classify(ElemQT);
+  unsigned ResultLen =
+  S.getASTContext().getTypeSize(Call->getType()); // Always 32-bit integer.
+  APInt Result(ResultLen, 0);
+
+  if (ElemQT->isIntegerType()) {
+unsigned BitsInAByte = 8;
+unsigned ElemBitWidth = S.getASTContext().getTypeSize(ElemQT);
+unsigned ResultIdx = 0;
+INT_TYPE_SWITCH_NO_BOOL(*ElemPT, {
+  for (unsigned I = 0; I != SourceLen; ++I) {
+APInt Elem = Source.elem(I).toAPSInt();
+   

[clang] [ObjC][Preprocessor] Handle @import directive as a pp-directive (PR #157726)

2025-10-14 Thread via cfe-commits


@@ -947,6 +940,10 @@ bool Scanner::lexPPLine(const char *&First, const char 
*const End) {
   auto ScEx2 = make_scope_exit(
   [&]() { TheLexer.setParsingPreprocessorDirective(false); });
 
+  // FIXME: Shoule we handle @import as a preprocessing directive?

yronglin wrote:

Good catch, we should remove this comments

https://github.com/llvm/llvm-project/pull/157726
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Accept empty enum in MSVC compatible C (PR #159981)

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


@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+
+typedef enum tag1 { } A; // expected-warning {{empty enumeration types are a 
Microsoft extension}}
+typedef enum tag2 { } B; // expected-warning {{empty enumeration types are a 
Microsoft extension}}
+typedef enum : unsigned { } C; // expected-warning {{enumeration types with a 
fixed underlying type are a Microsoft extension}}\

AaronBallman wrote:

I think emitting two diagnostics is fine (one for the underlying type and one 
for the empty enum) because they are separate extensions. But I think it's a 
bit odd that we claim the underlying type is a Microsoft extension rather than 
a C23 extension -- that seems to be a preexisting issue which could be handled 
in a separate PR: https://godbolt.org/z/sMhGoE3qq

https://github.com/llvm/llvm-project/pull/159981
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 255db37 - [clangd] Retrieve documentation for class member instance from index (#153337)

2025-10-14 Thread via cfe-commits

Author: Nathan Ridge
Date: 2025-10-06T13:30:02-04:00
New Revision: 255db37e778e0cb61417765f12a280605efc11b8

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

LOG: [clangd] Retrieve documentation for class member instance from index 
(#153337)

Fixes https://github.com/clangd/clangd/issues/2290

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/DeclTemplate.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index c6deed3ab1e7b..e4df7581f1315 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -43,6 +43,7 @@
 #include "support/Trace.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
@@ -1886,7 +1887,15 @@ class CodeCompleteFlow {
 for (auto &Cand : C.first) {
   if (Cand.SemaResult &&
   Cand.SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
-auto ID = clangd::getSymbolID(Cand.SemaResult->getDeclaration());
+const NamedDecl *DeclToLookup = Cand.SemaResult->getDeclaration();
+// For instantiations of members of class templates, the
+// documentation will be stored at the member's original
+// declaration.
+if (const NamedDecl *Adjusted =
+dyn_cast(&adjustDeclToTemplate(*DeclToLookup))) 
{
+  DeclToLookup = Adjusted;
+}
+auto ID = clangd::getSymbolID(DeclToLookup);
 if (!ID)
   continue;
 Req.IDs.insert(ID);

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 7640569128172..768f88f177e56 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1154,23 +1154,45 @@ TEST(CompletionTest, CommentsOnMembersFromHeader) {
   /// This is a member function.
   int delta();
 };
+
+template 
+struct beta {
+  /// This is a member field inside a template.
+  int omega;
+
+  /// This is a member function inside a template.
+  int epsilon();
+};
   )cpp";
 
   auto File = testPath("foo.cpp");
   Annotations Test(R"cpp(
 #include "foo.h"
 alpha a;
-int x = a.^
+beta b;
+int x = a.$p1^;
+int y = b.$p2^;
  )cpp");
   runAddDocument(Server, File, Test.code());
   auto CompletionList =
-  llvm::cantFail(runCodeComplete(Server, File, Test.point(), {}));
+  llvm::cantFail(runCodeComplete(Server, File, Test.point("p1"), {}));
 
   EXPECT_THAT(CompletionList.Completions,
   Contains(AllOf(named("gamma"), doc("This is a member field.";
   EXPECT_THAT(
   CompletionList.Completions,
   Contains(AllOf(named("delta"), doc("This is a member function.";
+
+  CompletionList =
+  llvm::cantFail(runCodeComplete(Server, File, Test.point("p2"), {}));
+
+  EXPECT_THAT(CompletionList.Completions,
+  Contains(AllOf(named("omega")
+ /* FIXME: Doc retrieval does not work yet*/)));
+  EXPECT_THAT(
+  CompletionList.Completions,
+  Contains(AllOf(named("epsilon"),
+ doc("This is a member function inside a template.";
 }
 
 TEST(CompletionTest, CommentsOnMembersFromHeaderOverloadBundling) {

diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index bba72365089f9..a3c67a60d0329 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -3399,6 +3399,11 @@ inline UnsignedOrNone getExpandedPackSize(const 
NamedDecl *Param) {
 /// for their AssociatedDecl.
 TemplateParameterList *getReplacedTemplateParameterList(const Decl *D);
 
+/// If we have a 'templated' declaration for a template, adjust 'D' to
+/// refer to the actual template.
+/// If we have an implicit instantiation, adjust 'D' to refer to template.
+const Decl &adjustDeclToTemplate(const Decl &D);
+
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_DECLTEMPLATE_H

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 056bfe36b2a0a..a074990cce7fe 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -330,76 +330,6 @@ void ASTContext::addComment(const RawComment &RC) {
   Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
 }
 
-/// If we have a 'templated' declaration