1 //===- CompilationDatabasePluginRegistry.h ----------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H 11 #define LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H 12 13 #include "clang/Tooling/CompilationDatabase.h" 14 #include "llvm/Support/Registry.h" 15 16 namespace clang { 17 namespace tooling { 18 19 /// Interface for compilation database plugins. 20 /// 21 /// A compilation database plugin allows the user to register custom compilation 22 /// databases that are picked up as compilation database if the corresponding 23 /// library is linked in. To register a plugin, declare a static variable like: 24 /// 25 /// \code 26 /// static CompilationDatabasePluginRegistry::Add<MyDatabasePlugin> 27 /// X("my-compilation-database", "Reads my own compilation database"); 28 /// \endcode 29 class CompilationDatabasePlugin { 30 public: 31 virtual ~CompilationDatabasePlugin(); 32 33 /// Loads a compilation database from a build directory. 34 /// 35 /// \see CompilationDatabase::loadFromDirectory(). 36 virtual std::unique_ptr<CompilationDatabase> 37 loadFromDirectory(StringRef Directory, std::string &ErrorMessage) = 0; 38 }; 39 40 using CompilationDatabasePluginRegistry = 41 llvm::Registry<CompilationDatabasePlugin>; 42 43 } // namespace tooling 44 } // namespace clang 45 46 #endif // LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H 47