aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-09-19 17:14:45 +0000
committerChris Lattner <sabre@nondot.org>2007-09-19 17:14:45 +0000
commit6693da003b826b5a5755fb3d97941d52f36cbb5d (patch)
treebfa6380f54d91b6e424a8a82b97dfd123e0e90aa
parent742f9b66822cb03af0cf7b94436e9d0288565591 (diff)
reject things like "declare internal @foo"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42140 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/VMCore/Verifier.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 982de30b72..447b8846be 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -310,10 +310,15 @@ void Verifier::visitGlobalValue(GlobalValue &GV) {
}
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 @@ void Verifier::visitFunction(Function &F) {
"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)