https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/126758
- Disable `CXXOperatorNames` for HLSL - Add tests to confirm we can use the alt names as functions >From 3b7e458bfeb2abab799789d30ebaa4b214e4168e Mon Sep 17 00:00:00 2001 From: Farzon Lotfi <farzonlo...@microsoft.com> Date: Tue, 11 Feb 2025 11:07:23 -0500 Subject: [PATCH] [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 1cf62ab46613456..618815db2843404 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 000000000000000..8ae253a9f3c06cb --- /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() {} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits