[clang] [clang] Track final substitution for Subst* AST nodes (PR #132748)

2025-04-05 Thread Thurston Dang via cfe-commits

thurstond wrote:

If it is not quick and easy to fix forward, please consider reverting in the 
meantime, so that the buildbots can be green and provide useful feedback to 
contributors. Thanks!

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


[clang] [llvm] Remove Native Client support (PR #133661)

2025-04-05 Thread Fangrui Song via cfe-commits

MaskRay wrote:

> Thanks for working on this! This will be the first time I'm not going to 
> oppose an effort to remove Native Client support 🎉 Although I am going to ask 
> you to wait a couple of months to land it, until we finally turn it off for 
> good and start deleting the support code from Chromium. This is planned after 
> the M139 branch in late June. I will also give this a good review.

Is it feasible to remove ARM and MIPS support earlier? (Also make the PR 
smaller)

> @MaskRay Another thing I wanted to ask about was there were some tests I 
> removed with nacl in the name that used nacl triples as well as 
> rodata-section.s. I am not sure if any of them are still relevant outside of 
> a nacl environment. Should they be renamed and use a different triple or any 
> other changes?

`test/MC/X86/AlignedBundling` is for an assembler extension only used by nacl. 
Should be fine to remove `test/MC/X86/AlignedBundling/rodata-section.s`

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


[clang] [clang-sycl-linker] Fix flaky failure and add REQUIRES (PR #134125)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-win-fast` running on `as-builder-3` while building `clang` 
at step 6 "build-unified-tree".

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


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

```
Step 6 (build-unified-tree) failure: build (failure)
...
[4153/4173] Linking CXX executable bin\clang-scan-deps.exe
[4154/4173] Linking CXX executable bin\clang-refactor.exe
[4155/4173] Linking CXX executable bin\clang-extdef-mapping.exe
[4156/4173] Linking CXX executable bin\clang-installapi.exe
[4157/4173] Linking CXX executable bin\clang-nvlink-wrapper.exe
[4158/4173] Linking CXX shared library bin\LTO.dll
[4159/4173] Linking CXX executable bin\llvm-reduce.exe
[4160/4173] Linking CXX executable bin\opt.exe
[4161/4173] Linking CXX shared library bin\libclang.dll
[4162/4173] Building CXX object 
tools\clang\tools\clang-sycl-linker\CMakeFiles\clang-sycl-linker.dir\ClangSYCLLinker.cpp.obj
FAILED: 
tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.obj
 
C:\ninja\ccache.exe 
C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1438~1.331\bin\Hostx64\x64\cl.exe
  /nologo /TP -DCLANG_BUILD_STATIC -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC 
-DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\tools\clang\tools\clang-sycl-linker
 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\tools\clang-sycl-linker
 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\include
 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\tools\clang\include 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\build\include 
-IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include 
/DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj 
/permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 
-wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 
-wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 
-wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 
-wd4275 -w14062 -we4238 /Gw /O2 /Ob2 /DNDEBUG -MD  /EHs-c- /GR- -std:c++17 
/showIncludes 
/Fotools\clang\tools\clang-sycl-linker\CMakeFiles\clang-sycl-linker.dir\ClangSYCLLinker.cpp.obj
 /Fdtools\clang\tools\clang-sycl-linker\CMakeFiles\clang-sycl-linker.dir\ /FS 
-c 
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\tools\clang-sycl-linker\ClangSYCLLinker.cpp
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\tools\clang-sycl-linker\ClangSYCLLinker.cpp(285):
 error C2065: 'M': undeclared identifier
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\tools\clang-sycl-linker\ClangSYCLLinker.cpp(285):
 error C2248: 'llvm::Error::Error': cannot access protected member declared in 
class 'llvm::Error'
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include\llvm/Support/Error.h(181):
 note: see declaration of 'llvm::Error::Error'
C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include\llvm/Support/WithColor.h(17):
 note: see declaration of 'llvm::Error'
[4163/4173] Linking CXX executable bin\clang-import-test.exe
[4164/4173] Linking CXX executable bin\clang-check.exe
[4165/4173] Linking CXX executable bin\c-index-test.exe
[4166/4173] Linking CXX executable bin\clang-repl.exe
[4167/4173] Linking CXX executable bin\clang.exe
[4168/4173] Generating export list for LLVM-C
ninja: build stopped: subcommand failed.

```



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


[clang] [clang] ASTContext: flesh out implementation of getCommonNNS (PR #131964)

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

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


[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

2025-04-05 Thread Alex Voicu via cfe-commits


@@ -15576,6 +15609,38 @@ static bool isOverflowingIntegerType(ASTContext &Ctx, 
QualType T) {
   return Ctx.getIntWidth(T) >= Ctx.getIntWidth(Ctx.IntTy);
 }
 
+static Expr *ExpandAMDGPUPredicateBI(ASTContext &Ctx, CallExpr *CE) {
+  if (!CE->getBuiltinCallee())
+return CXXBoolLiteralExpr::Create(Ctx, false, Ctx.BoolTy, 
CE->getExprLoc());
+
+  if (Ctx.getTargetInfo().getTriple().isSPIRV()) {
+CE->setType(Ctx.getLogicalOperationType());
+return CE;
+  }
+
+  bool P = false;
+  auto &TI = Ctx.getTargetInfo();
+
+  if (CE->getDirectCallee()->getName() == "__builtin_amdgcn_processor_is") {

AlexVlx wrote:

These are both true, and I thank you for the feedback. As a relatively weak 
retort, I will note that:
- I went for the names because it felt a bit icky to add the AMDGPU specific 
builtin header, considering we're trying to limit the scope of these; also I 
did not feel confident enough to make these generic Clang BIs (for good reason, 
as the review shows:));
- The call to this function comes after having already checked that the Callee 
is one of the predicates, `IsAMDGPUPredicateBI` and `ValidateAMDGPUPredicateBI` 
get called before, so the precondition that we are indeed dealing with the 
magical BIs is established; furthermore, we're already checking upon entry that 
the Callee is indeed a builtin, and I *believe* that builtins always have 
non-elaborated names which can always be obtained via getName - I could be 
wrong here.
Having said that, using the Builtin IDs would indeed be nicer, so I can switch 
to that, thank you for the suggestion.

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


[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)

2025-04-05 Thread Ilya Biryukov via cfe-commits


@@ -49,6 +51,135 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry)
 
 namespace {
 
+/// Dumps deserialized declarations.
+class DeserializedDeclsLineRangePrinter : public 
DelegatingDeserializationListener, public ASTConsumer {
+public:
+  explicit DeserializedDeclsLineRangePrinter(SourceManager &SM, 
std::unique_ptr OS)
+  : DelegatingDeserializationListener(nullptr, false), SM(SM), 
OS(std::move(OS)) {}

ilya-biryukov wrote:

SG! I have missed the fact the `ASTConsumer` can have a deserialization 
listener attached to it and there is logic in Clang to handle that. The 
approach SG.

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


[libclc] [libclc] Fix unresolved reference to missing table (PR #133691)

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

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/133691

Splitting the 'ln_tbl' into two in db98e292 wasn't done thoroughly enough as 
some references to the old table still remained. This commit fixes the 
unresolved references by updating to the new split table.

>From 4e9bc686e6cd0654dce488177af21056e1f1fe59 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 31 Mar 2025 10:43:43 +0100
Subject: [PATCH] [libclc] Fix unresolved reference to missing table

Splitting the 'ln_tbl' into two in db98e292 wasn't done thoroughly
enough as some references to the old table still remained. This commit
fixes the unresolved references by updating to the new split table.
---
 libclc/clc/include/clc/math/tables.h   | 1 -
 libclc/clc/lib/generic/math/clc_log_base.h | 5 ++---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libclc/clc/include/clc/math/tables.h 
b/libclc/clc/include/clc/math/tables.h
index f2118082b1bdb..3120a18cc996e 100644
--- a/libclc/clc/include/clc/math/tables.h
+++ b/libclc/clc/include/clc/math/tables.h
@@ -78,7 +78,6 @@ CLC_TABLE_FUNCTION_DECL(float, exp_tbl_ep_tail);
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
-TABLE_FUNCTION_DECL(double2, ln_tbl);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_lo);
 CLC_TABLE_FUNCTION_DECL(double, ln_tbl_hi);
 CLC_TABLE_FUNCTION_DECL(double, atan_jby256_tbl_head);
diff --git a/libclc/clc/lib/generic/math/clc_log_base.h 
b/libclc/clc/lib/generic/math/clc_log_base.h
index 7d084c037f67e..9418535db827d 100644
--- a/libclc/clc/lib/generic/math/clc_log_base.h
+++ b/libclc/clc/lib/generic/math/clc_log_base.h
@@ -261,9 +261,8 @@ __clc_log(double x)
   int index = __clc_as_int2(ux).hi >> 13;
   index = ((0x80 | (index & 0x7e)) >> 1) + (index & 0x1);
 
-  double2 tv = USE_TABLE(ln_tbl, index - 64);
-  double z1 = tv.s0;
-  double q = tv.s1;
+  double z1 = USE_TABLE(ln_tbl_lo, index - 64);
+  double q = USE_TABLE(ln_tbl_hi, index - 64);
 
   double f1 = index * 0x1.0p-7;
   double f2 = f - f1;

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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-04-05 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat updated 
https://github.com/llvm/llvm-project/pull/132250

From d4878a62a69304dc2ae32902803f8c8efb1c69ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Thu, 20 Mar 2025 17:09:46 +0100
Subject: [PATCH 1/3] [NFC][analyzer] Multipart checker refactor 2:
 NullabilityChecker

Simplify `NullabilityChecker.cpp` with new multipart checker framework
introduced in 27099982da2f5a6c2d282d6b385e79d080669546. This is part of
a commit series that will perform analogous changes in all checker
classes that implement multiple user-facing checker parts (with separate
names).
---
 .../Checkers/NullabilityChecker.cpp   | 157 +-
 1 file changed, 81 insertions(+), 76 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
index 04472bb3895a7..8fe7d21ca7984 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -112,25 +112,38 @@ class NullabilityChecker
   void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
   const char *Sep) const override;
 
-  enum CheckKind {
-CK_NullPassedToNonnull,
-CK_NullReturnedFromNonnull,
-CK_NullableDereferenced,
-CK_NullablePassedToNonnull,
-CK_NullableReturnedFromNonnull,
-CK_NumCheckKinds
+  // FIXME: This enumeration of checker parts is extremely similar to the
+  // ErrorKind enum. It would be nice to unify them to simplify the code.
+  // FIXME: The modeling checker NullabilityBase is a dummy "empty checker
+  // part" that registers this checker class without enabling any of the real
+  // checker parts. As far as I understand no other checker references it, so
+  // it should be removed.
+  enum : CheckerPartIdx {
+NullabilityBase,
+NullPassedToNonnullChecker,
+NullReturnedFromNonnullChecker,
+NullableDereferencedChecker,
+NullablePassedToNonnullChecker,
+NullableReturnedFromNonnullChecker,
+NumCheckerParts
   };
 
-  bool ChecksEnabled[CK_NumCheckKinds] = {false};
-  CheckerNameRef CheckNames[CK_NumCheckKinds];
-  mutable std::unique_ptr BTs[CK_NumCheckKinds];
-
-  const std::unique_ptr &getBugType(CheckKind Kind) const {
-if (!BTs[Kind])
-  BTs[Kind].reset(new BugType(CheckNames[Kind], "Nullability",
-  categories::MemoryError));
-return BTs[Kind];
-  }
+  // FIXME: Currently the `Description` fields of these `BugType`s are all
+  // identical ("Nullability") -- they should be more descriptive than this.
+  // NOTE: NullabilityBase is a dummy checker part that does nothing, so its
+  // bug type is left empty.
+  BugType BugTypes[NumCheckerParts] = {
+  {this, NullabilityBase, "", ""},
+  {this, NullPassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableDereferencedChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullablePassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError}};
 
   // When set to false no nullability information will be tracked in
   // NullabilityMap. It is possible to catch errors like passing a null pointer
@@ -163,17 +176,16 @@ class NullabilityChecker
   ///
   /// When \p SuppressPath is set to true, no more bugs will be reported on 
this
   /// path by this checker.
-  void reportBugIfInvariantHolds(StringRef Msg, ErrorKind Error, CheckKind CK,
- ExplodedNode *N, const MemRegion *Region,
- CheckerContext &C,
+  void reportBugIfInvariantHolds(StringRef Msg, ErrorKind Error,
+ CheckerPartIdx Idx, ExplodedNode *N,
+ const MemRegion *Region, CheckerContext &C,
  const Stmt *ValueExpr = nullptr,
  bool SuppressPath = false) const;
 
-  void reportBug(StringRef Msg, ErrorKind Error, CheckKind CK, ExplodedNode *N,
- const MemRegion *Region, BugReporter &BR,
+  void reportBug(StringRef Msg, ErrorKind Error, CheckerPartIdx Idx,
+ ExplodedNode *N, const MemRegion *Region, BugReporter &BR,
  const Stmt *ValueExpr = nullptr) const {
-const std::unique_ptr &BT = getBugType(CK);
-auto R = std::make_unique(*BT, Msg, N);
+auto R = std::make_unique(BugTypes[Idx], Msg, N);
 if (Region) {
   R->markInteresting(Region);
   R->addVisitor(Region);
@@ -479,7 +491,7 @@ static bool checkInvariantViolation(ProgramStateRef State, 
ExplodedNode *N,
 }
 
 void NullabilityChecker::reportBugIfInvariantHolds(
-StringRef Msg, ErrorKind Error, CheckKind CK, ExplodedNode *N,
+StringRef M

[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Sumit Agarwal (sumitsays)


Changes

Resolves #99221 
Key points: For SPIRV backend, it decompose into a `dot` followed a `add`.

- [x] Implement dot2add clang builtin,
- [x] Link dot2add clang builtin with hlsl_intrinsics.h
- [x] Add sema checks for dot2add to CheckHLSLBuiltinFunctionCall in 
SemaHLSL.cpp
- [x] Add codegen for dot2add to EmitHLSLBuiltinExpr in CGBuiltin.cpp
- [x] Add codegen tests to clang/test/CodeGenHLSL/builtins/dot2add.hlsl
- [x] Add sema tests to clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl
- [x] Create the int_dx_dot2add intrinsic in IntrinsicsDirectX.td
- [x] Create the DXILOpMapping of int_dx_dot2add to 162 in DXIL.td
- [x] Create the dot2add.ll and dot2add_errors.ll tests in 
llvm/test/CodeGen/DirectX/
- [ ] ~~Create the int_spv_dot2add intrinsic in IntrinsicsSPIRV.td~~ --- Not 
needed
- [ ] ~~In SPIRVInstructionSelector.cpp create the dot2add lowering and map it 
to int_spv_dot2add in SPIRVInstructionSelector::selectIntrinsic.~~ --- Not 
needed
- [ ] ~~Create SPIR-V backend test case in 
llvm/test/CodeGen/SPIRV/hlsl-intrinsics/dot2add.ll~~ --- Not needed

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


11 Files Affected:

- (modified) clang/include/clang/Basic/Builtins.td (+6) 
- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+15) 
- (modified) clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h (+8) 
- (modified) clang/lib/Headers/hlsl/hlsl_intrinsics.h (+12) 
- (modified) clang/lib/Sema/SemaHLSL.cpp (+50-9) 
- (added) clang/test/CodeGenHLSL/builtins/dot2add.hlsl (+17) 
- (added) clang/test/SemaHLSL/BuiltIns/Dot2Add-errors.hlsl (+11) 
- (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (+4) 
- (modified) llvm/lib/Target/DirectX/DXIL.td (+11) 
- (modified) llvm/lib/Target/DirectX/DXILOpLowering.cpp (+47-2) 
- (added) llvm/test/CodeGen/DirectX/dot2add.ll (+8) 


``diff
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 72a5e495c4059..76ab463ca0ed6 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4891,6 +4891,12 @@ def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLDot2Add : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_dot2add"];
+  let Attributes = [NoThrow, Const, CustomTypeChecking];
+  let Prototype = "void(...)";
+}
+
 def HLSLDot4AddI8Packed : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_dot4add_i8packed"];
   let Attributes = [NoThrow, Const];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c126f88b9e3a5..b3d9db5be7d8d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19681,6 +19681,21 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 getDotProductIntrinsic(CGM.getHLSLRuntime(), VecTy0->getElementType()),
 ArrayRef{Op0, Op1}, nullptr, "hlsl.dot");
   }
+  case Builtin::BI__builtin_hlsl_dot2add: {
+llvm::Triple::ArchType Arch = CGM.getTarget().getTriple().getArch();
+if (Arch != llvm::Triple::dxil) {
+  llvm_unreachable("Intrinsic dot2add can be executed as a builtin only on 
dxil");
+}
+Value *A = EmitScalarExpr(E->getArg(0));
+Value *B = EmitScalarExpr(E->getArg(1));
+Value *C = EmitScalarExpr(E->getArg(2));
+
+//llvm::Intrinsic::dx_##IntrinsicPostfix
+Intrinsic::ID ID = llvm ::Intrinsic::dx_dot2add;
+return Builder.CreateIntrinsic(
+/*ReturnType=*/C->getType(), ID, ArrayRef{A, B, C}, nullptr,
+"hlsl.dot2add");
+  }
   case Builtin::BI__builtin_hlsl_dot4add_i8packed: {
 Value *A = EmitScalarExpr(E->getArg(0));
 Value *B = EmitScalarExpr(E->getArg(1));
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
index 5f7c047dbf340..46653d7b295b2 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h
@@ -45,6 +45,14 @@ distance_vec_impl(vector X, vector Y) {
   return length_vec_impl(X - Y);
 }
 
+constexpr float dot2add_impl(half2 a, half2 b, float c) {
+#if defined(__DIRECTX__)
+  return __builtin_hlsl_dot2add(a, b, c);
+#else
+  return dot(a, b) + c;
+#endif
+}
+
 template  constexpr T reflect_impl(T I, T N) {
   return I - 2 * N * I * N;
 }
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 5459cbeb34fd0..b1c1335ce3328 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -117,6 +117,18 @@ const inline float 
distance(__detail::HLSL_FIXED_VECTOR X,
   return __detail::distance_vec_impl(X, Y);
 }
 
+//===--===//
+// dot2add builtins
+//===--===//
+
+/// \fn float dot2add(half2 a, half2 b, float

[clang] [llvm] [Clang][NVVM] Support `-f[no-]cuda-prec-sqrt` and propagate precision flag to `NVVMReflect` (PR #134244)

2025-04-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Why is this a module flag, instead of a function attribute?

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


[clang-tools-extra] [clang-tidy] Improve integer comparison by matching valid expressions outside implicitCastExpr (PR #134188)

2025-04-05 Thread David Rivera via cfe-commits

https://github.com/RiverDave updated 
https://github.com/llvm/llvm-project/pull/134188

>From 357f8d3b2fc424968a9e17c3dd2a13fe046f6cf9 Mon Sep 17 00:00:00 2001
From: David Rivera 
Date: Wed, 2 Apr 2025 21:02:00 -0400
Subject: [PATCH] [clang-tidy] Improve integer comparison by matching valid
 expressions outside implicitCastExpr

---
 .../UseIntegerSignComparisonCheck.cpp | 17 +---
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 +++
 .../modernize/use-integer-sign-comparison.cpp | 26 +++
 3 files changed, 44 insertions(+), 3 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index eeba5cce80da5..8f2bb4c4ba8f2 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -39,9 +39,11 @@ intCastExpression(bool IsSigned,
   // std::cmp_{} functions trigger a compile-time error if either LHS or RHS
   // is a non-integer type, char, enum or bool
   // (unsigned char/ signed char are Ok and can be used).
-  auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
+  const auto HasIntegerType = hasType(hasCanonicalType(qualType(
   isInteger(), IsSigned ? isSignedInteger() : isUnsignedInteger(),
-  unless(isActualChar()), unless(booleanType()), unless(enumType());
+  unless(isActualChar()), unless(booleanType()), unless(enumType();
+
+  auto IntTypeExpr = expr(HasIntegerType);
 
   const auto ImplicitCastExpr =
   CastBindName.empty() ? implicitCastExpr(hasSourceExpression(IntTypeExpr))
@@ -52,8 +54,17 @@ intCastExpression(bool IsSigned,
   const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
   const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
 
+  // Match function calls or variable references not directly wrapped by an
+  // implicit cast
+  const auto CallIntExpr = CastBindName.empty()
+   ? callExpr(HasIntegerType)
+   : callExpr(HasIntegerType).bind(CastBindName);
+  const auto DeclRefIntExpr =
+  CastBindName.empty() ? declRefExpr(HasIntegerType)
+   : declRefExpr(HasIntegerType).bind(CastBindName);
+
   return expr(anyOf(ImplicitCastExpr, CStyleCastExpr, StaticCastExpr,
-FunctionalCastExpr));
+FunctionalCastExpr, CallIntExpr));
 }
 
 static StringRef parseOpCode(BinaryOperator::Opcode Code) {
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6cb8d572d3a78..d90f277045003 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -177,6 +177,10 @@ Changes in existing checks
   matched scenarios of ``find`` and ``rfind`` methods and fixing false
   positives when those methods were called with 3 arguments.
 
+- Improved :doc:`modernize-use-integer-sign-comparison
+  ` check by matching
+  valid integer expressions not directly wrapped around an Implicit Cast.
+
 - Improved :doc:`modernize-use-std-numbers
   ` check to support math
   functions of different precisions.
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
index 99f00444c2d3f..1d2f64a359a2c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
@@ -120,3 +120,29 @@ int AllComparisons() {
 
 return 0;
 }
+
+namespace PR127471 {
+int getSignedValue();
+unsigned int getUnsignedValue();
+
+void callExprTest() {
+
+if (getSignedValue() < getUnsignedValue())
+return;
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
+// CHECK-FIXES:  if (std::cmp_less(getSignedValue() , getUnsignedValue()))
+
+int sVar = 0;
+if (getUnsignedValue() > sVar)
+return;
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
+// CHECK-FIXES: if (std::cmp_greater(getUnsignedValue() , sVar))
+
+unsigned int uVar = 0;
+if (getSignedValue() > uVar)
+return;
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
+// CHECK-FIXES: if (std::cmp_greater(getSignedValue() , uVar))
+
+}
+} // namespace PR127471

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


[clang] [clang] Handle Binary StingLiteral kind in one more place (PR #132201)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mariya Podchishchaeva (Fznamznon)


Changes

The bots are upset by https://github.com/llvm/llvm-project/pull/127629 . Fix 
that.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaExprCXX.cpp (+1) 


``diff
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index f085facf7ff55..8f204b949cb2c 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4143,6 +4143,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr 
*From, QualType ToType) {
 // We don't allow UTF literals to be implicitly converted
 break;
   case StringLiteralKind::Ordinary:
+  case StringLiteralKind::Binary:
 return (ToPointeeType->getKind() == BuiltinType::Char_U ||
 ToPointeeType->getKind() == BuiltinType::Char_S);
   case StringLiteralKind::Wide:

``




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


[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits


@@ -2474,19 +2474,46 @@ bool CXXMethodDecl::isUsualDeallocationFunction(
   getOverloadedOperator() != OO_Array_Delete)
 return false;
 
+  auto NumParams = getNumParams();
+  bool IsTypeAware = IsTypeAwareOperatorNewOrDelete();
+
   // C++ [basic.stc.dynamic.deallocation]p2:
   //   A template instance is never a usual deallocation function,
   //   regardless of its signature.
-  if (getPrimaryTemplate())
-return false;
+  if (auto *PrimaryTemplate = getPrimaryTemplate()) {

ojhunt wrote:

Done.




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


[clang] [CIR] Upstream a basic version of class LexicalScope (PR #131945)

2025-04-05 Thread David Olsen via cfe-commits

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


[clang] [CIR] Add binary operators (PR #132420)

2025-04-05 Thread Morris Hafner via cfe-commits


@@ -558,8 +624,225 @@ class ScalarExprEmitter : public 
StmtVisitor {
 
 return res;
   }
+
+  BinOpInfo emitBinOps(const BinaryOperator *e,
+   QualType promotionType = QualType()) {
+BinOpInfo result;
+result.lhs = cgf.emitPromotedScalarExpr(e->getLHS(), promotionType);
+result.rhs = cgf.emitPromotedScalarExpr(e->getRHS(), promotionType);
+if (!promotionType.isNull())
+  result.fullType = promotionType;
+else
+  result.fullType = e->getType();
+result.compType = result.fullType;
+if (const auto *vecType = dyn_cast_or_null(result.fullType)) {
+  result.compType = vecType->getElementType();
+}
+result.opcode = e->getOpcode();
+result.loc = e->getSourceRange();
+// TODO(cir): Result.FPFeatures
+assert(!cir::MissingFeatures::getFPFeaturesInEffect());
+result.e = e;
+return result;
+  }
+
+  mlir::Value emitMul(const BinOpInfo &ops);
+  mlir::Value emitDiv(const BinOpInfo &ops);
+  mlir::Value emitRem(const BinOpInfo &ops);
+  mlir::Value emitAdd(const BinOpInfo &ops);
+  mlir::Value emitSub(const BinOpInfo &ops);
+  mlir::Value emitShl(const BinOpInfo &ops);
+  mlir::Value emitShr(const BinOpInfo &ops);
+  mlir::Value emitAnd(const BinOpInfo &ops);
+  mlir::Value emitXor(const BinOpInfo &ops);
+  mlir::Value emitOr(const BinOpInfo &ops);
+
+  LValue emitCompoundAssignLValue(
+  const CompoundAssignOperator *e,
+  mlir::Value (ScalarExprEmitter::*f)(const BinOpInfo &),
+  mlir::Value &result);
+  mlir::Value
+  emitCompoundAssign(const CompoundAssignOperator *e,
+ mlir::Value (ScalarExprEmitter::*f)(const BinOpInfo &));
+
+  // TODO(cir): Candidate to be in a common AST helper between CIR and LLVM
+  // codegen.
+  QualType getPromotionType(QualType ty) {

mmha wrote:

I think we should leave this as a TODO in this patch. It's easier to have a 
mostly unimplemented `getPromotionType` and change the calls later on than to 
go back and figure out where it's supposed to be called.

There's a `getPromotionType` `CGExprScalar.cpp` and another one in 
`CGExprComplex.cpp`. So refactoring that should probably be done in a separate 
patch.

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


[clang] [Format] Do not crash on non-null terminated strings (PR #131299)

2025-04-05 Thread Ilya Biryukov via cfe-commits


@@ -29096,6 +29096,17 @@ TEST_F(FormatTest, BreakBeforeClassName) {
"ArenaSafeUniquePtr {};");
 }
 
+TEST_F(FormatTest, DoesNotCrashOnNonNullTerminatedStringRefs) {
+  llvm::StringRef TwoLines = "namespace foo {}\n"
+ "namespace bar {}";
+  llvm::StringRef FirstLine =
+  TwoLines.take_until([](char c) { return c == '\n'; });
+
+  // The internal API used to crash when passed a non-null-terminated 
StringRef.
+  // Check this does not happen anymore.
+  verifyFormat(FirstLine);

ilya-biryukov wrote:

Using it now, thanks.

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


[clang] [X86][AVX10.2] Replace nepbh with bf16 to match with others, NFCI (PR #134240)

2025-04-05 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon commented:

are we missing clang codegen tests for these?

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


[clang] [HLSL] Finish exposing half types and intrinsics always (PR #132804)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Sarah Spall (spall)


Changes

Finish the work of #81782 
Closes #132793 

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


1 Files Affected:

- (modified) clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h (+32-16) 


``diff
diff --git a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
index 585e905c7bf5d..d1e23007f92ff 100644
--- a/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_alias_intrinsics.h
@@ -134,16 +134,18 @@ double4 abs(double4);
 /// \brief Returns the arccosine of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
 half acos(half);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
 half2 acos(half2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
 half3 acos(half3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
 half4 acos(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
 float acos(float);
@@ -447,16 +449,18 @@ double4 asdouble(uint4, uint4);
 /// \brief Returns the arcsine of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
 half asin(half);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
 half2 asin(half2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
 half3 asin(half3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
 half4 asin(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
 float asin(float);
@@ -475,16 +479,18 @@ float4 asin(float4);
 /// \brief Returns the arctangent of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
 half atan(half);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
 half2 atan(half2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
 half3 atan(half3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
 half4 atan(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
 float atan(float);
@@ -505,16 +511,18 @@ float4 atan(float4);
 /// \param y The y-coordinate.
 /// \param x The x-coordinate.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
 half atan2(half y, half x);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
 half2 atan2(half2 y, half2 x);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
 half3 atan2(half3 y, half3 x);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
 half4 atan2(half4 y, half4 x);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
 float atan2(float y, float x);
@@ -721,16 +729,18 @@ float4 cos(float4);
 /// \brief Returns the hyperbolic cosine of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
 half cosh(half);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
 half2 cosh(half2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
 half3 cosh(half3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
 half4 cosh(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
 float cosh(float);
@@ -2124,16 +2134,18 @@ float4 sin(float4);
 /// \brief Returns the hyperbolic sine of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
 half sinh(half);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
 half2 sinh(half2);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
 half3 sinh(half3);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
 half4 sinh(half4);
-#endif
 
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
 float sinh(float);
@@ -2215,16 +2227,18 @@ float4 step(float4, float4);
 /// \brief Returns the tangent of the input value, \a Val.
 /// \param Val The input value.
 
-#ifdef __HLSL_ENABLE_16_BIT
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
 half tan(half);
+_HLSL_AVAILABILITY(shadermodel, 6.2)
 _HLSL_

[clang] [HLSL][RootSignature] Define and integrate `HLSLRootSignatureAttr` (PR #134124)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-hip-vega20` running 
on `hip-vega20-0` while building `clang` at step 3 "annotate".

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


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

```
Step 3 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure)
...
[731/1466] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/MemoryUnsafeCastChecker.cpp.o
[732/1466] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Value.cpp.o
[733/1466] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/DeviceOffload.cpp.o
[734/1466] Building CXX object 
tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelInjector.cpp.o
[735/1466] Building CXX object 
tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ShowEnabledWarnings.cpp.o
[736/1466] Building CXX object 
tools/clang/tools/driver/CMakeFiles/clang.dir/driver.cpp.o
[737/1466] Building CXX object 
tools/clang/tools/extra/clang-tidy/utils/CMakeFiles/obj.clangTidyUtils.dir/ASTUtils.cpp.o
[738/1466] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/ForwardDeclChecker.cpp.o
[739/1466] Building CXX object 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
[740/1466] Linking CXX executable bin/clang-scan-deps
FAILED: bin/clang-scan-deps 
: && /usr/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -O3 -DNDEBUG 
-Wl,-rpath-link,/home/botworker/bbot/clang-hip-vega20/botworker/clang-hip-vega20/llvm/./lib
  -Wl,--gc-sections 
tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/ClangScanDeps.cpp.o
 
tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/clang-scan-deps-driver.cpp.o
 -o bin/clang-scan-deps  -Wl,-rpath,"\$ORIGIN/../lib:"  
lib/libLLVMAMDGPUCodeGen.a  lib/libLLVMAMDGPUAsmParser.a  
lib/libLLVMAMDGPUDesc.a  lib/libLLVMAMDGPUDisassembler.a  
lib/libLLVMAMDGPUInfo.a  lib/libLLVMAMDGPUUtils.a  lib/libLLVMX86CodeGen.a  
lib/libLLVMX86AsmParser.a  lib/libLLVMX86Desc.a  lib/libLLVMX86Disassembler.a  
lib/libLLVMX86Info.a  lib/libLLVMCore.a  lib/libLLVMOption.a  
lib/libLLVMSupport.a  lib/libLLVMTargetParser.a  lib/libclangAST.a  
lib/libclangBasic.a  lib/libclangDependencyScanning.a  lib/libclangDriver.a  
lib/libclangFrontend.a  lib/libclangLex.a  lib/libclangSerialization.a  
lib/libclangTooling.a  lib/libLLVMMIRParser.a  lib/libLLVMPasses.a  
lib/libLLVMHipStdPar.a  lib/libLLVMCoroutines.a  lib/libLLVMipo.a  
lib/libLLVMLinker.a  lib/libLLVMVectorize.a  lib/libLLVMSandboxIR.a  
lib/libLLVMAMDGPUDesc.a  lib/libLLVMAMDGPUInfo.a  lib/libLLVMAMDGPUUtils.a  
lib/libLLVMAsmPrinter.a  lib/libLLVMGlobalISel.a  lib/libLLVMIRPrinter.a  
lib/libLLVMInstrumentation.a  lib/libLLVMSelectionDAG.a  lib/libLLVMCodeGen.a  
lib/libLLVMCGData.a  lib/libLLVMBitWriter.a  lib/libLLVMObjCARCOpts.a  
lib/libLLVMTarget.a  lib/libLLVMCFGuard.a  lib/libLLVMCodeGenTypes.a  
lib/libLLVMMCDisassembler.a  lib/libclangFrontend.a  lib/libclangDriver.a  
lib/libLLVMWindowsDriver.a  lib/libLLVMOption.a  lib/libclangParse.a  
lib/libclangSerialization.a  lib/libclangSema.a  lib/libclangAPINotes.a  
lib/libclangEdit.a  lib/libclangAnalysis.a  lib/libclangSupport.a  
lib/libLLVMFrontendHLSL.a  lib/libclangASTMatchers.a  lib/libclangAST.a  
lib/libclangFormat.a  lib/libclangToolingInclusions.a  
lib/libclangToolingCore.a  lib/libclangRewrite.a  lib/libclangLex.a  
lib/libclangBasic.a  lib/libLLVMFrontendOpenMP.a  lib/libLLVMScalarOpts.a  
lib/libLLVMAggressiveInstCombine.a  lib/libLLVMInstCombine.a  
lib/libLLVMFrontendOffloading.a  lib/libLLVMTransformUtils.a  
lib/libLLVMObjectYAML.a  lib/libLLVMFrontendAtomic.a  lib/libLLVMAnalysis.a  
lib/libLLVMProfileData.a  lib/libLLVMSymbolize.a  lib/libLLVMDebugInfoDWARF.a  
lib/libLLVMDebugInfoPDB.a  lib/libLLVMDebugInfoCodeView.a  
lib/libLLVMDebugInfoMSF.a  lib/libLLVMDebugInfoBTF.a  lib/libLLVMObject.a  
lib/libLLVMMCParser.a  lib/libLLVMMC.a  lib/libLLVMIRReader.a  
lib/libLLVMBitReader.a  lib/libLLVMAsmParser.a  lib/libLLVMCore.a  
lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMTextAPI.a  
lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  
lib/libLLVMDemangle

[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
FAIL: test_diagnostic_category


```



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


[clang] [CIR] Upstream initial support for unary op (PR #131369)

2025-04-05 Thread Bruno Cardoso Lopes via cfe-commits

bcardosolopes wrote:

> The git history says the FIXME about "Pure" was added when @cmarcelo 
> introduced `UnaryOp` in the incubator, but there is no PR associated with the 
> commit so I don't know what discussions may have taken place.

We floated the idea of implementing operators as part of `UnaryOp`. This was a 
while ago and it probably doesn't make sense and is outdated!

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


[clang] [clang][bytecode] Return Invalid() on non-constexpr builtins (PR #133700)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

So the diagnostic output matches with the current interpreter

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+1-1) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+9) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index d7de4c09e2614..e838528b8a16c 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2102,7 +2102,7 @@ static bool interp__builtin_memchr(InterpState &S, 
CodePtr OpPC,
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
   const CallExpr *Call, uint32_t BuiltinID) {
   if (!S.getASTContext().BuiltinInfo.isConstantEvaluated(BuiltinID))
-return false;
+return Invalid(S, OpPC);
 
   const InterpFrame *Frame = S.Current;
 
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 828822375e95e..ea09eede4ff12 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1545,3 +1545,12 @@ namespace WMemChr {
   constexpr bool c = !wcschr(L"hello", L'h'); // both-error {{constant 
expression}} \
   // both-note {{non-constexpr 
function 'wcschr' cannot be used in a constant expression}}
 }
+
+namespace Invalid {
+  constexpr int test() { // both-error {{never produces a constant expression}}
+__builtin_abort(); // both-note 2{{subexpression not valid in a constant 
expression}}
+return 0;
+  }
+  static_assert(test() == 0); // both-error {{not an integral constant 
expression}} \
+  // both-note {{in call to}}
+}

``




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


[clang] Reapply "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (#132348)" (PR #134043)

2025-04-05 Thread via cfe-commits

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-04-05 Thread Sumit Agarwal via cfe-commits

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


[clang] [Clang] Introduce a trait to determine the structure binding size (PR #131515)

2025-04-05 Thread via cfe-commits


@@ -368,7 +368,11 @@ std::optional SValBuilder::getConstantVal(const Expr 
*E) {
 
   case Stmt::TypeTraitExprClass: {
 const auto *TE = cast(E);
-return makeTruthVal(TE->getValue(), TE->getType());
+if (TE->isStoredAsBoolean())
+  return makeTruthVal(TE->getBoolValue(), TE->getType());
+if (TE->getType()->isIntegralOrEnumerationType())
+  return makeIntVal(TE->getAPValue().getInt());
+return std::nullopt;

cor3ntin wrote:

I replaced by an assert.

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


[clang] [WIP][Clang] Allow floating point fixed vectors with atomic builtins (PR #129495)

2025-04-05 Thread Vikram Hegde via cfe-commits


@@ -240,6 +255,9 @@ void f(_Atomic(int) *i, const _Atomic(int) *ci,
   __atomic_fetch_sub(P, 3, memory_order_seq_cst);
   __atomic_fetch_sub(F, 3, memory_order_seq_cst);
   __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer, pointer or supported floating point type}}
+  __atomic_fetch_sub(evf, fvec, memory_order_seq_cst);
+  __atomic_fetch_sub(evd, dvec, memory_order_seq_cst);
+  __atomic_fetch_sub(evi, ivec, memory_order_seq_cst); // expected-error 
{{must be a pointer to integer, pointer or supported floating point type}}

vikramRH wrote:

done

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


[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-04-05 Thread Matt Arsenault via cfe-commits
Juan Manuel Martinez =?utf-8?q?Caamaño?= ,
Juan Manuel Martinez =?utf-8?q?Caamaño?= ,
Juan Manuel Martinez =?utf-8?q?Caamaño?= 
Message-ID:
In-Reply-To: 



@@ -260,7 +260,7 @@ AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple 
&Triple,
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   CUMode = !(GPUFeatures & llvm::AMDGPU::FEATURE_WGP);
-  for (auto F : {"image-insts", "gws"})
+  for (auto F : {"image-insts", "gws", "mem-to-lds-load-insts"})

arsenm wrote:

```suggestion
  for (auto F : {"image-insts", "gws", "vmem-to-lds-load-insts"})
```

Not sure about the naming. The manual refers to this as "LDS DMA", but was new 
in gfx8 (or maybe, the store case was new? I thought the load case always 
existed, we just never made use of it).

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


[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

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

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

>From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 28 Mar 2025 13:01:58 -0400
Subject: [PATCH 1/3] [C11] Implement WG14 N1285 (temporary lifetimes)

This feature largely models the same behavior as in C++11. It is
technically a breaking change between C99 and C11, so the paper is not
being backported to older language modes.

One difference between C++ and C is that things which are rvalues in C
are often lvalues in C++ (such as the result of a ternary operator or a
comma operator).
---
 clang/docs/ReleaseNotes.rst  |   9 +
 clang/lib/CodeGen/CGExpr.cpp |   4 +-
 clang/lib/Sema/Sema.cpp  |   5 +-
 clang/lib/Sema/SemaInit.cpp  |   2 +-
 clang/test/C/C11/n1285.c |  83 ++--
 clang/test/C/C11/n1285_1.c   | 212 +++
 clang/test/CodeGenObjC/property-array-type.m |   5 +-
 clang/www/c_status.html  |   2 +-
 8 files changed, 301 insertions(+), 21 deletions(-)
 create mode 100644 clang/test/C/C11/n1285_1.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b96780cec75d9..c51b3c44f3b3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -160,6 +160,15 @@ C23 Feature Support
   treated as if the compound literal were within the body rather than at file
   scope.
 
+C11 Feature Support
+^^^
+- Implemented `WG14 N1285 
`_
+  which introduces the notion of objects with a temporary lifetime. When an
+  expression resulting in an rvalue with structure or union type and that type
+  contains a member of array type, the expression result is an automatic 
storage
+  duration object with temporary lifetime which begins when the expression is
+  evaluated and ends at the evaluation of the containing full expression.
+
 Non-comprehensive list of changes in this release
 -
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 5943ff9294e1a..2328ad0def736 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -387,8 +387,8 @@ pushTemporaryCleanup(CodeGenFunction &CGF, const 
MaterializeTemporaryExpr *M,
   if (const RecordType *RT =
   E->getType()->getBaseElementTypeUnsafe()->getAs()) {
 // Get the destructor for the reference temporary.
-auto *ClassDecl = cast(RT->getDecl());
-if (!ClassDecl->hasTrivialDestructor())
+if (auto *ClassDecl = dyn_cast(RT->getDecl());
+ClassDecl && !ClassDecl->hasTrivialDestructor())
   ReferenceTemporaryDtor = ClassDecl->getDestructor();
   }
 
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 93a2d797679d4..4b573abb8efba 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -741,10 +741,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
   if (Kind == CK_ArrayToPointerDecay) {
 // C++1z [conv.array]: The temporary materialization conversion is applied.
 // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
-if (getLangOpts().CPlusPlus && E->isPRValue()) {
+if ((getLangOpts().C11 || getLangOpts().CPlusPlus) && E->isPRValue()) {
   // The temporary is an lvalue in C++98 and an xvalue otherwise.
   ExprResult Materialized = CreateMaterializeTemporaryExpr(
-  E->getType(), E, !getLangOpts().CPlusPlus11);
+  E->getType(), E,
+  getLangOpts().CPlusPlus && !getLangOpts().CPlusPlus11);
   if (Materialized.isInvalid())
 return ExprError();
   E = Materialized.get();
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 9814c3f456f0d..c47ea71cbafb5 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -7654,7 +7654,7 @@ ExprResult Sema::TemporaryMaterializationConversion(Expr 
*E) {
   // FIXME: This means that AST consumers need to deal with "prvalues" that
   // denote materialized temporaries. Maybe we should add another ValueKind
   // for "xvalue pretending to be a prvalue" for C++98 support.
-  if (!E->isPRValue() || !getLangOpts().CPlusPlus11)
+  if (!E->isPRValue() || (!getLangOpts().CPlusPlus11 && !getLangOpts().C11))
 return E;
 
   // C++1z [conv.rval]/1: T shall be a complete type.
diff --git a/clang/test/C/C11/n1285.c b/clang/test/C/C11/n1285.c
index e7a9463e68103..c4fb199e33ae5 100644
--- a/clang/test/C/C11/n1285.c
+++ b/clang/test/C/C11/n1285.c
@@ -1,24 +1,81 @@
-// RUN: %clang_cc1 -verify=wrong -std=c99 %s
-// RUN: %clang_cc1 -verify=wrong -std=c11 %s
-// RUN: %clang_cc1 -verify=cpp -std=c++11 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -verify=good -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expect

[clang] [clang-tools-extra] [clang] Concepts: support pack expansions for type constraints (PR #132626)

2025-04-05 Thread via cfe-commits

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


[clang] 69b7011 - [TableGen] Avoid repeated hash lookups (NFC) (#132142)

2025-04-05 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-03-20T09:10:23-07:00
New Revision: 69b70110b78930b942a5e92db40bcefd0ac7890b

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

LOG: [TableGen] Avoid repeated hash lookups (NFC) (#132142)

Added: 


Modified: 
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 5669b5e329587..bc142526ac973 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -1809,12 +1809,11 @@ Intrinsic::DagEmitter::emitDagSaveTemp(const DagInit 
*DI) {
   assert_with_loc(!N.empty(),
   "save_temp() expects a name as the first argument");
 
-  assert_with_loc(Intr.Variables.find(N) == Intr.Variables.end(),
-  "Variable already defined!");
-  Intr.Variables[N] = Variable(A.first, N + Intr.VariablePostfix);
+  auto [It, Inserted] =
+  Intr.Variables.try_emplace(N, A.first, N + Intr.VariablePostfix);
+  assert_with_loc(Inserted, "Variable already defined!");
 
-  std::string S =
-  A.first.str() + " " + Intr.Variables[N].getName() + " = " + A.second;
+  std::string S = A.first.str() + " " + It->second.getName() + " = " + 
A.second;
 
   return std::make_pair(Type::getVoid(), S);
 }
@@ -2246,9 +2245,9 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
 // Sorted by immediate argument index
 ArrayRef Checks = Def->getImmChecks();
 
-const auto it = Emitted.find(Def->getMangledName());
-if (it != Emitted.end()) {
-  assert(areRangeChecksCompatible(Checks, it->second) &&
+auto [It, Inserted] = Emitted.try_emplace(Def->getMangledName(), Checks);
+if (!Inserted) {
+  assert(areRangeChecksCompatible(Checks, It->second) &&
  "Neon intrinsics with incompatible immediate range checks cannot "
  "share a builtin.");
   continue; // Ensure this is emitted only once
@@ -2262,7 +2261,6 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
  << Check.getVecSizeInBits() << ");\n"
  << " break;\n";
 }
-Emitted[Def->getMangledName()] = Checks;
   }
 
   OS << "#endif\n\n";



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


[clang] [llvm] [llvm:ir] Add support for constant data exceeding 4GiB (PR #126481)

2025-04-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Code formatter returned issues; please fix 
(https://github.com/llvm/llvm-project/pull/126481#issuecomment-2649368078)

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-04-05 Thread Sumit Agarwal via cfe-commits

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


[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #132638)

2025-04-05 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/132638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][OpenMP][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

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

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


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


[clang] 468452b - [CodeGen] Fix unused variable warning (NFC)

2025-04-05 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2025-03-20T19:36:38+01:00
New Revision: 468452b0814a3ad04700455af2d225e25a6aecaf

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

LOG: [CodeGen] Fix unused variable warning (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 257b7b40fd19e..96ab4dd1837ce 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2935,7 +2935,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   bool IsIncompleteFunction,
   bool IsThunk) {
 
-  if (llvm::Intrinsic::ID IID = F->getIntrinsicID()) {
+  if (F->getIntrinsicID() != llvm::Intrinsic::not_intrinsic) {
 // If this is an intrinsic function, the attributes will have been set
 // when the function was created.
 return;



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


[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-05 Thread Piotr Zegar via cfe-commits

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


[clang] [clang-tools-extra] [clang] Consistently use "load" to refer to populating clang::ModuleMap (PR #132970)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Michael Spencer (Bigcheese)


Changes

Now that we have ModuleMapFile.cpp which parses module maps, it's confusing 
what ModuleMap::parseModuleMapFile actually does. HeaderSearch already called 
this loading a module map, so consistently use that term in ModuleMap too.

An upcoming patch will allow just parsing a module map without loading the 
modules from it.

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


4 Files Affected:

- (modified) clang-tools-extra/modularize/ModuleAssistant.cpp (+2-2) 
- (modified) clang/include/clang/Lex/ModuleMap.h (+10-10) 
- (modified) clang/lib/Lex/HeaderSearch.cpp (+2-2) 
- (modified) clang/lib/Lex/ModuleMap.cpp (+31-31) 


``diff
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp 
b/clang-tools-extra/modularize/ModuleAssistant.cpp
index c7259d70bd58f..b4ec96617449f 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -129,8 +129,8 @@ Module *Module::findSubModule(llvm::StringRef SubName) {
 // Implementation functions:
 
 // Reserved keywords in module.modulemap syntax.
-// Keep in sync with keywords in module map parser in Lex/ModuleMap.cpp,
-// such as in ModuleMapParser::consumeToken().
+// Keep in sync with keywords in module map parser in Lex/ModuleMapFile.cpp,
+// such as in ModuleMapFileParser::consumeToken().
 static const char *const ReservedNames[] = {
   "config_macros", "export",   "module", "conflict", "framework",
   "requires",  "exclude",  "header", "private",  "explicit",
diff --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 3baeea08cc0e3..43c3890631bd1 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -43,7 +43,7 @@ class FileManager;
 class HeaderSearch;
 class SourceManager;
 
-/// A mechanism to observe the actions of the module map parser as it
+/// A mechanism to observe the actions of the module map loader as it
 /// reads module map files.
 class ModuleMapCallbacks {
   virtual void anchor();
@@ -195,7 +195,7 @@ class ModuleMap {
   using AdditionalModMapsSet = llvm::DenseSet;
 
 private:
-  friend class ModuleMapParser;
+  friend class ModuleMapLoader;
 
   using HeadersMap = llvm::DenseMap>;
 
@@ -259,9 +259,9 @@ class ModuleMap {
 
   llvm::DenseMap AdditionalModMaps;
 
-  /// Describes whether we haved parsed a particular file as a module
+  /// Describes whether we haved loaded a particular file as a module
   /// map.
-  llvm::DenseMap ParsedModuleMap;
+  llvm::DenseMap LoadedModuleMap;
 
   /// Resolve the given export declaration into an actual export
   /// declaration.
@@ -693,10 +693,10 @@ class ModuleMap {
   void addHeader(Module *Mod, Module::Header Header,
  ModuleHeaderRole Role, bool Imported = false);
 
-  /// Parse the given module map file, and record any modules we
+  /// Load the given module map file, and record any modules we
   /// encounter.
   ///
-  /// \param File The file to be parsed.
+  /// \param File The file to be loaded.
   ///
   /// \param IsSystem Whether this module map file is in a system header
   /// directory, and therefore should be considered a system module.
@@ -713,10 +713,10 @@ class ModuleMap {
   ///that caused us to load this module map file, if any.
   ///
   /// \returns true if an error occurred, false otherwise.
-  bool parseModuleMapFile(FileEntryRef File, bool IsSystem,
-  DirectoryEntryRef HomeDir, FileID ID = FileID(),
-  unsigned *Offset = nullptr,
-  SourceLocation ExternModuleLoc = SourceLocation());
+  bool loadModuleMapFile(FileEntryRef File, bool IsSystem,
+ DirectoryEntryRef HomeDir, FileID ID = FileID(),
+ unsigned *Offset = nullptr,
+ SourceLocation ExternModuleLoc = SourceLocation());
 
   /// Dump the contents of the module map, for debugging purposes.
   void dump();
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ad9263f2994f2..95f294238a0d4 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1783,7 +1783,7 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, 
bool IsSystem,
   if (!AddResult.second)
 return AddResult.first->second ? LMM_AlreadyLoaded : LMM_InvalidModuleMap;
 
-  if (ModMap.parseModuleMapFile(File, IsSystem, Dir, ID, Offset)) {
+  if (ModMap.loadModuleMapFile(File, IsSystem, Dir, ID, Offset)) {
 LoadedModuleMaps[File] = false;
 return LMM_InvalidModuleMap;
   }
@@ -1791,7 +1791,7 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, 
bool IsSystem,
   // Try to load a corresponding private module map.
   if (OptionalFileEntryRef PMMFile =
   getPrivateModuleMap(File, FileMgr, Diags)) {
-if (ModMap.parseModuleMapFile(*PMMFile, IsSystem, Dir)) {
+  

[clang] dcc2fae - [HLSL] Fix codegen to support classes in `cbuffer` (#132828)

2025-04-05 Thread via cfe-commits

Author: Helena Kotas
Date: 2025-03-31T10:05:59-07:00
New Revision: dcc2faecd8aebc64eb541aebe0005ecceffef558

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

LOG: [HLSL] Fix codegen to support classes in `cbuffer` (#132828)

Fixes #132309

Added: 


Modified: 
clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
clang/test/CodeGenHLSL/cbuffer.hlsl

Removed: 




diff  --git a/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp 
b/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
index e0f5b0f59ef40..b546b6dd574ff 100644
--- a/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
@@ -52,11 +52,11 @@ static unsigned getScalarOrVectorSizeInBytes(llvm::Type 
*Ty) {
 namespace clang {
 namespace CodeGen {
 
-// Creates a layout type for given struct with HLSL constant buffer layout
-// taking into account PackOffsets, if provided.
+// Creates a layout type for given struct or class with HLSL constant buffer
+// layout taking into account PackOffsets, if provided.
 // Previously created layout types are cached by CGHLSLRuntime.
 //
-// The function iterates over all fields of the StructType (including base
+// The function iterates over all fields of the record type (including base
 // classes) and calls layoutField to converts each field to its corresponding
 // LLVM type and to calculate its HLSL constant buffer layout. Any embedded
 // structs (or arrays of structs) are converted to target layout types as well.
@@ -67,12 +67,11 @@ namespace CodeGen {
 // -1 value instead. These elements must be placed at the end of the layout
 // after all of the elements with specific offset.
 llvm::TargetExtType *HLSLBufferLayoutBuilder::createLayoutType(
-const RecordType *StructType,
-const llvm::SmallVector *PackOffsets) {
+const RecordType *RT, const llvm::SmallVector *PackOffsets) {
 
   // check if we already have the layout type for this struct
   if (llvm::TargetExtType *Ty =
-  CGM.getHLSLRuntime().getHLSLBufferLayoutType(StructType))
+  CGM.getHLSLRuntime().getHLSLBufferLayoutType(RT))
 return Ty;
 
   SmallVector Layout;
@@ -87,7 +86,7 @@ llvm::TargetExtType 
*HLSLBufferLayoutBuilder::createLayoutType(
 
   // iterate over all fields of the record, including fields on base classes
   llvm::SmallVector RecordTypes;
-  RecordTypes.push_back(StructType);
+  RecordTypes.push_back(RT);
   while (RecordTypes.back()->getAsCXXRecordDecl()->getNumBases()) {
 CXXRecordDecl *D = RecordTypes.back()->getAsCXXRecordDecl();
 assert(D->getNumBases() == 1 &&
@@ -148,7 +147,7 @@ llvm::TargetExtType 
*HLSLBufferLayoutBuilder::createLayoutType(
 
   // create the layout struct type; anonymous struct have empty name but
   // non-empty qualified name
-  const CXXRecordDecl *Decl = StructType->getAsCXXRecordDecl();
+  const CXXRecordDecl *Decl = RT->getAsCXXRecordDecl();
   std::string Name =
   Decl->getName().empty() ? "anon" : Decl->getQualifiedNameAsString();
   llvm::StructType *StructTy =
@@ -158,7 +157,7 @@ llvm::TargetExtType 
*HLSLBufferLayoutBuilder::createLayoutType(
   llvm::TargetExtType *NewLayoutTy = llvm::TargetExtType::get(
   CGM.getLLVMContext(), LayoutTypeName, {StructTy}, Layout);
   if (NewLayoutTy)
-CGM.getHLSLRuntime().addHLSLBufferLayoutType(StructType, NewLayoutTy);
+CGM.getHLSLRuntime().addHLSLBufferLayoutType(RT, NewLayoutTy);
   return NewLayoutTy;
 }
 
@@ -202,9 +201,9 @@ bool HLSLBufferLayoutBuilder::layoutField(const FieldDecl 
*FD,
 }
 // For array of structures, create a new array with a layout type
 // instead of the structure type.
-if (Ty->isStructureType()) {
+if (Ty->isStructureOrClassType()) {
   llvm::Type *NewTy =
-  
cast(createLayoutType(Ty->getAsStructureType()));
+  cast(createLayoutType(Ty->getAs()));
   if (!NewTy)
 return false;
   assert(isa(NewTy) && "expected target type");
@@ -220,9 +219,10 @@ bool HLSLBufferLayoutBuilder::layoutField(const FieldDecl 
*FD,
 ArrayStride = llvm::alignTo(ElemSize, CBufferRowSizeInBytes);
 ElemOffset = (Packoffset != -1) ? Packoffset : NextRowOffset;
 
-  } else if (FieldTy->isStructureType()) {
+  } else if (FieldTy->isStructureOrClassType()) {
 // Create a layout type for the structure
-ElemLayoutTy = createLayoutType(FieldTy->getAsStructureType());
+ElemLayoutTy =
+createLayoutType(cast(FieldTy->getAs()));
 if (!ElemLayoutTy)
   return false;
 assert(isa(ElemLayoutTy) && "expected target type");

diff  --git a/clang/test/CodeGenHLSL/cbuffer.hlsl 
b/clang/test/CodeGenHLSL/cbuffer.hlsl
index 98948ea6811e3..db06cea808b62 100644
--- a/clang/test/CodeGenHLSL/cbuffer.hlsl
+++ b/clang/test/CodeGenHLSL/cbuffer.hlsl
@@ -13,6 +13,12 @@
 // CHECK: %C = 

[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

2025-04-05 Thread Alexey Bataev via cfe-commits


@@ -18933,12 +18945,34 @@ static bool actOnOMPReductionKindClause(
 reportOriginalDsa(S, Stack, D, DVar);
 continue;
   }
+  // OpenMP 6.0 [ 7.6.10 ]
+  // Support Reduction over private variables with reduction clause.
+  // A list item in a reduction clause can now be private in the enclosing
+  // context. For orphaned constructs it is assumed to be shared unless the
+  // original(private) modifier appears in the clause.
+  DVar = Stack->getImplicitDSA(D, true);
+  bool IsOrphaned = false;
+  OpenMPDirectiveKind CurrDir = Stack->getCurrentDirective();
+  OpenMPDirectiveKind ParentDir = Stack->getParentDirective();
+  // Check if the construct is orphaned (has no enclosing OpenMP context)
+  IsOrphaned = ParentDir == OMPD_unknown;
+  // OpenMP 6.0: Private DSA check
+  IsPrivate =
+  (S.getLangOpts().OpenMP > 52) &&

alexey-bataev wrote:

Extra parens

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


[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits


@@ -2527,6 +2527,32 @@ class FunctionDecl : public DeclaratorDecl,
   /// If this function is an allocation/deallocation function that takes
   /// the `std::nothrow_t` tag, return true through IsNothrow,
   bool isReplaceableGlobalAllocationFunction(
+  std::optional *AlignmentParam = nullptr,
+  bool *IsNothrow = nullptr) const {
+if (isTypeAwareOperatorNewOrDelete())
+  return false;
+return isUsableAsGlobalAllocationFunctionInConstantEvaluation(
+AlignmentParam, IsNothrow);
+  }
+
+  /// Determines whether this function is one of the replaceable global
+  /// allocation functions described in isReplaceableGlobalAllocationFunction,
+  /// or is a function that may be treated as such during constant evaluation.
+  /// This adds support for potentially templated type aware global allocation
+  /// functions of the form:
+  ///void *operator new(type-identity, std::size_t, std::align_val_t)
+  ///void *operator new(type-identity, std::size_t, std::align_val_t, 
const std::nothrow_t &) noexcept;
+  ///void *operator new[](type-identity, std::size_t, std::align_val_t)
+  ///void *operator new[](type-identity, std::size_t, std::align_val_t, 
const std::nothrow_t &) noexcept;
+  ///void operator delete(type-identity, void*, std::size_t, 
std::align_val_t) noexcept;

ojhunt wrote:

clang-format wraps these as if they're comments which I've been unwrapping for 
now pending what the correct format should be.

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


[clang] 4e3440d - [CIR] Upstream a basic version of class LexicalScope (#131945)

2025-04-05 Thread via cfe-commits

Author: David Olsen
Date: 2025-03-19T12:56:41-07:00
New Revision: 4e3440d9dd181f83ac1aa23f9c458d1344413e98

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

LOG: [CIR] Upstream a basic version of class LexicalScope (#131945)

Upstream the parts of class `CIRGenFunction::LexicalScope` that
implement function return values. There is a bit of other functionality
in here, such as the implicit `cir.yield` at the end of a non-function
scope, but this is mostly about function returns.

The parts of `LexicalScope` that handle calling destructors, switch
statements, ternary expressions, and exception handling still need to be
upstreamed.

There is a change in the generated ClangIR (which is why many of the
tests needed updating). Return values are stored in the
compiler-generated variable `__retval` rather than being passed to the
`cir.return` op directly. But there should be no change in the behavior
of the generated code.

Added: 


Modified: 
clang/include/clang/CIR/Dialect/IR/CIROps.td
clang/include/clang/CIR/MissingFeatures.h
clang/lib/CIR/CodeGen/CIRGenFunction.cpp
clang/lib/CIR/CodeGen/CIRGenFunction.h
clang/lib/CIR/CodeGen/CIRGenStmt.cpp
clang/test/CIR/CodeGen/basic.c
clang/test/CIR/CodeGen/basic.cpp
clang/test/CIR/CodeGen/cast.cpp
clang/test/CIR/CodeGen/unary.cpp
clang/test/CIR/Lowering/basic.cpp
clang/test/CIR/Lowering/func-simple.cpp
clang/test/CIR/func-simple.cpp

Removed: 




diff  --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 2a5caf1bf1f63..352d72ff31a8a 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -832,6 +832,22 @@ def FuncOp : CIR_Op<"func", [
   let hasVerifier = 1;
 }
 
+//===--===//
+// UnreachableOp
+//===--===//
+
+def UnreachableOp : CIR_Op<"unreachable", [Terminator]> {
+  let summary = "invoke immediate undefined behavior";
+  let description = [{
+If the program control flow reaches a `cir.unreachable` operation, the
+program exhibits undefined behavior immediately. This operation is useful
+in cases where the unreachability of a program point needs to be explicitly
+marked.
+  }];
+
+  let assemblyFormat = "attr-dict";
+}
+
 
//===--===//
 // TrapOp
 
//===--===//

diff  --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 52bf56727a51b..d276af5686995 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -89,6 +89,7 @@ struct MissingFeatures {
   static bool astVarDeclInterface() { return false; }
   static bool stackSaveOp() { return false; }
   static bool aggValueSlot() { return false; }
+  static bool generateDebugInfo() { return false; }
 
   static bool fpConstraints() { return false; }
   static bool sanitizers() { return false; }

diff  --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp 
b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
index 2338ec9cd952a..16547f2401292 100644
--- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
@@ -135,6 +135,13 @@ mlir::Location CIRGenFunction::getLoc(mlir::Location lhs, 
mlir::Location rhs) {
   return mlir::FusedLoc::get(locs, metadata, &getMLIRContext());
 }
 
+void CIRGenFunction::emitAndUpdateRetAlloca(QualType type, mlir::Location loc,
+CharUnits alignment) {
+  if (!type->isVoidType()) {
+fnRetAlloca = emitAlloca("__retval", convertType(type), loc, alignment);
+  }
+}
+
 void CIRGenFunction::declare(mlir::Value addrVal, const Decl *var, QualType ty,
  mlir::Location loc, CharUnits alignment,
  bool isParam) {
@@ -149,6 +156,118 @@ void CIRGenFunction::declare(mlir::Value addrVal, const 
Decl *var, QualType ty,
 allocaOp.setConstantAttr(mlir::UnitAttr::get(&getMLIRContext()));
 }
 
+void CIRGenFunction::LexicalScope::cleanup() {
+  CIRGenBuilderTy &builder = cgf.builder;
+  LexicalScope *localScope = cgf.curLexScope;
+
+  if (returnBlock != nullptr) {
+// Write out the return block, which loads the value from `__retval` and
+// issues the `cir.return`.
+mlir::OpBuilder::InsertionGuard guard(builder);
+builder.setInsertionPointToEnd(returnBlock);
+(void)emitReturn(*returnLoc);
+  }
+
+  mlir::Block *curBlock = builder.getBlock();
+  if (isGlobalInit() && !curBlock)
+return;
+  if (curBlock->mightHaveT

[clang] [clang-format] Recognize TableGen paste operator on separate line (PR #133722)

2025-04-05 Thread Björn Schäpers via cfe-commits

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


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


[clang] Fix complex long double division with -mno-x87. (PR #133152)

2025-04-05 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/133152

>From 56a000612da3f58928362229a46800c6f077cc71 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Wed, 26 Mar 2025 13:18:36 -0700
Subject: [PATCH 1/3] Fix complex long division with -mno-x87.

---
 clang/lib/CodeGen/CGExprComplex.cpp   |  4 ++
 clang/lib/Sema/SemaExpr.cpp   |  6 ++-
 clang/test/CodeGen/promoted-complex-div.c | 49 +++
 3 files changed, 57 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/promoted-complex-div.c

diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index a7c8b96da6853..184a355734046 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -303,6 +303,10 @@ class ComplexExprEmitter
 // doubles the exponent of SmallerType.LargestFiniteVal)
 if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 <=
 llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  if (!Ctx.getTargetInfo().hasLongDoubleType() &&
+  HigherElementType.getCanonicalType().getUnqualifiedType() ==
+  Ctx.LongDoubleTy)
+return QualType();
   FPHasBeenPromoted = true;
   return Ctx.getComplexType(HigherElementType);
 } else {
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3af6d6c23438f..69a13aff14a00 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15304,8 +15304,10 @@ static void DetectPrecisionLossInComplexDivision(Sema 
&S, SourceLocation OpLoc,
   Ctx.getFloatTypeSemantics(ElementType);
   const llvm::fltSemantics &HigherElementTypeSemantics =
   Ctx.getFloatTypeSemantics(HigherElementType);
-  if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
-  llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
+  if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
+   llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
+  (HigherElementType == Ctx.LongDoubleTy &&
+   !Ctx.getTargetInfo().hasLongDoubleType())) {
 // Retain the location of the first use of higher precision type.
 if (!S.LocationOfExcessPrecisionNotSatisfied.isValid())
   S.LocationOfExcessPrecisionNotSatisfied = OpLoc;
diff --git a/clang/test/CodeGen/promoted-complex-div.c 
b/clang/test/CodeGen/promoted-complex-div.c
new file mode 100644
index 0..02300126965ed
--- /dev/null
+++ b/clang/test/CodeGen/promoted-complex-div.c
@@ -0,0 +1,49 @@
+// RUN %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
+// RUN -verify -complex-range=promoted -o - | FileCheck %s
+
+// RUN %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
+// RUN -verify=nopromotion -complex-range=promoted -target-feature -x87 -o - | 
FileCheck %s --check-prefix=X87
+
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-windows \
+// RUN: -verify=nopromotion -complex-range=promoted -o - | FileCheck %s 
--check-prefix=X87
+
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-windows \
+// RUN: -verify=nopromotion -complex-range=promoted -target-feature -x87 -o - 
| FileCheck %s --check-prefix=X87
+
+
+
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local <2 x float> @divd
+_Complex float divd(_Complex float a, _Complex float b) {
+  // CHECK: fpext float {{.*}} to double
+  // CHECK: fpext float {{.*}} to double
+  // CHECK: fdiv double
+  // CHECK: fdiv double
+  // CHECK: fptrunc double {{.*}} to float
+  // CHECK: fptrunc double {{.*}} to float
+
+  // X87: fpext float {{.*}} to double
+  // X87: fpext float {{.*}} to double
+  // X87: fdiv double
+  // X87: fdiv double
+  // X87: fptrunc double {{.*}} to float
+  // X87: fptrunc double {{.*}} to float
+
+  return a / b;
+}
+
+// CHECK-LABEL: define dso_local { double, double } @divf
+_Complex double divf(_Complex double a, _Complex double b) {
+  // CHECK: fpext double {{.*}} to x86_fp80
+  // CHECK: fpext double {{.*}} to x86_fp80
+  // CHECK: fdiv x86_fp80
+  // CHECK: fdiv x86_fp80
+  // CHECK: fptrunc x86_fp80
+  // CHECK: fptrunc x86_fp80
+
+  // X87: fdiv double
+  // X87: fdiv double
+
+  return a / b; // nopromotion-warning{{excess precision is requested but the 
target does not support excess precision which may result in observable 
differences in complex division behavior}}
+}

>From 15396dc494ee1ea3c18b1221a3aaaf1532d7010d Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Mon, 31 Mar 2025 08:06:43 -0700
Subject: [PATCH 2/3] Addressed Josh's review comments.

---
 clang/test/CodeGen/promoted-complex-div.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/test/CodeGen/promoted-complex-div.c 
b/clang/test/CodeGen/promoted-complex-div.c
index 02300126965ed..ce520f93db4f1 100644
--- a/clang/test/CodeGen/

[clang] [clang][analyzer] Move 'alpha.core.FixedAddressDereference' out of alpha (PR #132404)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Balázs Kéri (balazske)


Changes



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


8 Files Affected:

- (modified) clang/docs/analyzer/checkers.rst (+35-35) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+6-6) 
- (modified) clang/test/Analysis/analyzer-enabled-checkers.c (+1) 
- (modified) clang/test/Analysis/dtor.cpp (+1-1) 
- (modified) clang/test/Analysis/fixed-address-notes.c (+1-1) 
- (modified) clang/test/Analysis/misc-ps.m (+2-2) 
- (modified) clang/test/Analysis/pr22954.c (+1-1) 
- (modified) clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c 
(+1) 


``diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 28286a8a5dba6..c676bef90078f 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -97,6 +97,41 @@ core.DivideZero (C, C++, ObjC)
 .. literalinclude:: checkers/dividezero_example.c
 :language: c
 
+.. _core-FixedAddressDereference:
+
+core.FixedAddressDereference (C, C++, ObjC)
+"""
+Check for dereferences of fixed addresses.
+
+A pointer contains a fixed address if it was set to a hard-coded value or it
+becomes otherwise obvious that at that point it can have only a single specific
+value.
+
+.. code-block:: c
+
+ void test1() {
+   int *p = (int *)0x020;
+   int x = p[0]; // warn
+ }
+
+ void test2(int *p) {
+   if (p == (int *)-1)
+ *p = 0; // warn
+ }
+
+ void test3() {
+   int (*p_function)(char, char);
+   p_function = (int (*)(char, char))0x04080;
+   int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
+ }
+
+If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
+to true (the default value), then this checker never reports dereference of
+pointers with a specified address space. If the option is set to false, then
+reports from the specific x86 address spaces 256, 257 and 258 are still
+suppressed, but fixed address dereferences from other address spaces are
+reported.
+
 .. _core-NonNullParamChecker:
 
 core.NonNullParamChecker (C, C++, ObjC)
@@ -2919,41 +2954,6 @@ Check for assignment of a fixed address to a pointer.
p = (int *) 0x1; // warn
  }
 
-.. _alpha-core-FixedAddressDereference:
-
-alpha.core.FixedAddressDereference (C, C++, ObjC)
-"
-Check for dereferences of fixed addresses.
-
-A pointer contains a fixed address if it was set to a hard-coded value or it
-becomes otherwise obvious that at that point it can have only a single specific
-value.
-
-.. code-block:: c
-
- void test1() {
-   int *p = (int *)0x020;
-   int x = p[0]; // warn
- }
-
- void test2(int *p) {
-   if (p == (int *)-1)
- *p = 0; // warn
- }
-
- void test3() {
-   int (*p_function)(char, char);
-   p_function = (int (*)(char, char))0x04080;
-   int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
- }
-
-If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
-to true (the default value), then this checker never reports dereference of
-pointers with a specified address space. If the option is set to false, then
-reports from the specific x86 address spaces 256, 257 and 258 are still
-suppressed, but fixed address dereferences from other address spaces are
-reported.
-
 .. _alpha-core-PointerArithm:
 
 alpha.core.PointerArithm (C)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 6632254955fe6..a34ddee455720 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -211,6 +211,12 @@ def DereferenceModeling : Checker<"DereferenceModeling">,
   Documentation,
   Hidden;
 
+def FixedAddressDereferenceChecker
+: Checker<"FixedAddressDereference">,
+  HelpText<"Check for dereferences of fixed addresses">,
+  Documentation,
+  Dependencies<[DereferenceModeling]>;
+
 def NullDereferenceChecker : Checker<"NullDereference">,
   HelpText<"Check for dereferences of null pointers">,
   Documentation,
@@ -278,12 +284,6 @@ def FixedAddressChecker : Checker<"FixedAddr">,
   HelpText<"Check for assignment of a fixed address to a pointer">,
   Documentation;
 
-def FixedAddressDereferenceChecker
-: Checker<"FixedAddressDereference">,
-  HelpText<"Check for dereferences of fixed addresses">,
-  Documentation,
-  Dependencies<[DereferenceModeling]>;
-
 def PointerArithChecker : Checker<"PointerArithm">,
   HelpText<"Check for pointer arithmetic on locations other than array "
"elements">,
diff --git a/clang/test/Analysis/analyzer-enabled-checkers.c 
b/clang/test/Analysis/analyzer-enabled-checkers.c
index e5d0acb84a039..66b9be9795f12 100644
--- a/clang/test/Analysis/analyzer-enabled-checkers.c
+++ b/clang/test/Analysis/analyzer-enabled-ch

[clang] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (PR #133871)

2025-04-05 Thread Mats Jun Larsen via cfe-commits

junlarsen wrote:

* **#133871** https://app.graphite.dev/github/pr/llvm/llvm-project/133871?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/133871?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[clang] Revert "[Clang] [NFC] Introduce a helper for emitting compatibility diagnostics" (PR #134036)

2025-04-05 Thread via cfe-commits

https://github.com/Sirraide created 
https://github.com/llvm/llvm-project/pull/134036

Reverts llvm/llvm-project#132348

Some tests are failing and I still need to figure out what is going on here.

>From 12372457f6284197ba610616c3fdd4ddea937d5c Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Wed, 2 Apr 2025 08:28:09 +0200
Subject: [PATCH] =?UTF-8?q?Revert=20"[Clang]=20[NFC]=20Introduce=20a=20hel?=
 =?UTF-8?q?per=20for=20emitting=20compatibility=20diagnosti=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 9d06e0879b5600b19cd8cebd98e4f92b5e62400f.
---
 clang/include/clang/Basic/CMakeLists.txt  | 10 ---
 clang/include/clang/Basic/Diagnostic.td   | 18 -
 clang/include/clang/Basic/DiagnosticAST.h | 12 ---
 .../include/clang/Basic/DiagnosticAnalysis.h  | 12 ---
 clang/include/clang/Basic/DiagnosticComment.h | 12 ---
 clang/include/clang/Basic/DiagnosticCrossTU.h | 12 ---
 clang/include/clang/Basic/DiagnosticDriver.h  | 12 ---
 .../include/clang/Basic/DiagnosticFrontend.h  | 12 ---
 clang/include/clang/Basic/DiagnosticIDs.h | 18 -
 .../clang/Basic/DiagnosticInstallAPI.h| 12 ---
 clang/include/clang/Basic/DiagnosticLex.h | 12 ---
 clang/include/clang/Basic/DiagnosticParse.h   | 12 ---
 .../clang/Basic/DiagnosticParseKinds.td   | 12 +--
 .../clang/Basic/DiagnosticRefactoring.h   | 12 ---
 clang/include/clang/Basic/DiagnosticSema.h| 13 
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +-
 .../clang/Basic/DiagnosticSerialization.h | 12 ---
 clang/include/clang/Parse/Parser.h|  6 --
 clang/include/clang/Sema/SemaBase.h   |  4 -
 clang/lib/Basic/DiagnosticIDs.cpp | 46 
 clang/lib/Parse/ParseDecl.cpp |  7 +-
 clang/lib/Parse/Parser.cpp| 10 ---
 clang/lib/Sema/SemaBase.cpp   |  7 --
 clang/lib/Sema/SemaDecl.cpp   | 11 ++-
 clang/lib/Sema/SemaDeclCXX.cpp| 75 +--
 clang/lib/Sema/SemaExpr.cpp   |  4 +-
 clang/lib/Sema/SemaTemplate.cpp   | 19 -
 clang/test/Misc/show-diag-options.c   |  2 +-
 .../TableGen/ClangDiagnosticsEmitter.cpp  | 44 ---
 clang/utils/TableGen/TableGen.cpp |  6 --
 clang/utils/TableGen/TableGenBackends.h   |  3 -
 31 files changed, 93 insertions(+), 356 deletions(-)

diff --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 6be6d063c20b4..a671d5c764c22 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -8,11 +8,6 @@ macro(clang_diag_gen component)
 -gen-clang-diags-enums -clang-component=${component}
 SOURCE Diagnostic.td
 TARGET ClangDiagnostic${component}Enums)
-
-  clang_tablegen(Diagnostic${component}CompatIDs.inc
--gen-clang-diags-compat-ids -clang-component=${component}
-SOURCE Diagnostic.td
-TARGET ClangDiagnostic${component}CompatIDs)
 endmacro(clang_diag_gen)
 
 clang_diag_gen(Analysis)
@@ -36,11 +31,6 @@ clang_tablegen(DiagnosticIndexName.inc 
-gen-clang-diags-index-name
   SOURCE Diagnostic.td
   TARGET ClangDiagnosticIndexName)
 
-clang_tablegen(DiagnosticAllCompatIDs.inc
-  -gen-clang-diags-compat-ids
-  SOURCE Diagnostic.td
-  TARGET ClangDiagnosticAllCompatIDs)
-
 clang_tablegen(AttrList.inc -gen-clang-attr-list
   -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
   SOURCE Attr.td
diff --git a/clang/include/clang/Basic/Diagnostic.td 
b/clang/include/clang/Basic/Diagnostic.td
index 65b19f3feea4f..b31d846210a8e 100644
--- a/clang/include/clang/Basic/Diagnostic.td
+++ b/clang/include/clang/Basic/Diagnostic.td
@@ -155,19 +155,6 @@ class DefaultWarnNoWerror {
 }
 class DefaultRemark { Severity DefaultSeverity = SEV_Remark; }
 
-class CompatWarningId {
-  string Component = ?;
-  string Name = name;
-  string Diag = diag;
-  string DiagPre = diag_pre;
-  int Std = std;
-
-  // This is unused, but Tablegen will complain if it's missing because we 
define
-  // the compatibility ids in the same place as the other diagnostics (which 
means
-  // that we'll be inside a 'let CategoryName = "" in { ... }' block).
-  string CategoryName = ?;
-}
-
 // C++ compatibility warnings.
 multiclass CXXCompat<
 string message,
@@ -191,11 +178,6 @@ multiclass CXXCompat<
  "CXX98Compat",
  "CXXPre"#std_ver#"Compat"))>,
 DefaultIgnore;
-
-def : CompatWarningId<
-NAME, std_ver,
-"compat_cxx"#std_ver#"_"#NAME,
-"compat_pre_cxx"#std_ver#"_"#NAME>;
 }
 
 // These generate pairs of C++ compatibility warnings of the form:
diff --git a/clang/include/clang/Basic/DiagnosticAST.h 
b/clang/include/clang/Basic/DiagnosticAST.h
index 41e2598f7cc3b..4f82114b7406b 100644
--- a/clang/include/clang/Basic/DiagnosticAST.h
+++ b/clang/include/clang/Basic/DiagnosticAST.h
@@ -36,

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

2025-04-05 Thread Akira Hatanaka via cfe-commits


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

[clang] [C2y] Implement WG14 N3369 and N3469 (_Countof) (PR #133125)

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

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

>From 75ef42d644da9136fb07014ade18b6be137426a1 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Wed, 26 Mar 2025 12:54:29 -0400
Subject: [PATCH 1/3] [C2y] Implement WG14 N3369 and N3469 (_Countof)

C2y adds the _Countof operator which returns the number of elements in
an array. As with sizeof, _Countof either accepts a parenthesized type
name or an expression. Its operand must be (of) an array type. When
passed a constant-size array operand, the operator is a constant
expression which is valid for use as an integer constant expression.

Fixes #102836
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  6 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  5 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/TokenKinds.def  |  2 +
 clang/lib/AST/ExprConstant.cpp| 19 +++-
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp| 15 ++-
 clang/lib/Parse/ParseExpr.cpp | 21 -
 clang/lib/Sema/SemaExpr.cpp   | 39 ++--
 clang/test/C/C2y/n3369.c  | 61 
 clang/test/C/C2y/n3369_1.c| 25 +
 clang/test/C/C2y/n3369_2.c| 92 +++
 clang/test/C/C2y/n3469.c  | 14 +++
 clang/www/c_status.html   |  4 +-
 15 files changed, 288 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/C/C2y/n3369.c
 create mode 100644 clang/test/C/C2y/n3369_1.c
 create mode 100644 clang/test/C/C2y/n3369_2.c
 create mode 100644 clang/test/C/C2y/n3469.c

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index d4771775c9739..8b5707ce2acac 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1653,6 +1653,7 @@ Array & element qualification (N2607) 
 C
 Attributes (N2335) 
C23   C89
 ``#embed`` (N3017) 
C23   C89, C++
 Octal literals prefixed with ``0o`` or ``0O``  
C2y   C89, C++
+``_Countof`` (N3369, N3469)
C2y   C89
 =  
= =
 
 Builtin type aliases
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 04ec2cfef679c..b82e79c092c4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -141,6 +141,12 @@ C2y Feature Support
   paper also introduced octal and hexadecimal delimited escape sequences (e.g.,
   ``"\x{12}\o{12}"``) which are also supported as an extension in older C
   language modes.
+- Implemented `WG14 N3369 
`_
+  which introduces the ``_Lengthof`` operator, and `WG14 N3469 
`_
+  which renamed ``_Lengthof`` to ``_Countof``. This feature is implemented as
+  a conforming extension in earlier C language modes, but not in C++ language
+  modes (``std::extent`` and ``std::rank`` already provide the same
+  functionality but with more granularity).
 
 C23 Feature Support
 ^^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 4dc956f7ae6f7..86c361b4dbcf7 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -171,12 +171,17 @@ def ext_c99_feature : Extension<
   "'%0' is a C99 extension">, InGroup;
 def ext_c11_feature : Extension<
   "'%0' is a C11 extension">, InGroup;
+def ext_c2y_feature : Extension<
+  "'%0' is a C2y extension">, InGroup;
 def warn_c11_compat_keyword : Warning<
   "'%0' is incompatible with C standards before C11">,
   InGroup, DefaultIgnore;
 def warn_c23_compat_keyword : Warning<
  "'%0' is incompatible with C standards before C23">,
  InGroup, DefaultIgnore;
+def warn_c2y_compat_keyword : Warning<
+  "'%0' is incompatible with C standards before C2y">,
+  InGroup, DefaultIgnore;
 
 def err_c11_noreturn_misplaced : Error<
   "'_Noreturn' keyword must precede function declarator">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c77cde297dc32..1e900437d41ce 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7022,6 +7022,8 @@ def err_sizeof_alignof_typeof_bitfield : Error<
   "bit-field">;
 def err_alignof_member_of_incomplete_type : Error<
   "invalid application of 'alignof' to a field of a class still being 

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-04-05 Thread Oliver Hunt via cfe-commits

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


[clang] [Clang] Fix various bugs in alias CTAD transform (PR #132061)

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


@@ -1650,6 +1665,23 @@ namespace {
   return inherited::TransformTemplateArgument(Input, Output, Uneval);
 }
 
+std::optional ComputeSizeOfPackExprWithoutSubstitution(
+ArrayRef PackArgs) {
+  // Don't do this when rewriting template parameters for CTAD:
+  //   1) The heuristic needs the unpacked Subst* nodes to figure out the
+  //   expanded size, but this never applies since Subst* nodes are not
+  //   created in rewrite scenarios.
+  //
+  //   2) The heuristic substitutes into the pattern with pack expansion
+  //   suppressed, which does not meet the requirements for argument
+  //   rewriting when template arguments include a non-pack matching 
against
+  //   a pack, particularly when rewriting an alias CTAD.
+  if (TemplateArgs.isRewrite())
+return std::nullopt;

zyn0217 wrote:

It's not that hard to contrive an example to demonstrate the difference (though 
invalid):

```cpp
template < typename... _Types >
struct variant {
  template 
  variant(_Types...);
};

template 
using AstNode = variant; // <-- Note here!

AstNode tree(42, 43, 44);

```

We still would end up here with a rewrite MLTAL = {int, int, int}, so we fall 
through to the normal way and crash because we don't have a valid SubstIndex 
for a pack

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


[clang] [clang] Merge gtest binaries into AllClangUnitTests (PR #134196)

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

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


[clang] [Clang][Cmake] fix libtool duplicate member name warnings (PR #133619)

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

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

This looks sensible to me.

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


[clang] [flang] [flang] Added driver options for arrays repacking. (PR #134002)

2025-04-05 Thread David Truby via cfe-commits

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

LGTM thanks!

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


[clang] [clang-tools-extra] Revert "[clang] NFC: Clear some uses of MemberPointerType::getClass" (PR #132281)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Matheus Izvekov (mizvekov)


Changes

Reverts llvm/llvm-project#131965

Reverted due to issue reported here: 
https://github.com/llvm/llvm-project/pull/131965#issuecomment-2741619498

---

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


19 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
 (+4-1) 
- (modified) clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp (+2-2) 
- (modified) clang/include/clang/AST/CanonicalType.h (-2) 
- (modified) clang/include/clang/Sema/Sema.h (+3-4) 
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+4-6) 
- (modified) clang/lib/AST/ExprConstant.cpp (+2-3) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (+5-5) 
- (modified) clang/lib/AST/Type.cpp (+9-11) 
- (modified) clang/lib/CodeGen/CGCXXABI.cpp (+3-2) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+4-3) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-2) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+4-4) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1-1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+5-6) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+25-23) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+14-18) 
- (modified) clang/lib/Sema/SemaLookup.cpp (+5-2) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+20-17) 
- (modified) clang/lib/Sema/SemaStmt.cpp (+1-2) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
 
b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
index a8a9e6bdcdff8..9d1d92b989bf1 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
@@ -70,7 +70,10 @@ void ComparePointerToMemberVirtualFunctionCheck::check(
   // compare with variable which type is pointer to member function.
   llvm::SmallVector SameSignatureVirtualMethods{};
   const auto *MPT = cast(DRE->getType().getCanonicalType());
-  const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
+  const Type *T = MPT->getClass();
+  if (T == nullptr)
+return;
+  const CXXRecordDecl *RD = T->getAsCXXRecordDecl();
   if (RD == nullptr)
 return;
 
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index b66cc8512fad6..0fea7946a59f9 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -219,8 +219,8 @@ bool isQualificationConvertiblePointer(QualType From, 
QualType To,
 
 if (P1->isMemberPointerType())
   return P2->isMemberPointerType() &&
- P1->getAs()->getMostRecentCXXRecordDecl() ==
- P2->getAs()->getMostRecentCXXRecordDecl();
+ P1->getAs()->getClass() ==
+ P2->getAs()->getClass();
 
 if (P1->isConstantArrayType())
   return P2->isConstantArrayType() &&
diff --git a/clang/include/clang/AST/CanonicalType.h 
b/clang/include/clang/AST/CanonicalType.h
index 50d1ba1b8f63f..6699284d215bd 100644
--- a/clang/include/clang/AST/CanonicalType.h
+++ b/clang/include/clang/AST/CanonicalType.h
@@ -454,8 +454,6 @@ struct CanProxyAdaptor
   : public CanProxyBase {
   LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Type *, getClass)
-  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const CXXRecordDecl *,
-  getMostRecentCXXRecordDecl)
 };
 
 // CanProxyAdaptors for arrays are intentionally unimplemented because
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9724f0def743a..0befe615c4ee1 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5769,11 +5769,10 @@ class Sema final : public SemaBase {
 
   /// Determine whether the type \p Derived is a C++ class that is
   /// derived from the type \p Base.
-  bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
- CXXRecordDecl *Base, CXXBasePaths &Paths);
-  bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived,
- CXXRecordDecl *Base);
   bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base);
+
+  /// Determine whether the type \p Derived is a C++ class that is
+  /// derived from the type \p Base.
   bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base,
  CXXBasePaths &Paths);
 
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 9dc02b25f8495..91640c4eb5cf9 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -238,9 +238,8 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 const auto *FromMP 

[clang] [compiler-rt] Reland [Coverage] Fix region termination for GNU statement expressions (PR #132222)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Justin Cady (justincady)


Changes

Relands #130976 with adjustments to test requirements.

Calls to __noreturn__ functions result in region termination for
coverage mapping. But this creates incorrect coverage results when
__noreturn__ functions (or other constructs that result in region
termination) occur within [GNU statement expressions][1].

In this scenario an extra gap region is introduced within VisitStmt,
such that if the following line does not introduce a new region it
is unconditionally counted as uncovered.

This change adjusts the mapping such that terminate statements
within statement expressions do not propagate that termination
state after the statement expression is processed.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

Fixes #124296


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


3 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+8) 
- (modified) clang/test/CoverageMapping/terminate-statements.cpp (+7) 
- (added) compiler-rt/test/profile/Linux/coverage-statement-expression.cpp 
(+24) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index f09157771d2b5..73811d15979d5 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1505,6 +1505,14 @@ struct CounterCoverageMappingBuilder
 handleFileExit(getEnd(S));
   }
 
+  void VisitStmtExpr(const StmtExpr *E) {
+Visit(E->getSubStmt());
+// Any region termination (such as a noreturn CallExpr) within the 
statement
+// expression has been handled by visiting the sub-statement. The visitor
+// cannot be at a terminate statement leaving the statement expression.
+HasTerminateStmt = false;
+  }
+
   void VisitDecl(const Decl *D) {
 Stmt *Body = D->getBody();
 
diff --git a/clang/test/CoverageMapping/terminate-statements.cpp 
b/clang/test/CoverageMapping/terminate-statements.cpp
index 0067185fee8e6..3f8e43f0fbcb6 100644
--- a/clang/test/CoverageMapping/terminate-statements.cpp
+++ b/clang/test/CoverageMapping/terminate-statements.cpp
@@ -346,6 +346,12 @@ int elsecondnoret(void) {
   return 0;
 }
 
+// CHECK-LABEL: _Z18statementexprnoretb
+int statementexprnoret(bool crash) {
+  int rc = ({ if (crash) abort(); 0; }); // CHECK: File 0, 351:35 -> 352:12 = 
(#0 - #1)
+  return rc; // CHECK-NOT: Gap
+}
+
 int main() {
   foo(0);
   foo(1);
@@ -368,5 +374,6 @@ int main() {
   ornoret();
   abstractcondnoret();
   elsecondnoret();
+  statementexprnoret(false);
   return 0;
 }
diff --git a/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp 
b/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp
new file mode 100644
index 0..19300411d54a2
--- /dev/null
+++ b/compiler-rt/test/profile/Linux/coverage-statement-expression.cpp
@@ -0,0 +1,24 @@
+// REQUIRES: lld-available
+// XFAIL: powerpc64-target-arch
+
+// RUN: %clangxx_profgen -std=gnu++17 -fuse-ld=lld -fcoverage-mapping -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: llvm-cov show %t -instr-profile=%t.profdata 2>&1 | FileCheck %s
+
+#include 
+
+// clang-format off
+__attribute__ ((__noreturn__))
+void foo(void) { while (1); }   // CHECK:  [[@LINE]]| 0|void 
foo(void)
+_Noreturn void bar(void) { while (1); } // CHECK:  [[@LINE]]| 
0|_Noreturn void bar(void)
+// CHECK:  [[@LINE]]|  |
+int main(int argc, char **argv) {   // CHECK:  [[@LINE]]| 1|int 
main(
+  int rc = ({ if (argc > 3) foo(); 0; });   // CHECK:  [[@LINE]]| 1|  int 
rc =
+  printf("coverage after foo is present\n");// CHECK:  [[@LINE]]| 1|  
printf(
+// CHECK:  [[@LINE]]|  |
+  int rc2 = ({ if (argc > 3) bar(); 0; });  // CHECK:  [[@LINE]]| 1|  int 
rc2 =
+  printf("coverage after bar is present\n");// CHECK:  [[@LINE]]| 1|  
printf(
+  return rc + rc2;  // CHECK:  [[@LINE]]| 1|  
return rc
+}   // CHECK:  [[@LINE]]| 1|}
+// clang-format on

``




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


[clang] [alpha.webkit.ForwardDeclChecker] Ignore forward declared struct. (PR #133804)

2025-04-05 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp
index 399ae9e0a..2c63224df 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp
@@ -127,8 +127,8 @@ public:
 auto Name = R->getName();
 return !R->hasDefinition() && !RTC.isUnretained(QT) &&
!SystemTypes.contains(CanonicalType) &&
-   !SystemTypes.contains(PointeeType) &&
-   !Name.starts_with("Opaque") && Name != "_NSZone";
+   !SystemTypes.contains(PointeeType) && !Name.starts_with("Opaque") &&
+   Name != "_NSZone";
   }
 
   void visitRecordDecl(const RecordDecl *RD, const Decl *DeclWithIssue) const {

``




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


[clang] 976a384 - [clang] implement common-sugar for adjusted member-pointers (#133613)

2025-04-05 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2025-03-30T01:45:00-03:00
New Revision: 976a384ba67adf059ab9fe5550e7e67b6fc53396

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

LOG: [clang] implement common-sugar for adjusted member-pointers (#133613)

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/SemaCXX/sugar-common-types.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c9d1bea4c623a..2d9480ebcf00c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14135,7 +14135,6 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, 
const Type *X,
 CANONICAL_TYPE(IncompleteArray)
 CANONICAL_TYPE(HLSLAttributedResource)
 CANONICAL_TYPE(LValueReference)
-CANONICAL_TYPE(MemberPointer)
 CANONICAL_TYPE(ObjCInterface)
 CANONICAL_TYPE(ObjCObject)
 CANONICAL_TYPE(ObjCObjectPointer)
@@ -14313,6 +14312,15 @@ static QualType getCommonSugarTypeNode(ASTContext 
&Ctx, const Type *X,
   return QualType();
 return Ctx.getUsingType(CD, Ctx.getQualifiedType(Underlying));
   }
+  case Type::MemberPointer: {
+const auto *PX = cast(X),
+   *PY = cast(Y);
+CXXRecordDecl *Cls = PX->getMostRecentCXXRecordDecl();
+assert(Cls == PY->getMostRecentCXXRecordDecl());
+return Ctx.getMemberPointerType(
+::getCommonPointeeType(Ctx, PX, PY),
+::getCommonQualifier(Ctx, PX, PY, /*IsSame=*/false), Cls);
+  }
   case Type::CountAttributed: {
 const auto *DX = cast(X),
*DY = cast(Y);

diff  --git a/clang/test/SemaCXX/sugar-common-types.cpp 
b/clang/test/SemaCXX/sugar-common-types.cpp
index a21032517b2ba..d58f6cdd900fc 100644
--- a/clang/test/SemaCXX/sugar-common-types.cpp
+++ b/clang/test/SemaCXX/sugar-common-types.cpp
@@ -186,3 +186,19 @@ namespace arrays {
 // expected-error@-1 {{lvalue of type 'const volatile volatile B1[1]' (aka 
'const volatile volatile int[1]')}}
   } // namespace balanced_qualifiers
 } // namespace arrays
+
+namespace member_pointers {
+  template  struct W {
+X1 a;
+Y1 b;
+  };
+  struct W1 : W {};
+  struct W2 : W {};
+
+  N t1 = 0 ? &W::a : &W::b;
+  // expected-error@-1 {{rvalue of type 'B1 W::*'}}
+
+  // FIXME: adjusted MemberPointer does not preserve qualifier
+  N t3 = 0 ? &W1::a : &W2::b;
+  // expected-error@-1 {{rvalue of type 'B1 W::*'}}
+} // namespace member_pointers



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


[clang] [clang-tools-extra] [clang] improve class type sugar preservation in pointers to members (PR #130537)

2025-04-05 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] Do not share ownership of `HeaderSearchOptions` (PR #132984)

2025-04-05 Thread Ben Langmuir via cfe-commits


@@ -48,7 +48,7 @@ void ASTMergeAction::ExecuteAction() {
 /*ShouldOwnClient=*/true));
 std::unique_ptr Unit = ASTUnit::LoadFromASTFile(
 ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything, 
Diags,
-CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr());
+CI.getFileSystemOpts(), CI.getHeaderSearchOpts());

benlangmuir wrote:

@adrian-prantl I think this change would mean that `LoadFromASTFile` would no 
longer modify the header search options on `CI` here.  I'm not familiar with 
the ASTMerge code; do you know if that is okay?

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


[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)

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


@@ -3194,18 +3194,12 @@ bool Lexer::LexEndOfFile(Token &Result, const char 
*CurPtr) {
 SourceLocation EndLoc = getSourceLocation(BufferEnd);
 unsigned DiagID = diag::warn_no_newline_eof;
 
-if (LangOpts.CPlusPlus11) {
-  // C++11 [lex.phases] 2.2 p2
-  // Prefer the C++98 pedantic compatibility warning over the generic,
-  // non-extension, user-requested "missing newline at EOF" warning.
-  if (!Diags.isIgnored(diag::warn_cxx98_compat_no_newline_eof, EndLoc))
-DiagID = diag::warn_cxx98_compat_no_newline_eof;
-} else {
-  // This is conforming in C2y, but is an extension in earlier language
-  // modes.
-  if (!LangOpts.C2y)
-DiagID = diag::ext_no_newline_eof;
-}
+// C++11 [lex.phases] 2.2 p2
+// Prefer the C++98 pedantic compatibility warning over the generic,
+// non-extension, user-requested "missing newline at EOF" warning.
+if (LangOpts.CPlusPlus11 &&

erichkeane wrote:

It isn't clear what the status of this in C++98 actually is, right?  I guess 
this is before WG21 was all crazy about everything-as-a-DR so we don't have 
much guidance here from them, but it feels DR-ish for both.


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


[clang] Reapply "[cmake] Refactor clang unittest cmake" (PR #134195)

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

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


[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-05 Thread Piotr Zegar via cfe-commits


@@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext 
&Context,
 llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false);
 LowerValue.setBit(PrecisionBits);
 LowerValue.setSignBit();
-return {LowerValue, UpperValue};
+return {std::move(LowerValue), UpperValue};

PiotrZSL wrote:

this doesn't have any impact.
And if using move, why not for a second too

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


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

2025-04-05 Thread via cfe-commits


@@ -14689,18 +14934,24 @@ void Sema::LookupOverloadedBinOp(OverloadCandidateSet 
&CandidateSet,
   // rewritten candidates using these functions if necessary.
   AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
 
+  // As template candidates are not deduced immediately,
+  // persist the arry in the overload set.

Sirraide wrote:

```suggestion
  // persist the array in the overload set.
```

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


[clang] [llvm] [HLSL][RootSignature] Implement parsing of a DescriptorTable with empty clauses (PR #133302)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Finn Plummer (inbelic)


Changes

- defines the Parser class and an initial set of helper methods to
support consuming tokens. functionality is demonstrated through a simple
empty descriptor table test case
- defines an initial in-memory representation of a DescriptorTable
- implements a test harness that will be used to validate the correct
diagnostics are generated. it will construct a dummy pre-processor with
diagnostics consumer to do so

---

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


10 Files Affected:

- (modified) clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def (+11-11) 
- (modified) clang/include/clang/Lex/LexHLSLRootSignature.h (+1-1) 
- (added) clang/include/clang/Parse/ParseHLSLRootSignature.h (+110) 
- (modified) clang/lib/Parse/CMakeLists.txt (+1) 
- (added) clang/lib/Parse/ParseHLSLRootSignature.cpp (+188) 
- (modified) clang/unittests/CMakeLists.txt (+1) 
- (modified) clang/unittests/Lex/LexHLSLRootSignatureTest.cpp (+1-1) 
- (added) clang/unittests/Parse/CMakeLists.txt (+23) 
- (added) clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp (+244) 
- (added) llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h (+44) 


``diff
diff --git a/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def 
b/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
index e6df763920430..697c6abc54efa 100644
--- a/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
+++ b/clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def
@@ -14,16 +14,16 @@
 
//===--===//
 
 #ifndef TOK
-#define TOK(X)
+#define TOK(X, SPELLING)
 #endif
 #ifndef PUNCTUATOR
-#define PUNCTUATOR(X,Y) TOK(pu_ ## X)
+#define PUNCTUATOR(X,Y) TOK(pu_ ## X, Y)
 #endif
 #ifndef KEYWORD
-#define KEYWORD(X) TOK(kw_ ## X)
+#define KEYWORD(X) TOK(kw_ ## X, #X)
 #endif
 #ifndef ENUM
-#define ENUM(NAME, LIT) TOK(en_ ## NAME)
+#define ENUM(NAME, LIT) TOK(en_ ## NAME, LIT)
 #endif
 
 // Defines the various types of enum
@@ -49,15 +49,15 @@
 #endif
 
 // General Tokens:
-TOK(invalid)
-TOK(end_of_stream)
-TOK(int_literal)
+TOK(invalid, "invalid identifier")
+TOK(end_of_stream, "end of stream")
+TOK(int_literal, "integer literal")
 
 // Register Tokens:
-TOK(bReg)
-TOK(tReg)
-TOK(uReg)
-TOK(sReg)
+TOK(bReg, "b register")
+TOK(tReg, "t register")
+TOK(uReg, "u register")
+TOK(sReg, "s register")
 
 // Punctuators:
 PUNCTUATOR(l_paren, '(')
diff --git a/clang/include/clang/Lex/LexHLSLRootSignature.h 
b/clang/include/clang/Lex/LexHLSLRootSignature.h
index 21c44e0351d9e..b82237411b2ab 100644
--- a/clang/include/clang/Lex/LexHLSLRootSignature.h
+++ b/clang/include/clang/Lex/LexHLSLRootSignature.h
@@ -24,7 +24,7 @@ namespace hlsl {
 
 struct RootSignatureToken {
   enum Kind {
-#define TOK(X) X,
+#define TOK(X, SPELLING) X,
 #include "clang/Lex/HLSLRootSignatureTokenKinds.def"
   };
 
diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h 
b/clang/include/clang/Parse/ParseHLSLRootSignature.h
new file mode 100644
index 0..bd593fa3e8873
--- /dev/null
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -0,0 +1,110 @@
+//===--- ParseHLSLRootSignature.h ---*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines the ParseHLSLRootSignature interface.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
+#define LLVM_CLANG_PARSE_PARSEHLSLROOTSIGNATURE_H
+
+#include "clang/Basic/DiagnosticParse.h"
+#include "clang/Lex/LexHLSLRootSignature.h"
+#include "clang/Lex/Preprocessor.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+
+#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
+
+namespace clang {
+namespace hlsl {
+
+class RootSignatureParser {
+public:
+  RootSignatureParser(SmallVector &Elements,
+  RootSignatureLexer &Lexer, clang::Preprocessor &PP);
+
+  /// Consumes tokens from the Lexer and constructs the in-memory
+  /// representations of the RootElements. Tokens are consumed until an
+  /// error is encountered or the end of the buffer.
+  ///
+  /// Returns true if a parsing error is encountered.
+  bool Parse();
+
+private:
+  DiagnosticsEngine &Diags() { return PP.getDiagnostics(); }
+
+  // All private Parse.* methods follow a similar pattern:
+  //   - Each method will start with an assert to denote what the CurToken is
+  // expected to be and will parse from that token forward
+  //
+  //   - Therefore, it is the callers responsibility to ensure that you are
+  // at the correct 

[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

2025-04-05 Thread Alexey Bataev via cfe-commits

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

LG with a nit

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


[clang] [flang] [llvm] [AMDGPU] Use a target feature to enable __builtin_amdgcn_global_load_lds on gfx9/10 (PR #133055)

2025-04-05 Thread Juan Manuel Martinez Caamaño via cfe-commits

jmmartinez wrote:

I've added a commit to have a common attribute that we could use for both, 
global-load-lds and buffer-load-lds builtins.

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


[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #133524)

2025-04-05 Thread Ayush Pareek via cfe-commits

https://github.com/ayushpareek2003 created 
https://github.com/llvm/llvm-project/pull/133524

-Optimized addModuleFiles functions for both CompilerInvocation and 
CowCompilerInvocation to reduce redundant function calls and improve efficiency

-Introduced memory preallocation using reserve() when eager load is enabled to 
reduce reallocation overhead

-Used try_emplace() instead of insert() for PrebuiltModuleFiles to avoid 
unnecessary overwrites

>From 8fb08ccb6e6a0c8e47a61d7760a2a863dada4626 Mon Sep 17 00:00:00 2001
From: Ayush Pareek 
Date: Sat, 29 Mar 2025 03:19:16 +0530
Subject: [PATCH] Optimize Module Dependency Handling for Efficient Memory
 Usage

-Optimized addModuleFiles functions for both CompilerInvocation and 
CowCompilerInvocation to reduce redundant function calls and improve efficiency

-Introduced memory preallocation using reserve() when eager load is enabled to 
reduce reallocation overhead

-Used try_emplace() instead of insert() for PrebuiltModuleFiles to avoid 
unnecessary overwrites
---
 .../DependencyScanning/ModuleDepCollector.cpp | 59 ---
 1 file changed, 38 insertions(+), 21 deletions(-)

diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 364f156566855..6a5876ef921b6 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -396,40 +396,57 @@ void ModuleDepCollector::addModuleMapFiles(
   if (Service.shouldEagerLoadModules())
 return; // Only pcm is needed for eager load.
 
+  // Preallocate memory to avoid multiple allocations
+  CI.getFrontendOpts().ModuleMapFiles.reserve(
+   CI.getFrontendOpts().ModuleMapFiles.size() + ClangModuleDeps.size());
   for (const ModuleID &MID : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(MID);
-assert(MD && "Inconsistent dependency info");
-CI.getFrontendOpts().ModuleMapFiles.push_back(MD->ClangModuleMapFile);
+if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) { // Single lookup
+   assert(MD && "Inconsistent dependency info");
+   
CI.getFrontendOpts().ModuleMapFiles.emplace_back(MD->ClangModuleMapFile);
+ }
   }
 }
 
 void ModuleDepCollector::addModuleFiles(
 CompilerInvocation &CI, ArrayRef ClangModuleDeps) const {
+   // Preallocate memory if eager load is enabled
+  if (Service.shouldEagerLoadModules()) {
+ CI.getFrontendOpts().ModuleFiles.reserve(
+ CI.getFrontendOpts().ModuleFiles.size() + ClangModuleDeps.size());
+  }
   for (const ModuleID &MID : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(MID);
-std::string PCMPath =
-Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
-
-if (Service.shouldEagerLoadModules())
-  CI.getFrontendOpts().ModuleFiles.push_back(std::move(PCMPath));
-else
-  CI.getHeaderSearchOpts().PrebuiltModuleFiles.insert(
-  {MID.ModuleName, std::move(PCMPath)});
+if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) {  
+  std::string PCMPath =
+   Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
+  
+  if (Service.shouldEagerLoadModules()) {
+CI.getFrontendOpts().ModuleFiles.emplace_back(std::move(PCMPath));
+  } else {
+CI.getHeaderSearchOpts().PrebuiltModuleFiles.try_emplace(
+MID.ModuleName, std::move(PCMPath));
+  }
+}
   }
 }
 
 void ModuleDepCollector::addModuleFiles(
 CowCompilerInvocation &CI, ArrayRef ClangModuleDeps) const {
+   // Preallocation
+   if (Service.shouldEagerLoadModules()) {
+ CI.getMutFrontendOpts().ModuleFiles.reserve(
+ CI.getMutFrontendOpts().ModuleFiles.size() + ClangModuleDeps.size());
+   }
   for (const ModuleID &MID : ClangModuleDeps) {
-ModuleDeps *MD = ModuleDepsByID.lookup(MID);
-std::string PCMPath =
-Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
-
-if (Service.shouldEagerLoadModules())
-  CI.getMutFrontendOpts().ModuleFiles.push_back(std::move(PCMPath));
-else
-  CI.getMutHeaderSearchOpts().PrebuiltModuleFiles.insert(
-  {MID.ModuleName, std::move(PCMPath)});
+if (ModuleDeps *MD = ModuleDepsByID.lookup(MID)) {
+  std::string PCMPath =
+   Controller.lookupModuleOutput(*MD, ModuleOutputKind::ModuleFile);
+  if (Service.shouldEagerLoadModules()) {
+ CI.getMutFrontendOpts().ModuleFiles.emplace_back(std::move(PCMPath));
+  } else {
+CI.getMutHeaderSearchOpts().PrebuiltModuleFiles.try_emplace(
+ MID.ModuleName, std::move(PCMPath));
+  }
+}
   }
 }
 

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


[clang] [profile] Add a clang option -fprofile-continuous that enables continuous instrumentation profiling mode (PR #124353)

2025-04-05 Thread Zequan Wu via cfe-commits


@@ -785,6 +786,34 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Val;
   }
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_continuous)) {
+if (!PGOGenerateArg && !CSPGOGenerateArg && !ProfileGenerateArg)
+  D.Diag(clang::diag::err_drv_argument_only_allowed_with)
+  << A->getSpelling()
+  << "-fprofile-generate, -fprofile-instr-generate, or "
+ "-fcs-profile-generate";
+else {
+  CmdArgs.push_back("-fprofile-continuous");
+  // Platforms that require a bias variable:
+  if (T.isOSFuchsia() || T.isOSBinFormatELF() || T.isOSAIX()) {
+CmdArgs.push_back("-mllvm");

ZequanWu wrote:

NVM, https://github.com/llvm/llvm-project/commit/9ef7287d425 already added it 
for windows.

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


[clang] [CLANG-CL] ignores wpadded (PR #130182)

2025-04-05 Thread Mikael Holmén via cfe-commits


@@ -3004,6 +3010,15 @@ void MicrosoftRecordLayoutBuilder::layoutField(const 
FieldDecl *FD) {
   } else {
 FieldOffset = Size.alignTo(Info.Alignment);
   }
+
+  uint64_t UnpaddedFielddOffsetInBits =
+  Context.toBits(DataSize) - RemainingBitsInField;

mikaelholmen wrote:

Do we know why the failed bots didn't show up as comments in this PR? 

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


[libclc] libclc: erfc: fix fp32 implementation (PR #132390)

2025-04-05 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr created 
https://github.com/llvm/llvm-project/pull/132390

On some implementation, the current implementation lead to slight accuracy 
issues.
While the maths behing this implementation is correct, it does not take into 
account the accumulation of errors coming from other operators that do not 
provide correct rounding (like the exp function).
To avoid it, compute staticaly exp(-0.5625).

Fix #391536453

>From bf79eec4f768bbc0e7e1ea41d468751de83193fb Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
Date: Fri, 21 Mar 2025 13:51:41 +0100
Subject: [PATCH] libclc: erfc: fix fp32 implementation

On some implementation, the current implementation lead to slight
accuracy issues.
While the maths behing this implementation is correct, it does not
take into account the accumulation of errors coming from other
operators that do not provide correct rounding (like the exp
function).
To avoid it, compute staticaly exp(-0.5625).

Fix #391536453
---
 libclc/generic/lib/math/erf.cl  | 11 ++-
 libclc/generic/lib/math/erfc.cl | 11 ++-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libclc/generic/lib/math/erf.cl b/libclc/generic/lib/math/erf.cl
index 8349f306a63f7..79fdecdc866fd 100644
--- a/libclc/generic/lib/math/erf.cl
+++ b/libclc/generic/lib/math/erf.cl
@@ -23,7 +23,7 @@
 
 #define erx   8.4506291151e-01f/* 0x3f58560b */
 
-// Coefficients for approximation to  erf on [00.84375]
+// Coefficients for approximation to  erf on [0, 0.84375]
 
 #define efx   1.2837916613e-01f/* 0x3e0375d4 */
 #define efx8  1.0270333290e+00f/* 0x3f8375d4 */
@@ -39,7 +39,7 @@
 #define qq4   1.3249473704e-04f/* 0x390aee49 */
 #define qq5  -3.9602282413e-06f/* 0xb684e21a */
 
-// Coefficients for approximation to  erf  in [0.843751.25]
+// Coefficients for approximation to  erf  in [0.84375, 1.25]
 
 #define pa0  -2.3621185683e-03f/* 0xbb1acdc6 */
 #define pa1   4.1485610604e-01f/* 0x3ed46805 */
@@ -55,7 +55,7 @@
 #define qa5   1.3637083583e-02f/* 0x3c5f6e13 */
 #define qa6   1.1984500103e-02f/* 0x3c445aa3 */
 
-// Coefficients for approximation to  erfc in [1.251/0.35]
+// Coefficients for approximation to  erfc in [1.25, 1/0.35]
 
 #define ra0  -9.8649440333e-03f/* 0xbc21a093 */
 #define ra1  -6.9385856390e-01f/* 0xbf31a0b7 */
@@ -74,7 +74,7 @@
 #define sa7   6.5702495575e+00f/* 0x40d23f7c */
 #define sa8  -6.0424413532e-02f/* 0xbd777f97 */
 
-// Coefficients for approximation to  erfc in [1/.3528]
+// Coefficients for approximation to  erfc in [1/0.35, 28]
 
 #define rb0  -9.8649431020e-03f/* 0xbc21a092 */
 #define rb1  -7.9928326607e-01f/* 0xbf4c9dd4 */
@@ -130,7 +130,8 @@ _CLC_OVERLOAD _CLC_DEF float erf(float x) {
 
 // |x| < 6
 float z = as_float(ix & 0xf000);
-float r = exp(mad(-z, z, -0.5625f)) * exp(mad(z-absx, z+absx, q));
+float r = exp(-z * z) * exp(mad(z - absx, z + absx, q));
+r *= 0x1.23ba94p-1; // exp(-0.5625)
 r = 1.0f - MATH_DIVIDE(r,  absx);
 ret = absx < 6.0f ? r : ret;
 
diff --git a/libclc/generic/lib/math/erfc.cl b/libclc/generic/lib/math/erfc.cl
index 01526d7ae1eb5..05492972ed434 100644
--- a/libclc/generic/lib/math/erfc.cl
+++ b/libclc/generic/lib/math/erfc.cl
@@ -23,7 +23,7 @@
 
 #define erx_f   8.4506291151e-01f/* 0x3f58560b */
 
-// Coefficients for approximation to  erf on [00.84375]
+// Coefficients for approximation to  erf on [0, 0.84375]
 
 #define efx   1.2837916613e-01f/* 0x3e0375d4 */
 #define efx8  1.0270333290e+00f/* 0x3f8375d4 */
@@ -39,7 +39,7 @@
 #define qq4   1.3249473704e-04f/* 0x390aee49 */
 #define qq5  -3.9602282413e-06f/* 0xb684e21a */
 
-// Coefficients for approximation to  erf  in [0.843751.25]
+// Coefficients for approximation to  erf  in [0.84375, 1.25]
 
 #define pa0  -2.3621185683e-03f/* 0xbb1acdc6 */
 #define pa1   4.1485610604e-01f/* 0x3ed46805 */
@@ -55,7 +55,7 @@
 #define qa5   1.3637083583e-02f/* 0x3c5f6e13 */
 #define qa6   1.1984500103e-02f/* 0x3c445aa3 */
 
-// Coefficients for approximation to  erfc in [1.251/0.35]
+// Coefficients for approximation to  erfc in [1.25, 1/0.35]
 
 #define ra0  -9.8649440333e-03f/* 0xbc21a093 */
 #define ra1  -6.9385856390e-01f/* 0xbf31a0b7 */
@@ -74,7 +74,7 @@
 #define sa7   6.5702495575e+00f/* 0x40d23f7c */
 #define sa8  -6.0424413532e-02f/* 0xbd777f97 */
 
-// Coefficients for approximation to  erfc in [1/.3528]
+// Coefficients for approximation to  erfc in [1/0.35, 28]
 
 #define rb0  -9.8649431020e-03f/* 0xbc21a092 */
 #define rb1  -7.9928326607e-01f/* 0xbf4c9dd4 */
@@ -131,7 +131,8 @@ _CLC_OVERLOAD _CLC_DEF float erfc(float x) {
 float ret = 0.0f;
 
 float z = as_float(ix & 0xf000);
-float r = exp(mad(-z, z, -0.5625f)) * exp(mad(z - absx, z + absx, q));
+float r = exp(-z * z) * exp(mad(z - absx, z

[clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)

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


@@ -0,0 +1,32 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md 
--check-prefix=MD-MyClass-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MyClass-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MyClass
+
+#define DECLARE_METHODS   \
+/**
+ * @brief Declare a method to calculate the sum of two numbers
+ */   \
+int Add(int a, int b) \
+{ \
+return a + b; \
+}
+
+// MD-MyClass: ### Add

ilovepi wrote:

```suggestion
// MD-MYCLASS: ### Add
```
Use all caps for check prefixes 

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


[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

2025-04-05 Thread Alexey Bataev via cfe-commits


@@ -18933,12 +18945,35 @@ static bool actOnOMPReductionKindClause(
 reportOriginalDsa(S, Stack, D, DVar);
 continue;
   }
+  // OpenMP 6.0 [ 7.6.10 ]
+  // Support Reduction over private variables with reduction clause.
+  // A list item in a reduction clause can now be private in the enclosing
+  // context. For orphaned constructs it is assumed to be shared unless the
+  // original(private) modifier appears in the clause.
+  DVar = Stack->getImplicitDSA(D, true);
+  bool IsOrphaned = false;
+  OpenMPDirectiveKind CurrDir = Stack->getCurrentDirective();
+  OpenMPDirectiveKind ParentDir = Stack->getParentDirective();
+  // Check if the construct is orphaned (has no enclosing OpenMP context)
+  IsOrphaned = (ParentDir == OMPD_unknown);
+  IsPrivate =
+  ((isOpenMPPrivate(DVar.CKind) && DVar.CKind != OMPC_reduction &&
+isOpenMPWorksharingDirective(CurrDir) &&
+!isOpenMPParallelDirective(CurrDir) &&
+!isOpenMPTeamsDirective(CurrDir) &&
+!isOpenMPSimdDirective(ParentDir)) ||
+   (IsOrphaned && DVar.CKind == OMPC_unknown) ||
+   RD.OrigSharingModifier != OMPC_ORIGINAL_SHARING_shared);
+  // Disable private handling for OpenMP versions <= 5.2
+  if (S.getLangOpts().OpenMP <= 52)
+IsPrivate = false;

alexey-bataev wrote:

Shall it report an error, if DSA is private for version <= 52? If so, it should 
not change the value of IsPrivate here, instead it shall return IsPrivate or, 
if it cannot be private at all, add an assertion.

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


[clang] [MS][clang] Fix crash on deletion of array of pointers (PR #134088)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-remote-linux-ubuntu` 
running on `as-builder-9` while building `clang` at step 16 
"test-check-lldb-api".

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


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

```
Step 16 (test-check-lldb-api) failure: Test just built components: 
check-lldb-api completed (failure)
 TEST 'lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManySignals.py' FAILED 

Script:
--
/usr/bin/python3.12 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib
 --env 
LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include
 --env 
LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin
 --libcxx-include-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1
 --libcxx-include-target-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1
 --libcxx-library-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu
 --arch aarch64 --build-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex
 --lldb-module-cache-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb 
--compiler 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang 
--dsymutil 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil
 --make /usr/bin/gmake --llvm-tools-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin 
--lldb-obj-root 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb 
--lldb-libs-dir 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib 
--platform-url connect://jetson-agx-2198.lab.llvm.org:1234 
--platform-working-dir /home/ubuntu/lldb-tests --sysroot 
/mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name 
remote-linux --skip-category=lldb-server 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/functionalities/thread/concurrent_events
 -p TestConcurrentManySignals.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
22130ca486b2fb43198453a53eb048cd8a97e9a8)
  clang revision 22130ca486b2fb43198453a53eb048cd8a97e9a8
  llvm revision 22130ca486b2fb43198453a53eb048cd8a97e9a8
Setting up remote platform 'remote-linux'
Connecting to remote platform 'remote-linux' at 
'connect://jetson-agx-2198.lab.llvm.org:1234'...
Connected.
Setting remote platform working directory to '/home/ubuntu/lldb-tests'...
Skipping the following test categories: ['lldb-server', 'dsym', 'gmodules', 
'debugserver', 'objc', 'lldb-dap']

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx 
arguments
FAIL: LLDB 
(/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64)
 :: test (TestConcurrentManySignals.ConcurrentManySignals.test)
==
FAIL: test (TestConcurrentManySignals.ConcurrentManySignals.test)
   Test 100 signals from 100 threads.
--
Traceback (most recent call last):
  File 
"/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 148, in wrapper
return func(*args, **kwargs)
   ^
  File 
"/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentManySignals.py",
 line 16, in test
self.do_thread_actions(num_signal_threads=100)
  File 
"/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/concurrent_base.py",
 line 261, in do_thread_actions
self.assertEqual(
AssertionError: 1 != 0 : Expected main thread (finish) breakpoint to be hit once
Config=aarch64-/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang
--
Ran 1 test in 10.007s

FAILED (failures=1)

--




```



https://github.com/llvm/llvm-project/pull/134088
__

[clang] [llvm] [NVPTX] Auto-Upgrade llvm.nvvm.atomic.load.{inc,dec}.32 (PR #134111)

2025-04-05 Thread Akshay Deodhar via cfe-commits


@@ -2314,6 +2317,12 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, 
CallBase *CI,
 Value *Val = CI->getArgOperand(1);
 Rep = Builder.CreateAtomicRMW(AtomicRMWInst::FAdd, Ptr, Val, MaybeAlign(),
   AtomicOrdering::SequentiallyConsistent);
+  } else if (Name.consume_front("atomic.load.") && Name.consume_back(".32")) {
+Value *Ptr = CI->getArgOperand(0);
+Value *Val = CI->getArgOperand(1);
+auto Op = Name == "inc" ? AtomicRMWInst::UIncWrap : 
AtomicRMWInst::UDecWrap;
+Rep = Builder.CreateAtomicRMW(Op, Ptr, Val, MaybeAlign(),
+  AtomicOrdering::SequentiallyConsistent);

akshayrdeodhar wrote:

The intrinsic does not mention anything about ordering, but I suppose seq_cst 
is the safest?

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


[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

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

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


[clang] [CodeGen] Don't include CGDebugInfo.h in CodeGenFunction.h (NFC) (PR #134100)

2025-04-05 Thread Nikita Popov via cfe-commits

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


[clang-tools-extra] [clang-doc][fix] crashes when generating HTML without `--repository` (PR #131698)

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

ilovepi wrote:

> @ilovepi I see you opened a PR to solve the same issue 
> [here](https://github.com/llvm/llvm-project/pull/131939). Wouldn't be better 
> if I continue working on it with your suggestions? 😅

I'm fine either way, but I wanted some kind of testing so I could verify the 
fix.


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


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

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


@@ -14354,6 +14584,17 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, 
Expr *Fn,
   OverloadingResult OverloadResult =
   CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
 
+  // [C++23][over.call.func]
+  // if overload resolution selects a non-static member function,
+  // the call is ill-formed;
+  if (CSK == OverloadCandidateSet::CSK_AddressOfOverloadSet &&
+  Best != CandidateSet.end()) {

zyn0217 wrote:

Hmmm. I'm surprised this wasn't caught until now. Do you have a test case? (or 
is this something copied from elsewhere?)

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


[clang] [clang] Merge gtest binaries into AllClangUnitTests (PR #134196)

2025-04-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Reid Kleckner (rnk)


Changes

This reduces the size of the clang/unittests build directory by 64% and my 
overall build dir size by 5%. Static linking is the real driving factor here, 
but even if the default build configuration used shared libraries, I don't see 
why we should be building so many unit test binaries.

To make the project more approachable for new contributors, I'm attempting to 
make the build a bit less resource-intensive. Build directory size is a common 
complaint, and this is low-hanging fruit.

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


4 Files Affected:

- (modified) clang/unittests/CMakeLists.txt (+51-2) 
- (modified) clang/unittests/Driver/ModuleCacheTest.cpp (+1-1) 
- (modified) clang/unittests/Interpreter/CMakeLists.txt (+1-1) 
- (modified) clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt (+1-1) 


``diff
diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt
index f3823ba309420..8d4476761e03e 100644
--- a/clang/unittests/CMakeLists.txt
+++ b/clang/unittests/CMakeLists.txt
@@ -15,11 +15,11 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 endif()
 
-# add_clang_unittest(test_name file1.cpp file2.cpp)
+# add_distinct_clang_unittest(test_name file1.cpp file2.cpp)
 #
 # Will compile the list of files together and link against the clang
 # Produces a binary named 'basename(test_name)'.
-function(add_clang_unittest test_name)
+function(add_distinct_clang_unittest test_name)
   cmake_parse_arguments(ARG
 ""
 ""
@@ -47,6 +47,33 @@ function(add_clang_unittest test_name)
   target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})
 endfunction()
 
+define_property(GLOBAL PROPERTY CLANG_UNITTEST_SRCS)
+define_property(GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
+define_property(GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)
+define_property(GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)
+
+# add_clang_unittest(test_name file1.cpp file2.cpp)
+#
+# Adds unittests to the combined AllClangUnitTests binary. The unittest binary
+# is defined after adding all unittest subdirectories.
+function(add_clang_unittest test_name)
+  cmake_parse_arguments(ARG
+""
+""
+"CLANG_LIBS;LINK_LIBS;LLVM_COMPONENTS"
+${ARGN})
+
+  file(RELATIVE_PATH src_prefix "${CMAKE_CURRENT_FUNCTION_LIST_DIR}" 
"${CMAKE_CURRENT_SOURCE_DIR}")
+  set(srcs_prefixed)
+  foreach(src ${ARG_UNPARSED_ARGUMENTS})
+set(srcs_prefixed ${srcs_prefixed} "${src_prefix}/${src}")
+  endforeach()
+  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_SRCS ${srcs_prefixed})
+  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_CLANG_LIBS 
${ARG_CLANG_LIBS})
+  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_LINK_LIBS 
${ARG_LINK_LIBS})
+  set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS 
${ARG_LLVM_COMPONENTS})
+endfunction()
+
 add_subdirectory(Basic)
 add_subdirectory(Lex)
 add_subdirectory(Parse)
@@ -77,3 +104,25 @@ add_subdirectory(Index)
 add_subdirectory(InstallAPI)
 add_subdirectory(Serialization)
 add_subdirectory(Support)
+
+
+# If we're doing a single merged clang unit test binary, add that target after
+# all the previous subdirectories have been processed.
+get_property(SRCS GLOBAL PROPERTY CLANG_UNITTEST_SRCS)
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS)
+get_property(LINK_LIBS GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS)
+get_property(LLVM_COMPONENTS GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS)
+add_distinct_clang_unittest(AllClangUnitTests
+  ${SRCS}
+  CLANG_LIBS
+  ${CLANG_LIBS}
+  LINK_LIBS
+  ${LINK_LIBS}
+  LLVM_COMPONENTS
+  ${LLVM_COMPONENTS}
+)
+
+# The Tooling library has some internal headers. Make those work. If we like
+# the merged clang unit test binary, we can udpate the include paths and make
+# this the default.
+include_directories(Tooling)
diff --git a/clang/unittests/Driver/ModuleCacheTest.cpp 
b/clang/unittests/Driver/ModuleCacheTest.cpp
index 48744415647e6..7aa5047c59bd3 100644
--- a/clang/unittests/Driver/ModuleCacheTest.cpp
+++ b/clang/unittests/Driver/ModuleCacheTest.cpp
@@ -17,7 +17,7 @@ using namespace clang::driver;
 
 namespace {
 
-TEST(ModuleCacheTest, GetTargetAndMode) {
+TEST(DriverModuleCacheTest, GetTargetAndMode) {
   SmallString<128> Buf;
   Driver::getDefaultModuleCachePath(Buf);
   StringRef Path = Buf;
diff --git a/clang/unittests/Interpreter/CMakeLists.txt 
b/clang/unittests/Interpreter/CMakeLists.txt
index 9df1a4b03da47..1dda9024075a1 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_clang_unittest(ClangReplInterpreterTests
+add_distinct_clang_unittest(ClangReplInterpreterTests
   IncrementalCompilerBuilderTest.cpp
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
diff --git a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt 
b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
index eb366a860661c..dfd94d8e6442c 

[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-05 Thread Ankur Ahir via cfe-commits

https://github.com/Ankur-0429 updated 
https://github.com/llvm/llvm-project/pull/133878

>From 289f8630dccf916b8cf7cc43758bae60df036c5d Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 1/3] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..431ae0863d9e4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now Supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of file

>From 78fecd58986e25147b47220ee9ef0a392c45651e Mon Sep 17 00:00:00 2001
From: Ankur Ahir 
Date: Wed, 2 Apr 2025 00:53:33 -0700
Subject: [PATCH 2/3] clang frontend crash with friend class declaration and
 overloaded operator ==

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaDeclCXX.cpp   |  3 +--
 .../class/class.compare/class.compare.default/p1.cpp | 12 
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index daad01919ecd4..88ed3018c58ea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -342,6 +342,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations
 - Clang now diagnoses copy constructors taking the class by value in template 
instantiations. (#GH130866)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Clang now prints the correct instantiation context for diagnostics suppressed
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 676d53a1f4b45..d1516860dfe71 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9037,8 +9037,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index a195e0548152d..5db4f05da552c 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -285,3 +285,15 @@ struct j {
 };
 bool j::operator==(const j &) const = default;
 }
+
+namespace evil2 {
+  struct k {
+  };
+  
+  struct l {
+  friend bool operator==(const l& a, const l& b);
+  friend class k;
+  };
+  
+  bool operator==(const l& a, const l& b) = default;
+}
\ No newline at end of f

[clang] [clang][HeuristicResolver] Default argument heuristic for template parameters (PR #132465)

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

HighCommander4 wrote:

This was previously submitted and approved at 
https://github.com/llvm/llvm-project/pull/131074, I just mistakenly merged that 
into a user branch.

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


[clang] [llvm] [ARM][Clang] Make `+nosimd` functional for AArch32 Targets (PR #130623)

2025-04-05 Thread Jack Styles via cfe-commits


@@ -0,0 +1,31 @@
+// Ensures that when targeting an ARM target with an Asm file, clang
+// collects the features from the FPU. This is critical in the
+// activation of NEON for supported targets. The Cortex-R52 will be
+// used and tested for VFP and NEON Support
+
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null | 
count 0
+// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null -### 
2> %t | FileCheck --check-prefix=CHECK-TARGET-FEATURES < %t %s

Stylie777 wrote:

Done

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


[clang] fixed clang frontend crash with friend class declaration and overload == (PR #133878)

2025-04-05 Thread via cfe-commits


@@ -355,6 +355,7 @@ Bug Fixes to Attribute Support
 Bug Fixes to C++ Support
 
 
+- Clang Now supports Implicitly-Defined Comparison Operators for 
Friend-Declarations

cor3ntin wrote:

```suggestion
- Clang now supports implicitly defined comparison operators for friend 
declarations. (#GH132249)
```

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


[clang-tools-extra] [clangd] Add `HeaderInsertion` yaml config option (PR #128503)

2025-04-05 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [llvm] [LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. (PR #130973)

2025-04-05 Thread Paul Walker via cfe-commits


@@ -2034,6 +2071,18 @@ static Value *convertValue(const DataLayout &DL, 
IRBuilderTy &IRB, Value *V,
 }
   }
 
+  if (isa(NewTy) && isa(OldTy)) {
+auto *Ty = VectorType::getWithSizeAndScalar(cast(NewTy), 
OldTy);
+V = IRB.CreateInsertVector(Ty, PoisonValue::get(Ty), V, IRB.getInt64(0));
+return IRB.CreateBitCast(V, NewTy);
+  }
+
+  if (isa(NewTy) && isa(OldTy)) {
+auto *Ty = VectorType::getWithSizeAndScalar(cast(OldTy), 
NewTy);
+V = IRB.CreateBitCast(V, Ty);
+return IRB.CreateExtractVector(NewTy, V, IRB.getInt64(0));
+  }

paulwalker-arm wrote:

I've extended the coverage to input pointer casts but creating a wrapper 
function so that existing uses of CreateBitCast are replaced with a variant 
that supports bit casting between fixed and scalable vector types.

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


[clang] [Clang] emit -Wunused-variable warning for unused structured bindings without the [[maybe_unused]] attribute (PR #127061)

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

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

>From a76ee008bdb87655da465e21d09c840edecc2b1b Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Thu, 13 Feb 2025 15:24:09 +0200
Subject: [PATCH 1/2] [Clang] emit -Wunused-variable warning for unused
 structured bindings without the [[maybe_unused]] attribute

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/Sema/SemaDecl.cpp|  9 +
 clang/test/SemaCXX/unused-bindings.cpp | 17 +
 clang/test/SemaCXX/unused.cpp  |  3 ++-
 4 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/SemaCXX/unused-bindings.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6344c4b36e357..4f20415ec006d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -160,6 +160,8 @@ Bug Fixes to C++ Support
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - The initialization kind of elements of structured bindings
   direct-list-initialized from an array is corrected to direct-initialization.
+- Clang now emits the ``-Wunused-variable`` warning when some structured 
bindings are unused
+  and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6eedc77ed20a0..19a73a66be5af 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1921,13 +1921,14 @@ static bool ShouldDiagnoseUnusedDecl(const LangOptions 
&LangOpts,
 // For a decomposition declaration, warn if none of the bindings are
 // referenced, instead of if the variable itself is referenced (which
 // it is, by the bindings' expressions).
-bool IsAllPlaceholders = true;
+bool IsAllIgnored = true;
 for (const auto *BD : DD->bindings()) {
-  if (BD->isReferenced() || BD->hasAttr())
+  if (BD->isReferenced())
 return false;
-  IsAllPlaceholders = IsAllPlaceholders && BD->isPlaceholderVar(LangOpts);
+  IsAllIgnored = IsAllIgnored && (BD->isPlaceholderVar(LangOpts) ||
+  BD->hasAttr());
 }
-if (IsAllPlaceholders)
+if (IsAllIgnored)
   return false;
   } else if (!D->getDeclName()) {
 return false;
diff --git a/clang/test/SemaCXX/unused-bindings.cpp 
b/clang/test/SemaCXX/unused-bindings.cpp
new file mode 100644
index 0..01f2126133a20
--- /dev/null
+++ b/clang/test/SemaCXX/unused-bindings.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c -Wunused %s
+
+namespace GH125810 {
+struct S {
+  int a, b;
+};
+
+void t(S s) {
+  auto &[_, _] = s;
+  auto &[a1, _] = s; // expected-warning {{unused variable '[a1, _]'}}
+  auto &[_, b2] = s; // expected-warning {{unused variable '[_, b2]'}}
+
+  auto &[a3 [[maybe_unused]], b3 [[maybe_unused]]] = s;
+  auto &[a4, b4 [[maybe_unused]]] = s; // expected-warning {{unused variable 
'[a4, b4]'}}
+  auto &[a5 [[maybe_unused]], b5] = s; // expected-warning {{unused variable 
'[a5, b5]'}}
+}
+}
diff --git a/clang/test/SemaCXX/unused.cpp b/clang/test/SemaCXX/unused.cpp
index 1f40c1b1ca903..ab728069f2faf 100644
--- a/clang/test/SemaCXX/unused.cpp
+++ b/clang/test/SemaCXX/unused.cpp
@@ -114,7 +114,8 @@ namespace maybe_unused_binding {
 
 void test() {
   struct X { int a, b; } x;
-  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}}
+  auto [a [[maybe_unused]], b] = x; // expected-warning {{an attribute 
specifier sequence attached to a structured binding declaration is a C++2c 
extension}} \
+// expected-warning {{unused variable '[a, 
b]'}}
 }
 
 }

>From c600c2a2378310c3f2fc82edaca66ca80b40284d Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 14 Feb 2025 13:43:53 +0200
Subject: [PATCH 2/2] update test to use std c++26

---
 clang/test/SemaCXX/unused-bindings.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/SemaCXX/unused-bindings.cpp 
b/clang/test/SemaCXX/unused-bindings.cpp
index 01f2126133a20..83250dd4b0a11 100644
--- a/clang/test/SemaCXX/unused-bindings.cpp
+++ b/clang/test/SemaCXX/unused-bindings.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c -Wunused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++26 -Wunused %s
 
 namespace GH125810 {
 struct S {

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


[clang] [Clang] Fix the assertion condition after b8d1f3d6 (PR #132669)

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

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


[clang] [CMAKE][AMDGPU] fix build failure caused by PR #133619 (PR #133776)

2025-04-05 Thread Farzon Lotfi via cfe-commits

farzonl wrote:

> I tried to build it locally and I got a series of 'undefined reference' 
> errors. Sorry, I will need to revert my approval. Attn. @jhuber6
> 
> Thanks

Could you provide the failures you were seeing, specific build instructions,  
and platform you were doing this on.

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


[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

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

carlosgalvezp wrote:

> Hi, I tried to explain everything here:

Thanks, I missed that! For RFCs it's preferable to use 
[Discourse](https://discourse.llvm.org/c/clang/clang-tidy/71), as there is a 
lot less traffic and can more easily catch the eyes of relevant people. I did 
not see much discussion in the original RFC though, which may hint that not 
many people were aware. 

My understanding is that the goal is to avoid rebuilding clang-tidy/plugins to 
be able to add new simple checks via .clang-tidy file. I see the benefit of 
this, however I'm not sure it justifies introducing this dependency from 
`clang-tidy` to `clang-query` in the build system. 

Do you know how much build times and binary size are affected by this change? 
Are there any drawbacks of this now tight coupling between clang-tidy and 
clang-query, from an architectural/design point of view?

I tagged @AaronBallman in the code comment but maybe it's easier to bring it up 
in the top-level discussion (sorry for the double ping!)


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


[clang] [flang] [flang] Complete alignment of -x language modes with gfortran (PR #133775)

2025-04-05 Thread David Truby via cfe-commits

https://github.com/DavidTruby updated 
https://github.com/llvm/llvm-project/pull/133775

>From aeca7c2c7bf4cc7aef87374f3890f2a42e61d07d Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Mon, 31 Mar 2025 19:39:37 +0100
Subject: [PATCH 1/2] [flang] Complete alignment of -x language modes with
 gfortran

This fixes an issue where, since the alignment of the -x lanaguage
modes, .f90 files were being preprocessed by default. This patch
completes the alignment of the meaning of the f95-pp-input and f95
language modes to match gfortran, fixing that issue.
---
 clang/include/clang/Driver/Types.def |  4 ++--
 .../Driver/input-from-stdin/input-from-stdin.f90 |  2 +-
 flang/test/Driver/phases.f90 | 12 ++--
 flang/test/Driver/pp-fixed-form.f90  | 16 
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/clang/include/clang/Driver/Types.def 
b/clang/include/clang/Driver/Types.def
index 214c5e7a789f9..2b6b3e75c1c97 100644
--- a/clang/include/clang/Driver/Types.def
+++ b/clang/include/clang/Driver/Types.def
@@ -88,8 +88,8 @@ TYPE("assembler-with-cpp",   Asm,  PP_Asm,
  "S",  phases
 // modules when Flang needs to emit pre-processed files. Therefore, the
 // `PP_TYPE` is set to `PP_Fortran` so that the driver is fine with
 // "pre-processing a pre-processed file".
-TYPE("f95",  PP_Fortran,   PP_Fortran,  "i",  
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, 
phases::Link)
-TYPE("f95-cpp-input",Fortran,  PP_Fortran,  nullptr,  
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, 
phases::Link)
+TYPE("f95",  Fortran,   PP_Fortran,  nullptr,  
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, 
phases::Link)
+TYPE("f95-cpp-input",PP_Fortran,  PP_Fortran,  "i",  
phases::Preprocess, phases::Compile, phases::Backend, phases::Assemble, 
phases::Link)
 TYPE("java", Java, INVALID, nullptr,  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 
 // LLVM IR/LTO types. We define separate types for IR and LTO because LTO
diff --git a/flang/test/Driver/input-from-stdin/input-from-stdin.f90 
b/flang/test/Driver/input-from-stdin/input-from-stdin.f90
index 1fcc0340a64ba..285f0751b35d8 100644
--- a/flang/test/Driver/input-from-stdin/input-from-stdin.f90
+++ b/flang/test/Driver/input-from-stdin/input-from-stdin.f90
@@ -6,7 +6,7 @@
 ! Input type is implicit
 ! RUN: cat %s | %flang -E -cpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED
 ! RUN: cat %s | %flang -DNEW -E -cpp - | FileCheck %s --check-prefix=PP-DEFINED
-! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
+! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
 ! RUN: cat %s | %flang -DNEW -E -nocpp - | FileCheck %s 
--check-prefix=PP-NOT-DEFINED
 
 ! Input type is explicit
diff --git a/flang/test/Driver/phases.f90 b/flang/test/Driver/phases.f90
index b688600dae035..9346773c883ef 100644
--- a/flang/test/Driver/phases.f90
+++ b/flang/test/Driver/phases.f90
@@ -4,15 +4,15 @@
 ! RUN: %flang -fsyntax-only -ccc-print-phases %s 2>&1 | FileCheck %s 
--check-prefix=COMPILE
 ! RUN: %flang -c -ccc-print-phases %s 2>&1 | FileCheck %s 
--check-prefix=EMIT_OBJ
 
-! PP: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
-! PP-NEXT: 1: preprocessor, {0}, f95
+! PP: +- 0: input, "{{.*}}phases.f90", f95
+! PP-NEXT: 1: preprocessor, {0}, f95-cpp-input
 
-! COMPILE: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
-! COMPILE-NEXT: 1: preprocessor, {0}, f95
+! COMPILE: +- 0: input, "{{.*}}phases.f90", f95
+! COMPILE-NEXT: 1: preprocessor, {0}, f95-cpp-input
 ! COMPILE-NEXT: 2: compiler, {1}, none
 
-! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
-! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95
+! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95
+! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95-cpp-input
 ! EMIT_OBJ-NEXT: 2: compiler, {1}, ir
 ! EMIT_OBJ-NEXT: +- 3: backend, {2}, assembler
 ! EMIT_OBJ-NEXT: 4: assembler, {3}, object
diff --git a/flang/test/Driver/pp-fixed-form.f90 
b/flang/test/Driver/pp-fixed-form.f90
index 4695da78763ae..bb869cd3341a7 100644
--- a/flang/test/Driver/pp-fixed-form.f90
+++ b/flang/test/Driver/pp-fixed-form.f90
@@ -1,19 +1,19 @@
 !RUN: %flang -save-temps -### %S/Inputs/free-form-test.f90  2>&1 | FileCheck 
%s --check-prefix=FREE
-FREE:   "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95-cpp-input" 
"{{.*}}/free-form-test.f90"
-FREE-NEXT:  "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "free-form-test.i"
+FREE:   "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95" 
"{{.*}}/free-form-test.f90"
+FREE-NEXT:  "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95-cpp-input" 
"free-form-test.i"
 
 !RUN: %flang -save-temps -### %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s 
--check-prefix=FIXED
-FIXED:  "-fc1"

[clang] [clang][modules] Lazily load by name lookups in module maps (PR #132853)

2025-04-05 Thread Michael Spencer via cfe-commits


@@ -2128,9 +2245,16 @@ bool ModuleMap::loadModuleMapFile(FileEntryRef File, 
bool IsSystem,
 
   // If the module map file wasn't already entered, do so now.
   if (ID.isInvalid()) {
-auto FileCharacter =
-IsSystem ? SrcMgr::C_System_ModuleMap : SrcMgr::C_User_ModuleMap;
-ID = SourceMgr.createFileID(File, ExternModuleLoc, FileCharacter);
+ID = SourceMgr.translateFile(File);
+// TODO: The way we compute affecting module maps requires this to be a
+//   local FileID. This should be changed to reuse loaded FileIDs when
+//   available, and change the way that affecting module maps are
+//   computed to not require this.
+if (ID.isInvalid() || SourceMgr.isLoadedFileID(ID)) {

Bigcheese wrote:

Yeah, the preference is that we don't create new SourceManager entries for a 
file as that takes up SLoc space and has a tiny bit of serialization overhead. 
The TODO is to remove the `isLoadedFileID()` and otherwise ensure that we never 
create extra FileIDs. 

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


[clang] [llvm] [HLSL] Add SPIR-V target type for StructuredBuffers (PR #132027)

2025-04-05 Thread Nathan Gauër via cfe-commits


@@ -711,13 +711,14 @@ 
BuiltinTypeDeclBuilder::addHandleAccessFunction(DeclarationName &Name,
   using PH = BuiltinTypeMethodBuilder::PlaceHolder;
 
   QualType ElemTy = getHandleElementType();
-  // TODO: Map to an hlsl_device address space.
-  QualType ElemPtrTy = AST.getPointerType(ElemTy);
-  QualType ReturnTy = ElemTy;
+  QualType AddrSpaceElemTy =
+  AST.getAddrSpaceQualType(ElemTy, LangAS::hlsl_device);
+  QualType ElemPtrTy = AST.getPointerType(AddrSpaceElemTy);
+  // QualType ReturnTy = (IsRef ? AST.getLValueReferenceType(ElemTy) : ElemTy);

Keenuts wrote:

remove?

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


[clang] [clang-tools-extra] Revert "[clang] NFC: Clear some uses of MemberPointerType::getClass" (PR #132281)

2025-04-05 Thread Matheus Izvekov via cfe-commits

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


[clang] [Clang][CodeGen] Do not set inbounds flag for struct GEP with null base pointers (PR #130734)

2025-04-05 Thread Eli Friedman via cfe-commits


@@ -42,6 +42,11 @@ Potentially Breaking Changes
 C/C++ Language Potentially Breaking Changes
 ---
 
+- Some old-style offsetof idioms like ``((int)(&(((struct S *)0)->field)))`` 
are treated

efriedma-quic wrote:

Well, no, but https://github.com/llvm/llvm-project/pull/130742 is a potentially 
breaking change, and probably it makes sense to discuss the two together.

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


[clang] [Clang] Improve subsumption. (PR #132849)

2025-04-05 Thread via cfe-commits

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

>From b5b5275093f6942238536834c6508551f7ceffd8 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Sun, 16 Mar 2025 23:34:19 +0100
Subject: [PATCH 1/6] [Clang] Improve subsumption.

The main goal of this patch is to improve the
performance of concept subsumption by

 - Making sure literal (atomic) clauses are de-duplicated
   (Whether 2 atomic constraint is established during the
initial normal form production).
 - Eagerly removing redundant clauses.

This should minimize the risks of exponentially-large
that can be produced by a naive {C,D}NF transformation.

While at it, I restructured that part of the code to be a bit
clearer.

Subsumption of fold expanded constraint is also cached.

---

Note that removing redundant clauses (even naively)
seems to be necessary and sufficient to have acceptable performance
on anything that could be construed as reasonable code.

Ultimately, the number of clauses is always going to be fairly
small (but $2^{fairly\ small}$ is quickly fairly large..).

I went too far in the rabbit hole of Tseitin transformations etc,
which was much faster but would then require to check satisfiabiliy
to establish subsumption between some constraints (although it was
good enough to pass all but ones of our tests...).

It doesn't help that the C++ standard has a very specific
definition of subsumption that is really more of an implication...

While that sort of musing is fascinating, it was ultimately a fool's
errand, at least until such time that there is more motivation for
a SAT solver in clang (clang-tidy can after all use z3!).

Here be dragons.

Fixes #122581
---
 clang/docs/ReleaseNotes.rst |   1 +
 clang/include/clang/Sema/SemaConcept.h  | 225 +-
 clang/lib/Sema/SemaConcept.cpp  | 452 +++-
 clang/test/SemaCXX/concepts-subsumption.cpp | 194 +
 4 files changed, 636 insertions(+), 236 deletions(-)
 create mode 100644 clang/test/SemaCXX/concepts-subsumption.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2f15c90ab1583..05bde5c9cc1d1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -358,6 +358,7 @@ Bug Fixes to C++ Support
 - Fixed a Clang regression in C++20 mode where unresolved dependent call 
expressions were created inside non-dependent contexts (#GH122892)
 - Clang now emits the ``-Wunused-variable`` warning when some structured 
bindings are unused
   and the ``[[maybe_unused]]`` attribute is not applied. (#GH125810)
+- Clang no longer crash when establishing subsumption between some constraint 
expressions. (#GH122581)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/SemaConcept.h 
b/clang/include/clang/Sema/SemaConcept.h
index 5c599a70532f6..87fee1678fb05 100644
--- a/clang/include/clang/Sema/SemaConcept.h
+++ b/clang/include/clang/Sema/SemaConcept.h
@@ -14,13 +14,14 @@
 #define LLVM_CLANG_SEMA_SEMACONCEPT_H
 #include "clang/AST/ASTConcept.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/Expr.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -56,49 +57,10 @@ struct alignas(ConstraintAlignment) AtomicConstraint {
 }
 return true;
   }
-
-  bool subsumes(ASTContext &C, const AtomicConstraint &Other) const {
-// C++ [temp.constr.order] p2
-//   - an atomic constraint A subsumes another atomic constraint B
-// if and only if the A and B are identical [...]
-//
-// C++ [temp.constr.atomic] p2
-//   Two atomic constraints are identical if they are formed from the
-//   same expression and the targets of the parameter mappings are
-//   equivalent according to the rules for expressions [...]
-
-// We do not actually substitute the parameter mappings into the
-// constraint expressions, therefore the constraint expressions are
-// the originals, and comparing them will suffice.
-if (ConstraintExpr != Other.ConstraintExpr)
-  return false;
-
-// Check that the parameter lists are identical
-return hasMatchingParameterMapping(C, Other);
-  }
 };
 
-struct alignas(ConstraintAlignment) FoldExpandedConstraint;
-
-using NormalFormConstraint =
-llvm::PointerUnion;
-struct NormalizedConstraint;
-using NormalForm =
-llvm::SmallVector, 4>;
-
-// A constraint is in conjunctive normal form when it is a conjunction of
-// clauses where each clause is a disjunction of atomic constraints. For atomic
-// constraints A, B, and C, the constraint A  ∧ (B  ∨ C) is in conjunctive
-// normal form.
-NormalForm makeCNF(const NormalizedConstraint &Normalized);
-
-// A constraint is in disjunctive normal 

[clang] [CodeGen] Don't include CGDebugInfo.h in CodeGenFunction.h (NFC) (PR #134100)

2025-04-05 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-coroutines

@llvm/pr-subscribers-debuginfo

Author: Nikita Popov (nikic)


Changes

This is an expensive header, only include it where needed. Move some functions 
out of line to achieve that.

This reduces time to build clang by ~0.5% in terms of instructions retired.

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


19 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+1) 
- (modified) clang/lib/CodeGen/CGCoroutine.cpp (+2-1) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+20) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGException.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (+1) 
- (modified) clang/lib/CodeGen/CGExprComplex.cpp (+1) 
- (modified) clang/lib/CodeGen/CGNonTrivialStruct.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+1) 
- (modified) clang/lib/CodeGen/CGVTables.cpp (+1) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+4-28) 
- (modified) clang/lib/CodeGen/CodeGenPGO.cpp (+12) 
- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+1) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+1) 
- (modified) clang/lib/CodeGen/TargetBuiltins/ARM.cpp (+1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 91ac7c5847b02..310addebd50e9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14,6 +14,7 @@
 #include "ABIInfo.h"
 #include "CGCUDARuntime.h"
 #include "CGCXXABI.h"
+#include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenCLRuntime.h"
 #include "CGRecordLayout.h"
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3cefa3b0c585c..b202255c3a15b 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -17,6 +17,7 @@
 #include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
+#include "CGDebugInfo.h"
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
diff --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index a9795c2c0dc8f..0fc488e98aaf0 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -11,10 +11,11 @@
 
//===--===//
 
 #include "CGCleanup.h"
+#include "CGDebugInfo.h"
 #include "CodeGenFunction.h"
-#include "llvm/ADT/ScopeExit.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtVisitor.h"
+#include "llvm/ADT/ScopeExit.h"
 
 using namespace clang;
 using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 52aa956121d73..d659243d38d5f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -6223,3 +6223,23 @@ CGDebugInfo::createConstantValueExpression(const 
clang::ValueDecl *VD,
 
   return nullptr;
 }
+
+CodeGenFunction::LexicalScope::LexicalScope(CodeGenFunction &CGF,
+SourceRange Range)
+: RunCleanupsScope(CGF), Range(Range), ParentScope(CGF.CurLexicalScope) {
+  CGF.CurLexicalScope = this;
+  if (CGDebugInfo *DI = CGF.getDebugInfo())
+DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
+}
+
+CodeGenFunction::LexicalScope::~LexicalScope() {
+  if (CGDebugInfo *DI = CGF.getDebugInfo())
+DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
+
+  // If we should perform a cleanup, force them now.  Note that
+  // this ends the cleanup scope before rescoping any labels.
+  if (PerformCleanup) {
+ApplyDebugLocation DL(CGF, Range.getEnd());
+ForceCleanup();
+  }
+}
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 33c048b48795c..e0921993bd14e 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -11,6 +11,7 @@
 
//===--===//
 
 #include "CGCXXABI.h"
+#include "CGDebugInfo.h"
 #include "CGHLSLRuntime.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
diff --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index b4b8c2952b02b..ebecb3aa5241d 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -12,6 +12,7 @@
 
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
+#include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
 #include "CodeGenFunction.h"
 #include "ConstantEmitter.h"
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index c8bdda375d1b1..87b2a73fb0c03 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -11,6 +11,7 @@
 
//===---

[clang] [Clang] Add warning message for C++17 alias template CTAD (PR #133806)

2025-04-05 Thread via cfe-commits


@@ -9920,7 +9920,9 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
 if (auto *AliasTemplate = dyn_cast_or_null(
 TemplateName.getAsTemplateDecl())) {
   Diag(Kind.getLocation(),
-   diag::warn_cxx17_compat_ctad_for_alias_templates);
+   getLangOpts().CPlusPlus20

Sirraide wrote:

It has been merged since (I had to revert it once but I’ve already relanded it)

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


[clang] [alpha.webkit.UncountedCallArgsChecker] os_log functions should be treated as safe. (PR #131500)

2025-04-05 Thread Ryosuke Niwa via cfe-commits

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


[clang] [clang-format] add option to control bin-packing keyworded parameters (PR #131605)

2025-04-05 Thread Eugene Shalygin via cfe-commits

https://github.com/zeule updated 
https://github.com/llvm/llvm-project/pull/131605

>From 352742af34d52dd265cc01ff47ca73047aa423e5 Mon Sep 17 00:00:00 2001
From: Eugene Shalygin 
Date: Mon, 17 Mar 2025 11:23:35 +0100
Subject: [PATCH] [clang-format] option to control bin-packing keyworded
 parameters

The Q_PROPERTY declaration is almost like a function declaration, but
uses keywords as parameter separators. This allows users to provide list
of those keywords to be used to control bin-packing of the macro
parameters.
---
 clang/docs/ClangFormatStyleOptions.rst| 32 ++
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/docs/tools/dump_format_style.py |  1 +
 clang/docs/tools/plurals.txt  |  1 +
 clang/include/clang/Format/Format.h   | 40 +
 clang/lib/Format/ContinuationIndenter.cpp |  4 ++
 clang/lib/Format/Format.cpp   | 11 
 clang/lib/Format/FormatToken.cpp  |  2 +
 clang/lib/Format/FormatToken.h|  1 +
 clang/lib/Format/TokenAnnotator.cpp   | 47 ++-
 clang/unittests/Format/ConfigParseTest.cpp| 10 
 clang/unittests/Format/FormatTest.cpp | 59 +++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 33 +++
 13 files changed, 240 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 3f8a5f49313b2..d61bafc1b4dd0 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4781,6 +4781,38 @@ the configuration (without a prefix: ``Auto``).
   replaced with a single newline and form feed followed by the remaining
   newlines.
 
+.. _KeywordedFunctionLikeMacros:
+
+**KeywordedFunctionLikeMacros** (``List of KeywordedFunctionLikeMacros``) 
:versionbadge:`clang-format 21` :ref:`¶ `
+  Allows to format function-like macros with keyworded parameters according
+  to the BinPackParameters setting, treating keywords as parameter
+  separators.
+
+  Q_PROPERTY is an example of such a macro:
+
+  .. code-block:: c++
+
+Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+
+  With ``BinPackParameters``  set to ``OnePerLine`` (or
+  ``AlwaysOnePerLine``) and
+
+  .. code-block:: yaml
+
+KeywordedFunctionLikeMacros:
+- Name: "Q_PROPERTY"
+  Keywords: ['READ', 'WRITE', 'MEMBER', 'RESET', 'NOTIFY']
+
+  the line above will be split on these keywords:
+
+  .. code-block:: c++
+
+Q_PROPERTY(
+int name
+READ name
+WRITE setName
+NOTIFY nameChanged)
+
 .. _LambdaBodyIndentation:
 
 **LambdaBodyIndentation** (``LambdaBodyIndentationKind``) 
:versionbadge:`clang-format 13` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c4e82678949ff..3b9c584410864 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -515,6 +515,8 @@ clang-format
   top of the file.
 - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
   ``enum`` enumerator lists.
+- Allow to apply parameters bin-packing options to function-like macros that
+  use keywords to delimit parameters (e.g. Q_PROPERTY).
 
 libclang
 
diff --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index f035143f6b3d1..85732af8e0a60 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -462,6 +462,7 @@ class State:
 "std::string",
 "std::vector",
 "std::vector",
+"std::vector",
 "std::vector",
 "std::optional",
 "deprecated",
diff --git a/clang/docs/tools/plurals.txt b/clang/docs/tools/plurals.txt
index e20b7f970ba43..bd08c65df1c52 100644
--- a/clang/docs/tools/plurals.txt
+++ b/clang/docs/tools/plurals.txt
@@ -1,3 +1,4 @@
 Strings
 IncludeCategories
+KeywordedFunctionLikeMacros
 RawStringFormats
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index cea5e257659d6..846e5a8f7f94b 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3309,6 +3309,45 @@ struct FormatStyle {
   /// \version 20
   bool KeepFormFeed;
 
+  /// Function-like declaration with keyworded parameters.
+  /// Lists possible keywords for a named function-like macro.
+  struct KeywordedFunctionLikeMacro {
+std::string Name;
+std::vector Keywords;
+
+bool operator==(const KeywordedFunctionLikeMacro &Other) const {
+  return Name == Other.Name && Keywords == Other.Keywords;
+}
+  };
+
+  /// Allows to format function-like macros with keyworded parameters according
+  /// to the BinPackParameters setting, treating keywords as parameter
+  /// separators.
+  ///
+  /// Q_PROPERTY is an example of such a macro:
+  /// \code
+  ///   Q_PROPERTY(int name READ name WRITE setName NOTIFY nameChanged)
+  /// 

[clang] [clang] Implement CWG2815 (PR #132778)

2025-04-05 Thread Vlad Serebrennikov via cfe-commits


@@ -47,6 +47,28 @@ void f() {
 #endif
 } // namespace cwg2813
 
+namespace cwg2815 { // cwg2815: 21
+#if __cpp_noexcept_function_type >= 201510

Endilll wrote:

Yes, C++ DR tests are concerned with language modes, and not individual 
features.

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


  1   2   3   4   5   6   7   8   >