diff options
author | Mike Stump <mrs@apple.com> | 2009-12-24 02:33:48 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-12-24 02:33:48 +0000 |
commit | 4e6f8ee45d9b822b437529e2334b146bb8c3537f (patch) | |
tree | cf58b25219f79e51d528c5f8c68fbb33cddbaf59 | |
parent | 0faa51632584b8d56311d5792a2a275729bc67e3 (diff) |
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
-rw-r--r-- | lib/CodeGen/CGRTTI.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
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<MemberPointerType>()) @@ -269,12 +270,26 @@ public: && 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 @@ public: && 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 @@ 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)); } |