Add sanity checks

llvm-svn: 48184
This commit is contained in:
Anton Korobeynikov 2008-03-10 22:36:53 +00:00
parent d5160da577
commit 510fc32d15
1 changed files with 10 additions and 0 deletions

View File

@ -659,6 +659,11 @@ static bool LinkAlias(Module *Dest, const Module *Src,
// The only allowed way is to link alias with external declaration.
if (DGV->isDeclaration()) {
// But only if aliasee is global too...
if (!isa<GlobalVariable>(DAliasee))
return Error(Err, "Global-Alias Collision on '" + SGA->getName() +
"': aliasee is not global variable");
NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(),
SGA->getName(), DAliasee, Dest);
CopyGVAttributes(NewGA, SGA);
@ -685,6 +690,11 @@ static bool LinkAlias(Module *Dest, const Module *Src,
// The only allowed way is to link alias with external declaration.
if (DF->isDeclaration()) {
// But only if aliasee is function too...
if (!isa<Function>(DAliasee))
return Error(Err, "Function-Alias Collision on '" + SGA->getName() +
"': aliasee is not function");
NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(),
SGA->getName(), DAliasee, Dest);
CopyGVAttributes(NewGA, SGA);