aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-19 18:41:44 +0000
committerChris Lattner <sabre@nondot.org>2002-11-19 18:41:44 +0000
commit9a641b4bce58f9aaea469f78a3e1d91866622fee (patch)
tree38edfc73e59e95a7ca63177f3b75cd3d4a31f8d8 /lib/VMCore/Module.cpp
parentaf43b64d12b089b41ca691e2a30c0bde2bbab97e (diff)
downloadexternal_llvm-9a641b4bce58f9aaea469f78a3e1d91866622fee.zip
external_llvm-9a641b4bce58f9aaea469f78a3e1d91866622fee.tar.gz
external_llvm-9a641b4bce58f9aaea469f78a3e1d91866622fee.tar.bz2
Add a new Module::getNamedFunction method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Module.cpp')
-rw-r--r--lib/VMCore/Module.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp
index fec6fec..c12b32d 100644
--- a/lib/VMCore/Module.cpp
+++ b/lib/VMCore/Module.cpp
@@ -182,11 +182,20 @@ Function *Module::getMainFunction() {
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...
}