LLVM API Documentation
00001 //===-- PluginLoader.cpp - Implement -load command line option ------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the -load <plugin> command line option handler. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #define DONT_GET_PLUGIN_LOADER_OPTION 00015 #include "llvm/Support/ManagedStatic.h" 00016 #include "llvm/Support/PluginLoader.h" 00017 #include "llvm/Support/Streams.h" 00018 #include "llvm/System/DynamicLibrary.h" 00019 #include <ostream> 00020 #include <vector> 00021 using namespace llvm; 00022 00023 static ManagedStatic<std::vector<std::string> > Plugins; 00024 00025 void PluginLoader::operator=(const std::string &Filename) { 00026 std::string Error; 00027 if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { 00028 cerr << "Error opening '" << Filename << "': " << Error 00029 << "\n -load request ignored.\n"; 00030 } else { 00031 Plugins->push_back(Filename); 00032 } 00033 } 00034 00035 unsigned PluginLoader::getNumPlugins() { 00036 return Plugins.isConstructed() ? Plugins->size() : 0; 00037 } 00038 00039 std::string &PluginLoader::getPlugin(unsigned num) { 00040 assert(Plugins.isConstructed() && num < Plugins->size() && 00041 "Asking for an out of bounds plugin"); 00042 return (*Plugins)[num]; 00043 }
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.