diff options
-rw-r--r-- | include/llvm/Module.h | 13 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 14 |
2 files changed, 14 insertions, 13 deletions
diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 1ee8750..da2b53d 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -137,13 +137,14 @@ public: // /// getGlobalVariable - Look up the specified global variable in the module - /// symbol table. If it does not exist, return null. Note that this only - /// returns a global variable if it does not have internal linkage. The type - /// argument should be the underlying type of the global, i.e., it should not - /// have the top-level PointerType, which represents the address of the - /// global. + /// symbol table. If it does not exist, return null. The type argument + /// should be the underlying type of the global, i.e., it should not have + /// the top-level PointerType, which represents the address of the global. + /// If AllowInternal is set to true, this function will return types that + /// have InternalLinkage. By default, these types are not returned. /// - GlobalVariable *getGlobalVariable(const std::string &Name, const Type *Ty); + GlobalVariable *getGlobalVariable(const std::string &Name, const Type *Ty, + bool AllowInternal = false); //===--------------------------------------------------------------------===// diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index a554d8e..de63b4b 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -206,17 +206,17 @@ Function *Module::getNamedFunction(const std::string &Name) { // /// getGlobalVariable - Look up the specified global variable in the module -/// symbol table. If it does not exist, return null. Note that this only -/// returns a global variable if it does not have internal linkage. The type -/// argument should be the underlying type of the global, ie, it should not -/// have the top-level PointerType, which represents the address of the -/// global. +/// symbol table. If it does not exist, return null. The type argument +/// should be the underlying type of the global, i.e., it should not have +/// the top-level PointerType, which represents the address of the global. +/// If AllowInternal is set to true, this function will return types that +/// have InternalLinkage. By default, these types are not returned. /// GlobalVariable *Module::getGlobalVariable(const std::string &Name, - const Type *Ty) { + const Type *Ty, bool AllowInternal) { if (Value *V = getSymbolTable().lookup(PointerType::get(Ty), Name)) { GlobalVariable *Result = cast<GlobalVariable>(V); - if (!Result->hasInternalLinkage()) + if (AllowInternal || !Result->hasInternalLinkage()) return Result; } return 0; |