[clang] d3e4727 - [HLSL] add -D option for dxc mode.
Xiang Li via cfe-commits
cfe-commits at lists.llvm.org
Tue May 31 17:50:45 PDT 2022
Author: Xiang Li
Date: 2022-05-31T17:50:36-07:00
New Revision: d3e4727907e533a088fdb42963b6efcd1f26ec88
URL: https://github.com/llvm/llvm-project/commit/d3e4727907e533a088fdb42963b6efcd1f26ec88
DIFF: https://github.com/llvm/llvm-project/commit/d3e4727907e533a088fdb42963b6efcd1f26ec88.diff
LOG: [HLSL] add -D option for dxc mode.
Create dxc_D as alias to option D which Define <macro> to <value> (or 1 if <value> omitted).
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D125338
Added:
clang/test/Driver/dxc_D.hlsl
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index fc8bda55c561..a7622e0c9976 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6804,6 +6804,8 @@ def target_profile : DXCJoinedOrSeparate<"T">, MetaVarName<"<profile>">,
"lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_x,"
"ms_6_5, ms_6_6, ms_6_7,"
"as_6_5, as_6_6, as_6_7">;
+def dxc_D : Option<["--", "/", "-"], "D", KIND_JOINED_OR_SEPARATE>,
+ Group<dxc_Group>, Flags<[DXCOption, NoXarchOption]>, Alias<D>;
def emit_pristine_llvm : DXCFlag<"emit-pristine-llvm">,
HelpText<"Emit pristine LLVM IR from the frontend by not running any LLVM passes at all."
"Same as -S + -emit-llvm + -disable-llvm-passes.">;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index a8706215bf60..f32dfdcdfe4b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3477,9 +3477,9 @@ static void RenderOpenCLOptions(const ArgList &Args, ArgStringList &CmdArgs,
static void RenderHLSLOptions(const ArgList &Args, ArgStringList &CmdArgs,
types::ID InputType) {
- const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
- options::OPT_S, options::OPT_emit_llvm,
- options::OPT_disable_llvm_passes};
+ const unsigned ForwardedArguments[] = {
+ options::OPT_dxil_validator_version, options::OPT_D, options::OPT_S,
+ options::OPT_emit_llvm, options::OPT_disable_llvm_passes};
for (const auto &Arg : ForwardedArguments)
if (const auto *A = Args.getLastArg(Arg))
diff --git a/clang/test/Driver/dxc_D.hlsl b/clang/test/Driver/dxc_D.hlsl
new file mode 100644
index 000000000000..d32d885f11b0
--- /dev/null
+++ b/clang/test/Driver/dxc_D.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_dxc -DTEST=2 -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2 -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
+
+// Make sure -D send to cc1.
+// CHECK:"-D" "TEST=2"
+
+#ifndef TEST
+#error "TEST not defined"
+#elif TEST != 2
+#error "TEST defined to wrong value"
+#endif
+
+// ERROR-NOT: error:
More information about the cfe-commits
mailing list