15 #ifndef LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H 16 #define LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H 21 #include "llvm/ADT/ArrayRef.h" 22 #include "llvm/ADT/StringMap.h" 23 #include "llvm/ADT/StringRef.h" 24 #include "llvm/Support/MemoryBuffer.h" 25 #include "llvm/Support/SourceMgr.h" 26 #include "llvm/Support/YAMLParser.h" 68 static std::unique_ptr<JSONCompilationDatabase>
69 loadFromFile(StringRef FilePath, std::string &ErrorMessage,
75 static std::unique_ptr<JSONCompilationDatabase>
76 loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage,
84 std::vector<CompileCommand>
85 getCompileCommands(StringRef FilePath)
const override;
90 std::vector<std::string> getAllFiles()
const override;
94 std::vector<CompileCommand> getAllCompileCommands()
const override;
100 : Database(std::move(Database)), Syntax(Syntax),
101 YAMLStream(this->Database->getBuffer(),
SM) {}
107 bool parse(std::string &ErrorMessage);
116 using CompileCommandRef =
117 std::tuple<llvm::yaml::ScalarNode *, llvm::yaml::ScalarNode *,
118 std::vector<llvm::yaml::ScalarNode *>,
119 llvm::yaml::ScalarNode *>;
123 std::vector<CompileCommand> &Commands)
const;
126 llvm::StringMap<std::vector<CompileCommandRef>> IndexByFile;
130 std::vector<CompileCommandRef> AllCommands;
134 std::unique_ptr<llvm::MemoryBuffer> Database;
137 llvm::yaml::Stream YAMLStream;
143 #endif // LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Dataflow Directional Tag Classes.