[cfe-commits] r65077 - in /cfe/trunk/lib: AST/ASTContext.cpp CodeGen/CGExpr.cpp CodeGen/CGObjCMac.cpp
Fariborz Jahanian
fjahanian at apple.com
Thu Feb 19 15:36:07 PST 2009
Author: fjahanian
Date: Thu Feb 19 17:36:06 2009
New Revision: 65077
URL: http://llvm.org/viewvc/llvm-project?rev=65077&view=rev
Log:
More objc's gc ir-gen stuff.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=65077&r1=65076&r2=65077&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Feb 19 17:36:06 2009
@@ -2417,9 +2417,14 @@
getLangOptions().getGCMode() != LangOptions::NonGC) {
GCAttrs = Ty.getObjCGCAttr();
// Default behavious under objective-c's gc is for objective-c pointers
- // be treated as though they were declared as __strong.
- if (GCAttrs == QualType::GCNone && isObjCObjectPointerType(Ty))
- GCAttrs = QualType::Strong;
+ // (or pointers to them) be treated as though they were declared
+ // as __strong.
+ if (GCAttrs == QualType::GCNone) {
+ if (isObjCObjectPointerType(Ty))
+ GCAttrs = QualType::Strong;
+ else if (Ty->isPointerType())
+ return getObjCGCAttrKind(Ty->getAsPointerType()->getPointeeType());
+ }
}
return GCAttrs;
}
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=65077&r1=65076&r2=65077&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb 19 17:36:06 2009
@@ -109,7 +109,8 @@
ErrorUnsupported(E, Name);
llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType()));
return LValue::MakeAddr(llvm::UndefValue::get(Ty),
- E->getType().getCVRQualifiers());
+ E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
/// EmitLValue - Emit code to compute a designator that specifies the location
@@ -611,15 +612,6 @@
Builder.CreateStore(Vec, Dst.getExtVectorAddr(), Dst.isVolatileQualified());
}
-/// SetDeclObjCGCAttrInLvalue - Set __weak/__strong attributes into the LValue
-/// object.
-static void SetDeclObjCGCAttrInLvalue(ASTContext &Ctx, const QualType &Ty,
- LValue &LV)
-{
- QualType::GCAttrTypes attr = Ctx.getObjCGCAttrKind(Ty);
- LValue::SetObjCType(attr, LV);
-}
-
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
const VarDecl *VD = dyn_cast<VarDecl>(E->getDecl());
@@ -628,32 +620,32 @@
LValue LV;
if (VD->getStorageClass() == VarDecl::Extern) {
LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
- E->getType().getCVRQualifiers());
+ E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
else {
llvm::Value *V = LocalDeclMap[VD];
assert(V && "BlockVarDecl not entered in LocalDeclMap?");
- LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers());
+ LV = LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
- if (VD->isBlockVarDecl() &&
- (VD->getStorageClass() == VarDecl::Static ||
- VD->getStorageClass() == VarDecl::Extern))
- SetDeclObjCGCAttrInLvalue(getContext(), E->getType(), LV);
return LV;
} else if (VD && VD->isFileVarDecl()) {
LValue LV = LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD),
- E->getType().getCVRQualifiers());
- SetDeclObjCGCAttrInLvalue(getContext(), E->getType(), LV);
+ E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
return LV;
} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) {
return LValue::MakeAddr(CGM.GetAddrOfFunction(FD),
- E->getType().getCVRQualifiers());
+ E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
else if (const ImplicitParamDecl *IPD =
dyn_cast<ImplicitParamDecl>(E->getDecl())) {
llvm::Value *V = LocalDeclMap[IPD];
assert(V && "BlockVarDecl not entered in LocalDeclMap?");
- return LValue::MakeAddr(V, E->getType().getCVRQualifiers());
+ return LValue::MakeAddr(V, E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
assert(0 && "Unimp declref");
//an invalid LValue, but the assert will
@@ -670,9 +662,12 @@
switch (E->getOpcode()) {
default: assert(0 && "Unknown unary operator lvalue!");
case UnaryOperator::Deref:
- return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
- ExprTy->getAsPointerType()->getPointeeType()
- .getCVRQualifiers());
+ {
+ QualType T = E->getSubExpr()->getType()->getAsPointerType()->getPointeeType();
+ return LValue::MakeAddr(EmitScalarExpr(E->getSubExpr()),
+ ExprTy->getAsPointerType()->getPointeeType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(T));
+ }
case UnaryOperator::Real:
case UnaryOperator::Imag:
LValue LV = EmitLValue(E->getSubExpr());
@@ -921,22 +916,23 @@
"tmp");
}
- LValue LV =
- LValue::MakeAddr(V,
- Field->getType().getCVRQualifiers()|CVRQualifiers);
+ QualType::GCAttrTypes attr = QualType::GCNone;
if (CGM.getLangOptions().ObjC1 &&
CGM.getLangOptions().getGCMode() != LangOptions::NonGC) {
QualType Ty = Field->getType();
- QualType::GCAttrTypes attr = Ty.getObjCGCAttr();
+ attr = Ty.getObjCGCAttr();
if (attr != QualType::GCNone) {
// __weak attribute on a field is ignored.
- if (attr == QualType::Strong)
- LValue::SetObjCType(QualType::Strong, LV);
+ if (attr == QualType::Weak)
+ attr = QualType::GCNone;
}
else if (getContext().isObjCObjectPointerType(Ty))
- LValue::SetObjCType(QualType::Strong, LV);
-
+ attr = QualType::Strong;
}
+ LValue LV =
+ LValue::MakeAddr(V,
+ Field->getType().getCVRQualifiers()|CVRQualifiers,
+ attr);
return LV;
}
@@ -999,14 +995,16 @@
llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType()));
EmitAggExpr(E, Temp, false);
// FIXME: Are these qualifiers correct?
- return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers());
+ return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
LValue CodeGenFunction::EmitCallExprLValue(const CallExpr *E) {
// Can only get l-value for call expression returning aggregate type
RValue RV = EmitCallExpr(E);
return LValue::MakeAddr(RV.getAggregateAddr(),
- E->getType().getCVRQualifiers());
+ E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
LValue CodeGenFunction::EmitVAArgExprLValue(const VAArgExpr *E) {
@@ -1027,7 +1025,8 @@
RValue RV = EmitObjCMessageExpr(E);
// FIXME: can this be volatile?
return LValue::MakeAddr(RV.getAggregateAddr(),
- E->getType().getCVRQualifiers());
+ E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
}
llvm::Value *CodeGenFunction::EmitIvarOffset(ObjCInterfaceDecl *Interface,
@@ -1056,7 +1055,6 @@
ObjectTy,
BaseValue, Ivar, Field,
CVRQualifiers);
- SetDeclObjCGCAttrInLvalue(getContext(), Ivar->getType(), LV);
return LV;
}
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=65077&r1=65076&r2=65077&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Feb 19 17:36:06 2009
@@ -2203,7 +2203,8 @@
unsigned Index = CGM.getTypes().getLLVMFieldNo(Field);
llvm::Value *V = CGF.Builder.CreateStructGEP(BaseValue, Index, "tmp");
LValue LV = LValue::MakeAddr(V,
- Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+ Ivar->getType().getCVRQualifiers()|CVRQualifiers,
+ CGM.getContext().getObjCGCAttrKind(Ivar->getType()));
LValue::SetObjCIvar(LV, true);
return LV;
}
@@ -4350,7 +4351,8 @@
CVRQualifiers);
LValue LV = LValue::MakeAddr(V,
- Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+ Ivar->getType().getCVRQualifiers()|CVRQualifiers,
+ CGM.getContext().getObjCGCAttrKind(Ivar->getType()));
LValue::SetObjCIvar(LV, true);
return LV;
}
More information about the cfe-commits
mailing list