[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-25 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/89942

>From 8c5f1d0f92d77bffec88759c19133a0bac130f32 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Wed, 24 Apr 2024 23:36:10 +0800
Subject: [PATCH 1/6] [Clang] Implement P2748R5 "Disallow Binding a Returned
 Glvalue to a Temporary"

Signed-off-by: yronglin 
---
 clang/docs/ReleaseNotes.rst|  4 +++-
 .../include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/SemaInit.cpp| 13 +++--
 clang/test/CXX/drs/cwg650.cpp  |  2 +-
 clang/test/CXX/stmt.stmt/stmt.return/p6.cpp| 18 ++
 5 files changed, 35 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CXX/stmt.stmt/stmt.return/p6.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..5e07000198d63a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -129,7 +129,9 @@ C++2c Feature Support
 
 - Implemented `P2662R3 Pack Indexing `_.
 
-- Implemented `P2573R2: = delete("should have a reason"); 
`_
+- Implemented `P2573R2: = delete("should have a reason"); 
`_.
+
+- Implemented `P2748R5 Disallow Binding a Returned Glvalue to a Temporary 
`_.
 
 
 Resolutions to C++ Defect Reports
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6732a1a98452ad..7342215db9cc3d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9950,6 +9950,8 @@ def warn_ret_stack_addr_ref : Warning<
 def warn_ret_local_temp_addr_ref : Warning<
   "returning %select{address of|reference to}0 local temporary object">,
   InGroup;
+def err_ret_local_temp_addr_ref : Error<
+  "returning %select{address of|reference to}0 local temporary object">;
 def warn_ret_addr_label : Warning<
   "returning address of label, which is local">,
   InGroup;
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 793e16df178914..003c4c34810e1f 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity ,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.
+if (getLangOpts().CPlusPlus26)
+  Diag(DiagLoc, diag::err_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;
+else
+  Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;
   }
   break;
 }
diff --git a/clang/test/CXX/drs/cwg650.cpp b/clang/test/CXX/drs/cwg650.cpp
index dcb844095b0598..01a841b04b42d3 100644
--- a/clang/test/CXX/drs/cwg650.cpp
+++ b/clang/test/CXX/drs/cwg650.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
 // RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
-// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// Since C++26, P2748R5 "Disallow Binding a Returned Glvalue to a Temporary". 
Therefore we do not test this issue after C++26.
 
 #if __cplusplus == 199711L
 #define NOTHROW throw()
diff --git a/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp 
b/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp
new file mode 100644
index 00..682d3a8a075d4e
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+auto&& 

[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread Tim Pham via cfe-commits

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


[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread Tim Pham via cfe-commits

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-25 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 21ef187654c819fd097171afcc6c9855dccdb36d 
0ee6abe93159a29052af3ef9befff6a7e029eb31 -- 
clang/test/CXX/stmt.stmt/stmt.return/p6.cpp clang/lib/Sema/SemaInit.cpp 
clang/test/CXX/drs/cwg650.cpp clang/test/SemaCXX/type-traits.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index d22ab1311d..34f340333a 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8373,7 +8373,8 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity ,
 // copy-initialization of a temporary of the appropriate type, which 
for
 // this expression is identical to the return statement (since NRVO
 // doesn't apply), and not really build a `return create()` in
-// type traits expression evaluation. Therefor, P2748R5 has no impact 
for
+// type traits expression evaluation. Therefor, P2748R5 has no impact
+// for
 // {__is_convertible, __is_nothrow_convertible, __is_convertible_to}
 // evaluation.
 //

``




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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-25 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/89942

>From 8c5f1d0f92d77bffec88759c19133a0bac130f32 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Wed, 24 Apr 2024 23:36:10 +0800
Subject: [PATCH 1/3] [Clang] Implement P2748R5 "Disallow Binding a Returned
 Glvalue to a Temporary"

Signed-off-by: yronglin 
---
 clang/docs/ReleaseNotes.rst|  4 +++-
 .../include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/SemaInit.cpp| 13 +++--
 clang/test/CXX/drs/cwg650.cpp  |  2 +-
 clang/test/CXX/stmt.stmt/stmt.return/p6.cpp| 18 ++
 5 files changed, 35 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CXX/stmt.stmt/stmt.return/p6.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..5e07000198d63a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -129,7 +129,9 @@ C++2c Feature Support
 
 - Implemented `P2662R3 Pack Indexing `_.
 
-- Implemented `P2573R2: = delete("should have a reason"); 
`_
+- Implemented `P2573R2: = delete("should have a reason"); 
`_.
+
+- Implemented `P2748R5 Disallow Binding a Returned Glvalue to a Temporary 
`_.
 
 
 Resolutions to C++ Defect Reports
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6732a1a98452ad..7342215db9cc3d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9950,6 +9950,8 @@ def warn_ret_stack_addr_ref : Warning<
 def warn_ret_local_temp_addr_ref : Warning<
   "returning %select{address of|reference to}0 local temporary object">,
   InGroup;
+def err_ret_local_temp_addr_ref : Error<
+  "returning %select{address of|reference to}0 local temporary object">;
 def warn_ret_addr_label : Warning<
   "returning address of label, which is local">,
   InGroup;
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 793e16df178914..003c4c34810e1f 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity ,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.
+if (getLangOpts().CPlusPlus26)
+  Diag(DiagLoc, diag::err_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;
+else
+  Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;
   }
   break;
 }
diff --git a/clang/test/CXX/drs/cwg650.cpp b/clang/test/CXX/drs/cwg650.cpp
index dcb844095b0598..01a841b04b42d3 100644
--- a/clang/test/CXX/drs/cwg650.cpp
+++ b/clang/test/CXX/drs/cwg650.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
 // RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
-// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// Since C++26, P2748R5 "Disallow Binding a Returned Glvalue to a Temporary". 
Therefore we do not test this issue after C++26.
 
 #if __cplusplus == 199711L
 #define NOTHROW throw()
diff --git a/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp 
b/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp
new file mode 100644
index 00..682d3a8a075d4e
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+auto&& 

[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread Tim Pham via cfe-commits

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


[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread Tim Pham via cfe-commits

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


[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author:  Tim Pham (timmyhoa)


Changes

Closes #88917 

Do I really know what is going on? Nope. 
Do I know what the bug is? Enough to fix it (hopefully) :)

I'm just a beginner so sorry for any obvious mistake.  

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+4) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d085e735ecb443..7e79b6ce350beb 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5706,6 +5706,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant 
*old,
 
   llvm::Type *newRetTy = newFn->getReturnType();
   SmallVector newArgs;
+  SmallVector toBeRemoved;
 
   for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
  ui != ue; ) {
@@ -5792,6 +5793,9 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant 
*old,
 if (callSite->getDebugLoc())
   newCall->setDebugLoc(callSite->getDebugLoc());
 
+toBeRemoved.push_back(callSite);
+  }
+  for (llvm::CallBase *callSite : toBeRemoved) {
 callSite->eraseFromParent();
   }
 }

``




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


[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)

2024-04-25 Thread Andrew Sukach via cfe-commits

https://github.com/soukatch updated 
https://github.com/llvm/llvm-project/pull/90012

>From 9007597af4f138d2744405bb7980fce4555d7508 Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Wed, 24 Apr 2024 22:50:50 -0400
Subject: [PATCH 1/2] [clang] MangledSymbol: remove pointless copy of vector

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..81a827dba26b90 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
 
 MangledSymbol(const std::string , uint8_t Type, uint8_t Binding,
   std::vector Names)
-: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {}
+: ParentName(ParentName), Type(Type), Binding(Binding),
+  Names(std::move(Names)) {}
   };
   using MangledSymbols = std::map;
 

>From 7774ca198e84946f45ae9301769f53ee91aaddac Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Fri, 26 Apr 2024 01:29:28 -0400
Subject: [PATCH 2/2]


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


[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [Clang][CodeGen] Segfault when compiling weird code (PR #90165)

2024-04-25 Thread Tim Pham via cfe-commits

https://github.com/timmyhoa created 
https://github.com/llvm/llvm-project/pull/90165

Closes #88917 

Do I really know what is going on? Nope. 
Do I know what the bug is? Enough to fix it (hopefully) :)

I'm just a beginner so sorry for any obvious mistake.  

>From 99a85014b6dd2193afcaff1cb92b92a52bb92654 Mon Sep 17 00:00:00 2001
From: timmyhoa 
Date: Fri, 26 Apr 2024 01:12:20 -0400
Subject: [PATCH 1/2] fixed delete in for loop

---
 clang/lib/CodeGen/CodeGenModule.cpp | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index d085e735ecb443..cd50f06b4a976a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5706,6 +5706,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant 
*old,
 
   llvm::Type *newRetTy = newFn->getReturnType();
   SmallVector newArgs;
+  SmallVector toBeRemoved;
 
   for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
  ui != ue; ) {
@@ -5792,7 +5793,10 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant 
*old,
 if (callSite->getDebugLoc())
   newCall->setDebugLoc(callSite->getDebugLoc());
 
-callSite->eraseFromParent();
+toBeRemoved.push_back(callSite);
+  }
+  for (llvm::CallBase *callSite : toBeRemoved) {
+   callSite->eraseFromParent();
   }
 }
 

>From 33d1a75b1c0b130b612a9dd478609e86315ddf5c Mon Sep 17 00:00:00 2001
From: timmyhoa 
Date: Fri, 26 Apr 2024 01:16:08 -0400
Subject: [PATCH 2/2] formatted

---
 clang/lib/CodeGen/CodeGenModule.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index cd50f06b4a976a..7e79b6ce350beb 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5706,7 +5706,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant 
*old,
 
   llvm::Type *newRetTy = newFn->getReturnType();
   SmallVector newArgs;
-  SmallVector toBeRemoved;
+  SmallVector toBeRemoved;
 
   for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
  ui != ue; ) {
@@ -5796,7 +5796,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant 
*old,
 toBeRemoved.push_back(callSite);
   }
   for (llvm::CallBase *callSite : toBeRemoved) {
-   callSite->eraseFromParent();
+callSite->eraseFromParent();
   }
 }
 

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


[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)

2024-04-25 Thread Andrew Sukach via cfe-commits

https://github.com/soukatch updated 
https://github.com/llvm/llvm-project/pull/90012

>From 9007597af4f138d2744405bb7980fce4555d7508 Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Wed, 24 Apr 2024 22:50:50 -0400
Subject: [PATCH] [clang] MangledSymbol: remove pointless copy of vector

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..81a827dba26b90 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
 
 MangledSymbol(const std::string , uint8_t Type, uint8_t Binding,
   std::vector Names)
-: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {}
+: ParentName(ParentName), Type(Type), Binding(Binding),
+  Names(std::move(Names)) {}
   };
   using MangledSymbols = std::map;
 

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


[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)

2024-04-25 Thread Andrew Sukach via cfe-commits

https://github.com/soukatch updated 
https://github.com/llvm/llvm-project/pull/90012

>From b8e20a5a3e37ab9a657ac640b848f638387215fa Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Wed, 24 Apr 2024 22:50:50 -0400
Subject: [PATCH 1/2] [clang] MangledSymbol: remove pointless copy of vector

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..81a827dba26b90 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -33,7 +33,8 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
 
 MangledSymbol(const std::string , uint8_t Type, uint8_t Binding,
   std::vector Names)
-: ParentName(ParentName), Type(Type), Binding(Binding), Names(Names) {}
+: ParentName(ParentName), Type(Type), Binding(Binding),
+  Names(std::move(Names)) {}
   };
   using MangledSymbols = std::map;
 

>From c2195e410896f626c9119b407acba512c273720f Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Fri, 26 Apr 2024 01:27:10 -0400
Subject: [PATCH 2/2]


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


