[clang] [HLSL] Allow non `.hlsl` files as source files (PR #137378)
Steven Perron via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 25 11:07:21 PDT 2025
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/137378
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
>From 163b214e77e63d919ea7fdd1e52762263037175d Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Fri, 25 Apr 2025 13:16:53 -0400
Subject: [PATCH] [HLSL] Allow non `.hlsl` files as source files
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
---
clang/lib/Driver/Driver.cpp | 2 ++
clang/test/Driver/dxc_I.test | 4 ++++
2 files changed, 6 insertions(+)
create mode 100644 clang/test/Driver/dxc_I.test
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"
More information about the cfe-commits
mailing list