aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-04-07 20:26:30 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-04-07 20:26:30 +0000
commitcf71dd4242fd00ab155b5430a4c6c9f88fe5c4be (patch)
treeb36259f2d2f18de86fcf0812e0439efc92014ac0
parent85a5319ea4b5c916d7dd665e84af61e4a8a0b9c2 (diff)
Propagte -fvisibility to objc2's class symbols.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68543 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGObjCMac.cpp15
-rw-r--r--test/CodeGenObjC/class-obj-hidden-visibility.m6
-rw-r--r--test/CodeGenObjC/metadata_symbols.m6
3 files changed, 14 insertions, 13 deletions
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 // <rdr://4923634>
};
-// <rdr://5142207&4705298&4843145>
-static bool IsClassHidden(const ObjCInterfaceDecl *ID) {
+bool CGObjCCommonMac::IsClassHidden(const ObjCInterfaceDecl *ID) {
if (const VisibilityAttr *attr = ID->getAttr<VisibilityAttr>()) {
- // 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);
}
/*
@@ -4523,9 +4523,6 @@ llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar(
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);
IvarOffsetGV->setSection("__DATA, __objc_const");
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.