1 //===- CompilationDatabasePluginRegistry.h ----------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H 10 #define LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H 11 12 #include "clang/Support/Compiler.h" 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 namespace llvm { 47 extern template class CLANG_TEMPLATE_ABI 48 Registry<clang::tooling::CompilationDatabasePlugin>; 49 } // namespace llvm 50 51 #endif // LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H 52