1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Don't crash on redefinitions.

One error we were not deleting the alias or putting it in the Module. The
end result is that there was an use left of the aliasee when the module was
deleted.

llvm-svn: 208447
This commit is contained in:
Rafael Espindola 2014-05-09 21:49:17 +00:00
parent 96b4e50b21
commit 5a89507638
2 changed files with 14 additions and 5 deletions

View File

@ -673,9 +673,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
return Error(AliaseeLoc, "alias must have pointer type");
// Okay, create the alias but do not insert it into the module yet.
GlobalAlias* GA = new GlobalAlias(Aliasee->getType(),
(GlobalValue::LinkageTypes)Linkage, Name,
Aliasee);
std::unique_ptr<GlobalAlias> GA(new GlobalAlias(
Aliasee->getType(), (GlobalValue::LinkageTypes)Linkage, Name, Aliasee));
GA->setVisibility((GlobalValue::VisibilityTypes)Visibility);
GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass);
@ -697,15 +696,18 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
// If they agree, just RAUW the old value with the alias and remove the
// forward ref info.
Val->replaceAllUsesWith(GA);
Val->replaceAllUsesWith(GA.get());
Val->eraseFromParent();
ForwardRefVals.erase(I);
}
// Insert into the module, we know its name won't collide now.
M->getAliasList().push_back(GA);
M->getAliasList().push_back(GA.get());
assert(GA->getName() == Name && "Should not be a name conflict!");
// The module owns this now
GA.release();
return false;
}

View File

@ -0,0 +1,7 @@
; RUN: not llvm-as %s 2>&1 | FileCheck %s
; CHECK: error: redefinition of global named '@bar'
@foo = global i32 0
@bar = alias i32* @foo
@bar = alias i32* @foo