PluginLoader.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- 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. // A tool can #include this file to get a -load option that allows the user to
  10. // load arbitrary shared objects into the tool's address space. Note that this
  11. // header can only be included by a program ONCE, so it should never to used by
  12. // library authors.
  13. //
  14. //===----------------------------------------------------------------------===//
  15. #ifndef LLVM_SUPPORT_PLUGINLOADER_H
  16. #define LLVM_SUPPORT_PLUGINLOADER_H
  17. #ifndef DONT_GET_PLUGIN_LOADER_OPTION
  18. #include "llvm/Support/CommandLine.h"
  19. #endif
  20. #include <string>
  21. namespace llvm {
  22. struct PluginLoader {
  23. void operator=(const std::string &Filename);
  24. static unsigned getNumPlugins();
  25. static std::string& getPlugin(unsigned num);
  26. };
  27. #ifndef DONT_GET_PLUGIN_LOADER_OPTION
  28. // This causes operator= above to be invoked for every -load option.
  29. static cl::opt<PluginLoader, false, cl::parser<std::string> >
  30. LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"),
  31. cl::desc("Load the specified plugin"));
  32. #endif
  33. }
  34. #endif