aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-02-18 21:49:28 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-02-18 21:49:28 +0000
commit4fd83ea566f4a0c083001c84b75da6cc8c99c1d6 (patch)
tree9f30de529516131aedbf0a5ef53ebec50c1ea977 /lib/CodeGen/CGExpr.cpp
parentca2f3fdeedc4e4beea4f7572d6d975188d0bb5ef (diff)
Some refactoring and simplificaiotn of objc's gc
ir gen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r--lib/CodeGen/CGExpr.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index ae8d4b433a..e991c8ec77 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -604,22 +604,15 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
Builder.CreateStore(Vec, Dst.getExtVectorAddr(), Dst.isVolatileQualified());
}
-/// SetVarDeclObjCAttribute - Set __weak/__strong attributes into the LValue
+/// SetDeclObjCGCAttrInLvalue - Set __weak/__strong attributes into the LValue
/// object.
-static void SetVarDeclObjCAttribute(ASTContext &Ctx, const Decl *VD,
- const QualType &Ty, LValue &LV)
+static void SetDeclObjCGCAttrInLvalue(ASTContext &Ctx, const QualType &Ty,
+ LValue &LV)
{
- if (Ctx.getLangOptions().ObjC1 &&
- Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
- QualType::GCAttrTypes attr = Ty.getObjCGCAttr();
- if (attr != QualType::GCNone)
- LValue::SetObjCType(attr == QualType::Weak,
- attr == QualType::Strong, LV);
- // Default behavious under objective-c's gc is for objective-c pointers
- // be treated as though they were declared as __strong.
- else if (Ctx.isObjCObjectPointerType(Ty))
- LValue::SetObjCType(false, true, LV);
- }
+ QualType::GCAttrTypes attr = Ctx.getObjCGCAttrKind(Ty);
+ if (attr != QualType::GCNone)
+ LValue::SetObjCType(attr == QualType::Weak,
+ attr == QualType::Strong, LV);
}
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
@@ -640,12 +633,12 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
if (VD->isBlockVarDecl() &&
(VD->getStorageClass() == VarDecl::Static ||
VD->getStorageClass() == VarDecl::Extern))
- SetVarDeclObjCAttribute(getContext(), VD, E->getType(), LV);
+ SetDeclObjCGCAttrInLvalue(getContext(), E->getType(), LV);
return LV;
} else if (VD && VD->isFileVarDecl()) {
LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
E->getType().getCVRQualifiers());
- SetVarDeclObjCAttribute(getContext(), VD, E->getType(), LV);
+ SetDeclObjCGCAttrInLvalue(getContext(), E->getType(), LV);
return LV;
} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) {
return LValue::MakeAddr(CGM.GetAddrOfFunction(FD),
@@ -1054,7 +1047,7 @@ LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
ObjectTy,
BaseValue, Ivar, Field,
CVRQualifiers);
- SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
+ SetDeclObjCGCAttrInLvalue(getContext(), Ivar->getType(), LV);
return LV;
}