From 5e20cdd81c44a443562a09007668ffdf76c455af Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 27 May 2015 18:47:56 +0000 Subject: Vendor import of clang trunk r238337: https://llvm.org/svn/llvm-project/cfe/trunk@238337 --- lib/Tooling/CompilationDatabase.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lib/Tooling/CompilationDatabase.cpp') diff --git a/lib/Tooling/CompilationDatabase.cpp b/lib/Tooling/CompilationDatabase.cpp index 7613988c96d9a..2514f027f4727 100644 --- a/lib/Tooling/CompilationDatabase.cpp +++ b/lib/Tooling/CompilationDatabase.cpp @@ -29,9 +29,8 @@ #include "llvm/Support/Path.h" #include #include - -namespace clang { -namespace tooling { +using namespace clang; +using namespace tooling; CompilationDatabase::~CompilationDatabase() {} @@ -109,6 +108,7 @@ CompilationDatabase::autoDetectFromDirectory(StringRef SourceDir, CompilationDatabasePlugin::~CompilationDatabasePlugin() {} +namespace { // Helper for recursively searching through a chain of actions and collecting // all inputs, direct and indirect, of compile jobs. struct CompileJobAnalyzer { @@ -156,8 +156,8 @@ public: // recording for our own purposes. UnusedInputDiagConsumer(DiagnosticConsumer *Other) : Other(Other) {} - virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, - const Diagnostic &Info) override { + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + 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)); @@ -183,6 +183,7 @@ struct MatchesAny { private: ArrayRef Arr; }; +} // namespace /// \brief Strips any positional args and possible argv[0] from a command-line /// provided by the user to construct a FixedCompilationDatabase. @@ -282,11 +283,9 @@ static bool stripPositionalArgs(std::vector Args, return true; } -FixedCompilationDatabase * -FixedCompilationDatabase::loadFromCommandLine(int &Argc, - const char **Argv, - Twine Directory) { - const char **DoubleDash = std::find(Argv, Argv + Argc, StringRef("--")); +FixedCompilationDatabase *FixedCompilationDatabase::loadFromCommandLine( + int &Argc, const char *const *Argv, Twine Directory) { + const char *const *DoubleDash = std::find(Argv, Argv + Argc, StringRef("--")); if (DoubleDash == Argv + Argc) return nullptr; std::vector CommandLine(DoubleDash + 1, Argv + Argc); @@ -324,6 +323,9 @@ FixedCompilationDatabase::getAllCompileCommands() const { return std::vector(); } +namespace clang { +namespace tooling { + // This anchor is used to force the linker to link in the generated object file // and thus register the JSONCompilationDatabasePlugin. extern volatile int JSONAnchorSource; -- cgit v1.2.3