[clang] [HLSL] Allow non `.hlsl` files as source files (PR #137378)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 25 11:07:57 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Steven Perron (s-perron)
<details>
<summary>Changes</summary>
Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.
Fixes https://github.com/llvm/llvm-project/issues/137370
---
Full diff: https://github.com/llvm/llvm-project/pull/137378.diff
2 Files Affected:
- (modified) clang/lib/Driver/Driver.cpp (+2)
- (added) clang/test/Driver/dxc_I.test (+4)
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2b8c6e35263b1..a648cc928afdc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3001,6 +3001,8 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
Ty = types::TY_CXX;
else if (CCCIsCPP() || CCGenDiagnostics)
Ty = types::TY_C;
+ else if (IsDXCMode())
+ Ty = types::TY_HLSL;
else
Ty = types::TY_Object;
}
diff --git a/clang/test/Driver/dxc_I.test b/clang/test/Driver/dxc_I.test
new file mode 100644
index 0000000000000..e88537c6b1ab8
--- /dev/null
+++ b/clang/test/Driver/dxc_I.test
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -Tlib_6_3 -### %s 2>&1 | FileCheck %s
+
+// Make sure a non `.hlsl` file is considered an HLSL source file in dxc mode.
+// CHECK: "-x" "hlsl" "{{.*}}/dxc_I.test"
``````````
</details>
https://github.com/llvm/llvm-project/pull/137378
More information about the cfe-commits
mailing list