Remember plugins should someone like bugpoint want to know them.
authorAndrew Lenharth <andrewl@lenharth.org>
Thu, 26 Jan 2006 18:36:50 +0000 (18:36 +0000)
committerAndrew Lenharth <andrewl@lenharth.org>
Thu, 26 Jan 2006 18:36:50 +0000 (18:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25649 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PluginLoader.h
lib/Support/PluginLoader.cpp

index 74e5a0394df8af87cf236b19ecd7145190103472..7789ae8b548649603e4e22aa26e1c9b5247f5a16 100644 (file)
@@ -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
index 799c1256584b0b291e3d26ba9142975dd11dd582..77eb52852dee6d0a46c5770f9544d12313e5a8c8 100644 (file)
 #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];
+}