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

Chris Lattner sabre at nondot.org
Mon Jun 9 00:25:28 PDT 2008


Author: lattner
Date: Mon Jun  9 02:25:28 2008
New Revision: 52133

URL: http://llvm.org/viewvc/llvm-project?rev=52133&view=rev
Log:
simplify function visibility handling.

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=52133&r1=52132&r2=52133&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Jun  9 02:25:28 2008
@@ -827,19 +827,22 @@
                               &Dest->getTypeSymbolTable(), "");
     }
 
+    if (DF && DF->hasInternalLinkage())
+      DF = NULL;
+    
     // Check visibility
-    if (DF && !DF->hasInternalLinkage() &&
-        SF->getVisibility() != DF->getVisibility()) {
+    if (DF && SF->getVisibility() != DF->getVisibility()) {
       // If one is a prototype, ignore its visibility.  Prototypes are always
       // overridden by the definition.
       if (!SF->isDeclaration() && !DF->isDeclaration())
         return Error(Err, "Linking functions named '" + SF->getName() +
                      "': symbols have different visibilities!");
+      
+      // Otherwise, replace the visibility of DF if DF is a prototype.
+      if (DF->isDeclaration())
+        DF->setVisibility(SF->getVisibility());
     }
     
-    if (DF && DF->hasInternalLinkage())
-      DF = NULL;
-
     if (DF && DF->getType() != SF->getType()) {
       if (DF->isDeclaration() && !SF->isDeclaration()) {
         // We have a definition of the same name but different type in the
@@ -911,8 +914,6 @@
       // Link the external functions, update linkage qualifiers
       ValueMap.insert(std::make_pair(SF, DF));
       DF->setLinkage(SF->getLinkage());
-      // Visibility of prototype is overridden by vis of definition.
-      DF->setVisibility(SF->getVisibility());
     } else if (SF->hasWeakLinkage() || SF->hasLinkOnceLinkage() ||
                SF->hasCommonLinkage()) {
       // At this point we know that DF has LinkOnce, Weak, or External* linkage.





More information about the llvm-commits mailing list