[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

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


@@ -1421,6 +1421,18 @@ def fhip_emit_relocatable : Flag<["-"], 
"fhip-emit-relocatable">,
   HelpText<"Compile HIP source to relocatable">;
 def fno_hip_emit_relocatable : Flag<["-"], "fno-hip-emit-relocatable">,
   HelpText<"Do not override toolchain to compile HIP source to relocatable">;
+def hip_use_experimental_spirv_backend

arsenm wrote:

Doesn't have anything to do with hip either, I'd expect the flag to work for 
any language 

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


[clang] [clang][analyzer] Save path- and syntax-analysis times per entry point (PR #162089)

2025-10-10 Thread Arseniy Zaostrovnykh via cfe-commits


@@ -33,7 +33,15 @@ struct Registry {
 
   struct Snapshot {
 const Decl *EntryPoint;
-std::vector BoolStatValues;
+// Boolean statistics are always set explicitly. If they are not set, their
+// value is absent resulting in empty CSV cells
+std::vector> BoolStatValues;

necto wrote:

Good point. I will break it down into a few PRs. here is the first one: #162817

https://github.com/llvm/llvm-project/pull/162089
___
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-10 Thread Simon Pilgrim via cfe-commits

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

>From 79006fe91ed7d53329a956a65fb753dad2c8c6e2 Mon Sep 17 00:00:00 2001
From: kimsh02 
Date: Fri, 3 Oct 2025 09:30:23 -0700
Subject: [PATCH 1/6] Stash

---
 clang/include/clang/Basic/BuiltinsX86.td | 16 ++---
 clang/lib/AST/ExprConstant.cpp   | 41 
 clang/lib/Headers/avx2intrin.h   |  2 +-
 clang/lib/Headers/avxintrin.h|  4 +--
 clang/lib/Headers/emmintrin.h|  4 +--
 clang/lib/Headers/xmmintrin.h|  4 +--
 clang/test/CodeGen/X86/mmx-builtins.c|  1 +
 7 files changed, 60 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index a0181b7ae8f9d..7c14a54ed4c68 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -181,7 +181,7 @@ 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, Constexpr, 
RequiredVectorWidth<128>] in {
   def movmskps : X86Builtin<"int(_Vector<4, float>)">;
 }
 
@@ -207,7 +207,7 @@ 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 {
+let Features = "sse2", Attributes = [NoThrow, Constexpr, 
RequiredVectorWidth<128>] in {
   def movmskpd : X86Builtin<"int(_Vector<2, double>)">;
   def pmovmskb128 : X86Builtin<"int(_Vector<16, char>)">;
 }
@@ -526,6 +526,11 @@ let Features = "avx", Attributes = [NoThrow, Const, 
RequiredVectorWidth<128>] in
   def vtestnzcps : X86Builtin<"int(_Vector<4, float>, _Vector<4, float>)">;
 }
 
+let Features = "avx", Attributes = [NoThrow, Constexpr, 
RequiredVectorWidth<256>] in {
+  def movmskpd256 : X86Builtin<"int(_Vector<4, double>)">;
+  def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
+}
+
 let Features = "avx", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] 
in {
   def vtestzpd256 : X86Builtin<"int(_Vector<4, double>, _Vector<4, double>)">;
   def vtestcpd256 : X86Builtin<"int(_Vector<4, double>, _Vector<4, double>)">;
@@ -536,8 +541,6 @@ let Features = "avx", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] in
   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>)">;
-  def movmskpd256 : X86Builtin<"int(_Vector<4, double>)">;
-  def movmskps256 : X86Builtin<"int(_Vector<8, float>)">;
 }
 
 let Features = "avx", Attributes = [NoThrow] in {
@@ -572,6 +575,10 @@ let Features = "avx", Attributes = [NoThrow, Const, 
Constexpr, RequiredVectorWid
   def vec_set_v8si : X86Builtin<"_Vector<8, int>(_Vector<8, int>, int, 
_Constant int)">;
 }
 
+let Features = "avx2", Attributes = [NoThrow, Constexpr, 
RequiredVectorWidth<256>] in {
+  def pmovmskb256 : X86Builtin<"int(_Vector<32, char>)">;
+}
+
 let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] 
in {
   def mpsadbw256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, 
_Vector<32, char>, _Constant char)">;
   def palignr256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, 
_Vector<32, char>, _Constant int)">;
@@ -583,7 +590,6 @@ let Features = "avx2", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] i
   def phsubsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Vector<16, short>)">;
   def pmaddubsw256 : X86Builtin<"_Vector<16, short>(_Vector<32, char>, 
_Vector<32, char>)">;
   def pmaddwd256 : X86Builtin<"_Vector<8, int>(_Vector<16, short>, _Vector<16, 
short>)">;
-  def pmovmskb256 : X86Builtin<"int(_Vector<32, char>)">;
   def pmulhrsw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, 
_Vector<16, short>)">;
   def psadbw256 : X86Builtin<"_Vector<4, long long int>(_Vector<32, char>, 
_Vector<32, char>)">;
   def pshufb256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, 
char>)">;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 7bf28d988f405..1c553e7780b1d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -13767,6 +13767,38 @@ static bool getBuiltinAlignArguments(const CallExpr 
*E, EvalInfo &Info,
 bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
 unsigned BuiltinOp) {
 
+  auto EvalMoveMaskOp = [&]() {
+APValue Source;
+if (!Evaluate(Source, Info, E->getArg(0))) return false;
+unsigned SourceLen = Source.getVectorLength();
+const VectorType *VT = E->getAr

[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

2025-10-10 Thread Manuel Carrasco via cfe-commits

https://github.com/mgcarrasco updated 
https://github.com/llvm/llvm-project/pull/162282

>From e89ce89521602f651495cf936e016d8f0c926974 Mon Sep 17 00:00:00 2001
From: Manuel Carrasco 
Date: Tue, 7 Oct 2025 06:05:21 -0700
Subject: [PATCH 1/2] [HIP][SPIRV] Enable the SPIRV backend instead of the
 translator through an experimental flag.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Juan Manuel Martinez Caamaño 
---
 clang/include/clang/Driver/Options.td| 14 
 clang/lib/Driver/ToolChains/HIPAMD.cpp   | 36 +++-
 clang/test/Driver/amdgpu-spirv-backend-opt.c | 12 +++
 3 files changed, 53 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/Driver/amdgpu-spirv-backend-opt.c

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ec38231f906eb..37dbb820ce22f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5483,6 +5483,20 @@ defm wavefrontsize64 : SimpleMFlag<"wavefrontsize64",
 defm amdgpu_precise_memory_op
 : SimpleMFlag<"amdgpu-precise-memory-op", "Enable", "Disable",
   " precise memory mode (AMDGPU only)">;
+def amdgpu_use_experimental_spirv_backend
+: Flag<["-"], "amdgpu-use-experimental-spirv-backend">,
+  Group,
+  Flags<[HelpHidden]>,
+  Visibility<[ClangOption]>,
+  HelpText<"Use experimental SPIRV backend for AMDGPU compilation (AMDGPU "
+   "only)">;
+def no_amdgpu_use_experimental_spirv_backend
+: Flag<["-"], "no-amdgpu-use-experimental-spirv-backend">,
+  Group,
+  Flags<[HelpHidden]>,
+  Visibility<[ClangOption]>,
+  HelpText<"Do not use experimental SPIRV backend for AMDGPU compilation "
+   "(AMDGPU only)">;
 
 def munsafe_fp_atomics : Flag<["-"], "munsafe-fp-atomics">,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, 
Alias;
diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp 
b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index c0c8afec07264..aeccf381c7a63 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -175,15 +175,33 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
 
   constructLlvmLinkCommand(C, JA, Inputs, LinkedBCFile, Args);
 
-  // Emit SPIR-V binary.
-  llvm::opt::ArgStringList TrArgs{
-  "--spirv-max-version=1.6",
-  "--spirv-ext=+all",
-  "--spirv-allow-unknown-intrinsics",
-  "--spirv-lower-const-expr",
-  "--spirv-preserve-auxdata",
-  "--spirv-debug-info-version=nonsemantic-shader-200"};
-  SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile, TrArgs);
+  bool UseSPIRVBackend = Args.hasFlag(
+  options::OPT_amdgpu_use_experimental_spirv_backend,
+  options::OPT_no_amdgpu_use_experimental_spirv_backend, 
/*Default=*/false);
+
+  // Emit SPIR-V binary either using the SPIRV backend or the translator.
+  if (UseSPIRVBackend) {
+llvm::opt::ArgStringList CmdArgs;
+const char *Triple =
+C.getArgs().MakeArgString("-triple=spirv64-amd-amdhsa");
+CmdArgs.append({"-cc1", Triple, "-emit-obj", LinkedBCFile.getFilename(),
+"-o", Output.getFilename()});
+const char *Exec = getToolChain().getDriver().getClangProgramPath();
+C.addCommand(std::make_unique(JA, *this,
+   ResponseFileSupport::None(), Exec,
+   CmdArgs, LinkedBCFile, Output));
+  } else {
+// Use the SPIRV translator for code gen.
+llvm::opt::ArgStringList TrArgs{
+"--spirv-max-version=1.6",
+"--spirv-ext=+all",
+"--spirv-allow-unknown-intrinsics",
+"--spirv-lower-const-expr",
+"--spirv-preserve-auxdata",
+"--spirv-debug-info-version=nonsemantic-shader-200"};
+SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile,
+ TrArgs);
+  }
 }
 
 // For amdgcn the inputs of the linker job are device bitcode and output is
diff --git a/clang/test/Driver/amdgpu-spirv-backend-opt.c 
b/clang/test/Driver/amdgpu-spirv-backend-opt.c
new file mode 100644
index 0..0435ad9dad6d1
--- /dev/null
+++ b/clang/test/Driver/amdgpu-spirv-backend-opt.c
@@ -0,0 +1,12 @@
+// COM: This test case validates the behavior of 
-amdgpu-use-experimental-spirv-backend
+
+// COM: Test that -amdgpu-use-experimental-spirv-backend calls clang -cc1 with 
the SPIRV triple.
+// RUN: %clang -x hip %s --cuda-device-only --offload-arch=amdgcnspirv 
-amdgpu-use-experimental-spirv-backend -nogpuinc -nogpulib -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SPIRV-BACKEND
+// CHECK-SPIRV-BACKEND: "{{.*}}clang{{.*}}" "-cc1" 
"{{.*-triple=spirv64-amd-amdhsa}}"
+
+// COM: Test that -no-amdgpu-use-experimental-spirv-backend calls the SPIRV 
translator
+// RUN: %clang -x hip %s --cuda-device-only --offload-arch=amdgcnspirv 
-no-amdgpu-use-experimental-spi

