aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2012-04-18 07:41:50 +0000
committerManuel Klimek <klimek@google.com>2012-04-18 07:41:50 +0000
commit30318e6df9c8c24d080211dfb92ef8065fa7381c (patch)
tree928c1951e5c086cb47024a690c0fa85579ed2a59 /lib
parent6403683411dac55afbe3435ceb19033e27cd9f96 (diff)
Adds a FixedCompilationDatabase to be able to specify tool parameters
at the command line. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154989 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Tooling/CompilationDatabase.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Tooling/CompilationDatabase.cpp b/lib/Tooling/CompilationDatabase.cpp
index f8993658da..dd9ccc07b6 100644
--- a/lib/Tooling/CompilationDatabase.cpp
+++ b/lib/Tooling/CompilationDatabase.cpp
@@ -121,6 +121,33 @@ CompilationDatabase::loadFromDirectory(StringRef BuildDirectory,
return Database.take();
}
+FixedCompilationDatabase *
+FixedCompilationDatabase::loadFromCommandLine(int &Argc,
+ const char **Argv,
+ Twine Directory) {
+ const char **DoubleDash = std::find(Argv, Argv + Argc, StringRef("--"));
+ if (DoubleDash == Argv + Argc)
+ return NULL;
+ std::vector<std::string> CommandLine(DoubleDash + 1, Argv + Argc);
+ Argc = DoubleDash - Argv;
+ return new FixedCompilationDatabase(Directory, CommandLine);
+}
+
+FixedCompilationDatabase::
+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));
+}
+
+std::vector<CompileCommand>
+FixedCompilationDatabase::getCompileCommands(StringRef FilePath) const {
+ std::vector<CompileCommand> Result(CompileCommands);
+ Result[0].CommandLine.push_back(FilePath);
+ return Result;
+}
+
JSONCompilationDatabase *
JSONCompilationDatabase::loadFromFile(StringRef FilePath,
std::string &ErrorMessage) {