From 4b934766bde8989b4eeb3f4a1cc222327e262379 Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Thu, 26 Jan 2006 18:36:50 +0000 Subject: [PATCH] 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 --- include/llvm/Support/PluginLoader.h | 2 ++ lib/Support/PluginLoader.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/llvm/Support/PluginLoader.h b/include/llvm/Support/PluginLoader.h index 74e5a0394df..7789ae8b548 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 799c1256584..77eb52852de 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 +#include using namespace llvm; +std::vector 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]; +}