diff options
Diffstat (limited to 'include/clang/Tooling/JSONCompilationDatabase.h')
-rw-r--r-- | include/clang/Tooling/JSONCompilationDatabase.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/include/clang/Tooling/JSONCompilationDatabase.h b/include/clang/Tooling/JSONCompilationDatabase.h index 2a13fc155cead..9a6866240b08c 100644 --- a/include/clang/Tooling/JSONCompilationDatabase.h +++ b/include/clang/Tooling/JSONCompilationDatabase.h @@ -55,6 +55,7 @@ namespace tooling { /// /// JSON compilation databases can for example be generated in CMake projects /// by setting the flag -DCMAKE_EXPORT_COMPILE_COMMANDS. +enum class JSONCommandLineSyntax { Windows, Gnu, AutoDetect }; class JSONCompilationDatabase : public CompilationDatabase { public: /// \brief Loads a JSON compilation database from the specified file. @@ -62,15 +63,17 @@ public: /// Returns NULL and sets ErrorMessage if the database could not be /// loaded from the given file. static std::unique_ptr<JSONCompilationDatabase> - loadFromFile(StringRef FilePath, std::string &ErrorMessage); + loadFromFile(StringRef FilePath, std::string &ErrorMessage, + JSONCommandLineSyntax Syntax); /// \brief Loads a JSON compilation database from a data buffer. /// /// Returns NULL and sets ErrorMessage if the database could not be loaded. static std::unique_ptr<JSONCompilationDatabase> - loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage); + loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage, + JSONCommandLineSyntax Syntax); - /// \brief Returns all compile comamnds in which the specified file was + /// \brief Returns all compile commands in which the specified file was /// compiled. /// /// FIXME: Currently FilePath must be an absolute path inside the @@ -89,8 +92,9 @@ public: private: /// \brief Constructs a JSON compilation database on a memory buffer. - JSONCompilationDatabase(std::unique_ptr<llvm::MemoryBuffer> Database) - : Database(std::move(Database)), + JSONCompilationDatabase(std::unique_ptr<llvm::MemoryBuffer> Database, + JSONCommandLineSyntax Syntax) + : Database(std::move(Database)), Syntax(Syntax), YAMLStream(this->Database->getBuffer(), SM) {} /// \brief Parses the database file and creates the index. @@ -99,15 +103,17 @@ private: /// failed. bool parse(std::string &ErrorMessage); - // Tuple (directory, filename, commandline) where 'commandline' points to the - // corresponding scalar nodes in the YAML stream. + // Tuple (directory, filename, commandline, output) 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. + // The output field may be a nullptr. typedef std::tuple<llvm::yaml::ScalarNode *, llvm::yaml::ScalarNode *, - std::vector<llvm::yaml::ScalarNode *>> CompileCommandRef; + std::vector<llvm::yaml::ScalarNode *>, + llvm::yaml::ScalarNode *> CompileCommandRef; /// \brief Converts the given array of CompileCommandRefs to CompileCommands. void getCommands(ArrayRef<CompileCommandRef> CommandsRef, @@ -123,6 +129,7 @@ private: FileMatchTrie MatchTrie; std::unique_ptr<llvm::MemoryBuffer> Database; + JSONCommandLineSyntax Syntax; llvm::SourceMgr SM; llvm::yaml::Stream YAMLStream; }; |