* s/Method/Function
authorChris Lattner <sabre@nondot.org>
Fri, 29 Mar 2002 19:06:18 +0000 (19:06 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 29 Mar 2002 19:06:18 +0000 (19:06 +0000)
* Implement a check to make sure a function is not internal and external
  at the same time

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2050 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index e6333f71dd36fbad060f2825d6871512a2e8f8af..2bdc0163c09ec96efe0effb48695294c9262b04c 100644 (file)
@@ -1,6 +1,6 @@
 //===-- Verifier.cpp - Implement the Module Verifier -------------*- C++ -*-==//
 //
-// This file defines the method verifier interface, that can be used for some
+// This file defines the function verifier interface, that can be used for some
 // sanity checking of input to the system.
 //
 // Note that this does not provide full 'java style' security and verifications,
 //  * Only phi nodes can be self referential: 'add int %0, %0 ; <int>:0' is bad
 //  * PHI nodes must have an entry for each predecessor, with no extras.
 //  * All basic blocks should only end with terminator insts, not contain them
-//  * The entry node to a method must not have predecessors
+//  * The entry node to a function must not have predecessors
 //  * All Instructions must be embeded into a basic block
 //  . Verify that none of the Value getType()'s are null.
-//  . Method's cannot take a void typed parameter
-//  . Verify that a method's argument list agrees with it's declared type.
+//  . Function's cannot take a void typed parameter
+//  . Verify that a function's argument list agrees with it's declared type.
 //  . Verify that arrays and structures have fixed elements: No unsized arrays.
 //  * It is illegal to specify a name for a void value.
+//  * It is illegal to have a internal function that is just a declaration
 //  . All other things that are tested by asserts spread about the code...
 //
 //===----------------------------------------------------------------------===//
@@ -34,7 +35,7 @@
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Pass.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Module.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Type.h"
@@ -171,15 +172,18 @@ static bool verifySymbolTable(const SymbolTable *ST) {
 // verifyModule and direct clients of the verifyMethod function are correctly
 // informed.
 //
-bool verifyMethod(const Method *M) {
-  if (M->isExternal()) return false;  // Can happen if called by verifyModule
+bool verifyMethod(const Function *F) {
+  if (F->isExternal()) return false;  // Can happen if called by verifyModule
+  bool Broken = verifySymbolTable(F->getSymbolTable());
 
-  bool Broken = verifySymbolTable(M->getSymbolTable());
-  const BasicBlock *Entry = M->front();
+  Assert1(!F->isExternal() || F->hasExternalLinkage(),
+          "Function cannot be an 'internal' 'declare'ation!", F);
+
+  const BasicBlock *Entry = F->getEntryNode();
   Assert1(pred_begin(Entry) == pred_end(Entry),
           "Entry block to method must not have predecessors!", Entry);
 
-  Broken |= reduce_apply_bool(M->begin(), M->end(), verifyBasicBlock);
+  Broken |= reduce_apply_bool(F->begin(), F->end(), verifyBasicBlock);
   return Broken;
 }