diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2021-01-14 08:26:12 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2021-01-15 08:41:50 +0100 |
commit | c495dfe0268bc2be8737725d657411baa1399e9d (patch) | |
tree | 627b3eb1922f7352258eff9017686141b671db41 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 5508516b06633e95fb5c2d6a5e196e4dcaa72c8d (diff) | |
download | llvm-c495dfe0268bc2be8737725d657411baa1399e9d.zip llvm-c495dfe0268bc2be8737725d657411baa1399e9d.tar.gz llvm-c495dfe0268bc2be8737725d657411baa1399e9d.tar.bz2 |
[clang][cli] NFC: Decrease the scope of ParseLangArgs parameters
Instead of passing the whole `TargetOptions` and `PreprocessorOptions` to `ParseLangArgs` give it only the necessary members.
This makes tracking the dependencies between various parsers and option groups easier.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D94674
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 6327723..d80d1f7 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1889,7 +1889,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args, 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 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, 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 const StringRef GetInputKindName(InputKind IK) { } 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 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, 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 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, 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 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, // 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 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, } 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()) { |