From 3176e97f130184ece0e1a21352c8124cc83ff24a Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 30 Dec 2015 11:49:41 +0000 Subject: Vendor import of clang trunk r256633: https://llvm.org/svn/llvm-project/cfe/trunk@256633 --- include/clang/Tooling/JSONCompilationDatabase.h | 31 +++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'include/clang/Tooling/JSONCompilationDatabase.h') diff --git a/include/clang/Tooling/JSONCompilationDatabase.h b/include/clang/Tooling/JSONCompilationDatabase.h index b4edc31..2a13fc1 100644 --- a/include/clang/Tooling/JSONCompilationDatabase.h +++ b/include/clang/Tooling/JSONCompilationDatabase.h @@ -33,18 +33,26 @@ namespace tooling { /// \brief A JSON based compilation database. /// /// JSON compilation database files must contain a list of JSON objects which -/// provide the command lines in the attributes 'directory', 'command' and -/// 'file': +/// provide the command lines in the attributes 'directory', 'command', +/// 'arguments' and 'file': /// [ /// { "directory": "", /// "command": "", /// "file": "" /// }, +/// { "directory": "", +/// "arguments": ["", "" "" ""], +/// "file": "" +/// }, /// ... /// ] /// Each object entry defines one compile action. The specified file is /// considered to be the main source file for the translation unit. /// +/// 'command' is a full command line that will be unescaped. +/// +/// 'arguments' is a list of command line arguments that will not be unescaped. +/// /// JSON compilation databases can for example be generated in CMake projects /// by setting the flag -DCMAKE_EXPORT_COMPILE_COMMANDS. class JSONCompilationDatabase : public CompilationDatabase { @@ -91,17 +99,26 @@ private: /// failed. bool parse(std::string &ErrorMessage); - // Tuple (directory, commandline) where 'commandline' pointing to the - // corresponding nodes in the YAML stream. - typedef std::pair CompileCommandRef; + // Tuple (directory, filename, commandline) where 'commandline' points to the + // corresponding scalar nodes in the YAML stream. + // If the command line contains a single argument, it is a shell-escaped + // command line. + // Otherwise, each entry in the command line vector is a literal + // argument to the compiler. + typedef std::tuple> CompileCommandRef; /// \brief Converts the given array of CompileCommandRefs to CompileCommands. void getCommands(ArrayRef CommandsRef, std::vector &Commands) const; // Maps file paths to the compile command lines for that file. - llvm::StringMap< std::vector > IndexByFile; + llvm::StringMap> IndexByFile; + + /// All the compile commands in the order that they were provided in the + /// JSON stream. + std::vector AllCommands; FileMatchTrie MatchTrie; -- cgit v1.1