[llvm-commits] CVS: llvm/lib/Support/PluginLoader.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Jul 7 10:14:16 PDT 2006



Changes in directory llvm/lib/Support:

PluginLoader.cpp updated: 1.17 -> 1.18
---
Log message:

LoadLibraryPermanently no longer throws an exception, so this code doesn't have
to catch it.  Other minor cleanups.


---
Diffs of the changes:  (+14 -28)

 PluginLoader.cpp |   42 ++++++++++++++----------------------------
 1 files changed, 14 insertions(+), 28 deletions(-)


Index: llvm/lib/Support/PluginLoader.cpp
diff -u llvm/lib/Support/PluginLoader.cpp:1.17 llvm/lib/Support/PluginLoader.cpp:1.18
--- llvm/lib/Support/PluginLoader.cpp:1.17	Thu Jan 26 13:38:58 2006
+++ llvm/lib/Support/PluginLoader.cpp	Fri Jul  7 12:14:04 2006
@@ -16,42 +16,28 @@
 #include "llvm/System/DynamicLibrary.h"
 #include <iostream>
 #include <vector>
-
 using namespace llvm;
 
-static std::vector<std::string>* plugins;
+static std::vector<std::string> *Plugins;
 
 void PluginLoader::operator=(const std::string &Filename) {
-  std::string ErrorMessage;
-
-  if (!plugins)
-    plugins = new std::vector<std::string>();
+  if (!Plugins)
+    Plugins = new std::vector<std::string>();
 
-  try {
-    sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str());
-    plugins->push_back(Filename);
-  } catch (const std::string& errmsg) {
-    if (errmsg.empty()) {
-      ErrorMessage = "Unknown";
-    } else {
-      ErrorMessage = errmsg;
-    }
-  }
-  if (!ErrorMessage.empty())
-    std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
+  std::string Error;
+  if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
+    std::cerr << "Error opening '" << Filename << "': " << Error
               << "\n  -load request ignored.\n";
+  } else {
+    Plugins->push_back(Filename);
+  }
 }
 
-unsigned PluginLoader::getNumPlugins()
-{
-  if(plugins)
-    return plugins->size();
-  else 
-    return 0;
+unsigned PluginLoader::getNumPlugins() {
+  return Plugins ? Plugins->size() : 0;
 }
 
-std::string& PluginLoader::getPlugin(unsigned num)
-{
-  assert(plugins && num < plugins->size() && "Asking for an out of bounds plugin");
-  return (*plugins)[num];
+std::string &PluginLoader::getPlugin(unsigned num) {
+  assert(Plugins && num < Plugins->size() && "Asking for an out of bounds plugin");
+  return (*Plugins)[num];
 }






More information about the llvm-commits mailing list