summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/CompilationDatabase.cpp
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
commitff26efceb44ad0ced3bf1006d5a85e21426e9956 (patch)
treea975485f7452c2d654263c0570fef347ed15000e /clang/lib/Tooling/CompilationDatabase.cpp
parent4d4d02575165600e9212c17275e0868f7f17fa1e (diff)
downloadbcm5719-llvm-ff26efceb44ad0ced3bf1006d5a85e21426e9956.tar.gz
bcm5719-llvm-ff26efceb44ad0ced3bf1006d5a85e21426e9956.zip
Adds a FixedCompilationDatabase to be able to specify tool parameters
at the command line. llvm-svn: 154989
Diffstat (limited to 'clang/lib/Tooling/CompilationDatabase.cpp')
-rw-r--r--clang/lib/Tooling/CompilationDatabase.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index f8993658da3..dd9ccc07b60 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud