[clang] [HLSL] Change clang Driver Options to not set CXXOperatorNames (PR #126758)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 11 08:27:23 PST 2025
https://github.com/farzonl updated https://github.com/llvm/llvm-project/pull/126758
>From 3b7e458bfeb2abab799789d30ebaa4b214e4168e Mon Sep 17 00:00:00 2001
From: Farzon Lotfi <farzonlotfi at microsoft.com>
Date: Tue, 11 Feb 2025 11:07:23 -0500
Subject: [PATCH 1/2] [HLSL] Change clang Driver Options to not set
CXXOperatorNames
---
clang/include/clang/Driver/Options.td | 2 +-
.../use-cxx-alt-operator-names.hlsl | 41 +++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1cf62ab4661345..618815db284340 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3397,7 +3397,7 @@ def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group<f_Group>,
def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group<f_Group>,
Visibility<[ClangOption, FlangOption]>;
defm operator_names : BoolFOption<"operator-names",
- LangOpts<"CXXOperatorNames">, Default<cplusplus.KeyPath>,
+ LangOpts<"CXXOperatorNames">, Default<!strconcat(cplusplus.KeyPath, " && !",hlsl.KeyPath)>,
NegFlag<SetFalse, [], [ClangOption, CC1Option],
"Do not treat C++ operator name keywords as synonyms for operators">,
PosFlag<SetTrue>>;
diff --git a/clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl b/clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl
new file mode 100644
index 00000000000000..8ae253a9f3c06c
--- /dev/null
+++ b/clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl
@@ -0,0 +1,41 @@
+
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN: dxil-pc-shadermodel6.3-library %s \
+// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
+// RUN: spirv-unknown-vulkan-compute %s \
+// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+// CHECK-LABEL: and
+void and() {}
+
+// CHECK-LABEL: and_eq
+void and_eq() {}
+
+// CHECK-LABEL: bitand
+void bitand() {}
+
+// CHECK-LABEL: bitor
+void bitor() {}
+
+// CHECK-LABEL: compl
+void compl() {}
+
+// CHECK-LABEL: not
+void not() {}
+
+// CHECK-LABEL: not_eq
+void not_eq() {}
+
+// CHECK-LABEL: or
+void or() {}
+
+// CHECK-LABEL: or_eq
+void or_eq() {}
+
+// CHECK-LABEL: xor
+void xor() {}
+
+// CHECK-LABEL: xor_eq
+void xor_eq() {}
>From 68b78917adceda57e83e7ebfc68053ed30698635 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi <farzonlotfi at microsoft.com>
Date: Tue, 11 Feb 2025 11:27:10 -0500
Subject: [PATCH 2/2] address pr feedback
---
.../use-cxx-alt-operator-names.hlsl | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
rename clang/test/{CodeGenHLSL => SemaHLSL}/use-cxx-alt-operator-names.hlsl (55%)
diff --git a/clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl b/clang/test/SemaHLSL/use-cxx-alt-operator-names.hlsl
similarity index 55%
rename from clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl
rename to clang/test/SemaHLSL/use-cxx-alt-operator-names.hlsl
index 8ae253a9f3c06c..2ee7ae2a1b1fe5 100644
--- a/clang/test/CodeGenHLSL/use-cxx-alt-operator-names.hlsl
+++ b/clang/test/SemaHLSL/use-cxx-alt-operator-names.hlsl
@@ -1,11 +1,4 @@
-
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN: dxil-pc-shadermodel6.3-library %s \
-// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
-
-// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
-// RUN: spirv-unknown-vulkan-compute %s \
-// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library %s -ast-dump | FileCheck %s
// CHECK-LABEL: and
void and() {}
More information about the cfe-commits
mailing list