summaryrefslogtreecommitdiff
path: root/lib/Support/PluginLoader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-07 17:14:04 +0000
committerChris Lattner <sabre@nondot.org>2006-07-07 17:14:04 +0000
commit17aa9d3f53d0afe6a5188fd5f76f0738cb7e6a07 (patch)
tree5e69b2e36d946bab18cc790a459e79b3068fbe23 /lib/Support/PluginLoader.cpp
parentcc2fa54dfa5096772a2cdc3881e6f13791d41e2a (diff)
downloadllvm-17aa9d3f53d0afe6a5188fd5f76f0738cb7e6a07.tar.gz
llvm-17aa9d3f53d0afe6a5188fd5f76f0738cb7e6a07.tar.bz2
llvm-17aa9d3f53d0afe6a5188fd5f76f0738cb7e6a07.tar.xz
LoadLibraryPermanently no longer throws an exception, so this code doesn't have
to catch it. Other minor cleanups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29050 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/PluginLoader.cpp')
-rw-r--r--lib/Support/PluginLoader.cpp42
1 files changed, 14 insertions, 28 deletions
diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp
index 94cbec3a93..2ed9836fd0 100644
--- a/lib/Support/PluginLoader.cpp
+++ b/lib/Support/PluginLoader.cpp
@@ -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];
}