[llvm-commits] [llvm] r42140 - /llvm/trunk/lib/VMCore/Verifier.cpp

Chris Lattner sabre at nondot.org
Wed Sep 19 10:14:45 PDT 2007


Author: lattner
Date: Wed Sep 19 12:14:45 2007
New Revision: 42140

URL: http://llvm.org/viewvc/llvm-project?rev=42140&view=rev
Log:
reject things like "declare internal @foo"

Modified:
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=42140&r1=42139&r2=42140&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Sep 19 12:14:45 2007
@@ -310,10 +310,15 @@
 }
 
 void Verifier::visitGlobalVariable(GlobalVariable &GV) {
-  if (GV.hasInitializer())
+  if (GV.hasInitializer()) {
     Assert1(GV.getInitializer()->getType() == GV.getType()->getElementType(),
             "Global variable initializer type does not match global "
             "variable type!", &GV);
+  } else {
+    Assert1(GV.hasExternalLinkage() || GV.hasDLLImportLinkage() ||
+            GV.hasExternalWeakLinkage(),
+            "invalid linkage type for global declaration", &GV);
+  }
 
   visitGlobalValue(GV);
 }
@@ -467,7 +472,11 @@
             "Functions cannot take aggregates as arguments by value!", I);
    }
 
-  if (!F.isDeclaration()) {
+  if (F.isDeclaration()) {
+    Assert1(F.hasExternalLinkage() || F.hasDLLImportLinkage() ||
+            F.hasExternalWeakLinkage(),
+            "invalid linkage type for function declaration", &F);
+  } else {
     // Verify that this function (which has a body) is not named "llvm.*".  It
     // is not legal to define intrinsics.
     if (F.getName().size() >= 5)





More information about the llvm-commits mailing list