[clang] [llvm] Reland: [llvm][clang] Allocate a new stack instead of spawning a new thread to get more stack space (PR #136046)

2025-04-17 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 -- 
llvm/include/llvm/Support/ProgramStack.h llvm/lib/Support/ProgramStack.cpp 
llvm/unittests/Support/ProgramStackTest.cpp clang/include/clang/Basic/Stack.h 
clang/lib/Basic/Stack.cpp clang/lib/Frontend/CompilerInstance.cpp 
llvm/include/llvm/Support/CrashRecoveryContext.h 
llvm/include/llvm/Support/thread.h llvm/lib/Support/CrashRecoveryContext.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/Stack.cpp b/clang/lib/Basic/Stack.cpp
index 8cbb84943..aa3862a95 100644
--- a/clang/lib/Basic/Stack.cpp
+++ b/clang/lib/Basic/Stack.cpp
@@ -49,10 +49,12 @@ void 
clang::runWithSufficientStackSpaceSlow(llvm::function_ref Diag,
   llvm::CrashRecoveryContext CRC;
   // Preserve the BottomOfStack in case RunSafelyOnNewStack uses split stacks.
   uintptr_t PrevBottom = BottomOfStack;
-  CRC.RunSafelyOnNewStack([&] {
-noteBottomOfStack(true);
-Diag();
-Fn();
-  }, DesiredStackSize);
+  CRC.RunSafelyOnNewStack(
+  [&] {
+noteBottomOfStack(true);
+Diag();
+Fn();
+  },
+  DesiredStackSize);
   BottomOfStack = PrevBottom;
 }
diff --git a/llvm/include/llvm/Support/ProgramStack.h 
b/llvm/include/llvm/Support/ProgramStack.h
index 55964c977..524cdd468 100644
--- a/llvm/include/llvm/Support/ProgramStack.h
+++ b/llvm/include/llvm/Support/ProgramStack.h
@@ -18,8 +18,8 @@
 // and other tooling.
 #if defined(__APPLE__) && defined(__MACH__) && defined(__aarch64__) && 
\
 __has_extension(gnu_asm)
-# define LLVM_HAS_SPLIT_STACKS
-# define LLVM_HAS_SPLIT_STACKS_AARCH64
+#define LLVM_HAS_SPLIT_STACKS
+#define LLVM_HAS_SPLIT_STACKS_AARCH64
 #endif
 
 namespace llvm {
diff --git a/llvm/lib/Support/ProgramStack.cpp 
b/llvm/lib/Support/ProgramStack.cpp
index 66f74ff66..993ceb452 100644
--- a/llvm/lib/Support/ProgramStack.cpp
+++ b/llvm/lib/Support/ProgramStack.cpp
@@ -11,15 +11,15 @@
 #include "llvm/Support/Compiler.h"
 
 #ifdef LLVM_ON_UNIX
-# include  // for getrlimit
+#include  // for getrlimit
 #endif
 
 #ifdef _MSC_VER
-# include   // for _AddressOfReturnAddress
+#include  // for _AddressOfReturnAddress
 #endif
 
 #ifndef LLVM_HAS_SPLIT_STACKS
-# include "llvm/Support/thread.h"
+#include "llvm/Support/thread.h"
 #endif
 
 using namespace llvm;
@@ -65,38 +65,34 @@ void runOnNewStackImpl(void *Stack, void (*Fn)(void *), 
void *Ctx) __asm__(
 //
 // When adding new platforms it may be better to move to a .S file with macros
 // for dealing with platform differences.
-__asm__ (
-".globl  _ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_\n\t"
-".p2align  2\n\t"
-"_ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_:\n\t"
-".cfi_startproc\n\t"
-"mov   x16, sp\n\t"
-"sub   x0, x0, #0x20\n\t"// subtract space from stack
-"stp   xzr, x16, [x0, #0x00]\n\t"// save old sp
-"stp   x29, x30, [x0, #0x10]\n\t"// save fp, lr
-"mov   sp, x0\n\t"   // switch to new stack
-"add   x29, x0, #0x10\n\t"   // switch to new frame
-".cfi_def_cfa w29, 16\n\t"
-".cfi_offset w30, -8\n\t"// lr
-".cfi_offset w29, -16\n\t"   // fp
-
-"mov   x0, x2\n\t"   // Ctx is the only argument
-"blr   x1\n\t"   // call Fn
-
-"ldp   x29, x30, [sp, #0x10]\n\t"// restore fp, lr
-"ldp   xzr, x16, [sp, #0x00]\n\t"// load old sp
-"mov   sp, x16\n\t"
-"ret\n\t"
-".cfi_endproc"
-);
+__asm__(".globl  _ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_\n\t"
+".p2align  2\n\t"
+"_ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_:\n\t"
+".cfi_startproc\n\t"
+"mov   x16, sp\n\t"
+"sub   x0, x0, #0x20\n\t" // subtract space from stack
+"stp   xzr, x16, [x0, #0x00]\n\t" // save old sp
+"stp   x29, x30, [x0, #0x10]\n\t" // save fp, lr
+"mov   sp, x0\n\t"// switch to new stack
+"add   x29, x0, #0x10\n\t"// switch to new frame
+".cfi_def_cfa w29, 16\n\t"
+".cfi_offset w30, -8\n\t"  // lr
+".cfi_offset w29, -16\n\t" // fp
+
+"mov   x0, x2\n\t" // Ctx is the only argument
+"blr   x1\n\t" // call Fn
+
+"ldp   x29, x30, [sp, #0x10]\n\t" // restore fp, lr
+"ldp   xzr, x16, [sp, #0x00]\n\t" // load old sp
+"mov   sp, x16\n\t"
+"ret\n\t"
+".cfi_endproc");
 #endif
 } // namespace llvm
 
 namespace {
 #ifdef LLVM_HAS_SPLIT_STACKS
-void callback(void *Ctx) {
-  (*reinterpret_cast *>(Ctx))();
-}
+void callback(void *Ctx) { (*reinterpret_cast *>(Ctx))(); 
}
 #endif
 } // namespace
 
diff --git a/llvm/unittests/Support/ProgramStackTest.cpp

[clang] [clang] Fix Name Mangling Crashes (PR #134486)

2025-04-17 Thread via cfe-commits

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


[clang] [llvm] [RISCV] Add processor definition for XiangShan-KunMingHu-V2R2 (PR #123193)

2025-04-17 Thread Pengcheng Wang via cfe-commits


@@ -126,6 +126,7 @@ Changes to the PowerPC Backend
 Changes to the RISC-V Backend
 -
 
+

wangpc-pp wrote:

Remove this extra blank line.

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


[clang-tools-extra] [clang-tidy][NFC] fix `clang-tidy` warnings in `clang-tools-extra/clang-tidy` directory (PR #136097)

2025-04-17 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor created 
https://github.com/llvm/llvm-project/pull/136097

Mostly stylistic changes to `clang-tidy` source code.

Command run:
`python3 clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -p build/ -j 
$(nproc) clang-tools-extra/clang-tidy`

>From 479e98e5cc3bfe6992d1aa3ed6a6076b4105dc69 Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Thu, 17 Apr 2025 10:35:14 +0300
Subject: [PATCH] refactor: fix 'clang-tidy' warnings in clang-tidy code

---
 .../clang-tidy/abseil/CleanupCtadCheck.cpp| 10 +-
 .../clang-tidy/bugprone/BranchCloneCheck.cpp  | 10 +-
 .../bugprone/SignalHandlerCheck.cpp   |  2 +-
 .../bugprone/StandaloneEmptyCheck.cpp |  4 +-
 .../bugprone/StringviewNullptrCheck.cpp   | 97 +--
 .../bugprone/TaggedUnionMemberCountCheck.cpp  | 11 +--
 .../clang-tidy/hicpp/NoAssemblerCheck.cpp |  2 +-
 .../misc/ConfusableIdentifierCheck.cpp|  6 +-
 .../ConfusableTable/BuildConfusableTable.cpp  | 24 ++---
 .../clang-tidy/modernize/MacroToEnumCheck.cpp |  6 +-
 .../clang-tidy/objc/AssertEquals.cpp  | 36 +++
 .../performance/MoveConstArgCheck.cpp |  4 +-
 .../portability/StdAllocatorConstCheck.cpp| 14 +--
 .../clang-tidy/tool/ClangTidyMain.cpp |  2 +-
 .../clang-tidy/utils/ExceptionAnalyzer.cpp| 16 +--
 .../clang-tidy/utils/ExprSequence.cpp |  8 +-
 16 files changed, 126 insertions(+), 126 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
index 06f98c76269b5..664ec59997b59 100644
--- a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
@@ -21,9 +21,9 @@ using namespace ::clang::transformer;
 
 namespace clang::tidy::abseil {
 
-RewriteRuleWith CleanupCtadCheckImpl() {
-  auto warning_message = cat("prefer absl::Cleanup's class template argument "
- "deduction pattern in C++17 and higher");
+RewriteRuleWith cleanupCtadCheckImpl() {
+  auto WarningMessage = cat("prefer absl::Cleanup's class template argument "
+"deduction pattern in C++17 and higher");
 
   return makeRule(
   declStmt(hasSingleDecl(varDecl(
@@ -34,10 +34,10 @@ RewriteRuleWith CleanupCtadCheckImpl() {
   .bind("make_cleanup_call")),
   {changeTo(node("auto_type_loc"), cat("absl::Cleanup")),
changeTo(node("make_cleanup_call"), 
cat(callArgs("make_cleanup_call")))},
-  warning_message);
+  WarningMessage);
 }
 
 CleanupCtadCheck::CleanupCtadCheck(StringRef Name, ClangTidyContext *Context)
-: utils::TransformerClangTidyCheck(CleanupCtadCheckImpl(), Name, Context) 
{}
+: utils::TransformerClangTidyCheck(cleanupCtadCheckImpl(), Name, Context) 
{}
 
 } // namespace clang::tidy::abseil
diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index a7e25141b3fe2..a544ef0d9dd04 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -250,10 +250,10 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const 
Stmt *Stmt1,
 
 if (!llvm::all_of(llvm::zip(CompStmt1->body(), CompStmt2->body()),
   [&Ctx, IgnoreSideEffects](
-  std::tuple stmtPair) {
-const Stmt *stmt0 = std::get<0>(stmtPair);
-const Stmt *stmt1 = std::get<1>(stmtPair);
-return isIdenticalStmt(Ctx, stmt0, stmt1,
+  std::tuple StmtPair) {
+const Stmt *Stmt0 = std::get<0>(StmtPair);
+const Stmt *Stmt1 = std::get<1>(StmtPair);
+return isIdenticalStmt(Ctx, Stmt0, Stmt1,
IgnoreSideEffects);
   })) {
   return false;
@@ -477,7 +477,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult 
&Result) {
 
   if (const auto *IS = Result.Nodes.getNodeAs("ifWithDescendantIf")) {
 const Stmt *Then = IS->getThen();
-auto CS = dyn_cast(Then);
+const auto *CS = dyn_cast(Then);
 if (CS && (!CS->body_empty())) {
   const auto *InnerIf = dyn_cast(*CS->body_begin());
   if (InnerIf && isIdenticalStmt(Context, IS->getCond(), 
InnerIf->getCond(),
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
index 27045816a80d3..c066b3e7b19a5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
@@ -301,7 +301,7 @@ bool isCXXOnlyStmt(const Stmt *S) {
 /// It is unspecified which call is found if multiple calls exist, but the 
order
 /// should be deterministic (depend only on the AST).
 Expr *findCa

[clang-tools-extra] [clangd] Header not found error message now contains file path (PR #136096)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




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

Author: Tongsheng Wu (tongshengw)


Changes

IncludeCleaner header not found messages now show file path.

[https://github.com/clangd/clangd/issues/2334](https://github.com/clangd/clangd/issues/2334)

New error messages:
```
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' 
from include  : No such file or directory
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' 
from include "doesntexist.hpp" : No such file or directory
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' 
from include "/path/doesnt/exist" : No such file or directory
```
Old error messages:
```
E[03:34:47.752] IncludeCleaner: Failed to get an entry for resolved path : No 
such file or directory
```

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


1 Files Affected:

- (modified) clang-tools-extra/clangd/IncludeCleaner.cpp (+3-2) 


``diff
diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index e34706172f0bf..dc4c8fc498b1f 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -345,8 +345,9 @@ include_cleaner::Includes convertIncludes(const ParsedAST 
&AST) {
 // which is based on FileManager::getCanonicalName(ParentDir).
 auto FE = SM.getFileManager().getFileRef(Inc.Resolved);
 if (!FE) {
-  elog("IncludeCleaner: Failed to get an entry for resolved path {0}: {1}",
-   Inc.Resolved, FE.takeError());
+  elog("IncludeCleaner: Failed to get an entry for resolved path '{0}' "
+   "from include {1} : {2}",
+   Inc.Resolved, Inc.Written, FE.takeError());
   continue;
 }
 TransformedInc.Resolved = *FE;

``




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


[clang-tools-extra] [clangd] Header not found error message now contains file path (PR #136096)

2025-04-17 Thread Tongsheng Wu via cfe-commits

https://github.com/tongshengw created 
https://github.com/llvm/llvm-project/pull/136096

IncludeCleaner header not found messages now show file path.

[https://github.com/clangd/clangd/issues/2334](https://github.com/clangd/clangd/issues/2334)

New error messages:
```
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' 
from include  : No such file or directory
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' 
from include "doesntexist.hpp" : No such file or directory
E[03:32:43.219] IncludeCleaner: Failed to get an entry for resolved path '' 
from include "/path/doesnt/exist" : No such file or directory
```
Old error messages:
```
E[03:34:47.752] IncludeCleaner: Failed to get an entry for resolved path : No 
such file or directory
```

>From fa866721e59707060165d588d3797acd49792837 Mon Sep 17 00:00:00 2001
From: Tongsheng Wu 
Date: Thu, 17 Apr 2025 03:25:36 -0400
Subject: [PATCH] [clangd] Header not found error message now contains file
 path

---
 clang-tools-extra/clangd/IncludeCleaner.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index e34706172f0bf..dc4c8fc498b1f 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -345,8 +345,9 @@ include_cleaner::Includes convertIncludes(const ParsedAST 
&AST) {
 // which is based on FileManager::getCanonicalName(ParentDir).
 auto FE = SM.getFileManager().getFileRef(Inc.Resolved);
 if (!FE) {
-  elog("IncludeCleaner: Failed to get an entry for resolved path {0}: {1}",
-   Inc.Resolved, FE.takeError());
+  elog("IncludeCleaner: Failed to get an entry for resolved path '{0}' "
+   "from include {1} : {2}",
+   Inc.Resolved, Inc.Written, FE.takeError());
   continue;
 }
 TransformedInc.Resolved = *FE;

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


[clang-tools-extra] [clangd] Header not found error message now contains file path (PR #136096)

2025-04-17 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [flang] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)

2025-04-17 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-flang-driver

Author: FYK (fanju110)


Changes



This patch implements IR-based Profile-Guided Optimization support in Flang 
through the following flags:

- `-fprofile-generate` for instrumentation-based profile generation

- `-fprofile-use=/file` for profile-guided optimization

Resolves #74216 (implements IR PGO support phase)

**Key changes:**

- Frontend flag handling aligned with Clang/GCC semantics

- Instrumentation hooks into LLVM PGO infrastructure

- LIT tests verifying:

- Instrumentation metadata generation

- Profile loading from specified path

- Branch weight attribution (IR checks)

**Tests:**

- Added gcc-flag-compatibility.f90 test module verifying:

-  Flag parsing boundary conditions

-  IR-level profile annotation consistency

-  Profile input path normalization rules

- SPEC2006 benchmark results will be shared in comments

For details on LLVM's PGO framework, refer to [Clang PGO 
Documentation](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization).

This implementation was developed by  [XSCC Compiler 
Team](https://github.com/orgs/OpenXiangShan/teams/xscc).












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


10 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+2-2) 
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+8) 
- (modified) flang/include/flang/Frontend/CodeGenOptions.def (+5) 
- (modified) flang/include/flang/Frontend/CodeGenOptions.h (+49) 
- (modified) flang/lib/Frontend/CompilerInvocation.cpp (+12) 
- (modified) flang/lib/Frontend/FrontendActions.cpp (+54) 
- (modified) flang/test/Driver/flang-f-opts.f90 (+5) 
- (added) flang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext (+19) 
- (added) flang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext 
(+14) 
- (added) flang/test/Profile/gcc-flag-compatibility.f90 (+39) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index affc076a876ad..0b0dbc467c1e0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1756,7 +1756,7 @@ def fmcdc_max_test_vectors_EQ : Joined<["-"], 
"fmcdc-max-test-vectors=">,
   HelpText<"Maximum number of test vectors in MC/DC coverage">,
   MarshallingInfoInt, "0x7FFE">;
 def fprofile_generate : Flag<["-"], "fprofile-generate">,
-Group, Visibility<[ClangOption, CLOption]>,
+Group, Visibility<[ClangOption, CLOption, FlangOption, 
FC1Option]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_generate_EQ : Joined<["-"], "fprofile-generate=">,
 Group, Visibility<[ClangOption, CLOption]>,
@@ -1773,7 +1773,7 @@ def fprofile_use : Flag<["-"], "fprofile-use">, 
Group,
 Visibility<[ClangOption, CLOption]>, Alias;
 def fprofile_use_EQ : Joined<["-"], "fprofile-use=">,
 Group,
-Visibility<[ClangOption, CLOption]>,
+Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>,
 MetaVarName<"">,
 HelpText<"Use instrumentation data for profile-guided optimization. If 
pathname is a directory, it reads from /default.profdata. Otherwise, 
it reads from file .">;
 def fno_profile_instr_generate : Flag<["-"], "fno-profile-instr-generate">,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index a8b4688aed09c..fcdbe8a6aba5a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -882,6 +882,14 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // TODO: Handle interactions between -w, -pedantic, -Wall, -WOption
   Args.AddLastArg(CmdArgs, options::OPT_w);
 
+
+  if (Args.hasArg(options::OPT_fprofile_generate)){ 
+CmdArgs.push_back("-fprofile-generate");
+  }
+  if (const Arg *A = Args.getLastArg(options::OPT_fprofile_use_EQ)) {
+CmdArgs.push_back(Args.MakeArgString(std::string("-fprofile-use=") + 
A->getValue()));
+  }
+
   // Forward flags for OpenMP. We don't do this if the current action is an
   // device offloading action other than OpenMP.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
diff --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flang/Frontend/CodeGenOptions.def
index 57830bf51a1b3..4dec86cd8f51b 100644
--- a/flang/include/flang/Frontend/CodeGenOptions.def
+++ b/flang/include/flang/Frontend/CodeGenOptions.def
@@ -24,6 +24,11 @@ CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option 
specified.
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 
+ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
+ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileNone)
+/// Whether emit extra debug info for sample pgo profile collectio

[clang] [flang] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)

2025-04-17 Thread via cfe-commits

https://github.com/fanju110 created 
https://github.com/llvm/llvm-project/pull/136098



This patch implements IR-based Profile-Guided Optimization support in Flang 
through the following flags:

- `-fprofile-generate` for instrumentation-based profile generation

- `-fprofile-use=/file` for profile-guided optimization

Resolves #74216 (implements IR PGO support phase)

**Key changes:**

- Frontend flag handling aligned with Clang/GCC semantics

- Instrumentation hooks into LLVM PGO infrastructure

- LIT tests verifying:

- Instrumentation metadata generation

- Profile loading from specified path

- Branch weight attribution (IR checks)

**Tests:**

- Added gcc-flag-compatibility.f90 test module verifying:

-  Flag parsing boundary conditions

-  IR-level profile annotation consistency

-  Profile input path normalization rules

- SPEC2006 benchmark results will be shared in comments

For details on LLVM's PGO framework, refer to [Clang PGO 
Documentation](https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization).

This implementation was developed by  [XSCC Compiler 
Team](https://github.com/orgs/OpenXiangShan/teams/xscc).












>From 9494c9752400e4708dbc8b6a5ca4993ea9565e95 Mon Sep 17 00:00:00 2001
From: fanyikang 
Date: Thu, 17 Apr 2025 15:17:07 +0800
Subject: [PATCH] Add support for IR PGO
 (-fprofile-generate/-fprofile-use=/file)

This patch implements IR-based Profile-Guided Optimization support in Flang 
through the following flags:
-fprofile-generate for instrumentation-based profile generation
-fprofile-use=/file for profile-guided optimization

Co-Authored-By: ict-ql <168183727+ict...@users.noreply.github.com>
---
 clang/include/clang/Driver/Options.td |  4 +-
 clang/lib/Driver/ToolChains/Flang.cpp |  8 +++
 .../include/flang/Frontend/CodeGenOptions.def |  5 ++
 flang/include/flang/Frontend/CodeGenOptions.h | 49 +
 flang/lib/Frontend/CompilerInvocation.cpp | 12 +
 flang/lib/Frontend/FrontendActions.cpp| 54 +++
 flang/test/Driver/flang-f-opts.f90|  5 ++
 .../Inputs/gcc-flag-compatibility_IR.proftext | 19 +++
 .../gcc-flag-compatibility_IR_entry.proftext  | 14 +
 flang/test/Profile/gcc-flag-compatibility.f90 | 39 ++
 10 files changed, 207 insertions(+), 2 deletions(-)
 create mode 100644 flang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
 create mode 100644 
flang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
 create mode 100644 flang/test/Profile/gcc-flag-compatibility.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index affc076a876ad..0b0dbc467c1e0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1756,7 +1756,7 @@ def fmcdc_max_test_vectors_EQ : Joined<["-"], 
"fmcdc-max-test-vectors=">,
   HelpText<"Maximum number of test vectors in MC/DC coverage">,
   MarshallingInfoInt, "0x7FFE">;
 def fprofile_generate : Flag<["-"], "fprofile-generate">,
-Group, Visibility<[ClangOption, CLOption]>,
+Group, Visibility<[ClangOption, CLOption, FlangOption, 
FC1Option]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_generate_EQ : Joined<["-"], "fprofile-generate=">,
 Group, Visibility<[ClangOption, CLOption]>,
@@ -1773,7 +1773,7 @@ def fprofile_use : Flag<["-"], "fprofile-use">, 
Group,
 Visibility<[ClangOption, CLOption]>, Alias;
 def fprofile_use_EQ : Joined<["-"], "fprofile-use=">,
 Group,
-Visibility<[ClangOption, CLOption]>,
+Visibility<[ClangOption, CLOption, FlangOption, FC1Option]>,
 MetaVarName<"">,
 HelpText<"Use instrumentation data for profile-guided optimization. If 
pathname is a directory, it reads from /default.profdata. Otherwise, 
it reads from file .">;
 def fno_profile_instr_generate : Flag<["-"], "fno-profile-instr-generate">,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index a8b4688aed09c..fcdbe8a6aba5a 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -882,6 +882,14 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // TODO: Handle interactions between -w, -pedantic, -Wall, -WOption
   Args.AddLastArg(CmdArgs, options::OPT_w);
 
+
+  if (Args.hasArg(options::OPT_fprofile_generate)){ 
+CmdArgs.push_back("-fprofile-generate");
+  }
+  if (const Arg *A = Args.getLastArg(options::OPT_fprofile_use_EQ)) {
+CmdArgs.push_back(Args.MakeArgString(std::string("-fprofile-use=") + 
A->getValue()));
+  }
+
   // Forward flags for OpenMP. We don't do this if the current action is an
   // device offloading action other than OpenMP.
   if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
diff --git a/flang/include/flang/Frontend/CodeGenOptions.def 
b/flang/include/flan

[clang] [flang] Add IR Profile-Guided Optimization (IR PGO) support to the Flang compiler (PR #136098)

2025-04-17 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [clang-format] Fix a bug in parsing C-style cast lambda (PR #136099)

2025-04-17 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/136099

Fix #135959

>From 53033b278f89a508d079614eadd58b103211d5dd Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Thu, 17 Apr 2025 00:35:19 -0700
Subject: [PATCH] [clang-format] Fix a bug in parsing C-style cast lambda

Fix #135959
---
 clang/lib/Format/UnwrappedLineParser.cpp  | 3 ++-
 clang/unittests/Format/TokenAnnotatorTest.cpp | 5 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b9430d4389feb..4442e965e0f51 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2371,7 +2371,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
   if ((Previous && ((Previous->Tok.getIdentifierInfo() &&
  !Previous->isOneOf(tok::kw_return, tok::kw_co_await,
 tok::kw_co_yield, tok::kw_co_return)) 
||
-Previous->closesScope())) ||
+(Previous->closesScope() &&
+ !Previous->endsSequence(tok::r_paren, tok::greater ||
   LeftSquare->isCppStructuredBinding(IsCpp)) {
 return false;
   }
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 2c7319ccefec2..7a07fbd0250be 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2159,6 +2159,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) {
   // FIXME:
   // EXPECT_TOKEN(Tokens[13], tok::l_paren, TT_LambdaDefinitionLParen);
   EXPECT_TOKEN(Tokens[17], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("auto foo{(std::function)[] { return 0; }};");
+  ASSERT_EQ(Tokens.size(), 23u) << Tokens;
+  EXPECT_TOKEN(Tokens[13], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[15], tok::l_brace, TT_LambdaLBrace);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsFunctionAnnotations) {

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


[clang] [clang-format] Fix a bug in parsing C-style cast lambda (PR #136099)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fix #135959

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


2 Files Affected:

- (modified) clang/lib/Format/UnwrappedLineParser.cpp (+2-1) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+5) 


``diff
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b9430d4389feb..4442e965e0f51 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2371,7 +2371,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
   if ((Previous && ((Previous->Tok.getIdentifierInfo() &&
  !Previous->isOneOf(tok::kw_return, tok::kw_co_await,
 tok::kw_co_yield, tok::kw_co_return)) 
||
-Previous->closesScope())) ||
+(Previous->closesScope() &&
+ !Previous->endsSequence(tok::r_paren, tok::greater ||
   LeftSquare->isCppStructuredBinding(IsCpp)) {
 return false;
   }
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 2c7319ccefec2..7a07fbd0250be 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2159,6 +2159,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) {
   // FIXME:
   // EXPECT_TOKEN(Tokens[13], tok::l_paren, TT_LambdaDefinitionLParen);
   EXPECT_TOKEN(Tokens[17], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("auto foo{(std::function)[] { return 0; }};");
+  ASSERT_EQ(Tokens.size(), 23u) << Tokens;
+  EXPECT_TOKEN(Tokens[13], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[15], tok::l_brace, TT_LambdaLBrace);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsFunctionAnnotations) {

``




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


[clang] [llvm] [RISCV] Add processor definition for XiangShan-KunMingHu-V2R2 (PR #123193)

2025-04-17 Thread Pengcheng Wang via cfe-commits


@@ -558,6 +558,34 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
 
+def XIANGSHAN_KUNMINGHU : RISCVProcessorModel<"xiangshan-kunminghu",
+  NoSchedModel,
+  !listconcat(RVA23S64Features,
+  [FeatureStdExtZicsr,

wangpc-pp wrote:

Zicsr is in `RVA23S64Features` already.

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


[clang] [clang][bytecode] Enter a non-constant context when revisiting (PR #136104)

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

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/136104

>From 33e4c2f88d8446604c091002c1992b097e3e477c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 17 Apr 2025 09:38:57 +0200
Subject: [PATCH] [clang][bytecode] Enter a non-constant context when
 revisiting

Otherwise, things like __builtin_is_constant_evaluated() return
the wrong value.
---
 clang/lib/AST/ByteCode/Compiler.cpp| 5 +
 clang/lib/AST/ByteCode/Interp.h| 9 +
 clang/lib/AST/ByteCode/InterpState.h   | 2 +-
 clang/lib/AST/ByteCode/Opcodes.td  | 3 +++
 clang/test/AST/ByteCode/builtin-constant-p.cpp | 8 
 5 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 157e306e5cdb3..d3eabc513a9ac 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6466,8 +6466,13 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
 
   // In case we need to re-visit a declaration.
   auto revisit = [&](const VarDecl *VD) -> bool {
+if (!this->emitPushCC(VD->hasConstantInitialization(), E))
+  return false;
 auto VarState = this->visitDecl(VD, /*IsConstexprUnknown=*/true);
 
+if (!this->emitPopCC(E))
+  return false;
+
 if (VarState.notCreated())
   return true;
 if (!VarState)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index bd58c2a88e9d9..49e2326186bf8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2848,6 +2848,15 @@ inline bool EndSpeculation(InterpState &S, CodePtr OpPC) 
{
   return true;
 }
 
+inline bool PushCC(InterpState &S, CodePtr OpPC, bool Value) {
+  S.ConstantContextOverride = Value;
+  return true;
+}
+inline bool PopCC(InterpState &S, CodePtr OpPC) {
+  S.ConstantContextOverride = std::nullopt;
+  return true;
+}
+
 /// Do nothing and just abort execution.
 inline bool Error(InterpState &S, CodePtr OpPC) { return false; }
 
diff --git a/clang/lib/AST/ByteCode/InterpState.h 
b/clang/lib/AST/ByteCode/InterpState.h
index 74001b80d9c00..528c1a24e7b05 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -127,7 +127,6 @@ class InterpState final : public State, public SourceMapper 
{
   SourceMapper *M;
   /// Allocator used for dynamic allocations performed via the program.
   DynamicAllocator Alloc;
-  std::optional ConstantContextOverride;
 
 public:
   /// Reference to the module containing all bytecode.
@@ -147,6 +146,7 @@ class InterpState final : public State, public SourceMapper 
{
   /// Things needed to do speculative execution.
   SmallVectorImpl *PrevDiags = nullptr;
   unsigned SpeculationDepth = 0;
+  std::optional ConstantContextOverride;
 
   llvm::SmallVector<
   std::pair>
diff --git a/clang/lib/AST/ByteCode/Opcodes.td 
b/clang/lib/AST/ByteCode/Opcodes.td
index 5a9079fea0846..8451e54ad0c41 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -872,3 +872,6 @@ def GetTypeidPtr : Opcode { let Args = [ArgTypePtr]; }
 def DiagTypeid : Opcode;
 
 def CheckDestruction : Opcode;
+
+def PushCC : Opcode { let Args = [ArgBool]; }
+def PopCC : Opcode;
diff --git a/clang/test/AST/ByteCode/builtin-constant-p.cpp 
b/clang/test/AST/ByteCode/builtin-constant-p.cpp
index ed9e606ed16aa..f5b16761bfdc9 100644
--- a/clang/test/AST/ByteCode/builtin-constant-p.cpp
+++ b/clang/test/AST/ByteCode/builtin-constant-p.cpp
@@ -121,3 +121,11 @@ constexpr int mutate6(bool mutate) {
 static_assert(mutate6(false) == 11);
 static_assert(mutate6(true) == 21); // ref-error {{static assertion failed}} \
 // ref-note {{evaluates to '10 == 21'}}
+
+#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+void g() {
+  /// f will be revisited when evaluating the static_assert, since it's
+  /// a local variable. But it should be visited in a non-constant context.
+  const float f = __builtin_is_constant_evaluated();
+  static_assert(fold(f == 0.0f));
+}

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


[clang-tools-extra] [clangd] Improve `BlockEnd` inlayhint presentation (PR #136106)

2025-04-17 Thread via cfe-commits

https://github.com/MythreyaK created 
https://github.com/llvm/llvm-project/pull/136106

Previous iteration of this PR was 
[here](https://github.com/llvm/llvm-project/pull/72345). I retained their first 
commit as-is, rebased it, and added my changes based on the comments in the 
thread 
[here](https://github.com/llvm/llvm-project/pull/72345#issuecomment-1826997798).

[Related issue](https://github.com/clangd/clangd/issues/1807). 

I am working on adding tests, but wanted to get an initial review to make sure 
I am on the right track. 

>From a0e3a33eda624bbebd436d6ac97a18348be39e7c Mon Sep 17 00:00:00 2001
From: daiyousei-qz 
Date: Tue, 14 Nov 2023 20:42:10 -0800
Subject: [PATCH 1/2] Improve BlockEnd presentation including: 1. Explicitly
 state a function call 2. Print literal nullptr 3. Escape for abbreviated
 string 4. Adjust min line limit to 10

---
 clang-tools-extra/clangd/InlayHints.cpp | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 1b1bcf78c9855..b1e3bd97d4fd9 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -112,7 +112,9 @@ std::string summarizeExpr(const Expr *E) {
   return getSimpleName(*E->getFoundDecl()).str();
 }
 std::string VisitCallExpr(const CallExpr *E) {
-  return Visit(E->getCallee());
+  std::string Result = Visit(E->getCallee());
+  Result += E->getNumArgs() == 0 ? "()" : "(...)";
+  return Result;
 }
 std::string
 VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
@@ -147,6 +149,9 @@ std::string summarizeExpr(const Expr *E) {
 }
 
 // Literals are just printed
+std::string VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+  return "nullptr";
+}
 std::string VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
   return E->getValue() ? "true" : "false";
 }
@@ -165,12 +170,14 @@ std::string summarizeExpr(const Expr *E) {
   std::string Result = "\"";
   if (E->containsNonAscii()) {
 Result += "...";
-  } else if (E->getLength() > 10) {
-Result += E->getString().take_front(7);
-Result += "...";
   } else {
 llvm::raw_string_ostream OS(Result);
-llvm::printEscapedString(E->getString(), OS);
+if (E->getLength() > 10) {
+  llvm::printEscapedString(E->getString().take_front(7), OS);
+  Result += "...";
+} else {
+  llvm::printEscapedString(E->getString(), OS);
+}
   }
   Result.push_back('"');
   return Result;
@@ -1120,7 +1127,7 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 2;
+constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =

>From 755e6a3876a752df0c2ee1532351a6cd1f50c4a0 Mon Sep 17 00:00:00 2001
From: Mythreya 
Date: Thu, 17 Apr 2025 01:28:53 -0700
Subject: [PATCH 2/2] Add `InlayHintOptions`

---
 clang-tools-extra/clangd/InlayHints.cpp | 16 ++--
 clang-tools-extra/clangd/InlayHints.h   |  8 +++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index b1e3bd97d4fd9..298e19d7fe41d 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -415,12 +415,14 @@ struct Callee {
 class InlayHintVisitor : public RecursiveASTVisitor {
 public:
   InlayHintVisitor(std::vector &Results, ParsedAST &AST,
-   const Config &Cfg, std::optional RestrictRange)
+   const Config &Cfg, std::optional RestrictRange,
+   InlayHintOptions HintOptions)
   : Results(Results), AST(AST.getASTContext()), Tokens(AST.getTokens()),
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()),
+HintOptions(HintOptions) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, &Invalid);
@@ -1127,7 +1129,6 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
   // Otherwise, the hint shouldn't be shown.
   std::optional computeBlockEndHintRange(SourceRange BraceRange,
 StringRef OptionalPunctuation) 
{
-constexpr unsigned HintMinLineLimit = 10;
 
 auto &SM = AST.getSourceManager();
 auto [BlockBeginFileId, BlockBeginOffset] =
@@ -1155,7 +11

[clang] [llvm] [RISCV] Add processor definition for XiangShan-KunMingHu-V2R2 (PR #123193)

2025-04-17 Thread via cfe-commits

https://github.com/liliumShade updated 
https://github.com/llvm/llvm-project/pull/123193

>From 08f81150949fb97411d6cc6e58c2b9f293cc1bf5 Mon Sep 17 00:00:00 2001
From: Chyaka 
Date: Thu, 16 Jan 2025 19:02:54 +0800
Subject: [PATCH 1/5] [RISCV] Add processor definition for
 XiangShan-KunMingHu-V2R2

Co-Authored-By: Shenglin Tang 
Co-Authored-By: Xu, Zefan 
Co-Authored-By: Tang Haojin 
---
 clang/test/Driver/riscv-cpus.c| 47 +++
 .../test/Misc/target-invalid-cpu-note/riscv.c |  2 +
 llvm/docs/ReleaseNotes.md |  1 +
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 31 
 4 files changed, 81 insertions(+)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index e97b6940662d9..b9b27eec61c6f 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -31,6 +31,53 @@
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-feature" "+zks" "-target-feature" 
"+zksed" "-target-feature" "+zksh" "-target-feature" "+svinval"
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=xiangshan-kunminghu | 
FileCheck -check-prefix=MCPU-XIANGSHAN-KUNMINGHU %s
+// MCPU-XIANGSHAN-KUNMINGHU: "-nostdsysteminc" "-target-cpu" 
"xiangshan-kunminghu"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+m"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+a"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+f"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+d"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+c"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+b"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+v"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zic64b" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicbom" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicbop" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicboz" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+ziccif" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicclsm" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+ziccrse" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicntr" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicond" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicsr" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zacas" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zfh" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zba" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbb" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbc"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbkb" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbkc" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbkx" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbs"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zkn" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zks" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zvfh"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zvl128b"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+smcsrind"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+smdbltrp"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+smmpm"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+smnpm"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+smrnmi"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+smstateen"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+sscsrind"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+ssdbltrp"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+sspm"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+ssstrict"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "-zawrs" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "-ziccamoa" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "-zihintntl" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-abi" "lp64d"
+
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=spacemit-x60 | FileCheck 
-check-prefix=MCPU-SPACEMIT-X60 %s
 // MCPU-SPACEMIT-X60: "-nostdsysteminc" "-target-cpu" "spacemit-x60"
 // MCPU-SPACEMIT-X60-SAME: "-target-feature" "+m"
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c 
b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index fb54dcb5b3a93..e9ed7ff476477 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -45,6 +45,7 @@
 // RISCV64-SAME: {{^}}, syntacore-scr7
 // RISCV64-SAME: {{^}}, tt-ascalon-d8
 // RISCV64-SAME: {{^}}, veyron-v1
+// RISCV64-SAME: {{^}}, xiangshan-kunminghu
 // RISCV64-SAME: {{^}}, xiangshan-nanhu
 // RISCV64-SAME: {{$}}
 
@@ -94,6 +95,7 @@
 // TUNE-RISCV64-SAME: {{^}}, syntacore-scr7
 // TUNE-RISCV64-SAME: {{^}}, tt-ascalon-d8
 // TUNE-RISCV64-SAME: {{^}}, veyron-v1
+// TUNE-RISCV64-SAME: {{^}}, xiangshan-kunminghu
 // TUNE-RISCV64-SAME: {{^

[clang] [HLSL] Add a warning for implicit bindings (PR #135909)

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

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


[clang] [clang-format] Fix a bug in FormatToken::isObjCAccessSpecifier() (PR #136109)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fix #136092

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


2 Files Affected:

- (modified) clang/lib/Format/FormatToken.h (+3-2) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+6) 


``diff
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 87e16397ad069..946cd7b81587f 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -706,8 +706,9 @@ struct FormatToken {
   [[nodiscard]] bool isTypeOrIdentifier(const LangOptions &LangOpts) const;
 
   bool isObjCAccessSpecifier() const {
-return Next && Next->isOneOf(tok::objc_public, tok::objc_protected,
- tok::objc_package, tok::objc_private);
+return is(tok::at) && Next &&
+   Next->isOneOf(tok::objc_public, tok::objc_protected,
+ tok::objc_package, tok::objc_private);
   }
 
   /// Returns whether \p Tok is ([{ or an opening < of a template or in
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 2c7319ccefec2..0f144d043667e 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3963,6 +3963,12 @@ TEST_F(TokenAnnotatorTest, UTF8StringLiteral) {
   EXPECT_TOKEN(Tokens[1], tok::utf8_string_literal, TT_Unknown);
 }
 
+TEST_F(TokenAnnotatorTest, IdentifierPackage) {
+  auto Tokens = annotate("auto package;");
+  ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang

``




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


[clang] [llvm] [MIPS] Add FeatureMSA to i6400 and i6500 cores (PR #134985)

2025-04-17 Thread Mallikarjuna Gouda via cfe-commits

https://github.com/mgoudar updated 
https://github.com/llvm/llvm-project/pull/134985

>From 36a78bb9fe38781fa8ea126aeae5b7ed48140651 Mon Sep 17 00:00:00 2001
From: Mallikarjuna Gouda 
Date: Tue, 1 Apr 2025 12:35:27 +0530
Subject: [PATCH 1/3] [MIPS] Add FeatureMSA to i6400 and i6500 cores

i6400 and i6500 cores support MIPS SIMD Architecture (MSA) instructions
---
 llvm/lib/Target/Mips/Mips.td|  4 +-
 llvm/test/CodeGen/Mips/msa/i6500.ll | 69 +
 2 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/msa/i6500.ll

diff --git a/llvm/lib/Target/Mips/Mips.td b/llvm/lib/Target/Mips/Mips.td
index 43a5ae8133d83..ca3df1fd94144 100644
--- a/llvm/lib/Target/Mips/Mips.td
+++ b/llvm/lib/Target/Mips/Mips.td
@@ -242,11 +242,11 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
 // same CPU architecture.
 def ImplI6400
 : SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400",
-   "MIPS I6400 Processor", [FeatureMips64r6]>;
+   "MIPS I6400 Processor", [FeatureMips64r6, FeatureMSA]>;
 
 def ImplI6500
 : SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500",
-   "MIPS I6500 Processor", [FeatureMips64r6]>;
+   "MIPS I6500 Processor", [FeatureMips64r6, FeatureMSA]>;
 
 class Proc Features>
  : ProcessorModel;
diff --git a/llvm/test/CodeGen/Mips/msa/i6500.ll 
b/llvm/test/CodeGen/Mips/msa/i6500.ll
new file mode 100644
index 0..b8404ab72fea3
--- /dev/null
+++ b/llvm/test/CodeGen/Mips/msa/i6500.ll
@@ -0,0 +1,69 @@
+; Test the MSA intrinsics that are encoded with the SPECIAL instruction format.
+
+; RUN: llc -mtriple=mips-elf -mcpu=i6500 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS32
+; RUN: llc -mtriple=mips64-elf -mcpu=i6500 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS64
+; RUN: llc -mtriple=mips-elf -mcpu=i6500 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS32
+; RUN: llc -mtriple=mips64-elf -mcpu=i6500 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS64
+; RUN: llc -mtriple=mips64-elf -mcpu=i6500 -mattr=-msa < %s | \
+; RUN:   FileCheck %s --check-prefix=NO-DSLA
+; RUN: llc -mtriple=mips-elf -mcpu=i6400 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS32
+; RUN: llc -mtriple=mips64-elf -mcpu=i6400 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS64
+; RUN: llc -mtriple=mips-elf -mcpu=i6400 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS32
+; RUN: llc -mtriple=mips64-elf -mcpu=i6400 < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS64
+; RUN: llc -mtriple=mips64-elf -mcpu=i6400 -mattr=-msa < %s | \
+; RUN:   FileCheck %s --check-prefix=NO-DSLA
+
+define i32 @llvm_mips_lsa_test(i32 %a, i32 %b) nounwind {
+entry:
+  %0 = tail call i32 @llvm.mips.lsa(i32 %a, i32 %b, i32 2)
+  ret i32 %0
+}
+
+declare i32 @llvm.mips.lsa(i32, i32, i32) nounwind
+
+; MIPS32: llvm_mips_lsa_test:
+; MIPS32: lsa {{\$[0-9]+}}, $5, $4, 2
+; MIPS32: .size llvm_mips_lsa_test
+
+define i32 @lsa_test(i32 %a, i32 %b) nounwind {
+entry:
+  %0 = shl i32 %b, 2
+  %1 = add i32 %a, %0
+  ret i32 %1
+}
+
+; MIPS32: lsa_test:
+; MIPS32: lsa {{\$[0-9]+}}, $5, $4, 2
+; MIPS32: .size lsa_test
+
+define i64 @llvm_mips_dlsa_test(i64 %a, i64 %b) nounwind {
+entry:
+  %0 = tail call i64 @llvm.mips.dlsa(i64 %a, i64 %b, i32 2)
+  ret i64 %0
+}
+
+declare i64 @llvm.mips.dlsa(i64, i64, i32) nounwind
+
+; MIPS64: llvm_mips_dlsa_test:
+; MIPS64: dlsa {{\$[0-9]+}}, $5, $4, 2
+; MIPS64: .size llvm_mips_dlsa_test
+; NO-DSLA-NOT: dlsa {{\$[0-9]+}}, $5, $4, 2
+define i64 @dlsa_test(i64 %a, i64 %b) nounwind {
+entry:
+  %0 = shl i64 %b, 2
+  %1 = add i64 %a, %0
+  ret i64 %1
+}
+
+; MIPS64: dlsa_test:
+; MIPS64: dlsa {{\$[0-9]+}}, $5, $4, 2
+; MIPS64: .size dlsa_test
+; NO-DSLA-NOT: dlsa {{\$[0-9]+}}, $5, $4, 2

>From 4ed92eba68d556a0b2badbde1a39e35349a38d98 Mon Sep 17 00:00:00 2001
From: Mallikarjuna Gouda 
Date: Thu, 10 Apr 2025 10:47:30 +0530
Subject: [PATCH 2/3] Update test case with update_llc_test_checks.py

---
 llvm/test/CodeGen/Mips/msa/i6500.ll | 105 
 1 file changed, 62 insertions(+), 43 deletions(-)

diff --git a/llvm/test/CodeGen/Mips/msa/i6500.ll 
b/llvm/test/CodeGen/Mips/msa/i6500.ll
index b8404ab72fea3..779dbf1b1c165 100644
--- a/llvm/test/CodeGen/Mips/msa/i6500.ll
+++ b/llvm/test/CodeGen/Mips/msa/i6500.ll
@@ -1,69 +1,88 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; Test the MSA intrinsics that are encoded with the SPECIAL instruction format.
 
 ; RUN: llc -mtriple=mips-elf -mcpu=i6500 < %s | \
 ; RUN:   FileCheck %s --check-prefix=MIPS32
-; RUN: llc -mtriple=mips64-elf -mcpu=i6500 < %s | \
-; RUN:   FileCheck %s --check-prefix=MIPS64
-; RUN: llc -mtriple=mips-elf -mcpu=i6500 < %s | \
-; RUN:   FileCheck %s --check-prefix=MIPS32
+; RUN: llc -mtriple=mips-elf -mcpu=i6500 -mattr=-msa < %s | \
+; RUN:   FileCheck %s --check-prefix=MIPS32-NO-LSA
+
 ; RUN: ll

[clang] 2a91d04 - Revert "[Clang] Bypass TAD during overload resolution if a perfect match exists" (#136113)

2025-04-17 Thread via cfe-commits

Author: cor3ntin
Date: 2025-04-17T11:00:56+02:00
New Revision: 2a91d04b022f1295fe2057bc88dc89987e6a6e04

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

LOG: Revert "[Clang] Bypass TAD during overload resolution if a perfect match 
exists" (#136113)

Reverts llvm/llvm-project#136018

Still some bots failing
https://lab.llvm.org/buildbot/#/builders/52/builds/7643

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp

clang/test/CXX/temp/temp.constr/temp.constr.atomic/constrant-satisfaction-conversions.cpp
clang/test/SemaCUDA/function-overload.cu
clang/test/SemaCXX/implicit-member-functions.cpp
clang/test/SemaTemplate/instantiate-function-params.cpp
clang/test/Templight/templight-empty-entries-fix.cpp

Removed: 
clang/test/SemaCXX/overload-resolution-deferred-templates.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc36962b317e8..4f640697e1817 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -96,12 +96,6 @@ C++ Language Changes
   asm((std::string_view("nop")) ::: (std::string_view("memory")));
 }
 
-- Clang now implements the changes to overload resolution proposed by section 
1 and 2 of
-  `P3606 `_. If a non-template candidate exists in 
an overload set that is
-  a perfect match (all conversion sequences are identity conversions) template 
candidates are not instantiated.
-  Diagnostics that would have resulted from the instantiation of these 
template candidates are no longer
-  produced. This aligns Clang closer to the behavior of GCC, and fixes 
(#GH62096), (#GH74581), and (#GH74581).
-
 C++2c Feature Support
 ^
 

diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e667147bfac7e..6e08762dcc6d7 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -407,26 +407,6 @@ class Sema;
  Third == ICK_Identity;
 }
 
-/// A conversion sequence is perfect if it is an identity conversion and
-/// the type of the source is the same as the type of the target.
-bool isPerfect(const ASTContext &C) const {
-  if (!isIdentityConversion())
-return false;
-  // If we are not performing a reference binding, we can skip comparing
-  // the types, which has a noticeable performance impact.
-  if (!ReferenceBinding) {
-// The types might 
diff er if there is an array-to-pointer conversion
-// or lvalue-to-rvalue conversion.
-assert(First || C.hasSameUnqualifiedType(getFromType(), getToType(2)));
-return true;
-  }
-  if (!C.hasSameType(getFromType(), getToType(2)))
-return false;
-  if (BindsToRvalue && IsLvalueReference)
-return false;
-  return true;
-}
-
 ImplicitConversionRank getRank() const;
 NarrowingKind
 getNarrowingKind(ASTContext &Context, const Expr *Converted,
@@ -763,12 +743,6 @@ class Sema;
   Standard.setAllToTypes(T);
 }
 
-/// A conversion sequence is perfect if it is an identity conversion and
-/// the type of the source is the same as the type of the target.
-bool isPerfect(const ASTContext &C) const {
-  return isStandard() && Standard.isPerfect(C);
-}
-
 // True iff this is a conversion sequence from an initializer list to an
 // array or std::initializer.
 bool hasInitializerListContainerType() const {
@@ -965,10 +939,6 @@ class Sema;
 LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
 unsigned IsADLCandidate : 1;
 
-/// Whether FinalConversion has been set.
-LLVM_PREFERRED_TYPE(bool)
-unsigned HasFinalConversion : 1;
-
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
@@ -1009,20 +979,6 @@ class Sema;
   return false;
 }
 
-// An overload is a perfect match if the conversion
-// sequences for each argument are perfect.
-bool isPerfectMatch(const ASTContext &Ctx) const {
-  if (!Viable)
-return false;
-  for (const auto &C : Conversions) {
-if (!C.isInitialized() || !C.isPerfect(Ctx))
-  return false;
-  }
-  if (HasFinalConversion)
-return FinalConversion.isPerfect(Ctx);
-  return true;
-}
-
 bool TryToFixBadConversion(unsigned Idx, Sema &S) {
   bool CanFix = Fix.tryToFixConversion(
   Conversions[Idx].Bad.FromExpr,
@@ -1056,67 +1012,8 @@ class Sema;
 : IsSurrogate(fa

[clang] Revert "[Clang] Bypass TAD during overload resolution if a perfect match exists" (PR #136113)

2025-04-17 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/136113

Reverts llvm/llvm-project#136018

Still some bots failing https://lab.llvm.org/buildbot/#/builders/52/builds/7643

>From 61705818e19b6a2e35a4a65f1104d26ce0c1929a Mon Sep 17 00:00:00 2001
From: cor3ntin 
Date: Thu, 17 Apr 2025 11:00:23 +0200
Subject: [PATCH] =?UTF-8?q?Revert=20"[Clang]=20Bypass=20TAD=20during=20ove?=
 =?UTF-8?q?rload=20resolution=20if=20a=20perfect=20match=20exis=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 377ec36b323ea99ca316cb5cf79c0a0c93eebc37.
---
 clang/docs/ReleaseNotes.rst   |   6 -
 clang/include/clang/Sema/Overload.h   | 232 +---
 clang/lib/Sema/SemaCodeComplete.cpp   |   6 +-
 clang/lib/Sema/SemaInit.cpp   |  18 +-
 clang/lib/Sema/SemaOverload.cpp   | 532 --
 clang/lib/Sema/SemaTemplateDeduction.cpp  |   4 +-
 .../constrant-satisfaction-conversions.cpp|   8 +-
 clang/test/SemaCUDA/function-overload.cu  |   3 +
 .../SemaCXX/implicit-member-functions.cpp |  21 +-
 ...overload-resolution-deferred-templates.cpp | 200 ---
 .../instantiate-function-params.cpp   |   7 +-
 .../Templight/templight-empty-entries-fix.cpp | 126 +++--
 12 files changed, 219 insertions(+), 944 deletions(-)
 delete mode 100644 
clang/test/SemaCXX/overload-resolution-deferred-templates.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc36962b317e8..4f640697e1817 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -96,12 +96,6 @@ C++ Language Changes
   asm((std::string_view("nop")) ::: (std::string_view("memory")));
 }
 
-- Clang now implements the changes to overload resolution proposed by section 
1 and 2 of
-  `P3606 `_. If a non-template candidate exists in 
an overload set that is
-  a perfect match (all conversion sequences are identity conversions) template 
candidates are not instantiated.
-  Diagnostics that would have resulted from the instantiation of these 
template candidates are no longer
-  produced. This aligns Clang closer to the behavior of GCC, and fixes 
(#GH62096), (#GH74581), and (#GH74581).
-
 C++2c Feature Support
 ^
 
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e667147bfac7e..6e08762dcc6d7 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -407,26 +407,6 @@ class Sema;
  Third == ICK_Identity;
 }
 
-/// A conversion sequence is perfect if it is an identity conversion and
-/// the type of the source is the same as the type of the target.
-bool isPerfect(const ASTContext &C) const {
-  if (!isIdentityConversion())
-return false;
-  // If we are not performing a reference binding, we can skip comparing
-  // the types, which has a noticeable performance impact.
-  if (!ReferenceBinding) {
-// The types might differ if there is an array-to-pointer conversion
-// or lvalue-to-rvalue conversion.
-assert(First || C.hasSameUnqualifiedType(getFromType(), getToType(2)));
-return true;
-  }
-  if (!C.hasSameType(getFromType(), getToType(2)))
-return false;
-  if (BindsToRvalue && IsLvalueReference)
-return false;
-  return true;
-}
-
 ImplicitConversionRank getRank() const;
 NarrowingKind
 getNarrowingKind(ASTContext &Context, const Expr *Converted,
@@ -763,12 +743,6 @@ class Sema;
   Standard.setAllToTypes(T);
 }
 
-/// A conversion sequence is perfect if it is an identity conversion and
-/// the type of the source is the same as the type of the target.
-bool isPerfect(const ASTContext &C) const {
-  return isStandard() && Standard.isPerfect(C);
-}
-
 // True iff this is a conversion sequence from an initializer list to an
 // array or std::initializer.
 bool hasInitializerListContainerType() const {
@@ -965,10 +939,6 @@ class Sema;
 LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
 unsigned IsADLCandidate : 1;
 
-/// Whether FinalConversion has been set.
-LLVM_PREFERRED_TYPE(bool)
-unsigned HasFinalConversion : 1;
-
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
@@ -1009,20 +979,6 @@ class Sema;
   return false;
 }
 
-// An overload is a perfect match if the conversion
-// sequences for each argument are perfect.
-bool isPerfectMatch(const ASTContext &Ctx) const {
-  if (!Viable)
-return false;
-  for (const auto &C : Conversions) {
-if (!C.isInitialized() || !C.isPerfect(Ctx))
-  return false;
-  }
-  if (HasFinalConversion)
-return FinalConversion.isPerfect(Ctx);

[clang] [llvm] [MIPS] Add FeatureMSA to i6400 and i6500 cores (PR #134985)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Mallikarjuna Gouda (mgoudar)


Changes

Enable 'FeatureMSA' for MIPS i6400 and i6500 cpu.

MIPS i6400 and i6500 cores implements MSA (MIPS SIMD ARCHITECTURE) by default.

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


2 Files Affected:

- (added) clang/test/Driver/mips-cpus.c (+9) 
- (modified) llvm/lib/Target/Mips/Mips.td (+2-2) 


``diff
diff --git a/clang/test/Driver/mips-cpus.c b/clang/test/Driver/mips-cpus.c
new file mode 100644
index 0..effb5ef60166a
--- /dev/null
+++ b/clang/test/Driver/mips-cpus.c
@@ -0,0 +1,9 @@
+// Check target CPUs are correctly passed.
+
+// RUN: %clang --target=mips64 -### -c %s 2>&1 -mcpu=i6400 -mmsa | FileCheck 
-check-prefix=MCPU-I6400 %s
+// MCPU-I6400: "-target-cpu" "i6400"
+// MCPU-I6400-SAME: "-target-feature" "+msa"
+
+// RUN: %clang --target=mips64 -### -c %s 2>&1 -mcpu=i6500 -mmsa | FileCheck 
-check-prefix=MCPU-I6500 %s
+// MCPU-I6500: "-target-cpu" "i6500"
+// MCPU-I6500-SAME: "-target-feature" "+msa"
diff --git a/llvm/lib/Target/Mips/Mips.td b/llvm/lib/Target/Mips/Mips.td
index 43a5ae8133d83..ca3df1fd94144 100644
--- a/llvm/lib/Target/Mips/Mips.td
+++ b/llvm/lib/Target/Mips/Mips.td
@@ -242,11 +242,11 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
 // same CPU architecture.
 def ImplI6400
 : SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400",
-   "MIPS I6400 Processor", [FeatureMips64r6]>;
+   "MIPS I6400 Processor", [FeatureMips64r6, FeatureMSA]>;
 
 def ImplI6500
 : SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500",
-   "MIPS I6500 Processor", [FeatureMips64r6]>;
+   "MIPS I6500 Processor", [FeatureMips64r6, FeatureMSA]>;
 
 class Proc Features>
  : ProcessorModel;

``




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


[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

2025-04-17 Thread Theo de Magalhaes via cfe-commits

https://github.com/theomagellan updated 
https://github.com/llvm/llvm-project/pull/136062

>From 842f0fbed0043ad0aa1679d8a30bc13d64eb25cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20de=20Magalhaes?= 
Date: Thu, 17 Apr 2025 01:45:12 +0200
Subject: [PATCH] fix(ms_struct): bitfield padding warning presents padding to
 exact bit count

---
 clang/lib/AST/RecordLayoutBuilder.cpp   |  4 +++-
 clang/test/SemaCXX/windows-Wpadded-bitfield.cpp | 15 +++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index ea353f88a8aec..ca08e186f4ff2 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1538,6 +1538,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
   bool AlignIsRequired = FieldInfo.isAlignRequired();
+  unsigned char PaddingInLastUnit = 0;
 
   // UnfilledBitsInLastUnit is the difference between the end of the
   // last allocated bitfield (i.e. the first bit offset available for
@@ -1610,6 +1611,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   if (!LastBitfieldStorageUnitSize && !FieldSize)
 FieldAlign = 1;
 
+  PaddingInLastUnit = UnfilledBitsInLastUnit;
   UnfilledBitsInLastUnit = 0;
   LastBitfieldStorageUnitSize = 0;
 }
@@ -1706,7 +1708,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const 
FieldDecl *D) {
   // For purposes of diagnostics, we're going to simultaneously
   // compute the field offsets that we would have used if we weren't
   // adding any alignment padding or if the field weren't packed.
-  uint64_t UnpaddedFieldOffset = FieldOffset;
+  uint64_t UnpaddedFieldOffset = FieldOffset - PaddingInLastUnit;
   uint64_t UnpackedFieldOffset = FieldOffset;
 
   // Check if we need to add padding to fit the bitfield within an
diff --git a/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp 
b/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
index ee5a57124eca5..0b88b4c170617 100644
--- a/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
+++ b/clang/test/SemaCXX/windows-Wpadded-bitfield.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -verify -Wpadded 
%s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -Wpadded %s
 
 struct __attribute__((ms_struct)) BitfieldStruct { // expected-warning 
{{padding size of 'BitfieldStruct' with 3 bytes to alignment boundary}}
   char c : 1;
@@ -24,9 +25,23 @@ struct __attribute__((ms_struct)) DifferentUnitSizeBitfield 
{ // expected-warnin
   char i; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' 
with 31 bits to align 'i'}}
 };
 
+struct __attribute__((ms_struct)) Foo { // expected-warning {{padding size of 
'Foo' with 63 bits to alignment boundary}}
+  long long x;
+  char a : 1;
+  long long b : 1; // expected-warning {{padding struct 'Foo' with 63 bits to 
align 'b'}}
+};
+
+struct __attribute__((ms_struct)) SameUnitSizeMultiple { // expected-warning 
{{padding size of 'SameUnitSizeMultiple' with 2 bits to alignment boundary}}
+  char c : 1;
+  char cc : 2;
+  char ccc : 3;
+};
+
 int main() {
   BitfieldStruct b;
   SevenBitfieldStruct s;
   SameUnitSizeBitfield su;
   DifferentUnitSizeBitfield du;
+  Foo f;
+  SameUnitSizeMultiple susm;
 }

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


[clang] Revert "[Clang] Bypass TAD during overload resolution if a perfect match exists" (PR #136113)

2025-04-17 Thread via cfe-commits

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


[clang] [llvm] [RISCV] Add processor definition for XiangShan-KunMingHu-V2R2 (PR #123193)

2025-04-17 Thread via cfe-commits


@@ -558,6 +558,34 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
 
+def XIANGSHAN_KUNMINGHU : RISCVProcessorModel<"xiangshan-kunminghu",
+  NoSchedModel,
+  !listconcat(RVA23S64Features,
+  [FeatureStdExtZicsr,

liliumShade wrote:

You are right, but I didn't find FeatureStdExtZicsr in RISCVProfiles.td. So, 
just to confirm, there won't be any problem if it is removed, right? 😮

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


[clang] [llvm] [MIPS] Add FeatureMSA to i6400 and i6500 cores (PR #134985)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mallikarjuna Gouda (mgoudar)


Changes

Enable 'FeatureMSA' for MIPS i6400 and i6500 cpu.

MIPS i6400 and i6500 cores implements MSA (MIPS SIMD ARCHITECTURE) by default.

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


2 Files Affected:

- (added) clang/test/Driver/mips-cpus.c (+9) 
- (modified) llvm/lib/Target/Mips/Mips.td (+2-2) 


``diff
diff --git a/clang/test/Driver/mips-cpus.c b/clang/test/Driver/mips-cpus.c
new file mode 100644
index 0..effb5ef60166a
--- /dev/null
+++ b/clang/test/Driver/mips-cpus.c
@@ -0,0 +1,9 @@
+// Check target CPUs are correctly passed.
+
+// RUN: %clang --target=mips64 -### -c %s 2>&1 -mcpu=i6400 -mmsa | FileCheck 
-check-prefix=MCPU-I6400 %s
+// MCPU-I6400: "-target-cpu" "i6400"
+// MCPU-I6400-SAME: "-target-feature" "+msa"
+
+// RUN: %clang --target=mips64 -### -c %s 2>&1 -mcpu=i6500 -mmsa | FileCheck 
-check-prefix=MCPU-I6500 %s
+// MCPU-I6500: "-target-cpu" "i6500"
+// MCPU-I6500-SAME: "-target-feature" "+msa"
diff --git a/llvm/lib/Target/Mips/Mips.td b/llvm/lib/Target/Mips/Mips.td
index 43a5ae8133d83..ca3df1fd94144 100644
--- a/llvm/lib/Target/Mips/Mips.td
+++ b/llvm/lib/Target/Mips/Mips.td
@@ -242,11 +242,11 @@ def ImplP5600 : SubtargetFeature<"p5600", "ProcImpl",
 // same CPU architecture.
 def ImplI6400
 : SubtargetFeature<"i6400", "ProcImpl", "MipsSubtarget::CPU::I6400",
-   "MIPS I6400 Processor", [FeatureMips64r6]>;
+   "MIPS I6400 Processor", [FeatureMips64r6, FeatureMSA]>;
 
 def ImplI6500
 : SubtargetFeature<"i6500", "ProcImpl", "MipsSubtarget::CPU::I6500",
-   "MIPS I6500 Processor", [FeatureMips64r6]>;
+   "MIPS I6500 Processor", [FeatureMips64r6, FeatureMSA]>;
 
 class Proc Features>
  : ProcessorModel;

``




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


[clang] [clang][bytecode] Enter a non-constant context when revisiting (PR #136104)

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

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

Otherwise, things like __builtin_is_constant_evaluated() return the wrong value.

>From d55ada6a4b88db3579570a4f1fbd43ae38a715b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 17 Apr 2025 09:38:57 +0200
Subject: [PATCH] [clang][bytecode] Enter a non-constant context when
 revisiting

Otherwise, things like __builtin_is_constant_evaluated() return
the wrong value.
---
 clang/lib/AST/ByteCode/Compiler.cpp| 5 +
 clang/lib/AST/ByteCode/Interp.h| 9 +
 clang/lib/AST/ByteCode/InterpState.h   | 2 +-
 clang/lib/AST/ByteCode/Opcodes.td  | 3 +++
 clang/test/AST/ByteCode/builtin-constant-p.cpp | 8 
 5 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 157e306e5cdb3..bdff40c57b0e1 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6466,8 +6466,13 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
 
   // In case we need to re-visit a declaration.
   auto revisit = [&](const VarDecl *VD) -> bool {
+if (!this->emitPushCC(E))
+  return false;
 auto VarState = this->visitDecl(VD, /*IsConstexprUnknown=*/true);
 
+if (!this->emitPopCC(E))
+  return false;
+
 if (VarState.notCreated())
   return true;
 if (!VarState)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index bd58c2a88e9d9..bca87fc937f9f 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2848,6 +2848,15 @@ inline bool EndSpeculation(InterpState &S, CodePtr OpPC) 
{
   return true;
 }
 
+inline bool PushCC(InterpState &S, CodePtr OpPC) {
+  S.ConstantContextOverride = false;
+  return true;
+}
+inline bool PopCC(InterpState &S, CodePtr OpPC) {
+  S.ConstantContextOverride = std::nullopt;
+  return true;
+}
+
 /// Do nothing and just abort execution.
 inline bool Error(InterpState &S, CodePtr OpPC) { return false; }
 
diff --git a/clang/lib/AST/ByteCode/InterpState.h 
b/clang/lib/AST/ByteCode/InterpState.h
index 74001b80d9c00..528c1a24e7b05 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -127,7 +127,6 @@ class InterpState final : public State, public SourceMapper 
{
   SourceMapper *M;
   /// Allocator used for dynamic allocations performed via the program.
   DynamicAllocator Alloc;
-  std::optional ConstantContextOverride;
 
 public:
   /// Reference to the module containing all bytecode.
@@ -147,6 +146,7 @@ class InterpState final : public State, public SourceMapper 
{
   /// Things needed to do speculative execution.
   SmallVectorImpl *PrevDiags = nullptr;
   unsigned SpeculationDepth = 0;
+  std::optional ConstantContextOverride;
 
   llvm::SmallVector<
   std::pair>
diff --git a/clang/lib/AST/ByteCode/Opcodes.td 
b/clang/lib/AST/ByteCode/Opcodes.td
index 5a9079fea0846..01e4aefdaffe0 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -872,3 +872,6 @@ def GetTypeidPtr : Opcode { let Args = [ArgTypePtr]; }
 def DiagTypeid : Opcode;
 
 def CheckDestruction : Opcode;
+
+def PushCC : Opcode;
+def PopCC : Opcode;
diff --git a/clang/test/AST/ByteCode/builtin-constant-p.cpp 
b/clang/test/AST/ByteCode/builtin-constant-p.cpp
index ed9e606ed16aa..f5b16761bfdc9 100644
--- a/clang/test/AST/ByteCode/builtin-constant-p.cpp
+++ b/clang/test/AST/ByteCode/builtin-constant-p.cpp
@@ -121,3 +121,11 @@ constexpr int mutate6(bool mutate) {
 static_assert(mutate6(false) == 11);
 static_assert(mutate6(true) == 21); // ref-error {{static assertion failed}} \
 // ref-note {{evaluates to '10 == 21'}}
+
+#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+void g() {
+  /// f will be revisited when evaluating the static_assert, since it's
+  /// a local variable. But it should be visited in a non-constant context.
+  const float f = __builtin_is_constant_evaluated();
+  static_assert(fold(f == 0.0f));
+}

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


[clang] Revert "[Clang] Bypass TAD during overload resolution if a perfect match exists" (PR #136113)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)


Changes

Reverts llvm/llvm-project#136018

Still some bots failing https://lab.llvm.org/buildbot/#/builders/52/builds/7643

---

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


12 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-6) 
- (modified) clang/include/clang/Sema/Overload.h (+10-222) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+2-4) 
- (modified) clang/lib/Sema/SemaInit.cpp (+5-13) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+100-432) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+2-2) 
- (modified) 
clang/test/CXX/temp/temp.constr/temp.constr.atomic/constrant-satisfaction-conversions.cpp
 (+4-4) 
- (modified) clang/test/SemaCUDA/function-overload.cu (+3) 
- (modified) clang/test/SemaCXX/implicit-member-functions.cpp (+14-7) 
- (removed) clang/test/SemaCXX/overload-resolution-deferred-templates.cpp 
(-200) 
- (modified) clang/test/SemaTemplate/instantiate-function-params.cpp (+4-3) 
- (modified) clang/test/Templight/templight-empty-entries-fix.cpp (+75-51) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc36962b317e8..4f640697e1817 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -96,12 +96,6 @@ C++ Language Changes
   asm((std::string_view("nop")) ::: (std::string_view("memory")));
 }
 
-- Clang now implements the changes to overload resolution proposed by section 
1 and 2 of
-  `P3606 `_. If a non-template candidate exists in 
an overload set that is
-  a perfect match (all conversion sequences are identity conversions) template 
candidates are not instantiated.
-  Diagnostics that would have resulted from the instantiation of these 
template candidates are no longer
-  produced. This aligns Clang closer to the behavior of GCC, and fixes 
(#GH62096), (#GH74581), and (#GH74581).
-
 C++2c Feature Support
 ^
 
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e667147bfac7e..6e08762dcc6d7 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -407,26 +407,6 @@ class Sema;
  Third == ICK_Identity;
 }
 
-/// A conversion sequence is perfect if it is an identity conversion and
-/// the type of the source is the same as the type of the target.
-bool isPerfect(const ASTContext &C) const {
-  if (!isIdentityConversion())
-return false;
-  // If we are not performing a reference binding, we can skip comparing
-  // the types, which has a noticeable performance impact.
-  if (!ReferenceBinding) {
-// The types might differ if there is an array-to-pointer conversion
-// or lvalue-to-rvalue conversion.
-assert(First || C.hasSameUnqualifiedType(getFromType(), getToType(2)));
-return true;
-  }
-  if (!C.hasSameType(getFromType(), getToType(2)))
-return false;
-  if (BindsToRvalue && IsLvalueReference)
-return false;
-  return true;
-}
-
 ImplicitConversionRank getRank() const;
 NarrowingKind
 getNarrowingKind(ASTContext &Context, const Expr *Converted,
@@ -763,12 +743,6 @@ class Sema;
   Standard.setAllToTypes(T);
 }
 
-/// A conversion sequence is perfect if it is an identity conversion and
-/// the type of the source is the same as the type of the target.
-bool isPerfect(const ASTContext &C) const {
-  return isStandard() && Standard.isPerfect(C);
-}
-
 // True iff this is a conversion sequence from an initializer list to an
 // array or std::initializer.
 bool hasInitializerListContainerType() const {
@@ -965,10 +939,6 @@ class Sema;
 LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
 unsigned IsADLCandidate : 1;
 
-/// Whether FinalConversion has been set.
-LLVM_PREFERRED_TYPE(bool)
-unsigned HasFinalConversion : 1;
-
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
@@ -1009,20 +979,6 @@ class Sema;
   return false;
 }
 
-// An overload is a perfect match if the conversion
-// sequences for each argument are perfect.
-bool isPerfectMatch(const ASTContext &Ctx) const {
-  if (!Viable)
-return false;
-  for (const auto &C : Conversions) {
-if (!C.isInitialized() || !C.isPerfect(Ctx))
-  return false;
-  }
-  if (HasFinalConversion)
-return FinalConversion.isPerfect(Ctx);
-  return true;
-}
-
 bool TryToFixBadConversion(unsigned Idx, Sema &S) {
   bool CanFix = Fix.tryToFixConversion(
   Conversions[Idx].Bad.FromExpr,
@@ -1056,67 +1012,8 @@ class Sema;
 : IsSurrogate(false), IgnoreObjectArgument(false),
   TookAddre

[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

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


@@ -8623,6 +8624,13 @@ inline bool Type::isIntegralOrEnumerationType() const {
 inline bool Type::isBooleanType() const {
   if (const auto *BT = dyn_cast(CanonicalType))
 return BT->getKind() == BuiltinType::Bool;
+  if (const EnumType *ET = dyn_cast(CanonicalType)) {
+// Incomplete enum types are not treated as integer types.
+// FIXME: In C++, enum types are never integer types.
+return IsEnumDeclComplete(ET->getDecl()) &&
+   !IsEnumDeclScoped(ET->getDecl()) &&

AaronBallman wrote:

Why does the the enum being scoped matter?

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


[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

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


@@ -2336,16 +2336,9 @@ bool Type::isArithmeticType() const {
 }
 
 bool Type::hasBooleanRepresentation() const {
-  if (isBooleanType())
-return true;
-
-  if (const EnumType *ET = getAs())
-return ET->getDecl()->getIntegerType()->isBooleanType();
-
-  if (const AtomicType *AT = getAs())
-return AT->getValueType()->hasBooleanRepresentation();
-
-  return false;
+  if (const auto *VT = dyn_cast(CanonicalType))

AaronBallman wrote:

I missed the PR for adding this function; what does it mean for a type to have 
a boolean representation? I think the header needs some comments explaining 
this. Does it mean it's an `i1` in LLVM IR?

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-17 Thread Matt Arsenault via cfe-commits


@@ -387,21 +387,39 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
   set( opt_flags )
   set( spvflags --spirv-max-version=1.1 )
   set( MACRO_ARCH SPIRV32 )
   if( ARCH STREQUAL spirv64 )
 set( MACRO_ARCH SPIRV64 )
   endif()
-elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+elseif( ${DARCH} STREQUAL clspv )
+  # Refer to https://github.com/google/clspv for OpenCL version.
+  set( opencl_lang_std "CL3.0" )
   set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
   set( opt_flags -O3 )
   set( MACRO_ARCH CLSPV32 )
   if( ARCH STREQUAL clspv64 )
 set( MACRO_ARCH CLSPV64 )
   endif()
+elseif( ${DARCH} STREQUAL nvptx )
+  # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV 
implementation.
+  set( opencl_lang_std "CL3.0" )
+  set( build_flags )
+  set( opt_flags -O3 )
+  set( MACRO_ARCH ${ARCH} )
+elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa )
+  # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL 
version.
+  set( opencl_lang_std "CL2.0" )

arsenm wrote:

I thought we already picked out device compatible default versions in clang? 

https://github.com/llvm/llvm-project/pull/135733
___
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-04-17 Thread Paul Walker via cfe-commits


@@ -5464,6 +5464,15 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   Builder.CreateStore(errorValue, swiftErrorTemp);
 }
 
+// Mfloat8 type is loaded as scalar type, but is treated as single
+// vector type for other operations. We need to bitcast it to the 
vector
+// type here.
+if (auto *EltTy =

paulwalker-arm wrote:

Does the ABI say this?  My understand is that values of type _mfp8 are 
floating-point 8-bit values that are passes as _mfp8. The pretend it's an `i8` 
in some cases and `<1 x i8>` in others is purely an implementation detail 
within clang.

This is not to say the code is invalid, but we should be cautious with how far 
down the rabbit hole we go.

FYI: As part of @MacDue's work to improve streaming-mode code generation I 
asked him to add the MVT `aarch64mfp8` along with support to load and store it. 
 I expect over time we'll migrate away from using `i8` as our scalar type.

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-17 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

I'd expect the libclc build (or any other runtime support library) to 
consistently use the same language version independent of the target. If the 
target doesn't support that version (which IIRC isn't actually a hard error 
anywhere) and fails to compile on some feature, those should be carved out into 
separate version dependent build (as in, this isn't a compile target property 
but a specific build target property)

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


[clang-tools-extra] [clang-tidy] Fix bugprone-tagged-union-member-count false-positive (PR #135831)

2025-04-17 Thread via cfe-commits
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?=,=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?Message-ID:
In-Reply-To: 


https://github.com/tigbr updated 
https://github.com/llvm/llvm-project/pull/135831

>From 525459a04dd6e7d0079095ac531c7cd712ac91d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20T=C3=B3thv=C3=A1ri?=
 
Date: Mon, 14 Apr 2025 17:09:07 +0200
Subject: [PATCH 1/3] [clang-tidy] Fix bugprone-tagged-union-member-count
 false-positive

Types from system headers and the std namespace are no longer considered as
the enum part or the union part of a user-defined tagged union.

Fixes #134840
---
 .../bugprone/TaggedUnionMemberCountCheck.cpp  | 12 ++
 .../bugprone/tagged-union-member-count.rst| 22 +++
 .../bugprone/tagged-union-member-count.c  | 13 +++
 .../bugprone/tagged-union-member-count.cpp| 13 +++
 .../bugprone/tagged-union-member-count.m  | 13 +++
 .../bugprone/tagged-union-member-count.mm | 13 +++
 6 files changed, 82 insertions(+), 4 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
index db99ef3786e5f..b91da7db39463 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
@@ -106,11 +106,15 @@ void TaggedUnionMemberCountCheck::storeOptions(
 
 void TaggedUnionMemberCountCheck::registerMatchers(MatchFinder *Finder) {
 
-  auto UnionField = fieldDecl(hasType(qualType(
-  hasCanonicalType(recordType(hasDeclaration(recordDecl(isUnion(;
+  auto NotFromSystemHeaderOrStdNamespace =
+  unless(anyOf(isExpansionInSystemHeader(), isInStdNamespace()));
 
-  auto EnumField = fieldDecl(hasType(
-  qualType(hasCanonicalType(enumType(hasDeclaration(enumDecl()));
+  auto UnionField =
+  fieldDecl(hasType(qualType(hasCanonicalType(recordType(hasDeclaration(
+  recordDecl(isUnion(), NotFromSystemHeaderOrStdNamespace)));
+
+  auto EnumField = fieldDecl(hasType(qualType(hasCanonicalType(
+  
enumType(hasDeclaration(enumDecl(NotFromSystemHeaderOrStdNamespace)));
 
   auto hasOneUnionField = fieldCountOfKindIsOne(UnionField, 
UnionMatchBindName);
   auto hasOneEnumField = fieldCountOfKindIsOne(EnumField, TagMatchBindName);
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
index 2f1036c10345e..b47a49543143b 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
@@ -9,6 +9,9 @@ different from the number of data members inside the union.
 A struct or a class is considered to be a tagged union if it has
 exactly one union data member and exactly one enum data member and
 any number of other data members that are neither unions or enums.
+The union and enum data members that are from system header files or
+the std namespace are not considered to make up the tagged union part
+of a user-defined tagged union type.
 
 Example:
 
@@ -28,6 +31,25 @@ Example:
 } Data;
   };
 
+The following example illustrates the exception for unions and enums from
+system header files and the std namespace.
+
+.. code-block:: c++
+
+  #include 
+
+  struct NotTaggedUnion {
+enum MyEnum { MyEnumConstant1, MyEnumConstant2 } En;
+pthread_mutex_t Mutex;
+  };
+
+The pthread_mutex_t type may be defined as a union behind a typedef,
+in which case the check could mistake this type as a user-defined tagged union.
+After all it has exactly one enum data member and exactly one union data 
member.
+To avoid false-positive cases originating from this, unions and enums from
+system headers and the std namespace are ignored when pinpointing the
+union part and the enum part of a potential user-defined tagged union.
+
 How enum constants are counted
 --
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.c
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.c
index 60c93c553baca..96255c7fdd4fe 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.c
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.c
@@ -147,3 +147,16 @@ struct Name {\
 
 // CHECK-MESSAGES: :[[@LINE+1]]:44: warning: tagged union has more data 
members (4) than tags (3)
 DECLARE_TAGGED_UNION_STRUCT(Tags3, Union4, TaggedUnionStructFromMacro);
+
+// Typedefed unions from system header files should be ignored when
+// we are trying to pinpoint the union part in a user-defined tagged union.
+#include "pthread.h"
+
+// This should not be analyzed as a user-defined tagged union,
+// even though pthread_mutex_t may be declared as a typede

[clang-tools-extra] [clangd] Store documentation when indexing standard library (PR #133681)

2025-04-17 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

> The described options seem a bit more involved than necessary to fix this 
> bug, given that it's just the value of the `StoreAllDocumentation` flag 
> that's a problem.

Maybe I miscommunicated something, but I was talking about a change like 
https://github.com/kadircet/llvm-project/commit/ff0c31d232b2aed9e95d69d16a9dfbb9babea711.

> I revised the patch to add a new parameter to `createStaticIndexingAction()` 
> (now called `createIndexingAction()`) and set the flag based on that -- does 
> this address your concern about callers having to decide whether they want 
> `StoreAllDocumentation`?

I think this still leaves possibility for future divergences. Conceptually we 
should either make stdlib index act as dynamic-index (what I am suggesting) or 
change its priority to be similar to static-index. Otherwise we're likely to 
hit more discrepancies as the code evolves. Moreover changing 
`createStaticIndexingAction` also increases the mental load around all the 
complicated indexing architecture now.

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


[clang] [clang] Handle instantiated members to determine visibility (PR #136128)

2025-04-17 Thread Andrew Savonichev via cfe-commits

https://github.com/asavonic created 
https://github.com/llvm/llvm-project/pull/136128

As reported in issue #103477, visibility of instantiated member functions used 
to be ignored when calculating visibility of a specialization.

This patch modifies `getLVForClassMember` to look up for a source template for 
an instantiated member, and changes `mergeTemplateLV` to apply it.

A similar issue was reported in #31462, but it seems that `extern` declaration 
with visibility prevents the function from being emitted as hidden. This 
behavior seems correct, even though GCC emits it as with default visibility 
instead.

Both tests from #103477 and #31462 are added as LIT tests `test72` and `test73` 
respectively.

>From c08102ae11bf16869bb2f05b9b866146cf93ab5d Mon Sep 17 00:00:00 2001
From: Andrew Savonichev 
Date: Thu, 17 Apr 2025 20:18:52 +0900
Subject: [PATCH] [clang] Handle instantiated members to determine visibility

As reported in issue #103477, visibility of instantiated member
functions used to be ignored when calculating visibility of a
specialization.

This patch modifies `getLVForClassMember` to look up for a source
template for an instantiated member, and changes `mergeTemplateLV` to
apply it.

A similar issue was reported in #31462, but it seems that `extern`
declaration with visibility prevents the function from being emitted
as hidden. This behavior seems correct, even though GCC emits it as
with default visibility instead.

Both tests from #103477 and #31462 are added as LIT tests `test72` and
`test73` respectively.
---
 clang/lib/AST/Decl.cpp   | 13 +++---
 clang/test/CodeGenCXX/visibility.cpp | 38 +++-
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ad1cb01592e9b..b59619892979a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -400,9 +400,9 @@ void LinkageComputer::mergeTemplateLV(
   FunctionTemplateDecl *temp = specInfo->getTemplate();
   // Merge information from the template declaration.
   LinkageInfo tempLV = getLVForDecl(temp, computation);
-  // The linkage of the specialization should be consistent with the
-  // template declaration.
-  LV.setLinkage(tempLV.getLinkage());
+  // The linkage and visibility of the specialization should be
+  // consistent with the template declaration.
+  LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
 
   // Merge information from the template parameters.
   LinkageInfo paramsLV =
@@ -1051,6 +1051,13 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
 if (const auto *redeclTemp = dyn_cast(temp)) {
   if (isExplicitMemberSpecialization(redeclTemp)) {
 explicitSpecSuppressor = temp->getTemplatedDecl();
+  } else if (const RedeclarableTemplateDecl *from =
+ redeclTemp->getInstantiatedFromMemberTemplate()) {
+// If no explicit visibility is specified yet, and this is an
+// instantiated member of a template, look up visibility there
+// as well.
+LinkageInfo fromLV = from->getLinkageAndVisibility();
+LV.mergeMaybeWithVisibility(fromLV, considerVisibility);
   }
 }
   }
diff --git a/clang/test/CodeGenCXX/visibility.cpp 
b/clang/test/CodeGenCXX/visibility.cpp
index e1061f3dbd18f..b69278a71d48e 100644
--- a/clang/test/CodeGenCXX/visibility.cpp
+++ b/clang/test/CodeGenCXX/visibility.cpp
@@ -1457,9 +1457,45 @@ namespace test71 {
   // CHECK-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
   // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIiE3barIiEET_v(
   // CHECK-LABEL: define linkonce_odr hidden noundef i64 
@_ZN6test713fooIlE3zedEv(
-  // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
+  // CHECK-LABEL: define linkonce_odr hidden noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
   // CHECK-HIDDEN-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
   // CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIiE3barIiEET_v(
   // CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i64 
@_ZN6test713fooIlE3zedEv(
   // CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
 }
+
+// https://github.com/llvm/llvm-project/issues/103477
+namespace test72 {
+  template 
+  struct t {
+template 
+static HIDDEN void bar() {}
+  };
+
+  void test() {
+  t::bar<1>();
+  }
+  // CHECK-LABEL: define linkonce_odr hidden void 
@_ZN6test721tIcE3barILi1EEEvv(
+  // CHECK-HIDDEN-LABEL: define linkonce_odr hidden void 
@_ZN6test721tIcE3barILi1EEEvv(
+}
+
+// https://github.com/llvm/llvm-project/issues/31462
+namespace test73 {
+  template  struct s {
+template 
+__attribute__((__visibility__("hidden"))) U should_not_be_exported();
+  };
+
+  template  template  U s::should_not_be_exported() {
+return U();
+  }
+
+  extern template struct __attribute__((__visibility__("default"))) s;
+
+  int f() {
+s o;
+

[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)

2025-04-17 Thread Mohamed Emad via cfe-commits

https://github.com/hulxv updated 
https://github.com/llvm/llvm-project/pull/132991

>From c476948593a80ed31765cdd711a626e4e03930ab Mon Sep 17 00:00:00 2001
From: hulxv 
Date: Tue, 25 Mar 2025 22:56:51 +0200
Subject: [PATCH 1/2] [include-cleaner] rename enabled flags to `disable-*`

---
 .../include-cleaner/test/tool.cpp |  4 ++--
 .../include-cleaner/tool/IncludeCleaner.cpp   | 20 +--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp 
b/clang-tools-extra/include-cleaner/test/tool.cpp
index d72d2317ce2b1..8b723a5bf40e2 100644
--- a/clang-tools-extra/include-cleaner/test/tool.cpp
+++ b/clang-tools-extra/include-cleaner/test/tool.cpp
@@ -6,11 +6,11 @@ int x = foo();
 //  CHANGE: - "foobar.h"
 // CHANGE-NEXT: + "foo.h"
 
-// RUN: clang-include-cleaner -remove=0 -print=changes %s -- 
-I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
+// RUN: clang-include-cleaner -disable-remove -print=changes %s -- 
-I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
 //  INSERT-NOT: - "foobar.h"
 //  INSERT: + "foo.h"
 
-// RUN: clang-include-cleaner -insert=0 -print=changes %s -- 
-I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
+// RUN: clang-include-cleaner -disable-insert -print=changes %s -- 
-I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
 //  REMOVE: - "foobar.h"
 //  REMOVE-NOT: + "foo.h"
 
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 1d9458ffc4d32..472611073f732 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -91,16 +91,16 @@ cl::opt Edit{
 cl::cat(IncludeCleaner),
 };
 
-cl::opt Insert{
-"insert",
-cl::desc("Allow header insertions"),
-cl::init(true),
+cl::opt DisableInsert{
+"disable-insert",
+cl::desc("DIsable header insertions"),
+cl::init(false),
 cl::cat(IncludeCleaner),
 };
-cl::opt Remove{
-"remove",
-cl::desc("Allow header removals"),
-cl::init(true),
+cl::opt DisableRemove{
+"disable-remove",
+cl::desc("Disable header removals"),
+cl::init(false),
 cl::cat(IncludeCleaner),
 };
 
@@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction {
 auto Results =
 analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI,
 getCompilerInstance().getPreprocessor(), HeaderFilter);
-if (!Insert)
+if (DisableInsert)
   Results.Missing.clear();
-if (!Remove)
+if (DisableRemove)
   Results.Unused.clear();
 std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath));
 

>From 9bbae72d13e2d3f221ea3f55266413d7a18eb03a Mon Sep 17 00:00:00 2001
From: hulxv 
Date: Thu, 17 Apr 2025 13:52:17 +0200
Subject: [PATCH 2/2] [include-cleaner] return `--remove` and `--insert` to be
 in deprecation period

---
 .../include-cleaner/test/tool.cpp |  8 
 .../include-cleaner/tool/IncludeCleaner.cpp   | 19 +++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp 
b/clang-tools-extra/include-cleaner/test/tool.cpp
index 8b723a5bf40e2..2584f75b6a54c 100644
--- a/clang-tools-extra/include-cleaner/test/tool.cpp
+++ b/clang-tools-extra/include-cleaner/test/tool.cpp
@@ -14,6 +14,14 @@ int x = foo();
 //  REMOVE: - "foobar.h"
 //  REMOVE-NOT: + "foo.h"
 
+// RUN: clang-include-cleaner -remove=0 -print=changes %s -- 
-I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
+//  INSERT-NOT: - "foobar.h"
+//  INSERT: + "foo.h"
+
+// RUN: clang-include-cleaner -insert=0 -print=changes %s -- 
-I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
+//  REMOVE: - "foobar.h"
+//  REMOVE-NOT: + "foo.h"
+
 //RUN: clang-include-cleaner -print=changes %s 
--ignore-headers="foobar\.h,foo\.h" -- -I%S/Inputs/ | FileCheck 
--match-full-lines --allow-empty --check-prefix=IGNORE %s
 // IGNORE-NOT: - "foobar.h"
 // IGNORE-NOT: + "foo.h"
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 472611073f732..7a07d09ce277d 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -90,10 +90,21 @@ cl::opt Edit{
 cl::desc("Apply edits to analyzed source files"),
 cl::cat(IncludeCleaner),
 };
-
+cl::opt Insert{
+"insert",
+cl::desc("Allow header insertions"),
+cl::init(true),
+cl::cat(IncludeCleaner),
+};
+cl::opt Remove{
+"remove",
+cl::desc("Allow header removals"),
+cl::init(true),
+cl::cat(IncludeCleaner),
+};
 cl::opt DisableInsert{
 "disable-insert",
-cl::desc("DIsable header insertions"),
+cl::desc("Disable header insertions"),
 cl::init(false),
 cl::cat(IncludeCleaner),
 };
@@ -183,9 

[clang] [clang][bytecode] Reject assignments in C (PR #136126)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Similar to what the current interpreter does.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+5-1) 
- (added) clang/test/AST/ByteCode/c2y.c (+23) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 157e306e5cdb3..d6c8817610742 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -863,8 +863,12 @@ bool Compiler::VisitBinaryOperator(const 
BinaryOperator *BO) {
   return this->VisitPointerArithBinOp(BO);
   }
 
-  // Assignmentes require us to evalute the RHS first.
+  // Assignments require us to evalute the RHS first.
   if (BO->getOpcode() == BO_Assign) {
+// We don't support assignments in C.
+if (!Ctx.getLangOpts().CPlusPlus)
+  return this->emitInvalid(BO);
+
 if (!visit(RHS) || !visit(LHS))
   return false;
 if (!this->emitFlip(*LT, *RT, BO))
diff --git a/clang/test/AST/ByteCode/c2y.c b/clang/test/AST/ByteCode/c2y.c
new file mode 100644
index 0..bbb163ab83833
--- /dev/null
+++ b/clang/test/AST/ByteCode/c2y.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=expected,both 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=ref,both
+
+// both-no-diagnostics
+
+struct S {
+  int x;
+  char c;
+  float f;
+};
+
+#define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)]
+
+struct T {
+  DECL_BUFFER(struct S, buffer);
+};
+
+int quorble() {
+  DECL_BUFFER(struct T, buffer);
+  ((struct S *)((struct T *)buffer)->buffer)->x = 12;
+  const struct S *s_ptr = (struct S *)((struct T *)buffer)->buffer;
+  return s_ptr->x;
+}

``




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


[clang] [clang][ExprConst] Diagnose ptr subs with non-zero offset (PR #135938)

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

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

LGTM!

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


[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-17 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/135957

>From b194133f44768a61a7af6486dc40deae2de73f9a Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Wed, 16 Apr 2025 05:59:24 -0700
Subject: [PATCH 1/6] [clang] Implement StmtPrinter for EmbedExpr

Tries to avoid memory leaks caused by saving filename earlier by
allocating memory in the preprocessor.

Fixes https://github.com/llvm/llvm-project/issues/132641
---
 clang/include/clang/AST/Expr.h  |  4 +++
 clang/include/clang/Lex/Preprocessor.h  |  3 +-
 clang/include/clang/Sema/Sema.h |  2 +-
 clang/lib/AST/StmtPrinter.cpp   |  6 +++-
 clang/lib/Lex/PPDirectives.cpp  | 13 ++--
 clang/lib/Parse/ParseInit.cpp   |  3 +-
 clang/lib/Sema/SemaExpr.cpp |  4 ++-
 clang/test/Preprocessor/embed_weird.cpp | 40 +
 8 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 529c6228bfa19..a83320a7ddec2 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4961,6 +4961,9 @@ class SourceLocExpr final : public Expr {
 /// Stores data related to a single #embed directive.
 struct EmbedDataStorage {
   StringLiteral *BinaryData;
+  // FileName string already includes braces, i.e. it is  for a
+  // directive #embed .
+  StringRef FileName;
   size_t getDataElementCount() const { return BinaryData->getByteLength(); }
 };
 
@@ -5007,6 +5010,7 @@ class EmbedExpr final : public Expr {
   SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
 
   StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
+  StringRef getFileName() const { return Data->FileName; }
   EmbedDataStorage *getData() const { return Data; }
 
   unsigned getStartingElementPos() const { return Begin; }
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index f8f2f567f9171..10260c61bdf11 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2761,7 +2761,7 @@ class Preprocessor {
 const FileEntry *LookupFromFile = nullptr);
   void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
 const LexEmbedParametersResult &Params,
-StringRef BinaryContents);
+StringRef BinaryContents, StringRef FileName);
 
   // File inclusion.
   void HandleIncludeDirective(SourceLocation HashLoc, Token &Tok,
@@ -3065,6 +3065,7 @@ class EmptylineHandler {
 /// preprocessor to the parser through an annotation token.
 struct EmbedAnnotationData {
   StringRef BinaryData;
+  StringRef FileName;
 };
 
 /// Registry of pragma handlers added by plugins
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1f23b754a69cb..a757f4c6430ae 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7256,7 +7256,7 @@ class Sema final : public SemaBase {
 
   // #embed
   ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-StringLiteral *BinaryData);
+StringLiteral *BinaryData, StringRef FileName);
 
   // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index aae10fd3bd885..2993d7d0ee865 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1284,7 +1284,11 @@ void StmtPrinter::VisitSourceLocExpr(SourceLocExpr 
*Node) {
 }
 
 void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
-  llvm::report_fatal_error("Not implemented");
+  // Embed parameters are not reflected in the AST, so there is no way to print
+  // them yet.
+  OS << "#embed ";
+  OS << Node->getFileName();
+  OS << NL;
 }
 
 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 21ec83b437ef4..cd90dfd885007 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3909,7 +3909,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool 
ForHasEmbed) {
 
 void Preprocessor::HandleEmbedDirectiveImpl(
 SourceLocation HashLoc, const LexEmbedParametersResult &Params,
-StringRef BinaryContents) {
+StringRef BinaryContents, StringRef FileName) {
   if (BinaryContents.empty()) {
 // If we have no binary contents, the only thing we need to emit are the
 // if_empty tokens, if any.
@@ -3940,6 +3940,7 @@ void Preprocessor::HandleEmbedDirectiveImpl(
 
   EmbedAnnotationData *Data = new (BP) EmbedAnnotationData;
   Data->BinaryData = BinaryContents;
+  Data->FileName = FileName;
 
   Toks[CurIdx].startToken();
   Toks[CurIdx].setKind(tok::annot_embed);
@@ -4049,5 +4050,13 @@ void Preprocessor::HandleEmbedDirective(Sourc

[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

2025-04-17 Thread Andy Kaylor via cfe-commits

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


[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

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

https://github.com/AaronBallman commented:

Can you do the JSONNodeDumper as well so the two stay somewhat in-sync?

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


[clang] [CIR] cir.call with scalar return type (PR #135552)

2025-04-17 Thread Sirui Mu via cfe-commits

https://github.com/Lancern updated 
https://github.com/llvm/llvm-project/pull/135552

>From 0d5b4290c6bbcf8654e6898bb20182c252243e07 Mon Sep 17 00:00:00 2001
From: Sirui Mu 
Date: Sun, 13 Apr 2025 23:34:21 +0800
Subject: [PATCH] [CIR] cir.call with scalar return type

This patch introduces support for calling functions with a scalar return type to
the upstream. This patch also includes an initial version of CIRGenTargetInfo
and related definitions which are essential for the CIRGen of call ops.
---
 clang/include/clang/CIR/ABIArgInfo.h  | 92 +++
 .../CIR/Dialect/Builder/CIRBaseBuilder.h  |  8 +-
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  6 +-
 clang/include/clang/CIR/MissingFeatures.h |  5 +
 clang/lib/CIR/CodeGen/ABIInfo.h   | 32 +++
 clang/lib/CIR/CodeGen/CIRGenCall.cpp  | 79 ++--
 clang/lib/CIR/CodeGen/CIRGenCall.h|  4 +
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  | 24 -
 clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp|  7 +-
 clang/lib/CIR/CodeGen/CIRGenFunction.h| 15 ++-
 clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h| 39 +++-
 clang/lib/CIR/CodeGen/CIRGenModule.cpp| 28 ++
 clang/lib/CIR/CodeGen/CIRGenModule.h  |  6 ++
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 24 -
 clang/lib/CIR/CodeGen/CIRGenTypes.h   |  9 +-
 clang/lib/CIR/CodeGen/CMakeLists.txt  |  1 +
 clang/lib/CIR/CodeGen/TargetInfo.cpp  | 59 
 clang/lib/CIR/CodeGen/TargetInfo.h| 85 +
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   | 29 +-
 clang/test/CIR/CodeGen/call.cpp   | 10 ++
 clang/test/CIR/IR/call.cir| 14 +++
 clang/test/CIR/IR/invalid-call.cir| 43 +
 22 files changed, 579 insertions(+), 40 deletions(-)
 create mode 100644 clang/include/clang/CIR/ABIArgInfo.h
 create mode 100644 clang/lib/CIR/CodeGen/ABIInfo.h
 create mode 100644 clang/lib/CIR/CodeGen/TargetInfo.cpp
 create mode 100644 clang/lib/CIR/CodeGen/TargetInfo.h
 create mode 100644 clang/test/CIR/IR/invalid-call.cir

diff --git a/clang/include/clang/CIR/ABIArgInfo.h 
b/clang/include/clang/CIR/ABIArgInfo.h
new file mode 100644
index 0..b8d10445f9586
--- /dev/null
+++ b/clang/include/clang/CIR/ABIArgInfo.h
@@ -0,0 +1,92 @@
+//==-- ABIArgInfo.h - Abstract info regarding ABI-specific arguments 
---==//
+//
+// 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
+//
+//===--===//
+//
+// Defines ABIArgInfo and associated types used by CIR to track information
+// regarding ABI-coerced types for function arguments and return values. This
+// was moved to the common library as it might be used by both CIRGen and
+// passes.
+//
+//===--===//
+
+#ifndef CLANG_CIR_ABIARGINFO_H
+#define CLANG_CIR_ABIARGINFO_H
+
+#include "mlir/IR/Types.h"
+#include "clang/CIR/MissingFeatures.h"
+
+namespace cir {
+
+class ABIArgInfo {
+public:
+  enum Kind : uint8_t {
+/// Pass the argument directly using the normal converted CIR type,
+/// or by coercing to another specified type stored in 'CoerceToType'). If
+/// an offset is specified (in UIntData), then the argument passed is 
offset
+/// by some number of bytes in the memory representation. A dummy argument
+/// is emitted before the real argument if the specified type stored in
+/// "PaddingType" is not zero.
+Direct,
+
+/// Ignore the argument (treat as void). Useful for void and empty
+/// structs.
+Ignore,
+
+// TODO: more argument kinds will be added as the upstreaming proceeds.
+  };
+
+private:
+  mlir::Type typeData;
+  struct DirectAttrInfo {
+unsigned offset;
+unsigned align;
+  };
+  union {
+DirectAttrInfo directAttr;
+  };
+  Kind theKind;
+
+public:
+  ABIArgInfo(Kind k = Direct) : directAttr{0, 0}, theKind(k) {}
+
+  static ABIArgInfo getDirect(mlir::Type ty = nullptr) {
+ABIArgInfo info(Direct);
+info.setCoerceToType(ty);
+assert(!cir::MissingFeatures::abiArgInfo());
+return info;
+  }
+
+  static ABIArgInfo getIgnore() { return ABIArgInfo(Ignore); }
+
+  Kind getKind() const { return theKind; }
+  bool isDirect() const { return theKind == Direct; }
+  bool isIgnore() const { return theKind == Ignore; }
+
+  bool canHaveCoerceToType() const {
+assert(!cir::MissingFeatures::abiArgInfo());
+return isDirect();
+  }
+
+  unsigned getDirectOffset() const {
+assert(!cir::MissingFeatures::abiArgInfo());
+return directAttr.offset;
+  }
+
+  mlir::Type getCoerceToType() const {
+assert(canHaveCoerceToType() && "invalid kind!");
+return typeData;
+  }
+
+  void setCoerceToType(mlir::Type ty) {
+asser

[clang] [SYCL] Basic code generation for SYCL kernel caller offload entry point functions. (PR #133030)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-dap/locations/TestDAP_locations.py (1175 of 2956)
PASS: lldb-api :: tools/lldb-dap/memory/TestDAP_memory.py (1176 of 2956)
PASS: lldb-api :: tools/lldb-dap/optimized/TestDAP_optimized.py (1177 of 2956)
PASS: lldb-api :: tools/lldb-dap/output/TestDAP_output.py (1178 of 2956)
PASS: lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py (1179 of 2956)
PASS: lldb-api :: tools/lldb-dap/evaluate/TestDAP_evaluate.py (1180 of 2956)
PASS: lldb-api :: tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py (1181 
of 2956)
UNSUPPORTED: lldb-api :: 
tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py (1182 of 2956)
UNSUPPORTED: lldb-api :: tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py 
(1183 of 2956)
UNRESOLVED: lldb-api :: tools/lldb-dap/module/TestDAP_module.py (1184 of 2956)
 TEST 'lldb-api :: tools/lldb-dap/module/TestDAP_module.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/module
 -p TestDAP_module.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
0348ff515854438cab8a48b79e8839cb99d48701)
  clang revision 0348ff515854438cab8a48b79e8839cb99d48701
  llvm revision 0348ff515854438cab8a48b79e8839cb99d48701
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
= DEBUG ADAPTER PROTOCOL LOGS =
1744897404.046192408 --> (stdin/stdout) 
{"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1}
1744897404.051200151 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb 
version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
0348ff515854438cab8a48b79e8839cb99d48701)\n  clang revision 
0348ff515854438cab8a48b79e8839cb99d48701\n  llvm revision 
0348ff515854438cab8a48b79e8839cb99d48701","completionTriggerCharacters":["."," 
","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++
 Catch"},{"default":false,"filter":"cpp_throw","label":"C++ 
Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C 
Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C 
Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsDisassembleRequest":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsInstructionBreakpoints":true,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsReadMemoryRequest":true,"supportsRestartRequest":true,"supportsSetVariable":true,"supportsStepInTargetsRequest":true,"supportsSteppingGranularity":true,"supportsValueFormattingOptions":true},"command":"initialize","request_seq":1,"seq":0,"success":true,"type":"response"}
1744897404

[clang] [clang][bytecode] Enter a non-constant context when revisiting (PR #136104)

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

https://github.com/tbaederr closed 
https://github.com/llvm/llvm-project/pull/136104
___
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-04-17 Thread Paul Walker via cfe-commits

paulwalker-arm wrote:

For my education can you explain why the fp8 variants are broken out into their 
own definitions.  Taking `VREV64_MF8` as an example, it looks like you should 
be able to add the new type strings to the current definition?

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


[clang] [llvm] [LLVM] Add intrinsics for v_cvt_pk_norm_{i16, u16}_f16 (PR #135631)

2025-04-17 Thread Acim Maravic via cfe-commits

https://github.com/Acim-Maravic updated 
https://github.com/llvm/llvm-project/pull/135631

>From df4b39ea8558dcf18a0e6c2947c5f33eb356e77f Mon Sep 17 00:00:00 2001
From: Acim Maravic 
Date: Mon, 14 Apr 2025 16:29:11 +0200
Subject: [PATCH] [LLVM] Add intrinsics for v_cvt_pk_norm_{i16,u16}_f16

Added builtin and intrinsic for v_cvt_pk_norm_i16_f16 and
v_cvt_pk_norm_u16_f16
---
 clang/include/clang/Basic/BuiltinsAMDGPU.def  |   3 +
 .../CodeGenOpenCL/builtins-amdgcn-gfx9.cl |  16 +++
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td  |  12 ++
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  |   2 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.td |   1 +
 llvm/lib/Target/AMDGPU/VOP3Instructions.td|   7 +-
 .../AMDGPU/llvm.amdgcn.cvt.pk.norm.i16.f16.ll | 124 ++
 .../AMDGPU/llvm.amdgcn.cvt.pk.norm.u16.f16.ll | 124 ++
 8 files changed, 287 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.pk.norm.i16.f16.ll
 create mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.pk.norm.u16.f16.ll

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 39fef9e4601f8..0f3789d282304 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -259,6 +259,9 @@ TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, 
"V2sV2s*3V2s", "t", "atom
 TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", 
"atomic-ds-pk-add-16-insts")
 TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", 
"vmem-to-lds-load-insts")
 
+TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_norm_i16_f16, "V2sxx", "nc", 
"gfx9-insts")
+TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_norm_u16_f16, "V2Usxx", "nc", 
"gfx9-insts")
+
 
//===--===//
 // Deep learning builtins.
 
//===--===//
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
index 87f2da20a21a6..06417a693d303 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl
@@ -5,6 +5,8 @@
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 typedef unsigned int uint;
 typedef unsigned long ulong;
+typedef short __attribute__((ext_vector_type(2))) short2;
+typedef unsigned short __attribute__((ext_vector_type(2))) ushort2;
 
 // CHECK-LABEL: @test_fmed3_f16
 // CHECK: call half @llvm.amdgcn.fmed3.f16(half %a, half %b, half %c)
@@ -26,3 +28,17 @@ void test_groupstaticsize(global uint* out)
 {
   *out = __builtin_amdgcn_groupstaticsize();
 }
+
+// CHECK-LABEL: define dso_local void @test_cvt_pk_norm_i16_f16(
+// CHECK: call <2 x i16> @llvm.amdgcn.cvt.pk.norm.i16.f16(half %src0, half 
%src1)
+void test_cvt_pk_norm_i16_f16(global short2* out, half src0, half src1)
+{
+  *out = __builtin_amdgcn_cvt_pk_norm_i16_f16(src0, src1);
+}
+
+// CHECK-LABEL: define dso_local void @test_cvt_pk_norm_u16_f16(
+// CHECK: call <2 x i16> @llvm.amdgcn.cvt.pk.norm.u16.f16(half %src0, half 
%src1)
+void test_cvt_pk_norm_u16_f16(global ushort2* out, half src0, half src1)
+{
+  *out = __builtin_amdgcn_cvt_pk_norm_u16_f16(src0, src1);
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 217e43fcce4fd..60904e9202238 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -2644,6 +2644,18 @@ def int_amdgcn_global_load_lds : AMDGPUGlobalLoadLDS;
 def int_amdgcn_pops_exiting_wave_id :
   DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrHasSideEffects]>;
 
+def int_amdgcn_cvt_pk_norm_i16_f16 :
+  ClangBuiltin<"__builtin_amdgcn_cvt_pk_norm_i16_f16">,
+  DefaultAttrsIntrinsic<[llvm_v2i16_ty], [llvm_half_ty, llvm_half_ty],
+[IntrNoMem, IntrSpeculatable]
+>;
+
+def int_amdgcn_cvt_pk_norm_u16_f16 :
+  ClangBuiltin<"__builtin_amdgcn_cvt_pk_norm_u16_f16">,
+  DefaultAttrsIntrinsic<[llvm_v2i16_ty], [llvm_half_ty, llvm_half_ty],
+[IntrNoMem, IntrSpeculatable]
+>;
+
 
//===--===//
 // GFX10 Intrinsics
 
//===--===//
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index 1d0e81db5a5db..8d35721d6df8f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -4669,6 +4669,8 @@ AMDGPURegisterBankInfo::getInstrMapping(const 
MachineInstr &MI) const {
 case Intrinsic::amdgcn_swmmac_f32_16x16x32_fp8_bf8:
 case Intrinsic::amdgcn_swmmac_f32_16x16x32_bf8_fp8:
 case Intrinsic::amdgcn_swmmac_f32_16x16x32_bf8_bf8:
+case Intrinsic::amdgcn_cvt_pk_norm_i16_f16:
+case Intrinsic::amdgcn_cvt_pk_norm_u16_f16:
   

[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-17 Thread Mariya Podchishchaeva via cfe-commits

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


[clang] [CUDA][HIP] Add a __device__ version of std::__glibcxx_assert_fail() (PR #136133)

2025-04-17 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

> This patch is cruelly missing some tests. Is there a place for tests of this 
> kind? I haven't found an obvious one for other headers.

You may consider adding a test here 
https://github.com/llvm/llvm-test-suite/tree/main/External/HIP.

If possible, I would be happy to see std::array etc be used in device code.

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


[clang] [CUDA][HIP] Add a __device__ version of std::__glibcxx_assert_fail() (PR #136133)

2025-04-17 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

LGTM. The addition of the device version of std::__glibcxx_assert_fail() seems 
reasonable and straightforward. 

WDYT @Artem-B 

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


[clang] 90ddb54 - [clang][bytecode] Enter a non-constant context when revisiting (#136104)

2025-04-17 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-04-17T12:50:28+02:00
New Revision: 90ddb5444030b8d7cca6e91a27994e4fa9a6525d

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

LOG: [clang][bytecode] Enter a non-constant context when revisiting (#136104)

Otherwise, things like __builtin_is_constant_evaluated() return the
wrong value.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Interp.h
clang/lib/AST/ByteCode/InterpState.h
clang/lib/AST/ByteCode/Opcodes.td
clang/test/AST/ByteCode/builtin-constant-p.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 157e306e5cdb3..d3eabc513a9ac 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6466,8 +6466,13 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
 
   // In case we need to re-visit a declaration.
   auto revisit = [&](const VarDecl *VD) -> bool {
+if (!this->emitPushCC(VD->hasConstantInitialization(), E))
+  return false;
 auto VarState = this->visitDecl(VD, /*IsConstexprUnknown=*/true);
 
+if (!this->emitPopCC(E))
+  return false;
+
 if (VarState.notCreated())
   return true;
 if (!VarState)

diff  --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index bd58c2a88e9d9..49e2326186bf8 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2848,6 +2848,15 @@ inline bool EndSpeculation(InterpState &S, CodePtr OpPC) 
{
   return true;
 }
 
+inline bool PushCC(InterpState &S, CodePtr OpPC, bool Value) {
+  S.ConstantContextOverride = Value;
+  return true;
+}
+inline bool PopCC(InterpState &S, CodePtr OpPC) {
+  S.ConstantContextOverride = std::nullopt;
+  return true;
+}
+
 /// Do nothing and just abort execution.
 inline bool Error(InterpState &S, CodePtr OpPC) { return false; }
 

diff  --git a/clang/lib/AST/ByteCode/InterpState.h 
b/clang/lib/AST/ByteCode/InterpState.h
index 74001b80d9c00..528c1a24e7b05 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -127,7 +127,6 @@ class InterpState final : public State, public SourceMapper 
{
   SourceMapper *M;
   /// Allocator used for dynamic allocations performed via the program.
   DynamicAllocator Alloc;
-  std::optional ConstantContextOverride;
 
 public:
   /// Reference to the module containing all bytecode.
@@ -147,6 +146,7 @@ class InterpState final : public State, public SourceMapper 
{
   /// Things needed to do speculative execution.
   SmallVectorImpl *PrevDiags = nullptr;
   unsigned SpeculationDepth = 0;
+  std::optional ConstantContextOverride;
 
   llvm::SmallVector<
   std::pair>

diff  --git a/clang/lib/AST/ByteCode/Opcodes.td 
b/clang/lib/AST/ByteCode/Opcodes.td
index 5a9079fea0846..8451e54ad0c41 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -872,3 +872,6 @@ def GetTypeidPtr : Opcode { let Args = [ArgTypePtr]; }
 def DiagTypeid : Opcode;
 
 def CheckDestruction : Opcode;
+
+def PushCC : Opcode { let Args = [ArgBool]; }
+def PopCC : Opcode;

diff  --git a/clang/test/AST/ByteCode/builtin-constant-p.cpp 
b/clang/test/AST/ByteCode/builtin-constant-p.cpp
index ed9e606ed16aa..f5b16761bfdc9 100644
--- a/clang/test/AST/ByteCode/builtin-constant-p.cpp
+++ b/clang/test/AST/ByteCode/builtin-constant-p.cpp
@@ -121,3 +121,11 @@ constexpr int mutate6(bool mutate) {
 static_assert(mutate6(false) == 11);
 static_assert(mutate6(true) == 21); // ref-error {{static assertion failed}} \
 // ref-note {{evaluates to '10 == 21'}}
+
+#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+void g() {
+  /// f will be revisited when evaluating the static_assert, since it's
+  /// a local variable. But it should be visited in a non-constant context.
+  const float f = __builtin_is_constant_evaluated();
+  static_assert(fold(f == 0.0f));
+}



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


[clang] c536967 - Split _Countof tests into two files; NFC

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

Author: Aaron Ballman
Date: 2025-04-17T07:13:31-04:00
New Revision: c536967af123c30b43f186133e8719e0090f24a6

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

LOG: Split _Countof tests into two files; NFC

Post-commit review feedback during the language WG meeting requested
that I try to generalize the testing for this rather than only test on
a single target as we previously did.

The tests which are hard to generalize are the VLA tests, so those
still have specific triples in the RUN line, but have more coverage and
a comment explaining that the test should generalize to all targets.

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

Modified: 
clang/test/C/C2y/n3369_2.c

Removed: 




diff  --git a/clang/test/C/C2y/n3369_2.c b/clang/test/C/C2y/n3369_2.c
index 0cbf362d38d4e..9cab828b461b5 100644
--- a/clang/test/C/C2y/n3369_2.c
+++ b/clang/test/C/C2y/n3369_2.c
@@ -1,116 +1,26 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
-// RUN: %clang_cc1 -std=c2y -triple x86_64-unknown-unknown -emit-llvm -o - %s 
| FileCheck %s
+// RUN: %clang_cc1 -std=c2y -emit-llvm -o - %s | FileCheck %s
 
-// This tests the codegen behavior for _Countof.
-// CHECK-LABEL: define dso_local i32 @test1(
+// This tests the non-VLA codegen behavior for _Countof.
+
+typedef typeof(sizeof(0)) size_t;
+
+// CHECK-LABEL: define dso_local i64 @test1(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:[[ARRAY:%.*]] = alloca [12 x i32], align 16
-// CHECK-NEXT:ret i32 12
+// CHECK-NEXT:[[ARRAY:%.*]] = alloca [12 x i32], align
+// CHECK-NEXT:ret i64 12
 //
-int test1() {
+size_t test1() {
   int array[12];
   return _Countof(array);
 }
 
-// CHECK-LABEL: define dso_local i32 @test2(
-// CHECK-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
-// CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:[[N_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[SAVED_STACK:%.*]] = alloca ptr, align 8
-// CHECK-NEXT:[[__VLA_EXPR0:%.*]] = alloca i64, align 8
-// CHECK-NEXT:store i32 [[N]], ptr [[N_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[N_ADDR]], align 4
-// CHECK-NEXT:[[TMP1:%.*]] = zext i32 [[TMP0]] to i64
-// CHECK-NEXT:[[TMP2:%.*]] = call ptr @llvm.stacksave.p0()
-// CHECK-NEXT:store ptr [[TMP2]], ptr [[SAVED_STACK]], align 8
-// CHECK-NEXT:[[VLA:%.*]] = alloca i32, i64 [[TMP1]], align 16
-// CHECK-NEXT:store i64 [[TMP1]], ptr [[__VLA_EXPR0]], align 8
-// CHECK-NEXT:[[CONV:%.*]] = trunc i64 [[TMP1]] to i32
-// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[SAVED_STACK]], align 8
-// CHECK-NEXT:call void @llvm.stackrestore.p0(ptr [[TMP3]])
-// CHECK-NEXT:ret i32 [[CONV]]
-//
-int test2(int n) {
-  int array[n];
-  return _Countof(array);
-}
-
-// CHECK-LABEL: define dso_local i32 @test3(
-// CHECK-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
-// CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:[[N_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT:store i32 [[N]], ptr [[N_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[N_ADDR]], align 4
-// CHECK-NEXT:[[TMP1:%.*]] = zext i32 [[TMP0]] to i64
-// CHECK-NEXT:[[CONV:%.*]] = trunc i64 [[TMP1]] to i32
-// CHECK-NEXT:ret i32 [[CONV]]
-//
-int test3(int n) {
-  return _Countof(int[n]);
-}
-
-// CHECK-LABEL: define dso_local i32 @test4(
+// CHECK-LABEL: define dso_local i64 @test2(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:ret i32 100
+// CHECK-NEXT:ret i64 100
 //
-int test4() {
+size_t test2() {
   return _Countof(float[100]);
 }
-
-// CHECK-LABEL: define dso_local i32 @test5(
-// CHECK-SAME: i32 noundef [[N:%.*]]) #[[ATTR0]] {
-// CHECK-NEXT:  [[ENTRY:.*:]]
-// CHECK-NEXT:[[N_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[SAVED_STACK:%.*]] = alloca ptr, align 8
-// CHECK-NEXT:[[__VLA_EXPR0:%.*]] = alloca i64, align 8
-// CHECK-NEXT:[[X:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[Y:%.*]] = alloca i32, align 4
-// CHECK-NEXT:store i32 [[N]], ptr [[N_ADDR]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[N_ADDR]], align 4
-// CHECK-NEXT:[[TMP1:%.*]] = zext i32 [[TMP0]] to i64
-// CHECK-NEXT:[[TMP2:%.*]] = call ptr @llvm.stacksave.p0()
-// CHECK-NEXT:store ptr [[TMP2]], ptr [[SAVED_STACK]], align 8
-// CHECK-NEXT:[[VLA:%.*]] = alloca [7 x i32], i64 [[TMP1]], align 16
-// CHECK-NEXT:store i64 [[TMP1]], ptr [[__VLA_EXPR0]], align 8
-// CHECK-NEXT:[[CONV:%.*]] = trunc i64 [[TMP1]] to i32
-// CHECK-NEXT:store i32 [[CONV]], ptr [[X]], align 4
-// CHECK-NEXT:store i32 7, ptr [[Y]], align 4
-// CHECK-NEXT:[[TMP3:%.*]] = load i32, ptr [[X]], align 4
-// CHECK-NEXT:[[TMP4:%.*]] = load i32, ptr [[Y]], align

[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

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

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

Print the member pointer decl and the path.

>From ae8fac6c80a757a5ee3a0fa6e59d7546f71ce116 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 17 Apr 2025 13:44:50 +0200
Subject: [PATCH] [clang] Implement dump() for MemberPointer APValues

---
 clang/lib/AST/TextNodeDumper.cpp   | 16 ++--
 clang/test/AST/ast-dump-APValue-lvalue.cpp | 18 --
 clang/test/AST/ast-dump-APValue-todo.cpp   | 22 --
 3 files changed, 30 insertions(+), 26 deletions(-)
 delete mode 100644 clang/test/AST/ast-dump-APValue-todo.cpp

diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index c8b459ee78e6b..89567425f0d5f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -829,9 +829,21 @@ void TextNodeDumper::Visit(const APValue &Value, QualType 
Ty) {
 
 return;
   }
-  case APValue::MemberPointer:
-OS << "MemberPointer ";
+  case APValue::MemberPointer: {
+OS << "MemberPointer ";
+auto Path = Value.getMemberPointerPath();
+for (const CXXRecordDecl *D : Path) {
+  {
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << D->getDeclName();
+  }
+  OS << "::";
+}
+
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << Value.getMemberPointerDecl()->getDeclName();
 return;
+  }
   case APValue::AddrLabelDiff:
 OS << "AddrLabelDiff ";
 return;
diff --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp 
b/clang/test/AST/ast-dump-APValue-lvalue.cpp
index 333f7aa419377..51d22a5ba8b6d 100644
--- a/clang/test/AST/ast-dump-APValue-lvalue.cpp
+++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp
@@ -27,6 +27,16 @@ namespace std {
   class type_info;
 }
 
+struct P {
+  int x;
+};
+struct Q {
+  float m;
+};
+struct MP : P, Q {
+  int i;
+};
+
 void Test(int (&arr)[10]) {
   constexpr int *pi = &i;
   // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pi 'int 
*const' constexpr cinit
@@ -53,6 +63,10 @@ void Test(int (&arr)[10]) {
   // CHECK-NEXT:  |   |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, 
PathLength=0, Path=()
 
   constexpr const std::type_info* pti = &typeid(int);
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
-  // CHECK-NEXT:  |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
+  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
+  // CHECK-NEXT:  |   |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
+
+  constexpr int(MP::*pmi) = (int MP::*)&P::x;
+  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pmi 'int 
(MP::*const)' constexpr cinit
+  // CHECK-NEXT:  |-value: MemberPointer MP::x
 }
diff --git a/clang/test/AST/ast-dump-APValue-todo.cpp 
b/clang/test/AST/ast-dump-APValue-todo.cpp
deleted file mode 100644
index acaa82ba53b6f..0
--- a/clang/test/AST/ast-dump-APValue-todo.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test without serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:-ast-dump %s -ast-dump-filter Test \
-// RUN: | FileCheck --strict-whitespace --match-full-lines %s
-//
-// Test with serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 -emit-pch -o %t %s
-// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:   -include-pch %t -ast-dump-all -ast-dump-filter Test 
/dev/null \
-// RUN: | sed -e "s/ //" -e "s/ imported//" \
-// RUN: | FileCheck --strict-whitespace --match-full-lines %s
-
-int i;
-struct S {
-  int i;
-};
-
-void Test() {
-  constexpr int(S::*pmi) = &S::i;
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pmi 'int 
(S::*const)' constexpr cinit
-  // CHECK-NEXT:  |-value: MemberPointer 
-}

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


[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Print the member pointer decl and the path.

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


3 Files Affected:

- (modified) clang/lib/AST/TextNodeDumper.cpp (+14-2) 
- (modified) clang/test/AST/ast-dump-APValue-lvalue.cpp (+16-2) 
- (removed) clang/test/AST/ast-dump-APValue-todo.cpp (-22) 


``diff
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index c8b459ee78e6b..89567425f0d5f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -829,9 +829,21 @@ void TextNodeDumper::Visit(const APValue &Value, QualType 
Ty) {
 
 return;
   }
-  case APValue::MemberPointer:
-OS << "MemberPointer ";
+  case APValue::MemberPointer: {
+OS << "MemberPointer ";
+auto Path = Value.getMemberPointerPath();
+for (const CXXRecordDecl *D : Path) {
+  {
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << D->getDeclName();
+  }
+  OS << "::";
+}
+
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << Value.getMemberPointerDecl()->getDeclName();
 return;
+  }
   case APValue::AddrLabelDiff:
 OS << "AddrLabelDiff ";
 return;
diff --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp 
b/clang/test/AST/ast-dump-APValue-lvalue.cpp
index 333f7aa419377..51d22a5ba8b6d 100644
--- a/clang/test/AST/ast-dump-APValue-lvalue.cpp
+++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp
@@ -27,6 +27,16 @@ namespace std {
   class type_info;
 }
 
+struct P {
+  int x;
+};
+struct Q {
+  float m;
+};
+struct MP : P, Q {
+  int i;
+};
+
 void Test(int (&arr)[10]) {
   constexpr int *pi = &i;
   // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pi 'int 
*const' constexpr cinit
@@ -53,6 +63,10 @@ void Test(int (&arr)[10]) {
   // CHECK-NEXT:  |   |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, 
PathLength=0, Path=()
 
   constexpr const std::type_info* pti = &typeid(int);
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
-  // CHECK-NEXT:  |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
+  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
+  // CHECK-NEXT:  |   |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
+
+  constexpr int(MP::*pmi) = (int MP::*)&P::x;
+  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pmi 'int 
(MP::*const)' constexpr cinit
+  // CHECK-NEXT:  |-value: MemberPointer MP::x
 }
diff --git a/clang/test/AST/ast-dump-APValue-todo.cpp 
b/clang/test/AST/ast-dump-APValue-todo.cpp
deleted file mode 100644
index acaa82ba53b6f..0
--- a/clang/test/AST/ast-dump-APValue-todo.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test without serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:-ast-dump %s -ast-dump-filter Test \
-// RUN: | FileCheck --strict-whitespace --match-full-lines %s
-//
-// Test with serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 -emit-pch -o %t %s
-// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:   -include-pch %t -ast-dump-all -ast-dump-filter Test 
/dev/null \
-// RUN: | sed -e "s/ //" -e "s/ imported//" \
-// RUN: | FileCheck --strict-whitespace --match-full-lines %s
-
-int i;
-struct S {
-  int i;
-};
-
-void Test() {
-  constexpr int(S::*pmi) = &S::i;
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pmi 'int 
(S::*const)' constexpr cinit
-  // CHECK-NEXT:  |-value: MemberPointer 
-}

``




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


[clang] 4bd9b9e - Fix failing bot with changes to _Countof testing

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

Author: Aaron Ballman
Date: 2025-04-17T07:32:12-04:00
New Revision: 4bd9b9e9adf9db1a326e2f2fa616c714beb83c4f

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

LOG: Fix failing bot with changes to _Countof testing

This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/190/builds/18484

Added: 


Modified: 
clang/test/C/C2y/n3369_2.c

Removed: 




diff  --git a/clang/test/C/C2y/n3369_2.c b/clang/test/C/C2y/n3369_2.c
index 9cab828b461b5..3e9e14283497e 100644
--- a/clang/test/C/C2y/n3369_2.c
+++ b/clang/test/C/C2y/n3369_2.c
@@ -5,7 +5,7 @@
 
 typedef typeof(sizeof(0)) size_t;
 
-// CHECK-LABEL: define dso_local i64 @test1(
+// CHECK-LABEL: define{{( dso_local)?}} i64 @test1(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:[[ARRAY:%.*]] = alloca [12 x i32], align
@@ -16,7 +16,7 @@ size_t test1() {
   return _Countof(array);
 }
 
-// CHECK-LABEL: define dso_local i64 @test2(
+// CHECK-LABEL: define{{( dso_local)?}} i64 @test2(
 // CHECK-SAME: ) #[[ATTR0]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:ret i64 100



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


[clang] [llvm] [RISCV] Add processor definition for XiangShan-KunMingHu-V2R2 (PR #123193)

2025-04-17 Thread Pengcheng Wang via cfe-commits


@@ -558,6 +558,34 @@ def XIANGSHAN_NANHU : 
RISCVProcessorModel<"xiangshan-nanhu",
 TuneZExtWFusion,
 TuneShiftedZExtWFusion]>;
 
+def XIANGSHAN_KUNMINGHU : RISCVProcessorModel<"xiangshan-kunminghu",
+  NoSchedModel,
+  !listconcat(RVA23S64Features,
+  [FeatureStdExtZicsr,

wangpc-pp wrote:

https://github.com/llvm/llvm-project/pull/136134

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


[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

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

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


[clang] fb00fa5 - [clang] Implement dump() for MemberPointer APValues (#136130)

2025-04-17 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-04-17T14:52:23+02:00
New Revision: fb00fa56b51b191d026eec104905e416bf34bbda

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

LOG: [clang] Implement dump() for MemberPointer APValues (#136130)

Print the member pointer decl and the path.

Added: 


Modified: 
clang/lib/AST/TextNodeDumper.cpp
clang/test/AST/ast-dump-APValue-lvalue.cpp

Removed: 
clang/test/AST/ast-dump-APValue-todo.cpp



diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index c8b459ee78e6b..89567425f0d5f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -829,9 +829,21 @@ void TextNodeDumper::Visit(const APValue &Value, QualType 
Ty) {
 
 return;
   }
-  case APValue::MemberPointer:
-OS << "MemberPointer ";
+  case APValue::MemberPointer: {
+OS << "MemberPointer ";
+auto Path = Value.getMemberPointerPath();
+for (const CXXRecordDecl *D : Path) {
+  {
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << D->getDeclName();
+  }
+  OS << "::";
+}
+
+ColorScope Color(OS, ShowColors, DeclNameColor);
+OS << Value.getMemberPointerDecl()->getDeclName();
 return;
+  }
   case APValue::AddrLabelDiff:
 OS << "AddrLabelDiff ";
 return;

diff  --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp 
b/clang/test/AST/ast-dump-APValue-lvalue.cpp
index 333f7aa419377..51d22a5ba8b6d 100644
--- a/clang/test/AST/ast-dump-APValue-lvalue.cpp
+++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp
@@ -27,6 +27,16 @@ namespace std {
   class type_info;
 }
 
+struct P {
+  int x;
+};
+struct Q {
+  float m;
+};
+struct MP : P, Q {
+  int i;
+};
+
 void Test(int (&arr)[10]) {
   constexpr int *pi = &i;
   // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pi 'int 
*const' constexpr cinit
@@ -53,6 +63,10 @@ void Test(int (&arr)[10]) {
   // CHECK-NEXT:  |   |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, 
PathLength=0, Path=()
 
   constexpr const std::type_info* pti = &typeid(int);
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
-  // CHECK-NEXT:  |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
+  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
+  // CHECK-NEXT:  |   |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
+
+  constexpr int(MP::*pmi) = (int MP::*)&P::x;
+  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pmi 'int 
(MP::*const)' constexpr cinit
+  // CHECK-NEXT:  |-value: MemberPointer MP::x
 }

diff  --git a/clang/test/AST/ast-dump-APValue-todo.cpp 
b/clang/test/AST/ast-dump-APValue-todo.cpp
deleted file mode 100644
index acaa82ba53b6f..0
--- a/clang/test/AST/ast-dump-APValue-todo.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test without serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:-ast-dump %s -ast-dump-filter Test \
-// RUN: | FileCheck --strict-whitespace --match-full-lines %s
-//
-// Test with serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 -emit-pch -o %t %s
-// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:   -include-pch %t -ast-dump-all -ast-dump-filter Test 
/dev/null \
-// RUN: | sed -e "s/ //" -e "s/ imported//" \
-// RUN: | FileCheck --strict-whitespace --match-full-lines %s
-
-int i;
-struct S {
-  int i;
-};
-
-void Test() {
-  constexpr int(S::*pmi) = &S::i;
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pmi 'int 
(S::*const)' constexpr cinit
-  // CHECK-NEXT:  |-value: MemberPointer 
-}



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


[clang] [llvm] [LLVM] Add intrinsics for v_cvt_pk_norm_{i16, u16}_f16 (PR #135631)

2025-04-17 Thread via cfe-commits

github-actions[bot] wrote:




:warning: undef deprecator found issues in your code. :warning:



You can test this locally with the following command:


``bash
git diff -U0 --pickaxe-regex -S 
'([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 'HEAD~1' HEAD 
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.pk.norm.i16.f16.ll 
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.pk.norm.u16.f16.ll 
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
``




The following files introduce new uses of undef:
 - llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.pk.norm.i16.f16.ll
 - llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.pk.norm.u16.f16.ll

[Undef](https://llvm.org/docs/LangRef.html#undefined-values) is now deprecated 
and should only be used in the rare cases where no replacement is possible. For 
example, a load of uninitialized memory yields `undef`. You should use `poison` 
values for placeholders instead.

In tests, avoid using `undef` and having tests that trigger undefined behavior. 
If you need an operand with some unimportant value, you can add a new argument 
to the function and use that instead.

For example, this is considered a bad practice:
```llvm
define void @fn() {
  ...
  br i1 undef, ...
}
```

Please use the following instead:
```llvm
define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}
```

Please refer to the [Undefined Behavior 
Manual](https://llvm.org/docs/UndefinedBehavior.html) for more information.



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


[clang] [clang] Handle instantiated members to determine visibility (PR #136128)

2025-04-17 Thread Andrew Savonichev via cfe-commits

https://github.com/asavonic updated 
https://github.com/llvm/llvm-project/pull/136128

>From 79a70bb55f864a14a7bc7d4ec99af44b86b801ba Mon Sep 17 00:00:00 2001
From: Andrew Savonichev 
Date: Thu, 17 Apr 2025 20:18:52 +0900
Subject: [PATCH] [clang] Handle instantiated members to determine visibility

As reported in issue #103477, visibility of instantiated member
functions used to be ignored when calculating visibility of a
specialization.

This patch modifies `getLVForClassMember` to look up for a source
template for an instantiated member, and changes `mergeTemplateLV` to
apply it.

A similar issue was reported in #31462, but it seems that `extern`
declaration with visibility prevents the function from being emitted
as hidden. This behavior seems correct, even though GCC emits it as
with default visibility instead.

Both tests from #103477 and #31462 are added as LIT tests `test72` and
`test73` respectively.
---
 clang/lib/AST/Decl.cpp   | 13 +++---
 clang/test/CodeGenCXX/visibility.cpp | 38 +++-
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ad1cb01592e9b..b59619892979a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -400,9 +400,9 @@ void LinkageComputer::mergeTemplateLV(
   FunctionTemplateDecl *temp = specInfo->getTemplate();
   // Merge information from the template declaration.
   LinkageInfo tempLV = getLVForDecl(temp, computation);
-  // The linkage of the specialization should be consistent with the
-  // template declaration.
-  LV.setLinkage(tempLV.getLinkage());
+  // The linkage and visibility of the specialization should be
+  // consistent with the template declaration.
+  LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
 
   // Merge information from the template parameters.
   LinkageInfo paramsLV =
@@ -1051,6 +1051,13 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
 if (const auto *redeclTemp = dyn_cast(temp)) {
   if (isExplicitMemberSpecialization(redeclTemp)) {
 explicitSpecSuppressor = temp->getTemplatedDecl();
+  } else if (const RedeclarableTemplateDecl *from =
+ redeclTemp->getInstantiatedFromMemberTemplate()) {
+// If no explicit visibility is specified yet, and this is an
+// instantiated member of a template, look up visibility there
+// as well.
+LinkageInfo fromLV = from->getLinkageAndVisibility();
+LV.mergeMaybeWithVisibility(fromLV, considerVisibility);
   }
 }
   }
diff --git a/clang/test/CodeGenCXX/visibility.cpp 
b/clang/test/CodeGenCXX/visibility.cpp
index e1061f3dbd18f..b69278a71d48e 100644
--- a/clang/test/CodeGenCXX/visibility.cpp
+++ b/clang/test/CodeGenCXX/visibility.cpp
@@ -1457,9 +1457,45 @@ namespace test71 {
   // CHECK-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
   // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIiE3barIiEET_v(
   // CHECK-LABEL: define linkonce_odr hidden noundef i64 
@_ZN6test713fooIlE3zedEv(
-  // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
+  // CHECK-LABEL: define linkonce_odr hidden noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
   // CHECK-HIDDEN-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
   // CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIiE3barIiEET_v(
   // CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i64 
@_ZN6test713fooIlE3zedEv(
   // CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
 }
+
+// https://github.com/llvm/llvm-project/issues/103477
+namespace test72 {
+  template 
+  struct t {
+template 
+static HIDDEN void bar() {}
+  };
+
+  void test() {
+  t::bar<1>();
+  }
+  // CHECK-LABEL: define linkonce_odr hidden void 
@_ZN6test721tIcE3barILi1EEEvv(
+  // CHECK-HIDDEN-LABEL: define linkonce_odr hidden void 
@_ZN6test721tIcE3barILi1EEEvv(
+}
+
+// https://github.com/llvm/llvm-project/issues/31462
+namespace test73 {
+  template  struct s {
+template 
+__attribute__((__visibility__("hidden"))) U should_not_be_exported();
+  };
+
+  template  template  U s::should_not_be_exported() {
+return U();
+  }
+
+  extern template struct __attribute__((__visibility__("default"))) s;
+
+  int f() {
+s o;
+return o.should_not_be_exported();
+  }
+  // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test731sIiE22should_not_be_exportedIiEET_v(
+  // CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 
@_ZN6test731sIiE22should_not_be_exportedIiEET_v(
+}

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


[clang-tools-extra] [clang-tidy] Fix bugprone-tagged-union-member-count false-positive (PR #135831)

2025-04-17 Thread Baranov Victor via cfe-commits
=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?=,=?utf-8?b?R8OhYm9yIFTDs3RodsOhcmk=?Message-ID:
In-Reply-To: 


vbvictor wrote:

I'm not sure if we need to check explicitly if some `struct`/`enum` comes from 
`std` since all `std` namespace is already placed in system headers unless some 
niece cases like `std::hash<>`. I'm okay leaving it as is, but please then add 
test with `std` namespace because now only system headers are tested.

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


[clang] [clang][bytecode] Reject assignments in C (PR #136126)

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

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

Similar to what the current interpreter does.

>From 646321191ac22da6ff4c83031ea995da4a2f8756 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 17 Apr 2025 13:02:45 +0200
Subject: [PATCH] [clang][bytecode] Reject assignments in C

Similar to what the current interpreter does.
---
 clang/lib/AST/ByteCode/Compiler.cpp |  6 +-
 clang/test/AST/ByteCode/c2y.c   | 23 +++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/AST/ByteCode/c2y.c

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 157e306e5cdb3..d6c8817610742 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -863,8 +863,12 @@ bool Compiler::VisitBinaryOperator(const 
BinaryOperator *BO) {
   return this->VisitPointerArithBinOp(BO);
   }
 
-  // Assignmentes require us to evalute the RHS first.
+  // Assignments require us to evalute the RHS first.
   if (BO->getOpcode() == BO_Assign) {
+// We don't support assignments in C.
+if (!Ctx.getLangOpts().CPlusPlus)
+  return this->emitInvalid(BO);
+
 if (!visit(RHS) || !visit(LHS))
   return false;
 if (!this->emitFlip(*LT, *RT, BO))
diff --git a/clang/test/AST/ByteCode/c2y.c b/clang/test/AST/ByteCode/c2y.c
new file mode 100644
index 0..bbb163ab83833
--- /dev/null
+++ b/clang/test/AST/ByteCode/c2y.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=expected,both 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=ref,both
+
+// both-no-diagnostics
+
+struct S {
+  int x;
+  char c;
+  float f;
+};
+
+#define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)]
+
+struct T {
+  DECL_BUFFER(struct S, buffer);
+};
+
+int quorble() {
+  DECL_BUFFER(struct T, buffer);
+  ((struct S *)((struct T *)buffer)->buffer)->x = 12;
+  const struct S *s_ptr = (struct S *)((struct T *)buffer)->buffer;
+  return s_ptr->x;
+}

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


[clang] [clang] Handle instantiated members to determine visibility (PR #136128)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Andrew Savonichev (asavonic)


Changes

As reported in issue #103477, visibility of instantiated member 
functions used to be ignored when calculating visibility of a specialization.

This patch modifies `getLVForClassMember` to look up for a source template for 
an instantiated member, and changes `mergeTemplateLV` to apply it.

A similar issue was reported in #31462, but it seems that `extern` 
declaration with visibility prevents the function from being emitted as hidden. 
This behavior seems correct, even though GCC emits it as with default 
visibility instead.

Both tests from #103477 and #31462 are added as LIT tests 
`test72` and `test73` respectively.

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


2 Files Affected:

- (modified) clang/lib/AST/Decl.cpp (+10-3) 
- (modified) clang/test/CodeGenCXX/visibility.cpp (+37-1) 


``diff
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ad1cb01592e9b..b59619892979a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -400,9 +400,9 @@ void LinkageComputer::mergeTemplateLV(
   FunctionTemplateDecl *temp = specInfo->getTemplate();
   // Merge information from the template declaration.
   LinkageInfo tempLV = getLVForDecl(temp, computation);
-  // The linkage of the specialization should be consistent with the
-  // template declaration.
-  LV.setLinkage(tempLV.getLinkage());
+  // The linkage and visibility of the specialization should be
+  // consistent with the template declaration.
+  LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
 
   // Merge information from the template parameters.
   LinkageInfo paramsLV =
@@ -1051,6 +1051,13 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
 if (const auto *redeclTemp = dyn_cast(temp)) {
   if (isExplicitMemberSpecialization(redeclTemp)) {
 explicitSpecSuppressor = temp->getTemplatedDecl();
+  } else if (const RedeclarableTemplateDecl *from =
+ redeclTemp->getInstantiatedFromMemberTemplate()) {
+// If no explicit visibility is specified yet, and this is an
+// instantiated member of a template, look up visibility there
+// as well.
+LinkageInfo fromLV = from->getLinkageAndVisibility();
+LV.mergeMaybeWithVisibility(fromLV, considerVisibility);
   }
 }
   }
diff --git a/clang/test/CodeGenCXX/visibility.cpp 
b/clang/test/CodeGenCXX/visibility.cpp
index e1061f3dbd18f..b69278a71d48e 100644
--- a/clang/test/CodeGenCXX/visibility.cpp
+++ b/clang/test/CodeGenCXX/visibility.cpp
@@ -1457,9 +1457,45 @@ namespace test71 {
   // CHECK-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
   // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIiE3barIiEET_v(
   // CHECK-LABEL: define linkonce_odr hidden noundef i64 
@_ZN6test713fooIlE3zedEv(
-  // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
+  // CHECK-LABEL: define linkonce_odr hidden noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
   // CHECK-HIDDEN-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
   // CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 
@_ZN6test713fooIiE3barIiEET_v(
   // CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i64 
@_ZN6test713fooIlE3zedEv(
   // CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i32 
@_ZN6test713fooIlE3barIiEET_v(
 }
+
+// https://github.com/llvm/llvm-project/issues/103477
+namespace test72 {
+  template 
+  struct t {
+template 
+static HIDDEN void bar() {}
+  };
+
+  void test() {
+  t::bar<1>();
+  }
+  // CHECK-LABEL: define linkonce_odr hidden void 
@_ZN6test721tIcE3barILi1EEEvv(
+  // CHECK-HIDDEN-LABEL: define linkonce_odr hidden void 
@_ZN6test721tIcE3barILi1EEEvv(
+}
+
+// https://github.com/llvm/llvm-project/issues/31462
+namespace test73 {
+  template  struct s {
+template 
+__attribute__((__visibility__("hidden"))) U should_not_be_exported();
+  };
+
+  template  template  U s::should_not_be_exported() {
+return U();
+  }
+
+  extern template struct __attribute__((__visibility__("default"))) s;
+
+  int f() {
+s o;
+return o.should_not_be_exported();
+  }
+  // CHECK-LABEL: define linkonce_odr noundef i32 
@_ZN6test731sIiE22should_not_be_exportedIiEET_v(
+  // CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 
@_ZN6test731sIiE22should_not_be_exportedIiEET_v(
+}

``




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


[clang-tools-extra] [include-cleaner] rename enabled flags to `disable-*` (PR #132991)

2025-04-17 Thread Mohamed Emad via cfe-commits

hulxv wrote:

> Do we need a deprecation period for this change? This will break anyone using 
> the old names in scripts and whatnot.
> 
> Also, the changes will need something in the release notes so users know 
> about the new names.

Is there a specific way to mark flags as deprecated? I didn't find anything 
like that in 
[`Support/CommandLine`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Support/CommandLine.cpp).
 It will be useful if we implement something like that to mark a specific flag 
as deprecated, and it will appear when the user shows the help message

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


[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

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

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

LGTM! Precommit CI failures appear to be unrelated.

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


[clang] 51295d6 - [clang][bytecode] Reject assignments in C (#136126)

2025-04-17 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-04-17T13:39:27+02:00
New Revision: 51295d6d56f938b878ca0e2bb0a749eb801e8202

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

LOG: [clang][bytecode] Reject assignments in C (#136126)

Similar to what the current interpreter does.

Added: 
clang/test/AST/ByteCode/c2y.c

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 d3eabc513a9ac..3e53f2a2c8557 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -863,8 +863,12 @@ bool Compiler::VisitBinaryOperator(const 
BinaryOperator *BO) {
   return this->VisitPointerArithBinOp(BO);
   }
 
-  // Assignmentes require us to evalute the RHS first.
+  // Assignments require us to evalute the RHS first.
   if (BO->getOpcode() == BO_Assign) {
+// We don't support assignments in C.
+if (!Ctx.getLangOpts().CPlusPlus)
+  return this->emitInvalid(BO);
+
 if (!visit(RHS) || !visit(LHS))
   return false;
 if (!this->emitFlip(*LT, *RT, BO))

diff  --git a/clang/test/AST/ByteCode/c2y.c b/clang/test/AST/ByteCode/c2y.c
new file mode 100644
index 0..bbb163ab83833
--- /dev/null
+++ b/clang/test/AST/ByteCode/c2y.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=expected,both 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=ref,both
+
+// both-no-diagnostics
+
+struct S {
+  int x;
+  char c;
+  float f;
+};
+
+#define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)]
+
+struct T {
+  DECL_BUFFER(struct S, buffer);
+};
+
+int quorble() {
+  DECL_BUFFER(struct T, buffer);
+  ((struct S *)((struct T *)buffer)->buffer)->x = 12;
+  const struct S *s_ptr = (struct S *)((struct T *)buffer)->buffer;
+  return s_ptr->x;
+}



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


[clang] [clang][bytecode] Reject assignments in C (PR #136126)

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

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


[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

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


@@ -8623,6 +8624,13 @@ inline bool Type::isIntegralOrEnumerationType() const {
 inline bool Type::isBooleanType() const {
   if (const auto *BT = dyn_cast(CanonicalType))
 return BT->getKind() == BuiltinType::Bool;
+  if (const EnumType *ET = dyn_cast(CanonicalType)) {

AaronBallman wrote:

> I'm not entirely sure it makes sense to handle enums here

I don't believe it makes sense to report true for an enum type. An enumeration 
type is never a boolean type in C or in C++. An enumeration can have a boolean 
underlying type, but it's still an enumeration type rather than a boolean type.

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


[clang] [clang] Implement StmtPrinter for EmbedExpr (PR #135957)

2025-04-17 Thread Mariya Podchishchaeva via cfe-commits


@@ -435,6 +435,7 @@ ExprResult Parser::createEmbedExpr() {
   ExprResult Res;
   ASTContext &Context = Actions.getASTContext();
   SourceLocation StartLoc = ConsumeAnnotationToken();
+

Fznamznon wrote:

```suggestion
```

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


[clang] [clang] Handle instantiated members to determine visibility (PR #136128)

2025-04-17 Thread Andrew Savonichev via cfe-commits

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


[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

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

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

LGTM assuming precommit CI is happy too.

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


[clang] [CUDA][HIP] Add a __device__ version of std::__glibcxx_assert_fail() (PR #136133)

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

https://github.com/jmmartinez created 
https://github.com/llvm/llvm-project/pull/136133

libstdc++ 15 uses the non-constexpr function
std::__glibcxx_assert_fail() to trigger compilation errors when the 
__glibcxx_assert(cond) macro is used in a constantly evaluated context.

Compilation fails when using code from the libstdc++ (such as std::array) on 
device code, since these assertions invoke a non-constexpr host function from 
device code.

This patch proposes a cuda wrapper header "bits/c++config.h" which adds a 
__device__ version of std::__glibcxx_assert_fail().

From 66d1103d813c9a087ff8239a035badc34039d113 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Thu, 17 Apr 2025 13:41:55 +0200
Subject: [PATCH] [CUDA][HIP] Add a __device__ version of
 std::__glibcxx_assert_fail()

libstdc++ 15 uses the non-constexpr function
std::__glibcxx_assert_fail() to trigger compilation errors when the
__glibcxx_assert(cond) macro is used in a constantly evaluated context.

Compilation fails when using code from the libstdc++ (such as
std::array) on device code, since these assertions invoke a
non-constexpr host function from device code.

This patch proposes a cuda wrapper header "bits/c++config.h" which adds a
__device__ version of std::__glibcxx_assert_fail().
---
 clang/lib/Headers/CMakeLists.txt  |  1 +
 .../Headers/cuda_wrappers/bits/c++config.h| 39 +++
 2 files changed, 40 insertions(+)
 create mode 100644 clang/lib/Headers/cuda_wrappers/bits/c++config.h

diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index acf49e40c447e..54395e053dbc4 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -333,6 +333,7 @@ set(cuda_wrapper_files
 )
 
 set(cuda_wrapper_bits_files
+  cuda_wrappers/bits/c++config.h
   cuda_wrappers/bits/shared_ptr_base.h
   cuda_wrappers/bits/basic_string.h
   cuda_wrappers/bits/basic_string.tcc
diff --git a/clang/lib/Headers/cuda_wrappers/bits/c++config.h 
b/clang/lib/Headers/cuda_wrappers/bits/c++config.h
new file mode 100644
index 0..583e595f7f529
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/bits/c++config.h
@@ -0,0 +1,39 @@
+// libstdc++ uses the non-constexpr function std::__glibcxx_assert_fail()
+// to trigger compilation errors when the __glibcxx_assert(cond) macro
+// is used in a constexpr context.
+// Compilation fails when using code from the libstdc++ (such as std::array) on
+// device code, since these assertions invoke a non-constexpr host function 
from
+// device code.
+//
+// To work around this issue, we declare our own device version of the function
+
+#ifndef __CLANG_CUDA_WRAPPERS_BITS_CPP_CONFIG
+#define __CLANG_CUDA_WRAPPERS_BITS_CPP_CONFIG
+
+#include_next 
+
+#if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
+
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
+namespace std {
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
+#endif
+__device__
+__attribute__((__always_inline__, __visibility__("default"))) inline void
+__glibcxx_assert_fail() {}
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+#endif
+} // namespace std
+#endif
+
+#endif
+
+#endif

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


[clang] [CUDA][HIP] Add a __device__ version of std::__glibcxx_assert_fail() (PR #136133)

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

jmmartinez wrote:

This patch is cruelly missing some tests. Is there a place for tests of this 
kind? I haven't found an obvious one for other headers.

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


[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

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

tbaederr wrote:

> Can you do the JSONNodeDumper as well so the two stay somewhat in-sync?

Looks like that goes through `APValue::printPretty()`, so nothing to do for 
that.

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


[clang] [clang] Handle instantiated members to determine visibility (PR #136128)

2025-04-17 Thread Andrew Savonichev via cfe-commits

asavonic wrote:

Libcxx tests failed. I'll check them tomorrow.
```
Failed Tests (15):
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/extents/assert.conversion.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/extents/assert.ctor_from_array.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/extents/assert.ctor_from_integral.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/extents/assert.ctor_from_span.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/extents/assert.obs.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_left/assert.conversion.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_left/assert.ctor.extents.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_left/assert.ctor.layout_right.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_left/assert.ctor.layout_stride.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_right/assert.conversion.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_right/assert.ctor.extents.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_right/assert.ctor.layout_left.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_right/assert.ctor.layout_stride.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_stride/assert.ctor.extents_array.pass.cpp
  llvm-libc++-shared.cfg.in :: 
libcxx/containers/views/mdspan/layout_stride/assert.ctor.extents_span.pass.cpp
```

```
# | 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/libcxx/test/libcxx/containers/views/mdspan/extents/assert.conversion.pass.cpp:39:29:
 error: declaration of 'dynamic_extent' must be imported from module 
'std.span.fwd' before it is required
# |39 |   constexpr size_t D = std::dynamic_extent;
# |   | ^
# | 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-bt7k7-1/llvm-project/github-pull-requests/build/runtimes/runtimes-bins/libcxx/test-suite-install/include/c++/v1/__fwd/span.h:28:25:
 note: declaration here is not visible
# |28 | inline constexpr size_t dynamic_extent = 
numeric_limits::max();
# |   | ^
# | 1 error generated.
```


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


[clang] [clang] Fix a use-after-free in expression evaluation (PR #118480)

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

AaronBallman wrote:

> > > ping, is this still a problem?
> > 
> > 
> > yes, this is still happening. but I am currently lacking cycles to dig 
> > deeper into expression evaluation to see if this is the right fix given the 
> > reproducer. @VitaNuo was to take a look with some limited capacity, but I 
> > think she's also in a similar situation as me :D. If anyone wants to take 
> > over/help, feel free to do so. But I'll wait for an update from @VitaNuo, 
> > in case she already made progress here.
> 
> Has there been any chance to get back into this yet?

CC @kadircet @VitaNuo 

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


[clang] [CUDA][HIP] Add a __device__ version of std::__glibcxx_assert_fail() (PR #136133)

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

jmmartinez wrote:

See 
https://github.com/gcc-mirror/gcc/blob/c237297ee596545552f48ec9582d7d16703d8949/libstdc%2B%2B-v3/include/bits/c%2B%2Bconfig#L645-L659
 for the problematic libstdc++ snippet

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


[clang] 4041791 - [clang] Implement StmtPrinter for EmbedExpr (#135957)

2025-04-17 Thread via cfe-commits

Author: Mariya Podchishchaeva
Date: 2025-04-17T15:15:07+02:00
New Revision: 40417915a161e87b398f1cc3e9b7c159207abd77

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

LOG: [clang] Implement StmtPrinter for EmbedExpr (#135957)

Tries to avoid memory leaks previously caused by saving filename by
allocating memory in the preprocessor.

Fixes https://github.com/llvm/llvm-project/issues/132641
Fixes https://github.com/llvm/llvm-project/issues/107869

-

Co-authored-by: Aaron Ballman 

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Expr.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/StmtPrinter.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Preprocessor/embed_weird.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f640697e1817..0ea8498351c24 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -426,6 +426,9 @@ Bug Fixes in This Version
   using C++23 "deducing this" did not have a diagnostic location (#GH135522)
 
 - Fixed a crash when a ``friend`` function is redefined as deleted. (#GH135506)
+- Fixed a crash when ``#embed`` appears as a part of a failed constant
+  evaluation. The crashes were happening during diagnostics emission due to
+  unimplemented statement printer. (#GH132641)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 529c6228bfa19..a83320a7ddec2 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4961,6 +4961,9 @@ class SourceLocExpr final : public Expr {
 /// Stores data related to a single #embed directive.
 struct EmbedDataStorage {
   StringLiteral *BinaryData;
+  // FileName string already includes braces, i.e. it is  for a
+  // directive #embed .
+  StringRef FileName;
   size_t getDataElementCount() const { return BinaryData->getByteLength(); }
 };
 
@@ -5007,6 +5010,7 @@ class EmbedExpr final : public Expr {
   SourceLocation getEndLoc() const { return EmbedKeywordLoc; }
 
   StringLiteral *getDataStringLiteral() const { return Data->BinaryData; }
+  StringRef getFileName() const { return Data->FileName; }
   EmbedDataStorage *getData() const { return Data; }
 
   unsigned getStartingElementPos() const { return Begin; }

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 24bb524783e93..19d54edf23faf 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2762,7 +2762,7 @@ class Preprocessor {
 const FileEntry *LookupFromFile = nullptr);
   void HandleEmbedDirectiveImpl(SourceLocation HashLoc,
 const LexEmbedParametersResult &Params,
-StringRef BinaryContents);
+StringRef BinaryContents, StringRef FileName);
 
   // File inclusion.
   void HandleIncludeDirective(SourceLocation HashLoc, Token &Tok,
@@ -3066,6 +3066,7 @@ class EmptylineHandler {
 /// preprocessor to the parser through an annotation token.
 struct EmbedAnnotationData {
   StringRef BinaryData;
+  StringRef FileName;
 };
 
 /// Registry of pragma handlers added by plugins

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index fe37fd7701ce3..c167f8df28acd 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7256,7 +7256,7 @@ class Sema final : public SemaBase {
 
   // #embed
   ExprResult ActOnEmbedExpr(SourceLocation EmbedKeywordLoc,
-StringLiteral *BinaryData);
+StringLiteral *BinaryData, StringRef FileName);
 
   // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy,

diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index aae10fd3bd885..c6c49c6c1ba4d 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1284,7 +1284,11 @@ void StmtPrinter::VisitSourceLocExpr(SourceLocExpr 
*Node) {
 }
 
 void StmtPrinter::VisitEmbedExpr(EmbedExpr *Node) {
-  llvm::report_fatal_error("Not implemented");
+  // FIXME: Embed parameters are not reflected in the AST, so there is no way 
to
+  // print them yet.
+  OS << "#embed ";
+  OS << Node->getFileName();
+  OS << NL;
 }
 
 void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 8411526019f3e..49a4e24923a5e 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++

[clang] 9bd0c87 - [clang-format] Fix a bug in BWACS_MultiLine (#135906)

2025-04-17 Thread via cfe-commits

Author: Owen Pan
Date: 2025-04-16T18:48:10-07:00
New Revision: 9bd0c8726a5e3fd4f76e84692bd920dfca7a8d7f

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

LOG: [clang-format] Fix a bug in BWACS_MultiLine (#135906)

Fix #51940

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index ef5f07e2c62ee..144983f675828 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4153,8 +4153,18 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
  ChildSize + Current->SpacesRequiredBefore;
 }
 
-if (Current->is(TT_CtorInitializerColon))
+if (Current->is(TT_ControlStatementLBrace)) {
+  if (Style.ColumnLimit > 0 &&
+  Style.BraceWrapping.AfterControlStatement ==
+  FormatStyle::BWACS_MultiLine &&
+  Line.Level * Style.IndentWidth + Line.Last->TotalLength >
+  Style.ColumnLimit) {
+Current->CanBreakBefore = true;
+Current->MustBreakBefore = true;
+  }
+} else if (Current->is(TT_CtorInitializerColon)) {
   InFunctionDecl = false;
+}
 
 // FIXME: Only calculate this if CanBreakBefore is true once static
 // initializers etc. are sorted out.
@@ -5586,12 +5596,13 @@ static bool isAllmanLambdaBrace(const FormatToken &Tok) 
{
 
 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
  const FormatToken &Right) const {
-  const FormatToken &Left = *Right.Previous;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0 &&
   (!Style.RemoveEmptyLinesInUnwrappedLines || &Right == Line.First)) {
 return true;
   }
 
+  const FormatToken &Left = *Right.Previous;
+
   if (Style.BreakFunctionDefinitionParameters && Line.MightBeFunctionDecl &&
   Line.mightBeFunctionDefinition() && Left.MightBeFunctionDeclParen &&
   Left.ParameterCount > 0) {

diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 617d46ad281d5..6806ab18312ea 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -424,43 +424,14 @@ class LineJoiner {
  : 0;
 }
 // Try to merge a control statement block with left brace wrapped.
-if (NextLine.First->is(tok::l_brace)) {
-  if ((TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
-   tok::kw_for, tok::kw_switch, tok::kw_try,
-   tok::kw_do, TT_ForEachMacro) ||
-   (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
-TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
-  Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_MultiLine) {
-// If possible, merge the next line's wrapped left brace with the
-// current line. Otherwise, leave it on the next line, as this is a
-// multi-line control statement.
-return (Style.ColumnLimit == 0 || TheLine->Level * Style.IndentWidth +
-  TheLine->Last->TotalLength <=
-  Style.ColumnLimit)
-   ? 1
-   : 0;
-  }
-  if (TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
-  tok::kw_for, TT_ForEachMacro)) {
-return (Style.BraceWrapping.AfterControlStatement ==
-FormatStyle::BWACS_Always)
-   ? tryMergeSimpleBlock(I, E, Limit)
-   : 0;
-  }
-  if (TheLine->First->isOneOf(tok::kw_else, tok::kw_catch) &&
-  Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_MultiLine) {
-// This case if 
diff erent from the upper BWACS_MultiLine processing
-// in that a preceding r_brace is not on the same line as else/catch
-// most likely because of BeforeElse/BeforeCatch set to true.
-// If the line length doesn't fit ColumnLimit, leave l_brace on the
-// next line to respect the BWACS_MultiLine.
-return (Style.ColumnLimit == 0 ||
-TheLine->Last->TotalLength <= Style.ColumnLimit)
-   ? 1
-   : 0;
-  }
+if (NextLine.First->is(TT_ControlStatementLBrace)) {
+  // If possible, merge the next line's wrapped left brace with the
+  // current line. Otherwise, leave it on the next 

[clang] [clang] [CodeGen] fix crash when Ty isDependentType in CodeGenFunction::EmitAutoVarAlloca (PR #135643)

2025-04-17 Thread via cfe-commits

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


[clang] [clang] Adds a RecursiveASTEnterExitVisitor (PR #136136)

2025-04-17 Thread Christopher Taylor via cfe-commits

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


[clang] [clang] Adds a RecursiveASTEnterExitVisitor data type (PR #136136)

2025-04-17 Thread Christopher Taylor via cfe-commits

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


[clang] [clang] Implement dump() for MemberPointer APValues (PR #136130)

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

AaronBallman wrote:

> > Can you do the JSONNodeDumper as well so the two stay somewhat in-sync?
> 
> Looks like that goes through `APValue::printPretty()`, so nothing to do for 
> that.

Ah, good to know, thanks!

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


[clang] [clang] Adds a RecursiveASTEnterExitVisitor (PR #136136)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Christopher Taylor (ct-clmsn)


Changes

@Sirraide : This is my first PR to clang and llvm. The PR creates a 
RecursiveASTVisitor type called `RecursiveASTEnterExitVisitor` that allows 
users to implement Visit methods before visiting an AST node and after visiting 
an AST node. The additional functionality is additive in nature and extends the 
existing work. Users can optionally implement `VisitEnter`, 
`Visit`, and `VisitExit`. This 
functionality makes visitation method behavior explicitly defined.

---

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


39 Files Affected:

- (added) clang/include/clang/AST/RecursiveASTEnterExitVisitor.h (+4187) 
- (modified) clang/include/clang/AST/RecursiveASTVisitor.h (+3) 
- (modified) clang/include/clang/AST/StmtOpenACC.h (+1) 
- (modified) clang/unittests/Tooling/CMakeLists.txt (+34) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTestDeclVisitor.cpp (+138) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTestPostOrderVisitor.cpp 
(+114) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTestTypeLocVisitor.cpp 
(+100) 
- (added) clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/Attr.cpp 
(+51) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/BitfieldInitializer.cpp
 (+34) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CXXBoolLiteralExpr.cpp
 (+36) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CXXMemberCall.cpp 
(+97) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CXXMethodDecl.cpp 
(+73) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CXXOperatorCallExprTraverser.cpp
 (+36) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CallbacksBinaryOperator.cpp
 (+211) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CallbacksCallExpr.cpp 
(+249) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CallbacksCommon.h 
(+102) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CallbacksCompoundAssignOperator.cpp
 (+212) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CallbacksLeaf.cpp 
(+285) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/CallbacksUnaryOperator.cpp
 (+201) 
- (added) clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/Class.cpp 
(+42) 
- (added) clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/Concept.cpp 
(+167) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/ConstructExpr.cpp 
(+66) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/DeclRefExpr.cpp 
(+116) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/DeductionGuide.cpp 
(+83) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/ImplicitCtor.cpp 
(+40) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/ImplicitCtorInitializer.cpp
 (+52) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/InitListExprPostOrder.cpp
 (+36) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/InitListExprPostOrderNoQueue.cpp
 (+40) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/InitListExprPreOrder.cpp
 (+48) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/InitListExprPreOrderNoQueue.cpp
 (+37) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/IntegerLiteral.cpp 
(+32) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/LambdaDefaultCapture.cpp
 (+34) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/LambdaExpr.cpp (+99) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/LambdaTemplateParams.cpp
 (+52) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/MemberPointerTypeLoc.cpp
 (+58) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/NestedNameSpecifiers.cpp
 (+73) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/ParenExpr.cpp (+30) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/TemplateArgumentLocTraverser.cpp
 (+38) 
- (added) 
clang/unittests/Tooling/RecursiveASTEnterExitVisitorTests/TraversalScope.cpp 
(+58) 


``diff
diff --git a/clang/include/clang/AST/RecursiveASTEnterExitVisitor.h 
b/clang/include/clang/AST/RecursiveASTEnterExitVisitor.h
new file mode 100644
index 0..fd275cc75e9a5
--- /dev/null
+++ b/clang/include/clang/AST/RecursiveASTEnterExitVisitor.h
@@ -0,0 +1,4187 @@
+//===--- RecursiveASTEnterExitVisitor.h - Recursive AST Visitor --*- 
C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license informati

[clang] [clang] Adds a RecursiveASTEnterExitVisitor (PR #136136)

2025-04-17 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [CUDA][HIP] Add a __device__ version of std::__glibcxx_assert_fail() (PR #136133)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Juan Manuel Martinez Caamaño (jmmartinez)


Changes

libstdc++ 15 uses the non-constexpr function
std::__glibcxx_assert_fail() to trigger compilation errors when the 
__glibcxx_assert(cond) macro is used in a constantly evaluated context.

Compilation fails when using code from the libstdc++ (such as std::array) on 
device code, since these assertions invoke a non-constexpr host function from 
device code.

This patch proposes a cuda wrapper header "bits/c++config.h" which adds a 
__device__ version of std::__glibcxx_assert_fail().

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


2 Files Affected:

- (modified) clang/lib/Headers/CMakeLists.txt (+1) 
- (added) clang/lib/Headers/cuda_wrappers/bits/c++config.h (+39) 


``diff
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index acf49e40c447e..54395e053dbc4 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -333,6 +333,7 @@ set(cuda_wrapper_files
 )
 
 set(cuda_wrapper_bits_files
+  cuda_wrappers/bits/c++config.h
   cuda_wrappers/bits/shared_ptr_base.h
   cuda_wrappers/bits/basic_string.h
   cuda_wrappers/bits/basic_string.tcc
diff --git a/clang/lib/Headers/cuda_wrappers/bits/c++config.h 
b/clang/lib/Headers/cuda_wrappers/bits/c++config.h
new file mode 100644
index 0..583e595f7f529
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/bits/c++config.h
@@ -0,0 +1,39 @@
+// libstdc++ uses the non-constexpr function std::__glibcxx_assert_fail()
+// to trigger compilation errors when the __glibcxx_assert(cond) macro
+// is used in a constexpr context.
+// Compilation fails when using code from the libstdc++ (such as std::array) on
+// device code, since these assertions invoke a non-constexpr host function 
from
+// device code.
+//
+// To work around this issue, we declare our own device version of the function
+
+#ifndef __CLANG_CUDA_WRAPPERS_BITS_CPP_CONFIG
+#define __CLANG_CUDA_WRAPPERS_BITS_CPP_CONFIG
+
+#include_next 
+
+#if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED
+
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
+namespace std {
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#endif
+#endif
+__device__
+__attribute__((__always_inline__, __visibility__("default"))) inline void
+__glibcxx_assert_fail() {}
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
+#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_END_NAMESPACE_VERSION
+#endif
+} // namespace std
+#endif
+
+#endif
+
+#endif

``




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


[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)

2025-04-17 Thread Stephen Tozer via cfe-commits

SLTozer wrote:

> It would be great to also have some documentation that shows step by step how 
> you've used these abilities to find the bugs you've found.

SGTM - I think that should come in a separate patch. I have a branch with all 
my changes on it (not stable, I rebase semi-regularly) 
[here](https://github.com/SLTozer/llvm-project/tree/llvm-project-coverage-tracker),
 where the patches can be divided into 3 categories: bug fixes, the coverage 
tracking feature, and a variety of random tweaks and features I've added to 
display info and help myself triage bugs. I haven't yet put any work into 
getting the last category merge-ready, but I think that would be the 
appropriate place for such documentation to go.

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


[clang] [clang][bytecode] Check if operator delete calls are in the right frame (PR #136141)

2025-04-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

This is only permitted in a std::allocator::deallocate frame.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+35) 
- (modified) clang/test/AST/ByteCode/new-delete.cpp (+12) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 31d97d9060142..34553301ef630 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1651,6 +1651,41 @@ static bool interp__builtin_operator_delete(InterpState 
&S, CodePtr OpPC,
   const Expr *Source = nullptr;
   const Block *BlockToDelete = nullptr;
 
+  if (S.checkingPotentialConstantExpression())
+return false;
+
+  // This is permitted only within a call to std::allocator::deallocate.
+  bool DeallocateFrameFound = false;
+  for (const InterpFrame *F = Frame; F; F = F->Caller) {
+const Function *Func = F->getFunction();
+if (!Func)
+  continue;
+const auto *MD = dyn_cast_if_present(Func->getDecl());
+if (!MD)
+  continue;
+const IdentifierInfo *FnII = MD->getIdentifier();
+if (!FnII || !FnII->isStr("deallocate"))
+  continue;
+
+const auto *CTSD =
+dyn_cast(MD->getParent());
+if (!CTSD)
+  continue;
+
+const IdentifierInfo *ClassII = CTSD->getIdentifier();
+const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
+if (CTSD->isInStdNamespace() && ClassII && ClassII->isStr("allocator") &&
+TAL.size() >= 1 && TAL[0].getKind() == TemplateArgument::Type) {
+  DeallocateFrameFound = true;
+  break;
+}
+  }
+
+  if (!DeallocateFrameFound) {
+S.FFDiag(Call);
+return true;
+  }
+
   {
 const Pointer &Ptr = S.Stk.peek();
 
diff --git a/clang/test/AST/ByteCode/new-delete.cpp 
b/clang/test/AST/ByteCode/new-delete.cpp
index 5ddd7070f6710..e1b81e9a7963e 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -992,6 +992,18 @@ namespace ZeroSizeSub {
// both-note {{in call to}}
 }
 
+namespace WrongFrame {
+  constexpr int foo() {
+int *p = nullptr;
+__builtin_operator_delete(p); // both-note {{subexpression not valid in a 
constant expression}}
+
+return 1;
+  }
+  static_assert(foo()); // both-error {{not an integral constant expression}} \
+// both-note {{in call to}}
+
+}
+
 #else
 /// Make sure we reject this prior to C++20
 constexpr int a() { // both-error {{never produces a constant expression}}

``




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


[clang] [clang][ExprConst] Diagnose ptr subs with non-zero offset (PR #135938)

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

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/135938

>From 4a7fbbc62ee5b90627d053a641182d62bac38d09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Wed, 16 Apr 2025 10:34:33 +0200
Subject: [PATCH] [clang][ExprConst] Diagnose ptr subs with non-zero offset

---
 clang/lib/AST/ExprConstant.cpp   | 3 ---
 clang/test/AST/ByteCode/arrays.cpp   | 2 +-
 clang/test/SemaCXX/constant-expression-cxx11.cpp | 4 
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d1cc722fb7945..b14ff21a8ebc2 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -14764,9 +14764,6 @@ bool IntExprEvaluator::VisitBinaryOperator(const 
BinaryOperator *E) {
 // Reject differing bases from the normal codepath; we special-case
 // comparisons to null.
 if (!HasSameBase(LHSValue, RHSValue)) {
-  // Handle &&A - &&B.
-  if (!LHSValue.Offset.isZero() || !RHSValue.Offset.isZero())
-return Error(E);
   const Expr *LHSExpr = LHSValue.Base.dyn_cast();
   const Expr *RHSExpr = RHSValue.Base.dyn_cast();
 
diff --git a/clang/test/AST/ByteCode/arrays.cpp 
b/clang/test/AST/ByteCode/arrays.cpp
index f60cc19b09bd2..e50839e0f0877 100644
--- a/clang/test/AST/ByteCode/arrays.cpp
+++ b/clang/test/AST/ByteCode/arrays.cpp
@@ -107,7 +107,7 @@ static_assert(k1 == 1, "");
 static_assert((&arr[0] - &arr[1]) == -1, "");
 
 constexpr int k2 = &arr2[1] - &arr[0]; // both-error {{must be initialized by 
a constant expression}} \
-   // expected-note {{arithmetic involving 
unrelated objects}}
+   // both-note {{arithmetic involving 
unrelated objects}}
 
 static_assert((arr + 0) == arr, "");
 static_assert(&arr[0] == arr, "");
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp 
b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index c35f3a5632a05..28016da925ef9 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -409,6 +409,10 @@ constexpr int a = 0;
 constexpr int b = 1;
 constexpr int n = &b - &a; // expected-error {{must be initialized by a 
constant expression}} \
// expected-note {{arithmetic involving unrelated 
objects '&b' and '&a' has unspecified value}}
+constexpr static int arrk[2] = {1,2};
+constexpr static int arrk2[2] = {3,4};
+constexpr int k2 = &arrk[1] - &arrk2[0]; // expected-error {{must be 
initialized by a constant expression}} \
+ // expected-note {{arithmetic 
involving unrelated objects}}
 
 namespace MaterializeTemporary {
 

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


[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

2025-04-17 Thread Stephen Tozer via cfe-commits

SLTozer wrote:

> Is this ready to go? I can't recall if we ultimately accepted the RFC.

My interpretation of the RFC is that there was a general acceptance of `-Og = 
-O1 + -fextend-variable-liveness`, so with the acceptance here I believe this 
is ready!

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


[clang] [clang-tools-extra] [lldb] Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (PR #136077)

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

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


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


[clang] Mark the file opened by DeserializedDeclsSourceRangePrinter as a text file (PR #135842)

2025-04-17 Thread Zibi Sarbinowski via cfe-commits

zibi2 wrote:

The 2 failing checks above don't seem to be related and they happen in other 
PRs. I'm going to merge this in.

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


[clang] Mark the file opened by DeserializedDeclsSourceRangePrinter as a text file (PR #135842)

2025-04-17 Thread Zibi Sarbinowski via cfe-commits

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


[clang] bd0b903 - Mark the file opened by DeserializedDeclsSourceRangePrinter as a text file (#135842)

2025-04-17 Thread via cfe-commits

Author: Zibi Sarbinowski
Date: 2025-04-17T10:08:57-04:00
New Revision: bd0b903a91721570e0bc98f7ed8b0aaf2f2a628b

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

LOG: Mark the file opened by DeserializedDeclsSourceRangePrinter as a text file 
(#135842)

This PR will fix the following lit failure seeing on z/OS and most likely on 
Windows:

`FAIL: Clang :: Frontend/dump-minimization-hints.cpp`

Without `OF_TextWithCRLF` flag, a file is treated as binary and is read 
improperly, at least on z/OS.

Added: 


Modified: 
clang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index bd084aa94fc37..1c4dec08575d1 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -312,7 +312,7 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
&CI,
 std::error_code ErrorCode;
 auto FileStream = std::make_unique(
 DumpDeserializedDeclarationRangesPath, ErrorCode,
-llvm::sys::fs::OF_None);
+llvm::sys::fs::OF_TextWithCRLF);
 if (!ErrorCode) {
   
Consumers.push_back(std::make_unique(
   CI.getSourceManager(), std::move(FileStream)));



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


[clang] [clang] Handle instantiated members to determine visibility (PR #136128)

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

erichkeane wrote:

This seems reasonable to me, but I'd like to see if @mizvekov has thoughts? 

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


[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

2025-04-17 Thread Stephen Tozer via cfe-commits

https://github.com/SLTozer updated 
https://github.com/llvm/llvm-project/pull/118026

>From 351971bbff4e77b0f36cd92cd1a881584d17a9e7 Mon Sep 17 00:00:00 2001
From: Stephen Tozer 
Date: Thu, 28 Nov 2024 13:53:20 +
Subject: [PATCH 1/2] Enable -fextend-lifetimes at -Og

---
 clang/docs/CommandGuide/clang.rst| 7 +--
 clang/docs/ReleaseNotes.rst  | 4 
 clang/lib/Driver/ToolChains/Clang.cpp| 8 +++-
 clang/test/Driver/extend-variable-liveness.c | 3 ++-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 42aac7b25d93c..68e9e07ed0005 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -443,8 +443,11 @@ Code Generation Options
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
-:option:`-Og` Like :option:`-O1`. In future versions, this option might
-disable different optimizations in order to improve debuggability.
+:option:`-Og` Similar to :option:`-O1`, but with slightly reduced
+optimization and better variable visibility. The same optimizations are run
+as at :option:`-O1`, but the :option:`-fextend-variable-liveness` flag is
+also set, which tries to prevent optimizations from reducing the liveness 
of
+user variables, improving their availability when debugging.
 
 :option:`-O` Equivalent to :option:`-O1`.
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f640697e1817..23a3d481e66c2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -219,6 +219,10 @@ Modified Compiler Flags
 
 - `-Wpadded` option implemented for the `x86_64-windows-msvc` target. Fixes 
#61702
 
+- The ``-Og`` optimization flag now sets ``-fextend-variable-liveness``, a new
+  compiler flag which trades a small amount of optimization in exchange for
+  improved variable visibility.
+
 Removed Compiler Flags
 -
 
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8506a5c00e7bc..b2dd4b3b54869 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7681,7 +7681,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (Args.hasArg(options::OPT_fretain_comments_from_system_headers))
 CmdArgs.push_back("-fretain-comments-from-system-headers");
 
-  Args.AddLastArg(CmdArgs, options::OPT_fextend_variable_liveness_EQ);
+  if (Arg *A = Args.getLastArg(options::OPT_fextend_variable_liveness_EQ)) {
+A->render(Args, CmdArgs);
+  } else if (Arg *A = Args.getLastArg(options::OPT_O_Group);
+ A && A->containsValue("g")) {
+// Set -fextend-variable-liveness=all by default at -Og.
+CmdArgs.push_back("-fextend-variable-liveness=all");
+  }
 
   // Forward -fcomment-block-commands to -cc1.
   Args.AddAllArgs(CmdArgs, options::OPT_fcomment_block_commands);
diff --git a/clang/test/Driver/extend-variable-liveness.c 
b/clang/test/Driver/extend-variable-liveness.c
index bbfb2ece6f297..99a5409ceccea 100644
--- a/clang/test/Driver/extend-variable-liveness.c
+++ b/clang/test/Driver/extend-variable-liveness.c
@@ -1,7 +1,8 @@
 // Tests that -fextend-variable-liveness and its aliases are correctly passed
-// by the driver.
+// by the driver, and are set by default at -Og.
 
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,DEFAULT
+// RUN: %clang -### -Og -c %s 2>&1 | FileCheck %s --check-prefixes=CHECK,ALL
 // RUN: %clang -fextend-variable-liveness=none -### -c %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK,NONE
 // RUN: %clang -fextend-variable-liveness=this -### -c %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK,THIS
 // RUN: %clang -fextend-variable-liveness=all -### -c %s 2>&1 | FileCheck %s 
--check-prefixes=CHECK,ALL

>From e5037472fd98a7f4a2d9f8298799f46a8b647f87 Mon Sep 17 00:00:00 2001
From: Stephen Tozer 
Date: Thu, 17 Apr 2025 15:14:55 +0100
Subject: [PATCH 2/2] Update docs to fit current compiler/doc state

---
 clang/docs/CommandGuide/clang.rst | 2 +-
 clang/docs/ReleaseNotes.rst   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 68e9e07ed0005..a1e738f1afec8 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -445,7 +445,7 @@ Code Generation Options
 
 :option:`-Og` Similar to :option:`-O1`, but with slightly reduced
 optimization and better variable visibility. The same optimizations are run
-as at :option:`-O1`, but the :option:`-fextend-variable-liveness` flag is
+as at :option:`-O1`, but the ``-fextend-variable-liveness`` flag is
 also set, which tries to prevent optimizations from reducing the liveness 
of
 user variables, improving their availability when debugging.
 
diff --git a/clang/docs/ReleaseN

[clang] [CIR] Upstream support for record packing and padding (PR #136036)

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

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

I'm not sure I did a great job reviewing all the layout code, but didn't see 
anything of concern.  I'm somewhat fearful that we're pulling in existing 
"scary" code from Classic-CodeGen that is a 'thar be dragons' though.

At the same time, re-engineering this at this time also seems scary as well, so 
I think we have to live with it for now?  Anyway, please let others review this 
before merging.

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


[clang] Fixed issue #128882: don't warn if 1st argument to 'getcwd' is NULL (PR #135720)

2025-04-17 Thread Balazs Benics via cfe-commits


@@ -105,9 +105,6 @@ void errno_getcwd(char *Buf, size_t Sz) {
 clang_analyzer_eval(errno != 0);   // expected-warning{{TRUE}}
 clang_analyzer_eval(Path == NULL); // expected-warning{{TRUE}}
 if (errno) {}  // no warning
-  } else if (Path == NULL) {
-clang_analyzer_eval(errno != 0);   // expected-warning{{TRUE}}
-if (errno) {}  // no warning

steakhal wrote:

Why did you drop this branch?

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


[clang] Fixed issue #128882: don't warn if 1st argument to 'getcwd' is NULL (PR #135720)

2025-04-17 Thread Balazs Benics via cfe-commits

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


[clang] [CIR] Upstream support for record packing and padding (PR #136036)

2025-04-17 Thread Henrich Lauko via cfe-commits


@@ -225,17 +235,108 @@ void RecordType::complete(ArrayRef members, bool 
packed, bool padded) {
 
//===--===//
 
 llvm::TypeSize
-RecordType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout,
-  ::mlir::DataLayoutEntryListRef params) const {
-  assert(!cir::MissingFeatures::recordTypeLayoutInfo());
-  return llvm::TypeSize::getFixed(8);
+RecordType::getTypeSizeInBits(const mlir::DataLayout &dataLayout,
+  mlir::DataLayoutEntryListRef params) const {
+  if (!layoutInfo)
+computeSizeAndAlignment(dataLayout);
+  return llvm::TypeSize::getFixed(
+  mlir::cast(layoutInfo).getSize() * 8);
 }
 
 uint64_t
 RecordType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
 ::mlir::DataLayoutEntryListRef params) const {
-  assert(!cir::MissingFeatures::recordTypeLayoutInfo());
-  return 4;
+  if (!layoutInfo)
+computeSizeAndAlignment(dataLayout);
+  return mlir::cast(layoutInfo).getAlignment();
+}
+
+void RecordType::computeSizeAndAlignment(
+const mlir::DataLayout &dataLayout) const {
+  assert(isComplete() && "Cannot get layout of incomplete records");
+  // Do not recompute.
+  if (layoutInfo)

xlauko wrote:

Just tested locally on clangir tests, this condition is never met, so it 
supports my claim that it does not really cache anything.

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


  1   2   3   4   5   >