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

Chris B via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 17:41:32 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");
+      }
----------------
llvm-beanz wrote:

What about 202x? What about unrecognized values?

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


More information about the cfe-commits mailing list