[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread Jack Styles via cfe-commits


@@ -1354,9 +1354,9 @@ let isScalarNarrowShift = 1 in {
   // Signed/Unsigned Saturating Rounded Shift Right Narrow (Immediate)
   def SCALAR_SQRSHRN_N: SInst<"vqrshrn_n", "(1<)1I", "SsSiSlSUsSUiSUl">;
   // Signed Saturating Shift Right Unsigned Narrow (Immediate)
-  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1<)1I", "SsSiSl">;
+  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1;

Stylie777 wrote:

You have updated this in tablegen, have we covered all the test cases in 
`clang/test/CodeGen/aarch64-neon-intrinsics.c`?

>From a quick grep, it looks like there are some test cases that need their 
>integer type changing from signed to unsigned. 

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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread Jack Styles via cfe-commits


@@ -1354,9 +1354,9 @@ let isScalarNarrowShift = 1 in {
   // Signed/Unsigned Saturating Rounded Shift Right Narrow (Immediate)
   def SCALAR_SQRSHRN_N: SInst<"vqrshrn_n", "(1<)1I", "SsSiSlSUsSUiSUl">;
   // Signed Saturating Shift Right Unsigned Narrow (Immediate)
-  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1<)1I", "SsSiSl">;
+  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1;

Stylie777 wrote:

The tests for this specific intrinsic are already unsigned, resolving.

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


[clang] [NVPTX][AMDGPU][CodeGen] Fix `local_space nullptr` handling for NVPTX and local/private `nullptr` value for AMDGPU. (PR #78759)

2024-02-06 Thread Matt Arsenault via cfe-commits

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

amdgpu parts lgtm (which could be split to a separate change from the ptx 
change)

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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread Jack Styles via cfe-commits

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

LGTM

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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread Jack Styles via cfe-commits

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


[clang] [Clang][AArch64] Warn when calling streaming/non-streaming about vect… (PR #79842)

2024-02-06 Thread Dinar Temirbulatov via cfe-commits


@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-fsyntax-only -verify=expected-cpp -x c++ %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sme -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sme -fsyntax-only -verify=expected-cpp -x c++ %s
+#include 

dtemirbulatov wrote:

ok, but then I have to define __clang_svint32x4_t.

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


[clang] [Clang][AArch64] Warn when calling streaming/non-streaming about vect… (PR #79842)

2024-02-06 Thread Dinar Temirbulatov via cfe-commits

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


[llvm] [clang] [clang-tools-extra] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

2024-02-06 Thread via cfe-commits


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

cor3ntin wrote:

I think a good litmus test as to whether a test belong in Clang or not is, "if 
the test fail, can we fix it?"
And here we would not be able to, lowering IR is not in the purview of the 
front end, so this is not testing the front end.

And sure, there is a wider question here: Does the LLVM middle-end implements 
and test the semantics of C++
and those core issues that are relevant?

But regardless of the answer that question, putting such test here would not 
serve to increase out coverage.
We test that clang produces good IR, and we trust that given the IR of a 
well-formed program LLVM will preserve the semantics.

Ditto we should not test libc++, libc++abi, etc 


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


[llvm] [clang] [clang-tools-extra] [DebugInfo][RemoveDIs] Don't allocate one DPMarker per instruction (PR #79345)

2024-02-06 Thread Jeremy Morse via cfe-commits

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


[llvm] [clang-tools-extra] [clang] [DebugInfo][RemoveDIs] Don't allocate one DPMarker per instruction (PR #79345)

2024-02-06 Thread Jeremy Morse via cfe-commits

jmorse wrote:

Landed in ddc4935

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


[llvm] [clang-tools-extra] [clang] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

2024-02-06 Thread via cfe-commits

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


[clang] [Clang] Implement CWG2598: Union of non-literal types (PR #78195)

2024-02-06 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

@cor3ntin , perhaps a dumb question, but 
https://github.com/llvm/llvm-project/pull/77753 should only help in post C++20 
modes since only there destructor can be `constexpr`. How about older versions? 
Clang will still emit an error that the type from 
https://github.com/llvm/llvm-project/pull/78195#issuecomment-1895950521 is not 
literal in C++17 for example.

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


[clang] 26db3c3 - [clang][Interp] Handle discarding ConstantExprs

2024-02-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-02-06T14:32:21+01:00
New Revision: 26db3c3b72d3c915ad296a5a5313210bde8ce3e1

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

LOG: [clang][Interp] Handle discarding ConstantExprs

Assume no side-effects in the presence of a cashed result in the form
of an APValue. This is also what the current interpreter does.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/cxx20.cpp
clang/test/SemaCXX/cxx11-default-member-initializers.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 10e32d9b7bcf3..f31755e72e8de 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1030,14 +1030,17 @@ bool 
ByteCodeExprGen::VisitSubstNonTypeTemplateParmExpr(
 
 template 
 bool ByteCodeExprGen::VisitConstantExpr(const ConstantExpr *E) {
-  // Try to emit the APValue directly, without visiting the subexpr.
-  // This will only fail if we can't emit the APValue, so won't emit any
-  // diagnostics or any double values.
   std::optional T = classify(E->getType());
-  if (T && E->hasAPValueResult() &&
-  this->visitAPValue(E->getAPValueResult(), *T, E))
-return true;
+  if (T && E->hasAPValueResult()) {
+// Try to emit the APValue directly, without visiting the subexpr.
+// This will only fail if we can't emit the APValue, so won't emit any
+// diagnostics or any double values.
+if (DiscardResult)
+  return true;
 
+if (this->visitAPValue(E->getAPValueResult(), *T, E))
+  return true;
+  }
   return this->delegate(E->getSubExpr());
 }
 

diff  --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp
index 50a7c02925878..0af553a77892e 100644
--- a/clang/test/AST/Interp/cxx20.cpp
+++ b/clang/test/AST/Interp/cxx20.cpp
@@ -752,3 +752,16 @@ namespace TryCatch {
   }
   static_assert(foo() == 11);
 }
+
+namespace IgnoredConstantExpr {
+  consteval int immediate() { return 0;}
+  struct ReferenceToNestedMembers {
+int m;
+int a = ((void)immediate(), m);
+int b = ((void)immediate(), this->m);
+  };
+  struct ReferenceToNestedMembersTest {
+void* m = nullptr;
+ReferenceToNestedMembers j{0};
+  } test_reference_to_nested_members;
+}

diff  --git a/clang/test/SemaCXX/cxx11-default-member-initializers.cpp 
b/clang/test/SemaCXX/cxx11-default-member-initializers.cpp
index 9c18c73be8f68..dd8e9c6b7fc11 100644
--- a/clang/test/SemaCXX/cxx11-default-member-initializers.cpp
+++ b/clang/test/SemaCXX/cxx11-default-member-initializers.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 -verify %s -pedantic
+// RUN: %clang_cc1 -std=c++11 -verify %s -pedantic 
-fexperimental-new-constant-interpreter
 // RUN: %clang_cc1 -std=c++20 -verify %s -pedantic
+// RUN: %clang_cc1 -std=c++20 -verify %s -pedantic 
-fexperimental-new-constant-interpreter
 
 
 namespace PR31692 {



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


[llvm] [clang-tools-extra] [clang] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

2024-02-06 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

AaronBallman wrote:

> Clang's CodeGen is also concerned whether optimization are enabled or not in 
> 55 places. I don't want to miss those codepaths.

Keep in mind that changes get tested in multiple places (when done correctly), 
so when someone implements a DR (or a feature with the DR already applied), 
they should have test coverage in `clang/test/CodeGen*` as well as in 
`clang/test/Sema*`, and here in the DR test file. We don't need to re-test 
things covered by other tests, and sometimes the coverage makes more sense 
elsewhere than a DR test.

I tend to agree with @cor3ntin that this may be going overboard in terms of 
test runs. I would drop the -O3 tests (and remove the -O0 from the other tests) 
unless there's some evidence that we're increasing test coverage we don't 
otherwise get. (We have a coverage report 
(https://lab.llvm.org/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/index.html)
 but it doesn't get run regularly, but that would be one way to show that the 
extra test coverage is testing more paths.)

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


[llvm] [clang-tools-extra] [clang] Reapply "InstCombine: Introduce SimplifyDemandedUseFPClass"" (PR #74056)

2024-02-06 Thread Matt Arsenault via cfe-commits

arsenm wrote:

ping, I want to get this in and move to remove the flag 

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


[llvm] [clang-tools-extra] [clang] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

2024-02-06 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

AaronBallman wrote:

> And sure, there is a wider question here: Does the LLVM middle-end implements 
> and test the semantics of C++ and those core issues that are relevant?

CC @lattner as [general LLVM code 
owner](https://github.com/llvm/llvm-project/blob/26db3c3b72d3c915ad296a5a5313210bde8ce3e1/llvm/CODE_OWNERS.TXT#L154),
 both for an answer to this question, but also as a request to find a dedicated 
code owner within LLVM that the Clang community can interface with regarding C 
and C++ conformance from the LLVM side of things. (For example, we really need 
someone on the LLVM side who we can talk to regarding changes to the memory 
object model in both C and C++ as the languages evolve so that we can plan a 
path forward accordingly.)

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


[llvm] [clang] [AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets (PR #76955)

2024-02-06 Thread Pierre van Houtryve via cfe-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/76955

>From 616dda8bc9e000e4243ddb8f6b7f4b04f956a620 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Thu, 4 Jan 2024 14:48:05 +0100
Subject: [PATCH 1/3] [AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets

These generic targets include multiple GPUs and will, in the future, provide a 
way to build once and run on multiple GPU, at the cost of less optimization 
opportunities.
Note that this is just doing the compiler side of things, device libs an 
runtimes/loader/etc. don't know about these targets yet, so none of them 
actually work in practice right now. This is just the initial commit to make 
LLVM aware of them.

No docs in this patch either as I plan to do it all in a follow-up patch.
---
 clang/lib/Basic/Targets/AMDGPU.cpp|  20 +-
 clang/test/Driver/amdgpu-macros.cl|   5 +
 clang/test/Driver/amdgpu-mcpu.cl  |  10 +
 llvm/docs/AMDGPUUsage.rst | 325 +-
 llvm/include/llvm/BinaryFormat/ELF.h  |   6 +-
 llvm/include/llvm/TargetParser/TargetParser.h |  10 +
 llvm/lib/Object/ELFObjectFile.cpp |  10 +
 llvm/lib/ObjectYAML/ELFYAML.cpp   |   4 +
 llvm/lib/Target/AMDGPU/AMDGPU.td  |  87 +++--
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |   6 +
 .../AMDGPURemoveIncompatibleFunctions.cpp |   6 +-
 llvm/lib/Target/AMDGPU/GCNProcessors.td   |  22 ++
 llvm/lib/Target/AMDGPU/GCNSubtarget.h |   4 +
 .../MCTargetDesc/AMDGPUTargetStreamer.cpp |  26 ++
 llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h |  11 +
 llvm/lib/TargetParser/TargetParser.cpp|  46 +++
 .../GlobalISel/llvm.amdgcn.workitem.id.ll |   1 +
 .../CodeGen/AMDGPU/directive-amdgcn-target.ll |  14 +
 .../CodeGen/AMDGPU/elf-header-flags-mach.ll   |  10 +
 llvm/test/CodeGen/AMDGPU/gds-allocation.ll|   1 +
 llvm/test/CodeGen/AMDGPU/gds-atomic.ll|   1 +
 .../AMDGPU/generic-targets-require-v6.ll  |  18 +
 .../AMDGPU/hsa-generic-target-features.ll |  31 ++
 .../llvm.amdgcn.image.gather4.d16.dim.ll  |   3 +
 .../AMDGPU/llvm.amdgcn.image.sample.dim.ll|   3 +
 .../AMDGPU/unsupported-image-sample.ll|  12 +-
 .../Object/AMDGPU/elf-header-flags-mach.yaml  |  29 ++
 .../llvm-objdump/ELF/AMDGPU/subtarget.ll  |  20 ++
 .../llvm-readobj/ELF/AMDGPU/elf-headers.test  |  12 +
 llvm/tools/llvm-readobj/ELFDumper.cpp | 128 +++
 30 files changed, 689 insertions(+), 192 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/generic-targets-require-v6.ll
 create mode 100644 llvm/test/CodeGen/AMDGPU/hsa-generic-target-features.ll

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 141501e8a4d9a..799634ccec7ba 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -279,13 +279,25 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (GPUKind == llvm::AMDGPU::GK_NONE && !IsHIPHost)
 return;
 
-  StringRef CanonName = isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
-  : getArchNameR600(GPUKind);
+  std::string CanonName = (isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
+ : getArchNameR600(GPUKind))
+  .str();
+
+  // Sanitize the name of generic targets.
+  // e.g. gfx10.1-generic -> gfx10_1_generic
+  if (GPUKind >= llvm::AMDGPU::GK_AMDGCN_GENERIC_FIRST &&
+  GPUKind <= llvm::AMDGPU::GK_AMDGCN_GENERIC_LAST) {
+std::replace(CanonName.begin(), CanonName.end(), '.', '_');
+std::replace(CanonName.begin(), CanonName.end(), '-', '_');
+  }
+
   Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
   // Emit macros for gfx family e.g. gfx906 -> __GFX9__, gfx1030 -> __GFX10___
   if (isAMDGCN(getTriple()) && !IsHIPHost) {
-assert(CanonName.starts_with("gfx") && "Invalid amdgcn canonical name");
-Builder.defineMacro(Twine("__") + Twine(CanonName.drop_back(2).upper()) +
+assert(StringRef(CanonName).starts_with("gfx") &&
+   "Invalid amdgcn canonical name");
+StringRef CanonFamilyName = getArchFamilyNameAMDGCN(GPUKind);
+Builder.defineMacro(Twine("__") + Twine(CanonFamilyName.upper()) +
 Twine("__"));
 Builder.defineMacro("__amdgcn_processor__",
 Twine("\"") + Twine(CanonName) + Twine("\""));
diff --git a/clang/test/Driver/amdgpu-macros.cl 
b/clang/test/Driver/amdgpu-macros.cl
index 81c22af460d12..3b10444ef71d3 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -131,6 +131,11 @@
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1200 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1200 
-DFAMILY=GFX12
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1201 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,FAST_FMAF %s 

[clang] [NFC][Clang][Headers] Update refs to ACLE in comments (PR #78305)

2024-02-06 Thread James Westwood via cfe-commits


@@ -308,7 +313,7 @@ __qdbl(int32_t __t) {
 }
 #endif
 
-/* 9.4.3 Accumultating multiplications */
+/* 8.4.3 Accumultating multiplications */

jwestwood921 wrote:

There is a spelling error: 'Accumultating' instead of 'Accumulating'.

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


[llvm] [clang] [AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets (PR #76955)

2024-02-06 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 500846d2f542c93e349161a39a1baae0f1f6fad0 
eb8bd3422c24604af788e21d06958154631adc81 -- clang/lib/Basic/Targets/AMDGPU.cpp 
clang/test/Misc/target-invalid-cpu-note.c llvm/include/llvm/BinaryFormat/ELF.h 
llvm/include/llvm/TargetParser/TargetParser.h llvm/lib/Object/ELFObjectFile.cpp 
llvm/lib/ObjectYAML/ELFYAML.cpp llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp 
llvm/lib/Target/AMDGPU/GCNSubtarget.h 
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp 
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h 
llvm/lib/TargetParser/TargetParser.cpp llvm/tools/llvm-readobj/ELFDumper.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 7cfae129a6..10cba6b7ea 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -280,8 +280,9 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (GPUKind == llvm::AMDGPU::GK_NONE && !IsHIPHost)
 return;
 
- llvm::SmallString<16> CanonName = (isAMDGCN(getTriple()) ? 
getArchNameAMDGCN(GPUKind)
- : getArchNameR600(GPUKind));
+  llvm::SmallString<16> CanonName =
+  (isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
+ : getArchNameR600(GPUKind));
 
   // Sanitize the name of generic targets.
   // e.g. gfx10.1-generic -> gfx10_1_generic

``




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


[llvm] [clang-tools-extra] [flang] [clang] [Matrix] Convert column-vector ops feeding dot product to row-vectors. (PR #72647)

2024-02-06 Thread Florian Hahn via cfe-commits

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


[clang] [NFC][Clang][Headers] Update refs to ACLE in comments (PR #78305)

2024-02-06 Thread James Westwood via cfe-commits


@@ -540,7 +545,7 @@ __usub16(uint16x2_t __a, uint16x2_t __b) {
 }
 #endif
 
-/* 9.5.10 Parallel 16-bit multiplications */
+/* 8.5.10 Parallel 16-bit multiplications */

jwestwood921 wrote:

Nit pick: The ACLE document has 'multiplication', instead of 'multiplications'.

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


[clang] [CLANG] Fix INF/NAN warning. (PR #80290)

2024-02-06 Thread Aaron Ballman via cfe-commits

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

LGTM, thank you!

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


[llvm] [clang] Revert "InstCombine: Fold is.fpclass(x, fcInf) to fabs+fcmp" (PR #76338)

2024-02-06 Thread Matt Arsenault via cfe-commits

arsenm wrote:

@dtcxzyw are you planning on a codegen patch to improve the backend handling? 

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


[llvm] [clang] [AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets (PR #76955)

2024-02-06 Thread Pierre van Houtryve via cfe-commits

https://github.com/Pierre-vh updated 
https://github.com/llvm/llvm-project/pull/76955

>From 616dda8bc9e000e4243ddb8f6b7f4b04f956a620 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Thu, 4 Jan 2024 14:48:05 +0100
Subject: [PATCH 1/4] [AMDGPU] Introduce GFX9/10.1/10.3/11 Generic Targets

These generic targets include multiple GPUs and will, in the future, provide a 
way to build once and run on multiple GPU, at the cost of less optimization 
opportunities.
Note that this is just doing the compiler side of things, device libs an 
runtimes/loader/etc. don't know about these targets yet, so none of them 
actually work in practice right now. This is just the initial commit to make 
LLVM aware of them.

No docs in this patch either as I plan to do it all in a follow-up patch.
---
 clang/lib/Basic/Targets/AMDGPU.cpp|  20 +-
 clang/test/Driver/amdgpu-macros.cl|   5 +
 clang/test/Driver/amdgpu-mcpu.cl  |  10 +
 llvm/docs/AMDGPUUsage.rst | 325 +-
 llvm/include/llvm/BinaryFormat/ELF.h  |   6 +-
 llvm/include/llvm/TargetParser/TargetParser.h |  10 +
 llvm/lib/Object/ELFObjectFile.cpp |  10 +
 llvm/lib/ObjectYAML/ELFYAML.cpp   |   4 +
 llvm/lib/Target/AMDGPU/AMDGPU.td  |  87 +++--
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |   6 +
 .../AMDGPURemoveIncompatibleFunctions.cpp |   6 +-
 llvm/lib/Target/AMDGPU/GCNProcessors.td   |  22 ++
 llvm/lib/Target/AMDGPU/GCNSubtarget.h |   4 +
 .../MCTargetDesc/AMDGPUTargetStreamer.cpp |  26 ++
 llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h |  11 +
 llvm/lib/TargetParser/TargetParser.cpp|  46 +++
 .../GlobalISel/llvm.amdgcn.workitem.id.ll |   1 +
 .../CodeGen/AMDGPU/directive-amdgcn-target.ll |  14 +
 .../CodeGen/AMDGPU/elf-header-flags-mach.ll   |  10 +
 llvm/test/CodeGen/AMDGPU/gds-allocation.ll|   1 +
 llvm/test/CodeGen/AMDGPU/gds-atomic.ll|   1 +
 .../AMDGPU/generic-targets-require-v6.ll  |  18 +
 .../AMDGPU/hsa-generic-target-features.ll |  31 ++
 .../llvm.amdgcn.image.gather4.d16.dim.ll  |   3 +
 .../AMDGPU/llvm.amdgcn.image.sample.dim.ll|   3 +
 .../AMDGPU/unsupported-image-sample.ll|  12 +-
 .../Object/AMDGPU/elf-header-flags-mach.yaml  |  29 ++
 .../llvm-objdump/ELF/AMDGPU/subtarget.ll  |  20 ++
 .../llvm-readobj/ELF/AMDGPU/elf-headers.test  |  12 +
 llvm/tools/llvm-readobj/ELFDumper.cpp | 128 +++
 30 files changed, 689 insertions(+), 192 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/generic-targets-require-v6.ll
 create mode 100644 llvm/test/CodeGen/AMDGPU/hsa-generic-target-features.ll

diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 141501e8a4d9a..799634ccec7ba 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -279,13 +279,25 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (GPUKind == llvm::AMDGPU::GK_NONE && !IsHIPHost)
 return;
 
-  StringRef CanonName = isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
-  : getArchNameR600(GPUKind);
+  std::string CanonName = (isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
+ : getArchNameR600(GPUKind))
+  .str();
+
+  // Sanitize the name of generic targets.
+  // e.g. gfx10.1-generic -> gfx10_1_generic
+  if (GPUKind >= llvm::AMDGPU::GK_AMDGCN_GENERIC_FIRST &&
+  GPUKind <= llvm::AMDGPU::GK_AMDGCN_GENERIC_LAST) {
+std::replace(CanonName.begin(), CanonName.end(), '.', '_');
+std::replace(CanonName.begin(), CanonName.end(), '-', '_');
+  }
+
   Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
   // Emit macros for gfx family e.g. gfx906 -> __GFX9__, gfx1030 -> __GFX10___
   if (isAMDGCN(getTriple()) && !IsHIPHost) {
-assert(CanonName.starts_with("gfx") && "Invalid amdgcn canonical name");
-Builder.defineMacro(Twine("__") + Twine(CanonName.drop_back(2).upper()) +
+assert(StringRef(CanonName).starts_with("gfx") &&
+   "Invalid amdgcn canonical name");
+StringRef CanonFamilyName = getArchFamilyNameAMDGCN(GPUKind);
+Builder.defineMacro(Twine("__") + Twine(CanonFamilyName.upper()) +
 Twine("__"));
 Builder.defineMacro("__amdgcn_processor__",
 Twine("\"") + Twine(CanonName) + Twine("\""));
diff --git a/clang/test/Driver/amdgpu-macros.cl 
b/clang/test/Driver/amdgpu-macros.cl
index 81c22af460d12..3b10444ef71d3 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -131,6 +131,11 @@
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1200 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,FAST_FMAF %s -DWAVEFRONT_SIZE=32 -DCPU=gfx1200 
-DFAMILY=GFX12
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1201 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,FAST_FMAF %s 

[clang] [clang][Interp] Bail out on missing ComparisonCategoryInfo (PR #80131)

2024-02-06 Thread Aaron Ballman via cfe-commits


@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter 
-verify

AaronBallman wrote:

I'm really confused what this test has to do with the changes above. The 
changes relate to three-way comparison operators but this test is a C test file 
and has no comparison operators involved. Why would this test hit that 
assertion?

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


[llvm] [clang-tools-extra] [clang] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

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


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

Endilll wrote:

> I think a good litmus test as to whether a test belong in Clang or not is, 
> "if the test fail, can we fix it?"
And here we would not be able to, lowering IR is not in the purview of the 
front end, so this is not testing the front end.

Lowering AST to IR _is_ in purview of Clang, and we're responsible that this 
happens correctly (even if no single individual in this conversation is an 
expert in that part of Clang). I hope everyone here agrees that middle-end 
folks are not responsible for the correctness of our CodeGen from the C++ 
language semantics perspective.

> And sure, there is a wider question here: Does the LLVM middle-end implements 
> and test the semantics of C++
and those core issues that are relevant?

No, there is no such question, and there wasn't at any point in DR testing 
discussion. CodeGen DR tests are interested in Clang's CodeGen, and I do my 
best to ensure that middle-end does not interfere. If you think middle-end is 
still involved somehow, let me know how this can be fixed.

> Keep in mind that changes get tested in multiple places (when done 
> correctly), so when someone implements a DR (or a feature with the DR already 
> applied), they should have test coverage in clang/test/CodeGen* as well as in 
> clang/test/Sema*, and here in the DR test file. We don't need to re-test 
> things covered by other tests, and sometimes the coverage makes more sense 
> elsewhere than a DR test.

This holds for the "usual" DR tests as well. They sure duplicate some of Sema 
tests. Same goes for the whole CXX directory. On top of the fact that 
calculating coverage is both time- and resource- consuming, making automatic 
duplicate discovery a serious burden, regular Sema and CodeGen tests are not 
necessarily designed to cover use cases DR tests cover. Which means they can 
change in a ways not fit for DR testing. So we should be careful about 
depending on them.

> I tend to agree with @cor3ntin that this may be going overboard in terms of 
> test runs.

It wouldn't take too much time for a list of lang

[llvm] [clang] [clang-tools-extra] [Clang] Fix : More Detailed "No expected directives found" (PR #78338)

2024-02-06 Thread Aaron Ballman via cfe-commits


@@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error<
 "%select{expected|'expected-no-diagnostics'}0 directive cannot follow "
 "%select{'expected-no-diagnostics' directive|other expected directives}0">;

AaronBallman wrote:

No worries about the extra pings (we'd rather see people "too" enthusiastic 
than disengaged!), just something to keep in mind for the future. :-)

The reason I think this diagnostic also needs to be updated is because of: 
https://godbolt.org/z/sEf4o8YY9 and https://godbolt.org/z/8oMWffoxY where it 
says `'expected-no-diagnostics'` in the diagnostic message. I think those 
should also say `'foo-no-diagnostics'` similar to how you've fixed it for the 
`no expected directives found` warning.

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


[llvm] [clang] [AIX] support builtin_cpu_is() for aix (PR #80069)

2024-02-06 Thread zhijian lin via cfe-commits


@@ -16542,22 +16542,75 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 
   Intrinsic::ID ID = Intrinsic::not_intrinsic;
 
+#include "llvm/TargetParser/PPCTargetParser.def"
+  auto GetOpRes = [&](Value *FieldValue, unsigned Mask, unsigned Op,
+  unsigned Op_Value) -> Value * {
+Value *Value1 = FieldValue;
+if (Mask)
+  Value1 = Builder.CreateAnd(Value1, Mask);
+assert((Op == OP_EQ) && "Only support equal comparision");
+return Builder.CreateICmp(ICmpInst::ICMP_EQ, FieldValue,
+  ConstantInt::get(Int32Ty, Op_Value));
+  };
+
+  auto ConvBuiltinCpu = [&](unsigned SupportOP, unsigned FieldIdx,
+unsigned Op_Mask, unsigned Op,
+unsigned Op_Value) -> Value * {
+if (SupportOP == AIX_BUILTIN_PPC_FALSE)
+  return llvm::ConstantInt::getFalse(ConvertType(E->getType()));

diggerlin wrote:

I guess you want to let the code more efficiently with pulling out E->getType() 
? 
but
1. if I pull out E->getType() , it means that  E->getType() will be run in the 
all call flow path even `SupportOP == OP_EQ`, which do not need the 
E->getType(). 
 2. the  `E->getType()` only be called once at maximum at each call flow path.  

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


[clang] [compiler-rt] [llvm] [clang-tools-extra] [libc] [flang] [VPlan] Consistently use (Part, 0) for first lane scalar values (PR #80271)

2024-02-06 Thread Florian Hahn via cfe-commits

https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/80271

>From f4dabdfaa66744ecfca4c0a57472a357db9715d9 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 31 Jan 2024 14:02:38 +
Subject: [PATCH 1/3] [VPlan] Update VPInst::onlyFirstLaneUsed to check users.

A VPInstruction only has its first lane used if all users use its first
lane only. Use vputils::onlyFirstLaneUsed to continue checking the
recipe's users to handle more cases.

Besides allowing additional introduction of scalar steps when
interleaving in some cases, this also enables using an Add VPInstruction
to model the increment.
---
 llvm/lib/Transforms/Vectorize/VPlan.cpp   |   4 +-
 llvm/lib/Transforms/Vectorize/VPlan.h |  20 +--
 .../lib/Transforms/Vectorize/VPlanRecipes.cpp |  18 ++
 .../pr45679-fold-tail-by-masking.ll   | 160 +-
 .../tail-folding-vectorization-factor-1.ll|  66 
 5 files changed, 129 insertions(+), 139 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index a1bd6aaf0e551..1ca2cfef447f6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1397,9 +1397,9 @@ void VPSlotTracker::assignSlots(const VPBasicBlock *VPBB) 
{
   assignSlot(Def);
 }
 
-bool vputils::onlyFirstLaneUsed(VPValue *Def) {
+bool vputils::onlyFirstLaneUsed(const VPValue *Def) {
   return all_of(Def->users(),
-[Def](VPUser *U) { return U->onlyFirstLaneUsed(Def); });
+[Def](const VPUser *U) { return U->onlyFirstLaneUsed(Def); });
 }
 
 bool vputils::onlyFirstPartUsed(VPValue *Def) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 20792cb9ac7c1..30dc521947b3b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1256,23 +1256,7 @@ class VPInstruction : public VPRecipeWithIRFlags {
 }
   }
 
-  /// Returns true if the recipe only uses the first lane of operand \p Op.
-  bool onlyFirstLaneUsed(const VPValue *Op) const override {
-assert(is_contained(operands(), Op) &&
-   "Op must be an operand of the recipe");
-if (getOperand(0) != Op)
-  return false;
-switch (getOpcode()) {
-default:
-  return false;
-case VPInstruction::ActiveLaneMask:
-case VPInstruction::CalculateTripCountMinusVF:
-case VPInstruction::CanonicalIVIncrementForPart:
-case VPInstruction::BranchOnCount:
-  return true;
-};
-llvm_unreachable("switch should return");
-  }
+  bool onlyFirstLaneUsed(const VPValue *Op) const override;
 
   /// Returns true if the recipe only uses the first part of operand \p Op.
   bool onlyFirstPartUsed(const VPValue *Op) const override {
@@ -3385,7 +3369,7 @@ class VPlanSlp {
 namespace vputils {
 
 /// Returns true if only the first lane of \p Def is used.
-bool onlyFirstLaneUsed(VPValue *Def);
+bool onlyFirstLaneUsed(const VPValue *Def);
 
 /// Returns true if only the first part of \p Def is used.
 bool onlyFirstPartUsed(VPValue *Def);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index e51184b0dd1fe..21b8d1eb77bf9 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -515,6 +515,24 @@ void VPInstruction::execute(VPTransformState &State) {
 State.set(this, GeneratedValue, Part);
   }
 }
+bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const {
+  assert(is_contained(operands(), Op) && "Op must be an operand of the 
recipe");
+  if (Instruction::isBinaryOp(getOpcode()))
+return vputils::onlyFirstLaneUsed(this);
+
+  switch (getOpcode()) {
+  default:
+return false;
+  case Instruction::ICmp:
+return vputils::onlyFirstLaneUsed(this);
+  case VPInstruction::ActiveLaneMask:
+  case VPInstruction::CalculateTripCountMinusVF:
+  case VPInstruction::CanonicalIVIncrementForPart:
+  case VPInstruction::BranchOnCount:
+return getOperand(0) == Op;
+  };
+  llvm_unreachable("switch should return");
+}
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 void VPInstruction::dump() const {
diff --git a/llvm/test/Transforms/LoopVectorize/pr45679-fold-tail-by-masking.ll 
b/llvm/test/Transforms/LoopVectorize/pr45679-fold-tail-by-masking.ll
index e81fb66239bd4..f05ec30619c5d 100644
--- a/llvm/test/Transforms/LoopVectorize/pr45679-fold-tail-by-masking.ll
+++ b/llvm/test/Transforms/LoopVectorize/pr45679-fold-tail-by-masking.ll
@@ -67,7 +67,7 @@ define void @pr45679(ptr %A) optsize {
 ; CHECK-NEXT:store i32 13, ptr [[ARRAYIDX]], align 1
 ; CHECK-NEXT:[[RIVPLUS1]] = add nuw nsw i32 [[RIV]], 1
 ; CHECK-NEXT:[[COND:%.*]] = icmp eq i32 [[RIVPLUS1]], 14
-; CHECK-NEXT:br i1 [[COND]], label [[EXIT]], label [[LOOP]], !llvm.loop 
[[LOOP2:![0-9]+]]
+; CHECK-NEXT:br i1 [[COND]], label [[EXIT]], label [[LOOP]], !llvm.loop 
[[LOOP3:![0-9]+]]
 ; CHECK:

[clang] [clang] require template arg list after template kw (PR #80801)

2024-02-06 Thread Erick Velez via cfe-commits


@@ -1414,7 +1414,7 @@ namespace dr96 { // dr96: no
 // FIXME: This is ill-formed, because 'f' is not a template-id and does not
 // name a class template.
 // FIXME: What about alias templates?

evelez7 wrote:

The use of 'template' before an alias template is 
[deprecated](https://eel.is/c++draft/depr.template.template), along with before 
a class template. I wasn't sure how to interpret this for clang, they aren't 
errors yet?

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


[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)

2024-02-06 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm requested changes to this pull request.

Is this redundant with #68515? Do we just need to add OpenCL test coverage?

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


[clang] [clang][Interp] Bail out on missing ComparisonCategoryInfo (PR #80131)

2024-02-06 Thread Timm Baeder via cfe-commits


@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter 
-verify

tbaederr wrote:

The AST we trip up on is
```
BinaryOperator 0x5216ed08 'struct S' '='
|-DeclRefExpr 0x5216eba0 'struct S' lvalue Var 0x5216e998 'tmp' 'struct 
S'
`-CStyleCastExpr 0x5216ecd8 'struct S' 
  `-CallExpr 0x5216ec88 'struct S'
`-ImplicitCastExpr 0x5216ec68 'const struct S (*)(void)' 

  `-DeclRefExpr 0x5216ebc8 'const struct S (void)' Function 
0x5216e870 'foo' 'const struct S (void)'
```

IIUC this should be rejected since the assignment doesn't work, but we're 
asserting that we found `CmpInfo`. We could of course also add more assertions 
that we're even in C++ mode when looking for the spaceship operator stuff.

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


[clang] [llvm] [clang-tools-extra] [clang] reject to capture variable in `RequiresExprBodyDecl` (PR #78598)

2024-02-06 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/78598

>From 8fa3dc43e770025308da47f6aff309fa58c47fc3 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 18 Jan 2024 23:12:23 +0800
Subject: [PATCH 1/4] [clang] reject to capture variable in
 `RequiresExprBodyDecl`

Expression in `RequiresExprBodyDecl` is resolved as constants and should not be 
captured.
Fixes: #69307, #76593.
---
 clang/lib/Sema/SemaExpr.cpp   | 21 ++--
 ...uires-expression-with-capture-variable.cpp | 25 +++
 2 files changed, 38 insertions(+), 8 deletions(-)
 create mode 100644 
clang/test/SemaCXX/requires-expression-with-capture-variable.cpp

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6413a48f809ac..580e759f63495 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19704,6 +19704,12 @@ static void buildLambdaCaptureFixit(Sema &Sema, 
LambdaScopeInfo *LSI,
   }
 }
 
+static DeclContext *ignoreReuquiresBodyDecl(DeclContext *DC) {
+  if (isa_and_present(DC))
+return DC->getParent();
+  return DC;
+}
+
 bool Sema::tryCaptureVariable(
 ValueDecl *Var, SourceLocation ExprLoc, TryCaptureKind Kind,
 SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType,
@@ -19711,15 +19717,15 @@ bool Sema::tryCaptureVariable(
   // An init-capture is notionally from the context surrounding its
   // declaration, but its parent DC is the lambda class.
   DeclContext *VarDC = Var->getDeclContext();
-  DeclContext *DC = CurContext;
-
   // tryCaptureVariable is called every time a DeclRef is formed,
   // it can therefore have non-negigible impact on performances.
   // For local variables and when there is no capturing scope,
   // we can bailout early.
-  if (CapturingFunctionScopes == 0 && (!BuildAndDiagnose || VarDC == DC))
+  if (CapturingFunctionScopes == 0 && (!BuildAndDiagnose || VarDC == 
CurContext))
 return true;
 
+  DeclContext *DC = ignoreReuquiresBodyDecl(CurContext);
+
   const auto *VD = dyn_cast(Var);
   if (VD) {
 if (VD->isInitCapture())
@@ -19789,11 +19795,10 @@ bool Sema::tryCaptureVariable(
 
 // Only block literals, captured statements, and lambda expressions can
 // capture; other scopes don't work.
-DeclContext *ParentDC =
-!IsInScopeDeclarationContext
-? DC->getParent()
-: getParentOfCapturingContextOrNull(DC, Var, ExprLoc,
-BuildAndDiagnose, *this);
+DeclContext *ParentDC = IsInScopeDeclarationContext
+? getParentOfCapturingContextOrNull(
+  DC, Var, ExprLoc, BuildAndDiagnose, 
*this)
+: DC->getParent();
 // We need to check for the parent *first* because, if we *have*
 // private-captured a global variable, we need to recursively capture it in
 // intermediate blocks, lambdas, etc.
diff --git a/clang/test/SemaCXX/requires-expression-with-capture-variable.cpp 
b/clang/test/SemaCXX/requires-expression-with-capture-variable.cpp
new file mode 100644
index 0..d01a54133f6c3
--- /dev/null
+++ b/clang/test/SemaCXX/requires-expression-with-capture-variable.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -fsyntax-only -std=c++20 -Xclang -verify %s
+
+// expected-no-diagnostics
+
+auto GH69307_Func_1() {
+  constexpr auto b = 1;
+  return [&](auto c) -> int
+   requires requires { b + c; }
+  { return 1; };
+};
+auto GH69307_Func_Ret = GH69307_Func_1()(1);
+
+auto GH69307_Lambda_1 = []() {
+  return [&](auto c) -> int
+   requires requires { c; }
+  { return 1; };
+};
+auto GH69307_Lambda_1_Ret = GH69307_Lambda_1()(1);
+
+auto GH69307_Lambda_2 = [](auto c) {
+  return [&]() -> int
+   requires requires { c; }
+  { return 1; };
+};
+auto GH69307_Lambda_2_Ret = GH69307_Lambda_2(1)();

>From a99f16ff51702ff249cdf8a47de0cf24a08f694a Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Sat, 20 Jan 2024 13:40:12 +0800
Subject: [PATCH 2/4] another test

---
 clang/test/SemaCXX/warn-unused-lambda-capture-cxx20.cpp | 7 +++
 clang/test/SemaCXX/warn-unused-lambda-capture.cpp   | 4 
 2 files changed, 11 insertions(+)
 create mode 100644 clang/test/SemaCXX/warn-unused-lambda-capture-cxx20.cpp

diff --git a/clang/test/SemaCXX/warn-unused-lambda-capture-cxx20.cpp 
b/clang/test/SemaCXX/warn-unused-lambda-capture-cxx20.cpp
new file mode 100644
index 0..b787edb188ed8
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-lambda-capture-cxx20.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++20 %s
+
+void test() {
+  int i;
+  auto explicit_by_value_unused_requires = [i] (auto) requires requires { i; } 
{}; // expected-warning{{lambda capture 'i' is not required to be captured for 
this use}}
+  explicit_by_value_unused_requires(1);
+}
diff --git a/clang/

[clang] [llvm] [clang-tools-extra] [clang] reject to capture variable in `RequiresExprBodyDecl` (PR #78598)

2024-02-06 Thread Congcong Cai via cfe-commits


@@ -19706,22 +19706,29 @@ static void buildLambdaCaptureFixit(Sema &Sema, 
LambdaScopeInfo *LSI,
   }
 }
 
+static DeclContext *ignoreReuquiresBodyDecl(DeclContext *DC) {

HerrCai0907 wrote:

I think inline it will be better since we only call it once.

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


[clang] [clang-tools-extra] [llvm] [clang] reject to capture variable in `RequiresExprBodyDecl` (PR #78598)

2024-02-06 Thread Congcong Cai via cfe-commits


@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++20 %s
+
+void test() {
+  int i;
+  auto explicit_by_value_unused_requires = [i] (auto) requires requires { i; } 
{}; // expected-warning{{lambda capture 'i' is not required to be captured for 
this use}}

HerrCai0907 wrote:

That would be interesting. I will try to do it later in festival.

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


[clang] [clang-tools-extra] [llvm] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

2024-02-06 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

AaronBallman wrote:

CC @rjmccall and @efriedma-quic as Clang codegen code owners.

> Lowering AST to IR _is_ in purview of Clang, and we're responsible that this 
> happens correctly (even if no single individual in this conversation is an 
> expert in that part of Clang). I hope everyone here agrees that middle-end 
> folks are not responsible for the correctness of our CodeGen from the C++ 
> language semantics perspective.

There's a handshake involved between Clang and LLVM, so I don't think there's 
*one* responsible party for correctness here. Part of the correctness comes 
from Clang lowering to sensible LLVM IR, but we sometimes need LLVM folks to 
tell us what that sensible IR is or to provide different tools for us if 
existing IR doesn't suffice. However, in terms of DR testing, I think most of 
the effort should be expended on Clang's side of things.

> It wouldn't take too much time for a list of language modes to have the same 
> length. Is cutting a number of language modes DR tests are run in also on the 
> table because of arbitrary limits (as I see them at the moment)?

IMO, we want to find a happy middle ground between testing too much and testing 
too little. The issues with testing too little are obvious, but the issue from 
over-testing is that we waste significant resources for little benefit. 
Everyone runs the test suite (precommit CI, postcommit CI, and developers on 
their local machines) so if we increase the test time significantly without 
discernible benefit, that can lead to death-by-a-thousand-cuts problems.

FWIW, I wasn't insisting on code coverage measurements. I was more pointing out 
that I think we should not add the extra RUN lines for -O3 while speculating 
that it increases test coverage. We should have some reason to believe it 
increases test coverage, and we might want to consider splitting those tests 
out into their own file so we don't run 100 DR tests in two optimization modes 
for every standard version we're testing.

https://github.com/llvm/llvm-project/pull/80823
___

[clang] [CLANG] Fix INF/NAN warning. (PR #80290)

2024-02-06 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

Tagging @zeroomega and @mikaelholmen for awareness.

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


[clang] 62c352e - [CLANG] Fix INF/NAN warning. (#80290)

2024-02-06 Thread via cfe-commits

Author: Zahira Ammarguellat
Date: 2024-02-06T09:23:22-05:00
New Revision: 62c352e13c145b5606ace88ecbe9164ff011b5cf

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

LOG: [CLANG] Fix INF/NAN warning. (#80290)

In https://github.com/llvm/llvm-project/pull/76873 a warning was added
when the macros INFINITY and NAN are used in binary expressions when
-menable-no-nans or -menable-no-infs are used. If the user uses an
option that nullifies these two options, the warning will still be
generated. This patch adds an additional information to the warning
comment to let the user know about this. It also suppresses the warning
when #ifdef INFINITY, #ifdef NAN, #ifdef NAN or #ifndef NAN are used in
the code.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/DiagnosticDocs.td
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPExpressions.cpp
clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
clang/test/Sema/warn-infinity-nan-disabled-win.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b28..08bb1d81ba29f1 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning<
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
   "due to the currently enabled floating-point options">,
-  InGroup>;
+  InGroup>;
 }
 
 // Parse && Sema

diff  --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index e9862422b4997e..8c024b5cad740a 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -87,3 +87,12 @@ program by treating all string literals as having type 
``const char *``
 instead of ``char *``. This can cause unexpected behaviors with type-sensitive
 constructs like ``_Generic``.
 }];
+
+defvar NanInfDisabledDocs = [{
+This warning is enabled when source code using the macros ``INFINITY`` or 
``NAN``
+is compiled with floating-point options preventing these two values. This can
+lead to undefined behavior. Check the order of command line arguments that 
modify
+this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and
+``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is
+generated unexpectedly.
+}];

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 9d0d53129a12dd..0836b7d439bb04 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2838,7 +2838,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2847,12 +2848,12 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
+if (!IsIfnDef) {
+  if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
 emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
+  if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
 emitRestrictInfNaNWarning(Identifier, 1);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3ba..a980f4bcbae124 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");

diff  --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 1feb0eb18d71e6..8f25c67ec9dfbe 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token 
&PeekTok, DefinedTracker &DT,
   Result.Val.setIsUnsigned(false); // Result is signed intm

[clang] [CLANG] Fix INF/NAN warning. (PR #80290)

2024-02-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [CLANG] Fix INF/NAN warning. (PR #80290)

2024-02-06 Thread via cfe-commits

mikaelholmen wrote:

Thanks!

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


[clang-tools-extra] [clang] [llvm] [codegen] Emit cleanups for lifetime-extended temporaries when an expr contains control-flow (PR #80698)

2024-02-06 Thread Utkarsh Saxena via cfe-commits

usx95 wrote:

Thanks for the example. I was only considering branches leading outside 
function scope (`return` and coroutine destruction while `co_await`-ing).

I have captured the lifetime-extended cleanup stack size expected by the jump 
destination. This seems to generalize well to all kinds of branch instructions.
PTAL

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


[clang-tools-extra] [clang] [llvm] [codegen] Emit cleanups for lifetime-extended temporaries when an expr contains control-flow (PR #80698)

2024-02-06 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/80698

>From 28d90711ff8e4924135d4bd4e5f252d96ac41b93 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 23 Jan 2024 20:18:25 +
Subject: [PATCH 1/4] [misc-coroutine-hostile-raii] Use getOperand instead of
 getCommonExpr

---
 .../misc/CoroutineHostileRAIICheck.cpp|  2 +-
 .../checkers/misc/coroutine-hostile-raii.cpp  | 34 ++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp 
b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
index a0e8700b0522b..360335b86c641 100644
--- a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
@@ -56,7 +56,7 @@ AST_MATCHER_P(Stmt, forEachPrevStmt, 
ast_matchers::internal::Matcher,
 // Matches the expression awaited by the `co_await`.
 AST_MATCHER_P(CoawaitExpr, awaitable, ast_matchers::internal::Matcher,
   InnerMatcher) {
-  if (Expr *E = Node.getCommonExpr())
+  if (Expr *E = Node.getOperand())
 return InnerMatcher.matches(*E, Finder, Builder);
   return false;
 }
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
index 55a7e4b8f2954..c23c355dac1b2 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \
 // RUN:   -config="{CheckOptions: {\
 // RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; 
::my::other::Mutex', \
-// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::my::other::awaitable' \
+// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::transformable::awaitable' \
 // RUN: }}"
 
 namespace std {
@@ -136,6 +136,9 @@ ReturnObject scopedLockableTest() {
 absl::Mutex no_warning_5;
 }
 
+// 

+// Safe awaitable
+// 

 namespace safe {
   struct awaitable {
   bool await_ready() noexcept { return false; }
@@ -150,6 +153,32 @@ ReturnObject RAIISafeSuspendTest() {
   co_await other{};
 } 
 
+// 

+// Safe transformable awaitable
+// 

+struct transformable { struct awaitable{}; };
+using alias_transformable_awaitable = transformable::awaitable;
+struct UseTransformAwaitable {
+  struct promise_type {
+UseTransformAwaitable get_return_object() { return {}; }
+std::suspend_always initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception() {}
+std::suspend_always await_transform(transformable::awaitable) { return {}; 
}
+  };
+};
+
+auto retAwaitable() { return transformable::awaitable{}; }
+UseTransformAwaitable RAIISafeSuspendTest2() {
+  absl::Mutex a;
+  co_await retAwaitable();
+  co_await transformable::awaitable{};
+  co_await alias_transformable_awaitable{};
+}
+
+// 

+// Lambdas
+// 

 void lambda() {
   absl::Mutex no_warning;
   auto lambda = []() -> ReturnObject {
@@ -164,6 +193,9 @@ void lambda() {
   absl::Mutex no_warning_2;
 }
 
+// 

+// Denylisted RAII
+// 

 template
 ReturnObject raii_in_template(){
   T a;

>From 442809ce6047f8f83c9f3f54b17182c18535bb03 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Mon, 5 Feb 2024 15:52:56 +
Subject: [PATCH 2/4] [codegen] Emit cleanups for lifetime-extended temporaries
 when statment-expression has control-flow

---
 clang/lib/CodeGen/CGCleanup.cpp   | 31 +--
 clang/lib/CodeGen/CodeGenFunction.h   |  4 +
 .../return-in-stmt-expr-cleanup.cpp   | 37 +
 .../coro-suspend-in-agg-init.cpp  | 82 +++
 4 files changed, 145 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/return-in-stmt-expr-cleanup.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-in-agg-init.cpp

diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index f87caf050eeaa..da0528b271aa3 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -488,16 +488,11 @@ vo

[clang] [clang][Interp] Bail out on missing ComparisonCategoryInfo (PR #80131)

2024-02-06 Thread Aaron Ballman via cfe-commits


@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fexperimental-new-constant-interpreter 
-verify

AaronBallman wrote:

Why should this assignment not work? (The code looks valid to me). Oh, wait, 
you mean this assignment shouldn't be a constant expression? (If so, I agree.)

That said, I see now why we're hitting the assertion on an assignment operator 
in C; the call to `lookupInfoForType()` will return `nullptr` in that case and 
we need to handle that.

I don't think we want to look for the spaceship operator stuff outside of C++ 
mode, but that can be done in a follow-up as this is fixing a failing assertion.

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


[clang-tools-extra] [llvm] [clang] 64803 (PR #80838)

2024-02-06 Thread Shourya Goel via cfe-commits

https://github.com/Sh0g0-1758 created 
https://github.com/llvm/llvm-project/pull/80838

Fixes: #64803

**PR SUMMARY**: Updated Regex to now accept colon endings in GitHub automation. 

>From b98f02d4c155b5be9bd4f5b2e4bf73720a81f39a Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 
Date: Wed, 17 Jan 2024 01:24:17 +0530
Subject: [PATCH 01/20] Fix : more detailed no expected directive message

---
 clang-tools-extra/clangd/test/indexer.test   | 2 +-
 clang/include/clang/Basic/Diagnostic.h   | 4 +++-
 clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 +-
 clang/lib/AST/ASTContext.cpp | 2 +-
 clang/lib/Frontend/VerifyDiagnosticConsumer.cpp  | 4 +++-
 clang/test/ARCMT/verify.m| 2 +-
 clang/test/Frontend/verify.c | 2 +-
 clang/test/Frontend/verify2.c| 2 +-
 clang/test/Frontend/verify3.c| 4 ++--
 9 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/clang-tools-extra/clangd/test/indexer.test 
b/clang-tools-extra/clangd/test/indexer.test
index 2f01f6c557a7d..213d33f8e2d6a 100644
--- a/clang-tools-extra/clangd/test/indexer.test
+++ b/clang-tools-extra/clangd/test/indexer.test
@@ -5,5 +5,5 @@
 # `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should
 # strip those.
 # RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | 
FileCheck %s
-# CHECK-NOT: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+# CHECK-NOT: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 # RUN: not ls %t.ii
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 0c7836c2ea569..a185c75e418b5 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -9,7 +9,9 @@
 /// \file
 /// Defines the Diagnostic-related interfaces.
 //
-//===--===//
+//===--===//]
+
+// look into this file as well
 
 #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
 #define LLVM_CLANG_BASIC_DIAGNOSTIC_H
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 568000106a84d..42d2767af6b70 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error<
 "%select{expected|'expected-no-diagnostics'}0 directive cannot follow "
 "%select{'expected-no-diagnostics' directive|other expected directives}0">;
 def err_verify_no_directives : Error<
-"no expected directives found: consider use of 'expected-no-diagnostics'">;
+"no expected directives found: consider use of '%0'-no-diagnostics">;
 def err_verify_nonconst_addrspace : Error<
   "qualifier 'const' is needed for variables in address space '%0'">;
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b60dcfaabfd1a..0997ac9fa7df0 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
&Target,
 getTranslationUnitDecl()->addDecl(MSGuidTagDecl);
   }
 }
-
+// maybe change here also. 
 DiagnosticsEngine &ASTContext::getDiagnostics() const {
   return SourceMgr.getDiagnostics();
 }
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 8a3d2286cd168..9a26905a76d46 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -1098,7 +1098,9 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  // change here
+  std::string directives = 
*Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+  Diags.Report(diag::err_verify_no_directives).setForceEmit() << 
directives;
   ++NumErrors;
   Status = HasNoDirectivesReported;
 }
diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m
index 7d245fe80575e..13fd599f530fb 100644
--- a/clang/test/ARCMT/verify.m
+++ b/clang/test/ARCMT/verify.m
@@ -11,7 +11,7 @@
 #error
 // expected-error@-1 {{}}
 
-//  CHECK: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+//  CHECK: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
 // CHECK-NEXT:   (frontend): error reading '{{.*}}verify.m.tmp.invalid'
 // CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c
index 221b71

[clang-tools-extra] [llvm] [clang] 64803 (PR #80838)

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


[clang-tools-extra] [llvm] [clang] Accept /branch: and /cherry-pick: commands (PR #80838)

2024-02-06 Thread Shourya Goel via cfe-commits

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


[clang-tools-extra] [llvm] [clang] [codegen] Emit cleanups for lifetime-extended temporaries when an expr contains control-flow (PR #80698)

2024-02-06 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/80698

>From 28d90711ff8e4924135d4bd4e5f252d96ac41b93 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 23 Jan 2024 20:18:25 +
Subject: [PATCH 1/5] [misc-coroutine-hostile-raii] Use getOperand instead of
 getCommonExpr

---
 .../misc/CoroutineHostileRAIICheck.cpp|  2 +-
 .../checkers/misc/coroutine-hostile-raii.cpp  | 34 ++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp 
b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
index a0e8700b0522b..360335b86c641 100644
--- a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
@@ -56,7 +56,7 @@ AST_MATCHER_P(Stmt, forEachPrevStmt, 
ast_matchers::internal::Matcher,
 // Matches the expression awaited by the `co_await`.
 AST_MATCHER_P(CoawaitExpr, awaitable, ast_matchers::internal::Matcher,
   InnerMatcher) {
-  if (Expr *E = Node.getCommonExpr())
+  if (Expr *E = Node.getOperand())
 return InnerMatcher.matches(*E, Finder, Builder);
   return false;
 }
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
index 55a7e4b8f2954..c23c355dac1b2 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \
 // RUN:   -config="{CheckOptions: {\
 // RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; 
::my::other::Mutex', \
-// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::my::other::awaitable' \
+// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::transformable::awaitable' \
 // RUN: }}"
 
 namespace std {
@@ -136,6 +136,9 @@ ReturnObject scopedLockableTest() {
 absl::Mutex no_warning_5;
 }
 
+// 

+// Safe awaitable
+// 

 namespace safe {
   struct awaitable {
   bool await_ready() noexcept { return false; }
@@ -150,6 +153,32 @@ ReturnObject RAIISafeSuspendTest() {
   co_await other{};
 } 
 
+// 

+// Safe transformable awaitable
+// 

+struct transformable { struct awaitable{}; };
+using alias_transformable_awaitable = transformable::awaitable;
+struct UseTransformAwaitable {
+  struct promise_type {
+UseTransformAwaitable get_return_object() { return {}; }
+std::suspend_always initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception() {}
+std::suspend_always await_transform(transformable::awaitable) { return {}; 
}
+  };
+};
+
+auto retAwaitable() { return transformable::awaitable{}; }
+UseTransformAwaitable RAIISafeSuspendTest2() {
+  absl::Mutex a;
+  co_await retAwaitable();
+  co_await transformable::awaitable{};
+  co_await alias_transformable_awaitable{};
+}
+
+// 

+// Lambdas
+// 

 void lambda() {
   absl::Mutex no_warning;
   auto lambda = []() -> ReturnObject {
@@ -164,6 +193,9 @@ void lambda() {
   absl::Mutex no_warning_2;
 }
 
+// 

+// Denylisted RAII
+// 

 template
 ReturnObject raii_in_template(){
   T a;

>From 442809ce6047f8f83c9f3f54b17182c18535bb03 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Mon, 5 Feb 2024 15:52:56 +
Subject: [PATCH 2/5] [codegen] Emit cleanups for lifetime-extended temporaries
 when statment-expression has control-flow

---
 clang/lib/CodeGen/CGCleanup.cpp   | 31 +--
 clang/lib/CodeGen/CodeGenFunction.h   |  4 +
 .../return-in-stmt-expr-cleanup.cpp   | 37 +
 .../coro-suspend-in-agg-init.cpp  | 82 +++
 4 files changed, 145 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/return-in-stmt-expr-cleanup.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-in-agg-init.cpp

diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index f87caf050eeaa..da0528b271aa3 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -488,16 +488,11 @@ vo

[clang-tools-extra] [llvm] [clang] [codegen] Emit cleanups for lifetime-extended temporaries when an expr contains control-flow (PR #80698)

2024-02-06 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/80698

>From 28d90711ff8e4924135d4bd4e5f252d96ac41b93 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 23 Jan 2024 20:18:25 +
Subject: [PATCH 1/6] [misc-coroutine-hostile-raii] Use getOperand instead of
 getCommonExpr

---
 .../misc/CoroutineHostileRAIICheck.cpp|  2 +-
 .../checkers/misc/coroutine-hostile-raii.cpp  | 34 ++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp 
b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
index a0e8700b0522b..360335b86c641 100644
--- a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
@@ -56,7 +56,7 @@ AST_MATCHER_P(Stmt, forEachPrevStmt, 
ast_matchers::internal::Matcher,
 // Matches the expression awaited by the `co_await`.
 AST_MATCHER_P(CoawaitExpr, awaitable, ast_matchers::internal::Matcher,
   InnerMatcher) {
-  if (Expr *E = Node.getCommonExpr())
+  if (Expr *E = Node.getOperand())
 return InnerMatcher.matches(*E, Finder, Builder);
   return false;
 }
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
index 55a7e4b8f2954..c23c355dac1b2 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \
 // RUN:   -config="{CheckOptions: {\
 // RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; 
::my::other::Mutex', \
-// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::my::other::awaitable' \
+// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::transformable::awaitable' \
 // RUN: }}"
 
 namespace std {
@@ -136,6 +136,9 @@ ReturnObject scopedLockableTest() {
 absl::Mutex no_warning_5;
 }
 
+// 

+// Safe awaitable
+// 

 namespace safe {
   struct awaitable {
   bool await_ready() noexcept { return false; }
@@ -150,6 +153,32 @@ ReturnObject RAIISafeSuspendTest() {
   co_await other{};
 } 
 
+// 

+// Safe transformable awaitable
+// 

+struct transformable { struct awaitable{}; };
+using alias_transformable_awaitable = transformable::awaitable;
+struct UseTransformAwaitable {
+  struct promise_type {
+UseTransformAwaitable get_return_object() { return {}; }
+std::suspend_always initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception() {}
+std::suspend_always await_transform(transformable::awaitable) { return {}; 
}
+  };
+};
+
+auto retAwaitable() { return transformable::awaitable{}; }
+UseTransformAwaitable RAIISafeSuspendTest2() {
+  absl::Mutex a;
+  co_await retAwaitable();
+  co_await transformable::awaitable{};
+  co_await alias_transformable_awaitable{};
+}
+
+// 

+// Lambdas
+// 

 void lambda() {
   absl::Mutex no_warning;
   auto lambda = []() -> ReturnObject {
@@ -164,6 +193,9 @@ void lambda() {
   absl::Mutex no_warning_2;
 }
 
+// 

+// Denylisted RAII
+// 

 template
 ReturnObject raii_in_template(){
   T a;

>From 442809ce6047f8f83c9f3f54b17182c18535bb03 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Mon, 5 Feb 2024 15:52:56 +
Subject: [PATCH 2/6] [codegen] Emit cleanups for lifetime-extended temporaries
 when statment-expression has control-flow

---
 clang/lib/CodeGen/CGCleanup.cpp   | 31 +--
 clang/lib/CodeGen/CodeGenFunction.h   |  4 +
 .../return-in-stmt-expr-cleanup.cpp   | 37 +
 .../coro-suspend-in-agg-init.cpp  | 82 +++
 4 files changed, 145 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/return-in-stmt-expr-cleanup.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-in-agg-init.cpp

diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index f87caf050eeaa..da0528b271aa3 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -488,16 +488,11 @@ vo

[clang-tools-extra] [clang] [llvm] Accept /branch: and /cherry-pick: commands (PR #80838)

2024-02-06 Thread Shourya Goel via cfe-commits

https://github.com/Sh0g0-1758 updated 
https://github.com/llvm/llvm-project/pull/80838

>From b98f02d4c155b5be9bd4f5b2e4bf73720a81f39a Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 
Date: Wed, 17 Jan 2024 01:24:17 +0530
Subject: [PATCH 01/21] Fix : more detailed no expected directive message

---
 clang-tools-extra/clangd/test/indexer.test   | 2 +-
 clang/include/clang/Basic/Diagnostic.h   | 4 +++-
 clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 +-
 clang/lib/AST/ASTContext.cpp | 2 +-
 clang/lib/Frontend/VerifyDiagnosticConsumer.cpp  | 4 +++-
 clang/test/ARCMT/verify.m| 2 +-
 clang/test/Frontend/verify.c | 2 +-
 clang/test/Frontend/verify2.c| 2 +-
 clang/test/Frontend/verify3.c| 4 ++--
 9 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/clang-tools-extra/clangd/test/indexer.test 
b/clang-tools-extra/clangd/test/indexer.test
index 2f01f6c557a7d..213d33f8e2d6a 100644
--- a/clang-tools-extra/clangd/test/indexer.test
+++ b/clang-tools-extra/clangd/test/indexer.test
@@ -5,5 +5,5 @@
 # `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should
 # strip those.
 # RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | 
FileCheck %s
-# CHECK-NOT: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+# CHECK-NOT: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 # RUN: not ls %t.ii
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 0c7836c2ea569..a185c75e418b5 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -9,7 +9,9 @@
 /// \file
 /// Defines the Diagnostic-related interfaces.
 //
-//===--===//
+//===--===//]
+
+// look into this file as well
 
 #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
 #define LLVM_CLANG_BASIC_DIAGNOSTIC_H
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 568000106a84d..42d2767af6b70 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error<
 "%select{expected|'expected-no-diagnostics'}0 directive cannot follow "
 "%select{'expected-no-diagnostics' directive|other expected directives}0">;
 def err_verify_no_directives : Error<
-"no expected directives found: consider use of 'expected-no-diagnostics'">;
+"no expected directives found: consider use of '%0'-no-diagnostics">;
 def err_verify_nonconst_addrspace : Error<
   "qualifier 'const' is needed for variables in address space '%0'">;
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b60dcfaabfd1a..0997ac9fa7df0 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
&Target,
 getTranslationUnitDecl()->addDecl(MSGuidTagDecl);
   }
 }
-
+// maybe change here also. 
 DiagnosticsEngine &ASTContext::getDiagnostics() const {
   return SourceMgr.getDiagnostics();
 }
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 8a3d2286cd168..9a26905a76d46 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -1098,7 +1098,9 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  // change here
+  std::string directives = 
*Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+  Diags.Report(diag::err_verify_no_directives).setForceEmit() << 
directives;
   ++NumErrors;
   Status = HasNoDirectivesReported;
 }
diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m
index 7d245fe80575e..13fd599f530fb 100644
--- a/clang/test/ARCMT/verify.m
+++ b/clang/test/ARCMT/verify.m
@@ -11,7 +11,7 @@
 #error
 // expected-error@-1 {{}}
 
-//  CHECK: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+//  CHECK: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
 // CHECK-NEXT:   (frontend): error reading '{{.*}}verify.m.tmp.invalid'
 // CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c
index 221b715c19e41..657a9d3f2bf6b 100644
--- a/clang/test/Frontend/verify.c
+++ b/clang/test/Frontend/verify

[clang] [lld] [libcxx] [clang-tools-extra] [lldb] [mlir] [openmp] [libc] [llvm] [flang] [SLP]Add support for strided loads. (PR #80310)

2024-02-06 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev updated 
https://github.com/llvm/llvm-project/pull/80310

>From 92950afd39034c0184a3c807f8062e0053eead5c Mon Sep 17 00:00:00 2001
From: Alexey Bataev 
Date: Thu, 1 Feb 2024 17:22:34 +
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 .../llvm/Analysis/TargetTransformInfo.h   |  34 ++
 .../llvm/Analysis/TargetTransformInfoImpl.h   |  13 +
 llvm/lib/Analysis/TargetTransformInfo.cpp |  14 +
 .../Target/RISCV/RISCVTargetTransformInfo.cpp |  23 +
 .../Target/RISCV/RISCVTargetTransformInfo.h   |  23 +
 .../Transforms/Vectorize/SLPVectorizer.cpp| 397 --
 .../SLPVectorizer/RISCV/complex-loads.ll  | 132 +++---
 .../RISCV/strided-loads-vectorized.ll | 209 +
 .../strided-loads-with-external-use-ptr.ll|   4 +-
 .../SLPVectorizer/RISCV/strided-loads.ll  |  13 +-
 .../X86/gep-nodes-with-non-gep-inst.ll|   2 +-
 .../X86/remark_gather-load-redux-cost.ll  |   2 +-
 12 files changed, 478 insertions(+), 388 deletions(-)

diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h 
b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 3b615bc700bbb..b0b6dab03fa38 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -781,6 +781,9 @@ class TargetTransformInfo {
   /// Return true if the target supports masked expand load.
   bool isLegalMaskedExpandLoad(Type *DataType) const;
 
+  /// Return true if the target supports strided load.
+  bool isLegalStridedLoad(Type *DataType, Align Alignment) const;
+
   /// Return true if this is an alternating opcode pattern that can be lowered
   /// to a single instruction on the target. In X86 this is for the addsub
   /// instruction which corrsponds to a Shuffle + Fadd + FSub pattern in IR.
@@ -1412,6 +1415,20 @@ class TargetTransformInfo {
   Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
   const Instruction *I = nullptr) const;
 
+  /// \return The cost of strided memory operations.
+  /// \p Opcode - is a type of memory access Load or Store
+  /// \p DataTy - a vector type of the data to be loaded or stored
+  /// \p Ptr - pointer [or vector of pointers] - address[es] in memory
+  /// \p VariableMask - true when the memory access is predicated with a mask
+  ///   that is not a compile-time constant
+  /// \p Alignment - alignment of single element
+  /// \p I - the optional original context instruction, if one exists, e.g. the
+  ///load/store to transform or the call to the gather/scatter 
intrinsic
+  InstructionCost getStridedMemoryOpCost(
+  unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask,
+  Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
+  const Instruction *I = nullptr) const;
+
   /// \return The cost of the interleaved memory operation.
   /// \p Opcode is the memory operation code
   /// \p VecTy is the vector type of the interleaved access.
@@ -1848,6 +1865,7 @@ class TargetTransformInfo::Concept {
Align Alignment) = 0;
   virtual bool isLegalMaskedCompressStore(Type *DataType) = 0;
   virtual bool isLegalMaskedExpandLoad(Type *DataType) = 0;
+  virtual bool isLegalStridedLoad(Type *DataType, Align Alignment) = 0;
   virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0,
unsigned Opcode1,
const SmallBitVector &OpcodeMask) const = 0;
@@ -2023,6 +2041,11 @@ class TargetTransformInfo::Concept {
  bool VariableMask, Align Alignment,
  TTI::TargetCostKind CostKind,
  const Instruction *I = nullptr) = 0;
+  virtual InstructionCost
+  getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
+ bool VariableMask, Align Alignment,
+ TTI::TargetCostKind CostKind,
+ const Instruction *I = nullptr) = 0;
 
   virtual InstructionCost getInterleavedMemoryOpCost(
   unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef 
Indices,
@@ -2341,6 +2364,9 @@ class TargetTransformInfo::Model final : public 
TargetTransformInfo::Concept {
   bool isLegalMaskedExpandLoad(Type *DataType) override {
 return Impl.isLegalMaskedExpandLoad(DataType);
   }
+  bool isLegalStridedLoad(Type *DataType, Align Alignment) override {
+return Impl.isLegalStridedLoad(DataType, Alignment);
+  }
   bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1,
const SmallBitVector &OpcodeMask) const override {
 return Impl.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask);
@@ -2671,6 +2697,14 @@ class TargetTransformInfo::Model

[clang-tools-extra] [clang] [llvm] Accept /branch: and /cherry-pick: commands (PR #80838)

2024-02-06 Thread Shourya Goel via cfe-commits

Sh0g0-1758 wrote:

I hope the number of commits can be overlooked. Ran into some rebasing issues. 
Added a PR summary for the merge commit. 

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


[clang-tools-extra] [llvm] [clang] Accept /branch: and /cherry-pick: commands (PR #80838)

2024-02-06 Thread Shourya Goel via cfe-commits

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


[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-06 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

I think the only thing left is to add test coverage somewhere in 
`clang/test/Sema/`, probably in 
https://github.com/llvm/llvm-project/blob/main/clang/test/Sema/attr-cleanup.c.

You can probably test with something like:
```
extern void free(void *);
extern void *malloc(__typeof__(sizeof(0)));

void foo(void) {
  __attribute__((cleanup(free))) void *p = malloc(10);
}
```
but additional test coverage would make sense such as what I pointed out here: 
https://github.com/llvm/llvm-project/pull/80040#pullrequestreview-1856764787

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


[clang] [Clang][Sema] fix crash in codegen stage when an lambda expression declared in an unevaluated context (PR #80802)

2024-02-06 Thread Erich Keane via cfe-commits


@@ -1613,8 +1613,8 @@ namespace {
 bool TemplateInstantiator::AlreadyTransformed(QualType T) {
   if (T.isNull())
 return true;
-
-  if (T->isInstantiationDependentType() || T->isVariablyModifiedType())
+  if (T->isInstantiationDependentType() || T->isVariablyModifiedType() ||
+  (SemaRef.getLangOpts().CPlusPlus20 && T->isDecltypeType()))

erichkeane wrote:

Can you please add the relevant standards-quote here, particularly for the 
C++20 vs pre-C++20 change here?

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


[clang] [llvm] [clang-tools-extra] [codegen] Emit cleanups for lifetime-extended temporaries when an expr contains control-flow (PR #80698)

2024-02-06 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/80698

>From 28d90711ff8e4924135d4bd4e5f252d96ac41b93 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Tue, 23 Jan 2024 20:18:25 +
Subject: [PATCH 1/7] [misc-coroutine-hostile-raii] Use getOperand instead of
 getCommonExpr

---
 .../misc/CoroutineHostileRAIICheck.cpp|  2 +-
 .../checkers/misc/coroutine-hostile-raii.cpp  | 34 ++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp 
b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
index a0e8700b0522b..360335b86c641 100644
--- a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
@@ -56,7 +56,7 @@ AST_MATCHER_P(Stmt, forEachPrevStmt, 
ast_matchers::internal::Matcher,
 // Matches the expression awaited by the `co_await`.
 AST_MATCHER_P(CoawaitExpr, awaitable, ast_matchers::internal::Matcher,
   InnerMatcher) {
-  if (Expr *E = Node.getCommonExpr())
+  if (Expr *E = Node.getOperand())
 return InnerMatcher.matches(*E, Finder, Builder);
   return false;
 }
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
index 55a7e4b8f2954..c23c355dac1b2 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/coroutine-hostile-raii.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \
 // RUN:   -config="{CheckOptions: {\
 // RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; 
::my::other::Mutex', \
-// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::my::other::awaitable' \
+// RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 
'safe::awaitable; ::transformable::awaitable' \
 // RUN: }}"
 
 namespace std {
@@ -136,6 +136,9 @@ ReturnObject scopedLockableTest() {
 absl::Mutex no_warning_5;
 }
 
+// 

+// Safe awaitable
+// 

 namespace safe {
   struct awaitable {
   bool await_ready() noexcept { return false; }
@@ -150,6 +153,32 @@ ReturnObject RAIISafeSuspendTest() {
   co_await other{};
 } 
 
+// 

+// Safe transformable awaitable
+// 

+struct transformable { struct awaitable{}; };
+using alias_transformable_awaitable = transformable::awaitable;
+struct UseTransformAwaitable {
+  struct promise_type {
+UseTransformAwaitable get_return_object() { return {}; }
+std::suspend_always initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception() {}
+std::suspend_always await_transform(transformable::awaitable) { return {}; 
}
+  };
+};
+
+auto retAwaitable() { return transformable::awaitable{}; }
+UseTransformAwaitable RAIISafeSuspendTest2() {
+  absl::Mutex a;
+  co_await retAwaitable();
+  co_await transformable::awaitable{};
+  co_await alias_transformable_awaitable{};
+}
+
+// 

+// Lambdas
+// 

 void lambda() {
   absl::Mutex no_warning;
   auto lambda = []() -> ReturnObject {
@@ -164,6 +193,9 @@ void lambda() {
   absl::Mutex no_warning_2;
 }
 
+// 

+// Denylisted RAII
+// 

 template
 ReturnObject raii_in_template(){
   T a;

>From 442809ce6047f8f83c9f3f54b17182c18535bb03 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Mon, 5 Feb 2024 15:52:56 +
Subject: [PATCH 2/7] [codegen] Emit cleanups for lifetime-extended temporaries
 when statment-expression has control-flow

---
 clang/lib/CodeGen/CGCleanup.cpp   | 31 +--
 clang/lib/CodeGen/CodeGenFunction.h   |  4 +
 .../return-in-stmt-expr-cleanup.cpp   | 37 +
 .../coro-suspend-in-agg-init.cpp  | 82 +++
 4 files changed, 145 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/return-in-stmt-expr-cleanup.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-suspend-in-agg-init.cpp

diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index f87caf050eeaa..da0528b271aa3 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -488,16 +488,11 @@ vo

[clang] [clang][TSA] Make RequiresCapability a DeclOrType attribute (PR #67095)

2024-02-06 Thread Erich Keane via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -8938,6 +8957,11 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
   attr.setUsedAsTypeAttr();
   break;
 }
+case ParsedAttr::AT_RequiresCapability: {
+  HandleRequiresCapabilityAttr(state, type, attr);
+  attr.setUsedAsTypeAttr();
+  break;
+}

erichkeane wrote:

It would kind of stink to have to do it in 2 places, but it could go in 
trailing-storage/etc on `FunctionProtoType` and `FunctionNoProtoType`, then 
just disambiguate it with a function.  So it doesn't need to end up in 
`FunctionType::ExtInfo` or `FunctionType` itself.

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits

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

According to [[expr.prim.id.qual] 
p3](http://eel.is/c++draft/expr.prim.id.qual#3):
> The _nested-name-specifier_ `​:`:​ nominates the global namespace. A 
> _nested-name-specifier_ with a _computed-type-specifier_ nominates the type 
> denoted by the _computed-type-specifier_, which shall be a class or 
> enumeration type. **If a _nested-name-specifier_ `N` is declarative and has a 
> _simple-template-id_ with a template argument list `A` that involves a 
> template parameter, let `T` be the template nominated by `N` without `A`. `T` 
> shall be a class template.**

Meaning, the out-of-line definition of `A::f` in the following example is 
ill-formed:
```cpp
template
struct A 
{ 
void f(); 
};

template
using B = A;

template
void B::f() { } // error: a declarative nested name specifier cannot name a 
type alias template
```

This patch diagnoses such cases as an extension (in group 
`alias-template-in-declaration-name`).


>From 6f701b092a99d49a56d661255e76fa1b1d3a4601 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 6 Feb 2024 09:14:42 -0500
Subject: [PATCH] [Clang][Sema] Diagnose declarative nested-name-specifiers
 naming alias templates

---
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/lib/Sema/SemaDecl.cpp   | 36 +--
 .../expr.prim.id/expr.prim.id.qual/p3.cpp | 29 +++
 .../temp.res/temp.dep/temp.dep.type/p1.cpp|  2 +-
 4 files changed, 59 insertions(+), 11 deletions(-)
 create mode 100644 
clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f76e7a3392183e..d02fddd0693413 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8250,6 +8250,9 @@ def err_not_tag_in_scope : Error<
 def ext_template_after_declarative_nns : ExtWarn<
 "'template' cannot be used after a declarative nested name specifier">,
 InGroup>;
+def ext_alias_template_in_declarative_nns : ExtWarn<
+  "a declarative nested name specifier cannot name an alias template">,
+  InGroup>;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389bb..464f3738b0ba56 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6207,6 +6207,8 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, 
DeclContext *DC,
 SourceLocation Loc,
 TemplateIdAnnotation *TemplateId,
 bool IsMemberSpecialization) {
+  assert(SS.isValid() && "diagnoseQualifiedDeclaration called for declaration "
+ "without nested-name-specifier");
   DeclContext *Cur = CurContext;
   while (isa(Cur) || isa(Cur))
 Cur = Cur->getParent();
@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective, as it does not
+// forbid declarative nested-name-specifiers that begin with a
+// pack-index-speci

[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

According to [[expr.prim.id.qual] 
p3](http://eel.is/c++draft/expr.prim.id.qual#3):
> The _nested-name-specifier_ `​:`:​ nominates the global namespace. A 
_nested-name-specifier_ with a _computed-type-specifier_ nominates the type 
denoted by the _computed-type-specifier_, which shall be a class or enumeration 
type. **If a _nested-name-specifier_ `N` is declarative and has a 
_simple-template-id_ with a template argument list `A` that involves a template 
parameter, let `T` be the template nominated by `N` without `A`. `T` shall be a 
class template.**

Meaning, the out-of-line definition of `A::f` in the following example is 
ill-formed:
```cpp
template
struct A 
{ 
void f(); 
};

template
using B = A;

template
void B::f() { } // error: a declarative nested name specifier cannot 
name a type alias template
```

This patch diagnoses such cases as an extension (in group 
`alias-template-in-declaration-name`).


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


4 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+26-10) 
- (added) clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 
(+29) 
- (modified) clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f76e7a3392183..d02fddd069341 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8250,6 +8250,9 @@ def err_not_tag_in_scope : Error<
 def ext_template_after_declarative_nns : ExtWarn<
 "'template' cannot be used after a declarative nested name specifier">,
 InGroup>;
+def ext_alias_template_in_declarative_nns : ExtWarn<
+  "a declarative nested name specifier cannot name an alias template">,
+  InGroup>;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389b..464f3738b0ba5 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6207,6 +6207,8 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, 
DeclContext *DC,
 SourceLocation Loc,
 TemplateIdAnnotation *TemplateId,
 bool IsMemberSpecialization) {
+  assert(SS.isValid() && "diagnoseQualifiedDeclaration called for declaration "
+ "without nested-name-specifier");
   DeclContext *Cur = CurContext;
   while (isa(Cur) || isa(Cur))
 Cur = Cur->getParent();
@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective, as it does not
+// forbid declarative nested-name-specifiers that begin with a
+// pack-index-specifier.
+Diag(Loc, diag::err_decltype_in_declarator)
+<< SpecLoc.getTypeLoc().getSourceRange();
+  }
+}
+  } while ((SpecLoc = SpecLoc.getPrefix()));
 
   return false;
 }
diff -

[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits

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


[clang-tools-extra] [clang] [llvm] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

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


@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -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 
-disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -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 
-disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

Endilll wrote:

> We should have some reason to believe it increases test coverage, and we 
> might want to consider splitting those tests out into their own file so we 
> don't run 100 DR tests in two optimization modes for every standard version 
> we're testing.

But... every codegen tests is in its own file already because of an entirely 
different concern. I don't see us being able to combine them into a single file 
for foreseeable future. So running 100 DRs with those additional flags is not 
on the table.

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Erich Keane via cfe-commits

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Added other reviewers, this part of naming is something that I need other eyes 
on.

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Erich Keane via cfe-commits


@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective, as it does not

erichkeane wrote:

Can you contact the CWG chair and get an issue for htis one please? 

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


[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-06 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

> extern void free(void *);

Sure I already wrote some tests and will commit after locally checking them  
but idk everytime I restart pc clang rebuilds itself and that is taking time, 
is it normal for clang to rebuild everytime I restart? (I think it has 
something to do with the dual boot setup linux/windows.)

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits


@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective, as it does not

sdkrystian wrote:

@erichkeane Yup, I am drafting wording for this as we speak (as well some other 
issues relating to declarative nested-name-specifiers)

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/80842

>From 75734c9cf5c9467130fdc08efa64eb624e659879 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 6 Feb 2024 09:14:42 -0500
Subject: [PATCH] [Clang][Sema] Diagnose declarative nested-name-specifiers
 naming alias templates

---
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/lib/Sema/SemaDecl.cpp   | 36 +--
 .../expr.prim.id/expr.prim.id.qual/p3.cpp | 29 +++
 .../temp.res/temp.dep/temp.dep.type/p1.cpp|  2 +-
 4 files changed, 59 insertions(+), 11 deletions(-)
 create mode 100644 
clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f76e7a3392183e..d02fddd0693413 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8250,6 +8250,9 @@ def err_not_tag_in_scope : Error<
 def ext_template_after_declarative_nns : ExtWarn<
 "'template' cannot be used after a declarative nested name specifier">,
 InGroup>;
+def ext_alias_template_in_declarative_nns : ExtWarn<
+  "a declarative nested name specifier cannot name an alias template">,
+  InGroup>;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389bb..f11fc814d73a85 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6207,6 +6207,8 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, 
DeclContext *DC,
 SourceLocation Loc,
 TemplateIdAnnotation *TemplateId,
 bool IsMemberSpecialization) {
+  assert(SS.isValid() && "diagnoseQualifiedDeclaration called for declaration "
+ "without nested-name-specifier");
   DeclContext *Cur = CurContext;
   while (isa(Cur) || isa(Cur))
 Cur = Cur->getParent();
@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective as it does not
+// forbid declarative nested-name-specifiers that begin with a
+// pack-index-specifier.
+Diag(Loc, diag::err_decltype_in_declarator)
+<< SpecLoc.getTypeLoc().getSourceRange();
+  }
+}
+  } while ((SpecLoc = SpecLoc.getPrefix()));
 
   return false;
 }
diff --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
new file mode 100644
index 00..c73ffa55a26a31
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s
+
+template
+struct A {
+  void f();
+};
+
+template
+using B = A;
+
+template
+void B::f() { } // expected-warning {{a declarative nested name specifier 
cannot name an alias template}}
+
+template<>
+void B::f() { } // ok, template argument list of simple-template-id 
doesn't involve template parameters
+
+namespace N {
+
+  template
+  struct D {
+void f();
+  };
+
+  template
+  using E =

[llvm] [clang] [clang-tools-extra] [XCOFF] Add compiler version to an auxiliary symbol table entry (PR #80162)

2024-02-06 Thread via cfe-commits

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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread via cfe-commits

https://github.com/hlivin01 updated 
https://github.com/llvm/llvm-project/pull/80819

>From 370a0d91df75d034860fb38c0042daf2fab48aea Mon Sep 17 00:00:00 2001
From: Gleb Vinnychenko 
Date: Tue, 6 Feb 2024 10:24:58 +
Subject: [PATCH] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic 
 vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h

* fixes https://github.com/llvm/llvm-project/issues/71751
* changed return types in the table gen file responsible for generation
  of the problematic intrinsics
* this is to ensure that the return type for the functions is the same
  as specified in the Arm Developer Documentation and avoid casting
bugs
(https://developer.arm.com/architectures/instruction-sets/intrinsics/vqrshrunh_n_s16)
* updated lit tests to reflect the change in return type, worth noting
  that LLVM does not seems to differentiate signed and unsigned ints in
the IR, hence the change in type cannot be checked in IR as far as I am
aware
---
 clang/include/clang/Basic/arm_neon.td|  4 ++--
 clang/test/CodeGen/aarch64-neon-intrinsics.c | 12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 9cb7e0981384b..f16de97f4e6bd 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1354,9 +1354,9 @@ let isScalarNarrowShift = 1 in {
   // Signed/Unsigned Saturating Rounded Shift Right Narrow (Immediate)
   def SCALAR_SQRSHRN_N: SInst<"vqrshrn_n", "(1<)1I", "SsSiSlSUsSUiSUl">;
   // Signed Saturating Shift Right Unsigned Narrow (Immediate)
-  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1<)1I", "SsSiSl">;
+  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1;
   // Signed Saturating Rounded Shift Right Unsigned Narrow (Immediate)
-  def SCALAR_SQRSHRUN_N: SInst<"vqrshrun_n", "(1<)1I", "SsSiSl">;
+  def SCALAR_SQRSHRUN_N: SInst<"vqrshrun_n", "(1;
 }
 
 

diff --git a/clang/test/CodeGen/aarch64-neon-intrinsics.c 
b/clang/test/CodeGen/aarch64-neon-intrinsics.c
index 7c53b9b0af6bb..eeb50d095a5c9 100644
--- a/clang/test/CodeGen/aarch64-neon-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-neon-intrinsics.c
@@ -14132,8 +14132,8 @@ int32_t test_vqshrund_n_s64(int64_t a) {
 // CHECK:   [[VQRSHRUNH_N_S16:%.*]] = call <8 x i8> 
@llvm.aarch64.neon.sqrshrun.v8i8(<8 x i16> [[TMP0]], i32 8)
 // CHECK:   [[TMP1:%.*]] = extractelement <8 x i8> [[VQRSHRUNH_N_S16]], i64 0
 // CHECK:   ret i8 [[TMP1]]
-int8_t test_vqrshrunh_n_s16(int16_t a) {
-  return (int8_t)vqrshrunh_n_s16(a, 8);
+uint8_t test_vqrshrunh_n_s16(int16_t a) {
+  return (uint8_t)vqrshrunh_n_s16(a, 8);
 }
 
 // CHECK-LABEL: @test_vqrshruns_n_s32(
@@ -14141,15 +14141,15 @@ int8_t test_vqrshrunh_n_s16(int16_t a) {
 // CHECK:   [[VQRSHRUNS_N_S32:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.sqrshrun.v4i16(<4 x i32> [[TMP0]], i32 16)
 // CHECK:   [[TMP1:%.*]] = extractelement <4 x i16> [[VQRSHRUNS_N_S32]], i64 0
 // CHECK:   ret i16 [[TMP1]]
-int16_t test_vqrshruns_n_s32(int32_t a) {
-  return (int16_t)vqrshruns_n_s32(a, 16);
+uint16_t test_vqrshruns_n_s32(int32_t a) {
+  return (uint16_t)vqrshruns_n_s32(a, 16);
 }
 
 // CHECK-LABEL: @test_vqrshrund_n_s64(
 // CHECK:   [[VQRSHRUND_N_S64:%.*]] = call i32 
@llvm.aarch64.neon.sqrshrun.i32(i64 %a, i32 32)
 // CHECK:   ret i32 [[VQRSHRUND_N_S64]]
-int32_t test_vqrshrund_n_s64(int64_t a) {
-  return (int32_t)vqrshrund_n_s64(a, 32);
+uint32_t test_vqrshrund_n_s64(int64_t a) {
+  return (uint32_t)vqrshrund_n_s64(a, 32);
 }
 
 // CHECK-LABEL: @test_vcvts_n_f32_s32(

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits


@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective, as it does not

sdkrystian wrote:

https://github.com/cplusplus/CWG/issues/499


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


[clang] [clang] require template arg list after template kw (PR #80801)

2024-02-06 Thread Davis Herring via cfe-commits


@@ -1414,7 +1414,7 @@ namespace dr96 { // dr96: no
 // FIXME: This is ill-formed, because 'f' is not a template-id and does not
 // name a class template.
 // FIXME: What about alias templates?

opensdh wrote:

The alias template case was aligned with the class-template case as part of 
[CWG1710](https://cplusplus.github.io/CWG/issues/1710.html).

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


[clang] [clang] require template arg list after template kw (PR #80801)

2024-02-06 Thread Davis Herring via cfe-commits


@@ -1414,7 +1414,7 @@ namespace dr96 { // dr96: no
 // FIXME: This is ill-formed, because 'f' is not a template-id and does not

opensdh wrote:

I'm not sure what direction of "superseded" you mean here, but (except for the 
separable alias-template bit) the comment is simply correct (since CWG96; 
before that any template would do).  All that P1787R6 did here was correct the 
strange use of "name" to refer to (among other things) a *template-id* and 
deprecate the `T::template NestedTypeTemplate` case.

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Erich Keane via cfe-commits


@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective, as it does not

erichkeane wrote:

Cool, please add that reference to the comment/FIXME.  Also, @Endilll might 
want to check it out too!

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/80842

>From 13abf4ca1003f4cc04926881ce74c5f4818a761c Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 6 Feb 2024 09:14:42 -0500
Subject: [PATCH] [Clang][Sema] Diagnose declarative nested-name-specifiers
 naming alias templates

---
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/lib/Sema/SemaDecl.cpp   | 36 +--
 .../expr.prim.id/expr.prim.id.qual/p3.cpp | 29 +++
 .../temp.res/temp.dep/temp.dep.type/p1.cpp|  2 +-
 4 files changed, 59 insertions(+), 11 deletions(-)
 create mode 100644 
clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f76e7a3392183e..d02fddd0693413 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8250,6 +8250,9 @@ def err_not_tag_in_scope : Error<
 def ext_template_after_declarative_nns : ExtWarn<
 "'template' cannot be used after a declarative nested name specifier">,
 InGroup>;
+def ext_alias_template_in_declarative_nns : ExtWarn<
+  "a declarative nested name specifier cannot name an alias template">,
+  InGroup>;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389bb..9d4f757caf9ca3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6207,6 +6207,8 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, 
DeclContext *DC,
 SourceLocation Loc,
 TemplateIdAnnotation *TemplateId,
 bool IsMemberSpecialization) {
+  assert(SS.isValid() && "diagnoseQualifiedDeclaration called for declaration "
+ "without nested-name-specifier");
   DeclContext *Cur = CurContext;
   while (isa(Cur) || isa(Cur))
 Cur = Cur->getParent();
@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective as it does not forbid
+// declarative nested-name-specifiers with pack-index-specifiers.
+// See https://github.com/cplusplus/CWG/issues/499.
+Diag(Loc, diag::err_decltype_in_declarator)
+<< SpecLoc.getTypeLoc().getSourceRange();
+  }
+}
+  } while ((SpecLoc = SpecLoc.getPrefix()));
 
   return false;
 }
diff --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
new file mode 100644
index 00..c73ffa55a26a31
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s
+
+template
+struct A {
+  void f();
+};
+
+template
+using B = A;
+
+template
+void B::f() { } // expected-warning {{a declarative nested name specifier 
cannot name an alias template}}
+
+template<>
+void B::f() { } // ok, template argument list of simple-template-id 
doesn't involve template parameters
+
+namespace N {
+
+  template
+  struct D {
+void 

[clang-tools-extra] [clang] [llvm] [XCOFF] Add compiler version to an auxiliary symbol table entry (PR #80162)

2024-02-06 Thread Jan Patrick Lehr via cfe-commits

jplehr wrote:

This introduced a spelling mistake that broke some builds.
https://lab.llvm.org/buildbot/#/builders/193/builds/46220

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


[llvm] [clang] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)

2024-02-06 Thread Sergei Barannikov via cfe-commits

https://github.com/s-barannikov approved this pull request.


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


[clang] [llvm] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)

2024-02-06 Thread Sergei Barannikov via cfe-commits

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


[llvm] [clang] [SPARC] Support reserving arbitrary general purpose registers (PR #74927)

2024-02-06 Thread Sergei Barannikov via cfe-commits


@@ -82,6 +88,13 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
 return is64Bit() ? 2047 : 0;
   }
 
+  bool isRegisterReserved(MCPhysReg PhysReg) const {
+if (PhysReg >= SP::G0 && PhysReg <= SP::O7)
+  return ReserveRegister[PhysReg - SP::G0];

s-barannikov wrote:

I wouldn't bother "compacting" a BitVector. This would also allow reserving 
other registers in the future and not depend on exact values of enum members.

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


[lldb] [llvm] [lld] [clang-tools-extra] [clang] [flang] [libcxx] [libc] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-06 Thread David Stuttard via cfe-commits

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


[llvm] [clang] [AMDGPU] Adding the amdgpu-num-work-groups function attribute (PR #79035)

2024-02-06 Thread Krzysztof Drewniak via cfe-commits

krzysz00 wrote:

@arsenm Are you suggesting that these should instead be a range of 
minimum/maximum number of workitems globally?

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


[clang] Disable FTZ/DAZ when compiling shared libraries by default. (PR #80475)

2024-02-06 Thread James Y Knight via cfe-commits

jyknight wrote:

> So, alternatively...we could just go with the simplest solution, and use 
> "ieee" as the default even under -ffast-math.

This is feeling like the best option to me, at this point. Easily 
implementable, and doesn't seem to make things significantly worse than they 
are today, since the denormal mode can't be controlled by compilation options 
-- so being wrong in both directions is going to happen, anyhow.

We'd simply delete 
[Linux::getDefaultDenormalModeForType](https://github.com/llvm/llvm-project/blob/d4c5acac99e83ffa12d2d720c9e502a181cbd7ea/clang/lib/Driver/ToolChains/Linux.cpp#L838),
 which thus causes `-ffast-math` to simply not change the compiler's 
understanding of denormals handling -- like is already the case on everything 
except x86/x86_64 Linux.

Other more-involved changes, such as exposing "-fdenormal-fp-math=dynamic" in 
Clang, and potentially making it the default, could be done later if desired. 
I'd suggest that this change doesn't need to block on any such discussions.

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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread Jonathan Thackray via cfe-commits

jthackray wrote:

The author (Gleb) doesn't yet have llvm commit access, so has asked me to merge 
it for him.

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


[clang] 40fd17a - [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (#80819)

2024-02-06 Thread via cfe-commits

Author: hlivin01
Date: 2024-02-06T15:46:57Z
New Revision: 40fd17a90d4dcfb4bada663d73111a43c4c6ccb1

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

LOG: [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic  
vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (#80819)

* fixes https://github.com/llvm/llvm-project/issues/71751
* changed return types in the table gen file responsible for generation
  of the problematic intrinsics
* this is to ensure that the return type for the functions is the same
  as specified in the Arm Developer Documentation and avoid casting
bugs

(https://developer.arm.com/architectures/instruction-sets/intrinsics/vqrshrunh_n_s16)
* updated lit tests to reflect the change in return type, worth noting
  that LLVM does not seems to differentiate signed and unsigned ints in
the IR, hence the change in type cannot be checked in IR as far as I am
aware

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/test/CodeGen/aarch64-neon-intrinsics.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index 9cb7e0981384b..f16de97f4e6bd 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1354,9 +1354,9 @@ let isScalarNarrowShift = 1 in {
   // Signed/Unsigned Saturating Rounded Shift Right Narrow (Immediate)
   def SCALAR_SQRSHRN_N: SInst<"vqrshrn_n", "(1<)1I", "SsSiSlSUsSUiSUl">;
   // Signed Saturating Shift Right Unsigned Narrow (Immediate)
-  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1<)1I", "SsSiSl">;
+  def SCALAR_SQSHRUN_N: SInst<"vqshrun_n", "(1;
   // Signed Saturating Rounded Shift Right Unsigned Narrow (Immediate)
-  def SCALAR_SQRSHRUN_N: SInst<"vqrshrun_n", "(1<)1I", "SsSiSl">;
+  def SCALAR_SQRSHRUN_N: SInst<"vqrshrun_n", "(1;
 }
 
 


diff  --git a/clang/test/CodeGen/aarch64-neon-intrinsics.c 
b/clang/test/CodeGen/aarch64-neon-intrinsics.c
index 7c53b9b0af6bb..eeb50d095a5c9 100644
--- a/clang/test/CodeGen/aarch64-neon-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-neon-intrinsics.c
@@ -14132,8 +14132,8 @@ int32_t test_vqshrund_n_s64(int64_t a) {
 // CHECK:   [[VQRSHRUNH_N_S16:%.*]] = call <8 x i8> 
@llvm.aarch64.neon.sqrshrun.v8i8(<8 x i16> [[TMP0]], i32 8)
 // CHECK:   [[TMP1:%.*]] = extractelement <8 x i8> [[VQRSHRUNH_N_S16]], i64 0
 // CHECK:   ret i8 [[TMP1]]
-int8_t test_vqrshrunh_n_s16(int16_t a) {
-  return (int8_t)vqrshrunh_n_s16(a, 8);
+uint8_t test_vqrshrunh_n_s16(int16_t a) {
+  return (uint8_t)vqrshrunh_n_s16(a, 8);
 }
 
 // CHECK-LABEL: @test_vqrshruns_n_s32(
@@ -14141,15 +14141,15 @@ int8_t test_vqrshrunh_n_s16(int16_t a) {
 // CHECK:   [[VQRSHRUNS_N_S32:%.*]] = call <4 x i16> 
@llvm.aarch64.neon.sqrshrun.v4i16(<4 x i32> [[TMP0]], i32 16)
 // CHECK:   [[TMP1:%.*]] = extractelement <4 x i16> [[VQRSHRUNS_N_S32]], i64 0
 // CHECK:   ret i16 [[TMP1]]
-int16_t test_vqrshruns_n_s32(int32_t a) {
-  return (int16_t)vqrshruns_n_s32(a, 16);
+uint16_t test_vqrshruns_n_s32(int32_t a) {
+  return (uint16_t)vqrshruns_n_s32(a, 16);
 }
 
 // CHECK-LABEL: @test_vqrshrund_n_s64(
 // CHECK:   [[VQRSHRUND_N_S64:%.*]] = call i32 
@llvm.aarch64.neon.sqrshrun.i32(i64 %a, i32 32)
 // CHECK:   ret i32 [[VQRSHRUND_N_S64]]
-int32_t test_vqrshrund_n_s64(int64_t a) {
-  return (int32_t)vqrshrund_n_s64(a, 32);
+uint32_t test_vqrshrund_n_s64(int64_t a) {
+  return (uint32_t)vqrshrund_n_s64(a, 32);
 }
 
 // CHECK-LABEL: @test_vcvts_n_f32_s32(



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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread Jonathan Thackray via cfe-commits

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


[clang] [ARM][AARCH64][NEON]: Wrong return type of NEON intrinsic vqrshrunh_n_s16, vqrshruns_n_s32, and vqrshrund_n_s64 in arm_neon.h (PR #80819)

2024-02-06 Thread via cfe-commits

github-actions[bot] wrote:



@hlivin01 Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may recieve a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[llvm] [clang] [AMDGPU] Adding the amdgpu-num-work-groups function attribute (PR #79035)

2024-02-06 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> @arsenm Are you suggesting that these should instead be a range of 
> minimum/maximum number of workitems globally?

That's how all of the other attributes we already have do this. 
amdgpu-waves-per-eu is a single min, max pair. Same with 
amdgpu-flat-work-group-size

Although this one is weird because it's dimensional. I'm also wondering what 
the use of the minimum dispatch size would be? I can see some minimal use for 
the maximum 

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


[clang] Disable FTZ/DAZ when compiling shared libraries by default. (PR #80475)

2024-02-06 Thread Matt Arsenault via cfe-commits

arsenm wrote:

> > So, alternatively...we could just go with the simplest solution, and use 
> > "ieee" as the default even under -ffast-math.
> 

+1. There hasn't been a performance reason to use FTZ/DAZ since ~2011. Maybe 
there's still a power benefit? But in that case you could still explicitly 
request the flush separate from -ffast-math

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


[llvm] [clang-tools-extra] [clang] Accept /branch: and /cherry-pick: commands (PR #80838)

2024-02-06 Thread Shourya Goel via cfe-commits

https://github.com/Sh0g0-1758 updated 
https://github.com/llvm/llvm-project/pull/80838

>From b98f02d4c155b5be9bd4f5b2e4bf73720a81f39a Mon Sep 17 00:00:00 2001
From: Sh0g0-1758 
Date: Wed, 17 Jan 2024 01:24:17 +0530
Subject: [PATCH 01/21] Fix : more detailed no expected directive message

---
 clang-tools-extra/clangd/test/indexer.test   | 2 +-
 clang/include/clang/Basic/Diagnostic.h   | 4 +++-
 clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 +-
 clang/lib/AST/ASTContext.cpp | 2 +-
 clang/lib/Frontend/VerifyDiagnosticConsumer.cpp  | 4 +++-
 clang/test/ARCMT/verify.m| 2 +-
 clang/test/Frontend/verify.c | 2 +-
 clang/test/Frontend/verify2.c| 2 +-
 clang/test/Frontend/verify3.c| 4 ++--
 9 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/clang-tools-extra/clangd/test/indexer.test 
b/clang-tools-extra/clangd/test/indexer.test
index 2f01f6c557a7de..213d33f8e2d6a5 100644
--- a/clang-tools-extra/clangd/test/indexer.test
+++ b/clang-tools-extra/clangd/test/indexer.test
@@ -5,5 +5,5 @@
 # `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should
 # strip those.
 # RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | 
FileCheck %s
-# CHECK-NOT: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+# CHECK-NOT: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 # RUN: not ls %t.ii
diff --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 0c7836c2ea569c..a185c75e418b58 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -9,7 +9,9 @@
 /// \file
 /// Defines the Diagnostic-related interfaces.
 //
-//===--===//
+//===--===//]
+
+// look into this file as well
 
 #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
 #define LLVM_CLANG_BASIC_DIAGNOSTIC_H
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 568000106a84dc..42d2767af6b708 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error<
 "%select{expected|'expected-no-diagnostics'}0 directive cannot follow "
 "%select{'expected-no-diagnostics' directive|other expected directives}0">;
 def err_verify_no_directives : Error<
-"no expected directives found: consider use of 'expected-no-diagnostics'">;
+"no expected directives found: consider use of '%0'-no-diagnostics">;
 def err_verify_nonconst_addrspace : Error<
   "qualifier 'const' is needed for variables in address space '%0'">;
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b60dcfaabfd1a4..0997ac9fa7df04 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
&Target,
 getTranslationUnitDecl()->addDecl(MSGuidTagDecl);
   }
 }
-
+// maybe change here also. 
 DiagnosticsEngine &ASTContext::getDiagnostics() const {
   return SourceMgr.getDiagnostics();
 }
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 8a3d2286cd168c..9a26905a76d46b 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -1098,7 +1098,9 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
 // Produce an error if no expected-* directives could be found in the
 // source file(s) processed.
 if (Status == HasNoDirectives) {
-  Diags.Report(diag::err_verify_no_directives).setForceEmit();
+  // change here
+  std::string directives = 
*Diags.getDiagnosticOptions().VerifyPrefixes.begin();
+  Diags.Report(diag::err_verify_no_directives).setForceEmit() << 
directives;
   ++NumErrors;
   Status = HasNoDirectivesReported;
 }
diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m
index 7d245fe80575e5..13fd599f530fbe 100644
--- a/clang/test/ARCMT/verify.m
+++ b/clang/test/ARCMT/verify.m
@@ -11,7 +11,7 @@
 #error
 // expected-error@-1 {{}}
 
-//  CHECK: error: no expected directives found: consider use of 
'expected-no-diagnostics'
+//  CHECK: error: no expected directives found: consider use of 
{{.*}}-no-diagnostics
 // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected:
 // CHECK-NEXT:   (frontend): error reading '{{.*}}verify.m.tmp.invalid'
 // CHECK-NEXT: 2 errors generated.
diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c
index 221b715c19e416..657a9d3f2bf6bb 100644
--- a/clang/test/Frontend/verify.c
+++ b/clang/test/F

[clang-tools-extra] `cppcoreguidelines-macro-usage`: Skip common macros which cannot be converted to `constexpr` (PR #80797)

2024-02-06 Thread via cfe-commits

EugeneZelenko wrote:

I think Release Notes should be updated.

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


[clang-tools-extra] Add support for renaming objc methods, even those with multiple selector pieces (PR #76466)

2024-02-06 Thread David Goldman via cfe-commits


@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl 
&RenameDecl,
 Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
 }
   }
-  if (Result)
+  if (Result) {
 InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Result);
+  }
+  return std::nullopt;
+}
+
+bool isMatchingSelectorName(const syntax::Token &Cur, const syntax::Token 
&Next,
+const SourceManager &SM,
+llvm::StringRef SelectorName) {
+  if (SelectorName.empty())
+return Cur.kind() == tok::colon;
+  return Cur.kind() == tok::identifier && Next.kind() == tok::colon &&
+ Cur.text(SM) == SelectorName &&
+ // We require the selector name and : to be contiguous to avoid
+ // potential conflicts with ternary expression.
+ //
+ // e.g. support `foo:` but not `foo :`.
+ Cur.endLocation() == Next.location();

DavidGoldman wrote:

Done

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


[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-06 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

```
extern void free(void *);
extern void *malloc(size_t size);
void t8(void) {
  void *p __attribute__((cleanup(free))) = malloc(10); // 
expected-warning{{attempt to call free on non-heap object 'p'}}
}
```
 I added  this, but 
I am getting this error: (Sorry if its a silly doubt)

```
error: 'expected-warning' diagnostics expected but not seen: 
  File /home/happy/LLVM/llvm-project/clang/test/Sema/attr-cleanup.c Line 55: 
attempt to call free on non-heap object 'p'
error: 'expected-warning' diagnostics seen but not expected: 
  (frontend): attempt to call free on non-heap object 'p'
2 errors generated.
```

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


[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-06 Thread Erich Keane via cfe-commits

erichkeane wrote:

> ```
> extern void free(void *);
> extern void *malloc(size_t size);
> void t8(void) {
>   void *p __attribute__((cleanup(free))) = malloc(10); // 
> expected-warning{{attempt to call free on non-heap object 'p'}}
> }
> ```
> 
> I added this, but I am getting this error: (Sorry if its a silly doubt)
> 
> ```
> error: 'expected-warning' diagnostics expected but not seen: 
>   File /home/happy/LLVM/llvm-project/clang/test/Sema/attr-cleanup.c Line 55: 
> attempt to call free on non-heap object 'p'
> error: 'expected-warning' diagnostics seen but not expected: 
>   (frontend): attempt to call free on non-heap object 'p'
> 2 errors generated.
> ```

That looks like you got the source-location wrong on your diagnostic.

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


[clang] [Clang][Sema] Abbreviated function templates do not append invented parameters to empty template parameter lists (PR #80864)

2024-02-06 Thread Krystian Stasiowski via cfe-commits

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

According to [[dcl.fct] p23](http://eel.is/c++draft/dcl.fct#23):
> An abbreviated function template can have a _template-head_. The invented 
> _template-parameters_ are appended to the _template-parameter-list_ after the 
> explicitly declared _template-parameters_.

`template<>` is not a _template-head_ -- a _template-head_ must have at least 
one _template-parameter_. This patch corrects our current behavior of appending 
the invented template parameters to the innermost template parameter list, 
regardless of whether it is empty. Example:
```cpp
template
struct A 
{ 
void f(auto); 
};

template<>
void A::f(auto); // ok

template<>
template<> // warning: extraneous template parameter list in template 
specialization
void A::f(auto);
```


>From 570e25f19b428fb7d2936091726727f9633eec35 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 6 Feb 2024 11:08:04 -0500
Subject: [PATCH] [Clang][Sema] Abbreviated function templates do not append
 invented parameters to empty template parameter lists

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp| 11 -
 .../CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp  | 24 +++
 4 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4d57ea4fd55b8..d0ba986601e92 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -204,6 +204,8 @@ Bug Fixes to C++ Support
   parameter where we did an incorrect specialization of the initialization of
   the default parameter.
   Fixes (`#68490 `_)
+- Fixed a bug where abbreviated function templates would append their invented 
template parameters to
+  an empty template parameter lists.
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389b..d9704e5bfd67c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9759,7 +9759,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   SmallVector TemplateParamLists;
   llvm::append_range(TemplateParamLists, TemplateParamListsRef);
   if (TemplateParameterList *Invented = D.getInventedTemplateParameterList()) {
-if (!TemplateParamLists.empty() &&
+if (!TemplateParamLists.empty() && TemplateParamLists.back()->size() &&
 Invented->getDepth() == TemplateParamLists.back()->getDepth())
   TemplateParamLists.back() = Invented;
 else
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ab8a967b06a45..f34893d88a3b3 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -19294,7 +19294,16 @@ void Sema::ActOnStartFunctionDeclarationDeclarator(
 ExplicitLists, /*IsFriend=*/false, IsMemberSpecialization, IsInvalid,
 /*SuppressDiagnostic=*/true);
   }
-  if (ExplicitParams) {
+  // C++23 [dcl.fct]p23:
+  //   An abbreviated function template can have a template-head. The invented
+  //   template-parameters are appended to the template-parameter-list after
+  //   the explicitly declared template-parameters.
+  //
+  // A template-head must have one or more template-parameters (read:
+  // 'template<>' is *not* a template-head). Only append the invented
+  // template parameters if we matched the nested-name-specifier to a non-empty
+  // TemplateParameterList.
+  if (ExplicitParams && ExplicitParams->size()) {
 Info.AutoTemplateParameterDepth = ExplicitParams->getDepth();
 llvm::append_range(Info.TemplateParams, *ExplicitParams);
 Info.NumExplicitTemplateParams = ExplicitParams->size();
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp 
b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp
new file mode 100644
index 0..469c4e091953c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify %s
+
+// FIXME: This should be an error with -pedantic-errors.
+template<> // expected-warning {{extraneous template parameter list in 
template specialization}}
+void f(auto);
+
+template
+void f(auto);
+
+template
+struct A {
+  void g(auto);
+};
+
+template
+void A::g(auto) { }
+
+template<>
+void A::g(auto) { }
+
+// FIXME: This should be an error with -pedantic-errors.
+template<>
+template<> // expected-warning {{extraneous template parameter list in 
template specialization}}
+void A::g(auto) { }

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


[clang] [Clang][Sema] Abbreviated function templates do not append invented parameters to empty template parameter lists (PR #80864)

2024-02-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

According to [[dcl.fct] p23](http://eel.is/c++draft/dcl.fct#23):
> An abbreviated function template can have a _template-head_. The invented 
_template-parameters_ are appended to the _template-parameter-list_ after the 
explicitly declared _template-parameters_.

`template<>` is not a _template-head_ -- a _template-head_ must have at 
least one _template-parameter_. This patch corrects our current behavior of 
appending the invented template parameters to the innermost template parameter 
list, regardless of whether it is empty. Example:
```cpp
template
struct A 
{ 
void f(auto); 
};

template<>
void A::f(auto); // ok

template<>
template<> // warning: extraneous template parameter list in template 
specialization
void A::f(auto);
```


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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+10-1) 
- (added) clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp (+24) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4d57ea4fd55b8..d0ba986601e92 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -204,6 +204,8 @@ Bug Fixes to C++ Support
   parameter where we did an incorrect specialization of the initialization of
   the default parameter.
   Fixes (`#68490 `_)
+- Fixed a bug where abbreviated function templates would append their invented 
template parameters to
+  an empty template parameter lists.
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389b..d9704e5bfd67c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9759,7 +9759,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   SmallVector TemplateParamLists;
   llvm::append_range(TemplateParamLists, TemplateParamListsRef);
   if (TemplateParameterList *Invented = D.getInventedTemplateParameterList()) {
-if (!TemplateParamLists.empty() &&
+if (!TemplateParamLists.empty() && TemplateParamLists.back()->size() &&
 Invented->getDepth() == TemplateParamLists.back()->getDepth())
   TemplateParamLists.back() = Invented;
 else
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ab8a967b06a45..f34893d88a3b3 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -19294,7 +19294,16 @@ void Sema::ActOnStartFunctionDeclarationDeclarator(
 ExplicitLists, /*IsFriend=*/false, IsMemberSpecialization, IsInvalid,
 /*SuppressDiagnostic=*/true);
   }
-  if (ExplicitParams) {
+  // C++23 [dcl.fct]p23:
+  //   An abbreviated function template can have a template-head. The invented
+  //   template-parameters are appended to the template-parameter-list after
+  //   the explicitly declared template-parameters.
+  //
+  // A template-head must have one or more template-parameters (read:
+  // 'template<>' is *not* a template-head). Only append the invented
+  // template parameters if we matched the nested-name-specifier to a non-empty
+  // TemplateParameterList.
+  if (ExplicitParams && ExplicitParams->size()) {
 Info.AutoTemplateParameterDepth = ExplicitParams->getDepth();
 llvm::append_range(Info.TemplateParams, *ExplicitParams);
 Info.NumExplicitTemplateParams = ExplicitParams->size();
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp 
b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp
new file mode 100644
index 0..469c4e091953c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p23.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify %s
+
+// FIXME: This should be an error with -pedantic-errors.
+template<> // expected-warning {{extraneous template parameter list in 
template specialization}}
+void f(auto);
+
+template
+void f(auto);
+
+template
+struct A {
+  void g(auto);
+};
+
+template
+void A::g(auto) { }
+
+template<>
+void A::g(auto) { }
+
+// FIXME: This should be an error with -pedantic-errors.
+template<>
+template<> // expected-warning {{extraneous template parameter list in 
template specialization}}
+void A::g(auto) { }

``




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


[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-06 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

Umm how could I resolve that? I tried various things but none working. 🥲

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


[clang] [clang-tools-extra] [mlir] [llvm] [mlir][linalg] Refactor `EraseIdentityGenericOp` to be reused by other `LinalgOp`s (PR #80466)

2024-02-06 Thread via cfe-commits


@@ -1907,6 +1907,20 @@ void BroadcastOp::getEffects(
 getDpsInits());
 }
 
+LogicalResult BroadcastOp::canonicalize(BroadcastOp op,

srcarroll wrote:

any thoughts? :)

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


[clang] [Clang][Sema] Diagnose declarative nested-name-specifiers naming alias templates (PR #80842)

2024-02-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/80842

>From c7457d759a93a04c3243c036e1c31296c8e81ec4 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 6 Feb 2024 09:14:42 -0500
Subject: [PATCH] [Clang][Sema] Diagnose declarative nested-name-specifiers
 naming alias templates

---
 clang/docs/ReleaseNotes.rst   |  1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/lib/Sema/SemaDecl.cpp   | 36 +--
 .../expr.prim.id/expr.prim.id.qual/p3.cpp | 29 +++
 .../temp.res/temp.dep/temp.dep.type/p1.cpp|  2 +-
 5 files changed, 60 insertions(+), 11 deletions(-)
 create mode 100644 
clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4d57ea4fd55b8..866bc0048ef5f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -150,6 +150,7 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses member template declarations with multiple declarators.
 - Clang now diagnoses use of the ``template`` keyword after declarative nested 
name specifiers.
+- Clang now diagnoses declarative nested name specifiers that name alias 
templates.
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f76e7a3392183..d02fddd069341 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8250,6 +8250,9 @@ def err_not_tag_in_scope : Error<
 def ext_template_after_declarative_nns : ExtWarn<
 "'template' cannot be used after a declarative nested name specifier">,
 InGroup>;
+def ext_alias_template_in_declarative_nns : ExtWarn<
+  "a declarative nested name specifier cannot name an alias template">,
+  InGroup>;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 481d952d2389b..9d4f757caf9ca 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6207,6 +6207,8 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, 
DeclContext *DC,
 SourceLocation Loc,
 TemplateIdAnnotation *TemplateId,
 bool IsMemberSpecialization) {
+  assert(SS.isValid() && "diagnoseQualifiedDeclaration called for declaration "
+ "without nested-name-specifier");
   DeclContext *Cur = CurContext;
   while (isa(Cur) || isa(Cur))
 Cur = Cur->getParent();
@@ -6295,22 +6297,36 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
&SS, DeclContext *DC,
 << FixItHint::CreateRemoval(TemplateId->TemplateKWLoc);
 
   NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
-  while (SpecLoc.getPrefix()) {
+  do {
 if (SpecLoc.getNestedNameSpecifier()->getKind() ==
 NestedNameSpecifier::TypeSpecWithTemplate)
   Diag(Loc, diag::ext_template_after_declarative_nns)
   << FixItHint::CreateRemoval(
  SpecLoc.getTypeLoc().getTemplateKeywordLoc());
 
-SpecLoc = SpecLoc.getPrefix();
-  }
-  // C++11 [dcl.meaning]p1:
-  //   [...] "The nested-name-specifier of the qualified declarator-id shall
-  //   not begin with a decltype-specifer"
-  if (isa_and_nonnull(
-  SpecLoc.getNestedNameSpecifier()->getAsType()))
-Diag(Loc, diag::err_decltype_in_declarator)
-  << SpecLoc.getTypeLoc().getSourceRange();
+if (const Type *T = SpecLoc.getNestedNameSpecifier()->getAsType()) {
+  if (const auto *TST = T->getAsAdjusted()) {
+// C++23 [expr.prim.id.qual]p3:
+//   [...] If a nested-name-specifier N is declarative and has a
+//   simple-template-id with a template argument list A that involves a
+//   template parameter, let T be the template nominated by N without 
A.
+//   T shall be a class template.
+if (TST->isDependentType() && TST->isTypeAlias())
+  Diag(Loc, diag::ext_alias_template_in_declarative_nns)
+  << SpecLoc.getLocalSourceRange();
+  } else if (T->isDecltypeType()) {
+// C++23 [expr.prim.id.qual]p2:
+//   [...] A declarative nested-name-specifier shall not have a
+//   decltype-specifier.
+//
+// FIXME: This wording appears to be defective as it does not forbid
+// declarative nested-name-specifiers with pack-index-specifiers.
+// See https://github.com/cplusplus/CWG/issues/499.
+Diag(Loc, diag::err_decltype_in_declarator)
+<< SpecLoc.getTypeLoc().getSourceRange();
+  }
+}
+  } while ((SpecLoc = SpecLoc.getPrefix()));
 
   return false;
 }
diff --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 

[clang] Diagnose misuse of the cleanup attribute (PR #80040)

2024-02-06 Thread Erich Keane via cfe-commits

erichkeane wrote:

> Umm how could I resolve that? I tried various things but none working. 🥲

You'll have to spend some time in a debugger (note that 
`clang::DiagnosticIDs::EmitDiag` is where the diagnostic happens, so is a good 
place for a brekapoint).  But I see that in your creation of your expressions 
you use `SourceLocation{}` in a few places (which is the 'empty' source 
`SourceLocation` and likely what is being used for the diagnostic).

So you'll likely need to come up with a good location for at least one of those.

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


[clang-tools-extra] `cppcoreguidelines-macro-usage`: Skip common macros which cannot be converted to `constexpr` (PR #80797)

2024-02-06 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL requested changes to this pull request.

Missing release notes, and does not solve issue fully.

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


[clang-tools-extra] `cppcoreguidelines-macro-usage`: Skip common macros which cannot be converted to `constexpr` (PR #80797)

2024-02-06 Thread Piotr Zegar via cfe-commits

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


[clang-tools-extra] `cppcoreguidelines-macro-usage`: Skip common macros which cannot be converted to `constexpr` (PR #80797)

2024-02-06 Thread Piotr Zegar via cfe-commits


@@ -80,6 +80,20 @@ void MacroUsageCheck::warnMacro(const MacroDirective *MD, 
StringRef MacroName) {
   const MacroInfo *Info = MD->getMacroInfo();
   StringRef Message;
 
+  for (const auto &T : MD->getMacroInfo()->tokens()) {
+if (T.is(tok::hash)) {
+  return;
+}
+if (T.is(tok::identifier)) {
+  StringRef IdentName = T.getIdentifierInfo()->getName();
+  if (IdentName == "__FILE__") {
+return;
+  } else if (IdentName == "__LINE__") {
+return;
+  }
+}
+  }
+

PiotrZSL wrote:

Won't work for:
```
 #define MyLineAndFile __FILE__, __LINE__
#define logSomething(x) log(MyLineAndFile, x)
```

For me MacroExpands woud need to be used. And even for this scenario, would be 
good to add some configuration option regex and match to that.

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


  1   2   3   4   5   6   >