[clang] [clang] Support header shadowing diagnostics in Clang header search (PR #162491)

2025-10-10 Thread Jinjie Huang via cfe-commits

Jinjie-Huang wrote:

The current implementation directly reuses the search logic from 
HeaderSearch::LookupFile() and avoids side effects caused by performing 
additional searches.

Alternatively, we could recalculate the default search paths after locating the 
corresponding header file and then perform the extra search. This would make 
the implementation more consistent and better isolate functionalities.

Please let me know if the alternative seems preferable, I’m happy to adjust the 
implementation.

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


[clang] 80f48b8 - [C2y] Claim support for WG14 N3532; NFC (#162718)

2025-10-10 Thread via cfe-commits

Author: Aaron Ballman
Date: 2025-10-10T07:34:16-04:00
New Revision: 80f48b849378dd46b5ff19945995c0f1598eb16b

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

LOG: [C2y] Claim support for WG14 N3532; NFC (#162718)

This paper was ensuring that the left operand of . and -> must be a
complete object type. This has always been required in every version of
Clang.

Added: 
clang/test/C/C2y/n3532.c

Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/test/C/C2y/n3532.c b/clang/test/C/C2y/n3532.c
new file mode 100644
index 0..c481b58ba7d90
--- /dev/null
+++ b/clang/test/C/C2y/n3532.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -verify -std=c2y %s
+// RUN: %clang_cc1 -verify -std=c23 %s
+// RUN: %clang_cc1 -verify -std=c17 %s
+// RUN: %clang_cc1 -verify -std=c11 %s
+// RUN: %clang_cc1 -verify -std=c99 %s
+// RUN: %clang_cc1 -verify -std=c89 %s
+
+/* WG14 N3532: Yes
+ * Member access of an incomplete object
+ *
+ * Verify that the first operand to the . or -> operators is a complete object
+ * type.
+ */
+
+struct S {
+  int i;
+};
+
+union U {
+  int i;
+};
+
+void good_test(void) {
+  struct S s;
+  struct S *s_ptr = &s;
+  union U u;
+  union U *u_ptr = &u;
+
+  // Complete object type, correctly named member.
+  s.i = 10;
+  s_ptr->i = 10;
+  u.i = 10;
+  u_ptr->i = 10;
+}
+
+void bad_test(void) {
+  struct Incomplete *s_ptr;/* expected-note 2 {{forward declaration of 
'struct Incomplete'}} */
+  union AlsoIncomplete *u_ptr; /* expected-note 2 {{forward declaration of 
'union AlsoIncomplete'}} */
+  struct S s;
+  union U u;
+
+  // Incomplete object type.
+  s_ptr->i = 10; /* expected-error {{incomplete definition of type 'struct 
Incomplete'}} */
+  u_ptr->i = 10; /* expected-error {{incomplete definition of type 'union 
AlsoIncomplete'}} */
+
+  (*s_ptr).i = 10; /* expected-error {{incomplete definition of type 'struct 
Incomplete'}} */
+  (*u_ptr).i = 10; /* expected-error {{incomplete definition of type 'union 
AlsoIncomplete'}} */
+
+  // Complete object type, no named member.
+  s.f = "test"; /* expected-error {{no member named 'f' in 'struct S'}} */
+  u.f = "test"; /* expected-error {{no member named 'f' in 'union U'}} */
+}
+

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index 380f66495a367..1a5fa4bbda3dc 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -359,7 +359,7 @@ C2y implementation status
 
   Member access of an incomplete object
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3532.pdf";>N3532
-  Unknown
+  Yes

 
   Representation of Pointers and nullptr_t



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


[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`amdgpu-offload-rhel-8-cmake-build-only` running on `rocm-docker-rhel-8` while 
building `.github,clang,llvm` at step 4 "annotate".

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


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

```
Step 4 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py 
--jobs=32' (failure)
...
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG - Success
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL - Failed
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Failed
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Failed
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Failed
-- Performing Test C_SUPPORTS_NO_PASS_FAILED_FLAG
-- Performing Test C_SUPPORTS_NO_PASS_FAILED_FLAG - Success
-- Performing Test CXX_SUPPORTS_NO_PASS_FAILED_FLAG
-- Performing Test CXX_SUPPORTS_NO_PASS_FAILED_FLAG - Success
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Failed
-- Looking for os_signpost_interval_begin
-- Looking for os_signpost_interval_begin - not found
-- Looking for flock
-- Looking for flock - found
-- Linker detection: GNU ld
-- Performing Test LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS
-- Performing Test LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS - Success
-- Performing Test HAS_WERROR_GLOBAL_CTORS
-- Performing Test HAS_WERROR_GLOBAL_CTORS - Failed
-- Looking for __x86_64__
-- Looking for __x86_64__ - found
-- Found Git: /usr/bin/git (found version "2.43.5") 
-- Looking for logf128
-- Looking for logf128 - found
-- Targeting AMDGPU
-- Targeting SPIRV
-- Targeting X86
-- LLD version: 22.0.0
-- Performing Test C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION
-- Performing Test C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION - Success
-- Performing Test C_SUPPORTS_WUNDEF
-- Performing Test C_SUPPORTS_WUNDEF - Success
-- Performing Test C_SUPPORTS_WERROR_MISMATCHED_TAGS
-- Performing Test C_SUPPORTS_WERROR_MISMATCHED_TAGS - Failed
-- Performing Test CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER
-- Performing Test CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER - Success
-- Performing Test CXX_SUPPORTS_WNO_DEPRECTAED_COPY
-- Performing Test CXX_SUPPORTS_WNO_DEPRECTAED_COPY - Success
-- Performing Test C_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR
-- Performing Test C_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR - Failed
-- Performing Test CXX_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR
-- Performing Test CXX_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR - Failed
-- Performing Test COMPILER_SUPPORTS_WARNING_WEAK_VTABLES
Step 7 (build cmake config) failure: build cmake config (failure)
...
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/llvm/include/llvm/ADT/SmallVector.h:725:5:
   required from ‘void llvm::SmallVectorImpl::assign(ItTy, ItTy) [with ItTy 
= clang::lifetimes::internal::Fact* const*;  = void; T 
= const clang::lifetimes::internal::Fact*]’
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/include/clang/Analysis/Analyses/LifetimeSafety/Facts.h:196:65:
   required from here
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/llvm/include/llvm/ADT/SmallVector.h:203:45:
 warning: parameter ‘From’ set but not used [-Wunused-but-set-parameter]
   void assertSafeToReferenceAfterClear(ItTy From, ItTy To) {
~^~~~
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/llvm/include/llvm/ADT/SmallVector.h:203:56:
 warning: parameter ‘To’ set but not used [-Wunused-but-set-parameter]
   void assertSafeToReferenceAfterClear(ItTy From, ItTy To) {
   ~^~
cc1plus: warning: unrecognized command line option ‘-Wno-pass-failed’
[6377/8118] Linking CXX shared library 
lib/libclangAnalysisLifetimeSafety.so.22.0git
FAILED: lib/libclangAnalysisLifetimeSafety.so.22.0git 
: && /usr/bin/c++ -fPIC -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-array-bounds 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment 
-Wno-misleading-indentation -Wno-pass-failed -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -O3 
-DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   
-Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/./lib
  -Wl,--gc-sections -shared 
-Wl,-

[clang] [C2y] Support WG14 N3457, the __COUNTER__ macro (PR #162662)

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


@@ -90,6 +90,14 @@ def err_unterminated___pragma : Error<"missing terminating 
')' character">;
 
 def err_conflict_marker : Error<"version control conflict marker in file">;
 
+def err_counter_overflow : Error<
+  "'__COUNTER__' value cannot exceed 2147483647">;

AaronBallman wrote:

Okay, I'm sold. :-)

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


[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `hip-third-party-libs-test` 
running on `ext_buildbot_hw_05-hip-docker` while building `.github,clang,llvm` 
at step 4 "annotate".

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


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

```
Step 4 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/hip-tpl.py --jobs=32' (failure)
...
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG - Success
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL - Success
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Failed
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Failed
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Success
-- Performing Test C_SUPPORTS_NO_PASS_FAILED_FLAG
-- Performing Test C_SUPPORTS_NO_PASS_FAILED_FLAG - Success
-- Performing Test CXX_SUPPORTS_NO_PASS_FAILED_FLAG
-- Performing Test CXX_SUPPORTS_NO_PASS_FAILED_FLAG - Success
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Failed
-- Looking for os_signpost_interval_begin
-- Looking for os_signpost_interval_begin - not found
-- Looking for flock
-- Looking for flock - found
-- Linker detection: GNU ld
-- Performing Test LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS
-- Performing Test LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS - Success
-- Performing Test HAS_WERROR_GLOBAL_CTORS
-- Performing Test HAS_WERROR_GLOBAL_CTORS - Failed
-- Looking for __x86_64__
-- Looking for __x86_64__ - found
-- Found Git: /usr/bin/git (found version "2.34.1") 
-- Looking for logf128
-- Looking for logf128 - found
-- Targeting AMDGPU
-- Targeting SPIRV
-- Targeting X86
-- LLD version: 22.0.0
-- Performing Test C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION
-- Performing Test C_SUPPORTS_WERROR_IMPLICIT_FUNCTION_DECLARATION - Success
-- Performing Test C_SUPPORTS_WUNDEF
-- Performing Test C_SUPPORTS_WUNDEF - Success
-- Performing Test C_SUPPORTS_WERROR_MISMATCHED_TAGS
-- Performing Test C_SUPPORTS_WERROR_MISMATCHED_TAGS - Failed
-- Performing Test CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER
-- Performing Test CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER - Success
-- Performing Test CXX_SUPPORTS_WNO_DEPRECTAED_COPY
-- Performing Test CXX_SUPPORTS_WNO_DEPRECTAED_COPY - Success
-- Performing Test C_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR
-- Performing Test C_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR - Failed
-- Performing Test CXX_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR
-- Performing Test CXX_SUPPORTS_WERROR_GLOBAL_CONSTRUCTOR - Failed
-- Performing Test COMPILER_SUPPORTS_WARNING_WEAK_VTABLES
Step 7 (build cmake config) failure: build cmake config (failure)
...
[6401/8118] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LiveOrigins.cpp.o
[6402/8118] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LoanPropagation.cpp.o
[6403/8118] Building CXX object 
tools/clang/lib/InstallAPI/CMakeFiles/obj.clangInstallAPI.dir/Visitor.cpp.o
[6404/8118] Linking CXX shared library lib/libclangDriver.so.22.0git
[6405/8118] Creating library symlink lib/libclangDriver.so
[6406/8118] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/EntryPointStats.cpp.o
[6407/8118] Linking CXX shared library lib/libclangInstallAPI.so.22.0git
[6408/8118] Creating library symlink lib/libclangInstallAPI.so
[6409/8118] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o
[6410/8118] Linking CXX shared library 
lib/libclangAnalysisLifetimeSafety.so.22.0git
FAILED: lib/libclangAnalysisLifetimeSafety.so.22.0git 
: && /usr/bin/c++ -fPIC -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-array-bounds -Wno-stringop-overread 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -Wno-pass-failed 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   
-Wl,-rpath-link,/home/botworker/bbot/hip-third-party-libs-test/build/./lib  
-Wl,--gc-sections -shared -Wl,-soname,libclangAnalysisLifetimeSafety.so.22.0git 
-o lib/libclangAnalysisLifetimeSafety.so.22.0git 
tools/clang/lib/Analysis/Life

[clang] [Clang] Fix a regression introduced by #161163. (PR #162612)

2025-10-10 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

Now LGTM, thanks! Btw, do you know what 
`!RD->hasNonTrivialDefaultConstructor()` check is needed for? If you do, it 
would be good to add a corresponding test case. If not, a `TODO` to investigate 
it is worth placing in the code.

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


[clang] [Clang] Fix a regression introduced by #161163. (PR #162612)

2025-10-10 Thread Corentin Jabot via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/162612

>From af13d31f970cc62d46746b5e57075f16c5f5c4e8 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Thu, 9 Oct 2025 10:18:28 +0200
Subject: [PATCH 1/4] [Clang] Fix a regression introduced by #161163.

Classes with a user provided constructor are still implicit lifetime
if they have an implicit, trivial copy ctr.
---
 clang/lib/Sema/SemaTypeTraits.cpp  | 24 +---
 clang/test/SemaCXX/type-traits.cpp | 12 +++-
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Sema/SemaTypeTraits.cpp 
b/clang/lib/Sema/SemaTypeTraits.cpp
index 3e34675cbf064..13f25c453d8ba 100644
--- a/clang/lib/Sema/SemaTypeTraits.cpp
+++ b/clang/lib/Sema/SemaTypeTraits.cpp
@@ -1165,14 +1165,24 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, 
TypeTrait UTT,
 const CXXDestructorDecl *Dtor = RD->getDestructor();
 if (UnqualT->isAggregateType() && (!Dtor || !Dtor->isUserProvided()))
   return true;
-if (RD->hasTrivialDestructor() && (!Dtor || !Dtor->isDeleted())) {
-  for (CXXConstructorDecl *Ctr : RD->ctors()) {
-if (Ctr->isIneligibleOrNotSelected() || Ctr->isDeleted())
-  continue;
-if (Ctr->isTrivial())
-  return true;
-  }
+if (!(RD->hasTrivialDestructor() && (!Dtor || !Dtor->isDeleted(
+  return false;
+bool FoundCopyCtr = false;
+bool FoundMoveCtr = false;
+for (CXXConstructorDecl *Ctr : RD->ctors()) {
+  FoundCopyCtr = Ctr->isCopyConstructor();
+  FoundMoveCtr = Ctr->isMoveConstructor();
+  if (Ctr->isIneligibleOrNotSelected() || Ctr->isDeleted())
+continue;
+  if (Ctr->isTrivial())
+return true;
 }
+if (!FoundCopyCtr && RD->hasTrivialCopyConstructor() &&
+!RD->defaultedCopyConstructorIsDeleted())
+  return true;
+if (!FoundMoveCtr && RD->hasTrivialMoveConstructor() &&
+!RD->defaultedMoveConstructorIsDeleted())
+  return true;
 return false;
   }
   case UTT_IsIntangibleType:
diff --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index 901d510bba847..343529fe81b57 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -2066,7 +2066,17 @@ class UserProvidedConstructor {
 UserProvidedConstructor(const UserProvidedConstructor&)= 
delete;
 UserProvidedConstructor& operator=(const UserProvidedConstructor&) = 
delete;
 };
+struct Ctr {
+Ctr();
+};
+struct Ctr2 {
+Ctr2();
+private:
+  NoEligibleTrivialContructor inner;
+};
 
+static_assert(__builtin_is_implicit_lifetime(Ctr));
+static_assert(!__builtin_is_implicit_lifetime(NoEligibleTrivialContructor));
 static_assert(__builtin_is_implicit_lifetime(NonAggregate));
 static_assert(!__builtin_is_implicit_lifetime(DataMemberInitializer));
 static_assert(!__builtin_is_implicit_lifetime(UserProvidedConstructor));
@@ -2076,7 +2086,7 @@ template 
 class Tpl {
 Tpl() requires false = default ;
 };
-static_assert(!__builtin_is_implicit_lifetime(Tpl));
+static_assert(__builtin_is_implicit_lifetime(Tpl));
 
 #endif
 }

>From 32f2664975e61c3368a4d47a10bb992c2572edd5 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Thu, 9 Oct 2025 18:24:41 +0200
Subject: [PATCH 2/4] fix the case of non copyable subobjects

---
 clang/lib/Sema/SemaTypeTraits.cpp  | 10 --
 clang/test/SemaCXX/type-traits.cpp | 10 ++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaTypeTraits.cpp 
b/clang/lib/Sema/SemaTypeTraits.cpp
index 13f25c453d8ba..187d39e8f26ed 100644
--- a/clang/lib/Sema/SemaTypeTraits.cpp
+++ b/clang/lib/Sema/SemaTypeTraits.cpp
@@ -1167,16 +1167,22 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, 
TypeTrait UTT,
   return true;
 if (!(RD->hasTrivialDestructor() && (!Dtor || !Dtor->isDeleted(
   return false;
+if (RD->hasTrivialDefaultConstructor())
+  return true;
 bool FoundCopyCtr = false;
 bool FoundMoveCtr = false;
+bool FoundDefaultCtr = false;
 for (CXXConstructorDecl *Ctr : RD->ctors()) {
-  FoundCopyCtr = Ctr->isCopyConstructor();
-  FoundMoveCtr = Ctr->isMoveConstructor();
   if (Ctr->isIneligibleOrNotSelected() || Ctr->isDeleted())
 continue;
   if (Ctr->isTrivial())
 return true;
+  FoundCopyCtr = Ctr->isCopyConstructor();
+  FoundMoveCtr = Ctr->isMoveConstructor();
+  FoundDefaultCtr = Ctr->isDefaultConstructor();
 }
+if (!FoundDefaultCtr && RD->hasTrivialDefaultConstructor())
+  return true;
 if (!FoundCopyCtr && RD->hasTrivialCopyConstructor() &&
 !RD->defaultedCopyConstructorIsDeleted())
   return true;
diff --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index 343529fe81b57..bc010dc5932ca 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -2075,7 +2075,17 @@ struct Ctr2 {
   NoEligibl

[clang] [Clang] Only link C device libraries by default for OpenMP (PR #151239)

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

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

>From b4e64ea87bd2d780a0b714784e09b74d27cc4150 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Tue, 29 Jul 2025 16:43:24 -0500
Subject: [PATCH 1/2] [Clang] Only C link device libraries by default for
 OpenMP

Summary:
We link these implicitly for OpenMP because it's the canonical
implementation of those C language features. This was inhereted by HIP
and ended up with these resolving functions. There are some useful
functions in here, but this can be problematic as it could potentially
override functions intended to be provided by the ROCm device libraries.
Additionally the HIP runtime does not currently provide the handling for
the RPC server required to run the host resources so those just segfault.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d326a81feb762..1929952cff8a9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9210,8 +9210,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
options::OPT_nogpulibc)) {
 forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) 
{
   // The device C library is only available for NVPTX and AMDGPU targets
-  // currently.
-  if (!TC.getTriple().isNVPTX() && !TC.getTriple().isAMDGPU())
+  // and we only link it by default for OpenMP currently.
+  if (!TC.getTriple().isNVPTX() && !TC.getTriple().isAMDGPU() ||
+  !JA.isHostOffloading(Action::OFK_OpenMP))
 return;
   bool HasLibC = TC.getStdlibIncludePath().has_value();
   if (HasLibC) {

>From e0517a0de7e38a43d3a22b26303368c188e2b94d Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Fri, 10 Oct 2025 07:58:00 -0500
Subject: [PATCH 2/2] Add test

---
 clang/lib/Driver/ToolChains/Clang.cpp |  2 +-
 clang/test/Driver/gpu-libc-headers.c  | 14 
 clang/test/Driver/gpu-libc.c  | 32 +++
 3 files changed, 33 insertions(+), 15 deletions(-)
 delete mode 100644 clang/test/Driver/gpu-libc-headers.c
 create mode 100644 clang/test/Driver/gpu-libc.c

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1929952cff8a9..ff80a59ef3ce4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9211,7 +9211,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const 
JobAction &JA,
 forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) 
{
   // The device C library is only available for NVPTX and AMDGPU targets
   // and we only link it by default for OpenMP currently.
-  if (!TC.getTriple().isNVPTX() && !TC.getTriple().isAMDGPU() ||
+  if ((!TC.getTriple().isNVPTX() && !TC.getTriple().isAMDGPU()) ||
   !JA.isHostOffloading(Action::OFK_OpenMP))
 return;
   bool HasLibC = TC.getStdlibIncludePath().has_value();
diff --git a/clang/test/Driver/gpu-libc-headers.c 
b/clang/test/Driver/gpu-libc-headers.c
deleted file mode 100644
index 18029193edeba..0
--- a/clang/test/Driver/gpu-libc-headers.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a 
--sysroot=%S/Inputs/basic_gpu_tree \
-// RUN: -ccc-install-dir %S/Inputs/basic_gpu_tree/bin -nogpulib %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-HEADERS-AMDGPU
-// RUN:   %clang -### --target=nvptx64-nvidia-cuda -march=sm_89 
--sysroot=%S/Inputs/basic_gpu_tree \
-// RUN: -ccc-install-dir %S/Inputs/basic_gpu_tree/bin -nogpulib %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-HEADERS-NVPTX
-// CHECK-HEADERS-AMDGPU: "-cc1"{{.*}}"-isysroot"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}amdgcn-amd-amdhsa"
-// CHECK-HEADERS-NVPTX: "-cc1"{{.*}}"-isysroot"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}nvptx64-nvidia-cuda"
-
-// RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
-// RUN: -nogpuinc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-HEADERS-DISABLED
-// RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
-// RUN: -nostdinc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-HEADERS-DISABLED
-// RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx1030 -nogpulib \
-// RUN: -nobuiltininc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-HEADERS-DISABLED
-// CHECK-HEADERS-DISABLED-NOT: "-cc1"{{.*}}"-internal-isystem" 
"{{.*}}include{{.*}}gpu-none-llvm"
diff --git a/clang/test/Driver/gpu-libc.c b/clang/test/Driver/gpu-libc.c
new file mode 100644
index 0..88f346f32e0b8
--- /dev/null
+++ b/clang/test/Driver/gpu-libc.c
@@ -0,0 +1,32 @@
+// RUN:   %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx90a 
--sysroot=%S/Inputs/basic_gpu_tree \
+// RUN: -ccc-install-dir %S/Inputs/basic_gpu_tree/bin -nogpulib %s 2>&1 | 
File

[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ppc64le-rhel` 
running on `ppc64le-clang-rhel-test` while building `.github,clang,llvm` at 
step 5 "build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
66.882 [3062/192/3438] Building CXX object 
lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMFrameLowering.cpp.o
66.896 [3061/192/3439] Building CXX object 
lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMHazardRecognizer.cpp.o
66.923 [3060/192/3440] Linking CXX shared library 
lib/libLLVMFrontendOpenMP.so.22.0git
66.948 [3059/192/3441] Creating library symlink lib/libLLVMFrontendOpenMP.so
66.988 [3058/192/3442] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/ExprEngineObjC.cpp.o
67.112 [3057/192/3443] Building CXX object 
lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMInstructionSelector.cpp.o
67.166 [3056/192/3444] Building CXX object 
lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMISelDAGToDAG.cpp.o
67.174 [3055/192/3445] Building CXX object 
lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMInstrInfo.cpp.o
67.182 [3054/192/3446] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/CheckExprLifetime.cpp.o
67.203 [3053/192/3447] Linking CXX shared library 
lib/libclangAnalysisLifetimeSafety.so.22.0git
FAILED: [code=1] lib/libclangAnalysisLifetimeSafety.so.22.0git 
: && /home/buildbots/llvm-external-buildbots/clang.20.1.8/bin/clang++ 
--gcc-toolchain=/gcc-toolchain/usr -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -Wno-pass-failed 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -Wl,-z,defs 
-Wl,-z,nodelete -Wl,--color-diagnostics  -Wl,--gc-sections  -Xlinker 
--dependency-file=tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/clangAnalysisLifetimeSafety.dir/link.d
 -shared -Wl,-soname,libclangAnalysisLifetimeSafety.so.22.0git -o 
lib/libclangAnalysisLifetimeSafety.so.22.0git 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Facts.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeAnnotations.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeSafety.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LiveOrigins.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Loans.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LoanPropagation.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Origins.cpp.o
  
-Wl,-rpath,"\$ORIGIN/../lib:/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib:"
  lib/libLLVMFrontendOpenMP.so.22.0git  lib/libLLVMSupport.so.22.0git  
-Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib
 && :
ld.lld: error: undefined symbol: clang::PostOrderCFGView::getTag()
>>> referenced by Checker.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o:(clang::lifetimes::internal::runLifetimeChecker(clang::lifetimes::internal::LoanPropagationAnalysis
>>>  const&, clang::lifetimes::internal::LiveOriginsAnalysis const&, 
>>> clang::lifetimes::internal::FactManager const&, 
>>> clang::AnalysisDeclContext&, clang::lifetimes::LifetimeSafetyReporter*))
>>> referenced by Facts.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Facts.cpp.o:(clang::lifetimes::internal::FactManager::dump(clang::CFG
>>>  const&, clang::AnalysisDeclContext&) const)
>>> referenced by FactsGenerator.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o:(clang::lifetimes::internal::FactsGenerator::run())
>>> referenced 2 more times

ld.lld: error: undefined symbol: 
clang::AnalysisDeclContext::getAnalysisImpl(voi

[clang-tools-extra] [clang-tidy] Fix insertion location for certain function pointers in `cppcoreguidelines-init-variables` (PR #162218)

2025-10-10 Thread via cfe-commits

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


[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`bolt-aarch64-ubuntu-shared` running on `bolt-worker-aarch64` while building 
`.github,clang,llvm` at step 6 "test-build-bolt-check-bolt".

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


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

```
Step 6 (test-build-bolt-check-bolt) failure: test (failure)
...
13.374 [227/34/1427] Building CXX object 
tools/clang/lib/InstallAPI/CMakeFiles/obj.clangInstallAPI.dir/Frontend.cpp.o
13.411 [226/34/1428] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/FunctionSummary.cpp.o
13.420 [225/34/1429] Building CXX object 
tools/clang/lib/InstallAPI/CMakeFiles/obj.clangInstallAPI.dir/Visitor.cpp.o
13.441 [224/34/1430] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CompilerInvocation.cpp.o
13.517 [223/34/1431] Linking CXX shared library 
lib/libclangInstallAPI.so.22.0git
13.528 [222/34/1432] Creating library symlink lib/libclangInstallAPI.so
13.852 [221/34/1433] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o
13.872 [220/34/1434] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LiveOrigins.cpp.o
14.020 [219/34/1435] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LoanPropagation.cpp.o
14.075 [218/34/1436] Linking CXX shared library 
lib/libclangAnalysisLifetimeSafety.so.22.0git
FAILED: lib/libclangAnalysisLifetimeSafety.so.22.0git 
: && /usr/bin/c++ -fPIC -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-dangling-reference 
-Wno-redundant-move -Wno-pessimizing-move -Wno-array-bounds 
-Wno-stringop-overread -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation 
-Wctad-maybe-unsupported -Wno-pass-failed -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -O3 
-DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics   
-Wl,--gc-sections -shared -Wl,-soname,libclangAnalysisLifetimeSafety.so.22.0git 
-o lib/libclangAnalysisLifetimeSafety.so.22.0git 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Facts.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeAnnotations.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeSafety.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LiveOrigins.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Loans.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LoanPropagation.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Origins.cpp.o
  
-Wl,-rpath,"\$ORIGIN/../lib:/home/buildbot/workspace/bolt-aarch64-ubuntu-shared/build/lib:"
  lib/libLLVMFrontendOpenMP.so.22.0git  lib/libLLVMSupport.so.22.0git  
-Wl,-rpath-link,/home/buildbot/workspace/bolt-aarch64-ubuntu-shared/build/lib 
&& :
ld.lld: error: undefined symbol: clang::AnalysisDeclContext::getCFG()
>>> referenced by LifetimeSafety.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeSafety.cpp.o:(clang::lifetimes::internal::LifetimeSafetyAnalysis::run()
>>>  (.localalias))

ld.lld: error: undefined symbol: clang::Decl::getASTContext() const
>>> referenced by LifetimeSafety.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeSafety.cpp.o:(clang::lifetimes::internal::LifetimeSafetyAnalysis::run()
>>>  (.localalias))
>>> referenced by LifetimeAnnotations.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeAnnotations.cpp.o:(clang::lifetimes::isNormalAssignmentOperator(clang::FunctionDecl
>>>  const*) (.localalias))

ld.lld: error: undefined symbol: clang::CFG::dump(clang::LangOptions const&, 
bool) const
>>> referenced by LifetimeSafety.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeSafety.cpp.o:(clang::lifetimes::internal::LifetimeSafetyAnalysis::run()
>>>  (.loc

[clang] [OpenACC] Sema changes for +*&|^ reduction combiner recipes (PR #162740)

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

erichkeane wrote:

This will actually have about 20 tests that crash now with the new assert.  I 
am quite sure I have been messing up my uses of Array Section functions in 
quite a few places, so I have to put this on pause until I've figured out what 
I'm doing/what the right way to do stuff with this is.

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


[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #162741)

2025-10-10 Thread via cfe-commits


@@ -0,0 +1,72 @@
+.. title:: clang-tidy - modernize-use-constexpr
+
+modernize-use-constexpr
+===
+
+Finds functions and variables that can be declared ``constexpr``.
+
+This check currently supports the ``constexpr`` rule-set of C++11.
+
+The check analyses any function and variable according to the rules defined
+for the language version that the code compiles with.
+Changing to a newer language standard may therefore offer additional
+opportunities to declare a function or variable as ``constexpr``.
+Furthermore, this check can be incremental in terms of its diagnostics. For
+example, declaring a function ``constepxr`` might create new opportunities of
+marking additional variables or function ``constexpr``, which can only be found
+in subsequent runs of this check.
+
+Before C++23, ``static constexpr`` variables could not be declared inside a
+``constexpr`` function. This check prefers adding ``constexpr`` to an enclosing
+function over adding ``constexpr`` to a static local variable inside that
+function.
+
+Limitations
+---
+
+* Only analyzes variables declared ``const``, because this check would have
+  to duplicate the expensive analysis of the 
+  :doc:`misc-const-correctness<../misc/const-correctness>` check.
+  For the best results, enable both `misc-const-correctness` and
+  `modernize-use-constexpr` together.
+
+* Only analyzes variable declarations that declare a single variable
+
+Options
+---
+
+.. option:: ConservativeLiteralType
+
+  With this option enabled, only literal types that can be constructed at
+  compile-time are considered to supoprt ``constexpr``.

EugeneZelenko wrote:

```suggestion
  compile-time are considered to support ``constexpr``.
```

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


[clang] [clang] fix transform for constant template parameter type subst node (PR #162587)

2025-10-10 Thread Greg Bedwell via cfe-commits

gregbedwell wrote:

Hello!  I've bisected #162855 back to this commit.  Please can you take a look?

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


[clang] 2992d3d - [C2y] Claim support for WG14 N3623 (#162843)

2025-10-10 Thread via cfe-commits

Author: Aaron Ballman
Date: 2025-10-10T10:28:10-04:00
New Revision: 2992d3dfef31ff0cc284f23ee18245fa480d20f5

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

LOG: [C2y] Claim support for WG14 N3623 (#162843)

This requires invalid signatures of main to be diagnosed while still
allowing for common extensions. Clang has always supported this.

Added: 
clang/test/C/C2y/n3623.c

Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/test/C/C2y/n3623.c b/clang/test/C/C2y/n3623.c
new file mode 100644
index 0..a557edadae078
--- /dev/null
+++ b/clang/test/C/C2y/n3623.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -verify -std=c2y -DSTD1 %s
+// RUN: %clang_cc1 -verify -std=c2y -DSTD2 %s
+// RUN: %clang_cc1 -verify=gnu1 -std=gnu2y -DGNU1 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU2 %s
+// RUN: %clang_cc1 -verify=gnu3 -std=gnu2y -DGNU3 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU4 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU5 %s
+// RUN: %clang_cc1 -verify -std=gnu2y -DGNU6 %s
+// RUN: %clang_cc1 -verify=gnu7 -std=gnu2y -DGNU7 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -verify -std=c2y -DDARWIN1 %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32-mscv -verify -std=c2y 
-fms-compatibility -DMS1 %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32-mscv -verify -std=c2y 
-fms-compatibility -DMS2 %s
+// RUN: %clang_cc1 -verify=invalid -std=c2y -DINVALID1 %s
+// RUN: %clang_cc1 -verify=invalid -std=c2y -DINVALID2 %s
+// expected-no-diagnostics
+
+/* WG14 N3623: Yes
+ * Earthly Demon XV: Definition of Main
+ *
+ * This validates that we accept the standard type definitions of main or some
+ * other implementation-defined type.
+ */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+// These are the signatures required by the standard.
+#if defined(STD1)
+int main(void) {}
+#elif defined(STD2)
+int main(int argc, char *argv[]) {}
+#endif
+
+// GNU extensions.
+#if defined(GNU1)
+void main(void) {} /* gnu1-warning {{return type of 'main' is not 'int'}}
+  gnu1-note {{change return type to 'int'}}
+*/
+#elif defined(GNU2)
+const int main(void) {}
+#elif defined(GNU3)
+int main(...) {} /* gnu3-warning {{'main' is not allowed to be declared 
variadic}} */
+#elif defined(GNU4)
+int main(int, const char **) {}
+#elif defined(GNU5)
+int main(int, char const * const *) {}
+#elif defined(GNU6)
+int main(int, char * const *) {}
+#elif defined(GNU7)
+int main(int) {} /* gnu7-warning {{only one parameter on 'main' declaration}} 
*/
+#endif
+
+// Darwin extensions.
+#if defined(DARWIN1)
+int main(int argc, char *argv[], char *environ[], char **undocumented) {}
+#endif
+
+// Microsoft extensions.
+#if defined(MS1)
+int wmain(int, wchar_t *[]) {}
+#elif defined(MS2)
+int wmain(int, wchar_t *[], wchar_t *[]) {}
+#endif
+
+// Invalid signatures.
+#if defined(INVALID1)
+inline int main(int, char *[]); /* invalid-error {{'main' is not allowed to be 
declared inline}} */
+int main(int, char *[], char *[], float); /* invalid-error {{too many 
parameters (4) for 'main': must be 0, 2, or 3}} */
+float main(int); /* invalid-error {{'main' must return 'int'}} */
+_Noreturn int main(int, char *[]); /* invalid-warning {{'main' is not allowed 
to be declared _Noreturn}}
+  invalid-note {{remove '_Noreturn'}}
+*/
+#elif defined(INVALID2)
+static int main(void); /* invalid-warning {{'main' should not be declared 
static}} */
+#endif

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index f16c40202aa21..a6bcd4c197133 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -339,7 +339,7 @@ C2y implementation status
 
   Earthly Demon XV: Definition of Main
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3623.pdf";>N3623
-  Unknown
+  Yes

 
   static_assert without UB



___
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-10 Thread via cfe-commits


@@ -2376,6 +2381,33 @@ StmtResult Parser::ParseReturnStatement() {
   return Actions.ActOnReturnStmt(ReturnLoc, R.get(), getCurScope());
 }
 
+StmtResult Parser::ParseDeferStatement(SourceLocation *TrailingElseLoc) {
+  assert(Tok.is(tok::kw_defer));
+  SourceLocation DeferLoc = ConsumeToken();
+  Actions.ActOnStartOfDeferStmt(DeferLoc, getCurScope());
+  auto OnError = llvm::make_scope_exit(
+  [&] { Actions.ActOnDeferStmtError(getCurScope()); });
+
+  StmtResult Res = ParseStatement(TrailingElseLoc);
+  if (!Res.isUsable())
+return StmtError();
+
+  // Diagnose this *after* parsing the body for better synchronisation.
+  if (getLangOpts().CPlusPlus) {
+Diag(DeferLoc, diag::err_defer_unsupported);
+return StmtError();
+  }

Sirraide wrote:

> Maybe the alternative is to not parse the driver option at all in c++ mode 
> (`ShouldParseIf`)

I didn’t know that was a thing, but that looks like the proper way to do this.

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-tools-extra] [clang-tidy][NFC] Migrate tests away from `--match-partial-fixes` (PR #162851)

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


@@ -53,7 +53,7 @@ void integer_suffix() {
   static_assert(is_same::value, "");
   static_assert(v11 == 1, "");
 
-  static constexpr auto v12 = 1UL; // OK.
+  static constexpr auto v12 = 1UL;

localspook wrote:

Comment is wrong

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


[clang] [clang] Fix inconsistencies with the device_kernel attr on different targets (PR #161905)

2025-10-10 Thread Nick Sarnie via cfe-commits

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


[clang] [C2y] Claim support for WG14 N3623 (PR #162843)

2025-10-10 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/28819


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 :: C/C2y/n3623.c' 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 -verify -std=c2y -DSTD1 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # 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 -verify -std=c2y -DSTD1 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=c2y -DSTD2 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # RUN: at line 2
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=c2y -DSTD2 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify=gnu1 -std=gnu2y -DGNU1 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # RUN: at line 3
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify=gnu1 -std=gnu2y -DGNU1 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=gnu2y -DGNU2 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # RUN: at line 4
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=gnu2y -DGNU2 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify=gnu3 -std=gnu2y -DGNU3 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # RUN: at line 5
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify=gnu3 -std=gnu2y -DGNU3 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=gnu2y -DGNU4 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # RUN: at line 6
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=gnu2y -DGNU4 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=gnu2y -DGNU5 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
 # RUN: at line 7
+ /Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22/include 
-nostdsysteminc -verify -std=gnu2y -DGNU5 
/Users/buildbot/buildbot-root2/aarch64-darwin/llvm-project/clang/test/C/C2y/n3623.c
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Volumes/ExternalSSD/buildbot-root/aarch64-darwin/build/lib/clang/22

[clang] [CIR] Add inline function attributes (PR #162866)

2025-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Morris Hafner (mmha)


Changes

Unlike the incubator, this adds the inline attribute directly to FuncOp instead 
of adding the ExtraFnAttr dict.

This adds three new optional keywords to CIR: inline_always, inline_never and 
inline_hint. Just like in OGCG -O0 implies inline_never on functions withoutt 
the C++ `inline` keyword and no other inlining-related attribute.

This patch also adapts all tests that use functions so they account for LLVM 
attributes being attached now.

---

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


32 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+26) 
- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+5) 
- (modified) clang/include/clang/CIR/MissingFeatures.h (+12-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenCXX.cpp (+2-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+82-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.h (+4) 
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+26) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp (+7) 
- (modified) clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp (+38) 
- (modified) clang/test/CIR/CodeGen/array.cpp (+10-10) 
- (modified) clang/test/CIR/CodeGen/assign-operator.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/binassign.c (+2-2) 
- (modified) clang/test/CIR/CodeGen/bitfields_be.c (+2-2) 
- (modified) clang/test/CIR/CodeGen/builtin_call.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/builtin_printf.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/call.c (+12-12) 
- (modified) clang/test/CIR/CodeGen/call.cpp (+8-8) 
- (modified) clang/test/CIR/CodeGen/cmp.cpp (+8-8) 
- (modified) clang/test/CIR/CodeGen/comma.c (+2-2) 
- (modified) clang/test/CIR/CodeGen/ctor.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/dtors.cpp (+5-5) 
- (added) clang/test/CIR/CodeGen/inline-attributes.cpp (+79) 
- (modified) clang/test/CIR/CodeGen/label.c (+6-6) 
- (modified) clang/test/CIR/CodeGen/lambda-static-invoker.cpp (+7-7) 
- (modified) clang/test/CIR/CodeGen/lambda.cpp (+13-13) 
- (modified) clang/test/CIR/CodeGen/linkage-spec.cpp (+14-14) 
- (modified) clang/test/CIR/CodeGen/loop.cpp (+10-10) 
- (modified) clang/test/CIR/CodeGen/member-functions.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/nrvo.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/ternary.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/vbase.cpp (+5-5) 
- (modified) clang/test/CIR/CodeGen/vtt.cpp (+2-2) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index bb62223d9e152..7ec8dc6c08376 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -959,5 +959,31 @@ def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", 
[TypedAttrInterface]> {
 `<` custom($data) `>`
   }];
 }
+//===--===//
+// InlineAttr
+//===--===//
+
+def CIR_InlineKind : CIR_I32EnumAttr<"InlineKind", "inlineKind", [
+  I32EnumAttrCase<"NoInline", 1, "no">,
+  I32EnumAttrCase<"AlwaysInline", 2, "always">,
+  I32EnumAttrCase<"InlineHint", 3, "hint">
+]> {
+  let genSpecializedAttr = 0;
+}
+
+def CIR_InlineAttr : CIR_EnumAttr {
+  let summary = "Inline attribute";
+  let description = [{
+Inline attributes represents user directives.
+  }];
+
+  let cppClassName = "InlineAttr";
+
+  let extraClassDeclaration = [{
+bool isNoInline() const { return getValue() == InlineKind::NoInline; };
+bool isAlwaysInline() const { return getValue() == 
InlineKind::AlwaysInline; };
+bool isInlineHint() const { return getValue() == InlineKind::InlineHint; };
+  }];
+}
 
 #endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 27fe0cc46d7cf..5d4aa6ac782ec 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -2449,6 +2449,10 @@ def CIR_FuncOp : CIR_Op<"func", [
 without a prototype and, consequently, may contain calls with invalid
 arguments and undefined behavior.
 
+The `inline_never` keyword marks a function that should not be inlined.
+The `inline_always` keyword marks a function that should always be inlined.
+The `inline_hint` keyword suggests that the function should be inlined.
+
 Example:
 
 ```mlir
@@ -2483,6 +2487,7 @@ def CIR_FuncOp : CIR_Op<"func", [
UnitAttr:$dso_local,
DefaultValuedAttr:$linkage,
+   OptionalAttr:$inline_kind,
OptionalAttr:$sym_visibility,
UnitAttr:$comdat,
OptionalAttr:$arg_attrs,
diff --git a/clang/i

[clang] [AMDGPU][NFC] Fix clang frontend<->sema layering issue (PR #162865)

2025-10-10 Thread Jordan Rupprecht via cfe-commits

https://github.com/rupprecht created 
https://github.com/llvm/llvm-project/pull/162865

#140210 added `#include "clang/Frontend/FrontendDiagnostic.h"` to 
clang/lib/Sema/SemaAMDGPU.cpp, but Frontend itself has a dependency on Sema. 
This creates a layering issue as described in 
https://llvm.org/docs/CodingStandards.html#library-layering.

Fortunately, d076608d58d1ec55016eb747a995511e3a3f72aa made this easy to fix, as 
clang/Frontend/FrontendDiagnostic.h just forwards to 
clang/Basic/DiagnosticFrontend.h, so it's trivial to make this depend on basic 
instead of frontend.

>From 76775e5a4a86edac1fb5bc58d25a6806bd58487f Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht 
Date: Fri, 10 Oct 2025 08:11:40 -0700
Subject: [PATCH] [AMDGPU][NFC] Fix clang frontend<->sema layering issue

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

diff --git a/clang/lib/Sema/SemaAMDGPU.cpp b/clang/lib/Sema/SemaAMDGPU.cpp
index 45fe80de53fbc..e32f4376a5ebf 100644
--- a/clang/lib/Sema/SemaAMDGPU.cpp
+++ b/clang/lib/Sema/SemaAMDGPU.cpp
@@ -11,9 +11,9 @@
 
//===--===//
 
 #include "clang/Sema/SemaAMDGPU.h"
+#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/TargetBuiltins.h"
-#include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Sema/Ownership.h"
 #include "clang/Sema/Sema.h"
 #include "llvm/Support/AMDGPUAddrSpace.h"

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


[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

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


@@ -175,15 +175,33 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
 
   constructLlvmLinkCommand(C, JA, Inputs, LinkedBCFile, Args);
 
-  // Emit SPIR-V binary.
-  llvm::opt::ArgStringList TrArgs{
-  "--spirv-max-version=1.6",
-  "--spirv-ext=+all",
-  "--spirv-allow-unknown-intrinsics",
-  "--spirv-lower-const-expr",
-  "--spirv-preserve-auxdata",
-  "--spirv-debug-info-version=nonsemantic-shader-200"};
-  SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile, TrArgs);
+  bool UseSPIRVBackend = Args.hasFlag(
+  options::OPT_use_experimental_spirv_backend,
+  options::OPT_no_use_experimental_spirv_backend, /*Default=*/false);
+
+  // Emit SPIR-V binary either using the SPIRV backend or the translator.
+  if (UseSPIRVBackend) {
+llvm::opt::ArgStringList CmdArgs;
+const char *Triple =
+C.getArgs().MakeArgString("-triple=spirv64-amd-amdhsa");
+CmdArgs.append({"-cc1", Triple, "-emit-obj", LinkedBCFile.getFilename(),

arsenm wrote:

No, using llc is vetoed. The correct way to codegen is to use cc1 

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


[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

2025-10-10 Thread Utkarsh Saxena via cfe-commits

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


[clang] [llvm] [LifetimeSafety] Reorganize code into modular components (PR #162474)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`polly-x86_64-linux-shared-plugin` running on `polly-x86_64-gce2` while 
building `.github,clang,llvm` at step 5 "build".

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


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

```
Step 5 (build) failure: 'ninja' (failure)
...
[3331/4536] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LoanPropagation.cpp.o
[3332/4536] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o
[/4536] Building CXX object 
tools/clang/lib/Edit/CMakeFiles/obj.clangEdit.dir/EditedSource.cpp.o
[3334/4536] Building CXX object 
tools/clang/lib/Edit/CMakeFiles/obj.clangEdit.dir/Commit.cpp.o
[3335/4536] Building CXX object 
tools/clang/lib/Edit/CMakeFiles/obj.clangEdit.dir/RewriteObjCFoundationAPI.cpp.o
[3336/4536] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Origins.cpp.o
[3337/4536] Linking CXX shared library lib/libclangEdit.so.22.0git
[3338/4536] Creating library symlink lib/libclangEdit.so
[3339/4536] Building CXX object 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o
[3340/4536] Linking CXX shared library 
lib/libclangAnalysisLifetimeSafety.so.22.0git
FAILED: lib/libclangAnalysisLifetimeSafety.so.22.0git 
: && /usr/bin/c++ -fPIC -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-array-bounds -Wno-stringop-overread 
-Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -Wno-pass-failed 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld 
-Wl,--color-diagnostics   -Wl,--gc-sections -shared 
-Wl,-soname,libclangAnalysisLifetimeSafety.so.22.0git -o 
lib/libclangAnalysisLifetimeSafety.so.22.0git 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Facts.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeAnnotations.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LifetimeSafety.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LiveOrigins.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Loans.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/LoanPropagation.cpp.o
 
tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Origins.cpp.o
  
-Wl,-rpath,"\$ORIGIN/../lib:/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib:"
  lib/libLLVMFrontendOpenMP.so.22.0git  lib/libLLVMSupport.so.22.0git  
-Wl,-rpath-link,/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib
 && :
ld.lld: error: undefined symbol: clang::PostOrderCFGView::getTag()
>>> referenced by Checker.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o:(clang::lifetimes::internal::runLifetimeChecker(clang::lifetimes::internal::LoanPropagationAnalysis
>>>  const&, clang::lifetimes::internal::LiveOriginsAnalysis const&, 
>>> clang::lifetimes::internal::FactManager const&, 
>>> clang::AnalysisDeclContext&, clang::lifetimes::LifetimeSafetyReporter*))
>>> referenced by Facts.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Facts.cpp.o:(clang::lifetimes::internal::FactManager::dump(clang::CFG
>>>  const&, clang::AnalysisDeclContext&) const)
>>> referenced by FactsGenerator.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/FactsGenerator.cpp.o:(clang::lifetimes::internal::FactsGenerator::run())
>>> referenced 2 more times

ld.lld: error: undefined symbol: 
clang::AnalysisDeclContext::getAnalysisImpl(void const*)
>>> referenced by Checker.cpp
>>>   
>>> tools/clang/lib/Analysis/LifetimeSafety/CMakeFiles/obj.clangAnalysisLifetimeSafety.dir/Checker.cpp.o:(clang::lifetimes::internal::runLifetimeChecker(clang::lifetimes::internal::LoanPropagationAnalysis
>>>  const&, clang::lifetimes::intern

[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

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


@@ -175,15 +175,33 @@ void AMDGCN::Linker::constructLinkAndEmitSpirvCommand(
 
   constructLlvmLinkCommand(C, JA, Inputs, LinkedBCFile, Args);
 
-  // Emit SPIR-V binary.
-  llvm::opt::ArgStringList TrArgs{
-  "--spirv-max-version=1.6",
-  "--spirv-ext=+all",
-  "--spirv-allow-unknown-intrinsics",
-  "--spirv-lower-const-expr",
-  "--spirv-preserve-auxdata",
-  "--spirv-debug-info-version=nonsemantic-shader-200"};
-  SPIRV::constructTranslateCommand(C, *this, JA, Output, LinkedBCFile, TrArgs);
+  bool UseSPIRVBackend = Args.hasFlag(
+  options::OPT_use_experimental_spirv_backend,
+  options::OPT_no_use_experimental_spirv_backend, /*Default=*/false);
+
+  // Emit SPIR-V binary either using the SPIRV backend or the translator.
+  if (UseSPIRVBackend) {
+llvm::opt::ArgStringList CmdArgs;
+const char *Triple =
+C.getArgs().MakeArgString("-triple=spirv64-amd-amdhsa");
+CmdArgs.append({"-cc1", Triple, "-emit-obj", LinkedBCFile.getFilename(),

arsenm wrote:

This also seems to be reinventing driver infrastructure it shouldn't need to? 
There should be some function to call for this. In particular I'm worried about 
the hardcoded -emit-obj here, probably breaks -save-temps? 

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


[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

2025-10-10 Thread Alex Voicu via cfe-commits

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


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

2025-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Victor Chernyakin (localspook)


Changes

(See the test changes for a description of the problem.)

This is the problematic code:

https://github.com/llvm/llvm-project/blob/424fa833352177da4ea39238c040703e1dc3a0ab/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp#L310-L313

The key thing to know is that, on Windows, `unsigned long` is `uint32_t`.

Consider the `(isInjectUL(Result) ? 1UL : 1)` bit. The common type of `1UL` 
(`uint32_t`) and `1` (`int`) is `uint32_t`, so the type of the overall 
expression is `uint32_t`. Now consider the bigger `(... ? (isInjectUL(Result) ? 
1UL : 1) : -1)`. We just saw that the type of the first expression is 
`uint32_t`. The type of `-1` is `int`, so once again, the type of the overall 
expression is `uint32_t`. That means the `-1` becomes `UINT32_MAX`. 
`getZExtValue()`, however, returns `uint64_t`, so when we go to add this 
`UINT32_MAX` to it, it's zero-extended, and boom, instead of subtracting 1, we 
get a very big `uint64_t` value.

Implicit conversions strike again!

(While we're at it: this 64-bit result is stored in a `size_t`. That's only 32 
bits on a 32-bit system, so we have a narrowing conversion. That's rather ugly, 
so this PR also fixes that.)

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


4 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp (+3-4) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c
 (-5) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp
 (-5) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index d4676842a97ff..39e3a542aaf6b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -307,10 +307,9 @@ static void lengthExprHandle(const Expr *LengthExpr,
   // Try to obtain an 'IntegerLiteral' and adjust it.
   if (!IsMacroDefinition) {
 if (const auto *LengthIL = dyn_cast(LengthExpr)) {
-  size_t NewLength = LengthIL->getValue().getZExtValue() +
- (LengthHandle == LengthHandleKind::Increase
-  ? (isInjectUL(Result) ? 1UL : 1)
-  : -1);
+  uint64_t NewLength =
+  LengthIL->getValue().getZExtValue() +
+  (LengthHandle == LengthHandleKind::Increase ? 1 : -1);
 
   const auto NewLengthFix = FixItHint::CreateReplacement(
   LengthIL->getSourceRange(),
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index d2d79dcc92ec2..f0b21b88dd998 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -274,6 +274,10 @@ Changes in existing checks
   ` check by fixing
   false positive from analysis of a conditional expression in C.
 
+- Improved :doc:`bugprone-not-null-terminated-result
+  ` check by fixing
+  bogus fix-its for `strncmp` and `wcsncmp` on Windows.
+
 - Improved :doc:`bugprone-reserved-identifier
   ` check by ignoring
   declarations and macros in system headers.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c
index 366c1698e4f2d..795ab3d652f9f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c
@@ -1,11 +1,6 @@
 // RUN: %check_clang_tidy --match-partial-fixes %s 
bugprone-not-null-terminated-result %t -- \
 // RUN: -- -I %S/Inputs/not-null-terminated-result
 
-// FIXME: Something wrong with the APInt un/signed conversion on Windows:
-// in 'strncmp(str6, "string", 7);' it tries to inject '4294967302' as length.
-
-// UNSUPPORTED: system-windows
-
 #include "not-null-terminated-result-c.h"
 
 #define __STDC_LIB_EXT1__ 1
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp
index 06e2db9d6e0d6..288c5faabb0ec 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp
@@ -1,11 +1,6 @@
 // RUN: %check_clang_tidy --match-partial-fixes %s 
bugprone-not-null-terminated-result %t -- \
 // RUN: -- -std=c++11 -I %S/Inputs/not-null-terminated-result
 
-// FIXME: Something wrong with the APInt un/signed conversion on Windows:
-// in '

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

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

kimsh02 wrote:

@RKSimon Fixed rebase

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


[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add SSE/AVX VPTEST/VTESTPD/VTESTPS intrinsics to be used in constexpr (PR #160428)

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

kimsh02 wrote:

@RKSimon Fixed testcase

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


[clang-tools-extra] [clang-tidy][NFC] Remove stale comment in test (PR #162857)

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

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


[clang] [C2y] Implement WG14 N3622 static used in an inline (PR #162877)

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


@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=good -pedantic -Wall -std=c2y %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c23 %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c17 %s
+// good-no-diagnostics
+
+/* WG14 N3622: Clang 22
+ * Allow calling static inline within extern inline
+ *
+ * This verifies that a constraint from previous standards is no longer
+ * triggered in C2y mode. The constraint is with calling a statric function
+ * or using a static variable from an inline function with external linkage.
+ */
+
+static void static_func(void) {} // expected-note {{declared here}}
+static int static_var;   // expected-note {{declared here}}
+
+extern inline void test(void) {
+  static_func();   // expected-warning {{static function 'static_func' is used 
in an inline function with external linkage}}

AaronBallman wrote:

The diagnostic wording is existing code and I think is slightly more clear when 
you think about uses of static functions other than calls, like:
```
static void static_func(void) {}
extern inline void foo(void) {
  void (*fp)(void) = static_func; // This is similarly "bad" but there's no 
call in sight
}
```

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


[clang] [KeyInstr] Enable -gkey-instructions by default if optimisations are enabled (PR #149509)

2025-10-10 Thread Orlando Cazalet-Hyams via cfe-commits

OCHyams wrote:

@rnk despite my claims in the comment above, with @omern1's help, I've been 
able to observe something like you've described with SPGO without LTO.

Our initial experiments suggest that `-gkey-instructions` doesn't have an 
effect when used on the profile-gathering build. But the` -fprofile-sample-use` 
build is affected. I'm not yet sure why this is the case.

Key Instructions adds extra fields to `DILocation`s, so my first instinct is 
that this breaks some assumption somewhere in the PGO pipeline. E.g., 
`DILocation` pointer equality no longer working as expected, or some code 
otherwise getting confused about these new fields. I'm not terribly familiar 
with PGO in LLVM so it's slow going. I'm continuing to look into this, but 
thought it would be worth letting you know in case anyone has any insights.

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


[clang] [C2y] Implement WG14 N3622 static used in an inline (PR #162877)

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

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

>From b3e094947fefa338e920adf8ec51360251e343c6 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 10 Oct 2025 12:08:00 -0400
Subject: [PATCH 1/2] [C2y] Implement WG14 N3622 static used in an inline

This paper removes the constraint that a static variable or function
cannot be used within an extern inline function. The diagnostic is
still being produced in earlier language modes for conformance reasons
but has always been accepted as an extension.
---
 clang/docs/ReleaseNotes.rst |  3 +++
 clang/lib/Sema/SemaExpr.cpp |  6 +-
 clang/test/C/C2y/n3622.c| 20 
 3 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/C/C2y/n3622.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 99aa545831240..65b086caf3652 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -180,6 +180,9 @@ C Language Changes
 
 C2y Feature Support
 ^^^
+- No longer triggering ``-Wstatic-in-inline`` in C2y mode; use of a static
+  function or variable within an extern inline function is no longer a
+  constraint per `WG14 N3622 
`_.
 - Clang now supports `N3355 
`_ Named Loops.
 
 C23 Feature Support
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4230ea702e128..efb064c6de913 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -166,7 +166,11 @@ static void diagnoseUseOfInternalDeclInInlineFunction(Sema 
&S,
   // This is disabled under C++; there are too many ways for this to fire in
   // contexts where the warning is a false positive, or where it is technically
   // correct but benign.
-  if (S.getLangOpts().CPlusPlus)
+  //
+  // This is also disabled in C2y because of WG14 N3622 which removed the
+  // constraint entirely. It is left enabled in earlier language modes because
+  // this is a constraint in those language modes.
+  if (S.getLangOpts().CPlusPlus || S.getLangOpts().C2y)
 return;
 
   // Check if this is an inlined function or method.
diff --git a/clang/test/C/C2y/n3622.c b/clang/test/C/C2y/n3622.c
new file mode 100644
index 0..4ef6d81ec40f9
--- /dev/null
+++ b/clang/test/C/C2y/n3622.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=good -pedantic -Wall -std=c2y %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c23 %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c17 %s
+// good-no-diagnostics
+
+/* WG14 N3622: Clang 22
+ * Allow calling static inline within extern inline
+ *
+ * This verifies that a constraint from previous standards is no longer
+ * triggered in C2y mode. The constraint is with calling a statric function
+ * or using a static variable from an inline function with external linkage.
+ */
+
+static void static_func(void) {} // expected-note {{declared here}}
+static int static_var;   // expected-note {{declared here}}
+
+extern inline void test(void) {
+  static_func();   // expected-warning {{static function 'static_func' is used 
in an inline function with external linkage}}
+  static_var = 12; // expected-warning {{static variable 'static_var' is used 
in an inline function with external linkage}}
+}

>From 76012328a7f21a81b1e48c056f0aefe831a10cb2 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 10 Oct 2025 12:09:50 -0400
Subject: [PATCH 2/2] Update website too

---
 clang/www/c_status.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/www/c_status.html b/clang/www/c_status.html
index a6bcd4c197133..b8039622fe694 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -349,7 +349,7 @@ C2y implementation status
 
   Allow calling static inline within extern inline
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3622.txt";>N3622
-  Unknown
+  Clang 22

 
   Generic replacement (v. 2 of quasi-literals)

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


[clang] [C2y] Implement WG14 N3622 static used in an inline (PR #162877)

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


@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=good -pedantic -Wall -std=c2y %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c23 %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c17 %s
+// good-no-diagnostics
+
+/* WG14 N3622: Clang 22
+ * Allow calling static inline within extern inline
+ *
+ * This verifies that a constraint from previous standards is no longer
+ * triggered in C2y mode. The constraint is with calling a statric function
+ * or using a static variable from an inline function with external linkage.
+ */
+
+static void static_func(void) {} // expected-note {{declared here}}
+static int static_var;   // expected-note {{declared here}}
+
+extern inline void test(void) {
+  static_func();   // expected-warning {{static function 'static_func' is used 
in an inline function with external linkage}}

erichkeane wrote:

heh... "calling static function `static_func` in an inline function with 
external linkage is a C2y extension".

WDYT?

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


[clang] [OpenACC] Fix uses of getBaseOriginalType when we really want elt type. (PR #162880)

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

erichkeane wrote:

Still going to auto-merge, but found a few things I can use as a test, so 
stopping it since validation will be finished before i get my tests up :) 

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


[clang-tools-extra] [clangd] Fix regression regarding new line handling for hover/signature help content (PR #162029)

2025-10-10 Thread via cfe-commits

https://github.com/tcottin updated 
https://github.com/llvm/llvm-project/pull/162029

>From b1b2251a1f9a57b710227ab3f36e5369a7ad3079 Mon Sep 17 00:00:00 2001
From: Tim Cottin 
Date: Sun, 5 Oct 2025 21:49:57 +
Subject: [PATCH 1/2] handle new lines in paragraphs correctly for markdown and
 escaped markdown

---
 clang-tools-extra/clangd/support/Markup.cpp   | 194 +++---
 clang-tools-extra/clangd/support/Markup.h |  81 +++-
 .../clangd/unittests/HoverTests.cpp   |  38 +++-
 .../unittests/SymbolDocumentationTests.cpp|   4 +-
 .../clangd/unittests/support/MarkupTests.cpp  | 106 +-
 5 files changed, 328 insertions(+), 95 deletions(-)

diff --git a/clang-tools-extra/clangd/support/Markup.cpp 
b/clang-tools-extra/clangd/support/Markup.cpp
index 89bdc656d440f..e4247974ff9eb 100644
--- a/clang-tools-extra/clangd/support/Markup.cpp
+++ b/clang-tools-extra/clangd/support/Markup.cpp
@@ -450,31 +450,62 @@ std::string Block::asPlainText() const {
   return llvm::StringRef(OS.str()).trim().str();
 }
 
+void Paragraph::renderNewlinesMarkdown(llvm::raw_ostream &OS,
+   std::string &ParagraphText) const {
+  llvm::StringRef Line, Rest;
+
+  for (std::tie(Line, Rest) =
+   llvm::StringRef(ParagraphText).ltrim("\n").rtrim().split('\n');
+   !(Line.empty() && Rest.empty());
+   std::tie(Line, Rest) = Rest.split('\n')) {
+
+if (Line.empty()) {
+  // Blank lines are preserved in markdown.
+  OS << '\n';
+  continue;
+}
+
+OS << Line;
+
+if (!Rest.empty() && isHardLineBreakAfter(Line, Rest, /*IsMarkdown=*/true))
+  // In markdown, 2 spaces before a line break forces a line break.
+  OS << "  ";
+OS << '\n';
+  }
+}
+
 void Paragraph::renderEscapedMarkdown(llvm::raw_ostream &OS) const {
   bool NeedsSpace = false;
   bool HasChunks = false;
+  std::string ParagraphText;
+  ParagraphText.reserve(EstimatedStringSize);
+  llvm::raw_string_ostream ParagraphTextOS(ParagraphText);
   for (auto &C : Chunks) {
 if (C.SpaceBefore || NeedsSpace)
-  OS << " ";
+  ParagraphTextOS << " ";
 switch (C.Kind) {
 case ChunkKind::PlainText:
-  OS << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/true);
+  ParagraphTextOS << renderText(C.Contents, !HasChunks,
+/*EscapeMarkdown=*/true);
   break;
 case ChunkKind::InlineCode:
-  OS << renderInlineBlock(C.Contents);
+  ParagraphTextOS << renderInlineBlock(C.Contents);
   break;
 case ChunkKind::Bold:
-  OS << renderText("**" + C.Contents + "**", !HasChunks,
-   /*EscapeMarkdown=*/true);
+  ParagraphTextOS << renderText("**" + C.Contents + "**", !HasChunks,
+/*EscapeMarkdown=*/true);
   break;
 case ChunkKind::Emphasized:
-  OS << renderText("*" + C.Contents + "*", !HasChunks,
-   /*EscapeMarkdown=*/true);
+  ParagraphTextOS << renderText("*" + C.Contents + "*", !HasChunks,
+/*EscapeMarkdown=*/true);
   break;
 }
 HasChunks = true;
 NeedsSpace = C.SpaceAfter;
   }
+
+  renderNewlinesMarkdown(OS, ParagraphText);
+
   // A paragraph in markdown is separated by a blank line.
   OS << "\n\n";
 }
@@ -482,28 +513,39 @@ void Paragraph::renderEscapedMarkdown(llvm::raw_ostream 
&OS) const {
 void Paragraph::renderMarkdown(llvm::raw_ostream &OS) const {
   bool NeedsSpace = false;
   bool HasChunks = false;
+  std::string ParagraphText;
+  ParagraphText.reserve(EstimatedStringSize);
+  llvm::raw_string_ostream ParagraphTextOS(ParagraphText);
   for (auto &C : Chunks) {
 if (C.SpaceBefore || NeedsSpace)
-  OS << " ";
+  ParagraphTextOS << " ";
 switch (C.Kind) {
 case ChunkKind::PlainText:
-  OS << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/false);
+  ParagraphTextOS << renderText(C.Contents, !HasChunks,
+/*EscapeMarkdown=*/false);
   break;
 case ChunkKind::InlineCode:
-  OS << renderInlineBlock(C.Contents);
+  ParagraphTextOS << renderInlineBlock(C.Contents);
   break;
 case ChunkKind::Bold:
-  OS << "**" << renderText(C.Contents, !HasChunks, 
/*EscapeMarkdown=*/false)
- << "**";
+  ParagraphTextOS << "**"
+  << renderText(C.Contents, !HasChunks,
+/*EscapeMarkdown=*/false)
+  << "**";
   break;
 case ChunkKind::Emphasized:
-  OS << "*" << renderText(C.Contents, !HasChunks, /*EscapeMarkdown=*/false)
- << "*";
+  ParagraphTextOS << "*"
+  << renderText(C.Contents, !HasChunks,
+/*EscapeMarkdown=*/false)
+  << "*";
   break;
 }
 HasChunks = true;
 NeedsSpace = C.SpaceAfter;
   }
+
+  renderNewlinesMarkdown(OS, ParagraphText);
+
   // A para

[clang] [clang][CodeGen] Remove "unsafe-fp-math" attribute support (PR #162779)

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

andykaylor wrote:

I'm very happy to see progress being made on transitioning away from the 
function attributes for fast-math control. That said, it looks like there are 
still some things in the PowerPC ISel code that were using this attribute (by 
way of the UnsafeFPMath setting in TargetOptions).

Do you have plans to remove the backend handling of this attribute?

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


[clang] [CIR] Implement handling for VectorType with size 3 (PR #161232)

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

bcardosolopes wrote:

> As for what we do in CIR, I was thinking maybe we could initially annotate 
> the vector-3 loads and stores with some attribute indicating that a vector-4 
> load and store with a poison element is permitted/expected.

I'd leave the attribute as last resort, we can easily identify by the combo 
"target + vector size".

> If a similar extension were done in LLVM IR, this would lower naturally to a 
> masked load/store on targets that support that, but assuming there will at 
> least be a time before that happens in LLVM IR ...

If you can get an attribute in LLVMIR I guess it makes sense to have that in 
CIR as well.

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


[clang] [CIR] Upstream Exception CXXTryStmt (PR #162528)

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

bcardosolopes wrote:

> It would be useful to pull the CIR dialect changes out of this and into a 
> separate PR that precedes this one. You could also Move the CFG flattening 
> into a follow-up PR and just not lower to LLVM IR in this one. Those changes 
> would make this easier to review.

+1

> I realised that in OGCG, it will call EmitStmt(S.getTryBlock()); and in case 
> that try block is empty, nothing will be generated  In our case, in the 
> incubator, we added scope and use cir::TryOp but I think we can early return 
> in the codegen if the try block is empty. I will do that in another PR and 
> will update this PR after that to handle either non-catch all or try with 
> body.

Nice catch. We probably do this in the incubator because we are creating the 
scopes before we get into the actual emission, it might be more readable/easier 
to delete the ops altogether right after emission if they end being no-ops.

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


[clang] 8e60adc - [C2y] Implement WG14 N3622 static used in an inline (#162877)

2025-10-10 Thread via cfe-commits

Author: Aaron Ballman
Date: 2025-10-10T14:02:17-04:00
New Revision: 8e60adcaafbd5b6859f54879496e017dd218e541

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

LOG: [C2y] Implement WG14 N3622 static used in an inline (#162877)

This paper removes the constraint that a static variable or function
cannot be used within an extern inline function. The diagnostic is still
being produced in earlier language modes for conformance reasons but has
always been accepted as an extension.

Added: 
clang/test/C/C2y/n3622.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/inline.c
clang/www/c_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 99aa545831240..65b086caf3652 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -180,6 +180,9 @@ C Language Changes
 
 C2y Feature Support
 ^^^
+- No longer triggering ``-Wstatic-in-inline`` in C2y mode; use of a static
+  function or variable within an extern inline function is no longer a
+  constraint per `WG14 N3622 
`_.
 - Clang now supports `N3355 
`_ Named Loops.
 
 C23 Feature Support

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 4b27a42c6dd81..ef3f59f4f2263 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1400,7 +1400,7 @@ def C23 : DiagGroup<"c23-extensions", 
[VariadicMacroArgumentsOmitted]>;
 def : DiagGroup<"c2x-extensions", [C23]>;
 
 // A warning group for warnings about using C2y features as extensions.
-def C2y : DiagGroup<"c2y-extensions">;
+def C2y : DiagGroup<"c2y-extensions", [StaticInInline]>;
 
 // Previously supported warning group which is no longer pertinent as binary
 // literals are a C++14 and C23 extension now instead of a GNU extension.

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5be63c027cba7..3df28f2ef3334 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6326,11 +6326,14 @@ def warn_internal_linkage_local_storage : Warning<
   InGroup;
 
 def ext_internal_in_extern_inline : ExtWarn<
-  "static %select{function|variable}0 %1 is used in an inline function with "
-  "external linkage">, InGroup;
+  "using static %select{function|variable}0 %1 in an inline function with "
+  "external linkage is a C2y extension">, InGroup;
 def ext_internal_in_extern_inline_quiet : Extension<
-  "static %select{function|variable}0 %1 is used in an inline function with "
-  "external linkage">, InGroup;
+  ext_internal_in_extern_inline.Summary>, InGroup;
+def warn_c2y_compat_internal_in_extern_inline : Warning<
+  "using static %select{function|variable}0 %1 in an inline function with "
+  "external linkage is incompatible with standards before C2y">,
+  InGroup, DefaultIgnore;
 def warn_static_local_in_extern_inline : Warning<
   "non-constant static local variable in inline function may be 
diff erent "
   "in 
diff erent files">, InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4230ea702e128..01abc1fb2cd37 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -166,6 +166,11 @@ static void diagnoseUseOfInternalDeclInInlineFunction(Sema 
&S,
   // This is disabled under C++; there are too many ways for this to fire in
   // contexts where the warning is a false positive, or where it is technically
   // correct but benign.
+  //
+  // WG14 N3622 which removed the constraint entirely in C2y. It is left
+  // enabled in earlier language modes because this is a constraint in those
+  // language modes. But in C2y mode, we still want to issue the "incompatible
+  // with previous standards" diagnostic, too.
   if (S.getLangOpts().CPlusPlus)
 return;
 
@@ -190,16 +195,17 @@ static void 
diagnoseUseOfInternalDeclInInlineFunction(Sema &S,
   // This last can give us false negatives, but it's better than warning on
   // wrappers for simple C library functions.
   const FunctionDecl *UsedFn = dyn_cast(D);
-  bool DowngradeWarning = S.getSourceManager().isInMainFile(Loc);
-  if (!DowngradeWarning && UsedFn)
-DowngradeWarning = UsedFn->isInlined() || UsedFn->hasAttr();
-
-  S.Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
-   : diag::ext_internal_in_extern_inline)
-<< /*IsVar=*/!UsedFn <<

[clang] [Driver] Remove special handling for older Ubuntu (PR #162518)

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

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


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


[clang] [clang] Remove -g[no-]-* bool flags from g_Group (PR #162750)

2025-10-10 Thread Michael Buch via cfe-commits

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

thanks!

https://github.com/llvm/llvm-project/pull/162750
___
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-10 Thread Corentin Jabot via cfe-commits


@@ -2200,6 +2200,32 @@ 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);
+  if (Arg->isTypeDependent())
+return false;
+
+  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

cor3ntin wrote:

Indeed !

```suggestion
<< 1 << /*scalar=*/ 1 << /*unsigned integer=*/ 1 << /*floating point=*/ 0
```

However we are super inconsistent if you search for uses of 
`err_builtin_invalid_arg_type` elsewhere, so i could go either way.

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


[clang] [CIR] Add inline function attributes (PR #162866)

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


@@ -1720,6 +1720,22 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, 
OperationState &state) {
 hasAlias = true;
   }
 
+  // Parse optional inline attribute: inline_never, inline_always, or
+  // inline_hint
+  if (parser.parseOptionalKeyword("inline_never").succeeded()) {

bcardosolopes wrote:

Why not `parseOptionalAttribute`?

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


[clang] [CIR] Add inline function attributes (PR #162866)

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

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


[clang] [CIR] Upstream CIR Dialect TryOp with Catch Attrs (PR #162897)

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


@@ -2878,6 +2878,138 @@ LogicalResult cir::TypeInfoAttr::verify(
   return success();
 }
 
+//===--===//
+// TryOp
+//===--===//
+
+void cir::TryOp::build(
+OpBuilder &builder, OperationState &result,
+function_ref tryBuilder,
+function_ref catchBuilder) {
+  assert(tryBuilder && "expected builder callback for 'cir.try' body");
+  assert(catchBuilder && "expected builder callback for 'catch' body");
+
+  OpBuilder::InsertionGuard guard(builder);
+
+  // Try body region
+  Region *tryBodyRegion = result.addRegion();
+
+  // Create try body region and set insertion point
+  builder.createBlock(tryBodyRegion);
+  tryBuilder(builder, result.location);
+  catchBuilder(builder, result.location, result);
+}
+
+void cir::TryOp::getSuccessorRegions(
+mlir::RegionBranchPoint point, SmallVectorImpl ®ions) {
+  // If any index all the underlying regions branch back to the parent
+  // operation.
+  if (!point.isParent()) {
+regions.push_back(RegionSuccessor());
+return;
+  }
+
+  // If the condition isn't constant, both regions may be executed.
+  regions.push_back(RegionSuccessor(&getTryRegion()));
+
+  // FIXME: optimize, ideas include:
+  // - If we know a target function never throws a specific type, we can
+  //   remove the catch handler.
+  for (mlir::Region &r : this->getCatchRegions())
+regions.push_back(RegionSuccessor(&r));
+}
+
+static void printCatchRegions(OpAsmPrinter &printer, cir::TryOp op,
+  mlir::MutableArrayRef<::mlir::Region> regions,
+  mlir::ArrayAttr catchersAttr) {
+  if (!catchersAttr)
+return;
+
+  int currCatchIdx = 0;
+  printer << "catch [";
+  llvm::interleaveComma(catchersAttr, printer, [&](const Attribute &a) {
+if (mlir::isa(a)) {
+  printer.printAttribute(a);
+  printer << " ";
+} else if (!a) {
+  printer << "all";
+} else {
+  printer << "type ";
+  printer.printAttribute(a);
+  printer << " ";
+}
+printer.printRegion(regions[currCatchIdx], /*printEntryBLockArgs=*/false,
+/*printBlockTerminators=*/true);
+currCatchIdx++;
+  });
+
+  printer << "]";
+}
+
+static ParseResult parseCatchRegions(
+OpAsmParser &parser,
+llvm::SmallVectorImpl> ®ions,
+::mlir::ArrayAttr &catchersAttr) {
+  if (parser.parseKeyword("catch").failed())
+return parser.emitError(parser.getCurrentLocation(),
+"expected 'catch' keyword here");
+
+  auto parseAndCheckRegion = [&]() -> ParseResult {
+// Parse region attached to catch
+regions.emplace_back(new Region);
+Region &currRegion = *regions.back();
+SMLoc parserLoc = parser.getCurrentLocation();
+if (parser.parseRegion(currRegion)) {
+  regions.clear();
+  return failure();
+}
+
+if (currRegion.empty()) {
+  return parser.emitError(parser.getCurrentLocation(),
+  "catch region shall not be empty");
+}
+
+if (!(currRegion.back().mightHaveTerminator() &&
+  currRegion.back().getTerminator()))
+  return parser.emitError(
+  parserLoc, "blocks are expected to be explicitly terminated");
+
+return success();
+  };
+
+  llvm::SmallVector catchList;
+  auto parseCatchEntry = [&]() -> ParseResult {
+mlir::Attribute exceptionTypeInfo;
+
+if (parser.parseOptionalAttribute(exceptionTypeInfo).has_value()) {
+  catchList.push_back(exceptionTypeInfo);
+} else {
+  ::llvm::StringRef attrStr;
+  if (parser.parseOptionalKeyword(&attrStr, {"all"}).succeeded()) {
+// "all" keyword found, exceptionTypeInfo remains null
+  } else if (parser.parseOptionalKeyword("type").succeeded()) {
+if (parser.parseAttribute(exceptionTypeInfo).failed())
+  return parser.emitError(parser.getCurrentLocation(),

bcardosolopes wrote:

Add a invalid test for this

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


[clang] [CIR] Upstream CIR Dialect TryOp with Catch Attrs (PR #162897)

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


@@ -2878,6 +2878,138 @@ LogicalResult cir::TypeInfoAttr::verify(
   return success();
 }
 
+//===--===//
+// TryOp
+//===--===//
+
+void cir::TryOp::build(
+OpBuilder &builder, OperationState &result,
+function_ref tryBuilder,
+function_ref catchBuilder) {

bcardosolopes wrote:

Can we move this builder to tablegen?

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


[clang] 41f5f3b - [OpenACC] Fix uses of getBaseOriginalType when we really want elt type. (#162880)

2025-10-10 Thread via cfe-commits

Author: Erich Keane
Date: 2025-10-10T18:41:41Z
New Revision: 41f5f3be30105260ccc30433b49f60d5885e731b

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

LOG: [OpenACC] Fix uses of getBaseOriginalType when we really want elt type. 
(#162880)

Lately, I've been using 'getBaseOriginalType' in ArraySectionExpr
incorrectly: it gets the base-ist of element type, when in reality, I
want a single type of indirection. This patch corrects the handful of
uses that I had for it.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/Sema/SemaOpenACC.h
clang/lib/AST/Expr.cpp
clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp
clang/lib/Sema/SemaOpenACC.cpp
clang/lib/Sema/SemaOpenACCClause.cpp
clang/test/SemaOpenACC/combined-construct-reduction-clause.cpp
clang/test/SemaOpenACC/compute-construct-reduction-clause.c
clang/test/SemaOpenACC/compute-construct-reduction-clause.cpp
clang/test/SemaOpenACC/loop-construct-reduction-clause.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index e1a4005d1a890..573cc72db35c6 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -7160,6 +7160,18 @@ class ArraySectionExpr : public Expr {
   /// Return original type of the base expression for array section.
   static QualType getBaseOriginalType(const Expr *Base);
 
+  /// Return the effective 'element' type of this array section. As the array
+  /// section itself returns a collection of elements (closer to its `getBase`
+  /// type), this is only useful for figuring out the effective type of this if
+  /// it were a normal Array subscript expr.
+  QualType getElementType() const;
+
+  /// Returns the effective 'type' of the base of this array section.  This
+  /// should be the array/pointer type that this operates on.  Just
+  /// getBase->getType isn't sufficient, since it doesn't look through existing
+  /// Array sections to figure out the actual 'base' of this.
+  QualType getBaseType() const;
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == ArraySectionExprClass;
   }

diff  --git a/clang/include/clang/Sema/SemaOpenACC.h 
b/clang/include/clang/Sema/SemaOpenACC.h
index 09fdf75fbbd09..6cadc343cd728 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -911,6 +911,7 @@ class SemaOpenACC : public SemaBase {
   ExprResult CheckReductionVar(OpenACCDirectiveKind DirectiveKind,
OpenACCReductionOperator ReductionOp,
Expr *VarExpr);
+  bool CheckReductionVarType(Expr *VarExpr);
 
   /// Called to check the 'var' type is a variable of pointer type, necessary
   /// for 'deviceptr' and 'attach' clauses. Returns true on success.

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f899b3c4bb79c..597cbd846e4d9 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -5290,6 +5290,33 @@ QualType ArraySectionExpr::getBaseOriginalType(const 
Expr *Base) {
   return OriginalTy;
 }
 
+QualType ArraySectionExpr::getElementType() const {
+  QualType BaseTy = getBase()->IgnoreParenImpCasts()->getType();
+  // We only have to look into the array section exprs, else we will get the
+  // type of the base, which should already be valid.
+  if (auto *ASE = dyn_cast(getBase()->IgnoreParenImpCasts()))
+BaseTy = ASE->getElementType();
+
+  if (BaseTy->isAnyPointerType())
+return BaseTy->getPointeeType();
+  if (BaseTy->isArrayType())
+return BaseTy->castAsArrayTypeUnsafe()->getElementType();
+
+  // If this isn't a pointer or array, the base is a dependent expression, so
+  // just return the BaseTy anyway.
+  assert(BaseTy->isInstantiationDependentType());
+  return BaseTy;
+}
+
+QualType ArraySectionExpr::getBaseType() const {
+  // We only have to look into the array section exprs, else we will get the
+  // type of the base, which should already be valid.
+  if (auto *ASE = dyn_cast(getBase()->IgnoreParenImpCasts()))
+return ASE->getElementType();
+
+  return getBase()->IgnoreParenImpCasts()->getType();
+}
+
 RecoveryExpr::RecoveryExpr(ASTContext &Ctx, QualType T, SourceLocation 
BeginLoc,
SourceLocation EndLoc, ArrayRef SubExprs)
 : Expr(RecoveryExprClass, T.getNonReferenceType(),

diff  --git a/clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp 
b/clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp
index 4cf2237468afd..5ba6bcb192b91 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACC.cpp
@@ -73,7 +73,7 @@ CIRGenFunction::getOpenACCDataOperandInfo(const Expr *e) {
   // Array sections are special, and we have to treat them that way.
   if (const auto *section =
   dyn_cast

[clang] [OpenACC] Sema changes for +*&|^ reduction combiner recipes (PR #162740)

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

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


[clang-tools-extra] [clang-doc] simplify filename selection for namespaces (PR #162885)

2025-10-10 Thread Erick Velez via cfe-commits

https://github.com/evelez7 updated 
https://github.com/llvm/llvm-project/pull/162885

>From 17048c00c229a4ff52e00ce166abf30cc786c882 Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Wed, 8 Oct 2025 18:50:41 -0700
Subject: [PATCH] [clang-doc] simplify filename selection for namespaces

determineFileName was confusing regarding namespaces. The comment and
conditional were both misleading. Now, we just check against a static
global namespace USR to make a file use "index", or just use the name.
---
 clang-tools-extra/clang-doc/JSONGenerator.cpp | 7 +++
 clang-tools-extra/clang-doc/Representation.h  | 3 +++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp 
b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 26794a5e34d02..6fba2114b8c38 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -582,11 +582,10 @@ static SmallString<16> determineFileName(Info *I, 
SmallString<128> &Path) {
   if (I->IT == InfoType::IT_record) {
 auto *RecordSymbolInfo = static_cast(I);
 FileName = RecordSymbolInfo->MangledName;
-  } else if (I->IT == InfoType::IT_namespace && I->Name != "")
-// Serialize the global namespace as index.json
-FileName = I->Name;
+  } else if (I->USR == GlobalNamespaceID)
+FileName = "index";
   else
-FileName = I->getFileBaseName();
+FileName = I->Name;
   sys::path::append(Path, FileName + ".json");
   return FileName;
 }
diff --git a/clang-tools-extra/clang-doc/Representation.h 
b/clang-tools-extra/clang-doc/Representation.h
index 2a75f89696b7d..d8c2b9c0a5842 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -30,6 +30,9 @@ namespace doc {
 // SHA1'd hash of a USR.
 using SymbolID = std::array;
 
+constexpr SymbolID GlobalNamespaceID = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
 struct BaseRecordInfo;
 struct EnumInfo;
 struct FunctionInfo;

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


[clang] [clang][OpenMP] 6.0: Add default clause support for 'target' directive (PR #162910)

2025-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: David Pagan (ddpagan)


Changes

Per OpenMP 6.0 specification, section 7.5.1, default Clause

Page 224, lines 3-5 default Clause, Semantics
  If data-sharing-attribute is shared then the clause has no effect
  on a target construct; otherwise, its effect on a target construct is
  equivalent to specifying the defaultmap clause with the same
  data-sharing-attribute and variable-category.

Testing:
  OpenMP LIT tests
  check-all

---

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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+71-15) 
- (added) clang/test/OpenMP/target_default_codegen.cpp (+1531) 
- (modified) clang/test/OpenMP/target_default_messages.cpp (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 65b086caf3652..15e50d39a706b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -635,6 +635,7 @@ OpenMP Support
 - Added support for ``defaultmap`` directive implicit-behavior ``private``.
 - Added parsing and semantic analysis support for ``groupprivate`` directive.
 - Added support for 'omp fuse' directive.
+- Added support for ``default`` clause on ``target`` directive.
 
 Improvements
 
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 0fa21e89b1236..3416ff2632db6 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -17297,6 +17297,43 @@ OMPClause *SemaOpenMP::ActOnOpenMPSimpleClause(
   return Res;
 }
 
+static std::pair
+getDefaultmapModifierAndKind(llvm::omp::DefaultKind M,
+ OpenMPDefaultClauseVariableCategory VCKind) {
+  OpenMPDefaultmapClauseModifier DefMapMod;
+  OpenMPDefaultmapClauseKind DefMapKind;
+  switch (M) {
+  case OMP_DEFAULT_none:
+DefMapMod = OMPC_DEFAULTMAP_MODIFIER_none;
+break;
+  case OMP_DEFAULT_firstprivate:
+DefMapMod = OMPC_DEFAULTMAP_MODIFIER_firstprivate;
+break;
+  case OMP_DEFAULT_private:
+DefMapMod = OMPC_DEFAULTMAP_MODIFIER_private;
+break;
+  default:
+llvm_unreachable("unexpected DSA in OpenMP default clause");
+  }
+  switch (VCKind) {
+  case OMPC_DEFAULT_VC_aggregate:
+DefMapKind = OMPC_DEFAULTMAP_aggregate;
+break;
+  case OMPC_DEFAULT_VC_pointer:
+DefMapKind = OMPC_DEFAULTMAP_pointer;
+break;
+  case OMPC_DEFAULT_VC_scalar:
+DefMapKind = OMPC_DEFAULTMAP_scalar;
+break;
+  case OMPC_DEFAULT_VC_all:
+DefMapKind = OMPC_DEFAULTMAP_all;
+break;
+  default:
+llvm_unreachable("unexpected variable category in OpenMP default clause");
+  }
+  return std::make_pair(DefMapMod, DefMapKind);
+}
+
 OMPClause *SemaOpenMP::ActOnOpenMPDefaultClause(
 llvm::omp::DefaultKind M, SourceLocation MLoc,
 OpenMPDefaultClauseVariableCategory VCKind, SourceLocation VCKindLoc,
@@ -17309,21 +17346,40 @@ OMPClause *SemaOpenMP::ActOnOpenMPDefaultClause(
 return nullptr;
   }
 
-  switch (M) {
-  case OMP_DEFAULT_none:
-DSAStack->setDefaultDSANone(MLoc);
-break;
-  case OMP_DEFAULT_shared:
-DSAStack->setDefaultDSAShared(MLoc);
-break;
-  case OMP_DEFAULT_firstprivate:
-DSAStack->setDefaultDSAFirstPrivate(MLoc);
-break;
-  case OMP_DEFAULT_private:
-DSAStack->setDefaultDSAPrivate(MLoc);
-break;
-  default:
-llvm_unreachable("DSA unexpected in OpenMP default clause");
+  if (getLangOpts().OpenMP >= 60 &&
+  DSAStack->getCurrentDirective() == OMPD_target) {
+// OpenMP 6.0 (see page 224, lines 3-5) default Clause, Semantics
+// If data-sharing-attribute is shared then the clause has no effect
+// on a target construct; otherwise, its effect on a target construct is
+// equivalent to specifying the defaultmap clause with the same
+// data-sharing-attribute and variable-category.
+if (M != OMP_DEFAULT_shared) {
+  auto [DefMapMod, DefMapKind] = getDefaultmapModifierAndKind(M, VCKind);
+  if (DefMapKind == OMPC_DEFAULTMAP_all) {
+DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_aggregate, 
MLoc);
+DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_scalar, MLoc);
+DSAStack->setDefaultDMAAttr(DefMapMod, OMPC_DEFAULTMAP_pointer, MLoc);
+  } else {
+DSAStack->setDefaultDMAAttr(DefMapMod, DefMapKind, MLoc);
+  }
+}
+  } else {
+switch (M) {
+case OMP_DEFAULT_none:
+  DSAStack->setDefaultDSANone(MLoc);
+  break;
+case OMP_DEFAULT_shared:
+  DSAStack->setDefaultDSAShared(MLoc);
+  break;
+case OMP_DEFAULT_firstprivate:
+  DSAStack->setDefaultDSAFirstPrivate(MLoc);
+  break;
+case OMP_DEFAULT_private:
+  DSAStack->setDefaultDSAPrivate(MLoc);
+  break;
+default:
+  llvm_unreachable("DSA unexpected in OpenMP default clause");
+}
   }
 
   switch (VCKind) {
diff --git a/clang/test/Ope

[clang] [CIR] Add support for virtual destructor calls (PR #162725)

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

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


[clang] [CIR] Upstream CIR Dialect TryOp with Catch Attrs (PR #162897)

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

bcardosolopes wrote:

Is this part of splitting off https://github.com/llvm/llvm-project/pull/162528? 
Might be handy to mention these things in the description.

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


[clang] [CIR] Add inline function attributes (PR #162866)

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

https://github.com/bcardosolopes commented:

Overall looks good, some comments regarding the printing/parsing of the 
attribute

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


[clang] [CIR] Add support for virtual destructor calls (PR #162725)

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

https://github.com/andykaylor updated 
https://github.com/llvm/llvm-project/pull/162725

>From 30e5276cea1cfa2a36f19abe53dcffd1eaa5ad24 Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Thu, 2 Oct 2025 16:15:33 -0700
Subject: [PATCH 1/2] [CIR] Add support for virtual destructor calls

This adds support for calling virtual destructors.
---
 clang/lib/CIR/CodeGen/Address.h   |   7 +
 clang/lib/CIR/CodeGen/CIRGenCXXABI.h  |   9 ++
 clang/lib/CIR/CodeGen/CIRGenClass.cpp |  33 -
 clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp   |  43 --
 clang/lib/CIR/CodeGen/CIRGenFunction.cpp  |   8 +-
 clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp |  31 -
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp |   6 +-
 clang/lib/CIR/CodeGen/CIRGenVTables.cpp   |  10 +-
 .../CIR/CodeGen/virtual-destructor-calls.cpp  | 129 ++
 9 files changed, 252 insertions(+), 24 deletions(-)
 create mode 100644 clang/test/CIR/CodeGen/virtual-destructor-calls.cpp

diff --git a/clang/lib/CIR/CodeGen/Address.h b/clang/lib/CIR/CodeGen/Address.h
index fb74aa0f3bb00..683ff396eb5cb 100644
--- a/clang/lib/CIR/CodeGen/Address.h
+++ b/clang/lib/CIR/CodeGen/Address.h
@@ -90,6 +90,13 @@ class Address {
 return getPointer();
   }
 
+  /// Return the pointer contained in this class after authenticating it and
+  /// adding offset to it if necessary.
+  mlir::Value emitRawPointer() const {
+// TODO(cir): update this class with latest traditional LLVM codegen bits
+return getBasePointer();
+  }
+
   mlir::Type getType() const {
 assert(mlir::cast(
pointerAndKnownNonNull.getPointer().getType())
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
index 06f41cd8fcfdb..6d3741c417351 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
@@ -191,6 +191,15 @@ class CIRGenCXXABI {
   virtual void emitVTableDefinitions(CIRGenVTables &cgvt,
  const CXXRecordDecl *rd) = 0;
 
+  using DeleteOrMemberCallExpr =
+  llvm::PointerUnion;
+
+  virtual mlir::Value emitVirtualDestructorCall(CIRGenFunction &cgf,
+const CXXDestructorDecl *dtor,
+CXXDtorType dtorType,
+Address thisAddr,
+DeleteOrMemberCallExpr e) = 0;
+
   /// Emit any tables needed to implement virtual inheritance.  For Itanium,
   /// this emits virtual table tables.
   virtual void emitVirtualInheritanceTables(const CXXRecordDecl *rd) = 0;
diff --git a/clang/lib/CIR/CodeGen/CIRGenClass.cpp 
b/clang/lib/CIR/CodeGen/CIRGenClass.cpp
index 485b2c86cbc58..dd357ce69f1b3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenClass.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenClass.cpp
@@ -895,6 +895,26 @@ void CIRGenFunction::destroyCXXObject(CIRGenFunction &cgf, 
Address addr,
 }
 
 namespace {
+mlir::Value loadThisForDtorDelete(CIRGenFunction &cgf,
+  const CXXDestructorDecl *dd) {
+  if (Expr *thisArg = dd->getOperatorDeleteThisArg())
+return cgf.emitScalarExpr(thisArg);
+  return cgf.loadCXXThis();
+}
+
+/// Call the operator delete associated with the current destructor.
+struct CallDtorDelete final : EHScopeStack::Cleanup {
+  CallDtorDelete() {}
+
+  void emit(CIRGenFunction &cgf) override {
+const CXXDestructorDecl *dtor = cast(cgf.curFuncDecl);
+const CXXRecordDecl *classDecl = dtor->getParent();
+cgf.emitDeleteCall(dtor->getOperatorDelete(),
+   loadThisForDtorDelete(cgf, dtor),
+   cgf.getContext().getCanonicalTagType(classDecl));
+  }
+};
+
 class DestroyField final : public EHScopeStack::Cleanup {
   const FieldDecl *field;
   CIRGenFunction::Destroyer *destroyer;
@@ -932,7 +952,18 @@ void CIRGenFunction::enterDtorCleanups(const 
CXXDestructorDecl *dd,
   // The deleting-destructor phase just needs to call the appropriate
   // operator delete that Sema picked up.
   if (dtorType == Dtor_Deleting) {
-cgm.errorNYI(dd->getSourceRange(), "deleting destructor cleanups");
+assert(dd->getOperatorDelete() &&
+   "operator delete missing - EnterDtorCleanups");
+if (cxxStructorImplicitParamValue) {
+  cgm.errorNYI(dd->getSourceRange(), "deleting destructor with vtt");
+} else {
+  if (dd->getOperatorDelete()->isDestroyingOperatorDelete()) {
+cgm.errorNYI(dd->getSourceRange(),
+ "deleting destructor with destroying operator delete");
+  } else {
+ehStack.pushCleanup(NormalAndEHCleanup);
+  }
+}
 return;
   }
 
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
index 97c0944fca336..2d11cee38b4c6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprCXX.cpp
@@ -130,13 +130,11 @@ RValue 
CIRGenFunctio

[clang] [clang-installapi] Add test for -Xproject -fvisibility=* (PR #162908)

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

https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/162908

None

>From dcd875807bed0c7da7f3e7ccbed317aa39332ecc Mon Sep 17 00:00:00 2001
From: Cyndy Ishida 
Date: Fri, 10 Oct 2025 12:51:35 -0700
Subject: [PATCH] [clang-installapi] Add test for -Xproject -fvisibility=*

---
 .../project-header-only-args-visibility.test  | 69 +++
 1 file changed, 69 insertions(+)
 create mode 100644 
clang/test/InstallAPI/project-header-only-args-visibility.test

diff --git a/clang/test/InstallAPI/project-header-only-args-visibility.test 
b/clang/test/InstallAPI/project-header-only-args-visibility.test
new file mode 100644
index 0..0403487ae8642
--- /dev/null
+++ b/clang/test/InstallAPI/project-header-only-args-visibility.test
@@ -0,0 +1,69 @@
+; RUN: rm -rf %t
+; RUN: split-file %s %t
+; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
+
+; RUN: clang-installapi \
+; RUN: -target arm64-apple-macos26 -install_name @rpath/libfoo.dylib \
+; RUN: -current_version 1 -compatibility_version 1 \
+; RUN: -Xproject -fvisibility=hidden -I%t/usr/include \
+; RUN: -I%t -dynamiclib  %t/inputs.json \
+; RUN: -o %t/output.tbd 2>&1 | FileCheck %s --allow-empty
+; RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 2>&1 | FileCheck 
%s --allow-empty
+
+; CHECK-NOT: error
+; CHECK-NOT: warning
+
+//--- usr/include/public.h
+int foo(void);
+
+//--- project.h
+int bar(void);
+
+//--- expected.tbd
+{
+  "main_library": {
+"exported_symbols": [
+  {
+"text": {
+  "global": [
+"_foo"
+  ]
+}
+  }
+],
+"flags": [
+  {
+"attributes": [
+  "not_app_extension_safe"
+]
+  }
+],
+"install_names": [
+  {
+"name": "@rpath/libfoo.dylib"
+  }
+],
+"target_info": [
+  {
+"min_deployment": "26",
+"target": "arm64-macos"
+  }
+]
+  },
+  "tapi_tbd_version": 5
+}
+
+;--- inputs.json.in
+{
+  "headers": [ 
+  {
+"path" : "DSTROOT/usr/include/public.h",
+"type" : "public"
+  },
+  {
+"path" : "DSTROOT/project.h",
+"type" : "project"
+  }
+  ],
+  "version": "3"
+}

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


[clang-tools-extra] [clang-doc] create namespace names according to their paths (PR #162886)

2025-10-10 Thread Erick Velez via cfe-commits

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


[clang] Revert "[OpenACC] Sema changes for +*&|^ reduction combiner recipes (… (PR #162920)

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

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


[clang] [CIR] Upstream CIR Dialect TryOp with Catch Attrs (PR #162897)

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


@@ -4296,6 +4296,81 @@ def CIR_AllocExceptionOp : CIR_Op<"alloc.exception"> {
   }];
 }
 
+//===--===//
+// TryOp
+//===--===//
+
+def CIR_TryOp : CIR_Op<"try",[
+  DeclareOpInterfaceMethods,
+  RecursivelySpeculatable, AutomaticAllocationScope, NoRegionArguments
+]> {
+  let summary = "C++ try block";
+  let description = [{
+Holds the lexical scope of `try {}`. Note that resources used on catch
+clauses are usually allocated in the same parent as `cir.try`.
+
+`synthetic`: use `cir.try` to represent try/catches not originally
+present in the source code (e.g. `g = new Class` under `-fexceptions`).

andykaylor wrote:

```suggestion
present in the source code. For example, a synthetic `cir.try` region
is created around the constructor call when `operator new` is used
so that the memory allocated will be freed if the constructor throws
an exception.
```

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


[clang] Convert bf16 to f32 conversions to generic constexpr implementations (PR #162927)

2025-10-10 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [llvm] [OpenMP 60] Update parsing and semantic support for `nowait` clause to accept optional argument (PR #159628)

2025-10-10 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev approved this pull request.


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


[clang] [clang] Remove -g[no-]-* bool flags from g_Group (PR #162750)

2025-10-10 Thread Reid Kleckner via cfe-commits

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


[clang] Convert bf16 to f32 conversions to generic constexpr implementations (PR #162927)

2025-10-10 Thread 100 years of solid poop 🙏 via cfe-commits

https://github.com/wubowski updated 
https://github.com/llvm/llvm-project/pull/162927

From a4014ec1c26f93435cf4982f264ddf96e045b723 Mon Sep 17 00:00:00 2001
From: Jason 
Date: Fri, 10 Oct 2025 16:29:41 -0500
Subject: [PATCH 1/2] Rewrote bf16->f32 conversion intrinsics

---
 clang/lib/Headers/avx512bf16intrin.h   | 12 
 clang/lib/Headers/avx512vlbf16intrin.h | 20 ++--
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/clang/lib/Headers/avx512bf16intrin.h 
b/clang/lib/Headers/avx512bf16intrin.h
index 3973f0e389685..4968136f7c7cd 100644
--- a/clang/lib/Headers/avx512bf16intrin.h
+++ b/clang/lib/Headers/avx512bf16intrin.h
@@ -36,7 +36,7 @@ typedef __bf16 __bfloat16 __attribute__((deprecated("use 
__bf16 instead")));
 /// \returns A float data whose sign field and exponent field keep unchanged,
 ///and fraction field is extended to 23 bits.
 static __inline__ float __DEFAULT_FN_ATTRS _mm_cvtsbh_ss(__bf16 __A) {
-  return __builtin_ia32_cvtsbf162ss_32(__A);
+  return float(__A);
 }
 
 /// Convert Two Packed Single Data to One Packed BF16 Data.
@@ -236,8 +236,7 @@ _mm512_maskz_dpbf16_ps(__mmask16 __U, __m512 __D, __m512bh 
__A, __m512bh __B) {
 ///A 256-bit vector of [16 x bfloat].
 /// \returns A 512-bit vector of [16 x float] come from conversion of __A
 static __inline__ __m512 __DEFAULT_FN_ATTRS512 _mm512_cvtpbh_ps(__m256bh __A) {
-  return _mm512_castsi512_ps((__m512i)_mm512_slli_epi32(
-  (__m512i)_mm512_cvtepi16_epi32((__m256i)__A), 16));
+  return (__m512)__builtin_convertvector(__A, __v16sf);
 }
 
 /// Convert Packed BF16 Data to Packed float Data using zeroing mask.
@@ -252,8 +251,7 @@ static __inline__ __m512 __DEFAULT_FN_ATTRS512 
_mm512_cvtpbh_ps(__m256bh __A) {
 /// \returns A 512-bit vector of [16 x float] come from conversion of __A
 static __inline__ __m512 __DEFAULT_FN_ATTRS512
 _mm512_maskz_cvtpbh_ps(__mmask16 __U, __m256bh __A) {
-  return _mm512_castsi512_ps((__m512i)_mm512_slli_epi32(
-  (__m512i)_mm512_maskz_cvtepi16_epi32((__mmask16)__U, (__m256i)__A), 16));
+  return _mm512_maskz_mov_ps(__U, (__m512)__builtin_convertvector(__A, 
__v16sf));
 }
 
 /// Convert Packed BF16 Data to Packed float Data using merging mask.
@@ -270,9 +268,7 @@ _mm512_maskz_cvtpbh_ps(__mmask16 __U, __m256bh __A) {
 /// \returns A 512-bit vector of [16 x float] come from conversion of __A
 static __inline__ __m512 __DEFAULT_FN_ATTRS512
 _mm512_mask_cvtpbh_ps(__m512 __S, __mmask16 __U, __m256bh __A) {
-  return _mm512_castsi512_ps((__m512i)_mm512_mask_slli_epi32(
-  (__m512i)__S, (__mmask16)__U,
-  (__m512i)_mm512_cvtepi16_epi32((__m256i)__A), 16));
+  return _mm512_mask_mov_ps(__S, __U, (__m512)__builtin_convertvector(__A, 
__v16sf));
 }
 
 #undef __DEFAULT_FN_ATTRS
diff --git a/clang/lib/Headers/avx512vlbf16intrin.h 
b/clang/lib/Headers/avx512vlbf16intrin.h
index 2d7ea0114d6a5..a06a4bd8923f5 100644
--- a/clang/lib/Headers/avx512vlbf16intrin.h
+++ b/clang/lib/Headers/avx512vlbf16intrin.h
@@ -422,8 +422,7 @@ static __inline__ __bf16 __DEFAULT_FN_ATTRS128 
_mm_cvtness_sbh(float __A) {
 ///A 128-bit vector of [4 x bfloat].
 /// \returns A 128-bit vector of [4 x float] come from conversion of __A
 static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) {
-  return _mm_castsi128_ps(
-  (__m128i)_mm_slli_epi32((__m128i)_mm_cvtepi16_epi32((__m128i)__A), 16));
+  return (__m128)__builtin_convertvector(__A, __v4sf);
 }
 
 /// Convert Packed BF16 Data to Packed float Data.
@@ -434,8 +433,7 @@ static __inline__ __m128 __DEFAULT_FN_ATTRS128 
_mm_cvtpbh_ps(__m128bh __A) {
 ///A 128-bit vector of [8 x bfloat].
 /// \returns A 256-bit vector of [8 x float] come from conversion of __A
 static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_cvtpbh_ps(__m128bh __A) {
-  return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32(
-  (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), 16));
+  return (__m256)__builtin_convertvector(__A, __v8sf);
 }
 
 /// Convert Packed BF16 Data to Packed float Data using zeroing mask.
@@ -450,8 +448,7 @@ static __inline__ __m256 __DEFAULT_FN_ATTRS256 
_mm256_cvtpbh_ps(__m128bh __A) {
 /// \returns A 128-bit vector of [4 x float] come from conversion of __A
 static __inline__ __m128 __DEFAULT_FN_ATTRS128
 _mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) {
-  return _mm_castsi128_ps((__m128i)_mm_slli_epi32(
-  (__m128i)_mm_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16));
+  return __mm_maskz_mov_ps(__U, (__m128)__builtin_convertvector(__A, __v4sf));
 }
 
 /// Convert Packed BF16 Data to Packed float Data using zeroing mask.
@@ -466,8 +463,7 @@ _mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) {
 /// \returns A 256-bit vector of [8 x float] come from conversion of __A
 static __inline__ __m256 __DEFAULT_FN_ATTRS256
 _mm256_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) {
-  return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32(
-  (__m256i)_mm256_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16));
+

[clang] [Clang][Sema] Fix crash in CheckUsingDeclQualifier due to diagnostic missing an argument (PR #161277)

2025-10-10 Thread Richard Smith via cfe-commits


@@ -430,3 +434,15 @@ void ctad_test() {
   CTAD t = s; // expected-warning {{class template argument deduction is 
incompatible with C++ standards before C++17}}
 }
 #endif
+
+namespace GH161702 {
+struct S {
+  enum E { A };
+  using E::A; // expected-warning {{enumeration type in nested name specifier 
is incompatible with C++98}}
+#ifndef CXX20COMPAT 

zygoloid wrote:

I think this was just an oversight -- that change also added a distinct 
compatibility warning for `explicit(bool)`, and was probably trying to avoid 
issuing two warnings for the same thing by disabling the existing warning in 
C++20 mode, but went too far. Disabling the `explicit` conversion function 
warning in the case of `explicit(bool)` is probably the right thing to do 
instead of disabling it in C++20.

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


[clang] [clang] add no-op __builtin_static_analysis_assume (PR #162939)

2025-10-10 Thread Florian Mayer via cfe-commits

https://github.com/fmayer created 
https://github.com/llvm/llvm-project/pull/162939

This builtin can be used by user code to communicate with static
analyis tools (e.g. clang-tidy or clang-static-analyzer). Because the
arguments are unevaluated, it is suitable for use in macros, where
evaluating the same expression multiple times can change program
semantics.

RFC: https://discourse.llvm.org/t/rfc-builtin-static-analysis-assume/88544


>From 8c84fe63aac839472e4dff7e5daca03c1cb4ab8f Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Fri, 10 Oct 2025 16:08:14 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/include/clang/Basic/Builtins.td |  6 +
 clang/lib/CodeGen/CGBuiltin.cpp   |  2 ++
 .../test/AST/builtin-static-analysis-assume.c | 22 +++
 .../CodeGen/builtin-static-analysis-assume.c  | 17 ++
 .../Sema/builtin-static-analysis-assume.cpp   | 14 
 5 files changed, 61 insertions(+)
 create mode 100644 clang/test/AST/builtin-static-analysis-assume.c
 create mode 100644 clang/test/CodeGen/builtin-static-analysis-assume.c
 create mode 100644 clang/test/Sema/builtin-static-analysis-assume.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 792e2e07ec594..4f0e9129d98aa 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -5253,3 +5253,9 @@ def CountedByRef : Builtin {
   let Attributes = [NoThrow, CustomTypeChecking];
   let Prototype = "int(...)";
 }
+
+def StaticAnalysisAssume : Builtin {
+  let Spellings = ["__builtin_static_analysis_assume"];
+  let Attributes = [NoThrow, Const, Pure, UnevaluatedArguments];
+  let Prototype = "void(bool)";
+}
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9ee810c9d5775..34e6b512d20c6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3733,6 +3733,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 
 return RValue::get(Result);
   }
+  case Builtin::BI__builtin_static_analysis_assume:
+return RValue::get(nullptr);
   case Builtin::BI__builtin_prefetch: {
 Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0));
 // FIXME: Technically these constants should of type 'int', yes?
diff --git a/clang/test/AST/builtin-static-analysis-assume.c 
b/clang/test/AST/builtin-static-analysis-assume.c
new file mode 100644
index 0..ac544be49ab90
--- /dev/null
+++ b/clang/test/AST/builtin-static-analysis-assume.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -ast-dump -triple x86_64-linux-gnu %s \
+// RUN: | FileCheck %s --strict-whitespace --check-prefixes=CHECK
+//
+// Tests with serialization:
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -include-pch %t -ast-dump-all 
/dev/null \
+// RUN: | FileCheck %s --strict-whitespace
+
+int fun() {
+int x = 0;
+__builtin_static_analysis_assume(++x >= 1);
+return x;
+}
+
+// CHECK: |-CallExpr {{.*}}  'void'
+// CHECK: | |-ImplicitCastExpr {{.*}}  'void (*)(_Bool)' 

+// CHECK: | | `-DeclRefExpr {{.*}}  '' Function {{.*}} 
'__builtin_static_analysis_assume' 'void (_Bool)'
+// CHECK: | `-ImplicitCastExpr {{.*}}  '_Bool' 

+// CHECK: |   `-BinaryOperator {{.*}}  'int' '>='
+// CHECK: | |-UnaryOperator {{.*}}  'int' prefix '++'
+// CHECK: | | `-DeclRefExpr {{.*}}  'int' lvalue Var {{.*}} 'x' 
'int'
+// CHECK: | `-IntegerLiteral {{.*}}  'int' 1
diff --git a/clang/test/CodeGen/builtin-static-analysis-assume.c 
b/clang/test/CodeGen/builtin-static-analysis-assume.c
new file mode 100644
index 0..e73c2371be3b9
--- /dev/null
+++ b/clang/test/CodeGen/builtin-static-analysis-assume.c
@@ -0,0 +1,17 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 6
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefix CHECK %s
+
+// CHECK-LABEL: define dso_local i32 @fun(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[X:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, ptr [[X]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:ret i32 [[TMP0]]
+//
+int fun() {
+int x = 0;
+__builtin_static_analysis_assume(++x >= 1);
+return x;
+}
diff --git a/clang/test/Sema/builtin-static-analysis-assume.cpp 
b/clang/test/Sema/builtin-static-analysis-assume.cpp
new file mode 100644
index 0..3293e2ab15c55
--- /dev/null
+++ b/clang/test/Sema/builtin-static-analysis-assume.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+
+void voidfn();
+
+class Foo{};
+
+int fun() {
+int x = 0;
+

[clang] [llvm] [DebugInfo] Place local ODR-uniqued types in decl DISubprograms (PR #142166)

2025-10-10 Thread David Blaikie via cfe-commits

dwblaikie wrote:

I will say, partly as I'm not as heavily involved in debug info anymore, and 
partly as this work is getting more involved - I'm losing my grasp on all the 
details, but doing my best to help - just fair warning that you're getting out 
into pretty unmarked territory & just going to take the adventure and see what 
happens... 

I think it sounds roughly plausible - the perf issue I wouldn't /expect/ to be 
a problem, there's probably a lot more types (in a full debug info build at 
least) than functions (hmm, well, actually hard to say - guess it could go 
either way) & I guess it's well enough optimized it hopefully won't show up in 
profiles or the like.

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


[clang] [libunwind] [llvm] [wasm] Toolchain support for `wasm32-wali-linux-musl` target (PR #156087)

2025-10-10 Thread Arjun Ramesh via cfe-commits

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


[clang] 3149a77 - [CIR] Implement DesignatedInitUpdateExpr for AggregateExpr (#161897)

2025-10-10 Thread via cfe-commits

Author: Amr Hesham
Date: 2025-10-05T11:38:27Z
New Revision: 3149a7720f714c14f7e6320745d9e35f49dba62b

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

LOG: [CIR] Implement DesignatedInitUpdateExpr for AggregateExpr (#161897)

Implement the DesignatedInitUpdateExpr support for AggregateExpr

Added: 


Modified: 
clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
clang/test/CIR/CodeGen/struct.cpp

Removed: 




diff  --git a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
index e51c3fcdef962..60ccf18b743df 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
@@ -201,8 +201,10 @@ class AggExprEmitter : public StmtVisitor {
   }
 
   void VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *e) {
-cgf.cgm.errorNYI(e->getSourceRange(),
- "AggExprEmitter: VisitDesignatedInitUpdateExpr");
+AggValueSlot dest = ensureSlot(cgf.getLoc(e->getExprLoc()), e->getType());
+LValue destLV = cgf.makeAddrLValue(dest.getAddress(), e->getType());
+emitInitializationToLValue(e->getBase(), destLV);
+VisitInitListExpr(e->getUpdater());
   }
   void VisitAbstractConditionalOperator(const AbstractConditionalOperator *e) {
 cgf.cgm.errorNYI(e->getSourceRange(),

diff  --git a/clang/test/CIR/CodeGen/struct.cpp 
b/clang/test/CIR/CodeGen/struct.cpp
index c68f7426661b5..263799f8a5deb 100644
--- a/clang/test/CIR/CodeGen/struct.cpp
+++ b/clang/test/CIR/CodeGen/struct.cpp
@@ -184,6 +184,39 @@ void generic_selection() {
 // OGCG:   %[[D_ADDR:.*]] = alloca %struct.CompleteS, align 4
 // OGCG:   call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[D_ADDR]], ptr align 
4 %[[A_ADDR]], i64 8, i1 false)
 
+void designated_init_update_expr() {
+  CompleteS a;
+
+  struct Container {
+CompleteS c;
+  } b = {a, .c.a = 1};
+}
+
+// CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr, 
["a"]
+// CIR: %[[B_ADDR:.*]] = cir.alloca !rec_Container, !cir.ptr, 
["b", init]
+// CIR: %[[C_ADDR:.*]] = cir.get_member %[[B_ADDR]][0] {name = "c"} : 
!cir.ptr -> !cir.ptr
+// CIR: cir.call @_ZN9CompleteSC1ERKS_(%2, %[[A_ADDR]]) nothrow : 
(!cir.ptr, !cir.ptr) -> ()
+// CIR: %[[ELEM_0_PTR:.*]] = cir.get_member %[[C_ADDR]][0] {name = "a"} : 
!cir.ptr -> !cir.ptr
+// CIR: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[CONST_1]], %[[ELEM_0_PTR]] : !s32i, !cir.ptr
+// CIR: %[[ELEM_1_PTR:.*]] = cir.get_member %[[C_ADDR]][1] {name = "b"} : 
!cir.ptr -> !cir.ptr
+
+// LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
+// LLVM: %[[B_ADDR:.*]] = alloca %struct.Container, i64 1, align 4
+// LLVM: %[[C_ADDR:.*]] = getelementptr %struct.Container, ptr %[[B_ADDR]], 
i32 0, i32 0
+// LLVM: call void @_ZN9CompleteSC1ERKS_(ptr %[[C_ADDR]], ptr %[[A_ADDR]])
+// LLVM: %[[ELEM_0_PTR:.*]] = getelementptr %struct.CompleteS, ptr 
%[[C_ADDR]], i32 0, i32 0
+// LLVM: store i32 1, ptr %[[ELEM_0_PTR]], align 4
+// LLVM: %[[ELEM_1_PTR:.*]] = getelementptr %struct.CompleteS, ptr 
%[[C_ADDR]], i32 0, i32 1
+
+// OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
+// OGCG: %[[B_ADDR:.*]] = alloca %struct.Container, align 4
+// OGCG: %[[C_ADDR:.*]] = getelementptr inbounds nuw %struct.Container, ptr 
%[[B_ADDR]], i32 0, i32 0
+// OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[C_ADDR]], ptr align 4 
%[[A_ADDR]], i64 8, i1 false)
+// OGCG: %[[ELEM_0_PTR:.*]] = getelementptr inbounds nuw %struct.CompleteS, 
ptr %[[C_ADDR]], i32 0, i32 0
+// OGCG: store i32 1, ptr %[[ELEM_0_PTR]], align 4
+// OGCG: %[[ELEM_1_PTR:.*]] = getelementptr inbounds nuw %struct.CompleteS, 
ptr %[[C_ADDR]], i32 0, i32 1
+
 void atomic_init() {
   _Atomic CompleteS a;
   __c11_atomic_init(&a, {});



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


[clang] [HIP][SPIRV] Enable the SPIRV backend instead of the translator through an experimental flag. (PR #162282)

2025-10-10 Thread Shilei Tian via cfe-commits


@@ -0,0 +1,12 @@
+// COM: This test case validates the behavior of 
-hip-use-experimental-spirv-backend

shiltian wrote:

No need to use `COM:` prefix for comments.

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


[clang] [Clang] Fix a regression introduced by #161163. (PR #162612)

2025-10-10 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

Looks like your new test cases with `MultipleDefaults` pass even on the 
previous code revision (with `!RD->hasNonTrivialDefaultConstructor()` call).

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


[clang] [C2y] Support WG14 N3457, the __COUNTER__ macro (PR #162662)

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

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

>From 7a5e159aceef541c054a53f6508cdb7fdd9af04d Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Thu, 9 Oct 2025 10:12:55 -0400
Subject: [PATCH 1/7] [C2y] Support WG14 N3457, the __COUNTER__ macro

This implements the parts of 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm
which were adopted at the recent meeting in Brno.

Clang already implemented __COUNTER__, but needed some changes for
conformance. Specifically, we now diagnose when the macro is expanded
more than 2147483647 times. Additionally, we now give the expected
extension and pre-compat warnings for the feature.

To support testing the limits, this also adds a -cc1-only option,
-finitial-counter-value=, which lets you specify the initial value the
__COUNTER__ macro should expand to.
---
 clang/docs/LanguageExtensions.rst |  4 +-
 clang/docs/ReleaseNotes.rst   |  5 +++
 .../include/clang/Basic/DiagnosticLexKinds.td |  8 
 clang/include/clang/Driver/Options.td |  4 ++
 clang/include/clang/Lex/Preprocessor.h|  6 +--
 clang/include/clang/Lex/PreprocessorOptions.h |  4 ++
 clang/include/clang/Serialization/ASTReader.h |  8 ++--
 clang/lib/Frontend/ASTUnit.cpp|  9 +++--
 clang/lib/Frontend/InitPreprocessor.cpp   |  3 ++
 clang/lib/Lex/PPMacroExpansion.cpp| 13 ++-
 clang/lib/Serialization/ASTReader.cpp |  4 +-
 clang/test/C/C2y/n3457.c  | 37 +++
 clang/test/C/C2y/n3457_1.c| 20 ++
 clang/test/C/C2y/n3457_2.c| 10 +
 clang/www/c_status.html   |  2 +-
 15 files changed, 122 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/C/C2y/n3457.c
 create mode 100644 clang/test/C/C2y/n3457_1.c
 create mode 100644 clang/test/C/C2y/n3457_2.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 6bb99c757cd19..54c215e9ccfaa 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -385,7 +385,9 @@ Builtin Macros
 
 ``__COUNTER__``
   Defined to an integer value that starts at zero and is incremented each time
-  the ``__COUNTER__`` macro is expanded.
+  the ``__COUNTER__`` macro is expanded. This is a standard feature in C2y but
+  is an extension in earlier language modes and in C++. This macro can only be
+  expanded 2147483647 times at most.
 
 ``__INCLUDE_LEVEL__``
   Defined to an integral value that is the include depth of the file currently
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5e9a71e1e74d6..37e02e9638296 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -181,6 +181,11 @@ C Language Changes
 C2y Feature Support
 ^^^
 - Clang now supports `N3355 
`_ Named Loops.
+- Clang's implementation of ``__COUNTER__`` was updated to conform to
+  `WG14 N3457 `_.
+  This includes adding pedantic warnings for the feature being an extension in
+  other language modes as well as an error when the counter is expanded more
+  than 2147483647 times.
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index c7fe6e1db6d1f..46a7a88f7a50b 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -90,6 +90,14 @@ def err_unterminated___pragma : Error<"missing terminating 
')' character">;
 
 def err_conflict_marker : Error<"version control conflict marker in file">;
 
+def err_counter_overflow : Error<
+  "'__COUNTER__' value cannot exceed 2147483647">;
+def ext_counter : Extension<
+  "'__COUNTER__' is a C2y extension">, InGroup;
+def warn_counter : Warning<
+  "'__COUNTER__' is incompatible with standards before C2y">,
+  InGroup, DefaultIgnore;
+
 def err_raw_delim_too_long : Error<
   "raw string delimiter longer than 16 characters"
   "; use PREFIX( )PREFIX to delimit raw string">;
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8e96e125733c..2511f88f4e53c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8417,6 +8417,10 @@ def aligned_alloc_unavailable : Flag<["-"], 
"faligned-alloc-unavailable">,
   MarshallingInfoFlag>,
   ShouldParseIf;
 
+def finitial_counter_value_EQ : Joined<["-"], "finitial-counter-value=">,
+  HelpText<"Sets the initial value for __COUNTER__, defaults to 0.">,
+  MarshallingInfoInt, "0">;
+
 } // let Visibility = [CC1Option]
 
 
//===--===//
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 39754847a93e

[clang] [clang][analyzer] Print empty per-EP metrics as empty CSV cells, fix missing PathRunningTime metric (PR #162839)

2025-10-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Arseniy Zaostrovnykh (necto)


Changes

To avoid information loss, introduce a difference between unset stats and 0 for 
statistics that are supposed to be set once per entry point. Now, if the 
statistic is not set for an entry point, the corresponding CSV cell will be 
empty, and not 0.

Thanks to this differentiation, I noticed that `PathRunningTime` was actually 
never set, and fixed that.
Additionally, this patch enables the timers if `DumpEntryPointStatsToCSV` is 
set, because in most cases you dump these stats to get a detailed view on 
analyzer performance.

Finally, I added a dedicated debug checker that demonstrates the use of a 
statistic and tested the set and unset scenarios explicitly.

--

CPP-7097

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


8 Files Affected:

- (modified) clang/docs/analyzer/developer-docs/Statistics.rst (+1-1) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+4) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (+1) 
- (added) clang/lib/StaticAnalyzer/Checkers/UnsignedStatTesterChecker.cpp (+59) 
- (modified) clang/lib/StaticAnalyzer/Core/EntryPointStats.cpp (+49-20) 
- (modified) clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (+4-1) 
- (modified) clang/test/Analysis/analyzer-stats/entry-point-stats.cpp (+33-16) 


``diff
diff --git a/clang/docs/analyzer/developer-docs/Statistics.rst 
b/clang/docs/analyzer/developer-docs/Statistics.rst
index 4f2484a89a6af..355759d468282 100644
--- a/clang/docs/analyzer/developer-docs/Statistics.rst
+++ b/clang/docs/analyzer/developer-docs/Statistics.rst
@@ -22,7 +22,7 @@ However, note that with ``LLVM_ENABLE_STATS`` disabled, only 
storage of the valu
 If you want to define a statistic only for entry point, EntryPointStats.h has 
four classes at your disposal:
 
 
-- ``UnsignedEPStat`` - an unsigned value assigned at most once per entry 
point. For example: "the number of source characters in an entry-point body".
+- ``UnsignedEPStat`` - an unsigned value assigned at most once per entry 
point. For example: "the number of source characters in an entry-point body". 
If no value is assigned during analysis of an entry point, the corresponding 
CSV cell will be empty.
 - ``CounterEPStat`` - an additive statistic. It starts with 0 and you can add 
to it as many times as needed. For example: "the number of bugs discovered".
 - ``UnsignedMaxEPStat`` - a maximizing statistic. It starts with 0 and when 
you join it with a value, it picks the maximum of the previous value and the 
new one. For example, "the longest execution path of a bug".
 
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 4473c54d8d6e3..0db6794b2310a 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1502,6 +1502,10 @@ def TaintTesterChecker : Checker<"TaintTest">,
   HelpText<"Mark tainted symbols as such.">,
   Documentation;
 
+def UnsignedStatTesterChecker : Checker<"UnsignedStatTester">,
+  HelpText<"Test checker for demonstrating UnsignedEPStat usage.">,
+  Documentation;
+
 // This checker *technically* depends on SteamChecker, but we don't allow
 // dependency checkers to emit diagnostics, and a debug checker isn't worth
 // the chore needed to create a modeling portion on its own. Since this checker
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
index 389f17d36e65a..0a45deb33fcc9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/EntryPointStats.h
@@ -85,7 +85,7 @@ class UnsignedEPStat : public EntryPointStat {
 
 public:
   explicit UnsignedEPStat(llvm::StringLiteral Name);
-  unsigned value() const { return Value.value_or(0); }
+  std::optional value() const { return Value; }
   void reset() { Value.reset(); }
   void set(unsigned V) {
 assert(!Value.has_value());
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 29d2c4512d470..f70ae1a3e8a96 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -125,6 +125,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   UninitializedObject/UninitializedPointee.cpp
   UnixAPIChecker.cpp
   UnreachableCodeChecker.cpp
+  UnsignedStatTesterChecker.cpp
   VforkChecker.cpp
   VLASizeChecker.cpp
   VAListChecker.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/UnsignedStatTesterChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/UnsignedStatTesterChecker.cpp
new file mode 100644
index 000