[PATCH] D94674: [clang][cli] NFC: Decrease the scope of ParseLangArgs parameters
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 14 04:37:14 PST 2021
jansvoboda11 created this revision.
jansvoboda11 added reviewers: dexonsmith, Bigcheese.
jansvoboda11 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94674
Files:
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1889,7 +1889,7 @@
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
const llvm::Triple &T,
- PreprocessorOptions &PPOpts,
+ std::vector<std::string> &Includes,
LangStandard::Kind LangStd) {
// Set some properties which depend solely on the input kind; it would be nice
// to move these to the language standard, and have the driver resolve the
@@ -2000,9 +2000,9 @@
if (Opts.IncludeDefaultHeader) {
if (Opts.DeclareOpenCLBuiltins) {
// Only include base header file for builtin types and constants.
- PPOpts.Includes.push_back("opencl-c-base.h");
+ Includes.push_back("opencl-c-base.h");
} else {
- PPOpts.Includes.push_back("opencl-c.h");
+ Includes.push_back("opencl-c.h");
}
}
}
@@ -2138,8 +2138,8 @@
}
static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
- const TargetOptions &TargetOpts,
- PreprocessorOptions &PPOpts,
+ const llvm::Triple &T,
+ std::vector<std::string> &Includes,
DiagnosticsEngine &Diags) {
// FIXME: Cleanup per-file based stuff.
LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -2212,8 +2212,7 @@
Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
- llvm::Triple T(TargetOpts.Triple);
- CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
+ CompilerInvocation::setLangDefaults(Opts, IK, T, Includes, LangStd);
// -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
// This option should be deprecated for CL > 1.0 because
@@ -2490,7 +2489,6 @@
Diags.Report(diag::err_drv_argument_not_allowed_with)
<< A->getSpelling() << "-fdefault-calling-conv";
else {
- llvm::Triple T(TargetOpts.Triple);
if (T.getArch() != llvm::Triple::x86)
Diags.Report(diag::err_drv_argument_not_allowed_with)
<< A->getSpelling() << T.getTriple();
@@ -2527,8 +2525,7 @@
// Add unsupported host targets here:
case llvm::Triple::nvptx:
case llvm::Triple::nvptx64:
- Diags.Report(diag::err_drv_omp_host_target_not_supported)
- << TargetOpts.Triple;
+ Diags.Report(diag::err_drv_omp_host_target_not_supported) << T.str();
break;
}
}
@@ -2960,8 +2957,8 @@
} else {
// Other LangOpts are only initialized when the input is not AST or LLVM IR.
// FIXME: Should we really be calling this for an Language::Asm input?
- ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
- Res.getPreprocessorOpts(), Diags);
+ ParseLangArgs(LangOpts, Args, DashX, T, Res.getPreprocessorOpts().Includes,
+ Diags);
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
LangOpts.ObjCExceptions = 1;
if (T.isOSDarwin() && DashX.isPreprocessed()) {
Index: clang/include/clang/Frontend/CompilerInvocation.h
===================================================================
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -176,11 +176,12 @@
/// \param Opts - The LangOptions object to set up.
/// \param IK - The input language.
/// \param T - The target triple.
- /// \param PPOpts - The PreprocessorOptions affected.
+ /// \param Includes - The affected list of included files.
/// \param LangStd - The input language standard.
- static void setLangDefaults(LangOptions &Opts, InputKind IK,
- const llvm::Triple &T, PreprocessorOptions &PPOpts,
- LangStandard::Kind LangStd = LangStandard::lang_unspecified);
+ static void
+ setLangDefaults(LangOptions &Opts, InputKind IK, const llvm::Triple &T,
+ std::vector<std::string> &Includes,
+ LangStandard::Kind LangStd = LangStandard::lang_unspecified);
/// Retrieve a module hash string that is suitable for uniquely
/// identifying the conditions under which the module was built.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94674.316623.patch
Type: text/x-patch
Size: 4502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210114/a12abd50/attachment.bin>
More information about the cfe-commits
mailing list