aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Driver/Compilation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Driver/Compilation.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Driver/Compilation.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/contrib/llvm-project/clang/lib/Driver/Compilation.cpp b/contrib/llvm-project/clang/lib/Driver/Compilation.cpp
index 0144d808cf12..ad077d5bbfa6 100644
--- a/contrib/llvm-project/clang/lib/Driver/Compilation.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/Compilation.cpp
@@ -15,15 +15,14 @@
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Util.h"
-#include "llvm/ADT/None.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/Triple.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptSpecifier.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/Triple.h"
#include <cassert>
#include <string>
#include <system_error>
@@ -102,7 +101,7 @@ Compilation::getArgsForToolChain(const ToolChain *TC, StringRef BoundArch,
}
// Add allocated arguments to the final DAL.
- for (auto ArgPtr : AllocatedArgs)
+ for (auto *ArgPtr : AllocatedArgs)
Entry->AddSynthesizedArg(ArgPtr);
}
@@ -162,7 +161,8 @@ bool Compilation::CleanupFileMap(const ArgStringMap &Files,
}
int Compilation::ExecuteCommand(const Command &C,
- const Command *&FailingCommand) const {
+ const Command *&FailingCommand,
+ bool LogOnly) const {
if ((getDriver().CCPrintOptions ||
getArgs().hasArg(options::OPT_v)) && !getDriver().CCGenDiagnostics) {
raw_ostream *OS = &llvm::errs();
@@ -174,7 +174,7 @@ int Compilation::ExecuteCommand(const Command &C,
!getDriver().CCPrintOptionsFilename.empty()) {
std::error_code EC;
OwnedStream.reset(new llvm::raw_fd_ostream(
- getDriver().CCPrintOptionsFilename.c_str(), EC,
+ getDriver().CCPrintOptionsFilename, EC,
llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF));
if (EC) {
getDriver().Diag(diag::err_drv_cc_print_options_failure)
@@ -191,6 +191,9 @@ int Compilation::ExecuteCommand(const Command &C,
C.Print(*OS, "\n", /*Quote=*/getDriver().CCPrintOptions);
}
+ if (LogOnly)
+ return 0;
+
std::string Error;
bool ExecutionFailed;
int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
@@ -237,7 +240,8 @@ static bool InputsOk(const Command &C,
}
void Compilation::ExecuteJobs(const JobList &Jobs,
- FailingCommandList &FailingCommands) const {
+ FailingCommandList &FailingCommands,
+ bool LogOnly) const {
// According to UNIX standard, driver need to continue compiling all the
// inputs on the command line even one of them failed.
// In all but CLMode, execute all the jobs unless the necessary inputs for the
@@ -246,7 +250,7 @@ void Compilation::ExecuteJobs(const JobList &Jobs,
if (!InputsOk(Job, FailingCommands))
continue;
const Command *FailingCommand = nullptr;
- if (int Res = ExecuteCommand(Job, FailingCommand)) {
+ if (int Res = ExecuteCommand(Job, FailingCommand, LogOnly)) {
FailingCommands.push_back(std::make_pair(Res, FailingCommand));
// Bail as soon as one command fails in cl driver mode.
if (TheDriver.IsCLMode())
@@ -278,9 +282,9 @@ void Compilation::initCompilationForDiagnostics() {
options::OPT_o, options::OPT_MD, options::OPT_MMD, options::OPT_M,
options::OPT_MM, options::OPT_MF, options::OPT_MG, options::OPT_MJ,
options::OPT_MQ, options::OPT_MT, options::OPT_MV};
- for (unsigned i = 0, e = llvm::array_lengthof(OutputOpts); i != e; ++i) {
- if (TranslatedArgs->hasArg(OutputOpts[i]))
- TranslatedArgs->eraseArg(OutputOpts[i]);
+ for (const auto &Opt : OutputOpts) {
+ if (TranslatedArgs->hasArg(Opt))
+ TranslatedArgs->eraseArg(Opt);
}
TranslatedArgs->ClaimAllArgs();
@@ -292,7 +296,7 @@ void Compilation::initCompilationForDiagnostics() {
TCArgs.clear();
// Redirect stdout/stderr to /dev/null.
- Redirects = {None, {""}, {""}};
+ Redirects = {std::nullopt, {""}, {""}};
// Temporary files added by diagnostics should be kept.
ForceKeepTempFiles = true;
@@ -302,6 +306,6 @@ StringRef Compilation::getSysRoot() const {
return getDriver().SysRoot;
}
-void Compilation::Redirect(ArrayRef<Optional<StringRef>> Redirects) {
+void Compilation::Redirect(ArrayRef<std::optional<StringRef>> Redirects) {
this->Redirects = Redirects;
}