Fixed visibility issues related to objc2's synthesized

ivars.

llvm-svn: 68453
This commit is contained in:
Fariborz Jahanian 2009-04-06 18:30:00 +00:00
parent 6f811f149b
commit bc3c77b881
3 changed files with 31 additions and 21 deletions

View File

@ -4493,37 +4493,34 @@ llvm::Constant * CGObjCNonFragileABIMac::EmitIvarOffsetVar(
std::string ExternalName("\01_OBJC_IVAR_$_" + ID->getNameAsString() + '.'
+ Ivar->getNameAsString());
llvm::Constant *Init = llvm::ConstantInt::get(ObjCTypes.LongTy, Offset);
llvm::GlobalVariable *IvarOffsetGV =
CGM.getModule().getGlobalVariable(ExternalName);
if (IvarOffsetGV) {
if (IvarOffsetGV)
// ivar offset symbol already built due to user code referencing it.
IvarOffsetGV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.LongTy));
IvarOffsetGV->setInitializer(Init);
IvarOffsetGV->setSection("__DATA, __objc_const");
UsedGlobals.push_back(IvarOffsetGV);
return IvarOffsetGV;
}
IvarOffsetGV =
new llvm::GlobalVariable(Init->getType(),
false,
llvm::GlobalValue::ExternalLinkage,
Init,
ExternalName,
&CGM.getModule());
else
IvarOffsetGV =
new llvm::GlobalVariable(Init->getType(),
false,
llvm::GlobalValue::ExternalLinkage,
Init,
ExternalName,
&CGM.getModule());
IvarOffsetGV->setAlignment(
CGM.getTargetData().getPrefTypeAlignment(ObjCTypes.LongTy));
// @private and @package have hidden visibility.
bool globalVisibility = (Ivar->getAccessControl() == ObjCIvarDecl::Public ||
Ivar->getAccessControl() == ObjCIvarDecl::Protected);
Ivar->getAccessControl() == ObjCIvarDecl::Protected);
if (!globalVisibility)
IvarOffsetGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
else
if (IsClassHidden(ID))
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");
UsedGlobals.push_back(IvarOffsetGV);
return IvarOffsetGV;

View File

@ -1795,7 +1795,7 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
if (getLangOptions().ObjCNonFragileABI) {
Ivar = ObjCIvarDecl::Create(Context, CurContext, PropertyLoc,
PropertyIvar, PropType,
ObjCIvarDecl::Private,
ObjCIvarDecl::Public,
(Expr *)0);
property->setPropertyIvarDecl(Ivar);
}

View File

@ -0,0 +1,13 @@
// RUN: clang-cc -fvisibility=hidden -triple x86_64-apple-darwin10 -S -o - %s | grep -e "private_extern _OBJC_IVAR_"
@interface I
{
int P;
}
@property int P;
@end
@implementation I
@synthesize P;
@end