[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-10 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/102757

Currently the constexpr vectors lit test depend on CHECK to compare the vector 
values and IR, but after vector element access feature is implemented.

This patch rewrite all tests in constexpr vectors to depend on static asserts 
and element access feature

fixes: #102463

>From f847471e0d8b0a140c4e05109d73ff889906a384 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 10 Aug 2024 16:54:33 +0200
Subject: [PATCH] [clang][llvm-lit] Rewrite constexpr vectors test to use
 element access

Currently the constexpr vectors lit test depend on CHECK to compare
the vector values and IR, but after vector element access feature is
implemented.

This patch rewrite all tests in constexpr vectors to depend on static
asserts and element access feature
---
 clang/test/SemaCXX/constexpr-vectors.cpp | 539 ++-
 1 file changed, 331 insertions(+), 208 deletions(-)

diff --git a/clang/test/SemaCXX/constexpr-vectors.cpp 
b/clang/test/SemaCXX/constexpr-vectors.cpp
index 99b045f888d87c..6c04e99b021769 100644
--- a/clang/test/SemaCXX/constexpr-vectors.cpp
+++ b/clang/test/SemaCXX/constexpr-vectors.cpp
@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++17 -fsyntax-only -verify
 
-// FIXME: Unfortunately there is no good way to validate that our values are
-// correct since Vector types don't have operator [] implemented for constexpr.
-// Instead, we need to use filecheck to ensure the emitted IR is correct. Once
-// someone implements array subscript operator for these types as constexpr,
-// this test should modified to jsut use static asserts.
+// expected-no-diagnostics
 
 using FourCharsVecSize __attribute__((vector_size(4))) = char;
 using FourIntsVecSize __attribute__((vector_size(16))) = int;
@@ -150,564 +146,691 @@ constexpr auto CmpBinOr(T t, U u) {
   return t;
 }
 
+constexpr auto CmpF(float t, float u) {
+  return __builtin_fabs(t - u) < 0.0001;
+}
+
 // Only int vs float makes a difference here, so we only need to test 1 of 
each.
 // Test Char to make sure the mixed-nature of shifts around char is evident.
 void CharUsage() {
   constexpr auto a = FourCharsVecSize{6, 3, 2, 1} +
- FourCharsVecSize{12, 15, 5, 7};
-  // CHECK: store <4 x i8> 
+FourCharsVecSize{12, 15, 5, 7};
+  static_assert(a[0] == 18 && a[1] == 18 && a[2] == 7 && a[3] == 8);
+  
   constexpr auto b = FourCharsVecSize{19, 15, 13, 12} -
  FourCharsVecSize{13, 14, 5, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(b[0] == 6 && b[1] == 1 && b[2] == 8 && b[3] == 9);
+  
   constexpr auto c = FourCharsVecSize{8, 4, 2, 1} *
  FourCharsVecSize{3, 4, 5, 6};
-  // CHECK: store <4 x i8> 
+  static_assert(c[0] == 24 && c[1] == 16 && c[2] == 10 && c[3] == 6);
+
   constexpr auto d = FourCharsVecSize{12, 12, 10, 10} /
  FourCharsVecSize{6, 4, 5, 2};
-  // CHECK: store <4 x i8> 
+  static_assert(d[0] == 2 && d[1] == 3 && d[2] == 2 && d[3] == 5);
+
   constexpr auto e = FourCharsVecSize{12, 12, 10, 10} %
  FourCharsVecSize{6, 4, 4, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(e[0] == 0 && e[1] == 0 && e[2] == 2 && e[3] == 1);
 
   constexpr auto f = FourCharsVecSize{6, 3, 2, 1} + 3;
-  // CHECK: store <4 x i8> 
+  static_assert(f[0] == 9 && f[1] == 6 && f[2] == 5 && f[3] == 4);
+  
   constexpr auto g = FourCharsVecSize{19, 15, 12, 10} - 3;
-  // CHECK: store <4 x i8> 
+  static_assert(g[0] == 16 && g[1] == 12 && g[2] == 9 && g[3] == 7);  
+
   constexpr auto h = FourCharsVecSize{8, 4, 2, 1} * 3;
-  // CHECK: store <4 x i8> 
+  static_assert(h[0] == 24 && h[1] == 12 && h[2] == 6 && h[3] == 3);
+ 
   constexpr auto j = FourCharsVecSize{12, 15, 18, 21} / 3;
-  // CHECK: store <4 x i8> 
+  static_assert(j[0] == 4 && j[1] == 5 && j[2] == 6 && j[3] == 7);
+
   constexpr auto k = FourCharsVecSize{12, 17, 19, 22} % 3;
-  // CHECK: store <4 x i8> 
+  static_assert(k[0] == 0 && k[1] == 2 && k[2] == 1 && k[3] == 1);
 
   constexpr auto l = 3 + FourCharsVecSize{6, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(l[0] == 9 && l[1] == 6 && l[2] == 5 && l[3] == 4);
+
   constexpr auto m = 20 - FourCharsVecSize{19, 15, 12, 10};
-  // CHECK: store <4 x i8> 
+  static_assert(m[0] == 1 && m[1] == 5 && m[2] == 8 && m[3] == 10);
+ 
   constexpr auto n = 3 * FourCharsVecSize{8, 4, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(n[0] == 24 && n[1] == 12 && n[2] == 6 && n[3] == 3);
+
   constexpr auto o = 100 / FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(o[0] == 8 && o[1] == 6 && o[2] == 5 && o[3] == 4);
+
   constexpr auto p = 100 % FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(p[0] == 4 && p[1] == 10 && p[2] == 10 && p[3] == 16);
 
  

[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-11 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

If you have time for review @tbaederr 

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-11 Thread Amr Hesham via cfe-commits


@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++17 -fsyntax-only -verify

AmrDeveloper wrote:

To use C++ extension for static_assert, I can back to c++14 and add empty 
message if that needed

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-11 Thread Amr Hesham via cfe-commits


@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++17 -fsyntax-only -verify

AmrDeveloper wrote:

Sure i will, thanks

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-11 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/102757

>From 673b9e08de8a661c9deed2ee497889312f059f3d Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 10 Aug 2024 16:54:33 +0200
Subject: [PATCH] [clang][llvm-lit] Rewrite constexpr vectors test to use
 element access

Currently the constexpr vectors lit test depend on CHECK to compare
the vector values and IR, but after vector element access feature is
implemented.

This patch rewrite all tests in constexpr vectors to depend on static
asserts and element access feature
---
 clang/test/SemaCXX/constexpr-vectors.cpp | 539 ++-
 1 file changed, 331 insertions(+), 208 deletions(-)

diff --git a/clang/test/SemaCXX/constexpr-vectors.cpp 
b/clang/test/SemaCXX/constexpr-vectors.cpp
index 99b045f888d87c..6cd305e5732577 100644
--- a/clang/test/SemaCXX/constexpr-vectors.cpp
+++ b/clang/test/SemaCXX/constexpr-vectors.cpp
@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++14 -fsyntax-only -verify
 
-// FIXME: Unfortunately there is no good way to validate that our values are
-// correct since Vector types don't have operator [] implemented for constexpr.
-// Instead, we need to use filecheck to ensure the emitted IR is correct. Once
-// someone implements array subscript operator for these types as constexpr,
-// this test should modified to jsut use static asserts.
+// expected-no-diagnostics
 
 using FourCharsVecSize __attribute__((vector_size(4))) = char;
 using FourIntsVecSize __attribute__((vector_size(16))) = int;
@@ -150,564 +146,691 @@ constexpr auto CmpBinOr(T t, U u) {
   return t;
 }
 
+constexpr auto CmpF(float t, float u) {
+  return __builtin_fabs(t - u) < 0.0001;
+}
+
 // Only int vs float makes a difference here, so we only need to test 1 of 
each.
 // Test Char to make sure the mixed-nature of shifts around char is evident.
 void CharUsage() {
   constexpr auto a = FourCharsVecSize{6, 3, 2, 1} +
- FourCharsVecSize{12, 15, 5, 7};
-  // CHECK: store <4 x i8> 
+FourCharsVecSize{12, 15, 5, 7};
+  static_assert(a[0] == 18 && a[1] == 18 && a[2] == 7 && a[3] == 8, "");
+  
   constexpr auto b = FourCharsVecSize{19, 15, 13, 12} -
  FourCharsVecSize{13, 14, 5, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(b[0] == 6 && b[1] == 1 && b[2] == 8 && b[3] == 9, "");
+  
   constexpr auto c = FourCharsVecSize{8, 4, 2, 1} *
  FourCharsVecSize{3, 4, 5, 6};
-  // CHECK: store <4 x i8> 
+  static_assert(c[0] == 24 && c[1] == 16 && c[2] == 10 && c[3] == 6, "");
+
   constexpr auto d = FourCharsVecSize{12, 12, 10, 10} /
  FourCharsVecSize{6, 4, 5, 2};
-  // CHECK: store <4 x i8> 
+  static_assert(d[0] == 2 && d[1] == 3 && d[2] == 2 && d[3] == 5, "");
+
   constexpr auto e = FourCharsVecSize{12, 12, 10, 10} %
  FourCharsVecSize{6, 4, 4, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(e[0] == 0 && e[1] == 0 && e[2] == 2 && e[3] == 1, "");
 
   constexpr auto f = FourCharsVecSize{6, 3, 2, 1} + 3;
-  // CHECK: store <4 x i8> 
+  static_assert(f[0] == 9 && f[1] == 6 && f[2] == 5 && f[3] == 4, "");
+  
   constexpr auto g = FourCharsVecSize{19, 15, 12, 10} - 3;
-  // CHECK: store <4 x i8> 
+  static_assert(g[0] == 16 && g[1] == 12 && g[2] == 9 && g[3] == 7, "");  
+
   constexpr auto h = FourCharsVecSize{8, 4, 2, 1} * 3;
-  // CHECK: store <4 x i8> 
+  static_assert(h[0] == 24 && h[1] == 12 && h[2] == 6 && h[3] == 3, "");
+ 
   constexpr auto j = FourCharsVecSize{12, 15, 18, 21} / 3;
-  // CHECK: store <4 x i8> 
+  static_assert(j[0] == 4 && j[1] == 5 && j[2] == 6 && j[3] == 7, "");
+
   constexpr auto k = FourCharsVecSize{12, 17, 19, 22} % 3;
-  // CHECK: store <4 x i8> 
+  static_assert(k[0] == 0 && k[1] == 2 && k[2] == 1 && k[3] == 1, "");
 
   constexpr auto l = 3 + FourCharsVecSize{6, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(l[0] == 9 && l[1] == 6 && l[2] == 5 && l[3] == 4, "");
+
   constexpr auto m = 20 - FourCharsVecSize{19, 15, 12, 10};
-  // CHECK: store <4 x i8> 
+  static_assert(m[0] == 1 && m[1] == 5 && m[2] == 8 && m[3] == 10, "");
+ 
   constexpr auto n = 3 * FourCharsVecSize{8, 4, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(n[0] == 24 && n[1] == 12 && n[2] == 6 && n[3] == 3, "");
+
   constexpr auto o = 100 / FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(o[0] == 8 && o[1] == 6 && o[2] == 5 && o[3] == 4, "");
+
   constexpr auto p = 100 % FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(p[0] == 4 && p[1] == 10 && p[2] == 10 && p[3] == 16, "");
 
   constexpr auto q = FourCharsVecSize{6, 3, 2, 1} << FourCharsVecSize{1, 1, 2, 
2};
-  // CHECK: store <4 x i8> 
+  static_assert(q[0] == 12 && q[1] == 6 && q[2] == 8 && q[3] == 4, "");
+
   constexpr auto r = FourCh

[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-11 Thread Amr Hesham via cfe-commits


@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++17 -fsyntax-only -verify

AmrDeveloper wrote:

@tbaederr Done

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-13 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

Should we merge now?

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-13 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> > Should we merge now?
> 
> Well, there seem to be some CI failures, so unless those are unrelated, 
> they’ll have to be resolved first.

It was related to a file that not removed on the linux server

`rm: cannot remove Output.TestFile: Permission deniedz

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


[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-15 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/102757

>From 7c594e09860fd1be7d66a7c3f99d079267581c11 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 10 Aug 2024 16:54:33 +0200
Subject: [PATCH] [clang][llvm-lit] Rewrite constexpr vectors test to use
 element access

Currently the constexpr vectors lit test depend on CHECK to compare
the vector values and IR, but after vector element access feature is
implemented.

This patch rewrite all tests in constexpr vectors to depend on static
asserts and element access feature
---
 clang/test/SemaCXX/constexpr-vectors.cpp | 539 ++-
 1 file changed, 331 insertions(+), 208 deletions(-)

diff --git a/clang/test/SemaCXX/constexpr-vectors.cpp 
b/clang/test/SemaCXX/constexpr-vectors.cpp
index 99b045f888d87c..6cd305e5732577 100644
--- a/clang/test/SemaCXX/constexpr-vectors.cpp
+++ b/clang/test/SemaCXX/constexpr-vectors.cpp
@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++14 -fsyntax-only -verify
 
-// FIXME: Unfortunately there is no good way to validate that our values are
-// correct since Vector types don't have operator [] implemented for constexpr.
-// Instead, we need to use filecheck to ensure the emitted IR is correct. Once
-// someone implements array subscript operator for these types as constexpr,
-// this test should modified to jsut use static asserts.
+// expected-no-diagnostics
 
 using FourCharsVecSize __attribute__((vector_size(4))) = char;
 using FourIntsVecSize __attribute__((vector_size(16))) = int;
@@ -150,564 +146,691 @@ constexpr auto CmpBinOr(T t, U u) {
   return t;
 }
 
+constexpr auto CmpF(float t, float u) {
+  return __builtin_fabs(t - u) < 0.0001;
+}
+
 // Only int vs float makes a difference here, so we only need to test 1 of 
each.
 // Test Char to make sure the mixed-nature of shifts around char is evident.
 void CharUsage() {
   constexpr auto a = FourCharsVecSize{6, 3, 2, 1} +
- FourCharsVecSize{12, 15, 5, 7};
-  // CHECK: store <4 x i8> 
+FourCharsVecSize{12, 15, 5, 7};
+  static_assert(a[0] == 18 && a[1] == 18 && a[2] == 7 && a[3] == 8, "");
+  
   constexpr auto b = FourCharsVecSize{19, 15, 13, 12} -
  FourCharsVecSize{13, 14, 5, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(b[0] == 6 && b[1] == 1 && b[2] == 8 && b[3] == 9, "");
+  
   constexpr auto c = FourCharsVecSize{8, 4, 2, 1} *
  FourCharsVecSize{3, 4, 5, 6};
-  // CHECK: store <4 x i8> 
+  static_assert(c[0] == 24 && c[1] == 16 && c[2] == 10 && c[3] == 6, "");
+
   constexpr auto d = FourCharsVecSize{12, 12, 10, 10} /
  FourCharsVecSize{6, 4, 5, 2};
-  // CHECK: store <4 x i8> 
+  static_assert(d[0] == 2 && d[1] == 3 && d[2] == 2 && d[3] == 5, "");
+
   constexpr auto e = FourCharsVecSize{12, 12, 10, 10} %
  FourCharsVecSize{6, 4, 4, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(e[0] == 0 && e[1] == 0 && e[2] == 2 && e[3] == 1, "");
 
   constexpr auto f = FourCharsVecSize{6, 3, 2, 1} + 3;
-  // CHECK: store <4 x i8> 
+  static_assert(f[0] == 9 && f[1] == 6 && f[2] == 5 && f[3] == 4, "");
+  
   constexpr auto g = FourCharsVecSize{19, 15, 12, 10} - 3;
-  // CHECK: store <4 x i8> 
+  static_assert(g[0] == 16 && g[1] == 12 && g[2] == 9 && g[3] == 7, "");  
+
   constexpr auto h = FourCharsVecSize{8, 4, 2, 1} * 3;
-  // CHECK: store <4 x i8> 
+  static_assert(h[0] == 24 && h[1] == 12 && h[2] == 6 && h[3] == 3, "");
+ 
   constexpr auto j = FourCharsVecSize{12, 15, 18, 21} / 3;
-  // CHECK: store <4 x i8> 
+  static_assert(j[0] == 4 && j[1] == 5 && j[2] == 6 && j[3] == 7, "");
+
   constexpr auto k = FourCharsVecSize{12, 17, 19, 22} % 3;
-  // CHECK: store <4 x i8> 
+  static_assert(k[0] == 0 && k[1] == 2 && k[2] == 1 && k[3] == 1, "");
 
   constexpr auto l = 3 + FourCharsVecSize{6, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(l[0] == 9 && l[1] == 6 && l[2] == 5 && l[3] == 4, "");
+
   constexpr auto m = 20 - FourCharsVecSize{19, 15, 12, 10};
-  // CHECK: store <4 x i8> 
+  static_assert(m[0] == 1 && m[1] == 5 && m[2] == 8 && m[3] == 10, "");
+ 
   constexpr auto n = 3 * FourCharsVecSize{8, 4, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(n[0] == 24 && n[1] == 12 && n[2] == 6 && n[3] == 3, "");
+
   constexpr auto o = 100 / FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(o[0] == 8 && o[1] == 6 && o[2] == 5 && o[3] == 4, "");
+
   constexpr auto p = 100 % FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(p[0] == 4 && p[1] == 10 && p[2] == 10 && p[3] == 16, "");
 
   constexpr auto q = FourCharsVecSize{6, 3, 2, 1} << FourCharsVecSize{1, 1, 2, 
2};
-  // CHECK: store <4 x i8> 
+  static_assert(q[0] == 12 && q[1] == 6 && q[2] == 8 && q[3] == 4, "");
+
   constexpr auto r = FourCh

[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-15 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/102757

>From 7c0c21c60b70ee2970e1fa5ed414529b5bd5bc23 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 10 Aug 2024 16:54:33 +0200
Subject: [PATCH] [clang][llvm-lit] Rewrite constexpr vectors test to use
 element access

Currently the constexpr vectors lit test depend on CHECK to compare
the vector values and IR, but after vector element access feature is
implemented.

This patch rewrite all tests in constexpr vectors to depend on static
asserts and element access feature
---
 clang/test/SemaCXX/constexpr-vectors.cpp | 539 ++-
 1 file changed, 331 insertions(+), 208 deletions(-)

diff --git a/clang/test/SemaCXX/constexpr-vectors.cpp 
b/clang/test/SemaCXX/constexpr-vectors.cpp
index 99b045f888d87c..6cd305e5732577 100644
--- a/clang/test/SemaCXX/constexpr-vectors.cpp
+++ b/clang/test/SemaCXX/constexpr-vectors.cpp
@@ -1,10 +1,6 @@
-// RUN: %clang_cc1 -std=c++14 -Wno-unused-value %s -disable-llvm-passes 
-triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -Wno-uninitialized -std=c++14 -fsyntax-only -verify
 
-// FIXME: Unfortunately there is no good way to validate that our values are
-// correct since Vector types don't have operator [] implemented for constexpr.
-// Instead, we need to use filecheck to ensure the emitted IR is correct. Once
-// someone implements array subscript operator for these types as constexpr,
-// this test should modified to jsut use static asserts.
+// expected-no-diagnostics
 
 using FourCharsVecSize __attribute__((vector_size(4))) = char;
 using FourIntsVecSize __attribute__((vector_size(16))) = int;
@@ -150,564 +146,691 @@ constexpr auto CmpBinOr(T t, U u) {
   return t;
 }
 
+constexpr auto CmpF(float t, float u) {
+  return __builtin_fabs(t - u) < 0.0001;
+}
+
 // Only int vs float makes a difference here, so we only need to test 1 of 
each.
 // Test Char to make sure the mixed-nature of shifts around char is evident.
 void CharUsage() {
   constexpr auto a = FourCharsVecSize{6, 3, 2, 1} +
- FourCharsVecSize{12, 15, 5, 7};
-  // CHECK: store <4 x i8> 
+FourCharsVecSize{12, 15, 5, 7};
+  static_assert(a[0] == 18 && a[1] == 18 && a[2] == 7 && a[3] == 8, "");
+  
   constexpr auto b = FourCharsVecSize{19, 15, 13, 12} -
  FourCharsVecSize{13, 14, 5, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(b[0] == 6 && b[1] == 1 && b[2] == 8 && b[3] == 9, "");
+  
   constexpr auto c = FourCharsVecSize{8, 4, 2, 1} *
  FourCharsVecSize{3, 4, 5, 6};
-  // CHECK: store <4 x i8> 
+  static_assert(c[0] == 24 && c[1] == 16 && c[2] == 10 && c[3] == 6, "");
+
   constexpr auto d = FourCharsVecSize{12, 12, 10, 10} /
  FourCharsVecSize{6, 4, 5, 2};
-  // CHECK: store <4 x i8> 
+  static_assert(d[0] == 2 && d[1] == 3 && d[2] == 2 && d[3] == 5, "");
+
   constexpr auto e = FourCharsVecSize{12, 12, 10, 10} %
  FourCharsVecSize{6, 4, 4, 3};
-  // CHECK: store <4 x i8> 
+  static_assert(e[0] == 0 && e[1] == 0 && e[2] == 2 && e[3] == 1, "");
 
   constexpr auto f = FourCharsVecSize{6, 3, 2, 1} + 3;
-  // CHECK: store <4 x i8> 
+  static_assert(f[0] == 9 && f[1] == 6 && f[2] == 5 && f[3] == 4, "");
+  
   constexpr auto g = FourCharsVecSize{19, 15, 12, 10} - 3;
-  // CHECK: store <4 x i8> 
+  static_assert(g[0] == 16 && g[1] == 12 && g[2] == 9 && g[3] == 7, "");  
+
   constexpr auto h = FourCharsVecSize{8, 4, 2, 1} * 3;
-  // CHECK: store <4 x i8> 
+  static_assert(h[0] == 24 && h[1] == 12 && h[2] == 6 && h[3] == 3, "");
+ 
   constexpr auto j = FourCharsVecSize{12, 15, 18, 21} / 3;
-  // CHECK: store <4 x i8> 
+  static_assert(j[0] == 4 && j[1] == 5 && j[2] == 6 && j[3] == 7, "");
+
   constexpr auto k = FourCharsVecSize{12, 17, 19, 22} % 3;
-  // CHECK: store <4 x i8> 
+  static_assert(k[0] == 0 && k[1] == 2 && k[2] == 1 && k[3] == 1, "");
 
   constexpr auto l = 3 + FourCharsVecSize{6, 3, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(l[0] == 9 && l[1] == 6 && l[2] == 5 && l[3] == 4, "");
+
   constexpr auto m = 20 - FourCharsVecSize{19, 15, 12, 10};
-  // CHECK: store <4 x i8> 
+  static_assert(m[0] == 1 && m[1] == 5 && m[2] == 8 && m[3] == 10, "");
+ 
   constexpr auto n = 3 * FourCharsVecSize{8, 4, 2, 1};
-  // CHECK: store <4 x i8> 
+  static_assert(n[0] == 24 && n[1] == 12 && n[2] == 6 && n[3] == 3, "");
+
   constexpr auto o = 100 / FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(o[0] == 8 && o[1] == 6 && o[2] == 5 && o[3] == 4, "");
+
   constexpr auto p = 100 % FourCharsVecSize{12, 15, 18, 21};
-  // CHECK: store <4 x i8> 
+  static_assert(p[0] == 4 && p[1] == 10 && p[2] == 10 && p[3] == 16, "");
 
   constexpr auto q = FourCharsVecSize{6, 3, 2, 1} << FourCharsVecSize{1, 1, 2, 
2};
-  // CHECK: store <4 x i8> 
+  static_assert(q[0] == 12 && q[1] == 6 && q[2] == 8 && q[3] == 4, "");
+
   constexpr auto r = FourCh

[clang] [clang][llvm-lit] Rewrite constexpr vectors test to use element access (PR #102757)

2024-08-15 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

CI is happy now, i think we can merge @tbaederr, @Sirraide 

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-26 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From cd1c20ce8856ca24ffea6db22a758e588f0398e2 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|  10 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 134 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 134 ++
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  38 ++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  56 +++-
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +--
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  39 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  38 ++---
 clang/test/CodeGenHLSL/builtins/saturate.hlsl |  64 -
 .../semantics/DispatchThreadID.hlsl   |  10 +-
 10 files changed, 205 insertions(+), 334 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..e3fa0d2c3083fd 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK
 
 RWBuffer Buf;
 
 // CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
 // CHECK-NEXT: entry:
 
-// CHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// DXCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// SPVCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
-
-// CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..f431aa8eb692dd 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -16,262 +16,220 @@
 #ifdef __HLSL_ENABLE_16_BIT
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:dx]].all.i16
+// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:spv]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
 
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t(uint16_t p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t2(uint16_t2 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-26 Thread Amr Hesham via cfe-commits


@@ -15,70 +15,70 @@
 
 // DXIL_NATIVE_HALF: define noundef half @
 // SPIR_NATIVE_HALF: define spir_func noundef half @
-// DXIL_NATIVE_HALF: %hlsl.frac = call half @llvm.dx.frac.f16(
-// SPIR_NATIVE_HALF: %hlsl.frac = call half @llvm.spv.frac.f16(
+// DXIL_NATIVE_HALF: %hlsl.frac = call half @llvm.[[ICF:dx]].frac.f16(
+// SPIR_NATIVE_HALF: %hlsl.frac = call half @llvm.[[ICF:spv]].frac.f16(
 // NATIVE_HALF: ret half %hlsl.frac
 // DXIL_NO_HALF: define noundef float @
 // SPIR_NO_HALF: define spir_func noundef float @
-// DXIL_NO_HALF: %hlsl.frac = call float @llvm.dx.frac.f32(
-// SPIR_NO_HALF: %hlsl.frac = call float @llvm.spv.frac.f32(
+// DXIL_NO_HALF: %hlsl.frac = call float @llvm.[[ICF:dx]].frac.f32(
+// SPIR_NO_HALF: %hlsl.frac = call float @llvm.[[ICF:spv]].frac.f32(
 // NO_HALF: ret float %hlsl.frac
 half test_frac_half(half p0) { return frac(p0); }
 // DXIL_NATIVE_HALF: define noundef <2 x half> @
 // SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
-// DXIL_NATIVE_HALF: %hlsl.frac = call <2 x half> @llvm.dx.frac.v2f16
-// SPIR_NATIVE_HALF: %hlsl.frac = call <2 x half> @llvm.spv.frac.v2f16
+// DXIL_NATIVE_HALF: %hlsl.frac = call <2 x half> @llvm.[[ICF:dx]].frac.v2f16
+// SPIR_NATIVE_HALF: %hlsl.frac = call <2 x half> @llvm.[[ICF:spv]].frac.v2f16
 // NATIVE_HALF: ret <2 x half> %hlsl.frac
 // DXIL_NO_HALF: define noundef <2 x float> @
 // SPIR_NO_HALF: define spir_func noundef <2 x float> @
-// DXIL_NO_HALF: %hlsl.frac = call <2 x float> @llvm.dx.frac.v2f32(
-// SPIR_NO_HALF: %hlsl.frac = call <2 x float> @llvm.spv.frac.v2f32(
+// DXIL_NO_HALF: %hlsl.frac = call <2 x float> @llvm.[[ICF:dx]].frac.v2f32(
+// SPIR_NO_HALF: %hlsl.frac = call <2 x float> @llvm.[[ICF:spv]].frac.v2f32(
 // NO_HALF: ret <2 x float> %hlsl.frac
 half2 test_frac_half2(half2 p0) { return frac(p0); }
 // DXIL_NATIVE_HALF: define noundef <3 x half> @
 // SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
-// DXIL_NATIVE_HALF: %hlsl.frac = call <3 x half> @llvm.dx.frac.v3f16
-// SPIR_NATIVE_HALF: %hlsl.frac = call <3 x half> @llvm.spv.frac.v3f16
+// DXIL_NATIVE_HALF: %hlsl.frac = call <3 x half> @llvm.[[ICF:dx]].frac.v3f16
+// SPIR_NATIVE_HALF: %hlsl.frac = call <3 x half> @llvm.[[ICF:spv]].frac.v3f16
 // NATIVE_HALF: ret <3 x half> %hlsl.frac
 // DXIL_NO_HALF: define noundef <3 x float> @
 // SPIR_NO_HALF: define spir_func noundef <3 x float> @
-// DXIL_NO_HALF: %hlsl.frac = call <3 x float> @llvm.dx.frac.v3f32(
-// SPIR_NO_HALF: %hlsl.frac = call <3 x float> @llvm.spv.frac.v3f32(
+// DXIL_NO_HALF: %hlsl.frac = call <3 x float> @llvm.[[ICF:dx]].frac.v3f32(
+// SPIR_NO_HALF: %hlsl.frac = call <3 x float> @llvm.[[ICF:spv]].frac.v3f32(
 // NO_HALF: ret <3 x float> %hlsl.frac
 half3 test_frac_half3(half3 p0) { return frac(p0); }
 // DXIL_NATIVE_HALF: define noundef <4 x half> @
 // SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
-// DXIL_NATIVE_HALF: %hlsl.frac = call <4 x half> @llvm.dx.frac.v4f16
-// SPIR_NATIVE_HALF: %hlsl.frac = call <4 x half> @llvm.spv.frac.v4f16
+// DXIL_NATIVE_HALF: %hlsl.frac = call <4 x half> @llvm.[[ICF:dx]].frac.v4f16
+// SPIR_NATIVE_HALF: %hlsl.frac = call <4 x half> @llvm.[[ICF:spv]].frac.v4f16
 // NATIVE_HALF: ret <4 x half> %hlsl.frac
 // DXIL_NO_HALF: define noundef <4 x float> @
 // SPIR_NO_HALF: define spir_func noundef <4 x float> @
-// DXIL_NO_HALF: %hlsl.frac = call <4 x float> @llvm.dx.frac.v4f32(
-// SPIR_NO_HALF: %hlsl.frac = call <4 x float> @llvm.spv.frac.v4f32(
+// DXIL_NO_HALF: %hlsl.frac = call <4 x float> @llvm.[[ICF:dx]].frac.v4f32(
+// SPIR_NO_HALF: %hlsl.frac = call <4 x float> @llvm.[[ICF:spv]].frac.v4f32(
 // NO_HALF: ret <4 x float> %hlsl.frac
 half4 test_frac_half4(half4 p0) { return frac(p0); }
 
 // DXIL_CHECK: define noundef float @
 // SPIR_CHECK: define spir_func noundef float @
-// DXIL_CHECK: %hlsl.frac = call float @llvm.dx.frac.f32(
-// SPIR_CHECK: %hlsl.frac = call float @llvm.spv.frac.f32(
+// DXIL_CHECK: %hlsl.frac = call float @llvm.[[ICF:dx]].frac.f32(
+// SPIR_CHECK: %hlsl.frac = call float @llvm.[[ICF:spv]].frac.f32(
 // CHECK: ret float %hlsl.frac
 float test_frac_float(float p0) { return frac(p0); }
 // DXIL_CHECK: define noundef <2 x float> @
 // SPIR_CHECK: define spir_func noundef <2 x float> @
-// DXIL_CHECK: %hlsl.frac = call <2 x float> @llvm.dx.frac.v2f32
-// SPIR_CHECK: %hlsl.frac = call <2 x float> @llvm.spv.frac.v2f32
+// DXIL_CHECK: %hlsl.frac = call <2 x float> @llvm.[[ICF:dx]].frac.v2f32
+// SPIR_CHECK: %hlsl.frac = call <2 x float> @llvm.[[ICF:spv]].frac.v2f32
 // CHECK: ret <2 x float> %hlsl.frac
 float2 test_frac_float2(float2 p0) { return frac(p0); }
 // DXIL_CHECK: define noundef <3 x float> @
 // SPIR_CHECK: define spir_func noundef <3 x float> @
-// DXIL_CHECK: %hlsl.frac = call <3 x float> @llvm.dx.frac.v3f32
-// SPIR_CHECK: %hlsl.frac = call <3 x float> @llvm.spv.frac.v3f32
+// DXIL_CHECK: %hlsl.frac = call <3 x float> @llvm.[[ICF:dx]].frac.v3f32
+// SPIR_CHECK: %hlsl.frac = call <3 x float> @llvm.[[IC

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-26 Thread Amr Hesham via cfe-commits


@@ -25,7 +25,7 @@ void main(unsigned GI : SV_GroupIndex) {}
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @"?call_me_first@@YAXXZ"()
 //CHECK-NEXT:   call void @"?then_call_me@@YAXXZ"()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()

AmrDeveloper wrote:

Thank you done

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-26 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From f161a06ef18e52fd03809a7b73cc0aa978513344 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|  10 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 134 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 134 ++
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  38 ++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  56 +++-
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +--
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  39 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  38 ++---
 clang/test/CodeGenHLSL/builtins/saturate.hlsl |  64 -
 .../semantics/DispatchThreadID.hlsl   |  10 +-
 10 files changed, 205 insertions(+), 334 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..e3fa0d2c3083fd 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK
 
 RWBuffer Buf;
 
 // CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
 // CHECK-NEXT: entry:
 
-// CHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// DXCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// SPVCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
-
-// CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..f431aa8eb692dd 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -16,262 +16,220 @@
 #ifdef __HLSL_ENABLE_16_BIT
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:dx]].all.i16
+// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:spv]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
 
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t(uint16_t p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t2(uint16_t2 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-26 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 452073564bd2e5c43b7a485db2fdf1652aa3da1f Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|  10 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 134 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 134 ++
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  38 ++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  56 +++-
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +--
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  39 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  38 ++---
 .../semantics/DispatchThreadID.hlsl   |  10 +-
 9 files changed, 173 insertions(+), 302 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..e3fa0d2c3083fd 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK
 
 RWBuffer Buf;
 
 // CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
 // CHECK-NEXT: entry:
 
-// CHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// DXCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// SPVCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
-
-// CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..f431aa8eb692dd 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -16,262 +16,220 @@
 #ifdef __HLSL_ENABLE_16_BIT
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:dx]].all.i16
+// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:spv]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
 
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t(uint16_t p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_uint16_t2(uint16_t2 p0) { return all(p0); }
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all 

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 027034d06257953e065ab906a567e604023a33f3 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|  10 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 134 +++--
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  38 +--
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  56 ++--
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +-
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  39 +--
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  38 +--
 .../semantics/DispatchThreadID.hlsl   |  10 +-
 9 files changed, 219 insertions(+), 390 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..e3fa0d2c3083fd 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK
 
 RWBuffer Buf;
 
 // CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
 // CHECK-NEXT: entry:
 
-// CHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// DXCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// SPVCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
-
-// CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: de

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits


@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK

AmrDeveloper wrote:

Yes it broken now when i include CHECK in the prefixes, so i will keep it as it 
is maybe for other pr

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits


@@ -16,262 +16,220 @@
 #ifdef __HLSL_ENABLE_16_BIT
 // DXIL_NATIVE_HALF: define noundef i1 @
 // SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:dx]].all.i16
+// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.[[ICF:spv]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }

AmrDeveloper wrote:

Thats a lot better i did that for all.hlsl tests and will check other files

Thank you

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 1bcddd68fca3b5393ddd2c4918135d5f7fd397c2 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|   2 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 134 +++--
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  38 +--
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  56 ++--
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +-
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  39 +--
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  38 +--
 .../semantics/DispatchThreadID.hlsl   |  10 +-
 9 files changed, 215 insertions(+), 386 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..baddfcf2cf1d52 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -9,4 +9,4 @@ RWBuffer Buf;
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
 // CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
+// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
-
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func n

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From f2e483e38b4b0b4ad34aa8198aad9daa48d001db Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|   2 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 264 ++---
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  84 +++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  58 ++--
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +-
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  73 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  84 +++---
 .../semantics/DispatchThreadID.hlsl   |  10 +-
 9 files changed, 313 insertions(+), 546 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..baddfcf2cf1d52 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -9,4 +9,4 @@ RWBuffer Buf;
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
 // CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
+// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
-
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: de

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits


@@ -1,98 +1,83 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN:   --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,DXIL_CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 
-// DXIL_NATIVE_HALF: define noundef half @
-// SPIR_NATIVE_HALF: define spir_func noundef half @
-// DXIL_NATIVE_HALF: call half @llvm.dx.normalize.f16(half
-// SPIR_NATIVE_HALF: call half @llvm.spv.normalize.f16(half
-// DXIL_NO_HALF: call float @llvm.dx.normalize.f32(float
-// SPIR_NO_HALF: call float @llvm.spv.normalize.f32(float
+// NATIVE_HALF: define [[FNATTRS]] half @
+// NATIVE_HALF: call half @llvm.[[TARGET]].normalize.f16(half
+// NO_HALF: call float @llvm.[[TARGET]].normalize.f32(float
 // NATIVE_HALF: ret half
 // NO_HALF: ret float
 half test_normalize_half(half p0)
 {
 return normalize(p0);
 }
-// DXIL_NATIVE_HALF: define noundef <2 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
-// DXIL_NATIVE_HALF: call <2 x half> @llvm.dx.normalize.v2f16(<2 x half>
-// SPIR_NATIVE_HALF: call <2 x half> @llvm.spv.normalize.v2f16(<2 x half>
-// DXIL_NO_HALF: call <2 x float> @llvm.dx.normalize.v2f32(<2 x float>
-// SPIR_NO_HALF: call <2 x float> @llvm.spv.normalize.v2f32(<2 x float>
+// NATIVE_HALF: define [[FNATTRS]] <2 x half> @
+// NATIVE_HALF: call <2 x half> @llvm.[[TARGET]].normalize.v2f16(<2 x half>
+// NO_HALF: call <2 x float> @llvm.[[TARGET]].normalize.v2f32(<2 x float>
 // NATIVE_HALF: ret <2 x half> %hlsl.normalize
 // NO_HALF: ret <2 x float> %hlsl.normalize
 half2 test_normalize_half2(half2 p0)
 {
 return normalize(p0);
 }
-// DXIL_NATIVE_HALF: define noundef <3 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
-// DXIL_NATIVE_HALF: call <3 x half> @llvm.dx.normalize.v3f16(<3 x half>
-// SPIR_NATIVE_HALF: call <3 x half> @llvm.spv.normalize.v3f16(<3 x half>
-// DXIL_NO_HALF: call <3 x float> @llvm.dx.normalize.v3f32(<3 x float>
-// SPIR_NO_HALF: call <3 x float> @llvm.spv.normalize.v3f32(<3 x float>
+// NATIVE_HALF: define [[FNATTRS]] <3 x half> @
+// NATIVE_HALF: call <3 x half> @llvm.[[TARGET]].normalize.v3f16(<3 x half>
+// NO_HALF: call <3 x float> @llvm.[[TARGET]].normalize.v3f32(<3 x float>
 // NATIVE_HALF: ret <3 x half> %hlsl.normalize
 // NO_HALF: ret <3 x float> %hlsl.normalize
 half3 test_normalize_half3(half3 p0)
 {
 return normalize(p0);
 }
-// DXIL_NATIVE_HALF: define noundef <4 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
-// DXIL_NATIVE_HALF: call <4 x half> @llvm.dx.normalize.v4f16(<4 x half>
-// SPIR_NATIVE_HALF: call <4 x half> @llvm.spv.normalize.v4f16(<4 x half>
-// DXIL_NO_HALF: call <4 x float> @llvm.dx.normalize.v4f32(<4 x float>
-// SPIR_NO_HALF: call <4 x float> @llvm.spv.normalize.v4f32(<4 x float>
+// NATIVE_HALF: define [[FNATTRS]] <4 x half> @
+// NATIVE_HALF: call <4 x half> @llvm.[[TARGET]].normalize.v4f16(<4 x half>
+// NO_HALF: call <4 x float> @llvm.[[TARGET]].normalize.v4f32(<4 x float>
 // NATIVE_HALF: ret <4 x half> %hlsl.normalize
 // NO_HALF: ret <4 x float> %hlsl.normalize
 half4 test_normalize_half4(half4 p0)
 {
 return normalize(p0);
 }
 
-// DXIL_CHECK: define noundef float @
-// SPIR_CHECK: define spir_func noundef float @
-// DXIL_CHECK: call float @llvm.dx.normalize.f32(float
-// SPIR_CHECK: call float @llvm.spv.normalize.f32(float
+// CHECK: define [[FNATTRS]] float @
+// CHECK: call float @llvm.[[TARGET]].normalize.f32(float
 // CHECK: ret float
 float test_normalize_float(float p0)
 {
 return normalize(p0);
 }
-// DXIL_CHECK: define noundef <2 x float> @
-// SPIR_CHECK: define spir_func noundef <2 x float> @
-// DXIL_CHECK: %hlsl.normalize = call <2 x float> @llvm.dx.normalize.v2f32(
-// SPIR_CHECK: %

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 33b59a3cc600081fab5d8862b521d4ea929d566a Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|   2 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 264 ++---
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  84 +++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  58 ++--
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +-
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  73 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  84 +++---
 .../semantics/DispatchThreadID.hlsl   |  14 +-
 9 files changed, 315 insertions(+), 548 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..baddfcf2cf1d52 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -9,4 +9,4 @@ RWBuffer Buf;
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
 // CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
+// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
-
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: de

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 6ae18c6da6dff942ad8524d7e3aa2565369e8cfb Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|   2 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 264 ++---
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  84 +++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  58 ++--
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +-
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  72 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  84 +++---
 .../semantics/DispatchThreadID.hlsl   |  14 +-
 9 files changed, 314 insertions(+), 548 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..baddfcf2cf1d52 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -9,4 +9,4 @@ RWBuffer Buf;
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
 // CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
+// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
-
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: de

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From ff7bbba695a727da01ee51fcb0c1126380f6bb7f Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|   2 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 264 ++---
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  84 +++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  58 ++--
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  16 +-
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  73 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  84 +++---
 .../semantics/DispatchThreadID.hlsl   |  14 +-
 9 files changed, 315 insertions(+), 548 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..baddfcf2cf1d52 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -9,4 +9,4 @@ RWBuffer Buf;
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
 // CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
+// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
-
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: de

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-27 Thread Amr Hesham via cfe-commits


@@ -1,98 +1,83 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN:   --check-prefixes=CHECK,DXIL_CHECK,DXIL_NATIVE_HALF,NATIVE_HALF
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,DXIL_CHECK,NO_HALF,DXIL_NO_HALF
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,DXIL_CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s 
--check-prefixes=CHECK,NO_HALF,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 
-// DXIL_NATIVE_HALF: define noundef half @
-// SPIR_NATIVE_HALF: define spir_func noundef half @
-// DXIL_NATIVE_HALF: call half @llvm.dx.normalize.f16(half
-// SPIR_NATIVE_HALF: call half @llvm.spv.normalize.f16(half
-// DXIL_NO_HALF: call float @llvm.dx.normalize.f32(float
-// SPIR_NO_HALF: call float @llvm.spv.normalize.f32(float
+// NATIVE_HALF: define [[FNATTRS]] half @
+// NATIVE_HALF: call half @llvm.[[TARGET]].normalize.f16(half
+// NO_HALF: call float @llvm.[[TARGET]].normalize.f32(float
 // NATIVE_HALF: ret half
 // NO_HALF: ret float
 half test_normalize_half(half p0)
 {
 return normalize(p0);
 }
-// DXIL_NATIVE_HALF: define noundef <2 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <2 x half> @
-// DXIL_NATIVE_HALF: call <2 x half> @llvm.dx.normalize.v2f16(<2 x half>
-// SPIR_NATIVE_HALF: call <2 x half> @llvm.spv.normalize.v2f16(<2 x half>
-// DXIL_NO_HALF: call <2 x float> @llvm.dx.normalize.v2f32(<2 x float>
-// SPIR_NO_HALF: call <2 x float> @llvm.spv.normalize.v2f32(<2 x float>
+// NATIVE_HALF: define [[FNATTRS]] <2 x half> @
+// NATIVE_HALF: call <2 x half> @llvm.[[TARGET]].normalize.v2f16(<2 x half>
+// NO_HALF: call <2 x float> @llvm.[[TARGET]].normalize.v2f32(<2 x float>
 // NATIVE_HALF: ret <2 x half> %hlsl.normalize
 // NO_HALF: ret <2 x float> %hlsl.normalize
 half2 test_normalize_half2(half2 p0)
 {
 return normalize(p0);
 }
-// DXIL_NATIVE_HALF: define noundef <3 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <3 x half> @
-// DXIL_NATIVE_HALF: call <3 x half> @llvm.dx.normalize.v3f16(<3 x half>
-// SPIR_NATIVE_HALF: call <3 x half> @llvm.spv.normalize.v3f16(<3 x half>
-// DXIL_NO_HALF: call <3 x float> @llvm.dx.normalize.v3f32(<3 x float>
-// SPIR_NO_HALF: call <3 x float> @llvm.spv.normalize.v3f32(<3 x float>
+// NATIVE_HALF: define [[FNATTRS]] <3 x half> @
+// NATIVE_HALF: call <3 x half> @llvm.[[TARGET]].normalize.v3f16(<3 x half>
+// NO_HALF: call <3 x float> @llvm.[[TARGET]].normalize.v3f32(<3 x float>
 // NATIVE_HALF: ret <3 x half> %hlsl.normalize
 // NO_HALF: ret <3 x float> %hlsl.normalize
 half3 test_normalize_half3(half3 p0)
 {
 return normalize(p0);
 }
-// DXIL_NATIVE_HALF: define noundef <4 x half> @
-// SPIR_NATIVE_HALF: define spir_func noundef <4 x half> @
-// DXIL_NATIVE_HALF: call <4 x half> @llvm.dx.normalize.v4f16(<4 x half>
-// SPIR_NATIVE_HALF: call <4 x half> @llvm.spv.normalize.v4f16(<4 x half>
-// DXIL_NO_HALF: call <4 x float> @llvm.dx.normalize.v4f32(<4 x float>
-// SPIR_NO_HALF: call <4 x float> @llvm.spv.normalize.v4f32(<4 x float>
+// NATIVE_HALF: define [[FNATTRS]] <4 x half> @
+// NATIVE_HALF: call <4 x half> @llvm.[[TARGET]].normalize.v4f16(<4 x half>
+// NO_HALF: call <4 x float> @llvm.[[TARGET]].normalize.v4f32(<4 x float>
 // NATIVE_HALF: ret <4 x half> %hlsl.normalize
 // NO_HALF: ret <4 x float> %hlsl.normalize
 half4 test_normalize_half4(half4 p0)
 {
 return normalize(p0);
 }
 
-// DXIL_CHECK: define noundef float @
-// SPIR_CHECK: define spir_func noundef float @
-// DXIL_CHECK: call float @llvm.dx.normalize.f32(float
-// SPIR_CHECK: call float @llvm.spv.normalize.f32(float
+// CHECK: define [[FNATTRS]] float @
+// CHECK: call float @llvm.[[TARGET]].normalize.f32(float
 // CHECK: ret float
 float test_normalize_float(float p0)
 {
 return normalize(p0);
 }
-// DXIL_CHECK: define noundef <2 x float> @
-// SPIR_CHECK: define spir_func noundef <2 x float> @
-// DXIL_CHECK: %hlsl.normalize = call <2 x float> @llvm.dx.normalize.v2f32(
-// SPIR_CHECK: %

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-28 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 67beeaf5cf48372351e914519e7b0af3b94769b1 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../builtins/RWBuffer-constructor.hlsl|   2 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 268 ++
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 264 ++---
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  84 +++---
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  58 ++--
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  73 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  84 +++---
 .../semantics/DispatchThreadID.hlsl   |  14 +-
 8 files changed, 307 insertions(+), 540 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..baddfcf2cf1d52 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -9,4 +9,4 @@ RWBuffer Buf;
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
 // CHECK-SPIRV: %[[HandleRes:[0-9]+]] = call ptr @llvm.spv.create.handle(i8 1)
-// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
+// CHECK-SPIRV: store ptr %[[HandleRes]], ptr %h, align 8
\ No newline at end of file
diff --git a/clang/test/CodeGenHLSL/builtins/all.hlsl 
b/clang/test/CodeGenHLSL/builtins/all.hlsl
index b48daa287480ff..39f364c5953d60 100644
--- a/clang/test/CodeGenHLSL/builtins/all.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/all.hlsl
@@ -1,277 +1,193 @@
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,SPIR_NATIVE_HALF,SPIR_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,SPIR_NO_HALF,SPIR_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS="spir_func noundef" -DTARGET=spv
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ 
-// RUN:   --check-prefixes=CHECK,NATIVE_HALF,DXIL_NATIVE_HALF,DXIL_CHECK
+// RUN:   --check-prefixes=CHECK,NATIVE_HALF \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 // RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK,DXIL_NO_HALF,DXIL_CHECK
+// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
+// RUN:   -DFNATTRS=noundef -DTARGET=dx
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t(int16_t p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v2i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v2i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v2i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t2(int16_t2 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v3i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v3i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v3i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t3(int16_t3 p0) { return all(p0); }
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.all = call i1 @llvm.dx.all.v4i16
-// SPIR_NATIVE_HALF: %hlsl.all = call i1 @llvm.spv.all.v4i16
+// NATIVE_HALF: define [[FNATTRS]] i1 @
+// NATIVE_HALF: %hlsl.all = call i1 @llvm.[[TARGET]].all.v4i16
 // NATIVE_HALF: ret i1 %hlsl.all
 bool test_all_int16_t4(int16_t4 p0) { return all(p0); }
-
-// DXIL_NATIVE_HALF: define noundef i1 @
-// SPIR_NATIVE_HALF: define spir_func noundef i1 @
-// DXIL_NATIVE_HALF: %hlsl.

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-28 Thread Amr Hesham via cfe-commits


@@ -15,49 +15,49 @@
 // RUN:   -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF,SPIR_CHECK
 
 #ifdef __HLSL_ENABLE_16_BIT
-// DXIL_NATIVE_HALF: %dx.umad = call i16 @llvm.dx.umad.i16(i16 %0, i16 %1, i16 
%2)
+// DXIL_NATIVE_HALF: %dx.umad = call i16 @llvm.[[ICF:dx]].umad.i16(i16 %0, i16 
%1, i16 %2)

AmrDeveloper wrote:

Done

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-28 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> Looks great, thanks! Do you need someone to commit this for you?

Yes please, i don't have commit access yet :D

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-18 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/104717

Increase the default expression nesting limit from 256 to 1024

Fixes: #94728

Compile time with different Bracket depth

Clang version 20.0.0git (https://github.com/AmrDeveloper/llvm-project.git 
673b9e08de8a661c9deed2ee497889312f059f3d)
Target: arm64-apple-darwin23.5.0

Bracket depth = 256, time = 0.243
Bracket depth = 512, time = 0.329
Bracket depth = 1024, time = 0.489
Bracket depth = 2048, time = 0.851

>From ba301df0e8fc84243a994ddcd36becb16f34b32c Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 18 Aug 2024 20:05:38 +0200
Subject: [PATCH] [clang] Increase the default expression nesting limit

Increase the default expression nesting limit from 256 to 1024
---
 clang/include/clang/Driver/Options.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cfd9e595c55178..3a0054fdafc638 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7959,7 +7959,7 @@ def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-
   MarshallingInfoFlag>;
 def fbracket_depth : Separate<["-"], "fbracket-depth">,
   HelpText<"Maximum nesting level for parentheses, brackets, and braces">,
-  MarshallingInfoInt, "256">;
+  MarshallingInfoInt, "1024">;
 defm const_strings : BoolOption<"f", "const-strings",
   LangOpts<"ConstStrings">, DefaultFalse,
   PosFlag,

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-18 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/104717

>From 8add317c1997297980a5cda12ee750f4bc24e31f Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 18 Aug 2024 20:05:38 +0200
Subject: [PATCH] [clang] Increase the default expression nesting limit

Increase the default expression nesting limit from 256 to 1024
---
 clang/include/clang/Driver/Options.td | 2 +-
 clang/test/Parser/parser_overflow.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cfd9e595c55178..3a0054fdafc638 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7959,7 +7959,7 @@ def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-
   MarshallingInfoFlag>;
 def fbracket_depth : Separate<["-"], "fbracket-depth">,
   HelpText<"Maximum nesting level for parentheses, brackets, and braces">,
-  MarshallingInfoInt, "256">;
+  MarshallingInfoInt, "1024">;
 defm const_strings : BoolOption<"f", "const-strings",
   LangOpts<"ConstStrings">, DefaultFalse,
   PosFlag,
diff --git a/clang/test/Parser/parser_overflow.c 
b/clang/test/Parser/parser_overflow.c
index 9514e808550a4b..8c215af196bcb0 100644
--- a/clang/test/Parser/parser_overflow.c
+++ b/clang/test/Parser/parser_overflow.c
@@ -1,5 +1,5 @@
 // RUN: not %clang_cc1 %s -fsyntax-only -DHUGE 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: not %clang_cc1 %s -fsyntax-only -fbracket-depth 299 2>&1 | FileCheck %s
 // RUN: %clang_cc1 %s -fsyntax-only -fbracket-depth 300
 // RUN: not %clang %s -fsyntax-only -fbracket-depth=299 2>&1 | FileCheck %s
@@ -15,5 +15,5 @@ void foo(void) {
 #endif
 }
 
-// CHECK: fatal error: bracket nesting level exceeded maximum of {{256|299}}
+// CHECK: fatal error: bracket nesting level exceeded maximum of {{1024|299}}
 // CHECK: note: use -fbracket-depth=N to increase maximum nesting level

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-18 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/104717

>From 6635b518d0413273831dc730b89b27780c6f2419 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 18 Aug 2024 20:05:38 +0200
Subject: [PATCH] [clang] Increase the default expression nesting limit

Increase the default expression nesting limit from 256 to 1024
---
 clang/include/clang/Driver/Options.td | 2 +-
 clang/test/Parser/parser_overflow.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cfd9e595c55178..3a0054fdafc638 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7959,7 +7959,7 @@ def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-
   MarshallingInfoFlag>;
 def fbracket_depth : Separate<["-"], "fbracket-depth">,
   HelpText<"Maximum nesting level for parentheses, brackets, and braces">,
-  MarshallingInfoInt, "256">;
+  MarshallingInfoInt, "1024">;
 defm const_strings : BoolOption<"f", "const-strings",
   LangOpts<"ConstStrings">, DefaultFalse,
   PosFlag,
diff --git a/clang/test/Parser/parser_overflow.c 
b/clang/test/Parser/parser_overflow.c
index 9514e808550a4b..51e2b6437d731e 100644
--- a/clang/test/Parser/parser_overflow.c
+++ b/clang/test/Parser/parser_overflow.c
@@ -1,5 +1,5 @@
 // RUN: not %clang_cc1 %s -fsyntax-only -DHUGE 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -fsyntax-only
 // RUN: not %clang_cc1 %s -fsyntax-only -fbracket-depth 299 2>&1 | FileCheck %s
 // RUN: %clang_cc1 %s -fsyntax-only -fbracket-depth 300
 // RUN: not %clang %s -fsyntax-only -fbracket-depth=299 2>&1 | FileCheck %s
@@ -15,5 +15,5 @@ void foo(void) {
 #endif
 }
 
-// CHECK: fatal error: bracket nesting level exceeded maximum of {{256|299}}
+// CHECK: fatal error: bracket nesting level exceeded maximum of {{1024|299}}
 // CHECK: note: use -fbracket-depth=N to increase maximum nesting level

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-18 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

@AaronBallman 

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-19 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/104717

>From 42eee38e3139110ad95bde697c38b23046dd2c77 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sun, 18 Aug 2024 20:05:38 +0200
Subject: [PATCH] [clang] Increase the default expression nesting limit

Increase the default expression nesting limit from 256 to 1024
---
 clang/docs/ReleaseNotes.rst   | 2 ++
 clang/include/clang/Driver/Options.td | 2 +-
 clang/test/Parser/parser_overflow.c   | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b78c0229de4898..023c3650497353 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -174,6 +174,8 @@ Deprecated Compiler Flags
 Modified Compiler Flags
 ---
 
+- The compiler flag `-fbracket-depth` default value is increased from 256 to 
2048.
+
 Removed Compiler Flags
 -
 
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cfd9e595c55178..c66e035a259b3f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7959,7 +7959,7 @@ def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-
   MarshallingInfoFlag>;
 def fbracket_depth : Separate<["-"], "fbracket-depth">,
   HelpText<"Maximum nesting level for parentheses, brackets, and braces">,
-  MarshallingInfoInt, "256">;
+  MarshallingInfoInt, "2048">;
 defm const_strings : BoolOption<"f", "const-strings",
   LangOpts<"ConstStrings">, DefaultFalse,
   PosFlag,
diff --git a/clang/test/Parser/parser_overflow.c 
b/clang/test/Parser/parser_overflow.c
index 9514e808550a4b..53c79bc06d993d 100644
--- a/clang/test/Parser/parser_overflow.c
+++ b/clang/test/Parser/parser_overflow.c
@@ -1,5 +1,5 @@
 // RUN: not %clang_cc1 %s -fsyntax-only -DHUGE 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang_cc1 %s -fsyntax-only
 // RUN: not %clang_cc1 %s -fsyntax-only -fbracket-depth 299 2>&1 | FileCheck %s
 // RUN: %clang_cc1 %s -fsyntax-only -fbracket-depth 300
 // RUN: not %clang %s -fsyntax-only -fbracket-depth=299 2>&1 | FileCheck %s
@@ -15,5 +15,5 @@ void foo(void) {
 #endif
 }
 
-// CHECK: fatal error: bracket nesting level exceeded maximum of {{256|299}}
+// CHECK: fatal error: bracket nesting level exceeded maximum of {{2048|299}}
 // CHECK: note: use -fbracket-depth=N to increase maximum nesting level

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-19 Thread Amr Hesham via cfe-commits


@@ -7959,7 +7959,7 @@ def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-
   MarshallingInfoFlag>;
 def fbracket_depth : Separate<["-"], "fbracket-depth">,
   HelpText<"Maximum nesting level for parentheses, brackets, and braces">,
-  MarshallingInfoInt, "256">;
+  MarshallingInfoInt, "1024">;

AmrDeveloper wrote:

Done

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


[clang] [clang] Increase the default expression nesting limit (PR #104717)

2024-08-20 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> Hello! Looks like increasing the max depth makes the debug build stack 
> overflow. In release builds, `clang/test/Parser/parser_overflow.c` is fine, 
> but in debug builds, the stack size reaches my OS limit (8MB) and crashes. 
> Shall the max depth be reduced a bit?

@AaronBallman should we back to the 1024 option?

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-24 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/105930

Update all hybird DXIL/SPIRV codegen tests to use temp variable representing 
interchange target

Fixes: #105710

>From 6f7b394dc573dfb2c9ce68b5ff8ec3a933830225 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../GlobalConstructorFunction.hlsl|   2 +-
 .../test/CodeGenHLSL/GlobalConstructors.hlsl  |   2 +-
 clang/test/CodeGenHLSL/GlobalDestructors.hlsl |   2 +-
 .../builtins/RWBuffer-constructor.hlsl|   9 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 176 +-
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 176 +-
 .../CodeGenHLSL/builtins/clamp-builtin.hlsl   |   2 +-
 clang/test/CodeGenHLSL/builtins/clamp.hlsl|  80 
 .../CodeGenHLSL/builtins/create_handle.hlsl   |   2 +-
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  48 ++---
 clang/test/CodeGenHLSL/builtins/isinf.hlsl|  24 +--
 clang/test/CodeGenHLSL/builtins/length.hlsl   |  18 +-
 .../CodeGenHLSL/builtins/lerp-builtin.hlsl|   4 +-
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  60 +++---
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  48 ++---
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  48 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  48 ++---
 clang/test/CodeGenHLSL/builtins/saturate.hlsl |  64 +++
 .../semantics/DispatchThreadID.hlsl   |  12 +-
 .../semantics/GroupIndex-codegen.hlsl |   2 +-
 20 files changed, 414 insertions(+), 413 deletions(-)

diff --git a/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl 
b/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
index f954c9d2f029f2..6856cccb3fc3eb 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
@@ -25,7 +25,7 @@ void main(unsigned GI : SV_GroupIndex) {}
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @"?call_me_first@@YAXXZ"()
 //CHECK-NEXT:   call void @"?then_call_me@@YAXXZ"()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()
 //CHECK-NEXT:   call void @"?main@@YAXI@Z"(i32 %0)
 //CHECK-NEXT:   call void @"?call_me_last@@YAXXZ"(
 //CHECK-NEXT:   ret void
diff --git a/clang/test/CodeGenHLSL/GlobalConstructors.hlsl 
b/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
index 7e2f288726c954..676a24b2467c18 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
@@ -11,6 +11,6 @@ void main(unsigned GI : SV_GroupIndex) {}
 //CHECK:  define void @main()
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @_GLOBAL__sub_I_GlobalConstructors.hlsl()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()
 //CHECK-NEXT:   call void @"?main@@YAXI@Z"(i32 %0)
 //CHECK-NEXT:   ret void
diff --git a/clang/test/CodeGenHLSL/GlobalDestructors.hlsl 
b/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
index 24c3c039fc6192..d98a54bbc49fe8 100644
--- a/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
@@ -52,7 +52,7 @@ void main(unsigned GI : SV_GroupIndex) {
 //CHECK:  define void @main()
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @_GLOBAL__sub_I_GlobalDestructors.hlsl()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()
 //CHECK-NEXT:   call void @"?main@@YAXI@Z"(i32 %0)
 //CHECK-NEXT:   call void @_GLOBAL__D_a()
 //CHECK-NEXT:   ret void
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..1a2e9aa490709c 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,12 +1,13 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK
 
 RWBuffer Buf;
 
 // CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
 // CHECK-NEXT: entry:
 
-// CHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// DXCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.[[ICF:dx]].create.handle(i8 
1)
+// SPVCHECK: %[[HandleRes:[0-9]+]] = call ptr 
@llvm.[[ICF:spv]].crea

[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-24 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

@pow2clk 

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


[clang] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use temp var (PR #105930)

2024-08-24 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/105930

>From 4568aab8bfd39be10a3df69535e083f3429e3a9e Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 24 Aug 2024 10:08:23 +0200
Subject: [PATCH] [clang][HLSL] Update DXIL/SPIRV hybird CodeGen tests to use
 temp var

Update all hybird DXIL/SPIRV codegen tests to use temp variable
representing interchange target
---
 .../GlobalConstructorFunction.hlsl|   2 +-
 .../test/CodeGenHLSL/GlobalConstructors.hlsl  |   2 +-
 clang/test/CodeGenHLSL/GlobalDestructors.hlsl |   2 +-
 .../builtins/RWBuffer-constructor.hlsl|   9 +-
 clang/test/CodeGenHLSL/builtins/all.hlsl  | 176 +-
 clang/test/CodeGenHLSL/builtins/any.hlsl  | 176 +-
 .../CodeGenHLSL/builtins/clamp-builtin.hlsl   |   2 +-
 clang/test/CodeGenHLSL/builtins/clamp.hlsl|  80 
 .../CodeGenHLSL/builtins/create_handle.hlsl   |   2 +-
 clang/test/CodeGenHLSL/builtins/frac.hlsl |  48 ++---
 clang/test/CodeGenHLSL/builtins/isinf.hlsl|  24 +--
 clang/test/CodeGenHLSL/builtins/length.hlsl   |  18 +-
 .../CodeGenHLSL/builtins/lerp-builtin.hlsl|   4 +-
 clang/test/CodeGenHLSL/builtins/lerp.hlsl |  60 +++---
 clang/test/CodeGenHLSL/builtins/mad.hlsl  |  48 ++---
 .../test/CodeGenHLSL/builtins/normalize.hlsl  |  48 ++---
 clang/test/CodeGenHLSL/builtins/rsqrt.hlsl|  48 ++---
 clang/test/CodeGenHLSL/builtins/saturate.hlsl |  64 +++
 .../semantics/DispatchThreadID.hlsl   |  12 +-
 .../semantics/GroupIndex-codegen.hlsl |   2 +-
 20 files changed, 414 insertions(+), 413 deletions(-)

diff --git a/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl 
b/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
index f954c9d2f029f2..6856cccb3fc3eb 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
@@ -25,7 +25,7 @@ void main(unsigned GI : SV_GroupIndex) {}
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @"?call_me_first@@YAXXZ"()
 //CHECK-NEXT:   call void @"?then_call_me@@YAXXZ"()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()
 //CHECK-NEXT:   call void @"?main@@YAXI@Z"(i32 %0)
 //CHECK-NEXT:   call void @"?call_me_last@@YAXXZ"(
 //CHECK-NEXT:   ret void
diff --git a/clang/test/CodeGenHLSL/GlobalConstructors.hlsl 
b/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
index 7e2f288726c954..676a24b2467c18 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
@@ -11,6 +11,6 @@ void main(unsigned GI : SV_GroupIndex) {}
 //CHECK:  define void @main()
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @_GLOBAL__sub_I_GlobalConstructors.hlsl()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()
 //CHECK-NEXT:   call void @"?main@@YAXI@Z"(i32 %0)
 //CHECK-NEXT:   ret void
diff --git a/clang/test/CodeGenHLSL/GlobalDestructors.hlsl 
b/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
index 24c3c039fc6192..d98a54bbc49fe8 100644
--- a/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
@@ -52,7 +52,7 @@ void main(unsigned GI : SV_GroupIndex) {
 //CHECK:  define void @main()
 //CHECK-NEXT: entry:
 //CHECK-NEXT:   call void @_GLOBAL__sub_I_GlobalDestructors.hlsl()
-//CHECK-NEXT:   %0 = call i32 @llvm.dx.flattened.thread.id.in.group()
+//CHECK-NEXT:   %0 = call i32 @llvm.[[ICF:dx]].flattened.thread.id.in.group()
 //CHECK-NEXT:   call void @"?main@@YAXI@Z"(i32 %0)
 //CHECK-NEXT:   call void @_GLOBAL__D_a()
 //CHECK-NEXT:   ret void
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl 
b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index e51eac7f57c2d3..1a2e9aa490709c 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,12 +1,13 @@
-// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=DXCHECK
+
+// RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm 
-disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=SPVCHECK
 
 RWBuffer Buf;
 
 // CHECK: define linkonce_odr noundef ptr @"??0?$RWBuffer@M@hlsl@@QAA@XZ"
 // CHECK-NEXT: entry:
 
-// CHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.dx.create.handle(i8 1)
+// DXCHECK: %[[HandleRes:[0-9]+]] = call ptr @llvm.[[ICF:dx]].create.handle(i8 
1)
+// SPVCHECK: %[[HandleRes:[0-9]+]] = call ptr 
@llvm.[[ICF:spv]].create.handle(i8 1)
 // CHECK: store ptr %[[HandleRes]], ptr %h, align 4
 
-// CHECK-SPIRV: %[[HandleRes:[0-9]+]] = ca

[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From dea97ae4f893774489bfd423e9536e486f022bb9 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 6 +++---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++
 clang/test/SemaObjCXX/noescape.mm  | 2 +-
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..3a5bd3be43ee64 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. We skip dependence By default, we look through references
+  /// (the behavior used by nonnull), but if the second parameter is true, then
+  /// we treat a reference type as valid..
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..e709c936735c74 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return 
values that are pointers or references}}
+int atest6(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();
diff --git a/clang/test/SemaObjCXX/noescape.mm 
b/clang/test/SemaObjCXX/noescape.mm
index 4b52164dffd3da..cdcad07feb2bc8 100644
--- a/clang/test/SemaObjCXX/noescape.mm
+++ b/clang/test/SemaObjCXX/noescape.mm
@@ -17,7 +17,7 @@
 void noescapeFunc2(int *); // expected-error {{conflicting types for 
'noescapeFunc2'}}
 
 template 
-void noescapeFunc5(__attribute__((noescape)) T); // expected-warning 
{{'noescape' attribute only applies to pointer arguments}}
+void noescapeFunc5(__attribute__((noescape)) T);
 template 
 void noescapeFunc6(__attribute__((noescape)) const T &);
 template 

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits


@@ -1217,6 +1217,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
   if (RefOkay) {
+if (T->isDependentType())

AmrDeveloper wrote:

Think you, updated

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From 076c867c16141f2c1b78c55fd78250155c0d97fd Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/lib/Sema/SemaDeclAttr.cpp| 2 ++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..f3ed556faba778 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..4459580cdccc5d 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,9 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits


@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. By default, we skip dependence and look through references

AmrDeveloper wrote:

Thank you, all comments addressed

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> > This part in ObjectiveC tests conflict with the current solution, any 
> > suggestion how we can go around it right now until to be handled later
> > https://github.com/llvm/llvm-project/blob/18952bdcd6f987620e6396261c2bb444e428e07e/clang/test/SemaObjCXX/noescape.mm#L202-L205
> > 
> > @erichkeane @AaronBallman
> 
> Doesn't the fixme above that say it was diagnosing unintentionally? If so, 
> that fixme likely needs to be removed, and this is 'correct' now.

Yes but still got `call to deleted constructor of 'S6'` and `'S6' has been 
explicitly marked deleted here` errors on CI and local

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits


@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. We skip dependence By default, we look through references

AmrDeveloper wrote:

Yes, i think i was planning to make it like `We skip dependence and By default,`

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From 3e83fd9e73520bfeefd5a39da6daad172cfb2512 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 6 +++---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++
 clang/test/SemaCXX/noescape-attr.cpp   | 7 +++
 clang/test/SemaObjCXX/noescape.mm  | 2 +-
 6 files changed, 24 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/SemaCXX/noescape-attr.cpp

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..d0f8d4b417f2c6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. We skip dependence then By default, we look through 
references
+  /// (the behavior used by nonnull), but if the second parameter is true, then
+  /// we treat a reference type as valid..
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp 
b/clang/test/SemaCXX/alloc-align-attr.cpp
index 79095f8d985147..5a40e8d8fb6b56 100644
--- a/clang/test/SemaCXX/alloc-align-attr.cpp
+++ b/clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,6 +23,9 @@ void* dependent_param_func(T param) 
__attribute__((alloc_align(1)));// expected-
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // 
expected-error {{'alloc_align' attribute requires parameter 1 to be an integer 
constant}}
 
+template 
+T dependent_return_type(int p) __attribute__((alloc_align(1)));
+
 void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 
'dependent_ret' requested here}}
   a.Foo(1);
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..e709c936735c74 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return 
values that are pointers or references}}
+int atest6(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();
diff --git a/clang/test/SemaCXX/noescape-attr.cpp 
b/clang/test/SemaCXX/noescape-attr.cpp
new file mode 100644
index 00..78dc4f07ffef87
--- /dev/null
+++ b/clang/test/SemaCXX/noescape-attr.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+void test1(T __attribute__((noescape)) arr, int size);
+
+// expected-warning@+1 {{'noescape' attribute only applie

[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From d3f853895e806ebe2370dafdc628a21d0d4184a6 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 6 +++---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++
 clang/test/SemaCXX/noescape-attr.cpp   | 7 +++
 clang/test/SemaObjCXX/noescape.mm  | 7 +++
 6 files changed, 26 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/SemaCXX/noescape-attr.cpp

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..d0f8d4b417f2c6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. We skip dependence then By default, we look through 
references
+  /// (the behavior used by nonnull), but if the second parameter is true, then
+  /// we treat a reference type as valid..
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp 
b/clang/test/SemaCXX/alloc-align-attr.cpp
index 79095f8d985147..5a40e8d8fb6b56 100644
--- a/clang/test/SemaCXX/alloc-align-attr.cpp
+++ b/clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,6 +23,9 @@ void* dependent_param_func(T param) 
__attribute__((alloc_align(1)));// expected-
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // 
expected-error {{'alloc_align' attribute requires parameter 1 to be an integer 
constant}}
 
+template 
+T dependent_return_type(int p) __attribute__((alloc_align(1)));
+
 void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 
'dependent_ret' requested here}}
   a.Foo(1);
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..e709c936735c74 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return 
values that are pointers or references}}
+int atest6(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();
diff --git a/clang/test/SemaCXX/noescape-attr.cpp 
b/clang/test/SemaCXX/noescape-attr.cpp
new file mode 100644
index 00..78dc4f07ffef87
--- /dev/null
+++ b/clang/test/SemaCXX/noescape-attr.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+void test1(T __attribute__((noescape)) arr, int size);
+
+// expected-warning@+1 {{'noescape' attribute only 

[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> > This part in ObjectiveC tests conflict with the current solution, any 
> > suggestion how we can go around it right now until to be handled later
> > https://github.com/llvm/llvm-project/blob/18952bdcd6f987620e6396261c2bb444e428e07e/clang/test/SemaObjCXX/noescape.mm#L202-L205
> > 
> > @erichkeane @AaronBallman
> 
> Doesn't the fixme above that say it was diagnosing unintentionally? If so, 
> that fixme likely needs to be removed, and this is 'correct' now.

I handled it, i didn't know that `// expected-note n` is the number of expected 
notes, 

Thank you

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From a0066f706b1173afe573ddd5f79cb5c8916a19cf Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 7 ---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++
 clang/test/SemaCXX/noescape-attr.cpp   | 7 +++
 clang/test/SemaObjCXX/noescape.mm  | 7 +++
 6 files changed, 27 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/SemaCXX/noescape-attr.cpp

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..fea100e81f3efd 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,10 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. Dependent types are considered valid, so they can be checked
+  /// during instantiation time. By default, we look through references (the
+  /// behavior used by nonnull), but if the second parameter is true, then we
+  /// treat a reference type as valid..
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp 
b/clang/test/SemaCXX/alloc-align-attr.cpp
index 79095f8d985147..5a40e8d8fb6b56 100644
--- a/clang/test/SemaCXX/alloc-align-attr.cpp
+++ b/clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,6 +23,9 @@ void* dependent_param_func(T param) 
__attribute__((alloc_align(1)));// expected-
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // 
expected-error {{'alloc_align' attribute requires parameter 1 to be an integer 
constant}}
 
+template 
+T dependent_return_type(int p) __attribute__((alloc_align(1)));
+
 void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 
'dependent_ret' requested here}}
   a.Foo(1);
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..e709c936735c74 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return 
values that are pointers or references}}
+int atest6(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();
diff --git a/clang/test/SemaCXX/noescape-attr.cpp 
b/clang/test/SemaCXX/noescape-attr.cpp
new file mode 100644
index 00..78dc4f07ffef87
--- /dev/null
+++ b/clang/test/SemaCXX/noescape-attr.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+void test1(T __attribute__((noescape)

[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From 0f1405efdbb6a9bc24c878346d96ae6720771a44 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 7 ---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++
 clang/test/SemaCXX/noescape-attr.cpp   | 7 +++
 clang/test/SemaObjCXX/noescape.mm  | 7 +++
 6 files changed, 27 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/SemaCXX/noescape-attr.cpp

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..6931f50202162c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,10 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. Dependent types are considered valid so they can be checked
+  /// during instantiation time. By default, we look through references (the
+  /// behavior used by nonnull), but if the second parameter is true, then we
+  /// treat a reference type as valid.
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp 
b/clang/test/SemaCXX/alloc-align-attr.cpp
index 79095f8d985147..5a40e8d8fb6b56 100644
--- a/clang/test/SemaCXX/alloc-align-attr.cpp
+++ b/clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,6 +23,9 @@ void* dependent_param_func(T param) 
__attribute__((alloc_align(1)));// expected-
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // 
expected-error {{'alloc_align' attribute requires parameter 1 to be an integer 
constant}}
 
+template 
+T dependent_return_type(int p) __attribute__((alloc_align(1)));
+
 void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 
'dependent_ret' requested here}}
   a.Foo(1);
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..e709c936735c74 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return 
values that are pointers or references}}
+int atest6(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();
diff --git a/clang/test/SemaCXX/noescape-attr.cpp 
b/clang/test/SemaCXX/noescape-attr.cpp
new file mode 100644
index 00..78dc4f07ffef87
--- /dev/null
+++ b/clang/test/SemaCXX/noescape-attr.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+void test1(T __attribute__((noescape)) 

[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

This part in ObjectiveC tests conflict with the current solution, any 
suggestion how we can go around it right now until to be handled later

https://github.com/llvm/llvm-project/blob/18952bdcd6f987620e6396261c2bb444e428e07e/clang/test/SemaObjCXX/noescape.mm#L202-L205

@erichkeane @AaronBallman 

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/111573

Fix `assume_aligned` incorrectly diagnoses a dependent return type

Fixes: #111563

>From fd3247ecb2fb2c83e8441d082a446c85e6268146 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/lib/Sema/SemaDeclAttr.cpp| 2 ++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..c1d1ef31db6e92 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1217,6 +1217,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
   if (RefOkay) {
+if (T->isDependentType())
+  return true;
 if (T->isReferenceType())
   return true;
   } else {
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..4459580cdccc5d 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,9 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits


@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())

AmrDeveloper wrote:

Done, please check the updated documentation of the function

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From 4202153623dd64cec76b6ca9a08191ff884327a7 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 6 +++---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 3 +++
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..19e9392d2d5352 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. By default, we skip dependence and look through references
+  /// (the behavior used by nonnull), but if the second parameter is true, then
+  /// we treat a reference type as valid.
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..4459580cdccc5d 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,9 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();

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


[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-08 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/111573

>From 036f76530beca7f6fddae1460a5fd527a71bcf94 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Oct 2024 20:12:45 +0200
Subject: [PATCH] [clang] assume_aligned incorrectly diagnoses a dependent
 return type

---
 clang/include/clang/Sema/Sema.h| 6 +++---
 clang/lib/Sema/SemaDeclAttr.cpp| 7 ---
 clang/test/SemaCXX/alloc-align-attr.cpp| 3 +++
 clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp | 6 ++
 clang/test/SemaCXX/noescape-attr.cpp   | 7 +++
 clang/test/SemaObjCXX/noescape.mm  | 2 +-
 6 files changed, 24 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/SemaCXX/noescape-attr.cpp

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 7ff9c2754a6fe0..3a5bd3be43ee64 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4453,9 +4453,9 @@ class Sema final : public SemaBase {
   SourceLocation *ArgLocation = nullptr);
 
   /// Determine if type T is a valid subject for a nonnull and similar
-  /// attributes. By default, we look through references (the behavior used by
-  /// nonnull), but if the second parameter is true, then we treat a reference
-  /// type as valid.
+  /// attributes. We skip dependence By default, we look through references
+  /// (the behavior used by nonnull), but if the second parameter is true, then
+  /// we treat a reference type as valid..
   bool isValidPointerAttrType(QualType T, bool RefOkay = false);
 
   /// AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af983349a89b58..e2174ba926f17f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1216,6 +1216,8 @@ static void handlePreferredName(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
+  if (T->isDependentType())
+return true;
   if (RefOkay) {
 if (T->isReferenceType())
   return true;
@@ -1284,7 +1286,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
  I != E && !AnyPointers; ++I) {
   QualType T = getFunctionOrMethodParamType(D, I);
-  if (T->isDependentType() || S.isValidPointerAttrType(T))
+  if (S.isValidPointerAttrType(T))
 AnyPointers = true;
 }
 
@@ -1409,8 +1411,7 @@ void Sema::AddAllocAlignAttr(Decl *D, const 
AttributeCommonInfo &CI,
   AllocAlignAttr TmpAttr(Context, CI, ParamIdx());
   SourceLocation AttrLoc = CI.getLoc();
 
-  if (!ResultType->isDependentType() &&
-  !isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
+  if (!isValidPointerAttrType(ResultType, /* RefOkay */ true)) {
 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
 << &TmpAttr << CI.getRange() << 
getFunctionOrMethodResultSourceRange(D);
 return;
diff --git a/clang/test/SemaCXX/alloc-align-attr.cpp 
b/clang/test/SemaCXX/alloc-align-attr.cpp
index 79095f8d985147..5a40e8d8fb6b56 100644
--- a/clang/test/SemaCXX/alloc-align-attr.cpp
+++ b/clang/test/SemaCXX/alloc-align-attr.cpp
@@ -23,6 +23,9 @@ void* dependent_param_func(T param) 
__attribute__((alloc_align(1)));// expected-
 template 
 void* illegal_align_param(int p) __attribute__((alloc_align(T))); // 
expected-error {{'alloc_align' attribute requires parameter 1 to be an integer 
constant}}
 
+template 
+T dependent_return_type(int p) __attribute__((alloc_align(1)));
+
 void dependent_impl(int align) {
   dependent_ret a; // expected-note {{in instantiation of template class 
'dependent_ret' requested here}}
   a.Foo(1);
diff --git a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp 
b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
index 61b85557d6b294..e709c936735c74 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned-tmpl.cpp
@@ -52,6 +52,12 @@ T *atest3() __attribute__((assume_aligned(31, o))); // 
expected-error {{requeste
 template 
 T *atest4() __attribute__((assume_aligned(32, o)));
 
+template
+T atest5(int) __attribute__((assume_aligned(2)));
+
+// expected-warning@+1 {{'assume_aligned' attribute only applies to return 
values that are pointers or references}}
+int atest6(int) __attribute__((assume_aligned(2)));
+
 void test22() {
   atest3();
   atest4();
diff --git a/clang/test/SemaCXX/noescape-attr.cpp 
b/clang/test/SemaCXX/noescape-attr.cpp
new file mode 100644
index 00..78dc4f07ffef87
--- /dev/null
+++ b/clang/test/SemaCXX/noescape-attr.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template
+void test1(T __attribute__((noescape)) arr, int size);
+
+// expected-warning@+1 {{'noescape' attribute only applies to p

[clang] [clang] assume_aligned incorrectly diagnoses a dependent return type (PR #111573)

2024-10-09 Thread Amr Hesham via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-11-28 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/118031

Currently, we support `-wdeprecated-array-compare` for C++20 or above and don't 
report any warning for older versions, this PR supports `-Warray-compare` for 
older versions and for GCC compatibility.

Fixes #114770

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 1/4] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 2/4] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-11-28 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 1/6] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 2/6] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison always

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-11-28 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 1/5] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 2/5] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison always

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits


@@ -10264,6 +10264,10 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays compare their addresses and will be 
deprecated in c++20; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">;

AmrDeveloper wrote:

I think i misunderstood inlining diagnostic here, can you give me example about 
how inline it

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

All comments are addressed, please take a second look. 

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 01/12] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 02/12] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison al

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits


@@ -702,6 +702,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;

AmrDeveloper wrote:

Done, thanks

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 1/8] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 2/8] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison always

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

@shafik, @cor3ntin For C++26 there is already an issue and discussion their and 
i will handle it after landing this PR

https://github.com/llvm/llvm-project/issues/117859

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits


@@ -10264,6 +10264,10 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays compare their addresses and will be 
deprecated in c++20; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">;

AmrDeveloper wrote:

Cool i found `InGroup>` thanks, for release note i think 
`array-comparion` i think it be under New Compiler Flags

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits


@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "

AmrDeveloper wrote:

I think "comparison between two arrays compare their addresses and will be 
deprecated in c++20" is good for array-compare and we keep deprecated array 
compare as it is

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 01/11] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 02/11] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison al

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 01/10] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 02/10] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison al

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 1/8] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 2/8] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison always

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-02 Thread Amr Hesham via cfe-commits


@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "

AmrDeveloper wrote:

I am thinking to improve the diagnostic message for both array-compare and 
deprecated array compare and to be the same

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-03 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/118031

>From 9451a1e4f5db18d579b5f7eb206482708c9adc70 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 26 Nov 2024 22:28:16 +0100
Subject: [PATCH 1/7] Add support for '-Warray-compare' compiler flag

---
 clang/include/clang/Basic/DiagnosticGroups.td|  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  5 +
 clang/lib/Sema/SemaExpr.cpp  | 14 ++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index df9bf94b5d0398..0b57d41c617963 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -699,6 +699,7 @@ def GNUStatementExpressionFromMacroExpansion :
 def GNUStatementExpression : DiagGroup<"gnu-statement-expression",

[GNUStatementExpressionFromMacroExpansion]>;
 def StringConcatation : DiagGroup<"string-concatenation">;
+def ArrayCompare : DiagGroup<"array-compare">;
 def StringCompare : DiagGroup<"string-compare">;
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 834e588c18e376..a96fddcc797d36 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10264,6 +10264,11 @@ def warn_depr_array_comparison : Warning<
   "to compare array addresses, use unary '+' to decay operands to pointers">,
   InGroup;
 
+def warn_array_comparison : Warning<
+  "comparison between two arrays; "
+  "to compare array addresses, use unary '+' to decay operands to pointers">,
+  InGroup;
+
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
   "unspecified (use an explicit string comparison function instead)">,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c9d7444d5865a5..d51aca4fbaf492 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11857,11 +11857,17 @@ static void diagnoseTautologicalComparison(Sema &S, 
SourceLocation Loc,
   // C++2a [depr.array.comp]:
   //   Equality and relational comparisons ([expr.eq], [expr.rel]) between two
   //   operands of array type are deprecated.
-  if (S.getLangOpts().CPlusPlus20 && LHSStripped->getType()->isArrayType() &&
+  if (LHSStripped->getType()->isArrayType() &&
   RHSStripped->getType()->isArrayType()) {
-S.Diag(Loc, diag::warn_depr_array_comparison)
-<< LHS->getSourceRange() << RHS->getSourceRange()
-<< LHSStripped->getType() << RHSStripped->getType();
+auto IsDeprArrayComparionIgnored =
+S.getDiagnostics().isIgnored(diag::warn_depr_array_comparison, Loc);
+auto IsDeprArrayComparion =
+!S.getLangOpts().CPlusPlus20 || IsDeprArrayComparionIgnored;
+
+auto DiagID = IsDeprArrayComparion ? diag::warn_array_comparison
+   : diag::warn_depr_array_comparison;
+S.Diag(Loc, DiagID) << LHS->getSourceRange() << RHS->getSourceRange()
+<< LHSStripped->getType() << RHSStripped->getType();
 // Carry on to produce the tautological comparison warning, if this
 // expression is potentially-evaluated, we can resolve the array to a
 // non-weak declaration, and so on.

>From 6de4cba4dc9edae545efe85d2435d1f4430968af Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Wed, 27 Nov 2024 21:17:21 +0100
Subject: [PATCH 2/7] Add lit test for array-comparison

---
 clang/test/SemaCXX/deprecated.cpp| 12 +++-
 clang/test/SemaCXX/warn-self-comparisons.cpp |  6 +++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index 667f4d7d3edb03..03f3b2b8ff06be 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -246,17 +246,19 @@ namespace ArithConv {
 
 namespace ArrayComp {
   int arr1[3], arr2[4];
-  bool b1 = arr1 == arr2; // expected-warning {{array comparison always 
evaluates to false}} cxx20-warning {{comparison between two arrays is 
deprecated}}
-  bool b2 = arr1 < arr2; // expected-warning {{array comparison always 
evaluates to a constant}} cxx20-warning {{comparison between two arrays is 
deprecated}}
+  bool b1 = arr1 == arr2; // not-cxx20-warning {{comparison between two 
arrays}} cxx20-warning {{comparison between two arrays is deprecated}}
+  // expected-warning@-1 {{array comparison always 
evaluates to false}} 
+  bool b2 = arr1 < arr2; // not-cxx20-warning {{comparison between two 
arrays;}} cxx20-warning {{comparison between two arrays is deprecated}}
+ // expected-warning@-1 {{array comparison always

