diff options
author | Chris Lattner <sabre@nondot.org> | 2006-03-08 18:39:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-03-08 18:39:13 +0000 |
commit | 9d25824e4ca45b7269aacaa92f02a5e9fa8a8e5c (patch) | |
tree | ec9b07ab2fd3ee164e2f90996b962fd5612b8329 /lib/VMCore/Module.cpp | |
parent | 6665b97ae99d03cf85da54253c12dec6f1a227b2 (diff) |
add a new helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26618 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Module.cpp')
-rw-r--r-- | lib/VMCore/Module.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index b6761a616c..7c400aa515 100644 --- a/lib/VMCore/Module.cpp +++ b/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; +} + //===----------------------------------------------------------------------===// |