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

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 13 15:54:18 PDT 2002


Changes in directory llvm/lib/VMCore:

Function.cpp updated: 1.32 -> 1.33
Verifier.cpp updated: 1.40 -> 1.41

---
Log message:

  - Change Function's so that their argument list is populated when they are
    constructed.  Before, external functions would have an empty argument list,
    now a Function ALWAYS has a populated argument list.



---
Diffs of the changes:

Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.32 llvm/lib/VMCore/Function.cpp:1.33
--- llvm/lib/VMCore/Function.cpp:1.32	Mon Sep 16 20:17:57 2002
+++ llvm/lib/VMCore/Function.cpp	Sun Oct 13 15:53:14 2002
@@ -61,7 +61,7 @@
 	 "Invalid symtab argument!");
   if ((P = getParent()) && hasName()) P->getSymbolTable()->remove(this);
   Value::setName(name);
-  if (P && hasName()) P->getSymbolTable()->insert(this);
+  if (P && hasName()) P->getSymbolTableSure()->insert(this);
 }
 
 void Argument::setParent(Function *parent) {
@@ -85,6 +85,13 @@
   ArgumentList.setItemParent(this);
   ArgumentList.setParent(this);
   ParentSymTab = SymTab = 0;
+
+  // Create the arguments vector, all arguments start out unnamed.
+  for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) {
+    assert(Ty->getParamType(i) != Type::VoidTy &&
+           "Cannot have void typed arguments!");
+    ArgumentList.push_back(new Argument(Ty->getParamType(i)));
+  }
 
   // Make sure that we get added to a function
   LeakDetector::addGarbageObject(this);


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.40 llvm/lib/VMCore/Verifier.cpp:1.41
--- llvm/lib/VMCore/Verifier.cpp:1.40	Sun Oct  6 17:47:32 2002
+++ llvm/lib/VMCore/Verifier.cpp	Sun Oct 13 15:53:14 2002
@@ -193,32 +193,30 @@
 // visitFunction - Verify that a function is ok.
 //
 void Verifier::visitFunction(Function &F) {
-  if (F.isExternal()) return;
-
-  verifySymbolTable(F.getSymbolTable());
-
   // Check function arguments...
   const FunctionType *FT = F.getFunctionType();
   unsigned NumArgs = F.getArgumentList().size();
 
   Assert2(!FT->isVarArg(), "Cannot define varargs functions in LLVM!", &F, FT);
-  Assert2(FT->getParamTypes().size() == NumArgs,
+  Assert2(FT->getNumParams() == NumArgs,
           "# formal arguments must match # of arguments for function type!",
           &F, FT);
 
   // Check that the argument values match the function type for this function...
-  if (FT->getParamTypes().size() == NumArgs) {
-    unsigned i = 0;
-    for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++i)
-      Assert2(I->getType() == FT->getParamType(i),
-              "Argument value does not match function argument type!",
-              I, FT->getParamType(i));
-  }
+  unsigned i = 0;
+  for (Function::aiterator I = F.abegin(), E = F.aend(); I != E; ++I, ++i)
+    Assert2(I->getType() == FT->getParamType(i),
+            "Argument value does not match function argument type!",
+            I, FT->getParamType(i));
 
-  // Check the entry node
-  BasicBlock *Entry = &F.getEntryNode();
-  Assert1(pred_begin(Entry) == pred_end(Entry),
-          "Entry block to function must not have predecessors!", Entry);
+  if (!F.isExternal()) {
+    verifySymbolTable(F.getSymbolTable());
+
+    // Check the entry node
+    BasicBlock *Entry = &F.getEntryNode();
+    Assert1(pred_begin(Entry) == pred_end(Entry),
+            "Entry block to function must not have predecessors!", Entry);
+  }
 }
 
 





More information about the llvm-commits mailing list