blob: 95c087f03d9bf971608c9147aeb919e251ad6d4e [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
16#ifndef LLVM_SUPPORT_PLUGINLOADER_H
17#define LLVM_SUPPORT_PLUGINLOADER_H
18
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020019#ifndef DONT_GET_PLUGIN_LOADER_OPTION
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010020#include "llvm/Support/CommandLine.h"
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020021#endif
22
23#include <string>
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010024
25namespace llvm {
26 struct PluginLoader {
27 void operator=(const std::string &Filename);
28 static unsigned getNumPlugins();
29 static std::string& getPlugin(unsigned num);
30 };
31
32#ifndef DONT_GET_PLUGIN_LOADER_OPTION
33 // This causes operator= above to be invoked for every -load option.
34 static cl::opt<PluginLoader, false, cl::parser<std::string> >
35 LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"),
36 cl::desc("Load the specified plugin"));
37#endif
38}
39
40#endif