CompilationDatabasePluginRegistry.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- CompilationDatabasePluginRegistry.h ----------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
  14. #define LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
  15. #include "clang/Tooling/CompilationDatabase.h"
  16. #include "llvm/Support/Registry.h"
  17. namespace clang {
  18. namespace tooling {
  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. /// Loads a compilation database from a build directory.
  33. ///
  34. /// \see CompilationDatabase::loadFromDirectory().
  35. virtual std::unique_ptr<CompilationDatabase>
  36. loadFromDirectory(StringRef Directory, std::string &ErrorMessage) = 0;
  37. };
  38. using CompilationDatabasePluginRegistry =
  39. llvm::Registry<CompilationDatabasePlugin>;
  40. } // namespace tooling
  41. } // namespace clang
  42. #endif // LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
  43. #ifdef __GNUC__
  44. #pragma GCC diagnostic pop
  45. #endif