diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-03-20 11:40:34 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-06-04 11:58:51 +0000 | 
| commit | 4b6eb0e63c698094db5506763df44cc83c19f643 (patch) | |
| tree | f1d30b8c10bc6db323b91538745ae8ab8b593910 /contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | |
| parent | 76886853f03395abb680824bcc74e98f83bd477a (diff) | |
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp')
| -rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp | 15 | 
1 files changed, 9 insertions, 6 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp b/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp index 2e23ebfdf160..c5627d13a7a7 100644 --- a/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -30,6 +30,7 @@ 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) { +  assert(!ArgList.empty());    if (!Diags.get()) {      // No diagnostics engine was provided, so create our own diagnostics object      // with the default options. @@ -79,22 +80,24 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(        }      }    } -  if (Jobs.size() == 0 || !isa<driver::Command>(*Jobs.begin()) || -      (Jobs.size() > 1 && !OffloadCompilation)) { + +  bool PickFirstOfMany = OffloadCompilation || ShouldRecoverOnErorrs; +  if (Jobs.size() == 0 || (Jobs.size() > 1 && !PickFirstOfMany)) {      SmallString<256> Msg;      llvm::raw_svector_ostream OS(Msg);      Jobs.Print(OS, "; ", true);      Diags->Report(diag::err_fe_expected_compiler_job) << OS.str();      return nullptr;    } - -  const driver::Command &Cmd = cast<driver::Command>(*Jobs.begin()); -  if (StringRef(Cmd.getCreator().getName()) != "clang") { +  auto Cmd = llvm::find_if(Jobs, [](const driver::Command &Cmd) { +    return StringRef(Cmd.getCreator().getName()) == "clang"; +  }); +  if (Cmd == Jobs.end()) {      Diags->Report(diag::err_fe_expected_clang_command);      return nullptr;    } -  const ArgStringList &CCArgs = Cmd.getArguments(); +  const ArgStringList &CCArgs = Cmd->getArguments();    if (CC1Args)      *CC1Args = {CCArgs.begin(), CCArgs.end()};    auto CI = std::make_unique<CompilerInvocation>();  | 
