aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-09-11 20:43:05 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-09-11 20:43:05 +0000
commit74bcd21e342faffb558ff58d635f4c974c4213fc (patch)
treeff003ed177014ce223a0d7f2ea6900e480f6a522 /clang/lib
parent744267765caabf432cbcc126ad2726d96761a865 (diff)
downloadllvm-74bcd21e342faffb558ff58d635f4c974c4213fc.zip
llvm-74bcd21e342faffb558ff58d635f4c974c4213fc.tar.gz
llvm-74bcd21e342faffb558ff58d635f4c974c4213fc.tar.bz2
[tooling] In CompileCommand, Expose the 'file' that was associated with the command.
llvm-svn: 247468
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Tooling/CompilationDatabase.cpp4
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp9
2 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index c1817b7..957e401 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -299,13 +299,15 @@ FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
std::vector<std::string> ToolCommandLine(1, "clang-tool");
ToolCommandLine.insert(ToolCommandLine.end(),
CommandLine.begin(), CommandLine.end());
- CompileCommands.emplace_back(Directory, std::move(ToolCommandLine));
+ CompileCommands.emplace_back(Directory, StringRef(),
+ std::move(ToolCommandLine));
}
std::vector<CompileCommand>
FixedCompilationDatabase::getCompileCommands(StringRef FilePath) const {
std::vector<CompileCommand> Result(CompileCommands);
Result[0].CommandLine.push_back(FilePath);
+ Result[0].Filename = FilePath;
return Result;
}
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 3ac6f69..dd4d7a8 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -232,8 +232,11 @@ void JSONCompilationDatabase::getCommands(
std::vector<CompileCommand> &Commands) const {
for (int I = 0, E = CommandsRef.size(); I != E; ++I) {
SmallString<8> DirectoryStorage;
- Commands.emplace_back(CommandsRef[I].first->getValue(DirectoryStorage),
- nodeToCommandLine(CommandsRef[I].second));
+ SmallString<32> FilenameStorage;
+ Commands.emplace_back(
+ std::get<0>(CommandsRef[I])->getValue(DirectoryStorage),
+ std::get<1>(CommandsRef[I])->getValue(FilenameStorage),
+ nodeToCommandLine(std::get<2>(CommandsRef[I])));
}
}
@@ -335,7 +338,7 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) {
llvm::sys::path::native(FileName, NativeFilePath);
}
IndexByFile[NativeFilePath].push_back(
- CompileCommandRef(Directory, *Command));
+ CompileCommandRef(Directory, File, *Command));
MatchTrie.insert(NativeFilePath);
}
return true;