aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Compilation.cpp
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2018-03-20 21:08:59 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2018-03-20 21:08:59 +0000
commit5e4511cfc7e04c4bff78af66843f1625832a03d5 (patch)
treee48dbf9066f3b2a012282330995d2d7bf0a2b832 /clang/lib/Driver/Compilation.cpp
parent0f110a88bef3b2e46c029c21d9352a120cd995dd (diff)
downloadllvm-5e4511cfc7e04c4bff78af66843f1625832a03d5.zip
llvm-5e4511cfc7e04c4bff78af66843f1625832a03d5.tar.gz
llvm-5e4511cfc7e04c4bff78af66843f1625832a03d5.tar.bz2
[Driver] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 328044
Diffstat (limited to 'clang/lib/Driver/Compilation.cpp')
-rw-r--r--clang/lib/Driver/Compilation.cpp46
1 files changed, 26 insertions, 20 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index 645da50..5944936 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -1,4 +1,4 @@
-//===--- Compilation.cpp - Compilation Task Implementation ----------------===//
+//===- Compilation.cpp - Compilation Task Implementation ------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,26 +8,37 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/Compilation.h"
+#include "clang/Basic/LLVM.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/Job.h"
#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 <cassert>
+#include <string>
+#include <system_error>
+#include <utility>
-using namespace clang::driver;
using namespace clang;
+using namespace driver;
using namespace llvm::opt;
Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain,
InputArgList *_Args, DerivedArgList *_TranslatedArgs,
bool ContainsError)
- : TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u),
- Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false),
- ContainsError(ContainsError) {
+ : TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args),
+ TranslatedArgs(_TranslatedArgs), ContainsError(ContainsError) {
// The offloading host toolchain is the default toolchain.
OrderedOffloadingToolchains.insert(
std::make_pair(Action::OFK_Host, &DefaultToolChain));
@@ -74,9 +85,8 @@ 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);
- }
}
return *Entry;
@@ -105,7 +115,7 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
// so we don't need to check again.
if (IssueErrors)
- getDriver().Diag(clang::diag::err_drv_unable_to_remove_file)
+ getDriver().Diag(diag::err_drv_unable_to_remove_file)
<< EC.message();
return false;
}
@@ -115,9 +125,8 @@ bool Compilation::CleanupFile(const char *File, bool IssueErrors) const {
bool Compilation::CleanupFileList(const ArgStringList &Files,
bool IssueErrors) const {
bool Success = true;
- for (ArgStringList::const_iterator
- it = Files.begin(), ie = Files.end(); it != ie; ++it)
- Success &= CleanupFile(*it, IssueErrors);
+ for (const auto &File: Files)
+ Success &= CleanupFile(File, IssueErrors);
return Success;
}
@@ -125,14 +134,12 @@ bool Compilation::CleanupFileMap(const ArgStringMap &Files,
const JobAction *JA,
bool IssueErrors) const {
bool Success = true;
- for (ArgStringMap::const_iterator
- it = Files.begin(), ie = Files.end(); it != ie; ++it) {
-
+ for (const auto &File : Files) {
// If specified, only delete the files associated with the JobAction.
// Otherwise, delete all files in the map.
- if (JA && it->first != JA)
+ if (JA && File.first != JA)
continue;
- Success &= CleanupFile(it->second, IssueErrors);
+ Success &= CleanupFile(File.second, IssueErrors);
}
return Success;
}
@@ -151,7 +158,7 @@ int Compilation::ExecuteCommand(const Command &C,
llvm::sys::fs::F_Append |
llvm::sys::fs::F_Text);
if (EC) {
- getDriver().Diag(clang::diag::err_drv_cc_print_options_failure)
+ getDriver().Diag(diag::err_drv_cc_print_options_failure)
<< EC.message();
FailingCommand = &C;
delete OS;
@@ -173,7 +180,7 @@ int Compilation::ExecuteCommand(const Command &C,
int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
if (!Error.empty()) {
assert(Res && "Error string set with 0 result code!");
- getDriver().Diag(clang::diag::err_drv_command_failure) << Error;
+ getDriver().Diag(diag::err_drv_command_failure) << Error;
}
if (Res)
@@ -186,7 +193,6 @@ using FailingCommandList = SmallVectorImpl<std::pair<int, const Command *>>;
static bool ActionFailed(const Action *A,
const FailingCommandList &FailingCommands) {
-
if (FailingCommands.empty())
return false;
@@ -200,7 +206,7 @@ static bool ActionFailed(const Action *A,
if (A == &(CI.second->getSource()))
return true;
- for (const Action *AI : A->inputs())
+ for (const auto *AI : A->inputs())
if (ActionFailed(AI, FailingCommands))
return true;