[cfe-commits] r89191 - /cfe/trunk/lib/CodeGen/CGRtti.cpp

Mike Stump mrs at apple.com
Tue Nov 17 19:46:51 PST 2009


Author: mrs
Date: Tue Nov 17 21:46:51 2009
New Revision: 89191

URL: http://llvm.org/viewvc/llvm-project?rev=89191&view=rev
Log:
Propagate hidden to the _ZTS symbols appropriately.  WIP.

Modified:
    cfe/trunk/lib/CodeGen/CGRtti.cpp

Modified: cfe/trunk/lib/CodeGen/CGRtti.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRtti.cpp?rev=89191&r1=89190&r2=89191&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Tue Nov 17 21:46:51 2009
@@ -47,7 +47,7 @@
     return llvm::ConstantExpr::getBitCast(C, Int8PtrTy);
   }
 
-  llvm::Constant *BuildName(QualType Ty) {
+  llvm::Constant *BuildName(QualType Ty, bool Hidden) {
     llvm::SmallString<256> OutName;
     llvm::raw_svector_ostream Out(OutName);
     mangleCXXRttiName(CGM.getMangleContext(), Ty, Out);
@@ -58,11 +58,13 @@
     llvm::Constant *C;
     C = llvm::ConstantArray::get(VMContext, Out.str().substr(4));
 
-    llvm::Constant *s = new llvm::GlobalVariable(CGM.getModule(), C->getType(),
-                                                 true, linktype, C,
-                                                 Out.str());
-    s = llvm::ConstantExpr::getBitCast(s, Int8PtrTy);
-    return s;
+    llvm::GlobalVariable * GV = new llvm::GlobalVariable(CGM.getModule(),
+                                                         C->getType(),
+                                                         true, linktype, C,
+                                                         Out.str());
+    if (Hidden)
+      GV->setVisibility(llvm::GlobalVariable::HiddenVisibility);
+    return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
   };
 
   /// - BuildFlags - Build a psABI __flags value for __vmi_class_type_info.
@@ -145,7 +147,7 @@
 
   llvm::Constant *finish(std::vector<llvm::Constant *> &info,
                          llvm::GlobalVariable *GV,
-                         llvm::StringRef Name, bool Extern) {
+                         llvm::StringRef Name, bool Hidden) {
     llvm::GlobalVariable::LinkageTypes linktype;
     linktype = llvm::GlobalValue::LinkOnceODRLinkage;
 
@@ -165,7 +167,7 @@
       OGV->replaceAllUsesWith(NewPtr);
       OGV->eraseFromParent();
     }
-    if (!Extern)
+    if (Hidden)
       GV->setVisibility(llvm::GlobalVariable::HiddenVisibility);
     return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
   }
@@ -189,6 +191,8 @@
 
     std::vector<llvm::Constant *> info;
 
+    bool Hidden = CGM.getDeclVisibilityMode(RD) == LangOptions::Hidden;
+
     bool simple = false;
     if (RD->getNumBases() == 0)
       C = BuildVtableRef("_ZTVN10__cxxabiv117__class_type_infoE");
@@ -198,7 +202,7 @@
     } else
       C = BuildVtableRef("_ZTVN10__cxxabiv121__vmi_class_type_infoE");
     info.push_back(C);
-    info.push_back(BuildName(CGM.getContext().getTagDeclType(RD)));
+    info.push_back(BuildName(CGM.getContext().getTagDeclType(RD), Hidden));
 
     // If we have no bases, there are no more fields.
     if (RD->getNumBases()) {
@@ -231,9 +235,7 @@
       }
     }
 
-    bool Extern = CGM.getDeclVisibilityMode(RD) != LangOptions::Hidden;
-
-    return finish(info, GV, Out.str(), Extern);
+    return finish(info, GV, Out.str(), Hidden);
   }
 
   /// - BuildFlags - Build a __flags value for __pbase_type_info.
@@ -262,6 +264,10 @@
 
     std::vector<llvm::Constant *> info;
 
+    // FIXME: pointer to hidden should be hidden, we should be able to
+    // grab a bit off the type for this.
+    bool Hidden = false;
+
     QualType PTy = Ty->getPointeeType();
     QualType BTy;
     bool PtrMem = false;
@@ -276,7 +282,7 @@
     else
       C = BuildVtableRef("_ZTVN10__cxxabiv119__pointer_type_infoE");
     info.push_back(C);
-    info.push_back(BuildName(Ty));
+    info.push_back(BuildName(Ty, Hidden));
     Qualifiers Q = PTy.getQualifiers();
     PTy = CGM.getContext().getCanonicalType(PTy).getUnqualifiedType();
     int flags = 0;
@@ -294,7 +300,7 @@
     if (PtrMem)
       info.push_back(BuildType2(BTy));
 
-    return finish(info, GV, Out.str(), false);
+    return finish(info, GV, Out.str(), true);
   }
 
   llvm::Constant *BuildSimpleType(QualType Ty, const char *vtbl) {
@@ -311,11 +317,15 @@
 
     std::vector<llvm::Constant *> info;
 
+    // FIXME: pointer to hidden should be hidden, we should be able to
+    // grab a bit off the type for this.
+    bool Hidden = false;
+
     C = BuildVtableRef(vtbl);
     info.push_back(C);
-    info.push_back(BuildName(Ty));
+    info.push_back(BuildName(Ty, Hidden));
 
-    return finish(info, GV, Out.str(), false);
+    return finish(info, GV, Out.str(), true);
   }
 
   llvm::Constant *BuildType(QualType Ty) {





More information about the cfe-commits mailing list