xref: /freebsd-src/contrib/llvm-project/clang/include/clang/Tooling/CompilationDatabasePluginRegistry.h (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===- CompilationDatabasePluginRegistry.h ----------------------*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #ifndef LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
10*0b57cec5SDimitry Andric #define LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
11*0b57cec5SDimitry Andric 
12*0b57cec5SDimitry Andric #include "clang/Tooling/CompilationDatabase.h"
13*0b57cec5SDimitry Andric #include "llvm/Support/Registry.h"
14*0b57cec5SDimitry Andric 
15*0b57cec5SDimitry Andric namespace clang {
16*0b57cec5SDimitry Andric namespace tooling {
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric /// Interface for compilation database plugins.
19*0b57cec5SDimitry Andric ///
20*0b57cec5SDimitry Andric /// A compilation database plugin allows the user to register custom compilation
21*0b57cec5SDimitry Andric /// databases that are picked up as compilation database if the corresponding
22*0b57cec5SDimitry Andric /// library is linked in. To register a plugin, declare a static variable like:
23*0b57cec5SDimitry Andric ///
24*0b57cec5SDimitry Andric /// \code
25*0b57cec5SDimitry Andric /// static CompilationDatabasePluginRegistry::Add<MyDatabasePlugin>
26*0b57cec5SDimitry Andric /// X("my-compilation-database", "Reads my own compilation database");
27*0b57cec5SDimitry Andric /// \endcode
28*0b57cec5SDimitry Andric class CompilationDatabasePlugin {
29*0b57cec5SDimitry Andric public:
30*0b57cec5SDimitry Andric   virtual ~CompilationDatabasePlugin();
31*0b57cec5SDimitry Andric 
32*0b57cec5SDimitry Andric   /// Loads a compilation database from a build directory.
33*0b57cec5SDimitry Andric   ///
34*0b57cec5SDimitry Andric   /// \see CompilationDatabase::loadFromDirectory().
35*0b57cec5SDimitry Andric   virtual std::unique_ptr<CompilationDatabase>
36*0b57cec5SDimitry Andric   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) = 0;
37*0b57cec5SDimitry Andric };
38*0b57cec5SDimitry Andric 
39*0b57cec5SDimitry Andric using CompilationDatabasePluginRegistry =
40*0b57cec5SDimitry Andric     llvm::Registry<CompilationDatabasePlugin>;
41*0b57cec5SDimitry Andric 
42*0b57cec5SDimitry Andric } // namespace tooling
43*0b57cec5SDimitry Andric } // namespace clang
44*0b57cec5SDimitry Andric 
45*0b57cec5SDimitry Andric #endif // LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
46