llvm.org GIT mirror llvm / 61ffc0c
Guard the plugin loader. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73925 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
1 changed file(s) with 5 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1515 #include "llvm/Support/PluginLoader.h"
1616 #include "llvm/Support/Streams.h"
1717 #include "llvm/System/DynamicLibrary.h"
18 #include "llvm/System/Mutex.h"
1819 #include
1920 #include
2021 using namespace llvm;
2122
2223 static ManagedStatic > Plugins;
24 static ManagedStatic > PluginsLock;
2325
2426 void PluginLoader::operator=(const std::string &Filename) {
27 sys::SmartScopedLock Lock(&*PluginsLock);
2528 std::string Error;
2629 if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
2730 cerr << "Error opening '" << Filename << "': " << Error
3235 }
3336
3437 unsigned PluginLoader::getNumPlugins() {
38 sys::SmartScopedLock Lock(&*PluginsLock);
3539 return Plugins.isConstructed() ? Plugins->size() : 0;
3640 }
3741
3842 std::string &PluginLoader::getPlugin(unsigned num) {
43 sys::SmartScopedLock Lock(&*PluginsLock);
3944 assert(Plugins.isConstructed() && num < Plugins->size() &&
4045 "Asking for an out of bounds plugin");
4146 return (*Plugins)[num];