reject things like "declare internal @foo"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-09-19 17:14:45 +00:00
parent 742f9b6682
commit 6693da003b

View File

@ -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)