diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-04 19:20:19 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-08 19:02:26 +0000 |
commit | 81ad626541db97eb356e2c1d4a20eb2a26a766ab (patch) | |
tree | 311b6a8987c32b1e1dcbab65c54cfac3fdb56175 /contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | |
parent | 5fff09660e06a66bed6482da9c70df328e16bbb6 (diff) | |
parent | 145449b1e420787bb99721a429341fa6be3adfb6 (diff) |
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp index c5627d13a7a7..35b5e2144e6d 100644 --- a/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -26,16 +26,13 @@ using namespace clang; using namespace llvm::opt; -std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine( - ArrayRef<const char *> ArgList, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, - IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool ShouldRecoverOnErorrs, - std::vector<std::string> *CC1Args) { +std::unique_ptr<CompilerInvocation> +clang::createInvocation(ArrayRef<const char *> ArgList, + CreateInvocationOptions Opts) { assert(!ArgList.empty()); - if (!Diags.get()) { - // No diagnostics engine was provided, so create our own diagnostics object - // with the default options. - Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions); - } + auto Diags = Opts.Diags + ? std::move(Opts.Diags) + : CompilerInstance::createDiagnostics(new DiagnosticOptions); SmallVector<const char *, 16> Args(ArgList.begin(), ArgList.end()); @@ -47,15 +44,19 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine( // FIXME: We shouldn't have to pass in the path info. driver::Driver TheDriver(Args[0], llvm::sys::getDefaultTargetTriple(), *Diags, - "clang LLVM compiler", VFS); + "clang LLVM compiler", Opts.VFS); // Don't check that inputs exist, they may have been remapped. TheDriver.setCheckInputsExist(false); + TheDriver.setProbePrecompiled(Opts.ProbePrecompiled); std::unique_ptr<driver::Compilation> C(TheDriver.BuildCompilation(Args)); if (!C) return nullptr; + if (C->getArgs().hasArg(driver::options::OPT_fdriver_only)) + return nullptr; + // Just print the cc1 options if -### was present. if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) { C->getJobs().Print(llvm::errs(), "\n", true); @@ -81,7 +82,7 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine( } } - bool PickFirstOfMany = OffloadCompilation || ShouldRecoverOnErorrs; + bool PickFirstOfMany = OffloadCompilation || Opts.RecoverOnError; if (Jobs.size() == 0 || (Jobs.size() > 1 && !PickFirstOfMany)) { SmallString<256> Msg; llvm::raw_svector_ostream OS(Msg); @@ -98,11 +99,11 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine( } const ArgStringList &CCArgs = Cmd->getArguments(); - if (CC1Args) - *CC1Args = {CCArgs.begin(), CCArgs.end()}; + if (Opts.CC1Args) + *Opts.CC1Args = {CCArgs.begin(), CCArgs.end()}; auto CI = std::make_unique<CompilerInvocation>(); if (!CompilerInvocation::CreateFromArgs(*CI, CCArgs, *Diags, Args[0]) && - !ShouldRecoverOnErorrs) + !Opts.RecoverOnError) return nullptr; return CI; } |