diff options
author | Chris Lattner <sabre@nondot.org> | 2003-04-16 20:42:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-04-16 20:42:40 +0000 |
commit | 53997416228333e105b06df22acd400de0505c89 (patch) | |
tree | 1c73fb5e47c72f1a126e45adca777ec525d214e7 /lib/VMCore/Verifier.cpp | |
parent | 076e2ae92f4ef60103f75ccbf4e33063328effad (diff) | |
download | external_llvm-53997416228333e105b06df22acd400de0505c89.zip external_llvm-53997416228333e105b06df22acd400de0505c89.tar.gz external_llvm-53997416228333e105b06df22acd400de0505c89.tar.bz2 |
Add code to verify correctly linkages
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5788 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r-- | lib/VMCore/Verifier.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index e156692..0165e3b 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -94,8 +94,7 @@ namespace { // Anonymous namespace for class bool doFinalization(Module &M) { // Scan through, checking all of the external function's linkage now... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->isExternal() && I->hasInternalLinkage()) - CheckFailed("Function Declaration has Internal Linkage!", I); + visitGlobalValue(*I); for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) if (I->isExternal() && I->hasInternalLinkage()) @@ -122,8 +121,10 @@ namespace { // Anonymous namespace for class } } + // Verification methods... void verifySymbolTable(SymbolTable &ST); + void visitGlobalValue(GlobalValue &GV); void visitFunction(Function &F); void visitBasicBlock(BasicBlock &BB); void visitPHINode(PHINode &PN); @@ -171,6 +172,19 @@ namespace { // Anonymous namespace for class do { if (!(C)) { CheckFailed(M, V1, V2, V3, V4); return; } } while (0) +void Verifier::visitGlobalValue(GlobalValue &GV) { + Assert1(!GV.isExternal() || GV.hasExternalLinkage(), + "Global value has Internal Linkage!", &GV); + Assert1(!GV.hasAppendingLinkage() || isa<GlobalVariable>(GV), + "Only global variables can have appending linkage!", &GV); + + if (GV.hasAppendingLinkage()) { + GlobalVariable &GVar = cast<GlobalVariable>(GV); + Assert1(isa<ArrayType>(GVar.getType()->getElementType()), + "Only global arrays can have appending linkage!", &GV); + } +} + // verifySymbolTable - Verify that a function or module symbol table is ok // void Verifier::verifySymbolTable(SymbolTable &ST) { |