diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-01-15 15:43:18 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-01-15 16:41:34 +0100 |
commit | a7dcd3aeb0fb58ad774bc89428ed6c925f31f8aa (patch) | |
tree | 47ff7aa76cd4363e90349f953ecd56a68b759178 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 383262933045e1c138362105be4ee4d1b62ab4cc (diff) | |
download | llvm-a7dcd3aeb0fb58ad774bc89428ed6c925f31f8aa.zip llvm-a7dcd3aeb0fb58ad774bc89428ed6c925f31f8aa.tar.gz llvm-a7dcd3aeb0fb58ad774bc89428ed6c925f31f8aa.tar.bz2 |
[clang][cli] NFC: Parse some LangOpts after the defaults are set
This patch ensures we only parse the necessary options before calling `setLangDefaults` (explained in D94678).
Because neither `LangOpts.CFProtectionBranch` nor `LangOpts.SYCLIsDevice` are used in `setLangDefaults`, this is a NFC.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D94680
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index d261eb7..c672834 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2196,12 +2196,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, } } - if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) { - StringRef Name = A->getValue(); - if (Name == "full" || Name == "branch") { - Opts.CFProtectionBranch = 1; - } - } // -cl-std only applies for OpenCL language standards. // Override the -std option in this case. if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) { @@ -2224,14 +2218,21 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, LangStd = OpenCLLangStd; } - Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); - // These need to be parsed now. They are used to set OpenCL defaults. Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header); Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins); CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd); + if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) { + StringRef Name = A->getValue(); + if (Name == "full" || Name == "branch") { + Opts.CFProtectionBranch = 1; + } + } + + Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); + // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0. // This option should be deprecated for CL > 1.0 because // this option was added for compatibility with OpenCL 1.0. |