add a new helper method.
authorChris Lattner <sabre@nondot.org>
Wed, 8 Mar 2006 18:39:13 +0000 (18:39 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 8 Mar 2006 18:39:13 +0000 (18:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26618 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Module.cpp

index b6761a616cd002c304fccb52f9d25b84be4540e2..7c400aa515d032fe370de57308ba2258cd43e61b 100644 (file)
@@ -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;
+}
+
 
 
 //===----------------------------------------------------------------------===//