[clang] [llvm] [HLSL] Add -HV option translation to clang-dxc.exe (PR #83938)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 10:20:11 PST 2024


================
@@ -226,6 +226,47 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
       A->claim();
       continue;
     }
+    if (A->getOption().getID() == options::OPT_dxc_hlsl_version) {
+      // Translate -HV into -std for llvm
+      // depending on the value given
+      llvm::StringRef value(A->getValue());
+      llvm::StringRef acceptedValues(
+          Opts.getOptionValues(options::OPT_dxc_hlsl_version));
+      llvm::SmallVector<StringRef, 8> validValues;
+      acceptedValues.split(validValues, ", ");
+      if (value == validValues[0]) {
----------------
bob80905 wrote:

The idea to use getOptionValues was an idea inspired by @llvm-beanz 's feedback, to prevent littering direct string comparisons into the code and unify string handling. Originally, I did have the direct "2016" comparison. I'm not sure if the LLVM community would want access to these option values, but it seems like the most convenient way to get around direct string comparisons. I do remember string comparisons were a pain point in the DXC codebase and want to try and avoid that.

https://github.com/llvm/llvm-project/pull/83938


More information about the cfe-commits mailing list