[cfe-commits] r92118 - /cfe/trunk/lib/CodeGen/CGRTTI.cpp

Mike Stump mrs at apple.com
Wed Dec 23 18:33:48 PST 2009


Author: mrs
Date: Wed Dec 23 20:33:48 2009
New Revision: 92118

URL: http://llvm.org/viewvc/llvm-project?rev=92118&view=rev
Log:
Don't set hidden for a non-external symbol as that would make it extenal.

Refine codegen for visibility and hidden.  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=92118&r1=92117&r2=92118&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Wed Dec 23 20:33:48 2009
@@ -262,6 +262,7 @@
     return llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), n);
   }
 
+  // FIXME: unify with getTypeInfoLinkage
   bool DecideExtern(QualType Ty) {
     // For this type, see if all components are never in an anonymous namespace.
     if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>())
@@ -269,12 +270,26 @@
               && DecideExtern(QualType(MPT->getClass(), 0)));
     if (const PointerType *PT = Ty->getAs<PointerType>())
       return DecideExtern(PT->getPointeeType());
+    if (const FunctionType *FT = Ty->getAs<FunctionType>()) {
+      if (DecideExtern(FT->getResultType()) == false)
+        return false;
+      if (const FunctionProtoType *FPT = Ty->getAs<FunctionProtoType>()) {
+        for (unsigned i = 0; i <FPT->getNumArgs(); ++i)
+          if (DecideExtern(FPT->getArgType(i)) == false)
+            return false;
+        for (unsigned i = 0; i <FPT->getNumExceptions(); ++i)
+          if (DecideExtern(FPT->getExceptionType(i)) == false)
+            return false;
+        return true;
+      }
+    }
     if (const RecordType *RT = Ty->getAs<RecordType>())
       if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
         return !RD->isInAnonymousNamespace() && RD->hasLinkage();
     return true;
   }
 
+  // FIXME: unify with DecideExtern
   bool DecideHidden(QualType Ty) {
     // For this type, see if all components are never hidden.
     if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>())
@@ -282,6 +297,19 @@
               && DecideHidden(QualType(MPT->getClass(), 0)));
     if (const PointerType *PT = Ty->getAs<PointerType>())
       return DecideHidden(PT->getPointeeType());
+    if (const FunctionType *FT = Ty->getAs<FunctionType>()) {
+      if (DecideHidden(FT->getResultType()) == false)
+        return false;
+      if (const FunctionProtoType *FPT = Ty->getAs<FunctionProtoType>()) {
+        for (unsigned i = 0; i <FPT->getNumArgs(); ++i)
+          if (DecideHidden(FPT->getArgType(i)) == false)
+            return false;
+        for (unsigned i = 0; i <FPT->getNumExceptions(); ++i)
+          if (DecideHidden(FPT->getExceptionType(i)) == false)
+            return false;
+        return true;
+      }
+    }
     if (const RecordType *RT = Ty->getAs<RecordType>())
       if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
         return CGM.getDeclVisibilityMode(RD) == LangOptions::Hidden;
@@ -305,7 +333,7 @@
     Info.push_back(BuildName(Ty, Hidden, Extern));
     
     // We always generate these as hidden, only the name isn't hidden.
-    return finish(GV, Name, /*Hidden=*/true, 
+    return finish(GV, Name, /*Hidden=*/Extern ? true : false, 
                   GetLinkageFromExternFlag(Extern));
   }
 





More information about the cfe-commits mailing list