15 #ifndef LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H
16 #define LLVM_CLANG_TOOLING_JSONCOMPILATIONDATABASE_H
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/MemoryBuffer.h"
24 #include "llvm/Support/SourceMgr.h"
25 #include "llvm/Support/YAMLParser.h"
56 static std::unique_ptr<JSONCompilationDatabase>
57 loadFromFile(StringRef FilePath, std::string &ErrorMessage);
62 static std::unique_ptr<JSONCompilationDatabase>
63 loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage);
70 std::vector<CompileCommand>
76 std::vector<std::string>
getAllFiles()
const override;
85 : Database(std::move(Database)),
86 YAMLStream(this->Database->getBuffer(), SM) {}
92 bool parse(std::string &ErrorMessage);
96 typedef std::pair<llvm::yaml::ScalarNode*,
97 llvm::yaml::ScalarNode*> CompileCommandRef;
101 std::vector<CompileCommand> &Commands)
const;
104 llvm::StringMap< std::vector<CompileCommandRef> > IndexByFile;
108 std::unique_ptr<llvm::MemoryBuffer> Database;
110 llvm::yaml::Stream YAMLStream;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...