Author: Sarah Spall
Date: 2025-11-06T08:07:10-08:00
New Revision: 7227030a82ec28b4b4e7fd648e344fdee274e05a

URL: 
https://github.com/llvm/llvm-project/commit/7227030a82ec28b4b4e7fd648e344fdee274e05a
DIFF: 
https://github.com/llvm/llvm-project/commit/7227030a82ec28b4b4e7fd648e344fdee274e05a.diff

LOG: [HLSL] enable Wconversion by default for HLSL (#166617)

Add WConversion by default to cc1 args.  
Closes #134761

Added: 
    clang/test/Driver/HLSL/wconversion.hlsl

Modified: 
    clang/lib/Driver/ToolChains/HLSL.cpp
    clang/lib/Driver/ToolChains/HLSL.h

Removed: 
    


################################################################################
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..5bf385e13e962 100644
--- a/clang/lib/Driver/ToolChains/HLSL.h
+++ b/clang/lib/Driver/ToolChains/HLSL.h
@@ -91,6 +91,8 @@ 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"


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to