From: Chris Lattner Date: Wed, 23 Jul 2003 20:21:30 +0000 (+0000) Subject: Make Module::getNamedFunction prefer non-external functions if there is more than X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b6ede8aaa0501f875f8b3b73fcd5e4bc71b4c2e2;p=oota-llvm.git Make Module::getNamedFunction prefer non-external functions if there is more than one function of the same name git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7274 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 275d4cfbf31..abc4654da1d 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -172,10 +172,14 @@ Function *Module::getMainFunction() { /// Function *Module::getNamedFunction(const std::string &Name) { // Loop over all of the functions, looking for the function desired + Function *Found = 0; for (iterator I = begin(), E = end(); I != E; ++I) if (I->getName() == Name) - return I; - return 0; // function not found... + if (I->isExternal()) + Found = I; + else + return I; + return Found; // Non-external function not found... }