[clang] ca6c6f1 - [clang] UEFI do not mangle main (#139179)

2025-05-09 Thread via cfe-commits

Author: Prabhu Rajasekaran
Date: 2025-05-09T04:26:31-07:00
New Revision: ca6c6f1dfb03571dda8d8bca15b8df7d2983d4dc

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

LOG: [clang] UEFI do not mangle main (#139179)

Entry point functions such as main, wmain etc. should not be mangled for
UEFI targets.

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/default_calling_conv.cpp
clang/test/CodeGenCXX/mangle-ms.cpp
clang/test/CodeGenSYCL/kernel-caller-entry-point.cpp
clang/test/Sema/no-warn-missing-prototype.c

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index cbac75e9d109b..9cd1c71afd0f8 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3350,7 +3350,8 @@ bool FunctionDecl::isMSVCRTEntryPoint() const {
   // semantic analysis for these functions remains the same.
 
   // MSVCRT entry points only exist on MSVCRT targets.
-  if (!TUnit->getASTContext().getTargetInfo().getTriple().isOSMSVCRT())
+  if (!TUnit->getASTContext().getTargetInfo().getTriple().isOSMSVCRT() &&
+  !TUnit->getASTContext().getTargetInfo().getTriple().isUEFI())
 return false;
 
   // Nameless functions like constructors cannot be entry points.

diff  --git a/clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp 
b/clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
index 68fc10305218c..f7e593613cd6f 100644
--- a/clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
+++ b/clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-pc-win32 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-uefi %s -emit-llvm -o - | FileCheck %s
 
 // CHECK: foo{{[^#]*}}#[[ATTRS:[0-9]+]]
 __attribute__((no_caller_saved_registers)) void foo() {}

diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
index 9fcb1c68d7efa..30815bda020ea 100644
--- a/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
+++ b/clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -debug-info-kind=limited 
-emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix LINUX %s
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -debug-info-kind=limited 
-gcodeview -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix MSVC %s
+// RUN: %clang_cc1 -triple x86_64-uefi -debug-info-kind=limited -gcodeview 
-emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix MSVC %s
 
 int main(int argc, char* argv[], char* arge[]) {
   //

diff  --git a/clang/test/CodeGenCXX/default_calling_conv.cpp 
b/clang/test/CodeGenCXX/default_calling_conv.cpp
index ff81f3712116d..7b4eb156e90c4 100644
--- a/clang/test/CodeGenCXX/default_calling_conv.cpp
+++ b/clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=REGCALL --check-prefix=X86 --check-prefix=ALL
 // RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall 
-emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN32
 // RUN: %clang_cc1 -triple x86_64-windows-msvc 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s 
--check-prefix=WIN64
+// RUN: %clang_cc1 -triple x86_64-uefi -fdefault-calling-conv=vectorcall 
-emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN64
 // RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | 
FileCheck %s --check-prefix=EXPLICITCC
 // RUN: %clang_cc1 -triple m68k-unknown-linux-gnu -mrtd -emit-llvm -o - %s | 
FileCheck %s --check-prefix=RTDCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple m68k-unknown-linux-gnu 
-fdefault-calling-conv=rtdcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=RTDCALL --check-prefix=ALL

diff  --git a/clang/test/CodeGenCXX/mangle-ms.cpp 
b/clang/test/CodeGenCXX/mangle-ms.cpp
index cf69a83bbdf8c..cb1efc412ddd1 100644
--- a/clang/test/CodeGenCXX/mangle-ms.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=i386-pc-win32 
-std=c++98 | FileCheck %s
 // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=x86_64-pc-win32 
-std=c++98| FileCheck -check-prefix X64 %s
+// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=x86_64-uefi -std=c++98| 
FileCheck -check-prefix X64 %s
 // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=aarch64-pc-win32 
-std=c++98 -DARM | FileCheck -ch

[clang] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (PR #137851)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang-Unit :: ./AllClangUnitTests/11/48' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/unittests/./AllClangUnitTests-Clang-Unit-85833-11-48.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=48 GTEST_SHARD_INDEX=11 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/unittests/./AllClangUnitTests
--

Note: This is test shard 12 of 48.
[==] Running 510 tests from 105 test suites.
[--] Global test environment set-up.
[--] 1 test from MinimizeSourceToDependencyDirectivesTest
[ RUN  ] MinimizeSourceToDependencyDirectivesTest.DefineHorizontalWhitespace
[   OK ] 
MinimizeSourceToDependencyDirectivesTest.DefineHorizontalWhitespace (0 ms)
[--] 1 test from MinimizeSourceToDependencyDirectivesTest (0 ms total)

[--] 1 test from HeaderSearchTest
[ RUN  ] HeaderSearchTest.NoSearchDir
[   OK ] HeaderSearchTest.NoSearchDir (0 ms)
[--] 1 test from HeaderSearchTest (0 ms total)

[--] 1 test from ModuleDeclStateTest
[ RUN  ] ModuleDeclStateTest.ModuleImplementationPartition
[   OK ] ModuleDeclStateTest.ModuleImplementationPartition (0 ms)
[--] 1 test from ModuleDeclStateTest (0 ms total)

[--] 1 test from DxcModeTest
[ RUN  ] DxcModeTest.TargetProfileValidation
[   OK ] DxcModeTest.TargetProfileValidation (8 ms)
[--] 1 test from DxcModeTest (8 ms total)

[--] 1 test from MultilibTest
[ RUN  ] MultilibTest.SetPushback
[   OK ] MultilibTest.SetPushback (0 ms)
[--] 1 test from MultilibTest (0 ms total)

[--] 2 tests from ExprMutationAnalyzerTest
[ RUN  ] ExprMutationAnalyzerTest.CallUnresolved
[   OK ] ExprMutationAnalyzerTest.CallUnresolved (68 ms)
[ RUN  ] ExprMutationAnalyzerTest.RangeForNonArrayByConstRef
input.cc:1:103: warning: expression result unused [-Wunused-value]
1 | struct V { const int* begin() const; const int* end() const; };void f() 
{ V x; for (const int& e : x) e; }
  | 
  ^
[   OK ] ExprMutationAnalyzerTest.RangeForNonArrayByConstRef (3 ms)
[--] 2 tests from ExprMutationAnalyzerTest (71 ms total)

[--] 1 test from MacroExpansionContextTest
[ RUN  ] MacroExpansionContextTest.StringizingVariadicMacros
[   OK ] MacroExpansionContextTest.StringizingVariadicMacros (0 ms)
[--] 1 test from MacroExpansionContextTest (0 ms total)

[--] 1 test from EnvironmentTest
...

```



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


[clang] 6094080 - [clang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (#139115)

2025-05-09 Thread via cfe-commits

Author: Krzysztof Parzyszek
Date: 2025-05-09T07:41:54-05:00
New Revision: 6094080d27bc6dae4d85de207d4cf5586becf1aa

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

LOG: [clang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (#139115)

The OpenMP version is stored in language options in ASTContext. If the
context is not available, use the fallback version.

RFC:
https://discourse.llvm.org/t/rfc-alternative-spellings-of-openmp-directives/85507

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 572e62249b46f..757873fd6d414 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -9475,6 +9475,7 @@ class ConstOMPClauseVisitor :
 class OMPClausePrinter final : public OMPClauseVisitor {
   raw_ostream &OS;
   const PrintingPolicy &Policy;
+  unsigned Version;
 
   /// Process clauses with list of variables.
   template  void VisitOMPClauseList(T *Node, char StartSym);
@@ -9482,8 +9483,9 @@ class OMPClausePrinter final : public 
OMPClauseVisitor {
   template  void VisitOMPMotionClause(T *Node);
 
 public:
-  OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
-  : OS(OS), Policy(Policy) {}
+  OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy,
+   unsigned OpenMPVersion)
+  : OS(OS), Policy(Policy), Version(OpenMPVersion) {}
 
 #define GEN_CLANG_CLAUSE_CLASS
 #define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 22da5bf251ecd..3616419dce4ec 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1827,7 +1827,7 @@ void DeclPrinter::VisitOMPAllocateDecl(OMPAllocateDecl 
*D) {
 Out << ")";
   }
   if (!D->clauselist_empty()) {
-OMPClausePrinter Printer(Out, Policy);
+OMPClausePrinter Printer(Out, Policy, Context.getLangOpts().OpenMP);
 for (OMPClause *C : D->clauselists()) {
   Out << " ";
   Printer.Visit(C);
@@ -1838,7 +1838,7 @@ void DeclPrinter::VisitOMPAllocateDecl(OMPAllocateDecl 
*D) {
 void DeclPrinter::VisitOMPRequiresDecl(OMPRequiresDecl *D) {
   Out << "#pragma omp requires ";
   if (!D->clauselist_empty()) {
-OMPClausePrinter Printer(Out, Policy);
+OMPClausePrinter Printer(Out, Policy, Context.getLangOpts().OpenMP);
 for (auto I = D->clauselist_begin(), E = D->clauselist_end(); I != E; ++I)
   Printer.Visit(*I);
   }
@@ -1891,7 +1891,7 @@ void 
DeclPrinter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
 Out << D->getVarName();
 Out << ")";
 if (!D->clauselist_empty()) {
-  OMPClausePrinter Printer(Out, Policy);
+  OMPClausePrinter Printer(Out, Policy, Context.getLangOpts().OpenMP);
   for (auto *C : D->clauselists()) {
 Out << " ";
 Printer.Visit(C);

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 2226791a70b6e..c1682888934e5 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1821,7 +1821,7 @@ OMPThreadLimitClause 
*OMPThreadLimitClause::CreateEmpty(const ASTContext &C,
 void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
   OS << "if(";
   if (Node->getNameModifier() != OMPD_unknown)
-OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
+OS << getOpenMPDirectiveName(Node->getNameModifier(), Version) << ": ";
   Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
   OS << ")";
 }
@@ -2049,7 +2049,7 @@ void 
OMPClausePrinter::VisitOMPAbsentClause(OMPAbsentClause *Node) {
   for (auto &D : Node->getDirectiveKinds()) {
 if (!First)
   OS << ", ";
-OS << getOpenMPDirectiveName(D);
+OS << getOpenMPDirectiveName(D, Version);
 First = false;
   }
   OS << ")";
@@ -2067,7 +2067,7 @@ void 
OMPClausePrinter::VisitOMPContainsClause(OMPContainsClause *Node) {
   for (auto &D : Node->getDirectiveKinds()) {
 if (!First)
   OS << ", ";
-OS << getOpenMPDirectiveName(D);
+OS << getOpenMPDirectiveName(D, Version);
 First = false;
   }
   OS << ")";

diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index c6c49c6c1ba4d..dc8af1586624b 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -737,7 +737,9 @@ void StmtPrinter::VisitOMPCanonicalLoop(OMPCanonicalLoop 
*Node) {
 
 void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableD

[clang] [flang] [llvm] [flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139131)

2025-05-09 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [clang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139115)

2025-05-09 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [clang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139115)

2025-05-09 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [flang] [llvm] [flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139131)

2025-05-09 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [AArch64][SVE] Refactor getPTrue to return splat(1) when pattern=all. (PR #139236)

2025-05-09 Thread Ricardo Jesus via cfe-commits


@@ -25030,7 +25030,8 @@ static SDValue foldCSELofLASTB(SDNode *Op, SelectionDAG 
&DAG) {
   if (AnyPred.getOpcode() == AArch64ISD::REINTERPRET_CAST)
 AnyPred = AnyPred.getOperand(0);
 
-  if (TruePred != AnyPred && TruePred.getOpcode() != AArch64ISD::PTRUE)
+  if (TruePred != AnyPred && TruePred.getOpcode() != AArch64ISD::PTRUE &&
+  !ISD::isConstantSplatVectorAllOnes(TruePred.getNode()))

rj-jesus wrote:

Thanks very much for looking into this. :) In that case, I'll drop the `PTRUE` 
check in favour of `isAllActivePredicate`.

https://github.com/llvm/llvm-project/pull/139236
___
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 new check: modernize-use-scoped-lock (PR #126434)

2025-05-09 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor updated 
https://github.com/llvm/llvm-project/pull/126434

>From c30d6e1cb5770d9a7bda077c60958027515c065c Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Mon, 3 Mar 2025 09:25:03 +0300
Subject: [PATCH 01/12] [clang-tidy] add scoped-lock-check

---
 .../clang-tidy/modernize/CMakeLists.txt   |   1 +
 .../modernize/ModernizeTidyModule.cpp |   3 +
 .../modernize/UseScopedLockCheck.cpp  | 319 +++
 .../clang-tidy/modernize/UseScopedLockCheck.h |  54 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checks/modernize/use-scoped-lock.rst  | 102 +
 .../clang-tidy/checkers/Inputs/Headers/mutex  |  33 ++
 ...e-lock-warn-on-using-and-typedef-false.cpp |  31 ++
 ...scoped-lock-warn-on-single-locks-false.cpp |  96 +
 .../checkers/modernize/use-scoped-lock.cpp| 372 ++
 11 files changed, 1018 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
 create mode 100644 clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-scoped-lock.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/mutex
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-scope-lock-warn-on-using-and-typedef-false.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-scoped-lock-warn-on-single-locks-false.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-scoped-lock.cpp

diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
index bab1167fb15ff..619a27b2f9bb6 100644
--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
@@ -42,6 +42,7 @@ add_clang_library(clangTidyModernizeModule STATIC
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
   UseRangesCheck.cpp
+  UseScopedLockCheck.cpp
   UseStartsEndsWithCheck.cpp
   UseStdFormatCheck.cpp
   UseStdNumbersCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp 
b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
index fc46c72982fdc..b2d4ddd667502 100644
--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -43,6 +43,7 @@
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
 #include "UseRangesCheck.h"
+#include "UseScopedLockCheck.h"
 #include "UseStartsEndsWithCheck.h"
 #include "UseStdFormatCheck.h"
 #include "UseStdNumbersCheck.h"
@@ -80,6 +81,8 @@ class ModernizeModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "modernize-use-integer-sign-comparison");
 CheckFactories.registerCheck("modernize-use-ranges");
+CheckFactories.registerCheck(
+"modernize-use-scoped-lock");
 CheckFactories.registerCheck(
 "modernize-use-starts-ends-with");
 
CheckFactories.registerCheck("modernize-use-std-format");
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
new file mode 100644
index 0..5dbb3a2f671e6
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
@@ -0,0 +1,319 @@
+//===--- UseScopedLockCheck.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 "UseScopedLockCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Twine.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+namespace {
+
+bool isLockGuard(const QualType &Type) {
+  if (const auto *Record = Type->getAs()) {
+if (const RecordDecl *Decl = Record->getDecl()) {
+  return Decl->getName() == "lock_guard" && Decl->isInStdNamespace();
+}
+  }
+
+  if (const auto *TemplateSpecType =
+  Type->getAs()) {
+if (const TemplateDecl *Decl =
+TemplateSpecType->getTemplateName().getAsTemplateDecl()) {
+  return Decl->getName() == "lock_guard" && Decl->isInStdNamespace();
+}
+  }
+
+  return false;
+}
+
+llvm::SmallVector getLockGuardsFromDecl(const DeclStmt *DS) {
+  llvm::SmallVector LockGuards;
+
+  for (const Decl *Decl : DS->decls()) {
+if

[clang] Reland "Reland [Modules] Remove unnecessary check when generating name lookup table in ASTWriter" (PR #139253)

2025-05-09 Thread Haojian Wu via cfe-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/139253

>From b8ba1ae30227fd7c946c5f5e57fb83e47f3bbe69 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 9 May 2025 10:24:01 +0200
Subject: [PATCH] Reland "Reland [Modules] Remove unnecessary check when
 generating name lookup table in ASTWriter"

This relands the patch 
https://github.com/llvm/llvm-project/commit/67b298f6d82e0b4bb648ac0dabe895e816a77ef1
---
 clang/include/clang/Serialization/ASTWriter.h |   2 -
 clang/lib/Serialization/ASTWriter.cpp | 117 ++
 clang/test/Modules/pr61065.cppm   |   6 +-
 3 files changed, 44 insertions(+), 81 deletions(-)

diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 9f0570eddc34e..cf4ae610ea51f 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -592,8 +592,6 @@ class ASTWriter : public ASTDeserializationListener,
   void WriteTypeAbbrevs();
   void WriteType(ASTContext &Context, QualType T);
 
-  bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
-
   void GenerateSpecializationInfoLookupTable(
   const NamedDecl *D, llvm::SmallVectorImpl &Specializations,
   llvm::SmallVectorImpl &LookupTable, bool IsPartial);
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 8c5adc3959398..4211a4a7275e5 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -4504,12 +4504,6 @@ uint64_t ASTWriter::WriteSpecializationInfoLookupTable(
   return Offset;
 }
 
-bool ASTWriter::isLookupResultExternal(StoredDeclsList &Result,
-   DeclContext *DC) {
-  return Result.hasExternalDecls() &&
- DC->hasNeedToReconcileExternalVisibleStorage();
-}
-
 /// Returns ture if all of the lookup result are either external, not emitted 
or
 /// predefined. In such cases, the lookup result is not interesting and we 
don't
 /// need to record the result in the current being written module. Return false
@@ -4561,14 +4555,12 @@ void ASTWriter::GenerateNameLookupTable(
   // order.
   SmallVector Names;
 
-  // We also build up small sets of the constructor and conversion function
-  // names which are visible.
-  llvm::SmallPtrSet ConstructorNameSet, ConversionNameSet;
-
-  for (auto &Lookup : *DC->buildLookup()) {
-auto &Name = Lookup.first;
-auto &Result = Lookup.second;
+  // We also track whether we're writing out the DeclarationNameKey for
+  // constructors or conversion functions.
+  bool IncludeConstructorNames = false;
+  bool IncludeConversionNames = false;
 
+  for (auto &[Name, Result] : *DC->buildLookup()) {
 // If there are no local declarations in our lookup result, we
 // don't need to write an entry for the name at all. If we can't
 // write out a lookup set without performing more deserialization,
@@ -4577,15 +4569,8 @@ void ASTWriter::GenerateNameLookupTable(
 // Also in reduced BMI, we'd like to avoid writing unreachable
 // declarations in GMF, so we need to avoid writing declarations
 // that entirely external or unreachable.
-//
-// FIMXE: It looks sufficient to test
-// isLookupResultNotInteresting here. But due to bug we have
-// to test isLookupResultExternal here. See
-// https://github.com/llvm/llvm-project/issues/61065 for details.
-if ((GeneratingReducedBMI || isLookupResultExternal(Result, DC)) &&
-isLookupResultNotInteresting(*this, Result))
+if (GeneratingReducedBMI && isLookupResultNotInteresting(*this, Result))
   continue;
-
 // We also skip empty results. If any of the results could be external and
 // the currently available results are empty, then all of the results are
 // external and we skip it above. So the only way we get here with an empty
@@ -4600,24 +4585,26 @@ void ASTWriter::GenerateNameLookupTable(
 // results for them. This in almost certainly a bug in Clang's name lookup,
 // but that is likely to be hard or impossible to fix and so we tolerate it
 // here by omitting lookups with empty results.
-if (Lookup.second.getLookupResult().empty())
+if (Result.getLookupResult().empty())
   continue;
 
-switch (Lookup.first.getNameKind()) {
+switch (Name.getNameKind()) {
 default:
-  Names.push_back(Lookup.first);
+  Names.push_back(Name);
   break;
 
 case DeclarationName::CXXConstructorName:
-  assert(isa(DC) &&
- "Cannot have a constructor name outside of a class!");
-  ConstructorNameSet.insert(Name);
+  // assert(isa(DC) &&
+  //"Cannot have a constructor name outside of a class!");
+  // ConstructorNameSet.insert(Name);
+  IncludeConstructorNames = true;
   break;
 
 case DeclarationName::CXXConversionFunctionName:
-  assert(isa(DC) &&
- "Cannot have a conversion f

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

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

https://github.com/NagyDonat created 
https://github.com/llvm/llvm-project/pull/139256

The checker classes (i.e. classes derived from `CheckerBase` via the utility 
template `Checker<...>`) act as intermediates between the user and the analyzer 
engine, so they have two interfaces:
- On the frontend side, they have a public name, can be enabled or disabled, 
can accept checker options and can be reported as the source of bug reports.
- On the backend side, they can handle various checker callbacks and they 
"leave a mark" on the `ExplodedNode`s that are created by them. (These 
`ProgramPointTag` marks are internal: they appear in debug logs and can be 
queried by checker logic; but the user doesn't see them.)

In a significant majority of the checkers there is 1:1 correspondence between 
these sides, but there are also many checker classes where several related 
user-facing checkers share the same backend class. Historically each of these 
"multi-part checker" classes had its own hacks to juggle its multiple names, 
which led to lots of ugliness like lazy initialization of `mutable 
std::unique_ptr` members and redundant data members (when a checker 
used its custom `CheckNames` array and ignored the inherited single `Name`).

My recent commit 27099982da2f5a6c2d282d6b385e79d080669546 tried to unify and 
standardize these existing solutions to get rid of some of the technical debt, 
but it still used enum values to identify the checker parts within a 
"multi-part" checker class, which led to some ugliness.

This commit introduces a new framework which takes a more direct, 
object-oriented approach: instead of identifying checker parts with `{parent 
checker object, index of part}` pairs, the parts of a multi-part checker become 
stand-alone objects that store their own name (and enabled/disabled status) as 
a data member.

This is implemented by separating the functionality of `CheckerBase` into two 
new classes: `CheckerFrontend` and `CheckerBackend`. The name `CheckerBase` is 
kept (as a class derived from both `CheckerFrontend` and `CheckerBackend`), so 
"simple" checkers that use `CheckerBase` and `Checker<...>` continues to work 
without changes. However we also get first-class support for the "many 
frontends - one backend" situation:
- The class `CheckerFamily<...>` works exactly like `Checker<...>` but inherits 
from `CheckerBackend` instead of `CheckerBase`, so it won't have a superfluous 
single `Name` member.
- Classes deriving from `CheckerFamily` can freely own multiple 
`CheckerFrontend` data members, which are enabled within the registration 
methods corresponding to their name and can be used to initialize the 
`BugType`s that they can emit.

In this scheme each `CheckerFamily` needs to override the pure virtual method 
`ProgramPointTag::getTagDescription()` which returns a string which represents 
that class for debugging purposes. (Previously this used the name of one 
arbitrary sub-checker, which was passable for debugging purposes, but not too 
elegant.)

I'm planning to implement follow-up commits that convert all the "multi-part" 
checkers to this `CheckerFamily` framework.

From 3bead14691a29482705c76951eaed176bfbfc996 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Thu, 8 May 2025 18:46:41 +0200
Subject: [PATCH] [analyzer][NFC] Introduce framework for checker families

The checker classes (i.e. classes derived from `CheckerBase` via the
utility template `Checker<...>`) act as intermediates between the user
and the analyzer engine, so they have two interfaces:
- On the frontend side, they have a public name, can be enabled or
  disabled, can accept checker options and can be reported as the source
  of bug reports.
- On the backend side, they can handle various checker callbacks and
  they "leave a mark" on the `ExplodedNode`s that are created by them.
  (These `ProgramPointTag` marks are internal: they appear in debug logs
  and can be queried by checker logic; but the user doesn't see them.)

In a significant majority of the checkers there is 1:1 correspondence
between these sides, but there are also many checker classes where
several related user-facing checkers share the same backend class.
Historically each of these "multi-part checker" classes had its own
hacks to juggle its multiple names, which led to lots of ugliness like
lazy initialization of `mutable std::unique_ptr` members and
redundant data members (when a checker used its custom `CheckNames`
array and ignored the inherited single `Name`).

My recent commit 27099982da2f5a6c2d282d6b385e79d080669546 tried to
unify and standardize these existing solutions to get rid of some of the
technical debt, but it still used enum values to identify the checker
parts within a "multi-part" checker class, which led to some ugliness.

This commit introduces a new framework which takes a more direct,
object-oriented approach: instead of identifying checker parts with
`{parent checker object, index of part}` pairs, th

[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)

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


@@ -0,0 +1,93 @@
+//RUN: %libomp-cxx-compile -fopenmp-version=60  && %libomp-run
+#include 
+#include 
+#include "omp_testsuite.h"
+
+#define N 10
+class Sum {
+  int val;
+
+public:
+  Sum(int v = 0) : val(v) {}
+  Sum operator+(const Sum &rhs) const { return Sum(val + rhs.val); }
+  Sum &operator+=(const Sum &rhs) {
+val += rhs.val;
+return *this;
+  }
+  int getValue() const { return val; }
+};
+
+// Declare OpenMP reduction
+#pragma omp declare reduction(sum_reduction:Sum : omp_out += omp_in)   
\
+initializer(omp_priv = Sum(0))
+
+int checkUserDefinedReduction() {
+  Sum final_result_udr(0);
+  Sum array_sum[N];
+  int error_flag = 0;
+  int expected_value = 0;
+  for (int i = 0; i < N; ++i) {
+array_sum[i] = Sum(i);
+expected_value += i; // Calculate expected sum: 0 + 1 + ... + (N-1)
+  }
+#pragma omp parallel num_threads(4)
+  {
+#pragma omp for reduction(sum_reduction : final_result_udr)
+for (int i = 0; i < N; ++i) {
+  final_result_udr += array_sum[i];
+}
+
+if (final_result_udr.getValue() != expected_value)
+  error_flag += 1;
+  }
+  return error_flag;
+}
+
+void performReductions(int n_elements, const int *input_values,
+   int &sum_val_out, int &prod_val_out,
+   float &float_sum_val_out) {
+  // private variables for this thread's reduction.
+  sum_val_out = 0;
+  prod_val_out = 1;
+  float_sum_val_out = 0.0f;
+
+  const float kPiValue = 3.14f;
+#pragma omp for reduction(original(private), + : sum_val_out)  
\

alexey-bataev wrote:

Same, use 2 variables

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


[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)

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


@@ -0,0 +1,93 @@
+//RUN: %libomp-cxx-compile -fopenmp-version=60  && %libomp-run
+#include 
+#include 
+#include "omp_testsuite.h"
+
+#define N 10
+class Sum {
+  int val;
+
+public:
+  Sum(int v = 0) : val(v) {}
+  Sum operator+(const Sum &rhs) const { return Sum(val + rhs.val); }
+  Sum &operator+=(const Sum &rhs) {
+val += rhs.val;
+return *this;
+  }
+  int getValue() const { return val; }
+};
+
+// Declare OpenMP reduction
+#pragma omp declare reduction(sum_reduction:Sum : omp_out += omp_in)   
\
+initializer(omp_priv = Sum(0))
+
+int checkUserDefinedReduction() {
+  Sum final_result_udr(0);
+  Sum array_sum[N];
+  int error_flag = 0;
+  int expected_value = 0;
+  for (int i = 0; i < N; ++i) {
+array_sum[i] = Sum(i);
+expected_value += i; // Calculate expected sum: 0 + 1 + ... + (N-1)
+  }
+#pragma omp parallel num_threads(4)
+  {
+#pragma omp for reduction(sum_reduction : final_result_udr)

alexey-bataev wrote:

Make reductions over 2 variables

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


[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)

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


@@ -0,0 +1,93 @@
+//RUN: %libomp-cxx-compile -fopenmp-version=60  && %libomp-run
+#include 
+#include 
+#include "omp_testsuite.h"
+
+#define N 10
+class Sum {
+  int val;
+
+public:
+  Sum(int v = 0) : val(v) {}
+  Sum operator+(const Sum &rhs) const { return Sum(val + rhs.val); }
+  Sum &operator+=(const Sum &rhs) {
+val += rhs.val;
+return *this;
+  }
+  int getValue() const { return val; }
+};
+
+// Declare OpenMP reduction
+#pragma omp declare reduction(sum_reduction:Sum : omp_out += omp_in)   
\
+initializer(omp_priv = Sum(0))

alexey-bataev wrote:

Better to have Sum(1) or something else to check that not a defulat constructor 
is called

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


[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)

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

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

I didn't spot any further concerns, but I'd appreciate a second set of eyes on 
this given the size of the changes.

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


[clang] [llvm] [clang][DebugInfo] Add symbol for debugger with VTable information. (PR #130255)

2025-05-09 Thread Carlos Alberto Enciso via cfe-commits

https://github.com/CarlosAlbertoEnciso updated 
https://github.com/llvm/llvm-project/pull/130255



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [flang] [llvm] [flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (PR #139131)

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

llvm-ci wrote:

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

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


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

```
Step 4 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py 
--jobs=32' (failure)
...
[7297/7799] Building CXX object 
tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/CUFCommon.cpp.o
[7298/7799] Building CXX object 
tools/flang/unittests/Evaluate/CMakeFiles/folding.test.dir/folding.cpp.o
[7299/7799] Building CXX object 
tools/flang/lib/Optimizer/Analysis/CMakeFiles/FIRAnalysis.dir/AliasAnalysis.cpp.o
[7300/7799] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/common.cpp.o
[7301/7799] Building CXX object 
tools/flang/lib/Optimizer/Builder/CMakeFiles/FIRBuilder.dir/Runtime/Reduction.cpp.o
[7302/7799] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/complex.cpp.o
[7303/7799] Building CXX object 
tools/flang/unittests/Evaluate/CMakeFiles/expression.test.dir/expression.cpp.o
[7304/7799] Building CXX object 
tools/flang/tools/flang-driver/CMakeFiles/flang.dir/driver.cpp.o
[7305/7799] Building CXX object 
tools/flang/lib/Optimizer/HLFIR/Transforms/CMakeFiles/HLFIRTransforms.dir/SimplifyHLFIRIntrinsics.cpp.o
[7306/7799] Building CXX object 
tools/flang/tools/f18-parse-demo/CMakeFiles/f18-parse-demo.dir/f18-parse-demo.cpp.o
FAILED: 
tools/flang/tools/f18-parse-demo/CMakeFiles/f18-parse-demo.dir/f18-parse-demo.cpp.o
 
ccache /usr/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DGTEST_HAS_RTTI=0 
-DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/tools/flang/tools/f18-parse-demo
 
-I/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/flang/tools/f18-parse-demo
 
-I/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/flang/include
 
-I/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/tools/flang/include
 -I/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/include 
-I/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/llvm/include
 -isystem 
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/flang/../mlir/include
 -isystem 
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/tools/mlir/include
 -isystem 
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/tools/clang/include
 -isystem 
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/llvm/../clang/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wno-unnecessary-virtual-specifier -Wdelete-non-virtual-dtor -Wsuggest-override 
-Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported 
-fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy 
-Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition 
-fpch-preprocess -O3 -DNDEBUG -fno-semantic-interposition -std=c++17  
-fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT 
tools/flang/tools/f18-parse-demo/CMakeFiles/f18-parse-demo.dir/f18-parse-demo.cpp.o
 -MF 
tools/flang/tools/f18-parse-demo/CMakeFiles/f18-parse-demo.dir/f18-parse-demo.cpp.o.d
 -o 
tools/flang/tools/f18-parse-demo/CMakeFiles/f18-parse-demo.dir/f18-parse-demo.cpp.o
 -c 
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/flang/tools/f18-parse-demo/f18-parse-demo.cpp
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/flang/tools/f18-parse-demo/f18-parse-demo.cpp:
 In function ‘std::string CompileFortran(std::string, Fortran::parser::Options, 
DriverOptions&)’:
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/flang/tools/f18-parse-demo/f18-parse-demo.cpp:222:12:
 error: no matching function for call to ‘Unparse(llvm::raw_fd_ostream&, 
Fortran::parser::Program&, Fortran::parser::Encoding&, bool, bool)’
  222 | Unparse(llvm::outs(), parseTree, driver.encoding, true 
/*capitalize*/,
  | 
~~~^~~
  223 | options.features.IsEnabled(
  | ~~~
  224 | Fortran::common::LanguageFeature::BackslashEscapes));
  | 
In file included from 
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/fl

[clang] [NFC][Clang] Don't check hardcode op num (PR #135375)

2025-05-09 Thread Mészáros Gergely via cfe-commits

Maetveis wrote:

ping @ChuanqiXu9 can you please review?

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


[clang] 49c5138 - [clang][modules] Allow not forcing validation of user headers (#139091)

2025-05-09 Thread via cfe-commits

Author: Jan Svoboda
Date: 2025-05-09T08:33:28-07:00
New Revision: 49c513844db2e1513827a7c5b3c08acf87cfbd2b

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

LOG: [clang][modules] Allow not forcing validation of user headers (#139091)

Force-validation of user headers was implemented in acb803e8 to deal
with files changing during build. The dependency scanner guarantees an
immutable file system during single build session, so the validation is
unnecessary. (We don't hit the disk too often due to the caching VFS,
but even avoiding going to the cache and deserializing the input files
makes sense.)

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/HeaderSearchOptions.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/test/Modules/fmodules-validate-once-per-build-session.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 24f0bd8adf3cc..13d349b1cd03b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3269,6 +3269,13 @@ def fmodules_disable_diagnostic_validation : Flag<["-"], 
"fmodules-disable-diagn
   Group, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Disable validation of the diagnostic options when loading the 
module">,
   
MarshallingInfoNegativeFlag>;
+defm modules_force_validate_user_headers : BoolOption<"f", 
"modules-force-validate-user-headers",
+  HeaderSearchOpts<"ModulesForceValidateUserHeaders">, DefaultTrue,
+  PosFlag,
+  NegFlag,
+  BothFlags<[], [ClangOption],
+" validation of user headers when repeatedly loading a module file 
within single build session">>,
+  Group;
 defm modules_validate_system_headers : BoolOption<"f", 
"modules-validate-system-headers",
   HeaderSearchOpts<"ModulesValidateSystemHeaders">, DefaultFalse,
   PosFlag ReadTimer = {});

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index b59496babb62c..503d36467653e 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -638,8 +638,9 @@ IntrusiveRefCntPtr 
CompilerInstance::createPCHExternalASTSource(
   PP, ModCache, &Context, PCHContainerRdr, Extensions,
   Sysroot.empty() ? "" : Sysroot.data(), DisableValidation,
   AllowPCHWithCompilerErrors, /*AllowConfigurationMismatch*/ false,
-  HSOpts.ModulesValidateSystemHeaders, HSOpts.ValidateASTInputFilesContent,
-  UseGlobalModuleIndex));
+  HSOpts.ModulesValidateSystemHeaders,
+  HSOpts.ModulesForceValidateUserHeaders,
+  HSOpts.ValidateASTInputFilesContent, UseGlobalModuleIndex));
 
   // We need the external source to be set up before we read the AST, because
   // eagerly-deserialized declarations may use it.
@@ -1752,6 +1753,7 @@ void CompilerInstance::createASTReader() {
   PPOpts.DisablePCHOrModuleValidation,
   /*AllowASTWithCompilerErrors=*/FEOpts.AllowPCMWithCompilerErrors,
   /*AllowConfigurationMismatch=*/false, 
HSOpts.ModulesValidateSystemHeaders,
+  HSOpts.ModulesForceValidateUserHeaders,
   HSOpts.ValidateASTInputFilesContent,
   getFrontendOpts().UseGlobalModuleIndex, std::move(ReadTimer));
   if (hasASTConsumer()) {

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 51e9f2c6b39a7..8c75e1a46da54 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -364,7 +364,7 @@ void VerifyPCHAction::ExecuteAction() {
   DisableValidationForModuleKind::None,
   /*AllowASTWithCompilerErrors*/ false,
   /*AllowConfigurationMismatch*/ true,
-  /*ValidateSystemInputs*/ true));
+  /*ValidateSystemInputs*/ true, /*ForceValidateUserInputs*/ true));
 
   Reader->ReadAST(getCurrentFile(),
   Preamble ? serialization::MK_Preamble

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index a17d6229ee3a1..d068f5e163176 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3105,7 +3105,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
 if (HSOpts.ModulesValidateOncePerBuildSession &&
 F.InputFilesValidationTimestamp > HSOpts.BuildSessionTimestamp &&
 F.Kind == MK_ImplicitModule)
-  N = NumUserInputs;
+  N = ForceValidateUserInputs ? NumUserInputs : 0;
 
 for (unsigned I = 0; I < N; ++I) {
   InputFile IF = getInputFile(F, I+1, Complain);
@@ -10974,6 +10974,7 @@ AS

[clang] [llvm] [AARCH64] Add support for Cortex-A320 (PR #139055)

2025-05-09 Thread Ties Stuij via cfe-commits

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


[clang] [OpenMP] Fix crash when diagnosing dist_schedule (PR #139277)

2025-05-09 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-a-1` while building `clang` at step 4 
"annotate".

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


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)
...
[849/1366] Running the Clang regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using clang: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin/clang
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find cir-opt in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find clang-repl in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin
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-n_mai_jm/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-n_mai_jm/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-n_mai_jm/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-n_mai_jm/bin/wasm-ld
-- Testing: 21417 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70
FAIL: Clang :: OpenMP/teams_distribute_dist_schedule_messages.cpp (15500 of 
21417)
 TEST 'Clang :: 
OpenMP/teams_distribute_dist_schedule_messages.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin/clang -cc1 
-internal-isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/lib/clang/21/include
 -nostdsysteminc -verify -fopenmp 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized # RUN: at line 1
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/bin/clang 
-cc1 -internal-isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/lib/clang/21/include
 -nostdsysteminc -verify -fopenmp 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized
error: 'expected-error' diagnostics seen but not expected: 
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 Line 111: cannot find start ('{{') of expected string
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 Line 111: argument to 'dist_schedule' clause must be a strictly positive 
integer value
2 errors generated.

--


Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

Failed Tests (1):
  Clang :: OpenMP/teams_distribute_dist_schedule_messages.cpp


Testing Time: 134.87s

Total Discovered Tests: 46922
  Skipped  : 8 (0.02%)
  Unsupported  :   932 (1.99%)
  Passed   : 45954 (97.94%)
  Expectedly Failed:27 (0.06%)
  Failed   : 1 (0.00%)
[1364/1366] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
FAILED: tools/clang/test/CMakeFiles/check-clang 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/tools/clang/test/CMakeFiles/check-clang
 
cd 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/tools/clang/test
 && /usr/bin/python3.10 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/./bin/llvm-lit 
-sv --param USE_Z3_SOLVER=0 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm/tools/clang/test
ninja: build stopped: subcommand failed.
['ninja', '-C', 
'/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-n_mai_jm', 
'check-llvm', 'check-clang', 'check-lld'] exited with return code 1.
@@@STEP_FAILURE@@@
Step 7 (check) failure: check (failure)
...
[849/1366] Running the Clang regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using clang: 
/var/lib/buildbot/fuchsia-x86_64-linu

[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

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

mizvekov wrote:

Hello, it is helpful to include link to original landing attempt, and a brief 
description of what changed since last time, or otherwise explanation of why we 
go ahead and reland with no changes anyway.

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


[clang] [OpenMP] Fix crash when diagnosing dist_schedule (PR #139277)

2025-05-09 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` running on `sie-linux-worker3` while building 
`clang` at step 6 "test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: 
OpenMP/teams_distribute_dist_schedule_messages.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang -cc1 
-internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/21/include
 -nostdsysteminc -verify -fopenmp 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized # RUN: at line 1
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-cc1 -internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/21/include
 -nostdsysteminc -verify -fopenmp 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 Line 111: cannot find start ('{{') of expected string
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 Line 111: argument to 'dist_schedule' clause must be a strictly positive 
integer value
2 errors generated.

--




```



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


[clang] [OpenMP] Fix crash when diagnosing dist_schedule (PR #139277)

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

llvm-ci wrote:

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

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


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

```
Step 7 (Add check check-clang) failure: test (failure)
 TEST 'Clang :: 
OpenMP/teams_distribute_dist_schedule_messages.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/clang 
-cc1 -internal-isystem 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/lib/clang/21/include
 -nostdsysteminc -verify -fopenmp 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized # RUN: at line 1
+ /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/clang 
-cc1 -internal-isystem 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/lib/clang/21/include
 -nostdsysteminc -verify -fopenmp 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 Line 111: cannot find start ('{{') of expected string
  File 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/clang/test/OpenMP/teams_distribute_dist_schedule_messages.cpp
 Line 111: argument to 'dist_schedule' clause must be a strictly positive 
integer value
2 errors generated.

--




```



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


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

2025-05-09 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/5] 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-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

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


@@ -0,0 +1,26 @@
+.. title:: clang-tidy - modernize-use-enum-class
+
+modernize-use-enum-class
+=
+
+Scoped enums (enum class) should be preferred over unscoped enums:

JungPhilipp wrote:

Done

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


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

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


@@ -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 ");

JungPhilipp wrote:

Dropped for now. Done.

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


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

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


@@ -0,0 +1,58 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-use-enum-class %t

JungPhilipp wrote:

Done

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


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

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


@@ -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,

JungPhilipp wrote:

Done.

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


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

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


@@ -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")

JungPhilipp wrote:

Done

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


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

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


@@ -115,6 +115,11 @@ New checks
   Gives warnings for tagged unions, where the number of tags is
   different from the number of data members inside the union.
 
+- New :doc:`modernize-use-enum-class
+  ` check.
+
+  Finds plain non-class enum definitions that could use ``enum class``.

JungPhilipp wrote:

Done

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


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

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


@@ -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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEENUMCLASSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEENUMCLASSCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::modernize {
+
+/// Check for unscoped enums that are not contained in classes/structs.
+/// Suggest to use scoped enums (enum class) instead.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-enum-class.html
+class UseEnumClassCheck : public ClangTidyCheck {
+public:
+  UseEnumClassCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;

JungPhilipp wrote:

Done

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


[clang] [OpenMP] Fix a crash on invalid with unroll partial (PR #139280)

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

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [llvm] [NVPTX] Add intrinsics and clang builtins for conversions of f4x2 type (PR #139244)

2025-05-09 Thread Srinivasa Ravi via cfe-commits

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


[libunwind] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (PR #137949)

2025-05-09 Thread Alex Rønne Petersen via cfe-commits

alexrp wrote:

Ah, if there are no known users outside of the test suite, then it might not be 
worth the trouble.

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


[clang] 823b1a5 - [clang-installapi] Store dylib attributes in the order they are passed on the command line. (#139087)

2025-05-09 Thread via cfe-commits

Author: Cyndy Ishida
Date: 2025-05-08T21:15:10-07:00
New Revision: 823b1a582258f1417c648b3117ba08edc4855c68

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

LOG: [clang-installapi] Store dylib attributes in the order they are passed on 
the command line. (#139087)

With the introduction of tbd-v5 holding rpaths, the order in which those
attributes are passed to `clang-installapi` must be represented in tbd
files. Previously, all dylib attributes were stored in a
non-deterministic `StringMap`. Instead, hold them in a custom collection
with an underlying vector to continue supporting searching by attribute.
This makes the order of all diagnostics related to load command
comparisons stable.

This approach resolves errors when building with reverse-iteration.

Added: 


Modified: 
clang/include/clang/InstallAPI/DylibVerifier.h
clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
clang/lib/InstallAPI/DylibVerifier.cpp
clang/tools/clang-installapi/ClangInstallAPI.cpp
clang/tools/clang-installapi/Options.cpp

Removed: 




diff  --git a/clang/include/clang/InstallAPI/DylibVerifier.h 
b/clang/include/clang/InstallAPI/DylibVerifier.h
index 333f0cff077fd..4cf70a8adc9bc 100644
--- a/clang/include/clang/InstallAPI/DylibVerifier.h
+++ b/clang/include/clang/InstallAPI/DylibVerifier.h
@@ -25,9 +25,31 @@ enum class VerificationMode {
   Pedantic,
 };
 
-using LibAttrs = llvm::StringMap;
 using ReexportedInterfaces = llvm::SmallVector;
 
+/// Represents dynamic library specific attributes that are tied to
+/// architecture slices. It is commonly used for comparing options
+/// passed on the command line to installapi and what exists in dylib load
+/// commands.
+class LibAttrs {
+public:
+  using Entry = std::pair;
+  using AttrsToArchs = llvm::SmallVector;
+
+  // Mutable access to architecture set tied to the input attribute.
+  ArchitectureSet &getArchSet(StringRef Attr);
+  // Get entry based on the attribute.
+  std::optional find(StringRef Attr) const;
+  // Immutable access to underlying container.
+  const AttrsToArchs &get() const { return LibraryAttributes; };
+  // Mutable access to underlying container.
+  AttrsToArchs &get() { return LibraryAttributes; };
+  bool operator==(const LibAttrs &Other) const { return Other.get() == get(); 
};
+
+private:
+  AttrsToArchs LibraryAttributes;
+};
+
 // Pointers to information about a zippered declaration used for
 // querying and reporting violations against 
diff erent
 // declarations that all map to the same symbol.

diff  --git a/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp 
b/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
index c8d07f229902b..fd9db8113a41e 100644
--- a/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
+++ b/clang/lib/InstallAPI/DiagnosticBuilderWrappers.cpp
@@ -97,12 +97,12 @@ const DiagnosticBuilder &operator<<(const DiagnosticBuilder 
&DB,
 
 const clang::DiagnosticBuilder &
 operator<<(const clang::DiagnosticBuilder &DB,
-   const StringMapEntry &LibAttr) {
-  std::string IFAsString;
-  raw_string_ostream OS(IFAsString);
+   const clang::installapi::LibAttrs::Entry &LibAttr) {
+  std::string Entry;
+  raw_string_ostream OS(Entry);
 
-  OS << LibAttr.getKey() << " [ " << LibAttr.getValue() << " ]";
-  DB.AddString(IFAsString);
+  OS << LibAttr.first << " [ " << LibAttr.second << " ]";
+  DB.AddString(Entry);
   return DB;
 }
 

diff  --git a/clang/lib/InstallAPI/DiagnosticBuilderWrappers.h 
b/clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
index 48cfefbf65e6b..ba24ee415dfcf 100644
--- a/clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
+++ b/clang/lib/InstallAPI/DiagnosticBuilderWrappers.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_INSTALLAPI_DIAGNOSTICBUILDER_WRAPPER_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/InstallAPI/DylibVerifier.h"
 #include "llvm/TextAPI/Architecture.h"
 #include "llvm/TextAPI/ArchitectureSet.h"
 #include "llvm/TextAPI/InterfaceFile.h"
@@ -42,7 +43,7 @@ const clang::DiagnosticBuilder &operator<<(const 
clang::DiagnosticBuilder &DB,
 
 const clang::DiagnosticBuilder &
 operator<<(const clang::DiagnosticBuilder &DB,
-   const StringMapEntry &LibAttr);
+   const clang::installapi::LibAttrs::Entry &LibAttr);
 
 } // namespace MachO
 } // namespace llvm

diff  --git a/clang/lib/InstallAPI/DylibVerifier.cpp 
b/clang/lib/InstallAPI/DylibVerifier.cpp
index d5d760767b41f..45c84c00d9236 100644
--- a/clang/lib/InstallAPI/DylibVerifier.cpp
+++ b/clang/lib/InstallAPI/DylibVerifier.cpp
@@ -18,6 +18,25 @@ using namespace llvm::MachO;
 namespace clang {
 namespace installapi {
 
+ArchitectureSet &LibAttrs::getArchSet(StringRef Attr) {
+  auto *It = llvm::find_if(LibraryAttributes, [&Attr](co

[clang] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (PR #137851)

2025-05-09 Thread Yingwei Zheng via cfe-commits

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


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

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Donát Nagy (NagyDonat)


Changes

The checker classes (i.e. classes derived from `CheckerBase` via the utility 
template `Checker<...>`) act as intermediates between the user and the 
analyzer engine, so they have two interfaces:
- On the frontend side, they have a public name, can be enabled or disabled, 
can accept checker options and can be reported as the source of bug reports.
- On the backend side, they can handle various checker callbacks and they 
"leave a mark" on the `ExplodedNode`s that are created by them. (These 
`ProgramPointTag` marks are internal: they appear in debug logs and can be 
queried by checker logic; but the user doesn't see them.)

In a significant majority of the checkers there is 1:1 correspondence between 
these sides, but there are also many checker classes where several related 
user-facing checkers share the same backend class. Historically each of these 
"multi-part checker" classes had its own hacks to juggle its multiple names, 
which led to lots of ugliness like lazy initialization of `mutable 
std::unique_ptr` members and redundant data members (when a 
checker used its custom `CheckNames` array and ignored the inherited single 
`Name`).

My recent commit 27099982da2f5a6c2d282d6b385e79d080669546 tried to unify and 
standardize these existing solutions to get rid of some of the technical debt, 
but it still used enum values to identify the checker parts within a 
"multi-part" checker class, which led to some ugliness.

This commit introduces a new framework which takes a more direct, 
object-oriented approach: instead of identifying checker parts with `{parent 
checker object, index of part}` pairs, the parts of a multi-part checker become 
stand-alone objects that store their own name (and enabled/disabled status) as 
a data member.

This is implemented by separating the functionality of `CheckerBase` into two 
new classes: `CheckerFrontend` and `CheckerBackend`. The name `CheckerBase` is 
kept (as a class derived from both `CheckerFrontend` and `CheckerBackend`), so 
"simple" checkers that use `CheckerBase` and `Checker<...>` continues to 
work without changes. However we also get first-class support for the "many 
frontends - one backend" situation:
- The class `CheckerFamily<...>` works exactly like `Checker<...>` 
but inherits from `CheckerBackend` instead of `CheckerBase`, so it won't have a 
superfluous single `Name` member.
- Classes deriving from `CheckerFamily` can freely own multiple 
`CheckerFrontend` data members, which are enabled within the registration 
methods corresponding to their name and can be used to initialize the 
`BugType`s that they can emit.

In this scheme each `CheckerFamily` needs to override the pure virtual method 
`ProgramPointTag::getTagDescription()` which returns a string which represents 
that class for debugging purposes. (Previously this used the name of one 
arbitrary sub-checker, which was passable for debugging purposes, but not too 
elegant.)

I'm planning to implement follow-up commits that convert all the "multi-part" 
checkers to this `CheckerFamily` framework.

---

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


11 Files Affected:

- (modified) clang/include/clang/Analysis/ProgramPoint.h (+2-2) 
- (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(+4-3) 
- (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h 
(+25-19) 
- (modified) clang/include/clang/StaticAnalyzer/Core/Checker.h (+75-57) 
- (modified) clang/include/clang/StaticAnalyzer/Core/CheckerManager.h (+24-56) 
- (modified) clang/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp (+16-18) 
- (modified) clang/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (+15-14) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (+2-2) 
- (modified) clang/lib/StaticAnalyzer/Core/Checker.cpp (+5-9) 
- (modified) clang/lib/StaticAnalyzer/Core/CheckerManager.cpp (+11-11) 


``diff
diff --git a/clang/include/clang/Analysis/ProgramPoint.h 
b/clang/include/clang/Analysis/ProgramPoint.h
index c40aa3d8ffb72..d81b8e845cb48 100644
--- a/clang/include/clang/Analysis/ProgramPoint.h
+++ b/clang/include/clang/Analysis/ProgramPoint.h
@@ -40,8 +40,8 @@ class ProgramPointTag {
   ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {}
   virtual ~ProgramPointTag();
 
-  /// The description of this program point which will be displayed when the
-  /// ExplodedGraph is dumped in DOT format for debugging.
+  /// The description of this program point which will be dumped for debugging
+  /// purposes. Do not use in user-facing output!
   virtual StringRef getTagDescription() const = 0;
 
   /// Used to implement 'isKind' in subclasses.
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/

[clang] [OpenACC][CIR] Implement basic lowering for combined constructs (PR #139119)

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

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


[clang] 61a8da9 - [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (#137851)

2025-05-09 Thread via cfe-commits

Author: Yingwei Zheng
Date: 2025-05-09T19:23:48+08:00
New Revision: 61a8da9367dc7949f36916749f6038453ea4197f

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

LOG: [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (#137851)

This patch adds a workaround for the old glibc `__PTR_ALIGN` macro:
```
((sizeof(long int) < sizeof(void *) ? (base) : (char *)0) +
   (((pointer) - (sizeof(long int) < sizeof(void *) ? (base) : (char *)0) +
 (align_mask)) &
~(align_mask)));
```
Closes https://github.com/llvm/llvm-project/issues/137833.

Added: 
clang/test/CodeGen/glibc_ptr_align.c

Modified: 
clang/lib/AST/Expr.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index a4483a285ed4f..8557c3b82ca39 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2247,6 +2247,16 @@ bool 
BinaryOperator::isNullPointerArithmeticExtension(ASTContext &Ctx,
 return false;
   }
 
+  // Workaround for old glibc's __PTR_ALIGN macro
+  if (auto *Select =
+  dyn_cast(PExp->IgnoreParenNoopCasts(Ctx))) {
+// If the condition can be constant evaluated, we check the selected arm.
+bool EvalResult;
+if (!Select->getCond()->EvaluateAsBooleanCondition(EvalResult, Ctx))
+  return false;
+PExp = EvalResult ? Select->getTrueExpr() : Select->getFalseExpr();
+  }
+
   // Check that the pointer is a nullptr.
   if (!PExp->IgnoreParenCasts()
   ->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull))

diff  --git a/clang/test/CodeGen/glibc_ptr_align.c 
b/clang/test/CodeGen/glibc_ptr_align.c
new file mode 100644
index 0..0656d61eb0caa
--- /dev/null
+++ b/clang/test/CodeGen/glibc_ptr_align.c
@@ -0,0 +1,62 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -O3 -o - -emit-llvm %s | 
FileCheck %s
+
+// Make sure that we do not set inbounds flag if the base pointer may be a 
constant null.
+
+// CHECK-LABEL: define dso_local ptr @glibc_ptr_align(
+// CHECK-SAME: ptr noundef readnone captures(none) [[BASE:%.*]], ptr noundef 
[[POINTER:%.*]], i64 noundef [[ALIGN_MASK:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[POINTER]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[ALIGN_MASK]], 
[[SUB_PTR_LHS_CAST]]
+// CHECK-NEXT:[[NOT:%.*]] = xor i64 [[ALIGN_MASK]], -1
+// CHECK-NEXT:[[AND:%.*]] = and i64 [[ADD]], [[NOT]]
+// CHECK-NEXT:[[TMP0:%.*]] = inttoptr i64 [[AND]] to ptr
+// CHECK-NEXT:ret ptr [[TMP0]]
+//
+char *glibc_ptr_align(char *base, char *pointer, long align_mask) {
+  return (sizeof(long int) < sizeof(void *) ? (base) : (char *)0) +
+ (((pointer) -
+   (sizeof(long int) < sizeof(void *) ? (base) : (char *)0) +
+   (align_mask)) &
+  ~(align_mask));
+}
+
+// CHECK-LABEL: define dso_local ptr @glibc_ptr_align_commuted(
+// CHECK-SAME: ptr noundef readnone captures(none) [[BASE:%.*]], ptr noundef 
[[POINTER:%.*]], i64 noundef [[ALIGN_MASK:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[POINTER]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[ALIGN_MASK]], 
[[SUB_PTR_LHS_CAST]]
+// CHECK-NEXT:[[NOT:%.*]] = xor i64 [[ALIGN_MASK]], -1
+// CHECK-NEXT:[[AND:%.*]] = and i64 [[ADD]], [[NOT]]
+// CHECK-NEXT:[[TMP0:%.*]] = inttoptr i64 [[AND]] to ptr
+// CHECK-NEXT:ret ptr [[TMP0]]
+//
+char *glibc_ptr_align_commuted(char *base, char *pointer, long align_mask) {
+  return (sizeof(long int) >= sizeof(void *) ? (char *)0 : (base)) +
+ (((pointer) -
+   (sizeof(long int) >= sizeof(void *) ? (char *)0 : (base)) +
+   (align_mask)) &
+  ~(align_mask));
+}
+
+// CHECK-LABEL: define dso_local ptr @glibc_ptr_align_non_constexpr(
+// CHECK-SAME: ptr noundef [[BASE:%.*]], ptr noundef [[POINTER:%.*]], i64 
noundef [[ALIGN_MASK:%.*]], i32 noundef [[COND:%.*]]) local_unnamed_addr 
#[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[TOBOOL_NOT:%.*]] = icmp eq i32 [[COND]], 0
+// CHECK-NEXT:[[COND1:%.*]] = select i1 [[TOBOOL_NOT]], ptr null, ptr 
[[BASE]]
+// CHECK-NEXT:[[SUB_PTR_LHS_CAST:%.*]] = ptrtoint ptr [[POINTER]] to i64
+// CHECK-NEXT:[[SUB_PTR_RHS_CAST:%.*]] = ptrtoint ptr [[COND1]] to i64
+// CHECK-NEXT:[[SUB_PTR_SUB:%.*]] = add i64 [[ALIGN_MASK]], 
[[SUB_PTR_LHS_CAST]]
+// CHECK-NEXT:[[ADD:%.*]] = sub i64 [[SUB_PTR_SUB]], [[SUB_PTR_RHS_CAST]]
+// CHECK-NEXT:[[NOT:%.*]] = xor i64 [[ALIGN_MASK]], -1
+// CHECK-NEXT:[[AND:%.*]] = and i64 [[ADD]], [[NOT]]
+// CHECK-NEXT:[[ADD_PTR:%.*]] = geteleme

[libunwind] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (PR #137949)

2025-05-09 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> Would backporting this be worthwhile?

I guess it could be considered. However in practice I'm not aware of any 
external cases that actually use the "force unwinding" functionality, outside 
of the libunwind/libcxxabi testsuite. My main motivation is having the 
`check-unwind` and `check-cxxabi` testsuites passing in Windows on ARM 
configurations. It would of course be nice to have that on the 20.x release 
branch too, but that also requires another backport in 
https://github.com/llvm/llvm-project/pull/136449 which isn't clear whether it 
can be backported or not.

Then again, this is straightforward and simple to backport, so I guess we 
could. (But we'd want #137950 and #137951 to go with it then - I'll merge them 
soon too.)

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


[clang] 5ae2aed - clang: Remove dest LangAS argument from performAddrSpaceCast (#138866)

2025-05-09 Thread via cfe-commits

Author: Matt Arsenault
Date: 2025-05-09T14:24:54+02:00
New Revision: 5ae2aed218470783e6c7a2d255c7946f4549cb46

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

LOG: clang: Remove dest LangAS argument from performAddrSpaceCast (#138866)

It isn't used and is redundant with the result pointer type argument.
A more reasonable API would only have LangAS parameters, or IR parameters,
not both. Not all values have a meaningful value for this. I'm also
not sure why we have this at all, it's not overridden by any targets and
further simplification is possible.

Added: 


Modified: 
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index 0af3cd07b13a0..51f0799a792fd 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -1084,8 +1084,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   auto DestAS = getContext().getTargetAddressSpace(LangAS::opencl_generic);
   auto *DestType = llvm::PointerType::get(getLLVMContext(), DestAS);
 
-  return getTargetHooks().performAddrSpaceCast(
-  *this, V, AS, LangAS::opencl_generic, DestType, false);
+  return getTargetHooks().performAddrSpaceCast(*this, V, AS, DestType,
+   false);
 };
 
 Args.add(RValue::get(CastToGenericAddrSpace(Ptr.emitRawPointer(*this),

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e6816736412b8..45e0f69c46902 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4081,8 +4081,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 LangAS EAS = E->getType()->getPointeeType().getAddressSpace();
 if (AAS != EAS) {
   llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
-  return RValue::get(getTargetHooks().performAddrSpaceCast(*this, AI, AAS,
-   EAS, Ty));
+  return RValue::get(
+  getTargetHooks().performAddrSpaceCast(*this, AI, AAS, Ty));
 }
 return RValue::get(AI);
   }
@@ -4103,8 +4103,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 LangAS EAS = E->getType()->getPointeeType().getAddressSpace();
 if (AAS != EAS) {
   llvm::Type *Ty = CGM.getTypes().ConvertType(E->getType());
-  return RValue::get(getTargetHooks().performAddrSpaceCast(*this, AI, AAS,
-   EAS, Ty));
+  return RValue::get(
+  getTargetHooks().performAddrSpaceCast(*this, AI, AAS, Ty));
 }
 return RValue::get(AI);
   }

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 1e25de06c89b9..65970fcdc9648 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5245,12 +5245,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   if (SRetPtr.getAddressSpace() != RetAI.getIndirectAddrSpace()) {
 llvm::Value *V = SRetPtr.getBasePointer();
 LangAS SAS = getLangASFromTargetAS(SRetPtr.getAddressSpace());
-LangAS DAS = getLangASFromTargetAS(RetAI.getIndirectAddrSpace());
 llvm::Type *Ty = llvm::PointerType::get(getLLVMContext(),
 RetAI.getIndirectAddrSpace());
 
 SRetPtr = SRetPtr.withPointer(
-getTargetHooks().performAddrSpaceCast(*this, V, SAS, DAS, Ty, 
true),
+getTargetHooks().performAddrSpaceCast(*this, V, SAS, Ty, true),
 SRetPtr.isKnownNonNull());
   }
   IRCallArgs[IRFunctionArgs.getSRetArgNo()] =
@@ -5395,8 +5394,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   // we can look through a cast to a compatible address space value,
   // otherwise emit a copy.
   llvm::Value *Val = getTargetHooks().performAddrSpaceCast(
-  *this, V, I->Ty.getAddressSpace(), 
CGM.getASTAllocaAddressSpace(),
-  T, true);
+  *this, V, I->Ty.getAddressSpace(), T, true);
   if (ArgHasMaybeUndefAttr)
 Val = Builder.CreateFreeze(Val);
   IRCallArgs[FirstIRArg] = Val;
@@ -5485,12 +5483,9 @@ RValue CodeGenFunction::EmitCall(const C

[clang] [clang][modules][deps] Implicit modules are out of date when their explicit imports are (PR #138920)

2025-05-09 Thread Cyndy Ishida via cfe-commits


@@ -0,0 +1,178 @@
+// Test that modifications to a common header (imported from both a PCH and a 
TU)
+// cause rebuilds of dependent modules imported from the TU on incremental 
build.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- module.modulemap
+module mod_common { header "mod_common.h" }
+module mod_tu { header "mod_tu.h" }
+module mod_tu_extra { header "mod_tu_extra.h" }
+
+//--- mod_common.h
+#define MOD_COMMON_MACRO 0
+//--- mod_tu.h
+#include "mod_common.h"
+#if MOD_COMMON_MACRO
+#include "mod_tu_extra.h"
+#endif
+
+//--- mod_tu_extra.h
+
+//--- prefix.h
+#include "mod_common.h"
+
+//--- tu.c
+#include "mod_tu.h"
+
+// Clean: scan the PCH.
+// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch_clean.json -- 
\
+// RUN: %clang -x c-header %t/prefix.h -o %t/prefix.h.pch -F %t \
+// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
+
+// Clean: build the PCH.
+// RUN: %deps-to-rsp %t/deps_pch_clean.json --module-name mod_common > 
%t/mod_common.rsp
+// RUN: %deps-to-rsp %t/deps_pch_clean.json --tu-index 0 > %t/pch.rsp
+// RUN: %clang @%t/mod_common.rsp
+// RUN: %clang @%t/pch.rsp
+
+// Clean: scan the TU.
+// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu_clean.json -- \
+// RUN: %clang -c %t/tu.c -o %t/tu.o -include %t/prefix.h -F %t \
+// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
+// RUN: cat %t/deps_tu_clean.json | sed 's:\?:/:g' | FileCheck %s 
--check-prefix=CHECK-TU-CLEAN -DPREFIX=%/t
+// CHECK-TU-CLEAN:  {
+// CHECK-TU-CLEAN-NEXT:   "modules": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "clang-module-deps": [],
+// CHECK-TU-CLEAN-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/module.modulemap",
+// CHECK-TU-CLEAN-NEXT:   "command-line": [
+// CHECK-TU-CLEAN:],
+// CHECK-TU-CLEAN-NEXT:   "context-hash": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "file-deps": [
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/mod_tu.h"
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "link-libraries": [],
+// CHECK-TU-CLEAN-NEXT:   "name": "mod_tu"
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "translation-units": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "commands": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "clang-context-hash": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "clang-module-deps": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "context-hash": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "module-name": "mod_tu"
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "command-line": [
+// CHECK-TU-CLEAN:],
+// CHECK-TU-CLEAN-NEXT:   "executable": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "file-deps": [
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/tu.c",
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/prefix.h.pch"
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "input-file": "[[PREFIX]]/tu.c"
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN-NEXT:   ]
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN:]
+// CHECK-TU-CLEAN:  }
+
+// Clean: build the TU.
+// RUN: %deps-to-rsp %t/deps_tu_clean.json --module-name mod_tu > %t/mod_tu.rsp
+// RUN: %deps-to-rsp %t/deps_tu_clean.json --tu-index 0 > %t/tu.rsp
+// RUN: %clang @%t/mod_tu.rsp
+// RUN: %clang @%t/tu.rsp
+
+// Incremental: modify the common module.
+// RUN: sleep 1

cyndyishida wrote:

Why is this necessary?

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


[clang] [llvm] [NVPTX] Add intrinsics and clang builtins for conversions of f4x2 type (PR #139244)

2025-05-09 Thread Durgadoss R via cfe-commits


@@ -1663,6 +1663,13 @@ let TargetPrefix = "nvvm" in {
   def int_nvvm_ # type # _to_f16x2 # suffix : CVT_I16_TO_F16X2;
 }
   }
+
+  // FP4 conversions.
+  foreach relu = ["", "_relu"] in {
+defvar suffix = !strconcat("_rn", relu);

durga4github wrote:

nit: since it is only two variables, may be using # is simpler.

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


[clang] [Clang] Detect bit copies that should be relocation. (PR #139104)

2025-05-09 Thread via cfe-commits


@@ -9659,6 +9659,42 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
   if (BId == Builtin::BIbzero && !FirstArgTy->getAs())
 return;
 
+  // Try to detect a relocation operation
+  if (getLangOpts().CPlusPlus &&
+  (BId == Builtin::BImemmove || BId == Builtin::BImemcpy)) {
+const Expr *Dest = Call->getArg(0)->IgnoreParenImpCasts();
+const Expr *Src = Call->getArg(1)->IgnoreParenImpCasts();
+QualType DestTy = Dest->getType();
+QualType SrcTy = Src->getType();
+
+QualType DestPointeeTy = DestTy->getPointeeType();
+QualType SrcPointeeTy = SrcTy->getPointeeType();
+bool HasSameTargetAndSource =
+!DestPointeeTy.isNull() && !SrcPointeeTy.isNull() &&
+Context.hasSameUnqualifiedType(DestPointeeTy, SrcPointeeTy);
+
+if (HasSameTargetAndSource &&
+!DestPointeeTy.getUnqualifiedType()->isIncompleteType() &&
+!DestPointeeTy.isConstQualified() && !SrcPointeeTy.isConstQualified() 
&&
+!DestPointeeTy.isTriviallyCopyableType(getASTContext()) &&
+SemaRef.IsCXXTriviallyRelocatableType(DestPointeeTy)) {
+
+  bool SuggestStd = getLangOpts().CPlusPlus26 && getStdNamespace();
+  if (const Decl *D = Call->getReferencedDeclOfCallee();
+  D && !D->isInStdNamespace())
+SuggestStd = false;

Sirraide wrote:

> Right, the header might not be included. I don't think we would have a way to 
> generally detect a function exists in the STL

Yeah, I don’t think we need to care about that because there is no good way of 
doing that (and presumably we’d end up suggesting ‘include this header to get 
it’ anyway like we do w/ other functions which is fine imo). But in that case, 
imo we can just always suggest `std::trivially_relocate` in C++26 mode even if 
the `memcpy` we’re calling isn’t in the `std` namespace.

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


[clang] [llvm] [NVPTX] Add intrinsics and clang builtins for conversions of f4x2 type (PR #139244)

2025-05-09 Thread Durgadoss R via cfe-commits

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


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


[clang] [flang] [Clang][Driver][Test] Created test for unsupported driver options (PR #120900)

2025-05-09 Thread via cfe-commits

GeorgeKA wrote:

Ping @Maetveis 
Any more thoughts on this one? I think I've addressed the existing comments.

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


[clang] [clang][modules][deps] Implicit modules are out of date when their explicit imports are (PR #138920)

2025-05-09 Thread Jan Svoboda via cfe-commits


@@ -0,0 +1,178 @@
+// Test that modifications to a common header (imported from both a PCH and a 
TU)
+// cause rebuilds of dependent modules imported from the TU on incremental 
build.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- module.modulemap
+module mod_common { header "mod_common.h" }
+module mod_tu { header "mod_tu.h" }
+module mod_tu_extra { header "mod_tu_extra.h" }
+
+//--- mod_common.h
+#define MOD_COMMON_MACRO 0
+//--- mod_tu.h
+#include "mod_common.h"
+#if MOD_COMMON_MACRO
+#include "mod_tu_extra.h"
+#endif
+
+//--- mod_tu_extra.h
+
+//--- prefix.h
+#include "mod_common.h"
+
+//--- tu.c
+#include "mod_tu.h"
+
+// Clean: scan the PCH.
+// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch_clean.json -- 
\
+// RUN: %clang -x c-header %t/prefix.h -o %t/prefix.h.pch -F %t \
+// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
+
+// Clean: build the PCH.
+// RUN: %deps-to-rsp %t/deps_pch_clean.json --module-name mod_common > 
%t/mod_common.rsp
+// RUN: %deps-to-rsp %t/deps_pch_clean.json --tu-index 0 > %t/pch.rsp
+// RUN: %clang @%t/mod_common.rsp
+// RUN: %clang @%t/pch.rsp
+
+// Clean: scan the TU.
+// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu_clean.json -- \
+// RUN: %clang -c %t/tu.c -o %t/tu.o -include %t/prefix.h -F %t \
+// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
+// RUN: cat %t/deps_tu_clean.json | sed 's:\?:/:g' | FileCheck %s 
--check-prefix=CHECK-TU-CLEAN -DPREFIX=%/t
+// CHECK-TU-CLEAN:  {
+// CHECK-TU-CLEAN-NEXT:   "modules": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "clang-module-deps": [],
+// CHECK-TU-CLEAN-NEXT:   "clang-modulemap-file": 
"[[PREFIX]]/module.modulemap",
+// CHECK-TU-CLEAN-NEXT:   "command-line": [
+// CHECK-TU-CLEAN:],
+// CHECK-TU-CLEAN-NEXT:   "context-hash": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "file-deps": [
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/module.modulemap",
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/mod_tu.h"
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "link-libraries": [],
+// CHECK-TU-CLEAN-NEXT:   "name": "mod_tu"
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "translation-units": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "commands": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "clang-context-hash": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "clang-module-deps": [
+// CHECK-TU-CLEAN-NEXT: {
+// CHECK-TU-CLEAN-NEXT:   "context-hash": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "module-name": "mod_tu"
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "command-line": [
+// CHECK-TU-CLEAN:],
+// CHECK-TU-CLEAN-NEXT:   "executable": "{{.*}}",
+// CHECK-TU-CLEAN-NEXT:   "file-deps": [
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/tu.c",
+// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/prefix.h.pch"
+// CHECK-TU-CLEAN-NEXT:   ],
+// CHECK-TU-CLEAN-NEXT:   "input-file": "[[PREFIX]]/tu.c"
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN-NEXT:   ]
+// CHECK-TU-CLEAN-NEXT: }
+// CHECK-TU-CLEAN:]
+// CHECK-TU-CLEAN:  }
+
+// Clean: build the TU.
+// RUN: %deps-to-rsp %t/deps_tu_clean.json --module-name mod_tu > %t/mod_tu.rsp
+// RUN: %deps-to-rsp %t/deps_tu_clean.json --tu-index 0 > %t/tu.rsp
+// RUN: %clang @%t/mod_tu.rsp
+// RUN: %clang @%t/tu.rsp
+
+// Incremental: modify the common module.
+// RUN: sleep 1

jansvoboda11 wrote:

So that the modification time of `%t/mod_common.h` is guaranteed to not be the 
same as when it was created by `split-file`. Without this, the timing might 
work out such that the timestamp of this file is the same and the invalidation 
logic doesn't trigger.

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


[clang] [Clang] Improve ``-Wtautological-overlap-compare`` diagnostics flag (PR #133653)

2025-05-09 Thread via cfe-commits

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

LGTM

Feel free to @ me to merge this once clang-format and CI are fine with it 
because from what I can tell you don’t have commit access.

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


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

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


@@ -0,0 +1,26 @@
+.. title:: clang-tidy - modernize-use-enum-class
+
+modernize-use-enum-class
+=
+
+Scoped enums (enum class) should be preferred over unscoped enums:
+https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class

JungPhilipp wrote:

Done

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


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

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


@@ -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()

JungPhilipp wrote:

Added an option. Done.

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


[clang] [llvm] [NVPTX] Add intrinsics and clang builtins for conversions of f4x2 type (PR #139244)

2025-05-09 Thread Durgadoss R via cfe-commits

durga4github wrote:

Changes LGTM. Let us wait for Artem's review.

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


[libunwind] [libunwind] [SEH] Implement parsing of aarch64 pdata/xdata (PR #137949)

2025-05-09 Thread Alex Rønne Petersen via cfe-commits

alexrp wrote:

Would backporting this be worthwhile?

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


[clang] [Clang] Fix pack indexing profiling (PR #139276)

2025-05-09 Thread via cfe-commits

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


[clang] [OpenMP] Fix crash when diagnosing dist_schedule (PR #139277)

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

llvm-ci wrote:

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

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: 
OpenMP/teams_distribute_dist_schedule_messages.cpp' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -cc1 -internal-isystem 
Z:\b\llvm-clang-x86_64-sie-win\build\lib\clang\21\include -nostdsysteminc 
-verify -fopenmp 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\OpenMP\teams_distribute_dist_schedule_messages.cpp
 -Wuninitialized
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' -cc1 
-internal-isystem 'Z:\b\llvm-clang-x86_64-sie-win\build\lib\clang\21\include' 
-nostdsysteminc -verify -fopenmp 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\OpenMP\teams_distribute_dist_schedule_messages.cpp'
 -Wuninitialized
# .---command stderr
# | error: 'expected-error' diagnostics seen but not expected: 
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\OpenMP\teams_distribute_dist_schedule_messages.cpp
 Line 111: cannot find start ('{{') of expected string
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\OpenMP\teams_distribute_dist_schedule_messages.cpp
 Line 111: argument to 'dist_schedule' clause must be a strictly positive 
integer value
# | 2 errors generated.
# `-
# error: command failed with exit status: 1

--




```



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


[clang] 0077d4c - [Clang] Fix pack indexing profiling (#139276)

2025-05-09 Thread via cfe-commits

Author: cor3ntin
Date: 2025-05-09T18:02:09+02:00
New Revision: 0077d4ca78342ed009eca324f93f1c62a90399c5

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

LOG: [Clang] Fix pack indexing profiling (#139276)

When profiling a pack indexing that has been partially substituted, we
should profile the expansions, rather than the pattern itseld

This is a better approach to #139057

This mirrors the fix done for SizeOfPackExpr in #124533

Fixes #138255

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/Type.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/Type.cpp
clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3f38d510f7ad1..e8e67e14f007b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -679,6 +679,7 @@ Bug Fixes to C++ Support
   whose type depends on itself. (#GH51347), (#GH55872)
 - Improved parser recovery of invalid requirement expressions. In turn, this
   fixes crashes from follow-on processing of the invalid requirement. 
(#GH138820)
+- Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index e107db458742e..1fdc488a76507 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -221,7 +221,8 @@ class ASTContext : public RefCountedBase {
   mutable llvm::ContextualFoldingSet
   DependentDecltypeTypes;
 
-  mutable llvm::FoldingSet DependentPackIndexingTypes;
+  mutable llvm::ContextualFoldingSet
+  DependentPackIndexingTypes;
 
   mutable llvm::FoldingSet TemplateTypeParmTypes;
   mutable llvm::FoldingSet ObjCTypeParamTypes;

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 8710f252a0c5c..e26eeb2f59a5f 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4547,6 +4547,7 @@ class PackIndexingExpr final
   static PackIndexingExpr *CreateDeserialized(ASTContext &Context,
   unsigned NumTransformedExprs);
 
+  // The index expression and all elements of the pack have been substituted.
   bool isFullySubstituted() const { return FullySubstituted; }
 
   /// Determine if the expression was expanded to empty.

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 773796a55eaa1..242d7b72bd5b8 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5976,7 +5976,6 @@ class PackIndexingType final
   private llvm::TrailingObjects {
   friend TrailingObjects;
 
-  const ASTContext &Context;
   QualType Pattern;
   Expr *IndexExpr;
 
@@ -5987,9 +5986,8 @@ class PackIndexingType final
 
 protected:
   friend class ASTContext; // ASTContext creates these.
-  PackIndexingType(const ASTContext &Context, QualType Canonical,
-   QualType Pattern, Expr *IndexExpr, bool FullySubstituted,
-   ArrayRef Expansions = {});
+  PackIndexingType(QualType Canonical, QualType Pattern, Expr *IndexExpr,
+   bool FullySubstituted, ArrayRef Expansions = {});
 
 public:
   Expr *getIndexExpr() const { return IndexExpr; }
@@ -6024,14 +6022,10 @@ class PackIndexingType final
 return T->getTypeClass() == PackIndexing;
   }
 
-  void Profile(llvm::FoldingSetNodeID &ID) {
-if (hasSelectedType())
-  getSelectedType().Profile(ID);
-else
-  Profile(ID, Context, getPattern(), getIndexExpr(), isFullySubstituted());
-  }
+  void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context);
   static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
-  QualType Pattern, Expr *E, bool FullySubstituted);
+  QualType Pattern, Expr *E, bool FullySubstituted,
+  ArrayRef Expansions);
 
 private:
   const QualType *getExpansionsPtr() const {

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 92b246a83bcec..0ace0a55afd7a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -940,7 +940,7 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager 
&SM,
   DependentSizedMatrixTypes(this_()),
   FunctionProtoTypes(this_(), FunctionProtoTypesLog2InitSize),
   DependentTypeOfExprTypes(this_()), DependentDecltypeTypes(this_()),
-  TemplateSpecializationTypes(this_()),
+  DependentPackIndexingTypes(this_()), 
TemplateS

[clang] [OpenMP] Fix crash when diagnosing dist_schedule (PR #139277)

2025-05-09 Thread Mariya Podchishchaeva via cfe-commits


@@ -105,3 +105,11 @@ int main(int argc, char **argv) {
 
   return (tmain(argc) + tmain(argv[0][0])); // expected-note 
{{in instantiation of function template specialization 'tmain' 
requested here}} expected-note {{in instantiation of function template 
specialization 'tmain' requested here}}
 }
+
+namespace GH139266 {
+void f(void) {
+#pragma omp distribute dist_schedule(static, 0) // expected-error {[argument 
to 'dist_schedule' clause must be a strictly positive integer value}}

Fznamznon wrote:

a '{' is missing.

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


[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

2025-05-09 Thread via cfe-commits

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


[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

2025-05-09 Thread via cfe-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] Reland "Reland [Modules] Remove unnecessary check when generating name lookup table in ASTWriter" (PR #139253)

2025-05-09 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 cppm,cpp,h -- 
clang/include/clang/Serialization/ASTWriter.h 
clang/lib/Serialization/ASTWriter.cpp clang/test/Modules/pr61065.cppm
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 10e82fb5b..63dcf6687 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -4555,7 +4555,7 @@ void ASTWriter::GenerateNameLookupTable(
   // order.
   SmallVector Names;
 
-   // We also track whether we're writing out the DeclarationNameKey for
+  // We also track whether we're writing out the DeclarationNameKey for
   // constructors or conversion functions.
   bool IncludeConstructorNames = false;
   bool IncludeConversionNames = false;
@@ -4569,7 +4569,7 @@ void ASTWriter::GenerateNameLookupTable(
 // Also in reduced BMI, we'd like to avoid writing unreachable
 // declarations in GMF, so we need to avoid writing declarations
 // that entirely external or unreachable.
- if (GeneratingReducedBMI && isLookupResultNotInteresting(*this, Result))
+if (GeneratingReducedBMI && isLookupResultNotInteresting(*this, Result))
   continue;
 // We also skip empty results. If any of the results could be external and
 // the currently available results are empty, then all of the results are

``




https://github.com/llvm/llvm-project/pull/139253
___
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 direcrive and "looprange" clause (PR #139293)

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


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {
+if (auto *For = dyn_cast(LoopStmt)) {
+  OriginalInits.back().push_back(For->getInit());
+  ForStmts.push_back(For);
+  // Extract induction variable
+  if (auto *InitStmt = dyn_cast_or_null(For->getInit())) {
+if (auto *InitDecl = dyn_cast(InitStmt->getSingleDecl())) {
+  QualType InductionVarType = InitDecl->getType().getCanonicalType();
+
+  // Compare with first loop type
+  if (BaseInductionVarType.isNull()) {
+BaseInductionVarType = InductionVarT

[clang] 3668a3a - [OpenACC][CIR] 'if'/'self' combined construct lowering

2025-05-09 Thread via cfe-commits

Author: erichkeane
Date: 2025-05-09T11:26:15-07:00
New Revision: 3668a3a7c8a0a4cdb4bd781529bb72b8588e8f99

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

LOG: [OpenACC][CIR] 'if'/'self' combined construct lowering

These two require that we correctly set up the 'insertion points' for
the compute construct when doing a combined construct.  This patch adds
that and verifies that we're doing it correctly.

Added: 


Modified: 
clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
clang/test/CIR/CodeGenOpenACC/combined.cpp

Removed: 




diff  --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h 
b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
index 8892c49e41202..3692560b06e6f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
@@ -148,7 +148,8 @@ class OpenACCClauseCIREmitter final
   template , U>>
   void applyToComputeOp(const OpenACCClause &c) {
-// TODO OpenACC: we have to set the insertion scope here correctly still.
+mlir::OpBuilder::InsertionGuard guardCase(builder);
+builder.setInsertionPoint(operation.computeOp);
 OpenACCClauseCIREmitter computeEmitter{
 operation.computeOp, cgf, builder, dirKind, dirLoc};
 computeEmitter.lastDeviceTypeValues = lastDeviceTypeValues;
@@ -288,9 +289,11 @@ class OpenACCClauseCIREmitter final
   } else {
 llvm_unreachable("var-list version of self shouldn't get here");
   }
+} else if constexpr (isCombinedType) {
+  applyToComputeOp(clause);
 } else {
   // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. If, combined constructs remain.
+  // unreachable. update construct remains.
   return clauseNotImplemented(clause);
 }
   }
@@ -302,13 +305,15 @@ class OpenACCClauseCIREmitter final
mlir::acc::DataOp, mlir::acc::WaitOp>) {
   operation.getIfCondMutable().append(
   createCondition(clause.getConditionExpr()));
+} else if constexpr (isCombinedType) {
+  applyToComputeOp(clause);
 } else {
   // 'if' applies to most of the constructs, but hold off on lowering them
   // until we can write tests/know what we're doing with codegen to make
   // sure we get it right.
   // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. Enter data, exit data, host_data, update, combined
-  // constructs remain.
+  // unreachable. Enter data, exit data, host_data, update constructs
+  // remain.
   return clauseNotImplemented(clause);
 }
   }

diff  --git a/clang/test/CIR/CodeGenOpenACC/combined.cpp 
b/clang/test/CIR/CodeGenOpenACC/combined.cpp
index 3b2ae8a97d8c5..da8347a7f89c4 100644
--- a/clang/test/CIR/CodeGenOpenACC/combined.cpp
+++ b/clang/test/CIR/CodeGenOpenACC/combined.cpp
@@ -176,4 +176,80 @@ extern "C" void acc_combined(int N) {
   // CHECK-NEXT: } attributes {collapse = [1, 2, 2, 3], collapseDeviceType = 
[#acc.device_type, #acc.device_type, #acc.device_type, 
#acc.device_type]}
   // CHECK: acc.yield
   // CHECK-NEXT: } loc
+
+#pragma acc kernels loop self
+  for(unsigned I = 0; I < N; ++I);
+  // CHECK-NEXT: acc.kernels combined(loop) {
+  // CHECK-NEXT: acc.loop combined(kernels) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.terminator
+  // CHECK-NEXT: } attributes {selfAttr}
+
+#pragma acc serial loop self(N)
+  for(unsigned I = 0; I < N; ++I);
+  // CHECK-NEXT: %[[N_LOAD:.*]] = cir.load %[[ALLOCA_N]] : !cir.ptr, 
!s32i
+  // CHECK-NEXT: %[[BOOL_CAST:.*]] = cir.cast(int_to_bool, %[[N_LOAD]] : 
!s32i), !cir.bool
+  // CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast 
%[[BOOL_CAST]] : !cir.bool to i1
+  // CHECK-NEXT: acc.serial combined(loop) self(%[[CONV_CAST]]) {
+  // CHECK-NEXT: acc.loop combined(serial) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.yield
+  // CHECK-NEXT: } loc
+
+#pragma acc parallel loop if(N)
+  for(unsigned I = 0; I < N; ++I);
+  // CHECK-NEXT: %[[N_LOAD:.*]] = cir.load %[[ALLOCA_N]] : !cir.ptr, 
!s32i
+  // CHECK-NEXT: %[[BOOL_CAST:.*]] = cir.cast(int_to_bool, %[[N_LOAD]] : 
!s32i), !cir.bool
+  // CHECK-NEXT: %[[CONV_CAST:.*]] = builtin.unrealized_conversion_cast 
%[[BOOL_CAST]] : !cir.bool to i1
+  // CHECK-NEXT: acc.parallel combined(loop) if(%[[CONV_CAST]]) {
+  // CHECK-NEXT: acc.loop combined(parallel) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.yield
+  // CHECK-NEXT: } loc
+
+#pragma acc serial loop if(1)
+  for(unsigned I = 0; I < N; ++I);
+  // CHECK-NEXT: %[[ONE_LITERAL:.*]] = cir.const #cir.int<1> : !s32i
+  // CHECK-NEXT: %[[BOOL_CAST:.*]] = cir.cast(int_to_bool, %[[ONE_LITERAL]] : 
!s32i), !cir.bool
+  // CHECK-NEXT: %[[C

[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)

2025-05-09 Thread Sean Perry via cfe-commits


@@ -5087,6 +5087,19 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, 
AccessSpecifier AS,
   assert(EllipsisLoc.isInvalid() &&
  "Friend ellipsis but not friend-specified?");
 
+  if (DS.isExportSpecified()) {
+VisibilityAttr *existingAttr = TagD->getAttr();
+if (existingAttr) {
+  VisibilityAttr::VisibilityType existingValue =
+  existingAttr->getVisibility();
+  if (existingValue != VisibilityAttr::Default)
+Diag(DS.getExportSpecLoc(), diag::err_mismatched_visibility);
+} else {
+  Tag->addAttr(

perry-ca wrote:

Totally valid.  The intention was to have these be another way to specify 
`__attribute__((visibility("default")))`.  I've rewritten the code to these 
issues and have hopefully addressed all of your concerns.  

https://github.com/llvm/llvm-project/pull/111035
___
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 direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev 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;

alexey-bataev wrote:

Why do you need this new field?

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] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

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


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {

alexey-bataev wrote:

```suggestion
  auto StoreLoopStatements = [&](Stmt *LoopStmt) {
```


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] [CIR] Implement folder for VecExtractOp (PR #139304)

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


@@ -0,0 +1,20 @@
+// RUN: cir-opt %s -cir-canonicalize -o - | FileCheck %s
+
+!s32i = !cir.int
+
+module {
+  cir.func @fold_extract_vector_op_test() {
+%init = cir.alloca !s32i, !cir.ptr, ["e", init]
+%const_vec = cir.const #cir.const_vector<[#cir.int<1> : !s32i, #cir.int<2> 
: !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.vector<4 x !s32i>
+%index = cir.const #cir.int<1> : !s32i
+%ele = cir.vec.extract %const_vec[%index : !s32i] : !cir.vector<4 x !s32i>
+cir.store %ele, %init : !s32i, !cir.ptr
+cir.return
+  }
+
+  // CHECK: %[[INIT:.*]] = cir.alloca !s32i, !cir.ptr, ["e", init]
+  // CHECK: %[[VALUE:.*]] = cir.const #cir.int<2> : !s32i

bcardosolopes wrote:

Nice!

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --
+
+enum E {};
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum 
class' instead [cppcoreguidelines-use-enum-class]

vbvictor wrote:

nit: you can remove `[cppcoreguidelines-use-enum-class]` from all 
check-messages to make lines shorter and easier to read.
We have no need to check this part of message.

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


[clang] [Clang] Improve ``-Wtautological-overlap-compare`` diagnostics flag (PR #133653)

2025-05-09 Thread via cfe-commits


@@ -1170,82 +1171,117 @@ class CFGBuilder {
 if (!areExprTypesCompatible(NumExpr1, NumExpr2))
   return {};
 
+// Check that the two expressions are of the same type.
 Expr::EvalResult L1Result, L2Result;
-if (!NumExpr1->EvaluateAsInt(L1Result, *Context) ||
-!NumExpr2->EvaluateAsInt(L2Result, *Context))
-  return {};
-
-llvm::APSInt L1 = L1Result.Val.getInt();
-llvm::APSInt L2 = L2Result.Val.getInt();
-
-// Can't compare signed with unsigned or with different bit width.
-if (L1.isSigned() != L2.isSigned() || L1.getBitWidth() != L2.getBitWidth())
+if (!NumExpr1->EvaluateAsRValue(L1Result, *Context) ||
+!NumExpr2->EvaluateAsRValue(L2Result, *Context))
   return {};
 
-// Values that will be used to determine if result of logical
-// operator is always true/false
-const llvm::APSInt Values[] = {
-  // Value less than both Value1 and Value2
-  llvm::APSInt::getMinValue(L1.getBitWidth(), L1.isUnsigned()),
-  // L1
-  L1,
-  // Value between Value1 and Value2
-  ((L1 < L2) ? L1 : L2) + llvm::APSInt(llvm::APInt(L1.getBitWidth(), 1),
-  L1.isUnsigned()),
-  // L2
-  L2,
-  // Value greater than both Value1 and Value2
-  llvm::APSInt::getMaxValue(L1.getBitWidth(), L1.isUnsigned()),
-};
-
-// Check whether expression is always true/false by evaluating the 
following
+// Check whether expression is always true/false by evaluating the
+// following
 // * variable x is less than the smallest literal.
 // * variable x is equal to the smallest literal.
 // * Variable x is between smallest and largest literal.
 // * Variable x is equal to the largest literal.
 // * Variable x is greater than largest literal.
-bool AlwaysTrue = true, AlwaysFalse = true;
-// Track value of both subexpressions.  If either side is always
-// true/false, another warning should have already been emitted.
-bool LHSAlwaysTrue = true, LHSAlwaysFalse = true;
-bool RHSAlwaysTrue = true, RHSAlwaysFalse = true;
-for (const llvm::APSInt &Value : Values) {
-  TryResult Res1, Res2;
-  Res1 = analyzeLogicOperatorCondition(BO1, Value, L1);
-  Res2 = analyzeLogicOperatorCondition(BO2, Value, L2);
-
-  if (!Res1.isKnown() || !Res2.isKnown())
-return {};
+auto analyzeConditions = [&](const auto &Values,
+ const BinaryOperatorKind *BO1,
+ const BinaryOperatorKind *BO2) -> TryResult {
+  bool AlwaysTrue = true, AlwaysFalse = true;
+  // Track value of both subexpressions.  If either side is always
+  // true/false, another warning should have already been emitted.
+  bool LHSAlwaysTrue = true, LHSAlwaysFalse = true;
+  bool RHSAlwaysTrue = true, RHSAlwaysFalse = true;
+
+  for (const auto &Value : Values) {
+TryResult Res1 =
+analyzeLogicOperatorCondition(*BO1, Value, Values[1] /* L1 */);
+TryResult Res2 =
+analyzeLogicOperatorCondition(*BO2, Value, Values[3] /* L2 */);
+
+if (!Res1.isKnown() || !Res2.isKnown())
+  return {};
+
+const bool isAnd = B->getOpcode() == BO_LAnd;
+const bool combine = isAnd ? (Res1.isTrue() && Res2.isTrue())
+   : (Res1.isTrue() || Res2.isTrue());
+
+AlwaysTrue &= combine;
+AlwaysFalse &= !combine;
+
+LHSAlwaysTrue &= Res1.isTrue();
+LHSAlwaysFalse &= Res1.isFalse();
+RHSAlwaysTrue &= Res2.isTrue();
+RHSAlwaysFalse &= Res2.isFalse();
+  }
 
-  if (B->getOpcode() == BO_LAnd) {
-AlwaysTrue &= (Res1.isTrue() && Res2.isTrue());
-AlwaysFalse &= !(Res1.isTrue() && Res2.isTrue());
-  } else {
-AlwaysTrue &= (Res1.isTrue() || Res2.isTrue());
-AlwaysFalse &= !(Res1.isTrue() || Res2.isTrue());
+  if (AlwaysTrue || AlwaysFalse) {
+if (!LHSAlwaysTrue && !LHSAlwaysFalse && !RHSAlwaysTrue &&
+!RHSAlwaysFalse && BuildOpts.Observer) {
+  BuildOpts.Observer->compareAlwaysTrue(B, AlwaysTrue);
+}
+return TryResult(AlwaysTrue);
   }
+  return {};
+};
 
-  LHSAlwaysTrue &= Res1.isTrue();
-  LHSAlwaysFalse &= Res1.isFalse();
-  RHSAlwaysTrue &= Res2.isTrue();
-  RHSAlwaysFalse &= Res2.isFalse();
+// Handle integer comparison
+if (L1Result.Val.getKind() == APValue::Int &&
+L2Result.Val.getKind() == APValue::Int) {
+  llvm::APSInt L1 = L1Result.Val.getInt();
+  llvm::APSInt L2 = L2Result.Val.getInt();
+
+  // Can't compare signed with unsigned or with different bit width.
+  if (L1.isSigned() != L2.isSigned() ||
+  L1.getBitWidth() != L2.getBitWidth())
+return {};
+
+  // Values that will be used to determine if result of logical
+  // operator is always true/false
+  const llvm::APSInt Values[] = {

[clang] 7439d7b - [clang][bytecode] Slightly optimize integral casts of literals (#138879)

2025-05-09 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-05-09T09:02:25+02:00
New Revision: 7439d7bdf5aa0069c91693ec590561f234d05c20

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

LOG: [clang][bytecode] Slightly optimize integral casts of literals (#138879)

We often see initializers like

unsigned a = 10;

which take an integer literal and immediately cast it to another type.
Recognize this pattern and omit the cast, simply emitting the value as a
different type directly.

This reduces the instruction count by up to 0.13%:
http://llvm-compile-time-tracker.com/compare.php?from=303436c6d16518b35288d63a859506ffcc1681e4&to=648f5202f906d1606390b2d1081e4502dc74acc2&stat=instructions:u

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 3cc55c7052d23..51bfa8e548307 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -238,8 +238,8 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   case CK_DerivedToBaseMemberPointer: {
 assert(classifyPrim(CE->getType()) == PT_MemberPtr);
 assert(classifyPrim(SubExpr->getType()) == PT_MemberPtr);
-const auto *FromMP = SubExpr->getType()->getAs();
-const auto *ToMP = CE->getType()->getAs();
+const auto *FromMP = SubExpr->getType()->castAs();
+const auto *ToMP = CE->getType()->castAs();
 
 unsigned DerivedOffset =
 Ctx.collectBaseOffset(ToMP->getMostRecentCXXRecordDecl(),
@@ -254,8 +254,8 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   case CK_BaseToDerivedMemberPointer: {
 assert(classifyPrim(CE) == PT_MemberPtr);
 assert(classifyPrim(SubExpr) == PT_MemberPtr);
-const auto *FromMP = SubExpr->getType()->getAs();
-const auto *ToMP = CE->getType()->getAs();
+const auto *FromMP = SubExpr->getType()->castAs();
+const auto *ToMP = CE->getType()->castAs();
 
 unsigned DerivedOffset =
 Ctx.collectBaseOffset(FromMP->getMostRecentCXXRecordDecl(),
@@ -320,29 +320,30 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
   }
 
   case CK_IntegralToFloating: {
-std::optional FromT = classify(SubExpr->getType());
-if (!FromT)
+if (!CE->getType()->isRealFloatingType())
   return false;
-
 if (!this->visit(SubExpr))
   return false;
-
 const auto *TargetSemantics = &Ctx.getFloatSemantics(CE->getType());
-return this->emitCastIntegralFloating(*FromT, TargetSemantics,
-  getFPOptions(CE), CE);
+return this->emitCastIntegralFloating(
+classifyPrim(SubExpr), TargetSemantics, getFPOptions(CE), CE);
   }
 
-  case CK_FloatingToBoolean:
-  case CK_FloatingToIntegral: {
-
-std::optional ToT = classify(CE->getType());
-
-if (!ToT)
+  case CK_FloatingToBoolean: {
+if (!SubExpr->getType()->isRealFloatingType() ||
+!CE->getType()->isBooleanType())
   return false;
-
+if (const auto *FL = dyn_cast(SubExpr))
+  return this->emitConstBool(FL->getValue().isNonZero(), CE);
 if (!this->visit(SubExpr))
   return false;
+return this->emitCastFloatingIntegralBool(getFPOptions(CE), CE);
+  }
 
+  case CK_FloatingToIntegral: {
+if (!this->visit(SubExpr))
+  return false;
+PrimType ToT = classifyPrim(CE);
 if (ToT == PT_IntAP)
   return this->emitCastFloatingIntegralAP(Ctx.getBitWidth(CE->getType()),
   getFPOptions(CE), CE);
@@ -350,7 +351,7 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   return this->emitCastFloatingIntegralAPS(Ctx.getBitWidth(CE->getType()),
getFPOptions(CE), CE);
 
-return this->emitCastFloatingIntegral(*ToT, getFPOptions(CE), CE);
+return this->emitCastFloatingIntegral(ToT, getFPOptions(CE), CE);
   }
 
   case CK_NullToPointer:
@@ -395,9 +396,7 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
   case CK_ArrayToPointerDecay: {
 if (!this->visit(SubExpr))
   return false;
-if (!this->emitArrayDecay(CE))
-  return false;
-return true;
+return this->emitArrayDecay(CE);
   }
 
   case CK_IntegralToPointer: {
@@ -480,47 +479,63 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) 
{
 return this->emitBuiltinBitCast(CE);
 
   case CK_IntegralToBoolean:
-  case CK_FixedPointToBoolean:
+  case CK_FixedPointToBoolean: {
+// HLSL uses this to cast to one-element vectors.
+std::optional FromT = classify(SubExpr->getType());
+if (!FromT)
+  return false;
+
+if (const auto *IL = dyn_cast(SubExpr))
+  return this->emitConst(IL->getValue(), CE);
+if (!this->visit(SubExpr))
+  return false;
+return this->emitCast(*FromT, classifyPrim(CE), CE);
+

[clang] [Clang] Improve ``-Wtautological-overlap-compare`` diagnostics flag (PR #133653)

2025-05-09 Thread Yutong Zhu via cfe-commits

https://github.com/YutongZhuu updated 
https://github.com/llvm/llvm-project/pull/133653

>From ca795c3f27e37ad8a8f165a3b10e9415cbfd66a5 Mon Sep 17 00:00:00 2001
From: Yutong Zhu 
Date: Sat, 12 Apr 2025 15:32:46 -0400
Subject: [PATCH 1/5] Improved the -Wtautological-overlap-compare diagnostics
 to warn about overlapping and non-overlapping ranges involving character
 literals and floating-point literals.

---
 clang/docs/ReleaseNotes.rst   |   3 +
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +-
 clang/lib/Analysis/CFG.cpp| 179 +++---
 clang/lib/Sema/AnalysisBasedWarnings.cpp  |   5 +-
 clang/test/Sema/warn-overlap.c| 119 ++--
 5 files changed, 211 insertions(+), 97 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 11f62bc881b03..de5c877cf996b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -352,6 +352,9 @@ Improvements to Clang's diagnostics
 - Now correctly diagnose a tentative definition of an array with static
   storage duration in pedantic mode in C. (#GH50661)
 
+- Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
+  The warning message for non-overlapping cases has also been improved 
(#GH13473).
+  
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 180ca39bc07e9..c8b5c94676d18 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10356,7 +10356,7 @@ def warn_tautological_negation_or_compare: Warning<
   "'||' of a value and its negation always evaluates to true">,
   InGroup, DefaultIgnore;
 def warn_tautological_overlap_comparison : Warning<
-  "overlapping comparisons always evaluate to %select{false|true}0">,
+  "%select{non-|}0overlapping comparisons always evaluate to 
%select{false|true}0">,
   InGroup, DefaultIgnore;
 def warn_depr_array_comparison : Warning<
   "comparison between two arrays is deprecated; "
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 9af1e915482da..ec7c1fbfc423a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -70,19 +70,18 @@ static SourceLocation GetEndLoc(Decl *D) {
   return D->getLocation();
 }
 
-/// Returns true on constant values based around a single IntegerLiteral.
-/// Allow for use of parentheses, integer casts, and negative signs.
-/// FIXME: it would be good to unify this function with
-/// getIntegerLiteralSubexpressionValue at some point given the similarity
-/// between the functions.
+/// Returns true on constant values based around a single IntegerLiteral,
+/// CharacterLiteral, or FloatingLiteral. Allow for use of parentheses, integer
+/// casts, and negative signs.
 
-static bool IsIntegerLiteralConstantExpr(const Expr *E) {
+static bool IsLiteralConstantExpr(const Expr *E) {
   // Allow parentheses
   E = E->IgnoreParens();
 
   // Allow conversions to different integer kind.
   if (const auto *CE = dyn_cast(E)) {
-if (CE->getCastKind() != CK_IntegralCast)
+if (CE->getCastKind() != CK_IntegralCast &&
+CE->getCastKind() != CK_IntegralToFloating)
   return false;
 E = CE->getSubExpr();
   }
@@ -93,16 +92,16 @@ static bool IsIntegerLiteralConstantExpr(const Expr *E) {
   return false;
 E = UO->getSubExpr();
   }
-
-  return isa(E);
+  return isa(E) || isa(E) ||
+ isa(E);
 }
 
 /// Helper for tryNormalizeBinaryOperator. Attempts to extract an 
IntegerLiteral
-/// constant expression or EnumConstantDecl from the given Expr. If it fails,
-/// returns nullptr.
-static const Expr *tryTransformToIntOrEnumConstant(const Expr *E) {
+/// FloatingLiteral, CharacterLiteral or EnumConstantDecl from the given Expr.
+/// If it fails, returns nullptr.
+static const Expr *tryTransformToLiteralConstant(const Expr *E) {
   E = E->IgnoreParens();
-  if (IsIntegerLiteralConstantExpr(E))
+  if (IsLiteralConstantExpr(E))
 return E;
   if (auto *DR = dyn_cast(E->IgnoreParenImpCasts()))
 return isa(DR->getDecl()) ? DR : nullptr;
@@ -119,7 +118,7 @@ tryNormalizeBinaryOperator(const BinaryOperator *B) {
   BinaryOperatorKind Op = B->getOpcode();
 
   const Expr *MaybeDecl = B->getLHS();
-  const Expr *Constant = tryTransformToIntOrEnumConstant(B->getRHS());
+  const Expr *Constant = tryTransformToLiteralConstant(B->getRHS());
   // Expr looked like `0 == Foo` instead of `Foo == 0`
   if (Constant == nullptr) {
 // Flip the operator
@@ -133,7 +132,7 @@ tryNormalizeBinaryOperator(const BinaryOperator *B) {
   Op = BO_GE;
 
 MaybeDecl = B->getRHS();
-Constant = tryTransformToIntOrEnumConstant(B->getLHS());
+Constant = tryTransformToLiteralConstant(B->getLHS());
   }
 
   return 

[clang] [Clang] Detect bit copies that should be relocation. (PR #139104)

2025-05-09 Thread via cfe-commits


@@ -853,6 +853,13 @@ def warn_cxxstruct_memaccess : Warning<
   "first argument in call to "
   "%0 is a pointer to non-trivially copyable type %1">,
   InGroup;
+
+def warn_cxxstruct_memaccess_relocatable
+: Warning<"calling %0 with a pointer to a type %1 which is trivially "
+  "relocatable "
+  "but not trivially copyable; did you mean to call %2?">,

Sirraide wrote:

```suggestion
  "but not trivially copyable; did you mean to call '%2'?">,
```
This one needs to be quoted manually because it’s just a `StringRef`.

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


[clang] [Clang] Improve ``-Wtautological-overlap-compare`` diagnostics flag (PR #133653)

2025-05-09 Thread via cfe-commits


@@ -169,7 +169,84 @@ int struct_test(struct A a) {
   return a.x > 5 && a.y < 1;  // no warning, different variables
 
   return a.x > 5 && a.x < 1;
-  // expected-warning@-1{{overlapping comparisons always evaluate to false}}
+  // expected-warning@-1{{non-overlapping comparisons always evaluate to 
false}}
   return a.y == 1 || a.y != 1;
   // expected-warning@-1{{overlapping comparisons always evaluate to true}}
 }
+
+void char_tests(char c) {
+  if (c > 'a' || c < 'z') {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+  if (c > 'z' && c < 'a') {}
+  // expected-warning@-1{{non-overlapping comparisons always evaluate to 
false}}
+  if (c == 'a' && c == 'z') {}
+  // expected-warning@-1{{non-overlapping comparisons always evaluate to 
false}}
+  if (c != 'a' || c != 'z') {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}
+}
+
+void float_tests(float f) {
+  if (f > 1.0 || f < 2.0) {}
+  // expected-warning@-1{{overlapping comparisons always evaluate to true}}

Sirraide wrote:

> If we consider `nan` as a possible value for `f`, this flag would be wrong in 
> the first place

Yeah, that’s a good point. Maybe we should have a comment for that somewhere 
(either in the test cases or the code).

> `__builtin_nan()/__builtin_inf()` wouldn't trigger this flag at all since 
> this flag only deals with literal comparands, but I can still add them.

Right, I didn’t think about that because we’re doing constant evaluation to get 
the value, which *could* handle e.g. `__builtin_inf()`. I think in that case 
it’s fine as is.



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


[clang] [Clang] Detect bit copies that should be relocation. (PR #139104)

2025-05-09 Thread via cfe-commits

Sirraide wrote:

Also, should this come w/ a release note? Or does this just count as part of 
adding support for trivial relocation?

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


[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)

2025-05-09 Thread via cfe-commits

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



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [Clang] Detect bit copies that should be relocation. (PR #139104)

2025-05-09 Thread via cfe-commits


@@ -9659,6 +9659,42 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
   if (BId == Builtin::BIbzero && !FirstArgTy->getAs())
 return;
 
+  // Try to detect a relocation operation
+  if (getLangOpts().CPlusPlus &&
+  (BId == Builtin::BImemmove || BId == Builtin::BImemcpy)) {
+const Expr *Dest = Call->getArg(0)->IgnoreParenImpCasts();
+const Expr *Src = Call->getArg(1)->IgnoreParenImpCasts();
+QualType DestTy = Dest->getType();
+QualType SrcTy = Src->getType();
+
+QualType DestPointeeTy = DestTy->getPointeeType();
+QualType SrcPointeeTy = SrcTy->getPointeeType();
+bool HasSameTargetAndSource =
+!DestPointeeTy.isNull() && !SrcPointeeTy.isNull() &&
+Context.hasSameUnqualifiedType(DestPointeeTy, SrcPointeeTy);
+
+if (HasSameTargetAndSource &&
+!DestPointeeTy.getUnqualifiedType()->isIncompleteType() &&
+!DestPointeeTy.isConstQualified() && !SrcPointeeTy.isConstQualified() 
&&
+!DestPointeeTy.isTriviallyCopyableType(getASTContext()) &&
+SemaRef.IsCXXTriviallyRelocatableType(DestPointeeTy)) {
+
+  bool SuggestStd = getLangOpts().CPlusPlus26 && getStdNamespace();
+  if (const Decl *D = Call->getReferencedDeclOfCallee();
+  D && !D->isInStdNamespace())
+SuggestStd = false;

Sirraide wrote:

So if I’m reading this correctly this will cause us to suggest 
`std::trivially_relocate` if the user called `std::memcpy`, and 
`__builtin_trivially_relocate` if they called some other `memcpy` that isn’t 
defined in the `std` namespace. Is there a reason why we wouldn’t just always 
suggest `std::trivially_relocate` if C++26 is enabled (or is this because the 
header providing that function might not be included which could potentially be 
confusing if someone then uses `std::trivially_relocate` but then we start 
complaining about it not being found?).

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


[clang] [clang] Add managarm support (PR #139271)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: no92 (no92)


Changes

This PR is part of a series to upstream managarm support, as laid out in the 
[RFC](https://discourse.llvm.org/t/rfc-new-proposed-managarm-support-for-llvm-and-clang-87845/85884/1).
 This PR is a follow-up to #87845 and #138854.

---

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


33 Files Affected:

- (modified) clang/lib/Basic/Targets.cpp (+9) 
- (modified) clang/lib/Basic/Targets/OSTargets.h (+30) 
- (modified) clang/lib/Driver/CMakeLists.txt (+1) 
- (modified) clang/lib/Driver/Driver.cpp (+4) 
- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+2) 
- (added) clang/lib/Driver/ToolChains/Managarm.cpp (+221) 
- (added) clang/lib/Driver/ToolChains/Managarm.h (+55) 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/lib/aarch64-managarm-mlibc/.keep 
() 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/lib/riscv64-managarm-mlibc/.keep 
() 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/lib/x86_64-managarm-mlibc/.keep () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/lib64/aarch64-managarm-mlibc/.keep 
() 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/lib64/riscv64-managarm-mlibc/.keep 
() 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/lib64/x86_64-managarm-mlibc/.keep 
() 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/include/aarch64-managarm-mlibc/c++/10/.keep
 () 
- (added) clang/test/Driver/Inputs/basic_managarm_tree/usr/include/c++/10/.keep 
() 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/include/riscv64-managarm-mlibc/c++/10/.keep
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/include/x86_64-managarm-mlibc/c++/10/.keep
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/aarch64-managarm-mlibc/.keep
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/aarch64-managarm-mlibc/10/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/aarch64-managarm-mlibc/10/crtbeginS.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/aarch64-managarm-mlibc/10/crtbeginT.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/riscv64-managarm-mlibc/10/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/riscv64-managarm-mlibc/10/crtbeginS.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/riscv64-managarm-mlibc/10/crtbeginT.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/x86_64-managarm-mlibc/10/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/x86_64-managarm-mlibc/10/crtbeginS.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/gcc/x86_64-managarm-mlibc/10/crtbeginT.o
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/riscv64-managarm-mlibc/.keep
 () 
- (added) 
clang/test/Driver/Inputs/basic_managarm_tree/usr/lib/x86_64-managarm-mlibc/.keep
 () 
- (added) clang/test/Driver/Inputs/basic_managarm_tree/usr/lib64/.keep () 
- (added) clang/test/Driver/managarm.cpp (+195) 
- (modified) clang/test/Preprocessor/init.c (+5) 
- (modified) clang/test/Preprocessor/predefined-macros-no-warnings.c (+3) 


``diff
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 9889141ad2085..afa863308 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -164,6 +164,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 return std::make_unique>(Triple,
  Opts);
   }
+case llvm::Triple::Managarm:
+  return std::make_unique>(Triple,
+   Opts);
 case llvm::Triple::NetBSD:
   return std::make_unique>(Triple,
  Opts);
@@ -466,6 +469,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 return std::make_unique>(Triple,
Opts);
   }
+case llvm::Triple::Managarm:
+  return std::make_unique>(Triple,
+ Opts);
 default:
   return std::make_unique(Triple, Opts);
 }
@@ -654,6 +660,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
   return std::make_unique>(Triple, Opts);
 case llvm::Triple::Hurd:
   return std::make_unique>(Triple, Opts);
+case llvm::Triple::Managarm:
+  return std::make_unique>(Triple,
+Opts);
 default:
   return std::make_unique(Triple, Opts);
 }
diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index d148b38d03c7c

[clang] [OpenACC][CIR] Impl default/seq lowering for combined constructs (PR #139263)

2025-05-09 Thread Valentin Clement バレンタイン クレメン via cfe-commits

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

LGTM

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


[clang] [clang] Add managarm support (PR #139271)

2025-05-09 Thread via cfe-commits

https://github.com/no92 created https://github.com/llvm/llvm-project/pull/139271

This PR is part of a series to upstream managarm support, as laid out in the 
[RFC](https://discourse.llvm.org/t/rfc-new-proposed-managarm-support-for-llvm-and-clang-87845/85884/1).
 This PR is a follow-up to #87845 and #138854.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [llvm] [OpenMP] implementation set controls elision for begin declare variant (PR #139287)

2025-05-09 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,c -- 
clang/test/OpenMP/begin_declare_variant_elided_range_implementation.c 
clang/lib/Parse/ParseOpenMP.cpp llvm/include/llvm/Frontend/OpenMP/OMPContext.h 
llvm/lib/Frontend/OpenMP/OMPContext.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 293fb8a2e..2508bf579 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2282,7 +2282,8 @@ Parser::DeclGroupPtrTy 
Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
 /* ConstructTraits */ ArrayRef(),
 Actions.OpenMP().getOpenMPDeviceNum());
 
-if (isVariantApplicableInContext(VMI, OMPCtx, 
/*DeviceOrImplementationSetOnly=*/ true)) {
+if (isVariantApplicableInContext(VMI, OMPCtx,
+ /*DeviceOrImplementationSetOnly=*/true)) {
   Actions.OpenMP().ActOnOpenMPBeginDeclareVariant(Loc, TI);
   break;
 }

``




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


[clang] [CIR] Upstream insert op for VectorType (PR #139146)

2025-05-09 Thread Amr Hesham via cfe-commits


@@ -1969,6 +1969,43 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> {
   let hasVerifier = 1;
 }
 
+//===--===//
+// VecInsertOp
+//===--===//
+
+def VecInsertOp : CIR_Op<"vec.insert", [Pure,
+  TypesMatchWith<"argument type matches vector element type", "vec", "value",
+ "cast($_self).getElementType()">,
+  AllTypesMatch<["result", "vec"]>]> {
+
+  let summary = "Insert one element into a vector object";
+  let description = [{
+The `cir.vec.insert` operation replaces the element of the given vector at
+the given index with the given value.  The new vector with the inserted
+element is returned.

AmrDeveloper wrote:

As far as I understood, if we didn't emit StoreOp, the old vector will be in 
its original state, but I will double check in IR and LLVM dialect

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


[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

2025-05-09 Thread via cfe-commits

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

>From 4c87a813ed0d4b4646ab6d32374dfa1525a3711e Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 6 May 2025 20:00:18 +0200
Subject: [PATCH 1/4] [Clang] Diagnose invalid function types in dependent
 contexts

When forming an invalid function type, we were not diagnosing
it if the call was dependent.

However, we later rely on the function type to be sensible
during argument deduction.

We now diagnose anything that is not a potential function type,
to avoid constructing bogus call expressions.

Fixes #138657
Fixes #115725
Fixes #68852
---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaExpr.cpp  | 19 
 clang/test/SemaTemplate/fun-template-def.cpp | 51 +++-
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8f5f40d8fef7..cd452179a6555 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -680,6 +680,7 @@ Bug Fixes to C++ Support
 - Improved parser recovery of invalid requirement expressions. In turn, this
   fixes crashes from follow-on processing of the invalid requirement. 
(#GH138820)
 - Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
+- Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index deb8d2edfc5c9..9517c73006fd0 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6550,6 +6550,15 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
   return Call;
 }
 
+// Any type that could be used to form a callable expression
+static bool MayBeFunctionType(const ASTContext &Context, QualType T) {
+  return T == Context.BoundMemberTy || T == Context.UnknownAnyTy ||
+ T == Context.BuiltinFnTy || T == Context.OverloadTy ||
+ T->isFunctionType() || T->isFunctionReferenceType() ||
+ T->isMemberFunctionPointerType() || T->isFunctionPointerType() ||
+ T->isBlockPointerType() || T->isRecordType();
+}
+
 ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation 
LParenLoc,
MultiExprArg ArgExprs, SourceLocation RParenLoc,
Expr *ExecConfig, bool IsExecConfig,
@@ -6603,6 +6612,16 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
 *this, dyn_cast(Fn->IgnoreParens()),
 Fn->getBeginLoc());
 
+if (!Fn->getType()->isDependentType()) {
+  // If the type of the function itself is not dependent
+  // check that it is a reasonable as a function, as type deduction
+  // later assume the CallExpr has a sensible TYPE.
+  if (!MayBeFunctionType(Context, Fn->getType()))
+return ExprError(
+Diag(LParenLoc, diag::err_typecheck_call_not_function)
+<< Fn->getType() << Fn->getSourceRange());
+}
+
 return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
 VK_PRValue, RParenLoc, 
CurFPFeatureOverrides());
   }
diff --git a/clang/test/SemaTemplate/fun-template-def.cpp 
b/clang/test/SemaTemplate/fun-template-def.cpp
index de77901b5b601..716296e72bc44 100644
--- a/clang/test/SemaTemplate/fun-template-def.cpp
+++ b/clang/test/SemaTemplate/fun-template-def.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 // Tests that dependent expressions are always allowed, whereas non-dependent
 // are checked as usual.
@@ -32,7 +33,7 @@ T f1(T t1, U u1, int i1, T** tpp)
   i1 = t1[u1];
   i1 *= t1;
 
-  i1(u1, t1); // error
+  i1(u1, t1); // expected-error {{called object type 'int' is not a function 
or function pointer}}
   u1(i1, t1);
 
   U u2 = (T)i1;
@@ -60,3 +61,51 @@ void f3() {
   f2(0);
   f2(0); // expected-error {{no matching function for call to 'f2'}}
 }
+
+#if __cplusplus >= 202002L
+namespace GH138657 {
+template  // #gh138657-template-head
+class meta {};
+template
+class meta {}; // expected-error {{called object type 'int' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'int *' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'char *' is not a 
function or function point}}
+
+struct S {};
+template
+class meta {}; // expected-error {{template argument for non-type 
template parameter is treated as function type 'S ()'}}
+// expected-note@#gh138657-template

[clang] [CLANG] Allow parsing arbitrary order of attributes for declarations (PR #133107)

2025-05-09 Thread via cfe-commits

DenisGZM wrote:

> Do you need us to land the changes on your behalf, btw?
Yeah, why not

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


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

2025-05-09 Thread Baranov Victor via cfe-commits

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


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

2025-05-09 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor commented:

Mostly nits and documentation suggestions/improvements.

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -211,6 +211,7 @@ Clang-Tidy Checks
:doc:`cppcoreguidelines-rvalue-reference-param-not-moved 
`,
:doc:`cppcoreguidelines-slicing `,
:doc:`cppcoreguidelines-special-member-functions 
`,
+   :doc:`cppcoreguidelines-use-enum-class `, 
"Yes"

vbvictor wrote:

```suggestion
   :doc:`cppcoreguidelines-use-enum-class `,
```

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --
+
+enum E {};
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum 
class' instead [cppcoreguidelines-use-enum-class]
+
+enum class EC {};
+
+struct S {
+  enum E {};

vbvictor wrote:

Please add test with forward decl.

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.
+
+This check implements `Enum.3
+`_
+from the C++ Core Guidelines."
+
+Example:
+
+.. code-block:: c++
+
+  enum E {};// use "enum class E {};" instead
+  enum class E {};  // OK
+
+  struct S {
+  enum E {};// use "enum class E {};" instead
+// OK with option IgnoreUnscopedEnumsInClasses
+  };
+
+  namespace N {
+  enum E {};// use "enum class E {};" instead
+  }
+
+

vbvictor wrote:

Please add this two lines before declaring options.
```rst
Options
---
```
See any other check with options for reference.

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.
+
+This check implements `Enum.3
+`_
+from the C++ Core Guidelines."
+
+Example:
+
+.. code-block:: c++
+
+  enum E {};// use "enum class E {};" instead
+  enum class E {};  // OK
+
+  struct S {
+  enum E {};// use "enum class E {};" instead
+// OK with option IgnoreUnscopedEnumsInClasses
+  };
+
+  namespace N {
+  enum E {};// use "enum class E {};" instead
+  }
+
+
+.. option:: IgnoreUnscopedEnumsInClasses
+
+   When `true` (default is `false`), ignores unscoped ``enum`` declarations in 
classes.

vbvictor wrote:

```suggestion
   When `true`, ignores unscoped ``enum`` declarations in classes.
   Default is `false`.
```
Preferred way to write default values in options.

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -136,6 +136,11 @@ New checks
   Finds potentially erroneous calls to ``reset`` method on smart pointers when
   the pointee type also has a ``reset`` method.
 
+- New :doc:`cppcoreguidelines-use-enum-class

vbvictor wrote:

Please make in alphabetical order

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --

vbvictor wrote:

nit: for readability, please break this line in multiple ones
```cpp
// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- \
// RUN:   -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --
```

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


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

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.

vbvictor wrote:

```suggestion
Finds unscoped (non-class) ``enum`` declarations and suggests using ``enum 
class`` instead.
```
1. I think we should use original cppreference syntax (unscoped)
2. definitions -> declarations because in tests we also warn on `enum ForwardE`
3. rephrased "could use" because we actually don't check any conditions before 
giving warning.

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


[clang] [llvm] [AArch64][SVE] Refactor getPTrue to return splat(1) when pattern=all. (PR #139236)

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

https://github.com/paulwalker-arm approved this pull request.


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


[clang] [Clang] Improve ``-Wtautological-overlap-compare`` diagnostics flag (PR #133653)

2025-05-09 Thread Yutong Zhu via cfe-commits

https://github.com/YutongZhuu updated 
https://github.com/llvm/llvm-project/pull/133653

>From ca795c3f27e37ad8a8f165a3b10e9415cbfd66a5 Mon Sep 17 00:00:00 2001
From: Yutong Zhu 
Date: Sat, 12 Apr 2025 15:32:46 -0400
Subject: [PATCH 1/6] Improved the -Wtautological-overlap-compare diagnostics
 to warn about overlapping and non-overlapping ranges involving character
 literals and floating-point literals.

---
 clang/docs/ReleaseNotes.rst   |   3 +
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +-
 clang/lib/Analysis/CFG.cpp| 179 +++---
 clang/lib/Sema/AnalysisBasedWarnings.cpp  |   5 +-
 clang/test/Sema/warn-overlap.c| 119 ++--
 5 files changed, 211 insertions(+), 97 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 11f62bc881b03..de5c877cf996b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -352,6 +352,9 @@ Improvements to Clang's diagnostics
 - Now correctly diagnose a tentative definition of an array with static
   storage duration in pedantic mode in C. (#GH50661)
 
+- Improved the ``-Wtautological-overlap-compare`` diagnostics to warn about 
overlapping and non-overlapping ranges involving character literals and 
floating-point literals. 
+  The warning message for non-overlapping cases has also been improved 
(#GH13473).
+  
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 180ca39bc07e9..c8b5c94676d18 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10356,7 +10356,7 @@ def warn_tautological_negation_or_compare: Warning<
   "'||' of a value and its negation always evaluates to true">,
   InGroup, DefaultIgnore;
 def warn_tautological_overlap_comparison : Warning<
-  "overlapping comparisons always evaluate to %select{false|true}0">,
+  "%select{non-|}0overlapping comparisons always evaluate to 
%select{false|true}0">,
   InGroup, DefaultIgnore;
 def warn_depr_array_comparison : Warning<
   "comparison between two arrays is deprecated; "
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 9af1e915482da..ec7c1fbfc423a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -70,19 +70,18 @@ static SourceLocation GetEndLoc(Decl *D) {
   return D->getLocation();
 }
 
-/// Returns true on constant values based around a single IntegerLiteral.
-/// Allow for use of parentheses, integer casts, and negative signs.
-/// FIXME: it would be good to unify this function with
-/// getIntegerLiteralSubexpressionValue at some point given the similarity
-/// between the functions.
+/// Returns true on constant values based around a single IntegerLiteral,
+/// CharacterLiteral, or FloatingLiteral. Allow for use of parentheses, integer
+/// casts, and negative signs.
 
-static bool IsIntegerLiteralConstantExpr(const Expr *E) {
+static bool IsLiteralConstantExpr(const Expr *E) {
   // Allow parentheses
   E = E->IgnoreParens();
 
   // Allow conversions to different integer kind.
   if (const auto *CE = dyn_cast(E)) {
-if (CE->getCastKind() != CK_IntegralCast)
+if (CE->getCastKind() != CK_IntegralCast &&
+CE->getCastKind() != CK_IntegralToFloating)
   return false;
 E = CE->getSubExpr();
   }
@@ -93,16 +92,16 @@ static bool IsIntegerLiteralConstantExpr(const Expr *E) {
   return false;
 E = UO->getSubExpr();
   }
-
-  return isa(E);
+  return isa(E) || isa(E) ||
+ isa(E);
 }
 
 /// Helper for tryNormalizeBinaryOperator. Attempts to extract an 
IntegerLiteral
-/// constant expression or EnumConstantDecl from the given Expr. If it fails,
-/// returns nullptr.
-static const Expr *tryTransformToIntOrEnumConstant(const Expr *E) {
+/// FloatingLiteral, CharacterLiteral or EnumConstantDecl from the given Expr.
+/// If it fails, returns nullptr.
+static const Expr *tryTransformToLiteralConstant(const Expr *E) {
   E = E->IgnoreParens();
-  if (IsIntegerLiteralConstantExpr(E))
+  if (IsLiteralConstantExpr(E))
 return E;
   if (auto *DR = dyn_cast(E->IgnoreParenImpCasts()))
 return isa(DR->getDecl()) ? DR : nullptr;
@@ -119,7 +118,7 @@ tryNormalizeBinaryOperator(const BinaryOperator *B) {
   BinaryOperatorKind Op = B->getOpcode();
 
   const Expr *MaybeDecl = B->getLHS();
-  const Expr *Constant = tryTransformToIntOrEnumConstant(B->getRHS());
+  const Expr *Constant = tryTransformToLiteralConstant(B->getRHS());
   // Expr looked like `0 == Foo` instead of `Foo == 0`
   if (Constant == nullptr) {
 // Flip the operator
@@ -133,7 +132,7 @@ tryNormalizeBinaryOperator(const BinaryOperator *B) {
   Op = BO_GE;
 
 MaybeDecl = B->getRHS();
-Constant = tryTransformToIntOrEnumConstant(B->getLHS());
+Constant = tryTransformToLiteralConstant(B->getLHS());
   }
 
   return 

[clang] [Clang] Improve ``-Wtautological-overlap-compare`` diagnostics flag (PR #133653)

2025-05-09 Thread via cfe-commits

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


[clang] [CodeGen][RISCV] Use vscale_range to handle more fixed<->scalable casts of i1 vectors. (PR #138378)

2025-05-09 Thread Craig Topper via cfe-commits

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


[clang] [CodeGen][RISCV] Use vscale_range to handle more fixed<->scalable casts of i1 vectors. (PR #138378)

2025-05-09 Thread Craig Topper via cfe-commits

topperc wrote:

Replaced with #139190

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


[clang] [llvm] [clang] Simplify device kernel attributes (PR #137882)

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


@@ -1538,11 +1533,32 @@ def CUDAShared : InheritableAttr {
 }
 def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
 
-def SYCLKernel : InheritableAttr {
-  let Spellings = [Clang<"sycl_kernel">];
-  let Subjects = SubjectList<[FunctionTmpl]>;
-  let LangOpts = [SYCLDevice];
+def DeviceKernel : DeclOrTypeAttr {
+  let Spellings = [Clang<"device_kernel">, Clang<"sycl_kernel">,
+   Clang<"nvptx_kernel">, Clang<"amdgpu_kernel">,
+   CustomKeyword<"__kernel">, CustomKeyword<"kernel">];
   let Documentation = [SYCLKernelDocs];
+  let AdditionalMembers =

AaronBallman wrote:

I would still prefer using `Accessors` as the whole point to the feature is to 
do this based on spellings rather than doing it manually based on spelling list 
index.

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


[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)

2025-05-09 Thread Marco Elver via cfe-commits

melver wrote:

Thanks for the feedback. Addressed comments as best as I could.

Most notable changes:
- Also warns properly for loops with mismatching reentrancy depth.
- Devirtualized new helpers.
- Require ordering `reentrant_capability` after `capability`.
- Stylistic improvements.

PTAL.

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


[clang] [llvm] [HLSL][RootSignature] Define and integrate rootsig clang attr and decl (PR #137690)

2025-05-09 Thread Finn Plummer via cfe-commits

https://github.com/inbelic updated 
https://github.com/llvm/llvm-project/pull/137690

>From 87680ba4a99d35dbcc9416ab6b0710bd2f88d7bd Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Mon, 28 Apr 2025 18:42:10 +
Subject: [PATCH 01/16] [HLSL][RootSignature] Define and integrate rootsig
 clang attr and decl

- Defines a new declaration node `HLSLRootSignature` in `DeclNodes.td`
that will hold a reference to an in-memory construction of the root
signature, namely an array of `hlsl::rootsig::RootElement`s

- Defines a new clang attr `RootSignature` which simply holds an
identifier to a corresponding root signature declration as above

It was previously proposed that we could have the root elements
reference be stored directly as an additional member of the attribute
and to not have a seperate root signature decl. In contrast, by defining
them seperately as this change proposes, we will allow a unique root
signature to have its own declaration in the AST tree. This allows us
to only construct a single root signature for all duplicate rootsignature
attributes. Having it located directly as a declaration might also prove
advantageous when we consider root signature libraries.
---
 clang/include/clang/AST/Decl.h| 24 +
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +
 clang/include/clang/AST/TextNodeDumper.h  |  1 +
 clang/include/clang/Basic/Attr.td | 11 +++
 clang/include/clang/Basic/AttrDocs.td | 11 +++
 clang/include/clang/Basic/DeclNodes.td|  1 +
 clang/include/clang/Parse/Parser.h|  1 +
 clang/include/clang/Sema/SemaHLSL.h   |  1 +
 clang/lib/AST/Decl.cpp| 25 ++
 clang/lib/AST/DeclBase.cpp|  1 +
 clang/lib/AST/TextNodeDumper.cpp  |  4 +
 clang/lib/CodeGen/CGDecl.cpp  |  1 +
 clang/lib/Parse/ParseDeclCXX.cpp  | 90 +++
 clang/lib/Sema/SemaDeclAttr.cpp   |  3 +
 clang/lib/Sema/SemaHLSL.cpp   | 18 
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  5 ++
 clang/lib/Serialization/ASTCommon.cpp |  1 +
 clang/test/AST/HLSL/RootSignatures-AST.hlsl   | 58 
 clang/test/SemaHLSL/RootSignature-err.hlsl| 11 +++
 clang/tools/libclang/CIndex.cpp   |  1 +
 20 files changed, 270 insertions(+)
 create mode 100644 clang/test/AST/HLSL/RootSignatures-AST.hlsl
 create mode 100644 clang/test/SemaHLSL/RootSignature-err.hlsl

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 3faf63e395a08..8e45c19061b1d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -41,6 +41,7 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/TrailingObjects.h"
@@ -5178,6 +5179,29 @@ class HLSLBufferDecl final : public NamedDecl, public 
DeclContext {
   friend class ASTDeclWriter;
 };
 
+class HLSLRootSignatureDecl final : public NamedDecl {
+  ArrayRef RootElements;
+
+  HLSLRootSignatureDecl(
+  DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
+  ArrayRef RootElements);
+
+public:
+  static HLSLRootSignatureDecl *
+  Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, IdentifierInfo 
*ID,
+ ArrayRef RootElements);
+  static HLSLRootSignatureDecl *CreateDeserialized(ASTContext &C,
+   GlobalDeclID ID);
+
+  ArrayRef &getRootElements() {
+return RootElements;
+  }
+
+  // Implement isa/cast/dyncast/etc.
+  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
+  static bool classofKind(Kind K) { return K == HLSLRootSignature; }
+};
+
 /// Insertion operator for diagnostics.  This allows sending NamedDecl's
 /// into a diagnostic with <<.
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3edc8684d0a19..23a8c4f1f7380 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1599,6 +1599,8 @@ DEF_TRAVERSE_DECL(EmptyDecl, {})
 
 DEF_TRAVERSE_DECL(HLSLBufferDecl, {})
 
+DEF_TRAVERSE_DECL(HLSLRootSignatureDecl, {})
+
 DEF_TRAVERSE_DECL(LifetimeExtendedTemporaryDecl, {
   TRY_TO(TraverseStmt(D->getTemporaryExpr()));
 })
diff --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index ea3a0f058a8ed..1917a8ac29f05 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -408,6 +408,7 @@ class TextNodeDumper
   void
   VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
   void VisitHLSLBufferDecl(const HLSLBufferDecl *D);
+  void VisitHLSLRootSignatureDe

[clang] [CIR] Implement foldder for VecExtractOp (PR #139304)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangir

Author: Amr Hesham (AmrDeveloper)


Changes

This change adds a folder for the VecExtractOp

Issue https://github.com/llvm/llvm-project/issues/136487

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


4 Files Affected:

- (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+2) 
- (modified) clang/lib/CIR/Dialect/IR/CIRDialect.cpp (+20) 
- (modified) clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp (+3-2) 
- (added) clang/test/CIR/Transforms/vector-extract-fold.cir (+20) 


``diff
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 7aff5edb88167..f7f84bb715846 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -1995,6 +1995,8 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure,
   let assemblyFormat = [{
 $vec `[` $index `:` type($index) `]` attr-dict `:` qualified(type($vec))
   }];
+
+  let hasFolder = 1;
 }
 
 #endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index b131edaf403ed..9ddb1b1dd60b2 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -1395,6 +1395,26 @@ LogicalResult cir::VecCreateOp::verify() {
   return success();
 }
 
+//===--===//
+// VecExtractOp
+//===--===//
+
+OpFoldResult cir::VecExtractOp::fold(FoldAdaptor adaptor) {
+  const auto vectorAttr =
+  llvm::dyn_cast_if_present(adaptor.getVec());
+  if (!vectorAttr)
+return {};
+
+  const auto indexAttr =
+  llvm::dyn_cast_if_present(adaptor.getIndex());
+  if (!indexAttr)
+return {};
+
+  const mlir::ArrayAttr elements = vectorAttr.getElts();
+  const int64_t index = indexAttr.getSInt();
+  return elements[index];
+}
+
 
//===--===//
 // TableGen'd op method definitions
 
//===--===//
diff --git a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp 
b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
index 3b4c7bc613133..798bc0dab9384 100644
--- a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
@@ -125,9 +125,10 @@ void CIRCanonicalizePass::runOnOperation() {
 assert(!cir::MissingFeatures::complexRealOp());
 assert(!cir::MissingFeatures::complexImagOp());
 assert(!cir::MissingFeatures::callOp());
-// CastOp and UnaryOp are here to perform a manual `fold` in
+// CastOp, UnaryOp and VecExtractOp are here to perform a manual `fold` in
 // applyOpPatternsGreedily.
-if (isa(op))
+if (isa(
+op))
   ops.push_back(op);
   });
 
diff --git a/clang/test/CIR/Transforms/vector-extract-fold.cir 
b/clang/test/CIR/Transforms/vector-extract-fold.cir
new file mode 100644
index 0..5e1d6e1ddb629
--- /dev/null
+++ b/clang/test/CIR/Transforms/vector-extract-fold.cir
@@ -0,0 +1,20 @@
+// RUN: cir-opt %s -cir-canonicalize -o - | FileCheck %s
+
+!s32i = !cir.int
+
+module {
+  cir.func @fold_extract_vector_op_test() {
+%init = cir.alloca !s32i, !cir.ptr, ["e", init]
+%const_vec = cir.const #cir.const_vector<[#cir.int<1> : !s32i, #cir.int<2> 
: !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.vector<4 x !s32i>
+%index = cir.const #cir.int<1> : !s32i
+%ele = cir.vec.extract %const_vec[%index : !s32i] : !cir.vector<4 x !s32i>
+cir.store %ele, %init : !s32i, !cir.ptr
+cir.return
+  }
+
+  // CHECK: %[[INIT:.*]] = cir.alloca !s32i, !cir.ptr, ["e", init]
+  // CHECK: %[[VALUE:.*]] = cir.const #cir.int<2> : !s32i
+  // CHECK: cir.store %[[VALUE]], %[[INIT]] : !s32i, !cir.ptr
+}
+
+

``




https://github.com/llvm/llvm-project/pull/139304
___
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   >