[llvm-commits] CVS: llvm/lib/VMCore/Module.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 8 10:39:26 PST 2006



Changes in directory llvm/lib/VMCore:

Module.cpp updated: 1.64 -> 1.65
---
Log message:

add a new helper method.


---
Diffs of the changes:  (+14 -0)

 Module.cpp |   14 ++++++++++++++
 1 files changed, 14 insertions(+)


Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.64 llvm/lib/VMCore/Module.cpp:1.65
--- llvm/lib/VMCore/Module.cpp:1.64	Wed Jan 25 12:57:27 2006
+++ llvm/lib/VMCore/Module.cpp	Wed Mar  8 12:39:13 2006
@@ -222,6 +222,20 @@
   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;
+}
+
 
 
 //===----------------------------------------------------------------------===//






More information about the llvm-commits mailing list