[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

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

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


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

2025-05-04 Thread Brad Smith via cfe-commits

brad0 wrote:

@mshockwave 

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-05-04 Thread via cfe-commits

cor3ntin wrote:

@ldionne @erichkeane are you happy with a follow-up pr (within a few days of 
landing this) ?

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


[clang] f35e172 - [clang] Document -fstrict-flex-arrays option (#138388)

2025-05-04 Thread via cfe-commits

Author: serge-sans-paille
Date: 2025-05-04T08:17:51Z
New Revision: f35e172833f1bdd502e2847e13c3a58430bc654b

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

LOG: [clang] Document -fstrict-flex-arrays option (#138388)

Fix #138185

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2946ffaa28da0..11677626dbf1f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1554,7 +1554,11 @@ def fstrict_flex_arrays_EQ : Joined<["-"], 
"fstrict-flex-arrays=">, Group,
   NormalizedValuesScope<"LangOptions::StrictFlexArraysLevelKind">,
   NormalizedValues<["Default", "OneZeroOrIncomplete", "ZeroOrIncomplete", 
"IncompleteOnly"]>,
-  HelpText<"Enable optimizations based on the strict definition of flexible 
arrays">,
+  HelpText<"Enable optimizations based on the strict definition of flexible 
arrays.">,
+  DocBrief<[{If  is equal to 0, any trailing array member is considered 
a flexible array.
+ If  is equal to 1, trailing array members of size 0, 1 or 
undefined are considered flexible arrays.
+ If  is equal to 2, trailing array members of size 0 or 
undefined are considered flexible arrays.
+ If  is equal to 3, only trailing array members of 
undefined size are considered flexible arrays.}]>,
   MarshallingInfoEnum, "Default">;
 defm apple_pragma_pack : BoolFOption<"apple-pragma-pack",
   LangOpts<"ApplePragmaPack">, DefaultFalse,



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


[clang] [clang] Document -fstrict-flex-arrays option (PR #138388)

2025-05-04 Thread via cfe-commits

https://github.com/serge-sans-paille closed 
https://github.com/llvm/llvm-project/pull/138388
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4e81ee4 - [Driver] Use AddRunTimeLibs on Solaris (#137596)

2025-05-04 Thread via cfe-commits

Author: Rainer Orth
Date: 2025-05-04T10:26:01+02:00
New Revision: 4e81ee4a158b7c8e4b468c9370abb042a59129b6

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

LOG: [Driver] Use AddRunTimeLibs on Solaris (#137596)

When linking `libomp.so` on Solaris, I encountered
```
clang: warning: argument unused during compilation: '-static-libgcc' 
[-Wunused-command-line-argument]

```
This happens because `Solaris.cpp` (`solaris::Linker::ConstructJob`)
links `-lgcc_s` and `-lgcc` on its own instead of using the common
`CommonArgs.cpp` (`tools::AddRunTimeLibs`) which handles
`-static-libgcc` out of the box.

This patch switches to `AddRunTimeLibs` and adds a test for
`-static-libgcc` handling. In `solaris-ld.c`, a few tests had to be
adjusted because `-lgcc` is now linked before `-lgcc_s`.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 639497b8fbad2..a066aeea7ff13 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -243,13 +243,10 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-latomic");
   addAsNeededOption(ToolChain, Args, CmdArgs, false);
 }
-addAsNeededOption(ToolChain, Args, CmdArgs, true);
-CmdArgs.push_back("-lgcc_s");
-addAsNeededOption(ToolChain, Args, CmdArgs, false);
+
+AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 CmdArgs.push_back("-lc");
-if (!Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-lgcc");
-}
+
 const SanitizerArgs &SA = ToolChain.getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(ToolChain, Args, CmdArgs);

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index ce0728d392bf2..9aa7ed760666d 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -20,10 +20,10 @@
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD: "-z" "ignore" "-latomic" "-z" "record"
 // CHECK-GLD: "--as-needed" "-latomic" "--no-as-needed"
+// CHECK-LD-SPARC32-SAME: "-lgcc"
 // CHECK-LD: "-z" "ignore" "-lgcc_s" "-z" "record"
 // CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
 // CHECK-LD-SPARC32-SAME: "-lc"
-// CHECK-LD-SPARC32-SAME: "-lgcc"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtend.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -42,9 +42,9 @@
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
 // CHECK-LD-SPARC64-NOT:  "-latomic"
+// CHECK-LD-SPARC64-SAME: "-lgcc"
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
-// CHECK-LD-SPARC64-SAME: "-lgcc"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtend.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crtn.o"
 
@@ -63,9 +63,9 @@
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
 // CHECK-LD-X32-NOT:  "-latomic"
+// CHECK-LD-X32-SAME: "-lgcc"
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
-// CHECK-LD-X32-SAME: "-lgcc"
 // CHECK-LD-X32-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtend.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -85,9 +85,9 @@
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
 // CHECK-LD-X64-NOT:  "-latomic"
+// CHECK-LD-X64-SAME: "-lgcc"
 // CHECK-LD-X64-SAME: "-lgcc_s"
 // CHECK-LD-X64-SAME: "-lc"
-// CHECK-LD-X64-SAME: "-lgcc"
 // CHECK-LD-X64-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtend.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crtn.o"
 
@@ -101,6 +101,15 @@
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
 
+/// Check that -static-libgcc is supported.
+// RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -static-libgcc \
+// RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefixes=CHECK-STATIC-LIBGCC %s
+// CHECK-STATIC-LIBGCC-NOT: warning: argument unused during compilation: 
'-static-libgcc'
+// CHECK-STATIC-LIBGCC: "-lgcc" "-lgcc_eh"
+// CHECK-STATIC-LIBGCC-NOT: "-lgcc_s"
+
 // Check that libm is only linked with clang++.
 // RUN: %c

[clang] [Driver] Use AddRunTimeLibs on Solaris (PR #137596)

2025-05-04 Thread Rainer Orth via cfe-commits

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

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

dtcxzyw wrote:

See also the response from the Clang Area Team: 
https://discourse.llvm.org/t/rfc-implement-gcc-bound-pmf-in-clang/85951/7.


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


[clang] [Driver] Use AddRunTimeLibs on Solaris (PR #137596)

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

llvm-ci wrote:

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

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[846/1365] Running the Clang regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using clang: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/clang
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find cir-opt in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find clang-repl in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/wasm-ld
-- Testing: 21397 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50
FAIL: Clang :: Driver/solaris-ld.c (11872 of 21397)
 TEST 'Clang :: Driver/solaris-ld.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/clang -### 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/solaris-ld.c
 --target=sparc-sun-solaris2.11 -fuse-ld=  
--sysroot=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree
 2>&1| 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/FileCheck 
--check-prefixes=CHECK-LD-SPARC32,CHECK-LD 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/solaris-ld.c
 # RUN: at line 5
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/FileCheck 
--check-prefixes=CHECK-LD-SPARC32,CHECK-LD 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/solaris-ld.c
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/bin/clang 
-### 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/solaris-ld.c
 --target=sparc-sun-solaris2.11 -fuse-ld= 
--sysroot=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/solaris-ld.c:23:27:
 error: CHECK-LD-SPARC32-SAME: expected string not found in input
// CHECK-LD-SPARC32-SAME: "-lgcc"
  ^
:6:1204: note: scanning from here
 "/usr/bin/ld" "-C" "-e" "_start" "-o" "a.out" 
"/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crt1.o"
 
"/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/lib/crti.o"
 
"/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-Xa.o"
 
"/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/lib/values-xpg6.o"
 
"/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/crtbegin.o"
 
"-L/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 
"-L/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 
"-L/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/solaris_sparc_tree/usr/lib"
 "/tmp/lit-tmp-6nxbljqh/solaris-ld-1824e4.o" "-z" "ignore" "-latomic" "-z" 
"record" 
"/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-tpbe6mpo/lib/clang/21/lib/sparc-sun-solaris2.11/libclang_rt.builtins.

[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)

2025-05-04 Thread via cfe-commits

https://github.com/ZhongUncle updated 
https://github.com/llvm/llvm-project/pull/132510

>From a6a1916aba2d6e42ab7d5f110752a36ecf3268e8 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738...@qq.com>
Date: Sat, 22 Mar 2025 11:29:20 +0800
Subject: [PATCH 1/7] Fixes #59819. The underlying problem was fixed in
 https://reviews.llvm.org/D142560, but this patch adds a proper regression
 test.

---
 .../test/clang-doc/comments-in-macros.cpp | 35 +++
 1 file changed, 35 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/comments-in-macros.cpp

diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp 
b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
new file mode 100644
index 0..5dbb20eca6ae1
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -0,0 +1,35 @@
+// Fixes #59819. The underlying problem was fixed in 
https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md 
--check-prefix=MD-MyClass-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MyClass-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MyClass
+
+#define DECLARE_METHODS   \
+/**  \
+ * @brief Declare a method to calculate the sum of two numbers\
+ */   \
+int Add(int a, int b) \
+{ \
+return a + b; \
+}
+
+// MD-MyClass: ### Add
+// MD-MyClass: *public int Add(int a, int b)*
+// MD-MyClass: **brief** Declare a method to calculate the sum of two numbers
+
+// HTML-MyClass: public int Add(int a, int b)
+// HTML-MyClass: brief
+// HTML-MyClass:  Declare a method to calculate the sum of two numbers
+
+
+class MyClass {
+public:
+// MD-MyClass-LINE: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp#[[@LINE+2]]*
+// HTML-MyClass-LINE: Defined at line [[@LINE+1]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp
+DECLARE_METHODS
+};
+
+

>From b15a9d0d97bacb6df133c3c4c5c1c090069672d2 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738...@qq.com>
Date: Sat, 22 Mar 2025 11:44:29 +0800
Subject: [PATCH 2/7] Fixes #59819. The underlying problem was fixed in
 https://reviews.llvm.org/D142560, but this patch adds a proper regression
 test.

---
 clang-tools-extra/test/clang-doc/comments-in-macros.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp 
b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
index 5dbb20eca6ae1..24ad21eff164d 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -1,9 +1,9 @@
 // Fixes #59819. The underlying problem was fixed in 
https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
-// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
 // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md 
--check-prefix=MD-MyClass-LINE
 // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MyClass
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
 // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MyClass-LINE
 // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MyClass
 

>From 2b6556e554f0245734c2cade64d23a849efe6176 Mon Sep 17 00:00:00 2001
From: Zhong Uncle <2020738...@qq.com>
Date: Sat, 22 Mar 2025 11:50:47 +0800
Subject: [PATCH 3/7] Fixes #59819. The underlying problem was fixed in
 https://reviews.llvm.org/D142560, but this patch adds a proper regression
 test.

---
 .../test/clang-doc/comments-in-macros.cpp | 25 +--
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp 
b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
index 24ad21eff164d..3273ddcd9c92c 100644
--- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp
@@ -1,11 +1,11 @@
 // Fixes #59819. The underlying problem was fixed in 
https://reviews.llvm.org/D142560, but this patch adds a proper regression test.
 // RUN: rm -rf %t && mk

[clang-tools-extra] [clang-doc] Add regression test for test comments in macros (PR #132510)

2025-05-04 Thread via cfe-commits


@@ -0,0 +1,35 @@
+// Regression test for https://github.com/llvm/llvm-project/issues/59819
+
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md 
--check-prefix=MD-MYCLASS-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS
+
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MYCLASS-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MYCLASS
+
+#define DECLARE_METHODS   \
+/**  \
+ * @brief Declare a method to calculate the sum of two numbers\
+ */   \
+int Add(int a, int b) {   \
+return a + b; \
+}
+
+// MD-MYCLASS: ### Add
+// MD-MYCLASS: *public int Add(int a, int b)*
+// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
+
+// HTML-MYCLASS: public int Add(int a, int b)
+// HTML-MYCLASS: brief
+// HTML-MYCLASS:  Declare a method to calculate the sum of two numbers
+
+
+class MyClass {
+public:
+// MD-MYCLASS-LINE: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp#[[@LINE+2]]*
+// HTML-MYCLASS-LINE: Defined at line [[@LINE+1]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp

ZhongUncle wrote:

> I'm fine w/ any of the above if the test passes.

OK, I update code and passed CI. Please check.



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


[clang] [Driver] Use AddRunTimeLibs on Solaris (PR #137596)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-win-x-aarch64` 
running on `as-builder-2` while building `clang` at step 10 "test-check-clang".

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


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

```
Step 10 (test-check-clang) failure: Test just built components: check-clang 
completed (failure)
 TEST 'Clang :: Driver/solaris-ld.c' FAILED 

Exit Code: 1

Command Output (stdout):
--
# RUN: at line 5
c:\buildbot\as-builder-2\x-aarch64\build\bin\clang.exe -### 
C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver\solaris-ld.c 
--target=sparc-sun-solaris2.11 -fuse-ld=  
--sysroot=C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver/Inputs/solaris_sparc_tree
 2>&1| c:\buildbot\as-builder-2\x-aarch64\build\bin\filecheck.exe 
--check-prefixes=CHECK-LD-SPARC32,CHECK-LD 
C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver\solaris-ld.c
# executed command: 'c:\buildbot\as-builder-2\x-aarch64\build\bin\clang.exe' 
'-###' 
'C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver\solaris-ld.c'
 --target=sparc-sun-solaris2.11 -fuse-ld= 
'--sysroot=C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver/Inputs/solaris_sparc_tree'
# executed command: 
'c:\buildbot\as-builder-2\x-aarch64\build\bin\filecheck.exe' 
--check-prefixes=CHECK-LD-SPARC32,CHECK-LD 
'C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver\solaris-ld.c'
# .---command stderr
# | 
C:\buildbot\as-builder-2\x-aarch64\llvm-project\clang\test\Driver\solaris-ld.c:23:27:
 error: CHECK-LD-SPARC32-SAME: expected string not found in input
# | // CHECK-LD-SPARC32-SAME: "-lgcc"
# |   ^
# | :7:1272: note: scanning from here
# |  "/usr/bin/ld" "-C" "-e" "_start" "-o" "a.out" 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2\\crt1.o"
 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\crti.o"
 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\values-Xa.o"
 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\values-xpg6.o"
 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2\\crtbegin.o"
 
"-LC:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 
"-LC:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 
"-LC:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib"
 
"C:\\Users\\buildbot\\AppData\\Local\\Temp\\lit-tmp-2yfvnayz\\solaris-ld-e0ad4a.o"
 "-z" "ignore" "-latomic" "-z" "record" 
"C:\\buildbot\\as-builder-2\\x-aarch64\\build\\lib\\clang\\21\\lib\\sparc-sun-solaris2.11\\libclang_rt.builtins.a"
 "-z" "ignore" "-lunwind" "-z" "record" "-lc" 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2\\crtend.o"
 
"C:\\buildbot\\as-builder-2\\x-aarch64\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\crtn.o"
# | 














   ^
# | :7:1427: note: possible intended match here
# |  "/usr/bin/ld" "-C" "-e" "_start" "-o"

[clang] [Clang][NFC] Use std::move for Detail in timeTraceMetadata (PR #138352)

2025-05-04 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.


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


[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)

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

https://github.com/dtcxzyw updated 
https://github.com/llvm/llvm-project/pull/137849

>From f1db3a540ec1383451955efab62b64ed8d180349 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Wed, 30 Apr 2025 01:26:41 +0800
Subject: [PATCH 1/4] [Clang][CodeGen] Check
 `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic`

---
 clang/lib/CodeGen/CGExprScalar.cpp   |  3 ++-
 .../test/CodeGen/catch-nullptr-and-nonzero-offset.c  | 12 
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 8dbbcdaef25d8..d214d2af52563 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
   else
 elemTy = CGF.ConvertTypeForMem(elementType);
 
-  if (CGF.getLangOpts().PointerOverflowDefined)
+  if (CGF.getLangOpts().PointerOverflowDefined ||
+  CGF.isUnderlyingBasePointerConstantNull(pointerOperand))
 return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
 
   return CGF.EmitCheckedInBoundsGEP(
diff --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index 63b6db2c2adeb..c5ae3f8bcc368 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -431,6 +431,18 @@ char *void_ptr(void *base, unsigned long offset) {
   return base + offset;
 }
 
+int *constant_null_add(long offset) {
+  // CHECK: define{{.*}} ptr @constant_null_add(i64 noundef %[[OFFSET:.*]])
+  // CHECK-NEXT: [[ENTRY:.*]]:
+  // CHECK-NEXT:   %[[OFFSET_ADDR:.*]] = alloca i64, align 8
+  // CHECK-NEXT:   store i64 %[[OFFSET]], ptr %[[OFFSET_ADDR]], align 8
+  // CHECK-NEXT:   %[[OFFSET_RELOADED:.*]] = load i64, ptr %[[OFFSET_ADDR]], 
align 8
+  // CHECK-NEXT:   %[[ADD_PTR:.*]] = getelementptr i32, ptr null, i64 
%[[OFFSET_RELOADED]]
+  // CHECK-NEXT:   ret ptr %[[ADD_PTR]]
+#line 1800
+  return (int *)0 + offset;
+}
+
 #ifdef __cplusplus
 }
 #endif

>From 2796472ca05332419cade01afbea08d8f9446d76 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Wed, 30 Apr 2025 14:48:54 +0800
Subject: [PATCH 2/4] [Clang][CodeGen] Re-enable ubsan check

---
 clang/lib/CodeGen/CGExprScalar.cpp|  3 +-
 .../catch-nullptr-and-nonzero-offset.c| 38 ++-
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index d214d2af52563..96e48d65e8ace 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4239,7 +4239,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
 elemTy = CGF.ConvertTypeForMem(elementType);
 
   if (CGF.getLangOpts().PointerOverflowDefined ||
-  CGF.isUnderlyingBasePointerConstantNull(pointerOperand))
+  (!CGF.SanOpts.has(SanitizerKind::PointerOverflow) &&
+   CGF.isUnderlyingBasePointerConstantNull(pointerOperand)))
 return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
 
   return CGF.EmitCheckedInBoundsGEP(
diff --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index c5ae3f8bcc368..338f85f2d2fbd 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
+// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow 
-fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void 
@__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow 
-fsanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu 
| FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow 
-fsanitize-trap=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
 
-// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
+// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
 // RUN: %clang_cc1 -x c++ -fsanitize=pointer-overflow 
-fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck 

[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `isNullPointerArithmeticExtension` (PR #137849)

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

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


[clang] [Driver] Use AddRunTimeLibs on Solaris (PR #137596)

2025-05-04 Thread Rainer Orth via cfe-commits

rorth wrote:

I suspect the `-static-libgcc` test needs `-rtlib=platform 
--unwindlib=platform` to pass on non-UNIX platforms.  However, I've no way of 
verifying that.  Can someone with access to either affected targets please try 
this?  Thanks.

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


[clang] [Driver] Use AddRunTimeLibs on Solaris (PR #137596)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-win-x-armv7l` 
running on `as-builder-1` while building `clang` at step 10 "test-check-clang".

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


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

```
Step 10 (test-check-clang) failure: Test just built components: check-clang 
completed (failure)
 TEST 'Clang :: Driver/solaris-ld.c' FAILED 

Exit Code: 1

Command Output (stdout):
--
# RUN: at line 5
c:\buildbot\as-builder-1\x-armv7l\build\bin\clang.exe -### 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver\solaris-ld.c 
--target=sparc-sun-solaris2.11 -fuse-ld=  
--sysroot=C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver/Inputs/solaris_sparc_tree
 2>&1| c:\buildbot\as-builder-1\x-armv7l\build\bin\filecheck.exe 
--check-prefixes=CHECK-LD-SPARC32,CHECK-LD 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver\solaris-ld.c
# executed command: 'c:\buildbot\as-builder-1\x-armv7l\build\bin\clang.exe' 
'-###' 
'C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver\solaris-ld.c' 
--target=sparc-sun-solaris2.11 -fuse-ld= 
'--sysroot=C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver/Inputs/solaris_sparc_tree'
# executed command: 'c:\buildbot\as-builder-1\x-armv7l\build\bin\filecheck.exe' 
--check-prefixes=CHECK-LD-SPARC32,CHECK-LD 
'C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver\solaris-ld.c'
# .---command stderr
# | 
C:\buildbot\as-builder-1\x-armv7l\llvm-project\clang\test\Driver\solaris-ld.c:23:27:
 error: CHECK-LD-SPARC32-SAME: expected string not found in input
# | // CHECK-LD-SPARC32-SAME: "-lgcc"
# |   ^
# | :7:1266: note: scanning from here
# |  "/usr/bin/ld" "-C" "-e" "_start" "-o" "a.out" 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2\\crt1.o"
 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\crti.o"
 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\values-Xa.o"
 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\values-xpg6.o"
 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2\\crtbegin.o"
 
"-LC:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 
"-LC:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 
"-LC:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib"
 
"C:\\buildbot\\as-builder-1\\x-armv7l\\build\\lit-tmp-wi232u31\\solaris-ld-0f784c.o"
 "-z" "ignore" "-latomic" "-z" "record" 
"C:\\buildbot\\as-builder-1\\x-armv7l\\build\\lib\\clang\\21\\lib\\sparc-sun-solaris2.11\\libclang_rt.builtins.a"
 "-z" "ignore" "-lunwind" "-z" "record" "-lc" 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2\\crtend.o"
 
"C:\\buildbot\\as-builder-1\\x-armv7l\\llvm-project\\clang\\test\\Driver/Inputs/solaris_sparc_tree/usr/lib\\crtn.o"
# | 














 ^
# | :7:1420: note: possible intended match here
# |  "/usr/bin/ld" "-C" "-e" "_start" "-o" "a.out" 
"C:\\buildbot\\as-b

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

2025-05-04 Thread via cfe-commits

https://github.com/charan-003 updated 
https://github.com/llvm/llvm-project/pull/117953

>From b886394f3aca3ea53f2c97d85a8e963d192c122f Mon Sep 17 00:00:00 2001
From: charan-003 <85248228+charan-...@users.noreply.github.com>
Date: Wed, 27 Nov 2024 18:43:38 -0700
Subject: [PATCH 01/36] Update SemaLambda.cpp

This patch refines how Clang handles source ranges for unused lambda captures. 
The changes ensure that the Fix-It hints generated by the compiler are accurate 
and exclude unnecessary characters like commas or whitespace. Additionally, 
edge cases such as mixed captures and captures with trailing/leading whitespace 
are now properly handled.
---
 clang/lib/Sema/SemaLambda.cpp | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index a67c0b2b367d1..e7417d1a884dc 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1164,8 +1164,11 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   /*FunctionScopeIndexToStopAtPtr*/ nullptr,
   C->Kind == LCK_StarThis);
   if (!LSI->Captures.empty())
-LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = 
C->ExplicitRange;
-  continue;
+  {
+  SourceRange TrimmedRange = Lexer::makeFileCharRange(
+  C->ExplicitRange, SM, LangOpts);
+  LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = TrimmedRange;
+  }
 }
 
 assert(C->Id && "missing identifier for capture");
@@ -1329,7 +1332,11 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   tryCaptureVariable(Var, C->Loc, Kind, EllipsisLoc);
 }
 if (!LSI->Captures.empty())
-  LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = C->ExplicitRange;
+  {
+SourceRange TrimmedRange = Lexer::makeFileCharRange(
+C->ExplicitRange, SM, LangOpts);
+LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = TrimmedRange;
+}
   }
   finishLambdaExplicitCaptures(LSI);
   LSI->ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;

>From ccb39521d4e246bb2b1fd2c9f3727d2332b9a6df Mon Sep 17 00:00:00 2001
From: charan-003 <85248228+charan-...@users.noreply.github.com>
Date: Wed, 27 Nov 2024 18:48:37 -0700
Subject: [PATCH 02/36] Update fixit-unused-lambda-capture.cpp

This patch extends the existing test coverage in 
fixit-unused-lambda-capture.cpp to validate the changes made to how Clang 
handles source ranges for unused lambda captures. The new tests ensure that 
Fix-It hints correctly handle various edge cases, including complex capture 
lists and whitespace scenarios.
---
 .../FixIt/fixit-unused-lambda-capture.cpp | 32 +++
 1 file changed, 32 insertions(+)

diff --git a/clang/test/FixIt/fixit-unused-lambda-capture.cpp 
b/clang/test/FixIt/fixit-unused-lambda-capture.cpp
index ce0c78d677099..ae43d4ebbdf82 100644
--- a/clang/test/FixIt/fixit-unused-lambda-capture.cpp
+++ b/clang/test/FixIt/fixit-unused-lambda-capture.cpp
@@ -66,6 +66,38 @@ void test() {
   // CHECK: [z = (n = i)] {};
   [j,z = (n = i)] {};
   // CHECK: [z = (n = i)] {};
+
+  // New Edge Cases
+
+  // Test 1: Leading and trailing whitespace
+  [i,j] { return i; };
+  // CHECK: [i] { return i; };
+  [i ,j] { return j; };
+  // CHECK: [j] { return j; };
+  [i  ,  j ,  k] { return j + k; };
+  // CHECK: [j,k] { return j + k; };
+
+  // Test 2: Single unused capture
+  [i] {};
+  // CHECK: [] {};
+  [&i] {};
+  // CHECK: [] {};
+
+  // Test 3: Multiple commas
+  [i,,j] { return j; };
+  // CHECK: [j] { return j; };
+  [,i,j,,k] { return k; };
+  // CHECK: [k] { return k; };
+
+  // Test 4: Mixed captures
+  [=, &i, j] { return i; };
+  // CHECK: [&i] { return i; };
+  [&, i] {};
+  // CHECK: [&] {};
+
+  // Test 5: Capture with comments
+  [/*capture*/ i, j] { return j; };
+  // CHECK: [/*capture*/ j] { return j; };
 }
 
 class ThisTest {

>From 6b5fff5d2f10e422f94939213d2302a87501a867 Mon Sep 17 00:00:00 2001
From: charan-003 <85248228+charan-...@users.noreply.github.com>
Date: Wed, 27 Nov 2024 21:52:22 -0700
Subject: [PATCH 03/36] Update SemaLambda.cpp

added #include "clang/Lex/Lexer.h"
---
 clang/lib/Sema/SemaLambda.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index e7417d1a884dc..82a0f926d6af7 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -26,6 +26,7 @@
 #include "clang/Sema/SemaOpenMP.h"
 #include "clang/Sema/Template.h"
 #include "llvm/ADT/STLExtras.h"
+#include "clang/Lex/Lexer.h"
 #include 
 using namespace clang;
 using namespace sema;
@@ -1165,6 +1166,8 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   C->Kind == LCK_StarThis);
   if (!LSI->Captures.empty())
   {
+  SourceManager &SourceMgr = Context.getSourceManager(); 
+  cons

[clang] 1b60b83 - [Clang] Don't retain template FoundDecl for conversion function calls (#138377)

2025-05-04 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-05-04T19:27:08+08:00
New Revision: 1b60b83adad8c62140ce8cc092179ed06df7ff09

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

LOG: [Clang] Don't retain template FoundDecl for conversion function calls 
(#138377)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4bd9d904e1ea9..918ff952bb2c3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -637,6 +637,7 @@ Bug Fixes to C++ Support
 - Clang no longer crashes when establishing subsumption between some 
constraint expressions. (#GH122581)
 - Clang now issues an error when placement new is used to modify a 
const-qualified variable
   in a ``constexpr`` function. (#GH131432)
+- Fixed an incorrect TreeTransform for calls to ``consteval`` functions if a 
conversion template is present. (#GH137885)
 - Clang now emits a warning when class template argument deduction for alias 
templates is used in C++17. (#GH133806)
 - Fix a crash when checking the template template parameters of a dependent 
lambda appearing in an alias declaration.
   (#GH136432), (#GH137014), (#GH138018)

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index f7ec4081ce8be..d3ee9989c73ed 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -3983,7 +3983,7 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType 
ToType,
   //   phase of [over.match.list] when the initializer list has exactly
   //   one element that is itself an initializer list, [...] and the
   //   conversion is to X or reference to cv X, user-defined conversion
-  //   sequences are not cnosidered.
+  //   sequences are not considered.
   if (SuppressUserConversions && ListInitializing) {
 SuppressUserConversions =
 NumArgs == 1 && isa(Args[0]) &&
@@ -14765,6 +14765,12 @@ ExprResult 
Sema::CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass,
 ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl,
 CXXConversionDecl *Method,
 bool HadMultipleCandidates) {
+  // FoundDecl can be the TemplateDecl of Method. Don't retain a template in
+  // the FoundDecl as it impedes TransformMemberExpr.
+  // We go a bit further here: if there's no 
diff erence in UnderlyingDecl,
+  // then using FoundDecl vs Method shouldn't make a 
diff erence either.
+  if (FoundDecl->getUnderlyingDecl() == FoundDecl)
+FoundDecl = Method;
   // Convert the expression to match the conversion function's implicit object
   // parameter.
   ExprResult Exp;

diff  --git a/clang/test/SemaCXX/cxx2a-consteval.cpp 
b/clang/test/SemaCXX/cxx2a-consteval.cpp
index fef4674d17841..d9d144cafdbcc 100644
--- a/clang/test/SemaCXX/cxx2a-consteval.cpp
+++ b/clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1272,3 +1272,31 @@ int main() {
 }
 
 } // namespace GH107175
+
+namespace GH137885 {
+
+template  struct A {};
+
+template 
+struct B {
+  consteval B() {}
+
+  template  consteval operator A() const {
+static_assert(sizeof...(P) == N);
+return {};
+  }
+};
+
+template  struct type_identity {
+  using type = T;
+};
+
+template 
+void foo(typename type_identity>::type a, P...) {}
+
+void foo() {
+  foo(B<0>());
+  foo(B<5>(), 1, 2, 3, 4, 5);
+}
+
+}



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


[clang] [Clang] Don't retain template FoundDecl for conversion function calls (PR #138377)

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

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


[clang] [Clang] Don't retain template FoundDecl for conversion function calls (PR #138377)

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

llvm-ci wrote:

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

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


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

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

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

Script:
--
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/unittests/./AllClangUnitTests
 --gtest_filter=TimeProfilerTest.ConstantEvaluationC99
--
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/unittests/Support/TimeProfilerTest.cpp:349:
 Failure
Expected equality of these values:
  R"(
Frontend (test.c)
| ParseDeclarationOrFunctionDefinition (test.c:2:1)
| | isIntegerConstantExpr ()
| | EvaluateKnownConstIntCheckOverflow ()
| PerformPendingInstantiations
)"
Which is: "\nFrontend (test.c)\n| ParseDeclarationOrFunctionDefinition 
(test.c:2:1)\n| | isIntegerConstantExpr ()\n| | 
EvaluateKnownConstIntCheckOverflow ()\n| 
PerformPendingInstantiations\n"
  buildTraceGraph(Json)
Which is: "\nFrontend (test.c)\n| ParseDeclarationOrFunctionDefinition 
(test.c:2:1)\n| | isIntegerConstantExpr ()\n| | 
EvaluateKnownConstIntCheckOverflow ()\n| | 
PerformPendingInstantiations\n"
With diff:
@@ -4,3 +4,3 @@
 | | isIntegerConstantExpr ()
 | | EvaluateKnownConstIntCheckOverflow ()
-| PerformPendingInstantiations\n
+| | PerformPendingInstantiations\n



/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/unittests/Support/TimeProfilerTest.cpp:349
Expected equality of these values:
  R"(
Frontend (test.c)
| ParseDeclarationOrFunctionDefinition (test.c:2:1)
| | isIntegerConstantExpr ()
| | EvaluateKnownConstIntCheckOverflow ()
| PerformPendingInstantiations
)"
Which is: "\nFrontend (test.c)\n| ParseDeclarationOrFunctionDefinition 
(test.c:2:1)\n| | isIntegerConstantExpr ()\n| | 
EvaluateKnownConstIntCheckOverflow ()\n| 
PerformPendingInstantiations\n"
  buildTraceGraph(Json)
Which is: "\nFrontend (test.c)\n| ParseDeclarationOrFunctionDefinition 
(test.c:2:1)\n| | isIntegerConstantExpr ()\n| | 
EvaluateKnownConstIntCheckOverflow ()\n| | 
PerformPendingInstantiations\n"
With diff:
@@ -4,3 +4,3 @@
 | | isIntegerConstantExpr ()
 | | EvaluateKnownConstIntCheckOverflow ()
-| PerformPendingInstantiations\n
+| | PerformPendingInstantiations\n

...

```



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


[clang] [analyzer] Improve cache locality by using separate allocators (PR #138295)

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

steakhal wrote:

I had a look at the spreadsheet and the numbers for `linux-topro.c` looks 
really impressive.
However, in general, we need further investigation about why are we not getting 
faster e.g. in the `clang-MSP430ISelDAGToDAG.cpp` case. The direction seems 
right though.

(FYI it usually better to take the minimums of the different analysis attempts 
than the avg).

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


[clang] [clang][bytecode] Use bytecode interpreter in EvaluateCharRangeAsString (PR #138461)

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

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

>From 6cc6ff2f4c62e6d0a7b95338c461f8998a4a6bbc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 4 May 2025 07:25:20 +0200
Subject: [PATCH] [clang][bytecode] Use bytecode interpreter in
 EvaluateCharRangeAsString

This was always using the ast walker.
---
 clang/lib/AST/ByteCode/Context.cpp | 79 ++
 clang/lib/AST/ByteCode/Context.h   |  9 +++
 clang/lib/AST/ByteCode/EvalEmitter.cpp | 22 ++
 clang/lib/AST/ByteCode/EvalEmitter.h   |  5 ++
 clang/lib/AST/ByteCode/EvaluationResult.h  |  6 +-
 clang/lib/AST/ByteCode/Pointer.h   |  7 ++
 clang/lib/AST/ExprConstant.cpp |  6 +-
 clang/test/SemaCXX/gnu-asm-constexpr.cpp   |  1 +
 clang/test/SemaCXX/static-assert-cxx26.cpp |  1 +
 9 files changed, 130 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index b35b30cc20d81..db9df7abf7a29 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -134,6 +134,85 @@ bool Context::evaluateAsInitializer(State &Parent, const 
VarDecl *VD,
   return true;
 }
 
+template 
+bool Context::evaluateStringRepr(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, ResultT &Result) {
+  assert(Stk.empty());
+  Compiler C(*this, *P, Parent, Stk);
+
+  // Evaluate size value.
+  APValue SizeValue;
+  if (!evaluateAsRValue(Parent, SizeExpr, SizeValue))
+return false;
+
+  if (!SizeValue.isInt())
+return false;
+  uint64_t Size = SizeValue.getInt().getZExtValue();
+
+  auto PtrRes = C.interpretAsPointer(PtrExpr, [&](const Pointer &Ptr) {
+if (Size == 0) {
+  if constexpr (std::is_same_v)
+Result = APValue(APValue::UninitArray{}, 0, 0);
+  return true;
+}
+
+if (!Ptr.isLive() || !Ptr.getFieldDesc()->isPrimitiveArray())
+  return false;
+
+// Must be char.
+if (Ptr.getFieldDesc()->getElemSize() != 1 /*bytes*/)
+  return false;
+
+if (Size > Ptr.getNumElems()) {
+  Parent.FFDiag(SizeExpr, diag::note_constexpr_access_past_end) << AK_Read;
+  Size = Ptr.getNumElems();
+}
+
+if constexpr (std::is_same_v) {
+  QualType CharTy = PtrExpr->getType()->getPointeeType();
+  Result = APValue(APValue::UninitArray{}, Size, Size);
+  for (uint64_t I = 0; I != Size; ++I) {
+if (std::optional ElemVal =
+Ptr.atIndex(I).toRValue(*this, CharTy))
+  Result.getArrayInitializedElt(I) = *ElemVal;
+else
+  return false;
+  }
+} else {
+  assert((std::is_same_v));
+  if (Size < Result.max_size())
+Result.resize(Size);
+  Result.assign(reinterpret_cast(Ptr.getRawAddress()), Size);
+}
+
+return true;
+  });
+
+  if (PtrRes.isInvalid()) {
+C.cleanup();
+Stk.clear();
+return false;
+  }
+
+  return true;
+}
+
+bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr,
+const Expr *PtrExpr, APValue &Result) {
+  assert(SizeExpr);
+  assert(PtrExpr);
+
+  return evaluateStringRepr(Parent, SizeExpr, PtrExpr, Result);
+}
+
+bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr,
+const Expr *PtrExpr, std::string &Result) {
+  assert(SizeExpr);
+  assert(PtrExpr);
+
+  return evaluateStringRepr(Parent, SizeExpr, PtrExpr, Result);
+}
+
 const LangOptions &Context::getLangOpts() const { return Ctx.getLangOpts(); }
 
 std::optional Context::classify(QualType T) const {
diff --git a/clang/lib/AST/ByteCode/Context.h b/clang/lib/AST/ByteCode/Context.h
index 5a39f40ef3f11..33bc9fad883f8 100644
--- a/clang/lib/AST/ByteCode/Context.h
+++ b/clang/lib/AST/ByteCode/Context.h
@@ -59,6 +59,11 @@ class Context final {
   /// Evaluates a toplevel initializer.
   bool evaluateAsInitializer(State &Parent, const VarDecl *VD, APValue 
&Result);
 
+  bool evaluateCharRange(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, APValue &Result);
+  bool evaluateCharRange(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, std::string &Result);
+
   /// Returns the AST context.
   ASTContext &getASTContext() const { return Ctx; }
   /// Returns the language options.
@@ -122,6 +127,10 @@ class Context final {
   /// Runs a function.
   bool Run(State &Parent, const Function *Func);
 
+  template 
+  bool evaluateStringRepr(State &Parent, const Expr *SizeExpr,
+  const Expr *PtrExpr, ResultT &Result);
+
   /// Current compilation context.
   ASTContext &Ctx;
   /// Interpreter stack, shared across invocations.
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 71d688498ffa5..37e8d3788a6fe 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -72,6 +

[clang] [clang] Remove unused local variables (NFC) (PR #138453)

2025-05-04 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang-driver

Author: Kazu Hirata (kazutakahirata)


Changes



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


27 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (-1) 
- (modified) clang/lib/CodeGen/CGCUDANV.cpp (-1) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (-1) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (-2) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (-1) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (-1) 
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (-2) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/HLSL.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/OHOS.cpp (-1) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (-1) 
- (modified) clang/lib/Parse/ParsePragma.cpp (-1) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (-1) 
- (modified) clang/lib/Sema/SemaInit.cpp (-1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (-5) 
- (modified) clang/lib/Serialization/ASTReader.cpp (-2) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (-1) 
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (-1) 
- (modified) clang/tools/libclang/CIndex.cpp (-1) 
- (modified) clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp (-7) 
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (-1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1e4e055e04afd..6235473d19a31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1949,7 +1949,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr &E) {
   analyze_os_log::OSLogBufferLayout Layout;
   analyze_os_log::computeOSLogBufferLayout(Ctx, &E, Layout);
   Address BufAddr = EmitPointerWithAlignment(E.getArg(0));
-  llvm::SmallVector RetainableOperands;
 
   // Ignore argument 1, the format string. It is not currently used.
   CallArgList Args;
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 395263331d141..dd26be74e561b 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1194,7 +1194,6 @@ void CGNVCUDARuntime::transformManagedVars() {
 // registered. The linker will provide a pointer to this section so we can
 // register the symbols with the linked device image.
 void CGNVCUDARuntime::createOffloadingEntries() {
-  SmallVector Out;
   llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP
? llvm::object::OffloadKind::OFK_HIP
: llvm::object::OffloadKind::OFK_Cuda;
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8a214da6bf628..69d77f283db3b 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -748,7 +748,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
   if (!PrioritizedCXXGlobalInits.empty()) {
-SmallVector LocalCXXGlobalInits;
 llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
  PrioritizedCXXGlobalInits.end());
 for (SmallVectorImpl::iterator
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bba7d1e805f3f..2e01adc51fdf0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3955,8 +3955,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
   {CFITCK_UnrelatedCast, SanitizerKind::SO_CFIUnrelatedCast},
   {CFITCK_ICall, SanitizerKind::SO_CFIICall}};
 
-  SmallVector, 5>
-  Checks;
   for (auto CheckKindOrdinalPair : CheckKinds) {
 int Kind = CheckKindOrdinalPair.first;
 SanitizerKind::SanitizerOrdinal Ordinal = CheckKindOrdinalPair.second;
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..7917cdb7e12b6 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1814,7 +1814,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 
   // We'll need to enter cleanup scopes in case any of the element
   // initializers throws an exception.
-  SmallVector cleanups;
   CodeGenFunction::CleanupDeactivationScope DeactivateCleanups(CGF);
 
   unsigned curInitIndex = 0;
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6136417fcad60..f6608faaa7309 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -446,7 +446,6 @@ s

[clang] [clang] Remove unused local variables (NFC) (PR #138453)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Kazu Hirata (kazutakahirata)


Changes



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


27 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (-1) 
- (modified) clang/lib/CodeGen/CGCUDANV.cpp (-1) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (-1) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (-2) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (-1) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (-1) 
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (-2) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/HLSL.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/OHOS.cpp (-1) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (-1) 
- (modified) clang/lib/Parse/ParsePragma.cpp (-1) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (-1) 
- (modified) clang/lib/Sema/SemaInit.cpp (-1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (-5) 
- (modified) clang/lib/Serialization/ASTReader.cpp (-2) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (-1) 
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (-1) 
- (modified) clang/tools/libclang/CIndex.cpp (-1) 
- (modified) clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp (-7) 
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (-1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1e4e055e04afd..6235473d19a31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1949,7 +1949,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr &E) {
   analyze_os_log::OSLogBufferLayout Layout;
   analyze_os_log::computeOSLogBufferLayout(Ctx, &E, Layout);
   Address BufAddr = EmitPointerWithAlignment(E.getArg(0));
-  llvm::SmallVector RetainableOperands;
 
   // Ignore argument 1, the format string. It is not currently used.
   CallArgList Args;
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 395263331d141..dd26be74e561b 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1194,7 +1194,6 @@ void CGNVCUDARuntime::transformManagedVars() {
 // registered. The linker will provide a pointer to this section so we can
 // register the symbols with the linked device image.
 void CGNVCUDARuntime::createOffloadingEntries() {
-  SmallVector Out;
   llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP
? llvm::object::OffloadKind::OFK_HIP
: llvm::object::OffloadKind::OFK_Cuda;
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8a214da6bf628..69d77f283db3b 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -748,7 +748,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
   if (!PrioritizedCXXGlobalInits.empty()) {
-SmallVector LocalCXXGlobalInits;
 llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
  PrioritizedCXXGlobalInits.end());
 for (SmallVectorImpl::iterator
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bba7d1e805f3f..2e01adc51fdf0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3955,8 +3955,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
   {CFITCK_UnrelatedCast, SanitizerKind::SO_CFIUnrelatedCast},
   {CFITCK_ICall, SanitizerKind::SO_CFIICall}};
 
-  SmallVector, 5>
-  Checks;
   for (auto CheckKindOrdinalPair : CheckKinds) {
 int Kind = CheckKindOrdinalPair.first;
 SanitizerKind::SanitizerOrdinal Ordinal = CheckKindOrdinalPair.second;
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..7917cdb7e12b6 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1814,7 +1814,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 
   // We'll need to enter cleanup scopes in case any of the element
   // initializers throws an exception.
-  SmallVector cleanups;
   CodeGenFunction::CleanupDeactivationScope DeactivateCleanups(CGF);
 
   unsigned curInitIndex = 0;
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6136417fcad60..f6608faaa7309 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -446,7 +446,6 @@ static void gatherFunctions(SmallVe

[clang] [clang] Remove unused local variables (NFC) (PR #138453)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Kazu Hirata (kazutakahirata)


Changes



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


27 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (-1) 
- (modified) clang/lib/CodeGen/CGCUDANV.cpp (-1) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (-1) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (-2) 
- (modified) clang/lib/CodeGen/CGExprAgg.cpp (-1) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (-1) 
- (modified) clang/lib/CodeGen/CGObjCGNU.cpp (-2) 
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/HLSL.cpp (-1) 
- (modified) clang/lib/Driver/ToolChains/OHOS.cpp (-1) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (-1) 
- (modified) clang/lib/Lex/PPDirectives.cpp (-1) 
- (modified) clang/lib/Parse/ParsePragma.cpp (-1) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (-1) 
- (modified) clang/lib/Sema/SemaDeclObjC.cpp (-1) 
- (modified) clang/lib/Sema/SemaInit.cpp (-1) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (-5) 
- (modified) clang/lib/Serialization/ASTReader.cpp (-2) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (-1) 
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (-1) 
- (modified) clang/tools/libclang/CIndex.cpp (-1) 
- (modified) clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp (-7) 
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (-1) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1e4e055e04afd..6235473d19a31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1949,7 +1949,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr &E) {
   analyze_os_log::OSLogBufferLayout Layout;
   analyze_os_log::computeOSLogBufferLayout(Ctx, &E, Layout);
   Address BufAddr = EmitPointerWithAlignment(E.getArg(0));
-  llvm::SmallVector RetainableOperands;
 
   // Ignore argument 1, the format string. It is not currently used.
   CallArgList Args;
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 395263331d141..dd26be74e561b 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1194,7 +1194,6 @@ void CGNVCUDARuntime::transformManagedVars() {
 // registered. The linker will provide a pointer to this section so we can
 // register the symbols with the linked device image.
 void CGNVCUDARuntime::createOffloadingEntries() {
-  SmallVector Out;
   llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP
? llvm::object::OffloadKind::OFK_HIP
: llvm::object::OffloadKind::OFK_Cuda;
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8a214da6bf628..69d77f283db3b 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -748,7 +748,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
   if (!PrioritizedCXXGlobalInits.empty()) {
-SmallVector LocalCXXGlobalInits;
 llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
  PrioritizedCXXGlobalInits.end());
 for (SmallVectorImpl::iterator
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bba7d1e805f3f..2e01adc51fdf0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3955,8 +3955,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
   {CFITCK_UnrelatedCast, SanitizerKind::SO_CFIUnrelatedCast},
   {CFITCK_ICall, SanitizerKind::SO_CFIICall}};
 
-  SmallVector, 5>
-  Checks;
   for (auto CheckKindOrdinalPair : CheckKinds) {
 int Kind = CheckKindOrdinalPair.first;
 SanitizerKind::SanitizerOrdinal Ordinal = CheckKindOrdinalPair.second;
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..7917cdb7e12b6 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1814,7 +1814,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 
   // We'll need to enter cleanup scopes in case any of the element
   // initializers throws an exception.
-  SmallVector cleanups;
   CodeGenFunction::CleanupDeactivationScope DeactivateCleanups(CGF);
 
   unsigned curInitIndex = 0;
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6136417fcad60..f6608faaa7309 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -446,7 +446,6 @@ static void gatherFunctions(SmallVectorImpl 

[clang] [clang] Remove unused local variables (NFC) (PR #138453)

2025-05-04 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/138453

None

>From ae39ce905c81d94d2ca079bf1ebfd781a361bf57 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 4 May 2025 08:14:05 -0700
Subject: [PATCH] [clang] Remove unused local variables (NFC)

---
 clang/lib/CodeGen/CGBuiltin.cpp| 1 -
 clang/lib/CodeGen/CGCUDANV.cpp | 1 -
 clang/lib/CodeGen/CGDeclCXX.cpp| 1 -
 clang/lib/CodeGen/CGExpr.cpp   | 2 --
 clang/lib/CodeGen/CGExprAgg.cpp| 1 -
 clang/lib/CodeGen/CGHLSLRuntime.cpp| 1 -
 clang/lib/CodeGen/CGObjCGNU.cpp| 2 --
 clang/lib/CodeGen/CGStmtOpenMP.cpp | 1 -
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 1 -
 clang/lib/Driver/ToolChains/HLSL.cpp   | 1 -
 clang/lib/Driver/ToolChains/OHOS.cpp   | 1 -
 clang/lib/Frontend/InitPreprocessor.cpp| 1 -
 clang/lib/Lex/PPDirectives.cpp | 1 -
 clang/lib/Parse/ParsePragma.cpp| 1 -
 clang/lib/Sema/SemaCodeComplete.cpp| 1 -
 clang/lib/Sema/SemaDeclAttr.cpp| 1 -
 clang/lib/Sema/SemaDeclObjC.cpp| 1 -
 clang/lib/Sema/SemaInit.cpp| 1 -
 clang/lib/Sema/SemaOpenMP.cpp  | 5 -
 clang/lib/Serialization/ASTReader.cpp  | 2 --
 clang/lib/Serialization/ASTWriter.cpp  | 1 -
 clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp  | 1 -
 clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp  | 1 -
 .../lib/Tooling/DependencyScanning/ModuleDepCollector.cpp  | 1 -
 clang/tools/libclang/CIndex.cpp| 1 -
 clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp | 7 ---
 clang/utils/TableGen/ClangAttrEmitter.cpp  | 1 -
 27 files changed, 40 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1e4e055e04afd..6235473d19a31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1949,7 +1949,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr &E) {
   analyze_os_log::OSLogBufferLayout Layout;
   analyze_os_log::computeOSLogBufferLayout(Ctx, &E, Layout);
   Address BufAddr = EmitPointerWithAlignment(E.getArg(0));
-  llvm::SmallVector RetainableOperands;
 
   // Ignore argument 1, the format string. It is not currently used.
   CallArgList Args;
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 395263331d141..dd26be74e561b 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1194,7 +1194,6 @@ void CGNVCUDARuntime::transformManagedVars() {
 // registered. The linker will provide a pointer to this section so we can
 // register the symbols with the linked device image.
 void CGNVCUDARuntime::createOffloadingEntries() {
-  SmallVector Out;
   llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP
? llvm::object::OffloadKind::OFK_HIP
: llvm::object::OffloadKind::OFK_Cuda;
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8a214da6bf628..69d77f283db3b 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -748,7 +748,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
   if (!PrioritizedCXXGlobalInits.empty()) {
-SmallVector LocalCXXGlobalInits;
 llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
  PrioritizedCXXGlobalInits.end());
 for (SmallVectorImpl::iterator
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bba7d1e805f3f..2e01adc51fdf0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3955,8 +3955,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
   {CFITCK_UnrelatedCast, SanitizerKind::SO_CFIUnrelatedCast},
   {CFITCK_ICall, SanitizerKind::SO_CFIICall}};
 
-  SmallVector, 5>
-  Checks;
   for (auto CheckKindOrdinalPair : CheckKinds) {
 int Kind = CheckKindOrdinalPair.first;
 SanitizerKind::SanitizerOrdinal Ordinal = CheckKindOrdinalPair.second;
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..7917cdb7e12b6 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1814,7 +1814,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 
   // We'll need to enter cleanup scopes in case any of the element
   // initializers throws an exception.
-  SmallVector c

[clang] f002f30 - [clang] Remove unused local variables (NFC) (#138453)

2025-05-04 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-04T10:51:40-07:00
New Revision: f002f300c5e1f9ce8adf00441b7e879fec36a071

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

LOG: [clang] Remove unused local variables (NFC) (#138453)

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/HLSL.cpp
clang/lib/Driver/ToolChains/OHOS.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/tools/libclang/CIndex.cpp
clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1e4e055e04afd..6235473d19a31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1949,7 +1949,6 @@ RValue CodeGenFunction::emitBuiltinOSLogFormat(const 
CallExpr &E) {
   analyze_os_log::OSLogBufferLayout Layout;
   analyze_os_log::computeOSLogBufferLayout(Ctx, &E, Layout);
   Address BufAddr = EmitPointerWithAlignment(E.getArg(0));
-  llvm::SmallVector RetainableOperands;
 
   // Ignore argument 1, the format string. It is not currently used.
   CallArgList Args;

diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 395263331d141..dd26be74e561b 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1194,7 +1194,6 @@ void CGNVCUDARuntime::transformManagedVars() {
 // registered. The linker will provide a pointer to this section so we can
 // register the symbols with the linked device image.
 void CGNVCUDARuntime::createOffloadingEntries() {
-  SmallVector Out;
   llvm::object::OffloadKind Kind = CGM.getLangOpts().HIP
? llvm::object::OffloadKind::OFK_HIP
: llvm::object::OffloadKind::OFK_Cuda;

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8a214da6bf628..69d77f283db3b 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -748,7 +748,6 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
   // Add any initializers with specified priority; this uses the same  approach
   // as EmitCXXGlobalInitFunc().
   if (!PrioritizedCXXGlobalInits.empty()) {
-SmallVector LocalCXXGlobalInits;
 llvm::array_pod_sort(PrioritizedCXXGlobalInits.begin(),
  PrioritizedCXXGlobalInits.end());
 for (SmallVectorImpl::iterator

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bba7d1e805f3f..2e01adc51fdf0 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3955,8 +3955,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
   {CFITCK_UnrelatedCast, SanitizerKind::SO_CFIUnrelatedCast},
   {CFITCK_ICall, SanitizerKind::SO_CFIICall}};
 
-  SmallVector, 5>
-  Checks;
   for (auto CheckKindOrdinalPair : CheckKinds) {
 int Kind = CheckKindOrdinalPair.first;
 SanitizerKind::SanitizerOrdinal Ordinal = CheckKindOrdinalPair.second;

diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..7917cdb7e12b6 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -1814,7 +1814,6 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 
   // We'll need to enter cleanup scopes in case any of the element
   // initializers throws an exception.
-  SmallVector cleanups;
   CodeGenFunction::CleanupDeactivationScope DeactivateCleanups(CGF);
 
   unsigned curInitIndex = 0;

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 6136417fcad60..f6608faaa7309 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -446,7 +446,6 @@ static void gatherFunctions(SmallVectorImpl 
&Fns, llvm::Module &M,
   // HLSL neither supports priorities or COMDat values, so we will check those
   // in an a

[clang] [clang] Remove unused local variables (NFC) (PR #138453)

2025-05-04 Thread Kazu Hirata via cfe-commits


@@ -361,15 +361,8 @@ TEST(CallDescription, AliasNames) {
   std::cont v;
   v.data();
 })code";
-  constexpr StringRef UseStructNameInSpelling = R"code(
-void foo() {
-  std::container v;
-  v.data();
-})code";
   const std::string UseAliasInSpellingCode =
   (Twine{AliasNamesCode} + UseAliasInSpelling).str();
-  const std::string UseStructNameInSpellingCode =
-  (Twine{AliasNamesCode} + UseStructNameInSpelling).str();

kazutakahirata wrote:

Thank you for the review!  `UseStructNameInSpellingCode` seems to have been 
dead ever since it was added in
5644d152578f4604f7dc8c908a0a3f91a726ad80, a patch of yours.


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


[clang] [clang] Remove unused local variables (NFC) (PR #138453)

2025-05-04 Thread Kazu Hirata via cfe-commits

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


[clang] [llvm] [sancov] Introduce optional callback for stack-depth tracking (PR #138323)

2025-05-04 Thread Kees Cook via cfe-commits


@@ -1078,22 +1092,44 @@ void 
ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
 Store->setNoSanitizeMetadata();
   }
   if (Options.StackDepth && IsEntryBB && !IsLeafFunc) {
-// Check stack depth.  If it's the deepest so far, record it.
 Module *M = F.getParent();
-auto FrameAddrPtr = IRB.CreateIntrinsic(
-Intrinsic::frameaddress,
-IRB.getPtrTy(M->getDataLayout().getAllocaAddrSpace()),
-{Constant::getNullValue(Int32Ty)});
-auto FrameAddrInt = IRB.CreatePtrToInt(FrameAddrPtr, IntptrTy);
-auto LowestStack = IRB.CreateLoad(IntptrTy, SanCovLowestStack);
-auto IsStackLower = IRB.CreateICmpULT(FrameAddrInt, LowestStack);
-auto ThenTerm = SplitBlockAndInsertIfThen(
-IsStackLower, &*IP, false,
-MDBuilder(IRB.getContext()).createUnlikelyBranchWeights());
-IRBuilder<> ThenIRB(ThenTerm);
-auto Store = ThenIRB.CreateStore(FrameAddrInt, SanCovLowestStack);
-LowestStack->setNoSanitizeMetadata();
-Store->setNoSanitizeMetadata();
+if (Options.StackDepthCallbackMin) {
+  // In callback mode, only add call when stack depth reaches minimum.
+  const DataLayout &DL = M->getDataLayout();
+  uint32_t EstimatedStackSize = 0;
+
+  // Make an estimate on the stack usage.
+  for (auto &I : F.getEntryBlock()) {
+if (auto *AI = dyn_cast(&I)) {
+  if (AI->isStaticAlloca()) {
+uint32_t TypeSize = DL.getTypeAllocSize(AI->getAllocatedType());
+EstimatedStackSize += TypeSize;
+  } else {
+// Over-estimate dynamic sizes.
+EstimatedStackSize += 4096;

kees wrote:

Yeah, that's a good point. And yes, we have no dynamic stack sizes in Linux 
anymore, so this "else" will never get run there. I think "always make the 
callback" is a good choice here.

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


[clang] [llvm] [sancov] Introduce optional callback for stack-depth tracking (PR #138323)

2025-05-04 Thread Kees Cook via cfe-commits

kees wrote:

> This is also missing flag and IR tests.

Oh, yes, I will add those. Thanks!

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


[libunwind] [libunwind] [SEH] Implement parsing of ARM pdata/xdata (PR #137950)

2025-05-04 Thread Jacek Caban via cfe-commits

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

LGTM

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


[libunwind] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (PR #137951)

2025-05-04 Thread Jacek Caban via cfe-commits

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

Looks reasonable to me overall.

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


[libunwind] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (PR #137951)

2025-05-04 Thread Jacek Caban via cfe-commits


@@ -212,6 +238,21 @@ __libunwind_seh_personality(int version, _Unwind_Action 
state,
   ms_exc.ExceptionInformation[2] = state;
   DISPATCHER_CONTEXT *disp_ctx =
   __unw_seh_get_disp_ctx((unw_cursor_t *)context);
+#if defined(__aarch64__)
+  LOCAL_DISPATCHER_CONTEXT_NONVOLREG_ARM64 nonvol;
+  memcpy(&nonvol.GpNvRegs, &disp_ctx->ContextRecord->X19,
+ sizeof(nonvol.GpNvRegs));
+  for (int i = 0; i < 8; i++)
+nonvol.FpNvRegs[i] = disp_ctx->ContextRecord->V[i + 8].D[0];
+  disp_ctx->NonVolatileRegisters = (PBYTE)&nonvol;

cjacek wrote:

You could avoid the cast by using `nonvol.Buffer` here.

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


[libunwind] [libunwind] [SEH] Set NonVolatileRegisters before calling a personality function (PR #137951)

2025-05-04 Thread Jacek Caban via cfe-commits

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


[clang] [Clang][Cygwin] attempt to fix building shared libclang. (PR #138351)

2025-05-04 Thread via cfe-commits

jeremyd2019 wrote:

Surprisingly, it looks like Cygwin (@tyan0) is working around the export limit 
on gcc by setting `-DCMAKE_SHARED_LINKER_FLAGS=-fvisibility=hidden`.  I was 
surprised that worked on gcc - maybe it can be generalized here instead of 
fighting to build only static with gcc to then use that clang to build dynamic 
libraries?

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


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

2025-05-04 Thread Nathan Ridge via cfe-commits


@@ -158,6 +159,42 @@ TEST(StdLibTests, EndToEnd) {
   UnorderedElementsAre(StdlibSymbol("list"), StdlibSymbol("vector")));
 }
 
+TEST(StdLibTests, StdLibDocComments) {
+  Config Cfg;
+  Cfg.Index.StandardLibrary = true;
+  WithContextValue Enabled(Config::Key, std::move(Cfg));
+
+  MockFS FS;
+  FS.Files["stdlib/vector"] = R"cpp(
+namespace std {
+  struct vector {
+/**doc comment*/
+struct inner {};
+  };
+}
+  )cpp";
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags.push_back("-isystem" + testPath("stdlib"));
+  ClangdServer::Options Opts = ClangdServer::optsForTest();
+  Opts.BuildDynamicSymbolIndex = true; // also used for stdlib index
+  ClangdServer Server(CDB, FS, Opts);
+
+  // Open an empty file.  will not be part of the preamble index,
+  // but it will be part of the stdlib index.
+  Server.addDocument(testPath("foo.cc"), "");
+
+  // Wait for the stdlib index to be built.
+  ASSERT_TRUE(Server.blockUntilIdleForTest());
+
+  // Check that the index contains the doc comment.
+  FuzzyFindRequest Req;
+  Req.Query = "inner";
+  Req.Scopes = {"std::vector::"};
+  SymbolSlab Result = runFuzzyFind(*Server.getIndexForTest(), Req);

HighCommander4 wrote:

Done, thanks for the suggestion!

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


[clang-tools-extra] [clangd] Add CodePatterns config option under Completion (PR #137613)

2025-05-04 Thread via cfe-commits

Noustaa wrote:

There is 2 different features involved here.
1) The fact that if i type "inc" it will suggest me both includes snippets
Like the below image the ones tagged LSP on the right side
![image](https://github.com/user-attachments/assets/a21e1db2-f057-4460-921e-d62d25efb794)

2) The fact that if i type "#include https://github.com/llvm/llvm-project/pull/137613
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2025-05-04 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 updated 
https://github.com/llvm/llvm-project/pull/133681

>From ce15317543b135b7aa86d4987fb0c25abd597d56 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Mon, 31 Mar 2025 02:25:45 -0400
Subject: [PATCH] [clangd] Store documentation when indexing standard library

Fixes https://github.com/clangd/clangd/issues/2344
---
 clang-tools-extra/clangd/index/FileIndex.cpp  | 21 
 clang-tools-extra/clangd/index/FileIndex.h|  3 +-
 clang-tools-extra/clangd/index/StdLib.cpp | 37 +++---
 .../clangd/unittests/StdLibTests.cpp  | 48 +++
 clang-tools-extra/clangd/unittests/TestTU.cpp |  3 +-
 5 files changed, 81 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index aa573e312a756..de88edd0c7a0b 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -48,13 +48,12 @@ SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
const MainFileMacros *MacroRefsToIndex,
const include_cleaner::PragmaIncludes &PI,
bool IsIndexMainAST, llvm::StringRef Version,
-   bool CollectMainFileRefs) {
+   bool CollectMainFileRefs, SymbolOrigin Origin) {
   SymbolCollector::Options CollectorOpts;
   CollectorOpts.CollectIncludePath = true;
   CollectorOpts.PragmaIncludes = &PI;
   CollectorOpts.CountReferences = false;
-  CollectorOpts.Origin =
-  IsIndexMainAST ? SymbolOrigin::Open : SymbolOrigin::Preamble;
+  CollectorOpts.Origin = Origin;
   CollectorOpts.CollectMainFileRefs = CollectMainFileRefs;
   // We want stdlib implementation details in the index only if we've opened 
the
   // file in question. This does means xrefs won't work, though.
@@ -221,22 +220,24 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
 }
 
 SlabTuple indexMainDecls(ParsedAST &AST) {
-  return indexSymbols(
-  AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
-  &AST.getMacros(), AST.getPragmaIncludes(),
-  /*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
+  return indexSymbols(AST.getASTContext(), AST.getPreprocessor(),
+  AST.getLocalTopLevelDecls(), &AST.getMacros(),
+  AST.getPragmaIncludes(),
+  /*IsIndexMainAST=*/true, AST.version(),
+  /*CollectMainFileRefs=*/true, SymbolOrigin::Open);
 }
 
 SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
  Preprocessor &PP,
- const include_cleaner::PragmaIncludes &PI) {
+ const include_cleaner::PragmaIncludes &PI,
+ SymbolOrigin Origin) {
   std::vector DeclsToIndex(
   AST.getTranslationUnitDecl()->decls().begin(),
   AST.getTranslationUnitDecl()->decls().end());
   return indexSymbols(AST, PP, DeclsToIndex,
   /*MainFileMacros=*/nullptr, PI,
   /*IsIndexMainAST=*/false, Version,
-  /*CollectMainFileRefs=*/false);
+  /*CollectMainFileRefs=*/false, Origin);
 }
 
 FileSymbols::FileSymbols(IndexContents IdxContents, bool SupportContainedRefs)
@@ -463,7 +464,7 @@ void FileIndex::updatePreamble(PathRef Path, 
llvm::StringRef Version,
const include_cleaner::PragmaIncludes &PI) {
   IndexFileIn IF;
   std::tie(IF.Symbols, std::ignore, IF.Relations) =
-  indexHeaderSymbols(Version, AST, PP, PI);
+  indexHeaderSymbols(Version, AST, PP, PI, SymbolOrigin::Preamble);
   updatePreamble(std::move(IF));
 }
 
diff --git a/clang-tools-extra/clangd/index/FileIndex.h 
b/clang-tools-extra/clangd/index/FileIndex.h
index 8e88dc9712996..86af5ee3723f6 100644
--- a/clang-tools-extra/clangd/index/FileIndex.h
+++ b/clang-tools-extra/clangd/index/FileIndex.h
@@ -164,7 +164,8 @@ SlabTuple indexMainDecls(ParsedAST &AST);
 /// included headers.
 SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
  Preprocessor &PP,
- const include_cleaner::PragmaIncludes &PI);
+ const include_cleaner::PragmaIncludes &PI,
+ SymbolOrigin Origin);
 
 /// Takes slabs coming from a TU (multiple files) and shards them per
 /// declaration location.
diff --git a/clang-tools-extra/clangd/index/StdLib.cpp 
b/clang-tools-extra/clangd/index/StdLib.cpp
index d34838a45048d..483589365eace 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -15,12 +15,15 @@
 #include "Compiler.h"
 #include "Config.h"
 #include "SymbolCollector.h"
+#include "clang-include-cleaner/Record.h"
+#include "index/FileIndex.h"
 #include "index/IndexAction.h"
 #include "support/Logger.h"
 

[clang-tools-extra] [clangd] Add CodePatterns config option under Completion (PR #137613)

2025-05-04 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> There is 2 different features involved here.
> 
> [...]
>
> In the feature i'm trying to implement, number 1 should be OFF if 
> CodePatterns is set to None but number 2 should still be working.

That makes sense to me, as a user expectation.

The code I linked to in my previous comment is for (1). The completions for 
scenario (2) come from 
[here](https://searchfox.org/llvm/rev/1b60b83adad8c62140ce8cc092179ed06df7ff09/clang/lib/Sema/SemaCodeComplete.cpp#10355),
 but unfortunately that's also `RK_Pattern`.

> Are these 2 features (num 1 & 2) coupled or can they be managed separately as 
> the current state ?

It looks like we can achieve this by allowing `RK_Pattern` completions if 
`Context.getKind() == CodeCompletionContext::CCC_IncludedFile`.

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


[clang] [Clang] Add `noalias` to `this` pointer in C++ constructors (PR #136792)

2025-05-04 Thread Guy David via cfe-commits

guy-david wrote:

Comparison between latest Clang and GCC's output for a snippet out of a 
benchmark that could use this optimization: https://godbolt.org/z/35EEvcsPr.

I've ran llvm-test-suite ten times for the before and after, it executed 
correctly and expectedly saw no performance gains:
```
Tests: 3326
Metric: exec_time

   exec_time
l/r  lhsrhs diff
count  3326.003326.001554.00
mean   885.285851 885.132328 inf
std20163.199507   20160.504672  NaN 
min0.00   0.00  -1.00   
25%0.00   0.00  -0.004020   
50%0.00   0.00   0.00   
75%1.741165   1.840265   0.003943   
max802971.672414  802823.530425  inf
```

Also built a bootstrap build and confirmed that `ninja stage2-check-all` passes 
successfully, except for a few libcxx benchmarks that seem to fail regardless.

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


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

2025-05-04 Thread via cfe-commits

https://github.com/charan-003 updated 
https://github.com/llvm/llvm-project/pull/117953

>From b886394f3aca3ea53f2c97d85a8e963d192c122f Mon Sep 17 00:00:00 2001
From: charan-003 <85248228+charan-...@users.noreply.github.com>
Date: Wed, 27 Nov 2024 18:43:38 -0700
Subject: [PATCH 01/36] Update SemaLambda.cpp

This patch refines how Clang handles source ranges for unused lambda captures. 
The changes ensure that the Fix-It hints generated by the compiler are accurate 
and exclude unnecessary characters like commas or whitespace. Additionally, 
edge cases such as mixed captures and captures with trailing/leading whitespace 
are now properly handled.
---
 clang/lib/Sema/SemaLambda.cpp | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index a67c0b2b367d1..e7417d1a884dc 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1164,8 +1164,11 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   /*FunctionScopeIndexToStopAtPtr*/ nullptr,
   C->Kind == LCK_StarThis);
   if (!LSI->Captures.empty())
-LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = 
C->ExplicitRange;
-  continue;
+  {
+  SourceRange TrimmedRange = Lexer::makeFileCharRange(
+  C->ExplicitRange, SM, LangOpts);
+  LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = TrimmedRange;
+  }
 }
 
 assert(C->Id && "missing identifier for capture");
@@ -1329,7 +1332,11 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   tryCaptureVariable(Var, C->Loc, Kind, EllipsisLoc);
 }
 if (!LSI->Captures.empty())
-  LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = C->ExplicitRange;
+  {
+SourceRange TrimmedRange = Lexer::makeFileCharRange(
+C->ExplicitRange, SM, LangOpts);
+LSI->ExplicitCaptureRanges[LSI->Captures.size() - 1] = TrimmedRange;
+}
   }
   finishLambdaExplicitCaptures(LSI);
   LSI->ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;

>From ccb39521d4e246bb2b1fd2c9f3727d2332b9a6df Mon Sep 17 00:00:00 2001
From: charan-003 <85248228+charan-...@users.noreply.github.com>
Date: Wed, 27 Nov 2024 18:48:37 -0700
Subject: [PATCH 02/36] Update fixit-unused-lambda-capture.cpp

This patch extends the existing test coverage in 
fixit-unused-lambda-capture.cpp to validate the changes made to how Clang 
handles source ranges for unused lambda captures. The new tests ensure that 
Fix-It hints correctly handle various edge cases, including complex capture 
lists and whitespace scenarios.
---
 .../FixIt/fixit-unused-lambda-capture.cpp | 32 +++
 1 file changed, 32 insertions(+)

diff --git a/clang/test/FixIt/fixit-unused-lambda-capture.cpp 
b/clang/test/FixIt/fixit-unused-lambda-capture.cpp
index ce0c78d677099..ae43d4ebbdf82 100644
--- a/clang/test/FixIt/fixit-unused-lambda-capture.cpp
+++ b/clang/test/FixIt/fixit-unused-lambda-capture.cpp
@@ -66,6 +66,38 @@ void test() {
   // CHECK: [z = (n = i)] {};
   [j,z = (n = i)] {};
   // CHECK: [z = (n = i)] {};
+
+  // New Edge Cases
+
+  // Test 1: Leading and trailing whitespace
+  [i,j] { return i; };
+  // CHECK: [i] { return i; };
+  [i ,j] { return j; };
+  // CHECK: [j] { return j; };
+  [i  ,  j ,  k] { return j + k; };
+  // CHECK: [j,k] { return j + k; };
+
+  // Test 2: Single unused capture
+  [i] {};
+  // CHECK: [] {};
+  [&i] {};
+  // CHECK: [] {};
+
+  // Test 3: Multiple commas
+  [i,,j] { return j; };
+  // CHECK: [j] { return j; };
+  [,i,j,,k] { return k; };
+  // CHECK: [k] { return k; };
+
+  // Test 4: Mixed captures
+  [=, &i, j] { return i; };
+  // CHECK: [&i] { return i; };
+  [&, i] {};
+  // CHECK: [&] {};
+
+  // Test 5: Capture with comments
+  [/*capture*/ i, j] { return j; };
+  // CHECK: [/*capture*/ j] { return j; };
 }
 
 class ThisTest {

>From 6b5fff5d2f10e422f94939213d2302a87501a867 Mon Sep 17 00:00:00 2001
From: charan-003 <85248228+charan-...@users.noreply.github.com>
Date: Wed, 27 Nov 2024 21:52:22 -0700
Subject: [PATCH 03/36] Update SemaLambda.cpp

added #include "clang/Lex/Lexer.h"
---
 clang/lib/Sema/SemaLambda.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index e7417d1a884dc..82a0f926d6af7 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -26,6 +26,7 @@
 #include "clang/Sema/SemaOpenMP.h"
 #include "clang/Sema/Template.h"
 #include "llvm/ADT/STLExtras.h"
+#include "clang/Lex/Lexer.h"
 #include 
 using namespace clang;
 using namespace sema;
@@ -1165,6 +1166,8 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
   C->Kind == LCK_StarThis);
   if (!LSI->Captures.empty())
   {
+  SourceManager &SourceMgr = Context.getSourceManager(); 
+  cons

[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits

https://github.com/MightyFilipns updated 
https://github.com/llvm/llvm-project/pull/137610

>From dd0434829bebfa00493be35faa108b32efa62b03 Mon Sep 17 00:00:00 2001
From: MightyFilipns 
Date: Mon, 28 Apr 2025 11:54:20 +0200
Subject: [PATCH] clang-format: Add SpaceAfterOperatorKeyword option

---
 clang/docs/ClangFormatStyleOptions.rst | 10 ++
 clang/docs/ReleaseNotes.rst|  1 +
 clang/include/clang/Format/Format.h|  9 +
 clang/lib/Format/Format.cpp|  3 +++
 clang/lib/Format/TokenAnnotator.cpp|  2 +-
 clang/unittests/Format/ConfigParseTest.cpp |  1 +
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 7 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index b47291599649d..a4c381bf583b6 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6127,6 +6127,16 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  ! someExpression();vs. !someExpression();
 
+.. _SpaceAfterOperatorKeyword:
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 21` 
:ref:`¶ `
+  If ``true``, a space will be inserted after the ``operator`` keyword.
+
+  .. code-block:: c++
+
+ true:false:
+ bool operator ==(int a); vs. bool operator==(int a);
+
 .. _SpaceAfterTemplateKeyword:
 
 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 918ff952bb2c3..40239b50716b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -786,6 +786,7 @@ clang-format
 - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
   ``enum`` enumerator lists.
 - Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
+- Add ``SpaceAfterOperatorKeyword`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7fe41d800ccb3..b86c4bd00eb91 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4484,6 +4484,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If ``true``, a space will be inserted after the ``operator`` keyword.
+  /// \code
+  ///true:false:
+  ///bool operator ==(int a); vs. bool operator==(int a);
+  /// \endcode
+  /// \version 21
+  bool SpaceAfterOperatorKeyword;
+
   /// If \c true, a space will be inserted after the ``template`` keyword.
   /// \code
   ///true:  false:
@@ -5454,6 +5462,7 @@ struct FormatStyle {
SortJavaStaticImport == R.SortJavaStaticImport &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
+   SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f4b64ef4f5fe..20b5352b83a9e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1152,6 +1152,8 @@ template <> struct MappingTraits {
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
@@ -1639,6 +1641,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index caf386cffd25b..50a22149f7bd9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5039,7 +5039,7 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 }
 
 if (Left.is(tok::kw_operator))
-  return Right.is(tok::coloncolon);
+  return Right.is(tok::coloncolon) || Style.SpaceAfterOperatorKeyword;
 if (Rig

[clang] 1812a43 - [clang] Remove unused local variables (NFC) (#138468)

2025-05-04 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-04T14:14:23-07:00
New Revision: 1812a43a22a82adccf46d6589b8460a3a7a2678e

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

LOG: [clang] Remove unused local variables (NFC) (#138468)

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
clang/lib/Sema/SemaPPC.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
clang/unittests/Tooling/CompilationDatabaseTest.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index e084a13995306..d4052ef90de6e 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -324,8 +324,6 @@ class SMTConstraintManager : public 
clang::ento::SimpleConstraintManager {
 
 // Construct the logical AND of all the constraints
 if (I != IE) {
-  std::vector ASTs;
-
   llvm::SMTExprRef Constraint = I++->second;
   while (I != IE) {
 Constraint = Solver->mkAnd(Constraint, I++->second);

diff  --git a/clang/lib/Sema/SemaPPC.cpp b/clang/lib/Sema/SemaPPC.cpp
index b6802d6890ed1..9b4d82745f881 100644
--- a/clang/lib/Sema/SemaPPC.cpp
+++ b/clang/lib/Sema/SemaPPC.cpp
@@ -98,7 +98,6 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI,
   CallExpr *TheCall) {
   ASTContext &Context = getASTContext();
   bool IsTarget64Bit = TI.getTypeWidth(TI.getIntPtrType()) == 64;
-  llvm::APSInt Result;
 
   if (isPPC_64Builtin(BuiltinID) && !IsTarget64Bit)
 return Diag(TheCall->getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0ecdbb3ffb89f..c9de36383d334 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6605,8 +6605,6 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
 llvm_unreachable("Unexpected Result");
   }
 
-  SmallVector DeducedArgs(Deduced.begin(), Deduced.end());
-
   TemplateDeductionResult TDK;
   runWithSufficientStackSpace(Info.getLocation(), [&] {
 TDK = ::FinishTemplateArgumentDeduction(

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 0f0184c472f36..4ddd11495f534 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -370,8 +370,6 @@ std::optional isUnsafePtr(const QualType T, bool 
IsArcEnabled) {
 std::optional isGetterOfSafePtr(const CXXMethodDecl *M) {
   assert(M);
 
-  std::optional RTC;
-
   if (isa(M)) {
 const CXXRecordDecl *calleeMethodsClass = M->getParent();
 auto className = safeGetName(calleeMethodsClass);

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index f8db8d0bc8343..28b96f2717210 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3377,8 +3377,6 @@ 
PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
 BugReport *exampleReport,
 ArrayRef> consumers,
 ArrayRef bugReports) {
-  std::vector BasicBugReports;
-  std::vector PathSensitiveBugReports;
   if (isa(exampleReport))
 return BugReporter::generateDiagnosticForConsumerMap(exampleReport,
  consumers, 
bugReports);

diff  --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index 95d9df4100bfa..84a9c43d3572e 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -270,7 +270,7 @@ static bool isWithinConstantOverflowBounds(llvm::APSInt I) {
   assert(!AT.isUnsigned() &&
  "This only works with signed integers!");
 
-  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4), Min = -Max;
+  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4);
   return (I <= Max) && (I >= -Max);
 }
 

diff  --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 2032b13726c45..c1febaf40bf19 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -703,7 +703,6 @@ TEST(ParseFix

[clang] [clang] Remove unused local variables (NFC) (PR #138468)

2025-05-04 Thread Kazu Hirata via cfe-commits

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


[clang] [Clang] Add `noalias` to `this` pointer in C++ constructors (PR #136792)

2025-05-04 Thread Guy David via cfe-commits

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


[clang] [clang] Add support for Debian 14 Forky and Debian 15 Duke (PR #138460)

2025-05-04 Thread Sylvestre Ledru via cfe-commits

sylvestre wrote:

please let me know i should merge it


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


[clang] [clang] Add support for Debian 14 Forky and Debian 15 Duke (PR #138460)

2025-05-04 Thread Sylvestre Ledru via cfe-commits

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

excellent, thanks!



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


[clang] [clang] Remove unused local variables (NFC) (PR #138453)

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


@@ -361,15 +361,8 @@ TEST(CallDescription, AliasNames) {
   std::cont v;
   v.data();
 })code";
-  constexpr StringRef UseStructNameInSpelling = R"code(
-void foo() {
-  std::container v;
-  v.data();
-})code";
   const std::string UseAliasInSpellingCode =
   (Twine{AliasNamesCode} + UseAliasInSpelling).str();
-  const std::string UseStructNameInSpellingCode =
-  (Twine{AliasNamesCode} + UseStructNameInSpelling).str();

steakhal wrote:

This test code left me wondering if this is dead because it's intended to test 
something or dead because we moved the relevant parts to other tests thus 
become dead.
I think it's safe to remove these lines.

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


[clang] [clang] Remove unused local variables (NFC) (PR #138453)

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

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


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


[clang] [clang][bytecode] Use bytecode interpreter in EvaluateCharRangeAsString (PR #138461)

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

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

This was always using the ast walker.

>From 8d76bc91a3a443b6563cfe26f7558adf73d2f60c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 4 May 2025 07:25:20 +0200
Subject: [PATCH] [clang][bytecode] Use bytecode interpreter in
 EvaluateCharRangeAsString

This was always using the ast walker.
---
 clang/lib/AST/ByteCode/Context.cpp | 79 ++
 clang/lib/AST/ByteCode/Context.h   |  9 +++
 clang/lib/AST/ByteCode/EvalEmitter.cpp | 23 +++
 clang/lib/AST/ByteCode/EvalEmitter.h   |  6 ++
 clang/lib/AST/ByteCode/EvaluationResult.h  |  6 +-
 clang/lib/AST/ByteCode/Pointer.h   |  7 ++
 clang/lib/AST/ExprConstant.cpp |  7 +-
 clang/test/SemaCXX/gnu-asm-constexpr.cpp   |  1 +
 clang/test/SemaCXX/static-assert-cxx26.cpp |  1 +
 9 files changed, 133 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index b35b30cc20d81..db9df7abf7a29 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -134,6 +134,85 @@ bool Context::evaluateAsInitializer(State &Parent, const 
VarDecl *VD,
   return true;
 }
 
+template 
+bool Context::evaluateStringRepr(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, ResultT &Result) {
+  assert(Stk.empty());
+  Compiler C(*this, *P, Parent, Stk);
+
+  // Evaluate size value.
+  APValue SizeValue;
+  if (!evaluateAsRValue(Parent, SizeExpr, SizeValue))
+return false;
+
+  if (!SizeValue.isInt())
+return false;
+  uint64_t Size = SizeValue.getInt().getZExtValue();
+
+  auto PtrRes = C.interpretAsPointer(PtrExpr, [&](const Pointer &Ptr) {
+if (Size == 0) {
+  if constexpr (std::is_same_v)
+Result = APValue(APValue::UninitArray{}, 0, 0);
+  return true;
+}
+
+if (!Ptr.isLive() || !Ptr.getFieldDesc()->isPrimitiveArray())
+  return false;
+
+// Must be char.
+if (Ptr.getFieldDesc()->getElemSize() != 1 /*bytes*/)
+  return false;
+
+if (Size > Ptr.getNumElems()) {
+  Parent.FFDiag(SizeExpr, diag::note_constexpr_access_past_end) << AK_Read;
+  Size = Ptr.getNumElems();
+}
+
+if constexpr (std::is_same_v) {
+  QualType CharTy = PtrExpr->getType()->getPointeeType();
+  Result = APValue(APValue::UninitArray{}, Size, Size);
+  for (uint64_t I = 0; I != Size; ++I) {
+if (std::optional ElemVal =
+Ptr.atIndex(I).toRValue(*this, CharTy))
+  Result.getArrayInitializedElt(I) = *ElemVal;
+else
+  return false;
+  }
+} else {
+  assert((std::is_same_v));
+  if (Size < Result.max_size())
+Result.resize(Size);
+  Result.assign(reinterpret_cast(Ptr.getRawAddress()), Size);
+}
+
+return true;
+  });
+
+  if (PtrRes.isInvalid()) {
+C.cleanup();
+Stk.clear();
+return false;
+  }
+
+  return true;
+}
+
+bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr,
+const Expr *PtrExpr, APValue &Result) {
+  assert(SizeExpr);
+  assert(PtrExpr);
+
+  return evaluateStringRepr(Parent, SizeExpr, PtrExpr, Result);
+}
+
+bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr,
+const Expr *PtrExpr, std::string &Result) {
+  assert(SizeExpr);
+  assert(PtrExpr);
+
+  return evaluateStringRepr(Parent, SizeExpr, PtrExpr, Result);
+}
+
 const LangOptions &Context::getLangOpts() const { return Ctx.getLangOpts(); }
 
 std::optional Context::classify(QualType T) const {
diff --git a/clang/lib/AST/ByteCode/Context.h b/clang/lib/AST/ByteCode/Context.h
index 5a39f40ef3f11..33bc9fad883f8 100644
--- a/clang/lib/AST/ByteCode/Context.h
+++ b/clang/lib/AST/ByteCode/Context.h
@@ -59,6 +59,11 @@ class Context final {
   /// Evaluates a toplevel initializer.
   bool evaluateAsInitializer(State &Parent, const VarDecl *VD, APValue 
&Result);
 
+  bool evaluateCharRange(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, APValue &Result);
+  bool evaluateCharRange(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, std::string &Result);
+
   /// Returns the AST context.
   ASTContext &getASTContext() const { return Ctx; }
   /// Returns the language options.
@@ -122,6 +127,10 @@ class Context final {
   /// Runs a function.
   bool Run(State &Parent, const Function *Func);
 
+  template 
+  bool evaluateStringRepr(State &Parent, const Expr *SizeExpr,
+  const Expr *PtrExpr, ResultT &Result);
+
   /// Current compilation context.
   ASTContext &Ctx;
   /// Interpreter stack, shared across invocations.
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 71d688498ffa5..90aca568c9394 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib

[clang] [clang][bytecode] Use bytecode interpreter in EvaluateCharRangeAsString (PR #138461)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

This was always using the ast walker.

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


9 Files Affected:

- (modified) clang/lib/AST/ByteCode/Context.cpp (+79) 
- (modified) clang/lib/AST/ByteCode/Context.h (+9) 
- (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (+23) 
- (modified) clang/lib/AST/ByteCode/EvalEmitter.h (+6) 
- (modified) clang/lib/AST/ByteCode/EvaluationResult.h (+1-5) 
- (modified) clang/lib/AST/ByteCode/Pointer.h (+7) 
- (modified) clang/lib/AST/ExprConstant.cpp (+6-1) 
- (modified) clang/test/SemaCXX/gnu-asm-constexpr.cpp (+1) 
- (modified) clang/test/SemaCXX/static-assert-cxx26.cpp (+1) 


``diff
diff --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index b35b30cc20d81..db9df7abf7a29 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -134,6 +134,85 @@ bool Context::evaluateAsInitializer(State &Parent, const 
VarDecl *VD,
   return true;
 }
 
+template 
+bool Context::evaluateStringRepr(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, ResultT &Result) {
+  assert(Stk.empty());
+  Compiler C(*this, *P, Parent, Stk);
+
+  // Evaluate size value.
+  APValue SizeValue;
+  if (!evaluateAsRValue(Parent, SizeExpr, SizeValue))
+return false;
+
+  if (!SizeValue.isInt())
+return false;
+  uint64_t Size = SizeValue.getInt().getZExtValue();
+
+  auto PtrRes = C.interpretAsPointer(PtrExpr, [&](const Pointer &Ptr) {
+if (Size == 0) {
+  if constexpr (std::is_same_v)
+Result = APValue(APValue::UninitArray{}, 0, 0);
+  return true;
+}
+
+if (!Ptr.isLive() || !Ptr.getFieldDesc()->isPrimitiveArray())
+  return false;
+
+// Must be char.
+if (Ptr.getFieldDesc()->getElemSize() != 1 /*bytes*/)
+  return false;
+
+if (Size > Ptr.getNumElems()) {
+  Parent.FFDiag(SizeExpr, diag::note_constexpr_access_past_end) << AK_Read;
+  Size = Ptr.getNumElems();
+}
+
+if constexpr (std::is_same_v) {
+  QualType CharTy = PtrExpr->getType()->getPointeeType();
+  Result = APValue(APValue::UninitArray{}, Size, Size);
+  for (uint64_t I = 0; I != Size; ++I) {
+if (std::optional ElemVal =
+Ptr.atIndex(I).toRValue(*this, CharTy))
+  Result.getArrayInitializedElt(I) = *ElemVal;
+else
+  return false;
+  }
+} else {
+  assert((std::is_same_v));
+  if (Size < Result.max_size())
+Result.resize(Size);
+  Result.assign(reinterpret_cast(Ptr.getRawAddress()), Size);
+}
+
+return true;
+  });
+
+  if (PtrRes.isInvalid()) {
+C.cleanup();
+Stk.clear();
+return false;
+  }
+
+  return true;
+}
+
+bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr,
+const Expr *PtrExpr, APValue &Result) {
+  assert(SizeExpr);
+  assert(PtrExpr);
+
+  return evaluateStringRepr(Parent, SizeExpr, PtrExpr, Result);
+}
+
+bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr,
+const Expr *PtrExpr, std::string &Result) {
+  assert(SizeExpr);
+  assert(PtrExpr);
+
+  return evaluateStringRepr(Parent, SizeExpr, PtrExpr, Result);
+}
+
 const LangOptions &Context::getLangOpts() const { return Ctx.getLangOpts(); }
 
 std::optional Context::classify(QualType T) const {
diff --git a/clang/lib/AST/ByteCode/Context.h b/clang/lib/AST/ByteCode/Context.h
index 5a39f40ef3f11..33bc9fad883f8 100644
--- a/clang/lib/AST/ByteCode/Context.h
+++ b/clang/lib/AST/ByteCode/Context.h
@@ -59,6 +59,11 @@ class Context final {
   /// Evaluates a toplevel initializer.
   bool evaluateAsInitializer(State &Parent, const VarDecl *VD, APValue 
&Result);
 
+  bool evaluateCharRange(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, APValue &Result);
+  bool evaluateCharRange(State &Parent, const Expr *SizeExpr,
+ const Expr *PtrExpr, std::string &Result);
+
   /// Returns the AST context.
   ASTContext &getASTContext() const { return Ctx; }
   /// Returns the language options.
@@ -122,6 +127,10 @@ class Context final {
   /// Runs a function.
   bool Run(State &Parent, const Function *Func);
 
+  template 
+  bool evaluateStringRepr(State &Parent, const Expr *SizeExpr,
+  const Expr *PtrExpr, ResultT &Result);
+
   /// Current compilation context.
   ASTContext &Ctx;
   /// Interpreter stack, shared across invocations.
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp 
b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 71d688498ffa5..90aca568c9394 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -72,6 +72,25 @@ EvaluationResult EvalEmitter::interpretDecl(const VarDecl 
*VD,
   return std::move(this->EvalResult);
 }
 
+EvaluationResult EvalEmitter::interpretAsPoint

[clang] 4c587f5 - [clang] Use *(Set|Map)::contains (NFC) (#138464)

2025-05-04 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-05-04T11:56:31-07:00
New Revision: 4c587f549cbbea0ac1db2b983b8c5fb4fff82d72

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

LOG: [clang] Use *(Set|Map)::contains (NFC) (#138464)

Added: 


Modified: 
clang/lib/AST/DeclBase.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/libclang/CXCursor.cpp
clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index fead99c5f28a9..aea19c51401aa 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -2149,8 +2149,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl 
*D, bool Internal) {
   // have already checked the external source.
   if (!Internal)
 if (ExternalASTSource *Source = getParentASTContext().getExternalSource())
-  if (hasExternalVisibleStorage() &&
-  Map->find(D->getDeclName()) == Map->end())
+  if (hasExternalVisibleStorage() && !Map->contains(D->getDeclName()))
 Source->FindExternalVisibleDeclsByName(this, D->getDeclName(),
D->getDeclContext());
 

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 106a652049b07..e47bac0261356 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8646,9 +8646,8 @@ ASTReader::getLoadedSpecializationsLookupTables(const 
Decl *D, bool IsPartial) {
 
 bool ASTReader::haveUnloadedSpecializations(const Decl *D) const {
   assert(D->isCanonicalDecl());
-  return (PartialSpecializationsLookups.find(D) !=
-  PartialSpecializationsLookups.end()) ||
- (SpecializationsLookups.find(D) != SpecializationsLookups.end());
+  return PartialSpecializationsLookups.contains(D) ||
+ SpecializationsLookups.contains(D);
 }
 
 /// Under non-PCH compilation the consumer receives the objc methods

diff  --git a/clang/tools/libclang/CXCursor.cpp 
b/clang/tools/libclang/CXCursor.cpp
index 1d15120106017..635d03a88d105 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -1638,7 +1638,7 @@ unsigned clang_CXCursorSet_contains(CXCursorSet set, 
CXCursor cursor) {
   CXCursorSet_Impl *setImpl = unpackCXCursorSet(set);
   if (!setImpl)
 return 0;
-  return setImpl->find(cursor) != setImpl->end();
+  return setImpl->contains(cursor);
 }
 
 unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) {

diff  --git a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
index de79743a06e1f..e2eb65091bc5a 100644
--- a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
@@ -60,10 +60,8 @@ ParseTemplateParameterList(ParserState &PS,
 } else if (Arg->isSubClassOf("NTTP")) {
   auto Type = Arg->getValueAsString("TypeName");
 
-  if (TemplateNameToParmName.find(Type.str()) ==
-  TemplateNameToParmName.end()) {
+  if (!TemplateNameToParmName.contains(Type.str()))
 PrintFatalError("Unkown Type Name");
-  }
 
   auto TSIName = "TSI" + std::to_string(PS.UniqueCounter++);
   Code << " auto *" << TSIName << " = C.getTrivialTypeSourceInfo(QualType("



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


[clang] [clang] Use *(Set|Map)::contains (NFC) (PR #138464)

2025-05-04 Thread Kazu Hirata via cfe-commits

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


[clang] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix hosts (PR #138466)

2025-05-04 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/138466

`Clang :: Driver/solaris-ld.c` currently `FAIL`s on two non-Unix buildbots: 
[fuchsia-x86_64-linux](https://lab.llvm.org/buildbot/#/builders/11/builds/14369)
 and
[llvm-clang-win-x-aarch64](https://lab.llvm.org/buildbot/#/builders/193/builds/7452).

Judging from `linux-ld.c`, all subtests need `-rtlib=platform 
--unwindlib=platform` whenever host and target have different `rtlib` and 
`unwindlib` defaults, which is what this patch does for `solaris-ld.c`, too.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

>From 34c6251f497d21b49d525c69e83b180d7b577332 Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Sun, 4 May 2025 21:22:33 +0200
Subject: [PATCH] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix
 hosts

`Clang :: Driver/solaris-ld.c` currently `FAIL`s on two non-Unix buildbots:
[fuchsia-x86_64-linux](https://lab.llvm.org/buildbot/#/builders/11/builds/14369)
and
[llvm-clang-win-x-aarch64](https://lab.llvm.org/buildbot/#/builders/193/builds/7452).

Judging from `linux-ld.c`, all subtests need `-rtlib=platform
--unwindlib=platform` whenever host and target have different `rtlib` and
`unwindlib` defaults, which is what this patch does for `solaris-ld.c`,
too.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/test/Driver/solaris-ld.c | 36 +-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 9aa7ed760666d..5940ee2add769 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -3,9 +3,11 @@
 
 // Check sparc-sun-solaris2.11, 32bit
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld= \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-LD %s
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld=gld \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-GLD %s
 // CHECK-LD-SPARC32-NOT: warning:
@@ -29,6 +31,7 @@
 
 // Check sparc-sun-solaris2.11, 64bit
 // RUN: %clang -m64 -### %s 2>&1 --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
 // CHECK-LD-SPARC64-NOT: warning:
@@ -50,6 +53,7 @@
 
 // Check i386-pc-solaris2.11, 32bit
 // RUN: %clang -### %s 2>&1 --target=i386-pc-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
 // CHECK-LD-X32-NOT: warning:
@@ -72,6 +76,7 @@
 // Check i386-pc-solaris2.11, 64bit
 // RUN: %clang -m64 -### %s 2>&1 \
 // RUN: --target=i386-pc-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64 %s
 // CHECK-LD-X64-NOT: warning:
@@ -94,6 +99,7 @@
 // Check the right -l flags are present with -shared
 // RUN: %clang -### %s -shared 2>&1 \
 // RUN: --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC32-SHARED %s
 // CHECK-SPARC32-SHARED: "{{.*}}ld{{(.exe)?}}"
@@ -103,7 +109,7 @@
 
 /// Check that -static-libgcc is supported.
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
-// RUN: -static-libgcc \
+// RUN: -static-libgcc -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-STATIC-LIBGCC %s
 // CHECK-STATIC-LIBGCC-NOT: warning: argument unused during compilation: 
'-static-libgcc'
@@ -112,15 +118,19 @@
 
 // Check that libm is only linked with clang++.
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
 // RUN: %clang -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
 // RUN: %clangxx -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBM %s
 // RUN: %clangxx -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \

[clang] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix hosts (PR #138466)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Rainer Orth (rorth)


Changes

`Clang :: Driver/solaris-ld.c` currently `FAIL`s on two non-Unix buildbots: 
[fuchsia-x86_64-linux](https://lab.llvm.org/buildbot/#/builders/11/builds/14369)
 and
[llvm-clang-win-x-aarch64](https://lab.llvm.org/buildbot/#/builders/193/builds/7452).

Judging from `linux-ld.c`, all subtests need `-rtlib=platform 
--unwindlib=platform` whenever host and target have different `rtlib` and 
`unwindlib` defaults, which is what this patch does for `solaris-ld.c`, too.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and 
`x86_64-pc-linux-gnu`.

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


1 Files Affected:

- (modified) clang/test/Driver/solaris-ld.c (+35-1) 


``diff
diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 9aa7ed760666d..5940ee2add769 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -3,9 +3,11 @@
 
 // Check sparc-sun-solaris2.11, 32bit
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld= \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-LD %s
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld=gld \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-GLD %s
 // CHECK-LD-SPARC32-NOT: warning:
@@ -29,6 +31,7 @@
 
 // Check sparc-sun-solaris2.11, 64bit
 // RUN: %clang -m64 -### %s 2>&1 --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
 // CHECK-LD-SPARC64-NOT: warning:
@@ -50,6 +53,7 @@
 
 // Check i386-pc-solaris2.11, 32bit
 // RUN: %clang -### %s 2>&1 --target=i386-pc-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
 // CHECK-LD-X32-NOT: warning:
@@ -72,6 +76,7 @@
 // Check i386-pc-solaris2.11, 64bit
 // RUN: %clang -m64 -### %s 2>&1 \
 // RUN: --target=i386-pc-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64 %s
 // CHECK-LD-X64-NOT: warning:
@@ -94,6 +99,7 @@
 // Check the right -l flags are present with -shared
 // RUN: %clang -### %s -shared 2>&1 \
 // RUN: --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC32-SHARED %s
 // CHECK-SPARC32-SHARED: "{{.*}}ld{{(.exe)?}}"
@@ -103,7 +109,7 @@
 
 /// Check that -static-libgcc is supported.
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
-// RUN: -static-libgcc \
+// RUN: -static-libgcc -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-STATIC-LIBGCC %s
 // CHECK-STATIC-LIBGCC-NOT: warning: argument unused during compilation: 
'-static-libgcc'
@@ -112,15 +118,19 @@
 
 // Check that libm is only linked with clang++.
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
 // RUN: %clang -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
 // RUN: %clangxx -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBM %s
 // RUN: %clangxx -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBM %s
 // CHECK-LIBM: "-lm"
@@ -128,35 +138,45 @@
 
 // Check the right ld flags are present with -pie.
 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld= \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PIE-LD %s
 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld=gld \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PIE-GLD %s
 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld= \
+// RUN: -rtlib=p

[clang] [clang-linker-wrapper] Remove unused local variables (NFC) (PR #138480)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[   OK ] AddressSanitizer.AtoiAndFriendsOOBTest (2240 ms)
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (9 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (220 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (36 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (119 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (8 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (116 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (132 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN  ] AddressSanitizer.LongDoubleNegativeTest
[   OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms)
[--] 19 tests from AddressSanitizer (28059 ms total)

[--] Global test environment tear-down
[==] 22 tests from 2 test suites ran. (28085 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 1 DISABLED TEST

Step 34 (run instrumented asan tests 
[aarch64/bluejay-userdebug/TQ3A.230805.001]) failure: run instrumented asan 
tests [aarch64/bluejay-userdebug/TQ3A.230805.001] (failure)
...
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (9 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (220 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (36 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (119 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (8 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (116 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (132 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] Addr

[clang] [Clang] Add `noalias` to `this` pointer in C++ constructors (PR #136792)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Guy David (guy-david)


Changes

Note: the patch is probably amending the wrong piece of code, I've tried to add 
it to `buildThisParam` but hit an assertion because of a missing translation 
unit context.

Clang does not transform the following example into a 128-bit load and store:
```c++
class vector4f
{
private:
float _elements[4];
public:
explicit __attribute__((noinline)) vector4f(float const *src)
{
_elements[0] = src[0];
_elements[1] = src[1];
_elements[2] = src[2];
_elements[3] = src[3];
}
};
```
And instead generates 8 memory operations. That's because `src` might overlap 
with `_elements`. However, GCC is able to optimize it for constructors only.

According to the standard in 11.10.4.2 under [class.cdtor]:
> "During the construction of an object, if the value of the object or any 
of its subobjects is accessed through a glvalue that is not obtained, directly 
or indirectly, from the constructor’s this pointer, the value of the object or 
subobject thus obtained is unspecified."

which sounds like `restrict`.

Relevant GCC chain-mail: 
https://gcc.gnu.org/pipermail/gcc-patches/2018-May/498812.html.


---

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


132 Files Affected:

- (modified) clang/lib/CodeGen/CGCall.cpp (+7-2) 
- (modified) clang/test/CodeGen/attr-counted-by-pr88931.cpp (+1-1) 
- (modified) clang/test/CodeGen/attr-noundef.cpp (+152-151) 
- (modified) clang/test/CodeGen/paren-list-agg-init.cpp (+4-4) 
- (modified) clang/test/CodeGen/temporary-lifetime.cpp (+8-8) 
- (modified) clang/test/CodeGenCUDA/offload_via_llvm.cu (+5-5) 
- (modified) clang/test/CodeGenCUDA/record-layout.cu (+10-10) 
- (modified) clang/test/CodeGenCUDA/vtbl.cu (+1-1) 
- (modified) clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp 
(+1-1) 
- (modified) clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp 
(+4-4) 
- (modified) clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/amdgcn-func-arg.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/atomicinit.cpp (+3-3) 
- (modified) clang/test/CodeGenCXX/bug135668.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/cxx2a-consteval.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/cxx2b-deducing-this.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/fcheck-new.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/for-range.cpp (+8-8) 
- (modified) clang/test/CodeGenCXX/gh62818.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/ibm128-declarations.cpp (+4-4) 
- (modified) clang/test/CodeGenCXX/init-invariant.cpp (+5-5) 
- (modified) clang/test/CodeGenCXX/matrix-casts.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/no-elide-constructors.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/nrvo.cpp (+137-137) 
- (modified) clang/test/CodeGenCXX/pr13396.cpp (+4-4) 
- (modified) clang/test/CodeGenCXX/ptrauth-qualifier-struct.cpp (+2-2) 
- (modified) clang/test/CodeGenCXX/trivial_abi_debuginfo.cpp (+1-1) 
- (modified) clang/test/CodeGenCXX/vtt-address-space.cpp (+12-12) 
- (modified) clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp (+1-1) 
- (modified) 
clang/test/CodeGenHLSL/builtins/ByteAddressBuffers-constructors.hlsl (+9-9) 
- (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl (+9-9) 
- (modified) 
clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl (+9-9) 
- (modified) clang/test/Headers/__clang_hip_cmath.hip (+4-4) 
- (modified) clang/test/OpenMP/amdgcn_sret_ctor.cpp (+3-5) 
- (modified) clang/test/OpenMP/amdgcn_target_global_constructor.cpp (+4-4) 
- (modified) clang/test/OpenMP/distribute_firstprivate_codegen.cpp (+36-36) 
- (modified) clang/test/OpenMP/distribute_lastprivate_codegen.cpp (+44-44) 
- (modified) clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp 
(+36-36) 
- (modified) clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp 
(+52-52) 
- (modified) clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp 
(+20-20) 
- (modified) clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp 
(+52-52) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp 
(+259-259) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp 
(+244-244) 
- (modified) 
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp 
(+504-504) 
- (modified) clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp 
(+238-238) 
- (modified) clang/test/OpenMP/distribute_private_codegen.cpp (+44-44) 
- (modified) clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp 
(+168-168) 
- (modified) clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp 
(+176-176) 
- (modified) clang/test/OpenMP/distribute_simd_private_codegen.cpp (+190-190) 
- (modified

[clang] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix hosts (PR #138466)

2025-05-04 Thread Fangrui Song via cfe-commits

MaskRay wrote:

It's not due to non-Unix hosts. It's likely due to these builds setting 
CLANG_DEFAULT_RTLIB and CLANG_DEFAULT_UNWINDLIB.

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


[clang] [clang-format] Don't annotate enum colon as InheritanceColon (PR #138440)

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


@@ -1423,7 +1423,7 @@ class AnnotatingParser {
 Tok->setType(TT_BitFieldColon);
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case,
-  tok::kw_default)) {
+  tok::kw_default, tok::kw_typedef)) {

HazardyKnusperkeks wrote:

Sadly `typedef class` is a thing too, this would break, wouldn't it?

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


[clang] [Driver] Use AddRunTimeLibs on Solaris (PR #137596)

2025-05-04 Thread Rainer Orth via cfe-commits

rorth wrote:

I've just created PR #138466 which hopefully fixes those failures.  Can anyone 
affected please give this a try?

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits

https://github.com/MightyFilipns updated 
https://github.com/llvm/llvm-project/pull/137610

>From 2bbc9f699de5e73d899c5d58607ccfe36aa7a7d7 Mon Sep 17 00:00:00 2001
From: MightyFilipns 
Date: Mon, 28 Apr 2025 11:54:20 +0200
Subject: [PATCH] clang-format: Add SpaceAfterOperatorKeyword option

---
 clang/docs/ClangFormatStyleOptions.rst | 10 ++
 clang/docs/ReleaseNotes.rst|  1 +
 clang/include/clang/Format/Format.h|  9 +
 clang/lib/Format/Format.cpp|  3 +++
 clang/lib/Format/TokenAnnotator.cpp|  2 +-
 clang/unittests/Format/ConfigParseTest.cpp |  1 +
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 7 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 3f8a5f49313b2..eb67166e822b9 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6104,6 +6104,16 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  ! someExpression();vs. !someExpression();
 
+.. _SpaceAfterOperatorKeyword:
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 22` 
:ref:`¶ `
+  If ``true``, a space will be inserted after the ``operator`` keyword.
+
+  .. code-block:: c++
+
+ true:false:
+ bool operator == (int a) vs. bool operator== (int a)
+
 .. _SpaceAfterTemplateKeyword:
 
 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3105d8b481560..a058f9b1d1a87 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -695,6 +695,7 @@ clang-format
   top of the file.
 - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
   ``enum`` enumerator lists.
+- Add ``SpaceAfterOperatorKeyword`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f6ceef08b46da..c9557b0c6d65e 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4463,6 +4463,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If ``true``, a space will be inserted after the ``operator`` keyword.
+  /// \code
+  ///true:false:
+  ///bool operator ==(int a); vs. bool operator==(int a);
+  /// \endcode
+  /// \version 21
+  bool SpaceAfterOperatorKeyword;
+
   /// If \c true, a space will be inserted after the ``template`` keyword.
   /// \code
   ///true:  false:
@@ -5432,6 +5440,7 @@ struct FormatStyle {
SortJavaStaticImport == R.SortJavaStaticImport &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
+   SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 5a1c3f556b331..fdb26165beee0 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1151,6 +1151,8 @@ template <> struct MappingTraits {
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
@@ -1638,6 +1640,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index e56cc92987af7..1c7a0d92fefb3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5030,7 +5030,7 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 }
 
 if (Left.is(tok::kw_operator))
-  return Right.is(tok::coloncolon);
+  return Right.is(tok::coloncolon) || Style.SpaceAfterOperatorKeyword;
 if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) &&
 !L

[clang] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix hosts (PR #138466)

2025-05-04 Thread Fangrui Song via cfe-commits

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


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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits

https://github.com/MightyFilipns updated 
https://github.com/llvm/llvm-project/pull/137610

>From aabc71f63914ec58e312fc89f6102919333f0b7f Mon Sep 17 00:00:00 2001
From: MightyFilipns 
Date: Mon, 28 Apr 2025 11:54:20 +0200
Subject: [PATCH] clang-format: Add SpaceAfterOperatorKeyword option

# Conflicts:
#   clang/docs/ReleaseNotes.rst
---
 clang/docs/ClangFormatStyleOptions.rst |  10 ++
 clang/docs/ReleaseNotes.rst| 105 ++---
 clang/include/clang/Format/Format.h|   9 ++
 clang/lib/Format/Format.cpp|   3 +
 clang/lib/Format/TokenAnnotator.cpp|   2 +-
 clang/unittests/Format/ConfigParseTest.cpp |   1 +
 clang/unittests/Format/FormatTest.cpp  |   6 ++
 7 files changed, 38 insertions(+), 98 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index b47291599649d..b1d2e09ddaad1 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6127,6 +6127,16 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  ! someExpression();vs. !someExpression();
 
+.. _SpaceAfterOperatorKeyword:
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 22` 
:ref:`¶ `
+  If ``true``, a space will be inserted after the ``operator`` keyword.
+
+  .. code-block:: c++
+
+ true:false:
+ bool operator == (int a) vs. bool operator== (int a)
+
 .. _SpaceAfterTemplateKeyword:
 
 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 918ff952bb2c3..436d34dd5bb7d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -134,8 +134,6 @@ Resolutions to C++ Defect Reports
 - Bumped the ``__cpp_constexpr`` feature-test macro to ``202002L`` in C++20 
mode as indicated in
   `P2493R0 `_.
 
-- Implemented `CWG3005 Function parameters should never be name-independent 
`_.
-
 C Language Changes
 --
 
@@ -143,75 +141,15 @@ C Language Changes
   function type in Microsoft compatibility mode. #GH124869
 - Clang now allows ``restrict`` qualifier for array types with pointer 
elements (#GH92847).
 - Clang now diagnoses ``const``-qualified object definitions without an
-  initializer. If the object is a variable or field which is zero-initialized,
-  it will be diagnosed under the new warning ``-Wdefault-const-init-var`` or
-  ``-Wdefault-const-init-field``, respectively. Similarly, if the variable or
-  field is not zero-initialized, it will be diagnosed under the new diagnostic
-  ``-Wdefault-const-init-var-unsafe`` or ``-Wdefault-const-init-field-unsafe``,
-  respectively. The unsafe diagnostic variants are grouped under a new
-  diagnostic ``-Wdefault-const-init-unsafe``, which itself is grouped under the
-  new diagnostic ``-Wdefault-const-init``. Finally, ``-Wdefault-const-init`` is
-  grouped under ``-Wc++-compat`` because these constructs are not compatible
-  with C++. #GH19297
+  initializer. If the object is zero-initialized, it will be diagnosed under
+  the new warning ``-Wdefault-const-init`` (which is grouped under
+  ``-Wc++-compat`` because this construct is not compatible with C++). If the
+  object is left uninitialized, it will be diagnosed unsed the new warning
+  ``-Wdefault-const-init-unsafe`` (which is grouped under
+  ``-Wdefault-const-init``). #GH19297
 - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which
   diagnoses implicit conversion from ``void *`` to another pointer type as
   being incompatible with C++. (#GH17792)
-- Added ``-Wc++-keyword``, grouped under ``-Wc++-compat``, which diagnoses when
-  a C++ keyword is used as an identifier in C. (#GH21898)
-- Added ``-Wc++-hidden-decl``, grouped under ``-Wc++-compat``, which diagnoses
-  use of tag types which are visible in C but not visible in C++ due to scoping
-  rules. e.g.,
-
-  .. code-block:: c
-
-struct S {
-  struct T {
-int x;
-  } t;
-};
-struct T t; // Invalid C++, valid C, now diagnosed
-- Added ``-Wimplicit-int-enum-cast``, grouped under ``-Wc++-compat``, which
-  diagnoses implicit conversion from integer types to an enumeration type in C,
-  which is not compatible with C++. #GH37027
-- Split "implicit conversion from enum type to different enum type" diagnostic
-  from ``-Wenum-conversion`` into its own diagnostic group,
-  ``-Wimplicit-enum-enum-cast``, which is grouped under both
-  ``-Wenum-conversion`` and ``-Wimplicit-int-enum-cast``. This conversion is an
-  int-to-enum conversion because the enumeration on the right-hand side is
-  promoted to ``int`` before the assignment.
-- Added ``-Wtentative-definition-compat``, grouped under ``-Wc++-compat``,
-  which diagnoses tentative definitions in C with mul

[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits

https://github.com/MightyFilipns updated 
https://github.com/llvm/llvm-project/pull/137610

>From 601985f75cf961f585a3d232868eda3a400878fc Mon Sep 17 00:00:00 2001
From: MightyFilipns 
Date: Mon, 28 Apr 2025 11:54:20 +0200
Subject: [PATCH] clang-format: Add SpaceAfterOperatorKeyword option

---
 clang/docs/ClangFormatStyleOptions.rst | 10 ++
 clang/docs/ReleaseNotes.rst|  3 ++-
 clang/include/clang/Format/Format.h|  9 +
 clang/lib/Format/Format.cpp|  3 +++
 clang/lib/Format/TokenAnnotator.cpp|  2 +-
 clang/unittests/Format/ConfigParseTest.cpp |  1 +
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 7 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index b47291599649d..b1d2e09ddaad1 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6127,6 +6127,16 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  ! someExpression();vs. !someExpression();
 
+.. _SpaceAfterOperatorKeyword:
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 22` 
:ref:`¶ `
+  If ``true``, a space will be inserted after the ``operator`` keyword.
+
+  .. code-block:: c++
+
+ true:false:
+ bool operator == (int a) vs. bool operator== (int a)
+
 .. _SpaceAfterTemplateKeyword:
 
 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 918ff952bb2c3..e08b52c355387 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -786,6 +786,7 @@ clang-format
 - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
   ``enum`` enumerator lists.
 - Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
+- Add ``SpaceAfterOperatorKeyword`` option.
 
 libclang
 
@@ -876,4 +877,4 @@ tree.
 
 If you have any questions or comments about Clang, please feel free to
 contact us on the `Discourse forums (Clang Frontend category)
-`_.
+`_.
\ No newline at end of file
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7fe41d800ccb3..b86c4bd00eb91 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4484,6 +4484,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If ``true``, a space will be inserted after the ``operator`` keyword.
+  /// \code
+  ///true:false:
+  ///bool operator ==(int a); vs. bool operator==(int a);
+  /// \endcode
+  /// \version 21
+  bool SpaceAfterOperatorKeyword;
+
   /// If \c true, a space will be inserted after the ``template`` keyword.
   /// \code
   ///true:  false:
@@ -5454,6 +5462,7 @@ struct FormatStyle {
SortJavaStaticImport == R.SortJavaStaticImport &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
+   SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f4b64ef4f5fe..20b5352b83a9e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1152,6 +1152,8 @@ template <> struct MappingTraits {
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
@@ -1639,6 +1641,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index caf386cffd25b..50a22149f7bd9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/Toke

[clang] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix hosts (PR #138466)

2025-05-04 Thread Rainer Orth via cfe-commits

rorth wrote:

> It's not due to non-Unix hosts. It's likely due to these builds setting 
> CLANG_DEFAULT_RTLIB and CLANG_DEFAULT_UNWINDLIB.

That occured to me shortly after I created the PR.  I'll fix the description 
accordingly.

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


[clang] 142f99a - [clang][Driver][test] Fix Driver/solaris-ld.c (#138466)

2025-05-04 Thread via cfe-commits

Author: Rainer Orth
Date: 2025-05-04T21:44:56+02:00
New Revision: 142f99ad645f9e77dd5adb470e41c55ce6d37b2b

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

LOG: [clang][Driver][test] Fix Driver/solaris-ld.c (#138466)

`Clang :: Driver/solaris-ld.c` currently `FAIL`s on two buildbots:
[fuchsia-x86_64-linux](https://lab.llvm.org/buildbot/#/builders/11/builds/14369)
and

[llvm-clang-win-x-aarch64](https://lab.llvm.org/buildbot/#/builders/193/builds/7452).

Judging from `linux-ld.c`, all subtests need `-rtlib=platform
--unwindlib=platform` whenever host and target have different `rtlib`
and `unwindlib` defaults, which is what this patch does for
`solaris-ld.c`, too.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Added: 


Modified: 
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 9aa7ed760666d..5940ee2add769 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -3,9 +3,11 @@
 
 // Check sparc-sun-solaris2.11, 32bit
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld= \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-LD %s
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld=gld \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-GLD %s
 // CHECK-LD-SPARC32-NOT: warning:
@@ -29,6 +31,7 @@
 
 // Check sparc-sun-solaris2.11, 64bit
 // RUN: %clang -m64 -### %s 2>&1 --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
 // CHECK-LD-SPARC64-NOT: warning:
@@ -50,6 +53,7 @@
 
 // Check i386-pc-solaris2.11, 32bit
 // RUN: %clang -### %s 2>&1 --target=i386-pc-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
 // CHECK-LD-X32-NOT: warning:
@@ -72,6 +76,7 @@
 // Check i386-pc-solaris2.11, 64bit
 // RUN: %clang -m64 -### %s 2>&1 \
 // RUN: --target=i386-pc-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64 %s
 // CHECK-LD-X64-NOT: warning:
@@ -94,6 +99,7 @@
 // Check the right -l flags are present with -shared
 // RUN: %clang -### %s -shared 2>&1 \
 // RUN: --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC32-SHARED %s
 // CHECK-SPARC32-SHARED: "{{.*}}ld{{(.exe)?}}"
@@ -103,7 +109,7 @@
 
 /// Check that -static-libgcc is supported.
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
-// RUN: -static-libgcc \
+// RUN: -static-libgcc -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefixes=CHECK-STATIC-LIBGCC %s
 // CHECK-STATIC-LIBGCC-NOT: warning: argument unused during compilation: 
'-static-libgcc'
@@ -112,15 +118,19 @@
 
 // Check that libm is only linked with clang++.
 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
 // RUN: %clang -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
 // RUN: %clangxx -### %s --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBM %s
 // RUN: %clangxx -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBM %s
 // CHECK-LIBM: "-lm"
@@ -128,35 +138,45 @@
 
 // Check the right ld flags are present with -pie.
 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld= \
+// RUN: -rtlib=platform --unwindlib=platform \
 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PIE-LD %s
 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld=gld \
+/

[clang] [clang][Driver][test] Fix Driver/solaris-ld.c on non-Unix hosts (PR #138466)

2025-05-04 Thread Rainer Orth via cfe-commits

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits

https://github.com/MightyFilipns updated 
https://github.com/llvm/llvm-project/pull/137610

>From d18481a5535c64267bd00c84252a81d9dc6baecd Mon Sep 17 00:00:00 2001
From: MightyFilipns 
Date: Mon, 28 Apr 2025 11:54:20 +0200
Subject: [PATCH] clang-format: Add SpaceAfterOperatorKeyword option

---
 clang/docs/ClangFormatStyleOptions.rst | 10 ++
 clang/docs/ReleaseNotes.rst|  3 ++-
 clang/include/clang/Format/Format.h|  9 +
 clang/lib/Format/Format.cpp|  3 +++
 clang/lib/Format/TokenAnnotator.cpp|  2 +-
 clang/unittests/Format/ConfigParseTest.cpp |  1 +
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 7 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index b47291599649d..b1d2e09ddaad1 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6127,6 +6127,16 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  ! someExpression();vs. !someExpression();
 
+.. _SpaceAfterOperatorKeyword:
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 22` 
:ref:`¶ `
+  If ``true``, a space will be inserted after the ``operator`` keyword.
+
+  .. code-block:: c++
+
+ true:false:
+ bool operator == (int a) vs. bool operator== (int a)
+
 .. _SpaceAfterTemplateKeyword:
 
 **SpaceAfterTemplateKeyword** (``Boolean``) :versionbadge:`clang-format 4` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 918ff952bb2c3..e08b52c355387 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -786,6 +786,7 @@ clang-format
 - Add ``EnumTrailingComma`` option for inserting/removing commas at the end of
   ``enum`` enumerator lists.
 - Add ``OneLineFormatOffRegex`` option for turning formatting off for one line.
+- Add ``SpaceAfterOperatorKeyword`` option.
 
 libclang
 
@@ -876,4 +877,4 @@ tree.
 
 If you have any questions or comments about Clang, please feel free to
 contact us on the `Discourse forums (Clang Frontend category)
-`_.
+`_.
\ No newline at end of file
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7fe41d800ccb3..b86c4bd00eb91 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4484,6 +4484,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If ``true``, a space will be inserted after the ``operator`` keyword.
+  /// \code
+  ///true:false:
+  ///bool operator ==(int a); vs. bool operator==(int a);
+  /// \endcode
+  /// \version 21
+  bool SpaceAfterOperatorKeyword;
+
   /// If \c true, a space will be inserted after the ``template`` keyword.
   /// \code
   ///true:  false:
@@ -5454,6 +5462,7 @@ struct FormatStyle {
SortJavaStaticImport == R.SortJavaStaticImport &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
+   SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f4b64ef4f5fe..20b5352b83a9e 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1152,6 +1152,8 @@ template <> struct MappingTraits {
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
+IO.mapOptional("SpaceAfterOperatorKeyword",
+   Style.SpaceAfterOperatorKeyword);
 IO.mapOptional("SpaceAfterTemplateKeyword",
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceAroundPointerQualifiers",
@@ -1639,6 +1641,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;
   LLVMStyle.SpaceAfterCStyleCast = false;
   LLVMStyle.SpaceAfterLogicalNot = false;
+  LLVMStyle.SpaceAfterOperatorKeyword = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index caf386cffd25b..50a22149f7bd9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/Toke

[clang] [clang] Use *(Set|Map)::contains (NFC) (PR #138464)

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

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


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


[clang] [clang] Add support for Debian 14 Forky and Debian 15 Duke (PR #138460)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: lit :: allow-retries.py (89893 of 89902)
PASS: lit :: discovery.py (89894 of 89902)
PASS: lit :: shtest-external-shell-kill.py (89895 of 89902)
PASS: lit :: googletest-timeout.py (89896 of 89902)
PASS: lit :: selecting.py (89897 of 89902)
PASS: lit :: shtest-timeout.py (89898 of 89902)
PASS: lit :: max-time.py (89899 of 89902)
PASS: lit :: shtest-shell.py (89900 of 89902)
PASS: lit :: shtest-define.py (89901 of 89902)
TIMEOUT: AddressSanitizer-x86_64-linux-dynamic :: 
TestCases/asan_lsan_deadlock.cpp (89902 of 89902)
 TEST 'AddressSanitizer-x86_64-linux-dynamic :: 
TestCases/asan_lsan_deadlock.cpp' FAILED 
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/clang  
--driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer 
-fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only  -m64  
-shared-libasan -O0 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/compiler-rt/test/asan/TestCases/asan_lsan_deadlock.cpp
 -o 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_lsan_deadlock.cpp.tmp
 # RUN: at line 4
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/clang 
--driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer 
-fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 
-shared-libasan -O0 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/compiler-rt/test/asan/TestCases/asan_lsan_deadlock.cpp
 -o 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_lsan_deadlock.cpp.tmp
env ASAN_OPTIONS=detect_leaks=1 not  
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_lsan_deadlock.cpp.tmp
 2>&1 | FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/compiler-rt/test/asan/TestCases/asan_lsan_deadlock.cpp
 # RUN: at line 5
+ env ASAN_OPTIONS=detect_leaks=1 not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/runtimes/runtimes-bins/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/asan_lsan_deadlock.cpp.tmp
+ FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/compiler-rt/test/asan/TestCases/asan_lsan_deadlock.cpp

--



Timed Out Tests (1):
  AddressSanitizer-x86_64-linux-dynamic :: TestCases/asan_lsan_deadlock.cpp


Testing Time: 1169.99s

Total Discovered Tests: 124386
  Skipped  : 38 (0.03%)
  Unsupported  :   2646 (2.13%)
  Passed   : 121410 (97.61%)
  Expectedly Failed:291 (0.23%)
  Timed Out:  1 (0.00%)
FAILED: CMakeFiles/check-all 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/CMakeFiles/check-all
 
cd /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build && 
/usr/bin/python3.8 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/llvm-lit 
--verbose --timeout=900 --param USE_Z3_SOLVER=0 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/utils/mlgo-utils
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/cross-project-tests
 /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/lld/test 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/tools/extra/include-cleaner/test
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/tools/extra/test
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/tools/clang/test
 
@/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/runtimes/runtimes-bins/lit.tests
 /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/utils/lit 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/test
ninja: build stopped: subcommand failed.

```



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


[clang] [clang] Use *(Set|Map)::contains (NFC) (PR #138464)

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

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


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


[clang] [clang-linker-wrapper] Remove unused local variables (NFC) (PR #138480)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


1 Files Affected:

- (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (-5) 


``diff
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index bdeaa2031d184..63f6e641d8c9e 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -418,9 +418,6 @@ fatbinary(ArrayRef> 
InputFiles,
   if (!OffloadBundlerPath)
 return OffloadBundlerPath.takeError();
 
-  llvm::Triple Triple(
-  Args.getLastArgValue(OPT_host_triple_EQ, sys::getDefaultTargetTriple()));
-
   // Create a new file to write the linked device image to.
   auto TempFileOrErr =
   createOutputFile(sys::path::filename(ExecutableName), "hipfb");
@@ -758,7 +755,6 @@ bundleCuda(ArrayRef Images, const ArgList 
&Args) {
 InputFiles.emplace_back(std::make_pair(Image.Image->getBufferIdentifier(),
Image.StringData.lookup("arch")));
 
-  Triple TheTriple = Triple(Images.front().StringData.lookup("triple"));
   auto FileOrErr = nvptx::fatbinary(InputFiles, Args);
   if (!FileOrErr)
 return FileOrErr.takeError();
@@ -781,7 +777,6 @@ bundleHIP(ArrayRef Images, const ArgList 
&Args) {
 InputFiles.emplace_back(std::make_pair(Image.Image->getBufferIdentifier(),
Image.StringData.lookup("arch")));
 
-  Triple TheTriple = Triple(Images.front().StringData.lookup("triple"));
   auto FileOrErr = amdgcn::fatbinary(InputFiles, Args);
   if (!FileOrErr)
 return FileOrErr.takeError();

``




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


[clang] [clang-linker-wrapper] Remove unused local variables (NFC) (PR #138480)

2025-05-04 Thread Joseph Huber via cfe-commits

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


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


[clang] [clang-linker-wrapper] Remove unused local variables (NFC) (PR #138480)

2025-05-04 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/138480

None

>From fb19c7799d3ac769eb75d9fee0a3a8b7827d1908 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 4 May 2025 19:13:57 -0700
Subject: [PATCH] [clang-linker-wrapper] Remove unused local variables (NFC)

---
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 5 -
 1 file changed, 5 deletions(-)

diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index bdeaa2031d184..63f6e641d8c9e 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -418,9 +418,6 @@ fatbinary(ArrayRef> 
InputFiles,
   if (!OffloadBundlerPath)
 return OffloadBundlerPath.takeError();
 
-  llvm::Triple Triple(
-  Args.getLastArgValue(OPT_host_triple_EQ, sys::getDefaultTargetTriple()));
-
   // Create a new file to write the linked device image to.
   auto TempFileOrErr =
   createOutputFile(sys::path::filename(ExecutableName), "hipfb");
@@ -758,7 +755,6 @@ bundleCuda(ArrayRef Images, const ArgList 
&Args) {
 InputFiles.emplace_back(std::make_pair(Image.Image->getBufferIdentifier(),
Image.StringData.lookup("arch")));
 
-  Triple TheTriple = Triple(Images.front().StringData.lookup("triple"));
   auto FileOrErr = nvptx::fatbinary(InputFiles, Args);
   if (!FileOrErr)
 return FileOrErr.takeError();
@@ -781,7 +777,6 @@ bundleHIP(ArrayRef Images, const ArgList 
&Args) {
 InputFiles.emplace_back(std::make_pair(Image.Image->getBufferIdentifier(),
Image.StringData.lookup("arch")));
 
-  Triple TheTriple = Triple(Images.front().StringData.lookup("triple"));
   auto FileOrErr = amdgcn::fatbinary(InputFiles, Args);
   if (!FileOrErr)
 return FileOrErr.takeError();

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


[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-05-04 Thread via cfe-commits


@@ -5056,13 +5056,13 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
   S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T;
 } else
   diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
-
-// C++2a [dcl.fct]p12:
-//   A volatile-qualified return type is deprecated
-if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
-  S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
   }
 
+  // C++2a [dcl.fct]p12:
+  //   A volatile-qualified return type is deprecated
+  if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
+S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;

halbi2 wrote:

I understand that `CheckFunctionReturnType` is used when checking the type of a 
function like `using T = volatile int();` but this codepath here is used when 
checking a function declaration instead.

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


[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-05-04 Thread via cfe-commits


@@ -231,6 +231,13 @@ namespace DeprecatedVolatile {
 a = c = a;
 b += a;
   }
+
+  volatile struct amber jurassic();

halbi2 wrote:

Lines 207-215 are that, are they not?

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits


@@ -17630,6 +17630,10 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
   verifyFormat("int x = int (y);", SomeSpace2);
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
 
+  FormatStyle SpaceAfterOperatorKeyword = getLLVMStyle();
+  SpaceAfterOperatorKeyword.SpaceAfterOperatorKeyword = true;
+  verifyFormat("bool operator ++(int a)", SpaceAfterOperatorKeyword);

MightyFilipns wrote:

I have moved this into a separate TEST_F

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits


@@ -17630,6 +17630,10 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
   verifyFormat("int x = int (y);", SomeSpace2);
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
 
+  FormatStyle SpaceAfterOperatorKeyword = getLLVMStyle();
+  SpaceAfterOperatorKeyword.SpaceAfterOperatorKeyword = true;
+  verifyFormat("bool operator ++(int a)", SpaceAfterOperatorKeyword);

MightyFilipns wrote:

Fixed

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits


@@ -17630,6 +17630,10 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
   verifyFormat("int x = int (y);", SomeSpace2);
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
 
+  FormatStyle SpaceAfterOperatorKeyword = getLLVMStyle();

MightyFilipns wrote:

Fixed

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


[clang] [clang] Remove unused local variables (NFC) (PR #138468)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


7 Files Affected:

- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
(-2) 
- (modified) clang/lib/Sema/SemaPPC.cpp (-1) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (-2) 
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
(-2) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (-2) 
- (modified) clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (+1-1) 
- (modified) clang/unittests/Tooling/CompilationDatabaseTest.cpp (-1) 


``diff
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index e084a13995306..d4052ef90de6e 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -324,8 +324,6 @@ class SMTConstraintManager : public 
clang::ento::SimpleConstraintManager {
 
 // Construct the logical AND of all the constraints
 if (I != IE) {
-  std::vector ASTs;
-
   llvm::SMTExprRef Constraint = I++->second;
   while (I != IE) {
 Constraint = Solver->mkAnd(Constraint, I++->second);
diff --git a/clang/lib/Sema/SemaPPC.cpp b/clang/lib/Sema/SemaPPC.cpp
index b6802d6890ed1..9b4d82745f881 100644
--- a/clang/lib/Sema/SemaPPC.cpp
+++ b/clang/lib/Sema/SemaPPC.cpp
@@ -98,7 +98,6 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI,
   CallExpr *TheCall) {
   ASTContext &Context = getASTContext();
   bool IsTarget64Bit = TI.getTypeWidth(TI.getIntPtrType()) == 64;
-  llvm::APSInt Result;
 
   if (isPPC_64Builtin(BuiltinID) && !IsTarget64Bit)
 return Diag(TheCall->getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0ecdbb3ffb89f..c9de36383d334 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6605,8 +6605,6 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
 llvm_unreachable("Unexpected Result");
   }
 
-  SmallVector DeducedArgs(Deduced.begin(), Deduced.end());
-
   TemplateDeductionResult TDK;
   runWithSufficientStackSpace(Info.getLocation(), [&] {
 TDK = ::FinishTemplateArgumentDeduction(
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 0f0184c472f36..4ddd11495f534 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -370,8 +370,6 @@ std::optional isUnsafePtr(const QualType T, bool 
IsArcEnabled) {
 std::optional isGetterOfSafePtr(const CXXMethodDecl *M) {
   assert(M);
 
-  std::optional RTC;
-
   if (isa(M)) {
 const CXXRecordDecl *calleeMethodsClass = M->getParent();
 auto className = safeGetName(calleeMethodsClass);
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index f8db8d0bc8343..28b96f2717210 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3377,8 +3377,6 @@ 
PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
 BugReport *exampleReport,
 ArrayRef> consumers,
 ArrayRef bugReports) {
-  std::vector BasicBugReports;
-  std::vector PathSensitiveBugReports;
   if (isa(exampleReport))
 return BugReporter::generateDiagnosticForConsumerMap(exampleReport,
  consumers, 
bugReports);
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index 95d9df4100bfa..84a9c43d3572e 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -270,7 +270,7 @@ static bool isWithinConstantOverflowBounds(llvm::APSInt I) {
   assert(!AT.isUnsigned() &&
  "This only works with signed integers!");
 
-  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4), Min = -Max;
+  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4);
   return (I <= Max) && (I >= -Max);
 }
 
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 2032b13726c45..c1febaf40bf19 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -703,7 +703,6 @@ TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
   ASSERT_EQ(".", Result[0].Directory);
-  std::vector Expecte

[clang] [clang] Remove unused local variables (NFC) (PR #138468)

2025-05-04 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/138468

None

>From 89189fd5a12716b35019271a7473887867b2c3e1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 4 May 2025 13:03:48 -0700
Subject: [PATCH] [clang] Remove unused local variables (NFC)

---
 .../StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h| 2 --
 clang/lib/Sema/SemaPPC.cpp  | 1 -
 clang/lib/Sema/SemaTemplateDeduction.cpp| 2 --
 clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp  | 2 --
 clang/lib/StaticAnalyzer/Core/BugReporter.cpp   | 2 --
 clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp | 2 +-
 clang/unittests/Tooling/CompilationDatabaseTest.cpp | 1 -
 7 files changed, 1 insertion(+), 11 deletions(-)

diff --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index e084a13995306..d4052ef90de6e 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -324,8 +324,6 @@ class SMTConstraintManager : public 
clang::ento::SimpleConstraintManager {
 
 // Construct the logical AND of all the constraints
 if (I != IE) {
-  std::vector ASTs;
-
   llvm::SMTExprRef Constraint = I++->second;
   while (I != IE) {
 Constraint = Solver->mkAnd(Constraint, I++->second);
diff --git a/clang/lib/Sema/SemaPPC.cpp b/clang/lib/Sema/SemaPPC.cpp
index b6802d6890ed1..9b4d82745f881 100644
--- a/clang/lib/Sema/SemaPPC.cpp
+++ b/clang/lib/Sema/SemaPPC.cpp
@@ -98,7 +98,6 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI,
   CallExpr *TheCall) {
   ASTContext &Context = getASTContext();
   bool IsTarget64Bit = TI.getTypeWidth(TI.getIntPtrType()) == 64;
-  llvm::APSInt Result;
 
   if (isPPC_64Builtin(BuiltinID) && !IsTarget64Bit)
 return Diag(TheCall->getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0ecdbb3ffb89f..c9de36383d334 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6605,8 +6605,6 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
 llvm_unreachable("Unexpected Result");
   }
 
-  SmallVector DeducedArgs(Deduced.begin(), Deduced.end());
-
   TemplateDeductionResult TDK;
   runWithSufficientStackSpace(Info.getLocation(), [&] {
 TDK = ::FinishTemplateArgumentDeduction(
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 0f0184c472f36..4ddd11495f534 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -370,8 +370,6 @@ std::optional isUnsafePtr(const QualType T, bool 
IsArcEnabled) {
 std::optional isGetterOfSafePtr(const CXXMethodDecl *M) {
   assert(M);
 
-  std::optional RTC;
-
   if (isa(M)) {
 const CXXRecordDecl *calleeMethodsClass = M->getParent();
 auto className = safeGetName(calleeMethodsClass);
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index f8db8d0bc8343..28b96f2717210 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3377,8 +3377,6 @@ 
PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
 BugReport *exampleReport,
 ArrayRef> consumers,
 ArrayRef bugReports) {
-  std::vector BasicBugReports;
-  std::vector PathSensitiveBugReports;
   if (isa(exampleReport))
 return BugReporter::generateDiagnosticForConsumerMap(exampleReport,
  consumers, 
bugReports);
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index 95d9df4100bfa..84a9c43d3572e 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -270,7 +270,7 @@ static bool isWithinConstantOverflowBounds(llvm::APSInt I) {
   assert(!AT.isUnsigned() &&
  "This only works with signed integers!");
 
-  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4), Min = -Max;
+  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4);
   return (I <= Max) && (I >= -Max);
 }
 
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 2032b13726c45..c1febaf40bf19 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -703,7 +703,6 @@ TEST(ParseFixedCompilationDatabase, HandlesArgv

[clang] [clang] Remove unused local variables (NFC) (PR #138468)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Kazu Hirata (kazutakahirata)


Changes



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


7 Files Affected:

- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
(-2) 
- (modified) clang/lib/Sema/SemaPPC.cpp (-1) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (-2) 
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
(-2) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (-2) 
- (modified) clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (+1-1) 
- (modified) clang/unittests/Tooling/CompilationDatabaseTest.cpp (-1) 


``diff
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
index e084a13995306..d4052ef90de6e 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
@@ -324,8 +324,6 @@ class SMTConstraintManager : public 
clang::ento::SimpleConstraintManager {
 
 // Construct the logical AND of all the constraints
 if (I != IE) {
-  std::vector ASTs;
-
   llvm::SMTExprRef Constraint = I++->second;
   while (I != IE) {
 Constraint = Solver->mkAnd(Constraint, I++->second);
diff --git a/clang/lib/Sema/SemaPPC.cpp b/clang/lib/Sema/SemaPPC.cpp
index b6802d6890ed1..9b4d82745f881 100644
--- a/clang/lib/Sema/SemaPPC.cpp
+++ b/clang/lib/Sema/SemaPPC.cpp
@@ -98,7 +98,6 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI,
   CallExpr *TheCall) {
   ASTContext &Context = getASTContext();
   bool IsTarget64Bit = TI.getTypeWidth(TI.getIntPtrType()) == 64;
-  llvm::APSInt Result;
 
   if (isPPC_64Builtin(BuiltinID) && !IsTarget64Bit)
 return Diag(TheCall->getBeginLoc(), diag::err_64_bit_builtin_32_bit_tgt)
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0ecdbb3ffb89f..c9de36383d334 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6605,8 +6605,6 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
 llvm_unreachable("Unexpected Result");
   }
 
-  SmallVector DeducedArgs(Deduced.begin(), Deduced.end());
-
   TemplateDeductionResult TDK;
   runWithSufficientStackSpace(Info.getLocation(), [&] {
 TDK = ::FinishTemplateArgumentDeduction(
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 0f0184c472f36..4ddd11495f534 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -370,8 +370,6 @@ std::optional isUnsafePtr(const QualType T, bool 
IsArcEnabled) {
 std::optional isGetterOfSafePtr(const CXXMethodDecl *M) {
   assert(M);
 
-  std::optional RTC;
-
   if (isa(M)) {
 const CXXRecordDecl *calleeMethodsClass = M->getParent();
 auto className = safeGetName(calleeMethodsClass);
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index f8db8d0bc8343..28b96f2717210 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3377,8 +3377,6 @@ 
PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
 BugReport *exampleReport,
 ArrayRef> consumers,
 ArrayRef bugReports) {
-  std::vector BasicBugReports;
-  std::vector PathSensitiveBugReports;
   if (isa(exampleReport))
 return BugReporter::generateDiagnosticForConsumerMap(exampleReport,
  consumers, 
bugReports);
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
index 95d9df4100bfa..84a9c43d3572e 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -270,7 +270,7 @@ static bool isWithinConstantOverflowBounds(llvm::APSInt I) {
   assert(!AT.isUnsigned() &&
  "This only works with signed integers!");
 
-  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4), Min = -Max;
+  llvm::APSInt Max = AT.getMaxValue() / AT.getValue(4);
   return (I <= Max) && (I >= -Max);
 }
 
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp 
b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index 2032b13726c45..c1febaf40bf19 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -703,7 +703,6 @@ TEST(ParseFixedCompilationDatabase, HandlesArgv0) {
 Database->getCompileCommands("source");
   ASSERT_EQ(1ul, Result.size());
   ASSERT_EQ(".", Result[0].Directory);
-  s

[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits

https://github.com/MightyFilipns updated 
https://github.com/llvm/llvm-project/pull/137610



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits


@@ -4463,6 +4463,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If \c true, a space will be inserted after the ``operator`` keyword.

MightyFilipns wrote:

Fixed

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits


@@ -4463,6 +4463,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If \c true, a space will be inserted after the ``operator`` keyword.
+  /// \code
+  ///true:false:
+  ///bool operator == (int a) vs. bool operator== (int a)
+  /// \endcode
+  /// \version 22

MightyFilipns wrote:

Fixed

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


[clang] [clang-format] Add SpaceAfterOperatorKeyword option (PR #137610)

2025-05-04 Thread Filip Milosevic via cfe-commits


@@ -4463,6 +4463,14 @@ struct FormatStyle {
   /// \version 9
   bool SpaceAfterLogicalNot;
 
+  /// If \c true, a space will be inserted after the ``operator`` keyword.
+  /// \code
+  ///true:false:
+  ///bool operator == (int a) vs. bool operator== (int a)

MightyFilipns wrote:

Fixed

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


[clang] [llvm] Jay1 (PR #138469)

2025-05-04 Thread via cfe-commits

https://github.com/PatJay1703 created 
https://github.com/llvm/llvm-project/pull/138469

None

>From 8f7b6fc86234162d9c88547c543552693c8b5c79 Mon Sep 17 00:00:00 2001
From: Jay Satish Kumar Patel 
Date: Sun, 4 May 2025 09:49:01 -0500
Subject: [PATCH 1/3] changed config file

---
 .clang-format | 246 +-
 1 file changed, 245 insertions(+), 1 deletion(-)

diff --git a/.clang-format b/.clang-format
index 9b3aa8b7213b2..b52a604773bc2 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1 +1,245 @@
-BasedOnStyle: LLVM
+---
+Language:Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignArrayOfStructures: None
+AlignConsecutiveAssignments:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:true
+AlignConsecutiveBitFields:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:false
+AlignConsecutiveDeclarations:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:false
+AlignConsecutiveMacros:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:false
+AlignConsecutiveShortCaseStatements:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCaseColons: false
+AlignEscapedNewlines: Right
+AlignOperands:   Align
+AlignTrailingComments:
+  Kind:Always
+  OverEmptyLines:  0
+AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowBreakBeforeNoexceptSpecifier: Never
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortCompoundRequirementOnASingleLine: true
+AllowShortEnumsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: All
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: MultiLine
+AttributeMacros:
+  - __capability
+BinPackArguments: true
+BinPackParameters: true
+BitFieldColonSpacing: Both
+BraceWrapping:
+  AfterCaseLabel:  false
+  AfterClass:  false
+  AfterControlStatement: Never
+  AfterEnum:   false
+  AfterExternBlock: false
+  AfterFunction:   false
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct: false
+  AfterUnion:  false
+  BeforeCatch: false
+  BeforeElse:  false
+  BeforeLambdaBody: false
+  BeforeWhile: false
+  IndentBraces:false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakAdjacentStringLiterals: true
+BreakAfterAttributes: Leave
+BreakAfterJavaFieldAnnotations: false
+BreakArrays: true
+BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: Always
+BreakBeforeBraces: Attach
+BreakBeforeInlineASMColon: OnlyMultiline
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+BreakStringLiterals: true
+ColumnLimit: 80
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat:   false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IfMacros:
+  - KJ_IF_MAYBE
+IncludeBlocks:   Preserve
+IncludeCategories:
+  - Regex:   '^"(llvm|llvm-c|clang|clang-c)/'
+Priority:2
+SortPriority:0
+CaseSensitive:   false
+  - Regex:   '^(<|"(gtest|gmock|isl|json)/)'
+Priority:3
+SortPriority:0
+CaseSensitive:   false
+  - Regex:   '.*'
+Priority:1
+SortPriority:0
+CaseSensitive:   false
+IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
+IndentCaseBlocks: false
+IndentCaseLabels: false
+IndentExternBlock: AfterExternBlock
+IndentGotoLabels: true
+IndentPPDirectives: None
+IndentRequiresClause: true
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+InsertBraces:false
+InsertNewlineAtEOF: false
+InsertTrailingCommas: None
+IntegerLiteralSeparator:
+  Binary:  0
+  BinaryMinDigits: 0
+  Decimal: 0
+  DecimalMinDigits: 0
+  Hex: 0
+  HexMinDigits:0
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+KeepEmptyLinesAtEOF: false
+LambdaBodyIndentation: Signature
+LineEnding:  DeriveLF
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLin

[clang] [clang] Remove unused local variables (NFC) (PR #138468)

2025-05-04 Thread Nikita Popov via cfe-commits

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


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


[clang] [llvm] Jay1 (PR #138469)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (PatJay1703)


Changes



---

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


10 Files Affected:

- (modified) .clang-format (+245-1) 
- (added) clang-format-diff.py (+183) 
- (added) clang-tidy-diff.py (+424) 
- (modified) clang/lib/AST/ASTStructuralEquivalence.cpp (+14-15) 
- (added) config.yaml (+14) 
- (added) remote_clang_format.py (+52) 
- (added) remote_clang_tidy.py (+52) 
- (added) remote_class_check.py (+73) 
- (added) remote_header_check.py (+69) 
- (added) remote_naming_conventions.py (+145) 


``diff
diff --git a/.clang-format b/.clang-format
index 9b3aa8b7213b2..b52a604773bc2 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1 +1,245 @@
-BasedOnStyle: LLVM
+---
+Language:Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignArrayOfStructures: None
+AlignConsecutiveAssignments:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:true
+AlignConsecutiveBitFields:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:false
+AlignConsecutiveDeclarations:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:false
+AlignConsecutiveMacros:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCompound:   false
+  AlignFunctionPointers: false
+  PadOperators:false
+AlignConsecutiveShortCaseStatements:
+  Enabled: false
+  AcrossEmptyLines: false
+  AcrossComments:  false
+  AlignCaseColons: false
+AlignEscapedNewlines: Right
+AlignOperands:   Align
+AlignTrailingComments:
+  Kind:Always
+  OverEmptyLines:  0
+AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowBreakBeforeNoexceptSpecifier: Never
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortCompoundRequirementOnASingleLine: true
+AllowShortEnumsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: All
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: MultiLine
+AttributeMacros:
+  - __capability
+BinPackArguments: true
+BinPackParameters: true
+BitFieldColonSpacing: Both
+BraceWrapping:
+  AfterCaseLabel:  false
+  AfterClass:  false
+  AfterControlStatement: Never
+  AfterEnum:   false
+  AfterExternBlock: false
+  AfterFunction:   false
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct: false
+  AfterUnion:  false
+  BeforeCatch: false
+  BeforeElse:  false
+  BeforeLambdaBody: false
+  BeforeWhile: false
+  IndentBraces:false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakAdjacentStringLiterals: true
+BreakAfterAttributes: Leave
+BreakAfterJavaFieldAnnotations: false
+BreakArrays: true
+BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: Always
+BreakBeforeBraces: Attach
+BreakBeforeInlineASMColon: OnlyMultiline
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+BreakStringLiterals: true
+ColumnLimit: 80
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat:   false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IfMacros:
+  - KJ_IF_MAYBE
+IncludeBlocks:   Preserve
+IncludeCategories:
+  - Regex:   '^"(llvm|llvm-c|clang|clang-c)/'
+Priority:2
+SortPriority:0
+CaseSensitive:   false
+  - Regex:   '^(<|"(gtest|gmock|isl|json)/)'
+Priority:3
+SortPriority:0
+CaseSensitive:   false
+  - Regex:   '.*'
+Priority:1
+SortPriority:0
+CaseSensitive:   false
+IncludeIsMainRegex: '(Test)?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
+IndentCaseBlocks: false
+IndentCaseLabels: false
+IndentExternBlock: AfterExternBlock
+IndentGotoLabels: true
+IndentPPDirectives: None
+IndentRequiresClause: true
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+InsertBraces:false
+InsertNewlineAtEOF: false
+InsertTrailingCommas: None
+IntegerLiteralSeparator:
+  Binary:  0
+  BinaryMinDigits: 0
+  Decimal: 0
+  DecimalMinDigits: 0
+  Hex: 0
+

[clang] [llvm] Jay1 (PR #138469)

2025-05-04 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [llvm] Jay1 (PR #138469)

2025-05-04 Thread via cfe-commits

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


[clang] [clang] Add support for Debian 14 Forky and Debian 15 Duke (PR #138460)

2025-05-04 Thread Raul Tambre via cfe-commits

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


[clang] 58e6883 - [clang] Add support for Debian 14 Forky and Debian 15 Duke (#138460)

2025-05-04 Thread via cfe-commits

Author: Raul Tambre
Date: 2025-05-04T20:55:49+03:00
New Revision: 58e6883c8b6e571d6bd774645ee2b6348cfed6ba

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

LOG: [clang] Add support for Debian 14 Forky and Debian 15 Duke (#138460)

Futureproofs our single Debian-specific special case for roughly the next 6 
years.

See: https://lists.debian.org/debian-devel-announce/2025/01/msg4.html

Added: 


Modified: 
clang/include/clang/Driver/Distro.h
clang/lib/Driver/Distro.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Distro.h 
b/clang/include/clang/Driver/Distro.h
index 9f27c2baaeb47..5c25592e68ade 100644
--- a/clang/include/clang/Driver/Distro.h
+++ b/clang/include/clang/Driver/Distro.h
@@ -39,6 +39,8 @@ class Distro {
 DebianBullseye,
 DebianBookworm,
 DebianTrixie,
+DebianForky,
+DebianDuke,
 Exherbo,
 RHEL5,
 RHEL6,
@@ -129,7 +131,7 @@ class Distro {
   bool IsOpenSUSE() const { return DistroVal == OpenSUSE; }
 
   bool IsDebian() const {
-return DistroVal >= DebianLenny && DistroVal <= DebianTrixie;
+return DistroVal >= DebianLenny && DistroVal <= DebianDuke;
   }
 
   bool IsUbuntu() const {

diff  --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 82c627819d9fc..90e5a390be7eb 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -161,6 +161,10 @@ static Distro::DistroType 
DetectDistro(llvm::vfs::FileSystem &VFS) {
 return Distro::DebianBookworm;
   case 13:
 return Distro::DebianTrixie;
+  case 14:
+return Distro::DebianForky;
+  case 15:
+return Distro::DebianDuke;
   default:
 return Distro::UnknownDistro;
   }
@@ -174,6 +178,8 @@ static Distro::DistroType 
DetectDistro(llvm::vfs::FileSystem &VFS) {
 .Case("bullseye/sid", Distro::DebianBullseye)
 .Case("bookworm/sid", Distro::DebianBookworm)
 .Case("trixie/sid", Distro::DebianTrixie)
+.Case("forky/sid", Distro::DebianForky)
+.Case("duke/sid", Distro::DebianDuke)
 .Default(Distro::UnknownDistro);
   }
 



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


[clang] [clang] Use *(Set|Map)::contains (NFC) (PR #138464)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Kazu Hirata (kazutakahirata)


Changes



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


4 Files Affected:

- (modified) clang/lib/AST/DeclBase.cpp (+1-2) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+2-3) 
- (modified) clang/tools/libclang/CXCursor.cpp (+1-1) 
- (modified) clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp (+1-3) 


``diff
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index fead99c5f28a9..aea19c51401aa 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -2149,8 +2149,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl 
*D, bool Internal) {
   // have already checked the external source.
   if (!Internal)
 if (ExternalASTSource *Source = getParentASTContext().getExternalSource())
-  if (hasExternalVisibleStorage() &&
-  Map->find(D->getDeclName()) == Map->end())
+  if (hasExternalVisibleStorage() && !Map->contains(D->getDeclName()))
 Source->FindExternalVisibleDeclsByName(this, D->getDeclName(),
D->getDeclContext());
 
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 106a652049b07..e47bac0261356 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8646,9 +8646,8 @@ ASTReader::getLoadedSpecializationsLookupTables(const 
Decl *D, bool IsPartial) {
 
 bool ASTReader::haveUnloadedSpecializations(const Decl *D) const {
   assert(D->isCanonicalDecl());
-  return (PartialSpecializationsLookups.find(D) !=
-  PartialSpecializationsLookups.end()) ||
- (SpecializationsLookups.find(D) != SpecializationsLookups.end());
+  return PartialSpecializationsLookups.contains(D) ||
+ SpecializationsLookups.contains(D);
 }
 
 /// Under non-PCH compilation the consumer receives the objc methods
diff --git a/clang/tools/libclang/CXCursor.cpp 
b/clang/tools/libclang/CXCursor.cpp
index 1d15120106017..635d03a88d105 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -1638,7 +1638,7 @@ unsigned clang_CXCursorSet_contains(CXCursorSet set, 
CXCursor cursor) {
   CXCursorSet_Impl *setImpl = unpackCXCursorSet(set);
   if (!setImpl)
 return 0;
-  return setImpl->find(cursor) != setImpl->end();
+  return setImpl->contains(cursor);
 }
 
 unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) {
diff --git a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
index de79743a06e1f..e2eb65091bc5a 100644
--- a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
@@ -60,10 +60,8 @@ ParseTemplateParameterList(ParserState &PS,
 } else if (Arg->isSubClassOf("NTTP")) {
   auto Type = Arg->getValueAsString("TypeName");
 
-  if (TemplateNameToParmName.find(Type.str()) ==
-  TemplateNameToParmName.end()) {
+  if (!TemplateNameToParmName.contains(Type.str()))
 PrintFatalError("Unkown Type Name");
-  }
 
   auto TSIName = "TSI" + std::to_string(PS.UniqueCounter++);
   Code << " auto *" << TSIName << " = C.getTrivialTypeSourceInfo(QualType("

``




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


[clang] [clang] Use *(Set|Map)::contains (NFC) (PR #138464)

2025-05-04 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/138464

None

>From 988dae3f61b85a357f271336695619060103aeca Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 4 May 2025 10:41:49 -0700
Subject: [PATCH] [clang] Use *(Set|Map)::contains (NFC)

---
 clang/lib/AST/DeclBase.cpp| 3 +--
 clang/lib/Serialization/ASTReader.cpp | 5 ++---
 clang/tools/libclang/CXCursor.cpp | 2 +-
 clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp | 4 +---
 4 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index fead99c5f28a9..aea19c51401aa 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -2149,8 +2149,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl 
*D, bool Internal) {
   // have already checked the external source.
   if (!Internal)
 if (ExternalASTSource *Source = getParentASTContext().getExternalSource())
-  if (hasExternalVisibleStorage() &&
-  Map->find(D->getDeclName()) == Map->end())
+  if (hasExternalVisibleStorage() && !Map->contains(D->getDeclName()))
 Source->FindExternalVisibleDeclsByName(this, D->getDeclName(),
D->getDeclContext());
 
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 106a652049b07..e47bac0261356 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8646,9 +8646,8 @@ ASTReader::getLoadedSpecializationsLookupTables(const 
Decl *D, bool IsPartial) {
 
 bool ASTReader::haveUnloadedSpecializations(const Decl *D) const {
   assert(D->isCanonicalDecl());
-  return (PartialSpecializationsLookups.find(D) !=
-  PartialSpecializationsLookups.end()) ||
- (SpecializationsLookups.find(D) != SpecializationsLookups.end());
+  return PartialSpecializationsLookups.contains(D) ||
+ SpecializationsLookups.contains(D);
 }
 
 /// Under non-PCH compilation the consumer receives the objc methods
diff --git a/clang/tools/libclang/CXCursor.cpp 
b/clang/tools/libclang/CXCursor.cpp
index 1d15120106017..635d03a88d105 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -1638,7 +1638,7 @@ unsigned clang_CXCursorSet_contains(CXCursorSet set, 
CXCursor cursor) {
   CXCursorSet_Impl *setImpl = unpackCXCursorSet(set);
   if (!setImpl)
 return 0;
-  return setImpl->find(cursor) != setImpl->end();
+  return setImpl->contains(cursor);
 }
 
 unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) {
diff --git a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
index de79743a06e1f..e2eb65091bc5a 100644
--- a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
@@ -60,10 +60,8 @@ ParseTemplateParameterList(ParserState &PS,
 } else if (Arg->isSubClassOf("NTTP")) {
   auto Type = Arg->getValueAsString("TypeName");
 
-  if (TemplateNameToParmName.find(Type.str()) ==
-  TemplateNameToParmName.end()) {
+  if (!TemplateNameToParmName.contains(Type.str()))
 PrintFatalError("Unkown Type Name");
-  }
 
   auto TSIName = "TSI" + std::to_string(PS.UniqueCounter++);
   Code << " auto *" << TSIName << " = C.getTrivialTypeSourceInfo(QualType("

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


[clang] [clang] Use *(Set|Map)::contains (NFC) (PR #138464)

2025-05-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes



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


4 Files Affected:

- (modified) clang/lib/AST/DeclBase.cpp (+1-2) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+2-3) 
- (modified) clang/tools/libclang/CXCursor.cpp (+1-1) 
- (modified) clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp (+1-3) 


``diff
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index fead99c5f28a9..aea19c51401aa 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -2149,8 +2149,7 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl 
*D, bool Internal) {
   // have already checked the external source.
   if (!Internal)
 if (ExternalASTSource *Source = getParentASTContext().getExternalSource())
-  if (hasExternalVisibleStorage() &&
-  Map->find(D->getDeclName()) == Map->end())
+  if (hasExternalVisibleStorage() && !Map->contains(D->getDeclName()))
 Source->FindExternalVisibleDeclsByName(this, D->getDeclName(),
D->getDeclContext());
 
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 106a652049b07..e47bac0261356 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8646,9 +8646,8 @@ ASTReader::getLoadedSpecializationsLookupTables(const 
Decl *D, bool IsPartial) {
 
 bool ASTReader::haveUnloadedSpecializations(const Decl *D) const {
   assert(D->isCanonicalDecl());
-  return (PartialSpecializationsLookups.find(D) !=
-  PartialSpecializationsLookups.end()) ||
- (SpecializationsLookups.find(D) != SpecializationsLookups.end());
+  return PartialSpecializationsLookups.contains(D) ||
+ SpecializationsLookups.contains(D);
 }
 
 /// Under non-PCH compilation the consumer receives the objc methods
diff --git a/clang/tools/libclang/CXCursor.cpp 
b/clang/tools/libclang/CXCursor.cpp
index 1d15120106017..635d03a88d105 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -1638,7 +1638,7 @@ unsigned clang_CXCursorSet_contains(CXCursorSet set, 
CXCursor cursor) {
   CXCursorSet_Impl *setImpl = unpackCXCursorSet(set);
   if (!setImpl)
 return 0;
-  return setImpl->find(cursor) != setImpl->end();
+  return setImpl->contains(cursor);
 }
 
 unsigned clang_CXCursorSet_insert(CXCursorSet set, CXCursor cursor) {
diff --git a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
index de79743a06e1f..e2eb65091bc5a 100644
--- a/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinTemplatesEmitter.cpp
@@ -60,10 +60,8 @@ ParseTemplateParameterList(ParserState &PS,
 } else if (Arg->isSubClassOf("NTTP")) {
   auto Type = Arg->getValueAsString("TypeName");
 
-  if (TemplateNameToParmName.find(Type.str()) ==
-  TemplateNameToParmName.end()) {
+  if (!TemplateNameToParmName.contains(Type.str()))
 PrintFatalError("Unkown Type Name");
-  }
 
   auto TSIName = "TSI" + std::to_string(PS.UniqueCounter++);
   Code << " auto *" << TSIName << " = C.getTrivialTypeSourceInfo(QualType("

``




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


[clang] [llvm] [clang][OpenMP] New OpenMP 6.0 threadset clause (PR #135807)

2025-05-04 Thread via cfe-commits

Ritanya-B-Bharadwaj wrote:

@alexey-bataev I've addressed your comments. For anything that's out of scope 
for this patch, I'll handle it in upcoming patches. Let me know if this can be 
merged.

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


[clang] [llvm] [clang] [OpenMP] New OpenMP 6.0 self_maps clause - CodeGen (PR #134131)

2025-05-04 Thread via cfe-commits


@@ -236,6 +236,8 @@ enum class OpenMPOffloadMappingFlags : uint64_t {
   // dynamic.
   // This is an OpenMP extension for the sake of OpenACC support.
   OMP_MAP_OMPX_HOLD = 0x2000,
+  /// Self directs mapping without creating a separate device copy.
+  OMP_MAP_SELF = 0x4000,

Ritanya-B-Bharadwaj wrote:

@kparzysz @alexey-bataev any thoughts?

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


  1   2   >