summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-03-08 18:39:13 +0000
committerChris Lattner <sabre@nondot.org>2006-03-08 18:39:13 +0000
commit48a8e09ad006ca7316a0cf28d0970cf7a64f9953 (patch)
tree3e75cd75cccce937e2c6b39182cdd5c9d00af2ae /llvm/lib/VMCore/Module.cpp
parent3584fd73755c6aa9457d0ce107d5d9f7e80d176c (diff)
downloadbcm5719-llvm-48a8e09ad006ca7316a0cf28d0970cf7a64f9953.tar.gz
bcm5719-llvm-48a8e09ad006ca7316a0cf28d0970cf7a64f9953.zip
add a new helper method.
llvm-svn: 26618
Diffstat (limited to 'llvm/lib/VMCore/Module.cpp')
-rw-r--r--llvm/lib/VMCore/Module.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index b6761a616cd..7c400aa515d 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/lib/VMCore/Module.cpp
@@ -222,6 +222,20 @@ GlobalVariable *Module::getGlobalVariable(const std::string &Name,
return 0;
}
+/// getNamedGlobal - Return the first global variable in the module with the
+/// specified name, of arbitrary type. This method returns null if a global
+/// with the specified name is not found.
+///
+GlobalVariable *Module::getNamedGlobal(const std::string &Name) {
+ // FIXME: This would be much faster with a symbol table that doesn't
+ // discriminate based on type!
+ for (global_iterator I = global_begin(), E = global_end();
+ I != E; ++I)
+ if (I->getName() == Name)
+ return I;
+ return 0;
+}
+
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud