Skip to content

Commit a7dcd3a

Browse files
committed
[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
1 parent 3832629 commit a7dcd3a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,12 +2196,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
21962196
}
21972197
}
21982198

2199-
if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
2200-
StringRef Name = A->getValue();
2201-
if (Name == "full" || Name == "branch") {
2202-
Opts.CFProtectionBranch = 1;
2203-
}
2204-
}
22052199
// -cl-std only applies for OpenCL language standards.
22062200
// Override the -std option in this case.
22072201
if (const Arg *A = Args.getLastArg(OPT_cl_std_EQ)) {
@@ -2224,14 +2218,21 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
22242218
LangStd = OpenCLLangStd;
22252219
}
22262220

2227-
Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
2228-
22292221
// These need to be parsed now. They are used to set OpenCL defaults.
22302222
Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
22312223
Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
22322224

22332225
CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
22342226

2227+
if (const Arg *A = Args.getLastArg(OPT_fcf_protection_EQ)) {
2228+
StringRef Name = A->getValue();
2229+
if (Name == "full" || Name == "branch") {
2230+
Opts.CFProtectionBranch = 1;
2231+
}
2232+
}
2233+
2234+
Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
2235+
22352236
// -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
22362237
// This option should be deprecated for CL > 1.0 because
22372238
// this option was added for compatibility with OpenCL 1.0.

0 commit comments

Comments
 (0)