From: Fariborz Jahanian Date: Tue, 7 Apr 2009 20:26:30 +0000 (+0000) Subject: Propagte -fvisibility to objc2's class symbols. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf71dd4242fd00ab155b5430a4c6c9f88fe5c4be;p=clang Propagte -fvisibility to objc2's class symbols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68543 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index f410e213cb..f7829264e7 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -440,6 +440,8 @@ protected: llvm::Constant *BuildIvarLayout(const ObjCImplementationDecl *OI, bool ForStrongLayout); + bool IsClassHidden(const ObjCInterfaceDecl *ID); + void BuildAggrIvarLayout(const ObjCInterfaceDecl *OI, const llvm::StructLayout *Layout, const RecordDecl *RD, @@ -1426,10 +1428,8 @@ enum ClassFlags { eClassFlags_ABI2_HasCXXStructors = 0x00004 // }; -// -static bool IsClassHidden(const ObjCInterfaceDecl *ID) { +bool CGObjCCommonMac::IsClassHidden(const ObjCInterfaceDecl *ID) { if (const VisibilityAttr *attr = ID->getAttr()) { - // FIXME: Support -fvisibility switch (attr->getVisibility()) { default: assert(0 && "Unknown visibility"); @@ -1440,9 +1440,9 @@ static bool IsClassHidden(const ObjCInterfaceDecl *ID) { case VisibilityAttr::HiddenVisibility: return true; } - } else { - return false; // FIXME: Support -fvisibility - } + } else + return (CGM.getLangOptions().getVisibilityMode() == + LangOptions::HiddenVisibility); } /* @@ -4522,9 +4522,6 @@ llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar( IvarOffsetGV->setVisibility(llvm::GlobalValue::HiddenVisibility); else if (IsClassHidden(ID)) IvarOffsetGV->setVisibility(llvm::GlobalValue::HiddenVisibility); - else if (CGM.getLangOptions().getVisibilityMode() == - LangOptions::HiddenVisibility) - IvarOffsetGV->setVisibility(llvm::GlobalValue::HiddenVisibility); else if (CGM.getLangOptions().getVisibilityMode() == LangOptions::DefaultVisibility) IvarOffsetGV->setVisibility(llvm::GlobalValue::DefaultVisibility); diff --git a/test/CodeGenObjC/class-obj-hidden-visibility.m b/test/CodeGenObjC/class-obj-hidden-visibility.m new file mode 100644 index 0000000000..fc4ac12b18 --- /dev/null +++ b/test/CodeGenObjC/class-obj-hidden-visibility.m @@ -0,0 +1,6 @@ +// RUN: clang-cc -fvisibility=hidden -triple x86_64-apple-darwin10 -S -o - %s | grep -e "private_extern _OBJC_" | count 2 + +@interface INTF @end + +@implementation INTF @end + diff --git a/test/CodeGenObjC/metadata_symbols.m b/test/CodeGenObjC/metadata_symbols.m index 7141813df4..df36a50f52 100644 --- a/test/CodeGenObjC/metadata_symbols.m +++ b/test/CodeGenObjC/metadata_symbols.m @@ -10,10 +10,8 @@ // RUN: clang-cc -fvisibility=hidden -triple x86_64-apple-darwin9 -emit-llvm -o %t %s && -// FIXME: This is wrong, should be hidden -// RUN: grep '@"OBJC_METACLASS_$_A" = global .*section "__DATA, __objc_data", align 8' %t && -// FIXME: This is wrong, should be hidden -// RUN: grep '@"OBJC_CLASS_$_A" = global .*section "__DATA, __objc_data", align 8' %t && +// RUN: grep '@"OBJC_METACLASS_$_A" = hidden global .*section "__DATA, __objc_data", align 8' %t && +// RUN: grep '@"OBJC_CLASS_$_A" = hidden global .*section "__DATA, __objc_data", align 8' %t && // RUN: grep '@"OBJC_EHTYPE_$_EH1" = weak hidden global .*section "__DATA,__datacoal_nt,coalesced"' %t && // RUN: grep -F 'define internal void @"\01-[A im0]"' %t && // FIXME: Should include category name.