aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2017-04-06 20:23:57 +0000
committerMehdi Amini <mehdi.amini@apple.com>2017-04-06 20:23:57 +0000
commitdb11fdfda50017e0175602fec9949aa34141656a (patch)
tree97064cff0f2304c6d9c6f15e2a7c4f90fbbf9f8b /llvm/lib/IR/Module.cpp
parent98240e964366419bdbdb34706811f44e705d6786 (diff)
downloadllvm-db11fdfda50017e0175602fec9949aa34141656a.zip
llvm-db11fdfda50017e0175602fec9949aa34141656a.tar.gz
llvm-db11fdfda50017e0175602fec9949aa34141656a.tar.bz2
Revert "Turn some C-style vararg into variadic templates"
This reverts commit r299699, the examples needs to be updated. llvm-svn: 299702
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index fec9df1..c3bfee5 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -147,6 +147,47 @@ Constant *Module::getOrInsertFunction(StringRef Name,
return getOrInsertFunction(Name, Ty, AttributeList());
}
+// 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.
+//
+Constant *Module::getOrInsertFunction(StringRef Name,
+ AttributeList AttributeList, Type *RetTy,
+ ...) {
+ va_list Args;
+ va_start(Args, RetTy);
+
+ // Build the list of argument types...
+ std::vector<Type*> ArgTys;
+ while (Type *ArgTy = va_arg(Args, 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),
+ AttributeList);
+}
+
+Constant *Module::getOrInsertFunction(StringRef Name,
+ Type *RetTy, ...) {
+ va_list Args;
+ va_start(Args, RetTy);
+
+ // Build the list of argument types...
+ std::vector<Type*> ArgTys;
+ while (Type *ArgTy = va_arg(Args, 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),
+ AttributeList());
+}
+
// getFunction - Look up the specified function in the module symbol table.
// If it does not exist, return null.
//