summaryrefslogtreecommitdiff
path: root/external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp
diff options
context:
space:
mode:
authorjoerg <joerg@NetBSD.org>2014-05-30 18:13:37 +0000
committerjoerg <joerg@NetBSD.org>2014-05-30 18:13:37 +0000
commitafb6842aba94daaa92cf6da14f14e79943a4b315 (patch)
tree73c8d7687de2d406457602d3a873497cdd38f5fe /external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp
parent9e68444d2911346f3a60c226b76244119cd3a530 (diff)
Import Clang 3.5svn r209886.
Diffstat (limited to 'external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp')
-rw-r--r--external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp b/external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp
index 9dc23ed908a..94bdc8d25a4 100644
--- a/external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/external/bsd/llvm/dist/clang/lib/Tooling/CompilationDatabase.cpp
@@ -14,6 +14,7 @@
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
@@ -43,7 +44,7 @@ CompilationDatabase::loadFromDirectory(StringRef BuildDirectory,
Ie = CompilationDatabasePluginRegistry::end();
It != Ie; ++It) {
std::string DatabaseErrorMessage;
- OwningPtr<CompilationDatabasePlugin> Plugin(It->instantiate());
+ std::unique_ptr<CompilationDatabasePlugin> Plugin(It->instantiate());
if (CompilationDatabase *DB =
Plugin->loadFromDirectory(BuildDirectory, DatabaseErrorMessage))
return DB;
@@ -51,7 +52,7 @@ CompilationDatabase::loadFromDirectory(StringRef BuildDirectory,
ErrorStream << It->getName() << ": " << DatabaseErrorMessage << "\n";
}
ErrorMessage = ErrorStream.str();
- return NULL;
+ return nullptr;
}
static CompilationDatabase *
@@ -75,7 +76,7 @@ findCompilationDatabaseFromDirectory(StringRef Directory,
Directory = llvm::sys::path::parent_path(Directory);
}
ErrorMessage = ErrorStream.str();
- return NULL;
+ return nullptr;
}
CompilationDatabase *
@@ -150,14 +151,14 @@ private:
// options.
class UnusedInputDiagConsumer : public DiagnosticConsumer {
public:
- UnusedInputDiagConsumer() : Other(0) {}
+ UnusedInputDiagConsumer() : Other(nullptr) {}
// Useful for debugging, chain diagnostics to another consumer after
// recording for our own purposes.
UnusedInputDiagConsumer(DiagnosticConsumer *Other) : Other(Other) {}
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) LLVM_OVERRIDE {
+ const Diagnostic &Info) override {
if (Info.getID() == clang::diag::warn_drv_input_file_unused) {
// Arg 1 for this diagnostic is the option that didn't get used.
UnusedInputs.push_back(Info.getArgStdStr(0));
@@ -211,11 +212,11 @@ static bool stripPositionalArgs(std::vector<const char *> Args,
IntrusiveRefCntPtr<clang::DiagnosticIDs>(new DiagnosticIDs()),
&*DiagOpts, &DiagClient, false);
- // Neither clang executable nor default image name are required since the
- // jobs the driver builds will not be executed.
- OwningPtr<driver::Driver> NewDriver(new driver::Driver(
+ // The clang executable path isn't required since the jobs the driver builds
+ // will not be executed.
+ std::unique_ptr<driver::Driver> NewDriver(new driver::Driver(
/* ClangExecutable= */ "", llvm::sys::getDefaultTargetTriple(),
- /* DefaultImageName= */ "", Diagnostics));
+ Diagnostics));
NewDriver->setCheckInputsExist(false);
// This becomes the new argv[0]. The value is actually not important as it
@@ -238,10 +239,11 @@ static bool stripPositionalArgs(std::vector<const char *> Args,
// Remove -no-integrated-as; it's not used for syntax checking,
// and it confuses targets which don't support this option.
- std::remove_if(Args.begin(), Args.end(),
- MatchesAny(std::string("-no-integrated-as")));
+ Args.erase(std::remove_if(Args.begin(), Args.end(),
+ MatchesAny(std::string("-no-integrated-as"))),
+ Args.end());
- const OwningPtr<driver::Compilation> Compilation(
+ const std::unique_ptr<driver::Compilation> Compilation(
NewDriver->BuildCompilation(Args));
const driver::JobList &Jobs = Compilation->getJobs();
@@ -288,13 +290,13 @@ FixedCompilationDatabase::loadFromCommandLine(int &Argc,
Twine Directory) {
const char **DoubleDash = std::find(Argv, Argv + Argc, StringRef("--"));
if (DoubleDash == Argv + Argc)
- return NULL;
+ return nullptr;
std::vector<const char *> CommandLine(DoubleDash + 1, Argv + Argc);
Argc = DoubleDash - Argv;
std::vector<std::string> StrippedArgs;
if (!stripPositionalArgs(CommandLine, StrippedArgs))
- return 0;
+ return nullptr;
return new FixedCompilationDatabase(Directory, StrippedArgs);
}
@@ -303,7 +305,8 @@ FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
std::vector<std::string> ToolCommandLine(1, "clang-tool");
ToolCommandLine.insert(ToolCommandLine.end(),
CommandLine.begin(), CommandLine.end());
- CompileCommands.push_back(CompileCommand(Directory, ToolCommandLine));
+ CompileCommands.push_back(
+ CompileCommand(Directory, std::move(ToolCommandLine)));
}
std::vector<CompileCommand>