llvm.org GIT mirror llvm / 17aa9d3
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 Chris Lattner 14 years ago
1 changed file(s) with 14 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
1515 #include "llvm/System/DynamicLibrary.h"
1616 #include
1717 #include
18
1918 using namespace llvm;
2019
21 static std::vector* plugins;
20 static std::vector *Plugins;
2221
2322 void PluginLoader::operator=(const std::string &Filename) {
24 std::string ErrorMessage;
23 if (!Plugins)
24 Plugins = new std::vector();
2525
26 if (!plugins)
27 plugins = new std::vector();
28
29 try {
30 sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str());
31 plugins->push_back(Filename);
32 } catch (const std::string& errmsg) {
33 if (errmsg.empty()) {
34 ErrorMessage = "Unknown";
35 } else {
36 ErrorMessage = errmsg;
37 }
26 std::string Error;
27 if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
28 std::cerr << "Error opening '" << Filename << "': " << Error
29 << "\n -load request ignored.\n";
30 } else {
31 Plugins->push_back(Filename);
3832 }
39 if (!ErrorMessage.empty())
40 std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
41 << "\n -load request ignored.\n";
4233 }
4334
44 unsigned PluginLoader::getNumPlugins()
45 {
46 if(plugins)
47 return plugins->size();
48 else
49 return 0;
35 unsigned PluginLoader::getNumPlugins() {
36 return Plugins ? Plugins->size() : 0;
5037 }
5138
52 std::string& PluginLoader::getPlugin(unsigned num)
53 {
54 assert(plugins && num < plugins->size() && "Asking for an out of bounds plugin");
55 return (*plugins)[num];
39 std::string &PluginLoader::getPlugin(unsigned num) {
40 assert(Plugins && num < Plugins->size() && "Asking for an out of bounds plugin");
41 return (*Plugins)[num];
5642 }