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

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 5 15:24:44 PST 2024


================
@@ -226,6 +226,28 @@ 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, assign std to:
+      // c++14,c++17,c++20,c++latest,c11,c17
+      const char *value = A->getValue();
+      if (strcmp(value, "2016") == 0) {
+        DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_std_EQ),
+                            "hlsl2016");
+      } else if (strcmp(value, "2017") == 0) {
+        DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_std_EQ),
+                            "hlsl2017");
+      } else if (strcmp(value, "2018") == 0) {
+        DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_std_EQ),
+                            "hlsl2018");
+      } else if (strcmp(value, "2021") == 0) {
+        DAL->AddSeparateArg(nullptr, Opts.getOption(options::OPT_std_EQ),
+                            "hlsl2021");
+      }
----------------
bob80905 wrote:

Added a case for 202x and for unrecognized values. 
I notice 2015 used to be an accepted value, but I'm not sure how we want to treat that option, since DXC seems to treat it as a special option and has extra conditions for accepting it.

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


More information about the cfe-commits mailing list