diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2015-09-22 17:22:33 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2015-09-22 17:22:33 +0000 |
commit | 1a963b825c36012200d5bdb5ea2c2d6285980d29 (patch) | |
tree | 12372839a36fceb58fd256e0c536c73775191474 /lib/Tooling/JSONCompilationDatabase.cpp | |
parent | dd04d50d58e2a8b1f6be861aaba3c518c3a4a8b8 (diff) | |
download | clang-1a963b825c36012200d5bdb5ea2c2d6285980d29.tar.gz |
[tooling] Provide the compile commands of the JSON database in the order that they were provided in the JSON file.
This is useful for debugging of issues and reduction of test cases.
For example, an issue may show up due to the order that some commands were processed.
It is convenient to be able to remove commands from the file and still preserve the order
that they are returned, instead of getting a completely different order when removing a few commands.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248292 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Tooling/JSONCompilationDatabase.cpp')
-rw-r--r-- | lib/Tooling/JSONCompilationDatabase.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp index dd4d7a8f08..299fbdc149 100644 --- a/lib/Tooling/JSONCompilationDatabase.cpp +++ b/lib/Tooling/JSONCompilationDatabase.cpp @@ -206,11 +206,7 @@ JSONCompilationDatabase::getAllFiles() const { std::vector<CompileCommand> JSONCompilationDatabase::getAllCompileCommands() const { std::vector<CompileCommand> Commands; - for (llvm::StringMap< std::vector<CompileCommandRef> >::const_iterator - CommandsRefI = IndexByFile.begin(), CommandsRefEnd = IndexByFile.end(); - CommandsRefI != CommandsRefEnd; ++CommandsRefI) { - getCommands(CommandsRefI->getValue(), Commands); - } + getCommands(AllCommands, Commands); return Commands; } @@ -337,8 +333,9 @@ bool JSONCompilationDatabase::parse(std::string &ErrorMessage) { } else { llvm::sys::path::native(FileName, NativeFilePath); } - IndexByFile[NativeFilePath].push_back( - CompileCommandRef(Directory, File, *Command)); + auto Cmd = CompileCommandRef(Directory, File, *Command); + IndexByFile[NativeFilePath].push_back(Cmd); + AllCommands.push_back(Cmd); MatchTrie.insert(NativeFilePath); } return true; |