diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-31 00:19:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-31 00:19:28 +0000 |
commit | 0ae8e87e53d6f500f8d01785b67c68e2046fb8e8 (patch) | |
tree | e0451855b71122388897c1f8638c1fb047d97ecf /lib/VMCore/Module.cpp | |
parent | 12d40d2926776b490aed29bce56536aa17415365 (diff) | |
download | external_llvm-0ae8e87e53d6f500f8d01785b67c68e2046fb8e8.zip external_llvm-0ae8e87e53d6f500f8d01785b67c68e2046fb8e8.tar.gz external_llvm-0ae8e87e53d6f500f8d01785b67c68e2046fb8e8.tar.bz2 |
Implement new method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Module.cpp')
-rw-r--r-- | lib/VMCore/Module.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 8b61606..b7fe569 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -12,6 +12,7 @@ #include "Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" #include <algorithm> +#include <cstdarg> #include <map> Function *ilist_traits<Function>::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<const Type*> 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. // |