Author: Farzon Lotfi
Date: 2025-02-12T09:21:39-05:00
New Revision: 767b15f9d57cf31fd6ba2aed8c17a8c30d5b5e6e

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

LOG: [HLSL] Change clang Driver Options to not set CXXOperatorNames (#126758)

- Disable `CXXOperatorNames` for HLSL
- Add tests to confirm we can use the alt names as functions

Added: 
    clang/test/SemaHLSL/use-cxx-alt-operator-names.hlsl

Modified: 
    clang/include/clang/Driver/Options.td

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1cf62ab466134..618815db28434 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/SemaHLSL/use-cxx-alt-operator-names.hlsl 
b/clang/test/SemaHLSL/use-cxx-alt-operator-names.hlsl
new file mode 100644
index 0000000000000..e93be2bbf4e69
--- /dev/null
+++ b/clang/test/SemaHLSL/use-cxx-alt-operator-names.hlsl
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library %s -ast-dump | 
FileCheck %s
+
+// CHECK: -FunctionDecl {{.*}} and 'void ()'
+void and() {}
+
+// CHECK: -FunctionDecl {{.*}} and_eq 'void ()'
+void and_eq() {}
+
+// CHECK: -FunctionDecl {{.*}} bitand 'void ()'
+void bitand() {}
+
+// CHECK: -FunctionDecl {{.*}} bitor 'void ()'
+void bitor() {}
+
+// CHECK: -FunctionDecl {{.*}} compl 'void ()'
+void compl() {}
+
+// CHECK: -FunctionDecl {{.*}} not 'void ()'
+void not() {}
+
+// CHECK: -FunctionDecl {{.*}} not_eq 'void ()'
+void not_eq() {}
+
+// CHECK: -FunctionDecl {{.*}} or 'void ()'
+void or() {}
+
+// CHECK: -FunctionDecl {{.*}} or_eq 'void ()'
+void or_eq() {}
+
+// CHECK: -FunctionDecl {{.*}} xor 'void ()'
+void xor() {}
+
+// CHECK: -FunctionDecl {{.*}} xor_eq 'void ()'
+void xor_eq() {}


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

Reply via email to