[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-22 Thread Petr Polezhaev via cfe-commits

https://github.com/petr-polezhaev updated 
https://github.com/llvm/llvm-project/pull/122606

>From 994d7bfaf416b5015c5004365e199769e26dffc4 Mon Sep 17 00:00:00 2001
From: Petr Polezhaev 
Date: Sat, 11 Jan 2025 21:21:16 +0300
Subject: [PATCH] [clangd] Support .clangd command line modifications in
 ScanningAllProjectModules

---
 .../clangd/GlobalCompilationDatabase.cpp  | 10 +
 .../clangd/GlobalCompilationDatabase.h|  3 ++
 clang-tools-extra/clangd/ProjectModules.h |  7 +++
 .../clangd/ScanningProjectModules.cpp | 38 +---
 .../unittests/PrerequisiteModulesTest.cpp | 44 +--
 5 files changed, 83 insertions(+), 19 deletions(-)

diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 71e97ac4efd673..2b1da4be5c1bd6 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -830,6 +830,16 @@ bool OverlayCDB::setCompileCommand(PathRef File,
   return true;
 }
 
+std::unique_ptr
+OverlayCDB::getProjectModules(PathRef File) const {
+  auto MDB = DelegatingCDB::getProjectModules(File);
+  MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command,
+  PathRef CommandPath) {
+Mangler(Command, CommandPath);
+  });
+  return std::move(MDB);
+}
+
 DelegatingCDB::DelegatingCDB(const GlobalCompilationDatabase *Base)
 : Base(Base) {
   if (Base)
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.h 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.h
index f8349c6efecb01..1d636d73664bee 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.h
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.h
@@ -209,6 +209,9 @@ class OverlayCDB : public DelegatingCDB {
   setCompileCommand(PathRef File,
 std::optional CompilationCommand);
 
+  std::unique_ptr
+  getProjectModules(PathRef File) const override;
+
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */
diff --git a/clang-tools-extra/clangd/ProjectModules.h 
b/clang-tools-extra/clangd/ProjectModules.h
index 3b9b564a87da01..48d52ac9deb893 100644
--- a/clang-tools-extra/clangd/ProjectModules.h
+++ b/clang-tools-extra/clangd/ProjectModules.h
@@ -9,8 +9,10 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROJECTMODULES_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PROJECTMODULES_H
 
+#include "support/Function.h"
 #include "support/Path.h"
 #include "support/ThreadsafeFS.h"
+#include "clang/Tooling/CompilationDatabase.h"
 
 #include 
 
@@ -36,11 +38,16 @@ namespace clangd {
 /// `[:partition-name]`. So module names covers 
partitions.
 class ProjectModules {
 public:
+  using CommandMangler =
+  llvm::unique_function;
+
   virtual std::vector getRequiredModules(PathRef File) = 0;
   virtual PathRef
   getSourceForModuleName(llvm::StringRef ModuleName,
  PathRef RequiredSrcFile = PathRef()) = 0;
 
+  virtual void setCommandMangler(CommandMangler Mangler) {}
+
   virtual ~ProjectModules() = default;
 };
 
diff --git a/clang-tools-extra/clangd/ScanningProjectModules.cpp 
b/clang-tools-extra/clangd/ScanningProjectModules.cpp
index 92f75ef7d5c25a..e4dc11c1c28958 100644
--- a/clang-tools-extra/clangd/ScanningProjectModules.cpp
+++ b/clang-tools-extra/clangd/ScanningProjectModules.cpp
@@ -48,7 +48,8 @@ class ModuleDependencyScanner {
   };
 
   /// Scanning the single file specified by \param FilePath.
-  std::optional scan(PathRef FilePath);
+  std::optional
+  scan(PathRef FilePath, const ProjectModules::CommandMangler &Mangler);
 
   /// Scanning every source file in the current project to get the
   ///  to  map.
@@ -57,7 +58,7 @@ class ModuleDependencyScanner {
   /// a global module dependency scanner to monitor every file. Or we
   /// can simply require the build systems (or even the end users)
   /// to provide the map.
-  void globalScan();
+  void globalScan(const ProjectModules::CommandMangler &Mangler);
 
   /// Get the source file from the module name. Note that the language
   /// guarantees all the module names are unique in a valid program.
@@ -69,7 +70,9 @@ class ModuleDependencyScanner {
 
   /// Return the direct required modules. Indirect required modules are not
   /// included.
-  std::vector getRequiredModules(PathRef File);
+  std::vector
+  getRequiredModules(PathRef File,
+ const ProjectModules::CommandMangler &Mangler);
 
 private:
   std::shared_ptr CDB;
@@ -87,7 +90,8 @@ class ModuleDependencyScanner {
 };
 
 std::optional
-ModuleDependencyScanner::scan(PathRef FilePath) {
+ModuleDependencyScanner::scan(PathRef FilePath,
+  const ProjectModules::CommandMangler &Mangler) {
   auto Candidates = CDB->getCompileCommands(FilePath);
   if (Candidates.empty())
 return std::nullopt;
@@ -97,10 +101,8 @@ ModuleDependencyScanner::scan(PathRef F

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2025-01-22 Thread Aniket Lal via cfe-commits


@@ -1085,8 +1085,10 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const 
CGBlockInfo &blockInfo) {
   blockAddr.getPointer(), 
ConvertType(blockInfo.getBlockExpr()->getType()));
 
   if (IsOpenCL) {
-CGM.getOpenCLRuntime().recordBlockInfo(blockInfo.BlockExpression, InvokeFn,
-   result, blockInfo.StructureType);
+CGM.getOpenCLRuntime().recordBlockInfo(
+blockInfo.BlockExpression, InvokeFn, result, blockInfo.StructureType,
+CurGD && CurGD.isDeclOpenCLKernel() &&
+(CurGD.getKernelReferenceKind() == KernelReferenceKind::Kernel));

lalaniket8 wrote:

I have implemented the emission of kernels as directly calling its respective 
stubs. The kernel body only consists of a call to the stub. The stub contains 
the kernel body and is emitted with `alwaysinline` attribute. 

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


[clang-tools-extra] [clang-tidy] Add ClangQueryChecks config option (PR #123734)

2025-01-22 Thread via cfe-commits


@@ -126,8 +127,15 @@ struct ClangTidyOptions {
   using StringPair = std::pair;
   using OptionMap = llvm::StringMap;
 
+  struct QueryCheckValue {
+std::string Source;

DeNiCoN wrote:

It is used to dump the config back. As for example in the "Check config dump" 
test 
https://github.com/llvm/llvm-project/pull/123734/files#diff-3bffe1dc09dda3286149e7d1d46efbf11d0113d76262384b2b7c486677d11f22R47

I think I should add a comment line to that field, It wasn't obvious for me too 
at the beginning should the source be saved or not

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


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-01-22 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-x86_64-debian-fast` 
running on `gribozavr4` while building `clang` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: AST/ByteCode/cxx2a.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -cc1 
-internal-isystem /b/1/clang-x86_64-debian-fast/llvm.obj/lib/clang/20/include 
-nostdsysteminc -std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/cxx2a.cpp
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -cc1 -internal-isystem 
/b/1/clang-x86_64-debian-fast/llvm.obj/lib/clang/20/include -nostdsysteminc 
-std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/cxx2a.cpp
error: 'both-error' diagnostics expected but not seen: 
  File /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/cxx2a.cpp 
Line 142: constant expression
error: 'both-note' diagnostics expected but not seen: 
  File /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/cxx2a.cpp 
Line 142: typeid applied to object 'extern_b2' whose dynamic type is not 
constant
2 errors generated.

--




```



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


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-01-22 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` 
running on `gribozavr4` while building `clang` at step 6 
"test-build-unified-tree-check-clang".

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


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

```
Step 6 (test-build-unified-tree-check-clang) failure: test (failure)
 TEST 'Clang :: AST/ByteCode/cxx2a.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 
-internal-isystem /b/1/llvm-x86_64-debian-dylib/build/lib/clang/20/include 
-nostdsysteminc -std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem 
/b/1/llvm-x86_64-debian-dylib/build/lib/clang/20/include -nostdsysteminc 
-std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp
error: 'both-error' diagnostics expected but not seen: 
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp 
Line 142: constant expression
error: 'both-note' diagnostics expected but not seen: 
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp 
Line 142: typeid applied to object 'extern_b2' whose dynamic type is not 
constant
2 errors generated.

--




```



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


[clang-tools-extra] [clang-tidy] Add ClangQueryChecks config option (PR #123734)

2025-01-22 Thread via cfe-commits

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: YunQiang Su (wzssyqa)


Changes

Don't Evaluate RHS in if directive when short circuit. Examples include
   #if 0 && another_condition
   #if 1 || another_condition

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


2 Files Affected:

- (modified) clang/lib/Lex/PPExpressions.cpp (+27-1) 
- (added) clang/test/Preprocessor/directive-short-circuit.c (+74) 


``diff
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index a3b1384f0fa1d6..7e413ec6076642 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -624,7 +624,33 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, 
unsigned MinPrec,
 
 // Consume the operator, remembering the operator's location for reporting.
 SourceLocation OpLoc = PeekTok.getLocation();
-PP.LexNonComment(PeekTok);
+
+if (!RHSIsLive && (Operator == tok::ampamp || Operator == tok::pipepipe)) {
+  unsigned ThisPrec = PeekPrec;
+  while (true) {
+PP.LexUnexpandedNonComment(PeekTok);
+if (PeekTok.is(tok::l_paren)) {
+  unsigned NestParen = 1;
+  while (true) {
+PP.LexUnexpandedNonComment(PeekTok);
+if (PeekTok.is(tok::l_paren))
+  NestParen++;
+else if (PeekTok.is(tok::r_paren))
+  NestParen--;
+if (NestParen == 0)
+  break;
+  }
+  PP.LexUnexpandedNonComment(PeekTok);
+}
+PeekPrec = getPrecedence(PeekTok.getKind());
+if (PeekPrec <= ThisPrec) {
+  LHS.setEnd(PeekTok.getEndLoc());
+  break;
+}
+  }
+  continue;
+} else
+  PP.LexNonComment(PeekTok);
 
 PPValue RHS(LHS.getBitWidth());
 // Parse the RHS of the operator.
diff --git a/clang/test/Preprocessor/directive-short-circuit.c 
b/clang/test/Preprocessor/directive-short-circuit.c
new file mode 100644
index 00..d137f8198cbbcf
--- /dev/null
+++ b/clang/test/Preprocessor/directive-short-circuit.c
@@ -0,0 +1,74 @@
+// RUN: %clang -E -MD -MF - %s | FileCheck -check-prefix ZERO_AND_HAS_INCLUDE 
%s
+//
+// ZERO_AND_HAS_INCLUDE-NOT: limits.h
+//
+#if 0 && __has_include()
+#include 
+#endif
+
+#if 4==5 && __has_include()
+#include 
+#endif
+
+#if defined(_THIS_IS_NOT_DEFINED) && __has_include()
+#include 
+#endif
+
+#if 0 && (__has_include())
+#include 
+#endif
+
+#if 4==5 && (__has_include())
+#include 
+#endif
+
+#if defined(_THIS_IS_NOT_DEFINED) && (__has_include())
+#include 
+#endif
+
+#if 0 && (5==5 && __has_include())
+#include 
+#endif
+
+#if 1 && (4==5 && __has_include())
+#include 
+#endif
+
+
+
+
+
+
+#if 1 || __has_include()
+XX
+#endif
+#if 5==5 || __has_include()
+XX
+#endif
+
+#if defined(__clang__) || __has_include()
+XX
+#endif
+
+#if 1 || (__has_include())
+#endif
+
+#if 5==5 || (__has_include())
+XX
+#endif
+
+#if defined(__clang__) || (__has_include())
+XX
+#endif
+
+#if 1 && (5==5 || __has_include())
+XX
+#endif
+
+#if 1 || (5==5 || __has_include())
+XX
+#endif
+
+#if 0 || (5==5 || __has_include())
+XX
+#endif

``




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


[clang] [clang-tools-extra] Clang/Preprocessor: Not add headers of __has_include into DepColloctor (PR #120673)

2025-01-22 Thread YunQiang Su via cfe-commits

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


[clang] [PS4/PS5][Driver] Observe /target/lib for libraries (PR #123350)

2025-01-22 Thread Edd Dawson via cfe-commits

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


[clang] 1a1dbac - [PS4/PS5][Driver] Observe /target/lib for libraries (#123350)

2025-01-22 Thread via cfe-commits

Author: Edd Dawson
Date: 2025-01-22T10:46:17Z
New Revision: 1a1dbac5bc4eab4239b365c1b296e2729031a62e

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

LOG: [PS4/PS5][Driver] Observe /target/lib for libraries (#123350)

On PS5, if a custom --sysroot is supplied, `/target/lib` should
be added to the library search paths (this already occurs if the default
`--sysroot` is not overridden). Until now, this has been hardcoded as a
downstream patch in lld. Add it to the driver so that the private patch
can be removed.

On PS4 the library search paths remain unchanged. The proprietary linker
will continue to handle this aspect.

On either platform, warn if `/target/lib` is absent.
Previously, such warnings were emitted only when the default --sysroot
was not overridden.

SIE tracker: TOOLCHAIN-16704

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/ps4-sdk-root.c
clang/test/Driver/ps5-linker.c
clang/test/Driver/ps5-sdk-root.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index fd4c2f9bf68cd6..e1187ce48c3e4c 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -490,7 +490,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const 
llvm::Triple &Triple,
 
   bool Linking = !Args.hasArg(options::OPT_E, options::OPT_c, options::OPT_S,
   options::OPT_emit_ast);
-  if (!CustomSysroot && Linking) {
+  if (Linking) {
 SmallString<128> Dir(SDKLibraryRootDir);
 llvm::sys::path::append(Dir, "target/lib");
 if (CheckSDKPartExists(Dir, "system libraries"))

diff  --git a/clang/test/Driver/ps4-sdk-root.c 
b/clang/test/Driver/ps4-sdk-root.c
index 78eb1ce2ba6302..6e5f1e28958ad6 100644
--- a/clang/test/Driver/ps4-sdk-root.c
+++ b/clang/test/Driver/ps4-sdk-root.c
@@ -1,10 +1,10 @@
 /// PS4 clang emits warnings when SDK headers (/target/include/) or
-/// libraries (/target/lib/) are missing, unless the user takes 
control
-/// of search paths, when corresponding existence checks are skipped.
+/// libraries (/target/lib/) are missing. If the the user takes 
control
+/// of header search paths, the existence check for /target/include is
+/// skipped.
 ///
 /// User control of header search is assumed if `--sysroot`, `-isysroot`,
-/// `-nostdinc` or `-nostdlibinc` is supplied. User control of library search
-/// is assumed if `--sysroot` is supplied.
+/// `-nostdinc` or `-nostdlibinc` is supplied.
 ///
 /// Warnings are emitted if a specified `-isysroot` or `--sysroot` does not
 /// exist.
@@ -46,22 +46,23 @@
 // RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c -isysroot . 2>&1 | 
FileCheck -check-prefixes=NO-WARN %s
 // RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -c --sysroot=. 2>&1 | 
FileCheck -check-prefixes=NO-WARN %s
 
-/// --sysroot disables the existence check for libraries and headers.
-// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=. 2>&1 | 
FileCheck -check-prefix=NO-WARN %s
+/// --sysroot disables the existence check for headers. The check for libraries
+/// remains.
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=. 2>&1 | 
FileCheck -check-prefixes=WARN-SYS-LIBS,NO-WARN %s
 
 /// -isysroot overrides --sysroot for header search, but not library search.
-// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot . --sysroot=.. 
2>&1 | FileCheck -check-prefixes=ISYSTEM,NO-WARN %s
-// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=.. -isysroot . 
2>&1 | FileCheck -check-prefixes=ISYSTEM,NO-WARN %s
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot . 
--sysroot=%t.inconly 2>&1 | FileCheck 
-check-prefixes=ISYSTEM,WARN-SYS-LIBS,NO-WARN %s
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=%t.inconly 
-isysroot . 2>&1 | FileCheck -check-prefixes=ISYSTEM,WARN-SYS-LIBS,NO-WARN %s
 
 /// Warnings are emitted if non-existent --sysroot/-isysroot are supplied.
-// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot . 
2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
-// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot foo --sysroot=. 
2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
-// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot bar 
2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYSROOT2,NO-WARN %s
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot 
%t.both 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,WARN-SYS-LIBS,NO-WARN %s
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s -isysroot foo 
--sysroot=%t.both 2>&1 | FileCheck -check-prefixes=WARN-SYSROOT,NO-WARN %s
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s --sysroot=foo -isysroot bar 

[clang] [clang-format] Add null-terminated path option (#123921) (PR #123926)

2025-01-22 Thread Nikolaos Chatzikonstantinou via cfe-commits

https://github.com/createyourpersonalaccount created 
https://github.com/llvm/llvm-project/pull/123926

This makes the `git clang-format` tool compose nicely with other shell 
utilities in case of maliciously (or innocently) crafted filenames.

>From 9dfbb9a3cc7f6bc557bc1ccf25cc727a02c4274c Mon Sep 17 00:00:00 2001
From: Nikolaos Chatzikonstantinou 
Date: Wed, 22 Jan 2025 05:43:02 -0500
Subject: [PATCH] [clang-format] Add null-terminated path option (#123921)

This makes the `git clang-format` tool compose nicely with other shell
utilities in case of maliciously (or innocently) crafted filenames.
---
 clang/tools/clang-format/git-clang-format | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index da271bbe6e3a07..04c49e8910d0ac 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -205,6 +205,12 @@ def main():
 "commits"
 ),
 )
+p.add_argument(
+"-0",
+"--null",
+action="store_true",
+help="print the affected paths with null-terminated characters",
+)
 # We gather all the remaining positional arguments into 'args' since we 
need
 # to use some heuristics to determine whether or not  was present.
 # However, to print pretty messages, we make use of metavar and help.
@@ -261,11 +267,11 @@ def main():
 "ignored by clang-format):"
 )
 for filename in ignored_files:
-print("%s" % filename)
+print_filename(filename, opts.null)
 if changed_lines:
 print("Running clang-format on the following files:")
 for filename in changed_lines:
-print("%s" % filename)
+print_filename(filename, opts.null)
 
 if not changed_lines:
 if opts.verbose >= 0:
@@ -304,7 +310,7 @@ def main():
 if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
 print("changed files:")
 for filename in changed_files:
-print("%s" % filename)
+print_filename(filename, opts.null)
 
 return 1
 
@@ -869,5 +875,12 @@ def convert_string(bytes_input):
 return str(bytes_input)
 
 
+def print_filename(filename, null=False):
+if null:
+print(filename + "\0", end="")
+else:
+print("%s" % filename)
+
+
 if __name__ == "__main__":
 sys.exit(main())

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


[clang] [Clang] raise extension warning for unknown namespaced attributes (PR #120925)

2025-01-22 Thread Oleksandr T. via cfe-commits

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

>From bce88b1bb464438828fc177c978ad2b99957530f Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 23 Dec 2024 02:35:07 +0200
Subject: [PATCH 1/4] [Clang] raise extension warning for unknown namespaced
 attributes

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/include/clang/Basic/DiagnosticCommonKinds.td |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp|  2 ++
 .../CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp|  4 ++--
 clang/test/CXX/module/module.interface/p3.cpp  |  2 +-
 clang/test/Lexer/cxx2a-spaceship.cpp   |  2 +-
 clang/test/OpenMP/openmp_attribute_parsing.cpp |  2 +-
 clang/test/Parser/c2x-attributes.c |  2 +-
 clang/test/Parser/cxx0x-attributes.cpp |  2 +-
 clang/test/Sema/patchable-function-entry-attr.cpp  |  2 +-
 clang/test/Sema/unknown-attributes.c   | 10 ++
 clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp  |  4 ++--
 12 files changed, 26 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/Sema/unknown-attributes.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6b9e1109f3906e..e2cf90aecf3666 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -552,6 +552,8 @@ Attribute Changes in Clang
 - Clang now permits the usage of the placement new operator in 
``[[msvc::constexpr]]``
   context outside of the std namespace. (#GH74924)
 
+- Clang now raises warnings for unknown namespaced attributes only in pedantic 
mode (#GH120875).
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index f4a155bb00bb37..85653429aa5332 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -179,6 +179,8 @@ def err_opencl_unknown_type_specifier : Error<
 
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
+def ext_unknown_attribute_ignored : Extension<
+  "unknown attribute %0 ignored">, InGroup;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">,
   InGroup;
 def err_keyword_not_supported_on_target : Error<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bb4d33560b93b8..9b1ffebe0804a5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -6548,6 +6548,8 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, 
const ParsedAttr &AL,
? (unsigned)diag::err_keyword_not_supported_on_target
: AL.isDeclspecAttribute()
? (unsigned)diag::warn_unhandled_ms_attribute_ignored
+   : AL.getScopeName()
+   ? (unsigned)diag::ext_unknown_attribute_ignored
: (unsigned)diag::warn_unknown_attribute_ignored)
 << AL << AL.getRange();
 return;
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
index 192fa126109873..c7e66649fb7b22 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp
@@ -12,5 +12,5 @@
 [[using clang:]] extern int n; // ok
 [[using blah: clang::optnone]] extern int n; // expected-error {{attribute 
with scope specifier cannot follow}} expected-warning {{only applies to 
functions}}
 
-[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown 
attribute}}
-[[using unknown_ns: something]] extern int n; // expected-warning {{unknown 
attribute}}
+[[using clang: unknown_attr]] extern int n;
+[[using unknown_ns: something]] extern int n;
diff --git a/clang/test/CXX/module/module.interface/p3.cpp 
b/clang/test/CXX/module/module.interface/p3.cpp
index 32819b2dccb11d..3cde92c1a2cf34 100644
--- a/clang/test/CXX/module/module.interface/p3.cpp
+++ b/clang/test/CXX/module/module.interface/p3.cpp
@@ -40,7 +40,7 @@ export { // No diagnostic after P2615R1 DR
   extern "C++" {} // No diagnostic after P2615R1 DR
 }
 export [[]]; // No diagnostic after P2615R1 DR
-export [[example::attr]]; // expected-warning {{unknown attribute 'attr'}}
+export [[example::attr]]; // expected-error {{unknown attribute 'attr'}}
 
 // [...] shall not declare a name with internal linkage
 export static int a; // expected-error {{declaration of 'a' with internal 
linkage cannot be exported}}
diff --git a/clang/test/Lexer/cxx2a-spaceship.cpp 
b/clang/test/Lexer/cxx2a-spaceship.cpp
index 2163a0bf190f90..505f2f47c8ffb8 100644
--- a/clang/test/Lexer/cxx2a-spaceship.cpp
+++ b/clang/test/Lexer/cxx2a-spaceship.cpp
@@ -61,7 +61,7 @@ static_assert(__builtin_strcmp(b, "<=>") == 0);
 // CXX20: preprocess8: <=>=
 
 #define ID(x) x
-[[some_vendor::some_attribute( // expec

[clang] [llvm] [X86][AVX10.2-SATCVT][NFC] Remove NE from intrinsic and instruction name (PR #123275)

2025-01-22 Thread Phoebe Wang via cfe-commits


@@ -603,13 +603,13 @@ defm VCVTPS2IUBS : avx10_sat_cvt_base<0x6b, 
"vcvtps2iubs", SchedWriteVecIMul,
 X86vcvtp2iubsRnd>,
AVX512PDIi8Base, T_MAP5, EVEX_CD8<32, CD8VF>;
 
-defm VCVTTNEBF162IBS : avx10_sat_cvt_base<0x68, "vcvttnebf162ibs",
-  SchedWriteVecIMul, X86vcvttp2ibs,
-  avx512vl_i16_info, 
avx512vl_bf16_info>,
+defm VCVTTBF162IBS : avx10_sat_cvt_base<0x68, "vcvttbf162ibs",
+SchedWriteVecIMul, X86vcvttp2ibs,
+avx512vl_i16_info, avx512vl_bf16_info>,
AVX512XDIi8Base, T_MAP5, EVEX_CD8<16, CD8VF>;
-defm VCVTTNEBF162IUBS : avx10_sat_cvt_base<0x6a, "vcvttnebf162iubs",
-   SchedWriteVecIMul, X86vcvttp2iubs,
-   avx512vl_i16_info, 
avx512vl_bf16_info>,
+defm VCVTTBF162IUBS : avx10_sat_cvt_base<0x6a, "vcvttbf162iubs",
+ SchedWriteVecIMul, X86vcvttp2iubs,
+ avx512vl_i16_info, 
avx512vl_bf16_info>,
 AVX512XDIi8Base, T_MAP5, EVEX_CD8<16, CD8VF>;

phoebewang wrote:

There's no uniform rule on this. So I usually just pay attention to arguments 
in `<>`.
Align `AVX512XDIi8Base` with `avx10_sat_cvt_base` doesn't make much sense, 
because one is `class` while the other is `multiclass`. We uaually align them 
if we have more than one `multiclass`.

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


[clang] [llvm] [HIP] Support managed variables using the new driver (PR #123437)

2025-01-22 Thread Yaxun Liu via cfe-commits

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


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


[clang] [llvm] [X86][AVX10.2-SATCVT][NFC] Remove NE from intrinsic and instruction name (PR #123275)

2025-01-22 Thread Phoebe Wang via cfe-commits

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


[clang] [C++20] [Modules] Fix may-be incorrect ADL for module local entities (PR #123931)

2025-01-22 Thread Nikita Popov via cfe-commits

nikic wrote:

I'm not seeing any impact: 
https://llvm-compile-time-tracker.com/compare.php?from=ff0f1dd341cb2fdc1281a14413b3aa93bf9a20c7&to=4bfdd091675b9957686ac81457629e124950dc25&stat=instructions:u

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


[clang] [Clang] Add predefined macros for integer constants to implement section 7.18.4 of ISO/IEC 9899:1999 in `` in a safe way (PR #123514)

2025-01-22 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

Thank you for the fix! Can you also add test coverage for the changes to 
`clang/test/Headers` and a release note so users know about the fix to 
`clang/docs/ReleaseNotes.rst`?

Also, precommit CI found relevant failures:
```
 TEST 'Clang :: Preprocessor/init-aarch64.c' FAILED 

Exit Code: 1
Command Output (stderr):
--
RUN: at line 1: 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/bin/clang
 -cc1 -internal-isystem 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/lib/clang/20/include
 -nostdsysteminc -E -dM -triple=aarch64 -xc /dev/null > 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/tools/clang/test/Preprocessor/Output/init-aarch64.c.tmp.aarch64
+ 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/bin/clang
 -cc1 -internal-isystem 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/lib/clang/20/include
 -nostdsysteminc -E -dM -triple=aarch64 -xc /dev/null
RUN: at line 2: 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/bin/FileCheck
 --check-prefixes=AARCH64,AARCH64_LE,AARCH64_C 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/clang/test/Preprocessor/init-aarch64.c
 --match-full-lines < 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/tools/clang/test/Preprocessor/Output/init-aarch64.c.tmp.aarch64
+ 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/build/bin/FileCheck
 --check-prefixes=AARCH64,AARCH64_LE,AARCH64_C 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/clang/test/Preprocessor/init-aarch64.c
 --match-full-lines
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/clang/test/Preprocessor/init-aarch64.c:138:18:
 error: AARCH64-NEXT: is not on the line after the previous match
// AARCH64-NEXT: #define __INT16_C_SUFFIX__
 ^
:124:1: note: 'next' match was here
#define __INT16_C_SUFFIX__
^
:122:43: note: previous match ended here
#define __HAVE_FUNCTION_MULTI_VERSIONING 1
  ^
:123:1: note: non-matching line after previous match is here
#define __INT16_C(c) c
^
Input file: 
Check file: 
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-jfggl-1/llvm-project/github-pull-requests/clang/test/Preprocessor/init-aarch64.c
-dump-input=help explains the following input dump.
Input was:
<<
  .
  .
  .
119: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
120: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
121: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
122: #define __HAVE_FUNCTION_MULTI_VERSIONING 1
123: #define __INT16_C(c) c
124: #define __INT16_C_SUFFIX__
next:138 !~~  error: match on wrong line
125: #define __INT16_FMTd__ "hd"
126: #define __INT16_FMTi__ "hi"
127: #define __INT16_MAX__ 32767
128: #define __INT16_TYPE__ short
129: #define __INT32_C(c) c
  .
  .
  .
>>
--

```
(and similar in init.c)

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


[clang] 1df50e6 - [PS5][Driver] Don't link with --build-id when -static (#123930)

2025-01-22 Thread via cfe-commits

Author: Edd Dawson
Date: 2025-01-22T14:57:52Z
New Revision: 1df50e6245cbc04f3b28de3c40127ad61d46b43b

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

LOG: [PS5][Driver] Don't link with --build-id when -static (#123930)

Users of the PlayStation SDK aren't given the means to create or run
static executables. Uses of `-static` are limited a few specialized
cases within SIE. A `--build-id` isn't wanted in those cases.

SIE tracker: TOOLCHAIN-16704

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/ps5-linker.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index e1187ce48c3e4c..4f9755db238d99 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -262,7 +262,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 // index the symbols. `uuid` is the cheapest fool-proof method.
 // (The non-determinism and alternative methods are noted in the downstream
 // PlayStation docs).
-CmdArgs.push_back("--build-id=uuid");
+// Static executables are only used for a handful of specialized 
components,
+// where the extra section is not wanted.
+if (!Static)
+  CmdArgs.push_back("--build-id=uuid");
 
 // All references are expected to be resolved at static link time for both
 // executables and dynamic libraries. This has been the default linking

diff  --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 9dd35c40619b68..777826aade7ff2 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -49,7 +49,6 @@
 // CHECK-EXE: {{ld(\.exe)?}}"
 // CHECK-EXE-SAME: "--eh-frame-hdr"
 // CHECK-EXE-SAME: "--hash-style=sysv"
-// CHECK-EXE-SAME: "--build-id=uuid"
 // CHECK-EXE-SAME: "--unresolved-symbols=report-all"
 // CHECK-EXE-SAME: "-z" "now"
 // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
@@ -63,10 +62,23 @@
 // CHECK-NO-EXE: {{ld(\.exe)?}}"
 // CHECK-NO-EXE-NOT: "--eh-frame-hdr"
 // CHECK-NO-EXE-NOT: "--hash-style
-// CHECK-NO-EXE-NOT: "--build-id
 // CHECK-NO-EXE-NOT: "--unresolved-symbols
 // CHECK-NO-EXE-NOT: "-z"
 
+// Test that --build-id is supplied to the linker for non-static executables
+// and -shared.
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+
+// CHECK-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-BUILD-ID-SAME: "--build-id=uuid"
+
+// CHECK-NO-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-NO-BUILD-ID-NOT: "--build-id
+
 // Test that an appropriate linker script is supplied by the driver, but can
 // be overridden with -T.
 



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


[clang] [PS5][Driver] Don't link with --build-id when -static (PR #123930)

2025-01-22 Thread Edd Dawson via cfe-commits

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


[clang] [analyzer] Widen loops: Augment assignment note when values invalidated at the start of a loop (PR #122398)

2025-01-22 Thread Balazs Benics via cfe-commits

steakhal wrote:

> Hi @steakhal .
> 
> Thank you for the further clarification and example. I now understand how 
> your proposal fits in with what I'm trying to accomplish.

Thank you for your time for considering it!

> I've started to implement the proposal but I have a few questions:
> 
> * When regions are invalidated via `getWidenedLoopState` (see the call to ` 
> PrevState->invalidateRegions`), further down the call stack, in 
> `InvalidateRegionsWorker::VisitCluster`, regions are bound to a conjured 
> symbol constructed via `svalBuilder.conjureSymbolVal`. Is 
> `InvalidationArtifact` supposed to wrap the result of 
> `svalBuilder.conjureSymbolVal`, or is it supposed to be a replacement for 
> conjured symbols in the context of invalidation?

Excellent question!
If you look at the [class 
hierarchy](https://clang.llvm.org/doxygen/classclang_1_1ento_1_1SymExpr.html) 
of SymExprs, then you will see the `SymbolData` class. Any subclasses of it are 
equal in the sense that the actual subtype usually doesn't matter.
For instance, as far a checker is concerned, (usually) it shouldn't 
differentiate and handle differently Conjured symbols and MetadataSymbols, or 
any other symbols. The important part is that it's a SymbolData.

Now, for us this should mean that an `InvalidationArtifact` is just another 
subtype of SymbolData, and where in the past (for the lack of it) we used 
Conjured symbols for representing the value of a region "after" an 
invalidation, we would instead create an "InvalidationArtifact". While in the 
past, one could not conclude why we had a Conjured symbol for something, now we 
could tell if it's representing the value after some invalidation event.

This "refinement" may break existing code that currently relied on the fact 
that invalidation usually placed a Conjured symbol as the new value, but those 
could be fairly easily identified and should be even easier to fix: just check 
if the symbol is an InvalidationArtifact, and there you go. So at this point 
expect a couple of broken tests.

> * If `InvalidationArtifact` is a replacement for conjured symbols, is it 
> always the case that invalidation results in conjured symbols? From my 
> limited exploration, that seems like the case but I just want to confirm. If 
> so, would it make more sense to have `InvalidationArtifact` be an extension 
> of `SymbolConjured` with the addition of `InvalidationCause`?

Yes,  `InvalidationArtifact` is a replacement (or a better word would be 
"refinement") of conjured symbols **iff** those were conjured due to some 
invalidation event. Now, do we always have a conjured symbol for invalidation? 
Yes and no.
Let's first have a look at what a conjured symbol means. They have a type, 
let's say `int`. A conjured symbol of such means an arbitrary value within that 
domain. Even if we don't know anything concrete about such a symbol, we know 
that they always compare equal against itself. It's like in mathematics. This 
is not only true for conjured symbols, but to anything that is a SymbolData. 
(There is one little caviat to the type of a conjured symbol :D They frequently 
just left as `int` because IDK, they didn't pass the right type all the way, so 
don't be confused if you see `int` for the type for a conjured symbol that 
represents the value of IDK, a `char` for instance; funny right?)

If something escapes (and needs invalidation), then the best mental model is 
that a single write operation is simulated, but then what value should be bound 
there? You guessed it, we conjure a fresh symbol, and bind it. So, for regular 
primitive objects, such as `int`, we will end up with a conjured symbol of int.

However, for aggregates (like arrays) and most complicated stuff, we still just 
conjure a single symbol to the whole object, despite that we usually only 
operate on a smaller subobject, such as the concrete array element, or a 
specific field of a struct object.
This is where Derived symbols come into play. (an other sign of that some 
invalidation happened, besides conjured symbols).
Derived symbols represent a "slice" of another symbol (usually a conjured 
symbol) to represent the value of a small portion of the original symbol.
There are completely legit, unrelated reasons for having a conjured symbol 
representing a whole aggregate. For instance the by-value return value of some 
opaque function call (calling a function like `struct ZZZ getObj()` would 
return a conjured symbol for the whole `struct ZZZ` object, thus every time you 
would access a field of that `zzz.field`, a Derived symbol would "slice" the 
field portion of the whole object "zzz" represented by that conjured symbol). 
So the presence of derived symbols is not an indicator of some invalidation, 
just like it wasn't for conjured symbols.

In our new mental model, where we have InvalidationArtifacts, this concept 
still makes sense. The DerivedSymbol will just wrap an InvalidationArtifact 
symbol instead of a conjured one

[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-22 Thread Petr Polezhaev via cfe-commits


@@ -830,6 +830,16 @@ bool OverlayCDB::setCompileCommand(PathRef File,
   return true;
 }
 
+std::unique_ptr
+OverlayCDB::getProjectModules(PathRef File) const {
+  auto MDB = DelegatingCDB::getProjectModules(File);
+  MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command,
+  PathRef CommandPath) {
+Mangler(Command, CommandPath);
+  });
+  return std::move(MDB);

petr-polezhaev wrote:

:disappointed: Can't do anything about it - I don't have write permissions. Can 
you revert it and I'll resubmit the review?

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread Fabian Ritter via cfe-commits


@@ -23,7 +23,7 @@ template __attribute__((host, device)) int 
templatify(int x) {
 __attribute__((device)) const int GlobalConst = __AMDGCN_WAVEFRONT_SIZE__; // 
expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as 
deprecated}}
 constexpr int GlobalConstExpr = __AMDGCN_WAVEFRONT_SIZE__; // expected-warning 
{{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as deprecated}}
 
-#if defined(__HIP_DEVICE_COMPILE__) && (__AMDGCN_WAVEFRONT_SIZE__ == 64) // 
expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as 
deprecated}}
+#if (__AMDGCN_WAVEFRONT_SIZE__ == 64) && defined(__HIP_DEVICE_COMPILE__) // 
expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as 
deprecated}}

ritter-x2a wrote:

@AaronBallman thanks for notifying me! I think `-fcuda-is-device` isn't 
necessary; as far as I'm aware (I just tried) the second `RUN` line with 
`--offload-device-only` leads to a clang run with `__HIP_DEVICE_COMPILE__` 
defined to 1.

I'd prefer if we left this expression in the test as it was and changed the 
`expected-warning` comment behind it to an `ondevice-warning` and used 
`-verify=expected,ondevice` in the second `RUN` line instead, if we change 
preprocessing such that the deprecation warning isn't triggered due to 
short-circuit evaluation.

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


[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-22 Thread Petr Polezhaev via cfe-commits

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread Fabian Ritter via cfe-commits

ritter-x2a wrote:

I think it would be more useful in practice if the deprecation warnings 
respected lazy evaluation, as the PR suggests, but it's worth noting that this 
deviates from the C Standard, which specifies that macros are replaced first, 
before short-circuit evaluation takes place.

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


[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-22 Thread kadir çetinkaya via cfe-commits


@@ -830,6 +830,16 @@ bool OverlayCDB::setCompileCommand(PathRef File,
   return true;
 }
 
+std::unique_ptr
+OverlayCDB::getProjectModules(PathRef File) const {
+  auto MDB = DelegatingCDB::getProjectModules(File);
+  MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command,
+  PathRef CommandPath) {
+Mangler(Command, CommandPath);
+  });
+  return std::move(MDB);

kadircet wrote:

oops sorry for missing that, should be fixed with 
a2063ba7ffdbbb4faf5da5f32739ab761c2e4289

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


[clang] [C++20][Modules] Fix crash/compiler error due broken AST links (PR #123648)

2025-01-22 Thread Haojian Wu via cfe-commits


@@ -799,14 +817,12 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   }
 
   if (D->getFriendObjectKind()) {
-// For a function defined inline within a class template, we have to force
-// the canonical definition to be the one inside the canonical definition 
of
-// the template. Remember this relation to deserialize them together.
-if (auto *RD = dyn_cast(D->getLexicalParent()))
-  if (RD->isDependentContext() && RD->isThisDeclarationADefinition()) {
-Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
-Writer.GetDeclRef(D));
-  }
+// For a friend function defined inline within a class template, we have to
+// force the definition to be the one inside the definition of the template
+// class. Remember this relation to deserialize them together.
+if (auto *RD = getDependentDeclContext(D))

hokein wrote:

this seems like a behavior change: before, it uses `D->getLexicalParent()`; now 
it uses `D->getDeclContext()`.

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


[clang] Remove incorrect CUDA defines (PR #123898)

2025-01-22 Thread Sergey Kozub via cfe-commits

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


[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

2025-01-22 Thread Antonio Frighetto via cfe-commits


@@ -11610,9 +11610,10 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl 
*Found, Decl *Templated,
  bool TakingCandidateAddress) {
   TemplateParameter Param = DeductionFailure.getTemplateParameter();
   NamedDecl *ParamD;
-  (ParamD = Param.dyn_cast()) ||
-  (ParamD = Param.dyn_cast()) ||
-  (ParamD = Param.dyn_cast());
+  (ParamD = Param.dyn_cast()) ||
+  (ParamD = Param.dyn_cast()) ||
+  (ParamD = Param.dyn_cast());
+

antoniofrighetto wrote:

Space between type and pointer.
```suggestion
  (ParamD = Param.dyn_cast()) ||
  (ParamD = Param.dyn_cast()) ||
  (ParamD = Param.dyn_cast());
```

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


[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

2025-01-22 Thread Antonio Frighetto via cfe-commits


@@ -11714,13 +11715,52 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl 
*Found, Decl *Templated,
 return;
   }
 
-  case TemplateDeductionResult::InvalidExplicitArguments:
+  case TemplateDeductionResult::InvalidExplicitArguments: {
 assert(ParamD && "no parameter found for invalid explicit arguments");
-if (ParamD->getDeclName())
-  S.Diag(Templated->getLocation(),
- diag::note_ovl_candidate_explicit_arg_mismatch_named)
-  << ParamD->getDeclName();
-else {
+if (ParamD->getDeclName()) {
+  TemplateArgument FirstArg = *DeductionFailure.getFirstArg();
+  std::string ParamName = ParamD->getNameAsString();
+  TemplateArgument SecondArg = *DeductionFailure.getSecondArg();
+
+  if (auto *TTPD = dyn_cast(ParamD)) {
+if (TTPD->wasDeclaredWithTypename())
+  S.Diag(Templated->getLocation(),
+ diag::note_ovl_candidate_explicit_arg_mismatch_named_ttpd)
+  << ParamD->getDeclName() << FirstArg << SecondArg << ParamName
+  << "type";
+else {
+  // TODO write tests for type constrained classes
+  if (auto *constraint = TTPD->getTypeConstraint())
+S.Diag(Templated->getLocation(),
+   diag::note_ovl_candidate_explicit_arg_mismatch_named_ttpd)
+<< ParamD->getDeclName() << FirstArg << SecondArg << ParamName
+<< "valid type-constrained class";
+  else
+S.Diag(Templated->getLocation(),
+   diag::note_ovl_candidate_explicit_arg_mismatch_named_ttpd)
+<< ParamD->getDeclName() << FirstArg << SecondArg << ParamName
+<< "class";
+}
+  } else if (auto *NTTPD = dyn_cast(ParamD)) {
+if (SecondArg.isNull()) {
+  // Expected constant of type 'int', got type 'int'
+  S.Diag(Templated->getLocation(),
+ 
diag::note_ovl_candidate_explicit_arg_mismatch_named_nttpd_nsp)
+  << ParamD->getDeclName() << FirstArg << NTTPD->getType();
+} else {
+  // Could not convert A from B to C
+  S.Diag(Templated->getLocation(),
+ diag::note_ovl_candidate_explicit_arg_mismatch_named_nttpd_sp)
+  << ParamD->getDeclName() << FirstArg << SecondArg
+  << NTTPD->getType();
+}
+  } else if (auto *TTempPD = dyn_cast(ParamD)) {

antoniofrighetto wrote:

```suggestion
  } else if (isa(ParamD)) {
```

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


[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

2025-01-22 Thread Antonio Frighetto via cfe-commits


@@ -11714,13 +11715,52 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl 
*Found, Decl *Templated,
 return;
   }
 
-  case TemplateDeductionResult::InvalidExplicitArguments:
+  case TemplateDeductionResult::InvalidExplicitArguments: {
 assert(ParamD && "no parameter found for invalid explicit arguments");
-if (ParamD->getDeclName())
-  S.Diag(Templated->getLocation(),
- diag::note_ovl_candidate_explicit_arg_mismatch_named)
-  << ParamD->getDeclName();
-else {
+if (ParamD->getDeclName()) {
+  TemplateArgument FirstArg = *DeductionFailure.getFirstArg();
+  std::string ParamName = ParamD->getNameAsString();
+  TemplateArgument SecondArg = *DeductionFailure.getSecondArg();
+
+  if (auto *TTPD = dyn_cast(ParamD)) {
+if (TTPD->wasDeclaredWithTypename())
+  S.Diag(Templated->getLocation(),
+ diag::note_ovl_candidate_explicit_arg_mismatch_named_ttpd)
+  << ParamD->getDeclName() << FirstArg << SecondArg << ParamName
+  << "type";
+else {
+  // TODO write tests for type constrained classes
+  if (auto *constraint = TTPD->getTypeConstraint())

antoniofrighetto wrote:

```suggestion
  if (TTPD->getTypeConstraint())
```

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


[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2025-01-22 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/43

>From 567177e658ede96a59a22af14c9472e232391487 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 4 Oct 2024 20:22:59 +0800
Subject: [PATCH 1/2] [Clang] Implement CWG 2628 "Implicit deduction guides
 should propagate constraints"

---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp |  70 ++--
 clang/test/CXX/drs/cwg26xx.cpp|  19 +-
 clang/test/SemaTemplate/deduction-guide.cpp   | 163 ++
 clang/www/cxx_dr_status.html  |   2 +-
 5 files changed, 227 insertions(+), 30 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e7a5fb76b602b..a88c00ea038091 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -215,6 +215,9 @@ Resolutions to C++ Defect Reports
 - Clang now allows trailing requires clause on explicit deduction guides.
   (`CWG2707: Deduction guides cannot have a trailing requires-clause 
`_).
 
+- Respect constructor constraints during CTAD.
+  (`CWG2628: Implicit deduction guides should propagate constraints 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 545da21183c3c4..dc9eb1b83b03fe 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -195,12 +195,14 @@ class ExtractTypeForDeductionGuide
 // A deduction guide can be either a template or a non-template function
 // declaration. If \p TemplateParams is null, a non-template function
 // declaration will be created.
-NamedDecl *buildDeductionGuide(
-Sema &SemaRef, TemplateDecl *OriginalTemplate,
-TemplateParameterList *TemplateParams, CXXConstructorDecl *Ctor,
-ExplicitSpecifier ES, TypeSourceInfo *TInfo, SourceLocation LocStart,
-SourceLocation Loc, SourceLocation LocEnd, bool IsImplicit,
-llvm::ArrayRef MaterializedTypedefs = {}) {
+NamedDecl *
+buildDeductionGuide(Sema &SemaRef, TemplateDecl *OriginalTemplate,
+TemplateParameterList *TemplateParams,
+CXXConstructorDecl *Ctor, ExplicitSpecifier ES,
+TypeSourceInfo *TInfo, SourceLocation LocStart,
+SourceLocation Loc, SourceLocation LocEnd, bool IsImplicit,
+llvm::ArrayRef MaterializedTypedefs = 
{},
+Expr *FunctionTrailingRC = nullptr) {
   DeclContext *DC = OriginalTemplate->getDeclContext();
   auto DeductionGuideName =
   SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(
@@ -211,9 +213,9 @@ NamedDecl *buildDeductionGuide(
   TInfo->getTypeLoc().castAs().getParams();
 
   // Build the implicit deduction guide template.
-  auto *Guide =
-  CXXDeductionGuideDecl::Create(SemaRef.Context, DC, LocStart, ES, Name,
-TInfo->getType(), TInfo, LocEnd, Ctor);
+  auto *Guide = CXXDeductionGuideDecl::Create(
+  SemaRef.Context, DC, LocStart, ES, Name, TInfo->getType(), TInfo, LocEnd,
+  Ctor, DeductionCandidate::Normal, FunctionTrailingRC);
   Guide->setImplicit(IsImplicit);
   Guide->setParams(Params);
 
@@ -355,10 +357,11 @@ struct ConvertConstructorToDeductionGuideTransform {
 //   template arguments) of the constructor, if any.
 TemplateParameterList *TemplateParams =
 SemaRef.GetTemplateParameterList(Template);
+SmallVector Depth1Args;
+Expr *OuterRC = TemplateParams->getRequiresClause();
 if (FTD) {
   TemplateParameterList *InnerParams = FTD->getTemplateParameters();
   SmallVector AllParams;
-  SmallVector Depth1Args;
   AllParams.reserve(TemplateParams->size() + InnerParams->size());
   AllParams.insert(AllParams.begin(), TemplateParams->begin(),
TemplateParams->end());
@@ -391,7 +394,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   /*EvaluateConstraint=*/false);
 }
 
-assert(NewParam->getTemplateDepth() == 0 &&
+assert(getDepthAndIndex(NewParam).first == 0 &&
"Unexpected template parameter depth");
 
 AllParams.push_back(NewParam);
@@ -407,10 +410,11 @@ struct ConvertConstructorToDeductionGuideTransform {
 Args.addOuterRetainedLevel();
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
-ExprResult E = SemaRef.SubstExpr(InnerRC, Args);
-if (E.isInvalid())
+ExprResult E =
+SemaRef.SubstConstraintExprWithoutSatisfaction(InnerRC, Args);
+if (!E.isUsable())
   return nullptr;
-RequiresClause = E.getAs();
+RequiresClause = E.get();
   }
 
   TemplateParams = TemplateParameterList::Create(
@@ -446,10

[clang] [llvm] [AArch64] Implement NEON FP8 fused multiply-add intrinsics (non-indexed) (PR #123614)

2025-01-22 Thread Jonathan Thackray via cfe-commits

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

Déjà vu, LGTM.

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


[clang] 97c3a99 - Remove incorrect CUDA defines (#123898)

2025-01-22 Thread via cfe-commits

Author: Sergey Kozub
Date: 2025-01-22T12:15:32+01:00
New Revision: 97c3a990f05606cb807faf53bc41302fb62c7980

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

LOG: Remove incorrect CUDA defines (#123898)

Remove CUDA_127 and CUDA_129 defines incorrectly added in
https://github.com/llvm/llvm-project/pull/123398

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Cuda.cpp
clang/lib/Driver/ToolChains/Cuda.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index 1cdfc8178db843..f33ba46233a7ab 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -44,12 +44,10 @@ enum class CudaVersion {
   CUDA_124,
   CUDA_125,
   CUDA_126,
-  CUDA_127,
   CUDA_128,
-  CUDA_129,
   FULLY_SUPPORTED = CUDA_123,
   PARTIALLY_SUPPORTED =
-  CUDA_129, // Partially supported. Proceed with a warning.
+  CUDA_128, // Partially supported. Proceed with a warning.
   NEW = 1,  // Too new. Issue a warning, but allow using it.
 };
 const char *CudaVersionToString(CudaVersion V);

diff  --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index b1461429d4f51a..1bfec0b37c5ee8 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -44,9 +44,7 @@ static const CudaVersionMapEntry CudaNameVersionMap[] = {
 CUDA_ENTRY(12, 4),
 CUDA_ENTRY(12, 5),
 CUDA_ENTRY(12, 6),
-CUDA_ENTRY(12, 7),
 CUDA_ENTRY(12, 8),
-CUDA_ENTRY(12, 9),
 {"", CudaVersion::NEW, 
llvm::VersionTuple(std::numeric_limits::max())},
 {"unknown", CudaVersion::UNKNOWN, {}} // End of list tombstone.
 };
@@ -232,7 +230,7 @@ CudaVersion MinVersionForOffloadArch(OffloadArch A) {
 return CudaVersion::CUDA_120;
   case OffloadArch::SM_100:
   case OffloadArch::SM_100a:
-return CudaVersion::CUDA_127;
+return CudaVersion::CUDA_128;
   default:
 llvm_unreachable("invalid enum");
   }

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 27e1969dabe551..d4099216c81ba8 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -89,12 +89,8 @@ CudaVersion getCudaVersion(uint32_t raw_version) {
 return CudaVersion::CUDA_125;
   if (raw_version < 12070)
 return CudaVersion::CUDA_126;
-  if (raw_version < 12080)
-return CudaVersion::CUDA_127;
   if (raw_version < 12090)
 return CudaVersion::CUDA_128;
-  if (raw_version < 12100)
-return CudaVersion::CUDA_129;
   return CudaVersion::NEW;
 }
 
@@ -688,9 +684,7 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   case CudaVersion::CUDA_##CUDA_VER:   
\
 PtxFeature = "+ptx" #PTX_VER;  
\
 break;
-CASE_CUDA_VERSION(129, 87);
 CASE_CUDA_VERSION(128, 87);
-CASE_CUDA_VERSION(127, 86);
 CASE_CUDA_VERSION(126, 85);
 CASE_CUDA_VERSION(125, 85);
 CASE_CUDA_VERSION(124, 84);



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


[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #123613)

2025-01-22 Thread Jonathan Thackray via cfe-commits

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

LGTM

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


[clang] [llvm] [AArch64] Add Neon FP8 conversion intrinsics (PR #123612)

2025-01-22 Thread Jonathan Thackray via cfe-commits

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

LGTM

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


[clang] [llvm] [AArch64] Implement NEON FP8 intrinsics for fused multiply-add (indexed) (PR #123615)

2025-01-22 Thread Jonathan Thackray via cfe-commits

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

Phew, massive diff, LGTM.

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


[clang] [PS5][Driver] Don't link with --build-id when -static (PR #123930)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Edd Dawson (playstation-edd)


Changes

Users of the PlayStation SDK aren't given the means to create or run static 
executables. Uses of `-static` are limited a few specialized cases within SIE. 
A `--build-id` isn't wanted in those cases.

SIE tracker: TOOLCHAIN-16704

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+4-1) 
- (modified) clang/test/Driver/ps5-linker.c (+14-2) 


``diff
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index e1187ce48c3e4c..4f9755db238d99 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -262,7 +262,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 // index the symbols. `uuid` is the cheapest fool-proof method.
 // (The non-determinism and alternative methods are noted in the downstream
 // PlayStation docs).
-CmdArgs.push_back("--build-id=uuid");
+// Static executables are only used for a handful of specialized 
components,
+// where the extra section is not wanted.
+if (!Static)
+  CmdArgs.push_back("--build-id=uuid");
 
 // All references are expected to be resolved at static link time for both
 // executables and dynamic libraries. This has been the default linking
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 9dd35c40619b68..777826aade7ff2 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -49,7 +49,6 @@
 // CHECK-EXE: {{ld(\.exe)?}}"
 // CHECK-EXE-SAME: "--eh-frame-hdr"
 // CHECK-EXE-SAME: "--hash-style=sysv"
-// CHECK-EXE-SAME: "--build-id=uuid"
 // CHECK-EXE-SAME: "--unresolved-symbols=report-all"
 // CHECK-EXE-SAME: "-z" "now"
 // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
@@ -63,10 +62,23 @@
 // CHECK-NO-EXE: {{ld(\.exe)?}}"
 // CHECK-NO-EXE-NOT: "--eh-frame-hdr"
 // CHECK-NO-EXE-NOT: "--hash-style
-// CHECK-NO-EXE-NOT: "--build-id
 // CHECK-NO-EXE-NOT: "--unresolved-symbols
 // CHECK-NO-EXE-NOT: "-z"
 
+// Test that --build-id is supplied to the linker for non-static executables
+// and -shared.
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+
+// CHECK-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-BUILD-ID-SAME: "--build-id=uuid"
+
+// CHECK-NO-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-NO-BUILD-ID-NOT: "--build-id
+
 // Test that an appropriate linker script is supplied by the driver, but can
 // be overridden with -T.
 

``




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


[clang] [PS5][Driver] Don't link with --build-id when -static (PR #123930)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Edd Dawson (playstation-edd)


Changes

Users of the PlayStation SDK aren't given the means to create or run static 
executables. Uses of `-static` are limited a few specialized cases within SIE. 
A `--build-id` isn't wanted in those cases.

SIE tracker: TOOLCHAIN-16704

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+4-1) 
- (modified) clang/test/Driver/ps5-linker.c (+14-2) 


``diff
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index e1187ce48c3e4c..4f9755db238d99 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -262,7 +262,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 // index the symbols. `uuid` is the cheapest fool-proof method.
 // (The non-determinism and alternative methods are noted in the downstream
 // PlayStation docs).
-CmdArgs.push_back("--build-id=uuid");
+// Static executables are only used for a handful of specialized 
components,
+// where the extra section is not wanted.
+if (!Static)
+  CmdArgs.push_back("--build-id=uuid");
 
 // All references are expected to be resolved at static link time for both
 // executables and dynamic libraries. This has been the default linking
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 9dd35c40619b68..777826aade7ff2 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -49,7 +49,6 @@
 // CHECK-EXE: {{ld(\.exe)?}}"
 // CHECK-EXE-SAME: "--eh-frame-hdr"
 // CHECK-EXE-SAME: "--hash-style=sysv"
-// CHECK-EXE-SAME: "--build-id=uuid"
 // CHECK-EXE-SAME: "--unresolved-symbols=report-all"
 // CHECK-EXE-SAME: "-z" "now"
 // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
@@ -63,10 +62,23 @@
 // CHECK-NO-EXE: {{ld(\.exe)?}}"
 // CHECK-NO-EXE-NOT: "--eh-frame-hdr"
 // CHECK-NO-EXE-NOT: "--hash-style
-// CHECK-NO-EXE-NOT: "--build-id
 // CHECK-NO-EXE-NOT: "--unresolved-symbols
 // CHECK-NO-EXE-NOT: "-z"
 
+// Test that --build-id is supplied to the linker for non-static executables
+// and -shared.
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+
+// CHECK-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-BUILD-ID-SAME: "--build-id=uuid"
+
+// CHECK-NO-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-NO-BUILD-ID-NOT: "--build-id
+
 // Test that an appropriate linker script is supplied by the driver, but can
 // be overridden with -T.
 

``




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


[clang] [PS5][Driver] Don't link with --build-id when -static (PR #123930)

2025-01-22 Thread Edd Dawson via cfe-commits

https://github.com/playstation-edd created 
https://github.com/llvm/llvm-project/pull/123930

Users of the PlayStation SDK aren't given the means to create or run static 
executables. Uses of `-static` are limited a few specialized cases within SIE. 
A `--build-id` isn't wanted in those cases.

SIE tracker: TOOLCHAIN-16704

>From 8283f20d279aa94ddcf338066d9553b15cb40725 Mon Sep 17 00:00:00 2001
From: Edd Dawson 
Date: Tue, 21 Jan 2025 13:32:50 +
Subject: [PATCH] [PS5][Driver] Don't link with --build-id when -static

Users of the PlayStation SDK aren't given the means to create or run
static executables. Uses of `-static` are limited a few specialized
cases within SIE. A `--build-id` isn't wanted in those cases.

SIE tracker: TOOLCHAIN-16704
---
 clang/lib/Driver/ToolChains/PS4CPU.cpp |  5 -
 clang/test/Driver/ps5-linker.c | 16 ++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index e1187ce48c3e4c..4f9755db238d99 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -262,7 +262,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 // index the symbols. `uuid` is the cheapest fool-proof method.
 // (The non-determinism and alternative methods are noted in the downstream
 // PlayStation docs).
-CmdArgs.push_back("--build-id=uuid");
+// Static executables are only used for a handful of specialized 
components,
+// where the extra section is not wanted.
+if (!Static)
+  CmdArgs.push_back("--build-id=uuid");
 
 // All references are expected to be resolved at static link time for both
 // executables and dynamic libraries. This has been the default linking
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 9dd35c40619b68..777826aade7ff2 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -49,7 +49,6 @@
 // CHECK-EXE: {{ld(\.exe)?}}"
 // CHECK-EXE-SAME: "--eh-frame-hdr"
 // CHECK-EXE-SAME: "--hash-style=sysv"
-// CHECK-EXE-SAME: "--build-id=uuid"
 // CHECK-EXE-SAME: "--unresolved-symbols=report-all"
 // CHECK-EXE-SAME: "-z" "now"
 // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
@@ -63,10 +62,23 @@
 // CHECK-NO-EXE: {{ld(\.exe)?}}"
 // CHECK-NO-EXE-NOT: "--eh-frame-hdr"
 // CHECK-NO-EXE-NOT: "--hash-style
-// CHECK-NO-EXE-NOT: "--build-id
 // CHECK-NO-EXE-NOT: "--unresolved-symbols
 // CHECK-NO-EXE-NOT: "-z"
 
+// Test that --build-id is supplied to the linker for non-static executables
+// and -shared.
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck 
--check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-BUILD-ID %s
+
+// CHECK-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-BUILD-ID-SAME: "--build-id=uuid"
+
+// CHECK-NO-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-NO-BUILD-ID-NOT: "--build-id
+
 // Test that an appropriate linker script is supplied by the driver, but can
 // be overridden with -T.
 

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


[clang-tools-extra] [clang-tidy] Add EnableQtSupport option to modernize-use-integer-sign-comprison (PR #122127)

2025-01-22 Thread via cfe-commits

qt-tatiana wrote:

> lgtm. please update the pr title and description before merging. because the 
> option name is changed.

Done :)

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


[clang-tools-extra] [clang-tidy] Add EnableQtSupport option to modernize-use-integer-sign-comprison (PR #122127)

2025-01-22 Thread via cfe-commits

qt-tatiana wrote:

Hi all,

Could you please help me to merge the change? I don't have write access..

Thank you!

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


[clang] clang/limits.h: Avoid including limits.h twice (PR #120526)

2025-01-22 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> > > > Yes and no. It's due to the redefinitions, for sure. But that 
> > > > diagnostic is suppressed in system headers: 
> > > > https://godbolt.org/z/Mb7Kh975f, so I think we need to understand why 
> > > > there's a `limits.h` being included as though it were not a system 
> > > > header, because that's a bug.
> > > 
> > > 
> > > As we are building `glibc`, in which it includes the `limits.h` of 
> > > itself, instead of the system one.
> > 
> > 
> > That's the bug then. It needs to include the header as a system header, not 
> > a user header.
> 
> Yes. It does. It uses `-I` option to include limits.h of itself. 

Do you get the same behavior when you use `-isystem` instead?



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


[clang] bd56950 - [clang] Refine the temporay object member access filtering for GSL pointer (#122088)

2025-01-22 Thread via cfe-commits

Author: Haojian Wu
Date: 2025-01-22T14:11:16+01:00
New Revision: bd56950b9cd5b6b07e1ccb9b02c5d8a7125a23b6

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

LOG: [clang] Refine the temporay object member access filtering for GSL pointer 
(#122088)

We currently have ad-hoc filtering logic for temporary object member
access in `VisitGSLPointerArg`. This logic filters out more cases than
it should, leading to false negatives. Furthermore, this location lacks
sufficient context to implement a more accurate solution.

This patch refines the filtering logic by moving it to the central
filtering location, `analyzePathForGSLPointer`, consolidating the logic
and avoiding scattered filtering across multiple places. As a result,
the special handling for conditional operators (#120233) is no longer
necessary.

This change also resolves #120543.

Added: 


Modified: 
clang/lib/Sema/CheckExprLifetime.cpp
clang/test/Sema/Inputs/lifetime-analysis.h
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Removed: 




diff  --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index 27e6b5b2cb3930..8963cad86dbcae 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -200,6 +200,7 @@ struct IndirectLocalPathEntry {
 LifetimeBoundCall,
 TemporaryCopy,
 LambdaCaptureInit,
+MemberExpr,
 GslReferenceInit,
 GslPointerInit,
 GslPointerAssignment,
@@ -593,19 +594,6 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 Path.pop_back();
   };
   auto VisitGSLPointerArg = [&](const FunctionDecl *Callee, Expr *Arg) {
-// We are not interested in the temporary base objects of gsl Pointers:
-//   Temp().ptr; // Here ptr might not dangle.
-if (isa(Arg->IgnoreImpCasts()))
-  return;
-// Avoid false positives when the object is constructed from a conditional
-// operator argument. A common case is:
-//   // 'ptr' might not be owned by the Owner object.
-//   std::string_view s = cond() ? Owner().ptr : sv;
-if (const auto *Cond =
-dyn_cast(Arg->IgnoreImpCasts());
-Cond && isPointerLikeType(Cond->getType()))
-  return;
-
 auto ReturnType = Callee->getReturnType();
 
 // Once we initialized a value with a non gsl-owner reference, it can no
@@ -726,6 +714,9 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
 Init = ILE->getInit(0);
 }
 
+if (MemberExpr *ME = dyn_cast(Init->IgnoreImpCasts()))
+  Path.push_back(
+  {IndirectLocalPathEntry::MemberExpr, ME, ME->getMemberDecl()});
 // Step over any subobject adjustments; we may have a materialized
 // temporary inside them.
 Init = const_cast(Init->skipRValueSubobjectAdjustments());
@@ -1117,10 +1108,12 @@ enum PathLifetimeKind {
 static PathLifetimeKind
 shouldLifetimeExtendThroughPath(const IndirectLocalPath &Path) {
   for (auto Elem : Path) {
-if (Elem.Kind == IndirectLocalPathEntry::DefaultInit)
-  return PathLifetimeKind::Extend;
-if (Elem.Kind != IndirectLocalPathEntry::LambdaCaptureInit)
-  return PathLifetimeKind::NoExtend;
+if (Elem.Kind == IndirectLocalPathEntry::MemberExpr ||
+Elem.Kind == IndirectLocalPathEntry::LambdaCaptureInit)
+  continue;
+return Elem.Kind == IndirectLocalPathEntry::DefaultInit
+   ? PathLifetimeKind::Extend
+   : PathLifetimeKind::NoExtend;
   }
   return PathLifetimeKind::Extend;
 }
@@ -1138,6 +1131,7 @@ static SourceRange nextPathEntryRange(const 
IndirectLocalPath &Path, unsigned I,
 case IndirectLocalPathEntry::GslPointerInit:
 case IndirectLocalPathEntry::GslPointerAssignment:
 case IndirectLocalPathEntry::ParenAggInit:
+case IndirectLocalPathEntry::MemberExpr:
   // These exist primarily to mark the path as not permitting or
   // supporting lifetime extension.
   break;
@@ -1167,6 +1161,7 @@ static bool pathOnlyHandlesGslPointer(const 
IndirectLocalPath &Path) {
 case IndirectLocalPathEntry::VarInit:
 case IndirectLocalPathEntry::AddressOf:
 case IndirectLocalPathEntry::LifetimeBoundCall:
+case IndirectLocalPathEntry::MemberExpr:
   continue;
 case IndirectLocalPathEntry::GslPointerInit:
 case IndirectLocalPathEntry::GslReferenceInit:
@@ -1193,13 +1188,34 @@ enum AnalysisResult {
 // Analyze cases where a GSLPointer is initialized or assigned from a
 // temporary owner object.
 static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
-   Local L) {
+   Local L, LifetimeKind LK) {
   if (!pathOnlyHandlesGslPointer(Path))
 return NotGSLPoin

[clang] [clang] Refine the temporay object member access filtering for GSL pointer (PR #122088)

2025-01-22 Thread Haojian Wu via cfe-commits

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread Aaron Ballman via cfe-commits


@@ -23,7 +23,7 @@ template __attribute__((host, device)) int 
templatify(int x) {
 __attribute__((device)) const int GlobalConst = __AMDGCN_WAVEFRONT_SIZE__; // 
expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as 
deprecated}}
 constexpr int GlobalConstExpr = __AMDGCN_WAVEFRONT_SIZE__; // expected-warning 
{{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as deprecated}}
 
-#if defined(__HIP_DEVICE_COMPILE__) && (__AMDGCN_WAVEFRONT_SIZE__ == 64) // 
expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as 
deprecated}}
+#if (__AMDGCN_WAVEFRONT_SIZE__ == 64) && defined(__HIP_DEVICE_COMPILE__) // 
expected-warning {{macro '__AMDGCN_WAVEFRONT_SIZE__' has been marked as 
deprecated}}

AaronBallman wrote:

Errr, I think this change shows a bug with the `RUN` line. Should it be passing 
`-fcuda-is-device` so that `__HIP_DEVICE_COMPILE__` is actually defined? CC 
@ritter-x2a 

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,74 @@
+// RUN: %clang -E -MD -MF - %s | FileCheck -check-prefix ZERO_AND_HAS_INCLUDE 
%s
+//
+// ZERO_AND_HAS_INCLUDE-NOT: limits.h
+//
+#if 0 && __has_include()
+#include 
+#endif
+
+#if 4==5 && __has_include()
+#include 
+#endif
+
+#if defined(_THIS_IS_NOT_DEFINED) && __has_include()
+#include 
+#endif
+
+#if 0 && (__has_include())
+#include 
+#endif
+
+#if 4==5 && (__has_include())
+#include 
+#endif
+
+#if defined(_THIS_IS_NOT_DEFINED) && (__has_include())
+#include 
+#endif
+
+#if 0 && (5==5 && __has_include())
+#include 
+#endif
+
+#if 1 && (4==5 && __has_include())
+#include 
+#endif
+
+
+

AaronBallman wrote:

What happens with code like:
```
#if 0 && absolute garbage goes here
#endif
```
Do we still get an error for the incorrect code after the `&&`?

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


[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)

2025-01-22 Thread Oliver Stannard via cfe-commits

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

LGTM.

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


[clang] [PS5][Driver] Don't link with --build-id when -static (PR #123930)

2025-01-22 Thread Jeremy Morse via cfe-commits

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

LGTM

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


[clang] [Clang][Arch] Disable mve.fp when explicit -mfpu option (PR #123028)

2025-01-22 Thread Jack Styles via cfe-commits

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


[clang] Revert "[Modules] Delay deserialization of preferred_name attribute at r…" (PR #123962)

2025-01-22 Thread Viktoriia Bakalova via cfe-commits

https://github.com/VitaNuo created 
https://github.com/llvm/llvm-project/pull/123962

Reverts llvm/llvm-project#122726

We're seeing a 8-10% performance regression due to this patch.

>From 1d94f0a4598ec08cd75fb7c1c7353ce318da2472 Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova <115406782+vita...@users.noreply.github.com>
Date: Wed, 22 Jan 2025 17:17:53 +0100
Subject: [PATCH] =?UTF-8?q?Revert=20"[Modules]=20Delay=20deserialization?=
 =?UTF-8?q?=20of=20preferred=5Fname=20attribute=20at=20r=E2=80=A6=20(#1?=
 =?UTF-8?q?=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit c3ba6f378ef80d750e2278560c6f95a300114412.
---
 clang/include/clang/AST/Attr.h| 14 +---
 clang/include/clang/Basic/Attr.td | 11 ---
 clang/include/clang/Serialization/ASTReader.h | 19 -
 .../clang/Serialization/ASTRecordReader.h | 13 +--
 clang/lib/Serialization/ASTReader.cpp |  5 --
 clang/lib/Serialization/ASTReaderDecl.cpp | 79 +--
 clang/lib/Serialization/ASTWriter.cpp | 16 ++--
 clang/test/Modules/preferred_name.cppm| 12 +--
 clang/utils/TableGen/ClangAttrEmitter.cpp |  4 -
 9 files changed, 17 insertions(+), 156 deletions(-)

diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index bed532a84a1bde..3365ebe4d9012b 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -60,8 +60,6 @@ class Attr : public AttributeCommonInfo {
   unsigned IsLateParsed : 1;
   LLVM_PREFERRED_TYPE(bool)
   unsigned InheritEvenIfAlreadyPresent : 1;
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned DeferDeserialization : 1;
 
   void *operator new(size_t bytes) noexcept {
 llvm_unreachable("Attrs cannot be allocated with regular 'new'.");
@@ -82,11 +80,10 @@ class Attr : public AttributeCommonInfo {
 
 protected:
   Attr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
-   attr::Kind AK, bool IsLateParsed, bool DeferDeserialization = false)
+   attr::Kind AK, bool IsLateParsed)
   : AttributeCommonInfo(CommonInfo), AttrKind(AK), Inherited(false),
 IsPackExpansion(false), Implicit(false), IsLateParsed(IsLateParsed),
-InheritEvenIfAlreadyPresent(false),
-DeferDeserialization(DeferDeserialization) {}
+InheritEvenIfAlreadyPresent(false) {}
 
 public:
   attr::Kind getKind() const { return static_cast(AttrKind); }
@@ -108,8 +105,6 @@ class Attr : public AttributeCommonInfo {
   void setPackExpansion(bool PE) { IsPackExpansion = PE; }
   bool isPackExpansion() const { return IsPackExpansion; }
 
-  bool shouldDeferDeserialization() const { return DeferDeserialization; }
-
   // Clone this attribute.
   Attr *clone(ASTContext &C) const;
 
@@ -151,9 +146,8 @@ class InheritableAttr : public Attr {
 protected:
   InheritableAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
   attr::Kind AK, bool IsLateParsed,
-  bool InheritEvenIfAlreadyPresent,
-  bool DeferDeserialization = false)
-  : Attr(Context, CommonInfo, AK, IsLateParsed, DeferDeserialization) {
+  bool InheritEvenIfAlreadyPresent)
+  : Attr(Context, CommonInfo, AK, IsLateParsed) {
 this->InheritEvenIfAlreadyPresent = InheritEvenIfAlreadyPresent;
   }
 
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3969dd8af5dfae..408d3adf370c85 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -713,12 +713,6 @@ class Attr {
   // attribute may be documented under multiple categories, more than one
   // Documentation entry may be listed.
   list Documentation;
-  // Set to true if deserialization of this attribute must be deferred until 
-  // the parent Decl is fully deserialized (during header module file
-  // deserialization). E.g., this is the case for the preferred_name attribute,
-  // since its type deserialization depends on its target Decl type.
-  // (See https://github.com/llvm/llvm-project/issues/56490 for details).
-  bit DeferDeserialization = 0;
 }
 
 /// Used to define a set of mutually exclusive attributes.
@@ -3260,11 +3254,6 @@ def PreferredName : InheritableAttr {
   let InheritEvenIfAlreadyPresent = 1;
   let MeaningfulToClassTemplateDefinition = 1;
   let TemplateDependent = 1;
-  // Type of this attribute depends on the target Decl type.
-  // Therefore, its deserialization must be deferred until
-  // deserialization of the target Decl is complete
-  // (for header modules).
-  let DeferDeserialization = 1;
 }
 
 def PreserveMost : DeclOrTypeAttr {
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 82564fe664acba..7530015c9dacf3 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1236,24 +1236,6 @@ class ASTReader
   /// been completed.
   std::deque P

[clang] Revert "[Modules] Delay deserialization of preferred_name attribute at r…" (PR #123962)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Viktoriia Bakalova (VitaNuo)


Changes

Reverts llvm/llvm-project#122726

We're seeing a 8-10% performance regression due to this patch.

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


9 Files Affected:

- (modified) clang/include/clang/AST/Attr.h (+4-10) 
- (modified) clang/include/clang/Basic/Attr.td (-11) 
- (modified) clang/include/clang/Serialization/ASTReader.h (-19) 
- (modified) clang/include/clang/Serialization/ASTRecordReader.h (+1-12) 
- (modified) clang/lib/Serialization/ASTReader.cpp (-5) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+4-75) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+5-11) 
- (modified) clang/test/Modules/preferred_name.cppm (+3-9) 
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (-4) 


``diff
diff --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index bed532a84a1bde..3365ebe4d9012b 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -60,8 +60,6 @@ class Attr : public AttributeCommonInfo {
   unsigned IsLateParsed : 1;
   LLVM_PREFERRED_TYPE(bool)
   unsigned InheritEvenIfAlreadyPresent : 1;
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned DeferDeserialization : 1;
 
   void *operator new(size_t bytes) noexcept {
 llvm_unreachable("Attrs cannot be allocated with regular 'new'.");
@@ -82,11 +80,10 @@ class Attr : public AttributeCommonInfo {
 
 protected:
   Attr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
-   attr::Kind AK, bool IsLateParsed, bool DeferDeserialization = false)
+   attr::Kind AK, bool IsLateParsed)
   : AttributeCommonInfo(CommonInfo), AttrKind(AK), Inherited(false),
 IsPackExpansion(false), Implicit(false), IsLateParsed(IsLateParsed),
-InheritEvenIfAlreadyPresent(false),
-DeferDeserialization(DeferDeserialization) {}
+InheritEvenIfAlreadyPresent(false) {}
 
 public:
   attr::Kind getKind() const { return static_cast(AttrKind); }
@@ -108,8 +105,6 @@ class Attr : public AttributeCommonInfo {
   void setPackExpansion(bool PE) { IsPackExpansion = PE; }
   bool isPackExpansion() const { return IsPackExpansion; }
 
-  bool shouldDeferDeserialization() const { return DeferDeserialization; }
-
   // Clone this attribute.
   Attr *clone(ASTContext &C) const;
 
@@ -151,9 +146,8 @@ class InheritableAttr : public Attr {
 protected:
   InheritableAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
   attr::Kind AK, bool IsLateParsed,
-  bool InheritEvenIfAlreadyPresent,
-  bool DeferDeserialization = false)
-  : Attr(Context, CommonInfo, AK, IsLateParsed, DeferDeserialization) {
+  bool InheritEvenIfAlreadyPresent)
+  : Attr(Context, CommonInfo, AK, IsLateParsed) {
 this->InheritEvenIfAlreadyPresent = InheritEvenIfAlreadyPresent;
   }
 
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3969dd8af5dfae..408d3adf370c85 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -713,12 +713,6 @@ class Attr {
   // attribute may be documented under multiple categories, more than one
   // Documentation entry may be listed.
   list Documentation;
-  // Set to true if deserialization of this attribute must be deferred until 
-  // the parent Decl is fully deserialized (during header module file
-  // deserialization). E.g., this is the case for the preferred_name attribute,
-  // since its type deserialization depends on its target Decl type.
-  // (See https://github.com/llvm/llvm-project/issues/56490 for details).
-  bit DeferDeserialization = 0;
 }
 
 /// Used to define a set of mutually exclusive attributes.
@@ -3260,11 +3254,6 @@ def PreferredName : InheritableAttr {
   let InheritEvenIfAlreadyPresent = 1;
   let MeaningfulToClassTemplateDefinition = 1;
   let TemplateDependent = 1;
-  // Type of this attribute depends on the target Decl type.
-  // Therefore, its deserialization must be deferred until
-  // deserialization of the target Decl is complete
-  // (for header modules).
-  let DeferDeserialization = 1;
 }
 
 def PreserveMost : DeclOrTypeAttr {
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 82564fe664acba..7530015c9dacf3 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1236,24 +1236,6 @@ class ASTReader
   /// been completed.
   std::deque PendingDeclContextInfos;
 
-  /// Deserialization of some attributes must be deferred since they refer
-  /// to themselves in their type (e.g., preferred_name attribute refers to the
-  /// typedef that refers back to the template specialization of the template
-  /// that the attribute is attached to).
-  /// More attributes that store TypeSourceInfo might be potentially affected,
-  /// see https://github.com/llvm/

[clang] Revert "[Modules] Delay deserialization of preferred_name attribute at r…" (PR #123962)

2025-01-22 Thread via cfe-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo. Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account. See 
[LLVM 
Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it)
 for more information.

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


[clang] [clang] Track source deduction guide for alias template deduction guides (PR #123875)

2025-01-22 Thread Haojian Wu via cfe-commits

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

Thanks, the change looks good.

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


[clang] [Clang][Sema] Fix exception specification comparison for functions with different template depths (PR #111561)

2025-01-22 Thread via cfe-commits


@@ -501,6 +519,110 @@ bool Sema::CheckEquivalentExceptionSpec(
   return Result;
 }
 
+static const Expr *SubstituteExceptionSpecWithoutEvaluation(
+Sema &S, const Sema::TemplateCompareNewDeclInfo &DeclInfo,
+const Expr *ExceptionSpec) {
+  MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
+  DeclInfo.getDecl(), DeclInfo.getLexicalDeclContext(), /*Final=*/false,
+  /*Innermost=*/std::nullopt,
+  /*RelativeToPrimary=*/true,
+  /*ForConstraintInstantiation=*/true);
+
+  if (MLTAL.getNumSubstitutedLevels() == 0)
+return ExceptionSpec;
+
+  Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/false);
+
+  auto *FD = const_cast(DeclInfo.getDecl()->getAsFunction());
+  Sema::InstantiatingTemplate Inst(
+  S, DeclInfo.getLocation(), FD,
+  Sema::InstantiatingTemplate::ExceptionSpecification());
+  if (Inst.isInvalid())
+return nullptr;
+
+  // Set up a dummy 'instantiation' scope in the case of reference to function
+  // parameters that the surrounding function hasn't been instantiated yet. 
Note
+  // this may happen while we're comparing two templates' constraint
+  // equivalence.
+  LocalInstantiationScope ScopeForParameters(S);
+
+  for (auto *PVD : FD->parameters()) {
+if (!PVD->isParameterPack()) {
+  ScopeForParameters.InstantiatedLocal(PVD, PVD);
+  continue;
+}
+// This is hacky: we're mapping the parameter pack to a size-of-1 argument
+// to avoid building SubstTemplateTypeParmPackTypes for
+// PackExpansionTypes. The SubstTemplateTypeParmPackType node would
+// otherwise reference the AssociatedDecl of the template arguments, which
+// is, in this case, the template declaration.
+//
+// However, as we are in the process of comparing potential
+// re-declarations, the canonical declaration is the declaration itself at
+// this point. So if we didn't expand these packs, we would end up with an
+// incorrect profile difference because we will be profiling the
+// canonical types!
+//
+// FIXME: Improve the "no-transform" machinery in FindInstantiatedDecl so
+// that we can eliminate the Scope in the cases where the declarations are
+// not necessarily instantiated. It would also benefit the noexcept
+// specifier comparison.
+ScopeForParameters.MakeInstantiatedLocalArgPack(PVD);
+ScopeForParameters.InstantiatedLocalPackArg(PVD, PVD);
+  }
+
+  // See TreeTransform::RebuildTemplateSpecializationType. A context scope is
+  // essential for having an injected class as the canonical type for a 
template
+  // specialization type at the rebuilding stage. This guarantees that, for
+  // out-of-line definitions, injected class name types and their equivalent
+  // template specializations can be profiled to the same value, which makes it
+  // possible that e.g. constraints involving C> and C are
+  // perceived identical.
+  Sema::ContextRAII ContextScope(S, FD);
+
+  auto *MD = dyn_cast(FD);
+  Sema::CXXThisScopeRAII ThisScope(
+  S, MD ? MD->getParent() : nullptr,
+  MD ? MD->getMethodQualifiers() : Qualifiers{}, MD != nullptr);
+
+  EnterExpressionEvaluationContext ConstantEvaluated(
+  S, Sema::ExpressionEvaluationContext::ConstantEvaluated);

cor3ntin wrote:

Should that not be be Unevaluated?
https://eel.is/c++draft/expr.unary.noexcept#1

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


[clang] 0165d04 - [HIP] [NFC] Rename to `ClangArgs`

2025-01-22 Thread via cfe-commits

Author: Xeonacid
Date: 2025-01-22T18:01:52+08:00
New Revision: 0165d043a9d62197468e0d4f7578cd7a5e4084f8

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

LOG: [HIP] [NFC] Rename to `ClangArgs`

#112041 replaced `llvm-mc` with `clang`.
The args are now feeding to clang.

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIPUtility.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp 
b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index bfb6ec7a010583..81d8e4c00b69a0 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -466,7 +466,7 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-target", Args.MakeArgString(HostTriple.normalize()),
+  ArgStringList ClangArgs{"-target", 
Args.MakeArgString(HostTriple.normalize()),
"-o",  Output.getFilename(),
"-x",  "assembler",
ObjinFile, "-c"};



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


[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)

2025-01-22 Thread via cfe-commits

charan-003 wrote:

Hi @erichkeane, thank you for the feedback! I understand that the lexing logic 
should be moved to the parser. Could you please point me toward specific areas 
in the parser where this logic should be integrated? A bit more detail would 
help me ensure this is implemented correctly. Thank you!


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


[clang] c4ef805 - [Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#121943)

2025-01-22 Thread via cfe-commits

Author: Oliver Stannard
Date: 2025-01-22T10:48:04Z
New Revision: c4ef805b0bda16f734276086b0984583c2e21db6

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

LOG: [Clang] Re-write codegen for atomic_test_and_set and atomic_clear (#121943)

Re-write the sema and codegen for the atomic_test_and_set and
atomic_clear builtin functions to go via AtomicExpr, like the other
atomic builtins do. This simplifies the code, because AtomicExpr already
handles things like generating code for to dynamically select the memory
ordering, which was duplicated for these builtins. This also fixes a few
crash bugs, one when passing an integer to the pointer argument, and one
when using an array.

This also adds diagnostics for the memory orderings which are not valid
for atomic_clear according to
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html, which
were missing before.

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

This is a re-land of #120449, modified to allow any non-const pointer
type for the first argument.

Added: 
clang/test/CodeGen/atomic-test-and-set.c

Modified: 
clang/include/clang/Basic/Builtins.td
clang/lib/AST/Expr.cpp
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/atomic-ops.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index bbf4886b5cf053..60c360d4a9e075 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1977,16 +1977,16 @@ def AtomicNandFetch : AtomicBuiltin {
   let Prototype = "void(...)";
 }
 
-def AtomicTestAndSet : Builtin {
+def AtomicTestAndSet : AtomicBuiltin {
   let Spellings = ["__atomic_test_and_set"];
-  let Attributes = [NoThrow];
-  let Prototype = "bool(void volatile*, int)";
+  let Attributes = [NoThrow, CustomTypeChecking];
+  let Prototype = "bool(...)";
 }
 
-def AtomicClear : Builtin {
+def AtomicClear : AtomicBuiltin {
   let Spellings = ["__atomic_clear"];
-  let Attributes = [NoThrow];
-  let Prototype = "void(void volatile*, int)";
+  let Attributes = [NoThrow, CustomTypeChecking];
+  let Prototype = "void(...)";
 }
 
 def AtomicThreadFence : Builtin {

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f6a4ed970cb23f..31b95bca613c21 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -5077,6 +5077,8 @@ unsigned AtomicExpr::getNumSubExprs(AtomicOp Op) {
   case AO__opencl_atomic_init:
   case AO__c11_atomic_load:
   case AO__atomic_load_n:
+  case AO__atomic_test_and_set:
+  case AO__atomic_clear:
 return 2;
 
   case AO__scoped_atomic_load_n:

diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index f6cb2ad421e906..3adb2a7ad207f0 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -723,6 +723,24 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr 
*E, Address Dest,
   case AtomicExpr::AO__scoped_atomic_fetch_nand:
 Op = llvm::AtomicRMWInst::Nand;
 break;
+
+  case AtomicExpr::AO__atomic_test_and_set: {
+llvm::AtomicRMWInst *RMWI =
+CGF.emitAtomicRMWInst(llvm::AtomicRMWInst::Xchg, Ptr,
+  CGF.Builder.getInt8(1), Order, Scope, E);
+RMWI->setVolatile(E->isVolatile());
+llvm::Value *Result = CGF.Builder.CreateIsNotNull(RMWI, "tobool");
+CGF.Builder.CreateStore(Result, Dest);
+return;
+  }
+
+  case AtomicExpr::AO__atomic_clear: {
+llvm::StoreInst *Store =
+CGF.Builder.CreateStore(CGF.Builder.getInt8(0), Ptr);
+Store->setAtomic(Order, Scope);
+Store->setVolatile(E->isVolatile());
+return;
+  }
   }
 
   llvm::Value *LoadVal1 = CGF.Builder.CreateLoad(Val1);
@@ -878,6 +896,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   case AtomicExpr::AO__c11_atomic_load:
   case AtomicExpr::AO__opencl_atomic_load:
   case AtomicExpr::AO__hip_atomic_load:
+  case AtomicExpr::AO__atomic_test_and_set:
+  case AtomicExpr::AO__atomic_clear:
 break;
 
   case AtomicExpr::AO__atomic_load:
@@ -1200,6 +1220,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
 case AtomicExpr::AO__opencl_atomic_fetch_max:
 case AtomicExpr::AO__scoped_atomic_fetch_max:
 case AtomicExpr::AO__scoped_atomic_max_fetch:
+case AtomicExpr::AO__atomic_test_and_set:
+case AtomicExpr::AO__atomic_clear:
   llvm_unreachable("Integral atomic operations always become atomicrmw!");
 }
 
@@ -1239,7 +1261,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
  E->getOp() == AtomicExpr::AO__atomic_store ||
  E->getOp() == AtomicExpr::AO__atomic_store_n ||
  E->getOp() == AtomicExpr::AO__scoped_atomic

[clang] [Clang] Re-write codegen for atomic_test_and_set and atomic_clear (PR #121943)

2025-01-22 Thread Oliver Stannard via cfe-commits

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


[clang] [clang-format] Add null-terminated path option (#123921) (PR #123926)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Nikolaos Chatzikonstantinou (createyourpersonalaccount)


Changes

This makes the `git clang-format` tool compose nicely with other shell 
utilities in case of maliciously (or innocently) crafted filenames.

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


1 Files Affected:

- (modified) clang/tools/clang-format/git-clang-format (+16-3) 


``diff
diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index da271bbe6e3a07..04c49e8910d0ac 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -205,6 +205,12 @@ def main():
 "commits"
 ),
 )
+p.add_argument(
+"-0",
+"--null",
+action="store_true",
+help="print the affected paths with null-terminated characters",
+)
 # We gather all the remaining positional arguments into 'args' since we 
need
 # to use some heuristics to determine whether or not  was present.
 # However, to print pretty messages, we make use of metavar and help.
@@ -261,11 +267,11 @@ def main():
 "ignored by clang-format):"
 )
 for filename in ignored_files:
-print("%s" % filename)
+print_filename(filename, opts.null)
 if changed_lines:
 print("Running clang-format on the following files:")
 for filename in changed_lines:
-print("%s" % filename)
+print_filename(filename, opts.null)
 
 if not changed_lines:
 if opts.verbose >= 0:
@@ -304,7 +310,7 @@ def main():
 if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
 print("changed files:")
 for filename in changed_files:
-print("%s" % filename)
+print_filename(filename, opts.null)
 
 return 1
 
@@ -869,5 +875,12 @@ def convert_string(bytes_input):
 return str(bytes_input)
 
 
+def print_filename(filename, null=False):
+if null:
+print(filename + "\0", end="")
+else:
+print("%s" % filename)
+
+
 if __name__ == "__main__":
 sys.exit(main())

``




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


[clang] [clang-format] Add null-terminated path option (#123921) (PR #123926)

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


[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2025-01-22 Thread via cfe-commits


@@ -445,10 +449,46 @@ struct ConvertConstructorToDeductionGuideTransform {
   return nullptr;
 TypeSourceInfo *NewTInfo = TLB.getTypeSourceInfo(SemaRef.Context, NewType);
 
+// At this point, the function parameters are already 'instantiated' in the

cor3ntin wrote:

Why is 'instantiated' in quotes?

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


[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2025-01-22 Thread via cfe-commits

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


[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2025-01-22 Thread via cfe-commits

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

LGTM modulo nit/question

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


[clang] [StrTable] Mechanically convert Hexagon builtins to use TableGen (PR #123460)

2025-01-22 Thread Brian Cain via cfe-commits

androm3da wrote:

> I also so comments on the python script, but as I mentioned there, the script 
> is not code I'm suggesting to check in or maintain, merely documenting for 
> completeness. It was never written to be remotely readable or clean, just to 
> produce a verifiably equivalent TableGen file.

Sure - that's fine, I guess I am mostly skimming it for Ikhlas' sake in case 
she wants to run something similar downstream.

LGTM.

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


[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-01-22 Thread Balazs Benics via cfe-commits

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


[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-01-22 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,72 @@
+//===-- MemSpaces.cpp -*- C++ 
-*--//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines getters and setters for the memory space trait which
+// associates memory regions with memory spaces in the program state. It also
+// defines the MemSpacesMap which maps memory regions to memory spaces.
+//
+// These functions keep the following invariants over the MemSpacesMap:
+// 1. (Temporary as an intermediate step) Memory space traits are only
+//mapped for memory regions that have an unknown memory space
+// 2. Only base memory regions are mapped in the trait
+// 3. Memory regions which have no mapping in the trait are assumed to be
+//unknown; no memory region is allowed to be mapped to an unknown memory
+//space in the trait;
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemSpaces.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include 
+
+REGISTER_MAP_WITH_PROGRAMSTATE(MemSpacesMap, const clang::ento::MemRegion *,
+   const clang::ento::MemSpaceRegion *)
+
+namespace clang {
+namespace ento {
+namespace memspace {
+
+// Canonicalize to base, in case of subregions, we don't want base regions and
+// subregions to have different memory spaces
+[[nodiscard]] static const MemRegion *
+canonicalizeMemRegion(const MemRegion *MR) {
+  return MR->getBaseRegion();
+}
+
+ProgramStateRef setMemSpaceTrait(ProgramStateRef State, const MemRegion *MR,
+ const MemSpaceRegion *MS) {
+  MR = canonicalizeMemRegion(MR);
+
+  // For now, this should only be called to update the trait for memory regions
+  // that have an unknown memory spaces since we assume everywhere else that 
the
+  // memory space trait is set only for unknown memory spaces (setting this 
info
+  // otherwise would go unused).
+  assert(isa(MR->getMemorySpace()));
+
+  // Shouldn't use the memory space trait to associate UnknownSpaceRegion with
+  // an already UnknownSpaceRegion
+  assert(!isa(MS));
+
+  ProgramStateRef NewState = State->set(MR, MS);
+  return NewState;
+}
+
+const MemSpaceRegion *getMemSpace(ProgramStateRef State, const MemRegion *MR) {
+  MR = canonicalizeMemRegion(MR);
+
+  const MemSpaceRegion *const *Result = State->get(MR);

steakhal wrote:

Personally, I don't think this API is used widely enough in hot code.
Doing benchmarks is hard, time consuming and frequently even harder to 
eliminate other biases to attribute the slowdown to a specific change.
I don't think it's necessary here.

However, if we can do this check with UnknownSpace, we should do it.
The current implementation should feel complete on its own, even if we in long 
term we wish to get rid of the memspaces from the memregions hierarchy.

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


[clang] [nfc][analyzer] Add MemSpace trait to program state (PR #123003)

2025-01-22 Thread Balazs Benics via cfe-commits

https://github.com/steakhal commented:

I had a quick look at the PR, and over all it looks as expected. Good job!

Have you considered changing `MemRegion::getMemorySpace()` into 
`MemRegion::getMemorySpace(ProgramStateRef)`?

This should lessen the confusion of which APIs should a dev use to get the 
memspace of a region (aka. the getter). Speaking of the setter counter part, I 
think that's is special-purpose enough that most people shouldn't know it 
exist, so I don't think that would bring much confusion.

So the question is, would changing it into 
`MemRegion::getMemorySpace(ProgramStateRef)` be too intrusive to consider? 
(Maybe in some contexts where we currently call `getMemorySpace` we just don't 
have a State, and can't easily get one - and that would kill this approach.) 
Alternatively, we could say, just introduce this as an overload, and highlight 
that people should really really use this one. That would bring consistency 
while being pragmatic and accepting past design choices.

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


[clang] [llvm] [HIP] Support managed variables using the new driver (PR #123437)

2025-01-22 Thread Joseph Huber via cfe-commits

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

>From 4414706b8ced9048a572fb78544a7e637c4946a0 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Fri, 17 Jan 2025 19:56:18 -0600
Subject: [PATCH 1/3] [HIP] Support managed variables using the new driver

Summary:
Previously, managed variables didn't work in rdc mode using the new
driver because we just didn't register them. This was previously ignored
because we didn't have enough space in the current struct format. This
patch amends that by just emitting a struct pair for the two variables
and using the single pointer.

In the future, a more extensible entry format would be nice, but that
can be done later.
---
 clang/lib/CodeGen/CGCUDANV.cpp| 31 ++--
 clang/test/CodeGenCUDA/offloading-entries.cu  | 78 +--
 clang/test/Driver/linker-wrapper-image.c  | 28 ---
 .../llvm/Frontend/Offloading/Utility.h|  4 +
 .../Frontend/Offloading/OffloadWrapper.cpp| 16 
 llvm/lib/Frontend/Offloading/Utility.cpp  | 10 +++
 6 files changed, 109 insertions(+), 58 deletions(-)

diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index ae14d74f2d91511..0fc81491c40855d 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1221,12 +1221,31 @@ void CGNVCUDARuntime::createOffloadingEntries() {
  ? static_cast(llvm::offloading::OffloadGlobalNormalized)
  : 0);
 if (I.Flags.getKind() == DeviceVarFlags::Variable) {
-  llvm::offloading::emitOffloadingEntry(
-  M, I.Var, getDeviceSideName(I.D), VarSize,
-  (I.Flags.isManaged() ? llvm::offloading::OffloadGlobalManagedEntry
-   : llvm::offloading::OffloadGlobalEntry) |
-  Flags,
-  /*Data=*/0, Section);
+  if (I.Flags.isManaged()) {
+assert(I.Var->getName().ends_with(".managed") &&
+   "HIP managed variables not transformed");
+
+// Create a struct to contain the two variables.
+auto *ManagedVar = M.getNamedGlobal(
+I.Var->getName().drop_back(StringRef(".managed").size()));
+llvm::Constant *StructData[] = {ManagedVar, I.Var};
+llvm::Constant *Initializer = llvm::ConstantStruct::get(
+llvm::offloading::getManagedTy(M), StructData);
+auto *Struct = new llvm::GlobalVariable(
+M, llvm::offloading::getManagedTy(M),
+/*IsConstant=*/true, llvm::GlobalValue::PrivateLinkage, 
Initializer,
+I.Var->getName());
+
+llvm::offloading::emitOffloadingEntry(
+M, Struct, getDeviceSideName(I.D), VarSize,
+llvm::offloading::OffloadGlobalManagedEntry | Flags,
+/*Data=*/static_cast(I.Var->getAlignment()), Section);
+  } else {
+llvm::offloading::emitOffloadingEntry(
+M, I.Var, getDeviceSideName(I.D), VarSize,
+llvm::offloading::OffloadGlobalEntry | Flags,
+/*Data=*/0, Section);
+  }
 } else if (I.Flags.getKind() == DeviceVarFlags::Surface) {
   llvm::offloading::emitOffloadingEntry(
   M, I.Var, getDeviceSideName(I.D), VarSize,
diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 259e3324e8ac94f..d46a25969e3ecd7 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*" "managed.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -14,50 +14,68 @@
 
 #include "Inputs/cuda.h"
 
+#define __managed__ __attribute__((managed))
+
 //.
+// CUDA: @managed = global i32 undef, align 4
 // CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
 // CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
 // CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00", section ".llvm.rodata.offloading", align 1
 // CUDA: @.offloading.entry.var = we

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-22 Thread Serge Pavlov via cfe-commits

spavloff wrote:

> > If strict floating-point semantics are required at this call site, they are 
> > are required on every relevant call in this function. It means strictfp is 
> > a function attribute. Does anything prevents us from removal strictfp from 
> > all call sites?
>
> I think that takes us back to @kpneal's history, "Then we found that basic 
> blocks were being optimized when they didn't belong to a function so we 
> couldn't get to the where the strictfp attribute was located. The solution 
> was to add the attribute to every function call."

It sounds like a transient property, used in very specific cases. We could 
return to this problem later, when/if transition to bundles happens.

What about this PR? With it `strictfp` can be used as an indicator of a call 
that requires special handling for both constrained functions and calls with FP 
bundles, while both coexist. 

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


[clang] [llvm] [PseudoProbe] Support emitting to COFF object (PR #123870)

2025-01-22 Thread Haohai Wen via cfe-commits

https://github.com/HaohaiWen updated 
https://github.com/llvm/llvm-project/pull/123870

>From 7c531922f20bf284a5cd83b20e94cb624ef031d2 Mon Sep 17 00:00:00 2001
From: Haohai Wen 
Date: Thu, 9 Jan 2025 15:29:33 +0800
Subject: [PATCH 1/3] [COFF] Preserve UniqueID used to create MCSectionCOFF

This UniqueID can be used later to create associative section.
e.g. A .pseudo_probe associated to the section of the corresponding
function.
---
 llvm/include/llvm/MC/MCSectionCOFF.h | 9 +++--
 llvm/lib/MC/MCContext.cpp| 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/MC/MCSectionCOFF.h 
b/llvm/include/llvm/MC/MCSectionCOFF.h
index 97540d985dbd1d..9c79c27f2a9152 100644
--- a/llvm/include/llvm/MC/MCSectionCOFF.h
+++ b/llvm/include/llvm/MC/MCSectionCOFF.h
@@ -47,16 +47,19 @@ class MCSectionCOFF final : public MCSection {
   /// section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
   mutable int Selection;
 
+  unsigned UniqueID;
+
 private:
   friend class MCContext;
   // The storage of Name is owned by MCContext's COFFUniquingMap.
   MCSectionCOFF(StringRef Name, unsigned Characteristics,
-MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin)
+MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID,
+MCSymbol *Begin)
   : MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE,
   Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA,
   Begin),
 Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
-Selection(Selection) {
+Selection(Selection), UniqueID(UniqueID) {
 assert((Characteristics & 0x00F0) == 0 &&
"alignment must not be set upon section creation");
   }
@@ -72,6 +75,8 @@ class MCSectionCOFF final : public MCSection {
 
   void setSelection(int Selection) const;
 
+  unsigned getUniqueID() const { return UniqueID; }
+
   void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
 raw_ostream &OS,
 uint32_t Subsection) const override;
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 46222fcaa5b152..56aba5de4445e4 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -718,7 +718,7 @@ MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
   StringRef CachedName = Iter->first.SectionName;
   MCSymbol *Begin = getOrCreateSectionSymbol(Section);
   MCSectionCOFF *Result = new (COFFAllocator.Allocate()) MCSectionCOFF(
-  CachedName, Characteristics, COMDATSymbol, Selection, Begin);
+  CachedName, Characteristics, COMDATSymbol, Selection, UniqueID, Begin);
   Iter->second = Result;
   auto *F = allocInitialFragment(*Result);
   Begin->setFragment(F);

>From 5c201436acb13e3d0893893eabd6e128ccdff346 Mon Sep 17 00:00:00 2001
From: Haohai Wen 
Date: Tue, 21 Jan 2025 11:44:50 +0800
Subject: [PATCH 2/3] [PseudoProbe] Support emitting to COFF object

Support emitting pseudo probe to .pseudo_probe and .pseudo_probe_desc
COFF sections.
---
 clang/include/clang/Driver/Options.td |   2 +-
 clang/test/Driver/cl-options.c|   1 +
 .../llvm/Target/TargetLoweringObjectFile.h|   3 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  |  24 +-
 llvm/lib/MC/MCAsmStreamer.cpp |   3 +-
 llvm/lib/MC/MCContext.cpp |   8 +
 llvm/lib/MC/MCObjectFileInfo.cpp  |  81 --
 llvm/lib/Target/TargetLoweringObjectFile.cpp  |  27 ++
 .../pseudo-probe-callee-profile-mismatch.ll   |   4 +-
 .../SampleProfile/pseudo-probe-dangle.ll  |   2 +-
 .../SampleProfile/pseudo-probe-dangle2.ll |   2 +-
 .../SampleProfile/pseudo-probe-desc-guid.ll   |   2 +-
 .../SampleProfile/pseudo-probe-eh.ll  |   2 +-
 .../SampleProfile/pseudo-probe-emit-inline.ll |  73 --
 .../SampleProfile/pseudo-probe-emit.ll| 233 +-
 .../SampleProfile/pseudo-probe-icp-factor.ll  |   2 +-
 .../SampleProfile/pseudo-probe-inline.ll  |   2 +-
 .../SampleProfile/pseudo-probe-instsched.ll   |   2 +-
 .../SampleProfile/pseudo-probe-invoke.ll  |   4 +-
 .../pseudo-probe-missing-probe.ll |   2 +-
 .../pseudo-probe-no-debug-info.ll |   2 +-
 .../SampleProfile/pseudo-probe-peep.ll|   2 +-
 .../pseudo-probe-profile-mismatch-error.ll|   2 +-
 .../pseudo-probe-profile-mismatch-thinlto.ll  |   2 +-
 .../pseudo-probe-profile-mismatch.ll  |   4 +-
 .../pseudo-probe-selectionDAG.ll  |   2 +-
 .../SampleProfile/pseudo-probe-slotindex.ll   |   4 +-
 ...pseudo-probe-stale-profile-matching-LCS.ll |   4 +-
 ...pseudo-probe-stale-profile-matching-lto.ll |   4 +-
 .../pseudo-probe-stale-profile-matching.ll|   4 +-
 ...-probe-stale-profile-renaming-recursive.ll |   4 +-
 .../pseudo-probe-stale-profile-renaming.ll|   4 +-
 .../pseudo-probe-stale-profile-toplev-func.ll |   4 +-
 .../SampleProfile/pseudo-probe

[clang] Android defaults to pic (PR #123955)

2025-01-22 Thread via cfe-commits

https://github.com/hiraditya updated 
https://github.com/llvm/llvm-project/pull/123955

>From c26d8bd4dbbe8acbbac49249d1b8015cd5240ec9 Mon Sep 17 00:00:00 2001
From: AdityaK 
Date: Wed, 22 Jan 2025 07:23:20 -0800
Subject: [PATCH] Android defaults to pic

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6d94b964d50b01..c045069c34424f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1863,14 +1863,6 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const 
ArgList &Args) {
   // Android-specific defaults for PIC/PIE
   if (Triple.isAndroid()) {
 switch (Triple.getArch()) {
-case llvm::Triple::aarch64:
-case llvm::Triple::arm:
-case llvm::Triple::armeb:
-case llvm::Triple::thumb:
-case llvm::Triple::thumbeb:
-  PIC = true; // "-fpic"
-  break;
-
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:
   PIC = true; // "-fPIC"
@@ -1878,6 +1870,7 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const 
ArgList &Args) {
   break;
 
 default:
+  PIC = true; // "-fpic"
   break;
 }
   }

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


[clang] Revert "[Modules] Delay deserialization of preferred_name attribute at r…" (PR #123962)

2025-01-22 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 5a9b74d20d5f3b7f92c01d68d28778108dfb1308 
1d94f0a4598ec08cd75fb7c1c7353ce318da2472 --extensions h,cppm,cpp -- 
clang/include/clang/AST/Attr.h clang/include/clang/Serialization/ASTReader.h 
clang/include/clang/Serialization/ASTRecordReader.h 
clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp 
clang/lib/Serialization/ASTWriter.cpp clang/test/Modules/preferred_name.cppm 
clang/utils/TableGen/ClangAttrEmitter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index a580f375ae..69e326ee9c 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5158,8 +5158,8 @@ void ASTRecordWriter::AddAttr(const Attr *A) {
   // FIXME: Clang can't handle the serialization/deserialization of
   // preferred_name properly now. See
   // https://github.com/llvm/llvm-project/issues/56490 for example.
-  if (!A || (isa(A) &&
- Writer->isWritingStdCXXNamedModules()))
+  if (!A ||
+  (isa(A) && Writer->isWritingStdCXXNamedModules()))
 return Record.push_back(0);
 
   Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs

``




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


[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-pgo

Author: Sinkevich Artem (ArtSin)


Changes

Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID (build 
ID). It can be used with `%m` to avoid its signature collisions.

This is supported on all platforms where writing binary IDs into profiles is 
implemented, as the `__llvm_write_binary_ids` function is used.

Fixes #51560.

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


4 Files Affected:

- (modified) clang/docs/SourceBasedCodeCoverage.rst (+5) 
- (modified) clang/docs/UsersManual.rst (+3-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+52-5) 
- (added) compiler-rt/test/profile/Linux/binary-id-path.c (+37) 


``diff
diff --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 73910e134a5891..49bce3b72b45aa 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -94,6 +94,11 @@ directory structure will be created.  Additionally, the 
following special
   not specified (i.e the pattern is "%m"), it's assumed that ``N = 1``. The
   merge pool specifier can only occur once per filename pattern.
 
+* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to
+  avoid binary signature collisions. To use it, the program should be compiled
+  with the build ID linker option (``--build-id`` for GNU ld or LLD). Linux,
+  Windows and AIX are supported.
+
 * "%c" expands out to nothing, but enables a mode in which profile counter
   updates are continuously synced to a file. This means that if the
   instrumented program crashes, or is killed by a signal, perfect coverage
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..bc0ce3f3ccad07 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2880,7 +2880,8 @@ instrumentation:
environment variable to specify an alternate file. If non-default file name
is specified by both the environment variable and the command line option,
the environment variable takes precedence. The file name pattern specified
-   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%t``, and ``%c``.
+   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%b``, ``%t``, and
+   ``%c``.
 
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
@@ -2917,7 +2918,7 @@ instrumentation:
  $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
 
See `this `_ 
section
-   about the ``%t``, and ``%c`` modifiers.
+   about the ``%b``, ``%t``, and ``%c`` modifiers.
 
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index bad4cc71801ec4..01fd314e577f76 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -77,6 +77,7 @@ typedef struct lprofFilename {
   char Hostname[COMPILER_RT_MAX_HOSTLEN];
   unsigned NumPids;
   unsigned NumHosts;
+  unsigned NumBinaryIds;
   /* When in-process merging is enabled, this parameter specifies
* the total number of profile data files shared by all the processes
* spawned from the same binary. By default the value is 1. If merging
@@ -88,8 +89,8 @@ typedef struct lprofFilename {
   ProfileNameSpecifier PNS;
 } lprofFilename;
 
-static lprofFilename lprofCurFilename = {0,   0, 0, {0}, NULL,
- {0}, 0, 0, 0,   PNS_unknown};
+static lprofFilename lprofCurFilename = {0, 0, 0, {0}, NULL,   {0},
+ 0, 0, 0, 0,   PNS_unknown};
 
 static int ProfileMergeRequested = 0;
 static int getProfileFileSizeForMerging(FILE *ProfileFile,
@@ -790,7 +791,7 @@ static int checkBounds(int Idx, int Strlen) {
  * lprofcurFilename structure. */
 static int parseFilenamePattern(const char *FilenamePat,
 unsigned CopyFilenamePat) {
-  int NumPids = 0, NumHosts = 0, I;
+  int NumPids = 0, NumHosts = 0, NumBinaryIds = 0, I;
   char *PidChars = &lprofCurFilename.PidChars[0];
   char *Hostname = &lprofCurFilename.Hostname[0];
   int MergingEnabled = 0;
@@ -855,6 +856,15 @@ static int parseFilenamePattern(const char *FilenamePat,
 FilenamePat);
   return -1;
 }
+  } else if (FilenamePat[I] == 'b') {
+if (!NumBinaryIds++) {
+  if (__llvm_write_binary_ids(NULL) <= 0) {
+PROF_WARN("Unable to get binary ID for filename pattern %s. Using "
+  "the default name.",
+  FilenamePat);
+return -1;
+  }
+}
   } else if (FilenamePat[I] == 'c') {
 if (__llvm_profile_is_continuous_mode_enabled()) {
   PROF_WARN(

[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)

2025-01-22 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot3` while building 
`llvm` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[668/1346] Building CXX object 
unittests/Analysis/CMakeFiles/AnalysisTests.dir/CtxProfAnalysisTest.cpp.o
[669/1346] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/RecursiveASTVisitorTestPostOrderVisitor.cpp.o
[670/1346] Building CXX object 
unittests/DebugInfo/CodeView/CMakeFiles/DebugInfoCodeViewTests.dir/GUIDFormatTest.cpp.o
[671/1346] Building CXX object 
unittests/Analysis/CMakeFiles/AnalysisTests.dir/LoopInfoTest.cpp.o
[672/1346] Building CXX object 
unittests/CodeGen/CMakeFiles/CodeGenTests.dir/SchedBoundary.cpp.o
[673/1346] Building CXX object 
unittests/CodeGen/CMakeFiles/CodeGenTests.dir/SelectionDAGAddressAnalysisTest.cpp.o
[674/1346] Building CXX object 
unittests/DebugInfo/LogicalView/CMakeFiles/DebugInfoLogicalViewTests.dir/__/DWARF/DwarfUtils.cpp.o
[675/1346] Building CXX object 
unittests/Analysis/CMakeFiles/AnalysisTests.dir/IRSimilarityIdentifierTest.cpp.o
[676/1346] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/TransformerTest.cpp.o
[677/1346] Building CXX object 
unittests/CodeGen/GlobalISel/CMakeFiles/GlobalISelTests.dir/CSETest.cpp.o
FAILED: 
unittests/CodeGen/GlobalISel/CMakeFiles/GlobalISelTests.dir/CSETest.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build0/bin/clang++ 
-DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/unittests/CodeGen/GlobalISel
 
-I/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/CodeGen/GlobalISel
 -I/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/include 
-I/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include 
-I/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/third-party/unittest/googletest/include
 
-I/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/third-party/unittest/googlemock/include
 -nostdinc++ -isystem 
/home/b/sanitizer-x86_64-linux-fast/build/libcxx_install_asan_ubsan/include 
-isystem 
/home/b/sanitizer-x86_64-linux-fast/build/libcxx_install_asan_ubsan/include/c++/v1
 -fsanitize=address,undefined -fno-sanitize-recover=all 
-Wl,--rpath=/home/b/sanitizer-x86_64-linux-fast/build/libcxx_install_asan_ubsan/lib
 -L/home/b/sanitizer-x86_64-linux-fast/build/libcxx_install_asan_ubsan/lib -w 
-stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer 
-gline-tables-only -fsanitize=address -fsanitize=undefined 
-fno-sanitize=vptr,function -fno-sanitize-recover=all 
-fsanitize-blacklist=/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/sanitizers/ubsan_ignorelist.txt
 -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG 
-std=c++17  -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments 
-fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD 
-MT unittests/CodeGen/GlobalISel/CMakeFiles/GlobalISelTests.dir/CSETest.cpp.o 
-MF unittests/CodeGen/GlobalISel/CMakeFiles/GlobalISelTests.dir/CSETest.cpp.o.d 
-o unittests/CodeGen/GlobalISel/CMakeFiles/GlobalISelTests.dir/CSETest.cpp.o -c 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/CodeGen/GlobalISel/CSETest.cpp
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/CodeGen/GlobalISel/CSETest.cpp:84:14:
 error: no member named 'setFlag' in 'llvm::MachineInstrBuilder'; did you mean 
'setMIFlag'?
   84 | MIBFAdd2.setFlag(MachineInstr::FmNsz);
  |  ^~~
  |  setMIFlag
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/CodeGen/MachineInstrBuilder.h:280:30:
 note: 'setMIFlag' declared here
  280 |   const MachineInstrBuilder &setMIFlag(MachineInstr::MIFlag Flag) const 
{
  |  ^
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/CodeGen/GlobalISel/CSETest.cpp:87:13:
 error: no member named 'clearFlag' in 'llvm::MachineInstrBuilder'; did you 
mean to use '-

[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sinkevich Artem (ArtSin)


Changes

Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID (build 
ID). It can be used with `%m` to avoid its signature collisions.

This is supported on all platforms where writing binary IDs into profiles is 
implemented, as the `__llvm_write_binary_ids` function is used.

Fixes #51560.

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


4 Files Affected:

- (modified) clang/docs/SourceBasedCodeCoverage.rst (+5) 
- (modified) clang/docs/UsersManual.rst (+3-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+52-5) 
- (added) compiler-rt/test/profile/Linux/binary-id-path.c (+37) 


``diff
diff --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 73910e134a5891..49bce3b72b45aa 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -94,6 +94,11 @@ directory structure will be created.  Additionally, the 
following special
   not specified (i.e the pattern is "%m"), it's assumed that ``N = 1``. The
   merge pool specifier can only occur once per filename pattern.
 
+* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to
+  avoid binary signature collisions. To use it, the program should be compiled
+  with the build ID linker option (``--build-id`` for GNU ld or LLD). Linux,
+  Windows and AIX are supported.
+
 * "%c" expands out to nothing, but enables a mode in which profile counter
   updates are continuously synced to a file. This means that if the
   instrumented program crashes, or is killed by a signal, perfect coverage
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..bc0ce3f3ccad07 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2880,7 +2880,8 @@ instrumentation:
environment variable to specify an alternate file. If non-default file name
is specified by both the environment variable and the command line option,
the environment variable takes precedence. The file name pattern specified
-   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%t``, and ``%c``.
+   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%b``, ``%t``, and
+   ``%c``.
 
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
@@ -2917,7 +2918,7 @@ instrumentation:
  $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
 
See `this `_ 
section
-   about the ``%t``, and ``%c`` modifiers.
+   about the ``%b``, ``%t``, and ``%c`` modifiers.
 
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index bad4cc71801ec4..01fd314e577f76 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -77,6 +77,7 @@ typedef struct lprofFilename {
   char Hostname[COMPILER_RT_MAX_HOSTLEN];
   unsigned NumPids;
   unsigned NumHosts;
+  unsigned NumBinaryIds;
   /* When in-process merging is enabled, this parameter specifies
* the total number of profile data files shared by all the processes
* spawned from the same binary. By default the value is 1. If merging
@@ -88,8 +89,8 @@ typedef struct lprofFilename {
   ProfileNameSpecifier PNS;
 } lprofFilename;
 
-static lprofFilename lprofCurFilename = {0,   0, 0, {0}, NULL,
- {0}, 0, 0, 0,   PNS_unknown};
+static lprofFilename lprofCurFilename = {0, 0, 0, {0}, NULL,   {0},
+ 0, 0, 0, 0,   PNS_unknown};
 
 static int ProfileMergeRequested = 0;
 static int getProfileFileSizeForMerging(FILE *ProfileFile,
@@ -790,7 +791,7 @@ static int checkBounds(int Idx, int Strlen) {
  * lprofcurFilename structure. */
 static int parseFilenamePattern(const char *FilenamePat,
 unsigned CopyFilenamePat) {
-  int NumPids = 0, NumHosts = 0, I;
+  int NumPids = 0, NumHosts = 0, NumBinaryIds = 0, I;
   char *PidChars = &lprofCurFilename.PidChars[0];
   char *Hostname = &lprofCurFilename.Hostname[0];
   int MergingEnabled = 0;
@@ -855,6 +856,15 @@ static int parseFilenamePattern(const char *FilenamePat,
 FilenamePat);
   return -1;
 }
+  } else if (FilenamePat[I] == 'b') {
+if (!NumBinaryIds++) {
+  if (__llvm_write_binary_ids(NULL) <= 0) {
+PROF_WARN("Unable to get binary ID for filename pattern %s. Using "
+  "the default name.",
+  FilenamePat);
+return -1;
+  }
+}
   } else if (FilenamePat[I] == 'c') {
 if (__llvm_profile_is_continuous_mode_enabled()) {
   PROF_WAR

[clang] Android no longer supports arm < 7 (PR #123952)

2025-01-22 Thread via cfe-commits

https://github.com/hiraditya updated 
https://github.com/llvm/llvm-project/pull/123952

>From 7b83d000de0fb092461b15edd991413a3f27d713 Mon Sep 17 00:00:00 2001
From: AdityaK 
Date: Wed, 22 Jan 2025 07:14:34 -0800
Subject: [PATCH] Android no longer supports arm < 7

---
 clang/lib/Driver/ToolChains/Arch/ARM.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index c648fb66085c7f..95b82dc012c58c 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -443,14 +443,13 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple 
&Triple) {
 case llvm::Triple::MuslEABIHF:
 case llvm::Triple::EABIHF:
   return FloatABI::Hard;
+case llvm::Triple::Android:
 case llvm::Triple::GNUEABI:
 case llvm::Triple::GNUEABIT64:
 case llvm::Triple::MuslEABI:
 case llvm::Triple::EABI:
   // EABI is always AAPCS, and if it was not marked 'hard', it's softfp
   return FloatABI::SoftFP;
-case llvm::Triple::Android:
-  return (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 default:
   return FloatABI::Invalid;
 }

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


[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

2025-01-22 Thread Sinkevich Artem via cfe-commits

https://github.com/ArtSin created 
https://github.com/llvm/llvm-project/pull/123963

Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID (build 
ID). It can be used with `%m` to avoid its signature collisions.

This is supported on all platforms where writing binary IDs into profiles is 
implemented, as the `__llvm_write_binary_ids` function is used.

Fixes #51560.

>From cd11146d490985caae55a123fd34b6d3b3462077 Mon Sep 17 00:00:00 2001
From: ArtSin 
Date: Wed, 22 Jan 2025 20:20:56 +0400
Subject: [PATCH] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID

Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID
(build ID). It can be used with `%m` to avoid its signature collisions.

This is supported on all platforms where writing binary IDs into profiles
is implemented, as the `__llvm_write_binary_ids` function is used.

Fixes #51560.
---
 clang/docs/SourceBasedCodeCoverage.rst|  5 ++
 clang/docs/UsersManual.rst|  5 +-
 compiler-rt/lib/profile/InstrProfilingFile.c  | 57 +--
 .../test/profile/Linux/binary-id-path.c   | 37 
 4 files changed, 97 insertions(+), 7 deletions(-)
 create mode 100644 compiler-rt/test/profile/Linux/binary-id-path.c

diff --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 73910e134a5891..49bce3b72b45aa 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -94,6 +94,11 @@ directory structure will be created.  Additionally, the 
following special
   not specified (i.e the pattern is "%m"), it's assumed that ``N = 1``. The
   merge pool specifier can only occur once per filename pattern.
 
+* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to
+  avoid binary signature collisions. To use it, the program should be compiled
+  with the build ID linker option (``--build-id`` for GNU ld or LLD). Linux,
+  Windows and AIX are supported.
+
 * "%c" expands out to nothing, but enables a mode in which profile counter
   updates are continuously synced to a file. This means that if the
   instrumented program crashes, or is killed by a signal, perfect coverage
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..bc0ce3f3ccad07 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2880,7 +2880,8 @@ instrumentation:
environment variable to specify an alternate file. If non-default file name
is specified by both the environment variable and the command line option,
the environment variable takes precedence. The file name pattern specified
-   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%t``, and ``%c``.
+   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%b``, ``%t``, and
+   ``%c``.
 
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
@@ -2917,7 +2918,7 @@ instrumentation:
  $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
 
See `this `_ 
section
-   about the ``%t``, and ``%c`` modifiers.
+   about the ``%b``, ``%t``, and ``%c`` modifiers.
 
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index bad4cc71801ec4..01fd314e577f76 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -77,6 +77,7 @@ typedef struct lprofFilename {
   char Hostname[COMPILER_RT_MAX_HOSTLEN];
   unsigned NumPids;
   unsigned NumHosts;
+  unsigned NumBinaryIds;
   /* When in-process merging is enabled, this parameter specifies
* the total number of profile data files shared by all the processes
* spawned from the same binary. By default the value is 1. If merging
@@ -88,8 +89,8 @@ typedef struct lprofFilename {
   ProfileNameSpecifier PNS;
 } lprofFilename;
 
-static lprofFilename lprofCurFilename = {0,   0, 0, {0}, NULL,
- {0}, 0, 0, 0,   PNS_unknown};
+static lprofFilename lprofCurFilename = {0, 0, 0, {0}, NULL,   {0},
+ 0, 0, 0, 0,   PNS_unknown};
 
 static int ProfileMergeRequested = 0;
 static int getProfileFileSizeForMerging(FILE *ProfileFile,
@@ -790,7 +791,7 @@ static int checkBounds(int Idx, int Strlen) {
  * lprofcurFilename structure. */
 static int parseFilenamePattern(const char *FilenamePat,
 unsigned CopyFilenamePat) {
-  int NumPids = 0, NumHosts = 0, I;
+  int NumPids = 0, NumHosts = 0, NumBinaryIds = 0, I;
   char *PidChars = &lprofCurFilename.PidChars[0];
   char *Hostname = &lprofCurFilename.Hostname[0];
   int MergingEnabled = 0;
@@ -855,6 +856,15 @@ static int parseFilenamePattern(const char *FilenamePat,
  

[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

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


[clang] [llvm] [X86] Extend kCFI with a 3-bit arity indicator (PR #121070)

2025-01-22 Thread Sami Tolvanen via cfe-commits

samitolvanen wrote:

> A gentle reminder to please review this PR.

Overall this looks fine to me, but I was hoping to get an answer to my question 
about how the Kconfig detection is actually going to be implemented: 
https://github.com/llvm/llvm-project/pull/121070#discussion_r1911688455

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2025-01-22 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/115699

>From 8144673e0338acefe13fac0c20bbaba0412b8239 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Thu, 7 Nov 2024 12:40:56 +
Subject: [PATCH 1/4] [libclc] Move sign to the CLC builtins library

This patch necessitates some changes to how CLSPV and SPIR-V targets are
built. This is the first patch in this series in which an OpenCL
function declaration has been called from the CLC library for these
targets. Since libclc's OpenCL headers aren't being included at this
stage, the OpenCL sign function isn't available. To fix this, these two
libclc targets now have clang declare OpenCL builtins when building the
internal CLC library.

The __CLC_INTERNAL preprocessor definition has been repurposed (without
the leading underscores) to be passed when building the internal CLC
library. It was only used in one other place to guard an extra maths
preprocessor definition, which we can do unconditionally.

There are no changes (with llvm-diff) to any libclc target other than
SPIR-V, which now has OpenCL sign call __clc_sign.
---
 libclc/CMakeLists.txt | 11 ++-
 libclc/clc/include/clc/common/clc_sign.h  | 17 
 libclc/clc/include/clc/common/floatn.inc  | 85 +++
 libclc/clc/include/clc/common/unary_def.inc   |  7 ++
 libclc/clc/lib/generic/SOURCES|  1 +
 libclc/clc/lib/generic/common/clc_sign.cl | 38 +
 libclc/clc/lib/spirv/SOURCES  |  1 +
 libclc/clc/lib/spirv64/SOURCES|  1 +
 .../generic/include/clc/float/definitions.h   |  4 +-
 libclc/generic/lib/common/sign.cl | 37 +---
 10 files changed, 164 insertions(+), 38 deletions(-)
 create mode 100644 libclc/clc/include/clc/common/clc_sign.h
 create mode 100644 libclc/clc/include/clc/common/floatn.inc
 create mode 100644 libclc/clc/include/clc/common/unary_def.inc
 create mode 100644 libclc/clc/lib/generic/common/clc_sign.cl

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 2c2c7f16e29442..68ce43605b8dd6 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -347,7 +347,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )
 
 list( APPEND build_flags
-  -D__CLC_INTERNAL
   -D${CLC_TARGET_DEFINE}
   # All libclc builtin libraries see CLC headers
   -I${CMAKE_CURRENT_SOURCE_DIR}/clc/include
@@ -359,12 +358,20 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   list( APPEND build_flags -mcpu=${cpu} )
 endif()
 
+set( clc_build_flags ${build_flags} -DCLC_INTERNAL )
+
+# clspv and spir-v targets remap some CLC functions to OpenCL builtins.
+# Automatically provide those declarations to the compiler for CLC 
builtins.
+if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 OR ARCH STREQUAL clspv 
OR ARCH STREQUAL clspv64 )
+  list( APPEND clc_build_flags -Xclang -fdeclare-opencl-builtins )
+endif()
+
 add_libclc_builtin_set(
   CLC_INTERNAL
   ARCH ${ARCH}
   ARCH_SUFFIX clc-${arch_suffix}
   TRIPLE ${clang_triple}
-  COMPILE_FLAGS ${build_flags}
+  COMPILE_FLAGS ${clc_build_flags}
   OPT_FLAGS ${opt_flags}
   LIB_FILES ${clc_lib_files}
 )
diff --git a/libclc/clc/include/clc/common/clc_sign.h 
b/libclc/clc/include/clc/common/clc_sign.h
new file mode 100644
index 00..bda4fa65dfa890
--- /dev/null
+++ b/libclc/clc/include/clc/common/clc_sign.h
@@ -0,0 +1,17 @@
+#ifndef __CLC_COMMON_CLC_SIGN_H__
+#define __CLC_COMMON_CLC_SIGN_H__
+
+#if defined(CLC_CLSPV)
+// clspv targets provide their own OpenCL-compatible sign
+#define __clc_sign sign
+#else
+
+#define __CLC_FUNCTION __clc_sign
+#define __CLC_BODY 
+#include 
+#undef __CLC_FUNCTION
+#undef __CLC_BODY
+
+#endif
+
+#endif // __CLC_COMMON_CLC_SIGN_H__
diff --git a/libclc/clc/include/clc/common/floatn.inc 
b/libclc/clc/include/clc/common/floatn.inc
new file mode 100644
index 00..2c4285d5bcbc58
--- /dev/null
+++ b/libclc/clc/include/clc/common/floatn.inc
@@ -0,0 +1,85 @@
+#define __CLC_FLOATN float
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN float2
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN float3
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN float4
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN float8
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN float16
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#undef __CLC_FLOAT
+#undef __CLC_INT
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+#define __CLC_FLOATN double
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN double2
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN double3
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN double4
+#include __CLC_BODY
+#undef __CLC_FLOATN
+
+#define __CLC_FLOATN double8
+#include __

[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)

2025-01-22 Thread Nico Weber via cfe-commits

nico wrote:

Seems seems to break tests: http://45.33.8.238/linux/158130/step_11.txt

Please take a look, and revert for now if it takes a while to fix.

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


[libclc] [libclc] Move sign to the CLC builtins library (PR #115699)

2025-01-22 Thread Fraser Cormack via cfe-commits

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


[clang] [llvm] [X86] Extend kCFI with a 3-bit arity indicator (PR #121070)

2025-01-22 Thread Sami Tolvanen via cfe-commits

samitolvanen wrote:

> And AFAIK there's no other users of kCFI besides the Linux kernel (but please 
> correct me if I'm wrong).

There are firmware projects that use KCFI, but AFAIK none of them run on x86. 
I'm also fairly certain that only Linux performs runtime patching based on the 
code sequence we emit, so I'm not particularly concerned about breaking other 
KCFI users with this change.

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/123912

Don't Evaluate RHS in if directive when short circuit. Examples include
   #if 0 && another_condition
   #if 1 || another_condition

>From 43ec3fe59bd5f1000e484fa98f323b1512a5e892 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 22 Jan 2025 09:04:44 +
Subject: [PATCH] Clang/Preprocessor: Support short circuit in directive

Don't Evaluate RHS in if directive when short circuit.
Examples include
   #if 0 && another_condition
   #if 1 || another_condition
---
 clang/lib/Lex/PPExpressions.cpp   | 28 ++-
 .../Preprocessor/directive-short-circuit.c| 74 +++
 2 files changed, 101 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Preprocessor/directive-short-circuit.c

diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index a3b1384f0fa1d6..7e413ec6076642 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -624,7 +624,33 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, 
unsigned MinPrec,
 
 // Consume the operator, remembering the operator's location for reporting.
 SourceLocation OpLoc = PeekTok.getLocation();
-PP.LexNonComment(PeekTok);
+
+if (!RHSIsLive && (Operator == tok::ampamp || Operator == tok::pipepipe)) {
+  unsigned ThisPrec = PeekPrec;
+  while (true) {
+PP.LexUnexpandedNonComment(PeekTok);
+if (PeekTok.is(tok::l_paren)) {
+  unsigned NestParen = 1;
+  while (true) {
+PP.LexUnexpandedNonComment(PeekTok);
+if (PeekTok.is(tok::l_paren))
+  NestParen++;
+else if (PeekTok.is(tok::r_paren))
+  NestParen--;
+if (NestParen == 0)
+  break;
+  }
+  PP.LexUnexpandedNonComment(PeekTok);
+}
+PeekPrec = getPrecedence(PeekTok.getKind());
+if (PeekPrec <= ThisPrec) {
+  LHS.setEnd(PeekTok.getEndLoc());
+  break;
+}
+  }
+  continue;
+} else
+  PP.LexNonComment(PeekTok);
 
 PPValue RHS(LHS.getBitWidth());
 // Parse the RHS of the operator.
diff --git a/clang/test/Preprocessor/directive-short-circuit.c 
b/clang/test/Preprocessor/directive-short-circuit.c
new file mode 100644
index 00..d137f8198cbbcf
--- /dev/null
+++ b/clang/test/Preprocessor/directive-short-circuit.c
@@ -0,0 +1,74 @@
+// RUN: %clang -E -MD -MF - %s | FileCheck -check-prefix ZERO_AND_HAS_INCLUDE 
%s
+//
+// ZERO_AND_HAS_INCLUDE-NOT: limits.h
+//
+#if 0 && __has_include()
+#include 
+#endif
+
+#if 4==5 && __has_include()
+#include 
+#endif
+
+#if defined(_THIS_IS_NOT_DEFINED) && __has_include()
+#include 
+#endif
+
+#if 0 && (__has_include())
+#include 
+#endif
+
+#if 4==5 && (__has_include())
+#include 
+#endif
+
+#if defined(_THIS_IS_NOT_DEFINED) && (__has_include())
+#include 
+#endif
+
+#if 0 && (5==5 && __has_include())
+#include 
+#endif
+
+#if 1 && (4==5 && __has_include())
+#include 
+#endif
+
+
+
+
+
+
+#if 1 || __has_include()
+XX
+#endif
+#if 5==5 || __has_include()
+XX
+#endif
+
+#if defined(__clang__) || __has_include()
+XX
+#endif
+
+#if 1 || (__has_include())
+#endif
+
+#if 5==5 || (__has_include())
+XX
+#endif
+
+#if defined(__clang__) || (__has_include())
+XX
+#endif
+
+#if 1 && (5==5 || __has_include())
+XX
+#endif
+
+#if 1 || (5==5 || __has_include())
+XX
+#endif
+
+#if 0 || (5==5 || __has_include())
+XX
+#endif

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


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-01-22 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Just a `s/both/expected/` in those two lines should be enough

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


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-01-22 Thread Jan Patrick Lehr via cfe-commits

jplehr wrote:

Thank you.

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


[clang] Clang/Preprocessor: Support short circuit in directive (PR #123912)

2025-01-22 Thread via cfe-commits

cor3ntin wrote:

Can you explain the motivation for this change? Thanks

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


[clang] [C++20][Modules] Fix crash/compiler error due broken AST links (PR #123648)

2025-01-22 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin updated 
https://github.com/llvm/llvm-project/pull/123648

>From e5cd06ddbc4193f9d5910eba93f0eb309d67063c Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Mon, 20 Jan 2025 09:03:25 -0800
Subject: [PATCH 1/3] [C++20][Modules] Fix crash/compiler error due broken AST
 links
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Summary:
This PR fixes bugreport https://github.com/llvm/llvm-project/issues/122493
The root problem is the same as before lambda function and DeclRefExpr 
references
a variable that does not belong to the same module as the enclosing function 
body.
Therefore iteration over the function body doesn’t visit the VarDecl. Before 
this
change RelatedDeclsMap was created only for canonical decl but in reality it 
has to
be done for the definition of the function that does not always match the 
canonical decl.

Test Plan: check-clang
---
 clang/lib/Serialization/ASTWriterDecl.cpp |  5 +-
 ...ash-instantiated-in-scope-cxx-modules5.cpp | 92 +++
 2 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 
clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp

diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index f8ed155ca389d7..371b4b29e85991 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1571,9 +1571,10 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) 
{
 } else {
   Record.push_back(0);
 }
-// For lambdas inside canonical FunctionDecl remember the mapping.
+// For lambdas inside template functions, remember the mapping to
+// deserialize them together.
 if (auto FD = llvm::dyn_cast_or_null(D->getDeclContext());
-FD && FD->isCanonicalDecl()) {
+FD && FD->isDependentContext() && FD->isThisDeclarationADefinition()) {
   Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
   Writer.GetDeclRef(D));
 }
diff --git a/clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp 
b/clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp
new file mode 100644
index 00..ca80a3fd21dd00
--- /dev/null
+++ b/clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp
@@ -0,0 +1,92 @@
+// RUN: rm -fR %t
+// RUN: split-file %s %t
+// RUN: cd %t
+// RUN: %clang_cc1 -verify -std=c++20 -xc++ -emit-module module.cppmap 
-fmodule-name=mock_resolver -o mock_resolver.pcm
+// RUN: %clang_cc1 -verify -std=c++20 -xc++ -emit-module module.cppmap 
-fmodule-name=sql_internal -o sql_internal.pcm
+// RUN: %clang_cc1 -verify -std=c++20 -xc++ -fmodule-file=mock_resolver.pcm 
-fmodule-file=sql_internal.pcm main.cc -o main.o
+
+//--- module.cppmap
+module "mock_resolver" {
+  export *
+  module "mock_resolver.h" {
+export *
+header "mock_resolver.h"
+  }
+}
+
+module "sql_internal" {
+  export *
+  module "sql_transform_builder.h" {
+export *
+header "sql_transform_builder.h"
+  }
+}
+
+//--- set_bits2.h
+// expected-no-diagnostics
+#pragma once
+
+template 
+void fwd(const T& x) {}
+
+namespace vox::bitset {
+
+template 
+void ForEachSetBit2(const TFunc&) {
+  fwd([](int) {
+const int bit_index_base = 0;
+(void)[&](int) {
+  int v = bit_index_base;
+};
+  });
+}
+
+}  // namespace vox::bitset
+
+//--- sql_transform_builder.h
+// expected-no-diagnostics
+#pragma once
+
+#include "set_bits2.h"
+
+class QualifyingSet3 {
+ public:
+  void GetIndexes() const {
+vox::bitset::ForEachSetBit2([]() {});
+  }
+};
+
+template 
+void DoTransform() {
+  vox::bitset::ForEachSetBit2([]() {});
+}
+
+//--- mock_resolver.h
+// expected-no-diagnostics
+#pragma once 
+#include "set_bits2.h"
+
+class QualifyingSet2 {
+ public:
+  void GetIndexes() const {
+vox::bitset::ForEachSetBit2([]() {});
+  }
+};
+
+//--- main.cc
+// expected-no-diagnostics
+#include "sql_transform_builder.h"
+
+template 
+void get(const Callable& fn) {
+  fwd(fn);
+}
+
+namespace {
+
+void test() {
+  get([]() {});
+  DoTransform();
+}
+
+} // namespace

>From 01254792e2b75e00cc44259b27fcb4e38e719629 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Tue, 21 Jan 2025 02:32:33 -0800
Subject: [PATCH 2/3] Add -Werror=uninitialized to add compilation error in
 builds without assserts All improve comments

---
 clang/include/clang/Serialization/ASTReader.h | 11 ++-
 clang/lib/Serialization/ASTWriterDecl.cpp |  6 +++---
 .../crash-instantiated-in-scope-cxx-modules5.cpp  |  6 +++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 9f978762a6fb6b..d27a49863fc557 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -539,11 +539,12 @@ class ASTReader
 
   /// Mapping from main decl ID to the related decls IDs.
   //

[clang] [Driver][ASan] Refactor Clang-Driver "Sanitizer Bitcode" linking. (PR #123922)

2025-01-22 Thread Matt Arsenault via cfe-commits


@@ -70,6 +70,10 @@ def err_drv_no_rocm_device_lib : Error<
   "cannot find ROCm device library%select{| for %1| for ABI version %1}0; 
provide its path via "
   "'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build "
   "without ROCm device library">;
+def err_drv_no_asan_rt_lib
+: Error<"AMDGPU address sanitizer runtime library (asanrtl) is not found. "
+"Please install ROCm device library which supports address "
+"sanitizer">;

arsenm wrote:

```suggestion
: Error<"address sanitizer runtime library (asanrtl) is not found">;
```

Error messages should start with lowercase, and the suggestion to install 
anything is strange. Installation of anything is not required. I also don't see 
why we would have multiple configurations of the libraries, this should just be 
packaged in 100% of cases with the rest of the libraries 



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


[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-01-22 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: AST/ByteCode/cxx2a.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -std=c++2a -fsyntax-only -fcxx-exceptions -verify=ref,both 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp
error: 'both-error' diagnostics expected but not seen: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp
 Line 142: constant expression
error: 'both-note' diagnostics expected but not seen: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/cxx2a.cpp
 Line 142: typeid applied to object 'extern_b2' whose dynamic type is not 
constant
2 errors generated.

--




```



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


[clang] [C++20][Modules] Fix crash/compiler error due broken AST links (PR #123648)

2025-01-22 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin updated 
https://github.com/llvm/llvm-project/pull/123648

>From e5cd06ddbc4193f9d5910eba93f0eb309d67063c Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Mon, 20 Jan 2025 09:03:25 -0800
Subject: [PATCH 1/7] [C++20][Modules] Fix crash/compiler error due broken AST
 links
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Summary:
This PR fixes bugreport https://github.com/llvm/llvm-project/issues/122493
The root problem is the same as before lambda function and DeclRefExpr 
references
a variable that does not belong to the same module as the enclosing function 
body.
Therefore iteration over the function body doesn’t visit the VarDecl. Before 
this
change RelatedDeclsMap was created only for canonical decl but in reality it 
has to
be done for the definition of the function that does not always match the 
canonical decl.

Test Plan: check-clang
---
 clang/lib/Serialization/ASTWriterDecl.cpp |  5 +-
 ...ash-instantiated-in-scope-cxx-modules5.cpp | 92 +++
 2 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 
clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp

diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index f8ed155ca389d7..371b4b29e85991 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1571,9 +1571,10 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) 
{
 } else {
   Record.push_back(0);
 }
-// For lambdas inside canonical FunctionDecl remember the mapping.
+// For lambdas inside template functions, remember the mapping to
+// deserialize them together.
 if (auto FD = llvm::dyn_cast_or_null(D->getDeclContext());
-FD && FD->isCanonicalDecl()) {
+FD && FD->isDependentContext() && FD->isThisDeclarationADefinition()) {
   Writer.RelatedDeclsMap[Writer.GetDeclRef(FD)].push_back(
   Writer.GetDeclRef(D));
 }
diff --git a/clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp 
b/clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp
new file mode 100644
index 00..ca80a3fd21dd00
--- /dev/null
+++ b/clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp
@@ -0,0 +1,92 @@
+// RUN: rm -fR %t
+// RUN: split-file %s %t
+// RUN: cd %t
+// RUN: %clang_cc1 -verify -std=c++20 -xc++ -emit-module module.cppmap 
-fmodule-name=mock_resolver -o mock_resolver.pcm
+// RUN: %clang_cc1 -verify -std=c++20 -xc++ -emit-module module.cppmap 
-fmodule-name=sql_internal -o sql_internal.pcm
+// RUN: %clang_cc1 -verify -std=c++20 -xc++ -fmodule-file=mock_resolver.pcm 
-fmodule-file=sql_internal.pcm main.cc -o main.o
+
+//--- module.cppmap
+module "mock_resolver" {
+  export *
+  module "mock_resolver.h" {
+export *
+header "mock_resolver.h"
+  }
+}
+
+module "sql_internal" {
+  export *
+  module "sql_transform_builder.h" {
+export *
+header "sql_transform_builder.h"
+  }
+}
+
+//--- set_bits2.h
+// expected-no-diagnostics
+#pragma once
+
+template 
+void fwd(const T& x) {}
+
+namespace vox::bitset {
+
+template 
+void ForEachSetBit2(const TFunc&) {
+  fwd([](int) {
+const int bit_index_base = 0;
+(void)[&](int) {
+  int v = bit_index_base;
+};
+  });
+}
+
+}  // namespace vox::bitset
+
+//--- sql_transform_builder.h
+// expected-no-diagnostics
+#pragma once
+
+#include "set_bits2.h"
+
+class QualifyingSet3 {
+ public:
+  void GetIndexes() const {
+vox::bitset::ForEachSetBit2([]() {});
+  }
+};
+
+template 
+void DoTransform() {
+  vox::bitset::ForEachSetBit2([]() {});
+}
+
+//--- mock_resolver.h
+// expected-no-diagnostics
+#pragma once 
+#include "set_bits2.h"
+
+class QualifyingSet2 {
+ public:
+  void GetIndexes() const {
+vox::bitset::ForEachSetBit2([]() {});
+  }
+};
+
+//--- main.cc
+// expected-no-diagnostics
+#include "sql_transform_builder.h"
+
+template 
+void get(const Callable& fn) {
+  fwd(fn);
+}
+
+namespace {
+
+void test() {
+  get([]() {});
+  DoTransform();
+}
+
+} // namespace

>From 01254792e2b75e00cc44259b27fcb4e38e719629 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Tue, 21 Jan 2025 02:32:33 -0800
Subject: [PATCH 2/7] Add -Werror=uninitialized to add compilation error in
 builds without assserts All improve comments

---
 clang/include/clang/Serialization/ASTReader.h | 11 ++-
 clang/lib/Serialization/ASTWriterDecl.cpp |  6 +++---
 .../crash-instantiated-in-scope-cxx-modules5.cpp  |  6 +++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 9f978762a6fb6b..d27a49863fc557 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -539,11 +539,12 @@ class ASTReader
 
   /// Mapping from main decl ID to the related decls IDs.
   //

[clang] [C++20][Modules] Fix crash/compiler error due broken AST links (PR #123648)

2025-01-22 Thread Dmitry Polukhin via cfe-commits


@@ -799,14 +813,14 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   }
 
   if (D->getFriendObjectKind()) {
-// For a function defined inline within a class template, we have to force
-// the canonical definition to be the one inside the canonical definition 
of
-// the template. Remember this relation to deserialize them together.
-if (auto *RD = dyn_cast(D->getLexicalParent()))
-  if (RD->isDependentContext() && RD->isThisDeclarationADefinition()) {
-Writer.RelatedDeclsMap[Writer.GetDeclRef(RD)].push_back(
-Writer.GetDeclRef(D));
-  }
+// For a friend function defined inline within a class template, we have to
+// force the definition to be the one inside the definition of the template
+// class. Remember this relation to deserialize them together.
+if (auto *RD = dyn_cast(D->getLexicalParent());
+isDefinitionInDependentContext(RD)) {

dmpolukhin wrote:

Added but I think it cannot happen after `getFriendObjectKind` check.

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


[clang] [clang][ExprConst] Avoid initializer diags if there is no init (PR #123925)

2025-01-22 Thread Timm Baeder via cfe-commits

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


[clang] [clang-tools-extra] [clang-reorder-fields] Reorder leading comments (PR #123740)

2025-01-22 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentDelayWatchBreak.py (616 
of 2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py
 (617 of 2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py
 (618 of 2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py (619 
of 2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py (620 of 
2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py (621 of 
2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalDelayBreak.py (622 
of 2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManyCrash.py (623 of 
2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManySignals.py (624 of 
2071)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py (625 
of 2071)
FAIL: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py (626 of 
2071)
 TEST 'lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py' FAILED 

Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/thread/concurrent_events
 -p TestConcurrentSignalWatch.py
--
Exit Code: 1

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

Watchpoint 1 hit:
old value: 0
new value: 1

--
Command Output (stderr):
--
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test (TestConcurrentSignalWatch.ConcurrentSignalWatch)
==
FAIL: test (TestConcurrentSignalWatch.ConcurrentSignalWatch)
   Test a watchpoint and a signal in multiple threads.
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 148, in wrapper
return func(*args, **kwargs)
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py",
 line 14, in test
self.do_thread_actions(num_signal_threads=1, num_watchpoint_threads=1)
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/concurrent_base.py",
 line 333, in do_thread_actions
self.assertEqual(
AssertionError: 1 != 2 : Expected 1 stops due to signal delivery, but got 2
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
--
Ran 1 test in 0.685s


```



https://github.com/llvm/llvm-project/pull/123740
___
cfe-commits mailing lis

[clang-tools-extra] [clang-tidy] Add EnableQtSupport option to modernize-use-integer-sign-comprison (PR #122127)

2025-01-22 Thread via cfe-commits

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


[clang] 6b486f4 - [Clang][Arch] Disable mve.fp when explicit -mfpu option (#123028)

2025-01-22 Thread via cfe-commits

Author: flopop01
Date: 2025-01-22T15:49:19Z
New Revision: 6b486f458fe40919577d9249fa754daa913795d1

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

LOG: [Clang][Arch] Disable mve.fp when explicit -mfpu option (#123028)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Preprocessor/arm-target-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index c648fb66085c7f..f9d8aacaad234d 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -756,6 +756,15 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
   Features.push_back("-crc");
   }
 
+  // Invalid value of the __ARM_FEATURE_MVE macro when an explicit -mfpu= 
option
+  // disables MVE-FP -mfpu=fpv5-d16 or -mfpu=fpv5-sp-d16 disables the scalar
+  // half-precision floating-point operations feature. Therefore, because the
+  // M-profile Vector Extension (MVE) floating-point feature requires the 
scalar
+  // half-precision floating-point operations, this option also disables the 
MVE
+  // floating-point feature: -mve.fp
+  if (FPUKind == llvm::ARM::FK_FPV5_D16 || FPUKind == 
llvm::ARM::FK_FPV5_SP_D16)
+Features.push_back("-mve.fp");
+
   // For Arch >= ARMv8.0 && A or R profile:  crypto = sha2 + aes
   // Rather than replace within the feature vector, determine whether each
   // algorithm is enabled and append this to the end of the vector.

diff  --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index 95ca7d0cbc3c2a..ecf9d7eb5c19c9 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -1005,3 +1005,11 @@
 // CHECK-V83-OR-LATER: __ARM_FEATURE_COMPLEX 1
 // CHECK-V81-OR-LATER: __ARM_FEATURE_QRDMX 1
 // CHECK-BEFORE-V83-NOT: __ARM_FEATURE_COMPLEX 1
+
+// Check if MVE floating-point feature is disabled (-mve.fp) during explicit 
fpv5-d16 or fpv5-sp-d16
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp 
-mfpu=fpv5-d16 -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-MVE1 %s
+// CHECK-MVE1: #define __ARM_FEATURE_MVE 1
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp 
-mfpu=fpv5-sp-d16 -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-MVE1_2 %s
+// CHECK-MVE1_2: #define __ARM_FEATURE_MVE 1
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp -x c -E 
-dM %s -o - | FileCheck -check-prefix=CHECK-MVE3 %s
+// CHECK-MVE3: #define __ARM_FEATURE_MVE 3



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


[clang] [Clang][Arch] Disable mve.fp when explicit -mfpu option (PR #123028)

2025-01-22 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [clang][Modules] Raise empty.modulemap expected size to <70KB to fix RISC-V failure (PR #123959)

2025-01-22 Thread Alex Bradbury via cfe-commits

https://github.com/asb created https://github.com/llvm/llvm-project/pull/123959

I'm not sure why the test is larger for RISC-V than other targets, but we saw 
this before with #111360.

The file is just over the current 60KB limit:

```
62772 
/home/asb/llvm-project/build/stage2/tools/clang/test/Modules/Output/empty.modulemap.tmp/base.pcm
```

>From 00fb282a7bb78dd8e511226408f2e5578232b62a Mon Sep 17 00:00:00 2001
From: Alex Bradbury 
Date: Wed, 22 Jan 2025 15:45:49 +
Subject: [PATCH] [clang][Modules] Raise empty.modulemap expected size to <70KB
 to fix RISC-V failure

I'm not sure why the test is larger for RISC-V than other targets, but
we saw this before with #111360.

The file is just over the current 60KB limit:

```
62772 
/home/asb/llvm-project/build/stage2/tools/clang/test/Modules/Output/empty.modulemap.tmp/base.pcm
```
---
 clang/test/Modules/empty.modulemap | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Modules/empty.modulemap 
b/clang/test/Modules/empty.modulemap
index f2d37c19d77bcc..8cad8b67b91155 100644
--- a/clang/test/Modules/empty.modulemap
+++ b/clang/test/Modules/empty.modulemap
@@ -13,8 +13,8 @@
 // The module file should be identical each time we produce it.
 // RUN: diff %t/base.pcm %t/check.pcm
 //
-// We expect an empty module to be less than 60KB (and at least 10K, for now).
+// We expect an empty module to be less than 70KB (and at least 10K, for now).
 // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-6][0-9][0-9][0-9][0-9]($|[^0-9])}}
 
 module empty { header "Inputs/empty.h" export * }

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


[clang] [clang][Modules] Raise empty.modulemap expected size to <70KB to fix RISC-V failure (PR #123959)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Alex Bradbury (asb)


Changes

I'm not sure why the test is larger for RISC-V than other targets, but we saw 
this before with #111360.

The file is just over the current 60KB limit:

```
62772 
/home/asb/llvm-project/build/stage2/tools/clang/test/Modules/Output/empty.modulemap.tmp/base.pcm
```

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


1 Files Affected:

- (modified) clang/test/Modules/empty.modulemap (+2-2) 


``diff
diff --git a/clang/test/Modules/empty.modulemap 
b/clang/test/Modules/empty.modulemap
index f2d37c19d77bcc..8cad8b67b91155 100644
--- a/clang/test/Modules/empty.modulemap
+++ b/clang/test/Modules/empty.modulemap
@@ -13,8 +13,8 @@
 // The module file should be identical each time we produce it.
 // RUN: diff %t/base.pcm %t/check.pcm
 //
-// We expect an empty module to be less than 60KB (and at least 10K, for now).
+// We expect an empty module to be less than 70KB (and at least 10K, for now).
 // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-6][0-9][0-9][0-9][0-9]($|[^0-9])}}
 
 module empty { header "Inputs/empty.h" export * }

``




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


[clang] [C++20] [Modules] Fix may-be incorrect ADL for module local entities (PR #123931)

2025-01-22 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/123931

>From d83d7bd83cd6bd635420ec4e824afa299f20c154 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Wed, 22 Jan 2025 11:41:55 +0800
Subject: [PATCH] [C++20] [Modules] Fix may-be incorrect ADL for module local
 entities

Close https://github.com/llvm/llvm-project/issues/123815

See the comments for details
---
 clang/lib/Sema/SemaLookup.cpp | 52 ++-
 .../Modules/module-local-hidden-friend-2.cppm | 43 +++
 2 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Modules/module-local-hidden-friend-2.cppm

diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index e18e3c197383e2..2751cfd6b18e96 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2914,7 +2914,57 @@ static void 
CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces,
   while (!Ctx->isFileContext() || Ctx->isInlineNamespace())
 Ctx = Ctx->getParent();
 
-  Namespaces.insert(Ctx->getPrimaryContext());
+  // Actually it is fine to always do `Namespaces.insert(Ctx);` simply. But it
+  // may cause more allocations in Namespaces and more unnecessary lookups. So
+  // we'd like to insert the representative namespace only.
+  DeclContext *PrimaryCtx = Ctx->getPrimaryContext();
+  Decl *PrimaryD = cast(PrimaryCtx);
+  Decl *D = cast(Ctx);
+  ASTContext &AST = D->getASTContext();
+
+  // TODO: Technically it is better to insert one namespace per module. e.g.,
+  //
+  // ```
+  // //--- first.cppm
+  // export module first;
+  // namespace ns { ... } // first namespace
+  //
+  // //--- m-partA.cppm
+  // export module m:partA;
+  // import first;
+  //
+  // namespace ns { ... }
+  // namespace ns { ... }
+  //
+  // //--- m-partB.cppm
+  // export module m:partB;
+  // import first;
+  // import :partA;
+  //
+  // namespace ns { ... }
+  // namespace ns { ... }
+  //
+  // ...
+  //
+  // //--- m-partN.cppm
+  // export module m:partN;
+  // import first;
+  // import :partA;
+  // ...
+  // import :part$(N-1);
+  //
+  // namespace ns { ... }
+  // namespace ns { ... }
+  //
+  // consume(ns::any_decl); // the lookup
+  // ```
+  //
+  // We should only insert once for all namespaces in module m.
+  if (D->isInNamedModule() &&
+  !AST.isInSameModule(D->getOwningModule(), PrimaryD->getOwningModule()))
+Namespaces.insert(Ctx);
+  else
+Namespaces.insert(PrimaryCtx);
 }
 
 // Add the associated classes and namespaces for argument-dependent
diff --git a/clang/test/Modules/module-local-hidden-friend-2.cppm 
b/clang/test/Modules/module-local-hidden-friend-2.cppm
new file mode 100644
index 00..d415e495abb213
--- /dev/null
+++ b/clang/test/Modules/module-local-hidden-friend-2.cppm
@@ -0,0 +1,43 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm \
+// RUN: -fmodule-file=a=%t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm 
-fmodule-file=b=%t/b.pcm \
+// RUN: -fsyntax-only -verify
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o 
%t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o 
%t/b.pcm \
+// RUN: -fmodule-file=a=%t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm 
-fmodule-file=b=%t/b.pcm \
+// RUN: -fsyntax-only -verify
+
+//--- a.cppm
+export module a;
+
+namespace n {
+}
+
+//--- b.cppm
+export module b;
+import a;
+
+namespace n {
+struct monostate {
+   friend bool operator==(monostate, monostate) = default;
+};
+
+export struct wrapper {
+   friend bool operator==(wrapper const &, wrapper const &) = default;
+
+   monostate m_value;
+};
+}
+
+//--- use.cc
+// expected-no-diagnostics
+import b;
+
+static_assert(n::wrapper() == n::wrapper());

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


  1   2   3   4   5   >