[llvm-commits] CVS: llvm/lib/VMCore/Module.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Aug 30 19:20:01 PDT 2003


Changes in directory llvm/lib/VMCore:

Module.cpp updated: 1.38 -> 1.39

---
Log message:

Implement new method


---
Diffs of the changes:

Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.38 llvm/lib/VMCore/Module.cpp:1.39
--- llvm/lib/VMCore/Module.cpp:1.38	Sun Aug 24 08:48:48 2003
+++ llvm/lib/VMCore/Module.cpp	Sat Aug 30 19:19:28 2003
@@ -12,6 +12,7 @@
 #include "Support/LeakDetector.h"
 #include "SymbolTableListTraitsImpl.h"
 #include <algorithm>
+#include <cstdarg>
 #include <map>
 
 Function *ilist_traits<Function>::createNode() {
@@ -94,6 +95,29 @@
     return New;                    // Return the new prototype...
   }
 }
+
+// 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.





More information about the llvm-commits mailing list