[clang] [clang-format] Fix a crash with AlignArrayOfStructures option (PR #86420)

2024-03-23 Thread Owen Pan via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/86420

>From 2c131e544578072e349ba853543cc60816421a5e Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Sat, 23 Mar 2024 22:23:46 -0700
Subject: [PATCH] [clang-format] Fix a crash with AlignArrayOfStructures option

Fixes #86109.
---
 clang/lib/Format/WhitespaceManager.cpp |  2 +-
 clang/unittests/Format/FormatTest.cpp  | 18 --
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index fef85abf79a38c..710bf8d8a8ec70 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1491,7 +1491,7 @@ WhitespaceManager::CellDescriptions 
WhitespaceManager::getCells(unsigned Start,
 : Cell);
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
-while (NextNonComment->is(tok::comma))
+while (NextNonComment && NextNonComment->is(tok::comma))
   NextNonComment = NextNonComment->getNextNonComment();
 auto j = i;
 while (j < End && Changes[j].Tok != NextNonComment)
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index cf8d6ab691d9a0..03005384a6f667 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -21100,7 +21100,14 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresRightAlignment) {
 "[0] = {1, 1},\n"
 "[1] { 1, 1, },\n"
 "[2] { 1, 1, },\n"
-"};");
+"};",
+Style);
+  verifyNoCrash("test arr[] = {\n"
+"#define FOO(i) {i, i},\n"
+"SOME_GENERATOR(FOO)\n"
+"{2, 2}\n"
+"};",
+Style);
 
   verifyFormat("return GradForUnaryCwise(g, {\n"
"{{\"sign\"}, \"Sign\",  "
@@ -21353,7 +21360,14 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresLeftAlignment) {
 "[0] = {1, 1},\n"
 "[1] { 1, 1, },\n"
 "[2] { 1, 1, },\n"
-"};");
+"};",
+Style);
+  verifyNoCrash("test arr[] = {\n"
+"#define FOO(i) {i, i},\n"
+"SOME_GENERATOR(FOO)\n"
+"{2, 2}\n"
+"};",
+Style);
 
   verifyFormat("return GradForUnaryCwise(g, {\n"
"{{\"sign\"}, \"Sign\", {\"x\", 
"

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


[clang] [clang-format] Fix a crash with AlignArrayOfStructures option (PR #86420)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [clang-format] Fix a crash with AlignArrayOfStructures option (PR #86420)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [clang-format] Fix a crash with AlignArrayOfStructures option (PR #86420)

2024-03-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #86109.

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


2 Files Affected:

- (modified) clang/lib/Format/WhitespaceManager.cpp (+1-1) 
- (modified) clang/unittests/Format/FormatTest.cpp (+10) 


``diff
diff --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index fef85abf79a38c..710bf8d8a8ec70 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1491,7 +1491,7 @@ WhitespaceManager::CellDescriptions 
WhitespaceManager::getCells(unsigned Start,
 : Cell);
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
-while (NextNonComment->is(tok::comma))
+while (NextNonComment && NextNonComment->is(tok::comma))
   NextNonComment = NextNonComment->getNextNonComment();
 auto j = i;
 while (j < End && Changes[j].Tok != NextNonComment)
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index cf8d6ab691d9a0..a33520d81b8421 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -21101,6 +21101,11 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresRightAlignment) {
 "[1] { 1, 1, },\n"
 "[2] { 1, 1, },\n"
 "};");
+  verifyNoCrash("test arr[] = {\n"
+"#define FOO(i) {i, i},\n"
+"SOME_GENERATOR(FOO)\n"
+"{2, 2}\n"
+"};");
 
   verifyFormat("return GradForUnaryCwise(g, {\n"
"{{\"sign\"}, \"Sign\",  "
@@ -21354,6 +21359,11 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresLeftAlignment) {
 "[1] { 1, 1, },\n"
 "[2] { 1, 1, },\n"
 "};");
+  verifyNoCrash("test arr[] = {\n"
+"#define FOO(i) {i, i},\n"
+"SOME_GENERATOR(FOO)\n"
+"{2, 2}\n"
+"};");
 
   verifyFormat("return GradForUnaryCwise(g, {\n"
"{{\"sign\"}, \"Sign\", {\"x\", 
"

``




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


[clang] [clang-format] Fix a crash with AlignArrayOfStructures option (PR #86420)

2024-03-23 Thread Owen Pan via cfe-commits

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

Fixes #86109.

>From 682323acb1007308f55bf023e4d1657f268b55d1 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Sat, 23 Mar 2024 22:23:46 -0700
Subject: [PATCH] [clang-format] Fix a crash with AlignArrayOfStructures option

Fixes #86109.
---
 clang/lib/Format/WhitespaceManager.cpp |  2 +-
 clang/unittests/Format/FormatTest.cpp  | 10 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index fef85abf79a38c..710bf8d8a8ec70 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1491,7 +1491,7 @@ WhitespaceManager::CellDescriptions 
WhitespaceManager::getCells(unsigned Start,
 : Cell);
 // Go to the next non-comment and ensure there is a break in front
 const auto *NextNonComment = C.Tok->getNextNonComment();
-while (NextNonComment->is(tok::comma))
+while (NextNonComment && NextNonComment->is(tok::comma))
   NextNonComment = NextNonComment->getNextNonComment();
 auto j = i;
 while (j < End && Changes[j].Tok != NextNonComment)
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index cf8d6ab691d9a0..a33520d81b8421 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -21101,6 +21101,11 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresRightAlignment) {
 "[1] { 1, 1, },\n"
 "[2] { 1, 1, },\n"
 "};");
+  verifyNoCrash("test arr[] = {\n"
+"#define FOO(i) {i, i},\n"
+"SOME_GENERATOR(FOO)\n"
+"{2, 2}\n"
+"};");
 
   verifyFormat("return GradForUnaryCwise(g, {\n"
"{{\"sign\"}, \"Sign\",  "
@@ -21354,6 +21359,11 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresLeftAlignment) {
 "[1] { 1, 1, },\n"
 "[2] { 1, 1, },\n"
 "};");
+  verifyNoCrash("test arr[] = {\n"
+"#define FOO(i) {i, i},\n"
+"SOME_GENERATOR(FOO)\n"
+"{2, 2}\n"
+"};");
 
   verifyFormat("return GradForUnaryCwise(g, {\n"
"{{\"sign\"}, \"Sign\", {\"x\", 
"

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


[clang] [X86_64] fix SSE type error in vaarg. (PR #86377)

2024-03-23 Thread Eli Friedman via cfe-commits


@@ -21,3 +21,18 @@ empty empty_record_test(int z, ...) {
   __builtin_va_start(list, z);
   return __builtin_va_arg(list, empty);
 }
+

efriedma-quic wrote:

Please regenerate the CHECK lines with update_cc_test_checks.py.

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


[clang] [FMV] Allow multi versioning without default declaration. (PR #85454)

2024-03-23 Thread Jon Roelofs via cfe-commits

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


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


[clang] [FMV] Allow multi versioning without default declaration. (PR #85454)

2024-03-23 Thread Jon Roelofs via cfe-commits


@@ -483,14 +483,16 @@ void just_fine(void) {}
 
 __arm_locally_streaming
 __attribute__((target_version("sme2")))
-void just_fine_locally_streaming(void) {}
+void incompatible_locally_streaming(void) {}
+// expected-error@-1 {{attribute 'target_version' multiversioning cannot be 
combined with attribute '__arm_locally_streaming'}}
+// expected-cpp-error@-2 {{attribute 'target_version' multiversioning cannot 
be combined with attribute '__arm_locally_streaming'}}

jroelofs wrote:

I think this is a regression, but it's fine to fix it in another patch. The 
locally streaming function has the same ABI as the non-streaming one, so FMV 
_should_ be possible between them (unlike w/ a streaming one). LIkewise, it 
should be possible to FMV between streaming compatible functions and normal 
ones.

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


[clang] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (PR #84050)

2024-03-23 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

`Sema.h` changes look good to me.

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


[clang] [clang] Catch missing format attributes (PR #70024)

2024-03-23 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

I'm not able to review Sema.h changes because of a merge conflict.

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


[clang] add some missing Kinds to libclang python bindings (PR #85571)

2024-03-23 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

This looks good.
Sorry for the late reply.

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


[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-23 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

`Sema.h` changes look good to me.

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread Robin Caloudis via cfe-commits

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread Robin Caloudis via cfe-commits

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread Robin Caloudis via cfe-commits

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread Robin Caloudis via cfe-commits

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


[clang] [Clang][analyzer] add documentation for optin performance padding (padding checker) #73675 (PR #86411)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:

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


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


[clang] [Clang][analyzer] add documentation for optin performance padding (padding checker) #73675 (PR #86411)

2024-03-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (komalverma04)


Changes

# Added documentation for optin.performance.Padding.
- Performance package has `PaddingChecker` checker.
- It checks for excessively padded structs.
   - It has one option that is `AllowedPad`, an integer option.
   - It's default value is 24 bytes.
  - Reports are generated when padding exceeds `AllowedPad`.
 ## Purpose
The purpose of this pull request is to improve the clarity and completeness of 
the documentation for PaddingChecker in the optin.performance.Padding checker.

Closes #73675

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


2 Files Affected:

- (modified) clang/docs/analyzer/checkers.rst (+20-2) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+1-1) 


``diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index fe211514914272..64b09bc6ecd1d8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -804,10 +804,28 @@ Check for performance anti-patterns when using Grand 
Central Dispatch.
 
 .. _optin-performance-Padding:
 
-optin.performance.Padding
-"
+optin.performance.Padding (PaddingChecker)
+"""
 Check for excessively padded structs.
 
+.. code-block:: objc
+
+ struct TestStruct {
+  int data1;   // 4 bytes
+  char data2;  // 1 byte
+  char padding[27];  // 27 bytes of padding
+};  // Total size: 32 bytes 
+  
+  void TestFunction() {
+  struct TestStruct struct1;  // Warning is generated due to excessive 
padding.
+}
+
+   // Reports are only generated if the excessive padding exceeds 'AllowedPad' 
in bytes.
+
+  // AllowedPad: Default Value: 24 bytes
+
+   Usage: `AllowedPad=`
+
 .. _optin-portability-UnixAPI:
 
 optin.portability.UnixAPI
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 686e5e99f4a62c..c0e4e9a70c2ef3 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -908,7 +908,7 @@ def PaddingChecker : Checker<"Padding">,
   "24",
   Released>
   ]>,
-  Documentation;
+  Documentation;
 
 } // end: "padding"
 

``




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


[clang] [Clang][analyzer] add documentation for optin performance padding (padding checker) #73675 (PR #86411)

2024-03-23 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/86411
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][analyzer] add documentation for optin performance padding (padding checker) #73675 (PR #86411)

2024-03-23 Thread via cfe-commits

https://github.com/komalverma04 created 
https://github.com/llvm/llvm-project/pull/86411

# Added documentation for optin.performance.Padding.
- Performance package has `PaddingChecker` checker.
- It checks for excessively padded structs.
   - It has one option that is `AllowedPad`, an integer option.
   - It's default value is 24 bytes.
  - Reports are generated when padding exceeds `AllowedPad`.
 ## Purpose
The purpose of this pull request is to improve the clarity and completeness of 
the documentation for PaddingChecker in the optin.performance.Padding checker.

Closes #73675

>From b6ca6f0ef83d03e299d6ee9a8ed9b8044477914e Mon Sep 17 00:00:00 2001
From: komalverma04 <114138604+komalverm...@users.noreply.github.com>
Date: Sat, 23 Mar 2024 11:14:44 -0700
Subject: [PATCH 1/2] Update checkers.rst

Modification of documentation to demonstrate utilization of AllowedPad within 
PaddingChecker, along with its use and effects on code analysis.
---
 clang/docs/analyzer/checkers.rst | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index fe211514914272..64b09bc6ecd1d8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -804,10 +804,28 @@ Check for performance anti-patterns when using Grand 
Central Dispatch.
 
 .. _optin-performance-Padding:
 
-optin.performance.Padding
-"
+optin.performance.Padding (PaddingChecker)
+"""
 Check for excessively padded structs.
 
+.. code-block:: objc
+
+ struct TestStruct {
+  int data1;   // 4 bytes
+  char data2;  // 1 byte
+  char padding[27];  // 27 bytes of padding
+};  // Total size: 32 bytes 
+  
+  void TestFunction() {
+  struct TestStruct struct1;  // Warning is generated due to excessive 
padding.
+}
+
+   // Reports are only generated if the excessive padding exceeds 'AllowedPad' 
in bytes.
+
+  // AllowedPad: Default Value: 24 bytes
+
+   Usage: `AllowedPad=`
+
 .. _optin-portability-UnixAPI:
 
 optin.portability.UnixAPI

>From 403115cd960653a3afe0491d2855d35d377d9312 Mon Sep 17 00:00:00 2001
From: komalverma04 <114138604+komalverm...@users.noreply.github.com>
Date: Sat, 23 Mar 2024 11:20:46 -0700
Subject: [PATCH 2/2] Update Checkers.td

Changed NotDocumented to HasDocumentation for Padding Checker under performance 
checker.
---
 clang/include/clang/StaticAnalyzer/Checkers/Checkers.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 686e5e99f4a62c..c0e4e9a70c2ef3 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -908,7 +908,7 @@ def PaddingChecker : Checker<"Padding">,
   "24",
   Released>
   ]>,
-  Documentation;
+  Documentation;
 
 } // end: "padding"
 

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


[clang-tools-extra] [clang-tidy] Improved --verify-config when using literal style in config file (PR #85591)

2024-03-23 Thread Piotr Zegar via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: 



@@ -262,6 +262,9 @@ Miscellaneous
   option is specified. Now ``clang-apply-replacements`` applies formatting 
only with
   the option.
 
+- Fixed ``--verify-check`` option not properly parsing checks when using the 
+  literal operator in the ``.clang-tidy`` config.

PiotrZSL wrote:

I think this should be in line 103.

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


[clang] e14c6fa - [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (#86386)

2024-03-23 Thread via cfe-commits

Author: Michał Górny
Date: 2024-03-23T19:26:20Z
New Revision: e14c6fa31a303312d7561aa0c7219d687f3f2c75

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

LOG: [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion 
(#86386)

Move the code adding top-level cmake/Modules directory to
CMAKE_MODULE_PATH prior to including `GetDarwinLinkerVersion`, in order
to fix standalone builds.

Fixes a regression introduced by
3bc71c2abfa00413fd15cf0e5c08af6ec0d4768b.

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index ee783d52e4a4e2..284b2af24ddaa0 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -13,6 +13,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   set(CLANG_BUILT_STANDALONE TRUE)
 endif()
 
+# Make sure that our source directory is on the current cmake module path so 
that
+# we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
 # Must go below project(..)
 include(GNUInstallDirs)
 include(GetDarwinLinkerVersion)
@@ -141,13 +148,6 @@ if(CLANG_BUILT_STANDALONE)
   endif() # LLVM_INCLUDE_TESTS
 endif() # standalone
 
-# Make sure that our source directory is on the current cmake module path so 
that
-# we can include cmake files from this directory.
-list(INSERT CMAKE_MODULE_PATH 0
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
-
 # This allows disabling clang's XML dependency even if LLVM finds libxml2.
 # By default, clang depends on libxml2 if LLVM does.
 option(CLANG_ENABLE_LIBXML2 "Whether libclang may depend on libxml2"



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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Michał Górny via cfe-commits

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Michał Górny via cfe-commits

mgorny wrote:

Thanks!

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread Robin Caloudis via cfe-commits

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Usama Hameed via cfe-commits

usama54321 wrote:

Thanks a lot for fixing this

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Usama Hameed via cfe-commits

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


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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Robin Caloudis (robincaloudis)


Changes

This change removes the pow intrinsics with parameters of type double as it is 
not available in the DCX (trunk) compiler.

Introduced during 
https://github.com/llvm/llvm-project/commit/df5137e984a607248cd31ed67aa3822e8ac2a083.

Documentation for HLSL pow function is available here: 
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow#parameters

Closes https://github.com/llvm/llvm-project/issues/86181

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


2 Files Affected:

- (modified) clang/lib/Headers/hlsl/hlsl_intrinsics.h (-9) 
- (modified) clang/test/CodeGenHLSL/builtins/pow.hlsl (-13) 


``diff
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 5e703772b7ee4f..0d6baccd7c0ac9 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -1174,15 +1174,6 @@ float3 pow(float3, float3);
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
 float4 pow(float4, float4);
 
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double pow(double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double2 pow(double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double3 pow(double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double4 pow(double4, double4);
-
 
//===--===//
 // reversebits builtins
 
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/pow.hlsl 
b/clang/test/CodeGenHLSL/builtins/pow.hlsl
index e996ca2f336410..057cd7215aa5af 100644
--- a/clang/test/CodeGenHLSL/builtins/pow.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -39,16 +39,3 @@ float3 test_pow_float3(float3 p0, float3 p1) { return 
pow(p0, p1); }
 // CHECK: define noundef <4 x float> @"?test_pow_float4
 // CHECK: call <4 x float> @llvm.pow.v4f32
 float4 test_pow_float4(float4 p0, float4 p1) { return pow(p0, p1); }
-
-// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"(
-// CHECK: call double @llvm.pow.f64(
-double test_pow_double(double p0, double p1) { return pow(p0, p1); }
-// CHECK: define noundef <2 x double> 
@"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"(
-// CHECK: call <2 x double> @llvm.pow.v2f64
-double2 test_pow_double2(double2 p0, double2 p1) { return pow(p0, p1); }
-// CHECK: define noundef <3 x double> 
@"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"(
-// CHECK: call <3 x double> @llvm.pow.v3f64
-double3 test_pow_double3(double3 p0, double3 p1) { return pow(p0, p1); }
-// CHECK: define noundef <4 x double> 
@"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"(
-// CHECK: call <4 x double> @llvm.pow.v4f64
-double4 test_pow_double4(double4 p0, double4 p1) { return pow(p0, p1); }

``




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


[clang] [HLSL] Remove double pow intrinsics (PR #86407)

2024-03-23 Thread Robin Caloudis via cfe-commits

https://github.com/robincaloudis created 
https://github.com/llvm/llvm-project/pull/86407

This change removes the pow intrinsics with parameters of type double as it is 
not available in the DCX (trunk) compiler.

Introduced during 
https://github.com/llvm/llvm-project/commit/df5137e984a607248cd31ed67aa3822e8ac2a083.

Documentation for HLSL pow function is available here: 
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow#parameters

Closes https://github.com/llvm/llvm-project/issues/86181

>From 119a7efc998c04b3ad9354999112f669a333ca37 Mon Sep 17 00:00:00 2001
From: Robin Caloudis 
Date: Sat, 23 Mar 2024 19:12:08 +0100
Subject: [PATCH] [HLSL] Remove double pow intrinsics

This change removes the pow intrinsics with parameters of type double as it is 
not available in the DCX (trunk) compiler.

Introduced during 
https://github.com/llvm/llvm-project/commit/df5137e984a607248cd31ed67aa3822e8ac2a083.

Documentation for HLSL pow function is available here:
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow#parameters
---
 clang/lib/Headers/hlsl/hlsl_intrinsics.h |  9 -
 clang/test/CodeGenHLSL/builtins/pow.hlsl | 13 -
 2 files changed, 22 deletions(-)

diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 5e703772b7ee4f..0d6baccd7c0ac9 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -1174,15 +1174,6 @@ float3 pow(float3, float3);
 _HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
 float4 pow(float4, float4);
 
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double pow(double, double);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double2 pow(double2, double2);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double3 pow(double3, double3);
-_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
-double4 pow(double4, double4);
-
 
//===--===//
 // reversebits builtins
 
//===--===//
diff --git a/clang/test/CodeGenHLSL/builtins/pow.hlsl 
b/clang/test/CodeGenHLSL/builtins/pow.hlsl
index e996ca2f336410..057cd7215aa5af 100644
--- a/clang/test/CodeGenHLSL/builtins/pow.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -39,16 +39,3 @@ float3 test_pow_float3(float3 p0, float3 p1) { return 
pow(p0, p1); }
 // CHECK: define noundef <4 x float> @"?test_pow_float4
 // CHECK: call <4 x float> @llvm.pow.v4f32
 float4 test_pow_float4(float4 p0, float4 p1) { return pow(p0, p1); }
-
-// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"(
-// CHECK: call double @llvm.pow.f64(
-double test_pow_double(double p0, double p1) { return pow(p0, p1); }
-// CHECK: define noundef <2 x double> 
@"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"(
-// CHECK: call <2 x double> @llvm.pow.v2f64
-double2 test_pow_double2(double2 p0, double2 p1) { return pow(p0, p1); }
-// CHECK: define noundef <3 x double> 
@"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"(
-// CHECK: call <3 x double> @llvm.pow.v3f64
-double3 test_pow_double3(double3 p0, double3 p1) { return pow(p0, p1); }
-// CHECK: define noundef <4 x double> 
@"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"(
-// CHECK: call <4 x double> @llvm.pow.v4f64
-double4 test_pow_double4(double4 p0, double4 p1) { return pow(p0, p1); }

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


[clang] [FMV] Allow multi versioning without default declaration. (PR #85454)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [FMV] Allow multi versioning without default declaration. (PR #85454)

2024-03-23 Thread Alexandros Lamprineas via cfe-commits


@@ -109,9 +109,22 @@ int unused_with_implicit_default_def(void) { return 1; }
 int unused_with_implicit_forward_default_def(void) { return 0; }
 __attribute__((target_version("lse"))) int 
unused_with_implicit_forward_default_def(void) { return 1; }
 
-// This should generate a normal function.
+// This should generate a target version despite the default not being 
declared.
 __attribute__((target_version("rdm"))) int unused_without_default(void) { 
return 0; }
 
+// The following is guarded because in NOFMV we get errors for calling 
undeclared functions.
+#ifdef __HAVE_FUNCTION_MULTI_VERSIONING
+// This should generate a default declaration, two target versions and the 
resolver.
+__attribute__((target_version("jscvt"))) int 
used_def_without_default_decl(void) { return 1; }
+__attribute__((target_version("rdma"))) int 
used_def_without_default_decl(void) { return 2; }
+
+// This should generate a default declaration and the resolver.
+__attribute__((target_version("jscvt"))) int 
used_decl_without_default_decl(void);
+__attribute__((target_version("rdma"))) int 
used_decl_without_default_decl(void);
+
+int caller(void) { return used_def_without_default_decl() + 
used_decl_without_default_decl(); }

labrinea wrote:

With the latest revision we generate a mangled default and a resolver along 
side it. I believe that would be the user intended behavior in this example.

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


[clang] [FMV] Allow multi versioning without default declaration. (PR #85454)

2024-03-23 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/85454

>From 289d36fd371f9f47e2ceb3a682e3c6d122341f3b Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Fri, 15 Mar 2024 19:25:16 +
Subject: [PATCH] [FMV] Allow multi versioning without default declaration.

This was a limitation which has now been lifted. Please read the
thread below for more details:

https://github.com/llvm/llvm-project/pull/84405#discussion_r1525583647

Basically it allows to separate versioned implementations across
different TUs without having to share private header files which
contain the default declaration.

The ACLE spec has been updated accordingly to make this explicit:
"Each version declaration should be visible at the translation
 unit in which the corresponding function version resides."

https://github.com/ARM-software/acle/pull/310

If a resolver is required (because there is a caller in the TU),
then a default declaration is implicitly generated.
---
 clang/lib/CodeGen/CodeGenModule.cpp   | 131 ---
 clang/lib/Sema/SemaDecl.cpp   |   6 +-
 clang/lib/Sema/SemaOverload.cpp   |  44 ++-
 clang/test/CodeGen/attr-target-version.c  | 368 --
 clang/test/CodeGenCXX/attr-target-version.cpp |  62 +--
 clang/test/Sema/aarch64-sme-func-attrs.c  |   8 +-
 clang/test/Sema/attr-target-version.c |   8 +-
 clang/test/SemaCXX/attr-target-version.cpp|  11 +-
 8 files changed, 403 insertions(+), 235 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index cb153066b28dd1..ac81df8cf7adfe 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3711,7 +3711,8 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
 
 // Forward declarations are emitted lazily on first use.
 if (!FD->doesThisDeclarationHaveABody()) {
-  if (!FD->doesDeclarationForceExternallyVisibleDefinition())
+  if (!FD->doesDeclarationForceExternallyVisibleDefinition() &&
+  !FD->isTargetVersionMultiVersion())
 return;
 
   StringRef MangledName = getMangledName(GD);
@@ -4092,6 +4093,23 @@ llvm::GlobalValue::LinkageTypes 
getMultiversionLinkage(CodeGenModule ,
   return llvm::GlobalValue::WeakODRLinkage;
 }
 
+static FunctionDecl *createDefaultTargetVersionFrom(const FunctionDecl *FD) {
+  DeclContext *DeclCtx = FD->getASTContext().getTranslationUnitDecl();
+  TypeSourceInfo *TInfo = FD->getTypeSourceInfo();
+  StorageClass SC = FD->getStorageClass();
+  DeclarationName Name = FD->getNameInfo().getName();
+
+  FunctionDecl *NewDecl =
+  FunctionDecl::Create(FD->getASTContext(), DeclCtx, FD->getBeginLoc(),
+   FD->getEndLoc(), Name, TInfo->getType(), TInfo, SC);
+
+  NewDecl->setIsMultiVersion();
+  NewDecl->addAttr(TargetVersionAttr::CreateImplicit(
+  NewDecl->getASTContext(), "default", NewDecl->getSourceRange()));
+
+  return NewDecl;
+}
+
 void CodeGenModule::emitMultiVersionFunctions() {
   std::vector MVFuncsToEmit;
   MultiVersionFuncs.swap(MVFuncsToEmit);
@@ -4099,70 +4117,54 @@ void CodeGenModule::emitMultiVersionFunctions() {
 const auto *FD = cast(GD.getDecl());
 assert(FD && "Expected a FunctionDecl");
 
-bool EmitResolver = !FD->isTargetVersionMultiVersion();
+auto createFunction = [&](const FunctionDecl *Decl, unsigned MVIdx = 0) {
+  GlobalDecl CurGD{Decl->isDefined() ? Decl->getDefinition() : Decl, 
MVIdx};
+  StringRef MangledName = getMangledName(CurGD);
+  llvm::Constant *Func = GetGlobalValue(MangledName);
+  if (!Func) {
+if (Decl->isDefined()) {
+  EmitGlobalFunctionDefinition(CurGD, nullptr);
+  Func = GetGlobalValue(MangledName);
+} else {
+  const CGFunctionInfo  = 
getTypes().arrangeGlobalDeclaration(CurGD);
+  llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
+  Func = GetAddrOfFunction(CurGD, Ty, /*ForVTable=*/false,
+   /*DontDefer=*/false, ForDefinition);
+}
+assert(Func && "This should have just been created");
+  }
+  return cast(Func);
+};
+
+bool HasDefaultDecl = !FD->isTargetVersionMultiVersion();
+bool ShouldEmitResolver = !FD->isTargetVersionMultiVersion();
 SmallVector Options;
 if (FD->isTargetMultiVersion()) {
   getContext().forEachMultiversionedFunctionVersion(
-  FD, [this, , , ](const FunctionDecl *CurFD) {
-GlobalDecl CurGD{
-(CurFD->isDefined() ? CurFD->getDefinition() : CurFD)};
-StringRef MangledName = getMangledName(CurGD);
-llvm::Constant *Func = GetGlobalValue(MangledName);
-if (!Func) {
-  if (CurFD->isDefined()) {
-EmitGlobalFunctionDefinition(CurGD, nullptr);
-Func = GetGlobalValue(MangledName);
-  } else {
-const CGFunctionInfo  =
-   

[clang-tools-extra] [clang-tidy] Improved modernize-use-using by fixing a false-negative (PR #82947)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang-tools-extra] [clang-tidy] Improved modernize-use-using by fixing a false-negative (PR #82947)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang-tools-extra] [clang-tidy] Improved modernize-use-using by fixing a false-negative (PR #82947)

2024-03-23 Thread Félix-Antoine Constantin via cfe-commits

https://github.com/felix642 updated 
https://github.com/llvm/llvm-project/pull/82947

From 72f2b398d6f41372dc84579a83d273398884c869 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?F=C3=A9lix-Antoine=20Constantin?=
 
Date: Sun, 25 Feb 2024 20:20:59 -0500
Subject: [PATCH] [clang-tidy] Improved modernize-use-using by fixing a
 false-negative

The check needs a parent decl to match but if the typedef is in a function,
the parent is a declStmt which is not a decl by itself.
Improved the matcher to match on either a decl or a declstmt and extract
the decl from the stmt in the latter case.

fixes #72179
---
 .../clang-tidy/modernize/UseUsingCheck.cpp| 24 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 .../checkers/modernize/use-using.cpp  | 43 ++-
 3 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index bb05f206c717ce..24eefdb082eb32 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "UseUsingCheck.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclGroup.h"
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
@@ -24,6 +25,7 @@ static constexpr llvm::StringLiteral ExternCDeclName = 
"extern-c-decl";
 static constexpr llvm::StringLiteral ParentDeclName = "parent-decl";
 static constexpr llvm::StringLiteral TagDeclName = "tag-decl";
 static constexpr llvm::StringLiteral TypedefName = "typedef";
+static constexpr llvm::StringLiteral DeclStmtName = "decl-stmt";
 
 UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
@@ -41,7 +43,8 @@ void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   unless(isInstantiated()),
   optionally(hasAncestor(
   linkageSpecDecl(isExternCLinkage()).bind(ExternCDeclName))),
-  hasParent(decl().bind(ParentDeclName)))
+  anyOf(hasParent(decl().bind(ParentDeclName)),
+hasParent(declStmt().bind(DeclStmtName
   .bind(TypedefName),
   this);
 
@@ -51,17 +54,32 @@ void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   tagDecl(
   anyOf(allOf(unless(anyOf(isImplicit(),
classTemplateSpecializationDecl())),
-  hasParent(decl().bind(ParentDeclName))),
+  anyOf(hasParent(decl().bind(ParentDeclName)),
+hasParent(declStmt().bind(DeclStmtName,
 // We want the parent of the ClassTemplateDecl, not the parent
 // of the specialization.
 classTemplateSpecializationDecl(hasAncestor(classTemplateDecl(
-hasParent(decl().bind(ParentDeclName)))
+anyOf(hasParent(decl().bind(ParentDeclName)),
+  hasParent(declStmt().bind(DeclStmtName
   .bind(TagDeclName),
   this);
 }
 
 void UseUsingCheck::check(const MatchFinder::MatchResult ) {
   const auto *ParentDecl = Result.Nodes.getNodeAs(ParentDeclName);
+
+  if (!ParentDecl) {
+const auto *ParentDeclStmt = 
Result.Nodes.getNodeAs(DeclStmtName);
+if (ParentDeclStmt) {
+  if (ParentDeclStmt->isSingleDecl())
+ParentDecl = ParentDeclStmt->getSingleDecl();
+  else
+ParentDecl =
+ParentDeclStmt->getDeclGroup().getDeclGroup()
+[ParentDeclStmt->getDeclGroup().getDeclGroup().size() - 1];
+}
+  }
+
   if (!ParentDecl)
 return;
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a604e9276668ae..14c7064930bbbc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -235,6 +235,9 @@ Changes in existing checks
   analyzed, se the check now handles the common patterns
   `const auto e = (*vector_ptr)[i]` and `const auto e = vector_ptr->at(i);`.
 
+- Improved :doc:`modernize-use-using `
+  check by adding support for detection of typedefs declared on function level.
+
 - Improved :doc:`readability-implicit-bool-conversion
   ` check to provide
   valid fix suggestions for ``static_cast`` without a preceding space and
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index 462bc984fd3ad5..925e5f9c1ca54e 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-use-using %t -- -- -I 
%S/Inputs/use-using/
+// RUN: %check_clang_tidy %s modernize-use-using %t -- -- 
-fno-delayed-template-parsing -I %S/Inputs/use-using/
 
 typedef int Type;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: 

[clang-tools-extra] [clang-tidy] Improved --verify-config when using literal style in config file (PR #85591)

2024-03-23 Thread Félix-Antoine Constantin via cfe-commits

felix642 wrote:

Thank you for the review @SimplyDanny, as per your suggestion, I've rewrote 
part of my fix to unify the parsing logic rather than updating the duplicated 
code. The method now uses the GlobList which already handles correctly the 
regexes generation from the list of checks.

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


[clang-tools-extra] [clang-tidy] Improved --verify-config when using literal style in config file (PR #85591)

2024-03-23 Thread via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang-tools-extra] [clang-tidy] Improved --verify-config when using literal style in config file (PR #85591)

2024-03-23 Thread via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang-tools-extra] [clang-tidy] Improved --verify-config when using literal style in config file (PR #85591)

2024-03-23 Thread Félix-Antoine Constantin via cfe-commits

https://github.com/felix642 updated 
https://github.com/llvm/llvm-project/pull/85591

From f015496c511b4c2898b9f4d65ebfe39a34c5119c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?F=C3=A9lix-Antoine=20Constantin?=
 
Date: Sun, 17 Mar 2024 20:50:17 -0400
Subject: [PATCH 1/3] [clang-tidy] Improved --verify-config when using literal
 style in config file

Specifying checks using the literal style (|) in the clang-tidy config file is 
currently
supported but was not implemented for the --verify-config options.
This means that clang-tidy would work properly but, using the --verify-config 
option
would raise an error due to some checks not being parsed properly.

Fixes #53737
---
 clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp  |  9 ++---
 clang-tools-extra/docs/ReleaseNotes.rst  |  3 +++
 .../test/clang-tidy/infrastructure/verify-config.cpp | 12 
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 9f3d6b6db6cbca..b68a6215b383a6 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -454,11 +454,14 @@ static constexpr StringLiteral VerifyConfigWarningEnd = " 
[-verify-config]\n";
 
 static bool verifyChecks(const StringSet<> , StringRef CheckGlob,
  StringRef Source) {
-  llvm::StringRef Cur, Rest;
+  llvm::StringRef Cur = CheckGlob;
+  llvm::StringRef Rest = CheckGlob;
   bool AnyInvalid = false;
-  for (std::tie(Cur, Rest) = CheckGlob.split(',');
-   !(Cur.empty() && Rest.empty()); std::tie(Cur, Rest) = Rest.split(',')) {
+  while (!Cur.empty() || !Rest.empty()) {
+Cur = Rest.substr(0, Rest.find_first_of(",\n"));
+Rest = Rest.substr(Cur.size() + 1);
 Cur = Cur.trim();
+
 if (Cur.empty())
   continue;
 Cur.consume_front("-");
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a604e9276668ae..3887384e713896 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -262,6 +262,9 @@ Miscellaneous
   option is specified. Now ``clang-apply-replacements`` applies formatting 
only with
   the option.
 
+- Fixed ``--verify-check`` option not properly parsing checks when using the 
+  literal operator in the ``.clang-tidy`` config
+
 Improvements to include-fixer
 -
 
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
index 421f8641281acb..3659285986482a 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -18,3 +18,15 @@
 // CHECK-VERIFY: command-line option '-checks': warning: check glob 'bad*glob' 
doesn't match any known check [-verify-config]
 // CHECK-VERIFY: command-line option '-checks': warning: unknown check 
'llvm-includeorder'; did you mean 'llvm-include-order' [-verify-config]
 // CHECK-VERIFY: command-line option '-checks': warning: unknown check 
'my-made-up-check' [-verify-config]
+
+// RUN: echo -e 'Checks: |\n bugprone-argument-comment\n 
bugprone-assert-side-effect,\n bugprone-bool-pointer-implicit-conversion\n 
readability-use-anyof*' > %T/MyClangTidyConfig
+// RUN: clang-tidy -verify-config \
+// RUN: --config-file=%T/MyClangTidyConfig | FileCheck %s 
-check-prefix=CHECK-VERIFY-BLOCK-OK
+// CHECK-VERIFY-BLOCK-OK: No config errors detected.
+
+// RUN: echo -e 'Checks: |\n bugprone-arguments-*\n 
bugprone-assert-side-effects\n bugprone-bool-pointer-implicit-conversion' > 
%T/MyClangTidyConfigBad
+// RUN: not clang-tidy -verify-config \
+// RUN: --config-file=%T/MyClangTidyConfigBad 2>&1 | FileCheck %s 
-check-prefix=CHECK-VERIFY-BLOCK-BAD
+// CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: check glob 
'bugprone-arguments-*' doesn't match any known check [-verify-config]
+// CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: unknown 
check 'bugprone-assert-side-effects'; did you mean 
'bugprone-assert-side-effect' [-verify-config]
+

From 0e2cb54934829f42069b06f599fa9e724bdf40b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?F=C3=A9lix-Antoine=20Constantin?=
 
Date: Sat, 23 Mar 2024 13:30:28 -0400
Subject: [PATCH 2/3] fixup! [clang-tidy] Improved --verify-config when using
 literal style in config file

Partially rewrote verifyChecks() to realign the checks parsing logic.

Instead of manually parsing the string of globs, verifyCHecks() now uses a 
GlobList which is responsible
to parse the string and return a list of regexes. This ensures that any changes 
made to the checks parsing logic
has to be made at only one place rather than two.
---
 clang-tools-extra/clang-tidy/GlobList.cpp | 14 ++--
 clang-tools-extra/clang-tidy/GlobList.h   |  4 ++
 .../clang-tidy/tool/ClangTidyMain.cpp 

[clang-tools-extra] [clang-tidy] Fix result check after overwriteChangedFiles() (PR #86360)

2024-03-23 Thread Piotr Zegar via cfe-commits

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


[clang-tools-extra] d7ce6b4 - [clang-tidy] Fix result check after overwriteChangedFiles() (#86360)

2024-03-23 Thread via cfe-commits

Author: Mike Rice
Date: 2024-03-23T17:53:29+01:00
New Revision: d7ce6b4d96c8879f38ba4cb5fdb1cc09d5b129e5

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

LOG: [clang-tidy] Fix result check after overwriteChangedFiles() (#86360)

If any return from overwriteChangedFiles is true some fixes were not
applied.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 40ac6918faf407..b877ea06dc05cd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -233,7 +233,7 @@ class ErrorReporter {
 if (!tooling::applyAllReplacements(Replacements.get(), Rewrite)) {
   llvm::errs() << "Can't apply replacements for file " << File << "\n";
 }
-AnyNotWritten &= Rewrite.overwriteChangedFiles();
+AnyNotWritten |= Rewrite.overwriteChangedFiles();
   }
 
   if (AnyNotWritten) {



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


[clang-tools-extra] [clang-tidy] Fix result check after overwriteChangedFiles() (PR #86360)

2024-03-23 Thread Piotr Zegar via cfe-commits

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

LGTM.
Yes looks like previously AnyNotWritten coudn't be `true`.

I don't see need for test / release notes.
After all the only thing this impact is a print.

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


[clang] [clang-tools-extra] [compiler-rt] [flang] [lld] [lldb] [llvm] [mlir] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-03-23 Thread via cfe-commits

ldrumm wrote:

> LGTM overall, but the CI failure looks real.

```
Failed Tests (3):
  Clang :: CXX/drs/dr23xx.cpp
  Clang :: CXX/drs/dr6xx.cpp
  Clang :: Lexer/raw-string-dlim-invalid.cpp
```

None of these files are in the diffstat, and none of them include any headers. 
I'm a bit stumped. Is it possible this is spurious?


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


[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/84473

>From 870e6a6def8c17859ffbb30906f91912268f872d Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Fri, 8 Mar 2024 11:55:42 +0100
Subject: [PATCH 01/10] [Clang] Fix dependence of DREs in lambdas with an
 explicit object parameter

---
 clang/lib/Sema/SemaExpr.cpp| 44 +---
 clang/lib/Sema/TreeTransform.h |  4 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 81 ++
 3 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 47bb263f56aade..700769860aa806 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20687,20 +20687,42 @@ void Sema::MarkVariableReferenced(SourceLocation Loc, 
VarDecl *Var) {
 static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(
 Sema , ValueDecl *D, Expr *E) {
   auto *ID = dyn_cast(E);
-  if (!ID || ID->isTypeDependent())
+  if (!ID || ID->isTypeDependent() || 
!ID->refersToEnclosingVariableOrCapture())
 return;
 
+  // If any enclosing lambda with a dependent explicit object parameter either
+  // explicitly captures the variable by value, or has a capture default of '='
+  // and does not capture the variable by reference, then the type of the DRE
+  // is dependent on the type of that lambda's explicit object parameter.
   auto IsDependent = [&]() {
-const LambdaScopeInfo *LSI = SemaRef.getCurLambda();
-if (!LSI)
-  return false;
-if (!LSI->ExplicitObjectParameter ||
-!LSI->ExplicitObjectParameter->getType()->isDependentType())
-  return false;
-if (!LSI->CaptureMap.count(D))
-  return false;
-const Capture  = LSI->getCapture(D);
-return !Cap.isCopyCapture();
+for (auto *Scope : llvm::reverse(SemaRef.FunctionScopes)) {
+  auto *LSI = dyn_cast(Scope);
+  if (!LSI)
+continue;
+
+  if (LSI->Lambda && !LSI->Lambda->Encloses(SemaRef.CurContext) &&
+  LSI->AfterParameterList)
+return false;
+
+  const auto *MD = LSI->CallOperator;
+  if (MD->getType().isNull())
+continue;
+
+  const auto *Ty = cast(MD->getType());
+  if (!Ty || !MD->isExplicitObjectMemberFunction() ||
+  !Ty->getParamType(0)->isDependentType())
+continue;
+
+  if (auto *C = LSI->CaptureMap.count(D) ? >getCapture(D) : nullptr) {
+if (C->isCopyCapture())
+  return true;
+continue;
+  }
+
+  if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
+return true;
+}
+return false;
   }();
 
   ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 7389a48fe56fcc..867efd1ce5c80a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11099,8 +11099,8 @@ 
TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) {
   }
 
   if (!getDerived().AlwaysRebuild() &&
-  QualifierLoc == E->getQualifierLoc() &&
-  ND == E->getDecl() &&
+  E->getDependence() == ExprDependence::None &&
+  QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
   Found == E->getFoundDecl() &&
   NameInfo.getName() == E->getDecl()->getDeclName() &&
   !E->hasExplicitTemplateArgs()) {
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index b8ddb9ad300034..6c21954554d281 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -200,6 +200,87 @@ void TestMutationInLambda() {
 [i = 0](this auto){ i++; }();
 [i = 0](this const auto&){ i++; }();
 // expected-error@-1 {{cannot assign to a variable captured by copy in a 
non-mutable lambda}}
+// expected-note@-2 {{in instantiation of}}
+
+int x;
+const auto l1 = [x](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+const auto l2 = [=](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+
+const auto l3 = [](this auto&) {
+const auto l3a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l3a(); // expected-note {{in instantiation of}}
+};
+
+const auto l4 = [](this auto&) {
+const auto l4a = [=](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l4a(); // expected-note {{in instantiation of}}
+};
+
+const auto l5 = [x](this auto&) {
+const auto l5a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l5a(); // expected-note {{in instantiation of}}
+};
+
+const auto l6 = [=](this auto&) {
+   

[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Fangrui Song via cfe-commits

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


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


[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/84473

>From 870e6a6def8c17859ffbb30906f91912268f872d Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Fri, 8 Mar 2024 11:55:42 +0100
Subject: [PATCH 1/9] [Clang] Fix dependence of DREs in lambdas with an
 explicit object parameter

---
 clang/lib/Sema/SemaExpr.cpp| 44 +---
 clang/lib/Sema/TreeTransform.h |  4 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 81 ++
 3 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 47bb263f56aade..700769860aa806 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20687,20 +20687,42 @@ void Sema::MarkVariableReferenced(SourceLocation Loc, 
VarDecl *Var) {
 static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(
 Sema , ValueDecl *D, Expr *E) {
   auto *ID = dyn_cast(E);
-  if (!ID || ID->isTypeDependent())
+  if (!ID || ID->isTypeDependent() || 
!ID->refersToEnclosingVariableOrCapture())
 return;
 
+  // If any enclosing lambda with a dependent explicit object parameter either
+  // explicitly captures the variable by value, or has a capture default of '='
+  // and does not capture the variable by reference, then the type of the DRE
+  // is dependent on the type of that lambda's explicit object parameter.
   auto IsDependent = [&]() {
-const LambdaScopeInfo *LSI = SemaRef.getCurLambda();
-if (!LSI)
-  return false;
-if (!LSI->ExplicitObjectParameter ||
-!LSI->ExplicitObjectParameter->getType()->isDependentType())
-  return false;
-if (!LSI->CaptureMap.count(D))
-  return false;
-const Capture  = LSI->getCapture(D);
-return !Cap.isCopyCapture();
+for (auto *Scope : llvm::reverse(SemaRef.FunctionScopes)) {
+  auto *LSI = dyn_cast(Scope);
+  if (!LSI)
+continue;
+
+  if (LSI->Lambda && !LSI->Lambda->Encloses(SemaRef.CurContext) &&
+  LSI->AfterParameterList)
+return false;
+
+  const auto *MD = LSI->CallOperator;
+  if (MD->getType().isNull())
+continue;
+
+  const auto *Ty = cast(MD->getType());
+  if (!Ty || !MD->isExplicitObjectMemberFunction() ||
+  !Ty->getParamType(0)->isDependentType())
+continue;
+
+  if (auto *C = LSI->CaptureMap.count(D) ? >getCapture(D) : nullptr) {
+if (C->isCopyCapture())
+  return true;
+continue;
+  }
+
+  if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
+return true;
+}
+return false;
   }();
 
   ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 7389a48fe56fcc..867efd1ce5c80a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11099,8 +11099,8 @@ 
TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) {
   }
 
   if (!getDerived().AlwaysRebuild() &&
-  QualifierLoc == E->getQualifierLoc() &&
-  ND == E->getDecl() &&
+  E->getDependence() == ExprDependence::None &&
+  QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
   Found == E->getFoundDecl() &&
   NameInfo.getName() == E->getDecl()->getDeclName() &&
   !E->hasExplicitTemplateArgs()) {
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index b8ddb9ad300034..6c21954554d281 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -200,6 +200,87 @@ void TestMutationInLambda() {
 [i = 0](this auto){ i++; }();
 [i = 0](this const auto&){ i++; }();
 // expected-error@-1 {{cannot assign to a variable captured by copy in a 
non-mutable lambda}}
+// expected-note@-2 {{in instantiation of}}
+
+int x;
+const auto l1 = [x](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+const auto l2 = [=](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+
+const auto l3 = [](this auto&) {
+const auto l3a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l3a(); // expected-note {{in instantiation of}}
+};
+
+const auto l4 = [](this auto&) {
+const auto l4a = [=](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l4a(); // expected-note {{in instantiation of}}
+};
+
+const auto l5 = [x](this auto&) {
+const auto l5a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l5a(); // expected-note {{in instantiation of}}
+};
+
+const auto l6 = [=](this auto&) {
+ 

[clang] [clang-repl] Support wasm execution (PR #86402)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [clang-repl] Support wasm execution (PR #86402)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [clang][Sema] Ignore the parentheses in the guard of DiagnoseUnexpandedParameterPack (PR #86401)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [clang][Sema] Ignore the parentheses in the guard of DiagnoseUnexpandedParameterPack (PR #86401)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [clang-repl] Support wasm execution (PR #86402)

2024-03-23 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

cc: @sylvaincorlay, @JohanMabille, @anutosh491


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


[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/84473

>From 870e6a6def8c17859ffbb30906f91912268f872d Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Fri, 8 Mar 2024 11:55:42 +0100
Subject: [PATCH 1/8] [Clang] Fix dependence of DREs in lambdas with an
 explicit object parameter

---
 clang/lib/Sema/SemaExpr.cpp| 44 +---
 clang/lib/Sema/TreeTransform.h |  4 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 81 ++
 3 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 47bb263f56aade..700769860aa806 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20687,20 +20687,42 @@ void Sema::MarkVariableReferenced(SourceLocation Loc, 
VarDecl *Var) {
 static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(
 Sema , ValueDecl *D, Expr *E) {
   auto *ID = dyn_cast(E);
-  if (!ID || ID->isTypeDependent())
+  if (!ID || ID->isTypeDependent() || 
!ID->refersToEnclosingVariableOrCapture())
 return;
 
+  // If any enclosing lambda with a dependent explicit object parameter either
+  // explicitly captures the variable by value, or has a capture default of '='
+  // and does not capture the variable by reference, then the type of the DRE
+  // is dependent on the type of that lambda's explicit object parameter.
   auto IsDependent = [&]() {
-const LambdaScopeInfo *LSI = SemaRef.getCurLambda();
-if (!LSI)
-  return false;
-if (!LSI->ExplicitObjectParameter ||
-!LSI->ExplicitObjectParameter->getType()->isDependentType())
-  return false;
-if (!LSI->CaptureMap.count(D))
-  return false;
-const Capture  = LSI->getCapture(D);
-return !Cap.isCopyCapture();
+for (auto *Scope : llvm::reverse(SemaRef.FunctionScopes)) {
+  auto *LSI = dyn_cast(Scope);
+  if (!LSI)
+continue;
+
+  if (LSI->Lambda && !LSI->Lambda->Encloses(SemaRef.CurContext) &&
+  LSI->AfterParameterList)
+return false;
+
+  const auto *MD = LSI->CallOperator;
+  if (MD->getType().isNull())
+continue;
+
+  const auto *Ty = cast(MD->getType());
+  if (!Ty || !MD->isExplicitObjectMemberFunction() ||
+  !Ty->getParamType(0)->isDependentType())
+continue;
+
+  if (auto *C = LSI->CaptureMap.count(D) ? >getCapture(D) : nullptr) {
+if (C->isCopyCapture())
+  return true;
+continue;
+  }
+
+  if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
+return true;
+}
+return false;
   }();
 
   ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 7389a48fe56fcc..867efd1ce5c80a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11099,8 +11099,8 @@ 
TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) {
   }
 
   if (!getDerived().AlwaysRebuild() &&
-  QualifierLoc == E->getQualifierLoc() &&
-  ND == E->getDecl() &&
+  E->getDependence() == ExprDependence::None &&
+  QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
   Found == E->getFoundDecl() &&
   NameInfo.getName() == E->getDecl()->getDeclName() &&
   !E->hasExplicitTemplateArgs()) {
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index b8ddb9ad300034..6c21954554d281 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -200,6 +200,87 @@ void TestMutationInLambda() {
 [i = 0](this auto){ i++; }();
 [i = 0](this const auto&){ i++; }();
 // expected-error@-1 {{cannot assign to a variable captured by copy in a 
non-mutable lambda}}
+// expected-note@-2 {{in instantiation of}}
+
+int x;
+const auto l1 = [x](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+const auto l2 = [=](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+
+const auto l3 = [](this auto&) {
+const auto l3a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l3a(); // expected-note {{in instantiation of}}
+};
+
+const auto l4 = [](this auto&) {
+const auto l4a = [=](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l4a(); // expected-note {{in instantiation of}}
+};
+
+const auto l5 = [x](this auto&) {
+const auto l5a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l5a(); // expected-note {{in instantiation of}}
+};
+
+const auto l6 = [=](this auto&) {
+ 

[clang] [clang-repl] Support wasm execution (PR #86402)

2024-03-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vassil Vassilev (vgvassilev)


Changes

This commit introduces support for running clang-repl and executing C++ code 
interactively inside a Javascript engine using WebAssembly when built with 
Emscripten. This is achieved by producing WASM "shared libraries" that can be 
loaded by the Emscripten runtime using dlopen()

More discussion is available in https://reviews.llvm.org/D158140


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


6 Files Affected:

- (modified) clang/lib/Interpreter/CMakeLists.txt (+1) 
- (modified) clang/lib/Interpreter/IncrementalExecutor.cpp (+2) 
- (modified) clang/lib/Interpreter/IncrementalExecutor.h (+7-4) 
- (modified) clang/lib/Interpreter/Interpreter.cpp (+13-2) 
- (added) clang/lib/Interpreter/Wasm.cpp (+111) 
- (added) clang/lib/Interpreter/Wasm.h (+33) 


``diff
diff --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index 9065f998f73c47..9d302d995801d5 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -20,6 +20,7 @@ add_clang_library(clangInterpreter
   Interpreter.cpp
   InterpreterUtils.cpp
   Value.cpp
+  Wasm.cpp
 
   DEPENDS
   intrinsics_gen
diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 40bcef94797d43..5180905c9e6d24 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -35,6 +35,8 @@ LLVM_ATTRIBUTE_USED void linkComponents() {
 }
 
 namespace clang {
+IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext )
+: TSCtx(TSC) {}
 
 IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext ,
  llvm::Error ,
diff --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index dd0a210a061415..958be66efc3281 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -41,16 +41,19 @@ class IncrementalExecutor {
   llvm::DenseMap
   ResourceTrackers;
 
+protected:
+  IncrementalExecutor(llvm::orc::ThreadSafeContext );
+
 public:
   enum SymbolNameKind { IRName, LinkerName };
 
   IncrementalExecutor(llvm::orc::ThreadSafeContext , llvm::Error ,
   const clang::TargetInfo );
-  ~IncrementalExecutor();
+  virtual ~IncrementalExecutor();
 
-  llvm::Error addModule(PartialTranslationUnit );
-  llvm::Error removeModule(PartialTranslationUnit );
-  llvm::Error runCtors() const;
+  virtual llvm::Error addModule(PartialTranslationUnit );
+  virtual llvm::Error removeModule(PartialTranslationUnit );
+  virtual llvm::Error runCtors() const;
   llvm::Error cleanUp();
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 7fa52f2f15fc49..18c76685636855 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -15,6 +15,7 @@
 #include "IncrementalExecutor.h"
 #include "IncrementalParser.h"
 #include "InterpreterUtils.h"
+#include "Wasm.h"
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Mangle.h"
@@ -183,6 +184,12 @@ IncrementalCompilerBuilder::CreateCpp() {
   std::vector Argv;
   Argv.reserve(5 + 1 + UserArgs.size());
   Argv.push_back("-xc++");
+#ifdef __EMSCRIPTEN__
+  Argv.push_back("-target");
+  Argv.push_back("wasm32-unknown-emscripten");
+  Argv.push_back("-pie");
+  Argv.push_back("-shared");
+#endif
   Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());
 
   std::string TT = TargetTriple ? *TargetTriple : 
llvm::sys::getProcessTriple();
@@ -373,14 +380,18 @@ Interpreter::Parse(llvm::StringRef Code) {
 }
 
 llvm::Error Interpreter::CreateExecutor() {
-  const clang::TargetInfo  =
-  getCompilerInstance()->getASTContext().getTargetInfo();
   if (IncrExecutor)
 return llvm::make_error("Operation failed. "
"Execution engine exists",
std::error_code());
   llvm::Error Err = llvm::Error::success();
+  const clang::TargetInfo  =
+  getCompilerInstance()->getASTContext().getTargetInfo();
+#ifdef __EMSCRIPTEN__
+  auto Executor = std::make_unique(*TSCtx, Err, TI);
+#else
   auto Executor = std::make_unique(*TSCtx, Err, TI);
+#endif
   if (!Err)
 IncrExecutor = std::move(Executor);
 
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
new file mode 100644
index 00..cb455f111ea888
--- /dev/null
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -0,0 +1,111 @@
+//===- Wasm.cpp - Wasm Interpreter --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// 

[clang] [clang-repl] Support wasm execution (PR #86402)

2024-03-23 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev created 
https://github.com/llvm/llvm-project/pull/86402

This commit introduces support for running clang-repl and executing C++ code 
interactively inside a Javascript engine using WebAssembly when built with 
Emscripten. This is achieved by producing WASM "shared libraries" that can be 
loaded by the Emscripten runtime using dlopen()

More discussion is available in https://reviews.llvm.org/D158140


>From 8286544c2993b0ba7c4f97dcb62c8503a02d84b0 Mon Sep 17 00:00:00 2001
From: Anubhab Ghosh 
Date: Sat, 23 Mar 2024 15:13:57 +
Subject: [PATCH 1/2] [clang-repl] Support wasm execution.

This commit introduces support for running clang-repl and executing C++ code
interactively inside a Javascript engine using WebAssembly when built with
Emscripten. This is achieved by producing WASM "shared libraries" that can be
loaded by the Emscripten runtime using dlopen()

More discussion is available in https://reviews.llvm.org/D158140
---
 clang/lib/Interpreter/CMakeLists.txt  |   1 +
 clang/lib/Interpreter/IncrementalExecutor.cpp |   2 +
 clang/lib/Interpreter/IncrementalExecutor.h   |  11 +-
 clang/lib/Interpreter/Interpreter.cpp |  15 ++-
 clang/lib/Interpreter/WASM.cpp| 107 ++
 clang/lib/Interpreter/WASM.h  |  33 ++
 6 files changed, 163 insertions(+), 6 deletions(-)
 create mode 100644 clang/lib/Interpreter/WASM.cpp
 create mode 100644 clang/lib/Interpreter/WASM.h

diff --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index 9065f998f73c47..a8a287edf5b049 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -20,6 +20,7 @@ add_clang_library(clangInterpreter
   Interpreter.cpp
   InterpreterUtils.cpp
   Value.cpp
+  WASM.cpp
 
   DEPENDS
   intrinsics_gen
diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 40bcef94797d43..5180905c9e6d24 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -35,6 +35,8 @@ LLVM_ATTRIBUTE_USED void linkComponents() {
 }
 
 namespace clang {
+IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext )
+: TSCtx(TSC) {}
 
 IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext ,
  llvm::Error ,
diff --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index dd0a210a061415..958be66efc3281 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -41,16 +41,19 @@ class IncrementalExecutor {
   llvm::DenseMap
   ResourceTrackers;
 
+protected:
+  IncrementalExecutor(llvm::orc::ThreadSafeContext );
+
 public:
   enum SymbolNameKind { IRName, LinkerName };
 
   IncrementalExecutor(llvm::orc::ThreadSafeContext , llvm::Error ,
   const clang::TargetInfo );
-  ~IncrementalExecutor();
+  virtual ~IncrementalExecutor();
 
-  llvm::Error addModule(PartialTranslationUnit );
-  llvm::Error removeModule(PartialTranslationUnit );
-  llvm::Error runCtors() const;
+  virtual llvm::Error addModule(PartialTranslationUnit );
+  virtual llvm::Error removeModule(PartialTranslationUnit );
+  virtual llvm::Error runCtors() const;
   llvm::Error cleanUp();
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 7fa52f2f15fc49..b97ef0c5ddef26 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -15,6 +15,7 @@
 #include "IncrementalExecutor.h"
 #include "IncrementalParser.h"
 #include "InterpreterUtils.h"
+#include "WASM.h"
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Mangle.h"
@@ -183,6 +184,12 @@ IncrementalCompilerBuilder::CreateCpp() {
   std::vector Argv;
   Argv.reserve(5 + 1 + UserArgs.size());
   Argv.push_back("-xc++");
+#ifdef __EMSCRIPTEN__
+  Argv.push_back("-target");
+  Argv.push_back("wasm32-unknown-emscripten");
+  Argv.push_back("-pie");
+  Argv.push_back("-shared");
+#endif
   Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());
 
   std::string TT = TargetTriple ? *TargetTriple : 
llvm::sys::getProcessTriple();
@@ -373,14 +380,18 @@ Interpreter::Parse(llvm::StringRef Code) {
 }
 
 llvm::Error Interpreter::CreateExecutor() {
-  const clang::TargetInfo  =
-  getCompilerInstance()->getASTContext().getTargetInfo();
   if (IncrExecutor)
 return llvm::make_error("Operation failed. "
"Execution engine exists",
std::error_code());
   llvm::Error Err = llvm::Error::success();
+  const clang::TargetInfo  =
+  getCompilerInstance()->getASTContext().getTargetInfo();
+#ifdef __EMSCRIPTEN__
+  auto Executor = 

[clang] [clang][Sema] Ignore the parentheses in the guard of DiagnoseUnexpandedParameterPack (PR #86401)

2024-03-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

This is a follow-up for https://github.com/llvm/llvm-project/pull/69224, where 
the previous fix failed to handle the parentheses around the expression.

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

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+1-1) 
- (modified) clang/test/SemaCXX/pr61460.cpp (+1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8054d90fc70f93..1bf7d7fcda2a4a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -439,6 +439,8 @@ Bug Fixes to C++ Support
 - Fix a crash when instantiating a lambda that captures ``this`` outside of 
its context. Fixes (#GH85343).
 - Fix an issue where a namespace alias could be defined using a qualified name 
(all name components
   following the first `::` were ignored).
+- A follow-up fix was added for (#GH61460), where the fix previously 
overlooked the parentheses
+  around the expression. (#GH86361)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 903fbfd18e779c..1c4a09bca4e3ff 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -415,7 +415,7 @@ bool Sema::DiagnoseUnexpandedParameterPack(Expr *E,
   // FunctionParmPackExpr, but diagnosing unexpected parameter packs may still
   // see such an expression in a lambda body.
   // We'll bail out early in this case to avoid triggering an assertion.
-  if (isa(E) && getEnclosingLambda())
+  if (isa(E->IgnoreParens()) && getEnclosingLambda())
 return false;
 
   SmallVector Unexpanded;
diff --git a/clang/test/SemaCXX/pr61460.cpp b/clang/test/SemaCXX/pr61460.cpp
index 471b1b39d23c2b..44a11c30b95b59 100644
--- a/clang/test/SemaCXX/pr61460.cpp
+++ b/clang/test/SemaCXX/pr61460.cpp
@@ -2,6 +2,7 @@
 
 template  void g(Ts... p1s) {
   (void)[&](auto... p2s) { ([&] { p1s; p2s; }, ...); };
+  (void)[&](auto... p2s) { ([&] { (p1s); p2s; }, ...); };
 }
 
 void f1() {

``




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


[clang] [clang][Sema] Ignore the parentheses in the guard of DiagnoseUnexpandedParameterPack (PR #86401)

2024-03-23 Thread Younan Zhang via cfe-commits

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


[clang] [clang][Sema] Ignore the parentheses in the guard of DiagnoseUnexpandedParameterPack (PR #86401)

2024-03-23 Thread Younan Zhang via cfe-commits

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

>From 1a990278196bf9c8753fe318f060f17fb8d0e669 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 24 Mar 2024 00:00:31 +0800
Subject: [PATCH] [clang][Sema] Ignore the parentheses in the guard of
 DiagnoseUnexpandedParameterPack

This is a follow-up for https://github.com/llvm/llvm-project/pull/69224,
where the previous fix failed to handle the parentheses around the
expression.

Fixes https://github.com/llvm/llvm-project/issues/86361.
---
 clang/docs/ReleaseNotes.rst | 2 ++
 clang/lib/Sema/SemaTemplateVariadic.cpp | 2 +-
 clang/test/SemaCXX/pr61460.cpp  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 690fc7ed271a3d..9c3dec4d17e022 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -344,6 +344,8 @@ Bug Fixes to C++ Support
   when one of the function had more specialized templates.
   Fixes (`#82509 `_)
   and (`#74494 `_)
+- A follow-up fix was added for (#GH61460), where the fix previously 
overlooked the parentheses
+  around the expression. (#GH86361)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 903fbfd18e779c..1c4a09bca4e3ff 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -415,7 +415,7 @@ bool Sema::DiagnoseUnexpandedParameterPack(Expr *E,
   // FunctionParmPackExpr, but diagnosing unexpected parameter packs may still
   // see such an expression in a lambda body.
   // We'll bail out early in this case to avoid triggering an assertion.
-  if (isa(E) && getEnclosingLambda())
+  if (isa(E->IgnoreParens()) && getEnclosingLambda())
 return false;
 
   SmallVector Unexpanded;
diff --git a/clang/test/SemaCXX/pr61460.cpp b/clang/test/SemaCXX/pr61460.cpp
index 471b1b39d23c2b..44a11c30b95b59 100644
--- a/clang/test/SemaCXX/pr61460.cpp
+++ b/clang/test/SemaCXX/pr61460.cpp
@@ -2,6 +2,7 @@
 
 template  void g(Ts... p1s) {
   (void)[&](auto... p2s) { ([&] { p1s; p2s; }, ...); };
+  (void)[&](auto... p2s) { ([&] { (p1s); p2s; }, ...); };
 }
 
 void f1() {

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


[clang] [clang][Sema] Ignore the parentheses in the guard of DiagnoseUnexpandedParameterPack (PR #86401)

2024-03-23 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/86401

This is a follow-up for https://github.com/llvm/llvm-project/pull/69224, where 
the previous fix failed to handle the parentheses around the expression.

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

>From 1a990278196bf9c8753fe318f060f17fb8d0e669 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 24 Mar 2024 00:00:31 +0800
Subject: [PATCH] [clang][Sema] Ignore the parentheses in the guard of
 DiagnoseUnexpandedParameterPack

This is a follow-up for https://github.com/llvm/llvm-project/pull/69224,
where the previous fix failed to handle the parentheses around the
expression.

Fixes https://github.com/llvm/llvm-project/issues/86361.
---
 clang/docs/ReleaseNotes.rst | 2 ++
 clang/lib/Sema/SemaTemplateVariadic.cpp | 2 +-
 clang/test/SemaCXX/pr61460.cpp  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 690fc7ed271a3d..9c3dec4d17e022 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -344,6 +344,8 @@ Bug Fixes to C++ Support
   when one of the function had more specialized templates.
   Fixes (`#82509 `_)
   and (`#74494 `_)
+- A follow-up fix was added for (#GH61460), where the fix previously 
overlooked the parentheses
+  around the expression. (#GH86361)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 903fbfd18e779c..1c4a09bca4e3ff 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -415,7 +415,7 @@ bool Sema::DiagnoseUnexpandedParameterPack(Expr *E,
   // FunctionParmPackExpr, but diagnosing unexpected parameter packs may still
   // see such an expression in a lambda body.
   // We'll bail out early in this case to avoid triggering an assertion.
-  if (isa(E) && getEnclosingLambda())
+  if (isa(E->IgnoreParens()) && getEnclosingLambda())
 return false;
 
   SmallVector Unexpanded;
diff --git a/clang/test/SemaCXX/pr61460.cpp b/clang/test/SemaCXX/pr61460.cpp
index 471b1b39d23c2b..44a11c30b95b59 100644
--- a/clang/test/SemaCXX/pr61460.cpp
+++ b/clang/test/SemaCXX/pr61460.cpp
@@ -2,6 +2,7 @@
 
 template  void g(Ts... p1s) {
   (void)[&](auto... p2s) { ([&] { p1s; p2s; }, ...); };
+  (void)[&](auto... p2s) { ([&] { (p1s); p2s; }, ...); };
 }
 
 void f1() {

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


[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/84473

>From 870e6a6def8c17859ffbb30906f91912268f872d Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Fri, 8 Mar 2024 11:55:42 +0100
Subject: [PATCH 1/7] [Clang] Fix dependence of DREs in lambdas with an
 explicit object parameter

---
 clang/lib/Sema/SemaExpr.cpp| 44 +---
 clang/lib/Sema/TreeTransform.h |  4 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 81 ++
 3 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 47bb263f56aade..700769860aa806 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20687,20 +20687,42 @@ void Sema::MarkVariableReferenced(SourceLocation Loc, 
VarDecl *Var) {
 static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(
 Sema , ValueDecl *D, Expr *E) {
   auto *ID = dyn_cast(E);
-  if (!ID || ID->isTypeDependent())
+  if (!ID || ID->isTypeDependent() || 
!ID->refersToEnclosingVariableOrCapture())
 return;
 
+  // If any enclosing lambda with a dependent explicit object parameter either
+  // explicitly captures the variable by value, or has a capture default of '='
+  // and does not capture the variable by reference, then the type of the DRE
+  // is dependent on the type of that lambda's explicit object parameter.
   auto IsDependent = [&]() {
-const LambdaScopeInfo *LSI = SemaRef.getCurLambda();
-if (!LSI)
-  return false;
-if (!LSI->ExplicitObjectParameter ||
-!LSI->ExplicitObjectParameter->getType()->isDependentType())
-  return false;
-if (!LSI->CaptureMap.count(D))
-  return false;
-const Capture  = LSI->getCapture(D);
-return !Cap.isCopyCapture();
+for (auto *Scope : llvm::reverse(SemaRef.FunctionScopes)) {
+  auto *LSI = dyn_cast(Scope);
+  if (!LSI)
+continue;
+
+  if (LSI->Lambda && !LSI->Lambda->Encloses(SemaRef.CurContext) &&
+  LSI->AfterParameterList)
+return false;
+
+  const auto *MD = LSI->CallOperator;
+  if (MD->getType().isNull())
+continue;
+
+  const auto *Ty = cast(MD->getType());
+  if (!Ty || !MD->isExplicitObjectMemberFunction() ||
+  !Ty->getParamType(0)->isDependentType())
+continue;
+
+  if (auto *C = LSI->CaptureMap.count(D) ? >getCapture(D) : nullptr) {
+if (C->isCopyCapture())
+  return true;
+continue;
+  }
+
+  if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
+return true;
+}
+return false;
   }();
 
   ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 7389a48fe56fcc..867efd1ce5c80a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11099,8 +11099,8 @@ 
TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) {
   }
 
   if (!getDerived().AlwaysRebuild() &&
-  QualifierLoc == E->getQualifierLoc() &&
-  ND == E->getDecl() &&
+  E->getDependence() == ExprDependence::None &&
+  QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
   Found == E->getFoundDecl() &&
   NameInfo.getName() == E->getDecl()->getDeclName() &&
   !E->hasExplicitTemplateArgs()) {
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index b8ddb9ad300034..6c21954554d281 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -200,6 +200,87 @@ void TestMutationInLambda() {
 [i = 0](this auto){ i++; }();
 [i = 0](this const auto&){ i++; }();
 // expected-error@-1 {{cannot assign to a variable captured by copy in a 
non-mutable lambda}}
+// expected-note@-2 {{in instantiation of}}
+
+int x;
+const auto l1 = [x](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+const auto l2 = [=](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+
+const auto l3 = [](this auto&) {
+const auto l3a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l3a(); // expected-note {{in instantiation of}}
+};
+
+const auto l4 = [](this auto&) {
+const auto l4a = [=](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l4a(); // expected-note {{in instantiation of}}
+};
+
+const auto l5 = [x](this auto&) {
+const auto l5a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l5a(); // expected-note {{in instantiation of}}
+};
+
+const auto l6 = [=](this auto&) {
+ 

[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

Sirraide wrote:

@Link1J The issue you linked does seem to be another symptom of the underlying 
problem here, yeah. It’s also not technically a duplicate, so I’ve left it open 
and marked it as fixed by this pr.

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


[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/84473

>From 870e6a6def8c17859ffbb30906f91912268f872d Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Fri, 8 Mar 2024 11:55:42 +0100
Subject: [PATCH 1/6] [Clang] Fix dependence of DREs in lambdas with an
 explicit object parameter

---
 clang/lib/Sema/SemaExpr.cpp| 44 +---
 clang/lib/Sema/TreeTransform.h |  4 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 81 ++
 3 files changed, 116 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 47bb263f56aade..700769860aa806 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20687,20 +20687,42 @@ void Sema::MarkVariableReferenced(SourceLocation Loc, 
VarDecl *Var) {
 static void FixDependencyOfIdExpressionsInLambdaWithDependentObjectParameter(
 Sema , ValueDecl *D, Expr *E) {
   auto *ID = dyn_cast(E);
-  if (!ID || ID->isTypeDependent())
+  if (!ID || ID->isTypeDependent() || 
!ID->refersToEnclosingVariableOrCapture())
 return;
 
+  // If any enclosing lambda with a dependent explicit object parameter either
+  // explicitly captures the variable by value, or has a capture default of '='
+  // and does not capture the variable by reference, then the type of the DRE
+  // is dependent on the type of that lambda's explicit object parameter.
   auto IsDependent = [&]() {
-const LambdaScopeInfo *LSI = SemaRef.getCurLambda();
-if (!LSI)
-  return false;
-if (!LSI->ExplicitObjectParameter ||
-!LSI->ExplicitObjectParameter->getType()->isDependentType())
-  return false;
-if (!LSI->CaptureMap.count(D))
-  return false;
-const Capture  = LSI->getCapture(D);
-return !Cap.isCopyCapture();
+for (auto *Scope : llvm::reverse(SemaRef.FunctionScopes)) {
+  auto *LSI = dyn_cast(Scope);
+  if (!LSI)
+continue;
+
+  if (LSI->Lambda && !LSI->Lambda->Encloses(SemaRef.CurContext) &&
+  LSI->AfterParameterList)
+return false;
+
+  const auto *MD = LSI->CallOperator;
+  if (MD->getType().isNull())
+continue;
+
+  const auto *Ty = cast(MD->getType());
+  if (!Ty || !MD->isExplicitObjectMemberFunction() ||
+  !Ty->getParamType(0)->isDependentType())
+continue;
+
+  if (auto *C = LSI->CaptureMap.count(D) ? >getCapture(D) : nullptr) {
+if (C->isCopyCapture())
+  return true;
+continue;
+  }
+
+  if (LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval)
+return true;
+}
+return false;
   }();
 
   ID->setCapturedByCopyInLambdaWithExplicitObjectParameter(
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 7389a48fe56fcc..867efd1ce5c80a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11099,8 +11099,8 @@ 
TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) {
   }
 
   if (!getDerived().AlwaysRebuild() &&
-  QualifierLoc == E->getQualifierLoc() &&
-  ND == E->getDecl() &&
+  E->getDependence() == ExprDependence::None &&
+  QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
   Found == E->getFoundDecl() &&
   NameInfo.getName() == E->getDecl()->getDeclName() &&
   !E->hasExplicitTemplateArgs()) {
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index b8ddb9ad300034..6c21954554d281 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -200,6 +200,87 @@ void TestMutationInLambda() {
 [i = 0](this auto){ i++; }();
 [i = 0](this const auto&){ i++; }();
 // expected-error@-1 {{cannot assign to a variable captured by copy in a 
non-mutable lambda}}
+// expected-note@-2 {{in instantiation of}}
+
+int x;
+const auto l1 = [x](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+const auto l2 = [=](this auto&) { x = 42; }; // expected-error {{cannot 
assign to a variable captured by copy in a non-mutable lambda}}
+
+const auto l3 = [](this auto&) {
+const auto l3a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l3a(); // expected-note {{in instantiation of}}
+};
+
+const auto l4 = [](this auto&) {
+const auto l4a = [=](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l4a(); // expected-note {{in instantiation of}}
+};
+
+const auto l5 = [x](this auto&) {
+const auto l5a = [x](this auto&) { x = 42; }; // expected-error 
{{cannot assign to a variable captured by copy in a non-mutable lambda}}
+l5a(); // expected-note {{in instantiation of}}
+};
+
+const auto l6 = [=](this auto&) {
+ 

[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread via cfe-commits

Sirraide wrote:

> Does this fix #86054, or is it a different bug? It seems related to the other 
> issues mentioned here.

I’ll check.

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


[clang] [Clang] [Sema] Fix dependence of DREs in lambdas with an explicit object parameter (PR #84473)

2024-03-23 Thread Jared Irwin via cfe-commits

Link1J wrote:

Does this fix #86054, or is it a different bug?
It seems related to the other issues mentioned here.

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


[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

2024-03-23 Thread Younan Zhang via cfe-commits

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

>From 6e7b38b3e3f781e11db2fa5d552fdfb6123609df Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 22 Mar 2024 17:34:08 +0800
Subject: [PATCH 1/3] [Sema] Preserve ContainsUnexpandedParameterPack in
 TransformLambdaExpr

---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Sema/Sema.h   |  8 +++
 clang/lib/Sema/SemaTemplateVariadic.cpp   | 16 +-
 clang/lib/Sema/TreeTransform.h| 18 ++
 .../test/SemaTemplate/lambda-capture-pack.cpp | 57 +++
 5 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 690fc7ed271a3d..2d11a4b8c092a2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -344,6 +344,8 @@ Bug Fixes to C++ Support
   when one of the function had more specialized templates.
   Fixes (`#82509 `_)
   and (`#74494 `_)
+- Fixed a crash where template parameter packs were not expanded correctly in 
a lambda being
+  used as a pattern of a folded expression. (#GH56852), (#GH85667)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index cfc1c3b3494788..0d1a2e54840e52 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11201,6 +11201,14 @@ class Sema final {
   void collectUnexpandedParameterPacks(
   QualType T, SmallVectorImpl );
 
+  /// Collect the set of unexpanded parameter packs from a lambda call 
operator.
+  ///
+  /// \param LambdaCall The lambda call operator that will be traversed to find
+  /// unexpanded parameter packs.
+  void collectUnexpandedParameterPacksFromLambda(
+  CXXMethodDecl *LambdaCall,
+  SmallVectorImpl );
+
   /// Collect the set of unexpanded parameter packs within the given
   /// type.
   ///
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 903fbfd18e779c..638ceac4148aec 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -8,14 +8,15 @@
 //  This file implements semantic analysis for C++0x variadic templates.
 //===--===/
 
-#include "clang/Sema/Sema.h"
 #include "TypeLocBuilder.h"
+#include "clang/AST/ASTLambda.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/ScopeInfo.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
 #include 
@@ -61,8 +62,9 @@ namespace {
 
   public:
 explicit CollectUnexpandedParameterPacksVisitor(
-SmallVectorImpl )
-: Unexpanded(Unexpanded) {}
+SmallVectorImpl ,
+bool InLambda = false)
+: Unexpanded(Unexpanded), InLambda(InLambda) {}
 
 bool shouldWalkTypesOfTypeLocs() const { return false; }
 
@@ -544,6 +546,14 @@ void Sema::collectUnexpandedParameterPacks(QualType T,
   CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
 }
 
+void Sema::collectUnexpandedParameterPacksFromLambda(
+CXXMethodDecl *LambdaCall,
+SmallVectorImpl ) {
+  assert(isLambdaCallOperator(LambdaCall) && "Expected a lambda call 
operator");
+  CollectUnexpandedParameterPacksVisitor(Unexpanded, /*InLambda=*/true)
+  .TraverseDecl(LambdaCall);
+}
+
 void Sema::collectUnexpandedParameterPacks(TypeLoc TL,
SmallVectorImpl ) {
   CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2d22692f3ab750..f5a859c57034a5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13748,6 +13748,8 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 }
 NewVDs.push_back(NewVD);
 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
+LSI->ContainsUnexpandedParameterPack |=
+Init.get()->containsUnexpandedParameterPack();
   }
 
   if (Invalid)
@@ -13936,6 +13938,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 /*IsInstantiation*/ true);
   SavedContext.pop();
 
+  // The lambda may contain a pack that would be expanded by a fold expression
+  // outside. We should preserve the ContainsUnexpandedParameterPack flag here
+  // because CXXFoldExprs use it for the pattern.
+  // For example,
+  //
+  // []() { ([I = Is()]() {}, ...); }
+  //
+  // forgetting the flag will result in getPattern() of CXXFoldExpr returning
+  // null in terms of the inner lambda.
+  if 

[clang] [clang][CodeGen] Allow memcpy replace with trivial auto var init (PR #84230)

2024-03-23 Thread Antonio Frighetto via cfe-commits

antoniofrighetto wrote:

@tstellar Yes, thanks (I opened a new PR for that: 
https://github.com/llvm/llvm-project/pull/86106). 

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2024-03-23 Thread Charalampos Mitrodimas via cfe-commits

https://github.com/charmitro updated 
https://github.com/llvm/llvm-project/pull/74510

>From 89eb978ece40cd99b3ac535ae25191e0edadb378 Mon Sep 17 00:00:00 2001
From: Charalampos Mitrodimas 
Date: Tue, 5 Dec 2023 11:46:56 +0200
Subject: [PATCH] [clang] Disable missing definition warning on pure virtual
 functions

Warning '-Wundefined-func-template' incorrectly indicates that no
definition is available for a pure virtual function. However, a
definition is not needed for a pure virtual function.

Fixes #74016

Signed-off-by: Charalampos Mitrodimas 
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 clang/lib/Sema/SemaExpr.cpp   |  2 +-
 .../instantiate-pure-virtual-function.cpp | 67 +++
 3 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8054d90fc70f93..643eb6cc157732 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -294,6 +294,10 @@ Improvements to Clang's time-trace
 
 Bug Fixes in This Version
 -
+- Clang's ``-Wundefined-func-template`` no longer warns on pure virtual
+  functions.
+  (`#74016 `_)
+
 - Fixed missing warnings when comparing mismatched enumeration constants
   in C (`#29217 `).
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5f03b981428251..c696f5eee31dec 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18952,7 +18952,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, 
FunctionDecl *Func,
   //   constant evaluated
   bool NeededForConstantEvaluation =
   isPotentiallyConstantEvaluatedContext(*this) &&
-  isImplicitlyDefinableConstexprFunction(Func);
+  isImplicitlyDefinableConstexprFunction(Func) && !Func->isPureVirtual();
 
   // Determine whether we require a function definition to exist, per
   // C++11 [temp.inst]p3:
diff --git a/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp 
b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
new file mode 100644
index 00..caec42b6b77f95
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wundefined-func-template %s
+
+namespace GH74016 {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+virtual constexpr void bar(unsigned int) = 0;
+  };
+
+  template  class D : public B {
+  public:
+constexpr void bar(unsigned int) override {}
+  };
+
+  void test() {
+auto t = D();
+t.foo(0);
+  }
+};
+
+namespace call_pure_virtual_function_from_virtual {
+  template  class B {
+  public:
+const void foo(const T &) { B::bar(1); } // expected-warning 
{{instantiation of function 
'call_pure_virtual_function_from_virtual::B::bar' required here, but no 
definition is available}}
+// expected-note@-1 {{add an explicit instantiation declaration to 
suppress this warning if 'call_pure_virtual_function_from_virtual::B::bar' 
is explicitly instantiated in another translation unit}}
+virtual const void bar(unsigned int) = 0; // expected-note {{forward 
declaration of template entity is here}}
+  };
+
+  template  class D : public B {
+  public:
+const void bar(unsigned int) override {}
+  };
+
+  void test() {
+auto t = D();
+t.foo(0); // expected-note {{in instantiation of member function 
'call_pure_virtual_function_from_virtual::B::foo' requested here}}
+  }
+};
+
+namespace non_pure_virtual_function {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+
+virtual constexpr void bar(unsigned int); // expected-warning {{inline 
function 'non_pure_virtual_function::B::bar' is not defined}}
+// expected-note@-1 {{forward declaration of template entity is here}}
+// expected-note@-2 {{forward declaration of template entity is here}}
+// expected-note@-3 {{forward declaration of template entity is here}}
+  };
+
+  template  class D : public B { // expected-warning 
{{instantiation of function 'non_pure_virtual_function::B::bar' required 
here, but no definition is available}}
+// expected-warning@-1 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-warning@-2 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-note@-3 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-4 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another 

[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2024-03-23 Thread Charalampos Mitrodimas via cfe-commits

https://github.com/charmitro updated 
https://github.com/llvm/llvm-project/pull/74510

>From 7961a90a020f6fde5c6cd892024ff0fe329450ee Mon Sep 17 00:00:00 2001
From: Charalampos Mitrodimas 
Date: Tue, 5 Dec 2023 11:46:56 +0200
Subject: [PATCH] [clang] Disable missing definition warning on pure virtual
 functions

Warning '-Wundefined-func-template' incorrectly indicates that no
definition is available for a pure virtual function. However, a
definition is not needed for a pure virtual function.

Fixes #74016

Signed-off-by: Charalampos Mitrodimas 
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 clang/lib/Sema/SemaExpr.cpp   |  2 +-
 .../instantiate-pure-virtual-function.cpp | 67 +++
 3 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8054d90fc70f93..643eb6cc157732 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -294,6 +294,10 @@ Improvements to Clang's time-trace
 
 Bug Fixes in This Version
 -
+- Clang's ``-Wundefined-func-template`` no longer warns on pure virtual
+  functions.
+  (`#74016 `_)
+
 - Fixed missing warnings when comparing mismatched enumeration constants
   in C (`#29217 `).
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5f03b981428251..7eb252f663d43e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18952,7 +18952,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, 
FunctionDecl *Func,
   //   constant evaluated
   bool NeededForConstantEvaluation =
   isPotentiallyConstantEvaluatedContext(*this) &&
-  isImplicitlyDefinableConstexprFunction(Func);
+  isImplicitlyDefinableConstexprFunction(Func) && !Func->isPure();
 
   // Determine whether we require a function definition to exist, per
   // C++11 [temp.inst]p3:
diff --git a/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp 
b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
new file mode 100644
index 00..caec42b6b77f95
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wundefined-func-template %s
+
+namespace GH74016 {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+virtual constexpr void bar(unsigned int) = 0;
+  };
+
+  template  class D : public B {
+  public:
+constexpr void bar(unsigned int) override {}
+  };
+
+  void test() {
+auto t = D();
+t.foo(0);
+  }
+};
+
+namespace call_pure_virtual_function_from_virtual {
+  template  class B {
+  public:
+const void foo(const T &) { B::bar(1); } // expected-warning 
{{instantiation of function 
'call_pure_virtual_function_from_virtual::B::bar' required here, but no 
definition is available}}
+// expected-note@-1 {{add an explicit instantiation declaration to 
suppress this warning if 'call_pure_virtual_function_from_virtual::B::bar' 
is explicitly instantiated in another translation unit}}
+virtual const void bar(unsigned int) = 0; // expected-note {{forward 
declaration of template entity is here}}
+  };
+
+  template  class D : public B {
+  public:
+const void bar(unsigned int) override {}
+  };
+
+  void test() {
+auto t = D();
+t.foo(0); // expected-note {{in instantiation of member function 
'call_pure_virtual_function_from_virtual::B::foo' requested here}}
+  }
+};
+
+namespace non_pure_virtual_function {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+
+virtual constexpr void bar(unsigned int); // expected-warning {{inline 
function 'non_pure_virtual_function::B::bar' is not defined}}
+// expected-note@-1 {{forward declaration of template entity is here}}
+// expected-note@-2 {{forward declaration of template entity is here}}
+// expected-note@-3 {{forward declaration of template entity is here}}
+  };
+
+  template  class D : public B { // expected-warning 
{{instantiation of function 'non_pure_virtual_function::B::bar' required 
here, but no definition is available}}
+// expected-warning@-1 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-warning@-2 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-note@-3 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-4 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another 

[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

2024-03-23 Thread Younan Zhang via cfe-commits

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

>From 6e7b38b3e3f781e11db2fa5d552fdfb6123609df Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 22 Mar 2024 17:34:08 +0800
Subject: [PATCH 1/2] [Sema] Preserve ContainsUnexpandedParameterPack in
 TransformLambdaExpr

---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Sema/Sema.h   |  8 +++
 clang/lib/Sema/SemaTemplateVariadic.cpp   | 16 +-
 clang/lib/Sema/TreeTransform.h| 18 ++
 .../test/SemaTemplate/lambda-capture-pack.cpp | 57 +++
 5 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 690fc7ed271a3d..2d11a4b8c092a2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -344,6 +344,8 @@ Bug Fixes to C++ Support
   when one of the function had more specialized templates.
   Fixes (`#82509 `_)
   and (`#74494 `_)
+- Fixed a crash where template parameter packs were not expanded correctly in 
a lambda being
+  used as a pattern of a folded expression. (#GH56852), (#GH85667)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index cfc1c3b3494788..0d1a2e54840e52 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11201,6 +11201,14 @@ class Sema final {
   void collectUnexpandedParameterPacks(
   QualType T, SmallVectorImpl );
 
+  /// Collect the set of unexpanded parameter packs from a lambda call 
operator.
+  ///
+  /// \param LambdaCall The lambda call operator that will be traversed to find
+  /// unexpanded parameter packs.
+  void collectUnexpandedParameterPacksFromLambda(
+  CXXMethodDecl *LambdaCall,
+  SmallVectorImpl );
+
   /// Collect the set of unexpanded parameter packs within the given
   /// type.
   ///
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 903fbfd18e779c..638ceac4148aec 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -8,14 +8,15 @@
 //  This file implements semantic analysis for C++0x variadic templates.
 //===--===/
 
-#include "clang/Sema/Sema.h"
 #include "TypeLocBuilder.h"
+#include "clang/AST/ASTLambda.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/ScopeInfo.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
 #include 
@@ -61,8 +62,9 @@ namespace {
 
   public:
 explicit CollectUnexpandedParameterPacksVisitor(
-SmallVectorImpl )
-: Unexpanded(Unexpanded) {}
+SmallVectorImpl ,
+bool InLambda = false)
+: Unexpanded(Unexpanded), InLambda(InLambda) {}
 
 bool shouldWalkTypesOfTypeLocs() const { return false; }
 
@@ -544,6 +546,14 @@ void Sema::collectUnexpandedParameterPacks(QualType T,
   CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
 }
 
+void Sema::collectUnexpandedParameterPacksFromLambda(
+CXXMethodDecl *LambdaCall,
+SmallVectorImpl ) {
+  assert(isLambdaCallOperator(LambdaCall) && "Expected a lambda call 
operator");
+  CollectUnexpandedParameterPacksVisitor(Unexpanded, /*InLambda=*/true)
+  .TraverseDecl(LambdaCall);
+}
+
 void Sema::collectUnexpandedParameterPacks(TypeLoc TL,
SmallVectorImpl ) {
   CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2d22692f3ab750..f5a859c57034a5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13748,6 +13748,8 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 }
 NewVDs.push_back(NewVD);
 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
+LSI->ContainsUnexpandedParameterPack |=
+Init.get()->containsUnexpandedParameterPack();
   }
 
   if (Invalid)
@@ -13936,6 +13938,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 /*IsInstantiation*/ true);
   SavedContext.pop();
 
+  // The lambda may contain a pack that would be expanded by a fold expression
+  // outside. We should preserve the ContainsUnexpandedParameterPack flag here
+  // because CXXFoldExprs use it for the pattern.
+  // For example,
+  //
+  // []() { ([I = Is()]() {}, ...); }
+  //
+  // forgetting the flag will result in getPattern() of CXXFoldExpr returning
+  // null in terms of the inner lambda.
+  if 

[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)

2024-03-23 Thread Younan Zhang via cfe-commits

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

>From 6e7b38b3e3f781e11db2fa5d552fdfb6123609df Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 22 Mar 2024 17:34:08 +0800
Subject: [PATCH 1/2] [Sema] Preserve ContainsUnexpandedParameterPack in
 TransformLambdaExpr

---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Sema/Sema.h   |  8 +++
 clang/lib/Sema/SemaTemplateVariadic.cpp   | 16 +-
 clang/lib/Sema/TreeTransform.h| 18 ++
 .../test/SemaTemplate/lambda-capture-pack.cpp | 57 +++
 5 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 690fc7ed271a3d..2d11a4b8c092a2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -344,6 +344,8 @@ Bug Fixes to C++ Support
   when one of the function had more specialized templates.
   Fixes (`#82509 `_)
   and (`#74494 `_)
+- Fixed a crash where template parameter packs were not expanded correctly in 
a lambda being
+  used as a pattern of a folded expression. (#GH56852), (#GH85667)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index cfc1c3b3494788..0d1a2e54840e52 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11201,6 +11201,14 @@ class Sema final {
   void collectUnexpandedParameterPacks(
   QualType T, SmallVectorImpl );
 
+  /// Collect the set of unexpanded parameter packs from a lambda call 
operator.
+  ///
+  /// \param LambdaCall The lambda call operator that will be traversed to find
+  /// unexpanded parameter packs.
+  void collectUnexpandedParameterPacksFromLambda(
+  CXXMethodDecl *LambdaCall,
+  SmallVectorImpl );
+
   /// Collect the set of unexpanded parameter packs within the given
   /// type.
   ///
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 903fbfd18e779c..638ceac4148aec 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -8,14 +8,15 @@
 //  This file implements semantic analysis for C++0x variadic templates.
 //===--===/
 
-#include "clang/Sema/Sema.h"
 #include "TypeLocBuilder.h"
+#include "clang/AST/ASTLambda.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/ScopeInfo.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
 #include 
@@ -61,8 +62,9 @@ namespace {
 
   public:
 explicit CollectUnexpandedParameterPacksVisitor(
-SmallVectorImpl )
-: Unexpanded(Unexpanded) {}
+SmallVectorImpl ,
+bool InLambda = false)
+: Unexpanded(Unexpanded), InLambda(InLambda) {}
 
 bool shouldWalkTypesOfTypeLocs() const { return false; }
 
@@ -544,6 +546,14 @@ void Sema::collectUnexpandedParameterPacks(QualType T,
   CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
 }
 
+void Sema::collectUnexpandedParameterPacksFromLambda(
+CXXMethodDecl *LambdaCall,
+SmallVectorImpl ) {
+  assert(isLambdaCallOperator(LambdaCall) && "Expected a lambda call 
operator");
+  CollectUnexpandedParameterPacksVisitor(Unexpanded, /*InLambda=*/true)
+  .TraverseDecl(LambdaCall);
+}
+
 void Sema::collectUnexpandedParameterPacks(TypeLoc TL,
SmallVectorImpl ) {
   CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(TL);
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2d22692f3ab750..f5a859c57034a5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13748,6 +13748,8 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 }
 NewVDs.push_back(NewVD);
 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
+LSI->ContainsUnexpandedParameterPack |=
+Init.get()->containsUnexpandedParameterPack();
   }
 
   if (Invalid)
@@ -13936,6 +13938,22 @@ TreeTransform::TransformLambdaExpr(LambdaExpr 
*E) {
 /*IsInstantiation*/ true);
   SavedContext.pop();
 
+  // The lambda may contain a pack that would be expanded by a fold expression
+  // outside. We should preserve the ContainsUnexpandedParameterPack flag here
+  // because CXXFoldExprs use it for the pattern.
+  // For example,
+  //
+  // []() { ([I = Is()]() {}, ...); }
+  //
+  // forgetting the flag will result in getPattern() of CXXFoldExpr returning
+  // null in terms of the inner lambda.
+  if 

[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-03-23 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= ,
Pol Marcet =?utf-8?q?Sardà?= ,Pol M
 
Message-ID:
In-Reply-To: 



@@ -10895,6 +10899,132 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue , EvalInfo ,
+   const Expr *E, const QualType ) {
+  if (!Evaluate(Result, Info, E))
+return false;
+
+  if (Result.isLValue()) {
+// Source of the data is an lvalue; Manually handle the lvalue as if
+// it was an rvalue to get the current APValue.
+LValue LValueFound;
+LValueFound.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result))
+  return false;
+  }
+
+  return Result.isVector();
+}
+
+static bool handleVectorConversion(EvalInfo , const FPOptions FPO,
+   const Expr *E, QualType SourceTy,
+   QualType DestTy, APValue const ,
+   APValue ) {
+  if (SourceTy->isIntegerType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = APValue(APFloat(0.0));
+  return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(),
+  DestTy, Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(
+  HandleIntToIntCast(Info, E, DestTy, SourceTy, Original.getInt()));
+  return true;
+}
+  } else if (SourceTy->isRealFloatingType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = Original;
+  return HandleFloatToFloatCast(Info, E, SourceTy, DestTy,
+Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(APSInt());
+  return HandleFloatToIntCast(Info, E, SourceTy, Original.getFloat(),
+  DestTy, Result.getInt());
+}
+  }
+  return false;

Destroyerrrocket wrote:

I certainly don't know about any such case...

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


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-03-23 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= ,
Pol Marcet =?utf-8?q?Sardà?= ,Pol M
 
Message-ID:
In-Reply-To: 



@@ -10895,6 +10899,132 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue , EvalInfo ,
+   const Expr *E, const QualType ) {
+  if (!Evaluate(Result, Info, E))
+return false;
+
+  if (Result.isLValue()) {
+// Source of the data is an lvalue; Manually handle the lvalue as if
+// it was an rvalue to get the current APValue.
+LValue LValueFound;
+LValueFound.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result))
+  return false;
+  }
+
+  return Result.isVector();
+}
+
+static bool handleVectorConversion(EvalInfo , const FPOptions FPO,
+   const Expr *E, QualType SourceTy,
+   QualType DestTy, APValue const ,
+   APValue ) {
+  if (SourceTy->isIntegerType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = APValue(APFloat(0.0));
+  return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(),
+  DestTy, Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(
+  HandleIntToIntCast(Info, E, DestTy, SourceTy, Original.getInt()));
+  return true;
+}
+  } else if (SourceTy->isRealFloatingType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = Original;
+  return HandleFloatToFloatCast(Info, E, SourceTy, DestTy,
+Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(APSInt());
+  return HandleFloatToIntCast(Info, E, SourceTy, Original.getFloat(),
+  DestTy, Result.getInt());
+}
+  }
+  return false;
+}
+
+bool VectorExprEvaluator::VisitConvertVectorExpr(const ConvertVectorExpr *E) {
+  APValue Source;
+  QualType SourceVecType = E->getSrcExpr()->getType();
+  if (!EvaluateVectorOrLValue(Source, Info, E->getSrcExpr(), SourceVecType))
+return false;
+
+  QualType DestTy = E->getType()->castAs()->getElementType();
+  QualType SourceTy = SourceVecType->castAs()->getElementType();
+
+  const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+
+  auto SourceLen = Source.getVectorLength();
+  SmallVector ResultElements;

Destroyerrrocket wrote:

I chose 4 as plenty of times I've had to deal with SIMD code it has been either 
SSE code dealing with floats and doubles and AVX code mainly dealing with 
doubles, but this certainly is a biased worldview; not all applications deal 
with doubles and certainly from time to time I've had to code for avx512.

In any case, I think that doubling the smallvector would not be ideal 
stacksize-wise, and a normal vector with a reserve call would be more than 
enough to cover all cases. We always know the size and a normal allocation 
should be fine.

APValue is indeed expensive, but it is also convenient; I think I'm going to 
stick with it for this PR, and if very long vectors ever get supported this 
might need to be improved upon. Should I leave a comment explaining that to the 
reader?

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


[clang] [X86_32] fix 0 sized struct case in vaarg. (PR #86388)

2024-03-23 Thread Longsheng Mou via cfe-commits

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


[clang] [X86_32] fix 0 sized struct case in vaarg. (PR #86388)

2024-03-23 Thread Longsheng Mou via cfe-commits

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


[clang] [X86_32] fix weird edge case in vaarg. (PR #86388)

2024-03-23 Thread Longsheng Mou via cfe-commits

https://github.com/CoTinker updated 
https://github.com/llvm/llvm-project/pull/86388

>From 8752d9019851bd231f1777d20391af60f0b4365c Mon Sep 17 00:00:00 2001
From: Longsheng Mou 
Date: Sat, 23 Mar 2024 17:53:58 +0800
Subject: [PATCH] [X86_32] fix 0 sized struct case in vaarg.

struct SuperEmpty { struct{ int a[0];} b;};
Such 0 sized structs in c++ mode can not be ignored in i386 for
that c++ fields are never empty.But when EmitVAArg, its size is
0, so that va_list not increase.Maybe we can use direct in this
case.
---
 clang/lib/CodeGen/Targets/X86.cpp | 3 +++
 clang/test/CodeGenCXX/regparm.cpp | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 1ec0f159ebcb8a..8e6e7c17452048 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -805,6 +805,9 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 if (!IsWin32StructABI && isEmptyRecord(getContext(), Ty, true))
   return ABIArgInfo::getIgnore();
 
+if (TI.Width == 0 && getContext().getLangOpts().CPlusPlus)
+  return ABIArgInfo::getDirect();
+
 llvm::LLVMContext  = getVMContext();
 llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
 bool NeedsPadding = false;
diff --git a/clang/test/CodeGenCXX/regparm.cpp 
b/clang/test/CodeGenCXX/regparm.cpp
index 1fd471c2d0727b..559702a84c99e1 100644
--- a/clang/test/CodeGenCXX/regparm.cpp
+++ b/clang/test/CodeGenCXX/regparm.cpp
@@ -32,7 +32,7 @@ struct S3 {
   } a;
 };
 __attribute((regparm(2))) void foo4(S3 a, int b);
-// CHECK: declare void @_Z4foo42S3i(ptr noundef byval(%struct.S3) align 4, i32 
inreg noundef)
+// CHECK: declare void @_Z4foo42S3i(%struct.anon, i32 inreg noundef)
 void bar3(S3 a, int b) {
   foo4(a, b);
 }

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


[clang] [X86_32] fix weird edge case in vaarg. (PR #86388)

2024-03-23 Thread Longsheng Mou via cfe-commits

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


[clang] [X86_32] fix weird edge case in vaarg. (PR #86388)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [X86_32] fix weird edge case in vaarg. (PR #86388)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [X86_32] fix weird edge case in vaarg. (PR #86388)

2024-03-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Longsheng Mou (CoTinker)


Changes

struct SuperEmpty { struct{ int a[0];} b;};
Such 0 sized structs in c++ mode can not be ignored in i386 for that c++ fields 
are never empty.But when EmitVAArg, its size is 0, so that va_list not 
increase.Maybe we can use direct in this case.

https://github.com/llvm/llvm-project/blob/691b97c884a15a7eac641ddf67c9f2f30fb4e747/clang/lib/CodeGen/ABIInfoImpl.cpp#L202-L216

This case use indirect before and `DirectSize == 0`, now we use direct and 
`DirectSize == 4`.
Or we can just Ignore this kind of arguments, like X86_64 did. 

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


2 Files Affected:

- (modified) clang/lib/CodeGen/Targets/X86.cpp (+3) 
- (modified) clang/test/CodeGenCXX/regparm.cpp (+1-1) 


``diff
diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 1ec0f159ebcb8a..8e6e7c17452048 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -805,6 +805,9 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 if (!IsWin32StructABI && isEmptyRecord(getContext(), Ty, true))
   return ABIArgInfo::getIgnore();
 
+if (TI.Width == 0 && getContext().getLangOpts().CPlusPlus)
+  return ABIArgInfo::getDirect();
+
 llvm::LLVMContext  = getVMContext();
 llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
 bool NeedsPadding = false;
diff --git a/clang/test/CodeGenCXX/regparm.cpp 
b/clang/test/CodeGenCXX/regparm.cpp
index 1fd471c2d0727b..559702a84c99e1 100644
--- a/clang/test/CodeGenCXX/regparm.cpp
+++ b/clang/test/CodeGenCXX/regparm.cpp
@@ -32,7 +32,7 @@ struct S3 {
   } a;
 };
 __attribute((regparm(2))) void foo4(S3 a, int b);
-// CHECK: declare void @_Z4foo42S3i(ptr noundef byval(%struct.S3) align 4, i32 
inreg noundef)
+// CHECK: declare void @_Z4foo42S3i(%struct.anon, i32 inreg noundef)
 void bar3(S3 a, int b) {
   foo4(a, b);
 }

``




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


[clang] [X86_32] fix weird edge case in vaarg. (PR #86388)

2024-03-23 Thread Longsheng Mou via cfe-commits

https://github.com/CoTinker created 
https://github.com/llvm/llvm-project/pull/86388

struct SuperEmpty { struct{ int a[0];} b;};
Such 0 sized structs in c++ mode can not be ignored in i386 for that c++ fields 
are never empty.But when EmitVAArg, its size is 0, so that va_list not 
increase.Maybe we can use direct in this case.

https://github.com/llvm/llvm-project/blob/691b97c884a15a7eac641ddf67c9f2f30fb4e747/clang/lib/CodeGen/ABIInfoImpl.cpp#L202-L216

This case use indirect before and `DirectSize == 0`, now we use direct and 
`DirectSize == 4`.
Or we can just Ignore this kind of arguments, like X86_64 did. 

>From dda9d5ac87b05c71079b6ed3b5d4188ff22ce356 Mon Sep 17 00:00:00 2001
From: Longsheng Mou 
Date: Sat, 23 Mar 2024 17:53:58 +0800
Subject: [PATCH] [X86_32] fix weird edge case in vaarg.

struct SuperEmpty { struct{ int a[0];} b;};
Such 0 sized structs in c++ mode can not be ignored in i386 for
that c++ fields are never empty.But when EmitVAArg, its size is
0, so that va_list not increase.Maybe we can use direct in this
case.
---
 clang/lib/CodeGen/Targets/X86.cpp | 3 +++
 clang/test/CodeGenCXX/regparm.cpp | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/Targets/X86.cpp 
b/clang/lib/CodeGen/Targets/X86.cpp
index 1ec0f159ebcb8a..8e6e7c17452048 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -805,6 +805,9 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, 
CCState ,
 if (!IsWin32StructABI && isEmptyRecord(getContext(), Ty, true))
   return ABIArgInfo::getIgnore();
 
+if (TI.Width == 0 && getContext().getLangOpts().CPlusPlus)
+  return ABIArgInfo::getDirect();
+
 llvm::LLVMContext  = getVMContext();
 llvm::IntegerType *Int32 = llvm::Type::getInt32Ty(LLVMContext);
 bool NeedsPadding = false;
diff --git a/clang/test/CodeGenCXX/regparm.cpp 
b/clang/test/CodeGenCXX/regparm.cpp
index 1fd471c2d0727b..559702a84c99e1 100644
--- a/clang/test/CodeGenCXX/regparm.cpp
+++ b/clang/test/CodeGenCXX/regparm.cpp
@@ -32,7 +32,7 @@ struct S3 {
   } a;
 };
 __attribute((regparm(2))) void foo4(S3 a, int b);
-// CHECK: declare void @_Z4foo42S3i(ptr noundef byval(%struct.S3) align 4, i32 
inreg noundef)
+// CHECK: declare void @_Z4foo42S3i(%struct.anon, i32 inreg noundef)
 void bar3(S3 a, int b) {
   foo4(a, b);
 }

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Michał Górny (mgorny)


Changes

Move the code adding top-level cmake/Modules directory to CMAKE_MODULE_PATH 
prior to including `GetDarwinLinkerVersion`, in order to fix standalone builds.

Fixes a regression introduced by 3bc71c2abfa00413fd15cf0e5c08af6ec0d4768b.

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


1 Files Affected:

- (modified) clang/CMakeLists.txt (+7-7) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index ee783d52e4a4e2..284b2af24ddaa0 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -13,6 +13,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   set(CLANG_BUILT_STANDALONE TRUE)
 endif()
 
+# Make sure that our source directory is on the current cmake module path so 
that
+# we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
 # Must go below project(..)
 include(GNUInstallDirs)
 include(GetDarwinLinkerVersion)
@@ -141,13 +148,6 @@ if(CLANG_BUILT_STANDALONE)
   endif() # LLVM_INCLUDE_TESTS
 endif() # standalone
 
-# Make sure that our source directory is on the current cmake module path so 
that
-# we can include cmake files from this directory.
-list(INSERT CMAKE_MODULE_PATH 0
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
-
 # This allows disabling clang's XML dependency even if LLVM finds libxml2.
 # By default, clang depends on libxml2 if LLVM does.
 option(CLANG_ENABLE_LIBXML2 "Whether libclang may depend on libxml2"

``




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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Michał Górny via cfe-commits

https://github.com/mgorny created 
https://github.com/llvm/llvm-project/pull/86386

Move the code adding top-level cmake/Modules directory to CMAKE_MODULE_PATH 
prior to including `GetDarwinLinkerVersion`, in order to fix standalone builds.

Fixes a regression introduced by 3bc71c2abfa00413fd15cf0e5c08af6ec0d4768b.

From 1639e99721c2aeee584437d8987f0633010c401f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= 
Date: Sat, 23 Mar 2024 10:33:38 +0100
Subject: [PATCH] [clang] [cmake] Add cmake module dir before using
 GetDarwinLinkerVersion

Move the code adding top-level cmake/Modules directory
to CMAKE_MODULE_PATH prior to including `GetDarwinLinkerVersion`,
in order to fix standalone builds.

Fixes a regression introduced by 3bc71c2abfa00413fd15cf0e5c08af6ec0d4768b.
---
 clang/CMakeLists.txt | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index ee783d52e4a4e2..284b2af24ddaa0 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -13,6 +13,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   set(CLANG_BUILT_STANDALONE TRUE)
 endif()
 
+# Make sure that our source directory is on the current cmake module path so 
that
+# we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
 # Must go below project(..)
 include(GNUInstallDirs)
 include(GetDarwinLinkerVersion)
@@ -141,13 +148,6 @@ if(CLANG_BUILT_STANDALONE)
   endif() # LLVM_INCLUDE_TESTS
 endif() # standalone
 
-# Make sure that our source directory is on the current cmake module path so 
that
-# we can include cmake files from this directory.
-list(INSERT CMAKE_MODULE_PATH 0
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
-
 # This allows disabling clang's XML dependency even if LLVM finds libxml2.
 # By default, clang depends on libxml2 if LLVM does.
 option(CLANG_ENABLE_LIBXML2 "Whether libclang may depend on libxml2"

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


[clang] 47423e9 - [clang-format][NFC] Clean up IsQualifiedPointerOrReference in TokenAnnotator

2024-03-23 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2024-03-23T02:24:56-07:00
New Revision: 47423e9827abfdcc6b10ce41618965861b0e69a4

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

LOG: [clang-format][NFC] Clean up IsQualifiedPointerOrReference in 
TokenAnnotator

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 7757c8ff76398f..4c83a7a3a323be 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2753,10 +2753,9 @@ class AnnotatingParser {
 }
 
 // Heuristically try to determine whether the parentheses contain a type.
-auto IsQualifiedPointerOrReference = [this](FormatToken *T) {
+auto IsQualifiedPointerOrReference = [](FormatToken *T, bool IsCpp) {
   // This is used to handle cases such as x = (foo *const)
   assert(!T->isTypeName(IsCpp) && "Should have already been checked");
-  (void)IsCpp; // Avoid -Wunused-lambda-capture when assertion is disabled.
   // Strip trailing qualifiers such as const or volatile when checking
   // whether the parens could be a cast to a pointer/reference type.
   while (T) {
@@ -2789,7 +2788,7 @@ class AnnotatingParser {
 !Tok.Previous ||
 Tok.Previous->isOneOf(TT_TemplateCloser, TT_TypeDeclarationParen) ||
 Tok.Previous->isTypeName(IsCpp) ||
-IsQualifiedPointerOrReference(Tok.Previous);
+IsQualifiedPointerOrReference(Tok.Previous, IsCpp);
 bool ParensCouldEndDecl =
 Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
 if (ParensAreType && !ParensCouldEndDecl)



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


[clang] [clang-forma] Support `PointerAlignment` for pointers to members (PR #86253)

2024-03-23 Thread Owen Pan via cfe-commits

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


[clang] 579dc7f - [clang-forma] Support `PointerAlignment` for pointers to members (#86253)

2024-03-23 Thread via cfe-commits

Author: Owen Pan
Date: 2024-03-23T02:03:45-07:00
New Revision: 579dc7f8441a8044b92bdfa6f0db2f91301c0eed

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

LOG: [clang-forma] Support `PointerAlignment` for pointers to members (#86253)

Fixes #85761.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index a5cafcbacaa591..7757c8ff76398f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4357,9 +4357,11 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
   if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
 return false;
 
+  const auto *BeforeLeft = Left.Previous;
+
   // operator co_await(x)
-  if (Right.is(tok::l_paren) && Left.is(tok::kw_co_await) && Left.Previous &&
-  Left.Previous->is(tok::kw_operator)) {
+  if (Right.is(tok::l_paren) && Left.is(tok::kw_co_await) && BeforeLeft &&
+  BeforeLeft->is(tok::kw_operator)) {
 return false;
   }
   // co_await (x), co_yield (x), co_return (x)
@@ -4394,8 +4396,10 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
   }
   if (Left.is(tok::colon))
 return Left.isNot(TT_ObjCMethodExpr);
-  if (Left.is(tok::coloncolon))
-return false;
+  if (Left.is(tok::coloncolon)) {
+return Right.is(tok::star) && Right.is(TT_PointerOrReference) &&
+   Style.PointerAlignment != FormatStyle::PAS_Left;
+  }
   if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
 if (Style.Language == FormatStyle::LK_TextProto ||
 (Style.Language == FormatStyle::LK_Proto &&
@@ -4410,8 +4414,8 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
   return false;
   }
   if (Right.is(tok::ellipsis)) {
-return Left.Tok.isLiteral() || (Left.is(tok::identifier) && Left.Previous 
&&
-Left.Previous->is(tok::kw_case));
+return Left.Tok.isLiteral() || (Left.is(tok::identifier) && BeforeLeft &&
+BeforeLeft->is(tok::kw_case));
   }
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return Style.SpacesInSquareBrackets;
@@ -4479,8 +4483,8 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
 if (Right.is(tok::l_brace) && Right.is(BK_Block))
   return true;
 // for (auto a = 0, b = 0; const auto& c : {1, 2, 3})
-if (Left.Previous && Left.Previous->isTypeOrIdentifier(IsCpp) &&
-Right.Next && Right.Next->is(TT_RangeBasedForLoopColon)) {
+if (BeforeLeft && BeforeLeft->isTypeOrIdentifier(IsCpp) && Right.Next &&
+Right.Next->is(TT_RangeBasedForLoopColon)) {
   return getTokenPointerOrReferenceAlignment(Left) !=
  FormatStyle::PAS_Right;
 }
@@ -4502,12 +4506,17 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
   startsWithInitStatement(Line {
   return false;
 }
-return Left.Previous && !Left.Previous->isOneOf(
-tok::l_paren, tok::coloncolon, tok::l_square);
+if (!BeforeLeft)
+  return false;
+if (BeforeLeft->is(tok::coloncolon)) {
+  return Left.is(tok::star) &&
+ Style.PointerAlignment != FormatStyle::PAS_Right;
+}
+return !BeforeLeft->isOneOf(tok::l_paren, tok::l_square);
   }
   // Ensure right pointer alignment with ellipsis e.g. int *...P
-  if (Left.is(tok::ellipsis) && Left.Previous &&
-  Left.Previous->isPointerOrReference()) {
+  if (Left.is(tok::ellipsis) && BeforeLeft &&
+  BeforeLeft->isPointerOrReference()) {
 return Style.PointerAlignment != FormatStyle::PAS_Right;
   }
 
@@ -4669,13 +4678,13 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
   return Style.SpaceBeforeParensOptions.AfterFunctionDefinitionName ||
  spaceRequiredBeforeParens(Right);
 }
-if (!Left.Previous || !Left.Previous->isOneOf(tok::period, tok::arrow)) {
+if (!BeforeLeft || !BeforeLeft->isOneOf(tok::period, tok::arrow)) {
   if (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch)) {
 return Style.SpaceBeforeParensOptions.AfterControlStatements ||
spaceRequiredBeforeParens(Right);
   }
   if (Left.isOneOf(tok::kw_new, tok::kw_delete)) {
-return ((!Line.MightBeFunctionDecl || !Left.Previous) &&
+return ((!Line.MightBeFunctionDecl || !BeforeLeft) &&
 Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
spaceRequiredBeforeParens(Right);
   }

diff  --git a/clang/unittests/Format/FormatTest.cpp 

[clang] [clang-forma] Support `PointerAlignment` for pointers to members (PR #86253)

2024-03-23 Thread Owen Pan via cfe-commits

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


[libunwind] [libunwind] Compile the asm as well as the C++ source (PR #86351)

2024-03-23 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> I'm sorry to hear that. Reading through 
> https://libcxx.llvm.org/BuildingLibcxx.html now to see if I can make 
> ENABLE_RUNTIMES behave itself under cross compilation. I'm familiar with this 
> in the context of the "bootstrapping" build from the docs, the build clang 
> first one, which drops (most) arguments passed to cmake. Hopefully building 
> runtimes directly doesn't involve that quirk.

Indeed, pointing cmake at `llvm-project/runtimes` and specifying libunwind in 
ENABLE_RUNTIMES should work pretty much the same as pointing cmake at libunwind 
directly, just with a bunch of boilerplate centralized.

I agree that it probably would be good to keep the error message explaining 
this, especially if it otherwise seems to almost work.

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


[clang] [clang-forma] Support `PointerAlignment: Left` for pointer to member (PR #86253)

2024-03-23 Thread Björn Schäpers via cfe-commits

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


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


[clang] [clang-format] Fix anonymous reference parameter with default value (PR #86254)

2024-03-23 Thread Björn Schäpers via cfe-commits


@@ -471,6 +471,9 @@ AlignTokenSequence(const FormatStyle , unsigned 
Start, unsigned End,
Previous >= 0 &&
Changes[Previous].Tok->getType() == TT_PointerOrReference;
--Previous) {
+// Don't align function default argument using return type maximum size
+if (Changes[Previous + 1].Tok->is(tok::equal))
+  continue;

HazardyKnusperkeks wrote:

I have multiple issues with this snippet:
* I don't understand the comment.
* Comments end in full stop.
* You execute this in a loop, but it is either true on the first run or never.


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


[clang] [clang-format] Fix anonymous reference parameter with default value (PR #86254)

2024-03-23 Thread Björn Schäpers via cfe-commits


@@ -19056,6 +19056,9 @@ TEST_F(FormatTest, AlignConsecutiveDeclarations) {
   verifyFormat("inta(int x);\n"
"double b();",
Alignment);
+  verifyFormat("inta(const Test & = Test());\n"

HazardyKnusperkeks wrote:

I'd like to see something like
``` c++
int foo(someType & whatever, differentType & foo,
Test & = Test());
```
Maybe in some other variants, I want to see the alignment of the arguments.


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


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-03-23 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/83774

>From f1653805def59bc6eb23052b3ade80c900b4daaa Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Fri, 14 Jul 2023 10:38:14 +0800
Subject: [PATCH 1/3] [clang] Enable sized deallocation by default in C++14
 onwards

Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

Differential Revision: https://reviews.llvm.org/D112921
---
 .../clangd/unittests/FindTargetTests.cpp  |   4 +-
 .../checkers/misc/new-delete-overloads.cpp|  10 -
 clang/docs/ReleaseNotes.rst   |   5 +
 clang/include/clang/Driver/Options.td |   5 +-
 clang/lib/Driver/ToolChains/Clang.cpp |  13 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  58 -
 clang/lib/Driver/ToolChains/Darwin.h  |   4 +
 clang/lib/Driver/ToolChains/ZOS.cpp   |   6 +
 clang/test/AST/ast-dump-expr-json.cpp |   2 +-
 clang/test/AST/ast-dump-expr.cpp  |   2 +-
 clang/test/AST/ast-dump-stmt-json.cpp | 244 +-
 clang/test/Analysis/cxxnewexpr-callback.cpp   |   4 +-
 .../basic.stc.dynamic.deallocation/p2.cpp |   2 +-
 clang/test/CXX/drs/dr292.cpp  |  17 +-
 .../test/CXX/expr/expr.unary/expr.new/p14.cpp |   2 +-
 .../CodeGenCXX/cxx1y-sized-deallocation.cpp   |  10 +-
 .../CodeGenCXX/cxx1z-aligned-allocation.cpp   |   6 +-
 .../CodeGenCXX/cxx2a-destroying-delete.cpp|   4 +-
 clang/test/CodeGenCXX/delete-two-arg.cpp  |   4 +-
 clang/test/CodeGenCXX/delete.cpp  |  12 +-
 clang/test/CodeGenCXX/dllimport.cpp   |   4 +-
 clang/test/CodeGenCXX/new.cpp |   6 +-
 .../coro-aligned-alloc-2.cpp  |   2 -
 .../CodeGenCoroutines/coro-aligned-alloc.cpp  |   6 +-
 clang/test/CodeGenCoroutines/coro-alloc.cpp   |   6 +-
 clang/test/CodeGenCoroutines/coro-cleanup.cpp |   6 +-
 clang/test/CodeGenCoroutines/coro-dealloc.cpp |   2 -
 clang/test/CodeGenCoroutines/coro-gro.cpp |   3 +-
 clang/test/CodeGenCoroutines/pr56919.cpp  |   9 +-
 clang/test/Lexer/cxx-features.cpp |  20 +-
 clang/test/PCH/cxx1z-aligned-alloc.cpp|  10 +-
 clang/test/SemaCXX/MicrosoftExtensions.cpp|   8 +-
 .../SemaCXX/builtin-operator-new-delete.cpp   |   2 +-
 .../test/SemaCXX/cxx1y-sized-deallocation.cpp |   2 +-
 .../unavailable_aligned_allocation.cpp|  15 +-
 .../StaticAnalyzer/CallEventTest.cpp  |   2 +-
 clang/www/cxx_status.html |  11 +-
 .../support.dynamic/libcpp_deallocate.sh.cpp  |   3 +
 .../sized_delete_array14.pass.cpp |   8 +-
 .../new.delete.single/sized_delete14.pass.cpp |   8 +-
 40 files changed, 436 insertions(+), 111 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 0af6036734ba53..1b7b96281dfaa5 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -839,7 +839,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e19..f86fe8a4c5b14f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do not warn on 
mismatching
-  // placement operations.
-  // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope
-  void *operator new(size_t size) noexcept;
-  void operator delete(void *ptr, size_t) noexcept; // ok only if sized 
deallocation is enabled
-};
-
 struct U {
   void *operator new(size_t size) noexcept;
   void operator delete(void *ptr) noexcept;
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d6e179ca9d6904..489679d8c0c681 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -83,6 +83,11 @@ 

[clang] [clang][StaticAnalyzer] Adding getentropy to CStringChecker. (PR #83675)

2024-03-23 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the Python code 
formatter.

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


  1   2   >