[clang] [clang-tools-extra] [PAC][clang] Define `PointerAuthQualifier` and `PointerAuthenticationMode` (PR #84384)

2024-04-25 Thread Daniil Kovalev via cfe-commits

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


[clang] f4efa06 - [PAC][clang] Define `PointerAuthQualifier` and `PointerAuthenticationMode` (#84384)

2024-04-25 Thread via cfe-commits

Author: Daniil Kovalev
Date: 2024-04-26T08:26:15+03:00
New Revision: f4efa067435c8137718c907bf0de2b891b76552d

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

LOG: [PAC][clang] Define `PointerAuthQualifier` and `PointerAuthenticationMode` 
(#84384)

This brings declarations of `PointerAuthQualifier` class and
`PointerAuthenticationMode` enum and related functions required for
PAuth support in lldb (see #84387) from downstream Apple's code. See
#84387 for tests as well.

Co-authored-by: Ahmed Bougacha 
Co-authored-by: John McCall 

-

Co-authored-by: John McCall 
Co-authored-by: Ahmed Bougacha 

Added: 
clang/include/clang/Basic/PointerAuthOptions.h

Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/AbstractBasicReader.h
clang/include/clang/AST/AbstractBasicWriter.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/LangOptions.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 84e99c7fafc74b..10868129e76da9 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -967,7 +967,8 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
   // Get out the qualifiers of the original type. This will always be
   // re-applied to the WorkType to ensure it is the same qualification as the
   // original From was.
-  auto QualifiersToApply = From.split().Quals.getAsOpaqueValue();
+  auto FastQualifiersToApply = static_cast(
+  From.split().Quals.getAsOpaqueValue() & Qualifiers::FastMask);
 
   // LValue->RValue is irrelevant for the check, because it is a thing to be
   // done at a call site, and will be performed if need be performed.
@@ -993,7 +994,7 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
 // "const double -> double".
 LLVM_DEBUG(llvm::dbgs()
<< "--- approximateStdConv. Conversion between numerics.\n");
-WorkType = QualType{ToBuiltin, QualifiersToApply};
+WorkType = QualType{ToBuiltin, FastQualifiersToApply};
   }
 
   const auto *FromEnum = WorkType->getAs();
@@ -1002,7 +1003,7 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
 // Unscoped enumerations (or enumerations in C) convert to numerics.
 LLVM_DEBUG(llvm::dbgs()
<< "--- approximateStdConv. Unscoped enum to numeric.\n");
-WorkType = QualType{ToBuiltin, QualifiersToApply};
+WorkType = QualType{ToBuiltin, FastQualifiersToApply};
   } else if (FromNumeric && ToEnum && ToEnum->isUnscopedEnumerationType()) {
 // Numeric types convert to enumerations only in C.
 if (Ctx.getLangOpts().CPlusPlus) {
@@ -1013,7 +1014,7 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
 
 LLVM_DEBUG(llvm::dbgs()
<< "--- approximateStdConv. Numeric to unscoped enum.\n");
-WorkType = QualType{ToEnum, QualifiersToApply};
+WorkType = QualType{ToEnum, FastQualifiersToApply};
   }
 
   // Check for pointer conversions.
@@ -1022,14 +1023,14 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
   if (FromPtr && ToPtr) {
 if (ToPtr->isVoidPointerType()) {
   LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. To void pointer.\n");
-  WorkType = QualType{ToPtr, QualifiersToApply};
+  WorkType = QualType{ToPtr, FastQualifiersToApply};
 }
 
 const auto *FromRecordPtr = FromPtr->getPointeeCXXRecordDecl();
 const auto *ToRecordPtr = ToPtr->getPointeeCXXRecordDecl();
 if (isDerivedToBase(FromRecordPtr, ToRecordPtr)) {
   LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. Derived* to 
Base*\n");
-  WorkType = QualType{ToPtr, QualifiersToApply};
+  WorkType = QualType{ToPtr, FastQualifiersToApply};
 }
   }
 
@@ -1039,7 +1040,7 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
   const auto *ToRecord = To->getAsCXXRecordDecl();
   if (isDerivedToBase(FromRecord, ToRecord)) {
 LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. Derived To Base.\n");
-WorkType = QualType{ToRecord->getTypeForDecl(), QualifiersToApply};
+WorkType = QualType{ToRecord->getTypeForDecl(), FastQualifiersToApply};
   }
 
   if (Ctx.getLangOpts().CPlusPlus17 && FromPtr && ToPtr) {
@@ -1054,7 +1055,7 @@ approximateStandardConversionSequence(const TheCheck 
, QualType From,
 !ToFunctionPtr->hasNoexceptExceptionSpec()) {
   LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. noexcept function "
  

[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)

2024-04-25 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

> Looking at the logs, and the error seems to be unrelated to the changes made 
> https://buildkite.com/llvm-project/clang-ci/builds/16430#018f132d-506e-440c-b18b-fed98237def9/54-5446

You can try using `--allow-empty` to do an empty commit to kick off the build 
again.

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


[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-04-25 Thread Yeting Kuo via cfe-commits

yetingk wrote:

I fix the issue by using feature to control the permission of experimental 
extension.

> Does this disable use of experimental extensions for a `.option arch` in an 
> inline assembly block without -menable-experimental-extensions.



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


[clang] Notifying assume directive as 'worked on'. (PR #90022)

2024-04-25 Thread Sandeep Kosuri via cfe-commits

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


[clang] 4b25508 - Notifying assume directive as 'worked on'. (#90022)

2024-04-25 Thread via cfe-commits

Author: SunilKuravinakop
Date: 2024-04-26T10:31:55+05:30
New Revision: 4b255085833b58392d7699aaf5c20ea49559fda9

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

LOG: Notifying assume directive as 'worked on'.  (#90022)

Notifying assume directive as 'worked on'. When checked on slack
channel, nobody was working on assume directive.

 Changes to be committed:
modified:   clang/docs/OpenMPSupport.rst

-

Co-authored-by: Sunil Kuravinakop

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index f8146bc365e833..5e63b2c0f0be6b 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -310,7 +310,9 @@ implementation.
 
+--+--+--+---+
 | misc | dispatch construct and function variant 
argument adjustment  | :part:`worked on`| D99537, D99679
|
 
+--+--+--+---+
-| misc | assume and assumes directives 
   | :part:`worked on`| 
  |
+| misc | assumes directives
   | :part:`worked on`| 
  |
++--+--+--+---+
+| misc | assume directive  
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | misc | nothing directive 
   | :good:`done` | D123286 
  |
 
+--+--+--+---+



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


[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-04-25 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk updated 
https://github.com/llvm/llvm-project/pull/89727

>From a43014cf3daa1b0fd9092bfe41da979205ba64aa Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 23 Apr 2024 02:16:04 -0700
Subject: [PATCH 1/4] [RISCV] Teach .option arch to support experimental
 extensions.

Previously .option arch denied extenions are not belongs to RISC-V features. But
experimental features have experimental- prefix, so .option arch can not
serve for experimental extension.
This patch uses the features of extensions to identify extension
existance.
---
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 7 ---
 llvm/test/MC/RISCV/option-arch.s   | 9 -
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 3f4a73ad89bf8a..80ff70f1095f4c 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2824,8 +2824,9 @@ bool RISCVAsmParser::parseDirectiveOption() {
 break;
   }
 
-  auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch);
-  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch ||
+  std::string & = RISCVISAInfo::getTargetFeatureForExtension(Arch);
+  auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature);
+  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature ||
   !RISCVISAInfo::isSupportedExtension(Arch)) {
 if (isDigit(Arch.back()))
   return Error(
@@ -2834,7 +2835,7 @@ bool RISCVAsmParser::parseDirectiveOption() {
 return Error(Loc, "unknown extension feature");
   }
 
-  Args.emplace_back(Type, Ext->Key);
+  Args.emplace_back(Type, Arch.str());
 
   if (Type == RISCVOptionArchArgType::Plus) {
 FeatureBitset OldFeatureBits = STI->getFeatureBits();
diff --git a/llvm/test/MC/RISCV/option-arch.s b/llvm/test/MC/RISCV/option-arch.s
index 6ee133c7159a27..40675f9e4b434b 100644
--- a/llvm/test/MC/RISCV/option-arch.s
+++ b/llvm/test/MC/RISCV/option-arch.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple riscv32 -show-encoding < %s \
 # RUN:   | FileCheck -check-prefixes=CHECK %s
 # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \
-# RUN:   | llvm-objdump  --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -d -M 
no-aliases - \
+# RUN:   | llvm-objdump  --triple=riscv32 
--mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefixes=CHECK-INST %s
 
 # Test '.option arch, +' and '.option arch, -' directive
@@ -78,6 +78,13 @@ lr.w t0, (t1)
 # CHECK: encoding: [0xb3,0x22,0x73,0x20]
 sh1add t0, t1, t2
 
+# Test experimental extension
+# CHECK: .option arch, +zicfiss
+.option arch, +zicfiss
+# CHECK-INST: sspopchk ra
+# CHECK: encoding: [0x73,0xc0,0xc0,0xcd]
+sspopchk ra
+
 # Test '.option arch, ' directive
 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
 .option arch, rv32i2p1_m2p0_a2p1_c2p0

>From 471abce617a9d18ef91370303eef90bab228d9d3 Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 23 Apr 2024 21:55:12 -0700
Subject: [PATCH 2/4] Make this pr obey menable-experimental-extensions.

---
 clang/lib/Driver/ToolChains/Clang.cpp  | 5 +
 clang/test/Driver/riscv-option-arch.s  | 5 +
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 6 ++
 3 files changed, 16 insertions(+)
 create mode 100644 clang/test/Driver/riscv-option-arch.s

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5894a48e0e378b..8b0f523763486f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8449,6 +8449,11 @@ void ClangAs::AddRISCVTargetArgs(const ArgList ,
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-riscv-add-build-attributes");
   }
+
+  if (!Args.hasArg(options::OPT_menable_experimental_extensions)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-riscv-disable-experimental-ext");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,
diff --git a/clang/test/Driver/riscv-option-arch.s 
b/clang/test/Driver/riscv-option-arch.s
new file mode 100644
index 00..8ce84dd8ffe79d
--- /dev/null
+++ b/clang/test/Driver/riscv-option-arch.s
@@ -0,0 +1,5 @@
+# RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
+# RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
+
+.option arch, +zicfiss
+# CHECK-ERR: Unexpected experimental extensions.
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 80ff70f1095f4c..6225e0707015fe 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed,
 
 static cl::opt 

[clang] [compiler-rt] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)

2024-04-25 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 d26002ac38ee1dea32053e7d12f1bb5dc420ac2d 
2fa7299db558c2a953f641ffe760369f31a98b3d -- 
clang/test/CodeGen/RISCV/riscv-inline-asm.c 
clang/test/CodeGen/attr-counted-by.c clang/test/CodeGenCXX/atomicinit.cpp 
clang/test/CodeGenCXX/auto-var-init.cpp 
clang/test/Profile/c-unreachable-after-switch.c 
compiler-rt/test/profile/Linux/counter_promo_for.c 
compiler-rt/test/profile/Linux/counter_promo_while.c 
llvm/lib/Analysis/ConstantFolding.cpp
``





View the diff from clang-format here.


``diff
diff --git a/compiler-rt/test/profile/Linux/counter_promo_for.c 
b/compiler-rt/test/profile/Linux/counter_promo_for.c
index aa77e6084b..d843510697 100644
--- a/compiler-rt/test/profile/Linux/counter_promo_for.c
+++ b/compiler-rt/test/profile/Linux/counter_promo_for.c
@@ -18,30 +18,30 @@ int g;
 __attribute__((noinline)) void bar(int i) { g += i; }
 
 __attribute__((noinline)) void foo(int n, int N) {
-// PROMO-LABEL: @foo
-// PROMO: load{{.*}}@__profc_foo{{.*}} 24){{.*}}
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 24){{.*}}
-// PROMO: load{{.*}}@__profc_foo, align
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo, align
-// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// PROMO: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
-//
-// NOPROMO-LABEL: @foo
-// NOPROMO: load{{.*}}@__profc_foo, align
-// NOPROMO-NEXT: add
-// NOPROMO-NEXT: store{{.*}}@__profc_foo, align
-// NOPROMO: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// NOPROMO-NEXT: add
-// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// NOPROMO: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
-// NOPROMO-NEXT: add
-// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  // PROMO-LABEL: @foo
+  // PROMO: load{{.*}}@__profc_foo{{.*}} 24){{.*}}
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 24){{.*}}
+  // PROMO: load{{.*}}@__profc_foo, align
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo, align
+  // PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // PROMO: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  //
+  // NOPROMO-LABEL: @foo
+  // NOPROMO: load{{.*}}@__profc_foo, align
+  // NOPROMO-NEXT: add
+  // NOPROMO-NEXT: store{{.*}}@__profc_foo, align
+  // NOPROMO: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // NOPROMO-NEXT: add
+  // NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // NOPROMO: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  // NOPROMO-NEXT: add
+  // NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
   int i;
   for (i = 0; i < N; i++) {
 if (i < n + 1)
diff --git a/compiler-rt/test/profile/Linux/counter_promo_while.c 
b/compiler-rt/test/profile/Linux/counter_promo_while.c
index c6ea3a7282..e0a9ee3c24 100644
--- a/compiler-rt/test/profile/Linux/counter_promo_while.c
+++ b/compiler-rt/test/profile/Linux/counter_promo_while.c
@@ -16,27 +16,27 @@
 int g;
 __attribute__((noinline)) void bar(int i) { g += i; }
 __attribute__((noinline)) void foo(int n, int N) {
-// PROMO-LABEL: @foo
-// PROMO: load{{.*}}@__profc_foo, align
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo, align
-// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
-// PROMO-NEXT: add
-// PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
-//
-// NOPROMO-LABEL: @foo
-// NOPROMO: load{{.*}}@__profc_foo, align
-// NOPROMO-NEXT: add
-// NOPROMO-NEXT: store{{.*}}@__profc_foo, align
-// NOPROMO: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// NOPROMO-NEXT: add
-// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
-// NOPROMO: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
-// NOPROMO-NEXT: add
-// NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  // PROMO-LABEL: @foo
+  // PROMO: load{{.*}}@__profc_foo, align
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo, align
+  // PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // PROMO-NEXT: load{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  // PROMO-NEXT: add
+  // PROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 16){{.*}}
+  //
+  // NOPROMO-LABEL: @foo
+  // NOPROMO: load{{.*}}@__profc_foo, align
+  // NOPROMO-NEXT: add
+  // NOPROMO-NEXT: store{{.*}}@__profc_foo, align
+  // NOPROMO: load{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // NOPROMO-NEXT: add
+  // NOPROMO-NEXT: store{{.*}}@__profc_foo{{.*}} 8){{.*}}
+  // NOPROMO: 

[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)

2024-04-25 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

Here is a reduced testcase for the OpenMP test failure:

```c++
#pragma omp declare target

static long double ld_return1e() { return 0; }

void external() {
  void *p1 = reinterpret_cast(_return1e);
}

#pragma omp end declare target
```

When built with the following command:

> clang -cc1 -fopenmp -triple nvptx64-unknown-unknown -aux-triple 
> x86_64-unknown-linux test.cpp -fopenmp-is-target-device -fsyntax-only

Here are the diagnostics before this patch:

```console
test.cpp:6:39: error: 'ld_return1e' requires 128 bit size 'long double' type 
support, but target 'nvptx64-unknown-unknown' does not support it
6 |   void *p1 = reinterpret_cast(_return1e);
  |   ^
test.cpp:3:20: note: 'ld_return1e' defined here
3 | static long double ld_return1e() { return 0; }
  |^
1 error generated
```

and here are the diagnostics after this patch:

```console
test.cpp:6:39: error: 'ld_return1e' requires 128 bit size 'long double' type 
support, but target 'nvptx64-unknown-unknown' does not support it
6 |   void *p1 = reinterpret_cast(_return1e);
  |   ^
test.cpp:3:20: note: 'ld_return1e' defined here
3 | static long double ld_return1e() { return 0; }
  |^
test.cpp:3:20: error: 'ld_return1e' requires 128 bit size 'long double' type 
support, but target 'nvptx64-unknown-unknown' does not support it
3 | static long double ld_return1e() { return 0; }
  |^
test.cpp:6:39: note: called by 'external'
6 |   void *p1 = reinterpret_cast(_return1e);
  |   ^
test.cpp:3:20: note: 'ld_return1e' defined here
3 | static long double ld_return1e() { return 0; }
  |^
2 errors generated.
```

Basically, the patch somehow causes the same diagnostic to be issued a second 
time at a different location.

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


[clang] [clang] pointer to member with qualified-id enclosed in parentheses in unevaluated context should be invalid (PR #89713)

2024-04-25 Thread via cfe-commits


@@ -27,3 +26,20 @@ namespace rdar10544564 {
   X (Y::*func_mem_ptr1)() = ::memfunc1;
   X (Y::*func_mem_ptr2)() = ::memfunc2;
 }
+
+namespace test2 {
+  struct A {
+int val;
+void func() {}
+  };
+
+  void test() {
+decltype(&(A::val)) ptr1; // expected-error {{invalid use of non-static 
data member 'val'}}
+int A::* ptr2 = &(A::val); // expected-error {{invalid use of non-static 
data member 'val'}}
+
+// FIXME: Error messages in these cases are less than clear, we can do
+// better.
+int size = sizeof(&(A::func)); // expected-error {{call to non-static 
member function without an object argument}}
+void (A::* ptr3)() = &(A::func); // expected-error {{call to non-static 
member function without an object argument}}

zwuis wrote:

> This inconsistency is irrelevant to issue 40906. I am confused about the 
> following questions:
> 
> 1. Do I need to remove these tests?
> 2. Do I need to fix this inconsistency in this PR, or a new PR?
> 3. Should I open an issue for it?

@cor3ntin Could you give me some ideas for these questions? Thank you!

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


[clang] [llvm] [RISCV] Add processor definition for XiangShan-KunMingHu (PR #89359)

2024-04-25 Thread via cfe-commits

https://github.com/Khao7342 updated 
https://github.com/llvm/llvm-project/pull/89359

>From e51498e67409836b099fa892b17d71e44a7d403b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=83=9D=E5=BA=B7=E8=BE=BE?= 
Date: Fri, 19 Apr 2024 17:18:10 +0800
Subject: [PATCH] [RISCV] Add processor definition for XiangShan-KunMingHu

This pull request adds definitions for the XiangShan-KunMingHu processor. 
"XiangShan" is a high-performance open-source RISC-V processor project, and 
"KunMingHu" architecture is its third generation. Official documentation can be 
found at: [documentation](https://xiangshan-doc.readthedocs.io/zh-cn/latest/).

Currently, the KunMingHu core 
supports"RV64IMAFDCV_zba_zbb_zbc_zbs_zbkb_zbkc_zbkx_zknd_zkne_zknh_zksed_zksh_svinval_zicbom_zicboz_zicsr_zifencei".
 The scheduler model and other components will be submitted in subsequent 
patches.

Co-Authored-By: Bhe6669 <167076958+bhe6...@users.noreply.github.com>
Co-Authored-By: huxuan0307 <39661208+huxuan0...@users.noreply.github.com>
---
 clang/test/Driver/riscv-cpus.c| 36 +++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 27 +
 3 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba34..be13c17df04742 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -31,6 +31,39 @@
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-feature" "+zks" "-target-feature" 
"+zksed" "-target-feature" "+zksh" "-target-feature" "+svinval"
 // MCPU-XIANGSHAN-NANHU-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=xiangshan-kunminghu | 
FileCheck -check-prefix=MCPU-XIANGSHAN-KUNMINGHU %s
+// MCPU-XIANGSHAN-KUNMINGHU: "-nostdsysteminc" "-target-cpu" 
"xiangshan-kunminghu"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+m"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+a"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+f"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+d"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+c"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+v"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicbom" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicboz" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zicsr" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zifencei"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zba" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbb" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbc"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbkb" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbkc" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbkx" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zbs"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zkn" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zknd" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zkne" 
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zknh"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zve32f"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zve32x"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zve64d"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zve64f"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zve64x"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zvl128b"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zvl32b"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-feature" "+zvl64b"
+// MCPU-XIANGSHAN-KUNMINGHU-SAME: "-target-abi" "lp64d"
+
 // We cannot check much for -mcpu=native, but it should be replaced by a valid 
CPU string.
 // RUN: %clang --target=riscv64 -### -c %s -mcpu=native 2> %t.err || true
 // RUN: FileCheck --input-file=%t.err -check-prefix=MCPU-NATIVE %s
@@ -76,6 +109,9 @@
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=xiangshan-nanhu | 
FileCheck -check-prefix=MTUNE-XIANGSHAN-NANHU %s
 // MTUNE-XIANGSHAN-NANHU: "-tune-cpu" "xiangshan-nanhu"
 
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=xiangshan-kunminghu | 
FileCheck -check-prefix=MTUNE-XIANGSHAN-KUNMINGHU %s
+// MTUNE-XIANGSHAN-KUNMINGHU: "-tune-cpu" "xiangshan-kunminghu"
+
 // Check mtune alias CPU has resolved to the right CPU according XLEN.
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=generic | FileCheck 
-check-prefix=MTUNE-GENERIC-32 %s
 // MTUNE-GENERIC-32: "-tune-cpu" "generic"
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9c91c4157cd6a0..349785fed7dc72 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown 

[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-04-25 Thread Owen Pan via cfe-commits

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


[clang] 2de0bed - [clang-format] Do not update cursor pos if no includes replacement (#77456)

2024-04-25 Thread via cfe-commits

Author: NorthBlue333
Date: 2024-04-25T20:34:49-07:00
New Revision: 2de0bedfebb77a6c8a5b0d00902f796fa4022fd6

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

LOG: [clang-format] Do not update cursor pos if no includes replacement (#77456)

Fix https://github.com/llvm/llvm-project/issues/77450.

-

Signed-off-by: NorthBlue333 
Co-authored-by: Owen Pan 

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 373dd4e60bf33f..c8d8ec3afbd990 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3116,6 +3116,7 @@ static void sortCppIncludes(const FormatStyle ,
 return;
   }
 
+  const auto OldCursor = Cursor ? *Cursor : 0;
   std::string result;
   for (unsigned Index : Indices) {
 if (!result.empty()) {
@@ -3139,6 +3140,8 @@ static void sortCppIncludes(const FormatStyle ,
   // the entire range of blocks. Otherwise, no replacement is generated.
   if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
  IncludesBeginOffset, IncludesBlockSize {
+if (Cursor)
+  *Cursor = OldCursor;
 return;
   }
 

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index 772eb53806b4b1..824fa0078cd037 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -6,19 +6,19 @@
 //
 
//===--===//
 
-#include "FormatTestUtils.h"
+#include "FormatTestBase.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
-#define DEBUG_TYPE "format-test"
+#define DEBUG_TYPE "sort-includes-test"
 
 namespace clang {
 namespace format {
 namespace {
 
-class SortIncludesTest : public ::testing::Test {
+class SortIncludesTest : public test::FormatTestBase {
 protected:
   std::vector GetCodeRange(StringRef Code) {
 return std::vector(1, tooling::Range(0, Code.size()));
@@ -821,6 +821,122 @@ TEST_F(SortIncludesTest, 
CalculatesCorrectCursorPositionWithRegrouping) {
   EXPECT_EQ(27u, newCursor(Code, 28)); // Start of last line
 }
 
+TEST_F(SortIncludesTest,
+   CalculatesCorrectCursorPositionWhenNoReplacementsWithRegroupingAndCRLF) 
{
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  FmtStyle.LineEnding = FormatStyle::LE_CRLF;
+  Style.IncludeCategories = {
+  {"^\"a\"", 0, 0, false}, {"^\"b\"", 1, 1, false}, {".*", 2, 2, false}};
+  std::string Code = "#include \"a\"\r\n" // Start of line: 0
+ "\r\n"   // Start of line: 14
+ "#include \"b\"\r\n" // Start of line: 16
+ "\r\n"   // Start of line: 30
+ "#include \"c\"\r\n" // Start of line: 32
+ "\r\n"   // Start of line: 46
+ "int i;";// Start of line: 48
+  verifyNoChange(Code);
+  EXPECT_EQ(0u, newCursor(Code, 0));
+  EXPECT_EQ(14u, newCursor(Code, 14));
+  EXPECT_EQ(16u, newCursor(Code, 16));
+  EXPECT_EQ(30u, newCursor(Code, 30));
+  EXPECT_EQ(32u, newCursor(Code, 32));
+  EXPECT_EQ(46u, newCursor(Code, 46));
+  EXPECT_EQ(48u, newCursor(Code, 48));
+}
+
+TEST_F(
+SortIncludesTest,
+
CalculatesCorrectCursorPositionWhenRemoveLinesReplacementsWithRegroupingAndCRLF)
 {
+  Style.IncludeBlocks = Style.IBS_Regroup;
+  FmtStyle.LineEnding = FormatStyle::LE_CRLF;
+  Style.IncludeCategories = {{".*", 0, 0, false}};
+  std::string Code = "#include \"a\"\r\n" // Start of line: 0
+ "\r\n"   // Start of line: 14
+ "#include \"b\"\r\n" // Start of line: 16
+ "\r\n"   // Start of line: 30
+ "#include \"c\"\r\n" // Start of line: 32
+ "\r\n"   // Start of line: 46
+ "int i;";// Start of line: 48
+  std::string Expected = "#include \"a\"\r\n" // Start of line: 0
+ "#include \"b\"\r\n" // Start of line: 14
+ "#include \"c\"\r\n" // Start of line: 28
+ "\r\n"   // Start of line: 42
+ "int i;";// Start of line: 44
+  EXPECT_EQ(Expected, sort(Code));
+  EXPECT_EQ(0u, newCursor(Code, 0));
+  EXPECT_EQ(
+  14u,
+  newCursor(Code, 14)); // cursor on empty line in include block is ignored
+  EXPECT_EQ(14u, newCursor(Code, 16));
+  EXPECT_EQ(
+  30u,
+  newCursor(Code, 30)); // cursor on empty line in include block 

[clang] [clang] MangledSymbol: remove pointless copy of vector (PR #90012)

2024-04-25 Thread Andrew Sukach via cfe-commits

soukatch wrote:

Looking at the logs, and the error seems to be unrelated to the changes made
https://buildkite.com/llvm-project/clang-ci/builds/16430#018f132d-506e-440c-b18b-fed98237def9/54-5446

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


[clang] [clang-format] Add a space after a word token only if required (PR #90161)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #78166.

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


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+7-19) 
- (modified) clang/unittests/Format/FormatTest.cpp (+17-8) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index cdfb4256e41d93..63629fa743184e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4834,10 +4834,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine ,
 Right.is(TT_TemplateOpener)) {
   return true;
 }
-if (Left.is(tok::identifier) && Right.is(tok::numeric_constant) &&
-Right.TokenText[0] == '.') {
-  return false;
-}
+if (Left.Tok.getIdentifierInfo() && Right.is(tok::numeric_constant))
+  return Right.TokenText[0] != '.';
   } else if (Style.isProto()) {
 if (Right.is(tok::period) &&
 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
@@ -5266,21 +5264,11 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine ,
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
-if (Right.isNot(tok::l_paren)) {
-  // The alternative operators for ~ and ! are "compl" and "not".
-  // If they are used instead, we do not want to combine them with
-  // the token to the right, unless that is a left paren.
-  if (Left.is(tok::exclaim) && Left.TokenText == "not")
-return true;
-  if (Left.is(tok::tilde) && Left.TokenText == "compl")
-return true;
-  // Lambda captures allow for a lone &, so "&]" needs to be properly
-  // handled.
-  if (Left.is(tok::amp) && Right.is(tok::r_square))
-return Style.SpacesInSquareBrackets;
-}
-return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
-   Right.is(TT_BinaryOperator);
+// Lambda captures allow for a lone &, so "&]" needs to be properly
+// handled.
+if (Left.is(tok::amp) && Right.is(tok::r_square))
+  return Style.SpacesInSquareBrackets;
+return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim);
   }
 
   // If the next token is a binary operator or a selector name, we have
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index bc61b9c089e922..8ecc1188a127a5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -24507,16 +24507,25 @@ TEST_F(FormatTest, AlternativeOperators) {
   verifyFormat("int a compl(5);");
   verifyFormat("int a not(5);");
 
-  /* FIXME handle alternate tokens
-   * https://en.cppreference.com/w/cpp/language/operator_alternative
-  // alternative tokens
-  verifyFormat("compl foo();"); //  ~foo();
-  verifyFormat("foo() <%%>;");  // foo();
-  verifyFormat("void foo() <%%>;"); // void foo(){}
-  verifyFormat("int a <:1:>;"); // int a[1];[
+  verifyFormat("compl foo();"); // ~foo();
+  verifyFormat("foo() <%%>");   // foo() {}
+  verifyFormat("void foo() <%%>");  // void foo() {}
+  verifyFormat("int a<:1:>;");  // int a[1];
   verifyFormat("%:define ABC abc"); // #define ABC abc
   verifyFormat("%:%:"); // ##
-  */
+
+  verifyFormat("a = v(not;);\n"
+   "b = v(not+);\n"
+   "c = v(not x);\n"
+   "d = v(not 1);\n"
+   "e = v(not 123.f);");
+
+  verifyNoChange("#define ASSEMBLER_INSTRUCTION_LIST(V)  \\\n"
+ "  V(and)   \\\n"
+ "  V(not)   \\\n"
+ "  V(not!)  \\\n"
+ "  V(other)",
+ getLLVMStyleWithColumns(40));
 }
 
 TEST_F(FormatTest, STLWhileNotDefineChed) {

``




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


[clang] [clang-format] Add a space after a word token only if required (PR #90161)

2024-04-25 Thread Owen Pan via cfe-commits

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

Fixes #78166.

>From 3f59076142bd6a87f4875dc79e95e4570f4af7c2 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Thu, 25 Apr 2024 20:08:03 -0700
Subject: [PATCH] [clang-format] Add a space after a word token only if
 required

Fixes #78166.
---
 clang/lib/Format/TokenAnnotator.cpp   | 26 +++---
 clang/unittests/Format/FormatTest.cpp | 25 +
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index cdfb4256e41d93..63629fa743184e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4834,10 +4834,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine ,
 Right.is(TT_TemplateOpener)) {
   return true;
 }
-if (Left.is(tok::identifier) && Right.is(tok::numeric_constant) &&
-Right.TokenText[0] == '.') {
-  return false;
-}
+if (Left.Tok.getIdentifierInfo() && Right.is(tok::numeric_constant))
+  return Right.TokenText[0] != '.';
   } else if (Style.isProto()) {
 if (Right.is(tok::period) &&
 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
@@ -5266,21 +5264,11 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine ,
 return true;
   }
   if (Left.is(TT_UnaryOperator)) {
-if (Right.isNot(tok::l_paren)) {
-  // The alternative operators for ~ and ! are "compl" and "not".
-  // If they are used instead, we do not want to combine them with
-  // the token to the right, unless that is a left paren.
-  if (Left.is(tok::exclaim) && Left.TokenText == "not")
-return true;
-  if (Left.is(tok::tilde) && Left.TokenText == "compl")
-return true;
-  // Lambda captures allow for a lone &, so "&]" needs to be properly
-  // handled.
-  if (Left.is(tok::amp) && Right.is(tok::r_square))
-return Style.SpacesInSquareBrackets;
-}
-return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
-   Right.is(TT_BinaryOperator);
+// Lambda captures allow for a lone &, so "&]" needs to be properly
+// handled.
+if (Left.is(tok::amp) && Right.is(tok::r_square))
+  return Style.SpacesInSquareBrackets;
+return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim);
   }
 
   // If the next token is a binary operator or a selector name, we have
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index bc61b9c089e922..8ecc1188a127a5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -24507,16 +24507,25 @@ TEST_F(FormatTest, AlternativeOperators) {
   verifyFormat("int a compl(5);");
   verifyFormat("int a not(5);");
 
-  /* FIXME handle alternate tokens
-   * https://en.cppreference.com/w/cpp/language/operator_alternative
-  // alternative tokens
-  verifyFormat("compl foo();"); //  ~foo();
-  verifyFormat("foo() <%%>;");  // foo();
-  verifyFormat("void foo() <%%>;"); // void foo(){}
-  verifyFormat("int a <:1:>;"); // int a[1];[
+  verifyFormat("compl foo();"); // ~foo();
+  verifyFormat("foo() <%%>");   // foo() {}
+  verifyFormat("void foo() <%%>");  // void foo() {}
+  verifyFormat("int a<:1:>;");  // int a[1];
   verifyFormat("%:define ABC abc"); // #define ABC abc
   verifyFormat("%:%:"); // ##
-  */
+
+  verifyFormat("a = v(not;);\n"
+   "b = v(not+);\n"
+   "c = v(not x);\n"
+   "d = v(not 1);\n"
+   "e = v(not 123.f);");
+
+  verifyNoChange("#define ASSEMBLER_INSTRUCTION_LIST(V)  \\\n"
+ "  V(and)   \\\n"
+ "  V(not)   \\\n"
+ "  V(not!)  \\\n"
+ "  V(other)",
+ getLLVMStyleWithColumns(40));
 }
 
 TEST_F(FormatTest, STLWhileNotDefineChed) {

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


[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

2024-04-25 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> I'm planning to revise the patch to make the following changes:
> 
>1. Put the new behaviour behind a config option (I'm thinking `Hover` --> 
> `ShowFields`)
>2. Add C language mode tests
>3. Use `PrintingCallbacks` instead of a `PrintingPolicy` flag

These changes have been made in the latest version of the patch.

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


[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

2024-04-25 Thread Nathan Ridge via cfe-commits

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


[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

2024-04-25 Thread Nathan Ridge via cfe-commits

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

>From fcb2ac4c68554d9c708b3db779b5570ff94725e8 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 21 Apr 2024 20:30:16 -0400
Subject: [PATCH] [clangd] Show struct fields and enum members in hovers

Fixes https://github.com/clangd/clangd/issues/959
---
 clang-tools-extra/clangd/Config.h |   3 +
 clang-tools-extra/clangd/ConfigCompile.cpp|   6 +
 clang-tools-extra/clangd/ConfigFragment.h |   5 +-
 clang-tools-extra/clangd/ConfigYAML.cpp   |   4 +
 clang-tools-extra/clangd/Hover.cpp|  41 +
 .../clangd/unittests/ConfigYAMLTests.cpp  |  13 ++
 .../clangd/unittests/HoverTests.cpp   | 157 +-
 clang/include/clang/AST/PrettyPrinter.h   |  13 ++
 clang/lib/AST/DeclPrinter.cpp |  32 +++-
 clang/unittests/AST/DeclPrinterTest.cpp   |  34 +++-
 10 files changed, 295 insertions(+), 13 deletions(-)

diff --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 4371c80a6c5877..3b6658e7ff034f 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -136,6 +136,9 @@ struct Config {
   struct {
 /// Whether hover show a.k.a type.
 bool ShowAKA = true;
+
+/// Whether to show struct fields
+bool ShowFields = false;
   } Hover;
 
   struct {
diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 5bb2eb4a9f803f..714a04fc77a5fc 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -616,6 +616,12 @@ struct FragmentCompiler {
 C.Hover.ShowAKA = ShowAKA;
   });
 }
+if (F.ShowFields) {
+  Out.Apply.push_back(
+  [ShowFields(**F.ShowFields)](const Params &, Config ) {
+C.Hover.ShowFields = ShowFields;
+  });
+}
   }
 
   void compile(Fragment::InlayHintsBlock &) {
diff --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index 7fa61108c78a05..ccbc412f4fc533 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -309,8 +309,11 @@ struct Fragment {
 
   /// Describes hover preferences.
   struct HoverBlock {
-/// Whether hover show a.k.a type.
+/// Whether hovers show a.k.a type.
 std::optional> ShowAKA;
+
+/// Whether hovers show struct fields
+std::optional> ShowFields;
   };
   HoverBlock Hover;
 
diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index ce09af819247ae..68e4d66763d16c 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -235,6 +235,10 @@ class Parser {
   if (auto ShowAKA = boolValue(N, "ShowAKA"))
 F.ShowAKA = *ShowAKA;
 });
+Dict.handle("ShowFields", [&](Node ) {
+  if (auto ShowFields = boolValue(N, "ShowFields"))
+F.ShowFields = *ShowFields;
+});
 Dict.parse(N);
   }
 
diff --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 06b949bc4a2b55..db4049402f8fc0 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -66,12 +66,53 @@ namespace clang {
 namespace clangd {
 namespace {
 
+// A PrintingCallbacks implementation that prints public fields of
+// record types and enum members. Meant to be used with TerseOutput=true.
+class ClangdPrintingCallbacks : public PrintingCallbacks {
+public:
+  virtual ~ClangdPrintingCallbacks() = default;
+
+  void summarizeTagDecl(raw_ostream , const TagDecl *D,
+const PrintingPolicy ) const override {
+if (!Config::current().Hover.ShowFields) {
+  Out << " {}";
+  return;
+}
+
+// Don't worry about the details of the whitespace, e.g. space vs. newline,
+// as the printed definition will be passed through clang-format before
+// being sent to the client.
+Out << " { ";
+const bool IsRecord = isa(D);
+for (DeclContext::decl_iterator Member = D->decls_begin(),
+MemberEnd = D->decls_end();
+ Member != MemberEnd; ++Member) {
+  if (isa(*Member) ||
+  (isa(*Member) &&
+   dyn_cast(*Member)->getAccess() == AS_public)) {
+Member->print(Out, PP, 1);
+if (IsRecord) {
+  Out << "; ";
+} else {
+  DeclContext::decl_iterator Next = Member;
+  ++Next;
+  if (Next != MemberEnd)
+Out << ", ";
+}
+  }
+}
+Out << "}";
+  }
+};
+
 PrintingPolicy getPrintingPolicy(PrintingPolicy Base) {
+  static ClangdPrintingCallbacks Callbacks;
   Base.AnonymousTagLocations = false;
   Base.TerseOutput = true;
   Base.PolishForDeclaration = true;
   Base.ConstantsAsWritten = true;
   Base.SuppressTemplateArgsInCXXConstructors = true;
+  Base.Callbacks = 
   return Base;
 

[clang] [Clang][C++23] Core language changes from P1467R9 extended floating-point types and standard names. (PR #78503)

2024-04-25 Thread M. Zeeshan Siddiqui via cfe-commits

codemzs wrote:

> @codemzs Any news? Thanks a lot for your work!

@cor3ntin Sorry for the delay, I plan to get back to this PR in the next few 
weeks. Do you need this change for something?

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


[clang] [CUDA] make kernel stub ICF-proof (PR #90155)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Yaxun (Sam) Liu (yxsamliu)


Changes

MSVC linker merges functions having comdat which have identical set of 
instructions. CUDA uses kernel stub function as key to look up kernels in 
device executables. If kernel stub function for different kernels are merged by 
ICF, incorrect kernels will be launched.

To prevent ICF from merging kernel stub functions, an unique global variable is 
created for each kernel stub function having comdat and a store is added to the 
kernel stub function. This makes the set of instructions in each kernel 
function unique.

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

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGCUDANV.cpp (+28) 
- (modified) clang/test/CodeGenCUDA/kernel-stub-name.cu (+55-40) 


``diff
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 370642cb3d5364..4835ba4841dec4 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -424,6 +424,34 @@ void 
CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction ,
   CGM.CreateRuntimeFunction(FTy, LaunchKernelName);
   CGF.EmitCall(FI, CGCallee::forDirect(cudaLaunchKernelFn), ReturnValueSlot(),
LaunchKernelArgs);
+
+  // To prevent CUDA device stub functions from being merged by ICF in MSVC
+  // environment, create an unique global variable for each kernel and write to
+  // the variable in the device stub.
+  if (CGM.getContext().getTargetInfo().getCXXABI().isMicrosoft() &&
+  !CGF.getLangOpts().HIP) {
+llvm::Function *KernelFunction = llvm::cast(Kernel);
+if (KernelFunction->hasComdat()) {
+  std::string KernelName = KernelFunction->getName().str();
+  std::string GlobalVarName = KernelName + ".id";
+
+  llvm::GlobalVariable *HandleVar =
+  CGM.getModule().getNamedGlobal(GlobalVarName);
+  if (!HandleVar) {
+HandleVar = new llvm::GlobalVariable(
+CGM.getModule(), CGM.Int8Ty,
+/*Constant=*/false, KernelFunction->getLinkage(),
+llvm::ConstantInt::get(CGM.Int8Ty, 0), GlobalVarName);
+HandleVar->setDSOLocal(KernelFunction->isDSOLocal());
+HandleVar->setVisibility(KernelFunction->getVisibility());
+HandleVar->setComdat(CGM.getModule().getOrInsertComdat(GlobalVarName));
+  }
+
+  CGF.Builder.CreateAlignedStore(llvm::ConstantInt::get(CGM.Int8Ty, 1),
+ HandleVar, CharUnits::One());
+}
+  }
+
   CGF.EmitBranch(EndBlock);
 
   CGF.EmitBlock(EndBlock);
diff --git a/clang/test/CodeGenCUDA/kernel-stub-name.cu 
b/clang/test/CodeGenCUDA/kernel-stub-name.cu
index 23df7f5d721b56..00311109cf32fb 100644
--- a/clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ b/clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -2,7 +2,7 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
-// RUN:   | FileCheck -check-prefixes=CHECK,GNU %s
+// RUN:   | FileCheck -check-prefixes=CHECK,GNU,GNU-HIP,HIP %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
@@ -11,7 +11,12 @@
 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
 // RUN: -aux-triple amdgcn-amd-amdhsa -fcuda-include-gpubinary \
 // RUN: %t -o - -x hip\
-// RUN:   | FileCheck -check-prefixes=CHECK,MSVC %s
+// RUN:   | FileCheck -check-prefixes=CHECK,MSVC,MSVC-HIP,HIP %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
+// RUN: -aux-triple nvptx64 -fcuda-include-gpubinary \
+// RUN: %t -target-sdk-version=9.2 -o - \
+// RUN:   | FileCheck -check-prefixes=CHECK,MSVC,CUDA %s
 
 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
 // RUN: -aux-triple amdgcn-amd-amdhsa -fcuda-include-gpubinary \
@@ -22,19 +27,21 @@
 
 // Check kernel handles are emitted for non-MSVC target but not for MSVC 
target.
 
-// GNU: @[[HCKERN:ckernel]] = constant ptr @[[CSTUB:__device_stub__ckernel]], 
align 8
-// GNU: @[[HNSKERN:_ZN2ns8nskernelEv]] = constant ptr 
@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]], align 8
-// GNU: @[[HTKERN:_Z10kernelfuncIiEvv]] = linkonce_odr constant ptr 
@[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]], comdat, align 8
-// GNU: @[[HDKERN:_Z11kernel_declv]] = external constant ptr, align 8
-// GNU: @[[HTDKERN:_Z20template_kernel_declIiEvT_]] = external constant ptr, 
align 8
-
-// MSVC: @[[HCKERN:ckernel]] = dso_local constant ptr 
@[[CSTUB:__device_stub__ckernel]], align 8
-// MSVC: @[[HNSKERN:"\?nskernel@ns@@YAXXZ.*"]] = dso_local constant ptr 
@[[NSSTUB:"\?__device_stub__nskernel@ns@@YAXXZ"]], align 8
-// MSVC: @[[HTKERN:"\?\?\$kernelfunc@H@@YAXXZ.*"]] = linkonce_odr dso_local 
constant ptr @[[TSTUB:"\?\?\$__device_stub__kernelfunc@H@@YAXXZ.*"]], comdat, 
align 8
-// MSVC: @[[HDKERN:"\?kernel_decl@@YAXXZ.*"]] = 

[clang] [CUDA] make kernel stub ICF-proof (PR #90155)

2024-04-25 Thread Yaxun Liu via cfe-commits

https://github.com/yxsamliu created 
https://github.com/llvm/llvm-project/pull/90155

MSVC linker merges functions having comdat which have identical set of 
instructions. CUDA uses kernel stub function as key to look up kernels in 
device executables. If kernel stub function for different kernels are merged by 
ICF, incorrect kernels will be launched.

To prevent ICF from merging kernel stub functions, an unique global variable is 
created for each kernel stub function having comdat and a store is added to the 
kernel stub function. This makes the set of instructions in each kernel 
function unique.

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

>From 7b696d8c21c052fd17b8062f5b314a0248c0e33f Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" 
Date: Thu, 25 Apr 2024 22:23:26 -0400
Subject: [PATCH] [CUDA] make kernel stub ICF-proof

MSVC linker merges functions having comdat which have identical
set of instructions. CUDA uses kernel stub function as key to
look up kernels in device executables. If kernel stub function
for different kernels are merged by ICF, incorrect kernels
will be launched.

To prevent ICF from merging kernel stub functions, an unique
global variable is created for each kernel stub function
having comdat and a store is added to the kernel stub function.
This makes the set of instructions in each kernel function
unique.

Fixes: https://github.com/llvm/llvm-project/issues/3
---
 clang/lib/CodeGen/CGCUDANV.cpp | 28 +++
 clang/test/CodeGenCUDA/kernel-stub-name.cu | 95 +-
 2 files changed, 83 insertions(+), 40 deletions(-)

diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 370642cb3d5364..4835ba4841dec4 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -424,6 +424,34 @@ void 
CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction ,
   CGM.CreateRuntimeFunction(FTy, LaunchKernelName);
   CGF.EmitCall(FI, CGCallee::forDirect(cudaLaunchKernelFn), ReturnValueSlot(),
LaunchKernelArgs);
+
+  // To prevent CUDA device stub functions from being merged by ICF in MSVC
+  // environment, create an unique global variable for each kernel and write to
+  // the variable in the device stub.
+  if (CGM.getContext().getTargetInfo().getCXXABI().isMicrosoft() &&
+  !CGF.getLangOpts().HIP) {
+llvm::Function *KernelFunction = llvm::cast(Kernel);
+if (KernelFunction->hasComdat()) {
+  std::string KernelName = KernelFunction->getName().str();
+  std::string GlobalVarName = KernelName + ".id";
+
+  llvm::GlobalVariable *HandleVar =
+  CGM.getModule().getNamedGlobal(GlobalVarName);
+  if (!HandleVar) {
+HandleVar = new llvm::GlobalVariable(
+CGM.getModule(), CGM.Int8Ty,
+/*Constant=*/false, KernelFunction->getLinkage(),
+llvm::ConstantInt::get(CGM.Int8Ty, 0), GlobalVarName);
+HandleVar->setDSOLocal(KernelFunction->isDSOLocal());
+HandleVar->setVisibility(KernelFunction->getVisibility());
+HandleVar->setComdat(CGM.getModule().getOrInsertComdat(GlobalVarName));
+  }
+
+  CGF.Builder.CreateAlignedStore(llvm::ConstantInt::get(CGM.Int8Ty, 1),
+ HandleVar, CharUnits::One());
+}
+  }
+
   CGF.EmitBranch(EndBlock);
 
   CGF.EmitBlock(EndBlock);
diff --git a/clang/test/CodeGenCUDA/kernel-stub-name.cu 
b/clang/test/CodeGenCUDA/kernel-stub-name.cu
index 23df7f5d721b56..00311109cf32fb 100644
--- a/clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ b/clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -2,7 +2,7 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
-// RUN:   | FileCheck -check-prefixes=CHECK,GNU %s
+// RUN:   | FileCheck -check-prefixes=CHECK,GNU,GNU-HIP,HIP %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -fcuda-include-gpubinary %t -o - -x hip\
@@ -11,7 +11,12 @@
 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
 // RUN: -aux-triple amdgcn-amd-amdhsa -fcuda-include-gpubinary \
 // RUN: %t -o - -x hip\
-// RUN:   | FileCheck -check-prefixes=CHECK,MSVC %s
+// RUN:   | FileCheck -check-prefixes=CHECK,MSVC,MSVC-HIP,HIP %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
+// RUN: -aux-triple nvptx64 -fcuda-include-gpubinary \
+// RUN: %t -target-sdk-version=9.2 -o - \
+// RUN:   | FileCheck -check-prefixes=CHECK,MSVC,CUDA %s
 
 // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm %s \
 // RUN: -aux-triple amdgcn-amd-amdhsa -fcuda-include-gpubinary \
@@ -22,19 +27,21 @@
 
 // Check kernel handles are emitted for non-MSVC target but not for MSVC 
target.
 
-// GNU: @[[HCKERN:ckernel]] = constant ptr @[[CSTUB:__device_stub__ckernel]], 
align 8
-// GNU: @[[HNSKERN:_ZN2ns8nskernelEv]] = constant ptr 
@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]], align 8
-// GNU: 

[clang] [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, RefPtr, and their variants. (PR #90153)

2024-04-25 Thread Artem Dergachev via cfe-commits

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

LGTM!

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


[clang] Improve documented sampling profiler steps to best known methods (PR #88438)

2024-04-25 Thread Tim Creech via cfe-commits

https://github.com/tcreech-intel updated 
https://github.com/llvm/llvm-project/pull/88438

>From fe3404cbdf78b434f16f8351dc242175b4543112 Mon Sep 17 00:00:00 2001
From: Tim Creech 
Date: Thu, 11 Apr 2024 16:03:52 -0400
Subject: [PATCH 1/3] Improve documented sampling profiler steps to best known
 methods

1. Add `-fdebug-info-for-profiling -funique-internal-linkage-names`,
   which improve the usefulness of debug info for profiling.

2. Recommend the use of `br_inst_retired.near_taken:uppp`, which
   provides the most precise results on supporting hardware.  Mention
   `branches:u` as a more portable backup.

   Both should portray execution counts better than the default event
   (`cycles`) and have a better chance of working as an unprivileged
   user due to the `:u` modifier.
---
 clang/docs/UsersManual.rst | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index c464bc3a69adc5..818841285cfae5 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2443,13 +2443,15 @@ usual build cycle when using sample profilers for 
optimization:
usual build flags that you always build your application with. The only
requirement is that DWARF debug info including source line information is
generated. This DWARF information is important for the profiler to be able
-   to map instructions back to source line locations.
+   to map instructions back to source line locations. The usefulness of this
+   DWARF information can be improved with the ``-fdebug-info-for-profiling``
+   and ``-funique-internal-linkage-names`` options.
 
-   On Linux, ``-g`` or just ``-gline-tables-only`` is sufficient:
+   On Linux:
 
.. code-block:: console
 
- $ clang++ -O2 -gline-tables-only code.cc -o code
+ $ clang++ -O2 -gline-tables-only -fdebug-info-for-profiling 
-funique-internal-linkage-names code.cc -o code
 
While MSVC-style targets default to CodeView debug information, DWARF debug
information is required to generate source-level LLVM profiles. Use
@@ -2457,13 +2459,13 @@ usual build cycle when using sample profilers for 
optimization:
 
.. code-block:: console
 
- $ clang-cl -O2 -gdwarf -gline-tables-only coff-profile.cpp -fuse-ld=lld 
-link -debug:dwarf
+ $ clang-cl -O2 -gdwarf -gline-tables-only 
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names 
code.cc -o code -fuse-ld=lld -link -debug:dwarf
 
 2. Run the executable under a sampling profiler. The specific profiler
you use does not really matter, as long as its output can be converted
into the format that the LLVM optimizer understands.
 
-   Two such profilers are the the Linux Perf profiler
+   Two such profilers are the Linux Perf profiler
(https://perf.wiki.kernel.org/) and Intel's Sampling Enabling Product (SEP),
available as part of `Intel VTune

`_.
@@ -2477,7 +2479,9 @@ usual build cycle when using sample profilers for 
optimization:
 
.. code-block:: console
 
- $ perf record -b ./code
+ $ perf record -b -e BR_INST_RETIRED.NEAR_TAKEN:uppp ./code
+
+   If the event above is unavailable, ``branches:u`` is probably next-best.
 
Note the use of the ``-b`` flag. This tells Perf to use the Last Branch
Record (LBR) to record call chains. While this is not strictly required,

>From add91ec329f60eef6ecf79d6d5c9a548a8d6bcfe Mon Sep 17 00:00:00 2001
From: Tim Creech 
Date: Mon, 22 Apr 2024 11:11:36 -0400
Subject: [PATCH 2/3] fixup: add uniqueing note, match debug flags

---
 clang/docs/UsersManual.rst | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 818841285cfae5..b87fc7f2aaa4dd 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2314,6 +2314,8 @@ are listed below.
on ELF targets when using the integrated assembler. This flag currently
only has an effect on ELF targets.
 
+.. _funique_internal_linkage_names:
+
 .. option:: -f[no]-unique-internal-linkage-names
 
Controls whether Clang emits a unique (best-effort) symbol name for internal
@@ -2451,15 +2453,27 @@ usual build cycle when using sample profilers for 
optimization:
 
.. code-block:: console
 
- $ clang++ -O2 -gline-tables-only -fdebug-info-for-profiling 
-funique-internal-linkage-names code.cc -o code
+ $ clang++ -O2 -gline-tables-only \
+   -fdebug-info-for-profiling -funique-internal-linkage-names \
+   code.cc -o code
 
While MSVC-style targets default to CodeView debug information, DWARF debug
information is required to generate source-level LLVM profiles. Use
``-gdwarf`` to include DWARF debug information:
 
-   .. code-block:: console
+   .. code-block:: winbatch
+
+ $ clang-cl -O2 -gdwarf -gline-tables-only ^
+   

[clang] [clang-format] adds a space after not inside macros (PR #78176)

2024-04-25 Thread Owen Pan via cfe-commits

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


[clang] [llvm] [SCCP] Swap out range metadata to range attribute (PR #90134)

2024-04-25 Thread Nikita Popov via cfe-commits

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


[clang] 93de97d - [SCCP] Swap out range metadata to range attribute (#90134)

2024-04-25 Thread via cfe-commits

Author: Andreas Jonson
Date: 2024-04-26T11:04:47+09:00
New Revision: 93de97d750548cd90c53efd4367dbd0367aa30fd

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

LOG: [SCCP] Swap out range metadata to range attribute (#90134)

Also moved the range from the function's call sites to the functions
return value as that is possible now.

Added: 


Modified: 
clang/test/CodeGen/X86/ms-x86-intrinsics.c
clang/test/CodeGen/attr-counted-by.c
clang/test/CodeGen/ms-mixed-ptr-sizes.c
llvm/include/llvm/IR/Function.h
llvm/lib/IR/Function.cpp
llvm/lib/Transforms/IPO/SCCP.cpp
llvm/test/Transforms/FunctionSpecialization/discover-transitive-phis.ll
llvm/test/Transforms/FunctionSpecialization/global-var-constants.ll
llvm/test/Transforms/FunctionSpecialization/literal-const.ll
llvm/test/Transforms/LowerTypeTests/cfi-nounwind-direct-call.ll
llvm/test/Transforms/PhaseOrdering/AArch64/quant_4x4.ll
llvm/test/Transforms/PhaseOrdering/icmp-ashr-breaking-select-idiom.ll
llvm/test/Transforms/PhaseOrdering/min_max_loop.ll
llvm/test/Transforms/SCCP/and-add-shl.ll
llvm/test/Transforms/SCCP/ip-add-range-to-call.ll
llvm/test/Transforms/SCCP/ip-ranges-casts.ll
llvm/test/Transforms/SCCP/ipsccp-basic.ll
llvm/test/Transforms/SCCP/switch.ll
llvm/test/Transforms/SCCP/trunc-nuw-nsw-flags.ll

Removed: 




diff  --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index a1c90d71c8ebf5..aa557c8e19a83d 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -48,7 +48,7 @@ long long test__readfsqword(unsigned long Offset) {
 __int64 test__emul(int a, int b) {
   return __emul(a, b);
 }
-// CHECK-LABEL: define dso_local i64 @test__emul(i32 noundef %a, i32 noundef 
%b)
+// CHECK-LABEL: define dso_local range(i64 -4611686016279904256, 
4611686018427387905) i64 @test__emul(i32 noundef %a, i32 noundef %b)
 // CHECK: [[X:%[0-9]+]] = sext i32 %a to i64
 // CHECK: [[Y:%[0-9]+]] = sext i32 %b to i64
 // CHECK: [[RES:%[0-9]+]] = mul nsw i64 [[Y]], [[X]]
@@ -57,7 +57,7 @@ __int64 test__emul(int a, int b) {
 unsigned __int64 test__emulu(unsigned int a, unsigned int b) {
   return __emulu(a, b);
 }
-// CHECK-LABEL: define dso_local i64 @test__emulu(i32 noundef %a, i32 noundef 
%b)
+// CHECK-LABEL: define dso_local range(i64 0, -8589934590) i64 
@test__emulu(i32 noundef %a, i32 noundef %b)
 // CHECK: [[X:%[0-9]+]] = zext i32 %a to i64
 // CHECK: [[Y:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
@@ -108,13 +108,13 @@ long long test__readgsqword(unsigned long Offset) {
 __int64 test__mulh(__int64 a, __int64 b) {
   return __mulh(a, b);
 }
-// CHECK-X64-LABEL: define dso_local i64 @test__mulh(i64 noundef %a, i64 
noundef %b)
+// CHECK-X64-LABEL: define dso_local range(i64 -4611686018427387904, 
4611686018427387905) i64 @test__mulh(i64 noundef %a, i64 noundef %b)
 // CHECK-X64: = mul nsw i128 %
 
 unsigned __int64 test__umulh(unsigned __int64 a, unsigned __int64 b) {
   return __umulh(a, b);
 }
-// CHECK-X64-LABEL: define dso_local i64 @test__umulh(i64 noundef %a, i64 
noundef %b)
+// CHECK-X64-LABEL: define dso_local range(i64 0, -1) i64 @test__umulh(i64 
noundef %a, i64 noundef %b)
 // CHECK-X64: = mul nuw i128 %
 
 __int64 test_mul128(__int64 Multiplier,

diff  --git a/clang/test/CodeGen/attr-counted-by.c 
b/clang/test/CodeGen/attr-counted-by.c
index 1fb39f9a346667..de30a00138ac80 100644
--- a/clang/test/CodeGen/attr-counted-by.c
+++ b/clang/test/CodeGen/attr-counted-by.c
@@ -66,7 +66,7 @@ struct anon_struct {
 // SANITIZE-WITH-ATTR-NEXT:[[TMP1:%.*]] = icmp ult i64 [[IDXPROM]], 
[[TMP0]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR-NEXT:br i1 [[TMP1]], label [[CONT3:%.*]], label 
[[HANDLER_OUT_OF_BOUNDS:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR:   handler.out_of_bounds:
-// SANITIZE-WITH-ATTR-NEXT:tail call void 
@__ubsan_handle_out_of_bounds_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 
[[IDXPROM]]) #[[ATTR10:[0-9]+]], !nosanitize [[META2]]
+// SANITIZE-WITH-ATTR-NEXT:tail call void 
@__ubsan_handle_out_of_bounds_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 
[[IDXPROM]]) #[[ATTR10:[0-9]+]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR-NEXT:unreachable, !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR:   cont3:
 // SANITIZE-WITH-ATTR-NEXT:[[ARRAY:%.*]] = getelementptr inbounds i8, ptr 
[[P]], i64 12
@@ -114,7 +114,7 @@ void test1(struct annotated *p, int index, int val) {
 // SANITIZE-WITH-ATTR-NEXT:[[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 
[[INDEX]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR-NEXT:br i1 [[TMP1]], label [[CONT3:%.*]], label 
[[HANDLER_OUT_OF_BOUNDS:%.*]], 

[clang] [llvm] [SCCP] Swap out range metadata to range attribute (PR #90134)

2024-04-25 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-25 Thread A. Jiang via cfe-commits


@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity ,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.

frederick-vs-ja wrote:

> should we makes `std::is_nothrow_convertible_v` evaluated as 
> `true`?

I don't see any proper motivation for doing so. Implementations consistently 
match the design in [P0758R1](https://wg21.link/p0758r1). It's the standard 
wording that failed to reflect the intent, which is perhaps a defect. 
(Additionally, the pasted sample implementation would exactly reflect the bug 
in the `noexcept` operator, if any.)

And IMO `std::is_nothrow_convertible(_v)` should be implementable without 
intrinsic (and the implementation strategy would be [quite 
simple](https://en.cppreference.com/w/cpp/types/is_convertible#Possible_implementation)).
 The `__is_nothrow_convertible` instrinsic should only be meaningful for 
acceleration of compilation.

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


[clang] [Driver] Don't default to -mrelax-all for non-RISCV -O0 (PR #90013)

2024-04-25 Thread Nikita Popov via cfe-commits

nikic wrote:

FYI I'm seeing about 0.6% compile-time regressions for `O0` test-suite builds 
with this change 
(https://llvm-compile-time-tracker.com/compare.php?from=ef2ca97f48f1aee1483f0c29de5ba52979bec454=18376810f359dbd39d2a0aa0ddfc0f7f50eac199=instructions:u).
 Though there is also a 4.5% reduction in text size 
(https://llvm-compile-time-tracker.com/compare.php?from=ef2ca97f48f1aee1483f0c29de5ba52979bec454=18376810f359dbd39d2a0aa0ddfc0f7f50eac199=size-text)
 so maybe the tradeoff is reasonable even for `O0`.

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, RefPtr, and their variants. (PR #90153)

2024-04-25 Thread via cfe-commits

llvmbot wrote:



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

@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)


Changes

Skip the analysis of Ref, RefPtr, and their variant classes in 
UncountedCallArgsChecker since these classes are "trusted" to not do anything 
dangerous.

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


4 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h (+3) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp (+6) 
- (modified) clang/test/Analysis/Checkers/WebKit/call-args.cpp (+1-1) 
- (modified) clang/test/Analysis/Checkers/WebKit/mock-types.h (+52-15) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index 9ed8e7cab6abb9..ec1db1cc335807 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -50,6 +50,9 @@ std::optional isUncounted(const clang::CXXRecordDecl* 
Class);
 /// class, false if not, std::nullopt if inconclusive.
 std::optional isUncountedPtr(const clang::Type* T);
 
+/// \returns true if Name is a RefPtr, Ref, or its variant, false if not.
+bool isRefType(const std::string );
+
 /// \returns true if \p F creates ref-countable object from uncounted 
parameter,
 /// false if not.
 bool isCtorOfRefCounted(const clang::FunctionDecl *F);
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 8b41a949fd6734..741f336761589f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -53,6 +53,12 @@ class UncountedCallArgsChecker
   bool shouldVisitTemplateInstantiations() const { return true; }
   bool shouldVisitImplicitCode() const { return false; }
 
+  bool TraverseDecl(Decl *D) {
+if (isa(D) && isRefType(safeGetName(D)))
+  return true;
+return RecursiveASTVisitor::TraverseDecl(D);
+  }
+
   bool VisitCallExpr(const CallExpr *CE) {
 Checker->visitCallExpr(CE);
 return true;
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
index f2e1f9bc5a2464..2a4b6bb1f1063a 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
@@ -32,7 +32,7 @@ namespace ref_counted {
   void consume_ref_counted(Ref) {}
 
   void foo() {
-consume_refcntbl(provide_ref_counted().get());
+consume_refcntbl(provide_ref_counted().ptr());
 // no warning
   }
 }
diff --git a/clang/test/Analysis/Checkers/WebKit/mock-types.h 
b/clang/test/Analysis/Checkers/WebKit/mock-types.h
index aab99197dfa49e..c27ea9baaf3bf5 100644
--- a/clang/test/Analysis/Checkers/WebKit/mock-types.h
+++ b/clang/test/Analysis/Checkers/WebKit/mock-types.h
@@ -1,24 +1,61 @@
 #ifndef mock_types_1103988513531
 #define mock_types_1103988513531
 
-template  struct Ref {
-  T *t;
+template
+struct RawPtrTraits {
+  using StorageType = T*;
 
-  Ref() : t{} {};
-  Ref(T )
-: t(t) {
-if (t)
-  t->ref();
+  template
+  static T* exchange(StorageType& ptr, U&& newValue)
+  {
+StorageType oldValue = static_cast(ptr);
+ptr = static_cast(newValue);
+return oldValue;
   }
-  ~Ref() {
-if (t)
-  t->deref();
+
+  static void swap(StorageType& a, StorageType& b)
+  {
+StorageType temp = static_cast(a);
+a = static_cast(b);
+b = static_cast(temp);
   }
-  T *get() { return t; }
-  T *ptr() { return t; }
-  T *operator->() { return t; }
-  operator const T &() const { return *t; }
-  operator T &() { return *t; }
+  static T* unwrap(const StorageType& ptr) { return ptr; }
+};
+
+template struct DefaultRefDerefTraits {
+  static T* refIfNotNull(T* ptr)
+  {
+if (ptr)
+  ptr->ref();
+return ptr;
+  }
+
+  static T& ref(T& ref)
+  {
+ref.ref();
+return ref;
+  }
+
+  static void derefIfNotNull(T* ptr)
+  {
+if (ptr)
+  ptr->deref();
+  }
+};
+
+template , typename 
RefDerefTraits = DefaultRefDerefTraits> struct Ref {
+  typename PtrTraits::StorageType t;
+
+  Ref() : t{} {};
+  Ref(T ) : t(RefDerefTraits::refIfNotNull(t)) { }
+  Ref(const Ref& o) : t(RefDerefTraits::refIfNotNull(PtrTraits::unwrap(o.t))) 
{ }
+  ~Ref() { RefDerefTraits::derefIfNotNull(PtrTraits::exchange(t, nullptr)); }
+  T () { return *PtrTraits::unwrap(t); }
+  T *ptr() { return PtrTraits::unwrap(t); }
+  T *operator->() { return PtrTraits::unwrap(t); }
+  operator const T &() const { return *PtrTraits::unwrap(t); }
+  operator T &() { return *PtrTraits::unwrap(t); }
+  T* leakRef() { PtrTraits::exchange(t, nullptr); }
 };
 
 template  struct RefPtr {

``




https://github.com/llvm/llvm-project/pull/90153

[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-25 Thread Nikita Popov via cfe-commits

nikic wrote:

FYI this change has some visible compile-time impact, with some 0.5-1% 
regressions on various LLVM files 
(https://llvm-compile-time-tracker.com/compare_clang.php?from=2f2e31c3c980407b2660b4f5d10e7cdb3fa79138=a8fd0d029dca7d17eee72d0445223c2fe1ee7758=instructions%3Au=interestingness).
 Nothing terrible (it doesn't seem to be an across-the-board regression), just 
wanted to let you know in case this is unexpected.

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, RefPtr, and their variants. (PR #90153)

2024-04-25 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/90153

Skip the analysis of Ref, RefPtr, and their variant classes in 
UncountedCallArgsChecker since these classes are "trusted" to not do anything 
dangerous.

>From 04d9b292a48604ec0601e869d48d4f2c481f91bc Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 25 Apr 2024 18:42:01 -0700
Subject: [PATCH] [alpha.webkit.UncountedCallArgsChecker] Avoid emitting
 warnings for Ref, RefPtr, and their variants.

Skip the analysis of Ref, RefPtr, and their variant classes in 
UncountedCallArgsChecker since these
classes are "trusted" to not do anything dangerous.
---
 .../Checkers/WebKit/PtrTypesSemantics.h   |  3 +
 .../WebKit/UncountedCallArgsChecker.cpp   |  6 ++
 .../Analysis/Checkers/WebKit/call-args.cpp|  2 +-
 .../Analysis/Checkers/WebKit/mock-types.h | 67 ++-
 4 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index 9ed8e7cab6abb9..ec1db1cc335807 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -50,6 +50,9 @@ std::optional isUncounted(const clang::CXXRecordDecl* 
Class);
 /// class, false if not, std::nullopt if inconclusive.
 std::optional isUncountedPtr(const clang::Type* T);
 
+/// \returns true if Name is a RefPtr, Ref, or its variant, false if not.
+bool isRefType(const std::string );
+
 /// \returns true if \p F creates ref-countable object from uncounted 
parameter,
 /// false if not.
 bool isCtorOfRefCounted(const clang::FunctionDecl *F);
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 8b41a949fd6734..741f336761589f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -53,6 +53,12 @@ class UncountedCallArgsChecker
   bool shouldVisitTemplateInstantiations() const { return true; }
   bool shouldVisitImplicitCode() const { return false; }
 
+  bool TraverseDecl(Decl *D) {
+if (isa(D) && isRefType(safeGetName(D)))
+  return true;
+return RecursiveASTVisitor::TraverseDecl(D);
+  }
+
   bool VisitCallExpr(const CallExpr *CE) {
 Checker->visitCallExpr(CE);
 return true;
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
index f2e1f9bc5a2464..2a4b6bb1f1063a 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
@@ -32,7 +32,7 @@ namespace ref_counted {
   void consume_ref_counted(Ref) {}
 
   void foo() {
-consume_refcntbl(provide_ref_counted().get());
+consume_refcntbl(provide_ref_counted().ptr());
 // no warning
   }
 }
diff --git a/clang/test/Analysis/Checkers/WebKit/mock-types.h 
b/clang/test/Analysis/Checkers/WebKit/mock-types.h
index aab99197dfa49e..c27ea9baaf3bf5 100644
--- a/clang/test/Analysis/Checkers/WebKit/mock-types.h
+++ b/clang/test/Analysis/Checkers/WebKit/mock-types.h
@@ -1,24 +1,61 @@
 #ifndef mock_types_1103988513531
 #define mock_types_1103988513531
 
-template  struct Ref {
-  T *t;
+template
+struct RawPtrTraits {
+  using StorageType = T*;
 
-  Ref() : t{} {};
-  Ref(T )
-: t(t) {
-if (t)
-  t->ref();
+  template
+  static T* exchange(StorageType& ptr, U&& newValue)
+  {
+StorageType oldValue = static_cast(ptr);
+ptr = static_cast(newValue);
+return oldValue;
   }
-  ~Ref() {
-if (t)
-  t->deref();
+
+  static void swap(StorageType& a, StorageType& b)
+  {
+StorageType temp = static_cast(a);
+a = static_cast(b);
+b = static_cast(temp);
   }
-  T *get() { return t; }
-  T *ptr() { return t; }
-  T *operator->() { return t; }
-  operator const T &() const { return *t; }
-  operator T &() { return *t; }
+  static T* unwrap(const StorageType& ptr) { return ptr; }
+};
+
+template struct DefaultRefDerefTraits {
+  static T* refIfNotNull(T* ptr)
+  {
+if (ptr)
+  ptr->ref();
+return ptr;
+  }
+
+  static T& ref(T& ref)
+  {
+ref.ref();
+return ref;
+  }
+
+  static void derefIfNotNull(T* ptr)
+  {
+if (ptr)
+  ptr->deref();
+  }
+};
+
+template , typename 
RefDerefTraits = DefaultRefDerefTraits> struct Ref {
+  typename PtrTraits::StorageType t;
+
+  Ref() : t{} {};
+  Ref(T ) : t(RefDerefTraits::refIfNotNull(t)) { }
+  Ref(const Ref& o) : t(RefDerefTraits::refIfNotNull(PtrTraits::unwrap(o.t))) 
{ }
+  ~Ref() { RefDerefTraits::derefIfNotNull(PtrTraits::exchange(t, nullptr)); }
+  T () { return *PtrTraits::unwrap(t); }
+  T *ptr() { return PtrTraits::unwrap(t); }
+  T *operator->() { return PtrTraits::unwrap(t); }
+  operator const T &() const { return 

[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-25 Thread David Truby via cfe-commits

DavidTruby wrote:

As regards the backwards compatibility break here, I guess my take is that this 
change needs to happen some time and sooner is always going to be better than 
later. While we are still called flang-new and marked experimental I'm inclined 
to think we should just rip the band aid.

We could leave `-fno-fortran-main` in as deprecated but it won't actually do 
anything anymore, so that might just be confusing for users.

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


[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-25 Thread David Truby via cfe-commits

DavidTruby wrote:

> Great work David, thanks! Could you add some documentation explaining _where_ 
> `main` would be coming from in the case of mixed-source compilation? In fact, 
> is that tested anywhere?
> 
> Also, IMHO it would be good to advertise this on Discourse (thinking 
> specifically about `-fno-fortran-main`).

In mixed-source compilation where there's no `program` statement in Fortran 
then main should be provided by whatever other language you're linking to. In 
the example of C/C++ that would just mean defining `main` yourself. In the case 
where there's a `program` statement in the Fortran we're now defining `main` by 
declaring it through MLIR.

I've already posted about this on discourse, you can see the discussion here: 
https://discourse.llvm.org/t/rfc-link-to-fortran-main-using-embedded-linker-flags/77596.
 I should have put that in the PR comment!

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


[clang] [clang][CodeGen] fix UB in aarch64 bfloat16 scalar conversion (PR #89062)

2024-04-25 Thread via cfe-commits

nihui wrote:

@ostannard  hi, would you please review my fix   :)

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Helena Kotas via cfe-commits


@@ -3859,7 +3862,7 @@ def warn_availability_fuchsia_unavailable_minor : Warning<
   InGroup;
 
 def warn_unguarded_availability :
-  Warning<"%0 is only available on %1 %2 or newer">,
+  Warning<"%0 %select{is only|is not}5 available %select{|in %4 environment 
}3on %1 %2 %select{or newer|}5">,

hekota wrote:

If the API is available in higher version the warning will always be:

"%0 is only available on %1 %2 or newer"

The other formulation is only used when the API is not available in any future 
version for the target environment. This happens when there is an attribute 
narrowing down the availability to specific environment that is different from 
the current one. I kept the message under one ID so it can be turned on/off 
with `-Wunguarded-availability-new`.

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Chris B via cfe-commits


@@ -3859,7 +3862,7 @@ def warn_availability_fuchsia_unavailable_minor : Warning<
   InGroup;
 
 def warn_unguarded_availability :
-  Warning<"%0 is only available on %1 %2 or newer">,
+  Warning<"%0 %select{is only|is not}5 available %select{|in %4 environment 
}3on %1 %2 %select{or newer|}5">,

llvm-beanz wrote:

It looks like the change here is to make two different formulations of this 
warning one is saying:

"%0 is only available on %1 %2 or newer"

The other is saying:

"%0 is not available on %1 %2"

I think the original warning has the benefit of conveying what version the API 
becomes available, which gives more direct meaningful feedback to the user.

Since we don't have an existing warning text to try and match for HLSL, can we 
try and align with the existing warning text?

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Chris B via cfe-commits

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Chris B via cfe-commits

https://github.com/llvm-beanz commented:

Overall I really like the direction of this. I'm curious if any of the 
maintainers from Apple have thoughts since they're the primary users of 
availability annotations.

I think this dramatically simplifies things for what we need, but it might also 
have some benefits to be able to simplify how Apple expresses some of its 
existing annotations.

(cc @cyndyishida  )

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


[clang] [clang-scan-deps] Fix contention when updating `TrackingStatistic`s in hot code paths in `FileManager`. (PR #88427)

2024-04-25 Thread Fangrui Song via cfe-commits

MaskRay wrote:

(BTW: 
https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it/74223
 The recommendation is to avoid the github "hidden email" feature.)

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


[clang-tools-extra] 5a12f28 - LLVM_FALLTHROUGH => [[fallthrough]]. NFC

2024-04-25 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2024-04-25T17:50:59-07:00
New Revision: 5a12f2867a167bbe11099150f3cb6b6cb77d767c

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

LOG: LLVM_FALLTHROUGH => [[fallthrough]]. NFC

Added: 


Modified: 
clang-tools-extra/clangd/CodeCompletionStrings.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
llvm/include/llvm/IR/GenericConvergenceVerifierImpl.h
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/Support/regcomp.c
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/utils/TableGen/DXILEmitter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp 
b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
index 2075e5965f181e..9b4442b0bb76fd 100644
--- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -253,7 +253,7 @@ void getSignature(const CodeCompletionString , 
std::string *Signature,
   if (!IncludeFunctionArguments &&
   ResultKind == CodeCompletionResult::RK_Declaration)
 TruncateSnippetAt.emplace(Snippet->size());
-  LLVM_FALLTHROUGH;
+  [[fallthrough]];
 case CodeCompletionString::CK_RightParen:
 case CodeCompletionString::CK_LeftBracket:
 case CodeCompletionString::CK_RightBracket:

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index d3fc487aed4333..9409497f1c81ba 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1869,15 +1869,15 @@ 
AppleObjCRuntimeV2::DynamicClassInfoExtractor::ComputeHelper(
   if (loader->IsFullyInitialized()) {
 switch (exe_ctx.GetTargetRef().GetDynamicClassInfoHelper()) {
 case eDynamicClassInfoHelperAuto:
-  LLVM_FALLTHROUGH;
+  [[fallthrough]];
 case eDynamicClassInfoHelperGetRealizedClassList:
   if (m_runtime.m_has_objc_getRealizedClassList_trylock)
 return 
DynamicClassInfoExtractor::objc_getRealizedClassList_trylock;
-  LLVM_FALLTHROUGH;
+  [[fallthrough]];
 case eDynamicClassInfoHelperCopyRealizedClassList:
   if (m_runtime.m_has_objc_copyRealizedClassList)
 return DynamicClassInfoExtractor::objc_copyRealizedClassList;
-  LLVM_FALLTHROUGH;
+  [[fallthrough]];
 case eDynamicClassInfoHelperRealizedClassesStruct:
   return DynamicClassInfoExtractor::gdb_objc_realized_classes;
 }

diff  --git a/llvm/include/llvm/IR/GenericConvergenceVerifierImpl.h 
b/llvm/include/llvm/IR/GenericConvergenceVerifierImpl.h
index a3ebde709ae6e1..7525c9eb758bef 100644
--- a/llvm/include/llvm/IR/GenericConvergenceVerifierImpl.h
+++ b/llvm/include/llvm/IR/GenericConvergenceVerifierImpl.h
@@ -76,7 +76,7 @@ void GenericConvergenceVerifier::visit(const 
InstructionT ) {
   "Entry intrinsic cannot be preceded by a convergent operation in the 
"
   "same basic block.",
   {Context.print()});
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case CONV_ANCHOR:
 Check(!TokenDef,
   "Entry or anchor intrinsic cannot have a convergencectrl token "

diff  --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp 
b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 8cf392ab0567e5..d7b0c9aa166735 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -2223,7 +2223,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst 
, Intrinsic::ID ID,
 // addresses. We can treat it like a normal dbg_value intrinsic here; to
 // benefit from the full analysis of stack/SSA locations, GlobalISel would
 // need to register for and use the AssignmentTrackingAnalysis pass.
-LLVM_FALLTHROUGH;
+[[fallthrough]];
   case Intrinsic::dbg_value: {
 // This form of DBG_VALUE is target-independent.
 const DbgValueInst  = cast(CI);

diff  --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp 
b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index aefedd060f897d..ef9f7833551905 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1424,7 +1424,7 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst 
*II) {
 // happened (such as an optimised function being 

[clang] Clean up denormal handling with -ffp-model, -ffast-math, etc. (PR #89477)

2024-04-25 Thread Fangrui Song via cfe-commits


@@ -75,6 +76,7 @@
 // RUN:   --check-prefix=WARN12 %s
 // RUN: %clang -### -ffast-math -ffp-model=strict -c %s 2>&1 | FileCheck \
 // RUN:   --check-prefix=WARN12 %s
+// WARN12: clang

MaskRay wrote:

`clang` is unneeded. For diagnostics or -cc1 options, we just avoid check 
`clang` before `-cc1` since `clang` carries very little weight

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


[clang] Clean up denormal handling with -ffp-model, -ffast-math, etc. (PR #89477)

2024-04-25 Thread Fangrui Song via cfe-commits

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


[clang] Clean up denormal handling with -ffp-model, -ffast-math, etc. (PR #89477)

2024-04-25 Thread Fangrui Song via cfe-commits


@@ -1462,6 +1460,14 @@ floating point semantic models: precise (the default), 
strict, and fast.
   "allow_approximate_fns", "off", "off", "on"
   "allow_reassociation", "off", "off", "on"
 
+The ``-fp-model`` option does not modify the "fdenormal-fp-math" or
+"fdenormal-fp-math-f32" settings, but it does have an impact on whether

MaskRay wrote:

backticks for the fdenormal-fp-math and crtfastmath.o names

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-hlsl

Author: Helena Kotas (hekota)


Changes

Add `environment` parameter to Clang availability attribute. The allowed values 
for this parameter are a subset of values allowed in the `llvm::Triple` 
environment component. If the `environment` parameters is present, the declared 
availability attribute applies only to targets with the same platform and 
environment.

This new parameter will be initially used for annotating HLSL functions for the 
`shadermodel` platform because in HLSL built-in function availability can 
depend not just on the shader model version (mapped to `llvm::Triple::OSType`) 
but also on the target shader stage (mapped to 
`llvm::Triple::EnvironmentType`). See example in #89802 and 
microsoft/hlsl-specs#204 for more details.

Fixes #89802

---

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


19 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+30-3) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+5) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+5-2) 
- (modified) clang/include/clang/Parse/Parser.h (+3) 
- (modified) clang/include/clang/Sema/ParsedAttr.h (+28-14) 
- (modified) clang/include/clang/Sema/Sema.h (+8-7) 
- (modified) clang/lib/AST/DeclBase.cpp (+22-6) 
- (modified) clang/lib/Headers/hlsl/hlsl_intrinsics.h (+11-4) 
- (modified) clang/lib/Index/CommentToXML.cpp (+6) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+19-1) 
- (modified) clang/lib/Sema/SemaAPINotes.cpp (+2-1) 
- (modified) clang/lib/Sema/SemaAvailability.cpp (+81-33) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+30-9) 
- (modified) clang/test/Parser/attr-availability.c (+4) 
- (modified) clang/test/SemaHLSL/AvailabilityMarkup.hlsl (+4-4) 
- (added) clang/test/SemaHLSL/AvailabilityMarkupStages.hlsl (+44) 
- (modified) clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl (+2-2) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..251a2cf04e37d7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -956,7 +956,7 @@ def Availability : InheritableAttr {
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
   BoolArgument<"strict">, StringArgument<"replacement">,
-  IntArgument<"priority">];
+  IntArgument<"priority">, IdentifierArgument<"environment">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
@@ -976,7 +976,7 @@ def Availability : InheritableAttr {
  .Case("xros", "visionOS")
  .Case("xros_app_extension", "visionOS (App Extension)")
  .Case("swift", "Swift")
- .Case("shadermodel", "HLSL ShaderModel")
+ .Case("shadermodel", "Shader Model")
  .Case("ohos", "OpenHarmony OS")
  .Default(llvm::StringRef());
 }
@@ -1016,7 +1016,34 @@ static llvm::StringRef 
canonicalizePlatformName(llvm::StringRef Platform) {
  .Case("visionos_app_extension", "xros_app_extension")
  .Case("ShaderModel", "shadermodel")
  .Default(Platform);
-} }];
+}
+static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", "pixel shader")
+ .Case("vertex", "vertex shader")
+ .Case("geometry", "geometry shader")
+ .Case("hull", "hull shader")
+ .Case("domain", "domain shader")
+ .Case("compute", "compute shader")
+ .Case("mesh", "mesh shader")
+ .Case("amplification", "amplification shader")
+ .Case("library", "shader library")
+ .Default(Environment);
+}
+static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", llvm::Triple::Pixel)
+ .Case("vertex", llvm::Triple::Vertex)
+ .Case("geometry", llvm::Triple::Geometry)
+ .Case("hull", llvm::Triple::Hull)
+ .Case("domain", llvm::Triple::Domain)
+ .Case("compute", llvm::Triple::Compute)
+ .Case("mesh", llvm::Triple::Mesh)
+ .Case("amplification", llvm::Triple::Amplification)
+ .Case("library", llvm::Triple::Library)
+ .Default(llvm::Triple::UnknownEnvironment);
+}
+}];
   let HasCustomParsing = 1;
   let InheritEvenIfAlreadyPresent = 1;
   let Subjects = SubjectList<[Named]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Helena Kotas (hekota)


Changes

Add `environment` parameter to Clang availability attribute. The allowed values 
for this parameter are a subset of values allowed in the `llvm::Triple` 
environment component. If the `environment` parameters is present, the declared 
availability attribute applies only to targets with the same platform and 
environment.

This new parameter will be initially used for annotating HLSL functions for the 
`shadermodel` platform because in HLSL built-in function availability can 
depend not just on the shader model version (mapped to `llvm::Triple::OSType`) 
but also on the target shader stage (mapped to 
`llvm::Triple::EnvironmentType`). See example in #89802 and 
microsoft/hlsl-specs#204 for more details.

Fixes #89802

---

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


19 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+30-3) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+5) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+5-2) 
- (modified) clang/include/clang/Parse/Parser.h (+3) 
- (modified) clang/include/clang/Sema/ParsedAttr.h (+28-14) 
- (modified) clang/include/clang/Sema/Sema.h (+8-7) 
- (modified) clang/lib/AST/DeclBase.cpp (+22-6) 
- (modified) clang/lib/Headers/hlsl/hlsl_intrinsics.h (+11-4) 
- (modified) clang/lib/Index/CommentToXML.cpp (+6) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+19-1) 
- (modified) clang/lib/Sema/SemaAPINotes.cpp (+2-1) 
- (modified) clang/lib/Sema/SemaAvailability.cpp (+81-33) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+30-9) 
- (modified) clang/test/Parser/attr-availability.c (+4) 
- (modified) clang/test/SemaHLSL/AvailabilityMarkup.hlsl (+4-4) 
- (added) clang/test/SemaHLSL/AvailabilityMarkupStages.hlsl (+44) 
- (modified) clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl (+2-2) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..251a2cf04e37d7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -956,7 +956,7 @@ def Availability : InheritableAttr {
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
   BoolArgument<"strict">, StringArgument<"replacement">,
-  IntArgument<"priority">];
+  IntArgument<"priority">, IdentifierArgument<"environment">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
@@ -976,7 +976,7 @@ def Availability : InheritableAttr {
  .Case("xros", "visionOS")
  .Case("xros_app_extension", "visionOS (App Extension)")
  .Case("swift", "Swift")
- .Case("shadermodel", "HLSL ShaderModel")
+ .Case("shadermodel", "Shader Model")
  .Case("ohos", "OpenHarmony OS")
  .Default(llvm::StringRef());
 }
@@ -1016,7 +1016,34 @@ static llvm::StringRef 
canonicalizePlatformName(llvm::StringRef Platform) {
  .Case("visionos_app_extension", "xros_app_extension")
  .Case("ShaderModel", "shadermodel")
  .Default(Platform);
-} }];
+}
+static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", "pixel shader")
+ .Case("vertex", "vertex shader")
+ .Case("geometry", "geometry shader")
+ .Case("hull", "hull shader")
+ .Case("domain", "domain shader")
+ .Case("compute", "compute shader")
+ .Case("mesh", "mesh shader")
+ .Case("amplification", "amplification shader")
+ .Case("library", "shader library")
+ .Default(Environment);
+}
+static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", llvm::Triple::Pixel)
+ .Case("vertex", llvm::Triple::Vertex)
+ .Case("geometry", llvm::Triple::Geometry)
+ .Case("hull", llvm::Triple::Hull)
+ .Case("domain", llvm::Triple::Domain)
+ .Case("compute", llvm::Triple::Compute)
+ .Case("mesh", llvm::Triple::Mesh)
+ .Case("amplification", llvm::Triple::Amplification)
+ .Case("library", llvm::Triple::Library)
+ .Default(llvm::Triple::UnknownEnvironment);
+}
+}];
   let HasCustomParsing = 1;
   let InheritEvenIfAlreadyPresent = 1;
   let Subjects = SubjectList<[Named]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 

[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Helena Kotas via cfe-commits

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Helena Kotas via cfe-commits

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


[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent

2024-04-25 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

Will add tests tomorrow...

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


[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Krystian Stasiowski (sdkrystian)


Changes

Reapplies #84050, addressing a bug which cases a crash when an 
expression with the type of the current instantiation is used as the 
_postfix-expression_ in a class member access expression (arrow form).

---

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


30 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/FindTargetTests.cpp (+4-4) 
- (modified) clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp 
(+2) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
 (+12) 
- (modified) clang/docs/ReleaseNotes.rst (+12) 
- (modified) clang/include/clang/Sema/Lookup.h (+3-1) 
- (modified) clang/include/clang/Sema/Sema.h (+8-6) 
- (modified) clang/lib/AST/Expr.cpp (+1-1) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+5-2) 
- (modified) clang/lib/Sema/SemaAttr.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+4-3) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+3-3) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+10-10) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExprMember.cpp (+69-94) 
- (modified) clang/lib/Sema/SemaLookup.cpp (+89-25) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+12-5) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+12-20) 
- (modified) clang/lib/Sema/TreeTransform.h (+20) 
- (modified) clang/test/AST/HLSL/this-reference-template.hlsl (+1-1) 
- (modified) clang/test/CXX/drs/dr2xx.cpp (+5-5) 
- (modified) clang/test/CXX/drs/dr3xx.cpp (+8-8) 
- (added) clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp (+456) 
- (modified) clang/test/CXX/temp/temp.res/temp.local/p3.cpp (+1-2) 
- (modified) clang/test/CodeGenCXX/mangle.cpp (-8) 
- (modified) clang/test/Index/annotate-nested-name-specifier.cpp (+2-2) 
- (modified) clang/test/SemaCXX/member-expr.cpp (+2-2) 
- (modified) clang/test/SemaTemplate/instantiate-function-1.cpp (+7-7) 
- (modified) clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (+3-2) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..94437857cecca6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -854,7 +854,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but base expression involves a function call.
   Code = R"cpp(
@@ -872,7 +872,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but uses a function pointer.
   Code = R"cpp(
@@ -891,7 +891,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Base expression involves a member access into this.
   Code = R"cpp(
@@ -962,7 +962,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   void Foo() { this->[[find]](); }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+  EXPECT_DECLS("MemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 4156921d83edf8..30b9b1902aa9c7 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -621,7 +621,7 @@ sizeof...($TemplateParameter[[Elements]]);
   struct $Class_def[[Foo]] {
 int $Field_decl[[Waldo]];
 void $Method_def[[bar]]() {
-  $Class[[Foo]]().$Field_dependentName[[Waldo]];
+  $Class[[Foo]]().$Field[[Waldo]];
 }
 template $Bracket[[<]]typename $TemplateParameter_def[[U]]$Bracket[[>]]
 void $Method_def[[bar1]]() {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
index 574efe7bd91478..ae61b17ca14d20 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
@@ -309,6 +309,8 @@ struct HeapArray {  
// Ok, since destruc
 
   

[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent

2024-04-25 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/90152

Reapplies #84050, addressing a bug which cases a crash when an expression with 
the type of the current instantiation is used as the _postfix-expression_ in a 
class member access expression (arrow form).

>From 6ea7f9d476910681ad01e2fe4525fb4d2c556c6f Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Thu, 25 Apr 2024 14:50:53 -0400
Subject: [PATCH 1/2] Reapply "[Clang][Sema] Diagnose class member access
 expressions naming non-existent members of the current instantiation prior to
 instantiation in the absence of dependent base classes (#84050)"

Consider the following:
```cpp
template
struct A
{
auto f()
{
return this->x;
}
};
```
Although `A` has no dependent base classes and the lookup context for
`x` is the current instantiation, we currently do not diagnose the
absence of a member `x` until `A::f` is instantiated. This patch
moves the point of diagnosis for such expressions to occur at the point
of definition (i.e. prior to instantiation).
---
 .../clangd/unittests/FindTargetTests.cpp  |   8 +-
 .../unittests/SemanticHighlightingTests.cpp   |   2 +-
 .../cppcoreguidelines/owning-memory.cpp   |   2 +
 .../modernize/use-equals-default-copy.cpp |  12 +
 clang/docs/ReleaseNotes.rst   |  12 +
 clang/include/clang/Sema/Lookup.h |   4 +-
 clang/include/clang/Sema/Sema.h   |  14 +-
 clang/lib/AST/Expr.cpp|   2 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Sema/HLSLExternalSemaSource.cpp |   7 +-
 clang/lib/Sema/SemaAttr.cpp   |   2 +-
 clang/lib/Sema/SemaDecl.cpp   |   7 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   6 +-
 clang/lib/Sema/SemaExpr.cpp   |  20 +-
 clang/lib/Sema/SemaExprCXX.cpp|   2 +-
 clang/lib/Sema/SemaExprMember.cpp | 183 +++
 clang/lib/Sema/SemaLookup.cpp | 114 -
 clang/lib/Sema/SemaOpenMP.cpp |  17 +-
 clang/lib/Sema/SemaTemplate.cpp   |  32 +-
 clang/lib/Sema/TreeTransform.h|  20 +
 .../AST/HLSL/this-reference-template.hlsl |   2 +-
 clang/test/CXX/drs/dr2xx.cpp  |  10 +-
 clang/test/CXX/drs/dr3xx.cpp  |  16 +-
 .../temp.res/temp.dep/temp.dep.type/p4.cpp| 456 ++
 .../test/CXX/temp/temp.res/temp.local/p3.cpp  |   3 +-
 clang/test/CodeGenCXX/mangle.cpp  |   8 -
 .../Index/annotate-nested-name-specifier.cpp  |   4 +-
 clang/test/SemaCXX/member-expr.cpp|   4 +-
 .../SemaTemplate/instantiate-function-1.cpp   |  14 +-
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |   5 +-
 30 files changed, 765 insertions(+), 225 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..94437857cecca6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -854,7 +854,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but base expression involves a function call.
   Code = R"cpp(
@@ -872,7 +872,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but uses a function pointer.
   Code = R"cpp(
@@ -891,7 +891,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Base expression involves a member access into this.
   Code = R"cpp(
@@ -962,7 +962,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   void Foo() { this->[[find]](); }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+  EXPECT_DECLS("MemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 4156921d83edf8..30b9b1902aa9c7 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -621,7 +621,7 @@ sizeof...($TemplateParameter[[Elements]]);
   struct $Class_def[[Foo]] {
 int $Field_decl[[Waldo]];
 void $Method_def[[bar]]() {
-  $Class[[Foo]]().$Field_dependentName[[Waldo]];
+  $Class[[Foo]]().$Field[[Waldo]];
 }
 template 

[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-25 Thread Pranav Kant via cfe-commits

pranavk wrote:

Sorry, I just pushed the reverts. I reverted the commits for now. Feel free to 
re-land with fixes.

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


[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-25 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

@pranavk @ilovepi I have a potential fix ready... give me a few to test some 
edge cases 

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


[clang] 0c6e1ca - Revert "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base classe

2024-04-25 Thread Pranav Kant via cfe-commits

Author: Pranav Kant
Date: 2024-04-26T00:18:08Z
New Revision: 0c6e1ca1c704a3a0fb53ae54f7e3723736f477c7

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

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

This reverts commit a8fd0d029dca7d17eee72d0445223c2fe1ee7758.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Lookup.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Expr.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaExprMember.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/TreeTransform.h
clang/test/AST/HLSL/this-reference-template.hlsl
clang/test/CXX/drs/dr2xx.cpp
clang/test/CXX/drs/dr3xx.cpp
clang/test/CXX/temp/temp.res/temp.local/p3.cpp
clang/test/CodeGenCXX/mangle.cpp
clang/test/Index/annotate-nested-name-specifier.cpp
clang/test/SemaCXX/member-expr.cpp
clang/test/SemaTemplate/instantiate-function-1.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 
clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp



diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 94437857cecca6..799a549ff0816e 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -854,7 +854,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("MemberExpr", "void foo()");
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
 
   // Similar to above but base expression involves a function call.
   Code = R"cpp(
@@ -872,7 +872,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("MemberExpr", "void foo()");
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
 
   // Similar to above but uses a function pointer.
   Code = R"cpp(
@@ -891,7 +891,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("MemberExpr", "void foo()");
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
 
   // Base expression involves a member access into this.
   Code = R"cpp(
@@ -962,7 +962,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   void Foo() { this->[[find]](); }
 };
   )cpp";
-  EXPECT_DECLS("MemberExpr", "void find()");
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 30b9b1902aa9c7..4156921d83edf8 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -621,7 +621,7 @@ sizeof...($TemplateParameter[[Elements]]);
   struct $Class_def[[Foo]] {
 int $Field_decl[[Waldo]];
 void $Method_def[[bar]]() {
-  $Class[[Foo]]().$Field[[Waldo]];
+  $Class[[Foo]]().$Field_dependentName[[Waldo]];
 }
 template $Bracket[[<]]typename $TemplateParameter_def[[U]]$Bracket[[>]]
 void $Method_def[[bar1]]() {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
index ae61b17ca14d20..574efe7bd91478 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
@@ -309,8 +309,6 @@ struct HeapArray {  
// Ok, since destruc
 
   HeapArray(HeapArray &) : _data(other._data), size(other.size) { // Ok
 other._data = nullptr;  // Ok
-// CHECK-NOTES: [[@LINE-1]]:5: warning: expected assignment source to be 
of type 'gsl::owner<>'; got 'std::nullptr_t'
-// FIXME: This warning is emitted 

[clang] 45fc0e6 - Revert "[Clang][Sema] Fix warnings after #84050 (#90104)"

2024-04-25 Thread Pranav Kant via cfe-commits

Author: Pranav Kant
Date: 2024-04-26T00:17:28Z
New Revision: 45fc0e6b38b62a61b0ddcda2e7fe9b4fee7e3e58

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

LOG: Revert "[Clang][Sema] Fix warnings after #84050 (#90104)"

This reverts commit 6dd2617c80d5133b92fdff679364f2d8fcd93b47.

Added: 


Modified: 
clang/lib/Sema/SemaExprMember.cpp
clang/lib/Sema/SemaLookup.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 14dde1bff8fbc6..0eeb7b1faa0a22 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1793,6 +1793,7 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr 
*Base,
   DecomposeUnqualifiedId(Id, TemplateArgsBuffer,
  NameInfo, TemplateArgs);
 
+  DeclarationName Name = NameInfo.getName();
   bool IsArrow = (OpKind == tok::arrow);
 
   if (getLangOpts().HLSL && IsArrow)

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 2f6ad49fc08b61..a537eccc2ebaf0 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2791,7 +2791,7 @@ bool Sema::LookupParsedName(LookupResult , Scope *S, 
CXXScopeSpec *SS,
   return LookupInSuper(R, NNS->getAsRecordDecl());
 // This nested-name-specifier occurs after another nested-name-specifier,
 // so long into the context associated with the prior 
nested-name-specifier.
-if ((DC = computeDeclContext(*SS, EnteringContext))) {
+if (DC = computeDeclContext(*SS, EnteringContext)) {
   // The declaration context must be complete.
   if (!DC->isDependentContext() && RequireCompleteDeclContext(*SS, DC))
 return false;



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


[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-25 Thread Justin Stitt via cfe-commits

JustinStitt wrote:

@efriedma-quic:
> Attributes mostly do modify the type. The few that don't, like "aligned" and 
> "may_alias", are a constant source of problems because they get accidentally 
> stripped off. (I don't have any personal experience with "noderef".)

So do you believe the current approach is a no-go? I am happy to do whatever it 
takes to get this feature over the line but hear me out:

Any way of implementing this feature is subject to corner cases and can be 
broken -- like a lot of stuff in C. For its specific use case, this attribute 
provides immense power and clarity to existing code bases; the Linux Kernel 
would benefit massively as we could then enable multiple arithmetic sanitizers. 
With my custom wraps-enabled compiler and a syzkaller instance I've already 
located [dozens of potential 
bugs](https://gist.github.com/JustinStitt/51f988421522d9ab7d5dbf1c2025e7a0) 
that could be fixed with this attribute! (and ~hundreds of others with the 
`unsigned-integer-overflow` and `implicit-integer-truncation` sanitizers -- 
which I have yet to fuzz with).

The tests made by @kees (mostly kernel-tailored) and the tests I've checked in 
with this PR all pass without regression to existing integer sanitizer uses.

I'd love to hear more folk's opinions, too. With more feedback, we can make 
this feature and its documentation/testing as solid as possible.

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


[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-25 Thread Pranav Kant via cfe-commits

pranavk wrote:

Yes, I also think that this should be reverted. This commit seems to 
erroneously fail on cases like this:

https://github.com/tink-crypto/tink-cc/blob/4501627fe9ee312ad5d413600f050827b5f725ed/tink/util/secret_proto.h#L62

Note that ParseFromArray is being on an instance of T. So code is correct but 
this commit breaks such use cases.

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


[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Eli Friedman (efriedma-quic)


Changes

In the context of determining whether a class counts as an "aggregate", a 
constructor template counts as a user-provided constructor.

Fixes #86384

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


2 Files Affected:

- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+9-3) 
- (modified) clang/test/CodeGen/arm64-microsoft-arguments.cpp (+14) 


``diff
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index d38a26940a3cb6..d47927745759e1 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1131,9 +1131,15 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, 
QualType Ty,
 return false;
   if (RD->hasNonTrivialCopyAssignment())
 return false;
-  for (const CXXConstructorDecl *Ctor : RD->ctors())
-if (Ctor->isUserProvided())
-  return false;
+  for (const Decl *D : RD->decls()) {
+if (auto *Ctor = dyn_cast(D)) {
+  if (Ctor->isUserProvided())
+return false;
+} else if (auto *Template = dyn_cast(D)) {
+  if (isa(Template->getTemplatedDecl()))
+return false;
+}
+  }
   if (RD->hasNonTrivialDestructor())
 return false;
   return true;
diff --git a/clang/test/CodeGen/arm64-microsoft-arguments.cpp 
b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
index e8309888dcfe21..89299277422a29 100644
--- a/clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -201,3 +201,17 @@ S11 f11() {
   S11 x;
   return func11(x);
 }
+
+// Pass and return object with template constructor (pass directly,
+// return indirectly).
+// CHECK: define dso_local void @"?f12@@YA?AUS12@@XZ"(ptr dead_on_unwind inreg 
noalias writable sret(%struct.S12) align 4 {{.*}})
+// CHECK: call void @"?func12@@YA?AUS12@@U1@@Z"(ptr dead_on_unwind inreg 
writable sret(%struct.S12) align 4 {{.*}}, i64 {{.*}})
+struct S12 {
+  template S12(T*) {}
+  int x;
+};
+S12 func12(S12 x);
+S12 f12() {
+  S12 x((int*)0);
+  return func12(x);
+}

``




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


[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-25 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic created 
https://github.com/llvm/llvm-project/pull/90151

In the context of determining whether a class counts as an "aggregate", a 
constructor template counts as a user-provided constructor.

Fixes #86384

>From 9adeffc9ee780c84a525ce0535a84508105e05ae Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Thu, 25 Apr 2024 17:06:40 -0700
Subject: [PATCH] [clang codegen] Fix MS ABI detection of user-provided
 constructors.

In the context of determining whether a class counts as an "aggregate",
a constructor template counts as a user-provided constructor.

Fixes #86384
---
 clang/lib/CodeGen/MicrosoftCXXABI.cpp| 12 +---
 clang/test/CodeGen/arm64-microsoft-arguments.cpp | 14 ++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index d38a26940a3cb6..d47927745759e1 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1131,9 +1131,15 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, 
QualType Ty,
 return false;
   if (RD->hasNonTrivialCopyAssignment())
 return false;
-  for (const CXXConstructorDecl *Ctor : RD->ctors())
-if (Ctor->isUserProvided())
-  return false;
+  for (const Decl *D : RD->decls()) {
+if (auto *Ctor = dyn_cast(D)) {
+  if (Ctor->isUserProvided())
+return false;
+} else if (auto *Template = dyn_cast(D)) {
+  if (isa(Template->getTemplatedDecl()))
+return false;
+}
+  }
   if (RD->hasNonTrivialDestructor())
 return false;
   return true;
diff --git a/clang/test/CodeGen/arm64-microsoft-arguments.cpp 
b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
index e8309888dcfe21..89299277422a29 100644
--- a/clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ b/clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -201,3 +201,17 @@ S11 f11() {
   S11 x;
   return func11(x);
 }
+
+// Pass and return object with template constructor (pass directly,
+// return indirectly).
+// CHECK: define dso_local void @"?f12@@YA?AUS12@@XZ"(ptr dead_on_unwind inreg 
noalias writable sret(%struct.S12) align 4 {{.*}})
+// CHECK: call void @"?func12@@YA?AUS12@@U1@@Z"(ptr dead_on_unwind inreg 
writable sret(%struct.S12) align 4 {{.*}}, i64 {{.*}})
+struct S12 {
+  template S12(T*) {}
+  int x;
+};
+S12 func12(S12 x);
+S12 f12() {
+  S12 x((int*)0);
+  return func12(x);
+}

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


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-25 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast requested changes to this pull 
request.


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


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-25 Thread Hubert Tong via cfe-commits


@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -DWIN -verify -std=c++23 -fsyntax-only  %s
+// RUN: %clang_cc1 -verify -std=c++23 -fsyntax-only  %s
+
+// expected-no-diagnostics
+
+
+#ifdef WIN
+#define INFINITY ((float)(1e+300 * 1e+300))
+#define NAN  (-(float)(INFINITY * 0.0F))
+#else
+#define NAN (__builtin_nanf(""))
+#define INFINITY (__builtin_inff())
+#endif
+
+extern "C" void abort() noexcept;
+extern "C" int write(int, const void*, unsigned long);
+
+#define assert(condition) \
+  do { \
+if (!(condition)) {\
+  write(2, "Assertion failed: ", 18);  \
+  write(2, #condition, sizeof(#condition) - 1);\
+  write(2, "\n", 1);   \
+  abort(); \
+}  \
+  } while (false)
+
+int main() {
+int i;
+
+// fmin
+static_assert(__builtin_fmin(15.24, 1.3) == 1.3, "");
+static_assert(__builtin_fmin(-0.0, +0.0) == -0.0, "");
+static_assert(__builtin_fmin(+0.0, -0.0) == -0.0, "");
+assert(__builtin_isnan(__builtin_fminf(NAN,NAN)));
+assert(__builtin_isnan(__builtin_fminf(NAN, -1)));
+assert(__builtin_isnan(__builtin_fminf(-INFINITY, 0)));
+assert(__builtin_iszero(__builtin_fminf(+INFINITY, 0)));
+
+// frexp
+static_assert(__builtin_frexp(123.45, ) == 0.9644531250002);

hubert-reinterpretcast wrote:

This should not be a constant expression. This line is not supposed to compile.
`i` is supposed to be written to, but it lives outside of the constant 
expression evaluation.


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


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-25 Thread Hubert Tong via cfe-commits


@@ -14547,6 +14547,17 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   default:
 return false;
 
+  case Builtin::BI__builtin_frexpf:
+  case Builtin::BI__builtin_frexp: {
+LValue Pointer;
+if (!EvaluateFloat(E->getArg(0), Result, Info) ||
+!EvaluatePointer(E->getArg(1), Pointer, Info))
+  return false;
+llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
+int FrexpExp;
+Result = llvm::frexp(Result, FrexpExp, RM);

hubert-reinterpretcast wrote:

The value in `FrexpExp` is just ignored?

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


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-25 Thread Hubert Tong via cfe-commits

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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/89809

>From 22b67d30ca087d6a912183039c87fd1790eedfe4 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Tue, 23 Apr 2024 00:49:28 -0700
Subject: [PATCH 1/3] Add environment parameter to clang availability attribute

---
 clang/include/clang/Basic/Attr.td |  33 +-
 clang/include/clang/Basic/AttrDocs.td |   2 +
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 .../clang/Basic/DiagnosticSemaKinds.td|   5 +-
 clang/include/clang/Parse/Parser.h|   3 +
 clang/include/clang/Sema/ParsedAttr.h |  40 ---
 clang/include/clang/Sema/Sema.h   |   5 +-
 clang/lib/AST/DeclBase.cpp|  27 -
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  |  13 ++-
 clang/lib/Index/CommentToXML.cpp  |   3 +
 clang/lib/Parse/ParseDecl.cpp |  20 +++-
 clang/lib/Sema/SemaAPINotes.cpp   |   3 +-
 clang/lib/Sema/SemaAvailability.cpp   | 109 +-
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  34 --
 15 files changed, 232 insertions(+), 69 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dc87a8c6f022dc..1b07f4eb408093 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -956,7 +956,7 @@ def Availability : InheritableAttr {
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
   BoolArgument<"strict">, StringArgument<"replacement">,
-  IntArgument<"priority">];
+  IntArgument<"priority">, IdentifierArgument<"environment">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
@@ -976,7 +976,7 @@ def Availability : InheritableAttr {
  .Case("xros", "visionOS")
  .Case("xros_app_extension", "visionOS (App Extension)")
  .Case("swift", "Swift")
- .Case("shadermodel", "HLSL ShaderModel")
+ .Case("shadermodel", "HLSL Shader Model")
  .Case("ohos", "OpenHarmony OS")
  .Default(llvm::StringRef());
 }
@@ -1016,7 +1016,34 @@ static llvm::StringRef 
canonicalizePlatformName(llvm::StringRef Platform) {
  .Case("visionos_app_extension", "xros_app_extension")
  .Case("ShaderModel", "shadermodel")
  .Default(Platform);
-} }];
+}
+static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", "pixel shader")
+ .Case("vertex", "vertex shader")
+ .Case("geometry", "geometry shader")
+ .Case("hull", "hull shader")
+ .Case("domain", "domain shader")
+ .Case("compute", "compute shader")
+ .Case("mesh", "mesh shader")
+ .Case("amplification", "amplification shader")
+ .Case("library", "shader library")
+ .Default(Environment);
+}
+static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", llvm::Triple::Pixel)
+ .Case("vertex", llvm::Triple::Vertex)
+ .Case("geometry", llvm::Triple::Geometry)
+ .Case("hull", llvm::Triple::Hull)
+ .Case("domain", llvm::Triple::Domain)
+ .Case("compute", llvm::Triple::Compute)
+ .Case("mesh", llvm::Triple::Mesh)
+ .Case("amplification", llvm::Triple::Amplification)
+ .Case("library", llvm::Triple::Library)
+ .Default(llvm::Triple::UnknownEnvironment);
+}
+}];
   let HasCustomParsing = 1;
   let InheritEvenIfAlreadyPresent = 1;
   let Subjects = SubjectList<[Named]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a0bbe5861c5722..a81163df35ca8b 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1593,6 +1593,8 @@ replacement=\ *string-literal*
   a warning about use of a deprecated declaration. The Fix-It will replace
   the deprecated declaration with the new declaration specified.
 
+// HEKOTA TODO add docs here
+
 Multiple availability attributes can be placed on a declaration, which may
 correspond to different platforms. For most platforms, the availability
 attribute with the platform corresponding to the target platform will be used;
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 66405095d51de8..631dc8880fcfc8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1103,6 +1103,8 

[clang] [clang][dataflow] Fix crash when `ConstantExpr` is used in conditional operator. (PR #90112)

2024-04-25 Thread Yitzhak Mandelbaum via cfe-commits

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


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


[clang] [Clang][HLSL] Add environment parameter to availability attribute (PR #89809)

2024-04-25 Thread Helena Kotas via cfe-commits

https://github.com/hekota updated 
https://github.com/llvm/llvm-project/pull/89809

>From 22b67d30ca087d6a912183039c87fd1790eedfe4 Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Tue, 23 Apr 2024 00:49:28 -0700
Subject: [PATCH 1/3] Add environment parameter to clang availability attribute

---
 clang/include/clang/Basic/Attr.td |  33 +-
 clang/include/clang/Basic/AttrDocs.td |   2 +
 .../clang/Basic/DiagnosticParseKinds.td   |   2 +
 .../clang/Basic/DiagnosticSemaKinds.td|   5 +-
 clang/include/clang/Parse/Parser.h|   3 +
 clang/include/clang/Sema/ParsedAttr.h |  40 ---
 clang/include/clang/Sema/Sema.h   |   5 +-
 clang/lib/AST/DeclBase.cpp|  27 -
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  |  13 ++-
 clang/lib/Index/CommentToXML.cpp  |   3 +
 clang/lib/Parse/ParseDecl.cpp |  20 +++-
 clang/lib/Sema/SemaAPINotes.cpp   |   3 +-
 clang/lib/Sema/SemaAvailability.cpp   | 109 +-
 clang/lib/Sema/SemaDecl.cpp   |   2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  34 --
 15 files changed, 232 insertions(+), 69 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dc87a8c6f022dc..1b07f4eb408093 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -956,7 +956,7 @@ def Availability : InheritableAttr {
   VersionArgument<"deprecated">, VersionArgument<"obsoleted">,
   BoolArgument<"unavailable">, StringArgument<"message">,
   BoolArgument<"strict">, StringArgument<"replacement">,
-  IntArgument<"priority">];
+  IntArgument<"priority">, IdentifierArgument<"environment">];
   let AdditionalMembers =
 [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
 return llvm::StringSwitch(Platform)
@@ -976,7 +976,7 @@ def Availability : InheritableAttr {
  .Case("xros", "visionOS")
  .Case("xros_app_extension", "visionOS (App Extension)")
  .Case("swift", "Swift")
- .Case("shadermodel", "HLSL ShaderModel")
+ .Case("shadermodel", "HLSL Shader Model")
  .Case("ohos", "OpenHarmony OS")
  .Default(llvm::StringRef());
 }
@@ -1016,7 +1016,34 @@ static llvm::StringRef 
canonicalizePlatformName(llvm::StringRef Platform) {
  .Case("visionos_app_extension", "xros_app_extension")
  .Case("ShaderModel", "shadermodel")
  .Default(Platform);
-} }];
+}
+static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", "pixel shader")
+ .Case("vertex", "vertex shader")
+ .Case("geometry", "geometry shader")
+ .Case("hull", "hull shader")
+ .Case("domain", "domain shader")
+ .Case("compute", "compute shader")
+ .Case("mesh", "mesh shader")
+ .Case("amplification", "amplification shader")
+ .Case("library", "shader library")
+ .Default(Environment);
+}
+static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
+return llvm::StringSwitch(Environment)
+ .Case("pixel", llvm::Triple::Pixel)
+ .Case("vertex", llvm::Triple::Vertex)
+ .Case("geometry", llvm::Triple::Geometry)
+ .Case("hull", llvm::Triple::Hull)
+ .Case("domain", llvm::Triple::Domain)
+ .Case("compute", llvm::Triple::Compute)
+ .Case("mesh", llvm::Triple::Mesh)
+ .Case("amplification", llvm::Triple::Amplification)
+ .Case("library", llvm::Triple::Library)
+ .Default(llvm::Triple::UnknownEnvironment);
+}
+}];
   let HasCustomParsing = 1;
   let InheritEvenIfAlreadyPresent = 1;
   let Subjects = SubjectList<[Named]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a0bbe5861c5722..a81163df35ca8b 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1593,6 +1593,8 @@ replacement=\ *string-literal*
   a warning about use of a deprecated declaration. The Fix-It will replace
   the deprecated declaration with the new declaration specified.
 
+// HEKOTA TODO add docs here
+
 Multiple availability attributes can be placed on a declaration, which may
 correspond to different platforms. For most platforms, the availability
 attribute with the platform corresponding to the target platform will be used;
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 66405095d51de8..631dc8880fcfc8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1103,6 +1103,8 

[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-25 Thread Paul Kirth via cfe-commits

ilovepi wrote:

we're seeing similar crashes when building Fuchsia. 
https://ci.chromium.org/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.arm64-host_test_only-mac/b8749648123122633169/overview

A reproducer can be found here: 
https://storage.googleapis.com/fuchsia-artifacts/builds/8749648123122633169/build-debug/clang-crashreports/adc-61853f.tar

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


[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-25 Thread Justin Stitt via cfe-commits

https://github.com/JustinStitt updated 
https://github.com/llvm/llvm-project/pull/86618

>From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001
From: Justin Stitt 
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 01/15] implement wraps attribute

Signed-off-by: Justin Stitt 
---
 clang/docs/ReleaseNotes.rst   |  9 +++
 clang/include/clang/AST/Expr.h|  3 +
 clang/include/clang/Basic/Attr.td |  6 ++
 clang/include/clang/Basic/AttrDocs.td | 66 +++
 .../clang/Basic/DiagnosticSemaKinds.td|  3 +
 clang/include/clang/Sema/Sema.h   |  4 ++
 clang/lib/AST/Expr.cpp| 19 ++
 clang/lib/AST/ExprConstant.cpp|  6 +-
 clang/lib/AST/TypePrinter.cpp |  3 +
 clang/lib/CodeGen/CGExprScalar.cpp| 40 +--
 clang/lib/Sema/SemaDeclAttr.cpp   | 12 +++-
 clang/lib/Sema/SemaType.cpp   | 15 +
 clang/test/CodeGen/integer-overflow.c | 56 
 clang/test/CodeGen/unsigned-overflow.c| 63 +++---
 clang/test/Sema/attr-wraps.c  |  9 +++
 15 files changed, 298 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/Sema/attr-wraps.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2b3bafa1c30548..fa7acb894cd76f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -296,6 +296,15 @@ Attribute Changes in Clang
 - Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
   is ignored when applied to a local class or a member thereof.
 
+- Introduced ``__attribute((wraps))__`` which can be added to type or variable
+  declarations. Using an attributed type or variable in an arithmetic
+  expression will define the overflow behavior for that expression as having
+  two's complement wrap-around. These expressions cannot trigger integer
+  overflow warnings or sanitizer warnings. They also cannot be optimized away
+  by some eager UB optimizations.
+
+  This attribute is ignored in C++.
+
 Improvements to Clang's diagnostics
 ---
 - Clang now applies syntax highlighting to the code snippets it
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 2bfefeabc348be..68cd7d7c0fac3b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4077,6 +4077,9 @@ class BinaryOperator : public Expr {
   static unsigned sizeOfTrailingObjects(bool HasFPFeatures) {
 return HasFPFeatures * sizeof(FPOptionsOverride);
   }
+
+  /// Do one of the subexpressions have the wraps attribute?
+  bool oneOfWraps(const ASTContext ) const;
 };
 
 /// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dc87a8c6f022dc..06e41fcee206c4 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4506,3 +4506,9 @@ def CodeAlign: StmtAttr {
 static constexpr int MaximumAlignment = 4096;
   }];
 }
+
+def Wraps : DeclOrTypeAttr {
+  let Spellings = [Clang<"wraps">, CXX11<"", "wraps", 202403>];
+  let Subjects = SubjectList<[Var, TypedefName, Field]>;
+  let Documentation = [WrapsDocs];
+}
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a0bbe5861c5722..5f6e5a8de79954 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -8057,3 +8057,69 @@ requirement:
   }
   }];
 }
+
+def WrapsDocs : Documentation {
+  let Category = DocCatField;
+  let Content = [{
+This attribute can be used with type or variable declarations to denote that
+arithmetic containing these marked components have defined overflow behavior.
+Specifically, the behavior is defined as being consistent with two's complement
+wrap-around. For the purposes of sanitizers or warnings that concern themselves
+with the definedness of integer arithmetic, they will cease to instrument or
+warn about arithmetic that directly involves a "wrapping" component.
+
+For example, ``-fsanitize=signed-integer-overflow`` or ``-Winteger-overflow``
+will not warn about suspicious overflowing arithmetic -- assuming correct usage
+of the wraps attribute.
+
+This example shows some basic usage of ``__attribute__((wraps))`` on a type
+definition when building with ``-fsanitize=signed-integer-overflow``
+
+.. code-block:: c
+  typedef int __attribute__((wraps)) wrapping_int;
+
+  void foo() {
+wrapping_int a = INT_MAX;
+++a; // no sanitizer warning
+  }
+
+  int main() { foo(); }
+
+In the following example, we use ``__attribute__((wraps))`` on a variable to
+disable overflow instrumentation for arithmetic expressions it appears in. We
+do so with a popular overflow-checking pattern which we might not want to trip
+sanitizers (like ``-fsanitize=unsigned-integer-overflow``).
+

[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-25 Thread Pranav Kant via cfe-commits

pranavk wrote:

This makes clang crash in some cases. Here's a sample: 
https://godbolt.org/z/4sbvna4WY



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


[clang] [clang][modules] HeaderSearch::MarkFileModuleHeader sets textual headers' HeaderFileInfo non-external when it shouldn't (PR #89005)

2024-04-25 Thread Ian Anderson via cfe-commits

ian-twilightcoder wrote:

>From Jan:

> Maybe we can add the number of external HeaderFileInfos to 
> HeaderSearch::PrintStats() and have a test that checks for it.
> The flag to enable that output is -show-stats I think.

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


[clang-tools-extra] [clangd] Show definition of underlying struct when hovering over a typedef (PR #89570)

2024-04-25 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 9617da88ab961145047076c45bb2bb1ac4513634 
44aba390954c7b551ed7102e8e7b4209207c0d87 -- clang-tools-extra/clangd/Hover.cpp 
clang-tools-extra/clangd/unittests/HoverTests.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 582a311f35..fbef81f781 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1657,35 +1657,34 @@ TEST(Hover, All) {
 HI.NamespaceScope = "ns1::";
 HI.Definition = "struct MyClass {}";
   }},
-  {
-R"cpp(// Typedef to struct
+  {
+  R"cpp(// Typedef to struct
   struct Point { int x; int y; };
   typedef Point TPoint;
   [[TP^oint]] tp;
 )cpp",
-[](HoverInfo ) {
-  HI.Name = "TPoint";
-  HI.Kind = index::SymbolKind::TypeAlias;
-  HI.NamespaceScope = "";
-  HI.Type = "struct Point";
-  HI.Definition = "typedef Point TPoint;\nstruct Point {}";
-}
-  },
-  {
-R"cpp(// Two layers of typedef
+  [](HoverInfo ) {
+HI.Name = "TPoint";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.NamespaceScope = "";
+HI.Type = "struct Point";
+HI.Definition = "typedef Point TPoint;\nstruct Point {}";
+  }},
+  {
+  R"cpp(// Two layers of typedef
   struct Point { int x; int y; };
   typedef Point TPoint;
   typedef TPoint TTPoint;
   [[TTP^oint]] tp;
 )cpp",
-[](HoverInfo ) {
-  HI.Name = "TTPoint";
-  HI.Kind = index::SymbolKind::TypeAlias;
-  HI.NamespaceScope = "";
-  HI.Type = "struct Point";
-  HI.Definition = "typedef TPoint TTPoint;\ntypedef Point 
TPoint;\nstruct Point {}";
-}
-  },
+  [](HoverInfo ) {
+HI.Name = "TTPoint";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.NamespaceScope = "";
+HI.Type = "struct Point";
+HI.Definition = "typedef TPoint TTPoint;\ntypedef Point "
+"TPoint;\nstruct Point {}";
+  }},
   {
   R"cpp(// Class
 namespace ns1 {
@@ -3158,35 +3157,34 @@ TEST(Hover, CLanguage) {
 const char *const Code;
 const std::function ExpectedBuilder;
   } Cases[] = {
-{
-  R"cpp(// Typedef to struct
+  {
+  R"cpp(// Typedef to struct
 struct Point { int x; int y; };
 typedef struct Point TPoint;
 [[TP^oint]] tp;
   )cpp",
-  [](HoverInfo ) {
-HI.Name = "TPoint";
-HI.Kind = index::SymbolKind::TypeAlias;
-HI.NamespaceScope = "";
-HI.Type = "struct Point";
-HI.Definition = "typedef struct Point TPoint;\nstruct Point {}";
-  }
-},
-{
-  R"cpp(// Two layers of typedef
+  [](HoverInfo ) {
+HI.Name = "TPoint";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.NamespaceScope = "";
+HI.Type = "struct Point";
+HI.Definition = "typedef struct Point TPoint;\nstruct Point {}";
+  }},
+  {
+  R"cpp(// Two layers of typedef
 struct Point { int x; int y; };
 typedef struct Point TPoint;
 typedef TPoint TTPoint;
 [[TTP^oint]] tp;
   )cpp",
-  [](HoverInfo ) {
-HI.Name = "TTPoint";
-HI.Kind = index::SymbolKind::TypeAlias;
-HI.NamespaceScope = "";
-HI.Type = "struct Point";
-HI.Definition = "typedef TPoint TTPoint;\ntypedef struct Point 
TPoint;\nstruct Point {}";
-  }
-},
+  [](HoverInfo ) {
+HI.Name = "TTPoint";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.NamespaceScope = "";
+HI.Type = "struct Point";
+HI.Definition = "typedef TPoint TTPoint;\ntypedef struct Point "
+"TPoint;\nstruct Point {}";
+  }},
   };
   for (const auto  : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -4117,7 +4115,8 @@ TEST(Hover, Typedefs) {
 
   ASSERT_TRUE(H && H->Type);
   EXPECT_EQ(H->Type->Type, "int");
-  EXPECT_EQ(H->Definition, "using foo = type;\nusing type = 
int");
+  EXPECT_EQ(H->Definition,
+"using foo = type;\nusing type = int");
 }
 
 TEST(Hover, EvaluateMacros) {

``




https://github.com/llvm/llvm-project/pull/89570
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Jonathan Thackray (jthackray)


Changes

Neoverse-N3, Neoverse-V3 and Neoverse-V3AE are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Neoverse-N3:
   https://developer.arm.com/documentation/107997/latest/

Technical Reference Manual for Neoverse-V3:
   https://developer.arm.com/documentation/107734/latest/

Technical Reference Manual for Neoverse-V3AE:
   https://developer.arm.com/documentation/101595/latest/


---

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


9 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/test/Driver/aarch64-mcpu.c (+6) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+2-2) 
- (modified) llvm/docs/ReleaseNotes.rst (+2-1) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+21) 
- (modified) llvm/lib/Target/AArch64/AArch64Processors.td (+46) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+2) 
- (modified) llvm/lib/TargetParser/Host.cpp (+3) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+57-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 00c684e773a2e0..4b768db003b273 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -640,6 +640,9 @@ Arm and AArch64 Support
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
+* Arm Neoverse-N3 (neoverse-n3).
+* Arm Neoverse-V3 (neoverse-v3).
+* Arm Neoverse-V3AE (neoverse-v3ae).
 
 Android Support
 ^^^
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index 77ba43122b2453..ad4a5f9ac6fb80 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -64,10 +64,16 @@
 // NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v2  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V2 %s
 // NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V3 %s
+// NEOVERSE-V3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-V3AE %s
+// NEOVERSE-V3AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3ae"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N1 %s
 // NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
 // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-n3 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N3 %s
+// NEOVERSE-N3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n3"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-512TVB %s
 // NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-512tvb"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A520 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9c91c4157cd6a0..21d80b7134508f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, 
apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, 
exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, 

[clang-tools-extra] [clangd] Show definition of underlying struct when hovering over a typedef (PR #89570)

2024-04-25 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

Updated patch with the following changes:

 * Decoupled from https://github.com/clangd/clangd/issues/959
 * Handle the case of multiple layers of typedefs, and add tests for this case
 * Add C language specific tests

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


[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-25 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray created 
https://github.com/llvm/llvm-project/pull/90143

Neoverse-N3, Neoverse-V3 and Neoverse-V3AE are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Neoverse-N3:
   https://developer.arm.com/documentation/107997/latest/

Technical Reference Manual for Neoverse-V3:
   https://developer.arm.com/documentation/107734/latest/

Technical Reference Manual for Neoverse-V3AE:
   https://developer.arm.com/documentation/101595/latest/


>From 5ced9f33871ea66647e04f62c637b92259805c2e Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Tue, 2 Apr 2024 22:08:50 +0100
Subject: [PATCH] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and
 Neoverse-V3AE

Neoverse-N3, Neoverse-V3 and Neoverse-V3AE are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Neoverse-N3:
   https://developer.arm.com/documentation/107997/latest/

Technical Reference Manual for Neoverse-V3:
   https://developer.arm.com/documentation/107734/latest/

Technical Reference Manual for Neoverse-V3AE:
   https://developer.arm.com/documentation/101595/latest/
---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/test/Driver/aarch64-mcpu.c  |  6 ++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +-
 llvm/docs/ReleaseNotes.rst|  3 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 21 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 46 +++
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 +
 llvm/lib/TargetParser/Host.cpp|  3 +
 .../TargetParser/TargetParserTest.cpp | 58 ++-
 9 files changed, 142 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 00c684e773a2e0..4b768db003b273 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -640,6 +640,9 @@ Arm and AArch64 Support
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
+* Arm Neoverse-N3 (neoverse-n3).
+* Arm Neoverse-V3 (neoverse-v3).
+* Arm Neoverse-V3AE (neoverse-v3ae).
 
 Android Support
 ^^^
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index 77ba43122b2453..ad4a5f9ac6fb80 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -64,10 +64,16 @@
 // NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v2  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V2 %s
 // NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V3 %s
+// NEOVERSE-V3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-V3AE %s
+// NEOVERSE-V3AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3ae"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N1 %s
 // NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
 // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-n3 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N3 %s
+// NEOVERSE-N3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n3"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-512TVB %s
 // NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-512tvb"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A520 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9c91c4157cd6a0..21d80b7134508f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, 

[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #87414)

2024-04-25 Thread Jonathan Thackray via cfe-commits

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


[clang-tools-extra] [clangd] Show definition of underlying struct when hovering over a typedef (PR #89570)

2024-04-25 Thread Nathan Ridge via cfe-commits

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


[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #87414)

2024-04-25 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/87414

>From 5ced9f33871ea66647e04f62c637b92259805c2e Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Tue, 2 Apr 2024 22:08:50 +0100
Subject: [PATCH] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and
 Neoverse-V3AE

Neoverse-N3, Neoverse-V3 and Neoverse-V3AE are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Neoverse-N3:
   https://developer.arm.com/documentation/107997/latest/

Technical Reference Manual for Neoverse-V3:
   https://developer.arm.com/documentation/107734/latest/

Technical Reference Manual for Neoverse-V3AE:
   https://developer.arm.com/documentation/101595/latest/
---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/test/Driver/aarch64-mcpu.c  |  6 ++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +-
 llvm/docs/ReleaseNotes.rst|  3 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 21 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 46 +++
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 +
 llvm/lib/TargetParser/Host.cpp|  3 +
 .../TargetParser/TargetParserTest.cpp | 58 ++-
 9 files changed, 142 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 00c684e773a2e0..4b768db003b273 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -640,6 +640,9 @@ Arm and AArch64 Support
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
+* Arm Neoverse-N3 (neoverse-n3).
+* Arm Neoverse-V3 (neoverse-v3).
+* Arm Neoverse-V3AE (neoverse-v3ae).
 
 Android Support
 ^^^
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index 77ba43122b2453..ad4a5f9ac6fb80 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -64,10 +64,16 @@
 // NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v2  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V2 %s
 // NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V3 %s
+// NEOVERSE-V3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-V3AE %s
+// NEOVERSE-V3AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3ae"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N1 %s
 // NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
 // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-n3 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N3 %s
+// NEOVERSE-N3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n3"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-512TVB %s
 // NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-512tvb"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A520 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9c91c4157cd6a0..21d80b7134508f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, 
apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, 
exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 

[clang-tools-extra] [clangd] Show struct members when hovering over a typedef (PR #89570)

2024-04-25 Thread Nathan Ridge via cfe-commits

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

>From 44aba390954c7b551ed7102e8e7b4209207c0d87 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Mon, 22 Apr 2024 02:24:14 -0400
Subject: [PATCH] [clangd] Show definition of underlying struct when hovering
 over a typedef

Fixes https://github.com/clangd/clangd/issues/2020
---
 clang-tools-extra/clangd/Hover.cpp|  43 +++-
 .../clangd/unittests/HoverTests.cpp   | 102 +-
 2 files changed, 142 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 06b949bc4a2b55..864c73f379c884 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -136,6 +136,41 @@ std::string getNamespaceScope(const Decl *D) {
   return "";
 }
 
+void printDeclAndWrappers(const TypedefNameDecl *TND,
+  llvm::raw_string_ostream , PrintingPolicy PP) {
+  TND->print(OS, PP);
+  const Decl *LastPrintedDecl = TND;
+
+  auto PrintDeclForType = [&](QualType T) {
+Decl *D = nullptr;
+if (const auto *TT = dyn_cast(T.getTypePtr())) {
+  D = TT->getDecl();
+} else if (const auto *TT = dyn_cast(T.getTypePtr())) {
+  D = TT->getDecl();
+}
+if (D == LastPrintedDecl) {
+  return false;
+}
+if (D) {
+  OS << ";\n";
+  D->print(OS, PP);
+  LastPrintedDecl = D;
+}
+// In case of D == nullptr, return true. We might have a layer of type
+// sugar like ElaboratedType that doesn't itself have a distinct Decl,
+// but a subsequent layer of type sugar might.
+return true;
+  };
+
+  QualType Type = TND->getUnderlyingType();
+  while (PrintDeclForType(Type)) {
+QualType Desugared = Type->getLocallyUnqualifiedSingleStepDesugaredType();
+if (Desugared == Type)
+  break;
+Type = Desugared;
+  }
+}
+
 std::string printDefinition(const Decl *D, PrintingPolicy PP,
 const syntax::TokenBuffer ) {
   if (auto *VD = llvm::dyn_cast(D)) {
@@ -149,7 +184,13 @@ std::string printDefinition(const Decl *D, PrintingPolicy 
PP,
   }
   std::string Definition;
   llvm::raw_string_ostream OS(Definition);
-  D->print(OS, PP);
+
+  if (const auto *TND = dyn_cast(D)) {
+printDeclAndWrappers(TND, OS, PP);
+  } else {
+D->print(OS, PP);
+  }
+
   OS.flush();
   return Definition;
 }
diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 35db757b9c15b5..582a311f35658d 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1657,6 +1657,35 @@ TEST(Hover, All) {
 HI.NamespaceScope = "ns1::";
 HI.Definition = "struct MyClass {}";
   }},
+  {
+R"cpp(// Typedef to struct
+  struct Point { int x; int y; };
+  typedef Point TPoint;
+  [[TP^oint]] tp;
+)cpp",
+[](HoverInfo ) {
+  HI.Name = "TPoint";
+  HI.Kind = index::SymbolKind::TypeAlias;
+  HI.NamespaceScope = "";
+  HI.Type = "struct Point";
+  HI.Definition = "typedef Point TPoint;\nstruct Point {}";
+}
+  },
+  {
+R"cpp(// Two layers of typedef
+  struct Point { int x; int y; };
+  typedef Point TPoint;
+  typedef TPoint TTPoint;
+  [[TTP^oint]] tp;
+)cpp",
+[](HoverInfo ) {
+  HI.Name = "TTPoint";
+  HI.Kind = index::SymbolKind::TypeAlias;
+  HI.NamespaceScope = "";
+  HI.Type = "struct Point";
+  HI.Definition = "typedef TPoint TTPoint;\ntypedef Point 
TPoint;\nstruct Point {}";
+}
+  },
   {
   R"cpp(// Class
 namespace ns1 {
@@ -1880,7 +1909,7 @@ TEST(Hover, All) {
 HI.Name = "Foo";
 HI.Kind = index::SymbolKind::TypeAlias;
 HI.NamespaceScope = "";
-HI.Definition = "typedef struct Bar Foo";
+HI.Definition = "typedef struct Bar Foo;\nstruct Bar {}";
 HI.Type = "struct Bar";
 HI.Documentation = "Typedef with embedded definition";
   }},
@@ -3124,6 +3153,75 @@ TEST(Hover, All) {
   }
 }
 
+TEST(Hover, CLanguage) {
+  struct {
+const char *const Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {
+{
+  R"cpp(// Typedef to struct
+struct Point { int x; int y; };
+typedef struct Point TPoint;
+[[TP^oint]] tp;
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "TPoint";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.NamespaceScope = "";
+HI.Type = "struct Point";
+HI.Definition = "typedef struct Point TPoint;\nstruct Point {}";
+  }
+},
+{
+  R"cpp(// Two layers of 

[clang] [llvm] [CMake][Release] Enable CMAKE_POSITION_INDEPENDENT_CODE (PR #90139)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tom Stellard (tstellar)


Changes

Set this in the cache file directly instead of via the test-release.sh script 
so that the release builds can be reproduced with just the cache file.

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


2 Files Affected:

- (modified) clang/cmake/caches/Release.cmake (+1) 
- (modified) llvm/utils/release/test-release.sh (+1-2) 


``diff
diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index c164d5497275f3..c0bfcbdfc1c2ae 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -82,6 +82,7 @@ set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
 # stage2-instrumented and Final Stage Config:
 # Options that need to be set in both the instrumented stage (if we are doing
 # a pgo build) and the final stage.
+set_instrument_and_final_stage_var(CMAKE_POSITION_INDEPENDENT_CODE "ON" STRING)
 set_instrument_and_final_stage_var(LLVM_ENABLE_LTO 
"${LLVM_RELEASE_ENABLE_LTO}" STRING)
 if (LLVM_RELEASE_ENABLE_LTO)
   set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
diff --git a/llvm/utils/release/test-release.sh 
b/llvm/utils/release/test-release.sh
index 4314b565e11b03..050004aa08c493 100755
--- a/llvm/utils/release/test-release.sh
+++ b/llvm/utils/release/test-release.sh
@@ -353,8 +353,7 @@ function build_with_cmake_cache() {
   env CC="$c_compiler" CXX="$cxx_compiler" \
   cmake -G "$generator" -B $CMakeBuildDir -S $SrcDir/llvm \
 -C $SrcDir/clang/cmake/caches/Release.cmake \
-   
-DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_POSITION_INDEPENDENT_CODE;LLVM_LIT_ARGS" \
--DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+   -DCLANG_BOOTSTRAP_PASSTHROUGH="LLVM_LIT_ARGS" \
 -DLLVM_LIT_ARGS="-j $NumJobs $LitVerbose" \
 $ExtraConfigureFlags
 2>&1 | tee $LogDir/llvm.configure-$Flavor.log

``




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


[clang] [llvm] [CMake][Release] Enable CMAKE_POSITION_INDEPENDENT_CODE (PR #90139)

2024-04-25 Thread Tom Stellard via cfe-commits

https://github.com/tstellar created 
https://github.com/llvm/llvm-project/pull/90139

Set this in the cache file directly instead of via the test-release.sh script 
so that the release builds can be reproduced with just the cache file.

>From 67f3d1ede686758238bb37a2ea50790750f7693f Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Wed, 24 Apr 2024 07:57:09 -0700
Subject: [PATCH] [CMake][Release] Enable CMAKE_POSITION_INDEPENDENT_CODE

Set this in the cache file directly instead of via the test-release.sh
script so that the release builds can be reproduced with just the
cache file.
---
 clang/cmake/caches/Release.cmake   | 1 +
 llvm/utils/release/test-release.sh | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index c164d5497275f3..c0bfcbdfc1c2ae 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -82,6 +82,7 @@ set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
 # stage2-instrumented and Final Stage Config:
 # Options that need to be set in both the instrumented stage (if we are doing
 # a pgo build) and the final stage.
+set_instrument_and_final_stage_var(CMAKE_POSITION_INDEPENDENT_CODE "ON" STRING)
 set_instrument_and_final_stage_var(LLVM_ENABLE_LTO 
"${LLVM_RELEASE_ENABLE_LTO}" STRING)
 if (LLVM_RELEASE_ENABLE_LTO)
   set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
diff --git a/llvm/utils/release/test-release.sh 
b/llvm/utils/release/test-release.sh
index 4314b565e11b03..050004aa08c493 100755
--- a/llvm/utils/release/test-release.sh
+++ b/llvm/utils/release/test-release.sh
@@ -353,8 +353,7 @@ function build_with_cmake_cache() {
   env CC="$c_compiler" CXX="$cxx_compiler" \
   cmake -G "$generator" -B $CMakeBuildDir -S $SrcDir/llvm \
 -C $SrcDir/clang/cmake/caches/Release.cmake \
-   
-DCLANG_BOOTSTRAP_PASSTHROUGH="CMAKE_POSITION_INDEPENDENT_CODE;LLVM_LIT_ARGS" \
--DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+   -DCLANG_BOOTSTRAP_PASSTHROUGH="LLVM_LIT_ARGS" \
 -DLLVM_LIT_ARGS="-j $NumJobs $LitVerbose" \
 $ExtraConfigureFlags
 2>&1 | tee $LogDir/llvm.configure-$Flavor.log

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


[clang] [CMake][Release] Use the TGZ cpack generator for binaries (PR #90138)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tom Stellard (tstellar)


Changes



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


1 Files Affected:

- (modified) clang/cmake/caches/Release.cmake (+1) 


``diff
diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index c164d5497275f3..aa7e6f99e94d52 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -90,4 +90,5 @@ endif()
 # Final Stage Config (stage2)
 set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" 
STRING)
 set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" 
STRING)
+set_final_stage_var(CPACK_GENERATOR "TGZ" STRING)
 

``




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


[clang] [CMake][Release] Use the TGZ cpack generator for binaries (PR #90138)

2024-04-25 Thread Tom Stellard via cfe-commits

https://github.com/tstellar created 
https://github.com/llvm/llvm-project/pull/90138

None

>From 0d0484ac99affdc8ccb9bc3a1eff827cf996c51c Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Wed, 24 Apr 2024 07:54:41 -0700
Subject: [PATCH] [CMake][Release] Use the TGZ cpack generator for binaries

---
 clang/cmake/caches/Release.cmake | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake
index c164d5497275f3..aa7e6f99e94d52 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -90,4 +90,5 @@ endif()
 # Final Stage Config (stage2)
 set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" 
STRING)
 set_final_stage_var(LLVM_ENABLE_PROJECTS "${LLVM_RELEASE_ENABLE_PROJECTS}" 
STRING)
+set_final_stage_var(CPACK_GENERATOR "TGZ" STRING)
 

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


[clang] [CMake][Release] Refactor cache file and use two stages for non-PGO builds (PR #89812)

2024-04-25 Thread Tom Stellard via cfe-commits

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


[clang] 6473fbf - [CMake][Release] Refactor cache file and use two stages for non-PGO builds (#89812)

2024-04-25 Thread via cfe-commits

Author: Tom Stellard
Date: 2024-04-25T15:32:08-07:00
New Revision: 6473fbf2d68c8486d168f29afc35d3e8a6fabe69

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

LOG: [CMake][Release] Refactor cache file and use two stages for non-PGO builds 
(#89812)

Completely refactor the cache file to simplify it and remove unnecessary
variables. The main functional change here is that the non-PGO builds
now use two stages, so `ninja -C build stage2-package` can be used with
both PGO and non-PGO builds.

Added: 


Modified: 
clang/cmake/caches/Release.cmake

Removed: 




diff  --git a/clang/cmake/caches/Release.cmake 
b/clang/cmake/caches/Release.cmake
index fa972636553f1f..c164d5497275f3 100644
--- a/clang/cmake/caches/Release.cmake
+++ b/clang/cmake/caches/Release.cmake
@@ -1,95 +1,93 @@
 # Plain options configure the first build.
 # BOOTSTRAP_* options configure the second build.
 # BOOTSTRAP_BOOTSTRAP_* options configure the third build.
+# PGO Builds have 3 stages (stage1, stage2-instrumented, stage2)
+# non-PGO Builds have 2 stages (stage1, stage2)
 
-# General Options
+
+function (set_final_stage_var name value type)
+  if (LLVM_RELEASE_ENABLE_PGO)
+set(BOOTSTRAP_BOOTSTRAP_${name} ${value} CACHE ${type} "")
+  else()
+set(BOOTSTRAP_${name} ${value} CACHE ${type} "")
+  endif()
+endfunction()
+
+function (set_instrument_and_final_stage_var name value type)
+  # This sets the varaible for the final stage in non-PGO builds and in
+  # the stage2-instrumented stage for PGO builds.
+  set(BOOTSTRAP_${name} ${value} CACHE ${type} "")
+  if (LLVM_RELEASE_ENABLE_PGO)
+# Set the variable in the final stage for PGO builds.
+set(BOOTSTRAP_BOOTSTRAP_${name} ${value} CACHE ${type} "")
+  endif()
+endfunction()
+
+# General Options:
+# If you want to override any of the LLVM_RELEASE_* variables you can set them
+# on the command line via -D, but you need to do this before you pass this
+# cache file to CMake via -C. e.g.
+#
+# cmake -D LLVM_RELEASE_ENABLE_PGO=ON -C Release.cmake
 set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
 set(LLVM_RELEASE_ENABLE_PGO OFF CACHE BOOL "")
-
+set(LLVM_RELEASE_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" 
CACHE STRING "")
+set(LLVM_RELEASE_ENABLE_PROJECTS 
"clang;lld;lldb;clang-tools-extra;bolt;polly;mlir;flang" CACHE STRING "")
+# Note we don't need to add install here, since it is one of the pre-defined
+# steps.
+set(LLVM_RELEASE_FINAL_STAGE_TARGETS 
"clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 
-# Stage 1 Bootstrap Setup
+# Stage 1 Options
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+
+set(STAGE1_PROJECTS "clang")
+set(STAGE1_RUNTIMES "")
+
 if (LLVM_RELEASE_ENABLE_PGO)
+  list(APPEND STAGE1_PROJECTS "lld")
+  list(APPEND STAGE1_RUNTIMES "compiler-rt")
   set(CLANG_BOOTSTRAP_TARGETS
 generate-profdata
-stage2
 stage2-package
 stage2-clang
-stage2-distribution
 stage2-install
-stage2-install-distribution
-stage2-install-distribution-toolchain
 stage2-check-all
 stage2-check-llvm
-stage2-check-clang
-stage2-test-suite CACHE STRING "")
-else()
-  set(CLANG_BOOTSTRAP_TARGETS
-clang
-check-all
-check-llvm
-check-clang
-test-suite
-stage3
-stage3-clang
-stage3-check-all
-stage3-check-llvm
-stage3-check-clang
-stage3-install
-stage3-test-suite CACHE STRING "")
-endif()
+stage2-check-clang CACHE STRING "")
 
-# Stage 1 Options
-set(STAGE1_PROJECTS "clang")
-set(STAGE1_RUNTIMES "")
+  # Configuration for stage2-instrumented
+  set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "")
+  # This enables the build targets for the final stage which is called stage2.
+  set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} 
CACHE STRING "")
+  set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "")
+  set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt" CACHE STRING "")
+  set(BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "")
 
-if (LLVM_RELEASE_ENABLE_PGO)
-  list(APPEND STAGE1_PROJECTS "lld")
-  list(APPEND STAGE1_RUNTIMES "compiler-rt")
+else()
+  if (LLVM_RELEASE_ENABLE_LTO)
+list(APPEND STAGE1_PROJECTS "lld")
+  endif()
+  # Any targets added here will be given the target name stage2-${target}, so
+  # if you want to run them you can just use:
+  # ninja -C $BUILDDIR stage2-${target}
+  set(CLANG_BOOTSTRAP_TARGETS ${LLVM_RELEASE_FINAL_STAGE_TARGETS} CACHE STRING 
"")
 endif()
 
+# Stage 1 Common Config
 set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
 set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")
 
-set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
-
-# Stage 2 

[clang] [llvm] [SCCP] Swap out range metadata to range attribute (PR #90134)

2024-04-25 Thread Andreas Jonson via cfe-commits

andjo403 wrote:

CC @nikic as you have looked at the most of other range attribute PRs

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


[clang] [llvm] [SCCP] Swap out range metadata to range attribute (PR #90134)

2024-04-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-ir

Author: Andreas Jonson (andjo403)


Changes

Also moved the range from the function's call sites to the functions return 
value as that is possible now.

---

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


19 Files Affected:

- (modified) clang/test/CodeGen/X86/ms-x86-intrinsics.c (+4-4) 
- (modified) clang/test/CodeGen/attr-counted-by.c (+36-36) 
- (modified) clang/test/CodeGen/ms-mixed-ptr-sizes.c (+4-4) 
- (modified) llvm/include/llvm/IR/Function.h (+4) 
- (modified) llvm/lib/IR/Function.cpp (+4) 
- (modified) llvm/lib/Transforms/IPO/SCCP.cpp (+8-19) 
- (modified) 
llvm/test/Transforms/FunctionSpecialization/discover-transitive-phis.ll (+51-7) 
- (modified) 
llvm/test/Transforms/FunctionSpecialization/global-var-constants.ll (+4-4) 
- (modified) llvm/test/Transforms/FunctionSpecialization/literal-const.ll 
(+2-2) 
- (modified) llvm/test/Transforms/LowerTypeTests/cfi-nounwind-direct-call.ll 
(+12-12) 
- (modified) llvm/test/Transforms/PhaseOrdering/AArch64/quant_4x4.ll (+1-1) 
- (modified) 
llvm/test/Transforms/PhaseOrdering/icmp-ashr-breaking-select-idiom.ll (+2-2) 
- (modified) llvm/test/Transforms/PhaseOrdering/min_max_loop.ll (+2-2) 
- (modified) llvm/test/Transforms/SCCP/and-add-shl.ll (+2-2) 
- (modified) llvm/test/Transforms/SCCP/ip-add-range-to-call.ll (+37-36) 
- (modified) llvm/test/Transforms/SCCP/ip-ranges-casts.ll (+38-29) 
- (modified) llvm/test/Transforms/SCCP/ipsccp-basic.ll (+3-3) 
- (modified) llvm/test/Transforms/SCCP/switch.ll (+53-42) 
- (modified) llvm/test/Transforms/SCCP/trunc-nuw-nsw-flags.ll (+2-2) 


``diff
diff --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index a1c90d71c8ebf5..aa557c8e19a83d 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -48,7 +48,7 @@ long long test__readfsqword(unsigned long Offset) {
 __int64 test__emul(int a, int b) {
   return __emul(a, b);
 }
-// CHECK-LABEL: define dso_local i64 @test__emul(i32 noundef %a, i32 noundef 
%b)
+// CHECK-LABEL: define dso_local range(i64 -4611686016279904256, 
4611686018427387905) i64 @test__emul(i32 noundef %a, i32 noundef %b)
 // CHECK: [[X:%[0-9]+]] = sext i32 %a to i64
 // CHECK: [[Y:%[0-9]+]] = sext i32 %b to i64
 // CHECK: [[RES:%[0-9]+]] = mul nsw i64 [[Y]], [[X]]
@@ -57,7 +57,7 @@ __int64 test__emul(int a, int b) {
 unsigned __int64 test__emulu(unsigned int a, unsigned int b) {
   return __emulu(a, b);
 }
-// CHECK-LABEL: define dso_local i64 @test__emulu(i32 noundef %a, i32 noundef 
%b)
+// CHECK-LABEL: define dso_local range(i64 0, -8589934590) i64 
@test__emulu(i32 noundef %a, i32 noundef %b)
 // CHECK: [[X:%[0-9]+]] = zext i32 %a to i64
 // CHECK: [[Y:%[0-9]+]] = zext i32 %b to i64
 // CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
@@ -108,13 +108,13 @@ long long test__readgsqword(unsigned long Offset) {
 __int64 test__mulh(__int64 a, __int64 b) {
   return __mulh(a, b);
 }
-// CHECK-X64-LABEL: define dso_local i64 @test__mulh(i64 noundef %a, i64 
noundef %b)
+// CHECK-X64-LABEL: define dso_local range(i64 -4611686018427387904, 
4611686018427387905) i64 @test__mulh(i64 noundef %a, i64 noundef %b)
 // CHECK-X64: = mul nsw i128 %
 
 unsigned __int64 test__umulh(unsigned __int64 a, unsigned __int64 b) {
   return __umulh(a, b);
 }
-// CHECK-X64-LABEL: define dso_local i64 @test__umulh(i64 noundef %a, i64 
noundef %b)
+// CHECK-X64-LABEL: define dso_local range(i64 0, -1) i64 @test__umulh(i64 
noundef %a, i64 noundef %b)
 // CHECK-X64: = mul nuw i128 %
 
 __int64 test_mul128(__int64 Multiplier,
diff --git a/clang/test/CodeGen/attr-counted-by.c 
b/clang/test/CodeGen/attr-counted-by.c
index 1fb39f9a346667..de30a00138ac80 100644
--- a/clang/test/CodeGen/attr-counted-by.c
+++ b/clang/test/CodeGen/attr-counted-by.c
@@ -66,7 +66,7 @@ struct anon_struct {
 // SANITIZE-WITH-ATTR-NEXT:[[TMP1:%.*]] = icmp ult i64 [[IDXPROM]], 
[[TMP0]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR-NEXT:br i1 [[TMP1]], label [[CONT3:%.*]], label 
[[HANDLER_OUT_OF_BOUNDS:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR:   handler.out_of_bounds:
-// SANITIZE-WITH-ATTR-NEXT:tail call void 
@__ubsan_handle_out_of_bounds_abort(ptr nonnull @[[GLOB2:[0-9]+]], i64 
[[IDXPROM]]) #[[ATTR10:[0-9]+]], !nosanitize [[META2]]
+// SANITIZE-WITH-ATTR-NEXT:tail call void 
@__ubsan_handle_out_of_bounds_abort(ptr nonnull @[[GLOB1:[0-9]+]], i64 
[[IDXPROM]]) #[[ATTR10:[0-9]+]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR-NEXT:unreachable, !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR:   cont3:
 // SANITIZE-WITH-ATTR-NEXT:[[ARRAY:%.*]] = getelementptr inbounds i8, ptr 
[[P]], i64 12
@@ -114,7 +114,7 @@ void test1(struct annotated *p, int index, int val) {
 // SANITIZE-WITH-ATTR-NEXT:[[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 
[[INDEX]], !nosanitize [[META2]]
 // 

  1   2   3   4   >