[clang] [NFC][OpenACC] Refactor clause emission- (PR #140586)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' 
FAILED 
Exit Code: 1

Command Output (stdout):
--
warning: 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o:
 timestamp mismatch between object file (2025-03-11 17:27:45.671531848) and 
debug map (2022-07-12 20:49:30.0)
warning: 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o:
 timestamp mismatch between object file (2025-03-11 17:27:45.671531848) and 
debug map (2022-07-12 20:49:30.0)
warning: cann't read address attribute value.
note: while processing op-convert-offset1.c

--
Command Output (stderr):
--
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil 
-oso-prepend-path 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 # RUN: at line 23
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil 
-oso-prepend-path 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix OBJ # RUN: at line 24
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix OBJ
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump 
/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix DSYM # RUN: at line 25
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump 
/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix DSYM
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil --linker 
parallel -oso-prepend-path 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
   
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
   -o 
/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 # RUN: at line 27
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil --linker 
parallel -oso-prepend-path 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump
/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
 2>&1| /home/buil

[clang] [analyzer][NFC] Move PrettyStackTraceLocationContext into dispatchWorkItem (PR #140035)

2025-05-19 Thread Balázs Benics via cfe-commits

balazs-benics-sonarsource wrote:

I've updated the PR. I noticed some mistakes in the original submission.
Could you please have a look?

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


[clang] [analyzer][NFC] Move PrettyStackTraceLocationContext into dispatchWorkItem (PR #140035)

2025-05-19 Thread Balázs Benics via cfe-commits

https://github.com/balazs-benics-sonarsource updated 
https://github.com/llvm/llvm-project/pull/140035

From 3ef0391fdc58503f3414ac64e42370b0a6d4bddf Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Thu, 15 May 2025 11:17:24 +0200
Subject: [PATCH] [analyzer][NFC] Move PrettyStackTraceLocationContext into
 dispatchWorkItem

CPP-6476
---
 clang/lib/StaticAnalyzer/Core/CoreEngine.cpp|  2 ++
 clang/lib/StaticAnalyzer/Core/ExprEngine.cpp| 17 +++--
 .../Core/ExprEngineCallAndReturn.cpp|  6 +-
 3 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
index 2e6631f2f620c..8cc086a12ad70 100644
--- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h"
+#include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Stmt.h"
@@ -216,6 +217,7 @@ void CoreEngine::dispatchWorkItem(ExplodedNode *Pred, 
ProgramPoint Loc,
   llvm::TimeTraceScope tcs{timeTraceScopeName(Loc), [Loc, Pred]() {
  return timeTraceMetadata(Pred, Loc);
}};
+  PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
   // Dispatch on the location type.
   switch (Loc.getKind()) {
 case ProgramPoint::BlockEdgeKind:
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index ebad83dad0c8f..1afd4b52eb354 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -968,7 +968,6 @@ void ExprEngine::processEndWorklist() {
 
 void ExprEngine::processCFGElement(const CFGElement E, ExplodedNode *Pred,
unsigned StmtIdx, NodeBuilderContext *Ctx) {
-  PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
   currStmtIdx = StmtIdx;
   currBldrCtx = Ctx;
 
@@ -2541,7 +2540,6 @@ static const LocationContext 
*getInlinedLocationContext(ExplodedNode *Node,
 void ExprEngine::processCFGBlockEntrance(const BlockEdge &L,
  NodeBuilderWithSinks &nodeBuilder,
  ExplodedNode *Pred) {
-  PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
   // If we reach a loop which has a known bound (and meets
   // other constraints) then consider completely unrolling it.
   if(AMgr.options.ShouldUnrollLoops) {
@@ -2808,8 +2806,6 @@ void ExprEngine::processBranch(
 std::optional IterationsCompletedInLoop) {
   assert((!Condition || !isa(Condition)) &&
  "CXXBindTemporaryExprs are handled by processBindTemporary.");
-  const LocationContext *LCtx = Pred->getLocationContext();
-  PrettyStackTraceLocationContext StackCrashInfo(LCtx);
   currBldrCtx = &BldCtx;
 
   // Check for NULL conditions; e.g. "for(;;)"
@@ -2935,13 +2931,9 @@ void ExprEngine::processBranch(
 REGISTER_TRAIT_WITH_PROGRAMSTATE(InitializedGlobalsSet,
  llvm::ImmutableSet)
 
-void ExprEngine::processStaticInitializer(const DeclStmt *DS,
-  NodeBuilderContext &BuilderCtx,
-  ExplodedNode *Pred,
-  ExplodedNodeSet &Dst,
-  const CFGBlock *DstT,
-  const CFGBlock *DstF) {
-  PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
+void ExprEngine::processStaticInitializer(
+const DeclStmt *DS, NodeBuilderContext &BuilderCtx, ExplodedNode *Pred,
+ExplodedNodeSet &Dst, const CFGBlock *DstT, const CFGBlock *DstF) {
   currBldrCtx = &BuilderCtx;
 
   const auto *VD = cast(DS->getSingleDecl());
@@ -3064,9 +3056,6 @@ void ExprEngine::processEndOfFunction(NodeBuilderContext& 
BC,
   assert(areAllObjectsFullyConstructed(Pred->getState(),
Pred->getLocationContext(),
Pred->getStackFrame()->getParent()));
-
-  PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
-
   ExplodedNodeSet Dst;
   if (Pred->getLocationContext()->inTopFrame()) {
 // Remove dead symbols.
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
index 90625a96e9059..01e5076646a2c 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,7 +10,6 @@
 //
 
//===--===//
 
-#include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.

[clang] [libclang/python] Simplify __eq__ operators (PR #140540)

2025-05-19 Thread Jannick Kremer via cfe-commits

DeinAlptraum wrote:

The `# type: ignore [no-any-return]` are added in cases where the return type 
cannot be inferred, usually the libclang library functions called on the 
`conf.lib` object, since they are added dynamically. By combining the library 
call with the `isinstance` check, even without knowing the type of the library 
functions it becomes obvious that the result of a boolean expression is 
returned, so the type-ignore becomes unnecessary

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


[clang] [llvm] Boxu.zhang.llvm (PR #140671)

2025-05-19 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,cl -- 
clang/test/CodeGenOpenCL/test-printf-nvptx.cl clang/lib/AST/ASTContext.cpp 
clang/lib/AST/Decl.cpp clang/lib/CodeGen/CGGPUBuiltin.cpp 
clang/lib/Sema/SemaDecl.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/CGGPUBuiltin.cpp 
b/clang/lib/CodeGen/CGGPUBuiltin.cpp
index 0def190c7..8f99f52ab 100644
--- a/clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ b/clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -136,9 +136,9 @@ RValue EmitDevicePrintfCallExpr(const CallExpr *E, 
CodeGenFunction *CGF,
   llvm::Value *BufferPtr = r.first;
   llvm::Value *Fmt = Args[0].getRValue(*CGF).getScalarVal();
 
-  // For OpenCL, the default addrspace of 'format' argument is 
LangAS::opencl_constant,
-  // however, the 'vprintf' requires it to be unqualified 'ptr' type. Do 
pointer cast if
-  // it's the case.
+  // For OpenCL, the default addrspace of 'format' argument is
+  // LangAS::opencl_constant, however, the 'vprintf' requires it to be
+  // unqualified 'ptr' type. Do pointer cast if it's the case.
   if (CGM.getContext().getLangOpts().OpenCL)
 Fmt = Builder.CreatePointerCast(Fmt, llvm::PointerType::getUnqual(Ctx));
 

``




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


[clang] Reapply "[Clang] Profile singly-resolved UnresolvedLookupExpr with the declaration" (PR #140680)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

For a dependent variable template specialization, we don't build a dependent 
Decl node or a DeclRefExpr to represent it. Instead, we preserve the 
UnresolvedLookupExpr until instantiation.

However, this approach isn't ideal for constraint normalization. We consider 
the qualifier during profiling, but since that's based on the written code, it 
can introduce confusing differences, even when the expressions resolve to the 
same declaration.

This change profiles the underlying VarTemplateDecl if UnresolvedLookupExpr is 
used to model a dependent use of it.

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

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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/AST/StmtProfile.cpp (+8-2) 
- (modified) clang/test/SemaCXX/exception-spec.cpp (+21) 
- (modified) clang/test/SemaTemplate/concepts-out-of-line-def.cpp (+15) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f04cb7b91788c..4c839303f3621 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -741,6 +741,7 @@ Bug Fixes to C++ Support
 - Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
 - Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` 
and ``alignas`` attributes for declarations (#GH133107)
 - Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
+- Fixed a function declaration mismatch that caused inconsistencies between 
concepts and variable template declarations. (#GH139476)
 - Clang no longer segfaults when there is a configuration mismatch between 
modules and their users (http://crbug.com/400353616).
 - Fix an incorrect deduction when calling an explicit object member function 
template through an overload set address.
 - Fixed bug in constant evaluation that would allow using the value of a
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index f7d1655f67ed1..2f1dec434c30b 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2189,8 +2189,14 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const 
CXXPseudoDestructorExpr *S) {
 
 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
   VisitExpr(S);
-  VisitNestedNameSpecifier(S->getQualifier());
-  VisitName(S->getName(), /*TreatAsDecl*/ true);
+  bool DescribingDependentVarTemplate =
+  S->getNumDecls() == 1 && isa(*S->decls_begin());
+  if (DescribingDependentVarTemplate) {
+VisitDecl(*S->decls_begin());
+  } else {
+VisitNestedNameSpecifier(S->getQualifier());
+VisitName(S->getName(), /*TreatAsDecl*/ true);
+  }
   ID.AddBoolean(S->hasExplicitTemplateArgs());
   if (S->hasExplicitTemplateArgs())
 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
diff --git a/clang/test/SemaCXX/exception-spec.cpp 
b/clang/test/SemaCXX/exception-spec.cpp
index 6ad19aab397bd..31c691b28da4b 100644
--- a/clang/test/SemaCXX/exception-spec.cpp
+++ b/clang/test/SemaCXX/exception-spec.cpp
@@ -52,3 +52,24 @@ namespace AssignmentOp {
 D2 &operator=(const D2&); // expected-error {{more lax}}
   };
 }
+
+namespace OverloadedFunctions {
+
+template 
+void f(T&) noexcept;
+
+template 
+void f(T (&arr)[N]) noexcept(noexcept(f(*arr)));
+
+template 
+inline void f(T&) noexcept {}
+
+template 
+inline void f(T (&arr)[N]) noexcept(noexcept(f(*arr))) {}
+
+void g() {
+int x[1];
+f(x);
+}
+
+}
diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index e5d00491d3fb8..bf505dec0ca14 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -853,3 +853,18 @@ template 
 requires C
 auto TplClass::buggy() -> void {}
 }
+
+namespace GH139476 {
+
+namespace moo {
+  template 
+  constexpr bool baa = true;
+
+  template  requires baa
+  void caw();
+}
+
+template  requires moo::baa
+void moo::caw() {}
+
+}

``




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


[clang] [llvm] [RISCV] Add Andes A25/AX25 processor definition (PR #140681)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Jim Lin (tclin914)


Changes

Andes A25/AX25 are 32/64bit, 5-stage pipeline, linux-capable CPUs that 
implement the RV[32|64]IMAFDC_Zba_Zbb_Zbc_Zbs ISA extensions. They are 
developed by Andes Technology https://www.andestech.com, a RISC-V IP provider.

The overviews for A25/AX25:
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-a25/ 
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-ax25/

Scheduling model will be implemented in a later PR.

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


4 Files Affected:

- (modified) clang/test/Driver/riscv-cpus.c (+36) 
- (modified) clang/test/Misc/target-invalid-cpu-note/riscv.c (+8-4) 
- (modified) llvm/docs/ReleaseNotes.md (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+32) 


``diff
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index dacdb03fd09d9..cebf41aa626a7 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -699,6 +699,42 @@
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr7 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR7 %s
 // MTUNE-SYNTACORE-SCR7: "-tune-cpu" "syntacore-scr7"
 
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-a25 | FileCheck 
-check-prefix=MCPU-ANDES-A25 %s
+// MCPU-ANDES-A25: "-target-cpu" "andes-a25"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+m"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+a"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+f"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+d"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+c"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zicsr"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zifencei"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zba"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbb"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbc"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbs"
+// MCPU-ANDES-A25-SAME: "-target-abi" "ilp32d"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=andes-a25 | FileCheck 
-check-prefix=MTUNE-ANDES-A25 %s
+// MTUNE-ANDES-A25: "-tune-cpu" "andes-a25"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=andes-ax25 | FileCheck 
-check-prefix=MCPU-ANDES-AX25 %s
+// MCPU-ANDES-AX25: "-target-cpu" "andes-ax25"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+m"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+a"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+f"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+d"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+c"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zicsr"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zifencei"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zba"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbb"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbc"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbs"
+// MCPU-ANDES-AX25-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-ax25 | FileCheck 
-check-prefix=MTUNE-ANDES-AX25 %s
+// MTUNE-ANDES-AX25: "-tune-cpu" "andes-ax25"
+
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-n45 | FileCheck 
-check-prefix=MCPU-ANDES-N45 %s
 // MCPU-ANDES-N45: "-target-cpu" "andes-n45"
 // MCPU-ANDES-N45-SAME: "-target-feature" "+m"
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c 
b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index b4e83e59d296f..c57bde8aa531a 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -5,7 +5,8 @@
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
 // RISCV32-NEXT: note: valid target CPU values are:
-// RISCV32-SAME: {{^}} andes-a45
+// RISCV32-SAME: {{^}} andes-a25
+// RISCV32-SAME: {{^}}, andes-a45
 // RISCV32-SAME: {{^}}, andes-n45
 // RISCV32-SAME: {{^}}, generic-rv32
 // RISCV32-SAME: {{^}}, rocket-rv32
@@ -26,7 +27,8 @@
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
 // RISCV64-NEXT: note: valid target CPU values are:
-// RISCV64-SAME: {{^}} andes-ax45
+// RISCV64-SAME: {{^}} andes-ax25
+// RISCV64-SAME: {{^}}, andes-ax45
 // RISCV64-SAME: {{^}}, andes-nx45
 // RISCV64-SAME: {{^}}, generic-rv64
 // RISCV64-SAME: {{^}}, mips-p8700
@@ -57,7 +59,8 @@
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
 // TUNE-RISCV32-NEXT: note: valid target CPU values are:
-// TUNE-RISCV32-SAME: {{^}} andes-a45
+// TUNE-RISCV32-SAME: {{^}} andes-a25
+// TUNE-RISCV32-SAME: {{^}}, andes-a45
 // TUNE-RISCV32-SAME: {{^}}, andes-n45
 // TUNE-RISCV32-SAME: {{^}}, generic-rv32
 // TUNE-RISCV32-SAME: {{

[clang] [llvm] [RISCV] Add Andes A25/AX25 processor definition (PR #140681)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jim Lin (tclin914)


Changes

Andes A25/AX25 are 32/64bit, 5-stage pipeline, linux-capable CPUs that 
implement the RV[32|64]IMAFDC_Zba_Zbb_Zbc_Zbs ISA extensions. They are 
developed by Andes Technology https://www.andestech.com, a RISC-V IP provider.

The overviews for A25/AX25:
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-a25/ 
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-ax25/

Scheduling model will be implemented in a later PR.

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


4 Files Affected:

- (modified) clang/test/Driver/riscv-cpus.c (+36) 
- (modified) clang/test/Misc/target-invalid-cpu-note/riscv.c (+8-4) 
- (modified) llvm/docs/ReleaseNotes.md (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+32) 


``diff
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index dacdb03fd09d9..cebf41aa626a7 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -699,6 +699,42 @@
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr7 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR7 %s
 // MTUNE-SYNTACORE-SCR7: "-tune-cpu" "syntacore-scr7"
 
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-a25 | FileCheck 
-check-prefix=MCPU-ANDES-A25 %s
+// MCPU-ANDES-A25: "-target-cpu" "andes-a25"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+m"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+a"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+f"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+d"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+c"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zicsr"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zifencei"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zba"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbb"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbc"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbs"
+// MCPU-ANDES-A25-SAME: "-target-abi" "ilp32d"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=andes-a25 | FileCheck 
-check-prefix=MTUNE-ANDES-A25 %s
+// MTUNE-ANDES-A25: "-tune-cpu" "andes-a25"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=andes-ax25 | FileCheck 
-check-prefix=MCPU-ANDES-AX25 %s
+// MCPU-ANDES-AX25: "-target-cpu" "andes-ax25"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+m"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+a"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+f"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+d"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+c"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zicsr"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zifencei"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zba"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbb"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbc"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbs"
+// MCPU-ANDES-AX25-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-ax25 | FileCheck 
-check-prefix=MTUNE-ANDES-AX25 %s
+// MTUNE-ANDES-AX25: "-tune-cpu" "andes-ax25"
+
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-n45 | FileCheck 
-check-prefix=MCPU-ANDES-N45 %s
 // MCPU-ANDES-N45: "-target-cpu" "andes-n45"
 // MCPU-ANDES-N45-SAME: "-target-feature" "+m"
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c 
b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index b4e83e59d296f..c57bde8aa531a 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -5,7 +5,8 @@
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
 // RISCV32-NEXT: note: valid target CPU values are:
-// RISCV32-SAME: {{^}} andes-a45
+// RISCV32-SAME: {{^}} andes-a25
+// RISCV32-SAME: {{^}}, andes-a45
 // RISCV32-SAME: {{^}}, andes-n45
 // RISCV32-SAME: {{^}}, generic-rv32
 // RISCV32-SAME: {{^}}, rocket-rv32
@@ -26,7 +27,8 @@
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
 // RISCV64-NEXT: note: valid target CPU values are:
-// RISCV64-SAME: {{^}} andes-ax45
+// RISCV64-SAME: {{^}} andes-ax25
+// RISCV64-SAME: {{^}}, andes-ax45
 // RISCV64-SAME: {{^}}, andes-nx45
 // RISCV64-SAME: {{^}}, generic-rv64
 // RISCV64-SAME: {{^}}, mips-p8700
@@ -57,7 +59,8 @@
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
 // TUNE-RISCV32-NEXT: note: valid target CPU values are:
-// TUNE-RISCV32-SAME: {{^}} andes-a45
+// TUNE-RISCV32-SAME: {{^}} andes-a25
+// TUNE-RISCV32-SAME: {{^}}, andes-a45
 // TUNE-RISCV32-SAME: {{^}}, andes-n45
 // TUNE-RISCV32-SAME: {{^}}, generic-rv32
 // TUNE-RISCV32-SAME: {{^}}, rock

[clang] [llvm] [RISCV] Add Andes A25/AX25 processor definition (PR #140681)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Jim Lin (tclin914)


Changes

Andes A25/AX25 are 32/64bit, 5-stage pipeline, linux-capable CPUs that 
implement the RV[32|64]IMAFDC_Zba_Zbb_Zbc_Zbs ISA extensions. They are 
developed by Andes Technology https://www.andestech.com, a RISC-V IP provider.

The overviews for A25/AX25:
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-a25/ 
https://www.andestech.com/en/products-solutions/andescore-processors/riscv-ax25/

Scheduling model will be implemented in a later PR.

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


4 Files Affected:

- (modified) clang/test/Driver/riscv-cpus.c (+36) 
- (modified) clang/test/Misc/target-invalid-cpu-note/riscv.c (+8-4) 
- (modified) llvm/docs/ReleaseNotes.md (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+32) 


``diff
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index dacdb03fd09d9..cebf41aa626a7 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -699,6 +699,42 @@
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr7 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR7 %s
 // MTUNE-SYNTACORE-SCR7: "-tune-cpu" "syntacore-scr7"
 
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-a25 | FileCheck 
-check-prefix=MCPU-ANDES-A25 %s
+// MCPU-ANDES-A25: "-target-cpu" "andes-a25"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+m"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+a"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+f"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+d"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+c"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zicsr"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zifencei"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zba"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbb"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbc"
+// MCPU-ANDES-A25-SAME: "-target-feature" "+zbs"
+// MCPU-ANDES-A25-SAME: "-target-abi" "ilp32d"
+
+// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=andes-a25 | FileCheck 
-check-prefix=MTUNE-ANDES-A25 %s
+// MTUNE-ANDES-A25: "-tune-cpu" "andes-a25"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=andes-ax25 | FileCheck 
-check-prefix=MCPU-ANDES-AX25 %s
+// MCPU-ANDES-AX25: "-target-cpu" "andes-ax25"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+m"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+a"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+f"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+d"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+c"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zicsr"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zifencei"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zba"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbb"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbc"
+// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbs"
+// MCPU-ANDES-AX25-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-ax25 | FileCheck 
-check-prefix=MTUNE-ANDES-AX25 %s
+// MTUNE-ANDES-AX25: "-tune-cpu" "andes-ax25"
+
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-n45 | FileCheck 
-check-prefix=MCPU-ANDES-N45 %s
 // MCPU-ANDES-N45: "-target-cpu" "andes-n45"
 // MCPU-ANDES-N45-SAME: "-target-feature" "+m"
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c 
b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index b4e83e59d296f..c57bde8aa531a 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -5,7 +5,8 @@
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
 // RISCV32-NEXT: note: valid target CPU values are:
-// RISCV32-SAME: {{^}} andes-a45
+// RISCV32-SAME: {{^}} andes-a25
+// RISCV32-SAME: {{^}}, andes-a45
 // RISCV32-SAME: {{^}}, andes-n45
 // RISCV32-SAME: {{^}}, generic-rv32
 // RISCV32-SAME: {{^}}, rocket-rv32
@@ -26,7 +27,8 @@
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
 // RISCV64-NEXT: note: valid target CPU values are:
-// RISCV64-SAME: {{^}} andes-ax45
+// RISCV64-SAME: {{^}} andes-ax25
+// RISCV64-SAME: {{^}}, andes-ax45
 // RISCV64-SAME: {{^}}, andes-nx45
 // RISCV64-SAME: {{^}}, generic-rv64
 // RISCV64-SAME: {{^}}, mips-p8700
@@ -57,7 +59,8 @@
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
 // TUNE-RISCV32-NEXT: note: valid target CPU values are:
-// TUNE-RISCV32-SAME: {{^}} andes-a45
+// TUNE-RISCV32-SAME: {{^}} andes-a25
+// TUNE-RISCV32-SAME: {{^}}, andes-a45
 // TUNE-RISCV32-SAME: {{^}}, andes-n45
 // TUNE-RISCV32-SAME: {{^}}, generic-rv32
 // TUNE-RISCV32-SAME: {{^}

[clang] Reapply "[Clang] Profile singly-resolved UnresolvedLookupExpr with the declaration" (PR #140680)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Younan Zhang (zyn0217)


Changes

For a dependent variable template specialization, we don't build a dependent 
Decl node or a DeclRefExpr to represent it. Instead, we preserve the 
UnresolvedLookupExpr until instantiation.

However, this approach isn't ideal for constraint normalization. We consider 
the qualifier during profiling, but since that's based on the written code, it 
can introduce confusing differences, even when the expressions resolve to the 
same declaration.

This change profiles the underlying VarTemplateDecl if UnresolvedLookupExpr is 
used to model a dependent use of it.

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

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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/AST/StmtProfile.cpp (+8-2) 
- (modified) clang/test/SemaCXX/exception-spec.cpp (+21) 
- (modified) clang/test/SemaTemplate/concepts-out-of-line-def.cpp (+15) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f04cb7b91788c..4c839303f3621 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -741,6 +741,7 @@ Bug Fixes to C++ Support
 - Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
 - Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` 
and ``alignas`` attributes for declarations (#GH133107)
 - Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
+- Fixed a function declaration mismatch that caused inconsistencies between 
concepts and variable template declarations. (#GH139476)
 - Clang no longer segfaults when there is a configuration mismatch between 
modules and their users (http://crbug.com/400353616).
 - Fix an incorrect deduction when calling an explicit object member function 
template through an overload set address.
 - Fixed bug in constant evaluation that would allow using the value of a
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index f7d1655f67ed1..2f1dec434c30b 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2189,8 +2189,14 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const 
CXXPseudoDestructorExpr *S) {
 
 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
   VisitExpr(S);
-  VisitNestedNameSpecifier(S->getQualifier());
-  VisitName(S->getName(), /*TreatAsDecl*/ true);
+  bool DescribingDependentVarTemplate =
+  S->getNumDecls() == 1 && isa(*S->decls_begin());
+  if (DescribingDependentVarTemplate) {
+VisitDecl(*S->decls_begin());
+  } else {
+VisitNestedNameSpecifier(S->getQualifier());
+VisitName(S->getName(), /*TreatAsDecl*/ true);
+  }
   ID.AddBoolean(S->hasExplicitTemplateArgs());
   if (S->hasExplicitTemplateArgs())
 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
diff --git a/clang/test/SemaCXX/exception-spec.cpp 
b/clang/test/SemaCXX/exception-spec.cpp
index 6ad19aab397bd..31c691b28da4b 100644
--- a/clang/test/SemaCXX/exception-spec.cpp
+++ b/clang/test/SemaCXX/exception-spec.cpp
@@ -52,3 +52,24 @@ namespace AssignmentOp {
 D2 &operator=(const D2&); // expected-error {{more lax}}
   };
 }
+
+namespace OverloadedFunctions {
+
+template 
+void f(T&) noexcept;
+
+template 
+void f(T (&arr)[N]) noexcept(noexcept(f(*arr)));
+
+template 
+inline void f(T&) noexcept {}
+
+template 
+inline void f(T (&arr)[N]) noexcept(noexcept(f(*arr))) {}
+
+void g() {
+int x[1];
+f(x);
+}
+
+}
diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index e5d00491d3fb8..bf505dec0ca14 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -853,3 +853,18 @@ template 
 requires C
 auto TplClass::buggy() -> void {}
 }
+
+namespace GH139476 {
+
+namespace moo {
+  template 
+  constexpr bool baa = true;
+
+  template  requires baa
+  void caw();
+}
+
+template  requires moo::baa
+void moo::caw() {}
+
+}

``




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


[clang] Reapply "[Clang] Profile singly-resolved UnresolvedLookupExpr with the declaration" (PR #140680)

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

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/140680

For a dependent variable template specialization, we don't build a dependent 
Decl node or a DeclRefExpr to represent it. Instead, we preserve the 
UnresolvedLookupExpr until instantiation.

However, this approach isn't ideal for constraint normalization. We consider 
the qualifier during profiling, but since that's based on the written code, it 
can introduce confusing differences, even when the expressions resolve to the 
same declaration.

This change profiles the underlying VarTemplateDecl if UnresolvedLookupExpr is 
used to model a dependent use of it.

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

>From c7b2fde04d708279fcd9a82fd59eb84290a8955a Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 20 May 2025 13:48:28 +0800
Subject: [PATCH 1/2] Reapply "[Clang] Profile singly-resolved
 UnresolvedLookupExpr with the declaration" (#140655)

This reverts commit 383e5f3e2da5c11ecbf1482eb0c39df38ac84e59.
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/AST/StmtProfile.cpp |  5 -
 .../SemaTemplate/concepts-out-of-line-def.cpp | 15 +++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f04cb7b91788c..4c839303f3621 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -741,6 +741,7 @@ Bug Fixes to C++ Support
 - Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
 - Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` 
and ``alignas`` attributes for declarations (#GH133107)
 - Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
+- Fixed a function declaration mismatch that caused inconsistencies between 
concepts and variable template declarations. (#GH139476)
 - Clang no longer segfaults when there is a configuration mismatch between 
modules and their users (http://crbug.com/400353616).
 - Fix an incorrect deduction when calling an explicit object member function 
template through an overload set address.
 - Fixed bug in constant evaluation that would allow using the value of a
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index f7d1655f67ed1..19db338f760ba 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2189,7 +2189,10 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const 
CXXPseudoDestructorExpr *S) {
 
 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
   VisitExpr(S);
-  VisitNestedNameSpecifier(S->getQualifier());
+  if (S->getNumDecls() == 1)
+VisitDecl(*S->decls_begin());
+  else
+VisitNestedNameSpecifier(S->getQualifier());
   VisitName(S->getName(), /*TreatAsDecl*/ true);
   ID.AddBoolean(S->hasExplicitTemplateArgs());
   if (S->hasExplicitTemplateArgs())
diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index e5d00491d3fb8..bf505dec0ca14 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -853,3 +853,18 @@ template 
 requires C
 auto TplClass::buggy() -> void {}
 }
+
+namespace GH139476 {
+
+namespace moo {
+  template 
+  constexpr bool baa = true;
+
+  template  requires baa
+  void caw();
+}
+
+template  requires moo::baa
+void moo::caw() {}
+
+}

>From a450de85c4a70dbe1bc168d5b7f0c5f603104fa7 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 20 May 2025 13:48:50 +0800
Subject: [PATCH 2/2] Only profile Decls for dependent VarTemplates

---
 clang/lib/AST/StmtProfile.cpp |  9 ++---
 clang/test/SemaCXX/exception-spec.cpp | 21 +
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 19db338f760ba..2f1dec434c30b 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2189,11 +2189,14 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const 
CXXPseudoDestructorExpr *S) {
 
 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
   VisitExpr(S);
-  if (S->getNumDecls() == 1)
+  bool DescribingDependentVarTemplate =
+  S->getNumDecls() == 1 && isa(*S->decls_begin());
+  if (DescribingDependentVarTemplate) {
 VisitDecl(*S->decls_begin());
-  else
+  } else {
 VisitNestedNameSpecifier(S->getQualifier());
-  VisitName(S->getName(), /*TreatAsDecl*/ true);
+VisitName(S->getName(), /*TreatAsDecl*/ true);
+  }
   ID.AddBoolean(S->hasExplicitTemplateArgs());
   if (S->hasExplicitTemplateArgs())
 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
diff --git a/clang/test/SemaCXX/exception-spec.cpp 
b/clang/test/SemaCXX/exception-spec.cpp
index 6ad19aab397bd..31c691b28da4b 100644
--- a/clang/test/SemaCXX/exc

[clang] Reapply "[Clang] Profile singly-resolved UnresolvedLookupExpr with the declaration" (PR #140680)

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


@@ -2189,8 +2189,14 @@ StmtProfiler::VisitCXXPseudoDestructorExpr(const 
CXXPseudoDestructorExpr *S) {
 
 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
   VisitExpr(S);
-  VisitNestedNameSpecifier(S->getQualifier());
-  VisitName(S->getName(), /*TreatAsDecl*/ true);
+  bool DescribingDependentVarTemplate =
+  S->getNumDecls() == 1 && isa(*S->decls_begin());

zyn0217 wrote:

Instead of OverloadExpr, I'm thinking if it would be better to invent a new 
Expr node to describe dependent cases (we use DeclRefExpr for non-dependent 
uses), just like ConceptSpecializationExpr.

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


[clang] [Clang] suggest headers on undeclared errors (PR #140247)

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

tbaederr wrote:

I can only review this on a high level, so CC @AaronBallman to check if this is 
happening at the right level.

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


[clang] [Clang] Add clang driver option -fpartition-static-data-sections (PR #124991)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mingming Liu (mingmingl-llvm)


Changes



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


7 Files Affected:

- (modified) clang/include/clang/Basic/CodeGenOptions.def (+2) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+14) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+8) 
- (added) clang/test/Driver/fpartition-static-data-sections.c (+15) 
- (added) clang/test/Driver/test.c (+15) 


``diff
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 259972bdf8f00..86246eb373630 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -199,6 +199,8 @@ CODEGENOPT(DisableBlockSignatureString, 1, 0) ///< Set when 
-fdisable-block-sign
 CODEGENOPT(HIPSaveKernelArgName, 1, 0) ///< Set when -fhip-kernel-arg-name is 
enabled.
 CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get 
unique names.
 CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using 
profile information.
+CODEGENOPT(PartitionStaticDataSections, 1,
+   0) /// < Partition static data sections using profile information.
 CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in 
assembly
 CODEGENOPT(X86RelaxRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(X86Sse2Avx, 1, 0)   ///< -Wa,-msse2avx
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ba5600e1912a6..a7a3f58f60c6c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4385,6 +4385,12 @@ defm split_machine_functions: 
BoolFOption<"split-machine-functions",
   NegFlag,
   BothFlags<[], [ClangOption], " late function splitting using profile 
information (x86 and aarch64 ELF)">>;
 
+defm partition_static_data_sections: 
BoolFOption<"partition-static-data-sections",
+  CodeGenOpts<"PartitionStaticDataSections">, DefaultFalse,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], [ClangOption], " partition static data sections using profile 
information (x86 and aarch64 ELF)">>;
+
 defm strict_return : BoolFOption<"strict-return",
   CodeGenOpts<"StrictReturn">, DefaultTrue,
   NegFlaggetOption().matches(
+options::OPT_fno_partition_static_data_sections)) {
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
+A->render(Args, CmdArgs);
+  else
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+}
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2c4b082bcce4a..40878e9778499 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1087,6 +1087,14 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
"-split-machine-functions"));
   }
 
+  if (auto *A =
+  Args.getLastArg(options::OPT_fpartition_static_data_sections,
+  options::OPT_fno_partition_static_data_sections)) {
+if (A->getOption().matches(options::OPT_fpartition_static_data_sections))
+  CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
+   "-partition-static-data-sections"));
+  }
+
   if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
diff --git a/clang/test/Driver/fpartition-static-data-sections.c 
b/clang/test/Driver/fpartition-static-data-sections.c
new file mode 100644
index 0..8f158b81373de
--- /dev/null
+++ b/clang/test/Driver/fpartition-static-data-sections.c
@@ -0,0 +1,15 @@
+// RUN: %clang -### --target=x86_64 -fpartition-static-data-sections %s 2>&1 | 
FileCheck %s --check-prefixes=OPT
+// RUN: %clang -### --target=aarch64 -fpartition-static-data-sections %s 2>&1 
| FileCheck %s --check-prefixes=OPT
+
+// RUN: not %clang -### --target=arm -fpartition-static-data-sections %s 2>&1 
| FileCheck %s --check-prefixes=ERR
+
+// RUN: %clang -### --target=x86_64 -fpartition-static-data-sections 
-fno-partition-static-data-sections %s 2>&1 | FileCheck %s 
--implicit-check-not="-fpartition-static-data-sections"
+
+// RUN: %clang -### --target=x86_64-linux -flto 
-fpartition-static-data-sections %s 2>&1 | FileCheck %s --check-prefix=LTO
+// RUN: %clang -### --target=x86_64-linux -flto 
-fpartition-static-da

[clang] [analyzer][NFC] Move PrettyStackTraceLocationContext into dispatchWorkItem (PR #140035)

2025-05-19 Thread Balázs Benics via cfe-commits

https://github.com/balazs-benics-sonarsource edited 
https://github.com/llvm/llvm-project/pull/140035
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add --fallback-style to git-clang-format (PR #137609)

2025-05-19 Thread Andrej Pištek via cfe-commits

https://github.com/apdofficial updated 
https://github.com/llvm/llvm-project/pull/137609

From 2e82063e9e2c159a7a713ecedbcc0bfbdbf66143 Mon Sep 17 00:00:00 2001
From: Andrej Pistek 
Date: Mon, 7 Apr 2025 13:37:47 +0200
Subject: [PATCH 1/2] [git-clang-format] add fallback style arg

---
 clang/tools/clang-format/git-clang-format | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index e709803d9a3f1..8a92853dc96c4 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -189,6 +189,13 @@ def main():
 default=config.get("clangformat.style", None),
 help="passed to clang-format",
 ),
+p.add_argument(
+"--fallback-style",
+help="The name of the predefined style used as a "
+"fallback in case clang-format is invoked with "
+"--style=file, but can not find the .clang-format "
+"file to use.",
+),
 p.add_argument(
 "-v",
 "--verbose",
@@ -279,7 +286,11 @@ def main():
 old_tree = create_tree_from_workdir(changed_lines)
 revision = None
 new_tree = run_clang_format_and_save_to_tree(
-changed_lines, revision, binary=opts.binary, style=opts.style
+changed_lines,
+revision,
+binary=opts.binary,
+style=opts.style,
+fallback_style=opts.fallback_style,
 )
 if opts.verbose >= 1:
 print("old tree: %s" % old_tree)
@@ -531,7 +542,11 @@ def create_tree_from_index(filenames):
 
 
 def run_clang_format_and_save_to_tree(
-changed_lines, revision=None, binary="clang-format", style=None
+changed_lines,
+revision=None,
+binary="clang-format",
+style=None,
+fallback_style=None,
 ):
 """Run clang-format on each file and save the result to a git tree.
 
@@ -583,6 +598,7 @@ def run_clang_format_and_save_to_tree(
 revision=revision,
 binary=binary,
 style=style,
+fallback_style=fallback_style,
 env=env,
 )
 yield "%s %s\t%s" % (mode, blob_id, filename)
@@ -616,6 +632,7 @@ def clang_format_to_blob(
 revision=None,
 binary="clang-format",
 style=None,
+fallback_style=None,
 env=None,
 ):
 """Run clang-format on the given file and save the result to a git blob.
@@ -628,6 +645,8 @@ def clang_format_to_blob(
 clang_format_cmd = [binary]
 if style:
 clang_format_cmd.extend(["--style=" + style])
+if fallback_style:
+clang_format_cmd.extend(["--fallback-style=" + fallback_style])
 clang_format_cmd.extend(
 [
 "--lines=%s:%s" % (start_line, start_line + line_count - 1)

From 534efbfc9ab956064e1a9aa72be40b2637456386 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Pi=C5=A1tek?= 
Date: Tue, 20 May 2025 08:57:45 +0200
Subject: [PATCH 2/2] Update clang/tools/clang-format/git-clang-format

Co-authored-by: Owen Pan 
---
 clang/tools/clang-format/git-clang-format | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 8a92853dc96c4..23e15ee9a8fd3 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -191,10 +191,7 @@ def main():
 ),
 p.add_argument(
 "--fallback-style",
-help="The name of the predefined style used as a "
-"fallback in case clang-format is invoked with "
-"--style=file, but can not find the .clang-format "
-"file to use.",
+help="passed to clang-format",
 ),
 p.add_argument(
 "-v",

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


[clang] [clang-format][NFC] Upgrade SortIncludes option to a struct (PR #140497)

2025-05-19 Thread Daan De Meyer via cfe-commits

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

Thank you! FWIW, I went over the changes and they all look sensible to me

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


[clang] [libclang/python][NFC] Explain how null cursors are handled in docstring (PR #140499)

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

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/140499

Now that we looked at this aspect closely and fixed things, I think we can 
document this.

>From 445eacab8a326d3abcca95a31f07c272d0d155e7 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Mon, 19 May 2025 09:24:36 +0300
Subject: [PATCH] [libclang/python][NFC] Explain how null cursors are handled
 in documentation

---
 clang/bindings/python/clang/cindex.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index f65bcad780a70..82a6197bf61af 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1585,6 +1585,8 @@ class Cursor(Structure):
 """
 The Cursor class represents a reference to an element within the AST. It
 acts as a kind of iterator.
+
+Methods of this class return null cursors as None.
 """
 
 _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]

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


[clang] [libclang/python][NFC] Explain how null cursors are handled in docstring (PR #140499)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

Now that we looked at this aspect closely and fixed things, I think we can 
document this.

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


1 Files Affected:

- (modified) clang/bindings/python/clang/cindex.py (+2) 


``diff
diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index f65bcad780a70..82a6197bf61af 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1585,6 +1585,8 @@ class Cursor(Structure):
 """
 The Cursor class represents a reference to an element within the AST. It
 acts as a kind of iterator.
+
+Methods of this class return null cursors as None.
 """
 
 _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]

``




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


[clang] [libclang/python][NFC] Explain how null cursors are handled in docstring (PR #140499)

2025-05-19 Thread Jannick Kremer via cfe-commits

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


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


[clang] [libclang/python][NFC] Document how null cursors are handled (PR #140499)

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

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


[clang] [libclang/python][NFC] Document how null cursors are handled (PR #140499)

2025-05-19 Thread Jannick Kremer via cfe-commits

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


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


[clang] [clang][Driver][test][NFC] Adjust test for targets with no cc1as (PR #140490)

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

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

Thanks for the fix !

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


[clang] [KeyInstr][Clang] Add Clang option -g[no-]key-instructions (PR #134627)

2025-05-19 Thread Orlando Cazalet-Hyams via cfe-commits

OCHyams wrote:

Thanks for the reviews.

> Looks good; I understand we have to support driver flags forever because they 
> get baked into peoples build systems. Would we be able to get away with a cc1 
> flag instead?

> I suppose this strays into the topic of "how are we going to deploy this", 
> which as everything is behind a compile time flag, we probably don't need to 
> immediately answer. IMO we don't have to support driver flags forever that 
> were in turn behind their own experimental compile-time flag.

@jmorse Does the in-line conversation change your stance on this? If not, it 
would be easier to make this cc1 after I've uploaded bitcode handling patches, 
if it's alright to have it in this state temporarily to keep things moving - as 
all the front end patches are blocked on this one.

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


[clang] clang-format: Add IncludeSortKey option (PR #137840)

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


@@ -5368,6 +5368,8 @@ struct FormatStyle {
IncludeStyle.IncludeIsMainSourceRegex ==
R.IncludeStyle.IncludeIsMainSourceRegex &&
IncludeStyle.MainIncludeChar == R.IncludeStyle.MainIncludeChar &&
+   IncludeStyle.IncludeSortIgnoreExtension ==

HazardyKnusperkeks wrote:

Please resort.

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


[clang] clang-format: Add IncludeSortKey option (PR #137840)

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


@@ -152,6 +152,10 @@ struct IncludeStyle {
   /// \version 10
   std::string IncludeIsMainSourceRegex;
 
+  /// When sorting includes in each block, ignore file extensions.

HazardyKnusperkeks wrote:

I currently don't have a better name, but this isn't correct. You are not 
ignoring it, but still using it to break ties. Even if the name stays, I think 
there should be more explanation, maybe even an example.

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


[clang] [clang][bytecode] Use a SmallVector for EvalEmitter's locals (PR #140513)

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

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

The offset we return for them are just indices, so we can use a vector here.

>From e4bcf674619283cd0d7a7d4e613a5621de17ca66 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sat, 17 May 2025 14:27:43 +0200
Subject: [PATCH] [clang][bytecode] Use a SmallVector for EvalEmitter's locals

The offset we return for them are just indices, so we can use a vector
here.
---
 clang/lib/AST/ByteCode/EvalEmitter.cpp | 4 ++--
 clang/lib/AST/ByteCode/EvalEmitter.h   | 7 +++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 37e8d3788a6fe..5498065657e0a 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -20,7 +20,7 @@ EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State 
&Parent,
 : Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {}
 
 EvalEmitter::~EvalEmitter() {
-  for (auto &[K, V] : Locals) {
+  for (auto &V : Locals) {
 Block *B = reinterpret_cast(V.get());
 if (B->isInitialized())
   B->invokeDtor();
@@ -112,7 +112,7 @@ Scope::Local EvalEmitter::createLocal(Descriptor *D) {
 
   // Register the local.
   unsigned Off = Locals.size();
-  Locals.insert({Off, std::move(Memory)});
+  Locals.push_back(std::move(Memory));
   return {Off, D};
 }
 
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h 
b/clang/lib/AST/ByteCode/EvalEmitter.h
index f9c1ff07625b8..7303adba22af7 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -111,12 +111,11 @@ class EvalEmitter : public SourceMapper {
   std::optional PtrCB;
 
   /// Temporaries which require storage.
-  llvm::DenseMap> Locals;
+  llvm::SmallVector> Locals;
 
   Block *getLocal(unsigned Index) const {
-auto It = Locals.find(Index);
-assert(It != Locals.end() && "Missing local variable");
-return reinterpret_cast(It->second.get());
+assert(Index < Locals.size());
+return reinterpret_cast(Locals[Index].get());
   }
 
   void updateGlobalTemporaries();

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


[clang] [clang-format][NFC] Upgrade SortIncludes option to a struct (PR #140497)

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

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


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


[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)

2025-05-19 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/116709

>From e0bb550672326e21a556ac727f2e2a6ef65f0469 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Tue, 1 Oct 2024 11:08:02 +0200
Subject: [PATCH] [Clang] Add __builtin_invoke and recognize std::invoke as a
 builtin

---
 clang/include/clang/Basic/Builtins.td |   6 +
 clang/include/clang/Sema/Sema.h   |   9 +
 clang/lib/Parse/ParseDeclCXX.cpp  |  24 +--
 clang/lib/Sema/SemaChecking.cpp   |  97 +++
 clang/lib/Sema/SemaExprCXX.cpp| 105 ++--
 clang/test/CodeGenCXX/builtin-invoke.cpp  |  61 +++
 clang/test/SemaCXX/builtin-invoke.cpp | 133 +++
 libcxx/include/__type_traits/invoke.h | 155 ++
 .../__type_traits/is_core_convertible.h   |  11 ++
 9 files changed, 499 insertions(+), 102 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/builtin-invoke.cpp
 create mode 100644 clang/test/SemaCXX/builtin-invoke.cpp

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 187d3b5ed24a7..58cc35088c40a 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4272,6 +4272,12 @@ def MoveIfNsoexcept : CxxLibBuiltin<"utility"> {
   let Namespace = "std";
 }
 
+def Invoke : Builtin {
+  let Spellings = ["__builtin_invoke"];
+  let Attributes = [CustomTypeChecking, Constexpr];
+  let Prototype = "void(...)";
+}
+
 def Annotation : Builtin {
   let Spellings = ["__builtin_annotation"];
   let Attributes = [NoThrow, CustomTypeChecking];
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5ec67087aeea4..22d66e8688906 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2594,6 +2594,8 @@ class Sema final : public SemaBase {
SourceLocation BuiltinLoc,
SourceLocation RParenLoc);
 
+  ExprResult BuiltinInvoke(CallExpr *TheCall);
+
   static StringRef GetFormatStringTypeName(FormatStringType FST);
   static FormatStringType GetFormatStringType(StringRef FormatFlavor);
   static FormatStringType GetFormatStringType(const FormatAttr *Format);
@@ -15220,11 +15222,18 @@ class Sema final : public SemaBase {
SourceLocation Loc);
   QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind,
   SourceLocation Loc);
+
+  QualType BuiltinRemoveCVRef(QualType BaseType, SourceLocation Loc) {
+return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc);
+  }
+
   QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind,
   SourceLocation Loc);
   QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind,
SourceLocation Loc);
 
+  bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);
+
   /// Ensure that the type T is a literal type.
   ///
   /// This routine checks whether the type @p T is a literal type. If @p T is 
an
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 316bc30edf1f0..aeb1112bad8b4 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1611,29 +1611,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   Tok.isOneOf(
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait,
 #include "clang/Basic/TransformTypeTraits.def"
-  tok::kw___is_abstract,
-  tok::kw___is_aggregate,
-  tok::kw___is_arithmetic,
-  tok::kw___is_array,
-  tok::kw___is_assignable,
-  tok::kw___is_base_of,
-  tok::kw___is_bounded_array,
-  tok::kw___is_class,
-  tok::kw___is_complete_type,
-  tok::kw___is_compound,
-  tok::kw___is_const,
-  tok::kw___is_constructible,
-  tok::kw___is_convertible,
-  tok::kw___is_convertible_to,
-  tok::kw___is_destructible,
-  tok::kw___is_empty,
-  tok::kw___is_enum,
-  tok::kw___is_floating_point,
-  tok::kw___is_final,
-  tok::kw___is_function,
-  tok::kw___is_fundamental,
-  tok::kw___is_integral,
-  tok::kw___is_interface_class,
+  tok::kw___is_convertible, // Last use in libc++ was removed in 
925a11a
   tok::kw___is_literal,
   tok::kw___is_lvalue_expr,
   tok::kw___is_lvalue_reference,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a960b9931ddfd..26579de25bdf0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2368,6 +2368,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 return BuiltinShuffleVector(TheCall);
 // TheCall will be freed by the smart pointer here, but that's fine, since

[clang] [clang-format] Fix the indent of StartOfName after AttributeMacro (PR #140361)

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

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


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


[clang] [clang][bytecode] Use a SmallVector for EvalEmitter's locals (PR #140513)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

The offset we return for them are just indices, so we can use a vector here.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+2-2) 
- (modified) clang/lib/AST/ByteCode/EvalEmitter.h (+3-4) 


``diff
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 37e8d3788a6fe..5498065657e0a 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -20,7 +20,7 @@ EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State 
&Parent,
 : Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {}
 
 EvalEmitter::~EvalEmitter() {
-  for (auto &[K, V] : Locals) {
+  for (auto &V : Locals) {
 Block *B = reinterpret_cast(V.get());
 if (B->isInitialized())
   B->invokeDtor();
@@ -112,7 +112,7 @@ Scope::Local EvalEmitter::createLocal(Descriptor *D) {
 
   // Register the local.
   unsigned Off = Locals.size();
-  Locals.insert({Off, std::move(Memory)});
+  Locals.push_back(std::move(Memory));
   return {Off, D};
 }
 
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h 
b/clang/lib/AST/ByteCode/EvalEmitter.h
index f9c1ff07625b8..7303adba22af7 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -111,12 +111,11 @@ class EvalEmitter : public SourceMapper {
   std::optional PtrCB;
 
   /// Temporaries which require storage.
-  llvm::DenseMap> Locals;
+  llvm::SmallVector> Locals;
 
   Block *getLocal(unsigned Index) const {
-auto It = Locals.find(Index);
-assert(It != Locals.end() && "Missing local variable");
-return reinterpret_cast(It->second.get());
+assert(Index < Locals.size());
+return reinterpret_cast(Locals[Index].get());
   }
 
   void updateGlobalTemporaries();

``




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


[clang] [Clang][LoongArch] Match GCC behaviour when parsing FPRs in asm clobbers (PR #138391)

2025-05-19 Thread via cfe-commits

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

LGTM, thanks.

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


[clang] [clang-format] Merge short inline function in macro definition body (PR #140366)

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

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


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


[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2025-05-19 Thread Ming-Yi Lai via cfe-commits

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


[clang] [Clang][RISCV] Add Zicfilp CFI unlabeled scheme preprocessor macros (PR #109600)

2025-05-19 Thread Ming-Yi Lai via cfe-commits

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


[clang] [Clang][RISCV] Add Zicfilp CFI unlabeled scheme preprocessor macros (PR #109600)

2025-05-19 Thread Ming-Yi Lai via cfe-commits

mylai-mtk wrote:

Update: Rebase to `main` trunk

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


[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2025-05-19 Thread Ming-Yi Lai via cfe-commits

https://github.com/mylai-mtk updated 
https://github.com/llvm/llvm-project/pull/109600

>From 93617b9aa7bdc9368de80b2595e37f0e8ed72c52 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai 
Date: Fri, 10 May 2024 14:16:59 +0800
Subject: [PATCH 1/7] [clang][RISCV] Add Zicfilp CFI unlabeled scheme
 preprocessor macros

+ `#define __riscv_landing_pad 1` when any Zicfilp scheme is enabled
+ `#define __riscv_landing_pad_unlabeled 1` when the unlabeled Zicfilp scheme is
enabled
---
 clang/lib/Basic/Targets/RISCV.cpp | 19 +
 .../test/CodeGen/RISCV/riscv-cf-protection.c  | 79 +++
 2 files changed, 98 insertions(+)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index a1a2437f288a0..85d0610df974b 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -241,6 +241,25 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   if (Opts.CFProtectionReturn && ISAInfo->hasExtension("zicfiss"))
 Builder.defineMacro("__riscv_shadow_stack");
+
+  if (Opts.CFProtectionBranch) {
+auto Scheme = Opts.getCFBranchLabelScheme();
+if (Scheme == CFBranchLabelSchemeKind::Default)
+  Scheme = getDefaultCFBranchLabelScheme();
+
+Builder.defineMacro("__riscv_landing_pad", "1");
+switch (Scheme) {
+case CFBranchLabelSchemeKind::Unlabeled:
+  Builder.defineMacro("__riscv_landing_pad_unlabeled", "1");
+  break;
+case CFBranchLabelSchemeKind::FuncSig:
+  Builder.defineMacro("__riscv_landing_pad_func_sig", "1");
+  break;
+case CFBranchLabelSchemeKind::Default:
+  llvm_unreachable("default cf-branch-label scheme should already be "
+   "transformed to other scheme");
+}
+  }
 }
 
 static constexpr int NumRVVBuiltins =
diff --git a/clang/test/CodeGen/RISCV/riscv-cf-protection.c 
b/clang/test/CodeGen/RISCV/riscv-cf-protection.c
index 3a9855a3d2f01..db7b65061658c 100644
--- a/clang/test/CodeGen/RISCV/riscv-cf-protection.c
+++ b/clang/test/CodeGen/RISCV/riscv-cf-protection.c
@@ -1,71 +1,143 @@
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=unlabeled -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,UNLABELED-FLAG %s
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=func-sig -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,FUNC-SIG-MACRO %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=func-sig -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,FUNC-SIG-FLAG %s
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=unlabeled -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck \
+// RUN: --check-prefixes=NO-MACRO,UNLABELED-SCHEME-UNUSED %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=unlabeled -S \
 // RUN: -emit-llvm %s -o - 2>&1 | FileCheck \
 // RUN: --check-prefixes=NO-FLAG,UNLABELED-SCHEME-UNUSED %s
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=func-sig -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck \
+// RUN: --check-prefixes=NO-MACRO,FUNC-SIG-SCHEME-UNUSED %s
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=func-sig -S \
 // RUN: -emit-llvm %s -o - 2>&1 | FileCheck \
 // RUN: --check-prefixes=NO-FLAG,FUNC-SIG-SCHEME-UNUSED %s
 
+// RUN: %clang --target=riscv32 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
 // RUN: %clang --target=riscv32 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=unlabeled -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,UNLABELED-FLAG %s
 
+// RUN: %clang --target=riscv32 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=func-sig -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,FUNC-SIG-MACRO %s
+
 // RUN: %clang --target=riscv32 -fcf-protection=branch \
 // RUN: -mcf-branch-label-scheme=func-sig -S -emit-llvm %s -o - | FileCheck \
 // RUN: --check-prefixes=BRANCH-PROT-FLAG,FUNC-SIG-FLAG %s
 
+// RUN: %clang --target=riscv32 -mcf-branch-label-scheme=unlabeled -E -dM %s \
+// RUN: -o - 2>&1 | F

[clang] 8231182 - [libclang/python][NFC] Document how null cursors are handled (#140499)

2025-05-19 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-05-19T12:30:22+04:00
New Revision: 8231182fed491b25a9597ba83cd284e097cc31ac

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

LOG: [libclang/python][NFC] Document how null cursors are handled (#140499)

Now that we looked at this aspect closely and fixed things, I think we
can document this.

Added: 


Modified: 
clang/bindings/python/clang/cindex.py

Removed: 




diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index f65bcad780a70..6f7243cdf80ac 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1585,6 +1585,8 @@ class Cursor(Structure):
 """
 The Cursor class represents a reference to an element within the AST. It
 acts as a kind of iterator.
+
+Null cursors are mapped to None.
 """
 
 _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]



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


[clang] 6da2acf - [clang-format] Merge short inline function in macro definition body (#140366)

2025-05-19 Thread via cfe-commits

Author: Owen Pan
Date: 2025-05-19T01:30:42-07:00
New Revision: 6da2acf8e99ec517bfbe498af2519d29834e2583

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

LOG: [clang-format] Merge short inline function in macro definition body 
(#140366)

Fix #62356

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 1298e3e7bab38..f2ed027b2c047 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -314,8 +314,8 @@ class LineJoiner {
   const AnnotatedLine *Line = nullptr;
   for (auto J = I - 1; J >= AnnotatedLines.begin(); --J) {
 assert(*J);
-if ((*J)->InPPDirective || (*J)->isComment() ||
-(*J)->Level > TheLine->Level) {
+if (((*J)->InPPDirective && !(*J)->InMacroBody) ||
+(*J)->isComment() || (*J)->Level > TheLine->Level) {
   continue;
 }
 if ((*J)->Level < TheLine->Level ||

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 8fe57c80cbe25..c0633ba3c29b3 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -15093,6 +15093,13 @@ TEST_F(FormatTest, 
PullInlineFunctionDefinitionsIntoSingleLine) {
"};",
MergeInlineOnly);
 
+  MergeInlineOnly.AlignEscapedNewlines = FormatStyle::ENAS_Left;
+  verifyFormat("#define Foo\\\n"
+   "  struct S {   \\\n"
+   "void foo() { return; } \\\n"
+   "  }",
+   MergeInlineOnly);
+
   // Also verify behavior when BraceWrapping.AfterFunction = true
   MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
   MergeInlineOnly.BraceWrapping.AfterFunction = true;



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


[clang] [clang-format] Merge short inline function in macro definition body (PR #140366)

2025-05-19 Thread Owen Pan via cfe-commits

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


[clang] [WIP][analyzer] Refactor `ExplodedGraph::trim()` (PR #139939)

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

NagyDonat wrote:

You're right, repeating the same measurement produced significantly different 
results:

| Project | before this PR | this PR | Ratio |
| --- | --- | --- | --- |
| memcached | 25.70 | 28.12 | 109.4% |
| tmux | 74.18 | 74.30 | 100.2% |
| curl | 219.55 | 217.06 | 98.9% |
| twin | 52.27 | 47.75 | 91.4% |
| vim | 167.13 | 163.41 | 97.8% |
| openssl | 431.63 | 422.84 | 98.0% |
| sqlite | 959.32 | 941.19 | 98.1% |
| ffmpeg | 1353.04 | 1348.64 | 99.7% |
| postgres | 436.02 | 425.13 | 97.5% |
| tinyxml2 | 31.80 | 32.39 | 101.9% |
| libwebm | 67.39 | 65.77 | 97.6% |
| xerces | 201.98 | 225.78 | 111.8% |
| bitcoin | 175.57 | 173.28 | 98.7% |
| protobuf | 2585.72 | 2367.59 | 91.6% |
| qtbase | 3988.95 | 3984.71 | 99.9% |
| openrct2 | 1210.14 | 1175.08 | 97.1% |
| total | 11980.39 | 11693.04 | 97.6% |

At least now I know that our environment is noisy and I will need to repeat 
measurements multiple times to get usable results :sweat_smile:

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


[clang] 0cac25b - [clang-format] Fix the indent of StartOfName after AttributeMacro (#140361)

2025-05-19 Thread via cfe-commits

Author: Owen Pan
Date: 2025-05-19T01:29:16-07:00
New Revision: 0cac25bcf5a246eb8a1f02d5041731ae9a6f00e0

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

LOG: [clang-format] Fix the indent of StartOfName after AttributeMacro (#140361)

Fix #139510

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 55e1d1ceb55b7..4e4e48f90a89f 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1475,7 +1475,9 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
(PreviousNonComment->ClosesTemplateDeclaration ||
 PreviousNonComment->ClosesRequiresClause ||
 (PreviousNonComment->is(TT_AttributeMacro) &&
- Current.isNot(tok::l_paren)) ||
+ Current.isNot(tok::l_paren) &&
+ !Current.endsSequence(TT_StartOfName, TT_AttributeMacro,
+   TT_PointerOrReference)) ||
 PreviousNonComment->isOneOf(
 TT_AttributeRParen, TT_AttributeSquare, 
TT_FunctionAnnotationRParen,
 TT_JavaAnnotation, TT_LeadingJavaAnnotation))) ||

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 436beaf68bd2a..8fe57c80cbe25 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12714,6 +12714,13 @@ TEST_F(FormatTest, UnderstandsAttributes) {
   verifyGoogleFormat("SomeType* absl_nullable s{InitValue};");
   verifyGoogleFormat("SomeType* absl_nullability_unknown s(InitValue);");
   verifyGoogleFormat("SomeType* absl_nullability_unknown s{InitValue};");
+
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AttributeMacros.push_back("my_fancy_attr");
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("void foo(const MyLongTypeName* my_fancy_attr\n"
+   " testt);",
+   Style);
 }
 
 TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {



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


[clang] [clang-format] Fix the indent of StartOfName after AttributeMacro (PR #140361)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-b-1` while building `clang` at step 4 
"annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
  Passed   : 46002 (97.93%)
  Expectedly Failed:27 (0.06%)
[1368/1370] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
[1369/1370] Running the LLVM regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/wasm-ld
-- Testing: 59203 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80..
FAIL: LLVM :: tools/dsymutil/X86/op-convert-offset.test (52187 of 59203)
 TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' 
FAILED 
Exit Code: 1

Command Output (stdout):
--
warning: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o:
 timestamp mismatch between object file (2025-05-18 18:00:42.117291764) and 
debug map (2022-07-12 20:49:30.0)
warning: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o:
 timestamp mismatch between object file (2025-05-18 18:00:42.117291764) and 
debug map (2022-07-12 20:49:30.0)
warning: cann't read address attribute value.
note: while processing op-convert-offset1.c

--
Command Output (stderr):
--
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/dsymutil 
-oso-prepend-path 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 # RUN: at line 23
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/dsymutil 
-oso-prepend-path 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/llvm-dwarfdump
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
 2>&1 | 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix OBJ # RUN: at line 24
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/llvm-dwarfdump
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix OBJ
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/llvm-dwarfdump
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 | 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix DSYM # RUN: at line 25
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-m1xy5shn/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix DSYM
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-b

[clang] 5ddcd76 - [clang-format][NFC] Upgrade SortIncludes option to a struct (#140497)

2025-05-19 Thread via cfe-commits

Author: Owen Pan
Date: 2025-05-19T01:32:17-07:00
New Revision: 5ddcd765dbb088b3fe8eb09dd38db1252981962c

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

LOG: [clang-format][NFC] Upgrade SortIncludes option to a struct (#140497)

This allows adding other suboptions e.g. IgnoreExtension in #137840.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/tools/clang-format/ClangFormat.cpp
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatReplacementTest.cpp
clang/unittests/Format/SortImportsTestJava.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a4c381bf583b6..83716cc049ee3 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5990,41 +5990,25 @@ the configuration (without a prefix: ``Auto``).
 **SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 3.8` 
:ref:`¶ `
   Controls if and how clang-format will sort ``#includes``.
 
-  Possible values:
-
-  * ``SI_Never`` (in configuration: ``Never``)
-Includes are never sorted.
-
-.. code-block:: c++
-
-   #include "B/A.h"
-   #include "A/B.h"
-   #include "a/b.h"
-   #include "A/b.h"
-   #include "B/a.h"
-
-  * ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
-Includes are sorted in an ASCIIbetical or case sensitive fashion.
+  Nested configuration flags:
 
-.. code-block:: c++
+  Includes sorting options.
 
-   #include "A/B.h"
-   #include "A/b.h"
-   #include "B/A.h"
-   #include "B/a.h"
-   #include "a/b.h"
+  * ``bool Enabled`` If ``true``, includes are sorted based on the other 
suboptions below.
+(``Never`` is deprecated by ``Enabled: false``.)
 
-  * ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
-Includes are sorted in an alphabetical or case insensitive fashion.
+  * ``bool IgnoreCase`` Whether or not includes are sorted in a 
case-insensitive fashion.
+(``CaseSensitive`` and ``CaseInsensitive`` are deprecated by
+``IgnoreCase: false`` and ``IgnoreCase: true``, respectively.)
 
 .. code-block:: c++
 
-   #include "A/B.h"
-   #include "A/b.h"
-   #include "a/b.h"
-   #include "B/A.h"
-   #include "B/a.h"
-
+   true:  false:
+   #include "A/B.h"vs.#include "A/B.h"
+   #include "A/b.h"   #include "A/b.h"
+   #include "a/b.h"   #include "B/A.h"
+   #include "B/A.h"   #include "B/a.h"
+   #include "B/a.h"   #include "a/b.h"
 
 
 .. _SortJavaStaticImport:

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index b86c4bd00eb91..3ac4318824ac0 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4365,35 +4365,29 @@ struct FormatStyle {
   /// \version 18
   bool SkipMacroDefinitionBody;
 
-  /// Include sorting options.
-  enum SortIncludesOptions : int8_t {
-/// Includes are never sorted.
-/// \code
-///#include "B/A.h"
-///#include "A/B.h"
-///#include "a/b.h"
-///#include "A/b.h"
-///#include "B/a.h"
-/// \endcode
-SI_Never,
-/// Includes are sorted in an ASCIIbetical or case sensitive fashion.
-/// \code
-///#include "A/B.h"
-///#include "A/b.h"
-///#include "B/A.h"
-///#include "B/a.h"
-///#include "a/b.h"
-/// \endcode
-SI_CaseSensitive,
-/// Includes are sorted in an alphabetical or case insensitive fashion.
-/// \code
-///#include "A/B.h"
-///#include "A/b.h"
-///#include "a/b.h"
-///#include "B/A.h"
-///#include "B/a.h"
-/// \endcode
-SI_CaseInsensitive,
+  /// Includes sorting options.
+  struct SortIncludesOptions {
+/// If ``true``, includes are sorted based on the other suboptions below.
+/// (``Never`` is deprecated by ``Enabled: false``.)
+bool Enabled;
+/// Whether or not includes are sorted in a case-insensitive fashion.
+/// (``CaseSensitive`` and ``CaseInsensitive`` are deprecated by
+/// ``IgnoreCase: false`` and ``IgnoreCase: true``, respectively.)
+/// \code
+///true:  false:
+///#include "A/B.h"vs.#include "A/B.h"
+///#include "A/b.h"   #include "A/b.h"
+///#include "a/b.h"   #include "B/A.h"
+///#include "B/A.h"   #include "B/a.h"
+///#include "B/a.h"   #include "a/b.h"
+/// \endcode
+bool IgnoreCase;
+bool operator==(co

[clang] [llvm] [clang][RISCV] Emit RISCV function-signature-based CFI label in llvm::Function metadata (PR #111661)

2025-05-19 Thread Kito Cheng via cfe-commits

https://github.com/kito-cheng commented:

A high level suggestion is don't hash that until MC layer, so that we can 
easier debug and observe that from the IR level, so that means we can drop the 
hash part from this PR.

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


[clang] [clang][bytecode] Use a SmallVector for EvalEmitter's locals (PR #140513)

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

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation directive and "looprange" clause (PR #139293)

2025-05-19 Thread Walter J.T.V via cfe-commits


@@ -962,6 +962,9 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
 
   /// Number of loops generated by this loop transformation.
   unsigned NumGeneratedLoops = 0;
+  /// Number of top level canonical loop nests generated by this loop
+  /// transformation
+  unsigned NumGeneratedLoopNests = 0;

eZWALT wrote:

This distinction is indeed important and actively used in `SemaOpenMP.cpp` 
file, particularly within the `AnalyzeLoopSequence` function (starting at line 
14284). For example, it's referenced in lines 14344 and 14364 to differentiate 
between specific loop transformations. 


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


[clang-tools-extra] [clang-tidy] Do not flag strerror in concurrency-mt-unsafe (PR #140520)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Carlos Galvez (carlosgalvezp)


Changes

The docs of the check state:

> Glibc’s list is compiled from GNU web documentation with a search for 
MT-Safe tag

And strerror fulfills exactly that: 
https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html

> Function: char * strerror (int errnum)
> Preliminary: | MT-Safe | AS-Unsafe heap i18n | AC-Unsafe mem | See POSIX 
Safety Concepts.

So concurrency-mt-unsafe should not flag it.

Fixes #140515

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


3 Files Affected:

- (modified) clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp (-1) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp (+3) 


``diff
diff --git a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp 
b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
index acffaa30d418e..cf076bb40484f 100644
--- a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
@@ -153,7 +153,6 @@ static const clang::StringRef GlibcFunctions[] = {
 "::sigsuspend",
 "::sleep",
 "::srand48",
-"::strerror",
 "::strsignal",
 "::strtok",
 "::tcflow",
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 9b29ab12e1bfa..bd78b26b583c8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -172,6 +172,10 @@ Changes in existing checks
   ` check by fixing false positives when
   a function name is just prefixed with a targeted function name.
 
+- Improved :doc:`concurrency-mt-unsafe
+  ` check by fixing a false positive
+  where `strerror` was flagged as MT-unsafe.
+
 - Improved :doc:`misc-const-correctness
   ` check by adding the option
   `AllowedTypes`, that excludes specified types from const-correctness
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp
index 8b137de005a47..14d1912683795 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp
@@ -3,6 +3,7 @@
 extern unsigned int sleep (unsigned int __seconds);
 extern int *gmtime (const int *__timer);
 extern char *dirname (char *__path);
+extern char *strerror(int errnum);
 
 void foo() {
   sleep(2);
@@ -12,4 +13,6 @@ void foo() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe 
[concurrency-mt-unsafe]
 
   dirname(nullptr);
+
+  strerror(0);
 }

``




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


[clang-tools-extra] [clang-tidy] Do not flag strerror in concurrency-mt-unsafe (PR #140520)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Carlos Galvez (carlosgalvezp)


Changes

The docs of the check state:

> Glibc’s list is compiled from GNU web documentation with a search for 
MT-Safe tag

And strerror fulfills exactly that: 
https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html

> Function: char * strerror (int errnum)
> Preliminary: | MT-Safe | AS-Unsafe heap i18n | AC-Unsafe mem | See POSIX 
Safety Concepts.

So concurrency-mt-unsafe should not flag it.

Fixes #140515

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


3 Files Affected:

- (modified) clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp (-1) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp (+3) 


``diff
diff --git a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp 
b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
index acffaa30d418e..cf076bb40484f 100644
--- a/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
@@ -153,7 +153,6 @@ static const clang::StringRef GlibcFunctions[] = {
 "::sigsuspend",
 "::sleep",
 "::srand48",
-"::strerror",
 "::strsignal",
 "::strtok",
 "::tcflow",
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 9b29ab12e1bfa..bd78b26b583c8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -172,6 +172,10 @@ Changes in existing checks
   ` check by fixing false positives when
   a function name is just prefixed with a targeted function name.
 
+- Improved :doc:`concurrency-mt-unsafe
+  ` check by fixing a false positive
+  where `strerror` was flagged as MT-unsafe.
+
 - Improved :doc:`misc-const-correctness
   ` check by adding the option
   `AllowedTypes`, that excludes specified types from const-correctness
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp
index 8b137de005a47..14d1912683795 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/concurrency/mt-unsafe-glibc.cpp
@@ -3,6 +3,7 @@
 extern unsigned int sleep (unsigned int __seconds);
 extern int *gmtime (const int *__timer);
 extern char *dirname (char *__path);
+extern char *strerror(int errnum);
 
 void foo() {
   sleep(2);
@@ -12,4 +13,6 @@ void foo() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe 
[concurrency-mt-unsafe]
 
   dirname(nullptr);
+
+  strerror(0);
 }

``




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


[clang] [clang][bytecode] Add a scope to function calls (PR #140441)

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

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


[clang-tools-extra] Add check 'cppcoreguidelines-use-enum-class' (PR #138282)

2025-05-19 Thread Philipp Jung via cfe-commits

https://github.com/JungPhilipp updated 
https://github.com/llvm/llvm-project/pull/138282

>From 0567bc8e1168bb409ee759dd5505861a644a8ead Mon Sep 17 00:00:00 2001
From: Philipp Jung 
Date: Fri, 2 May 2025 15:22:40 +0200
Subject: [PATCH 1/9] Add check 'modernize-use-enum-class'

Warn on non-class enum definitions as suggested by the Core Guidelines:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class
---
 .../clang-tidy/modernize/CMakeLists.txt   |  1 +
 .../modernize/ModernizeTidyModule.cpp |  2 +
 .../modernize/UseEnumClassCheck.cpp   | 34 +++
 .../clang-tidy/modernize/UseEnumClassCheck.h  | 34 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../checks/modernize/use-enum-class.rst   | 26 +
 .../checkers/modernize/use-enum-class.cpp | 58 +++
 8 files changed, 161 insertions(+)
 create mode 100644 clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp
 create mode 100644 clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-enum-class.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-enum-class.cpp

diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
index bab1167fb15ff..ea19586b1f08c 100644
--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
@@ -34,6 +34,7 @@ add_clang_library(clangTidyModernizeModule STATIC
   UseDefaultMemberInitCheck.cpp
   UseDesignatedInitializersCheck.cpp
   UseEmplaceCheck.cpp
+  UseEnumClassCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
   UseIntegerSignComparisonCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp 
b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
index fc46c72982fdc..1f77c9a94d25a 100644
--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -35,6 +35,7 @@
 #include "UseDefaultMemberInitCheck.h"
 #include "UseDesignatedInitializersCheck.h"
 #include "UseEmplaceCheck.h"
+#include "UseEnumClassCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
 #include "UseIntegerSignComparisonCheck.h"
@@ -110,6 +111,7 @@ class ModernizeModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "modernize-use-default-member-init");
 CheckFactories.registerCheck("modernize-use-emplace");
+
CheckFactories.registerCheck("modernize-use-enum-class");
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp
new file mode 100644
index 0..9fc3614aaf498
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp
@@ -0,0 +1,34 @@
+//===--- UseEnumClassCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseEnumClassCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+void UseEnumClassCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  traverse(TK_AsIs,
+   enumDecl(unless(isScoped()), unless(hasParent(recordDecl()
+  .bind("unscoped_enum"),
+  this);
+}
+
+void UseEnumClassCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *UnscopedEnum = Result.Nodes.getNodeAs("unscoped_enum");
+
+  diag(UnscopedEnum->getLocation(),
+   "enum %0 is unscoped, use enum class instead")
+  << UnscopedEnum;
+  diag(UnscopedEnum->getLocation(), "insert 'class'", DiagnosticIDs::Note)
+  << FixItHint::CreateInsertion(UnscopedEnum->getLocation(), "class ");
+}
+
+} // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h
new file mode 100644
index 0..9cfb2024b9cfd
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h
@@ -0,0 +1,34 @@
+//===--- UseEnumClassCheck.h - clang-tidy ---*- 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
+//
+//==

[clang] [clang] Use *Map::try_emplace (NFC) (PR #140477)

2025-05-19 Thread Matt Arsenault via cfe-commits

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


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


[clang] [KeyInstr][Clang] Add Clang option -g[no-]key-instructions (PR #134627)

2025-05-19 Thread Jeremy Morse via cfe-commits

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

LGTM then, in practice we always get bitten by commandlines + LTO sooner or 
later, so I'm confident we'll end up doing-the-right-thing anyway after 
breaking our internal CI a few times.

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


[clang] [lld] [llvm] [polly] Fix regression tests with bad FileCheck checks (PR #140373)

2025-05-19 Thread Mohamed Emad via cfe-commits


@@ -377,7 +377,7 @@ void foo18() {
 // CHECK-NEXT: [[A:%.*a.*]] = getelementptr inbounds nuw [[STRUCT_G]], ptr 
[[G]], i32 0, i32 0
 // CHECK-NEXT: store i32 2, ptr [[A]], align 4
 // CHECK-NEXT: [[F:%.*]] = getelementptr inbounds i8, ptr [[G]], i64 4
-// CHECk-NEXT: call void @{{.*F.*}}(ptr noundef nonnull align 1 
dereferenceable(1)) [[F]], ie32 noundef 1)
+// CHECK-NEXT: call void @{{.*F.*}}(ptr noundef nonnull align 1 
dereferenceable(1)) [[F]], ie32 noundef 1)

hulxv wrote:

```suggestion
// CHECK-NEXT: call void @{{.*F.*}}(ptr noundef nonnull align 1 
dereferenceable(1) [[F]], i32 noundef 1)
```
I think there are some typos here that cause the failure in the tests

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


[clang] [lld] [llvm] [polly] Fix regression tests with bad FileCheck checks (PR #140373)

2025-05-19 Thread Mohamed Emad via cfe-commits


@@ -14,7 +14,7 @@
 // CHECK-DAG: @"_TI5?AUY@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo 
{ i32 0, ptr @"??_DY@@QAEXXZ", ptr null, ptr @"_CTA5?AUY@@" }, section 
".xdata", comdat
 // CHECK-DAG: @"_CT??_R0?AUDefault@@@8??_ODefault@@QAEXAAU0@@Z1" = 
linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, ptr 
@"??_R0?AUDefault@@@8", i32 0, i32 -1, i32 0, i32 1, ptr 
@"??_ODefault@@QAEXAAU0@@Z" }, section ".xdata", comdat
 // CHECK-DAG: @"_CT??_R0?AUDeletedCopy@@@81" = linkonce_odr unnamed_addr 
constant %eh.CatchableType { i32 0, ptr @"??_R0?AUDeletedCopy@@@8", i32 0, i32 
-1, i32 0, i32 1, ptr null }, section ".xdata", comdat
-// CHECk-DAG: @"_CT??_R0?AUMoveOnly@@@84" = linkonce_odr unnamed_addr constant 
%eh.CatchableType { i32 0, ptr @"??_R0?AUMoveOnly@@@8", i32 0, i321-1, i32 0, 
i32 4, ptr null }, section ".xdata", comda
+// CHECK-DAG: @"_CT??_R0?AUMoveOnly@@@84" = linkonce_odr unnamed_addr constant 
%eh.CatchableType { i32 0, ptr @"??_R0?AUMoveOnly@@@8", i32 0, i321-1, i32 0, 
i32 4, ptr null }, section ".xdata", comda

hulxv wrote:

```suggestion
// CHECK-DAG: @"_CT??_R0?AUMoveOnly@@@84" = linkonce_odr unnamed_addr constant 
%eh.CatchableType { i32 0, ptr @"??_R0?AUMoveOnly@@@8", i32 0, i32 -1, i32 0, 
i32 4, ptr null }, section ".xdata", comdat
```
More typos

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


[libclc] [libclc] Mov erf & erfc to CLC library (PR #140524)

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

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

This completes the set of maths builtins.

No attempt to vectorize or optimize this code. The implementation is licensed 
to SunPro so will probably need to be replaced at some point in the future 
anyway. Calls to other builtins have been replaced with the CLC equivalents, 
and some bit-hacking was replaced with the fabs builtin.

>From 38c1e5e62efa56c8dbca4e087555695ad34fe469 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 19 May 2025 11:10:08 +0100
Subject: [PATCH] [libclc] Mov erf & erfc to CLC library

This completes the set of maths builtins.

No attempt to vectorize or optimize this code. The implementation is
licensed to SunPro so will probably need to be replaced at some point in
the future anyway. Calls to other builtins have been replaced with the
CLC equivalents, and some bit-hacking was replaced with the fabs
builtin.
---
 libclc/clc/include/clc/math/clc_erf.h   |  19 +
 libclc/clc/include/clc/math/clc_erfc.h  |  19 +
 libclc/clc/lib/generic/SOURCES  |   2 +
 libclc/clc/lib/generic/math/clc_erf.cl  | 515 +++
 libclc/clc/lib/generic/math/clc_erfc.cl | 524 
 libclc/generic/lib/math/erf.cl  | 393 +-
 libclc/generic/lib/math/erfc.cl | 404 +-
 7 files changed, 1087 insertions(+), 789 deletions(-)
 create mode 100644 libclc/clc/include/clc/math/clc_erf.h
 create mode 100644 libclc/clc/include/clc/math/clc_erfc.h
 create mode 100644 libclc/clc/lib/generic/math/clc_erf.cl
 create mode 100644 libclc/clc/lib/generic/math/clc_erfc.cl

diff --git a/libclc/clc/include/clc/math/clc_erf.h 
b/libclc/clc/include/clc/math/clc_erf.h
new file mode 100644
index 0..01a21b36b352f
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_erf.h
@@ -0,0 +1,19 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ERF_H__
+#define __CLC_MATH_CLC_ERF_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_erf
+
+#include 
+
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ERF_H__
diff --git a/libclc/clc/include/clc/math/clc_erfc.h 
b/libclc/clc/include/clc/math/clc_erfc.h
new file mode 100644
index 0..efd581542879f
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_erfc.h
@@ -0,0 +1,19 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ERFC_H__
+#define __CLC_MATH_CLC_ERFC_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_erfc
+
+#include 
+
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ERFC_H__
diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index 9fbd8d9a77150..1cc8730d2ae8f 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -41,6 +41,8 @@ math/clc_cos.cl
 math/clc_cosh.cl
 math/clc_cospi.cl
 math/clc_ep_log.cl
+math/clc_erf.cl
+math/clc_erfc.cl
 math/clc_exp.cl
 math/clc_exp10.cl
 math/clc_exp2.cl
diff --git a/libclc/clc/lib/generic/math/clc_erf.cl 
b/libclc/clc/lib/generic/math/clc_erf.cl
new file mode 100644
index 0..3808b9b81411a
--- /dev/null
+++ b/libclc/clc/lib/generic/math/clc_erf.cl
@@ -0,0 +1,515 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * 
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * 
+ */
+
+#define erx 8.4506291151e-01f /* 0x3f58560b */
+
+// Coefficients for approximation to  erf on [0, 0.84375]
+
+#define efx 1.2837916613e-01f  /* 0x3e0375d4 */
+#define efx8 1.0270333290e+00f /* 0x3f8375d4 */
+
+#define pp0 1.2837916613e-01f  /* 0x3e0375d4 */
+#define pp1 -3

[clang] cc51cbe - [clang][Driver][test][NFC] Adjust test for targets with no cc1as (#140490)

2025-05-19 Thread via cfe-commits

Author: Hubert Tong
Date: 2025-05-19T06:23:45-04:00
New Revision: cc51cbe27877aa7cc297f7e41afa5515edabcbdc

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

LOG: [clang][Driver][test][NFC] Adjust test for targets with no cc1as (#140490)

Have the test accept use of the toolchain assembler instead of `-cc1as`
as some targets, such as AIX, do not use `-cc1as`.

Added: 


Modified: 
clang/test/Driver/no-integrated-cpp.c

Removed: 




diff  --git a/clang/test/Driver/no-integrated-cpp.c 
b/clang/test/Driver/no-integrated-cpp.c
index a7dc847f08a67..2094d4247184f 100644
--- a/clang/test/Driver/no-integrated-cpp.c
+++ b/clang/test/Driver/no-integrated-cpp.c
@@ -22,7 +22,7 @@
 // SRC-SAVE-SAME: "-o" "[[ASM:.*.s]]"
 // SRC-SAVE-SAME: "-x" "ir" "[[BITCODE]]"
 //
-// SRC-SAVE-NEXT: "-cc1as"
+// SRC-SAVE-NEXT: {{"-cc1as"|"[^"]*/as"}}
 // SRC-SAVE-SAME: "-o" "a.o" "[[ASM]]"
 //
 // RUN: %clang -O2 %t.i  -c -o a.o -no-integrated-cpp -### 2>&1 | FileCheck %s 
--check-prefixes=PRE
@@ -41,7 +41,7 @@
 // PRE-SAVE-SAME: "-o" "[[ASM:.*.s]]"
 // PRE-SAVE-SAME: "-x" "ir" "[[BITCODE]]"
 //
-// PRE-SAVE-NEXT: "-cc1as"
+// PRE-SAVE-NEXT: {{"-cc1as"|"[^"]*/as"}}
 // PRE-SAVE-SAME: "-o" "a.o" "[[ASM]]"
 //
 // RUN: %clang -O2 %s -c -emit-llvm -o a.bc -no-integrated-cpp -### 2>&1 | 
FileCheck %s --check-prefixes=LLVM



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


[clang] [clang][Driver][test][NFC] Adjust test for targets with no cc1as (PR #140490)

2025-05-19 Thread Hubert Tong via cfe-commits

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


[libclc] c27e10f - [libclc] Mov erf & erfc to CLC library (#140524)

2025-05-19 Thread via cfe-commits

Author: Fraser Cormack
Date: 2025-05-19T11:32:35+01:00
New Revision: c27e10fa65f76f5868da14c818f7cd021624ae8f

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

LOG: [libclc] Mov erf & erfc to CLC library (#140524)

This completes the set of maths builtins.

No attempt to vectorize or optimize this code. The implementation is
licensed to SunPro so will probably need to be replaced at some point in
the future anyway. Calls to other builtins have been replaced with the
CLC equivalents, and some bit-hacking was replaced with the fabs
builtin.

Added: 
libclc/clc/include/clc/math/clc_erf.h
libclc/clc/include/clc/math/clc_erfc.h
libclc/clc/lib/generic/math/clc_erf.cl
libclc/clc/lib/generic/math/clc_erfc.cl

Modified: 
libclc/clc/lib/generic/SOURCES
libclc/generic/lib/math/erf.cl
libclc/generic/lib/math/erfc.cl

Removed: 




diff  --git a/libclc/clc/include/clc/math/clc_erf.h 
b/libclc/clc/include/clc/math/clc_erf.h
new file mode 100644
index 0..01a21b36b352f
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_erf.h
@@ -0,0 +1,19 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ERF_H__
+#define __CLC_MATH_CLC_ERF_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_erf
+
+#include 
+
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ERF_H__

diff  --git a/libclc/clc/include/clc/math/clc_erfc.h 
b/libclc/clc/include/clc/math/clc_erfc.h
new file mode 100644
index 0..efd581542879f
--- /dev/null
+++ b/libclc/clc/include/clc/math/clc_erfc.h
@@ -0,0 +1,19 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef __CLC_MATH_CLC_ERFC_H__
+#define __CLC_MATH_CLC_ERFC_H__
+
+#define __CLC_BODY 
+#define __CLC_FUNCTION __clc_erfc
+
+#include 
+
+#undef __CLC_FUNCTION
+
+#endif // __CLC_MATH_CLC_ERFC_H__

diff  --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index 9fbd8d9a77150..1cc8730d2ae8f 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -41,6 +41,8 @@ math/clc_cos.cl
 math/clc_cosh.cl
 math/clc_cospi.cl
 math/clc_ep_log.cl
+math/clc_erf.cl
+math/clc_erfc.cl
 math/clc_exp.cl
 math/clc_exp10.cl
 math/clc_exp2.cl

diff  --git a/libclc/clc/lib/generic/math/clc_erf.cl 
b/libclc/clc/lib/generic/math/clc_erf.cl
new file mode 100644
index 0..3808b9b81411a
--- /dev/null
+++ b/libclc/clc/lib/generic/math/clc_erf.cl
@@ -0,0 +1,515 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * 
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * 
+ */
+
+#define erx 8.4506291151e-01f /* 0x3f58560b */
+
+// Coefficients for approximation to  erf on [0, 0.84375]
+
+#define efx 1.2837916613e-01f  /* 0x3e0375d4 */
+#define efx8 1.0270333290e+00f /* 0x3f8375d4 */
+
+#define pp0 1.2837916613e-01f  /* 0x3e0375d4 */
+#define pp1 -3.2504209876e-01f /* 0xbea66beb */
+#define pp2 -2.8481749818e-02f /* 0xbce9528f */
+#define pp3 -5.7702702470e-03f /* 0xbbbd1489 */
+#define pp4 -2.3763017452e-05f /* 0xb7c756b1 */
+#define qq1 3.9791721106e-01f  /* 0x3ecbbbce */
+#define qq2 6.5022252500e-02f  /* 0x3d852a63 */
+#define qq3 5.0813062117e-03f  /* 0x3ba68116 */
+#define qq4 1.3249473704e-04f  /* 0x390aee49 */
+#define qq5 -3.9602282413e-06f /* 0xb684e21a */
+
+// Coefficients for approximation to  erf  in [0.84375, 1.25]
+
+#define pa0 -2.3621185683e-03f /* 0xbb1acdc6 */
+#define pa1 4.1485610604e-01

[libclc] [libclc] Mov erf & erfc to CLC library (PR #140524)

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

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


[libclc] [libclc] Mov erf & erfc to CLC library (PR #140524)

2025-05-19 Thread Matt Arsenault via cfe-commits

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


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


[clang] c28d6c2 - [Clang][RISCV] Add Zicfilp CFI unlabeled scheme preprocessor macros (#109600)

2025-05-19 Thread via cfe-commits

Author: Ming-Yi Lai
Date: 2025-05-19T18:39:31+08:00
New Revision: c28d6c2f5fefa13e7c7efd245ace2698e47a494c

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

LOG: [Clang][RISCV] Add Zicfilp CFI unlabeled scheme preprocessor macros 
(#109600)

This patch adds preprocessor macros when Zicfilp CFI is enabled. To be
specific:

+ `#define __riscv_landing_pad 1` when `-fcf-protection=[full|branch]`
+ `#define __riscv_landing_pad_unlabeled 1` when
`-fcf-protection=[full|branch] -mcf-branch-label-scheme=unlabeled`

The macros are proposed in riscv-non-isa/riscv-c-api-doc#76 , and the
CLI flags are from riscv-non-isa/riscv-toolchain-conventions#54.

Added: 
clang/test/Preprocessor/riscv-cf-protection-branch.c

Modified: 
clang/lib/Basic/Targets/RISCV.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index a1a2437f288a0..6c83bf4576bf8 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -241,6 +241,25 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   if (Opts.CFProtectionReturn && ISAInfo->hasExtension("zicfiss"))
 Builder.defineMacro("__riscv_shadow_stack");
+
+  if (Opts.CFProtectionBranch) {
+auto Scheme = Opts.getCFBranchLabelScheme();
+if (Scheme == CFBranchLabelSchemeKind::Default)
+  Scheme = getDefaultCFBranchLabelScheme();
+
+Builder.defineMacro("__riscv_landing_pad");
+switch (Scheme) {
+case CFBranchLabelSchemeKind::Unlabeled:
+  Builder.defineMacro("__riscv_landing_pad_unlabeled");
+  break;
+case CFBranchLabelSchemeKind::FuncSig:
+  // TODO: Define macros after the func-sig scheme is implemented
+  break;
+case CFBranchLabelSchemeKind::Default:
+  llvm_unreachable("default cf-branch-label scheme should already be "
+   "transformed to other scheme");
+}
+  }
 }
 
 static constexpr int NumRVVBuiltins =

diff  --git a/clang/test/Preprocessor/riscv-cf-protection-branch.c 
b/clang/test/Preprocessor/riscv-cf-protection-branch.c
new file mode 100644
index 0..f658e0a8c6c0f
--- /dev/null
+++ b/clang/test/Preprocessor/riscv-cf-protection-branch.c
@@ -0,0 +1,83 @@
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=full \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -E -dM %s -o - 2>&1 | \
+// RUN: FileCheck --check-prefixes=NO-MACRO %s
+
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=unlabeled -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck --check-prefixes=NO-MACRO %s
+
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zicfilp1p0 -mcf-branch-label-scheme=func-sig -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck --check-prefixes=NO-MACRO %s
+
+// RUN: %clang --target=riscv32 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
+// RUN: %clang --target=riscv32 -fcf-protection=full \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
+// RUN: %clang --target=riscv32 -E -dM %s -o - 2>&1 | \
+// RUN: FileCheck --check-prefixes=NO-MACRO %s
+
+// RUN: %clang --target=riscv32 -mcf-branch-label-scheme=unlabeled -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck --check-prefixes=NO-MACRO %s
+
+// RUN: %clang --target=riscv32 -mcf-branch-label-scheme=func-sig -E -dM %s \
+// RUN: -o - 2>&1 | FileCheck --check-prefixes=NO-MACRO %s
+
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zicfilp1p0 -fcf-protection=branch \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zicfilp1p0 -fcf-protection=full \
+// RUN: -mcf-branch-label-scheme=unlabeled -E -dM %s -o - | FileCheck \
+// RUN: --check-prefixes=LPAD-MACRO,UNLABELED-MACRO %s
+
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zicfilp1p0 -E -dM %s -o - 2>&1 | \
+// RUN: FileCheck --check-prefixes=NO

[clang] [llvm] [NFCI] Avoid adding duplicated SpecialCaseList::Sections. (PR #140478)

2025-05-19 Thread Qinkun Bao via cfe-commits

https://github.com/qinkunbao updated 
https://github.com/llvm/llvm-project/pull/140478

>From c51ac31bd7ec778fcbb9faf74d9645384cf67206 Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Sun, 18 May 2025 20:51:54 +
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6
---
 llvm/lib/Support/SpecialCaseList.cpp  | 18 +++--
 .../unittests/Support/SpecialCaseListTest.cpp | 20 +++
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Support/SpecialCaseList.cpp 
b/llvm/lib/Support/SpecialCaseList.cpp
index dddf84cbb1ced..926aadb65d493 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -132,18 +132,24 @@ bool SpecialCaseList::createInternal(const MemoryBuffer 
*MB,
 Expected
 SpecialCaseList::addSection(StringRef SectionStr, unsigned LineNo,
 bool UseGlobs) {
-  Sections.emplace_back();
-  auto &Section = Sections.back();
-  Section.SectionStr = SectionStr;
-
-  if (auto Err = Section.SectionMatcher->insert(SectionStr, LineNo, UseGlobs)) 
{
+  auto it =
+  std::find_if(Sections.begin(), Sections.end(), [&](const Section &s) {
+return s.SectionStr == SectionStr;
+  });
+  if (it == Sections.end()) {
+Sections.emplace_back();
+auto &sec = Sections.back();
+sec.SectionStr = SectionStr;
+  }
+  it = std::prev(Sections.end());
+  if (auto Err = it->SectionMatcher->insert(SectionStr, LineNo, UseGlobs)) {
 return createStringError(errc::invalid_argument,
  "malformed section at line " + Twine(LineNo) +
  ": '" + SectionStr +
  "': " + toString(std::move(Err)));
   }
 
-  return &Section;
+  return &(*it);
 }
 
 bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) {
diff --git a/llvm/unittests/Support/SpecialCaseListTest.cpp 
b/llvm/unittests/Support/SpecialCaseListTest.cpp
index 4289a5e702155..15dc0222a57c3 100644
--- a/llvm/unittests/Support/SpecialCaseListTest.cpp
+++ b/llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -306,4 +306,24 @@ TEST_F(SpecialCaseListTest, Version2) {
   EXPECT_TRUE(SCL->inSection("sect2", "fun", "bar"));
   EXPECT_FALSE(SCL->inSection("sect3", "fun", "bar"));
 }
+
+TEST_F(SpecialCaseListTest, Version3) {
+  std::unique_ptr SCL = makeSpecialCaseList("[sect1]\n"
+ "fun:foo*\n"
+ "[sect1]\n"
+ "fun:bar*\n"
+ "[sect2]\n"
+ "fun:def\n");
+  EXPECT_TRUE(SCL->inSection("sect1", "fun", "fooz"));
+  EXPECT_TRUE(SCL->inSection("sect1", "fun", "barz"));
+  EXPECT_FALSE(SCL->inSection("sect2", "fun", "fooz"));
+
+  EXPECT_TRUE(SCL->inSection("sect2", "fun", "def"));
+  EXPECT_FALSE(SCL->inSection("sect1", "fun", "def"));
+
+  EXPECT_EQ(2u, SCL->inSectionBlame("sect1", "fun", "fooz"));
+  EXPECT_EQ(4u, SCL->inSectionBlame("sect1", "fun", "barz"));
+  EXPECT_EQ(6u, SCL->inSectionBlame("sect2", "fun", "def"));
+}
+
 }

>From 330e276fd300476df4b4ad1bd5e5c71a80f4e585 Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Mon, 19 May 2025 10:45:23 +
Subject: [PATCH 2/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6

[skip ci]
---
 .../clang/Basic/SanitizerSpecialCaseList.h|  7 +++-
 clang/lib/Basic/NoSanitizeList.cpp|  7 
 clang/lib/Basic/SanitizerSpecialCaseList.cpp  | 16 
 .../ubsan-src-ignorelist-category.test| 37 +++
 4 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/ubsan-src-ignorelist-category.test

diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // I

[clang] [llvm] [NFCI] Avoid adding duplicated SpecialCaseList::Sections. (PR #140478)

2025-05-19 Thread Qinkun Bao via cfe-commits

https://github.com/qinkunbao updated 
https://github.com/llvm/llvm-project/pull/140478

>From c51ac31bd7ec778fcbb9faf74d9645384cf67206 Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Sun, 18 May 2025 20:51:54 +
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6
---
 llvm/lib/Support/SpecialCaseList.cpp  | 18 +++--
 .../unittests/Support/SpecialCaseListTest.cpp | 20 +++
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Support/SpecialCaseList.cpp 
b/llvm/lib/Support/SpecialCaseList.cpp
index dddf84cbb1ced..926aadb65d493 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -132,18 +132,24 @@ bool SpecialCaseList::createInternal(const MemoryBuffer 
*MB,
 Expected
 SpecialCaseList::addSection(StringRef SectionStr, unsigned LineNo,
 bool UseGlobs) {
-  Sections.emplace_back();
-  auto &Section = Sections.back();
-  Section.SectionStr = SectionStr;
-
-  if (auto Err = Section.SectionMatcher->insert(SectionStr, LineNo, UseGlobs)) 
{
+  auto it =
+  std::find_if(Sections.begin(), Sections.end(), [&](const Section &s) {
+return s.SectionStr == SectionStr;
+  });
+  if (it == Sections.end()) {
+Sections.emplace_back();
+auto &sec = Sections.back();
+sec.SectionStr = SectionStr;
+  }
+  it = std::prev(Sections.end());
+  if (auto Err = it->SectionMatcher->insert(SectionStr, LineNo, UseGlobs)) {
 return createStringError(errc::invalid_argument,
  "malformed section at line " + Twine(LineNo) +
  ": '" + SectionStr +
  "': " + toString(std::move(Err)));
   }
 
-  return &Section;
+  return &(*it);
 }
 
 bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) {
diff --git a/llvm/unittests/Support/SpecialCaseListTest.cpp 
b/llvm/unittests/Support/SpecialCaseListTest.cpp
index 4289a5e702155..15dc0222a57c3 100644
--- a/llvm/unittests/Support/SpecialCaseListTest.cpp
+++ b/llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -306,4 +306,24 @@ TEST_F(SpecialCaseListTest, Version2) {
   EXPECT_TRUE(SCL->inSection("sect2", "fun", "bar"));
   EXPECT_FALSE(SCL->inSection("sect3", "fun", "bar"));
 }
+
+TEST_F(SpecialCaseListTest, Version3) {
+  std::unique_ptr SCL = makeSpecialCaseList("[sect1]\n"
+ "fun:foo*\n"
+ "[sect1]\n"
+ "fun:bar*\n"
+ "[sect2]\n"
+ "fun:def\n");
+  EXPECT_TRUE(SCL->inSection("sect1", "fun", "fooz"));
+  EXPECT_TRUE(SCL->inSection("sect1", "fun", "barz"));
+  EXPECT_FALSE(SCL->inSection("sect2", "fun", "fooz"));
+
+  EXPECT_TRUE(SCL->inSection("sect2", "fun", "def"));
+  EXPECT_FALSE(SCL->inSection("sect1", "fun", "def"));
+
+  EXPECT_EQ(2u, SCL->inSectionBlame("sect1", "fun", "fooz"));
+  EXPECT_EQ(4u, SCL->inSectionBlame("sect1", "fun", "barz"));
+  EXPECT_EQ(6u, SCL->inSectionBlame("sect2", "fun", "def"));
+}
+
 }

>From 330e276fd300476df4b4ad1bd5e5c71a80f4e585 Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Mon, 19 May 2025 10:45:23 +
Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6

[skip ci]
---
 .../clang/Basic/SanitizerSpecialCaseList.h|  7 +++-
 clang/lib/Basic/NoSanitizeList.cpp|  7 
 clang/lib/Basic/SanitizerSpecialCaseList.cpp  | 16 
 .../ubsan-src-ignorelist-category.test| 37 +++
 4 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/ubsan-src-ignorelist-category.test

diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // I

[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-05-19 Thread Daan De Meyer via cfe-commits

https://github.com/DaanDeMeyer updated 
https://github.com/llvm/llvm-project/pull/137840

>From ab2206d22a9d71df807753f193f4110b191ab77b Mon Sep 17 00:00:00 2001
From: Daan De Meyer 
Date: Tue, 29 Apr 2025 18:26:36 +0200
Subject: [PATCH] clang-format: Add IgnoreExtension option to
 SortIncludesOptions

Sorting without taking the file extension into account gives nicer results
when various header file names are substrings of other header file names,
for example, a CLI application with a main header named analyze.h and a
analyze-xxx.h header for each subcommand currently will always put analyze.h
last after all the analyze-xxx.h headers, but putting analyze.h first instead
of last is arguable nicer to read.

TLDR; Instead of

"""
/#include "analyze-blame.h"
/#include "analyze.h"
"""

You'd get

"""
/#include "analyze.h"
/#include "analyze-blame.h"
"""

Let's allow sorting without taking the file extension into account unless two
headers otherwise compare equal by introducing a new boolean option 
IgnoreExtension
for SortIncludesOptions.
---
 clang/docs/ClangFormatStyleOptions.rst  |  3 ++
 clang/include/clang/Format/Format.h | 11 ++-
 clang/lib/Format/Format.cpp | 34 +
 clang/unittests/Format/SortIncludesTest.cpp | 20 
 4 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 83716cc049ee3..18095cc09afbe 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6010,6 +6010,9 @@ the configuration (without a prefix: ``Auto``).
#include "B/A.h"   #include "B/a.h"
#include "B/a.h"   #include "a/b.h"
 
+  * ``bool IgnoreExtension`` :versionbadge:`clang-format 21`
+  When sorting includes in each block, ignore file extensions.
+
 
 .. _SortJavaStaticImport:
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3ac4318824ac0..18e314426c1ae 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4382,8 +4382,17 @@ struct FormatStyle {
 ///#include "B/a.h"   #include "a/b.h"
 /// \endcode
 bool IgnoreCase;
+/// When sorting includes in each block, Only take file extensions into
+/// account if two includes compare equal otherwise.
+/// \code
+///true:  false:
+///# include "A.h" # include "A-util.h"
+///# include "A.inc"   # include "A.h"
+///# include "A-util.h"# include "A.inc"
+/// \version 21
+bool IgnoreExtension;
 bool operator==(const SortIncludesOptions &R) const {
-  return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase;
+  return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase && 
IgnoreExtension == R.IgnoreExtension;
 }
 bool operator!=(const SortIncludesOptions &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b41a98ecb5be1..6bf951ff61bf0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1647,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
   LLVMStyle.ShortNamespaceLines = 1;
   LLVMStyle.SkipMacroDefinitionBody = false;
-  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false};
+  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false, 
/*IgnoreExtension=*/false};
   LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
@@ -3230,19 +3230,27 @@ static void sortCppIncludes(const FormatStyle &Style,
   SmallVector Indices =
   llvm::to_vector<16>(llvm::seq(0, Includes.size()));
 
-  if (Style.SortIncludes.Enabled && Style.SortIncludes.IgnoreCase) {
+  if (Style.SortIncludes.Enabled) {
 stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
-  const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
-  return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
-  Includes[LHSI].Filename) <
- std::tie(Includes[RHSI].Priority, RHSFilenameLower,
-  Includes[RHSI].Filename);
-});
-  } else {
-stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
- std::tie(Includes[RHSI].Priority, Includes[RHSI].Filename);
+  SmallString<128> LHSStem, RHSStem;
+  if (Style.SortIncludes.IgnoreExtension) {
+LHSStem = Includes[LHSI].Filename;
+RHSStem = Includes[RHSI].Filename;
+llvm::sys::path::replace_extension(LHSStem, "");
+llvm::sys::path::replace_extension(R

[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-05-19 Thread Daan De Meyer via cfe-commits

DaanDeMeyer wrote:

@owenca @HazardyKnusperkeks Rebased onto latest main to take advantage of 
@owenca's rework and addressed comments.

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


[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-05-19 Thread Daan De Meyer via cfe-commits


@@ -152,6 +152,10 @@ struct IncludeStyle {
   /// \version 10
   std::string IncludeIsMainSourceRegex;
 
+  /// When sorting includes in each block, ignore file extensions.

DaanDeMeyer wrote:

I added more explanation and added an example

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


[clang] [llvm] [NFCI] Avoid adding duplicated SpecialCaseList::Sections. (PR #140478)

2025-05-19 Thread Qinkun Bao via cfe-commits

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation directive and "looprange" clause (PR #139293)

2025-05-19 Thread Walter J.T.V via cfe-commits


@@ -11516,6 +11516,21 @@ def note_omp_implicit_dsa : Note<
   "implicitly determined as %0">;
 def err_omp_loop_var_dsa : Error<
   "loop iteration variable in the associated loop of 'omp %1' directive may 
not be %0, predetermined as %2">;
+def warn_omp_different_loop_ind_var_types : Warning <
+  "loop sequence following '#pragma omp %0' contains induction variables of 
differing types: %1 and %2">,
+  InGroup;
+def err_omp_not_canonical_loop : Error <
+  "loop after '#pragma omp %0' is not in canonical form">;
+def err_omp_not_a_loop_sequence : Error < 
+  "statement after '#pragma omp %0' must be a loop sequence containing 
canonical loops or loop-generating constructs">;
+def err_omp_empty_loop_sequence : Error <
+  "loop sequence after '#pragma omp %0' must contain at least 1 canonical loop 
or loop-generating construct">;
+def err_omp_invalid_looprange : Error <
+  "loop range in '#pragma omp %0' exceeds the number of available loops: "
+  "range end '%1' is greater than the total number of loops '%2'">;

eZWALT wrote:

The two errors serve different purposes:

1. The first is triggered when the loop sequence inside a fusion construct 
(full or ranged) contains no loops.
2. The second is specific to loopranged fusion and reports when the specified 
range exceeds the number of available loops.

While the first case is technically a subset of the second, they occur in 
different contexts. Keeping both improves clarity and helps users better 
understand the issue. That said, I’m open to refactoring if you'd prefer a 
single, more general diagnostic, though it may reduce the precision of the 
error messages.

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


[clang] [NVPTX] Support the OpenCL generic addrspace feature by default (PR #137940)

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

frasercrmck wrote:

ping, thanks

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


[clang] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-19 Thread Qinkun Bao via cfe-commits

https://github.com/qinkunbao created 
https://github.com/llvm/llvm-project/pull/140529

None

>From b83755d2aa0c5417ab8f359aa842449213437a7a Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Mon, 19 May 2025 11:14:01 +
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6
---
 .../clang/Basic/SanitizerSpecialCaseList.h|  7 +++-
 clang/lib/Basic/NoSanitizeList.cpp|  7 
 clang/lib/Basic/SanitizerSpecialCaseList.cpp  | 16 
 .../ubsan-src-ignorelist-category.test| 37 +++
 4 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/ubsan-src-ignorelist-category.test

diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // Initialize SanitizerSections.
   void createSanitizerSections();
 
   struct SanitizerSection {
 SanitizerSection(SanitizerMask SM, SectionEntries &E)
-: Mask(SM), Entries(E){};
+: Mask(SM), Entries(E) {};
 
 SanitizerMask Mask;
 SectionEntries &Entries;
diff --git a/clang/lib/Basic/NoSanitizeList.cpp 
b/clang/lib/Basic/NoSanitizeList.cpp
index e7e63c1f419e6..811480f914ec5 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -44,6 +44,13 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask,
 
 bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
   StringRef Category) const {
+  unsigned nosanline = SSCL->inSectionBlame(Mask, "src", FileName, Category);
+  unsigned sanline = SSCL->inSectionBlame(Mask, "src", FileName, "sanitize");
+  // If we have two cases such as `src:a.cpp=sanitize` and `src:a.cpp`, the
+  // current entry override the previous entry.
+  if (nosanline > 0 && sanline > 0) {
+return nosanline > sanline;
+  }
   return SSCL->inSection(Mask, "src", FileName, Category);
 }
 
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp 
b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index 2dbf04c6ede97..7da36f3801453 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -63,3 +63,19 @@ bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, 
StringRef Prefix,
 
   return false;
 }
+
+unsigned SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask,
+  StringRef Prefix,
+  StringRef Query,
+  StringRef Category) const {
+  for (auto &S : SanitizerSections) {
+if (S.Mask & Mask) {
+  unsigned lineNum =
+  SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category);
+  if (lineNum > 0) {
+return lineNum;
+  }
+}
+  }
+  return 0;
+}
diff --git a/clang/test/CodeGen/ubsan-src-ignorelist-category.test 
b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
new file mode 100644
index 0..e0efd65df8652
--- /dev/null
+++ b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck 
%s -check-prefix=CHECK-ALLOWLIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck 
%s -check-prefix=CHECK-IGNORELIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict1 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE1
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict2 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE2
+
+
+// Verify ubsan only emits checks for files in the allowlist
+
+//--- src.ignorelist
+src:*
+src:*/test1.c=sanitize
+
+//--- src.ignorelist.contradict1
+src:*

[clang] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Qinkun Bao (qinkunbao)


Changes



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


4 Files Affected:

- (modified) clang/include/clang/Basic/SanitizerSpecialCaseList.h (+6-1) 
- (modified) clang/lib/Basic/NoSanitizeList.cpp (+7) 
- (modified) clang/lib/Basic/SanitizerSpecialCaseList.cpp (+16) 
- (added) clang/test/CodeGen/ubsan-src-ignorelist-category.test (+37) 


``diff
diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // Initialize SanitizerSections.
   void createSanitizerSections();
 
   struct SanitizerSection {
 SanitizerSection(SanitizerMask SM, SectionEntries &E)
-: Mask(SM), Entries(E){};
+: Mask(SM), Entries(E) {};
 
 SanitizerMask Mask;
 SectionEntries &Entries;
diff --git a/clang/lib/Basic/NoSanitizeList.cpp 
b/clang/lib/Basic/NoSanitizeList.cpp
index e7e63c1f419e6..811480f914ec5 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -44,6 +44,13 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask,
 
 bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
   StringRef Category) const {
+  unsigned nosanline = SSCL->inSectionBlame(Mask, "src", FileName, Category);
+  unsigned sanline = SSCL->inSectionBlame(Mask, "src", FileName, "sanitize");
+  // If we have two cases such as `src:a.cpp=sanitize` and `src:a.cpp`, the
+  // current entry override the previous entry.
+  if (nosanline > 0 && sanline > 0) {
+return nosanline > sanline;
+  }
   return SSCL->inSection(Mask, "src", FileName, Category);
 }
 
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp 
b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index 2dbf04c6ede97..7da36f3801453 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -63,3 +63,19 @@ bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, 
StringRef Prefix,
 
   return false;
 }
+
+unsigned SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask,
+  StringRef Prefix,
+  StringRef Query,
+  StringRef Category) const {
+  for (auto &S : SanitizerSections) {
+if (S.Mask & Mask) {
+  unsigned lineNum =
+  SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category);
+  if (lineNum > 0) {
+return lineNum;
+  }
+}
+  }
+  return 0;
+}
diff --git a/clang/test/CodeGen/ubsan-src-ignorelist-category.test 
b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
new file mode 100644
index 0..e0efd65df8652
--- /dev/null
+++ b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck 
%s -check-prefix=CHECK-ALLOWLIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck 
%s -check-prefix=CHECK-IGNORELIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict1 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE1
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict2 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE2
+
+
+// Verify ubsan only emits checks for files in the allowlist
+
+//--- src.ignorelist
+src:*
+src:*/test1.c=sanitize
+
+//--- src.ignorelist.contradict1
+src:*
+src:*/test1.c=sanitize
+src:*/test1.c
+
+//--- src.ignorelist.contradict2
+src:*
+src:*/test1.c
+src:*/test1.c=sanitize
+
+//--- test1.c
+int add1(int a, int b) {
+// CHECK-ALLOWLIST: llvm.sadd.with.overflow.i32
+// CHECK-ALLOWLISTOVERIDE1-NOT: llvm.sadd.with.overflow.i32
+// CHECK-ALLOWLISTOVERIDE2: llvm.sadd.with.overflow.i32
+return a+b;
+}
+

[clang] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-19 Thread Qinkun Bao via cfe-commits

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


[clang] [libclang/python] Add typing annotations for the Type class (PR #140378)

2025-05-19 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

@Endilll thanks for the heads-up!   Looks like there has been some issue with 
network connectivity in our test lab over the weekend.  This is supposed to be 
resolved now; I'll keep observing the status for a bit.

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


[clang] [Clang][RISCV] Add Zicfilp CFI unlabeled scheme preprocessor macros (PR #109600)

2025-05-19 Thread Ming-Yi Lai via cfe-commits

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


[clang] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-19 Thread Qinkun Bao via cfe-commits

https://github.com/qinkunbao updated 
https://github.com/llvm/llvm-project/pull/140529

>From b83755d2aa0c5417ab8f359aa842449213437a7a Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Mon, 19 May 2025 11:14:01 +
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6
---
 .../clang/Basic/SanitizerSpecialCaseList.h|  7 +++-
 clang/lib/Basic/NoSanitizeList.cpp|  7 
 clang/lib/Basic/SanitizerSpecialCaseList.cpp  | 16 
 .../ubsan-src-ignorelist-category.test| 37 +++
 4 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/ubsan-src-ignorelist-category.test

diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // Initialize SanitizerSections.
   void createSanitizerSections();
 
   struct SanitizerSection {
 SanitizerSection(SanitizerMask SM, SectionEntries &E)
-: Mask(SM), Entries(E){};
+: Mask(SM), Entries(E) {};
 
 SanitizerMask Mask;
 SectionEntries &Entries;
diff --git a/clang/lib/Basic/NoSanitizeList.cpp 
b/clang/lib/Basic/NoSanitizeList.cpp
index e7e63c1f419e6..811480f914ec5 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -44,6 +44,13 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask,
 
 bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
   StringRef Category) const {
+  unsigned nosanline = SSCL->inSectionBlame(Mask, "src", FileName, Category);
+  unsigned sanline = SSCL->inSectionBlame(Mask, "src", FileName, "sanitize");
+  // If we have two cases such as `src:a.cpp=sanitize` and `src:a.cpp`, the
+  // current entry override the previous entry.
+  if (nosanline > 0 && sanline > 0) {
+return nosanline > sanline;
+  }
   return SSCL->inSection(Mask, "src", FileName, Category);
 }
 
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp 
b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index 2dbf04c6ede97..7da36f3801453 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -63,3 +63,19 @@ bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, 
StringRef Prefix,
 
   return false;
 }
+
+unsigned SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask,
+  StringRef Prefix,
+  StringRef Query,
+  StringRef Category) const {
+  for (auto &S : SanitizerSections) {
+if (S.Mask & Mask) {
+  unsigned lineNum =
+  SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category);
+  if (lineNum > 0) {
+return lineNum;
+  }
+}
+  }
+  return 0;
+}
diff --git a/clang/test/CodeGen/ubsan-src-ignorelist-category.test 
b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
new file mode 100644
index 0..e0efd65df8652
--- /dev/null
+++ b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck 
%s -check-prefix=CHECK-ALLOWLIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck 
%s -check-prefix=CHECK-IGNORELIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict1 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE1
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict2 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE2
+
+
+// Verify ubsan only emits checks for files in the allowlist
+
+//--- src.ignorelist
+src:*
+src:*/test1.c=sanitize
+
+//--- src.ignorelist.contradict1
+src:*
+

[clang] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-19 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,h -- 
clang/include/clang/Basic/SanitizerSpecialCaseList.h 
clang/lib/Basic/NoSanitizeList.cpp clang/lib/Basic/SanitizerSpecialCaseList.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp 
b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index 5030a7740..16b58c368 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -60,7 +60,7 @@ bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, 
StringRef Prefix,
 }
 
 unsigned SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask,
-  spStringRef Prefix,
+  sp StringRef Prefix,
   StringRef Query,
   StringRef Category) const {
   for (auto &S : SanitizerSections) {

``




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


[clang] [clang][bytecode] Diagnose failed constexpr assertions differently (PR #140000)

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

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


[clang] 572add0 - [clang][bytecode] Diagnose failed constexpr assertions differently (#140000)

2025-05-19 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-05-19T13:29:09+02:00
New Revision: 572add06012036366e02ff5fe6be8e0bd803b157

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

LOG: [clang][bytecode] Diagnose failed constexpr assertions differently 
(#14)

Adjust to the new way the ast walker is doing it.

Added: 


Modified: 
clang/lib/AST/ByteCode/Interp.cpp
clang/test/SemaCXX/consteval-assert.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 74efc3c914504..fc61de9f92701 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -851,6 +851,21 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const 
Function *F) {
   if (F->isLambdaStaticInvoker())
 return true;
 
+  // Diagnose failed assertions specially.
+  if (S.Current->getLocation(OpPC).isMacroID() &&
+  F->getDecl()->getIdentifier()) {
+// FIXME: Instead of checking for an implementation-defined function,
+// check and evaluate the assert() macro.
+StringRef Name = F->getDecl()->getName();
+bool AssertFailed =
+Name == "__assert_rtn" || Name == "__assert_fail" || Name == 
"_wassert";
+if (AssertFailed) {
+  S.FFDiag(S.Current->getLocation(OpPC),
+   diag::note_constexpr_assert_failed);
+  return false;
+}
+  }
+
   if (S.getLangOpts().CPlusPlus11) {
 const FunctionDecl *DiagDecl = F->getDecl();
 

diff  --git a/clang/test/SemaCXX/consteval-assert.cpp 
b/clang/test/SemaCXX/consteval-assert.cpp
index b54a38ff26105..8f0b9046518ee 100644
--- a/clang/test/SemaCXX/consteval-assert.cpp
+++ b/clang/test/SemaCXX/consteval-assert.cpp
@@ -1,6 +1,10 @@
-// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus -DTEST_LINUX %s
-// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus -DTEST_WINDOWS %s
-// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus -DTEST_DARWIN %s
+// RUN: %clang_cc1 -std=c++23 -verify -DTEST_LINUX %s
+// RUN: %clang_cc1 -std=c++23 -verify -DTEST_WINDOWS %s
+// RUN: %clang_cc1 -std=c++23 -verify -DTEST_DARWIN %s
+
+// RUN: %clang_cc1 -std=c++23 -verify -DTEST_LINUX %s   
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++23 -verify -DTEST_WINDOWS %s 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++23 -verify -DTEST_DARWIN %s  
-fexperimental-new-constant-interpreter
 
 #ifdef __ASSERT_FUNCTION
 #undef __ASSERT_FUNCTION



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


[clang] [Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (PR #140532)

2025-05-19 Thread Walter J.T.V via cfe-commits

https://github.com/eZWALT created 
https://github.com/llvm/llvm-project/pull/140532

This patch is closely related to #139293 and addresses an existing issue in the 
loop transformation codebase. Specifically, it corrects the handling of the 
`NumGeneratedLoops` variable in `OMPLoopTransformationDirective` AST nodes and 
its inheritors (such as OMPUnrollDirective, OMPTileDirective, etc.).

Previously, this variable was inaccurately set for certain transformations like 
reverse or tile. While this did not lead to functional bugs, since the value 
was only checked to determine whether it was greater than zero or equal to 
zero, the inconsistency could introduce problems when supporting more complex 
directives in the future.

>From affda91204c1aacdab8ebd0966a27e93feec6db3 Mon Sep 17 00:00:00 2001
From: eZWALT 
Date: Mon, 19 May 2025 10:49:10 +
Subject: [PATCH] Correct the number of generated loops

---
 clang/include/clang/AST/StmtOpenMP.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 736bcabbad1f7..7ded194dd6eb2 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5790,7 +5790,9 @@ class OMPReverseDirective final : public 
OMPLoopTransformationDirective {
   explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc)
   : OMPLoopTransformationDirective(OMPReverseDirectiveClass,
llvm::omp::OMPD_reverse, StartLoc,
-   EndLoc, 1) {}
+   EndLoc, 1) {
+setNumGeneratedLoops(1);
+  }
 
   void setPreInits(Stmt *PreInits) {
 Data->getChildren()[PreInitsOffset] = PreInits;
@@ -5857,7 +5859,7 @@ class OMPInterchangeDirective final : public 
OMPLoopTransformationDirective {
   : OMPLoopTransformationDirective(OMPInterchangeDirectiveClass,
llvm::omp::OMPD_interchange, StartLoc,
EndLoc, NumLoops) {
-setNumGeneratedLoops(3 * NumLoops);
+setNumGeneratedLoops(NumLoops);
   }
 
   void setPreInits(Stmt *PreInits) {

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


[clang] [Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (PR #140532)

2025-05-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Walter J.T.V (eZWALT)


Changes

This patch is closely related to #139293 and addresses an existing 
issue in the loop transformation codebase. Specifically, it corrects the 
handling of the `NumGeneratedLoops` variable in 
`OMPLoopTransformationDirective` AST nodes and its inheritors (such as 
OMPUnrollDirective, OMPTileDirective, etc.).

Previously, this variable was inaccurately set for certain transformations like 
reverse or tile. While this did not lead to functional bugs, since the value 
was only checked to determine whether it was greater than zero or equal to 
zero, the inconsistency could introduce problems when supporting more complex 
directives in the future.

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


1 Files Affected:

- (modified) clang/include/clang/AST/StmtOpenMP.h (+4-2) 


``diff
diff --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 736bcabbad1f7..7ded194dd6eb2 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -5790,7 +5790,9 @@ class OMPReverseDirective final : public 
OMPLoopTransformationDirective {
   explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc)
   : OMPLoopTransformationDirective(OMPReverseDirectiveClass,
llvm::omp::OMPD_reverse, StartLoc,
-   EndLoc, 1) {}
+   EndLoc, 1) {
+setNumGeneratedLoops(1);
+  }
 
   void setPreInits(Stmt *PreInits) {
 Data->getChildren()[PreInitsOffset] = PreInits;
@@ -5857,7 +5859,7 @@ class OMPInterchangeDirective final : public 
OMPLoopTransformationDirective {
   : OMPLoopTransformationDirective(OMPInterchangeDirectiveClass,
llvm::omp::OMPD_interchange, StartLoc,
EndLoc, NumLoops) {
-setNumGeneratedLoops(3 * NumLoops);
+setNumGeneratedLoops(NumLoops);
   }
 
   void setPreInits(Stmt *PreInits) {

``




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


[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-05-19 Thread Daan De Meyer via cfe-commits

https://github.com/DaanDeMeyer updated 
https://github.com/llvm/llvm-project/pull/137840

>From 33f84b217caab01a5ebbf93e4e5ac2182810c8db Mon Sep 17 00:00:00 2001
From: Daan De Meyer 
Date: Tue, 29 Apr 2025 18:26:36 +0200
Subject: [PATCH] clang-format: Add IgnoreExtension option to
 SortIncludesOptions

Sorting without taking the file extension into account gives nicer results
when various header file names are substrings of other header file names,
for example, a CLI application with a main header named analyze.h and a
analyze-xxx.h header for each subcommand currently will always put analyze.h
last after all the analyze-xxx.h headers, but putting analyze.h first instead
of last is arguable nicer to read.

TLDR; Instead of

"""
/#include "analyze-blame.h"
/#include "analyze.h"
"""

You'd get

"""
/#include "analyze.h"
/#include "analyze-blame.h"
"""

Let's allow sorting without taking the file extension into account unless two
headers otherwise compare equal by introducing a new boolean option 
IgnoreExtension
for SortIncludesOptions.
---
 clang/docs/ClangFormatStyleOptions.rst  | 11 +++
 clang/include/clang/Format/Format.h | 11 ++-
 clang/lib/Format/Format.cpp | 34 +
 clang/unittests/Format/SortIncludesTest.cpp | 20 
 4 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 83716cc049ee3..8ec658ef4b855 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6010,6 +6010,17 @@ the configuration (without a prefix: ``Auto``).
#include "B/A.h"   #include "B/a.h"
#include "B/a.h"   #include "a/b.h"
 
+  * ``bool IgnoreExtension`` :versionbadge:`clang-format 21`
+  When sorting includes in each block, Only take file extensions into
+account if two includes compare equal otherwise.
+
+.. code-block:: c++
+
+   true:  false:
+   # include "A.h" # include "A-util.h"
+   # include "A.inc"   # include "A.h"
+   # include "A-util.h"# include "A.inc"
+
 
 .. _SortJavaStaticImport:
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3ac4318824ac0..18e314426c1ae 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4382,8 +4382,17 @@ struct FormatStyle {
 ///#include "B/a.h"   #include "a/b.h"
 /// \endcode
 bool IgnoreCase;
+/// When sorting includes in each block, Only take file extensions into
+/// account if two includes compare equal otherwise.
+/// \code
+///true:  false:
+///# include "A.h" # include "A-util.h"
+///# include "A.inc"   # include "A.h"
+///# include "A-util.h"# include "A.inc"
+/// \version 21
+bool IgnoreExtension;
 bool operator==(const SortIncludesOptions &R) const {
-  return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase;
+  return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase && 
IgnoreExtension == R.IgnoreExtension;
 }
 bool operator!=(const SortIncludesOptions &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b41a98ecb5be1..6bf951ff61bf0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1647,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
   LLVMStyle.ShortNamespaceLines = 1;
   LLVMStyle.SkipMacroDefinitionBody = false;
-  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false};
+  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false, 
/*IgnoreExtension=*/false};
   LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
@@ -3230,19 +3230,27 @@ static void sortCppIncludes(const FormatStyle &Style,
   SmallVector Indices =
   llvm::to_vector<16>(llvm::seq(0, Includes.size()));
 
-  if (Style.SortIncludes.Enabled && Style.SortIncludes.IgnoreCase) {
+  if (Style.SortIncludes.Enabled) {
 stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
-  const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
-  return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
-  Includes[LHSI].Filename) <
- std::tie(Includes[RHSI].Priority, RHSFilenameLower,
-  Includes[RHSI].Filename);
-});
-  } else {
-stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
- std::tie(Includes[RHSI].Priority, Include

[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-05-19 Thread Daan De Meyer via cfe-commits

https://github.com/DaanDeMeyer updated 
https://github.com/llvm/llvm-project/pull/137840

>From beab0ecdeda1454de56cf1851dc03dda6d02673e Mon Sep 17 00:00:00 2001
From: Daan De Meyer 
Date: Tue, 29 Apr 2025 18:26:36 +0200
Subject: [PATCH] clang-format: Add IgnoreExtension option to
 SortIncludesOptions

Sorting without taking the file extension into account gives nicer results
when various header file names are substrings of other header file names,
for example, a CLI application with a main header named analyze.h and a
analyze-xxx.h header for each subcommand currently will always put analyze.h
last after all the analyze-xxx.h headers, but putting analyze.h first instead
of last is arguable nicer to read.

TLDR; Instead of

"""
/#include "analyze-blame.h"
/#include "analyze.h"
"""

You'd get

"""
/#include "analyze.h"
/#include "analyze-blame.h"
"""

Let's allow sorting without taking the file extension into account unless two
headers otherwise compare equal by introducing a new boolean option 
IgnoreExtension
for SortIncludesOptions.
---
 clang/docs/ClangFormatStyleOptions.rst  | 11 +++
 clang/include/clang/Format/Format.h | 12 +++-
 clang/lib/Format/Format.cpp | 34 +
 clang/unittests/Format/SortIncludesTest.cpp | 20 
 4 files changed, 63 insertions(+), 14 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 83716cc049ee3..8ec658ef4b855 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6010,6 +6010,17 @@ the configuration (without a prefix: ``Auto``).
#include "B/A.h"   #include "B/a.h"
#include "B/a.h"   #include "a/b.h"
 
+  * ``bool IgnoreExtension`` :versionbadge:`clang-format 21`
+  When sorting includes in each block, Only take file extensions into
+account if two includes compare equal otherwise.
+
+.. code-block:: c++
+
+   true:  false:
+   # include "A.h" # include "A-util.h"
+   # include "A.inc"   # include "A.h"
+   # include "A-util.h"# include "A.inc"
+
 
 .. _SortJavaStaticImport:
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3ac4318824ac0..fba16897b133a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4382,8 +4382,18 @@ struct FormatStyle {
 ///#include "B/a.h"   #include "a/b.h"
 /// \endcode
 bool IgnoreCase;
+/// When sorting includes in each block, Only take file extensions into
+/// account if two includes compare equal otherwise.
+/// \code
+///true:  false:
+///# include "A.h" # include "A-util.h"
+///# include "A.inc"   # include "A.h"
+///# include "A-util.h"# include "A.inc"
+/// \endcode
+/// \version 21
+bool IgnoreExtension;
 bool operator==(const SortIncludesOptions &R) const {
-  return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase;
+  return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase && 
IgnoreExtension == R.IgnoreExtension;
 }
 bool operator!=(const SortIncludesOptions &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index b41a98ecb5be1..6bf951ff61bf0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1647,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
   LLVMStyle.ShortNamespaceLines = 1;
   LLVMStyle.SkipMacroDefinitionBody = false;
-  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false};
+  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false, 
/*IgnoreExtension=*/false};
   LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
@@ -3230,19 +3230,27 @@ static void sortCppIncludes(const FormatStyle &Style,
   SmallVector Indices =
   llvm::to_vector<16>(llvm::seq(0, Includes.size()));
 
-  if (Style.SortIncludes.Enabled && Style.SortIncludes.IgnoreCase) {
+  if (Style.SortIncludes.Enabled) {
 stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  const auto LHSFilenameLower = Includes[LHSI].Filename.lower();
-  const auto RHSFilenameLower = Includes[RHSI].Filename.lower();
-  return std::tie(Includes[LHSI].Priority, LHSFilenameLower,
-  Includes[LHSI].Filename) <
- std::tie(Includes[RHSI].Priority, RHSFilenameLower,
-  Includes[RHSI].Filename);
-});
-  } else {
-stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-  return std::tie(Includes[LHSI].Priority, Includes[LHSI].Filename) <
- std::tie(Includes[RHSI

[clang] [clang-tools-extra] [clang-include-cleaner] Make cleanup attr report expr location (PR #140233)

2025-05-19 Thread Daan De Meyer via cfe-commits

https://github.com/DaanDeMeyer updated 
https://github.com/llvm/llvm-project/pull/140233

>From 75b6d33d0b46a4d3eaf794afc9224bcef9434cb9 Mon Sep 17 00:00:00 2001
From: Daan De Meyer 
Date: Fri, 16 May 2025 12:08:47 +0200
Subject: [PATCH] [clang-include-cleaner] Make cleanup attr report expr
 location

Instead of reporting the location of the attribute, let's report
the location of the function reference that's passed to the cleanup
attribute as the first argument. This is required as the attribute
might be coming from a macro which means clang-include-cleaner skips
the use as it gets attributed to the header file declaringt the macro
and not to the main file.

To make this work, we have to add a fake argument to the CleanupAttr
constructor so we can pass in the original Expr alongside the function
declaration.

Fixes #140212
---
 clang-tools-extra/include-cleaner/lib/WalkAST.cpp   | 2 +-
 clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp | 2 +-
 clang/include/clang/Basic/Attr.td   | 6 --
 clang/lib/Sema/SemaDeclAttr.cpp | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index ba6eff49e9c98..a6f2559dd8e93 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -322,7 +322,7 @@ class ASTWalker : public RecursiveASTVisitor {
   }
 
   bool VisitCleanupAttr(CleanupAttr *attr) {
-report(attr->getLocation(), attr->getFunctionDecl());
+report(attr->getExpr()->getExprLoc(), attr->getFunctionDecl());
 return true;
   }
 
diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
index 19695a34bd63e..0de0b77f33daf 100644
--- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -573,7 +573,7 @@ TEST(WalkAST, OperatorNewDelete) {
 
 TEST(WalkAST, CleanupAttr) {
   testWalk("void* $explicit^freep(void *p);",
-   "void foo() { __attribute__((^__cleanup__(freep))) char* x = 0; }");
+   "void foo() { __attribute__((__cleanup__(^freep))) char* x = 0; }");
 }
 
 } // namespace
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a6a7482a94a29..96a88089a47a2 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -226,7 +226,8 @@ class BoolArgument 
: Argument : Argument;
 class IntArgument : Argument;
 class StringArgument : Argument;
-class ExprArgument : Argument;
+class ExprArgument : Argument;
 class DeclArgument
 : Argument {
   DeclNode Kind = kind;
@@ -1351,7 +1352,8 @@ def OSConsumesThis : InheritableAttr {
 
 def Cleanup : InheritableAttr {
   let Spellings = [GCC<"cleanup">];
-  let Args = [DeclArgument];
+  let Args = [DeclArgument,
+  ExprArgument<"Expr", /*opt=*/0, /*fake=*/1>];
   let Subjects = SubjectList<[LocalVar]>;
   let Documentation = [CleanupDocs];
 }
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 4d7f0455444f1..cbd75124478df 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3620,7 +3620,7 @@ static void handleCleanupAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 return;
   }
 
-  D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD));
+  D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD, E));
 }
 
 static void handleEnumExtensibilityAttr(Sema &S, Decl *D,

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


[clang-tools-extra] Add modernize-use-span linter check (PR #140001)

2025-05-19 Thread JJ Marr via cfe-commits

jj-marr wrote:

`std::span` has a capability gap with a const reference to a `std::vector` 
until C++26 as `std::span` cannot be constructed from an initializer list. 
Should this be a C++26 check? 

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


[clang] [flang] [flang][veclib] Adding AMDLIBM target to fveclib (PR #140533)

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


[clang] [flang] [flang][veclib] Adding AMDLIBM target to fveclib (PR #140533)

2025-05-19 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-clang

Author: None (shivaramaarao)


Changes

This commit adds AMDLIBM support to fveclib targets. The support is already 
present in clang and this patch extends it to flang.

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


5 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1-1) 
- (modified) flang/include/flang/Frontend/CodeGenOptions.def (+1-1) 
- (modified) flang/lib/Frontend/CompilerInvocation.cpp (+1) 
- (modified) flang/test/Driver/fveclib-codegen.f90 (+2) 
- (modified) flang/test/Driver/fveclib.f90 (+3) 


``diff
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index b1ca747e68b89..0bd8d0c85e50a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -484,7 +484,7 @@ void Flang::addTargetOptions(const ArgList &Args,
   Triple.getArch() != llvm::Triple::x86_64)
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << Name << Triple.getArchName();
-} else if (Name == "libmvec") {
+} else if (Name == "libmvec" || Name == "AMDLIBM") {
   if (Triple.getArch() != llvm::Triple::x86 &&
   Triple.getArch() != llvm::Triple::x86_64)
 D.Diag(diag::err_drv_unsupported_opt_for_target)
diff --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flang/Frontend/CodeGenOptions.def
index d9dbd274e83e5..b50dd4fb3abda 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -42,7 +42,7 @@ CODEGENOPT(AliasAnalysis, 1, 0) ///< Enable alias analysis 
pass
 CODEGENOPT(Underscoring, 1, 1)
 ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, llvm::Reloc::PIC_) 
///< Name of the relocation model to use.
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
-ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
+ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
 ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) ///< Enable the usage of frame pointers
 
 ENUM_CODEGENOPT(DoConcurrentMapping, DoConcurrentMappingKind, 2, 
DoConcurrentMappingKind::DCMK_None) ///< Map `do concurrent` to OpenMP
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 238079a09ef3a..b6c37712d0f79 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -201,6 +201,7 @@ static bool 
parseVectorLibArg(Fortran::frontend::CodeGenOptions &opts,
   .Case("SLEEF", VectorLibrary::SLEEF)
   .Case("Darwin_libsystem_m", VectorLibrary::Darwin_libsystem_m)
   .Case("ArmPL", VectorLibrary::ArmPL)
+  .Case("AMDLIBM", VectorLibrary::AMDLIBM)
   .Case("NoLibrary", VectorLibrary::NoLibrary)
   .Default(std::nullopt);
   if (!val.has_value()) {
diff --git a/flang/test/Driver/fveclib-codegen.f90 
b/flang/test/Driver/fveclib-codegen.f90
index 802fff9772bb3..4cbb1e284f18e 100644
--- a/flang/test/Driver/fveclib-codegen.f90
+++ b/flang/test/Driver/fveclib-codegen.f90
@@ -1,6 +1,7 @@
 ! test that -fveclib= is passed to the backend
 ! RUN: %if aarch64-registered-target %{ %flang -S -Ofast -target 
aarch64-unknown-linux-gnu -fveclib=SLEEF -o - %s | FileCheck %s 
--check-prefix=SLEEF %}
 ! RUN: %if x86-registered-target %{ %flang -S -Ofast -target 
x86_64-unknown-linux-gnu -fveclib=libmvec -o - %s | FileCheck %s %}
+! RUN: %if x86-registered-target %{ %flang -S -O3 -ffast-math -target 
x86_64-unknown-linux-gnu -fveclib=AMDLIBM -o - %s | FileCheck %s 
--check-prefix=AMDLIBM %}
 ! RUN: %flang -S -Ofast -fveclib=NoLibrary -o - %s | FileCheck %s 
--check-prefix=NOLIB
 
 subroutine sb(a, b)
@@ -10,6 +11,7 @@ subroutine sb(a, b)
 ! check that we used a vectorized call to powf()
 ! CHECK: _ZGVbN4vv_powf
 ! SLEEF: _ZGVnN4vv_powf
+! AMDLIBM: amd_vrs4_powf
 ! NOLIB: powf
 a(i) = a(i) ** b(i)
   end do
diff --git a/flang/test/Driver/fveclib.f90 b/flang/test/Driver/fveclib.f90
index 1b536b8ad0f18..431a4bfc02522 100644
--- a/flang/test/Driver/fveclib.f90
+++ b/flang/test/Driver/fveclib.f90
@@ -5,6 +5,7 @@
 ! RUN: %flang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck 
-check-prefix CHECK-DARWIN_LIBSYSTEM_M %s
 ! RUN: %flang -### -c --target=aarch64-none-none -fveclib=SLEEF %s 2>&1 | 
FileCheck -check-prefix CHECK-SLEEF %s
 ! RUN: %flang -### -c --target=aarch64-none-none -fveclib=ArmPL %s 2>&1 | 
FileCheck -check-prefix CHECK-ARMPL %s
+! RUN: %flang -### -c --target=x86_64-unknown-linux-gnu -fveclib=AMDLIBM %s 
2>&1 | FileCheck -check-prefix CHECK-AMDLIBM %s
 ! RUN: %flang -### -c --target=aarch64-apple-darwi

[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

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

AaronBallman wrote:

> ```
> typedef __attribute__((__ext_vector_type__(2))) float float2;
> 
> struct vec2 {
> float2 _v;
> public:
> constexpr vec2(float x, float y) {
>_v.x = x;
>_v.y = y;
> }
> };
> 
> constexpr struct vec2 f() {
>   return vec2(1.0, 1.0);
> }
> 
> int main() {
> vec2 S = f();
> }
> ```
> 
> Clang crashes: https://godbolt.org/z/sx74s1bqd

Can confirm the crash is happening. The issue is related to the constructor 
being `constexpr` and not initializing the member variable. If you use a member 
initializer list, the assert is silenced: https://godbolt.org/z/vEbeb4jbz

Can you file an issue so we don't lose track of the bug? Also @vikramRH any 
chance you can look into this?

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


[clang] [flang] [flang][veclib] Adding AMDLIBM target to fveclib (PR #140533)

2025-05-19 Thread Kiran Chandramohan via cfe-commits

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

LG.

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


[clang] [clang][Sema] Diagnose exceptions only in non-dependent context in discarded `try/catch/throw` blocks (PR #139859)

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

AaronBallman wrote:

> > Moving the checks does work for these limited cases, but now that we don't 
> > have them there, one of the old tests now doesn't show up the diagnosis:
> > ```c++
> > void f() {
> >   throw;
> > }
> > 
> > void g() {
> >   try {
> > f();
> >   } catch (...) {
> >   }
> > }
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > Since there is a separate call:
> > ```c++
> > return Actions.ActOnCXXTryBlock(TryLoc, TryBlock.get(), Handlers);
> > ```
> > 
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
> > 
> >   
> > and debugging under lldb, breakpoints don't reach (i.e exit early) the 
> > transform calls.
> 
> Right, 'transform' only happens during template instantiation. So we need to 
> find 'some place' (that is a seperate function) to do these diagnostics. I 
> might suggest doing a new one, since there doesn't seem to be a sensible 
> place to do so otherwise... perhaps something like:
> 
> ```
> void Sema::DiagnoseExceptionUse(bool isTry) {
> // do the checking + diagnostic here, but have it check the decl-context for 
> dependence
> }
> ```
> 
> NOTE I had that return `void` instead of `bool`. (And is `Diagnose` instead 
> of `Check`). I wonder if there is value to continuing (@AaronBallman??) and 
> putting these in the AST anyway? The continued checking is perhaps valuable, 
> and tooling might appreciate it in the AST anyway.

Naively, I think `-fno-cxx-exceptions` would mean that `try`, `catch`, and 
`throw` are not even keywords; you're opting into a language dialect where 
exceptions simply don't exist at all. (`noexcept` is a bit of an outlier, I 
think the keyword should still exist, but I think `noexcept(false)` should be a 
semantic diagnostic.) However, that's not how Clang or GCC have traditionally 
behaved with this option.

GCC's behavior seems to be "if the code is outside of a discarded statement, 
then diagnose exception constructs, otherwise do not diagnose exception 
constructs but still validate that they're otherwise correct" which... is a 
choice: https://godbolt.org/z/36x5qM4dG GCC documents this as a codegen option 
so it kind of makes sense from that perspective: 
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options but 
then they diagnose even when codegen is not enabled, which is confusing: 
https://godbolt.org/z/fWfzb94e8

Clang's behavior is: "yell, yell loudly, yell as often as you can, don't ever 
stop yelling", which is... a worse choice: https://godbolt.org/z/75Y3dMr87 
Clang documents this as "enabling C++ exceptions" which is completely vague and 
unhelpful: 
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fcxx-exceptions
 Directly below, we use the same phrasing for 
`-fcxx-modules`/`-fno-cxx-modules`, which behaves how I would expect by 
disabling the keywords: https://godbolt.org/z/eq4K8E7Mr So our docs are 
inconsistent as well as unhelpful. :-/

What are the use cases for disabling exceptions but still allowing the 
constructs in source? e.g., do we want to start disabling the keywords 
entirely, and thus they won't appear in the AST? Or do we want them to be a 
codegen-only option, at which point they do appear in the AST and we only 
diagnose at CodeGen time (which is also inconsistent with GCC)? Or do we want 
to do whatever GCC does? (Note, Clang has -fcxx-exceptions and GCC does not, so 
we're already somewhat inconsistent between the two compilers.)

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


[clang] [flang] [flang][veclib] Adding AMDLIBM target to fveclib (PR #140533)

2025-05-19 Thread via cfe-commits

https://github.com/shivaramaarao created 
https://github.com/llvm/llvm-project/pull/140533

This commit adds AMDLIBM support to fveclib targets. The support is already 
present in clang and this patch extends it to flang.

>From 071cbdb22e6491ef5e5f7261cfded236e8f6582b Mon Sep 17 00:00:00 2001
From: Shivarama Rao 
Date: Mon, 19 May 2025 11:34:57 +
Subject: [PATCH] [flang][veclib] Add AMDLIBM target to fveclib

This commit adds AMDLIBM support to fveclib targets. The support is
already present in clang and this patch extends it to flang.
---
 clang/lib/Driver/ToolChains/Flang.cpp   | 2 +-
 flang/include/flang/Frontend/CodeGenOptions.def | 2 +-
 flang/lib/Frontend/CompilerInvocation.cpp   | 1 +
 flang/test/Driver/fveclib-codegen.f90   | 2 ++
 flang/test/Driver/fveclib.f90   | 3 +++
 5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index b1ca747e68b89..0bd8d0c85e50a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -484,7 +484,7 @@ void Flang::addTargetOptions(const ArgList &Args,
   Triple.getArch() != llvm::Triple::x86_64)
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << Name << Triple.getArchName();
-} else if (Name == "libmvec") {
+} else if (Name == "libmvec" || Name == "AMDLIBM") {
   if (Triple.getArch() != llvm::Triple::x86 &&
   Triple.getArch() != llvm::Triple::x86_64)
 D.Diag(diag::err_drv_unsupported_opt_for_target)
diff --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flang/Frontend/CodeGenOptions.def
index d9dbd274e83e5..b50dd4fb3abda 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -42,7 +42,7 @@ CODEGENOPT(AliasAnalysis, 1, 0) ///< Enable alias analysis 
pass
 CODEGENOPT(Underscoring, 1, 1)
 ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, llvm::Reloc::PIC_) 
///< Name of the relocation model to use.
 ENUM_CODEGENOPT(DebugInfo,  llvm::codegenoptions::DebugInfoKind, 4,  
llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate
-ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
+ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, 
llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use
 ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, 
llvm::FramePointerKind::None) ///< Enable the usage of frame pointers
 
 ENUM_CODEGENOPT(DoConcurrentMapping, DoConcurrentMappingKind, 2, 
DoConcurrentMappingKind::DCMK_None) ///< Map `do concurrent` to OpenMP
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 238079a09ef3a..b6c37712d0f79 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -201,6 +201,7 @@ static bool 
parseVectorLibArg(Fortran::frontend::CodeGenOptions &opts,
   .Case("SLEEF", VectorLibrary::SLEEF)
   .Case("Darwin_libsystem_m", VectorLibrary::Darwin_libsystem_m)
   .Case("ArmPL", VectorLibrary::ArmPL)
+  .Case("AMDLIBM", VectorLibrary::AMDLIBM)
   .Case("NoLibrary", VectorLibrary::NoLibrary)
   .Default(std::nullopt);
   if (!val.has_value()) {
diff --git a/flang/test/Driver/fveclib-codegen.f90 
b/flang/test/Driver/fveclib-codegen.f90
index 802fff9772bb3..4cbb1e284f18e 100644
--- a/flang/test/Driver/fveclib-codegen.f90
+++ b/flang/test/Driver/fveclib-codegen.f90
@@ -1,6 +1,7 @@
 ! test that -fveclib= is passed to the backend
 ! RUN: %if aarch64-registered-target %{ %flang -S -Ofast -target 
aarch64-unknown-linux-gnu -fveclib=SLEEF -o - %s | FileCheck %s 
--check-prefix=SLEEF %}
 ! RUN: %if x86-registered-target %{ %flang -S -Ofast -target 
x86_64-unknown-linux-gnu -fveclib=libmvec -o - %s | FileCheck %s %}
+! RUN: %if x86-registered-target %{ %flang -S -O3 -ffast-math -target 
x86_64-unknown-linux-gnu -fveclib=AMDLIBM -o - %s | FileCheck %s 
--check-prefix=AMDLIBM %}
 ! RUN: %flang -S -Ofast -fveclib=NoLibrary -o - %s | FileCheck %s 
--check-prefix=NOLIB
 
 subroutine sb(a, b)
@@ -10,6 +11,7 @@ subroutine sb(a, b)
 ! check that we used a vectorized call to powf()
 ! CHECK: _ZGVbN4vv_powf
 ! SLEEF: _ZGVnN4vv_powf
+! AMDLIBM: amd_vrs4_powf
 ! NOLIB: powf
 a(i) = a(i) ** b(i)
   end do
diff --git a/flang/test/Driver/fveclib.f90 b/flang/test/Driver/fveclib.f90
index 1b536b8ad0f18..431a4bfc02522 100644
--- a/flang/test/Driver/fveclib.f90
+++ b/flang/test/Driver/fveclib.f90
@@ -5,6 +5,7 @@
 ! RUN: %flang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck 
-check-prefix CHECK-DARWIN_LIBSYSTEM_M %s
 ! RUN: %flang -### -c --target=aarch64-none-none -fveclib=SLEEF %s 2>&1 | 
FileCheck -check-prefix CHECK-SLEEF %s
 ! RUN: %flang -### -c --target=aarch64-none-none -fveclib=ArmPL

[clang-tools-extra] [clang-tidy] Add avoid-pragma-once. (PR #140388)

2025-05-19 Thread Tommy Chen via cfe-commits

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

>From 5bc074dadddb094bf954388a95ecb818abe17b56 Mon Sep 17 00:00:00 2001
From: dl8sd11 
Date: Sat, 17 May 2025 17:23:26 +
Subject: [PATCH 1/8] [clang-tidy] Add avoid-pragma-once.

---
 .../portability/AvoidPragmaOnceCheck.cpp  | 49 +++
 .../portability/AvoidPragmaOnceCheck.h| 34 +
 .../clang-tidy/portability/CMakeLists.txt |  1 +
 .../portability/PortabilityTidyModule.cpp |  3 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../checks/portability/avoid-pragma-once.rst  | 12 +
 .../Inputs/avoid-pragma-once/lib.h|  1 +
 .../portability/avoid-pragma-once.cpp |  5 ++
 9 files changed, 111 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/portability/avoid-pragma-once.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/portability/Inputs/avoid-pragma-once/lib.h
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/portability/avoid-pragma-once.cpp

diff --git a/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
new file mode 100644
index 0..e13b2039ac366
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
@@ -0,0 +1,49 @@
+//===--- AvoidPragmaOnceCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidPragmaOnceCheck.h"
+
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang::tidy::portability {
+
+class PragmaOnceCallbacks : public PPCallbacks {
+ public:
+  PragmaOnceCallbacks(AvoidPragmaOnceCheck *Check, const SourceManager &SM)
+  : Check(Check), SM(SM) {}
+  void PragmaDirective(SourceLocation Loc,
+   PragmaIntroducerKind Introducer) override {
+auto Str = llvm::StringRef(SM.getCharacterData(Loc));
+if (!Str.consume_front("#")) {
+  return;
+}
+Str = Str.trim();
+if (!Str.consume_front("pragma")) {
+  return;
+}
+Str = Str.trim();
+if (Str.starts_with("once")) {
+  Check->diag(Loc, "Avoid pragma once.");
+}
+  }
+
+ private:
+  AvoidPragmaOnceCheck *Check;
+  const SourceManager &SM;
+};
+
+void AvoidPragmaOnceCheck::registerPPCallbacks(const SourceManager &SM,
+   Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) 
{
+  PP->addPPCallbacks(std::make_unique(this, SM));
+}
+
+}  // namespace clang::tidy::portability
diff --git a/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h 
b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h
new file mode 100644
index 0..f5a9246f8af58
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h
@@ -0,0 +1,34 @@
+//===--- AvoidPragmaOnceCheck.h - clang-tidy *- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::portability {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/portability/avoid-pragma-once.html
+class AvoidPragmaOnceCheck : public ClangTidyCheck {
+ public:
+  AvoidPragmaOnceCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;
+  }
+
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+};
+
+}  // namespace clang::tidy::portability
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
diff --git a/clang-tools-extra/clang-tidy/portability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/portability/CMakeLists.t

[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)

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

NagyDonat wrote:

> First, let's align on why we currently have the concept of "modeling" and 
> "reporting" checkers. I think you are probably already aware of this, but 
> let's clarify this.
>
> It's a great property if the exploded graph remains sort of the same no 
> matter what checkers are enabled. It makes it easier to reason about it and 
> when and why we have sink nodes, affecting what paths explored etc.
> In the past (and also still today AFAIK in some cases) checkers checked some 
> property and reported a fatal error node. So there was a sink node if the 
> checker was enabled, but as soon as it was disabled, the sink node was 
> missing, discovering different issues in other checkers down the line in the 
> exploded graph.
> To solve this, was the effort of splitting the checkers into modeling and 
> reporting and emit the sink node regardless. This way only the user-facing 
> diagnostics would be different, but the underlying egraph would remain the 
> same regardless if we enable or disable a checker. (This statement isn't 
> quite true, but you get the principle).

I'm aware of this goal that a checker should emit sinks even if the reports are 
suppressed, and I agree that this would be useful as the effect of disabling a 
"well-behaving", trustworthy checker. However, I would guess that checkers are 
usually disabled when they mismodel the analyzed code and produce crazy garbage 
(or e.g. it's an `optin` checker checking that enforces a design rule which is 
intentionally not followed), and in those situations I think the user needs a 
tool that is more drastic than just replacing the reports with sinks.

> So the problem was that we had to hack together multiple "checker frontends" 
> and conditionally report a fatal bug or a sink node on an error.
>In theory, a "checker frontend" should only ever depend on a set of "checker 
>backends" aka. "modeling checkers".
I wish we had some better way of doing this.

I agree and I hope that the checker family framework will provide a way towards 
implementing this.

> I think we are now better than ever to achieve this that we tie together the 
> BugType and a checker frontend that we can query.

Actually I introduced the class `CheckerFrontendWithBugType` only as an ad-hoc, 
invisible helper that I intend to use to write slightly shorter code in 
situations where it applies. In more complex checker families where a single 
frontend can have multiple bug types, I intend to define multiple `BugType`s 
that each take the same single `CheckerFrontend` as their constructor argument. 
(But if the transition to the new framework is complete, we can eliminate the 
`BugType` constructor that takes a `CheckerName`, so each `BugType` will hold a 
pointer to a `CheckerFrontend`.)

- 

> This makes me question why we want to improve the ergonomics of defining and 
> organizing checkers? Is this the most important pain point we want to focus 
> on right now?

No, this is not the most important pain point -- this was just annoying me 
personally, so I tried to fix it quickly and got carried away... I wouldn't say 
that this is completely useless (we will be able to build new functionality 
onto the new framework in a way that wouldn't be possible with the old swamp of 
hacks), but this isn't an urgent project.

> To me btw, this checker families and what we had before with raw bool flags 
> are the same thing. It's just now a lot less ugly.

I agree, this is after all a non-functional change -- I'm proposing it because 
I got fed up with ugly code.

> I'll be honest with you, that right now I can't see if the currently more 
> appealing direction with option 2 would be really the better path to take (or 
> something along that line). So I think it's a risky direction to have so many 
> changes on the flight in the subject before consolidating a statusquo first 
> with checker families. After that we may have a better view what's next, if 
> we still believe that the ergonomics is the best place to invest.

I agree here as well. When I started to describe the "Default" and 
"Alternative" plans I initially felt that we need to pick between them right 
now; but as I thought about it more, it seems that they are not opposed and in 
fact the best path for eventually implementing the "Alternative" plan (which is 
indeed more appealing intuitively) would be first implementing the "Default" 
plan (which cleans up lots of hacks, but leaves the modeling checkers 
unchanged) and then later introducing the "Alternative" plan if we feel that we 
need it.

Based on this I'll quickly incorporate your patches and the "use the internal 
classname-like checker name" logic onto the branch, and then I think we can 
merge it as a good enough implementation of the Default plan framework.

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

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

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

AaronBallman wrote:

> > I question if -Wloop-analysis should be completely rewritten using dataflow 
> > analysis, rather than AST based matching.
> 
> should changes inside functions be handled in the following cases?
> 
> https://github.com/llvm/llvm-project/blob/db0f754c5af8e6c96770533520bf8b17fc0dc977/clang/test/SemaCXX/warn-loop-analysis.cpp#L23
> 
> https://github.com/llvm/llvm-project/blob/db0f754c5af8e6c96770533520bf8b17fc0dc977/clang/test/SemaCXX/warn-loop-analysis.cpp#L8
> 
> > rewritten using dataflow analysis
> 
> [`ExprMutationAnalyzer`](https://github.com/llvm/llvm-project/blob/main/clang/lib/Analysis/ExprMutationAnalyzer.cpp)?
> 
> /cc @AaronBallman @zyn0217 @cor3ntin

Oh that's a fun case. I think the behavior of that test makes sense if there 
was no definition for `by_ref` because we'd want to assume the non-`const` 
reference parameter is modified. But because we can see the definition for 
`by_ref`, we know the body is empty and so the variable is not modified, and so 
issuing the diagnostic there would be reasonable. WDYT?

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


[clang] [flang] [flang][veclib] Adding AMDLIBM target to fveclib (PR #140533)

2025-05-19 Thread via cfe-commits

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

LGTM. Thanks

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


[clang-tools-extra] [clang-tidy] Add avoid-pragma-once. (PR #140388)

2025-05-19 Thread Tommy Chen via cfe-commits

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

>From 5bc074dadddb094bf954388a95ecb818abe17b56 Mon Sep 17 00:00:00 2001
From: dl8sd11 
Date: Sat, 17 May 2025 17:23:26 +
Subject: [PATCH 1/9] [clang-tidy] Add avoid-pragma-once.

---
 .../portability/AvoidPragmaOnceCheck.cpp  | 49 +++
 .../portability/AvoidPragmaOnceCheck.h| 34 +
 .../clang-tidy/portability/CMakeLists.txt |  1 +
 .../portability/PortabilityTidyModule.cpp |  3 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../checks/portability/avoid-pragma-once.rst  | 12 +
 .../Inputs/avoid-pragma-once/lib.h|  1 +
 .../portability/avoid-pragma-once.cpp |  5 ++
 9 files changed, 111 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/portability/avoid-pragma-once.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/portability/Inputs/avoid-pragma-once/lib.h
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/portability/avoid-pragma-once.cpp

diff --git a/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
new file mode 100644
index 0..e13b2039ac366
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp
@@ -0,0 +1,49 @@
+//===--- AvoidPragmaOnceCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidPragmaOnceCheck.h"
+
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang::tidy::portability {
+
+class PragmaOnceCallbacks : public PPCallbacks {
+ public:
+  PragmaOnceCallbacks(AvoidPragmaOnceCheck *Check, const SourceManager &SM)
+  : Check(Check), SM(SM) {}
+  void PragmaDirective(SourceLocation Loc,
+   PragmaIntroducerKind Introducer) override {
+auto Str = llvm::StringRef(SM.getCharacterData(Loc));
+if (!Str.consume_front("#")) {
+  return;
+}
+Str = Str.trim();
+if (!Str.consume_front("pragma")) {
+  return;
+}
+Str = Str.trim();
+if (Str.starts_with("once")) {
+  Check->diag(Loc, "Avoid pragma once.");
+}
+  }
+
+ private:
+  AvoidPragmaOnceCheck *Check;
+  const SourceManager &SM;
+};
+
+void AvoidPragmaOnceCheck::registerPPCallbacks(const SourceManager &SM,
+   Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) 
{
+  PP->addPPCallbacks(std::make_unique(this, SM));
+}
+
+}  // namespace clang::tidy::portability
diff --git a/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h 
b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h
new file mode 100644
index 0..f5a9246f8af58
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.h
@@ -0,0 +1,34 @@
+//===--- AvoidPragmaOnceCheck.h - clang-tidy *- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::portability {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/portability/avoid-pragma-once.html
+class AvoidPragmaOnceCheck : public ClangTidyCheck {
+ public:
+  AvoidPragmaOnceCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;
+  }
+
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+};
+
+}  // namespace clang::tidy::portability
+
+#endif  // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
diff --git a/clang-tools-extra/clang-tidy/portability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/portability/CMakeLists.t

[clang] [Clang][LoongArch] Match GCC behaviour when parsing FPRs in asm clobbers (PR #138391)

2025-05-19 Thread via cfe-commits

wangleiat wrote:

> There're four possible formats to refer a register in inline assembly,
> 
> 1. Numeric name without dollar sign ("f0")
> 2. Numeric name with dollar sign ("$f0")
> 3. ABI name without dollar sign ("fa0")
> 4. ABI name with dollar sign ("$fa0")
> 
> LoongArch GCC accepts 1 and 2 for FPRs before r15-8284[1] and all these 
> formats after the chagne. But Clang supports only 2 and 4 for FPRs. The 
> inconsistency has caused compatibility issues, such as QEMU's case[2].
> 
> This patch follows 
> [0bbf3dd](https://github.com/llvm/llvm-project/commit/0bbf3ddf5fea86e0eb0726142827e175aadaf53b)
>  ("[Clang][LoongArch] Add GPR alias handling without `$` prefix") and accepts 
> FPRs without dollar sign prefixes as well to keep aligned with GCC, avoiding 
> future compatibility problems.
> 
> Link: 
> https://gcc.gnu.org/cgit/gcc/commit/?id=d0110185eb78f14a8e485f410bee237c9c71548d
>  [1] Link: 
> https://lore.kernel.org/qemu-devel/20250314033150.53268-3-zi...@disroot.org/ 
> [2]

GCC handles `vr` and `xr` in the same way, but the generated registers are 
incorrect. For now, it's sufficient to handle only fr.


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


[clang] [Clang][RISCV] Add Zicfilp CFI unlabeled scheme preprocessor macros (PR #109600)

2025-05-19 Thread Kito Cheng via cfe-commits

https://github.com/kito-cheng approved this pull request.

LGTM

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


[clang] [libclang/python][NFC] Document how null cursors are handled (PR #140499)

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

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


[clang] 172c281 - [clang][bytecode] Use a SmallVector for EvalEmitter's locals (#140513)

2025-05-19 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-05-19T11:19:35+02:00
New Revision: 172c2817e5912901f65bd7a43f6df559fb5fcfd3

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

LOG: [clang][bytecode] Use a SmallVector for EvalEmitter's locals (#140513)

The offset we return for them are just indices, so we can use a vector
here.

Added: 


Modified: 
clang/lib/AST/ByteCode/EvalEmitter.cpp
clang/lib/AST/ByteCode/EvalEmitter.h

Removed: 




diff  --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 37e8d3788a6fe..5498065657e0a 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -20,7 +20,7 @@ EvalEmitter::EvalEmitter(Context &Ctx, Program &P, State 
&Parent,
 : Ctx(Ctx), P(P), S(Parent, P, Stk, Ctx, this), EvalResult(&Ctx) {}
 
 EvalEmitter::~EvalEmitter() {
-  for (auto &[K, V] : Locals) {
+  for (auto &V : Locals) {
 Block *B = reinterpret_cast(V.get());
 if (B->isInitialized())
   B->invokeDtor();
@@ -112,7 +112,7 @@ Scope::Local EvalEmitter::createLocal(Descriptor *D) {
 
   // Register the local.
   unsigned Off = Locals.size();
-  Locals.insert({Off, std::move(Memory)});
+  Locals.push_back(std::move(Memory));
   return {Off, D};
 }
 

diff  --git a/clang/lib/AST/ByteCode/EvalEmitter.h 
b/clang/lib/AST/ByteCode/EvalEmitter.h
index f9c1ff07625b8..7303adba22af7 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.h
+++ b/clang/lib/AST/ByteCode/EvalEmitter.h
@@ -111,12 +111,11 @@ class EvalEmitter : public SourceMapper {
   std::optional PtrCB;
 
   /// Temporaries which require storage.
-  llvm::DenseMap> Locals;
+  llvm::SmallVector> Locals;
 
   Block *getLocal(unsigned Index) const {
-auto It = Locals.find(Index);
-assert(It != Locals.end() && "Missing local variable");
-return reinterpret_cast(It->second.get());
+assert(Index < Locals.size());
+return reinterpret_cast(Locals[Index].get());
   }
 
   void updateGlobalTemporaries();



___
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   >