aboutsummaryrefslogtreecommitdiff
path: root/lib/Tooling/CompilationDatabase.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2012-07-13 12:31:45 +0000
committerManuel Klimek <klimek@google.com>2012-07-13 12:31:45 +0000
commita3c70966babdd6c63623470fbba9bb4ec37de4a5 (patch)
treeaffd8fdc1d19b656480a03f739244de6368b56f6 /lib/Tooling/CompilationDatabase.cpp
parent838925dc841f0968ac5daf941aed5d2331775a59 (diff)
Allows retrieving all files in a CompilationDatabase.
Patch by Tobias Koenig, some test changes by myself. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/CompilationDatabase.cpp')
-rw-r--r--lib/Tooling/CompilationDatabase.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Tooling/CompilationDatabase.cpp b/lib/Tooling/CompilationDatabase.cpp
index d54a5e79eb..802a4c3ea4 100644
--- a/lib/Tooling/CompilationDatabase.cpp
+++ b/lib/Tooling/CompilationDatabase.cpp
@@ -199,6 +199,11 @@ FixedCompilationDatabase::getCompileCommands(StringRef FilePath) const {
return Result;
}
+std::vector<std::string>
+FixedCompilationDatabase::getAllFiles() const {
+ return std::vector<std::string>();
+}
+
JSONCompilationDatabase *
JSONCompilationDatabase::loadFromFile(StringRef FilePath,
std::string &ErrorMessage) {
@@ -249,6 +254,21 @@ JSONCompilationDatabase::getCompileCommands(StringRef FilePath) const {
return Commands;
}
+std::vector<std::string>
+JSONCompilationDatabase::getAllFiles() const {
+ std::vector<std::string> Result;
+
+ llvm::StringMap< std::vector<CompileCommandRef> >::const_iterator
+ CommandsRefI = IndexByFile.begin();
+ const llvm::StringMap< std::vector<CompileCommandRef> >::const_iterator
+ CommandsRefEnd = IndexByFile.end();
+ for (; CommandsRefI != CommandsRefEnd; ++CommandsRefI) {
+ Result.push_back(CommandsRefI->first().str());
+ }
+
+ return Result;
+}
+
bool JSONCompilationDatabase::parse(std::string &ErrorMessage) {
llvm::yaml::document_iterator I = YAMLStream.begin();
if (I == YAMLStream.end()) {