LLVM API Documentation
00001 //===-- PluginLoader.cpp - Implement -load command line option ------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source 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/PluginLoader.h" 00016 #include "llvm/System/DynamicLibrary.h" 00017 #include <iostream> 00018 00019 using namespace llvm; 00020 00021 void PluginLoader::operator=(const std::string &Filename) { 00022 std::string ErrorMessage; 00023 try { 00024 sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str()); 00025 } catch (const std::string& errmsg) { 00026 if (errmsg.empty()) { 00027 ErrorMessage = "Unknown"; 00028 } else { 00029 ErrorMessage = errmsg; 00030 } 00031 } 00032 if (!ErrorMessage.empty()) 00033 std::cerr << "Error opening '" << Filename << "': " << ErrorMessage 00034 << "\n -load request ignored.\n"; 00035 }