From 4e6f8ee45d9b822b437529e2334b146bb8c3537f Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Thu, 24 Dec 2009 02:33:48 +0000 Subject: [PATCH] Don't set hidden for a non-external symbol as that would make it extenal. Refine codegen for visibility and hidden. WIP. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92118 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGRTTI.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp index e241089845..937a4420ef 100644 --- a/lib/CodeGen/CGRTTI.cpp +++ b/lib/CodeGen/CGRTTI.cpp @@ -262,6 +262,7 @@ public: 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()) @@ -269,12 +270,26 @@ public: && DecideExtern(QualType(MPT->getClass(), 0))); if (const PointerType *PT = Ty->getAs()) return DecideExtern(PT->getPointeeType()); + if (const FunctionType *FT = Ty->getAs()) { + if (DecideExtern(FT->getResultType()) == false) + return false; + if (const FunctionProtoType *FPT = Ty->getAs()) { + for (unsigned i = 0; i getNumArgs(); ++i) + if (DecideExtern(FPT->getArgType(i)) == false) + return false; + for (unsigned i = 0; i getNumExceptions(); ++i) + if (DecideExtern(FPT->getExceptionType(i)) == false) + return false; + return true; + } + } if (const RecordType *RT = Ty->getAs()) if (const CXXRecordDecl *RD = dyn_cast(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()) @@ -282,6 +297,19 @@ public: && DecideHidden(QualType(MPT->getClass(), 0))); if (const PointerType *PT = Ty->getAs()) return DecideHidden(PT->getPointeeType()); + if (const FunctionType *FT = Ty->getAs()) { + if (DecideHidden(FT->getResultType()) == false) + return false; + if (const FunctionProtoType *FPT = Ty->getAs()) { + for (unsigned i = 0; i getNumArgs(); ++i) + if (DecideHidden(FPT->getArgType(i)) == false) + return false; + for (unsigned i = 0; i getNumExceptions(); ++i) + if (DecideHidden(FPT->getExceptionType(i)) == false) + return false; + return true; + } + } if (const RecordType *RT = Ty->getAs()) if (const CXXRecordDecl *RD = dyn_cast(RT->getDecl())) return CGM.getDeclVisibilityMode(RD) == LangOptions::Hidden; @@ -305,7 +333,7 @@ public: 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)); } -- 2.50.1