diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-11-20 18:10:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-11-20 18:10:58 +0000 |
commit | d4081c697a54d2be237261219f40ee19bdbf2897 (patch) | |
tree | 1608706258fe3a8a5de1f3d1fd741f5060ca0539 /clang/lib/CodeGen/CGExpr.cpp | |
parent | 10b941284a9a94932f21106709ba21090a47879f (diff) | |
download | bcm5719-llvm-d4081c697a54d2be237261219f40ee19bdbf2897.tar.gz bcm5719-llvm-d4081c697a54d2be237261219f40ee19bdbf2897.zip |
Added a test case for __weak field decls. Change SetVarDeclObjCAttribute
to static function. Added comments.
llvm-svn: 59738
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 4228bc22b6f..a9cf4535cf8 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -523,18 +523,19 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, /// SetVarDeclObjCAttribute - Set __weak/__strong attributes into the LValue /// object. -void CodeGenFunction::SetVarDeclObjCAttribute(const VarDecl *VD, - const QualType &Ty, - LValue &LV) +static void SetVarDeclObjCAttribute(ASTContext &Ctx, const VarDecl *VD, + const QualType &Ty, LValue &LV) { if (const ObjCGCAttr *A = VD->getAttr<ObjCGCAttr>()) { ObjCGCAttr::GCAttrTypes attrType = A->getType(); LValue::SetObjCType(attrType == ObjCGCAttr::Weak, attrType == ObjCGCAttr::Strong, LV); } - else if (CGM.getLangOptions().ObjC1 && - CGM.getLangOptions().getGCMode() != LangOptions::NonGC) { - if (getContext().isObjCObjectPointerType(Ty)) + else if (Ctx.getLangOptions().ObjC1 && + Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) { + // Default behavious under objective-c's gc is for objective-c pointers + // be treated as though they were declared as __strong. + if (Ctx.isObjCObjectPointerType(Ty)) LValue::SetObjCType(false, true, LV); } } @@ -557,12 +558,12 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { if (VD->isBlockVarDecl() && (VD->getStorageClass() == VarDecl::Static || VD->getStorageClass() == VarDecl::Extern)) - SetVarDeclObjCAttribute(VD, E->getType(), LV); + SetVarDeclObjCAttribute(getContext(), VD, E->getType(), LV); return LV; } else if (VD && VD->isFileVarDecl()) { LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD), E->getType().getCVRQualifiers()); - SetVarDeclObjCAttribute(VD, E->getType(), LV); + SetVarDeclObjCAttribute(getContext(), VD, E->getType(), LV); return LV; } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) { return LValue::MakeAddr(CGM.GetAddrOfFunction(FD), |