This revision was automatically updated to reflect the committed changes. Closed by commit rG5a85526728c9: [clang] Use enum for LangOptions::SYCLVersion instead of unsigned (authored by jansvoboda11).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93540/new/ https://reviews.llvm.org/D93540 Files: clang/include/clang/Basic/LangOptions.def clang/include/clang/Basic/LangOptions.h clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/InitPreprocessor.cpp Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -476,7 +476,7 @@ if (LangOpts.SYCL) { // SYCL Version is set to a value when building SYCL applications - if (LangOpts.SYCLVersion == 2017) + if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017) Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121"); } Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -2277,11 +2277,13 @@ // -sycl-std applies to any SYCL source, not only those containing kernels, // but also those using the SYCL API if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) { - Opts.SYCLVersion = llvm::StringSwitch<unsigned>(A->getValue()) - .Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017) - .Default(0U); + Opts.setSYCLVersion( + llvm::StringSwitch<LangOptions::SYCLMajorVersion>(A->getValue()) + .Cases("2017", "1.2.1", "121", "sycl-1.2.1", + LangOptions::SYCL_2017) + .Default(LangOptions::SYCL_None)); - if (Opts.SYCLVersion == 0U) { + if (Opts.getSYCLVersion() == LangOptions::SYCL_None) { // User has passed an invalid value to the flag, this is an error Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << A->getValue(); Index: clang/include/clang/Basic/LangOptions.h =================================================================== --- clang/include/clang/Basic/LangOptions.h +++ clang/include/clang/Basic/LangOptions.h @@ -125,6 +125,11 @@ MSVC2019 = 1920, }; + enum SYCLMajorVersion { + SYCL_None, + SYCL_2017, + }; + /// Clang versions with different platform ABI conformance. enum class ClangABI { /// Attempt to be ABI-compatible with code generated by Clang 3.8.x Index: clang/include/clang/Basic/LangOptions.def =================================================================== --- clang/include/clang/Basic/LangOptions.def +++ clang/include/clang/Basic/LangOptions.def @@ -246,7 +246,7 @@ LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") -LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used") +ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 1, SYCL_None, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
Index: clang/lib/Frontend/InitPreprocessor.cpp =================================================================== --- clang/lib/Frontend/InitPreprocessor.cpp +++ clang/lib/Frontend/InitPreprocessor.cpp @@ -476,7 +476,7 @@ if (LangOpts.SYCL) { // SYCL Version is set to a value when building SYCL applications - if (LangOpts.SYCLVersion == 2017) + if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017) Builder.defineMacro("CL_SYCL_LANGUAGE_VERSION", "121"); } Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -2277,11 +2277,13 @@ // -sycl-std applies to any SYCL source, not only those containing kernels, // but also those using the SYCL API if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) { - Opts.SYCLVersion = llvm::StringSwitch<unsigned>(A->getValue()) - .Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017) - .Default(0U); + Opts.setSYCLVersion( + llvm::StringSwitch<LangOptions::SYCLMajorVersion>(A->getValue()) + .Cases("2017", "1.2.1", "121", "sycl-1.2.1", + LangOptions::SYCL_2017) + .Default(LangOptions::SYCL_None)); - if (Opts.SYCLVersion == 0U) { + if (Opts.getSYCLVersion() == LangOptions::SYCL_None) { // User has passed an invalid value to the flag, this is an error Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << A->getValue(); Index: clang/include/clang/Basic/LangOptions.h =================================================================== --- clang/include/clang/Basic/LangOptions.h +++ clang/include/clang/Basic/LangOptions.h @@ -125,6 +125,11 @@ MSVC2019 = 1920, }; + enum SYCLMajorVersion { + SYCL_None, + SYCL_2017, + }; + /// Clang versions with different platform ABI conformance. enum class ClangABI { /// Attempt to be ABI-compatible with code generated by Clang 3.8.x Index: clang/include/clang/Basic/LangOptions.def =================================================================== --- clang/include/clang/Basic/LangOptions.def +++ clang/include/clang/Basic/LangOptions.def @@ -246,7 +246,7 @@ LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") -LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used") +ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 1, SYCL_None, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits