summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-31 00:19:28 +0000
committerChris Lattner <sabre@nondot.org>2003-08-31 00:19:28 +0000
commitbd717d897fc2cb2aa0a5e9ee6f6d7f141a79fc4d (patch)
tree76a22c100c4e5457f61025cda408cec6e8dc4d54 /llvm/lib/VMCore/Module.cpp
parenta91cbd1aa9093e7791cb1a1fb7e74b244e5db3cc (diff)
downloadbcm5719-llvm-bd717d897fc2cb2aa0a5e9ee6f6d7f141a79fc4d.tar.gz
bcm5719-llvm-bd717d897fc2cb2aa0a5e9ee6f6d7f141a79fc4d.zip
Implement new method
llvm-svn: 8238
Diffstat (limited to 'llvm/lib/VMCore/Module.cpp')
-rw-r--r--llvm/lib/VMCore/Module.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index 8b61606dcad..b7fe5693fb2 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/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.
//
OpenPOWER on IntegriCloud