From 30614675f45809c43d44c7243d8b747b39403155 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Dec 2005 05:30:21 +0000 Subject: Add a flag to Module::getGlobalVariable to allow it to return vars with internal linkage. Patch provided by Evan Jones, thanks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24604 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Module.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/VMCore/Module.cpp') 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(V); - if (!Result->hasInternalLinkage()) + if (AllowInternal || !Result->hasInternalLinkage()) return Result; } return 0; -- cgit v1.1