[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

2024-12-15 Thread via cfe-commits

leijurv wrote:

Ping 🙏 

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


[clang] [llvm] [BoundsChecking] Add parameters to pass (PR #119894)

2024-12-15 Thread Thurston Dang via cfe-commits

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


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


[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-15 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 f4081711f0884ec7afe93577e118ecc89cb7b1cf 
1e79973ed4ea56c66f8b7eb1db9d00784edac7f0 --extensions cpp -- 
clang/lib/Format/MacroExpander.cpp 
clang/unittests/Format/MacroCallReconstructorTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/unittests/Format/MacroCallReconstructorTest.cpp 
b/clang/unittests/Format/MacroCallReconstructorTest.cpp
index 222e689f86..083d6f8174 100644
--- a/clang/unittests/Format/MacroCallReconstructorTest.cpp
+++ b/clang/unittests/Format/MacroCallReconstructorTest.cpp
@@ -226,7 +226,8 @@ TEST_F(MacroCallReconstructorTest, EmptyExpansion) {
   Unexp.addLine(line(Exp.getTokens()));
   EXPECT_TRUE(Unexp.finished());
   Matcher U(Call, Lex);
-  EXPECT_THAT(std::move(Unexp).takeResult(), 
matchesLine(line(U.consume("A()";
+  EXPECT_THAT(std::move(Unexp).takeResult(),
+  matchesLine(line(U.consume("A()";
 }
 
 TEST_F(MacroCallReconstructorTest, NestedLineWithinCall) {

``




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


[clang] [llvm] [NFC] [RISCV] Refactor class RISCVExtension (PR #120040)

2024-12-15 Thread Shao-Ce SUN via cfe-commits


@@ -22,11 +22,17 @@
 // uses the record name by replacing Feature with Has.
 // value - Value to assign to the field in RISCVSubtarget when this
 // extension is enabled. Usually "true", but can be changed.
-class RISCVExtension implies = [],
  string fieldname = !subst("Feature", "Has", NAME),
- string value = "true">
-: SubtargetFeature {
+ string value = "true", string prefix = "">

sunshaoce wrote:

Done. Thanks!

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


[clang] [llvm] [NFC] [RISCV] Refactor class RISCVExtension (PR #120040)

2024-12-15 Thread Pengcheng Wang via cfe-commits


@@ -22,11 +22,20 @@
 // uses the record name by replacing Feature with Has.
 // value - Value to assign to the field in RISCVSubtarget when this
 // extension is enabled. Usually "true", but can be changed.
-class RISCVExtension implies = [],
  string fieldname = !subst("Feature", "Has", NAME),
- string value = "true">
-: SubtargetFeature {
+ string value = "true", bit IsExperimental = false>
+: SubtargetFeature<
+!if(IsExperimental, "experimental-", "")

wangpc-pp wrote:

You can pass `""` here and use `let` to override the `Name` field, so that we 
can remove duplicated `!subst`s via using `defvar` statements.

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


[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Daniil Kovalev via cfe-commits

https://github.com/kovdan01 updated 
https://github.com/llvm/llvm-project/pull/119361

>From 944b2f8fb6357c5ef9efbdaf0c2c3dcd8cb9f890 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev 
Date: Tue, 10 Dec 2024 08:48:09 +0300
Subject: [PATCH 1/2] [PAC][ELF][AArch64] Support signed personality function
 pointer

If function pointer signing is enabled, sign personality function
pointer stored in `.DW.ref.__gxx_personality_v0` section with IA key,
0x7EAD = `ptrauth_string_discriminator("personality")` constant
discriminator and address diversity enabled.
---
 clang/lib/CodeGen/CodeGenModule.cpp   |  3 +
 clang/test/CodeGen/ptrauth-module-flags.c |  5 ++
 .../llvm/CodeGen/MachineModuleInfoImpls.h |  8 +-
 .../CodeGen/TargetLoweringObjectFileImpl.h|  8 +-
 .../llvm/Target/TargetLoweringObjectFile.h|  3 +-
 .../CodeGen/AsmPrinter/DwarfCFIException.cpp  |  3 +-
 llvm/lib/CodeGen/MachineModuleInfoImpls.cpp   | 12 +++
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 10 ++-
 .../AArch64/AArch64TargetObjectFile.cpp   | 16 
 .../Target/AArch64/AArch64TargetObjectFile.h  |  4 +
 .../MCTargetDesc/AArch64TargetStreamer.cpp| 10 +++
 .../MCTargetDesc/AArch64TargetStreamer.h  |  6 ++
 llvm/lib/Target/TargetLoweringObjectFile.cpp  |  7 +-
 .../AArch64/ptrauth-sign-personality.ll   | 73 +++
 14 files changed, 159 insertions(+), 9 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-sign-personality.ll

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d3d5c0743a520b..841fb1ced9a02b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1218,6 +1218,9 @@ void CodeGenModule::Release() {
   getModule().addModuleFlag(llvm::Module::Min, "ptrauth-elf-got", 1);
 
 if (getTriple().isOSLinux()) {
+  if (LangOpts.PointerAuthCalls)
+getModule().addModuleFlag(llvm::Module::Min, 
"ptrauth-sign-personality",
+  1);
   assert(getTriple().isOSBinFormatELF());
   using namespace llvm::ELF;
   uint64_t PAuthABIVersion =
diff --git a/clang/test/CodeGen/ptrauth-module-flags.c 
b/clang/test/CodeGen/ptrauth-module-flags.c
index 5a7e9a7c2a36fe..e441d52cb7c62b 100644
--- a/clang/test/CodeGen/ptrauth-module-flags.c
+++ b/clang/test/CodeGen/ptrauth-module-flags.c
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu   -emit-llvm %s  
-o - | FileCheck %s --check-prefix=OFF
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-elf-got -emit-llvm %s  
-o - | FileCheck %s --check-prefix=ELFGOT
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls   -emit-llvm %s  
-o - | FileCheck %s --check-prefix=PERSONALITY
 
 // ELFGOT:  !llvm.module.flags = !{
 // ELFGOT-SAME: !1
 // ELFGOT:  !1 = !{i32 8, !"ptrauth-elf-got", i32 1}
 
+// PERSONALITY:  !llvm.module.flags = !{
+// PERSONALITY-SAME: !1
+// PERSONALITY:  !1 = !{i32 8, !"ptrauth-sign-personality", i32 1}
+
 // OFF-NOT: "ptrauth-
diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h 
b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
index c1ae3d2d966df5..f7a028625ee3c8 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
@@ -83,10 +83,14 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
   /// extern_weak symbols.
   DenseMap AuthPtrStubs;
 
+  /// HasSignedPersonality is true if the corresponding IR module has the
+  /// "ptrauth-sign-personality" flag set to 1.
+  bool HasSignedPersonality = false;
+
   virtual void anchor(); // Out of line virtual method.
 
 public:
-  MachineModuleInfoELF(const MachineModuleInfo &) {}
+  MachineModuleInfoELF(const MachineModuleInfo &);
 
   StubValueTy &getGVStubEntry(MCSymbol *Sym) {
 assert(Sym && "Key cannot be null");
@@ -105,6 +109,8 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
   ExprStubListTy getAuthGVStubList() {
 return getSortedExprStubs(AuthPtrStubs);
   }
+
+  bool hasSignedPersonality() const { return HasSignedPersonality; }
 };
 
 /// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation
diff --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h 
b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index 8eef45ce565deb..a2a9e5d499e527 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -52,7 +52,13 @@ class TargetLoweringObjectFileELF : public 
TargetLoweringObjectFile {
   void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
 
   void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL,
-const MCSymbol *Sym) const override;
+const MCSymbol *Sym,
+const MachineModuleInfo *MMI) const override;
+
+  virtual void emitPersonalityValueImpl(MCStreame

[clang] [llvm] [NFC] [RISCV] Refactor class RISCVExtension (PR #120040)

2024-12-15 Thread Pengcheng Wang via cfe-commits


@@ -22,11 +22,20 @@
 // uses the record name by replacing Feature with Has.
 // value - Value to assign to the field in RISCVSubtarget when this
 // extension is enabled. Usually "true", but can be changed.
-class RISCVExtension implies = [],
  string fieldname = !subst("Feature", "Has", NAME),
- string value = "true">
-: SubtargetFeature {
+ string value = "true", bit IsExperimental = false>
+: SubtargetFeature<
+!if(IsExperimental, "experimental-", "")

wangpc-pp wrote:

And, we have some naming conventions for extension features after this change, 
so please document above that the name must start with `FeatureStdExt` for 
standard extensions and `FeatureVendor` for vendor extensions.

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


[clang] f65a21a - [PAC][ELF][AArch64] Support signed personality function pointer (#119361)

2024-12-15 Thread via cfe-commits

Author: Daniil Kovalev
Date: 2024-12-16T10:24:09+03:00
New Revision: f65a21a4ecc2e712c700c59842b6b9a1d2a9a060

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

LOG: [PAC][ELF][AArch64] Support signed personality function pointer (#119361)

Re-apply #113148 after revert in #119331

If function pointer signing is enabled, sign personality function
pointer stored in `.DW.ref.__gxx_personality_v0` section with IA key,
0x7EAD = `ptrauth_string_discriminator("personality")` constant
discriminator and address diversity enabled.

Added: 
llvm/test/CodeGen/AArch64/ptrauth-sign-personality.ll

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/ptrauth-module-flags.c
llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
llvm/include/llvm/Target/TargetLoweringObjectFile.h
llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
llvm/lib/CodeGen/MachineModuleInfoImpls.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp
llvm/lib/Target/AArch64/AArch64TargetObjectFile.h
llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
llvm/lib/Target/TargetLoweringObjectFile.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d3d5c0743a520b..841fb1ced9a02b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1218,6 +1218,9 @@ void CodeGenModule::Release() {
   getModule().addModuleFlag(llvm::Module::Min, "ptrauth-elf-got", 1);
 
 if (getTriple().isOSLinux()) {
+  if (LangOpts.PointerAuthCalls)
+getModule().addModuleFlag(llvm::Module::Min, 
"ptrauth-sign-personality",
+  1);
   assert(getTriple().isOSBinFormatELF());
   using namespace llvm::ELF;
   uint64_t PAuthABIVersion =

diff  --git a/clang/test/CodeGen/ptrauth-module-flags.c 
b/clang/test/CodeGen/ptrauth-module-flags.c
index 5a7e9a7c2a36fe..e441d52cb7c62b 100644
--- a/clang/test/CodeGen/ptrauth-module-flags.c
+++ b/clang/test/CodeGen/ptrauth-module-flags.c
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -triple aarch64-linux-gnu   -emit-llvm %s  
-o - | FileCheck %s --check-prefix=OFF
 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-elf-got -emit-llvm %s  
-o - | FileCheck %s --check-prefix=ELFGOT
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls   -emit-llvm %s  
-o - | FileCheck %s --check-prefix=PERSONALITY
 
 // ELFGOT:  !llvm.module.flags = !{
 // ELFGOT-SAME: !1
 // ELFGOT:  !1 = !{i32 8, !"ptrauth-elf-got", i32 1}
 
+// PERSONALITY:  !llvm.module.flags = !{
+// PERSONALITY-SAME: !1
+// PERSONALITY:  !1 = !{i32 8, !"ptrauth-sign-personality", i32 1}
+
 // OFF-NOT: "ptrauth-

diff  --git a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h 
b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
index c1ae3d2d966df5..f7a028625ee3c8 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
@@ -83,10 +83,14 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
   /// extern_weak symbols.
   DenseMap AuthPtrStubs;
 
+  /// HasSignedPersonality is true if the corresponding IR module has the
+  /// "ptrauth-sign-personality" flag set to 1.
+  bool HasSignedPersonality = false;
+
   virtual void anchor(); // Out of line virtual method.
 
 public:
-  MachineModuleInfoELF(const MachineModuleInfo &) {}
+  MachineModuleInfoELF(const MachineModuleInfo &);
 
   StubValueTy &getGVStubEntry(MCSymbol *Sym) {
 assert(Sym && "Key cannot be null");
@@ -105,6 +109,8 @@ class MachineModuleInfoELF : public MachineModuleInfoImpl {
   ExprStubListTy getAuthGVStubList() {
 return getSortedExprStubs(AuthPtrStubs);
   }
+
+  bool hasSignedPersonality() const { return HasSignedPersonality; }
 };
 
 /// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation

diff  --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h 
b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
index 8eef45ce565deb..a2a9e5d499e527 100644
--- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -52,7 +52,13 @@ class TargetLoweringObjectFileELF : public 
TargetLoweringObjectFile {
   void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
 
   void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL,
-const MCSymbol *Sym) const override;
+const MCSymbol *Sym,
+const MachineM

[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Daniil Kovalev via cfe-commits

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


[clang] [llvm] [NFC] [RISCV] Refactor class RISCVExtension (PR #120040)

2024-12-15 Thread Shao-Ce SUN via cfe-commits


@@ -22,11 +22,20 @@
 // uses the record name by replacing Feature with Has.
 // value - Value to assign to the field in RISCVSubtarget when this
 // extension is enabled. Usually "true", but can be changed.
-class RISCVExtension implies = [],
  string fieldname = !subst("Feature", "Has", NAME),
- string value = "true">
-: SubtargetFeature {
+ string value = "true", bit IsExperimental = false>
+: SubtargetFeature<
+!if(IsExperimental, "experimental-", "")

sunshaoce wrote:

Nice!

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


[libunwind] eb1f9cc - [libunwind] Fix compilation for the x32 ABI. (#116608)

2024-12-15 Thread via cfe-commits

Author: Alex Rønne Petersen
Date: 2024-12-15T05:57:51-05:00
New Revision: eb1f9cced9e878362aeac18e120895995f759ee3

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

LOG: [libunwind] Fix compilation for the x32 ABI. (#116608)

This would previously fail the static assertions in `UnwindCursor.hpp`
due to `UnwindCursor`'s size not matching `unw_cursor_t`'s size. As is
done for MIPS N32, this just declares the appropriate size in
`__libunwind_config.h`.

Added: 


Modified: 
libunwind/include/__libunwind_config.h

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 028b9e3baa8065..bb7fe4c83a3c17 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -53,6 +53,9 @@
 #else
 #  define _LIBUNWIND_CURSOR_SIZE 66
 #endif
+#  elif defined(__ILP32__)
+#define _LIBUNWIND_CONTEXT_SIZE 21
+#define _LIBUNWIND_CURSOR_SIZE 28
 #  else
 #define _LIBUNWIND_CONTEXT_SIZE 21
 #define _LIBUNWIND_CURSOR_SIZE 33



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


[libunwind] [libunwind] Fix compilation for the x32 ABI. (PR #116608)

2024-12-15 Thread Brad Smith via cfe-commits

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


[clang-tools-extra] [clangd] Re-land "support outgoing calls in call hierarchy" (PR #117673)

2024-12-15 Thread via cfe-commits

pidgeon777 wrote:

> > I would appreciate confirmation that this will indeed be possible with the 
> > upcoming **clangd** changes.
> 
> Yes, the returned data is sufficient for clients to implement either of the 
> above presentations.

This is great news, thank you!

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


[clang-tools-extra] e1271dd - [clangd] Index reserved symbols from `*intrin.h` system headers (#119735)

2024-12-15 Thread via cfe-commits

Author: Joseph Huber
Date: 2024-12-15T08:04:47-06:00
New Revision: e1271dd5a7ecf5cee59c8e2684b93501a1aab82d

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

LOG: [clangd] Index reserved symbols from `*intrin.h` system headers (#119735)

Summary:
`clangd` intentionally suppresses indexing symbols from system headers
as these are likely implementation details the user does not want.
Howver, there are plenty of system headers that provide extensions that
we want to index, such as vector intrinsic headers. This patch adds an
extra check for these commonly-named '*intrin.h' headers. This is not
fully inclusive for all symbols the user might want, but it's a good
start.

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

-

Co-authored-by: Nathan Ridge 

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 81125dbb1aeafc..6d0af20e31260c 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -550,9 +550,14 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl 
&ND,
   // Avoid indexing internal symbols in protobuf generated headers.
   if (isPrivateProtoDecl(ND))
 return false;
+
+  // System headers that end with `intrin.h` likely contain useful symbols.
   if (!Opts.CollectReserved &&
   (hasReservedName(ND) || hasReservedScope(*ND.getDeclContext())) &&
-  ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()))
+  ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()) &&
+  !ASTCtx.getSourceManager()
+   .getFilename(ND.getLocation())
+   .ends_with("intrin.h"))
 return false;
 
   return true;

diff  --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index e8088cb37fa51c..7a9703c744e93f 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -2111,6 +2111,20 @@ TEST_F(SymbolCollectorTest, Reserved) {
   EXPECT_THAT(Symbols, IsEmpty());
 }
 
+TEST_F(SymbolCollectorTest, ReservedSymbolInIntrinsicHeader) {
+  const char *Header = R"cpp(
+#pragma once
+void __foo();
+  )cpp";
+
+  TestHeaderName = "xintrin.h";
+  TestHeaderURI = URI::create(testPath(TestHeaderName)).toString();
+  InMemoryFileSystem = new llvm::vfs::InMemoryFileSystem;
+  CollectorOpts.FallbackDir = testRoot();
+  runSymbolCollector("#pragma GCC system_header\n" + std::string(Header), "");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(qName("__foo")));
+}
+
 TEST_F(SymbolCollectorTest, Concepts) {
   const char *Header = R"cpp(
 template 



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


[clang-tools-extra] [clangd] Index reserved symbols from `*intrin.h` system headers (PR #119735)

2024-12-15 Thread Joseph Huber via cfe-commits

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


[clang] [compiler-rt] [flang] [libc] [llvm] [polly] [cmake] Drop `AddFileDependencies` and `CMakeParseArguments` (PR #120002)

2024-12-15 Thread via cfe-commits

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

LGTM for the libc changes.

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


[clang-tools-extra] [clangd] Do not show `aParam` parameter hint for argument spelled `param` (PR #119162)

2024-12-15 Thread via cfe-commits


@@ -867,13 +867,28 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 }
   }
 
+  static bool argumentMatchesParamName(StringRef ArgName, StringRef ParamName) 
{
+// Exact match.
+if (ParamName == ArgName)
+  return true;
+
+// Parameter name uses "a" prefix (e.g. "aParam").
+if (ParamName.size() > 1 && ParamName[0] == 'a' &&

JVApen wrote:

I might be complicating things, though shouldn't this also cover `anApple`

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


[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)

2024-12-15 Thread via cfe-commits

https://github.com/AdUhTkJm updated 
https://github.com/llvm/llvm-project/pull/119098

>From 56670608becf2032867405778fa7b2b1a36fb3cf Mon Sep 17 00:00:00 2001
From: AdUhTkJm <2292398...@qq.com>
Date: Sun, 8 Dec 2024 08:07:59 +0800
Subject: [PATCH] [Clang] Fix crash for incompatible types in inline assembly

---
 clang/lib/Sema/SemaStmtAsm.cpp |  7 ++-
 clang/test/Sema/asm.c  | 21 +
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index 0b272b806391c4..a0b203fbdfec21 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -664,11 +664,16 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, 
bool IsSimple,
   SmallerValueMentioned |= OutSize < InSize;
 }
 
+// If the input is an integer register while the output is floating point,
+// or vice-versa, there is no way they can work together.
+bool FPTiedToInt = (InputDomain == AD_FP) ^ (OutputDomain == AD_FP);
+
 // If the smaller value wasn't mentioned in the asm string, and if the
 // output was a register, just extend the shorter one to the size of the
 // larger one.
-if (!SmallerValueMentioned && InputDomain != AD_Other &&
+if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other &&
 OutputConstraintInfos[TiedTo].allowsRegister()) {
+
   // FIXME: GCC supports the OutSize to be 128 at maximum. Currently 
codegen
   // crash when the size larger than the register size. So we limit it 
here.
   if (OutTy->isStructureType() &&
diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c
index a9cff5947ef5d0..a666b45b3150ca 100644
--- a/clang/test/Sema/asm.c
+++ b/clang/test/Sema/asm.c
@@ -365,3 +365,24 @@ void test19(long long x)
   // FIXME: This case should be supported by codegen, but it fails now.
   asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: 
input with type 'st_size128' (aka 'struct _st_size128') matching output with 
type 'long long'}}
 }
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+
+// GH118892
+void test20(char x) {
+  double d;
+  float f;
+
+  asm ("fabs" : "=t" (d): "0" (x)); // expected-error {{unsupported inline 
asm: input with type 'char' matching output with type 'double'}}
+  asm ("fabs" : "=t" (x): "0" (d)); // expected-error {{unsupported inline 
asm: input with type 'double' matching output with type 'char'}}
+  asm ("fabs" : "=t" (f): "0" (d)); // no-error
+  asm ("fabs" : "=t" (d): "0" (f)); // no-error
+
+  st_size64 a;
+  asm ("fabs" : "=t" (d): "0" (a)); // expected-error {{unsupported inline 
asm: input with type 'st_size64' (aka 'struct _st_size64') matching output with 
type 'double'}}
+  asm ("fabs" : "=t" (a): "0" (d)); // expected-error {{unsupported inline 
asm: input with type 'double' matching output with type 'st_size64' (aka 
'struct _st_size64')}}
+
+  int2 v;
+  asm ("fabs" : "=t" (d): "0" (v)); // expected-error {{unsupported inline 
asm: input with type 'int2' (vector of 2 'int' values) matching output with 
type 'double'}}
+  asm ("fabs" : "=t" (v): "0" (d)); // expected-error {{unsupported inline 
asm: input with type 'double' matching output with type 'int2' (vector of 2 
'int' values)}}
+}

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


[clang] [Tooling/Inclusion] Update std symbol mapping (PR #118174)

2024-12-15 Thread Vadim D. via cfe-commits

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


[clang] [libc] [Clang] Rename GPU intrinsic functions from `__gpu_` to `_gpu_` (PR #118674)

2024-12-15 Thread Joseph Huber via cfe-commits

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


[clang] [Tooling/Inclusion] Update std symbol mapping (PR #118174)

2024-12-15 Thread Vadim D. via cfe-commits

vvd170501 wrote:

@kadircet, could you review this PR or assign someone else?

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/120004

follow up patch for #119948.


>From b3b848df1a985754580ebbaa5f8136cb2c6bf3d6 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Sun, 15 Dec 2024 12:19:55 +0800
Subject: [PATCH] [clang-tidy][NFC] use local config in test cases

follow up patch for #119948.
---
 .../clang-tidy/misc/IncludeCleanerCheck.cpp|  7 +++
 .../InconsistentDeclarationParameterNameCheck.h|  2 +-
 clang-tools-extra/docs/ReleaseNotes.rst|  4 
 .../checkers/bugprone/argument-comment-strict.cpp  |  2 +-
 .../cppcoreguidelines/pro-type-const-cast.cpp  |  2 +-
 .../pro-type-static-cast-downcast.cpp  |  2 +-
 .../checkers/misc/unused-parameters-strict.cpp |  2 +-
 .../checkers/modernize/use-std-format.cpp  |  4 ++--
 .../checkers/modernize/use-std-print-absl.cpp  |  4 ++--
 .../checkers/modernize/use-std-print.cpp   |  4 ++--
 .../unittests/clang-tidy/IncludeCleanerTest.cpp| 14 --
 11 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 5e7a0e65690b7a..7638bbc103d16d 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -57,10 +57,9 @@ struct MissingIncludeInfo {
 IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreHeaders(utils::options::parseStringList(
-  Options.getLocalOrGlobal("IgnoreHeaders", ""))),
-  DeduplicateFindings(
-  Options.getLocalOrGlobal("DeduplicateFindings", true)) {
+  IgnoreHeaders(
+  utils::options::parseStringList(Options.get("IgnoreHeaders", ""))),
+  DeduplicateFindings(Options.get("DeduplicateFindings", true)) {
   for (const auto &Header : IgnoreHeaders) {
 if (!llvm::Regex{Header}.isValid())
   configurationDiag("Invalid ignore headers regex '%0'") << Header;
diff --git 
a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
 
b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
index 1c526577b403f6..0c5ead860c161a 100644
--- 
a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
+++ 
b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
@@ -26,7 +26,7 @@ class InconsistentDeclarationParameterNameCheck : public 
ClangTidyCheck {
 ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
-Strict(Options.getLocalOrGlobal("Strict", false)) {}
+Strict(Options.get("Strict", false)) {}
 
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6803842106791b..9e588913675039 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -115,6 +115,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Removed :program:`clang-tidy`'s global options for most of checks. All 
options
+  are changed to local options except `IncludeStyle`, `StrictMode` and
+  `IgnoreMacros`.
+
 New checks
 ^^
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
index c25d25ac5738fb..38d91f39846478 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
-// RUN:   -config="{CheckOptions: {StrictMode: true}}" --
+// RUN:   -config="{CheckOptions: {bugprone-argument-comment.StrictMode: 
true}}" --
 
 void f(int _with_underscores_);
 void g(int x_);
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
index be70e3ba356991..a775334260e35c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -check-suffix=STRICT  %s 
cppcoreguidelines-pro-type-const-cast %t -- -config="{CheckOptions: 
{StrictMode: true}}"
+// RUN: %check_clang_tidy -check-suf

[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread via cfe-commits

llvmbot wrote:




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

Author: Congcong Cai (HerrCai0907)


Changes

follow up patch for #119948.


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


11 Files Affected:

- (modified) clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp (+3-4) 
- (modified) 
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
 (+1-1) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-static-cast-downcast.cpp
 (+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters-strict.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp (+2-2) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-absl.cpp 
(+2-2) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp (+2-2) 
- (modified) clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp 
(+8-6) 


``diff
diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 5e7a0e65690b7a..7638bbc103d16d 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -57,10 +57,9 @@ struct MissingIncludeInfo {
 IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreHeaders(utils::options::parseStringList(
-  Options.getLocalOrGlobal("IgnoreHeaders", ""))),
-  DeduplicateFindings(
-  Options.getLocalOrGlobal("DeduplicateFindings", true)) {
+  IgnoreHeaders(
+  utils::options::parseStringList(Options.get("IgnoreHeaders", ""))),
+  DeduplicateFindings(Options.get("DeduplicateFindings", true)) {
   for (const auto &Header : IgnoreHeaders) {
 if (!llvm::Regex{Header}.isValid())
   configurationDiag("Invalid ignore headers regex '%0'") << Header;
diff --git 
a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
 
b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
index 1c526577b403f6..0c5ead860c161a 100644
--- 
a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
+++ 
b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
@@ -26,7 +26,7 @@ class InconsistentDeclarationParameterNameCheck : public 
ClangTidyCheck {
 ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
-Strict(Options.getLocalOrGlobal("Strict", false)) {}
+Strict(Options.get("Strict", false)) {}
 
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6803842106791b..9e588913675039 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -115,6 +115,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Removed :program:`clang-tidy`'s global options for most of checks. All 
options
+  are changed to local options except `IncludeStyle`, `StrictMode` and
+  `IgnoreMacros`.
+
 New checks
 ^^
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
index c25d25ac5738fb..38d91f39846478 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/argument-comment-strict.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s bugprone-argument-comment %t -- \
-// RUN:   -config="{CheckOptions: {StrictMode: true}}" --
+// RUN:   -config="{CheckOptions: {bugprone-argument-comment.StrictMode: 
true}}" --
 
 void f(int _with_underscores_);
 void g(int x_);
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
index be70e3ba356991..a775334260e35c 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-const-cast.c

[clang] [libc] [Clang] Rename GPU intrinsic functions from `__gpu_` to `_gpu_` (PR #118674)

2024-12-15 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

Unnecessary after updating clangd.

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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread via cfe-commits

EugeneZelenko wrote:

Please mention changes in Release Notes.

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


[clang] [llvm] [RISC-V] Add support for MIPS P8700 CPU (PR #117865)

2024-12-15 Thread Oren Benita Ben Simhon via cfe-commits


@@ -78,6 +78,19 @@ def GENERIC_RV64 : RISCVProcessorModel<"generic-rv64",
 // to change to the appropriate rv32/rv64 version.
 def GENERIC : RISCVTuneProcessorModel<"generic", NoSchedModel>, 
GenericTuneInfo;
 
+def MIPS_P8700 : RISCVProcessorModel<"mips-p8700",
+ MIPSP8700Model,
+ [Feature64Bit,
+  FeatureStdExtI,
+  FeatureStdExtM,
+  FeatureStdExtA,

OrenBenSimhon wrote:

performance wise, will it be better to not select AMO instructions from the 
first place?

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FVDOT, FVDOTB and FVDOTT intrinsics (PR #119922)

2024-12-15 Thread via cfe-commits


@@ -0,0 +1,54 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --filter-out "// kill:" --version 4
+; RUN: llc -force-streaming < %s | FileCheck %s
+target triple = "aarch64-linux"
+
+define void @test_fvdot16_1x2_indexed(i32 %slice.0,
+; CHECK-LABEL: test_fvdot16_1x2_indexed:
+; CHECK:  // %bb.0:
+; CHECK:mov w8, w0
+; CHECK:fvdot za.h[w8, 7, vgx2], { z0.b, z1.b }, z2.b[3]
+; CHECK:ret
+  %zn1,  %zn2,
+  %zm) #0 {
+  %slice = add i32 %slice.0, 7
+  call void @llvm.aarch64.sme.fp8.fvdot.lane.za16.vg1x2(i32 %slice,
+
%zn1,  %zn2,
+%zm, 
i32 3)
+  ret void
+}
+
+define void @test_fvdot32_bottom_1x4_indexed(i32 %slice.0,
+; CHECK-LABEL: test_fvdot32_bottom_1x4_indexed:
+; CHECK:  // %bb.0:
+; CHECK:mov w8, w0
+; CHECK:fvdotb za.s[w8, 7, vgx4], { z0.b, z1.b }, z2.b[3]
+; CHECK:ret
+  %zn1,  %zn2,
+  %zm) #0 {
+  %slice = add i32 %slice.0, 7
+  call void @llvm.aarch64.sme.fp8.fvdotb.lane.za32.vg1x4(i32 %slice,
+  
%zn1,  %zn2,
+  
%zm, i32 3)
+  ret void
+}
+
+define void @test_fvdot32_top_1x4_indexed(i32 %slice.0,
+; CHECK-LABEL: test_fvdot32_top_1x4_indexed:
+; CHECK:  // %bb.0:
+; CHECK:mov w8, w0
+; CHECK:fvdott za.s[w8, 7, vgx4], { z0.b, z1.b }, z2.b[3]
+; CHECK:ret
+   %zn1,  %zn2,
+   %zm) #0 {
+  %slice = add i32 %slice.0, 7
+  call void @llvm.aarch64.sme.fp8.fvdott.lane.za32.vg1x4(i32 %slice,
+  
%zn1,  %zn2,
+  
%zm, i32 3)
+  ret void
+}
+
+declare void @llvm.aarch64.sme.fp8.fvdot.lane.za16.vg1x2(i32, , , , i32)
+declare void @llvm.aarch64.sme.fp8.fvdotb.lane.za32.vg1x4(i32, , , , i32)
+declare void @llvm.aarch64.sme.fp8.fvdott.lane.za32.vg1x4(i32, , , , i32)
+
+attributes #0 = { "target-features" = "+sme-f8f32,+sme-f8f16" }

SpencerAbson wrote:

nits: These declarations are not needed, and (no strong opinion) it may be 
clearer to pass the target features directly to `llc` rather than via an 
attribute tag.

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FVDOT, FVDOTB and FVDOTT intrinsics (PR #119922)

2024-12-15 Thread via cfe-commits


@@ -5882,3 +5882,14 @@ multiclass sme2_fp8_fdot_index_za32_vg1x4;
 }
+
+multiclass sme2_fp8_fdotv_index_za32_vg1x4 {
+  def NAME : sme2_fp8_multi_vec_array_vg4_index,
+SMEPseudo2Instr {
+let Uses=[FPMR, FPCR];

SpencerAbson wrote:

Looks like the body of `sme2_fp8_multi_vec_array_vg4_index` already declares 
`let Uses=[FPMR, FPCR];`, so we can remove this here.

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FVDOT, FVDOTB and FVDOTT intrinsics (PR #119922)

2024-12-15 Thread via cfe-commits


@@ -748,11 +748,16 @@ let SMETargetGuard = "sme2" in {
 let SMETargetGuard = "sme-f8f32" in {
   def SVDOT_LANE_FP8_ZA32_VG1x2 : Inst<"svdot_lane_za32[_mf8]_vg1x2_fpm", 
"vm2di>", "m", MergeNone, "aarch64_sme_fp8_fdot_lane_za32_vg1x2", [IsStreaming, 
IsInOutZA, SetsFPMR, IsOverloadNone], [ImmCheck<3, ImmCheck0_3>]>;
   def SVDOT_LANE_FP8_ZA32_VG1x4 : Inst<"svdot_lane_za32[_mf8]_vg1x4_fpm", 
"vm4di>", "m", MergeNone, "aarch64_sme_fp8_fdot_lane_za32_vg1x4", [IsStreaming, 
IsInOutZA, SetsFPMR, IsOverloadNone], [ImmCheck<3, ImmCheck0_3>]>;
+
+  def SVVDOTB_LANE_FP8_ZA32_VG1x4 : Inst<"svvdotb_lane_za32[_f8]_vg1x4", 
"vm2di>", "m", MergeNone, "aarch64_sme_fp8_fvdotb_lane_za32_vg1x4", 
[IsOverloadNone, IsStreaming, IsInOutZA, SetsFPMR], [ImmCheck<3, ImmCheck0_3>]>;

SpencerAbson wrote:

https://github.com/ARM-software/acle/pull/323/ - The optional field in these 
intrinsics should be `_mf8` rather than `_f8`, and they would end with `_fpm`.

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FVDOT, FVDOTB and FVDOTT intrinsics (PR #119922)

2024-12-15 Thread via cfe-commits


@@ -5882,3 +5882,14 @@ multiclass sme2_fp8_fdot_index_za32_vg1x4;
 }
+
+multiclass sme2_fp8_fdotv_index_za32_vg1x4 {
+  def NAME : sme2_fp8_multi_vec_array_vg4_index,
+SMEPseudo2Instr {
+let Uses=[FPMR, FPCR];
+  }
+
+  def _PSEUDO : sme2_za_array_2op_multi_index_pseudo;
+
+  def : SME2_ZA_TwoOp_VG2_Multi_Index_Pat;

SpencerAbson wrote:

I think the appropriate `imm_ty` argument to this pattern 
is`VectorInedxS32b_timm`.

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


[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)

2024-12-15 Thread via cfe-commits


@@ -664,11 +664,22 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, 
bool IsSimple,
   SmallerValueMentioned |= OutSize < InSize;
 }
 
+// If the input is an integer register while the output is floating point,
+// there is no way they can work together.
+bool FPBoundToInt = false;
+if (InputDomain != AD_FP && OutputDomain == AD_FP) {
+  FPBoundToInt = true;
+}
+if (InputDomain == AD_FP && OutputDomain != AD_FP) {
+  FPBoundToInt = true;
+}

AdUhTkJm wrote:

Done.

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


[clang] [Clang] Fix crash for incompatible types in inline assembly (PR #119098)

2024-12-15 Thread via cfe-commits


@@ -365,3 +365,9 @@ void test19(long long x)
   // FIXME: This case should be supported by codegen, but it fails now.
   asm ("" : "=rm" (x): "0" (e)); // expected-error {{unsupported inline asm: 
input with type 'st_size128' (aka 'struct _st_size128') matching output with 
type 'long long'}}
 }
+
+// GH118892
+void test20(char x) {
+  double value;
+  asm ("fabs" : "=t" (value): "0" (x)); // expected-error {{unsupported inline 
asm: input with type 'char' matching output with type 'double'}}
+}

AdUhTkJm wrote:

Added.

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


[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #117904)

2024-12-15 Thread via cfe-commits


@@ -11774,6 +11774,9 @@ def err_omp_clause_requires_dispatch_construct : Error<
   "'%0' clause requires 'dispatch' context selector">;
 def err_omp_append_args_with_varargs : Error<
   "'append_args' is not allowed with varargs functions">;
+def warn_omp_dispatch_clause_novariants_nocontext : Warning<
+  "only 'novariants' clause is supported when 'novariants' & 'nocontext' 
clauses occur on the same dispatch construct">,

SunilKuravinakop wrote:

In case of 
   `#pragma omp dispatch nocontext(c1) novariants(c2) depend(inout:x)`
the alternative warning message that you have suggested may not be proper 
because it indicates `depend` is also not expected.

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


[clang] [compiler-rt] [flang] [libc] [llvm] [polly] [cmake] Drop `AddFileDependencies` and `CMakeParseArguments` (PR #120002)

2024-12-15 Thread via cfe-commits

https://github.com/paperchalice created 
https://github.com/llvm/llvm-project/pull/120002

Theses modules are deprecated and have trivial implementations in modern cmake.

>From 7d7d410e4893de02f69309c5e95f58c949df643a Mon Sep 17 00:00:00 2001
From: PaperChalice 
Date: Sat, 14 Dec 2024 15:50:00 +0800
Subject: [PATCH 1/2] [cmake] Drop `AddFileDependencies` and
 `CMakeParseArguments`

Theses modules are deprecated and have trivial implementations in modern cmake.
---
 llvm/cmake/modules/LLVMProcessSources.cmake | 3 ---
 llvm/tools/llvm-config/CMakeLists.txt   | 4 +++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/llvm/cmake/modules/LLVMProcessSources.cmake 
b/llvm/cmake/modules/LLVMProcessSources.cmake
index 205089bd2704cb..0670d60bf2afd7 100644
--- a/llvm/cmake/modules/LLVMProcessSources.cmake
+++ b/llvm/cmake/modules/LLVMProcessSources.cmake
@@ -1,6 +1,3 @@
-include(AddFileDependencies)
-include(CMakeParseArguments)
-
 function(llvm_replace_compiler_option var old new)
   # Replaces a compiler option or switch `old' in `var' by `new'.
   # If `old' is not in `var', appends `new' to `var'.
diff --git a/llvm/tools/llvm-config/CMakeLists.txt 
b/llvm/tools/llvm-config/CMakeLists.txt
index e02bda1ead50c0..02c2532dba77a7 100644
--- a/llvm/tools/llvm-config/CMakeLists.txt
+++ b/llvm/tools/llvm-config/CMakeLists.txt
@@ -89,7 +89,9 @@ if(LLVM_ENABLE_MODULES)
 endif()
 
 # Add the dependency on the generation step.
-add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp 
${BUILDVARIABLES_OBJPATH})
+set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp
+  APPEND PROPERTY OBJECT_DEPENDS ${BUILDVARIABLES_OBJPATH}
+)
 
 if(CMAKE_CROSSCOMPILING)
   if (LLVM_NATIVE_TOOL_DIR AND NOT LLVM_CONFIG_PATH)

>From d8143aadc14c6bcaaf014093499918ee25ddcf6f Mon Sep 17 00:00:00 2001
From: paperchalice 
Date: Sun, 15 Dec 2024 20:13:00 +0800
Subject: [PATCH 2/2] [cmake] Update for other projects

---
 clang/CMakeLists.txt  | 1 -
 compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake| 1 -
 compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake | 1 -
 flang/CMakeLists.txt  | 2 --
 libc/CMakeLists.txt   | 1 -
 polly/cmake/polly_macros.cmake| 3 ---
 6 files changed, 9 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 27e8095534a65c..b79e570667b2c4 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -362,7 +362,6 @@ if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
   message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
-include(CMakeParseArguments)
 include(AddClang)
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake 
b/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
index d8a491dbbd732a..53aa750d934d72 100644
--- a/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
@@ -1,4 +1,3 @@
-include(CMakeParseArguments)
 include(CompilerRTUtils)
 
 function(get_aix_libatomic_default_link_flags link_flags export_list)
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake 
b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 74a5d4edcd859f..fa8c6be6c5d462 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -1,4 +1,3 @@
-include(CMakeParseArguments)
 include(CompilerRTUtils)
 include(BuiltinTests)
 
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 971e5d5c93f231..e1e40bd70390a6 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -117,7 +117,6 @@ if (FLANG_STANDALONE_BUILD)
 set(USE_NO_MAYBE_UNINITIALIZED 1)
   endif()
 
-  include(CMakeParseArguments)
   include(AddLLVM)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
@@ -445,7 +444,6 @@ if (APPLE)
   endif()
 endif()
 
-include(CMakeParseArguments)
 include(AddFlang)
 
 if (FLANG_INCLUDE_TESTS)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 88cc75e83b043d..00a07ea3c8ac75 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -329,7 +329,6 @@ endif()
 
 option(LIBC_INCLUDE_DOCS "Build the libc documentation." ${LLVM_INCLUDE_DOCS})
 
-include(CMakeParseArguments)
 include(LLVMLibCCheckCpuFeatures)
 include(CheckCompilerFeatures)
 include(LLVMLibCRules)
diff --git a/polly/cmake/polly_macros.cmake b/polly/cmake/polly_macros.cmake
index a791be4fa5bc87..ddd6376273376a 100644
--- a/polly/cmake/polly_macros.cmake
+++ b/polly/cmake/polly_macros.cmake
@@ -1,6 +1,3 @@
-
-include(CMakeParseArguments)
-
 macro(add_polly_library name)
   cmake_parse_arguments(ARG "" "" "" ${ARGN})
   set(srcs ${ARG_UNPARSED_ARGUMENTS})

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


[clang] [compiler-rt] [flang] [libc] [llvm] [polly] [cmake] Drop `AddFileDependencies` and `CMakeParseArguments` (PR #120002)

2024-12-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (paperchalice)


Changes

Theses modules are deprecated and have trivial implementations in modern cmake.

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


8 Files Affected:

- (modified) clang/CMakeLists.txt (-1) 
- (modified) compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake (-1) 
- (modified) compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake (-1) 
- (modified) flang/CMakeLists.txt (-2) 
- (modified) libc/CMakeLists.txt (-1) 
- (modified) llvm/cmake/modules/LLVMProcessSources.cmake (-3) 
- (modified) llvm/tools/llvm-config/CMakeLists.txt (+3-1) 
- (modified) polly/cmake/polly_macros.cmake (-3) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 27e8095534a65c..b79e570667b2c4 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -362,7 +362,6 @@ if (APPLE AND NOT CMAKE_LINKER MATCHES ".*lld.*")
   message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
-include(CMakeParseArguments)
 include(AddClang)
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
diff --git a/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake 
b/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
index d8a491dbbd732a..53aa750d934d72 100644
--- a/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
@@ -1,4 +1,3 @@
-include(CMakeParseArguments)
 include(CompilerRTUtils)
 
 function(get_aix_libatomic_default_link_flags link_flags export_list)
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake 
b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 74a5d4edcd859f..fa8c6be6c5d462 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -1,4 +1,3 @@
-include(CMakeParseArguments)
 include(CompilerRTUtils)
 include(BuiltinTests)
 
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 971e5d5c93f231..e1e40bd70390a6 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -117,7 +117,6 @@ if (FLANG_STANDALONE_BUILD)
 set(USE_NO_MAYBE_UNINITIALIZED 1)
   endif()
 
-  include(CMakeParseArguments)
   include(AddLLVM)
   include(HandleLLVMOptions)
   include(VersionFromVCS)
@@ -445,7 +444,6 @@ if (APPLE)
   endif()
 endif()
 
-include(CMakeParseArguments)
 include(AddFlang)
 
 if (FLANG_INCLUDE_TESTS)
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 88cc75e83b043d..00a07ea3c8ac75 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -329,7 +329,6 @@ endif()
 
 option(LIBC_INCLUDE_DOCS "Build the libc documentation." ${LLVM_INCLUDE_DOCS})
 
-include(CMakeParseArguments)
 include(LLVMLibCCheckCpuFeatures)
 include(CheckCompilerFeatures)
 include(LLVMLibCRules)
diff --git a/llvm/cmake/modules/LLVMProcessSources.cmake 
b/llvm/cmake/modules/LLVMProcessSources.cmake
index 205089bd2704cb..0670d60bf2afd7 100644
--- a/llvm/cmake/modules/LLVMProcessSources.cmake
+++ b/llvm/cmake/modules/LLVMProcessSources.cmake
@@ -1,6 +1,3 @@
-include(AddFileDependencies)
-include(CMakeParseArguments)
-
 function(llvm_replace_compiler_option var old new)
   # Replaces a compiler option or switch `old' in `var' by `new'.
   # If `old' is not in `var', appends `new' to `var'.
diff --git a/llvm/tools/llvm-config/CMakeLists.txt 
b/llvm/tools/llvm-config/CMakeLists.txt
index e02bda1ead50c0..02c2532dba77a7 100644
--- a/llvm/tools/llvm-config/CMakeLists.txt
+++ b/llvm/tools/llvm-config/CMakeLists.txt
@@ -89,7 +89,9 @@ if(LLVM_ENABLE_MODULES)
 endif()
 
 # Add the dependency on the generation step.
-add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp 
${BUILDVARIABLES_OBJPATH})
+set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp
+  APPEND PROPERTY OBJECT_DEPENDS ${BUILDVARIABLES_OBJPATH}
+)
 
 if(CMAKE_CROSSCOMPILING)
   if (LLVM_NATIVE_TOOL_DIR AND NOT LLVM_CONFIG_PATH)
diff --git a/polly/cmake/polly_macros.cmake b/polly/cmake/polly_macros.cmake
index a791be4fa5bc87..ddd6376273376a 100644
--- a/polly/cmake/polly_macros.cmake
+++ b/polly/cmake/polly_macros.cmake
@@ -1,6 +1,3 @@
-
-include(CMakeParseArguments)
-
 macro(add_polly_library name)
   cmake_parse_arguments(ARG "" "" "" ${ARGN})
   set(srcs ${ARG_UNPARSED_ARGUMENTS})

``




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


[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #117904)

2024-12-15 Thread via cfe-commits


@@ -5965,6 +5967,264 @@ static bool teamsLoopCanBeParallelFor(Stmt *AStmt, Sema 
&SemaRef) {
   return Checker.teamsLoopCanBeParallelFor();
 }
 
+static Expr *getInitialExprFromCapturedExpr(Expr *Cond) {
+
+  Expr *SubExpr = Cond->IgnoreParenImpCasts();
+
+  if (auto *DeclRef = dyn_cast(SubExpr)) {
+if (auto *CapturedExprDecl =
+dyn_cast(DeclRef->getDecl())) {
+
+  // Retrieve the initial expression from the captured expression
+  return CapturedExprDecl->getInit();
+}
+  }
+  return nullptr;
+}
+
+static Expr *replaceWithNewTraitsOrDirectCall(const ASTContext &Context, Expr 
*,
+  SemaOpenMP *, bool);
+
+/// cloneAssociatedStmt() function is for cloning the Associated Statement
+/// present with a Directive and then modifying it. By this we avoid modifying
+/// the original Associated Statement.
+static StmtResult cloneAssociatedStmt(const ASTContext &Context, Stmt *StmtP,
+  SemaOpenMP *SemaPtr, bool NoContext) {
+  StmtResult ResultAssocStmt;
+  if (auto *AssocStmt = dyn_cast(StmtP)) {
+CapturedDecl *CDecl = AssocStmt->getCapturedDecl();
+Stmt *AssocExprStmt = AssocStmt->getCapturedStmt();
+auto *AssocExpr = dyn_cast(AssocExprStmt);
+Expr *NewCallOrPseudoObjOrBinExpr = replaceWithNewTraitsOrDirectCall(
+Context, AssocExpr, SemaPtr, NoContext);
+
+// Copy Current Captured Decl to a New Captured Decl for noting the
+// Annotation
+CapturedDecl *NewDecl =
+CapturedDecl::Create(const_cast(Context),
+ CDecl->getDeclContext(), CDecl->getNumParams());
+NewDecl->setBody(static_cast(NewCallOrPseudoObjOrBinExpr));
+for (unsigned I : llvm::seq(CDecl->getNumParams())) {
+  if (I != CDecl->getContextParamPosition())
+NewDecl->setParam(I, CDecl->getParam(I));
+  else
+NewDecl->setContextParam(I, CDecl->getContextParam());
+}
+
+// Create a New Captured Stmt containing the New Captured Decl
+SmallVector Captures;
+SmallVector CaptureInits;
+for (const CapturedStmt::Capture &Capture : AssocStmt->captures())
+  Captures.push_back(Capture);
+for (Expr *CaptureInit : AssocStmt->capture_inits())
+  CaptureInits.push_back(CaptureInit);
+auto *NewStmt = CapturedStmt::Create(
+Context, AssocStmt->getCapturedStmt(),
+AssocStmt->getCapturedRegionKind(), Captures, CaptureInits, NewDecl,
+const_cast(AssocStmt->getCapturedRecordDecl()));
+
+ResultAssocStmt = NewStmt;
+  }
+  return ResultAssocStmt;
+}
+
+/// replaceWithNewTraitsOrDirectCall() is for transforming the call traits.
+/// Call traits associated with a function call are removed and replaced with
+/// a direct call. For clause "nocontext" only, the direct call is then
+/// modified to have call traits for a non-dispatch variant.
+static Expr *replaceWithNewTraitsOrDirectCall(const ASTContext &Context,
+  Expr *AssocExpr,
+  SemaOpenMP *SemaPtr,
+  bool NoContext) {
+  BinaryOperator *BinaryCopyOpr = nullptr;
+  bool IsBinaryOp = false;
+  Expr *PseudoObjExprOrCall = AssocExpr;
+  if (auto *BinOprExpr = dyn_cast(AssocExpr)) {
+IsBinaryOp = true;
+BinaryCopyOpr = BinaryOperator::Create(
+Context, BinOprExpr->getLHS(), BinOprExpr->getRHS(),
+BinOprExpr->getOpcode(), BinOprExpr->getType(),
+BinOprExpr->getValueKind(), BinOprExpr->getObjectKind(),
+BinOprExpr->getOperatorLoc(), FPOptionsOverride());
+PseudoObjExprOrCall = BinaryCopyOpr->getRHS();
+  }
+
+  Expr *CallWithoutInvariants = PseudoObjExprOrCall;
+  // Change PseudoObjectExpr to a direct call
+  if (auto *PseudoObjExpr = dyn_cast(PseudoObjExprOrCall))
+CallWithoutInvariants = *((PseudoObjExpr->semantics_begin()) - 1);
+
+  Expr *FinalCall = CallWithoutInvariants; // For noinvariants clause
+  if (NoContext) {
+// example to explain the changes done for "nocontext" clause:
+//
+// #pragma omp declare variant(foo_variant_dispatch)
+//  match(construct = {dispatch})
+// #pragma omp declare variant(foo_variant_allCond)
+// match(user = {condition(1)})
+// ...
+// #pragma omp dispatch nocontext(cond_true)
+// foo(i, j); // with traits: CodeGen call to
+// foo_variant_dispatch(i,j)
+// dispatch construct is changed to:
+// if (cond_true) {
+//foo(i,j) // with traits: CodeGen call to foo_variant_allCond(i,j)
+// } else {
+//   #pragma omp dispatch
+//   foo(i,j)  // with traits: CodeGen call to foo_variant_dispatch(i,j)
+// }
+
+// Convert StmtResult to a CallExpr before calling ActOnOpenMPCall()
+auto *CallExprWithinStmt = cast(CallWithoutInvariants);
+int NumArgs = CallExprWithinStmt->getNum

[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #117904)

2024-12-15 Thread via cfe-commits


@@ -11774,6 +11774,9 @@ def err_omp_clause_requires_dispatch_construct : Error<
   "'%0' clause requires 'dispatch' context selector">;
 def err_omp_append_args_with_varargs : Error<
   "'append_args' is not allowed with varargs functions">;
+def warn_omp_dispatch_clause_novariants_nocontext : Warning<
+  "only 'novariants' clause is supported when 'novariants' & 'nocontext' 
clauses occur on the same dispatch construct">,

SunilKuravinakop wrote:

I have added extra tests in clang/test/OpenMP/dispatch_messages.cpp.

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


[clang] e869103 - [webkit.UncountedLambdaCapturesChecker] Add a fallback for checking lambda captures (#119800)

2024-12-15 Thread via cfe-commits

Author: Ryosuke Niwa
Date: 2024-12-15T13:32:29-08:00
New Revision: e86910337f98e57f5b9253f7d80d5b916eb1d97e

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

LOG: [webkit.UncountedLambdaCapturesChecker] Add a fallback for checking lambda 
captures (#119800)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp

Removed: 




diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
index 599c2179db0f0e..ac5cf3d899d55a 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -40,6 +40,7 @@ class UncountedLambdaCapturesChecker
 struct LocalVisitor : DynamicRecursiveASTVisitor {
   const UncountedLambdaCapturesChecker *Checker;
   llvm::DenseSet DeclRefExprsToIgnore;
+  llvm::DenseSet LambdasToIgnore;
   QualType ClsType;
 
   explicit LocalVisitor(const UncountedLambdaCapturesChecker *Checker)
@@ -61,6 +62,24 @@ class UncountedLambdaCapturesChecker
 return result && *result;
   }
 
+  bool VisitLambdaExpr(LambdaExpr *L) override {
+if (LambdasToIgnore.contains(L))
+  return true;
+Checker->visitLambdaExpr(L, shouldCheckThis());
+return true;
+  }
+
+  bool VisitVarDecl(VarDecl *VD) override {
+auto *Init = VD->getInit();
+if (!Init)
+  return true;
+auto *L = dyn_cast_or_null(Init->IgnoreParenCasts());
+if (!L)
+  return true;
+LambdasToIgnore.insert(L); // Evaluate lambdas in VisitDeclRefExpr.
+return true;
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *DRE) override {
 if (DeclRefExprsToIgnore.contains(DRE))
   return true;
@@ -73,6 +92,7 @@ class UncountedLambdaCapturesChecker
 auto *L = dyn_cast_or_null(Init->IgnoreParenCasts());
 if (!L)
   return true;
+LambdasToIgnore.insert(L);
 Checker->visitLambdaExpr(L, shouldCheckThis());
 return true;
   }
@@ -95,10 +115,10 @@ class UncountedLambdaCapturesChecker
 if (ArgIndex >= CE->getNumArgs())
   return true;
 auto *Arg = CE->getArg(ArgIndex)->IgnoreParenCasts();
-if (!Param->hasAttr() && !TreatAllArgsAsNoEscape) {
-  if (auto *L = dyn_cast_or_null(Arg)) {
+if (auto *L = dyn_cast_or_null(Arg)) {
+  LambdasToIgnore.insert(L);
+  if (!Param->hasAttr() && !TreatAllArgsAsNoEscape)
 Checker->visitLambdaExpr(L, shouldCheckThis());
-  }
 }
 ++ArgIndex;
   }
@@ -117,6 +137,10 @@ class UncountedLambdaCapturesChecker
 if (!MD || CE->getNumArgs() < 1)
   return;
 auto *Arg = CE->getArg(0)->IgnoreParenCasts();
+if (auto *L = dyn_cast_or_null(Arg)) {
+  LambdasToIgnore.insert(L); // Calling a lambda upon creation is safe.
+  return;
+}
 auto *ArgRef = dyn_cast(Arg);
 if (!ArgRef)
   return;
@@ -130,6 +154,7 @@ class UncountedLambdaCapturesChecker
 if (!L)
   return;
 DeclRefExprsToIgnore.insert(ArgRef);
+LambdasToIgnore.insert(L);
 Checker->visitLambdaExpr(L, shouldCheckThis(),
  /* ignoreParamVarDecl */ true);
   }

diff  --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp 
b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
index 65eee9d49106df..daff32e9940c83 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -1,16 +1,72 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
 
-struct A {
-  static void b();
+#include "mock-types.h"
+
+namespace WTF {
+
+namespace Detail {
+
+template
+class CallableWrapperBase {
+public:
+virtual ~CallableWrapperBase() { }
+virtual Out call(In...) = 0;
+};
+
+template class CallableWrapper;
+
+template
+class CallableWrapper : public CallableWrapperBase {
+public:
+explicit CallableWrapper(CallableType& callable)
+: m_callable(callable) { }
+Out call(In... in) final { return m_callable(in...); }
+
+private:
+CallableType m_callable;
+};
+
+} // namespace Detail
+
+template class Function;
+
+template Function 
adopt(Detail::CallableWrapperBase*);
+
+template 
+class Function {
+public:
+using Impl = Detail::CallableWrapperBase;
+
+   

[clang] [webkit.UncountedLambdaCapturesChecker] Add a fallback for checking lambda captures (PR #119800)

2024-12-15 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

Great. Thanks for the review.

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FVDOT, FVDOTB and FVDOTT intrinsics (PR #119922)

2024-12-15 Thread via cfe-commits

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


[clang] [webkit.UncountedLambdaCapturesChecker] Add a fallback for checking lambda captures (PR #119800)

2024-12-15 Thread Ryosuke Niwa via cfe-commits

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FVDOT, FVDOTB and FVDOTT intrinsics (PR #119922)

2024-12-15 Thread via cfe-commits

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


[clang] [llvm] [BoundsChecking] Add parameters to pass (PR #119894)

2024-12-15 Thread Fangrui Song via cfe-commits


@@ -1286,6 +1286,33 @@ Expected 
parseRtSanPassOptions(StringRef Params) {
   return Result;
 }
 
+Expected
+parseBoundsCheckingOptions(StringRef Params) {
+  BoundsCheckingPass::ReportingMode Mode =
+  BoundsCheckingPass::ReportingMode::Trap;
+  while (!Params.empty()) {
+StringRef ParamName;
+std::tie(ParamName, Params) = Params.split(';');
+if (ParamName == "trap") {

MaskRay wrote:

(1) that avoids -mllvm options is cleaner:)

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


[clang] [llvm] [BoundsChecking] Add parameters to pass (PR #119894)

2024-12-15 Thread Fangrui Song via cfe-commits

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


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


[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Fangrui Song via cfe-commits


@@ -59,3 +61,13 @@ MachineModuleInfoImpl::ExprStubListTy 
MachineModuleInfoImpl::getSortedExprStubs(
   ExprStubs.clear();
   return List;
 }
+
+MachineModuleInfoELF::MachineModuleInfoELF(const MachineModuleInfo &MMI) {
+  const Module *M = MMI.getModule();
+  const auto *Flag = mdconst::extract_or_null(
+  M->getModuleFlag("ptrauth-sign-personality"));
+  if (Flag && Flag->getZExtValue() == 1)

MaskRay wrote:

`HasSignedPersonality = Flag && ... == 1`

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


[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Fangrui Song via cfe-commits


@@ -431,6 +432,13 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(
   Streamer.emitELFSize(Label, E);
   Streamer.emitLabel(Label);
 
+  emitPersonalityValueImpl(Streamer, DL, Sym, MMI);
+}
+
+void TargetLoweringObjectFileELF::emitPersonalityValueImpl(
+MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym,
+const MachineModuleInfo *MMI) const {
+  unsigned Size = DL.getPointerSize();

MaskRay wrote:

inline used-once variable

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


[clang] [llvm] [PAC][ELF][AArch64] Support signed personality function pointer (PR #119361)

2024-12-15 Thread Fangrui Song via cfe-commits

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


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


[clang-tools-extra] [clangd] Do not show `aParam` parameter hint for argument spelled `param` (PR #119162)

2024-12-15 Thread Nathan Ridge via cfe-commits


@@ -867,13 +867,28 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 }
   }
 
+  static bool argumentMatchesParamName(StringRef ArgName, StringRef ParamName) 
{
+// Exact match.
+if (ParamName == ArgName)
+  return true;
+
+// Parameter name uses "a" prefix (e.g. "aParam").
+if (ParamName.size() > 1 && ParamName[0] == 'a' &&

HighCommander4 wrote:

In the codebase where I encountered this convention, the `a` prefix did not 
refer to the _word_ "a" (indefinite article), but rather was an abbreviation 
for "argument" (used as an imprecise synonym for "parameter"). So, with this 
convention, the prefix would be `a` even in front of `Apple`.

But I suppose I can imagine a different convention where the prefix is an 
indefinite article and so you'd get `anApple`.

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


[clang] [llvm] [NVPTX] Auto-Upgrade some nvvm.annotations to attributes (PR #119261)

2024-12-15 Thread Matt Arsenault via cfe-commits


@@ -1270,77 +1270,21 @@ exit:
 ; MODULE: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
 ; MODULE: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree 
nounwind willreturn }
 ; MODULE: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(inaccessiblemem: write) }
-; MODULE: attributes #[[ATTR4]] = { "kernel" }
-; MODULE: attributes #[[ATTR5]] = { nosync memory(none) }
+; MODULE: attributes #[[ATTR4]] = { "kernel" "nvvm.kernel" }
+; MODULE: attributes #[[ATTR5]] = { "kernel" }
+; MODULE: attributes #[[ATTR6]] = { nosync memory(none) }
 ;.
 ; CGSCC: attributes #[[ATTR0]] = { "llvm.assume"="ompx_aligned_barrier" }
 ; CGSCC: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
 ; CGSCC: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree 
nounwind willreturn }
 ; CGSCC: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(inaccessiblemem: write) }
-; CGSCC: attributes #[[ATTR4]] = { "kernel" }
-; CGSCC: attributes #[[ATTR5]] = { nosync memory(none) }
+; CGSCC: attributes #[[ATTR4]] = { "kernel" "nvvm.kernel" }

arsenm wrote:

Does PTX support calling a kernel entry point as an ordinary function from 
another function? I've never understood how PTX doesn't set an IR calling 
convention for the entries 

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


[clang] [llvm] [DebugInfo] Place local ODR-uniqued types in decl DISubprograms (PR #119001)

2024-12-15 Thread Jeremy Morse via cfe-commits

jmorse wrote:

Indeed @ the language, it's difficult to know that this is definitely going to 
work when I don't have a full understanding of the patch series, thus the 
caution,

I've studied a bit further and even with the full patch series we seem to be 
missing an important link. Here's a gist: 
https://gist.github.com/jmorse/091ae6ed42e6a36199b8593a7b81bd49 which contains 
the LLVM DWARF output for the aforementioned lexical-block-static-var.ll . 
While it passes the FileCheck lines in the test, it lacks the 
DW_AT_abstract_origin that gcc produces -- observe that nothing references 
addresses 8a or 5b. The consumer is then presumably left with a problem: it 
might be able to discover the static variables A and B, and that they're in a 
lexical block, but not _which_ lexical block. There's also a risk that I 
misapplied D144008, which I had to copy-and-paste out of Phab, @dzhidzhoev 
would you have a public-github branch that contains that patch?.

In the IR metadata, each DIGlobalVariable refers into a tree of distinct 
DILexicalScopes and DISubprograms that's part of the definition subprogram for 
the relevant function. I suspect that in scenarios where multiple instances of 
an inline function with a static variable are LTO'd, we might see a repeat of 
this type uniquing problem: LLVM will pick a single DIGlobalVariable as the 
location for such an inlined-function static variable, which will then refer 
into the DILexicalScope/DISubprogram tree for one instance of the inlined 
function, potentially causing confusion or hard-to-interpret DWARF. I think the 
natural solution to this is putting DIGlobalVariable scopes into a 
"declaration" tree of DILexicalScopes/DISubprograms too.

I'll try to cook up a precise example of this happening so that it's clear, but 
have to dash for now.

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


[clang] [FMV][AArch64] Emit mangled default version if explicitly specified. (PR #120022)

2024-12-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexandros Lamprineas (labrinea)


Changes

Curently we need at least one more version other than the default to trigger 
FMV. However we would like a header file declaration

__attribute__((target_version("default"))) void f(void);

to guarantee that there will be f.default

---

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


7 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+22-25) 
- (added) clang/test/CodeGen/AArch64/fmv-mix-explicit-implicit-default.c (+221) 
- (modified) clang/test/CodeGen/attr-target-version.c (+43-8) 
- (modified) clang/test/CodeGenCXX/fmv-namespace.cpp (+11-11) 
- (modified) clang/test/Sema/attr-target-version.c (+4) 
- (modified) clang/test/SemaCXX/attr-target-version.cpp (+3-1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d3d5c0743a520b..b65e3dc2496797 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4280,7 +4280,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
 getContext().forEachMultiversionedFunctionVersion(
 FD, [&](const FunctionDecl *CurFD) {
   llvm::SmallVector Feats;
-  bool IsDefined = CurFD->doesThisDeclarationHaveABody();
+  bool IsDefined = CurFD->getDefinition() != nullptr;
 
   if (const auto *TA = CurFD->getAttr()) {
 assert(getTarget().getTriple().isX86() && "Unsupported target");
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 55e891e3acf20d..7c3e5ceabb771d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11073,9 +11073,9 @@ bool Sema::shouldLinkDependentDeclWithPrevious(Decl *D, 
Decl *PrevDecl) {
 static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD) {
   const auto *TA = FD->getAttr();
   const auto *TVA = FD->getAttr();
-  assert(
-  (TA || TVA) &&
-  "MultiVersion candidate requires a target or target_version attribute");
+
+  assert((TA || TVA) && "Expecting target or target_version attribute");
+
   const TargetInfo &TargetInfo = S.Context.getTargetInfo();
   enum ErrType { Feature = 0, Architecture = 1 };
 
@@ -11372,10 +11372,6 @@ static bool CheckMultiVersionFirstFunction(Sema &S, 
FunctionDecl *FD) {
   // otherwise it is treated as a normal function.
   if (TA && !TA->isDefaultVersion())
 return false;
-  // The target_version attribute only causes Multiversioning if this
-  // declaration is NOT the default version.
-  if (TVA && TVA->isDefaultVersion())
-return false;
 
   if ((TA || TVA) && CheckMultiVersionValue(S, FD)) {
 FD->setInvalidDecl();
@@ -11422,26 +11418,24 @@ static bool 
CheckDeclarationCausesMultiVersioning(Sema &S, FunctionDecl *OldFD,
   LookupResult &Previous) {
   assert(!OldFD->isMultiVersion() && "Unexpected MultiVersion");
 
+  const auto *NewTA = NewFD->getAttr();
+  const auto *OldTA = OldFD->getAttr();
+  const auto *NewTVA = NewFD->getAttr();
+  const auto *OldTVA = OldFD->getAttr();
+
+  assert((NewTA || NewTVA) && "Excpecting target or target_version attribute");
+
   // The definitions should be allowed in any order. If we have discovered
   // a new target version and the preceeding was the default, then add the
   // corresponding attribute to it.
   patchDefaultTargetVersion(NewFD, OldFD);
 
-  const auto *NewTA = NewFD->getAttr();
-  const auto *NewTVA = NewFD->getAttr();
-  const auto *OldTA = OldFD->getAttr();
-
   // If the old decl is NOT MultiVersioned yet, and we don't cause that
   // to change, this is a simple redeclaration.
   if (NewTA && !NewTA->isDefaultVersion() &&
   (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
 return false;
 
-  // The target_version attribute only causes Multiversioning if this
-  // declaration is NOT the default version.
-  if (NewTVA && NewTVA->isDefaultVersion())
-return false;
-
   // Otherwise, this decl causes MultiVersioning.
   if (CheckMultiVersionAdditionalRules(S, OldFD, NewFD, true,
NewTVA ? MultiVersionKind::TargetVersion
@@ -11456,7 +11450,8 @@ static bool CheckDeclarationCausesMultiVersioning(Sema 
&S, FunctionDecl *OldFD,
   }
 
   // If this is 'default', permit the forward declaration.
-  if (NewTA && NewTA->isDefaultVersion() && !OldTA) {
+  if ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
+  (NewTVA && NewTVA->isDefaultVersion() && !OldTVA)) {
 Redeclaration = true;
 OldDecl = OldFD;
 OldFD->setIsMultiVersion();
@@ -11464,7 +11459,7 @@ static bool CheckDeclarationCausesMultiVersioning(Sema 
&S, FunctionDecl *OldFD,
 return false;
   }
 
-  if (CheckMultiVersionValue(S, OldFD)) {
+  if ((OldTA || OldTVA) && CheckMultiVersionValue(S, OldFD)) {
 S.Diag(NewFD->

[clang] [FMV][AArch64] Emit mangled default version if explicitly specified. (PR #120022)

2024-12-15 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea created 
https://github.com/llvm/llvm-project/pull/120022

Curently we need at least one more version other than the default to trigger 
FMV. However we would like a header file declaration

__attribute__((target_version("default"))) void f(void);

to guarantee that there will be f.default

>From f3997c43e57265444bade9372833a9235e3426cb Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Fri, 13 Dec 2024 12:42:31 +
Subject: [PATCH] [FMV][AArch64] Emit mangled default version if explicitly
 specified.

Curently we need at least one more version other than the default
to trigger FMV. However we would like a header file declaration

__attribute__((target_version("default"))) void f(void);

to guarantee that there will be f.default
---
 clang/lib/CodeGen/CodeGenModule.cpp   |   2 +-
 clang/lib/Sema/SemaDecl.cpp   |  47 ++--
 .../fmv-mix-explicit-implicit-default.c   | 221 ++
 clang/test/CodeGen/attr-target-version.c  |  51 +++-
 clang/test/CodeGenCXX/fmv-namespace.cpp   |  22 +-
 clang/test/Sema/attr-target-version.c |   4 +
 clang/test/SemaCXX/attr-target-version.cpp|   4 +-
 7 files changed, 305 insertions(+), 46 deletions(-)
 create mode 100644 
clang/test/CodeGen/AArch64/fmv-mix-explicit-implicit-default.c

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d3d5c0743a520b..b65e3dc2496797 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4280,7 +4280,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
 getContext().forEachMultiversionedFunctionVersion(
 FD, [&](const FunctionDecl *CurFD) {
   llvm::SmallVector Feats;
-  bool IsDefined = CurFD->doesThisDeclarationHaveABody();
+  bool IsDefined = CurFD->getDefinition() != nullptr;
 
   if (const auto *TA = CurFD->getAttr()) {
 assert(getTarget().getTriple().isX86() && "Unsupported target");
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 55e891e3acf20d..7c3e5ceabb771d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11073,9 +11073,9 @@ bool Sema::shouldLinkDependentDeclWithPrevious(Decl *D, 
Decl *PrevDecl) {
 static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD) {
   const auto *TA = FD->getAttr();
   const auto *TVA = FD->getAttr();
-  assert(
-  (TA || TVA) &&
-  "MultiVersion candidate requires a target or target_version attribute");
+
+  assert((TA || TVA) && "Expecting target or target_version attribute");
+
   const TargetInfo &TargetInfo = S.Context.getTargetInfo();
   enum ErrType { Feature = 0, Architecture = 1 };
 
@@ -11372,10 +11372,6 @@ static bool CheckMultiVersionFirstFunction(Sema &S, 
FunctionDecl *FD) {
   // otherwise it is treated as a normal function.
   if (TA && !TA->isDefaultVersion())
 return false;
-  // The target_version attribute only causes Multiversioning if this
-  // declaration is NOT the default version.
-  if (TVA && TVA->isDefaultVersion())
-return false;
 
   if ((TA || TVA) && CheckMultiVersionValue(S, FD)) {
 FD->setInvalidDecl();
@@ -11422,26 +11418,24 @@ static bool 
CheckDeclarationCausesMultiVersioning(Sema &S, FunctionDecl *OldFD,
   LookupResult &Previous) {
   assert(!OldFD->isMultiVersion() && "Unexpected MultiVersion");
 
+  const auto *NewTA = NewFD->getAttr();
+  const auto *OldTA = OldFD->getAttr();
+  const auto *NewTVA = NewFD->getAttr();
+  const auto *OldTVA = OldFD->getAttr();
+
+  assert((NewTA || NewTVA) && "Excpecting target or target_version attribute");
+
   // The definitions should be allowed in any order. If we have discovered
   // a new target version and the preceeding was the default, then add the
   // corresponding attribute to it.
   patchDefaultTargetVersion(NewFD, OldFD);
 
-  const auto *NewTA = NewFD->getAttr();
-  const auto *NewTVA = NewFD->getAttr();
-  const auto *OldTA = OldFD->getAttr();
-
   // If the old decl is NOT MultiVersioned yet, and we don't cause that
   // to change, this is a simple redeclaration.
   if (NewTA && !NewTA->isDefaultVersion() &&
   (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr()))
 return false;
 
-  // The target_version attribute only causes Multiversioning if this
-  // declaration is NOT the default version.
-  if (NewTVA && NewTVA->isDefaultVersion())
-return false;
-
   // Otherwise, this decl causes MultiVersioning.
   if (CheckMultiVersionAdditionalRules(S, OldFD, NewFD, true,
NewTVA ? MultiVersionKind::TargetVersion
@@ -11456,7 +11450,8 @@ static bool CheckDeclarationCausesMultiVersioning(Sema 
&S, FunctionDecl *OldFD,
   }
 
   // If this is 'default', permit the forward declaration.
-  if (NewTA && NewTA->isDefaultVersion() && !OldTA) {
+  if ((NewTA && NewTA->isDefaultVersion() && !OldTA) |

[clang] [llvm] [DebugInfo] Place local ODR-uniqued types in decl DISubprograms (PR #119001)

2024-12-15 Thread Jeremy Morse via cfe-commits

jmorse wrote:

(" it lacks the DW_AT_abstract_origin that gcc produces..." for the 
DW_TAG_lexical_scopes referring back to the abstract/declaration subprogram).

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


[clang] [FMV][AArch64] Emit mangled default version if explicitly specified. (PR #120022)

2024-12-15 Thread Alexandros Lamprineas via cfe-commits

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


[clang] [clang] Recover necessary AddrSpaceCast (PR #119246)

2024-12-15 Thread Youngsuk Kim via cfe-commits

https://github.com/JOE1994 updated 
https://github.com/llvm/llvm-project/pull/119246

>From 9dbcf65775a979553bee2c95b16e3e2328e957a1 Mon Sep 17 00:00:00 2001
From: Youngsuk Kim 
Date: Mon, 9 Dec 2024 10:33:18 -0600
Subject: [PATCH 1/3] [clang] Recover necessary AddrSpaceCast

A necessary AddrSpaceCast was wrongfully deleted in 
5c91b2886f6bf400b60ca7839069839ac3980f8f .
Recover the AddrSpaceCast.

This fixes #86791 .
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp|  3 +++
 clang/test/OpenMP/amdgpu_threadprivate.cpp | 11 +++
 2 files changed, 14 insertions(+)
 create mode 100644 clang/test/OpenMP/amdgpu_threadprivate.cpp

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 8cbd09d02c7556..0abea335ad69e4 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3302,6 +3302,9 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
   CharUnits Align = CGM.getContext().getDeclAlign(VD);
   Val = Builder.CreateAlignedLoad(Var->getValueType(), Val, Align);
 }
+if (Val->getType() != Wrapper->getReturnType()) {
+  Val = Builder.CreateAddrSpaceCast(Val, Wrapper->getReturnType());
+}
 
 Builder.CreateRet(Val);
   }
diff --git a/clang/test/OpenMP/amdgpu_threadprivate.cpp 
b/clang/test/OpenMP/amdgpu_threadprivate.cpp
new file mode 100644
index 00..5b15255ee62d4a
--- /dev/null
+++ b/clang/test/OpenMP/amdgpu_threadprivate.cpp
@@ -0,0 +1,11 @@
+// REQUIRES: asserts
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 
-disable-llvm-passes -fopenmp-targets=amdgcn-amd-amdhsa -x c++ -emit-llvm-bc %s 
-o %t-x86-host.bc
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-unknown-linux-gnu -target-cpu gfx906 -fopenmp -nogpulib 
-fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -x c++ %s
+
+// Don't crash with assertions build.
+int MyGlobVar;
+#pragma omp threadprivate(MyGlobVar)
+int main() {
+  MyGlobVar = 1;
+}

>From 4af1ba587d01ab74f222efaa1a14cf95c652964a Mon Sep 17 00:00:00 2001
From: Youngsuk Kim 
Date: Thu, 12 Dec 2024 10:00:53 -0600
Subject: [PATCH 2/3] Avoid redundant type check before AddrSpaceCast

As per feedback from reviewers.
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 0abea335ad69e4..cf9e338236e556 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3302,9 +3302,7 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
   CharUnits Align = CGM.getContext().getDeclAlign(VD);
   Val = Builder.CreateAlignedLoad(Var->getValueType(), Val, Align);
 }
-if (Val->getType() != Wrapper->getReturnType()) {
-  Val = Builder.CreateAddrSpaceCast(Val, Wrapper->getReturnType());
-}
+Val = Builder.CreateAddrSpaceCast(Val, Wrapper->getReturnType());
 
 Builder.CreateRet(Val);
   }

>From 64664374f53a788938e72e6160fa8f843d6541a3 Mon Sep 17 00:00:00 2001
From: Youngsuk Kim 
Date: Sun, 15 Dec 2024 17:24:06 -0600
Subject: [PATCH 3/3] Add FileCheck checks

---
 clang/test/OpenMP/amdgpu_threadprivate.cpp | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/test/OpenMP/amdgpu_threadprivate.cpp 
b/clang/test/OpenMP/amdgpu_threadprivate.cpp
index 5b15255ee62d4a..9828f3e375b356 100644
--- a/clang/test/OpenMP/amdgpu_threadprivate.cpp
+++ b/clang/test/OpenMP/amdgpu_threadprivate.cpp
@@ -1,11 +1,17 @@
-// REQUIRES: asserts
-
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 
-disable-llvm-passes -fopenmp-targets=amdgcn-amd-amdhsa -x c++ -emit-llvm-bc %s 
-o %t-x86-host.bc
-// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-unknown-linux-gnu -target-cpu gfx906 -fopenmp -nogpulib 
-fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -x c++ %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple 
x86_64-unknown-linux-gnu -target-cpu gfx906 -fopenmp -nogpulib 
-fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -x c++ 
-emit-llvm %s -o - | FileCheck %s
 
 // Don't crash with assertions build.
+
+// CHECK:   @MyGlobVar = external thread_local addrspace(1) global i32, 
align 4
+// CHECK:   define weak_odr hidden noundef ptr @_ZTW9MyGlobVar() #0 comdat 
{
+// CHECK-NEXT:%1 = call align 4 ptr addrspace(1) 
@llvm.threadlocal.address.p1(ptr addrspace(1) align 4 @MyGlobVar)
+// CHECK-NEXT:%2 = addrspacecast ptr addrspace(1) %1 to ptr
+// CHECK-NEXT:ret ptr %2
+// CHECK-NEXT:  }
 int MyGlobVar;
 #pragma omp threadprivate(MyGlobVar)
 int main() {
   MyGlobVar = 1;
 }
+

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


[clang] 1464b8e - Revert "Move interceptors for libresolv functions to MSan (#119071)"

2024-12-15 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2024-12-15T14:04:56-05:00
New Revision: 1464b8ec8a675fd11dc7280db1c56aac03771b0a

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

LOG: Revert "Move interceptors for libresolv functions to MSan (#119071)"

This reverts commit f5f965058a5f9b835382f96bd4041bc7e608ece0.
Breaks a test on some bots, see
https://github.com/llvm/llvm-project/pull/119071#issuecomment-2544000926

Added: 
compiler-rt/test/sanitizer_common/TestCases/Linux/b64.cpp
compiler-rt/test/sanitizer_common/TestCases/Linux/dn_expand.cpp

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/msan/msan_interceptors.cpp
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Removed: 
compiler-rt/test/msan/Linux/dn_expand.cpp



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 3c78b12b0741e0..ca675c117418cb 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1443,7 +1443,7 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
   // libresolv.a, even if exists, is an empty archive to satisfy POSIX -lresolv
   // requirement.
   if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() &&
-  !TC.getTriple().isMusl() && TC.getSanitizerArgs(Args).needsMsanRt())
+  !TC.getTriple().isMusl())
 CmdArgs.push_back("-lresolv");
 }
 

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 877a01c3de3047..c83066a334001a 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -15,7 +15,7 @@
 // CHECK-ASAN-LINUX: "-lpthread"
 // CHECK-ASAN-LINUX: "-lrt"
 // CHECK-ASAN-LINUX: "-ldl"
-// CHECK-ASAN-LINUX-NOT: "-lresolv"
+// CHECK-ASAN-LINUX: "-lresolv"
 
 // RUN: %clang -fsanitize=address -fno-sanitize-link-runtime -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
@@ -143,7 +143,7 @@
 // CHECK-ASAN-LINUX-CXX: "-lpthread"
 // CHECK-ASAN-LINUX-CXX: "-lrt"
 // CHECK-ASAN-LINUX-CXX: "-ldl"
-// CHECK-ASAN-LINUX-CXX-NOT: "-lresolv"
+// CHECK-ASAN-LINUX-CXX: "-lresolv"
 
 // RUN: %clang -### %s -o /dev/null -fsanitize=address \
 // RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform \
@@ -292,7 +292,7 @@
 // CHECK-TSAN-LINUX-CXX: "-lpthread"
 // CHECK-TSAN-LINUX-CXX: "-lrt"
 // CHECK-TSAN-LINUX-CXX: "-ldl"
-// CHECK-TSAN-LINUX-CXX-NOT: "-lresolv"
+// CHECK-TSAN-LINUX-CXX: "-lresolv"
 
 // RUN: %clang -fsanitize=thread -fno-sanitize-link-runtime -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
@@ -365,7 +365,7 @@
 // CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
 // CHECK-UBSAN-LINUX-NOT: "-lstdc++"
 // CHECK-UBSAN-LINUX: "-lpthread"
-// CHECK-UBSAN-LINUX-NOT: "-lresolv"
+// CHECK-UBSAN-LINUX: "-lresolv"
 
 // RUN: %clang -fsanitize=undefined -fno-sanitize-link-runtime -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
@@ -438,7 +438,7 @@
 // CHECK-UBSAN-LINUX-CXX: "-lstdc++"
 // CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
 // CHECK-UBSAN-LINUX-CXX: "-lpthread"
-// CHECK-UBSAN-LINUX-CXX-NOT: "-lresolv"
+// CHECK-UBSAN-LINUX-CXX: "-lresolv"
 
 // RUN: %clang -fsanitize=undefined -fsanitize-minimal-runtime -### %s 2>&1 \
 // RUN: --target=i386-unknown-linux -fuse-ld=ld \
@@ -448,7 +448,7 @@
 // CHECK-UBSAN-MINIMAL-LINUX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-UBSAN-MINIMAL-LINUX: "--whole-archive" 
"{{.*}}libclang_rt.ubsan_minimal.a" "--no-whole-archive"
 // CHECK-UBSAN-MINIMAL-LINUX: "-lpthread"
-// CHECK-UBSAN-MINIMAL-LINUX-NOT: "-lresolv"
+// CHECK-UBSAN-MINIMAL-LINUX: "-lresolv"
 
 // RUN: %clang -fsanitize=undefined -fsanitize-minimal-runtime -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin -fuse-ld=ld \
@@ -485,7 +485,7 @@
 // CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan
 // CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
 // CHECK-ASAN-UBSAN-LINUX: "-lpthread"
-// CHECK-ASAN-UBSAN-LINUX-NOT: "-lresolv"
+// CHECK-ASAN-UBSAN-LINUX: "-lresolv"
 
 // RUN: %clangxx -fsanitize=address,undefined -### %s 2>&1 \
 // RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform \
@@ -498,7 +498,7 @@
 // CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
-// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: "-lresolv"
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-lresolv"
 
 // RUN: %clangxx -fsanitize=memory,undefined -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
@@ -541,7 +541,7 @@
 // CHECK-LSAN-LINUX: libclang_rt.lsan.a"
 // CHECK-LSAN-LINUX: "-lpthread"
 // CHECK-LSAN-LINUX: "-ldl"
-// CHECK-LSAN-LINUX-

[clang] 5004622 - Revert "[Driver] Cache SanitizerArgs (NFC) (#119442)"

2024-12-15 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2024-12-15T14:04:55-05:00
New Revision: 50046221b8e913ec6506eb96ce4c0cd267a5cc99

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

LOG: Revert "[Driver] Cache SanitizerArgs (NFC) (#119442)"

This reverts commit bae383ba6b53b0d8257c83f99ceecdd751d0a378.
Prerequisite to reverting #119071.

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/lib/Driver/ToolChains/Solaris.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 0d851314a89539..3c78b12b0741e0 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1417,7 +1417,6 @@ void tools::addAsNeededOption(const ToolChain &TC,
 
 void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
  const llvm::opt::ArgList &Args,
- const SanitizerArgs &SanArgs,
  ArgStringList &CmdArgs) {
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
@@ -1444,18 +1443,18 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain 
&TC,
   // libresolv.a, even if exists, is an empty archive to satisfy POSIX -lresolv
   // requirement.
   if (TC.getTriple().isOSLinux() && !TC.getTriple().isAndroid() &&
-  !TC.getTriple().isMusl() && SanArgs.needsMsanRt())
+  !TC.getTriple().isMusl() && TC.getSanitizerArgs(Args).needsMsanRt())
 CmdArgs.push_back("-lresolv");
 }
 
 static void
 collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
- const SanitizerArgs &SanArgs,
  SmallVectorImpl &SharedRuntimes,
  SmallVectorImpl &StaticRuntimes,
  SmallVectorImpl &NonWholeStaticRuntimes,
  SmallVectorImpl &HelperStaticRuntimes,
  SmallVectorImpl &RequiredSymbols) {
+  const SanitizerArgs &SanArgs = TC.getSanitizerArgs(Args);
   // Collect shared runtimes.
   if (SanArgs.needsSharedRt()) {
 if (SanArgs.needsAsanRt()) {
@@ -1589,12 +1588,12 @@ collectSanitizerRuntimes(const ToolChain &TC, const 
ArgList &Args,
 // Should be called before we add system libraries (C++ ABI, libstdc++/libc++,
 // C runtime, etc). Returns true if sanitizer system deps need to be linked in.
 bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
- const SanitizerArgs &SanArgs,
  ArgStringList &CmdArgs) {
+  const SanitizerArgs &SanArgs = TC.getSanitizerArgs(Args);
   SmallVector SharedRuntimes, StaticRuntimes,
   NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols;
   if (SanArgs.linkRuntimes()) {
-collectSanitizerRuntimes(TC, Args, SanArgs, SharedRuntimes, StaticRuntimes,
+collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
  NonWholeStaticRuntimes, HelperStaticRuntimes,
  RequiredSymbols);
   }

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index de2d143b904790..b6ddd99b872798 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -38,12 +38,10 @@ void addLinkerCompressDebugSectionsOption(const ToolChain 
&TC,
 void claimNoWarnArgs(const llvm::opt::ArgList &Args);
 
 bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args,
-  const SanitizerArgs &SanArgs,
   llvm::opt::ArgStringList &CmdArgs);
 
 void linkSanitizerRuntimeDeps(const ToolChain &TC,
   const llvm::opt::ArgList &Args,
-  const SanitizerArgs &SanArgs,
   llvm::opt::ArgStringList &CmdArgs);
 
 bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args,

diff  --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 678efefb1afce8..be44fc4fe1a84d 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -297,9 +297,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   D.getLTOMode() == LTOK_Thin);
   }
 
-  const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args)

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-15 Thread Nico Weber via cfe-commits

nico wrote:

I reverted this in 1464b8ec8a675fd11dc7280db1c56aac03771b0a for now.

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Carlos Galvez via cfe-commits


@@ -26,7 +26,7 @@ class InconsistentDeclarationParameterNameCheck : public 
ClangTidyCheck {
 ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
-Strict(Options.getLocalOrGlobal("Strict", false)) {}
+Strict(Options.get("Strict", false)) {}

carlosgalvezp wrote:

We can look into it in a separate patch. Renaming is just as problematic as 
removing it: we break it for users who use `Strict`, so we once again need a 
grace period where we support both options and then switch to the new one. 
Personally I don't think it's worth the trouble so I'd just leave it like it is.

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Carlos Galvez via cfe-commits


@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -check-suffix=STRICT  %s 
cppcoreguidelines-pro-type-const-cast %t -- -config="{CheckOptions: 
{StrictMode: true}}"
+// RUN: %check_clang_tidy -check-suffix=STRICT  %s 
cppcoreguidelines-pro-type-const-cast %t -- -config="{CheckOptions: 
{cppcoreguidelines-pro-type-const-cast.StrictMode: true}}"

carlosgalvezp wrote:

This is interesting: the check option was actually something in between global 
and local, since it's inside the `CheckOptions` block, instead of at the very 
top-level of the .clang-tidy file.

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Carlos Galvez via cfe-commits

https://github.com/carlosgalvezp commented:

LGTM except the release notes, I think it would be more helpful to the users if 
we listed the changes explicitly.

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


[clang] [llvm] [AArch64] Implement intrinsics for SME FP8 FMLAL/FMLALL (Indexed) (PR #118549)

2024-12-15 Thread via cfe-commits

https://github.com/SpencerAbson updated 
https://github.com/llvm/llvm-project/pull/118549

>From 656465bfc10319c8864cefaf3423ac70881b88c9 Mon Sep 17 00:00:00 2001
From: Spencer Abson 
Date: Sun, 15 Dec 2024 20:28:08 +
Subject: [PATCH] [AArch64] Implement intrinsics for SME FP8 FMAL/FMLALL
 (indexed)

---
 clang/include/clang/Basic/arm_sme.td  |  14 ++
 .../fp8-intrinsics/acle_sme2_fp8_mla.c| 129 ++
 .../acle_sme2_fp8_imm.c   |  34 +
 .../acle_sme2_fp8_mla.c   |  26 
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  34 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  12 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  58 +---
 .../AArch64/sme2-fp8-intrinsics-mla.ll| 116 
 8 files changed, 399 insertions(+), 24 deletions(-)
 create mode 100644 
clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_mla.c
 create mode 100644 clang/test/Sema/aarch64-fp8-intrinsics/acle_sme2_fp8_mla.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-fp8-intrinsics-mla.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 0fae70866cd55e..7d5c62ae8f729f 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -842,11 +842,25 @@ let SMETargetGuard = "sme-lutv2" in {
 let SMETargetGuard = "sme-f8f32" in {
   def SVMOPA_FP8_ZA32 : Inst<"svmopa_za32[_mf8]_m_fpm", "viPPdd>", "m", 
MergeNone, "aarch64_sme_fp8_fmopa_za32",
  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<0, ImmCheck0_3>]>;
+   // FMLALL (indexed)
+  def SVMLA_FP8_ZA32_VG4x1 : Inst<"svmla_lane_za32[_mf8]_vg4x1_fpm", "vmddi>", 
"m", MergeNone, "aarch64_sme_fp8_fmlall_lane_za32_vg4x1",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA32_VG4x2 : Inst<"svmla_lane_za32[_mf8]_vg4x2_fpm", "vm2di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlall_lane_za32_vg4x2",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA16_VG4x4 : Inst<"svmla_lane_za32[_mf8]_vg4x4_fpm", "vm4di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlall_lane_za32_vg4x4",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
 }
 
 let SMETargetGuard = "sme-f8f16" in {
   def SVMOPA_FP8_ZA16 : Inst<"svmopa_za16[_mf8]_m_fpm", "viPPdd>", "m", 
MergeNone, "aarch64_sme_fp8_fmopa_za16",
  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<0, ImmCheck0_1>]>;
+  // FMLAL (indexed)
+  def SVMLA_FP8_ZA16_VG2x1 : Inst<"svmla_lane_za16[_mf8]_vg2x1_fpm", "vmddi>", 
"m", MergeNone, "aarch64_sme_fp8_fmlal_lane_za16_vg2x1",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA16_VG2x2 : Inst<"svmla_lane_za16[_mf8]_vg2x2_fpm", "vm2di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlal_lane_za16_vg2x2",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA16_VG2x4 : Inst<"svmla_lane_za16[_mf8]_vg2x4_fpm", "vm4di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlal_lane_za16_vg2x4",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
 }
 
 } // let SVETargetGuard = InvalidMode
diff --git a/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_mla.c 
b/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_mla.c
new file mode 100644
index 00..722ccc9f5d5b0d
--- /dev/null
+++ b/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_mla.c
@@ -0,0 +1,129 @@
+
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme-f8f16 -target-feature +sme-f8f32 -disable-O0-optnone 
-Werror -Wall -emit-llvm -o - %s | opt -S 
-passes=mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme-f8f16 -target-feature +sme-f8f32 -disable-O0-optnone 
-Werror -Wall -emit-llvm -o - -x c++ %s | opt -S 
-passes=mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme -target-feature +sme-f8f16 -target-feature +sme-f8f32 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S 
-passes=mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sme -target-feature +sme-f8f16 -target-feature +sme-f8f32 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S 
-

[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-15 Thread Matt Arsenault via cfe-commits


@@ -1846,6 +1846,16 @@ class TargetInfo : public TransferrableTargetInfo,
 return std::make_pair(64, 64);
   }
 
+  /// Returns the optimal vector type elements based on the provided vector
+  /// type. For example, on some targets, a vector with 3 elements may be
+  /// treated as one with 4 elements to enhance performance.
+  virtual llvm::FixedVectorType *
+  getOptimalVectorType(llvm::FixedVectorType *T, const LangOptions &Opt) const 
{
+if (!Opt.HLSL && T->getNumElements() == 3)
+  return llvm::FixedVectorType::get(T->getElementType(), 4);

arsenm wrote:

I think it would be better to keep this in a LangOptions field, regardless of 
whether we keep the flag or not.

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


[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-15 Thread Craig Topper via cfe-commits


@@ -2003,20 +2003,19 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address 
Addr, bool Volatile,
   return EmitFromMemory(V, Ty);
 }
 
-// Handle vectors of size 3 like size 4 for better performance.
-const llvm::Type *EltTy = Addr.getElementType();
-const auto *VTy = cast(EltTy);
-
-if (!CGM.getCodeGenOpts().PreserveVec3Type && VTy->getNumElements() == 3) {
-
-  llvm::VectorType *vec4Ty =
-  llvm::FixedVectorType::get(VTy->getElementType(), 4);
-  Address Cast = Addr.withElementType(vec4Ty);
-  // Now load value.
-  llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVec4");
-
-  // Shuffle vector to get vec3.
-  V = Builder.CreateShuffleVector(V, ArrayRef{0, 1, 2}, "extractVec");
+// Handles vectors of sizes that are likely to be expanded to a larger size
+// to optimize performance.
+auto *VTy = cast(Addr.getElementType());
+auto *NewVecTy = getTarget().getOptimalVectorType(VTy, getLangOpts());
+
+if (VTy != NewVecTy) {
+  Address Cast = Addr.withElementType(NewVecTy);
+  llvm::Value *V = Builder.CreateLoad(Cast, Volatile, "loadVecN");
+  unsigned OldNumElements = VTy->getNumElements();
+  SmallVector Mask(OldNumElements);
+  for (unsigned I = 0; I < OldNumElements; ++I)
+Mask[I] = I;

topperc wrote:

Can we use std::iota to fill the vector?

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


[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-15 Thread Craig Topper via cfe-commits


@@ -2146,21 +2145,21 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value 
*Value, Address Addr,
   Addr = Addr.withPointer(Builder.CreateThreadLocalAddress(GV),
   NotKnownNonNull);
 
+  // Handles vectors of sizes that are likely to be expanded to a larger size
+  // to optimize performance.
   llvm::Type *SrcTy = Value->getType();
   if (const auto *ClangVecTy = Ty->getAs()) {
-auto *VecTy = dyn_cast(SrcTy);
-if (!CGM.getCodeGenOpts().PreserveVec3Type) {
-  // Handle vec3 special.
-  if (VecTy && !ClangVecTy->isExtVectorBoolType() &&
-  cast(VecTy)->getNumElements() == 3) {
-// Our source is a vec3, do a shuffle vector to make it a vec4.
-Value = Builder.CreateShuffleVector(Value, ArrayRef{0, 1, 2, -1},
-"extractVec");
-SrcTy = llvm::FixedVectorType::get(VecTy->getElementType(), 4);
+if (auto *VecTy = dyn_cast(SrcTy)) {
+  auto *NewVecTy = getTarget().getOptimalVectorType(VecTy, getLangOpts());
+  if (!ClangVecTy->isExtVectorBoolType() && VecTy != NewVecTy) {
+SmallVector Mask(NewVecTy->getNumElements(), -1);
+for (unsigned I = 0; I < VecTy->getNumElements(); ++I)
+  Mask[I] = I;

topperc wrote:

std::iota?

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


[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-15 Thread Matt Arsenault via cfe-commits


@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Core

arsenm wrote:

This shouldn't be necessary. I think this code is in the wrong place, I would 
expect it to go in lib/CodeGen/Targets, not lib/Basic

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


[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-15 Thread Craig Topper via cfe-commits


@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Core

topperc wrote:

Does this create additional dependencies on clang based tools that don't need 
to use LLVM IR? For example, clang-format?

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


[clang] [llvm] [NVPTX] Auto-Upgrade some nvvm.annotations to attributes (PR #119261)

2024-12-15 Thread Matt Arsenault via cfe-commits

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


[clang] [llvm] [NVPTX] Auto-Upgrade some nvvm.annotations to attributes (PR #119261)

2024-12-15 Thread Joseph Huber via cfe-commits


@@ -1270,77 +1270,21 @@ exit:
 ; MODULE: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
 ; MODULE: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree 
nounwind willreturn }
 ; MODULE: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(inaccessiblemem: write) }
-; MODULE: attributes #[[ATTR4]] = { "kernel" }
-; MODULE: attributes #[[ATTR5]] = { nosync memory(none) }
+; MODULE: attributes #[[ATTR4]] = { "kernel" "nvvm.kernel" }
+; MODULE: attributes #[[ATTR5]] = { "kernel" }
+; MODULE: attributes #[[ATTR6]] = { nosync memory(none) }
 ;.
 ; CGSCC: attributes #[[ATTR0]] = { "llvm.assume"="ompx_aligned_barrier" }
 ; CGSCC: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
 ; CGSCC: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree 
nounwind willreturn }
 ; CGSCC: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(inaccessiblemem: write) }
-; CGSCC: attributes #[[ATTR4]] = { "kernel" }
-; CGSCC: attributes #[[ATTR5]] = { nosync memory(none) }
+; CGSCC: attributes #[[ATTR4]] = { "kernel" "nvvm.kernel" }

jhuber6 wrote:

It's an error at the PTX level so the backend just lets it happen and waits 
until `ptxas` blows up AFAICT.

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


[clang] [llvm] [NVPTX] Auto-Upgrade some nvvm.annotations to attributes (PR #119261)

2024-12-15 Thread Matt Arsenault via cfe-commits


@@ -1270,77 +1270,21 @@ exit:
 ; MODULE: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
 ; MODULE: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree 
nounwind willreturn }
 ; MODULE: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(inaccessiblemem: write) }
-; MODULE: attributes #[[ATTR4]] = { "kernel" }
-; MODULE: attributes #[[ATTR5]] = { nosync memory(none) }
+; MODULE: attributes #[[ATTR4]] = { "kernel" "nvvm.kernel" }
+; MODULE: attributes #[[ATTR5]] = { "kernel" }
+; MODULE: attributes #[[ATTR6]] = { nosync memory(none) }
 ;.
 ; CGSCC: attributes #[[ATTR0]] = { "llvm.assume"="ompx_aligned_barrier" }
 ; CGSCC: attributes #[[ATTR1:[0-9]+]] = { convergent nocallback nounwind }
 ; CGSCC: attributes #[[ATTR2:[0-9]+]] = { convergent nocallback nofree 
nounwind willreturn }
 ; CGSCC: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(inaccessiblemem: write) }
-; CGSCC: attributes #[[ATTR4]] = { "kernel" }
-; CGSCC: attributes #[[ATTR5]] = { nosync memory(none) }
+; CGSCC: attributes #[[ATTR4]] = { "kernel" "nvvm.kernel" }

arsenm wrote:

Yeah that really should just be a separate calling convention 

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Julian Schmidt via cfe-commits


@@ -26,7 +26,7 @@ class InconsistentDeclarationParameterNameCheck : public 
ClangTidyCheck {
 ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
-Strict(Options.getLocalOrGlobal("Strict", false)) {}
+Strict(Options.get("Strict", false)) {}

5chmidti wrote:

This one sounds like it could just be renamed to `StrictMode`, thoughts? 
(local-or-global)

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


[clang] [llvm] [Clang][OpenMP] Support for dispatch construct (Sema & Codegen) support (PR #117904)

2024-12-15 Thread via cfe-commits

https://github.com/SunilKuravinakop updated 
https://github.com/llvm/llvm-project/pull/117904

>From 1703aa62cfe35538aedbacb28e907535e838248c Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Fri, 20 Sep 2024 01:41:29 -0500
Subject: [PATCH 1/6] Support for dispatch construct (Sema & Codegen) support.
 Support for clauses depend, novariants & nocontext.

---
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Basic/OpenMPKinds.h   |   6 +
 clang/include/clang/Sema/SemaOpenMP.h |   7 +
 clang/lib/Basic/OpenMPKinds.cpp   |   5 +
 clang/lib/CodeGen/CGStmt.cpp  |   2 +-
 clang/lib/CodeGen/CGStmtOpenMP.cpp|   4 +
 clang/lib/CodeGen/CodeGenFunction.h   |   1 +
 clang/lib/Sema/SemaOpenMP.cpp | 301 ++-
 clang/test/OpenMP/dispatch_codegen.cpp| 359 ++
 clang/test/OpenMP/dispatch_unsupported.c  |   7 -
 .../include/llvm/Frontend/OpenMP/OMPContext.h |   6 +
 11 files changed, 687 insertions(+), 14 deletions(-)
 create mode 100644 clang/test/OpenMP/dispatch_codegen.cpp
 delete mode 100644 clang/test/OpenMP/dispatch_unsupported.c

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8495884dcd058f..81b876f9fd85c5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11774,6 +11774,9 @@ def err_omp_clause_requires_dispatch_construct : Error<
   "'%0' clause requires 'dispatch' context selector">;
 def err_omp_append_args_with_varargs : Error<
   "'append_args' is not allowed with varargs functions">;
+def warn_omp_dispatch_clause_novariants_nocontext : Warning<
+  "only 'novariants' clause is supported when 'novariants' & 'nocontext' 
clauses occur on the same dispatch construct">,
+  InGroup;
 def err_openmp_vla_in_task_untied : Error<
   "variable length arrays are not supported in OpenMP tasking regions with 
'untied' clause">;
 def warn_omp_unterminated_declare_target : Warning<
diff --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index 900ad6ca6d66f6..7579fab43dbb19 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -269,6 +269,12 @@ bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
 /// parallel', otherwise - false.
 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
 
+/// Checks if the specified directive is a dispatch-kind directive.
+/// \param DKind Specified directive.
+/// \return true - the directive is a dispatch-like directive like 'omp
+/// dispatch', otherwise - false.
+bool isOpenMPDispatchDirective(OpenMPDirectiveKind DKind);
+
 /// Checks if the specified directive is a target code offload directive.
 /// \param DKind Specified directive.
 /// \return true - the directive is a target code offload directive like
diff --git a/clang/include/clang/Sema/SemaOpenMP.h 
b/clang/include/clang/Sema/SemaOpenMP.h
index 3d1cc4fab1c10f..80cee9e7583051 100644
--- a/clang/include/clang/Sema/SemaOpenMP.h
+++ b/clang/include/clang/Sema/SemaOpenMP.h
@@ -1462,6 +1462,13 @@ class SemaOpenMP : public SemaBase {
: OMPDeclareVariantScopes.back().TI;
   }
 
+  StmtResult transformDispatchDirective(OpenMPDirectiveKind Kind,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion,
+ArrayRef Clauses,
+Stmt *AStmt, SourceLocation StartLoc,
+SourceLocation EndLoc);
+
   /// The current `omp begin/end declare variant` scopes.
   SmallVector OMPDeclareVariantScopes;
 
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 62a13f01481b28..44ee63df46adb5 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -621,6 +621,11 @@ bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind 
DKind) {
  llvm::is_contained(getLeafConstructs(DKind), OMPD_parallel);
 }
 
+bool clang::isOpenMPDispatchDirective(OpenMPDirectiveKind DKind) {
+  return DKind == OMPD_dispatch ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_target);
+}
+
 bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
   return DKind == OMPD_target ||
  llvm::is_contained(getLeafConstructs(DKind), OMPD_target);
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 698baf853507f4..f3eedb79844378 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -417,7 +417,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, 
ArrayRef Attrs) {
 EmitOMPInteropDirective(cast(*S));
 break;
   case Stmt::OMPDispatchDirectiveClass:
-CGM.ErrorUnsupported(S, "OpenMP dispatch directive");
+   

[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Carlos Galvez via cfe-commits


@@ -115,6 +115,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Removed :program:`clang-tidy`'s global options for most of checks. All 
options

carlosgalvezp wrote:

Typically we are explicit about which options and which checks have been 
affected. It's rather verbose and painful, but currently this release note 
doesn't really tell much to the users.

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Congcong Cai via cfe-commits


@@ -26,7 +26,7 @@ class InconsistentDeclarationParameterNameCheck : public 
ClangTidyCheck {
 ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),
 IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
-Strict(Options.getLocalOrGlobal("Strict", false)) {}
+Strict(Options.get("Strict", false)) {}

HerrCai0907 wrote:

we should rename it but i think we should do it after final decision of 
global/local options.

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


[clang-tools-extra] [clang-tidy][NFC] use local config in test cases (PR #120004)

2024-12-15 Thread Congcong Cai via cfe-commits


@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -check-suffix=STRICT  %s 
cppcoreguidelines-pro-type-const-cast %t -- -config="{CheckOptions: 
{StrictMode: true}}"
+// RUN: %check_clang_tidy -check-suffix=STRICT  %s 
cppcoreguidelines-pro-type-const-cast %t -- -config="{CheckOptions: 
{cppcoreguidelines-pro-type-const-cast.StrictMode: true}}"

HerrCai0907 wrote:

IMO, we should define check related config here instead of very top level. what 
i mention global options is also in this scopes instead of clangtidy's command 
line option.

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


[clang] [clang-tools-extra] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)


Changes

```c++
static void foo();
void foo() {}

struct A {
static void bar();
};
void A::bar() {}
```

Both definitions refer to their previous declaration, but were not
considered `static`, because the matcher did not check the canonical
declaration.


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


7 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp 
(+3-4) 
- (modified) 
clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp 
(+2-4) 
- (modified) 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp 
(+4-5) 
- (modified) 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp 
(+2-6) 
- (modified) clang/docs/LibASTMatchersReference.html (+3-1) 
- (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+4-2) 
- (modified) clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (+8) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
index 76fa2d916f0e86..c83c175ce4bdd5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -17,8 +18,6 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::bugprone {
 
 namespace {
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
   return Node.isOverloadedOperator();
 }
@@ -216,8 +215,8 @@ void VirtualNearMissCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   cxxMethodDecl(
   unless(anyOf(isOverride(), isImplicit(), cxxConstructorDecl(),
-   cxxDestructorDecl(), cxxConversionDecl(), isStatic(),
-   isOverloadedOperator(
+   cxxDestructorDecl(), cxxConversionDecl(),
+   isStaticStorageClass(), isOverloadedOperator(
   .bind("method"),
   this);
 }
diff --git 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
index 1284df6bd99cfd..42fc9d36ac41d1 100644
--- 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
@@ -11,15 +11,13 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
-
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, hasTrivialBody) { return Node.hasTrivialBody(); }
 
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
@@ -79,7 +77,7 @@ void 
ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
   cxxMethodDecl(
   isDefinition(), isUserProvided(),
   unless(anyOf(
-  isExpansionInSystemHeader(), isVirtual(), isStatic(),
+  isExpansionInSystemHeader(), isVirtual(), isStaticStorageClass(),
   hasTrivialBody(), isOverloadedOperator(), cxxConstructorDecl(),
   cxxDestructorDecl(), cxxConversionDecl(), isTemplate(),
   isDependentContext(),
diff --git 
a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
index d42fcba70e81b4..adf4584e75f9e5 100644
--- a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
@@ -11,14 +11,12 @@
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
-
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, hasTrivialBody) { return Node.hasTrivialBody(); }
 
 AST_MATCHER(CXXRecordDecl, hasAnyDependentBases) {
@@ -222,8 +220,9 @@ void 
MakeMemberFunctionConstCheck::registerMatchers(MatchFinder *Finder) {
   isDefinition(), isUserProvided(),
   unless(anyOf(
   isExpansionInSystemHeader(), isVirtual(), isConst(),
-  isSta

[clang] [clang-tools-extra] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti created 
https://github.com/llvm/llvm-project/pull/120027

```c++
static void foo();
void foo() {}

struct A {
static void bar();
};
void A::bar() {}
```

Both definitions refer to their previous declaration, but were not
considered `static`, because the matcher did not check the canonical
declaration.


>From 000e5322b0d3371df9a1861ad6c1aa010c52be33 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Mon, 16 Dec 2024 01:18:06 +0100
Subject: [PATCH] [ASTMatchers] fix `isStaticStorageClass` not matching
 definitions of forward declared functions

```c++
static void foo();
void foo() {}

struct A {
static void bar();
};
void A::bar() {}
```

Both definitions refer to their previous declaration, but were not
considered `static`, because the matcher did not check the canonical
declaration.
---
 .../clang-tidy/bugprone/VirtualNearMissCheck.cpp | 7 +++
 .../readability/ConvertMemberFunctionsToStatic.cpp   | 6 ++
 .../readability/MakeMemberFunctionConstCheck.cpp | 9 -
 .../readability/StaticAccessedThroughInstanceCheck.cpp   | 8 ++--
 clang/docs/LibASTMatchersReference.html  | 4 +++-
 clang/include/clang/ASTMatchers/ASTMatchers.h| 6 --
 clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | 8 
 7 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
index 76fa2d916f0e86..c83c175ce4bdd5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -17,8 +18,6 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::bugprone {
 
 namespace {
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
   return Node.isOverloadedOperator();
 }
@@ -216,8 +215,8 @@ void VirtualNearMissCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   cxxMethodDecl(
   unless(anyOf(isOverride(), isImplicit(), cxxConstructorDecl(),
-   cxxDestructorDecl(), cxxConversionDecl(), isStatic(),
-   isOverloadedOperator(
+   cxxDestructorDecl(), cxxConversionDecl(),
+   isStaticStorageClass(), isOverloadedOperator(
   .bind("method"),
   this);
 }
diff --git 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
index 1284df6bd99cfd..42fc9d36ac41d1 100644
--- 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
@@ -11,15 +11,13 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
-
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, hasTrivialBody) { return Node.hasTrivialBody(); }
 
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
@@ -79,7 +77,7 @@ void 
ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
   cxxMethodDecl(
   isDefinition(), isUserProvided(),
   unless(anyOf(
-  isExpansionInSystemHeader(), isVirtual(), isStatic(),
+  isExpansionInSystemHeader(), isVirtual(), isStaticStorageClass(),
   hasTrivialBody(), isOverloadedOperator(), cxxConstructorDecl(),
   cxxDestructorDecl(), cxxConversionDecl(), isTemplate(),
   isDependentContext(),
diff --git 
a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
index d42fcba70e81b4..adf4584e75f9e5 100644
--- a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
@@ -11,14 +11,12 @@
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
-
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, hasTrivialBody) { return Node.hasTriv

[clang] [clang-tools-extra] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti updated 
https://github.com/llvm/llvm-project/pull/120027

>From 35a1cecb08d1827fb45c2e6bb06983ed363ca769 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Mon, 16 Dec 2024 01:18:06 +0100
Subject: [PATCH] [ASTMatchers] fix `isStaticStorageClass` not matching
 definitions of forward declared functions

```c++
static void foo();
void foo() {}

struct A {
static void bar();
};
void A::bar() {}
```

Both definitions refer to their previous declaration, but were not
considered `static`, because the matcher did not check the canonical
declaration.
---
 .../clang-tidy/bugprone/VirtualNearMissCheck.cpp | 7 +++
 .../readability/ConvertMemberFunctionsToStatic.cpp   | 6 ++
 .../readability/MakeMemberFunctionConstCheck.cpp | 9 -
 .../readability/StaticAccessedThroughInstanceCheck.cpp   | 8 ++--
 clang/docs/LibASTMatchersReference.html  | 4 +++-
 clang/docs/ReleaseNotes.rst  | 3 +++
 clang/include/clang/ASTMatchers/ASTMatchers.h| 6 --
 clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | 8 
 8 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
index 76fa2d916f0e86..c83c175ce4bdd5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -17,8 +18,6 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::bugprone {
 
 namespace {
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
   return Node.isOverloadedOperator();
 }
@@ -216,8 +215,8 @@ void VirtualNearMissCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   cxxMethodDecl(
   unless(anyOf(isOverride(), isImplicit(), cxxConstructorDecl(),
-   cxxDestructorDecl(), cxxConversionDecl(), isStatic(),
-   isOverloadedOperator(
+   cxxDestructorDecl(), cxxConversionDecl(),
+   isStaticStorageClass(), isOverloadedOperator(
   .bind("method"),
   this);
 }
diff --git 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
index 1284df6bd99cfd..42fc9d36ac41d1 100644
--- 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
@@ -11,15 +11,13 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
-
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, hasTrivialBody) { return Node.hasTrivialBody(); }
 
 AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
@@ -79,7 +77,7 @@ void 
ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
   cxxMethodDecl(
   isDefinition(), isUserProvided(),
   unless(anyOf(
-  isExpansionInSystemHeader(), isVirtual(), isStatic(),
+  isExpansionInSystemHeader(), isVirtual(), isStaticStorageClass(),
   hasTrivialBody(), isOverloadedOperator(), cxxConstructorDecl(),
   cxxDestructorDecl(), cxxConversionDecl(), isTemplate(),
   isDependentContext(),
diff --git 
a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
index d42fcba70e81b4..adf4584e75f9e5 100644
--- a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
@@ -11,14 +11,12 @@
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::readability {
-
-AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
-
 AST_MATCHER(CXXMethodDecl, hasTrivialBody) { return Node.hasTrivialBody(); }
 
 AST_MATCHER(CXXRecordDecl, hasAnyDependentBases) {
@@ -222,8 +220,9 @@ void 
MakeMemberFunctionConstCheck::registerMatchers(MatchFinder *Finder) {
   isDefin

[clang] [clang-tools-extra] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits

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


[clang-tools-extra] [clang-tidy][docs] improve documentation on cppcoreguidelines-narrowing-conversions (#111510) (PR #118209)

2024-12-15 Thread Jonas Toth via cfe-commits

https://github.com/JonasToth updated 
https://github.com/llvm/llvm-project/pull/118209

>From f7f570b3fa5a96cd3eb140abd02e4351a4586e26 Mon Sep 17 00:00:00 2001
From: Jonas Toth 
Date: Sun, 1 Dec 2024 12:02:13 +0100
Subject: [PATCH] [clang-tidy][docs] improve documentation on
 cppcoreguidelines-narrowing-conversions (#111510)

---
 .../narrowing-conversions.rst | 34 +++
 1 file changed, 34 insertions(+)

diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
index 04260e75aa558f..7cc0b2809b4589 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
@@ -27,6 +27,40 @@ This check will flag:
  - All applications of binary operators with a narrowing conversions.
For example: ``int i; i+= 0.1;``.
 
+Arithmetic with smaller integer types than ``int`` trigger implicit 
conversions,
+as explained under `"Integral Promotion" on cppreference.com
+`_.
+This check diagnoses more instances of narrowing than the compiler warning
+`-Wconversion` does. The example below demonstrates this behavior.
+
+.. code-block:: c++
+
+   // The following function definition demonstrates usage of arithmetic with
+   // integer types smaller than `int` and how the narrowing conversion happens
+   // implicitly.
+   void computation(short argument1, short argument2) {
+ // Arithmetic written by humans:
+ short result = argument1 + argument2;
+ // Arithmetic actually performed by C++:
+ short result = static_cast(static_cast(argument1) + 
static_cast(argument2));
+   }
+
+   void recommended_resolution(short argument1, short argument2) {
+ short result = argument1 + argument2;
+ //   ^ warning: narrowing conversion from 'int' to signed type 
'short' is implementation-defined
+
+ // The cppcoreguidelines recommend to resolve this issue by using the GSL
+ // in one of two ways. Either by a cast that throws if a loss of precision
+ // would occur.
+ short result = gsl::narrow(argument1 + argument2);
+ // Or it can be resolved without checking the result risking invalid 
results.
+ short result = gsl::narrow_cast(argument1 + argument2);
+
+ // A classical `static_cast` will silence the warning as well if the GSL
+ // is not available.
+ short result = static_cast(argument1 + argument2);
+   }
+
 
 Options
 ---

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


[clang-tools-extra] [clang-tidy][docs] improve documentation on cppcoreguidelines-narrowing-conversions (#111510) (PR #118209)

2024-12-15 Thread Jonas Toth via cfe-commits


@@ -27,6 +27,39 @@ This check will flag:
  - All applications of binary operators with a narrowing conversions.
For example: ``int i; i+= 0.1;``.
 
+Arithmetic with smaller integer types than ``int`` trigger implicit 
conversions,
+as explained under `"Integral Promotion" on cppreference.com
+`_.
+This check diagnoses more instances of narrowing than the compiler warning
+`-Wconversion` does. The example below demonstrates this behavior.
+
+.. code-block:: c++
+
+   // The following function definition demonstrates usage of arithmetic with
+   // integer types smaller than `int` and how the narrowing conversion happens
+   // implicitly.
+   void computation(short argument1, short argument2) {
+ // Arithmetic written by humans:
+ short result = argument1 + argument2;
+ // Arithmetic actually performed by C++:
+ short result = static_cast(static_cast(argument1) + 
static_cast(argument2));
+   }
+
+   void recommended_resolution(short argument1, short argument2) {
+ short result = argument1 + argument2;
+ //   ^ warning: narrowing conversion from 'int' to signed type 
'short' is implementation-defined
+
+ // The recommended way to resolve this issue with the GSL is one of two 
ways.
+ // Either by a cast that throws if a loss of precision would occur.

JonasToth wrote:

Updated.

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


[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-15 Thread Nico Weber via cfe-commits

nico wrote:

This broke Linux/dn_expand.cpp on our bots, see 
https://issues.chromium.org/issues/384188036

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


[clang] [llvm] [AArch64] Implement intrinsics for SME FP8 FMLAL/FMLALL (Indexed) (PR #118549)

2024-12-15 Thread via cfe-commits

https://github.com/SpencerAbson updated 
https://github.com/llvm/llvm-project/pull/118549

>From 411f907b30b75e55db27b9259b2eb9b2077d388d Mon Sep 17 00:00:00 2001
From: Spencer Abson 
Date: Mon, 25 Nov 2024 21:47:20 +
Subject: [PATCH 1/3] [AArch64] Implement intrinsics for SME FP8 FMOPA

---
 llvm/include/llvm/IR/IntrinsicsAArch64.td | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td 
b/llvm/include/llvm/IR/IntrinsicsAArch64.td
index 54a88bac2fb4be..8d337694b6bc5f 100644
--- a/llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -2983,6 +2983,13 @@ let TargetPrefix = "aarch64" in {
LLVMMatchType<0>,
llvm_anyvector_ty], [ImmArg>]>;
 
+  class SME_FP8_OuterProduct_Intrinsic
+  : DefaultAttrsIntrinsic<[],
+  [llvm_i32_ty,
+   llvm_nxv16i1_ty, llvm_nxv16i1_ty,
+   llvm_nxv16i8_ty, llvm_nxv16i8_ty],
+  [ImmArg>, IntrInaccessibleMemOnly, IntrHasSideEffects]>;
+
   def int_aarch64_sme_mopa : SME_OuterProduct_Intrinsic;
   def int_aarch64_sme_mops : SME_OuterProduct_Intrinsic;
 
@@ -2998,6 +3005,10 @@ let TargetPrefix = "aarch64" in {
   def int_aarch64_sme_usmopa_wide : SME_OuterProduct_Intrinsic;
   def int_aarch64_sme_usmops_wide : SME_OuterProduct_Intrinsic;
 
+  // FP8 outer product
+  def int_aarch64_sme_fp8_fmopa_za16 : SME_FP8_OuterProduct_Intrinsic;
+  def int_aarch64_sme_fp8_fmopa_za32 : SME_FP8_OuterProduct_Intrinsic;
+
   class SME_AddVectorToTile_Intrinsic
   : DefaultAttrsIntrinsic<[],
   [llvm_i32_ty,

>From 5a2ccfce643ed2c557c8fe7608b2643ec9aeaab0 Mon Sep 17 00:00:00 2001
From: Spencer Abson 
Date: Tue, 3 Dec 2024 18:27:06 +
Subject: [PATCH 2/3] [AArch64] Implement intrinsics for SME FP8 FMLAL/FMLALL

---
 clang/include/clang/Basic/arm_sme.td  |  16 ++
 .../fp8-intrinsics/acle_sme2_fp8_mla.c| 128 +++
 .../acle_sme2_fp8_imm.c   |  34 +++
 .../aarch64-fp8-intrinsics/acle_sme_fp8_mla.c |  26 +++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  75 +--
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  45 ++--
 llvm/lib/Target/AArch64/SMEInstrFormats.td| 211 +-
 .../AArch64/sme2-fp8-intrinsics-mla.ll| 116 ++
 8 files changed, 503 insertions(+), 148 deletions(-)
 create mode 100644 
clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_mla.c
 create mode 100644 clang/test/Sema/aarch64-fp8-intrinsics/acle_sme_fp8_mla.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-fp8-intrinsics-mla.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 71b2c7cdd04f93..d3fb9de0b71070 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -827,11 +827,27 @@ let SMETargetGuard = "sme-lutv2" in {
 let SMETargetGuard = "sme-f8f32" in {
   def SVMOPA_FP8_ZA32 : Inst<"svmopa_za32[_mf8]_m_fpm", "viPPdd>", "m", 
MergeNone, "aarch64_sme_fp8_fmopa_za32",
  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<0, ImmCheck0_3>]>;
+
+  // FMLALL (indexed)
+  def SVMLA_FP8_ZA32_VG4x1 : Inst<"svmla_lane_za32[_mf8]_vg4x1_fpm", "vmddi>", 
"m", MergeNone, "aarch64_sme_fp8_fmlall_lane_za32_vg4x1",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA32_VG4x2 : Inst<"svmla_lane_za32[_mf8]_vg4x2_fpm", "vm2di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlall_lane_za32_vg4x2",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA16_VG4x4 : Inst<"svmla_lane_za32[_mf8]_vg4x4_fpm", "vm4di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlall_lane_za32_vg4x4",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
 }
 
 let SMETargetGuard = "sme-f8f16" in {
   def SVMOPA_FP8_ZA16 : Inst<"svmopa_za16[_mf8]_m_fpm", "viPPdd>", "m", 
MergeNone, "aarch64_sme_fp8_fmopa_za16",
  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<0, ImmCheck0_1>]>;
+
+  // FMLAL (indexed)
+  def SVMLA_FP8_ZA16_VG2x1 : Inst<"svmla_lane_za16[_mf8]_vg2x1_fpm", "vmddi>", 
"m", MergeNone, "aarch64_sme_fp8_fmlal_lane_za16_vg2x1",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA16_VG2x2 : Inst<"svmla_lane_za16[_mf8]_vg2x2_fpm", "vm2di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlal_lane_za16_vg2x2",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]>;
+  def SVMLA_FP8_ZA16_VG2x4 : Inst<"svmla_lane_za16[_mf8]_vg2x4_fpm", "vm4di>", 
"m", MergeNone, "aarch64_sme_fp8_fmlal_lane_za16_vg2x4",
+  [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<3, ImmCheck0_15>]

[clang] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits

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


[clang] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti updated 
https://github.com/llvm/llvm-project/pull/120027

>From 07dd31ddd40cdb792d33fc3394f6356de029a137 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Mon, 16 Dec 2024 01:28:42 +0100
Subject: [PATCH] [ASTMatchers] fix `isStaticStorageClass` not matching
 definitions of forward declared functions

```c++
static void foo();
void foo() {}

struct A {
static void bar();
};
void A::bar() {}
```

Both definitions refer to their previous declaration, but were not
considered `static`, because the matcher did not check the canonical
declaration.
---
 clang/docs/LibASTMatchersReference.html  | 4 +++-
 clang/docs/ReleaseNotes.rst  | 3 +++
 clang/include/clang/ASTMatchers/ASTMatchers.h| 6 --
 clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | 8 
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index f18e9cf1341696..fe24bd3ab9a0cd 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -4683,8 +4683,10 @@ Narrowing Matchers
   static int i = 0;
   extern int j;
   int k;
+  static void l();
+  void l() {}
 functionDecl(isStaticStorageClass())
-  matches the function declaration f.
+  matches the function declaration of f and l, and the definition of l.
 varDecl(isStaticStorageClass())
   matches the variable declaration i.
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index befa411e882b4c..66d3cd6b53c7eb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1041,6 +1041,9 @@ AST Matchers
 
 - Ensure ``pointee`` matches Objective-C pointer types.
 
+- Fixed `isStaticStorageClass` not matching the definition if the definition 
was
+  not marked `static` as well.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 897aa25dc95cc1..e7ab6c184349e4 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -5418,15 +5418,17 @@ AST_POLYMORPHIC_MATCHER(isExternC, 
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
 ///   static int i = 0;
 ///   extern int j;
 ///   int k;
+///   static void l();
+///   void l() {}
 /// \endcode
 /// functionDecl(isStaticStorageClass())
-///   matches the function declaration f.
+///   matches the function declaration of f and l, and the definition of l.
 /// varDecl(isStaticStorageClass())
 ///   matches the variable declaration i.
 AST_POLYMORPHIC_MATCHER(isStaticStorageClass,
 AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
 VarDecl)) {
-  return Node.getStorageClass() == SC_Static;
+  return Node.getCanonicalDecl()->getStorageClass() == SC_Static;
 }
 
 /// Matches deleted function declarations.
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 056b7c7b571ef4..f1efba5b0650fa 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1826,6 +1826,14 @@ TEST_P(ASTMatchersTest, IsStaticStorageClass) {
   EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("extern int i;", varDecl(isStaticStorageClass(;
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass(;
+
+  if (!GetParam().isCXX())
+return;
+
+  EXPECT_TRUE(matches("static void foo(); void foo() {}",
+  functionDecl(isDefinition(), isStaticStorageClass(;
+  EXPECT_TRUE(matches("struct A { static void bar(); }; void A::bar() {}",
+  cxxMethodDecl(isDefinition(), isStaticStorageClass(;
 }
 
 TEST_P(ASTMatchersTest, IsDefaulted) {

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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti commented:

> Not sure how many more tests I should add, since this uses the same code 
> paths as free functions.

I think the amount of tests you've added are enough

> This is the 5th instance of the `isStatic` matcher in clang-tidy.

Good point, thanks. I've checked to see if they could be replaced with 
`isStaticStorageClass`, but that won't work due to #120027, and the matcher has 
to be modified further by (IMO) overloading on `CXXMethodDecl` to use 
`isStatic` like these matchers, instead of the storage class alone. You can 
just keep it as-is.

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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits

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


[clang] [ASTMatchers] fix `isStaticStorageClass` not matching definitions of forward declared functions (PR #120027)

2024-12-15 Thread Julian Schmidt via cfe-commits

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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits


@@ -104,14 +104,16 @@ AST_MATCHER_FUNCTION_P(StatementMatcher,
 hasArgument(0, hasType(ReceiverType);
 }
 
+AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
+
 AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
   // Only allow initialization of a const reference from a free function if it
   // has no arguments. Otherwise it could return an alias to one of its
   // arguments and the arguments need to be checked for const use as well.
   return callExpr(callee(functionDecl(returns(hasCanonicalType(
   matchers::isReferenceToConst(
  .bind(FunctionDeclId)),
-  argumentCountIs(0), unless(callee(cxxMethodDecl(
+  argumentCountIs(0), 
unless(callee(cxxMethodDecl(unless(isStatic())

5chmidti wrote:

Please change `of a free function` to `from a call to a free function or static 
member function` in the comment above.

You can also move the check for the method and static inward:
```
callExpr(callee(functionDecl(returns(hasCanonicalType(matchers::isReferenceToConst())),
 
 unless(cxxMethodDecl(unless(isStatic()
 .bind(FunctionDeclId)),
  argumentCountIs(0))
```

Unrelated to this PR, but if you reorder anyway: please move the 
`argumentCountIs` to the front inside `callExpr`.

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


[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-15 Thread Shilei Tian via cfe-commits

shiltian wrote:

gentle ping

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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Julian Schmidt via cfe-commits

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


[clang] [webkit.UncountedLambdaCapturesChecker] Add a fallback for checking lambda captures (PR #119800)

2024-12-15 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building 
`clang` at step 7 "Add check check-offload".

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


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

```
Step 7 (Add check check-offload) failure: test (failure)
 TEST 'libomptarget :: amdgcn-amd-amdhsa :: 
sanitizer/use_after_free_2.c' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
  -fopenmp-targets=amdgcn-amd-amdhsa -O3 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/sanitizer/use_after_free_2.c
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/sanitizer/Output/use_after_free_2.c.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
 -fopenmp-targets=amdgcn-amd-amdhsa -O3 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/sanitizer/use_after_free_2.c
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/sanitizer/Output/use_after_free_2.c.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
# RUN: at line 3
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/not 
--crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/sanitizer/Output/use_after_free_2.c.tmp
 2>&1 | 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/sanitizer/use_after_free_2.c
 --check-prefixes=CHECK
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/not 
--crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/sanitizer/Output/use_after_free_2.c.tmp
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/sanitizer/use_after_free_2.c
 --check-prefixes=CHECK
# .---command stderr
# | 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/sanitizer/use_after_free_2.c:25:11:
 error: CHECK: expected string not found in input
# | // CHECK: OFFLOAD ERROR: Memory access fault by GPU {{.*}} (agent 0x{{.*}}) 
at virtual address [[PTR:0x[0-9a-z]*]]. Reasons: {{.*}}
# |   ^
# | :1:1: note: scanning from here
# | AMDGPU error: Error in hsa_amd_memory_pool_allocate: 
HSA_STATUS_ERROR_OUT_OF_RESOURCES: The runtime failed to allocate the neces

[clang] [compiler-rt] Move interceptors for libresolv functions to MSan (PR #119071)

2024-12-15 Thread Aaron Puchert via cfe-commits

aaronpuchert wrote:

@nico, could you provide some more information? This didn't break on the 
lab.llvm.org infrastructure, and I'm not sure what's different in your build. 
Locally I also used a Release build with assertions on x86_64 on Linux.

For what it's worth, the change simply moves the interceptors, and it should 
still unpoison for the length of the string plus one. So I'm not sure why the 
last byte of the string is poisoned for you.

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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Barnabás Pőcze via cfe-commits

https://github.com/pobrn updated 
https://github.com/llvm/llvm-project/pull/119974

From fcacca26be4350d005c08a781bf4cee29abb404e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= 
Date: Sat, 14 Dec 2024 16:57:57 +0100
Subject: [PATCH] [clang-tidy] performance-unnecessary-copy-initialization:
 Consider static functions

Static member functions can be considered the same way
as free functions are, so do that.
---
 .../UnnecessaryCopyInitialization.cpp |  6 +++--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 
 .../unnecessary-copy-initialization.cpp   | 24 +++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index 034894c11bf2c0..f63be0d33bf0a8 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -104,6 +104,8 @@ AST_MATCHER_FUNCTION_P(StatementMatcher,
 hasArgument(0, hasType(ReceiverType);
 }
 
+AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
+
 AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
   // Only allow initialization of a const reference from a free function if it
   // has no arguments. Otherwise it could return an alias to one of its
@@ -111,7 +113,7 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningFunctionCall) {
   return callExpr(callee(functionDecl(returns(hasCanonicalType(
   matchers::isReferenceToConst(
  .bind(FunctionDeclId)),
-  argumentCountIs(0), unless(callee(cxxMethodDecl(
+  argumentCountIs(0), 
unless(callee(cxxMethodDecl(unless(isStatic())
   .bind(InitFunctionCallId);
 }
 
@@ -232,7 +234,7 @@ 
UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
   Options.get("ExcludedContainerTypes", ""))) {}
 
 void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
-  auto LocalVarCopiedFrom = [this](const internal::Matcher &CopyCtorArg) 
{
+  auto LocalVarCopiedFrom = [this](const ast_matchers::internal::Matcher 
&CopyCtorArg) {
 return compoundStmt(
forEachDescendant(
declStmt(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6803842106791b..ca60cfacc55e3d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -332,6 +332,10 @@ Changes in existing checks
   ` check to
   validate ``namespace`` aliases.
 
+- Improved :doc:`performance-unnecessary-copy-initialization`
+   check
+  to consider static member functions the same way as free functions.
+
 Removed checks
 ^^
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index d02bb98cf583cb..b5325776f54c61 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -28,6 +28,8 @@ struct ExpensiveToCopyType {
   template 
   const A &templatedAccessor() const;
   operator int() const; // Implicit conversion to int.
+
+  static const ExpensiveToCopyType &instance();
 };
 
 template 
@@ -100,6 +102,28 @@ void PositiveFunctionCall() {
   VarCopyConstructed.constMethod();
 }
 
+void PositiveStaticMethodCall() {
+  const auto AutoAssigned = ExpensiveToCopyType::instance();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoAssigned' is copy-constructed from a const reference; consider making it a 
const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveToCopyType::instance();
+  AutoAssigned.constMethod();
+
+  const auto AutoCopyConstructed(ExpensiveToCopyType::instance());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoCopyConstructed'
+  // CHECK-FIXES: const auto& 
AutoCopyConstructed(ExpensiveToCopyType::instance());
+  AutoCopyConstructed.constMethod();
+
+  const ExpensiveToCopyType VarAssigned = ExpensiveToCopyType::instance();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarAssigned'
+  // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = 
ExpensiveToCopyType::instance();
+  VarAssigned.constMethod();
+
+  const ExpensiveToCopyType 
VarCopyConstructed(ExpensiveToCopyType::instance());
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarCopyConstructed'
+  // CHECK-FIXES: const ExpensiveToCopyType& 
VarCopyConstructed(ExpensiveT

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Barnabás Pőcze via cfe-commits

https://github.com/pobrn updated 
https://github.com/llvm/llvm-project/pull/119974

From e9cd529ef486df9b5279aef974f136c63cb367ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= 
Date: Sat, 14 Dec 2024 16:57:57 +0100
Subject: [PATCH] [clang-tidy] performance-unnecessary-copy-initialization:
 Consider static functions

Static member functions can be considered the same way
as free functions are, so do that.
---
 .../UnnecessaryCopyInitialization.cpp |  6 +++--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 
 .../unnecessary-copy-initialization.cpp   | 24 +++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index 034894c11bf2c0..f63be0d33bf0a8 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -104,6 +104,8 @@ AST_MATCHER_FUNCTION_P(StatementMatcher,
 hasArgument(0, hasType(ReceiverType);
 }
 
+AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
+
 AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
   // Only allow initialization of a const reference from a free function if it
   // has no arguments. Otherwise it could return an alias to one of its
@@ -111,7 +113,7 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningFunctionCall) {
   return callExpr(callee(functionDecl(returns(hasCanonicalType(
   matchers::isReferenceToConst(
  .bind(FunctionDeclId)),
-  argumentCountIs(0), unless(callee(cxxMethodDecl(
+  argumentCountIs(0), 
unless(callee(cxxMethodDecl(unless(isStatic())
   .bind(InitFunctionCallId);
 }
 
@@ -232,7 +234,7 @@ 
UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
   Options.get("ExcludedContainerTypes", ""))) {}
 
 void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
-  auto LocalVarCopiedFrom = [this](const internal::Matcher &CopyCtorArg) 
{
+  auto LocalVarCopiedFrom = [this](const ast_matchers::internal::Matcher 
&CopyCtorArg) {
 return compoundStmt(
forEachDescendant(
declStmt(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6803842106791b..d26a6c1a8061d6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -307,6 +307,10 @@ Changes in existing checks
   ` check to fix a crash when
   an argument type is declared but not defined.
 
+- Improved :doc:`performance-unnecessary-copy-initialization`
+   check
+  to consider static member functions the same way as free functions.
+
 - Improved :doc:`readability-container-contains
   ` check to let it work on
   any class that has a ``contains`` method. Fix some false negatives in the
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index d02bb98cf583cb..b5325776f54c61 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -28,6 +28,8 @@ struct ExpensiveToCopyType {
   template 
   const A &templatedAccessor() const;
   operator int() const; // Implicit conversion to int.
+
+  static const ExpensiveToCopyType &instance();
 };
 
 template 
@@ -100,6 +102,28 @@ void PositiveFunctionCall() {
   VarCopyConstructed.constMethod();
 }
 
+void PositiveStaticMethodCall() {
+  const auto AutoAssigned = ExpensiveToCopyType::instance();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoAssigned' is copy-constructed from a const reference; consider making it a 
const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveToCopyType::instance();
+  AutoAssigned.constMethod();
+
+  const auto AutoCopyConstructed(ExpensiveToCopyType::instance());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoCopyConstructed'
+  // CHECK-FIXES: const auto& 
AutoCopyConstructed(ExpensiveToCopyType::instance());
+  AutoCopyConstructed.constMethod();
+
+  const ExpensiveToCopyType VarAssigned = ExpensiveToCopyType::instance();
+  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 
'VarAssigned'
+  // CHECK-FIXES:   const ExpensiveToCopyType& VarAssigned = 
ExpensiveToCopyType::instance();
+  VarAssigned.constMethod();
+
+  const ExpensiveToCopyType 
VarCopyConstructed(ExpensiveToCopyType::instance());
+  // CHECK-MESSAGES: 

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2024-12-15 Thread Barnabás Pőcze via cfe-commits

pobrn wrote:

> Please mention changes in Release Notes.

Sorry, I hope it is fixed now.

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


[clang] [llvm] [RISC-V] Add support for MIPS P8700 CPU (PR #117865)

2024-12-15 Thread Jessica Clarke via cfe-commits


@@ -78,6 +78,19 @@ def GENERIC_RV64 : RISCVProcessorModel<"generic-rv64",
 // to change to the appropriate rv32/rv64 version.
 def GENERIC : RISCVTuneProcessorModel<"generic", NoSchedModel>, 
GenericTuneInfo;
 
+def MIPS_P8700 : RISCVProcessorModel<"mips-p8700",
+ MIPSP8700Model,
+ [Feature64Bit,
+  FeatureStdExtI,
+  FeatureStdExtM,
+  FeatureStdExtA,

jrtc27 wrote:

Yeah, if you're only implementing AMOs through trap-and-emulate then there's 
really little point telling software they exist. LR/SC will be orders of 
magnitude faster. You don't have an RV64GCZba_Zbb core, you have an 
RV64IMFDCZba_Zbb_Zalrsc core, and bodge in Zaamo in order to emulate being able 
to run RV64GC software. But claiming RV64GCZba_Zbb is just misleading to 
software, it'll perform atrociously if it's actually using atomics.

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


[clang-tools-extra] [clang-tidy] fix cppcoreguidelines-narrowing-conversions false positives when narrowing integer to signed integer in C++20 (PR #116591)

2024-12-15 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

The move to bugprone makes sense to me. 

However, I'm not sure that conversions of integers to signed integers should be 
ignored-by-default since C++20. It may be well-defined behavior w.r.t. the 
resulting value, but the pattern is still prone to bugs. You will get a 
well-defined wrong value from C++20 on, instead of an implementation-defined 
wrong value.

---

> 1. really implement defined behavior -> The above example about float to 
> unsigned
For the first level, we emit warning for explicit and implicit cast.

That sounds like a good idea.

> 2. standard implement defined behavior but at least gcc and clang in each 
> target has same behavior <- default

... and MSVC, and NVCC? I'd drop condition on the compilers behaving the same 
for targets. All implementation-defined behavior according to the standard 
sounds better than only those that are not agreed upon. There are also 
downstream versions of compilers for a few architectures (e.g., 
microcontrollers), and those may or may not follow the practice of their 
upstream counterparts (different targets).

> 3. most strictly check according to cppcodingguideline. <- create alias in 
> this level

I think that the bugprone check should also detect narrowing conversions for 
well-defined conversions because the check is primarily about loosing 
information (in my opinion), not that these narrowing conversions are 
implementation defined. Though that is also a core part of this check.

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


[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-15 Thread Owen Pan via cfe-commits

owenca wrote:

You should add unit tests in `clang/unittests/Format/`.

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


[clang-tools-extra] [clang-tidy][docs] improve documentation on cppcoreguidelines-narrowing-conversions (#111510) (PR #118209)

2024-12-15 Thread Jonas Toth via cfe-commits

https://github.com/JonasToth updated 
https://github.com/llvm/llvm-project/pull/118209

>From f4345664e10ac6a9e87b33b1e816b685a1355bb6 Mon Sep 17 00:00:00 2001
From: Jonas Toth 
Date: Sun, 1 Dec 2024 12:02:13 +0100
Subject: [PATCH 1/2] [clang-tidy][docs] improve documentation on
 cppcoreguidelines-narrowing-conversions (#111510)

---
 .../narrowing-conversions.rst | 33 +++
 1 file changed, 33 insertions(+)

diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
index 04260e75aa558f..6b0c3187b40874 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
@@ -27,6 +27,39 @@ This check will flag:
  - All applications of binary operators with a narrowing conversions.
For example: ``int i; i+= 0.1;``.
 
+Arithmetic with smaller integer types than ``int`` trigger implicit 
conversions,
+as explained under `"Integral Promotion" on cppreference.com
+`_.
+This check diagnoses more instances of narrowing than the compiler warning
+`-Wconversion` does. The example below demonstrates this behavior.
+
+.. code-block:: c++
+
+   // The following function definition demonstrates usage of arithmetic with
+   // integer types smaller than `int` and how the narrowing conversion happens
+   // implicitly.
+   void computation(short argument1, short argument2) {
+ // Arithmetic written by humans:
+ short result = argument1 + argument2;
+ // Arithmetic actually performed by C++:
+ short result = static_cast(static_cast(argument1) + 
static_cast(argument2));
+   }
+
+   void recommended_resolution(short argument1, short argument2) {
+ short result = argument1 + argument2;
+ //   ^ warning: narrowing conversion from 'int' to signed type 
'short' is implementation-defined
+
+ // The recommended way to resolve this issue with the GSL is one of two 
ways.
+ // Either by a cast that throws if a loss of precision would occur.
+ short result = gsl::narrow(argument1 + argument2);
+ // Or it can be resolved without checking the result.
+ short result = gsl::narrow_cast(argument1 + argument2);
+
+ // A classical `static_cast` will silence the warning as well if the GSL
+ // is not available.
+ short result = static_cast(argument1 + argument2);
+   }
+
 
 Options
 ---

>From 6d8b442137a175c854190e780d2faf6b6976323e Mon Sep 17 00:00:00 2001
From: Jonas Toth 
Date: Sun, 15 Dec 2024 18:38:57 +0100
Subject: [PATCH 2/2] fixup! [clang-tidy][docs] improve documentation on
 cppcoreguidelines-narrowing-conversions (#111510)

---
 .../checks/cppcoreguidelines/narrowing-conversions.rst | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
index 6b0c3187b40874..7cc0b2809b4589 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
@@ -49,10 +49,11 @@ This check diagnoses more instances of narrowing than the 
compiler warning
  short result = argument1 + argument2;
  //   ^ warning: narrowing conversion from 'int' to signed type 
'short' is implementation-defined
 
- // The recommended way to resolve this issue with the GSL is one of two 
ways.
- // Either by a cast that throws if a loss of precision would occur.
+ // The cppcoreguidelines recommend to resolve this issue by using the GSL
+ // in one of two ways. Either by a cast that throws if a loss of precision
+ // would occur.
  short result = gsl::narrow(argument1 + argument2);
- // Or it can be resolved without checking the result.
+ // Or it can be resolved without checking the result risking invalid 
results.
  short result = gsl::narrow_cast(argument1 + argument2);
 
  // A classical `static_cast` will silence the warning as well if the GSL

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


  1   2   >