[clang] [HLSL] enable Wconversion by default for HLSL (PR #166617)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 5 11:08:20 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-hlsl
Author: Sarah Spall (spall)
<details>
<summary>Changes</summary>
Add WConversion by default to cc1 args.
Closes #<!-- -->134761
---
Full diff: https://github.com/llvm/llvm-project/pull/166617.diff
3 Files Affected:
- (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+4)
- (modified) clang/lib/Driver/ToolChains/HLSL.h (+1)
- (added) clang/test/Driver/HLSL/wconversion.hlsl (+7)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp
index 8d3fba7137c7c..5d7221b8718a9 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -567,3 +567,7 @@ bool HLSLToolChain::isLastJob(DerivedArgList &Args,
// output to the result file.
return true;
}
+
+void HLSLToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {
+ CC1Args.push_back("-Wconversion");
+}
diff --git a/clang/lib/Driver/ToolChains/HLSL.h b/clang/lib/Driver/ToolChains/HLSL.h
index 3aed904648429..7590659cf22a7 100644
--- a/clang/lib/Driver/ToolChains/HLSL.h
+++ b/clang/lib/Driver/ToolChains/HLSL.h
@@ -91,6 +91,7 @@ class LLVM_LIBRARY_VISIBILITY HLSLToolChain : public ToolChain {
// Set default DWARF version to 4 for DXIL uses version 4.
unsigned GetDefaultDwarfVersion() const override { return 4; }
+ void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
private:
mutable std::unique_ptr<tools::hlsl::Validator> Validator;
mutable std::unique_ptr<tools::hlsl::MetalConverter> MetalConverter;
diff --git a/clang/test/Driver/HLSL/wconversion.hlsl b/clang/test/Driver/HLSL/wconversion.hlsl
new file mode 100644
index 0000000000000..1857a3dfe386e
--- /dev/null
+++ b/clang/test/Driver/HLSL/wconversion.hlsl
@@ -0,0 +1,7 @@
+// RUN: %clang_dxc -T lib_6_7 %s -### %s 2>&1 | FileCheck %s --check-prefixes=CONV
+// RUN: %clang_dxc -T lib_6_7 -Wno-conversion %s -### %s 2>&1 | FileCheck %s --check-prefixes=NOCONV
+
+// make sure we generate -Wconversion by default
+// CONV: "-Wconversion"
+// make sure -Wno-conversion still works
+// NOCONV: "-Wno-conversion"
``````````
</details>
https://github.com/llvm/llvm-project/pull/166617
More information about the cfe-commits
mailing list