[clang] [Clang][ExprConstant] fix constant expression did not evaluate to integer (PR #97146)

2024-07-06 Thread Zhikai Zeng via cfe-commits

https://github.com/Backl1ght updated 
https://github.com/llvm/llvm-project/pull/97146

>From 7e14846e93df9f86b994c526b0da1f729c9b7cd4 Mon Sep 17 00:00:00 2001
From: Backl1ght 
Date: Sat, 29 Jun 2024 15:26:21 +0800
Subject: [PATCH 1/2] fix

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/AST/ExprConstant.cpp  |  2 +-
 clang/test/SemaCXX/eval-crashes.cpp | 10 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f6431a76b38de..ad129da506b64 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -967,6 +967,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure about invalid conversion when calling lambda. 
(#GH96205).
 - Fixed a bug where the first operand of binary ``operator&`` would be 
transformed as if it was the operand
   of the address of operator. (#GH97483).
+- Fixed an assertion failure about constant expression did not evaluate to 
integer. (#GH96670).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 374a3acf7aa26..0ccdc5eaabeef 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15858,7 +15858,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
   }
 
   if (const auto *CE = dyn_cast(Exp)) {
-if (CE->hasAPValueResult()) {
+if (CE->hasAPValueResult() && !CE->getAPValueResult().isLValue()) {
   Result.Val = CE->getAPValueResult();
   IsConst = true;
   return true;
diff --git a/clang/test/SemaCXX/eval-crashes.cpp 
b/clang/test/SemaCXX/eval-crashes.cpp
index 017df977b26b7..0865dafe4bf92 100644
--- a/clang/test/SemaCXX/eval-crashes.cpp
+++ b/clang/test/SemaCXX/eval-crashes.cpp
@@ -61,3 +61,13 @@ struct array {
   array() : data(*new int[1][2]) {}
 };
 }
+
+namespace GH96670 {
+inline constexpr long ullNil = -1;
+
+template
+struct Test {};
+
+inline constexpr long lNil = -1;
+Test c;
+}

>From 247ea9d7257abd284823ec1ef61d79b3102fc89c Mon Sep 17 00:00:00 2001
From: Backl1ght 
Date: Sat, 29 Jun 2024 16:42:07 +0800
Subject: [PATCH 2/2] address comments

---
 clang/docs/ReleaseNotes.rst|  3 ++-
 clang/lib/AST/ExprConstant.cpp | 11 +++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ad129da506b64..d60c6fbf15d56 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -967,7 +967,8 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure about invalid conversion when calling lambda. 
(#GH96205).
 - Fixed a bug where the first operand of binary ``operator&`` would be 
transformed as if it was the operand
   of the address of operator. (#GH97483).
-- Fixed an assertion failure about constant expression did not evaluate to 
integer. (#GH96670).
+- Fixed an assertion failure about a constant expression which is a known 
integer but is not
+  evaluated to an integer. (#GH96670).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 0ccdc5eaabeef..e0c9ef68cb448 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15858,10 +15858,13 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
   }
 
   if (const auto *CE = dyn_cast(Exp)) {
-if (CE->hasAPValueResult() && !CE->getAPValueResult().isLValue()) {
-  Result.Val = CE->getAPValueResult();
-  IsConst = true;
-  return true;
+if (CE->hasAPValueResult()) {
+  APValue APV = CE->getAPValueResult();
+  if (!APV.isLValue()) {
+Result.Val = std::move(APV);
+IsConst = true;
+return true;
+  }
 }
 
 // The SubExpr is usually just an IntegerLiteral.

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


[clang-tools-extra] [llvm] [clang-doc] fix bug introduced by asset test (PR #97540)

2024-07-06 Thread Michał Górny via cfe-commits

mgorny wrote:

This change broke standalone clang builds against installed LLVM, since 
`LLVM_SHARE_OUTPUT_INTDIR` is not exported by LLVM and therefore resolves to an 
empty path:

```
ninja: error: mkdir(/clang-doc): Permission denied
ninja: build stopped: .
```

Why are you even declaring the directory inside LLVM when it's only used by 
Clang?

Please revert.

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


[clang] [Clang][ExprConstant] fix constant expression did not evaluate to integer (PR #97146)

2024-07-06 Thread Zhikai Zeng via cfe-commits

https://github.com/Backl1ght updated 
https://github.com/llvm/llvm-project/pull/97146

>From 804c18269ab0c8018834a89f286e05c7e479ed42 Mon Sep 17 00:00:00 2001
From: Backl1ght 
Date: Sat, 29 Jun 2024 15:26:21 +0800
Subject: [PATCH 1/2] fix

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/AST/ExprConstant.cpp  |  2 +-
 clang/test/SemaCXX/eval-crashes.cpp | 10 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f6431a76b38de..ad129da506b64 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -967,6 +967,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure about invalid conversion when calling lambda. 
(#GH96205).
 - Fixed a bug where the first operand of binary ``operator&`` would be 
transformed as if it was the operand
   of the address of operator. (#GH97483).
+- Fixed an assertion failure about constant expression did not evaluate to 
integer. (#GH96670).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 374a3acf7aa26..0ccdc5eaabeef 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15858,7 +15858,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
   }
 
   if (const auto *CE = dyn_cast(Exp)) {
-if (CE->hasAPValueResult()) {
+if (CE->hasAPValueResult() && !CE->getAPValueResult().isLValue()) {
   Result.Val = CE->getAPValueResult();
   IsConst = true;
   return true;
diff --git a/clang/test/SemaCXX/eval-crashes.cpp 
b/clang/test/SemaCXX/eval-crashes.cpp
index 017df977b26b7..0865dafe4bf92 100644
--- a/clang/test/SemaCXX/eval-crashes.cpp
+++ b/clang/test/SemaCXX/eval-crashes.cpp
@@ -61,3 +61,13 @@ struct array {
   array() : data(*new int[1][2]) {}
 };
 }
+
+namespace GH96670 {
+inline constexpr long ullNil = -1;
+
+template
+struct Test {};
+
+inline constexpr long lNil = -1;
+Test c;
+}

>From f72cad6f736b2555ac15f169b7d8614b2649c7f9 Mon Sep 17 00:00:00 2001
From: Backl1ght 
Date: Sat, 29 Jun 2024 16:42:07 +0800
Subject: [PATCH 2/2] address comments

---
 clang/docs/ReleaseNotes.rst|  3 ++-
 clang/lib/AST/ExprConstant.cpp | 11 +++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ad129da506b64..d60c6fbf15d56 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -967,7 +967,8 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure about invalid conversion when calling lambda. 
(#GH96205).
 - Fixed a bug where the first operand of binary ``operator&`` would be 
transformed as if it was the operand
   of the address of operator. (#GH97483).
-- Fixed an assertion failure about constant expression did not evaluate to 
integer. (#GH96670).
+- Fixed an assertion failure about a constant expression which is a known 
integer but is not
+  evaluated to an integer. (#GH96670).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 0ccdc5eaabeef..e0c9ef68cb448 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15858,10 +15858,13 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
   }
 
   if (const auto *CE = dyn_cast(Exp)) {
-if (CE->hasAPValueResult() && !CE->getAPValueResult().isLValue()) {
-  Result.Val = CE->getAPValueResult();
-  IsConst = true;
-  return true;
+if (CE->hasAPValueResult()) {
+  APValue APV = CE->getAPValueResult();
+  if (!APV.isLValue()) {
+Result.Val = std::move(APV);
+IsConst = true;
+return true;
+  }
 }
 
 // The SubExpr is usually just an IntegerLiteral.

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


[clang] 874ca08 - [Clang][ExprConstant] fix constant expression did not evaluate to integer (#97146)

2024-07-06 Thread via cfe-commits

Author: Zhikai Zeng
Date: 2024-07-06T16:28:23+08:00
New Revision: 874ca08645420413e525054a47caf039bebde28b

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

LOG: [Clang][ExprConstant] fix constant expression did not evaluate to integer 
(#97146)

fixes https://github.com/llvm/llvm-project/issues/96670

The cause is that we might return a lvalue here at


https://github.com/llvm/llvm-project/blob/3e53c97d33210db68188e731e93ee48dbaeeae32/clang/lib/AST/ExprConstant.cpp#L15861-L15865

This PR will make sure we return a rvalue in `FastEvaluateAsRValue`.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/eval-crashes.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f6431a76b38de..d60c6fbf15d56 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -967,6 +967,8 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure about invalid conversion when calling lambda. 
(#GH96205).
 - Fixed a bug where the first operand of binary ``operator&`` would be 
transformed as if it was the operand
   of the address of operator. (#GH97483).
+- Fixed an assertion failure about a constant expression which is a known 
integer but is not
+  evaluated to an integer. (#GH96670).
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 374a3acf7aa26..e0c9ef68cb448 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15859,9 +15859,12 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
 
   if (const auto *CE = dyn_cast(Exp)) {
 if (CE->hasAPValueResult()) {
-  Result.Val = CE->getAPValueResult();
-  IsConst = true;
-  return true;
+  APValue APV = CE->getAPValueResult();
+  if (!APV.isLValue()) {
+Result.Val = std::move(APV);
+IsConst = true;
+return true;
+  }
 }
 
 // The SubExpr is usually just an IntegerLiteral.

diff  --git a/clang/test/SemaCXX/eval-crashes.cpp 
b/clang/test/SemaCXX/eval-crashes.cpp
index 017df977b26b7..0865dafe4bf92 100644
--- a/clang/test/SemaCXX/eval-crashes.cpp
+++ b/clang/test/SemaCXX/eval-crashes.cpp
@@ -61,3 +61,13 @@ struct array {
   array() : data(*new int[1][2]) {}
 };
 }
+
+namespace GH96670 {
+inline constexpr long ullNil = -1;
+
+template
+struct Test {};
+
+inline constexpr long lNil = -1;
+Test c;
+}



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


[clang] [Clang][ExprConstant] fix constant expression did not evaluate to integer (PR #97146)

2024-07-06 Thread Zhikai Zeng via cfe-commits

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


[clang-tools-extra] [llvm] [clang-doc] revert asset bug fix (PR #97882)

2024-07-06 Thread via cfe-commits

https://github.com/PeterChou1 created 
https://github.com/llvm/llvm-project/pull/97882

reverts https://github.com/llvm/llvm-project/pull/97540

which broke clangs standalone build 

>From 361e3e379df2f292d1099f48e9479742c727572f Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Sat, 6 Jul 2024 04:26:31 -0400
Subject: [PATCH] [clang-doc] revert asset bug fix

---
 clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +-
 llvm/CMakeLists.txt | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt 
b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
index 19c17a8f3a51f..e93a5728d6b6b 100644
--- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
@@ -25,7 +25,7 @@ set(assets
 )
 
 set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets")
-set(resource_dir "${LLVM_SHARE_OUTPUT_INTDIR}/clang-doc")
+set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc")
 set(out_files)
 
 function(copy_files_to_dst src_dir dst_dir file)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index cbbf84ec286ed..12618966c4adf 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -446,7 +446,6 @@ mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR)
 # They are used as destination of target generators.
 set(LLVM_RUNTIME_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
 set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
-set(LLVM_SHARE_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/share)
 if(WIN32 OR CYGWIN)
   # DLL platform -- put DLLs into bin.
   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})

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


[clang-tools-extra] [llvm] [clang-doc] revert asset bug fix (PR #97882)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




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

Author: None (PeterChou1)


Changes

reverts https://github.com/llvm/llvm-project/pull/97540

which broke clangs standalone build 

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


2 Files Affected:

- (modified) clang-tools-extra/clang-doc/tool/CMakeLists.txt (+1-1) 
- (modified) llvm/CMakeLists.txt (-1) 


``diff
diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt 
b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
index 19c17a8f3a51f..e93a5728d6b6b 100644
--- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
@@ -25,7 +25,7 @@ set(assets
 )
 
 set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets")
-set(resource_dir "${LLVM_SHARE_OUTPUT_INTDIR}/clang-doc")
+set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc")
 set(out_files)
 
 function(copy_files_to_dst src_dir dst_dir file)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index cbbf84ec286ed..12618966c4adf 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -446,7 +446,6 @@ mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR)
 # They are used as destination of target generators.
 set(LLVM_RUNTIME_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
 set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
-set(LLVM_SHARE_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/share)
 if(WIN32 OR CYGWIN)
   # DLL platform -- put DLLs into bin.
   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})

``




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


[clang-tools-extra] ac9d34a - [clang-doc] revert asset bug fix (#97882)

2024-07-06 Thread via cfe-commits

Author: PeterChou1
Date: 2024-07-06T04:29:49-04:00
New Revision: ac9d34a2eed4c4d58edf25b92e397faa76170d00

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

LOG: [clang-doc] revert asset bug fix (#97882)

reverts https://github.com/llvm/llvm-project/pull/97540

which broke clangs standalone build

Added: 


Modified: 
clang-tools-extra/clang-doc/tool/CMakeLists.txt
llvm/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt 
b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
index 19c17a8f3a51f7..e93a5728d6b6b0 100644
--- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt
@@ -25,7 +25,7 @@ set(assets
 )
 
 set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets")
-set(resource_dir "${LLVM_SHARE_OUTPUT_INTDIR}/clang-doc")
+set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc")
 set(out_files)
 
 function(copy_files_to_dst src_dir dst_dir file)

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index cbbf84ec286ed2..12618966c4adfd 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -446,7 +446,6 @@ mark_as_advanced(LLVM_EXAMPLES_INSTALL_DIR)
 # They are used as destination of target generators.
 set(LLVM_RUNTIME_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
 set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
-set(LLVM_SHARE_OUTPUT_INTDIR 
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/share)
 if(WIN32 OR CYGWIN)
   # DLL platform -- put DLLs into bin.
   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})



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


[clang-tools-extra] [llvm] [clang-doc] revert asset bug fix (PR #97882)

2024-07-06 Thread via cfe-commits

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


[clang-tools-extra] [llvm] [clang-doc] revert asset bug fix (PR #97882)

2024-07-06 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `bolt-x86_64-ubuntu-dylib` 
running on `bolt-worker` while building `clang-tools-extra,llvm` at step 6 
"test-build-bolt-check-bolt".

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-bolt-check-bolt) failure: test (failure)
 TEST 'BOLT :: perf2bolt/perf_test.test' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 5: 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/clang 
/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/Inputs/perf_test.c 
-fuse-ld=lld 
-Wl,--script=/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/Inputs/perf_test.lds
 -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp
+ /home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/clang 
/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/Inputs/perf_test.c 
-fuse-ld=lld 
-Wl,--script=/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/Inputs/perf_test.lds
 -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp
RUN: at line 6: perf record -e cycles:u -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp2
 -- 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp
+ perf record -e cycles:u -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp2
 -- 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp
Lowering default frequency rate from 4000 to 2000.
Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.003 MB 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp2
 (25 samples) ]
RUN: at line 7: 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/perf2bolt 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp
 
-p=/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp2
 -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp3
 -nl -ignore-build-id 2>&1 | 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/FileCheck 
/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/perf_test.test
+ /home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/perf2bolt 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp
 
-p=/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp2
 -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp3
 -nl -ignore-build-id
+ /home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/FileCheck 
/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/perf_test.test
RUN: at line 12: 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/clang 
/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/Inputs/perf_test.c 
-no-pie -fuse-ld=lld -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp4
+ /home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/clang 
/home/worker/bolt-worker2/llvm-project/bolt/test/perf2bolt/Inputs/perf_test.c 
-no-pie -fuse-ld=lld -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp4
RUN: at line 13: perf record -e cycles:u -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp5
 -- 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp4
+ perf record -e cycles:u -o 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp5
 -- 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp4
Lowering default frequency rate from 4000 to 2000.
Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.002 MB 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tmp5
 (9 samples) ]
RUN: at line 14: 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/bin/perf2bolt 
/home/worker/bolt-worker2/bolt-x86_64-ubuntu-dylib/build/tools/bolt/test/perf2bolt/Output/perf_test.test.tm

[clang-tools-extra] [llvm] [clang-doc] revert asset bug fix (PR #97882)

2024-07-06 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/1/3 (1980 of 1989)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/2/3 (1981 of 1989)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (1982 of 1989)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (1983 of 1989)
PASS: lldb-unit :: Utility/./UtilityTests/0/8 (1984 of 1989)
PASS: lldb-unit :: Utility/./UtilityTests/5/8 (1985 of 1989)
PASS: lldb-unit :: Utility/./UtilityTests/6/8 (1986 of 1989)
PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/10 (1987 of 
1989)
PASS: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (1988 of 1989)
TIMEOUT: lldb-api :: api/multiple-debuggers/TestMultipleDebuggers.py (1989 of 
1989)
 TEST 'lldb-api :: 
api/multiple-debuggers/TestMultipleDebuggers.py' FAILED 
Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/api/multiple-debuggers
 -p TestMultipleDebuggers.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
ac9d34a2eed4c4d58edf25b92e397faa76170d00)
  clang revision ac9d34a2eed4c4d58edf25b92e397faa76170d00
  llvm revision ac9d34a2eed4c4d58edf25b92e397faa76170d00

--



Timed Out Tests (1):
  lldb-api :: api/multiple-debuggers/TestMultipleDebuggers.py


Testing Time: 600.08s

Total Discovered Tests: 2991
  Unsupported  :  487 (16.28%)
  Passed   : 2480 (82.92%)
  Expectedly Failed:   23 (0.77%)
  Timed Out:1 (0.03%)
FAILED: tools/lldb/test/CMakeFiles/check-lldb 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test/CMakeFiles/check-lldb
 
cd /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test && 
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/llvm-lit -v 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/test
ninja: build stopped: subcommand failed.

```

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


[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-06 Thread via cfe-commits

https://github.com/NimishMishra updated 
https://github.com/llvm/llvm-project/pull/92364

>From 6423811853ab17f7109a4de972b66ce37573e979 Mon Sep 17 00:00:00 2001
From: Nimish Mishra 
Date: Sat, 6 Jul 2024 15:14:32 +0530
Subject: [PATCH] [clang][flang][OpenMPIRBuilder] Emit __atomic_load and
 __atomic_compare_exchange libcalls for complex types in atomic update

---
 clang/lib/CodeGen/CGAtomic.cpp| 673 +-
 .../OpenMP/atomic-update-complex.f90  |  42 ++
 llvm/include/llvm/Frontend/Atomic/Atomic.h| 235 ++
 .../llvm/Frontend/OpenMP/OMPIRBuilder.h   |  24 +
 llvm/lib/Frontend/Atomic/Atomic.cpp   |  18 +
 llvm/lib/Frontend/Atomic/CMakeLists.txt   |  15 +
 llvm/lib/Frontend/CMakeLists.txt  |   1 +
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp |  47 ++
 8 files changed, 701 insertions(+), 354 deletions(-)
 create mode 100644 flang/test/Integration/OpenMP/atomic-update-complex.f90
 create mode 100644 llvm/include/llvm/Frontend/Atomic/Atomic.h
 create mode 100644 llvm/lib/Frontend/Atomic/Atomic.cpp
 create mode 100644 llvm/lib/Frontend/Atomic/CMakeLists.txt

diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index fbf942d06ca6e..a7bbbd20cc31b 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -19,6 +19,7 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/Frontend/Atomic/Atomic.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Operator.h"
@@ -27,275 +28,322 @@ using namespace clang;
 using namespace CodeGen;
 
 namespace {
-  class AtomicInfo {
-CodeGenFunction &CGF;
-QualType AtomicTy;
+class AtomicInfo : public llvm::AtomicInfo {
+  CodeGenFunction &CGF;
+  QualType AtomicTy;
+  QualType ValueTy;
+  TypeEvaluationKind EvaluationKind;
+  LValue LVal;
+  CGBitFieldInfo BFI;
+
+public:
+  llvm::AtomicInfo &getBase() { return *this; }
+
+  static AtomicInfo fromValue(CodeGenFunction &CGF, LValue &lvalue) {
+if (lvalue.isSimple())
+  return fromSimple(CGF, lvalue);
+if (lvalue.isBitField())
+  return fromBitfield(CGF, lvalue);
+if (lvalue.isVectorElt())
+  return fromVectorElt(CGF, lvalue);
+if (lvalue.isExtVectorElt())
+  return fromExtVectorElt(CGF, lvalue);
+llvm_unreachable("Type incompatible with atomics");
+  }
+
+  static AtomicInfo fromSimple(CodeGenFunction &CGF, LValue &lvalue) {
+assert(lvalue.isSimple());
+ASTContext &C = CGF.getContext();
+
+QualType AtomicTy = lvalue.getType();
 QualType ValueTy;
-uint64_t AtomicSizeInBits;
-uint64_t ValueSizeInBits;
-CharUnits AtomicAlign;
-CharUnits ValueAlign;
-TypeEvaluationKind EvaluationKind;
-bool UseLibcall;
-LValue LVal;
-CGBitFieldInfo BFI;
-  public:
-AtomicInfo(CodeGenFunction &CGF, LValue &lvalue)
-: CGF(CGF), AtomicSizeInBits(0), ValueSizeInBits(0),
-  EvaluationKind(TEK_Scalar), UseLibcall(true) {
-  assert(!lvalue.isGlobalReg());
-  ASTContext &C = CGF.getContext();
-  if (lvalue.isSimple()) {
-AtomicTy = lvalue.getType();
-if (auto *ATy = AtomicTy->getAs())
-  ValueTy = ATy->getValueType();
-else
-  ValueTy = AtomicTy;
-EvaluationKind = CGF.getEvaluationKind(ValueTy);
-
-uint64_t ValueAlignInBits;
-uint64_t AtomicAlignInBits;
-TypeInfo ValueTI = C.getTypeInfo(ValueTy);
-ValueSizeInBits = ValueTI.Width;
-ValueAlignInBits = ValueTI.Align;
-
-TypeInfo AtomicTI = C.getTypeInfo(AtomicTy);
-AtomicSizeInBits = AtomicTI.Width;
-AtomicAlignInBits = AtomicTI.Align;
-
-assert(ValueSizeInBits <= AtomicSizeInBits);
-assert(ValueAlignInBits <= AtomicAlignInBits);
-
-AtomicAlign = C.toCharUnitsFromBits(AtomicAlignInBits);
-ValueAlign = C.toCharUnitsFromBits(ValueAlignInBits);
-if (lvalue.getAlignment().isZero())
-  lvalue.setAlignment(AtomicAlign);
-
-LVal = lvalue;
-  } else if (lvalue.isBitField()) {
-ValueTy = lvalue.getType();
-ValueSizeInBits = C.getTypeSize(ValueTy);
-auto &OrigBFI = lvalue.getBitFieldInfo();
-auto Offset = OrigBFI.Offset % C.toBits(lvalue.getAlignment());
-AtomicSizeInBits = C.toBits(
-C.toCharUnitsFromBits(Offset + OrigBFI.Size + C.getCharWidth() - 1)
-.alignTo(lvalue.getAlignment()));
-llvm::Value *BitFieldPtr = lvalue.getRawBitFieldPointer(CGF);
-auto OffsetInChars =
-(C.toCharUnitsFromBits(OrigBFI.Offset) / lvalue.getAlignment()) *
-lvalue.getAlignment();
-llvm::Value *StoragePtr = CGF.Builder.CreateConstGEP1_64(
-CGF.Int8Ty, BitFieldPtr, OffsetInChars.getQuantity());
-StoragePtr = CGF.Builder.CreateAddrSpaceCast(
-StoragePtr, CGF.UnqualPtrTy, "at

[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-06 Thread via cfe-commits

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


[clang] [flang] [llvm] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

2024-07-06 Thread via cfe-commits

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


[clang-tools-extra] [llvm] [clang-doc] revert asset bug fix (PR #97882)

2024-07-06 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
29.979 [1/2/288] Linking CXX executable 
tools\lldb\unittests\ValueObject\LLDBValueObjectTests.exe
30.036 [1/1/289] Linking CXX executable 
tools\lldb\unittests\Thread\ThreadTests.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:57:
 note: using lit tools: C:\Users\tcwg\scoop\apps\git\2.39.0.windows.2\usr\bin
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using clang: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using ld.lld: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld.lld.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using lld-link: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\lld-link.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using ld64.lld: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\ld64.lld.exe
llvm-lit.py: 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\utils\lit\lit\llvm\config.py:508:
 note: using wasm-ld: 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\wasm-ld.exe
30.037 [0/1/289] Running lldb-- Testing: 1985 tests, 2 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: lldb-api :: tools/lldb-server/TestGdbRemoteLaunch.py (1148 of 1985)
 TEST 'lldb-api :: 
tools/lldb-server/TestGdbRemoteLaunch.py' FAILED 
Script:
--
C:/Users/tcwg/AppData/Local/Programs/Python/Python311-arm64/python.exe 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/llvm-project/lldb\test\API\dotest.py
 -u CXXFLAGS -u CFLAGS --env 
OBJCOPY=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/llvm-objcopy.exe
 --env LLVM_LIBS_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./lib 
--env 
LLVM_INCLUDE_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/include 
--env LLVM_TOOLS_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin 
--arch aarch64 --build-dir 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-lldb\lldb-api
 --clang-module-cache-dir 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-clang\lldb-api
 --executable 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/lldb.exe --compiler 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/clang.exe --dsymutil 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/dsymutil.exe 
--llvm-tools-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin 
--lldb-obj-root C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/tools/lldb 
--lldb-libs-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./lib 
--skip-category=watchpoint 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\tools\lldb-server
 -p TestGdbRemoteLaunch.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
ac9d34a2eed4c4d58edf25b92e397faa76170d00)
  clang revision ac9d34a2eed4c4d58edf25b92e397faa76170d00
  llvm revision ac9d34a2eed4c4d58edf25b92e397faa76170d00
Skipping the following test categories: ['watchpoint', 'libc++', 'libstdcxx', 
'dwo', 'dsym', 'gmodules', 'debugserver', 'objc', 'fork', 'pexpect']


--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe-aarch64) :: 
test_QEnvironmentHexEncoded_llgs 
(TestGdbRemoteLaunch.GdbRemoteLaunchTestCase.test_QEnvironmentHexEncoded_llgs) 
(skip on windows) 

UNSUPPORTED: LLDB 
(C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe-aarch64) :: 
test_QEnvironment_llgs 
(TestGdbRemoteLaunch.GdbRemoteLaunchTestCase.test_QEnvironment_llgs) (skip on 
windows) 

PASS: LLDB 
(C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe-aarch64) :: 
test_launch_failure_via_vRun_llgs 
(TestGdbRemoteLaunch.GdbRemoteLaunchTestCase.test_launch_failure_via_vRun_llgs)

UNSUPPORTED: LLDB 
(C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe-aarch64) :: 
test_launch_via_A_llgs 
(TestGdbRemoteLaunch.GdbRemoteLaunchTestCase.test_launch_via_A_llgs) (skip on 
windows) 

UNSUPPORTED: LLDB 
(C:\Users\tcwg\llvm-worker\lldb-aarch64-window

[clang] [Clang] Fix Microsoft ABI inheritance model when member pointer is used in a base specifier (PR #91990)

2024-07-06 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/91990

>From 5dc9193af0d98335a87e93ad70d945dbc0ffce79 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Mon, 13 May 2024 16:59:06 +0100
Subject: [PATCH 1/4] [Clang] Fix Microsoft ABI inheritance model when member
 pointer is used in a base specifier

Fix CXXRecordDecl::isParsingBaseSpecifiers so that it is true while parsing 
base specifiers instead of directly after they have been parsed.

-fcomplete-member-pointers now issues a diagnostic when a member pointer is 
used in a base specifier.

-fcomplete-member-pointers has also been relaxed to not issue a diagnostic for 
incomplete classes with an explicit __{single|multiple|virtual}_inheritance 
attribute, whose completeness would not affect the representation of 
pointer-to-member objects.
---
 clang/docs/ReleaseNotes.rst   |  4 +++
 clang/include/clang/AST/DeclCXX.h |  7 +++--
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/lib/AST/DeclCXX.cpp |  6 +
 clang/lib/Parse/ParseDeclCXX.cpp  | 24 +
 clang/lib/Sema/SemaDeclCXX.cpp|  3 ---
 clang/lib/Sema/SemaType.cpp   | 27 ---
 .../test/SemaCXX/complete-member-pointers.cpp | 24 -
 clang/test/SemaCXX/member-pointer-ms.cpp  |  8 ++
 9 files changed, 85 insertions(+), 20 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4702b8c10cdbb..054332c2cee4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -79,6 +79,10 @@ ABI Changes in This Version
 - Fixed Microsoft calling convention when returning classes that have a deleted
   copy assignment operator. Such a class should be returned indirectly.
 
+- Fixed Microsoft layout of pointer-to-members of classes when the layout is 
needed
+  directly or indirectly by the base classes of a class. These should use the 
most
+  general unspecified inheritance layout. Also affects 
-fcomplete-member-pointers.
+
 AST Dumping Potentially Breaking Changes
 
 
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..81669b1f606b3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -297,7 +297,8 @@ class CXXRecordDecl : public RecordDecl {
 LLVM_PREFERRED_TYPE(bool)
 unsigned IsLambda : 1;
 
-/// Whether we are currently parsing base specifiers.
+/// Whether we are currently parsing base specifiers; the
+/// colon has been consumed but the beginning left brace hasn't.
 LLVM_PREFERRED_TYPE(bool)
 unsigned IsParsingBaseSpecifiers : 1;
 
@@ -598,7 +599,9 @@ class CXXRecordDecl : public RecordDecl {
 return !hasDefinition() || !isDynamicClass() || hasAnyDependentBases();
   }
 
-  void setIsParsingBaseSpecifiers() { data().IsParsingBaseSpecifiers = true; }
+  void setIsParsingBaseSpecifiers(bool to = true) {
+data().IsParsingBaseSpecifiers = to;
+  }
 
   bool isParsingBaseSpecifiers() const {
 return data().IsParsingBaseSpecifiers;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9e82130c93609..a9f9f02651cff 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8003,6 +8003,8 @@ def err_bad_memptr_rhs : Error<
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def note_memptr_incomplete_until_bases : Note<
+  "this will affect the ABI of the member pointer until the bases have been 
specified">;
 def err_memptr_incomplete : Error<
   "member pointer has incomplete base type %0">;
 def warn_exception_caught_by_earlier_handler : Warning<
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 75c441293d62e..7f20a47e6a054 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -474,10 +474,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
   if (data().IsStandardLayout && NumBases > 1 && hasRepeatedBaseClass(this))
 data().IsStandardLayout = false;
 
-  if (VBases.empty()) {
-data().IsParsingBaseSpecifiers = false;
+  if (VBases.empty())
 return;
-  }
 
   // Create base specifier for any direct or indirect virtual bases.
   data().VBases = new (C) CXXBaseSpecifier[VBases.size()];
@@ -488,8 +486,6 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
   addedClassSubobject(Type->getAsCXXRecordDecl());
 data().getVBases()[I] = *VBases[I];
   }
-
-  data().IsParsingBaseSpecifiers = false;
 }
 
 unsigned CXXRecordDecl::getODRHash() const {
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 65ddebca49bc6..a28503b5b4de4 100644
--- a/clang/lib/Parse/ParseDecl

[clang] [Clang] Fix Microsoft ABI inheritance model when member pointer is used in a base specifier (PR #91990)

2024-07-06 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/91990

>From 5dc9193af0d98335a87e93ad70d945dbc0ffce79 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Mon, 13 May 2024 16:59:06 +0100
Subject: [PATCH 1/5] [Clang] Fix Microsoft ABI inheritance model when member
 pointer is used in a base specifier

Fix CXXRecordDecl::isParsingBaseSpecifiers so that it is true while parsing 
base specifiers instead of directly after they have been parsed.

-fcomplete-member-pointers now issues a diagnostic when a member pointer is 
used in a base specifier.

-fcomplete-member-pointers has also been relaxed to not issue a diagnostic for 
incomplete classes with an explicit __{single|multiple|virtual}_inheritance 
attribute, whose completeness would not affect the representation of 
pointer-to-member objects.
---
 clang/docs/ReleaseNotes.rst   |  4 +++
 clang/include/clang/AST/DeclCXX.h |  7 +++--
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/lib/AST/DeclCXX.cpp |  6 +
 clang/lib/Parse/ParseDeclCXX.cpp  | 24 +
 clang/lib/Sema/SemaDeclCXX.cpp|  3 ---
 clang/lib/Sema/SemaType.cpp   | 27 ---
 .../test/SemaCXX/complete-member-pointers.cpp | 24 -
 clang/test/SemaCXX/member-pointer-ms.cpp  |  8 ++
 9 files changed, 85 insertions(+), 20 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4702b8c10cdbb..054332c2cee4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -79,6 +79,10 @@ ABI Changes in This Version
 - Fixed Microsoft calling convention when returning classes that have a deleted
   copy assignment operator. Such a class should be returned indirectly.
 
+- Fixed Microsoft layout of pointer-to-members of classes when the layout is 
needed
+  directly or indirectly by the base classes of a class. These should use the 
most
+  general unspecified inheritance layout. Also affects 
-fcomplete-member-pointers.
+
 AST Dumping Potentially Breaking Changes
 
 
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..81669b1f606b3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -297,7 +297,8 @@ class CXXRecordDecl : public RecordDecl {
 LLVM_PREFERRED_TYPE(bool)
 unsigned IsLambda : 1;
 
-/// Whether we are currently parsing base specifiers.
+/// Whether we are currently parsing base specifiers; the
+/// colon has been consumed but the beginning left brace hasn't.
 LLVM_PREFERRED_TYPE(bool)
 unsigned IsParsingBaseSpecifiers : 1;
 
@@ -598,7 +599,9 @@ class CXXRecordDecl : public RecordDecl {
 return !hasDefinition() || !isDynamicClass() || hasAnyDependentBases();
   }
 
-  void setIsParsingBaseSpecifiers() { data().IsParsingBaseSpecifiers = true; }
+  void setIsParsingBaseSpecifiers(bool to = true) {
+data().IsParsingBaseSpecifiers = to;
+  }
 
   bool isParsingBaseSpecifiers() const {
 return data().IsParsingBaseSpecifiers;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9e82130c93609..a9f9f02651cff 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8003,6 +8003,8 @@ def err_bad_memptr_rhs : Error<
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def note_memptr_incomplete_until_bases : Note<
+  "this will affect the ABI of the member pointer until the bases have been 
specified">;
 def err_memptr_incomplete : Error<
   "member pointer has incomplete base type %0">;
 def warn_exception_caught_by_earlier_handler : Warning<
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 75c441293d62e..7f20a47e6a054 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -474,10 +474,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
   if (data().IsStandardLayout && NumBases > 1 && hasRepeatedBaseClass(this))
 data().IsStandardLayout = false;
 
-  if (VBases.empty()) {
-data().IsParsingBaseSpecifiers = false;
+  if (VBases.empty())
 return;
-  }
 
   // Create base specifier for any direct or indirect virtual bases.
   data().VBases = new (C) CXXBaseSpecifier[VBases.size()];
@@ -488,8 +486,6 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const 
*Bases,
   addedClassSubobject(Type->getAsCXXRecordDecl());
 data().getVBases()[I] = *VBases[I];
   }
-
-  data().IsParsingBaseSpecifiers = false;
 }
 
 unsigned CXXRecordDecl::getODRHash() const {
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 65ddebca49bc6..a28503b5b4de4 100644
--- a/clang/lib/Parse/ParseDecl

[clang-tools-extra] Allow unnecessary-value-param to match templated functions including lambdas with auto. (PR #97767)

2024-07-06 Thread Vitaly Goldshteyn via cfe-commits


@@ -0,0 +1,93 @@
+// RUN: %check_clang_tidy  -std=c++14-or-later %s 
performance-unnecessary-value-param %t
+
+struct ExpensiveToCopyType {
+  virtual ~ExpensiveToCopyType();
+};
+
+template  void templateWithNonTemplatizedParameter(const 
ExpensiveToCopyType S, T V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
+  // CHECK-MESSAGES: [[@LINE-2]]:95: warning: the parameter 'V'
+  // CHECK-FIXES: template  void 
templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, const T& V) {
+}
+
+void instantiatedWithExpensiveValue() {
+  templateWithNonTemplatizedParameter(
+  ExpensiveToCopyType(), ExpensiveToCopyType());
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), 5);
+}
+
+template  void 
templateWithNonTemplatizedParameterCheapTemplate(const ExpensiveToCopyType S, T 
V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:103: warning: the const qualified parameter 
'S'
+  // CHECK-FIXES: template  void 
templateWithNonTemplatizedParameterCheapTemplate(const ExpensiveToCopyType& S, 
T V) {
+}
+
+void instantiatedWithCheapValue() {
+  templateWithNonTemplatizedParameterCheapTemplate(ExpensiveToCopyType(), 5);
+}
+
+template  void nonInstantiatedTemplateWithConstValue(const T S) {}
+template  void nonInstantiatedTemplateWithNonConstValue(T S) {}
+
+template  void instantiatedTemplateSpecialization(T NoSpecS) {}
+template <>
+void instantiatedTemplateSpecialization(
+ExpensiveToCopyType SpecS) {
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: the parameter 'SpecS'
+  // When updating a template specialization, we also update the main template.

goldvitaly wrote:

Note that it is template specialization and not an overload.

Template specialization must have exactly the same signature.
See an example https://gcc.godbolt.org/z/cqTzG5Wsn

Note that nothing special is done to update both versions.
When template specialization is updated, the main template and all other 
template specializations are updated automatically.

I personally prefer to use overloads, but this test is necessary to be sure 
that we are not proposing non compiling changes.

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


[clang] [clang] Add C++26 diagnostics to compatibility diagnosic groups (PR #97806)

2024-07-06 Thread via cfe-commits

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


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


[clang-tools-extra] Allow unnecessary-value-param to match templated functions including lambdas with auto. (PR #97767)

2024-07-06 Thread Julian Schmidt via cfe-commits


@@ -0,0 +1,93 @@
+// RUN: %check_clang_tidy  -std=c++14-or-later %s 
performance-unnecessary-value-param %t
+
+struct ExpensiveToCopyType {
+  virtual ~ExpensiveToCopyType();
+};
+
+template  void templateWithNonTemplatizedParameter(const 
ExpensiveToCopyType S, T V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
+  // CHECK-MESSAGES: [[@LINE-2]]:95: warning: the parameter 'V'
+  // CHECK-FIXES: template  void 
templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, const T& V) {
+}
+
+void instantiatedWithExpensiveValue() {
+  templateWithNonTemplatizedParameter(
+  ExpensiveToCopyType(), ExpensiveToCopyType());
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), 5);
+}
+
+template  void 
templateWithNonTemplatizedParameterCheapTemplate(const ExpensiveToCopyType S, T 
V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:103: warning: the const qualified parameter 
'S'
+  // CHECK-FIXES: template  void 
templateWithNonTemplatizedParameterCheapTemplate(const ExpensiveToCopyType& S, 
T V) {
+}
+
+void instantiatedWithCheapValue() {
+  templateWithNonTemplatizedParameterCheapTemplate(ExpensiveToCopyType(), 5);
+}
+
+template  void nonInstantiatedTemplateWithConstValue(const T S) {}
+template  void nonInstantiatedTemplateWithNonConstValue(T S) {}
+
+template  void instantiatedTemplateSpecialization(T NoSpecS) {}
+template <>
+void instantiatedTemplateSpecialization(
+ExpensiveToCopyType SpecS) {
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: the parameter 'SpecS'
+  // When updating a template specialization, we also update the main template.

5chmidti wrote:

> Note that it is template specialization and not an overload.
Template specialization must have exactly the same signature.

Whoops, I must have done something weird to think this works.

Then what I would have originally written applies:
When a specialization A is defined in another TU, applying a fix to 
specialization B from the analyzed TU or the underlying template, will make A 
no longer compile. The same goes for specializations in headers that are not 
included, and also specializations that are:

```c++
template  void instantiatedTemplateSpecialization(T NoSpecS) {}
template <>
void instantiatedTemplateSpecialization(
ExpensiveToCopyType SpecS) {
  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: the parameter 'SpecS'
  // When updating a template specialization, we also update the main template.
  // CHECK-FIXES: const T& NoSpecS
  // CHECK-FIXES: const ExpensiveToCopyType& SpecS
  // CHECK-FIXES: const int& SpecS   <- fails, no fix generated it 
seems
}
template <>
void instantiatedTemplateSpecialization(
int SpecS) {
}
```

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


[clang-tools-extra] Allow unnecessary-value-param to match templated functions including lambdas with auto. (PR #97767)

2024-07-06 Thread Vitaly Goldshteyn via cfe-commits


@@ -0,0 +1,93 @@
+// RUN: %check_clang_tidy  -std=c++14-or-later %s 
performance-unnecessary-value-param %t
+
+struct ExpensiveToCopyType {
+  virtual ~ExpensiveToCopyType();
+};
+
+template  void templateWithNonTemplatizedParameter(const 
ExpensiveToCopyType S, T V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
+  // CHECK-MESSAGES: [[@LINE-2]]:95: warning: the parameter 'V'
+  // CHECK-FIXES: template  void 
templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, const T& V) {
+}
+
+void instantiatedWithExpensiveValue() {
+  templateWithNonTemplatizedParameter(
+  ExpensiveToCopyType(), ExpensiveToCopyType());
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), 5);
+}
+
+template  void 
templateWithNonTemplatizedParameterCheapTemplate(const ExpensiveToCopyType S, T 
V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:103: warning: the const qualified parameter 
'S'
+  // CHECK-FIXES: template  void 
templateWithNonTemplatizedParameterCheapTemplate(const ExpensiveToCopyType& S, 
T V) {
+}
+
+void instantiatedWithCheapValue() {
+  templateWithNonTemplatizedParameterCheapTemplate(ExpensiveToCopyType(), 5);
+}
+
+template  void nonInstantiatedTemplateWithConstValue(const T S) {}
+template  void nonInstantiatedTemplateWithNonConstValue(T S) {}
+
+template  void instantiatedTemplateSpecialization(T NoSpecS) {}
+template <>
+void instantiatedTemplateSpecialization(
+ExpensiveToCopyType SpecS) {
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: the parameter 'SpecS'
+  // When updating a template specialization, we also update the main template.

goldvitaly wrote:

That is unfortunately correct.  I was aware that other TUs can be broken.

But it seems that other template instantiations are  not fixed in the same file 
as well.

Do you know how to skip template specialization, but not all other template 
functions?

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


[clang] [Clang] Fix Microsoft ABI inheritance model when member pointer is used in a base specifier (PR #91990)

2024-07-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

`Sema.h` changes look good.

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


[clang] [clang] Add C++26 diagnostics to compatibility diagnosic groups (PR #97806)

2024-07-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/97806

>From b855fe1b301a156ea45caa4b6fd6eca1c69d5cf5 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Fri, 5 Jul 2024 12:39:13 +0300
Subject: [PATCH 1/3] [clang] Add C++26 diagnostics to compatibility diagnosic
 groups

---
 clang/docs/ReleaseNotes.rst   |  4 +++
 clang/include/clang/Basic/DiagnosticGroups.td | 30 ---
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 36cf615a4287c..cf1b529eb7321 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -476,6 +476,10 @@ Modified Compiler Flags
   evaluating to ``true`` and an empty body such as ``while(1);``)
   are considered infinite, even when the ``-ffinite-loop`` flag is set.
 
+- Diagnostics groups about compatibility with a particular C++ Standard version
+  now include dianostics about C++26 features that are not present in older
+  versions.
+
 Removed Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 9431eea1f6be2..a4496431e46e4 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -344,7 +344,8 @@ def CXX98Compat : DiagGroup<"c++98-compat",
  CXXPre14Compat,
  CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
@@ -353,7 +354,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX11NarrowingConstReference : 
DiagGroup<"c++11-narrowing-const-reference">;
 def CXX11Narrowing : DiagGroup<"c++11-narrowing", 
[CXX11NarrowingConstReference]>;
@@ -384,39 +386,47 @@ def CXX11Compat : DiagGroup<"c++11-compat",
  CXXPre14Compat,
  CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
 [CXX11Compat,
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXX14Compat,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
  DeprecatedIncrementBool,
  CXX17CompatMangling,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic",
 [CXX17Compat,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 def : DiagGroup<"c++1z-compat", [CXX17Compat]>;
 
-def 

[clang] [clang] Add C++26 diagnostics to compatibility diagnosic groups (PR #97806)

2024-07-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/97806

>From b855fe1b301a156ea45caa4b6fd6eca1c69d5cf5 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Fri, 5 Jul 2024 12:39:13 +0300
Subject: [PATCH 1/4] [clang] Add C++26 diagnostics to compatibility diagnosic
 groups

---
 clang/docs/ReleaseNotes.rst   |  4 +++
 clang/include/clang/Basic/DiagnosticGroups.td | 30 ---
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 36cf615a4287cc..cf1b529eb73210 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -476,6 +476,10 @@ Modified Compiler Flags
   evaluating to ``true`` and an empty body such as ``while(1);``)
   are considered infinite, even when the ``-ffinite-loop`` flag is set.
 
+- Diagnostics groups about compatibility with a particular C++ Standard version
+  now include dianostics about C++26 features that are not present in older
+  versions.
+
 Removed Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 9431eea1f6be22..a4496431e46e4c 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -344,7 +344,8 @@ def CXX98Compat : DiagGroup<"c++98-compat",
  CXXPre14Compat,
  CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
@@ -353,7 +354,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX11NarrowingConstReference : 
DiagGroup<"c++11-narrowing-const-reference">;
 def CXX11Narrowing : DiagGroup<"c++11-narrowing", 
[CXX11NarrowingConstReference]>;
@@ -384,39 +386,47 @@ def CXX11Compat : DiagGroup<"c++11-compat",
  CXXPre14Compat,
  CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
 [CXX11Compat,
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXX14Compat,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
  DeprecatedIncrementBool,
  CXX17CompatMangling,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic",
 [CXX17Compat,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 def : DiagGroup<"c++1z-compat", [CXX17Compat]>;
 
-

[clang] [Clang] Fix Microsoft ABI inheritance model when member pointer is used in a base specifier (PR #91990)

2024-07-06 Thread Mital Ashok via cfe-commits

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Yupei Liu via cfe-commits

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Younan Zhang via cfe-commits


@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   SemaRef.RebuildLambdaScopeInfo(cast(FD));
 
-  FunctionDecl *Pattern = getPatternFunctionDecl(FD);
-  if (Pattern) {
-SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+  FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+  if (!FDPattern)
+return;
 
-FunctionDecl *ParentFD = FD;
-while (ShouldAddDeclsFromParentScope) {
+  SemaRef.addInstantiatedCapturesToScope(FD, FDPattern, Scope, MLTAL);
 
-  ParentFD =
-  dyn_cast(getLambdaAwareParentOfDeclContext(ParentFD));
-  Pattern =
-  dyn_cast(getLambdaAwareParentOfDeclContext(Pattern));
+  if (!ShouldAddDeclsFromParentScope)
+return;
 
-  if (!ParentFD || !Pattern)
-break;
+  llvm::SmallVector, 4>
+  ParentInstantiations;
+  std::pair Current = {FDPattern, FD};
+  while (true) {
+Current.first = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.first));
+Current.second = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.second));

zyn0217 wrote:

Using `.first` and `.second` seems a bit unclear. Can we wrap them into a local 
struct?

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Younan Zhang via cfe-commits


@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   SemaRef.RebuildLambdaScopeInfo(cast(FD));
 
-  FunctionDecl *Pattern = getPatternFunctionDecl(FD);
-  if (Pattern) {
-SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+  FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+  if (!FDPattern)
+return;
 

zyn0217 wrote:

nit: Can you revert unrelated changes?

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Younan Zhang via cfe-commits


@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   SemaRef.RebuildLambdaScopeInfo(cast(FD));
 
-  FunctionDecl *Pattern = getPatternFunctionDecl(FD);
-  if (Pattern) {
-SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+  FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+  if (!FDPattern)
+return;
 
-FunctionDecl *ParentFD = FD;
-while (ShouldAddDeclsFromParentScope) {
+  SemaRef.addInstantiatedCapturesToScope(FD, FDPattern, Scope, MLTAL);
 
-  ParentFD =
-  dyn_cast(getLambdaAwareParentOfDeclContext(ParentFD));
-  Pattern =
-  dyn_cast(getLambdaAwareParentOfDeclContext(Pattern));
+  if (!ShouldAddDeclsFromParentScope)
+return;
 
-  if (!ParentFD || !Pattern)
-break;
+  llvm::SmallVector, 4>
+  ParentInstantiations;
+  std::pair Current = {FDPattern, FD};
+  while (true) {
+Current.first = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.first));
+Current.second = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.second));
 
-  SemaRef.addInstantiatedParametersToScope(ParentFD, Pattern, Scope, 
MLTAL);
-  SemaRef.addInstantiatedLocalVarsToScope(ParentFD, Pattern, Scope);
-}
+if (!Current.first || !Current.second)
+  break;
+
+ParentInstantiations.push_back(Current);
+  }
+
+  for (const auto &[Pattern, Inst] : llvm::reverse(ParentInstantiations)) {

zyn0217 wrote:

I think it would be better to retain the name `PatternFD`.
In addition, can you also add some comments to explain why we're enumerating 
instantiations in the reversed way here? An example would be
```
// Add instantiated parameters to scopes in the order from the outer lambda to
// the inner lambda. We do so because the inner parameters could depend on
// any outer template parameters.
```

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 commented:

Thanks! I think the approach makes sense. Just some nits from me
@cor3ntin do you have any other comments? I think you can do the last approval. 
:)

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Oh, I forgot it: this also needs a release note.

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


[clang] be3a8b8 - [clang] Add C++26 diagnostics to compatibility diagnosic groups (#97806)

2024-07-06 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-07-06T15:52:19+04:00
New Revision: be3a8b8d94608746b22cb0cf3fc03af33b7d8648

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

LOG: [clang] Add C++26 diagnostics to compatibility diagnosic groups (#97806)

This patch adds `CXXPre26Compat` and `CXXPre26CompatPedantic` groups
(which are concerned with new features not available in older language
modes) to `CXX98Compat`, etc. This way, if user has `-Wc++20-compat` and
they use pack indexing, they will be warned.

Ideally this should have been done when C++26 groups were created, but
we shipped two releases of Clang since then.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticGroups.td

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d60c6fbf15d56..39187078d5786 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -439,8 +439,11 @@ New Compiler Flags
   Matches MSVC behaviour by defining ``__STDC__`` to ``1`` when
   MSVC compatibility mode is used. It has no effect for C++ code.
 
+- ``-Wc++23-compat`` group was added to help migrating existing codebases
+  to C++23.
+
 - ``-Wc++2c-compat`` group was added to help migrating existing codebases
-  to C++26.
+  to upcoming C++26.
 
 Deprecated Compiler Flags
 -
@@ -480,6 +483,10 @@ Modified Compiler Flags
   evaluating to ``true`` and an empty body such as ``while(1);``)
   are considered infinite, even when the ``-ffinite-loop`` flag is set.
 
+- Diagnostics groups about compatibility with a particular C++ Standard version
+  now include dianostics about C++26 features that are not present in older
+  versions.
+
 Removed Compiler Flags
 -
 

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 1b25cf36dd4f8..2241f8481484e 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -344,7 +344,8 @@ def CXX98Compat : DiagGroup<"c++98-compat",
  CXXPre14Compat,
  CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
@@ -353,7 +354,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX11NarrowingConstReference : 
DiagGroup<"c++11-narrowing-const-reference">;
 def CXX11Narrowing : DiagGroup<"c++11-narrowing", 
[CXX11NarrowingConstReference]>;
@@ -384,42 +386,52 @@ def CXX11Compat : DiagGroup<"c++11-compat",
  CXXPre14Compat,
  CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
 [CXX11Compat,
  CXXPre14CompatPedantic,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+ CXXPre26CompatPedantic]>;
 
 def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat,
  CXXPre20Compat,
- CXXPre23Compat]>;
+ CXXPre23Compat,
+ CXXPre26Compat]>;
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXX14Compat,
  CXXPre17CompatPedantic,
  CXXPre20CompatPedantic,
- CXXPre23CompatPedantic]>;
+ CXXPre23CompatPedantic,
+

[clang] [clang] Add C++26 diagnostics to compatibility diagnosic groups (PR #97806)

2024-07-06 Thread Vlad Serebrennikov via cfe-commits

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


[clang] Enable aarch64-amazon-linux triple (PR #82232)

2024-07-06 Thread Byoungchan Lee via cfe-commits

bc-lee wrote:

I'm not the owner of this code, but I just dropped by to say that
I don't think this patch will be accepted. A few lines above your changes,
there is a comment that says, "Please don't add more elements to *Triples.".

@MaskRay is working to reduce the number of target triples like 
20d497c26fc95c80a1bacb38820d92e5f52bec58
and I think this patch goes against his goals.

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


[clang] Reapply "[Clang] Fix __is_trivially_equality_comparable returning true with ineligebile defaulted overloads" (#97002) (PR #97894)

2024-07-06 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 created 
https://github.com/llvm/llvm-project/pull/97894

This reverts commit 567b2c608c307c097315dd5ec4d6a5bbcddf898d.


>From 43b1972a867bf9fa16fdf0d93dcbca4deae9fd13 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sat, 29 Jun 2024 21:51:02 +0200
Subject: [PATCH] Reapply "[Clang] Fix __is_trivially_equality_comparable
 returning true with ineligebile defaulted overloads" (#97002)

This reverts commit 567b2c608c307c097315dd5ec4d6a5bbcddf898d.
---
 clang/docs/ReleaseNotes.rst|  5 +-
 clang/include/clang/AST/Type.h |  3 --
 clang/lib/AST/Type.cpp | 60 ---
 clang/lib/Sema/SemaExprCXX.cpp | 79 +-
 clang/test/SemaCXX/type-traits.cpp | 49 ++
 5 files changed, 131 insertions(+), 65 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index feba3c7ba8d779..5117b678b22210 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,7 +104,7 @@ ABI Changes in This Version
   ifuncs. Its purpose was to preserve backwards compatibility when the ".ifunc"
   suffix got removed from the name mangling. The alias interacts badly with
   GlobalOpt (see the issue #96197).
-  
+
 - Fixed Microsoft name mangling for auto non-type template arguments of pointer
   type for MSVC 1920+. This change resolves incompatibilities with code 
compiled
   by MSVC 1920+ but will introduce incompatibilities with code compiled by
@@ -740,6 +740,9 @@ Bug Fixes in This Version
   negatives where the analysis failed to detect unchecked access to guarded
   data.
 
+- ``__is_trivially_equality_comparable`` no longer returns true for types which
+  have a constrained defaulted comparison operator (#GH89293).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 62836ec5c63125..a98899f7f4222c 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1142,9 +1142,6 @@ class QualType {
   /// Return true if this is a trivially relocatable type.
   bool isTriviallyRelocatableType(const ASTContext &Context) const;
 
-  /// Return true if this is a trivially equality comparable type.
-  bool isTriviallyEqualityComparableType(const ASTContext &Context) const;
-
   /// Returns true if it is a class and it might be dynamic.
   bool mayBeDynamicClass() const;
 
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index d8b885870de3ac..cc535aba4936e3 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2815,66 +2815,6 @@ bool QualType::isTriviallyRelocatableType(const 
ASTContext &Context) const {
   }
 }
 
-static bool
-HasNonDeletedDefaultedEqualityComparison(const CXXRecordDecl *Decl) {
-  if (Decl->isUnion())
-return false;
-  if (Decl->isLambda())
-return Decl->isCapturelessLambda();
-
-  auto IsDefaultedOperatorEqualEqual = [&](const FunctionDecl *Function) {
-return Function->getOverloadedOperator() ==
-   OverloadedOperatorKind::OO_EqualEqual &&
-   Function->isDefaulted() && Function->getNumParams() > 0 &&
-   (Function->getParamDecl(0)->getType()->isReferenceType() ||
-Decl->isTriviallyCopyable());
-  };
-
-  if (llvm::none_of(Decl->methods(), IsDefaultedOperatorEqualEqual) &&
-  llvm::none_of(Decl->friends(), [&](const FriendDecl *Friend) {
-if (NamedDecl *ND = Friend->getFriendDecl()) {
-  return ND->isFunctionOrFunctionTemplate() &&
- IsDefaultedOperatorEqualEqual(ND->getAsFunction());
-}
-return false;
-  }))
-return false;
-
-  return llvm::all_of(Decl->bases(),
-  [](const CXXBaseSpecifier &BS) {
-if (const auto *RD = 
BS.getType()->getAsCXXRecordDecl())
-  return HasNonDeletedDefaultedEqualityComparison(RD);
-return true;
-  }) &&
- llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {
-   auto Type = FD->getType();
-   if (Type->isArrayType())
- Type = 
Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified();
-
-   if (Type->isReferenceType() || Type->isEnumeralType())
- return false;
-   if (const auto *RD = Type->getAsCXXRecordDecl())
- return HasNonDeletedDefaultedEqualityComparison(RD);
-   return true;
- });
-}
-
-bool QualType::isTriviallyEqualityComparableType(
-const ASTContext &Context) const {
-  QualType CanonicalType = getCanonicalType();
-  if (CanonicalType->isIncompleteType() || CanonicalType->isDependentType() ||
-  CanonicalType->isEnumeralType() || CanonicalType->isArrayType())
-return false;
-
-  if (const auto *RD = CanonicalType->getAsCXXRecordDecl()) {
-if (!HasNonDeletedDefaultedEqualityComparison(RD))
-  return false;
-  }
-
-  return Context.hasUnique

[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)

2024-07-06 Thread Younan Zhang via cfe-commits

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

One nit, otherwise LGTM.

Regarding the issue of attaching the constraint to a non-template function, 
pragmatically, this is just something internal to compiler, and we're still 
conforming to the standard in terms of the user's codes. So, it is probably 
fine now, given that GCC also seems to take a similar approach here.

However, let's wait another few days before merging if @zygoloid has some 
insights.

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


[clang] Reapply "[Clang] Fix __is_trivially_equality_comparable returning true with ineligebile defaulted overloads" (#97002) (PR #97894)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikolas Klauser (philnik777)


Changes

This reverts commit 567b2c608c307c097315dd5ec4d6a5bbcddf898d.


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


5 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4-1) 
- (modified) clang/include/clang/AST/Type.h (-3) 
- (modified) clang/lib/AST/Type.cpp (-60) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+78-1) 
- (modified) clang/test/SemaCXX/type-traits.cpp (+49) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index feba3c7ba8d77..5117b678b2221 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,7 +104,7 @@ ABI Changes in This Version
   ifuncs. Its purpose was to preserve backwards compatibility when the ".ifunc"
   suffix got removed from the name mangling. The alias interacts badly with
   GlobalOpt (see the issue #96197).
-  
+
 - Fixed Microsoft name mangling for auto non-type template arguments of pointer
   type for MSVC 1920+. This change resolves incompatibilities with code 
compiled
   by MSVC 1920+ but will introduce incompatibilities with code compiled by
@@ -740,6 +740,9 @@ Bug Fixes in This Version
   negatives where the analysis failed to detect unchecked access to guarded
   data.
 
+- ``__is_trivially_equality_comparable`` no longer returns true for types which
+  have a constrained defaulted comparison operator (#GH89293).
+
 Bug Fixes to Compiler Builtins
 ^^
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 62836ec5c6312..a98899f7f4222 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1142,9 +1142,6 @@ class QualType {
   /// Return true if this is a trivially relocatable type.
   bool isTriviallyRelocatableType(const ASTContext &Context) const;
 
-  /// Return true if this is a trivially equality comparable type.
-  bool isTriviallyEqualityComparableType(const ASTContext &Context) const;
-
   /// Returns true if it is a class and it might be dynamic.
   bool mayBeDynamicClass() const;
 
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index d8b885870de3a..cc535aba4936e 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2815,66 +2815,6 @@ bool QualType::isTriviallyRelocatableType(const 
ASTContext &Context) const {
   }
 }
 
-static bool
-HasNonDeletedDefaultedEqualityComparison(const CXXRecordDecl *Decl) {
-  if (Decl->isUnion())
-return false;
-  if (Decl->isLambda())
-return Decl->isCapturelessLambda();
-
-  auto IsDefaultedOperatorEqualEqual = [&](const FunctionDecl *Function) {
-return Function->getOverloadedOperator() ==
-   OverloadedOperatorKind::OO_EqualEqual &&
-   Function->isDefaulted() && Function->getNumParams() > 0 &&
-   (Function->getParamDecl(0)->getType()->isReferenceType() ||
-Decl->isTriviallyCopyable());
-  };
-
-  if (llvm::none_of(Decl->methods(), IsDefaultedOperatorEqualEqual) &&
-  llvm::none_of(Decl->friends(), [&](const FriendDecl *Friend) {
-if (NamedDecl *ND = Friend->getFriendDecl()) {
-  return ND->isFunctionOrFunctionTemplate() &&
- IsDefaultedOperatorEqualEqual(ND->getAsFunction());
-}
-return false;
-  }))
-return false;
-
-  return llvm::all_of(Decl->bases(),
-  [](const CXXBaseSpecifier &BS) {
-if (const auto *RD = 
BS.getType()->getAsCXXRecordDecl())
-  return HasNonDeletedDefaultedEqualityComparison(RD);
-return true;
-  }) &&
- llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {
-   auto Type = FD->getType();
-   if (Type->isArrayType())
- Type = 
Type->getBaseElementTypeUnsafe()->getCanonicalTypeUnqualified();
-
-   if (Type->isReferenceType() || Type->isEnumeralType())
- return false;
-   if (const auto *RD = Type->getAsCXXRecordDecl())
- return HasNonDeletedDefaultedEqualityComparison(RD);
-   return true;
- });
-}
-
-bool QualType::isTriviallyEqualityComparableType(
-const ASTContext &Context) const {
-  QualType CanonicalType = getCanonicalType();
-  if (CanonicalType->isIncompleteType() || CanonicalType->isDependentType() ||
-  CanonicalType->isEnumeralType() || CanonicalType->isArrayType())
-return false;
-
-  if (const auto *RD = CanonicalType->getAsCXXRecordDecl()) {
-if (!HasNonDeletedDefaultedEqualityComparison(RD))
-  return false;
-  }
-
-  return Context.hasUniqueObjectRepresentations(
-  CanonicalType, /*CheckIfTriviallyCopyable=*/false);
-}
-
 bool QualType::isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const {
   return !Context.getLangOpts().ObjCAutoRefCount &&
  Context.getLangOpts().ObjCWeak &&
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/

[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)

2024-07-06 Thread Younan Zhang via cfe-commits


@@ -3216,6 +3226,44 @@ void DeclareImplicitDeductionGuidesForTypeAlias(
   Guides.suppressDiagnostics();
 
   for (auto *G : Guides) {
+if (auto *DG = dyn_cast(G)) {
+  // The deduction guide is a non-template function decl, we just clone it.
+  auto *FunctionType =
+  SemaRef.Context.getTrivialTypeSourceInfo(DG->getType());
+  FunctionProtoTypeLoc FPTL =
+  FunctionType->getTypeLoc().castAs();
+
+  // Clone the parameters.
+  unsigned ProcessedParamIndex = 0;
+  for (auto *P : DG->parameters()) {

zyn0217 wrote:

nit: I think we can just use
```cpp
for (unsigned I = 0; N = DG->parameters().size(); I != N; ++I)
```

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


[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)

2024-07-06 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Simplify release notes and remove irrelevant comment (PR #96407)

2024-07-06 Thread via cfe-commits

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


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


[clang] [Sema] Fix crash in Sema::FindInstantiatedDecl (PR #96509)

2024-07-06 Thread via cfe-commits
Alejandro =?utf-8?q?=C3=81lvarez_Ayll=C3=B3n?=
Message-ID:
In-Reply-To: 


cor3ntin wrote:

Thanks for the fix; I think this makes sense. Can you provide a release note?


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


[clang] de88b2c - [Clang] Simplify release notes and remove irrelevant comment (#96407)

2024-07-06 Thread via cfe-commits

Author: Gábor Spaits
Date: 2024-07-06T15:22:51+02:00
New Revision: de88b2cb16af4bba659d0bb2ddf10bda681ec84d

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

LOG: [Clang] Simplify release notes and remove irrelevant comment (#96407)

As discussed before with @cor3ntin before
(https://github.com/llvm/llvm-project/pull/94752) here is the
simplification of the release note written for the previously mentioned
PR and the removal of a comment that is no longer useful.

(Sorry for creating this PR this late.)

Co-authored-by: Gabor Spaits 

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaInit.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 39187078d5786..edc932efd9416 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -236,9 +236,6 @@ C++20 Feature Support
    from libstdc++ to work correctly with Clang.
 
 - User defined constructors are allowed for copy-list-initialization with CTAD.
-  The example code for deduction guides for std::map in
-  (`cppreference 
`_)
-  will now work.
   (#GH62925).
 
 C++23 Feature Support

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 64e43ded0961e..41753a1661ace 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -9811,9 +9811,6 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
 // C++ [over.best.ics]p4:
 //   When [...] the constructor [...] is a candidate by
 //- [over.match.copy] (in all cases)
-// FIXME: The "second phase of [over.match.list] case can also
-// theoretically happen here, but it's not clear whether we can
-// ever have a parameter of the right type.
 if (TD) {
   SmallVector TmpInits;
   for (Expr *E : Inits)



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


[clang] [Clang] Simplify release notes and remove irrelevant comment (PR #96407)

2024-07-06 Thread Gábor Spaits via cfe-commits

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread via cfe-commits


@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   SemaRef.RebuildLambdaScopeInfo(cast(FD));
 
-  FunctionDecl *Pattern = getPatternFunctionDecl(FD);
-  if (Pattern) {
-SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+  FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+  if (!FDPattern)
+return;
 
-FunctionDecl *ParentFD = FD;
-while (ShouldAddDeclsFromParentScope) {
+  SemaRef.addInstantiatedCapturesToScope(FD, FDPattern, Scope, MLTAL);
 
-  ParentFD =
-  dyn_cast(getLambdaAwareParentOfDeclContext(ParentFD));
-  Pattern =
-  dyn_cast(getLambdaAwareParentOfDeclContext(Pattern));
+  if (!ShouldAddDeclsFromParentScope)
+return;
 
-  if (!ParentFD || !Pattern)
-break;
+  llvm::SmallVector, 4>
+  ParentInstantiations;
+  std::pair Current = {FDPattern, FD};
+  while (true) {
+Current.first = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.first));
+Current.second = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.second));

cor3ntin wrote:

Alternatively, only form the pair when emplacing in the vector.

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


[clang] [Clang] Add captures to the instantiation scope for noexcept specifiers (PR #97166)

2024-07-06 Thread via cfe-commits


@@ -60,3 +60,26 @@ template C1>> auto t3() {
 template C1>> auto t3();
 static_assert(is_same()), X>>>);
 #endif
+
+namespace GH95735 {
+
+int g(int fn) {
+  return [f = fn](auto tpl) noexcept(noexcept(f)) { return f; }(0);
+}
+
+int foo(auto... fn) {
+  // FIXME: This one hits the assertion "if the exception specification is 
dependent,
+  // then the noexcept expression should be value-dependent" in the 
constructor of
+  // FunctionProtoType.
+  // One possible solution is to update Sema::canThrow() to consider 
expressions
+  // (e.g. DeclRefExpr/FunctionParmPackExpr) involving unexpanded parameters 
as Dependent.
+  // This would effectively add an extra value-dependent flag to the noexcept 
expression.
+  // However, I'm afraid that would also cause ABI breakage.
+  // [...f = fn](auto tpl) noexcept(noexcept(f)) { return 0; }(0);

cor3ntin wrote:

Are we missing an unexpanded pack check here?

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


[clang] [Clang] Simplify release notes and remove irrelevant comment (PR #96407)

2024-07-06 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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

Here is the relevant piece of the build log for the reference:
```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
PASS: MemorySanitizer-POWERPC64LE :: stack-origin2.cpp (2429 of 2451)
PASS: MemorySanitizer-POWERPC64LE :: heap-origin.cpp (2430 of 2451)
PASS: MemorySanitizer-POWERPC64LE :: check_mem_is_initialized.cpp (2431 of 2451)
PASS: MemorySanitizer-POWERPC64LE :: use-after-free.cpp (2432 of 2451)
PASS: MemorySanitizer-POWERPC64LE :: stack-origin.cpp (2433 of 2451)
PASS: SanitizerCommon-tsan-powerpc64le-Linux :: max_allocation_size.cpp (2434 
of 2451)
PASS: MemorySanitizer-POWERPC64LE :: Linux/cmsghdr.cpp (2435 of 2451)
PASS: ThreadSanitizer-powerpc64le :: bench_threads.cpp (2436 of 2451)
PASS: MemorySanitizer-POWERPC64LE :: recover.cpp (2437 of 2451)
PASS: ScudoStandalone-Unit :: ./ScudoUnitTest-powerpc64le-Test/138/267 (2438 of 
2451)
FAIL: ThreadSanitizer-powerpc64le :: signal_reset.cpp (2439 of 2451)
 TEST 'ThreadSanitizer-powerpc64le :: signal_reset.cpp' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/./bin/clang
  --driver-mode=g++ -fsanitize=thread -Wall  -m64 -fno-function-sections   
-gline-tables-only 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../
 -std=c++11 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../
 -nostdinc++ 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_powerpc64le/include/c++/v1
 -O1 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_reset.cpp
 -o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_reset.cpp.tmp
 &&  
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_reset.cpp.tmp
 2>&1 | FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_reset.cpp
+ 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/./bin/clang
 --driver-mode=g++ -fsanitize=thread -Wall -m64 -fno-function-sections 
-gline-tables-only 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../
 -std=c++11 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../
 -nostdinc++ 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_powerpc64le/include/c++/v1
 -O1 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_reset.cpp
 -o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_reset.cpp.tmp
+ 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_reset.cpp.tmp
+ FileCheck 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_reset.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_reset.cpp:73:15:
 error: CHECK-NOT: excluded string found in input
// CHECK-NOT: WARNING: ThreadSanitizer:
  ^
:2:1: note: found here
WARNING: ThreadSanitizer: signal handler spoils errno (pid=1726010)
^

Input file: 
Check file: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_reset.cpp

-dump-input=help explains the following input dump.

Input was:
<<
1: == 
2: WARNING: ThreadSanitizer: signal handler spoils errno (pid=1726010) 
not:73 !  

[clang] [Clang] Add captures to the instantiation scope for noexcept specifiers (PR #97166)

2024-07-06 Thread via cfe-commits

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

LGTM, thanks!
I think your fixme can be resolved in a follow up PR

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


[clang] clang: Relax LangOpts checks when lexing quoted numbers during preprocessing (PR #95798)

2024-07-06 Thread via cfe-commits


@@ -2068,7 +2068,8 @@ bool Lexer::LexNumericConstant(Token &Result, const char 
*CurPtr) {
   }
 
   // If we have a digit separator, continue.
-  if (C == '\'' && (LangOpts.CPlusPlus14 || LangOpts.C23)) {
+  if (C == '\'' &&
+  (LangOpts.CPlusPlus14 || LangOpts.C23 || ParsingPreprocessorDirective)) {

cor3ntin wrote:

Can we introduce a `ScanningDependencies` flag somewhere (in `LangOpts`) ? that 
seems to covber the feedback in the previous PR and would let us handle future 
such cases

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


[clang] [Clang] [C23] Implement N2653: u8 strings are char8_t[] (PR #97208)

2024-07-06 Thread via cfe-commits


@@ -1165,6 +1165,8 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   DefineType("__WCHAR_TYPE__", TI.getWCharType(), Builder);
   DefineType("__WINT_TYPE__", TI.getWIntType(), Builder);
   DefineTypeSizeAndWidth("__SIG_ATOMIC", TI.getSigAtomicType(), TI, Builder);
+  if (LangOpts.Char8 || LangOpts.C23)
+DefineType("__CHAR8_TYPE__", TI.UnsignedChar, Builder);

cor3ntin wrote:

I'm certainly concerned with the impact of that in C++. It should not be 
defined in C++ (ie, char9_t is not unsigned char in C++)

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


[clang] [clang][Sema] Improve `Sema::CheckCXXDefaultArguments` (PR #97338)

2024-07-06 Thread via cfe-commits

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


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


[clang] Support `guarded_by` attribute and related attributes inside C structs and support late parsing them (PR #95455)

2024-07-06 Thread Pierre d'Herbemont via cfe-commits

pdherbemont wrote:

> LGTM. Let me know if you need me to merge this change.

Yes, please!

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


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

2024-07-06 Thread via cfe-commits

cor3ntin wrote:

> Thank you work on this! I really like this feature. Will this PR also provide 
> support for the new constant interpreter? The new constant interpreter seems 
> to already support some unknown constexpr features (FYI 
> https://godbolt.org/z/xTYhGEfxT). It has the concept of `DummyValue`.

I think that can be a separate PR @tbaederr 

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


[clang] [Clang] prevent checking destructor reference with an invalid initializer (PR #97860)

2024-07-06 Thread Oleksandr T. via cfe-commits

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

>From cb3c677c9eb10998ed7357cdde2722f3b3c1c847 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 6 Jul 2024 00:24:06 +0300
Subject: [PATCH] [Clang] prevent checking destructor reference with an invalid
 initializer

---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/lib/Sema/SemaInit.cpp   | 3 +++
 clang/test/SemaCXX/destructor.cpp | 9 +
 3 files changed, 13 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 36cf615a4287c..b85490376c848 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -963,6 +963,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure about invalid conversion when calling lambda. 
(#GH96205).
 - Fixed a bug where the first operand of binary ``operator&`` would be 
transformed as if it was the operand
   of the address of operator. (#GH97483).
+- Fix a crash when checking destructor reference with an invalid initializer. 
(#GH97230).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 64e43ded0961e..aa003c60b25ee 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -1986,6 +1986,9 @@ static bool checkDestructorReference(QualType 
ElementType, SourceLocation Loc,
 return false;
 
   CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(CXXRD);
+  if (!Destructor)
+return false;
+
   SemaRef.CheckDestructorAccess(Loc, Destructor,
 SemaRef.PDiag(diag::err_access_dtor_temp)
 << ElementType);
diff --git a/clang/test/SemaCXX/destructor.cpp 
b/clang/test/SemaCXX/destructor.cpp
index 028bc7cc19698..dfcd1b033af5a 100644
--- a/clang/test/SemaCXX/destructor.cpp
+++ b/clang/test/SemaCXX/destructor.cpp
@@ -577,4 +577,13 @@ static_assert(!__is_trivially_constructible(Foo, const Foo 
&), "");
 static_assert(!__is_trivially_constructible(Foo, Foo &&), "");
 } // namespace GH89544
 
+namespace GH97230 {
+struct X {
+  ~X() = defaul; // expected-error {{initializer on function does not look 
like a pure-specifier}} \
+ // expected-error {{use of undeclared identifier 'defaul'}}
+};
+struct Y : X {} y1{ }; // expected-error {{call to implicitly-deleted default 
constructor of 'struct Y'}} \
+   // expected-note {{default constructor of 'Y' is 
implicitly deleted because base class 'X' has no destructor}}
+}
+
 #endif // BE_THE_HEADER

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


[clang] [Clang] fix cast failures by adjusting the resolution of record declaration contexts to handle semantic and lexical distinctions (PR #96228)

2024-07-06 Thread Oleksandr T. via cfe-commits

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

>From 9e2730da07df0ee5102912490a687ba40bf06def Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 24 Jun 2024 18:55:51 +0300
Subject: [PATCH] [Clang] fix cast failures by adjusting the resolution of
 record declaration contexts to handle semantic and lexical distinctions

---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaDeclCXX.cpp |  5 -
 .../class.compare/class.compare.default/p1.cpp | 18 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index df579ae398c5ef..86bd8cf4a6210b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -934,6 +934,7 @@ Bug Fixes to C++ Support
 - Fix an assertion failure caused by parsing a lambda used as a default 
argument for the value of a
   forward-declared class. (#GH93512).
 - Fixed a bug in access checking inside return-type-requirement of compound 
requirements. (#GH93788).
+- Fixed failed assertion when resolving context of defaulted comparison method 
outside of struct. (#GH96043).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 9b220103247dd0..0ecad756d44999 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9192,7 +9192,10 @@ ComputeDefaultedComparisonExceptionSpec(Sema &S, 
SourceLocation Loc,
 EnterExpressionEvaluationContext Context(
 S, Sema::ExpressionEvaluationContext::Unevaluated);
 
-CXXRecordDecl *RD = cast(FD->getLexicalParent());
+CXXRecordDecl *RD =
+cast(FD->getFriendObjectKind() == Decl::FOK_None
+? FD->getDeclContext()
+: FD->getLexicalDeclContext());
 SourceLocation BodyLoc =
 FD->getEndLoc().isValid() ? FD->getEndLoc() : FD->getLocation();
 StmtResult Body =
diff --git a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp 
b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
index 252860bfc4de07..ddf82f432c2eab 100644
--- a/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -265,3 +265,21 @@ void f2() {
// access info for unnamed bit-field
 }
 }
+
+namespace GH96043 {
+template  class a {};
+template  b c(a);
+template  class e {
+public:
+  typedef a f;
+  f begin();
+};
+template  constexpr bool operator==(d h, g i) {
+  return *c(h.begin()) == *c(i.begin());
+}
+struct j {
+  e bar;
+  bool operator==(const j &) const;
+};
+bool j::operator==(const j &) const = default;
+}

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


[clang] e55585f - [Clang] Fix typo in cxx_status.html

2024-07-06 Thread via cfe-commits

Author: cor3ntin
Date: 2024-07-06T16:18:20+02:00
New Revision: e55585fd7bddf5bb3824a53cbe2971206d3c20c6

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

LOG: [Clang] Fix typo in cxx_status.html

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 0c013e6d7cb58..27e2213e54caa 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -213,7 +213,7 @@ C++2c implementation status
  
   Deleting a Pointer to an Incomplete Type Should be Ill-formed
   https://wg21.link/P3144";>P3144R2
-  Clang 19
+  Clang 19
  
  
   Ordering of constraints involving fold expressions



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


[clang] [Clang] [C23] Implement N2653: u8 strings are char8_t[] (PR #97208)

2024-07-06 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/97208

>From ef0072d1fc9b14f7ee657fa95f44a686b78b525a Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Sun, 30 Jun 2024 12:07:54 +0100
Subject: [PATCH 1/6] [Clang] [C23] Implement N2653: u8 strings are char8_t[]

---
 clang/docs/ReleaseNotes.rst   |  6 
 .../clang/Basic/DiagnosticSemaKinds.td|  5 +++-
 clang/lib/Frontend/InitPreprocessor.cpp   |  6 ++--
 clang/lib/Headers/stdatomic.h |  5 
 clang/lib/Sema/SemaExpr.cpp   | 23 ++-
 clang/test/C/C2x/n2653.c  | 29 +++
 clang/www/c_status.html   |  2 +-
 7 files changed, 65 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/C/C2x/n2653.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c720e47dbe35b..e51be81d8b11a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -337,6 +337,12 @@ C23 Feature Support
 - Properly promote bit-fields of bit-precise integer types to the field's type
   rather than to ``int``. #GH87641
 
+- Compiler support for `N2653 char8_t: A type for UTF-8 characters and strings`
+  `_: ``u8`` string
+  literals are now of type ``char8_t[N]`` in C23 and expose
+  ``__CLANG_ATOMIC_CHAR8_T_LOCK_FREE``/``__GCC_ATOMIC_CHAR8_T_LOCK_FREE`` to
+  implement the corresponding macro in .
+
 Non-comprehensive list of changes in this release
 -
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5dc36c594bcb7..6a00b92df1c36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7252,7 +7252,10 @@ def err_array_init_utf8_string_into_char : Error<
 def warn_cxx20_compat_utf8_string : Warning<
   "type of UTF-8 string literal will change from array of const char to "
   "array of const char8_t in C++20">, InGroup, DefaultIgnore;
-def note_cxx20_compat_utf8_string_remove_u8 : Note<
+def warn_c23_compat_utf8_string : Warning<
+  "type of UTF-8 string literal will change from array of char to "
+  "array of char8_t in C23">, InGroup, DefaultIgnore;
+def note_cxx20_c23_compat_utf8_string_remove_u8 : Note<
   "remove 'u8' prefix to avoid a change of behavior; "
   "Clang encodes unprefixed narrow string literals as UTF-8">;
 def err_array_init_different_type : Error<
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 55ec460064830..6270c37342bcf 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1342,8 +1342,10 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   getLockFreeValue(TI.get##Type##Width(), TI));
 DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
 DEFINE_LOCK_FREE_MACRO(CHAR, Char);
-if (LangOpts.Char8)
-  DEFINE_LOCK_FREE_MACRO(CHAR8_T, Char); // Treat char8_t like char.
+// char8_t has the same representation / width as unsigned
+// char in C++ and is a typedef for unsigned char in C23
+if (LangOpts.Char8 || LangOpts.C23)
+  DEFINE_LOCK_FREE_MACRO(CHAR8_T, Char);
 DEFINE_LOCK_FREE_MACRO(CHAR16_T, Char16);
 DEFINE_LOCK_FREE_MACRO(CHAR32_T, Char32);
 DEFINE_LOCK_FREE_MACRO(WCHAR_T, WChar);
diff --git a/clang/lib/Headers/stdatomic.h b/clang/lib/Headers/stdatomic.h
index 9c103d98af8c5..c33cd8083525c 100644
--- a/clang/lib/Headers/stdatomic.h
+++ b/clang/lib/Headers/stdatomic.h
@@ -35,6 +35,10 @@ extern "C" {
 
 #define ATOMIC_BOOL_LOCK_FREE   __CLANG_ATOMIC_BOOL_LOCK_FREE
 #define ATOMIC_CHAR_LOCK_FREE   __CLANG_ATOMIC_CHAR_LOCK_FREE
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) ||  
\
+defined(__cplusplus)
+#define ATOMIC_CHAR8_T_LOCK_FREE__CLANG_ATOMIC_CHAR8_T_LOCK_FREE
+#endif
 #define ATOMIC_CHAR16_T_LOCK_FREE   __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
 #define ATOMIC_CHAR32_T_LOCK_FREE   __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
 #define ATOMIC_WCHAR_T_LOCK_FREE__CLANG_ATOMIC_WCHAR_T_LOCK_FREE
@@ -104,6 +108,7 @@ typedef _Atomic(long)   atomic_long;
 typedef _Atomic(unsigned long)  atomic_ulong;
 typedef _Atomic(long long)  atomic_llong;
 typedef _Atomic(unsigned long long) atomic_ullong;
+typedef _Atomic(unsigned char)  atomic_char8_t;
 typedef _Atomic(uint_least16_t) atomic_char16_t;
 typedef _Atomic(uint_least32_t) atomic_char32_t;
 typedef _Atomic(wchar_t)atomic_wchar_t;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index db44cfe1288b6..a1b060f7f1510 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2082,6 +2082,8 @@ Sema::ActOnStringLiteral(ArrayRef StringToks, 
Scope *UDLScope) {
   } else if (Literal.isUTF8()) {
 if

[clang] Adds an arbitrary pseudonym to clang"s windows mangler... (PR #97792)

2024-07-06 Thread via cfe-commits

memory-thrasher wrote:

> Godbolt for reference: https://godbolt.org/z/b9v8KhPET

Huh. Must be my vstools install on this windows laptop is out of date or broken 
in some other way. I could copy the scheme in that use case into my PR for at 
least a non-zero chance that it would match the msvc mangler in all other 
instances triggering that if. I must say that the thought of digging through 
the msvc binary to get a comprehensive handling does not feel me with 
excitement.

> likely with a new triple

I love the idea of another triple though. I would of course be using itanium if 
interfacing with system resources was not impossible. I'm thinking of two 
possible interpretations of a hybrid triple:
* msvc for all non-templates, itanium for all templates. Also causes any 
explicit extern template instances to be ignored to prevent the already remote 
possibility that a specialization or instance could be provided by a library 
(which would of course be mangled msvc-style).
* an `__attribute__ ` or other intrinsic to specify (in a header file) that an 
alternate mangler is to be used for the single connected symbol. As much as I 
hate the idea of compiler-specific code features, sometimes they are the right 
answer.

I prefer the former.

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


[clang] [InstallAPI] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/97900

This patch addresses a static analyser concern about a potential null pointer 
dereference in the clang::installapi::enumerateFiles function.

The recursive_directory_iterator could become invalid (i.e., i.State set to 
nullptr) when iterating over files.

We now check the validity of the iterator before dereferencing it and handle 
possible errors from FS.status. This fix ensures safe iteration over the 
directory entries and prevents crashes due to undefined behavior.

>From dd36ef6dd52f57d175fd60534172f0e28e11ef48 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 08:29:26 -0700
Subject: [PATCH] [InstallAPI] Fix potential null pointer dereference in file
 enumeration

This patch addresses a static analyser concern about a potential null pointer
dereference in the clang::installapi::enumerateFiles function.

The recursive_directory_iterator could become invalid (i.e., i.State set to 
nullptr)
when iterating over files.

We now check the validity of the iterator before dereferencing it and handle 
possible
errors from FS.status. This fix ensures safe iteration over the directory 
entries and
prevents crashes due to undefined behavior.
---
 clang/lib/InstallAPI/HeaderFile.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index 0b7041ec8147eb..f25bf3428ee13a 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,8 +51,13 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
+Ensure the iterator is valid before dereferencing.
+if (i == ie || !i->isValid())
+  break;
+
 // Skip files that do not exist. This usually happens for broken symlinks.
-if (FS.status(i->path()) == std::errc::no_such_file_or_directory)
+auto StatusOrErr = FS.status(i->path());
+if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

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


[clang] [InstallAPI] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (smanna12)


Changes

This patch addresses a static analyser concern about a potential null pointer 
dereference in the clang::installapi::enumerateFiles function.

The recursive_directory_iterator could become invalid (i.e., i.State set to 
nullptr) when iterating over files.

We now check the validity of the iterator before dereferencing it and handle 
possible errors from FS.status. This fix ensures safe iteration over the 
directory entries and prevents crashes due to undefined behavior.

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


1 Files Affected:

- (modified) clang/lib/InstallAPI/HeaderFile.cpp (+6-1) 


``diff
diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index 0b7041ec8147e..f25bf3428ee13 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,8 +51,13 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
+Ensure the iterator is valid before dereferencing.
+if (i == ie || !i->isValid())
+  break;
+
 // Skip files that do not exist. This usually happens for broken symlinks.
-if (FS.status(i->path()) == std::errc::no_such_file_or_directory)
+auto StatusOrErr = FS.status(i->path());
+if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

``




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


[clang] [[clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

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


[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

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


[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 9e9404387d3b787305dc8bf21b0e20c477b6ff39 
dd36ef6dd52f57d175fd60534172f0e28e11ef48 -- clang/lib/InstallAPI/HeaderFile.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index f25bf3428e..f6101d6b7c 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,13 +51,13 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
-Ensure the iterator is valid before dereferencing.
-if (i == ie || !i->isValid())
-  break;
+Ensure the iterator is valid before dereferencing.if (i == ie ||
+  !i->isValid()) break;
 
 // Skip files that do not exist. This usually happens for broken symlinks.
 auto StatusOrErr = FS.status(i->path());
-if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
+if (!StatusOrErr ||
+StatusOrErr.getError() == std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

``




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


[clang] Adds an arbitrary pseudonym to clang"s windows mangler... (PR #97792)

2024-07-06 Thread via cfe-commits

https://github.com/memory-thrasher updated 
https://github.com/llvm/llvm-project/pull/97792

>From 9f909ffb4714294d62264e541a44137adfcd7cb9 Mon Sep 17 00:00:00 2001
From: Sidney Kelley 
Date: Thu, 4 Jul 2024 23:03:16 -0700
Subject: [PATCH] Adds an arbitrary pseudonym to clang"s windows mangler to
 handle template argument values that are pointers one-past-the-end of a
 non-array symbol. Also improves error messages in other template argument
 scenarios where clang bails.

---
 clang/lib/AST/MicrosoftMangle.cpp | 64 ++-
 .../CodeGen/ms_mangler_templatearg_opte.cpp   | 47 ++
 2 files changed, 96 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/CodeGen/ms_mangler_templatearg_opte.cpp

diff --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index fac14ce1dce8ce..2c5b0e8d7a66ef 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -1922,11 +1922,19 @@ void 
MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
 if (WithScalarType)
   mangleType(T, SourceRange(), QMM_Escape);
 
-// We don't know how to mangle past-the-end pointers yet.
-if (V.isLValueOnePastTheEnd())
-  break;
-
 APValue::LValueBase Base = V.getLValueBase();
+
+// this might not cover every case but did cover issue 97756
+// see test CodeGen/ms_mangler_templatearg_opte
+if (V.isLValueOnePastTheEnd()) {
+  Out << "5E";
+  auto *VD = Base.dyn_cast();
+  if (VD)
+mangle(VD);
+  Out << "@";
+  return;
+}
+
 if (!V.hasLValuePath() || V.getLValuePath().empty()) {
   // Taking the address of a complete object has a special-case mangling.
   if (Base.isNull()) {
@@ -1938,12 +1946,23 @@ void 
MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
 mangleNumber(V.getLValueOffset().getQuantity());
   } else if (!V.hasLValuePath()) {
 // FIXME: This can only happen as an extension. Invent a mangling.
-break;
+DiagnosticsEngine &Diags = Context.getDiags();
+unsigned DiagID =
+Diags.getCustomDiagID(DiagnosticsEngine::Error,
+  "cannot mangle this template argument yet "
+  "(non-null base with null lvalue path)");
+Diags.Report(DiagID);
+return;
   } else if (auto *VD = Base.dyn_cast()) {
 Out << "E";
 mangle(VD);
   } else {
-break;
+DiagnosticsEngine &Diags = Context.getDiags();
+unsigned DiagID = Diags.getCustomDiagID(
+DiagnosticsEngine::Error,
+"cannot mangle this template argument yet (empty lvalue path)");
+Diags.Report(DiagID);
+return;
   }
 } else {
   if (TAK == TplArgKind::ClassNTTP && T->isPointerType())
@@ -1988,8 +2007,14 @@ void 
MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
 Out << *I;
 
   auto *VD = Base.dyn_cast();
-  if (!VD)
-break;
+  if (!VD) {
+DiagnosticsEngine &Diags = Context.getDiags();
+unsigned DiagID = Diags.getCustomDiagID(
+DiagnosticsEngine::Error,
+"cannot mangle this template argument yet (null value decl)");
+Diags.Report(DiagID);
+return;
+  }
   Out << (TAK == TplArgKind::ClassNTTP ? 'E' : '1');
   mangle(VD);
 
@@ -2104,15 +2129,24 @@ void 
MicrosoftCXXNameMangler::mangleTemplateArgValue(QualType T,
 return;
   }
 
-  case APValue::AddrLabelDiff:
-  case APValue::FixedPoint:
-break;
+  case APValue::AddrLabelDiff: {
+DiagnosticsEngine &Diags = Context.getDiags();
+unsigned DiagID = Diags.getCustomDiagID(
+DiagnosticsEngine::Error, "cannot mangle this template argument yet "
+  "(value type: address label diff)");
+Diags.Report(DiagID);
+return;
   }
 
-  DiagnosticsEngine &Diags = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(
-  DiagnosticsEngine::Error, "cannot mangle this template argument yet");
-  Diags.Report(DiagID);
+  case APValue::FixedPoint: {
+DiagnosticsEngine &Diags = Context.getDiags();
+unsigned DiagID = Diags.getCustomDiagID(
+DiagnosticsEngine::Error,
+"cannot mangle this template argument yet (value type: fixed point)");
+Diags.Report(DiagID);
+return;
+  }
+  }
 }
 
 void MicrosoftCXXNameMangler::mangleObjCProtocol(const ObjCProtocolDecl *PD) {
diff --git a/clang/test/CodeGen/ms_mangler_templatearg_opte.cpp 
b/clang/test/CodeGen/ms_mangler_templatearg_opte.cpp
new file mode 100644
index 00..66fe6aa2c04c24
--- /dev/null
+++ b/clang/test/CodeGen/ms_mangler_templatearg_opte.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -std=c++20 -x c++ 
< %s | FileCheck -check-prefix=WIN64 %s
+
+/*
+
+This works (linux host):
+clang++ -std=c++20 -c ms_mangler_templatearg_opte.cpp -o /dev/null
+
+Before this cas

[clang] Adds an arbitrary pseudonym to clang"s windows mangler... (PR #97792)

2024-07-06 Thread via cfe-commits

memory-thrasher wrote:

PR updated to output mangled function name matching the one from godbolt for 
this specific use case. I suggest someone better at this stuff than me should 
eventually attempt to implement a more comprehensive mimicry.

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


[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 updated 
https://github.com/llvm/llvm-project/pull/97900

>From dd36ef6dd52f57d175fd60534172f0e28e11ef48 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 08:29:26 -0700
Subject: [PATCH 1/2] [InstallAPI] Fix potential null pointer dereference in
 file enumeration

This patch addresses a static analyser concern about a potential null pointer
dereference in the clang::installapi::enumerateFiles function.

The recursive_directory_iterator could become invalid (i.e., i.State set to 
nullptr)
when iterating over files.

We now check the validity of the iterator before dereferencing it and handle 
possible
errors from FS.status. This fix ensures safe iteration over the directory 
entries and
prevents crashes due to undefined behavior.
---
 clang/lib/InstallAPI/HeaderFile.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index 0b7041ec8147e..f25bf3428ee13 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,8 +51,13 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
+Ensure the iterator is valid before dereferencing.
+if (i == ie || !i->isValid())
+  break;
+
 // Skip files that do not exist. This usually happens for broken symlinks.
-if (FS.status(i->path()) == std::errc::no_such_file_or_directory)
+auto StatusOrErr = FS.status(i->path());
+if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

>From fe68a4ec84e02df7ecba701bcd7f3508ff8e85f7 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 08:54:32 -0700
Subject: [PATCH 2/2] Fix clang format errors

---
 clang/lib/InstallAPI/HeaderFile.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index f25bf3428ee13..d69b2ada27e9f 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,13 +51,14 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
-Ensure the iterator is valid before dereferencing.
+// Ensure the iterator is valid before dereferencing.
 if (i == ie || !i->isValid())
   break;
 
 // Skip files that do not exist. This usually happens for broken symlinks.
 auto StatusOrErr = FS.status(i->path());
-if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
+if (!StatusOrErr ||
+StatusOrErr.getError() == std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

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


[clang] [Clang] Remove unnecessary copy (PR #97902)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/97902

Reported by Static Analyzer Tool:

In clang::ASTNodeImporter::VisitCountAttributedType(clang::CountAttributedType 
const *): Using the auto keyword without an & causes the copy of an object of 
type TypeCoupledDeclRefInfo

>From 1f80c0a172b58ad15d6b1dce02b63ac682bc7dc0 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 09:03:15 -0700
Subject: [PATCH] [Clang] Remove unnecessary copy

Reported by Static Analyzer Tool:

In clang::ASTNodeImporter::VisitCountAttributedType(clang::CountAttributedType 
const *): Using the auto keyword without an & causes the copy of an object of 
type TypeCoupledDeclRefInfo
---
 clang/lib/AST/ASTImporter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 4e1b3a5a94de7..0c27f6f5df2da 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1551,7 +1551,7 @@ ASTNodeImporter::VisitCountAttributedType(const 
CountAttributedType *T) {
   Expr *CountExpr = importChecked(Err, T->getCountExpr());
 
   SmallVector CoupledDecls;
-  for (auto TI : T->dependent_decls()) {
+  for (const TypeCoupledDeclRefInfo &TI : T->dependent_decls()) {
 Expected ToDeclOrErr = import(TI.getDecl());
 if (!ToDeclOrErr)
   return ToDeclOrErr.takeError();

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


[clang] [Clang] Remove unnecessary copy (PR #97902)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (smanna12)


Changes

Reported by Static Analyzer Tool:

In clang::ASTNodeImporter::VisitCountAttributedType(clang::CountAttributedType 
const *): Using the auto keyword without an & causes the copy of an object 
of type TypeCoupledDeclRefInfo

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


1 Files Affected:

- (modified) clang/lib/AST/ASTImporter.cpp (+1-1) 


``diff
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 4e1b3a5a94de7..0c27f6f5df2da 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1551,7 +1551,7 @@ ASTNodeImporter::VisitCountAttributedType(const 
CountAttributedType *T) {
   Expr *CountExpr = importChecked(Err, T->getCountExpr());
 
   SmallVector CoupledDecls;
-  for (auto TI : T->dependent_decls()) {
+  for (const TypeCoupledDeclRefInfo &TI : T->dependent_decls()) {
 Expected ToDeclOrErr = import(TI.getDecl());
 if (!ToDeclOrErr)
   return ToDeclOrErr.takeError();

``




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


[clang] [clang-installapi] ] Fix potential null pointer dereference in file enumeration (PR #97900)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 updated 
https://github.com/llvm/llvm-project/pull/97900

>From dd36ef6dd52f57d175fd60534172f0e28e11ef48 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 08:29:26 -0700
Subject: [PATCH 1/3] [InstallAPI] Fix potential null pointer dereference in
 file enumeration

This patch addresses a static analyser concern about a potential null pointer
dereference in the clang::installapi::enumerateFiles function.

The recursive_directory_iterator could become invalid (i.e., i.State set to 
nullptr)
when iterating over files.

We now check the validity of the iterator before dereferencing it and handle 
possible
errors from FS.status. This fix ensures safe iteration over the directory 
entries and
prevents crashes due to undefined behavior.
---
 clang/lib/InstallAPI/HeaderFile.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index 0b7041ec8147e..f25bf3428ee13 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,8 +51,13 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
+Ensure the iterator is valid before dereferencing.
+if (i == ie || !i->isValid())
+  break;
+
 // Skip files that do not exist. This usually happens for broken symlinks.
-if (FS.status(i->path()) == std::errc::no_such_file_or_directory)
+auto StatusOrErr = FS.status(i->path());
+if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

>From fe68a4ec84e02df7ecba701bcd7f3508ff8e85f7 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 08:54:32 -0700
Subject: [PATCH 2/3] Fix clang format errors

---
 clang/lib/InstallAPI/HeaderFile.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index f25bf3428ee13..d69b2ada27e9f 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -51,13 +51,14 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
 if (EC)
   return errorCodeToError(EC);
 
-Ensure the iterator is valid before dereferencing.
+// Ensure the iterator is valid before dereferencing.
 if (i == ie || !i->isValid())
   break;
 
 // Skip files that do not exist. This usually happens for broken symlinks.
 auto StatusOrErr = FS.status(i->path());
-if (!StatusOrErr || StatusOrErr.getError() == 
std::errc::no_such_file_or_directory)
+if (!StatusOrErr ||
+StatusOrErr.getError() == std::errc::no_such_file_or_directory)
   continue;
 
 StringRef Path = i->path();

>From 8623cacdbc76060d35be3d20322aebb008b95eb3 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 09:08:37 -0700
Subject: [PATCH 3/3] Fix build error

---
 clang/lib/InstallAPI/HeaderFile.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/InstallAPI/HeaderFile.cpp 
b/clang/lib/InstallAPI/HeaderFile.cpp
index d69b2ada27e9f..5e00f6e14b554 100644
--- a/clang/lib/InstallAPI/HeaderFile.cpp
+++ b/clang/lib/InstallAPI/HeaderFile.cpp
@@ -52,7 +52,7 @@ llvm::Expected enumerateFiles(FileManager &FM, 
StringRef Directory) {
   return errorCodeToError(EC);
 
 // Ensure the iterator is valid before dereferencing.
-if (i == ie || !i->isValid())
+if (i == ie)
   break;
 
 // Skip files that do not exist. This usually happens for broken symlinks.

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


[clang] [llvm] [ValueTracking] use KnownBits to compute fpclass from bitcast (PR #97762)

2024-07-06 Thread Alex MacLean via cfe-commits

AlexMaclean wrote:

> Can you add some tests to demonstrate that this patch will enable more 
> optimizations in some real-world applications?

I can extend the existing test cases to make them more elaborate/real-looking, 
but I'm guessing that would not qualify as "real-world". This patch is 
motivated by an internal benchmark where there were some cases where this 
helped, though even that case is in some sense artificial. Is this a necessary 
criteria for landing this change? I believe we already handle float to int in 
KnownBits and adding the inverse in KnownFPClass seems like a correct and 
reasonable extension of the logic, even if there are not many cases where it is 
used.

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits

https://github.com/cor3ntin commented:

I think this is starting to look pretty good.

Can we simplify further by lexing the partition along with the module name, 
when there is one? 
We could also have a ModuleNameInfo::toString() function we could use in a 
couple places.

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits


@@ -741,6 +757,9 @@ class IdentifierTable {
 if (Name == "import")
   II->setModulesImport(true);
 
+if (Name == "module")

cor3ntin wrote:

```suggestion
   else if (Name == "module")
```

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits


@@ -160,6 +160,8 @@ static char GetFirstChar(const Preprocessor &PP, const 
Token &Tok) {
 bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok,
  const Token &PrevTok,
  const Token &Tok) const {
+  if (PrevTok.is(tok::annot_module_name))
+return false;

cor3ntin wrote:

can you explain this change?

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits


@@ -35,6 +35,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TokenKinds.h"

cor3ntin wrote:

I don't think we need that change

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits


@@ -905,6 +912,7 @@ void Preprocessor::Lex(Token &Result) {
 // This token is injected to represent the translation of '#include "a.h"'
 // into "import a.h;". Mimic the notional ';'.
 case tok::annot_module_include:
+case tok::annot_repl_input_end:

cor3ntin wrote:

Can you explain this change?

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-07-06 Thread via cfe-commits


@@ -860,9 +861,15 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) {
 ModuleImportLoc = Identifier.getLocation();
 NamedModuleImportPath.clear();
 IsAtImport = true;
-ModuleImportExpectsIdentifier = true;
 CurLexerCallback = CLK_LexAfterModuleImport;
   }
+
+  if ((II.isModulesDeclaration() || Identifier.is(tok::kw_module)) &&
+  !InMacroArgs && !DisableMacroExpansion &&
+  (getLangOpts().CPlusPlusModules || getLangOpts().DebuggerSupport) &&

cor3ntin wrote:

Remind me why we should parse modules in "DebuggerSupport" mode?

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


[clang] Enable aarch64-amazon-linux triple (PR #82232)

2024-07-06 Thread Fangrui Song via cfe-commits

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


[clang] Enable aarch64-amazon-linux triple (PR #82232)

2024-07-06 Thread Fangrui Song via cfe-commits

MaskRay wrote:

> I'm not the owner of this code, but I just dropped by to say that I don't 
> think this patch will be accepted. A few lines above your changes, there is a 
> comment that says, "Please don't add more elements to *Triples.".
> 
> @MaskRay is working to reduce the number of target triples like 
> [20d497c](https://github.com/llvm/llvm-project/commit/20d497c26fc95c80a1bacb38820d92e5f52bec58)
>  and I think this patch goes against his goals.

Thanks for the explanation!

That Apple issue tracker has some discussions. 
`LLVM_DEFAULT_TARGET_TRIPLE=aarch64-amazon-linux` shall work. We should not add 
new elements.

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


[libunwind] [libunwind] fix unwinding from signal handler (PR #92291)

2024-07-06 Thread Saleem Abdulrasool via cfe-commits


@@ -365,7 +365,12 @@ int DwarfInstructions::stepWithDwarf(A 
&addressSpace, pint_t pc,
 
   // Return address is address after call site instruction, so setting IP 
to
   // that does simulates a return.
-  newRegisters.setIP(returnAddress);
+  //
+  // In case of this is frame of signal handler, the IP should be
+  // incremented, because the IP saved in the signal handler points to
+  // first non-executed instruction, while FDE/CIE expects IP to be after
+  // the first non-executed instruction.
+  newRegisters.setIP(returnAddress + cieInfo.isSignalFrame);

compnerd wrote:

Could the register state not being used for anything else in between and thus 
be misleading?

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


[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Yupei Liu via cfe-commits

https://github.com/LYP951018 updated 
https://github.com/llvm/llvm-project/pull/97215

>From a997ae70f86230200b1082c9bdc0bdf56e30b7c4 Mon Sep 17 00:00:00 2001
From: letrec 
Date: Sun, 30 Jun 2024 21:03:23 +0800
Subject: [PATCH 1/2] Fix the order of addInstantiatedParameters in
 LambdaScopeForCallOperatorInstantiationRAII.

---
 clang/lib/Sema/SemaLambda.cpp   | 37 +
 clang/test/SemaTemplate/concepts-lambda.cpp | 14 
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca9c7cb9faadf..b6344f53861f4 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   SemaRef.RebuildLambdaScopeInfo(cast(FD));
 
-  FunctionDecl *Pattern = getPatternFunctionDecl(FD);
-  if (Pattern) {
-SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+  FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+  if (!FDPattern)
+return;
 
-FunctionDecl *ParentFD = FD;
-while (ShouldAddDeclsFromParentScope) {
+  SemaRef.addInstantiatedCapturesToScope(FD, FDPattern, Scope, MLTAL);
 
-  ParentFD =
-  dyn_cast(getLambdaAwareParentOfDeclContext(ParentFD));
-  Pattern =
-  dyn_cast(getLambdaAwareParentOfDeclContext(Pattern));
+  if (!ShouldAddDeclsFromParentScope)
+return;
 
-  if (!ParentFD || !Pattern)
-break;
+  llvm::SmallVector, 4>
+  ParentInstantiations;
+  std::pair Current = {FDPattern, FD};
+  while (true) {
+Current.first = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.first));
+Current.second = dyn_cast(
+getLambdaAwareParentOfDeclContext(Current.second));
 
-  SemaRef.addInstantiatedParametersToScope(ParentFD, Pattern, Scope, 
MLTAL);
-  SemaRef.addInstantiatedLocalVarsToScope(ParentFD, Pattern, Scope);
-}
+if (!Current.first || !Current.second)
+  break;
+
+ParentInstantiations.push_back(Current);
+  }
+
+  for (const auto &[Pattern, Inst] : llvm::reverse(ParentInstantiations)) {
+SemaRef.addInstantiatedParametersToScope(Inst, Pattern, Scope, MLTAL);
+SemaRef.addInstantiatedLocalVarsToScope(Inst, Pattern, Scope);
   }
 }
diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
index 280be71284f97..252ef08549a48 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -237,3 +237,17 @@ concept D = []() { return true; }();
 D auto x = 0;
 
 } // namespace GH93821
+
+namespace dependent_param_concept {
+template  void sink(Ts...) {}
+void dependent_param() {
+  auto L = [](auto... x) {
+return [](decltype(x)... y) {
+  return [](int z)
+requires requires { sink(y..., z); }
+  {};
+};
+  };
+  L(0, 1)(1, 2)(1);
+}
+} // namespace dependent_param_concept

>From 85730ed7829d0a327e9b9ba9efa95e0b6dce9761 Mon Sep 17 00:00:00 2001
From: letrec 
Date: Sun, 7 Jul 2024 02:27:53 +0800
Subject: [PATCH 2/2] CR comments

---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaLambda.cpp | 25 +++--
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c720e47dbe35b..8f6c8b98b1322 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -929,6 +929,7 @@ Bug Fixes to C++ Support
 - Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
 - Fixed several bugs in capturing variables within unevaluated contexts. 
(#GH63845), (#GH67260), (#GH69307),
   (#GH88081), (#GH89496), (#GH90669) and (#GH91633).
+- Fixed a crash in constraint instantiation under nested lambdas with 
dependent parameters.
 - Fixed handling of brace ellison when building deduction guides. (#GH64625), 
(#GH83368).
 - Clang now instantiates local constexpr functions eagerly for constant 
evaluators. (#GH35052), (#GH94849)
 - Fixed a failed assertion when attempting to convert an integer representing 
the difference
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index b6344f53861f4..e461827be1e9d 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -2390,21 +2390,26 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   llvm::SmallVector, 4>
   ParentInstantiations;
-  std::pair Current = {FDPattern, FD};
   while (true) {
-Current.first = dyn_cast(
-getLambdaAwareParentOfDeclContext(Current.first));
-Current.second = dyn_cast(
-getLambdaAwareParentOfDeclContext(Current.second));
+FDPattern =
+dyn_cast(getLambdaAwareParentOfDeclContext(FDPattern));
+FD = dyn_cast(getLambdaAwareParentOfDeclContext(FD));
 
-if (!Current.first || !Current.second)
+if (!FDPattern || !FD)
   break;
 
-ParentInstantiations.push_back(Current);
+ParentInstantiations.emplace_bac

[clang] [Clang] Fix the order of addInstantiatedParameters in LambdaScopeForCallOperatorInstantiationRAII (PR #97215)

2024-07-06 Thread Yupei Liu via cfe-commits


@@ -2379,23 +2379,32 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
 
   SemaRef.RebuildLambdaScopeInfo(cast(FD));
 
-  FunctionDecl *Pattern = getPatternFunctionDecl(FD);
-  if (Pattern) {
-SemaRef.addInstantiatedCapturesToScope(FD, Pattern, Scope, MLTAL);
+  FunctionDecl *FDPattern = getPatternFunctionDecl(FD);
+  if (!FDPattern)
+return;
 

LYP951018 wrote:

I would prefer to keep the current change. Firstly, this change is minimal and 
won’t significantly impact the review workload for this PR. Secondly, it 
reduces one level of indentation, which slightly improves readability. ;)

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


[clang] [clang][Sema] Improve `collectViableConversionCandidates` (PR #97908)

2024-07-06 Thread via cfe-commits

https://github.com/MagentaTreehouse created 
https://github.com/llvm/llvm-project/pull/97908

* Use range-based for
* The value of `Conv` is not used when `ConvTemplate` is not null, so we do not 
need to compute it on that path

>From def9d161e4ea79ee1b24a8d662a5c0dd17c2dd8f Mon Sep 17 00:00:00 2001
From: Mingyi Chen 
Date: Sat, 6 Jul 2024 15:41:08 -0400
Subject: [PATCH] [clang][Sema] Improve `collectViableConversionCandidates`

* Use range-based for
* The value of `Conv` is not used when `ConvTemplate` is not null, so we do not 
need to compute it on that path
---
 clang/lib/Sema/SemaOverload.cpp | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5ea6b06121c7cd..95c433dab4da43 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6504,29 +6504,23 @@ static void
 collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType,
   UnresolvedSetImpl &ViableConversions,
   OverloadCandidateSet &CandidateSet) {
-  for (unsigned I = 0, N = ViableConversions.size(); I != N; ++I) {
-DeclAccessPair FoundDecl = ViableConversions[I];
+  for (DeclAccessPair FoundDecl : ViableConversions.pairs()) {
 NamedDecl *D = FoundDecl.getDecl();
 CXXRecordDecl *ActingContext = cast(D->getDeclContext());
 if (isa(D))
   D = cast(D)->getTargetDecl();
 
-CXXConversionDecl *Conv;
-FunctionTemplateDecl *ConvTemplate;
-if ((ConvTemplate = dyn_cast(D)))
-  Conv = cast(ConvTemplate->getTemplatedDecl());
-else
-  Conv = cast(D);
-
-if (ConvTemplate)
+if (auto *ConvTemplate = dyn_cast(D)) {
   SemaRef.AddTemplateConversionCandidate(
   ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit*/ true);
-else
-  SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From,
- ToType, CandidateSet,
- /*AllowObjCConversionOnExplicit=*/false,
- /*AllowExplicit*/ true);
+  /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true);
+  continue;
+}
+CXXConversionDecl *Conv = cast(D);
+SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From, 
ToType,
+   CandidateSet,
+   /*AllowObjCConversionOnExplicit=*/false,
+   /*AllowExplicit=*/true);
   }
 }
 

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


[clang] [clang][Sema] Improve `collectViableConversionCandidates` (PR #97908)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (MagentaTreehouse)


Changes

* Use range-based for
* The value of `Conv` is not used when `ConvTemplate` is not null, so we do not 
need to compute it on that path

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaOverload.cpp (+10-16) 


``diff
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5ea6b06121c7c..95c433dab4da4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6504,29 +6504,23 @@ static void
 collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType,
   UnresolvedSetImpl &ViableConversions,
   OverloadCandidateSet &CandidateSet) {
-  for (unsigned I = 0, N = ViableConversions.size(); I != N; ++I) {
-DeclAccessPair FoundDecl = ViableConversions[I];
+  for (DeclAccessPair FoundDecl : ViableConversions.pairs()) {
 NamedDecl *D = FoundDecl.getDecl();
 CXXRecordDecl *ActingContext = cast(D->getDeclContext());
 if (isa(D))
   D = cast(D)->getTargetDecl();
 
-CXXConversionDecl *Conv;
-FunctionTemplateDecl *ConvTemplate;
-if ((ConvTemplate = dyn_cast(D)))
-  Conv = cast(ConvTemplate->getTemplatedDecl());
-else
-  Conv = cast(D);
-
-if (ConvTemplate)
+if (auto *ConvTemplate = dyn_cast(D)) {
   SemaRef.AddTemplateConversionCandidate(
   ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit*/ true);
-else
-  SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From,
- ToType, CandidateSet,
- /*AllowObjCConversionOnExplicit=*/false,
- /*AllowExplicit*/ true);
+  /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true);
+  continue;
+}
+CXXConversionDecl *Conv = cast(D);
+SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From, 
ToType,
+   CandidateSet,
+   /*AllowObjCConversionOnExplicit=*/false,
+   /*AllowExplicit=*/true);
   }
 }
 

``




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


[clang] [Clang] Fix null pointer dereference in VisitUsingEnumDecl (PR #97910)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/97910

This patch addresses static analyzer concern where TSI could be dereferenced 
after being assigned a null value from SubstType in 
clang::TemplateDeclInstantiator::VisitUsingEnumDecl(clang::UsingEnumDecl *).

The fix now checks null value of TSI after the call to SubstType and return 
nullptr to prevent potential null pointer dereferences when calling 
UsingEnumDecl::Create() and ensures safe execution.

>From 1c8d64e086f1d4e65fcc6bcc8afd13b75f675b6a Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 13:23:10 -0700
Subject: [PATCH] [Clang] Fix null pointer dereference in VisitUsingEnumDecl

This patch addresses static analyzer concern where TSI could be dereferenced 
after being assigned a null value from SubstType in 
clang::TemplateDeclInstantiator::VisitUsingEnumDecl(clang::UsingEnumDecl *).

The fix now checks null value of TSI after the call to SubstType and return 
nullptr to prevent potential null pointer dereferences when calling 
UsingEnumDecl::Create() and ensures safe execution.
---
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 64f6b01bed2292..8d856b807889ff 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3413,6 +3413,10 @@ Decl 
*TemplateDeclInstantiator::VisitUsingEnumDecl(UsingEnumDecl *D) {
 
   TypeSourceInfo *TSI = SemaRef.SubstType(D->getEnumType(), TemplateArgs,
   D->getLocation(), D->getDeclName());
+
+  if (!TSI)
+return nullptr;
+
   UsingEnumDecl *NewUD =
   UsingEnumDecl::Create(SemaRef.Context, Owner, D->getUsingLoc(),
 D->getEnumLoc(), D->getLocation(), TSI);

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


[clang] [Clang] Fix null pointer dereference in VisitUsingEnumDecl (PR #97910)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (smanna12)


Changes

This patch addresses static analyzer concern where TSI could be dereferenced 
after being assigned a null value from SubstType in 
clang::TemplateDeclInstantiator::VisitUsingEnumDecl(clang::UsingEnumDecl *).

The fix now checks null value of TSI after the call to SubstType and return 
nullptr to prevent potential null pointer dereferences when calling 
UsingEnumDecl::Create() and ensures safe execution.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+4) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 64f6b01bed229..8d856b807889f 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3413,6 +3413,10 @@ Decl 
*TemplateDeclInstantiator::VisitUsingEnumDecl(UsingEnumDecl *D) {
 
   TypeSourceInfo *TSI = SemaRef.SubstType(D->getEnumType(), TemplateArgs,
   D->getLocation(), D->getDeclName());
+
+  if (!TSI)
+return nullptr;
+
   UsingEnumDecl *NewUD =
   UsingEnumDecl::Create(SemaRef.Context, Owner, D->getUsingLoc(),
 D->getEnumLoc(), D->getLocation(), TSI);

``




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


[libclc] [libclc] Fix cross in-tree builds (PR #97392)

2024-07-06 Thread via cfe-commits

https://github.com/GO-NFT-GO commented:

Ok

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


[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-06 Thread Mike Crowe via cfe-commits

https://github.com/mikecrowe created 
https://github.com/llvm/llvm-project/pull/97911

Expanding all macros in the printf/absl::StrFormat format string before 
conversion could easily break code if those macros are expended to change their 
definition between builds. It's important for this check to expand the 
 PRI macros though, so let's ensure that the presence of any other 
macros in the format string causes the check to emit a warning and not perform 
any conversion.

>From f6c1a231681092189a621e2bc6af97300b2a7bfa Mon Sep 17 00:00:00 2001
From: Mike Crowe 
Date: Wed, 12 Jun 2024 21:06:26 +0100
Subject: [PATCH] [clang-tidy] Only expand  macros in
 modernize-use-std-format/print

Expanding all macros in the printf/absl::StrFormat format string before
conversion could easily break code if those macros are expended to
change their definition between builds. It's important for this check to
expand the  PRI macros though, so let's ensure that the
presence of any other macros in the format string causes the check to
emit a warning and not perform any conversion.
---
 .../modernize/UseStdFormatCheck.cpp   |  7 +--
 .../clang-tidy/modernize/UseStdFormatCheck.h  |  1 +
 .../clang-tidy/modernize/UseStdPrintCheck.cpp |  4 +-
 .../clang-tidy/modernize/UseStdPrintCheck.h   |  1 +
 .../utils/FormatStringConverter.cpp   | 52 --
 .../clang-tidy/utils/FormatStringConverter.h  |  6 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 +-
 .../checks/modernize/use-std-print.rst| 22 
 .../checkers/Inputs/Headers/inttypes.h| 26 +
 .../checkers/modernize/use-std-format.cpp | 53 +++
 .../checkers/modernize/use-std-print.cpp  | 47 +++-
 11 files changed, 181 insertions(+), 41 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
index d082faa786b37..7e8cbd40fe07a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
@@ -44,6 +44,7 @@ void UseStdFormatCheck::registerPPCallbacks(const 
SourceManager &SM,
 Preprocessor *PP,
 Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
@@ -78,9 +79,9 @@ void UseStdFormatCheck::check(const MatchFinder::MatchResult 
&Result) {
 
   utils::FormatStringConverter::Configuration ConverterConfig;
   ConverterConfig.StrictMode = StrictMode;
-  utils::FormatStringConverter Converter(Result.Context, StrFormat,
- FormatArgOffset, ConverterConfig,
- getLangOpts());
+  utils::FormatStringConverter Converter(
+  Result.Context, StrFormat, FormatArgOffset, ConverterConfig,
+  getLangOpts(), *Result.SourceManager, *PP);
   const Expr *StrFormatCall = StrFormat->getCallee();
   if (!Converter.canApply()) {
 diag(StrFormat->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
index b59a4708c6e4b..9ac2240212ebf 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
@@ -44,6 +44,7 @@ class UseStdFormatCheck : public ClangTidyCheck {
   StringRef ReplacementFormatFunction;
   utils::IncludeInserter IncludeInserter;
   std::optional MaybeHeaderToInclude;
+  Preprocessor *PP = nullptr;
 };
 
 } // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 1ea170c3cd310..69136c10d927b 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -68,6 +68,7 @@ void UseStdPrintCheck::registerPPCallbacks(const 
SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 static clang::ast_matchers::StatementMatcher
@@ -137,7 +138,8 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult 
&Result) {
   ConverterConfig.StrictMode = StrictMode;
   ConverterConfig.AllowTrailingNewlineRemoval = true;
   utils::FormatStringConverter Converter(
-  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts());
+  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts(),
+  *Result.SourceManager, *PP);
   const Expr *PrintfCall = Printf->getCallee();
   const StringRef ReplacementFunction = Converter.usePrintNewlineFunction()
 ? Repl

[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Mike Crowe (mikecrowe)


Changes

Expanding all macros in the printf/absl::StrFormat format string before 
conversion could easily break code if those macros are expended to change their 
definition between builds. It's important for this check to expand the 
 PRI macros though, so let's ensure that the presence of any 
other macros in the format string causes the check to emit a warning and not 
perform any conversion.

---

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


11 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
(+4-3) 
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h (+1) 
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp (+3-1) 
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h (+1) 
- (modified) clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp 
(+47-5) 
- (modified) clang-tools-extra/clang-tidy/utils/FormatStringConverter.h (+5-1) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+2-1) 
- (modified) 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst (+13-9) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/inttypes.h (+16-10) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp (+44-9) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp (+45-2) 


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
index d082faa786b375..7e8cbd40fe07ae 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
@@ -44,6 +44,7 @@ void UseStdFormatCheck::registerPPCallbacks(const 
SourceManager &SM,
 Preprocessor *PP,
 Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
@@ -78,9 +79,9 @@ void UseStdFormatCheck::check(const MatchFinder::MatchResult 
&Result) {
 
   utils::FormatStringConverter::Configuration ConverterConfig;
   ConverterConfig.StrictMode = StrictMode;
-  utils::FormatStringConverter Converter(Result.Context, StrFormat,
- FormatArgOffset, ConverterConfig,
- getLangOpts());
+  utils::FormatStringConverter Converter(
+  Result.Context, StrFormat, FormatArgOffset, ConverterConfig,
+  getLangOpts(), *Result.SourceManager, *PP);
   const Expr *StrFormatCall = StrFormat->getCallee();
   if (!Converter.canApply()) {
 diag(StrFormat->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
index b59a4708c6e4bc..9ac2240212ebf6 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
@@ -44,6 +44,7 @@ class UseStdFormatCheck : public ClangTidyCheck {
   StringRef ReplacementFormatFunction;
   utils::IncludeInserter IncludeInserter;
   std::optional MaybeHeaderToInclude;
+  Preprocessor *PP = nullptr;
 };
 
 } // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 1ea170c3cd3106..69136c10d927b2 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -68,6 +68,7 @@ void UseStdPrintCheck::registerPPCallbacks(const 
SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 static clang::ast_matchers::StatementMatcher
@@ -137,7 +138,8 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult 
&Result) {
   ConverterConfig.StrictMode = StrictMode;
   ConverterConfig.AllowTrailingNewlineRemoval = true;
   utils::FormatStringConverter Converter(
-  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts());
+  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts(),
+  *Result.SourceManager, *PP);
   const Expr *PrintfCall = Printf->getCallee();
   const StringRef ReplacementFunction = Converter.usePrintNewlineFunction()
 ? ReplacementPrintlnFunction
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
index 7a06cf38b4264f..995c740389e73b 100644
--- a/clang-tools-e

[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




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

Author: Mike Crowe (mikecrowe)


Changes

Expanding all macros in the printf/absl::StrFormat format string before 
conversion could easily break code if those macros are expended to change their 
definition between builds. It's important for this check to expand the 
 PRI macros though, so let's ensure that the presence of any 
other macros in the format string causes the check to emit a warning and not 
perform any conversion.

---

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


11 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
(+4-3) 
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h (+1) 
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp (+3-1) 
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h (+1) 
- (modified) clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp 
(+47-5) 
- (modified) clang-tools-extra/clang-tidy/utils/FormatStringConverter.h (+5-1) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+2-1) 
- (modified) 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst (+13-9) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/inttypes.h (+16-10) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp (+44-9) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp (+45-2) 


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
index d082faa786b37..7e8cbd40fe07a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
@@ -44,6 +44,7 @@ void UseStdFormatCheck::registerPPCallbacks(const 
SourceManager &SM,
 Preprocessor *PP,
 Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
@@ -78,9 +79,9 @@ void UseStdFormatCheck::check(const MatchFinder::MatchResult 
&Result) {
 
   utils::FormatStringConverter::Configuration ConverterConfig;
   ConverterConfig.StrictMode = StrictMode;
-  utils::FormatStringConverter Converter(Result.Context, StrFormat,
- FormatArgOffset, ConverterConfig,
- getLangOpts());
+  utils::FormatStringConverter Converter(
+  Result.Context, StrFormat, FormatArgOffset, ConverterConfig,
+  getLangOpts(), *Result.SourceManager, *PP);
   const Expr *StrFormatCall = StrFormat->getCallee();
   if (!Converter.canApply()) {
 diag(StrFormat->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
index b59a4708c6e4b..9ac2240212ebf 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
@@ -44,6 +44,7 @@ class UseStdFormatCheck : public ClangTidyCheck {
   StringRef ReplacementFormatFunction;
   utils::IncludeInserter IncludeInserter;
   std::optional MaybeHeaderToInclude;
+  Preprocessor *PP = nullptr;
 };
 
 } // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 1ea170c3cd310..69136c10d927b 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -68,6 +68,7 @@ void UseStdPrintCheck::registerPPCallbacks(const 
SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 static clang::ast_matchers::StatementMatcher
@@ -137,7 +138,8 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult 
&Result) {
   ConverterConfig.StrictMode = StrictMode;
   ConverterConfig.AllowTrailingNewlineRemoval = true;
   utils::FormatStringConverter Converter(
-  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts());
+  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts(),
+  *Result.SourceManager, *PP);
   const Expr *PrintfCall = Printf->getCallee();
   const StringRef ReplacementFunction = Converter.usePrintNewlineFunction()
 ? ReplacementPrintlnFunction
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
index 7a06cf38b4264..995c740389e73 100644
--- a/clang-tools-ex

[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-06 Thread Mike Crowe via cfe-commits

mikecrowe wrote:

I'm not particularly happy with the `FormatStringConverter` constructor now 
taking seven parameters. The risk of them getting muddled isn't huge though 
because they are all of different types. Should I perhaps put them all into the 
`FormatStringConverter::Configuration` struct or perhaps a separate struct in 
the absence of named parameters? Even if I leave them as seven parameters, is 
there a preferred order for them? Any recommendations gratefully received.

I considered adding a configuration option to list other macros that should be 
permitted in the format string. I will investigate doing so if this change is 
acceptable.

OpenBSD and mingw32 seem to just use `PRI` prefixes in their `inttypes.h`. I 
don't know whether Microsoft and MacOS do anything like glibc does which 
required the special `__PRI` handling.


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


[clang] [clang][Sema] Improve `collectViableConversionCandidates` (PR #97908)

2024-07-06 Thread via cfe-commits

https://github.com/MagentaTreehouse updated 
https://github.com/llvm/llvm-project/pull/97908

>From def9d161e4ea79ee1b24a8d662a5c0dd17c2dd8f Mon Sep 17 00:00:00 2001
From: Mingyi Chen 
Date: Sat, 6 Jul 2024 15:41:08 -0400
Subject: [PATCH 1/2] [clang][Sema] Improve `collectViableConversionCandidates`

* Use range-based for
* The value of `Conv` is not used when `ConvTemplate` is not null, so we do not 
need to compute it on that path
---
 clang/lib/Sema/SemaOverload.cpp | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5ea6b06121c7c..95c433dab4da4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6504,29 +6504,23 @@ static void
 collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType,
   UnresolvedSetImpl &ViableConversions,
   OverloadCandidateSet &CandidateSet) {
-  for (unsigned I = 0, N = ViableConversions.size(); I != N; ++I) {
-DeclAccessPair FoundDecl = ViableConversions[I];
+  for (DeclAccessPair FoundDecl : ViableConversions.pairs()) {
 NamedDecl *D = FoundDecl.getDecl();
 CXXRecordDecl *ActingContext = cast(D->getDeclContext());
 if (isa(D))
   D = cast(D)->getTargetDecl();
 
-CXXConversionDecl *Conv;
-FunctionTemplateDecl *ConvTemplate;
-if ((ConvTemplate = dyn_cast(D)))
-  Conv = cast(ConvTemplate->getTemplatedDecl());
-else
-  Conv = cast(D);
-
-if (ConvTemplate)
+if (auto *ConvTemplate = dyn_cast(D)) {
   SemaRef.AddTemplateConversionCandidate(
   ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
-  /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit*/ true);
-else
-  SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From,
- ToType, CandidateSet,
- /*AllowObjCConversionOnExplicit=*/false,
- /*AllowExplicit*/ true);
+  /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true);
+  continue;
+}
+CXXConversionDecl *Conv = cast(D);
+SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From, 
ToType,
+   CandidateSet,
+   /*AllowObjCConversionOnExplicit=*/false,
+   /*AllowExplicit=*/true);
   }
 }
 

>From 55267b7cfa948d62620fcf12f6ac4afea9a6f3ed Mon Sep 17 00:00:00 2001
From: Mingyi Chen 
Date: Sat, 6 Jul 2024 16:41:57 -0400
Subject: [PATCH 2/2] Format

---
 clang/lib/Sema/SemaOverload.cpp | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 95c433dab4da4..f63495731315e 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6517,10 +6517,9 @@ collectViableConversionCandidates(Sema &SemaRef, Expr 
*From, QualType ToType,
   continue;
 }
 CXXConversionDecl *Conv = cast(D);
-SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From, 
ToType,
-   CandidateSet,
-   /*AllowObjCConversionOnExplicit=*/false,
-   /*AllowExplicit=*/true);
+SemaRef.AddConversionCandidate(
+Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
+/*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true);
   }
 }
 

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


[clang] [Clang] Remove unnecessary copy (PR #97902)

2024-07-06 Thread Youngsuk Kim via cfe-commits


@@ -1551,7 +1551,7 @@ ASTNodeImporter::VisitCountAttributedType(const 
CountAttributedType *T) {
   Expr *CountExpr = importChecked(Err, T->getCountExpr());
 
   SmallVector CoupledDecls;
-  for (auto TI : T->dependent_decls()) {
+  for (const TypeCoupledDeclRefInfo &TI : T->dependent_decls()) {

JOE1994 wrote:

```suggestion
  for (const auto &TI : T->dependent_decls()) {
```

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


[clang] [Clang] Prevent null pointer dereference in TransformUnaryTransformType() (PR #97912)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/97912

This patch adds null check after TransformType call to avoid dereferencing a 
null pointer when calling getType().

>From c30e531027828d7b531d3791c48779b465e69360 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:02:16 -0700
Subject: [PATCH] [Clang] Prevent null pointer dereference in
 TransformUnaryTransformType

This patch adds null check after TransformType call to avoid dereferencing a 
null pointer when calling getType().
---
 clang/lib/Sema/TreeTransform.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4450ebaf615cd2..eb60528509fc53 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6734,8 +6734,12 @@ QualType 
TreeTransform::TransformUnaryTransformType(
   QualType Result = TL.getType();
   if (Result->isDependentType()) {
 const UnaryTransformType *T = TL.getTypePtr();
-QualType NewBase =
-  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
+
+QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
+if (!NewBaseType)
+  return QualType();
+QualType NewBase = NewBaseType->getType();
+
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),
 TL.getKWLoc());

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


[clang] [Clang] Prevent null pointer dereference in TransformUnaryTransformType() (PR #97912)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (smanna12)


Changes

This patch adds null check after TransformType call to avoid dereferencing a 
null pointer when calling getType().

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


1 Files Affected:

- (modified) clang/lib/Sema/TreeTransform.h (+6-2) 


``diff
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4450ebaf615cd..eb60528509fc5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6734,8 +6734,12 @@ QualType 
TreeTransform::TransformUnaryTransformType(
   QualType Result = TL.getType();
   if (Result->isDependentType()) {
 const UnaryTransformType *T = TL.getTypePtr();
-QualType NewBase =
-  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
+
+QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
+if (!NewBaseType)
+  return QualType();
+QualType NewBase = NewBaseType->getType();
+
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),
 TL.getKWLoc());

``




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


[clang] [Clang] Prevent null pointer dereference in TransformUnaryTransformType() (PR #97912)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 updated 
https://github.com/llvm/llvm-project/pull/97912

>From c30e531027828d7b531d3791c48779b465e69360 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:02:16 -0700
Subject: [PATCH 1/2] [Clang] Prevent null pointer dereference in
 TransformUnaryTransformType

This patch adds null check after TransformType call to avoid dereferencing a 
null pointer when calling getType().
---
 clang/lib/Sema/TreeTransform.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4450ebaf615cd..eb60528509fc5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6734,8 +6734,12 @@ QualType 
TreeTransform::TransformUnaryTransformType(
   QualType Result = TL.getType();
   if (Result->isDependentType()) {
 const UnaryTransformType *T = TL.getTypePtr();
-QualType NewBase =
-  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
+
+QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
+if (!NewBaseType)
+  return QualType();
+QualType NewBase = NewBaseType->getType();
+
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),
 TL.getKWLoc());

>From 87eceedcfabb4f3f3b7c69f970716a40c745bf7a Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:24:19 -0700
Subject: [PATCH 2/2] Fix Build errors

---
 clang/lib/Sema/TreeTransform.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index eb60528509fc5..46ac5ff989e37 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6735,10 +6735,11 @@ QualType 
TreeTransform::TransformUnaryTransformType(
   if (Result->isDependentType()) {
 const UnaryTransformType *T = TL.getTypePtr();
 
-QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
-if (!NewBaseType)
+TypeSourceInfo *NewBaseTSI =
+  getDerived().TransformType(TL.getUnderlyingTInfo());
+if (!NewBaseTSI)
   return QualType();
-QualType NewBase = NewBaseType->getType();
+QualType NewBaseTSI = NewBaseType->getType();
 
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),

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


[clang] [Clang] Prevent null pointer dereference in TransformUnaryTransformType() (PR #97912)

2024-07-06 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 8426b51e0e942b27af8a50b9cee53c1b68d139c2 
87eceedcfabb4f3f3b7c69f970716a40c745bf7a -- clang/lib/Sema/TreeTransform.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 46ac5ff989..e9071d7e89 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6736,7 +6736,7 @@ QualType 
TreeTransform::TransformUnaryTransformType(
 const UnaryTransformType *T = TL.getTypePtr();
 
 TypeSourceInfo *NewBaseTSI =
-  getDerived().TransformType(TL.getUnderlyingTInfo());
+getDerived().TransformType(TL.getUnderlyingTInfo());
 if (!NewBaseTSI)
   return QualType();
 QualType NewBaseTSI = NewBaseType->getType();

``




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


[clang] [Clang] Prevent null pointer dereference in TransformUnaryTransformType() (PR #97912)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 updated 
https://github.com/llvm/llvm-project/pull/97912

>From c30e531027828d7b531d3791c48779b465e69360 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:02:16 -0700
Subject: [PATCH 1/3] [Clang] Prevent null pointer dereference in
 TransformUnaryTransformType

This patch adds null check after TransformType call to avoid dereferencing a 
null pointer when calling getType().
---
 clang/lib/Sema/TreeTransform.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4450ebaf615cd..eb60528509fc5 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6734,8 +6734,12 @@ QualType 
TreeTransform::TransformUnaryTransformType(
   QualType Result = TL.getType();
   if (Result->isDependentType()) {
 const UnaryTransformType *T = TL.getTypePtr();
-QualType NewBase =
-  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
+
+QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
+if (!NewBaseType)
+  return QualType();
+QualType NewBase = NewBaseType->getType();
+
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),
 TL.getKWLoc());

>From 87eceedcfabb4f3f3b7c69f970716a40c745bf7a Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:24:19 -0700
Subject: [PATCH 2/3] Fix Build errors

---
 clang/lib/Sema/TreeTransform.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index eb60528509fc5..46ac5ff989e37 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6735,10 +6735,11 @@ QualType 
TreeTransform::TransformUnaryTransformType(
   if (Result->isDependentType()) {
 const UnaryTransformType *T = TL.getTypePtr();
 
-QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
-if (!NewBaseType)
+TypeSourceInfo *NewBaseTSI =
+  getDerived().TransformType(TL.getUnderlyingTInfo());
+if (!NewBaseTSI)
   return QualType();
-QualType NewBase = NewBaseType->getType();
+QualType NewBaseTSI = NewBaseType->getType();
 
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),

>From 3130939574ba875d8e9df47d3336d09f65e5c6ca Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:30:25 -0700
Subject: [PATCH 3/3] Fix wrong type

---
 clang/lib/Sema/TreeTransform.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 46ac5ff989e37..527be7e857a12 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6736,10 +6736,10 @@ QualType 
TreeTransform::TransformUnaryTransformType(
 const UnaryTransformType *T = TL.getTypePtr();
 
 TypeSourceInfo *NewBaseTSI =
-  getDerived().TransformType(TL.getUnderlyingTInfo());
+getDerived().TransformType(TL.getUnderlyingTInfo());
 if (!NewBaseTSI)
   return QualType();
-QualType NewBaseTSI = NewBaseType->getType();
+QualType NewBase = NewBaseTSI->getType();
 
 Result = getDerived().RebuildUnaryTransformType(NewBase,
 T->getUTTKind(),

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


[clang] [Clang] Guard against null in template instantiation process (PR #97913)

2024-07-06 Thread via cfe-commits

https://github.com/smanna12 created 
https://github.com/llvm/llvm-project/pull/97913

This patch adds a null check for InstantiatedFrom to prevent dereferencing a 
null pointer during the template instantiation process in 
clang::Sema::SetupConstraintScope().

The fix ensures that the function exits early with an appropriate error if the 
InstantiatedFrom pointer is not valid.

>From 47c87a6ba65fb2581737d8c15065a1e6c98a0944 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" 
Date: Sat, 6 Jul 2024 14:48:21 -0700
Subject: [PATCH] [Clang] Guard against null in template instantiation process

This patch adds a null check for InstantiatedFrom to prevent dereferencing a
null pointer during the template instantiation process in 
clang::Sema::SetupConstraintScope().

The fix ensures that the function exits early with an appropriate error if the
InstantiatedFrom pointer is not valid.
---
 clang/lib/Sema/SemaConcept.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 202dd86c67f62..353276e9b2802 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -636,6 +636,9 @@ bool Sema::SetupConstraintScope(
 ? FD->getInstantiatedFromMemberFunction()
 : FD->getInstantiatedFromDecl();
 
+if (!InstantiatedFrom)
+  return true;
+
 InstantiatingTemplate Inst(
 *this, FD->getPointOfInstantiation(),
 Sema::InstantiatingTemplate::ConstraintsCheck{}, InstantiatedFrom,

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


[clang] [Clang] Guard against null in template instantiation process (PR #97913)

2024-07-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (smanna12)


Changes

This patch adds a null check for InstantiatedFrom to prevent dereferencing a 
null pointer during the template instantiation process in 
clang::Sema::SetupConstraintScope().

The fix ensures that the function exits early with an appropriate error if the 
InstantiatedFrom pointer is not valid.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaConcept.cpp (+3) 


``diff
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 202dd86c67f62..353276e9b2802 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -636,6 +636,9 @@ bool Sema::SetupConstraintScope(
 ? FD->getInstantiatedFromMemberFunction()
 : FD->getInstantiatedFromDecl();
 
+if (!InstantiatedFrom)
+  return true;
+
 InstantiatingTemplate Inst(
 *this, FD->getPointOfInstantiation(),
 Sema::InstantiatingTemplate::ConstraintsCheck{}, InstantiatedFrom,

``




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


  1   2   >