Use range loops. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222723 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-11-25 04:26:19 +00:00
parent a4ebd338c4
commit 2db795c160

View File

@ -767,27 +767,25 @@ bool ModuleLinker::shouldLinkFromSource(bool &LinkFromSrc,
/// types 'Foo' but one got renamed when the module was loaded into the same /// types 'Foo' but one got renamed when the module was loaded into the same
/// LLVMContext. /// LLVMContext.
void ModuleLinker::computeTypeMapping() { void ModuleLinker::computeTypeMapping() {
// Incorporate globals. for (GlobalValue &SGV : SrcM->globals()) {
for (Module::global_iterator I = SrcM->global_begin(), GlobalValue *DGV = getLinkedToGlobal(&SGV);
E = SrcM->global_end(); I != E; ++I) { if (!DGV)
GlobalValue *DGV = getLinkedToGlobal(I); continue;
if (!DGV) continue;
if (!DGV->hasAppendingLinkage() || !I->hasAppendingLinkage()) { if (!DGV->hasAppendingLinkage() || !SGV.hasAppendingLinkage()) {
TypeMap.addTypeMapping(DGV->getType(), I->getType()); TypeMap.addTypeMapping(DGV->getType(), SGV.getType());
continue; continue;
} }
// Unify the element type of appending arrays. // Unify the element type of appending arrays.
ArrayType *DAT = cast<ArrayType>(DGV->getType()->getElementType()); ArrayType *DAT = cast<ArrayType>(DGV->getType()->getElementType());
ArrayType *SAT = cast<ArrayType>(I->getType()->getElementType()); ArrayType *SAT = cast<ArrayType>(SGV.getType()->getElementType());
TypeMap.addTypeMapping(DAT->getElementType(), SAT->getElementType()); TypeMap.addTypeMapping(DAT->getElementType(), SAT->getElementType());
} }
// Incorporate functions. for (GlobalValue &SGV : *SrcM) {
for (Module::iterator I = SrcM->begin(), E = SrcM->end(); I != E; ++I) { if (GlobalValue *DGV = getLinkedToGlobal(&SGV))
if (GlobalValue *DGV = getLinkedToGlobal(I)) TypeMap.addTypeMapping(DGV->getType(), SGV.getType());
TypeMap.addTypeMapping(DGV->getType(), I->getType());
} }
// Incorporate types by name, scanning all the types in the source module. // Incorporate types by name, scanning all the types in the source module.