From 510fc32d15830cd529be2adee39fd756abaa87ad Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Mon, 10 Mar 2008 22:36:53 +0000 Subject: [PATCH] Add sanity checks llvm-svn: 48184 --- llvm/lib/Linker/LinkModules.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 53fce4893fd0..3d6e52602b17 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -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(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(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);