diff options
author | Andrew Lenharth <andrewl@lenharth.org> | 2006-01-26 18:36:50 +0000 |
---|---|---|
committer | Andrew Lenharth <andrewl@lenharth.org> | 2006-01-26 18:36:50 +0000 |
commit | 4b934766bde8989b4eeb3f4a1cc222327e262379 (patch) | |
tree | a0786bf98fd63dd5742b3476b33bc776caeca30f | |
parent | c20dee356650a2f91533be5e36526f9774e0a1f8 (diff) | |
download | external_llvm-4b934766bde8989b4eeb3f4a1cc222327e262379.zip external_llvm-4b934766bde8989b4eeb3f4a1cc222327e262379.tar.gz external_llvm-4b934766bde8989b4eeb3f4a1cc222327e262379.tar.bz2 |
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
-rw-r--r-- | include/llvm/Support/PluginLoader.h | 2 | ||||
-rw-r--r-- | lib/Support/PluginLoader.cpp | 15 |
2 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Support/PluginLoader.h b/include/llvm/Support/PluginLoader.h index 74e5a03..7789ae8 100644 --- a/include/llvm/Support/PluginLoader.h +++ b/include/llvm/Support/PluginLoader.h @@ -22,6 +22,8 @@ namespace llvm { struct PluginLoader { void operator=(const std::string &Filename); + static unsigned getNumPlugins(); + static std::string& getPlugin(unsigned num); }; #ifndef DONT_GET_PLUGIN_LOADER_OPTION diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 799c125..77eb528 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -15,13 +15,17 @@ #include "llvm/Support/PluginLoader.h" #include "llvm/System/DynamicLibrary.h" #include <iostream> +#include <vector> using namespace llvm; +std::vector<std::string> plugins; + void PluginLoader::operator=(const std::string &Filename) { std::string ErrorMessage; try { sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str()); + plugins.push_back(Filename); } catch (const std::string& errmsg) { if (errmsg.empty()) { ErrorMessage = "Unknown"; @@ -33,3 +37,14 @@ void PluginLoader::operator=(const std::string &Filename) { std::cerr << "Error opening '" << Filename << "': " << ErrorMessage << "\n -load request ignored.\n"; } + +unsigned PluginLoader::getNumPlugins() +{ + return plugins.size(); +} + +std::string& PluginLoader::getPlugin(unsigned num) +{ + assert(num < plugins.size() && "Asking for an out of bounds plugin"); + return plugins[num]; +} |