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" 65 static std::unique_ptr<JSONCompilationDatabase>
66 loadFromFile(StringRef FilePath, std::string &ErrorMessage,
72 static std::unique_ptr<JSONCompilationDatabase>
73 loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage,
81 std::vector<CompileCommand>
82 getCompileCommands(StringRef FilePath)
const override;
87 std::vector<std::string> getAllFiles()
const override;
91 std::vector<CompileCommand> getAllCompileCommands()
const override;
97 : Database(std::move(Database)), Syntax(Syntax),
98 YAMLStream(this->Database->getBuffer(),
SM) {}
104 bool parse(std::string &ErrorMessage);
113 typedef std::tuple<llvm::yaml::ScalarNode *,
114 llvm::yaml::ScalarNode *,
115 std::vector<llvm::yaml::ScalarNode *>,
116 llvm::yaml::ScalarNode *> CompileCommandRef;
120 std::vector<CompileCommand> &Commands)
const;
123 llvm::StringMap<std::vector<CompileCommandRef>> IndexByFile;
127 std::vector<CompileCommandRef> AllCommands;
131 std::unique_ptr<llvm::MemoryBuffer> Database;
134 llvm::yaml::Stream YAMLStream;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Dataflow Directional Tag Classes.