llvm.org GIT mirror llvm / 4b93476
Remember plugins should someone like bugpoint want to know them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25649 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Lenharth 14 years ago
2 changed file(s) with 17 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2121 namespace llvm {
2222 struct PluginLoader {
2323 void operator=(const std::string &Filename);
24 static unsigned getNumPlugins();
25 static std::string& getPlugin(unsigned num);
2426 };
2527
2628 #ifndef DONT_GET_PLUGIN_LOADER_OPTION
1414 #include "llvm/Support/PluginLoader.h"
1515 #include "llvm/System/DynamicLibrary.h"
1616 #include
17 #include
1718
1819 using namespace llvm;
20
21 std::vector plugins;
1922
2023 void PluginLoader::operator=(const std::string &Filename) {
2124 std::string ErrorMessage;
2225 try {
2326 sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str());
27 plugins.push_back(Filename);
2428 } catch (const std::string& errmsg) {
2529 if (errmsg.empty()) {
2630 ErrorMessage = "Unknown";
3236 std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
3337 << "\n -load request ignored.\n";
3438 }
39
40 unsigned PluginLoader::getNumPlugins()
41 {
42 return plugins.size();
43 }
44
45 std::string& PluginLoader::getPlugin(unsigned num)
46 {
47 assert(num < plugins.size() && "Asking for an out of bounds plugin");
48 return plugins[num];
49 }