[llvm-commits] [llvm] r48184 - /llvm/trunk/lib/Linker/LinkModules.cpp

Anton Korobeynikov asl at math.spbu.ru
Mon Mar 10 15:36:53 PDT 2008


Author: asl
Date: Mon Mar 10 17:36:53 2008
New Revision: 48184

URL: http://llvm.org/viewvc/llvm-project?rev=48184&view=rev
Log:
Add sanity checks

Modified:
    llvm/trunk/lib/Linker/LinkModules.cpp

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=48184&r1=48183&r2=48184&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Mar 10 17:36:53 2008
@@ -659,6 +659,11 @@
 
       // 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 @@
 
       // 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);





More information about the llvm-commits mailing list