[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-04 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

Should we merge now? @cor3ntin @AaronBallman @erichkeane @shafik 

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-04 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> yes. do you need me to do it?

Thanks, i will merge now :D

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


[clang] [Clang] Add '-Warray-compare' flag for C++ below version 20 (PR #118031)

2024-12-04 Thread Amr Hesham via cfe-commits

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


[clang] [clang-tools-extra] [Clang] Warning as error Array Comparisons from C++26 (PR #118872)

2024-12-07 Thread Amr Hesham via cfe-commits

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-06 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> > We can also create a new matcher for `dependentNameType` so we can use it 
> > like `dependentNameType(hasDependentType(builtinType()))`, which is similar 
> > to Complex and Array types.
> 
> I don't think `DependentNameType` has a `Type` property that we could match 
> in this way; the idea behind `DependentNameType` is that resolving it to a 
> concrete `Type` needs to be deferred until after instantiation when the 
> dependent name can be looked up.
> 
> That said, it would be useful to have a matcher for the **name** of a 
> `DependentNameType`, something like 
> `dependentNameType(hasDependentName("type"))` for `typename T::type`. I don't 
> know how straightforward it is to overload a matcher name (`hasDependentName` 
> in this case) in this way, but if you're interested in playing around with 
> it, I think that would make for a useful addition!

Thanks for the explanation, I am interested to try to play around with it and 
will update you with result, 

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


[clang] [Clang][ASTMatcher] Add `dependentTemplateSpecializationType` AST mat… (PR #121435)

2025-01-01 Thread Amr Hesham via cfe-commits


@@ -2546,6 +2546,17 @@ Node Matchers
   };
 
 
+MatcherType>dependentTemplateSpecializationTypeMatcherDependentTemplateSpecializationType>...
+Matches dependent template 
specialization types.
+
+Example matches  A::template B

AmrDeveloper wrote:

```suggestion
Example matches A::template B
```

The same in `clang/include/clang/ASTMatchers/ASTMatchers.h`

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


[clang] [Clang][ASTMatcher] Add `dependentTemplateSpecializationType` AST mat… (PR #121435)

2025-01-01 Thread Amr Hesham via cfe-commits

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


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


[clang] [Clang][ASTMatcher] Add `dependentTemplateSpecializationType` AST mat… (PR #121435)

2025-01-01 Thread Amr Hesham via cfe-commits


@@ -1113,6 +1113,8 @@ AST Matchers
 
 - Add ``dependentNameType`` matcher to match a dependent name type.
 
+- Add ``dependentTemplateSpecializationType`` matcher to match dependent 
template specialization types.

AmrDeveloper wrote:

```suggestion
- Add ``dependentTemplateSpecializationType`` matcher to match a dependent 
template specialization type.
```

The same in `clang/docs/LibASTMatchersReference.html` and 
`clang/include/clang/ASTMatchers/ASTMatchers.h`

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


[clang] [Clang][ASTMatcher] Extend `hasDependentName` to match DependentNameType name (PR #121975)

2025-01-07 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/121975

Extending the `hasDependentName` to be a polymorphic matcher that matches the 
dependent name of `DependentNameType` or `DependentScopeDeclRefExpr`

>From 353f3ca4e997f658c65570e75749220e1abcad72 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 7 Jan 2025 19:13:26 +0100
Subject: [PATCH] [Clang][ASTMatcher] Extend `hasDependentName` matcher to
 match DependentNameType name

---
 clang/docs/LibASTMatchersReference.html   | 15 ++
 clang/docs/ReleaseNotes.rst   |  2 +-
 clang/include/clang/ASTMatchers/ASTMatchers.h | 20 +++
 .../clang/ASTMatchers/ASTMatchersInternal.h   |  8 
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |  8 
 5 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 18f9e7d6c0ea06..48dfd9cac00337 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -3462,6 +3462,21 @@ Narrowing Matchers
 
 
 
+MatcherDependentNameType>hasDependentNamestd::string 
N
+Matches the 
dependent name of a DependentNameType.
+
+Matches the dependent name of a DependentNameType
+
+Given:
+
+  template CXXDependentScopeMemberExpr>memberHasSameNameAsBoundNodestd::string
 BindingID
 Matches template-dependent, but known, 
member names against an already-bound
 node
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 93915e5db7d131..2258452d07ec5a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1130,7 +1130,7 @@ AST Matchers
 
 - Add ``dependentTemplateSpecializationType`` matcher to match a dependent 
template specialization type.
 
-- Add ``hasDependentName`` matcher to match the dependent name of a 
DependentScopeDeclRefExpr.
+- Add ``hasDependentName`` matcher to match the dependent name of a 
DependentScopeDeclRefExpr or DependentNameType.
 
 clang-format
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index f10135d7a901f1..f32170c93bee26 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3257,15 +3257,27 @@ AST_MATCHER_P(CXXDependentScopeMemberExpr, 
memberHasSameNameAsBoundNode,
   });
 }
 
-/// Matches the dependent name of a DependentScopeDeclRefExpr
+/// Matches the dependent name of a DependentScopeDeclRefExpr or
+/// DependentNameType
 ///
 /// Given:
 /// \code
 ///  template  class X : T { void f() { T::v; } };
 /// \endcode
 /// \c dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
-AST_MATCHER_P(DependentScopeDeclRefExpr, hasDependentName, std::string, N) {
-  return Node.getDeclName().getAsString() == N;
+///
+/// Given:
+/// \code
+///  template  struct declToImport {
+///typedef typename T::type dependent_name;
+///  };
+/// \endcode
+/// \c dependentNameType(hasDependentName("type")) matches `T::type`
+AST_POLYMORPHIC_MATCHER_P(hasDependentName,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(
+  DependentScopeDeclRefExpr, DependentNameType),
+  std::string, N) {
+  return internal::getDependentName(Node) == N;
 }
 
 /// Matches C++ classes that are directly or indirectly derived from a class
@@ -7724,7 +7736,7 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
 
 /// Matches a dependent name type
 ///
-/// Example matches  T::type
+/// Example matches T::type
 /// \code
 ///  template  struct declToImport {
 ///typedef typename T::type dependent_name;
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 04804d5def0461..1f7b5e7cac8465 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -2343,6 +2343,14 @@ MatchTemplateArgLocAt(const 
TemplateSpecializationTypeLoc &Node,
  InnerMatcher.matches(Node.getArgLoc(Index), Finder, Builder);
 }
 
+inline std::string getDependentName(const DependentScopeDeclRefExpr &node) {
+  return node.getDeclName().getAsString();
+}
+
+inline std::string getDependentName(const DependentNameType &node) {
+  return node.getIdentifier()->getName().str();
+}
+
 } // namespace internal
 
 } // namespace ast_matchers
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index f3d953454173ca..b2cd0dbd28ae1e 100644
--- a/clang/unittests/ASTMa

[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-06 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> Thanks! The update looks good, I have one more minor suggestion for a change 
> which I'll just go ahead and make before merging.

Thank you

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


[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

2025-01-06 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

@HighCommander4 

We can also create a new matcher for `dependentNameType` so we can use it like 
`dependentNameType(hasDependentType(builtinType()))`, which is similar to 
Complex and Array types.

If confirmed I can work on it too :D

Thank you

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-28 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/121263

>From bdbd11db849506c4d99036dd674f03d1eda815cc Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 28 Dec 2024 13:23:33 +0100
Subject: [PATCH 1/2] [Clang][ASTMatcher] Add `dependentNameType` Matcher

---
 clang/docs/LibASTMatchersReference.html   |  9 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 10 ++
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  1 +
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 clang/unittests/AST/ASTImporterTest.cpp   |  3 ---
 .../unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 15 +++
 7 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index ddc99020604c94..69fd43b2114723 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherStmt>dependentNameTypeMatcherDependentNameType>...
+Matches dependent 
name type.
+
+Example matches T::type
+
+  template  struct declToImport {
+typedef typename T::type dependent_name;
+  };
+
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 983c1da20ed4c8..7446aaf57a02dc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1110,6 +1110,8 @@ AST Matchers
 
 - Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
 
+- Add ``dependentNameType`` matcher to match dependent name type.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 22e2546ab81e0a..b27914306b8270 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
   return InnerType.matches(Node.getDecayedType(), Finder, Builder);
 }
 
+/// Matches dependent name type
+///
+/// Example matches  T::type
+/// \code
+///  template  struct declToImport {
+///typedef typename T::type dependent_name;
+///  };
+/// \endcode
+extern const AstTypeMatcher dependentNameType;
+
 /// Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 8c744eebbdfb50..a47633bf4bae24 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1108,6 +1108,7 @@ const AstTypeMatcher 
substTemplateTypeParmType;
 const AstTypeMatcher templateTypeParmType;
 const AstTypeMatcher injectedClassNameType;
 const AstTypeMatcher decayedType;
+const AstTypeMatcher dependentNameType;
 AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasElementType,
  AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
  ComplexType));
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 685d626d2978bf..674129aee59241 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
   REGISTER_MATCHER(decayedType);
+  REGISTER_MATCHER(dependentNameType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ec062a5cc953b8..ee1d896f1ca6dc 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3196,9 +3196,6 @@ TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
  has(callExpr(has(dependentScopeDeclRefExpr());
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentNameType;
-
 TEST_P(ImportExpr, DependentNameType) {
   MatchVerifier Verifier;
   testImport("template  struct declToImport {"
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index a3baad367a27b1..6dfa3d9c0992f0 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unitt

[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-28 Thread Amr Hesham via cfe-commits


@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
   REGISTER_MATCHER(decayedType);
+  REGISTER_MATCHER(dependentNameType);

AmrDeveloper wrote:

Done, thank you

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-28 Thread Amr Hesham via cfe-commits


@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
   return InnerType.matches(Node.getDecayedType(), Finder, Builder);
 }
 
+/// Matches dependent name type

AmrDeveloper wrote:

Done

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Amr Hesham via cfe-commits


@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherStmt>dependentNameTypeMatcherDependentNameType>...

AmrDeveloper wrote:

Thank you, Done

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Amr Hesham via cfe-commits


@@ -1912,6 +1912,21 @@ TEST_P(ASTMatchersTest, 
DeducedTemplateSpecializationType) {
   deducedTemplateSpecializationType()));
 }
 
+TEST_P(ASTMatchersTest, DependentNameType) {
+  if (!GetParam().isCXX()) {
+// FIXME: Add a test for `dependentNameType()` that does not depend on C++.

AmrDeveloper wrote:

Done

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/121263

>From bdbd11db849506c4d99036dd674f03d1eda815cc Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 28 Dec 2024 13:23:33 +0100
Subject: [PATCH 1/3] [Clang][ASTMatcher] Add `dependentNameType` Matcher

---
 clang/docs/LibASTMatchersReference.html   |  9 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 10 ++
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  1 +
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 clang/unittests/AST/ASTImporterTest.cpp   |  3 ---
 .../unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 15 +++
 7 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index ddc99020604c94..69fd43b2114723 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherStmt>dependentNameTypeMatcherDependentNameType>...
+Matches dependent 
name type.
+
+Example matches T::type
+
+  template  struct declToImport {
+typedef typename T::type dependent_name;
+  };
+
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 983c1da20ed4c8..7446aaf57a02dc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1110,6 +1110,8 @@ AST Matchers
 
 - Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
 
+- Add ``dependentNameType`` matcher to match dependent name type.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 22e2546ab81e0a..b27914306b8270 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
   return InnerType.matches(Node.getDecayedType(), Finder, Builder);
 }
 
+/// Matches dependent name type
+///
+/// Example matches  T::type
+/// \code
+///  template  struct declToImport {
+///typedef typename T::type dependent_name;
+///  };
+/// \endcode
+extern const AstTypeMatcher dependentNameType;
+
 /// Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 8c744eebbdfb50..a47633bf4bae24 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1108,6 +1108,7 @@ const AstTypeMatcher 
substTemplateTypeParmType;
 const AstTypeMatcher templateTypeParmType;
 const AstTypeMatcher injectedClassNameType;
 const AstTypeMatcher decayedType;
+const AstTypeMatcher dependentNameType;
 AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasElementType,
  AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
  ComplexType));
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 685d626d2978bf..674129aee59241 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
   REGISTER_MATCHER(decayedType);
+  REGISTER_MATCHER(dependentNameType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ec062a5cc953b8..ee1d896f1ca6dc 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3196,9 +3196,6 @@ TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
  has(callExpr(has(dependentScopeDeclRefExpr());
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentNameType;
-
 TEST_P(ImportExpr, DependentNameType) {
   MatchVerifier Verifier;
   testImport("template  struct declToImport {"
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index a3baad367a27b1..6dfa3d9c0992f0 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unitt

[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/120996

>From a0b71504fa31e55d42cb54e349838b2669f6fde5 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Mon, 23 Dec 2024 19:42:30 +0100
Subject: [PATCH 1/2] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr`
 Matcher

---
 clang/docs/LibASTMatchersReference.html   |  6 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 10 +
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  2 ++
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 clang/unittests/AST/ASTImporterTest.cpp   |  3 ---
 .../ASTMatchers/ASTMatchersNodeTest.cpp   | 22 +++
 7 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index f18e9cf1341696..ddc99020604c94 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1842,6 +1842,12 @@ Node Matchers
   if (x) {}
 
 
+MatcherStmt>dependentScopeDeclRefExprMatcherDependentScopeDeclRefExpr>...
+Matches 
expressions that refer to dependent scope declarations.
+
+Example matches T::v
+   template  class X : T { void f() { T::v; } };
+
 
 MatcherStmt>declStmtMatcherDeclStmt>...
 Matches declaration 
statements.
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..2a84a4704f0c21 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1101,6 +1101,8 @@ AST Matchers
 
 - Ensure ``pointee`` matches Objective-C pointer types.
 
+- Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 897aa25dc95cc1..22e2546ab81e0a 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2125,6 +2125,16 @@ extern const internal::VariadicDynCastAllOfMatcher expr;
 extern const internal::VariadicDynCastAllOfMatcher
 declRefExpr;
 
+/// Matches expressions that refer to dependent scope declarations.
+///
+/// example matches T::v;
+/// \code
+///  template  class X : T { void f() { T::v; } };
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+dependentScopeDeclRefExpr;
+
 /// Matches a reference to an ObjCIvar.
 ///
 /// Example: matches "a" in "init" method:
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index bf9dc5f2373f9e..8c744eebbdfb50 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -924,6 +924,8 @@ const internal::VariadicDynCastAllOfMatcher
 const internal::VariadicDynCastAllOfMatcher cxxFoldExpr;
 const internal::VariadicDynCastAllOfMatcher expr;
 const internal::VariadicDynCastAllOfMatcher declRefExpr;
+const internal::VariadicDynCastAllOfMatcher
+dependentScopeDeclRefExpr;
 const internal::VariadicDynCastAllOfMatcher 
objcIvarRefExpr;
 const internal::VariadicDynCastAllOfMatcher blockExpr;
 const internal::VariadicDynCastAllOfMatcher ifStmt;
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 837633fb2f0601..685d626d2978bf 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -222,6 +222,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
   REGISTER_MATCHER(declRefExpr);
+  REGISTER_MATCHER(dependentScopeDeclRefExpr);
   REGISTER_MATCHER(declStmt);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(decltypeType);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index f3f314b723dfc6..ec062a5cc953b8 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3172,9 +3172,6 @@ TEST_P(ImportDecl, ImportFieldOrder) {
  recordDecl(hasFieldOrder({"b", "a"})));
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentScopeDeclRefExpr;
-
 TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
   MatchVerifier Verifier;
   testImport("template  struct S { static T foo; };"
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 9bc287e07224aa..89897f1b3230a6 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -556,6 +556,22 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
  

[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-24 Thread Amr Hesham via cfe-commits


@@ -556,6 +556,22 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
  Reference));
 }
 
+TEST_P(ASTMatchersTest, DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+// FIXME: Add a test for `dependentScopeDeclRefExpr()` that does not depend

AmrDeveloper wrote:

Thank you, I updated it :D

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-30 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> ~@AmrDeveloper if you're not tired of these yet, I have one final one: 
> #121307~
> 
> (Update: that one's been taken by another contributor.)

Thank you, if you found another one, I will be interested to work on it, you 
can assign me directly :D

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


[clang] [Clang][ASTMatcher] Add `dependentScopeDeclRefExpr` Matcher (PR #120996)

2024-12-27 Thread Amr Hesham via cfe-commits

AmrDeveloper wrote:

> #121240

Sure, i am interested, Thank you :D

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-28 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/121263

Add AST Matcher for `DependentNameType`

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

>From 21873d01238f8da0eb0f19656801347400afae65 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 28 Dec 2024 13:23:33 +0100
Subject: [PATCH] [Clang][ASTMatcher] Add `dependentNameType` Matcher

---
 clang/docs/LibASTMatchersReference.html   |  9 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 10 ++
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  1 +
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 clang/unittests/AST/ASTImporterTest.cpp   |  3 ---
 .../unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 15 +++
 7 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index ddc99020604c94..69fd43b2114723 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherStmt>dependentNameTypeMatcherDependentNameType>...
+Matches dependent 
name type.
+
+Example matches T::type
+
+  template  struct declToImport {
+typedef typename T::type dependent_name;
+  };
+
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 983c1da20ed4c8..7446aaf57a02dc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1110,6 +1110,8 @@ AST Matchers
 
 - Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
 
+- Add ``dependentNameType`` matcher to match dependent name type.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 22e2546ab81e0a..b27914306b8270 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
   return InnerType.matches(Node.getDecayedType(), Finder, Builder);
 }
 
+/// Matches dependent name type
+///
+/// Example matches  T::type
+/// \code
+///  template  struct declToImport {
+///typedef typename T::type dependent_name;
+///  };
+/// \endcode
+extern const AstTypeMatcher dependentNameType;
+
 /// Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 8c744eebbdfb50..a47633bf4bae24 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1108,6 +1108,7 @@ const AstTypeMatcher 
substTemplateTypeParmType;
 const AstTypeMatcher templateTypeParmType;
 const AstTypeMatcher injectedClassNameType;
 const AstTypeMatcher decayedType;
+const AstTypeMatcher dependentNameType;
 AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasElementType,
  AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
  ComplexType));
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 685d626d2978bf..674129aee59241 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
   REGISTER_MATCHER(decayedType);
+  REGISTER_MATCHER(dependentNameType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ec062a5cc953b8..ee1d896f1ca6dc 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3196,9 +3196,6 @@ TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
  has(callExpr(has(dependentScopeDeclRefExpr());
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentNameType;
-
 TEST_P(ImportExpr, DependentNameType) {
   MatchVerifier Verifier;
   testImport("template  struct declToImport {"
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index a3baad367a27b1..0

  1   2   3   >