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

Chris Lattner lattner at cs.uiuc.edu
Tue Nov 19 12:42:03 PST 2002


Changes in directory llvm/lib/VMCore:

Module.cpp updated: 1.31 -> 1.32

---
Log message:

Add a new Module::getNamedFunction method



---
Diffs of the changes:

Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.31 llvm/lib/VMCore/Module.cpp:1.32
--- llvm/lib/VMCore/Module.cpp:1.31	Fri Nov  8 14:34:02 2002
+++ llvm/lib/VMCore/Module.cpp	Tue Nov 19 12:41:44 2002
@@ -182,11 +182,20 @@
       return F;
   }
 
-  // Loop over all of the methods, trying to find main the hard way...
+  // Ok, try to find main the hard way...
+  return getNamedFunction("main");
+}
+
+/// getNamedFunction - Return the first function in the module with the
+/// specified name, of arbitrary type.  This method returns null if a function
+/// with the specified name is not found.
+///
+Function *Module::getNamedFunction(const std::string &Name) {
+  // Loop over all of the functions, looking for the function desired
   for (iterator I = begin(), E = end(); I != E; ++I)
-    if (I->getName() == "main")
+    if (I->getName() == Name)
       return I;
-  return 0; // Main not found...
+  return 0; // function not found...
 }
 
 





More information about the llvm-commits mailing list