diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 8b61606dcad..b7fe5693fb2 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -12,6 +12,7 @@ #include "Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" #include +#include #include Function *ilist_traits::createNode() { @@ -95,6 +96,29 @@ Function *Module::getOrInsertFunction(const std::string &Name, } } +// getOrInsertFunction - Look up the specified function in the module symbol +// table. If it does not exist, add a prototype for the function and return it. +// This version of the method takes a null terminated list of function +// arguments, which makes it easier for clients to use. +// +Function *Module::getOrInsertFunction(const std::string &Name, + const Type *RetTy, ...) { + va_list Args; + va_start(Args, RetTy); + + // Build the list of argument types... + std::vector ArgTys; + while (const Type *ArgTy = va_arg(Args, const Type*)) + ArgTys.push_back(ArgTy); + + va_end(Args); + + // Build the function type and chain to the other getOrInsertFunction... + return getOrInsertFunction(Name, FunctionType::get(RetTy, ArgTys, false)); +} + + + // getFunction - Look up the specified function in the module symbol table. // If it does not exist, return null. //