From 7decc9e4ea6c56ffce14d25f542f5eda3eeba97a Mon Sep 17 00:00:00 2001 From: John McCall Date: Thu, 18 Nov 2010 06:31:45 +0000 Subject: Calculate the value kind of an expression when it's created and store it on the expression node. Also store an "object kind", which distinguishes ordinary "addressed" l-values (like variable references and pointer dereferences) and bitfield, @property, and vector-component l-values. Currently we're not using these for much, but I aim to switch pretty much everything calculating l-valueness over to them. For now they shouldn't necessarily be trusted. llvm-svn: 119685 --- clang/lib/CodeGen/CGBlocks.cpp | 28 ++++++++++++++-------------- clang/lib/CodeGen/CGObjC.cpp | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index c40cfaf6a97..8f3e0a63263 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -161,7 +161,7 @@ static void AllocateAllBlockDeclRefs(CodeGenFunction &CGF, CGBlockInfo &Info) { if (Info.NeedsObjCSelf) { ValueDecl *Self = cast(CGF.CurFuncDecl)->getSelfDecl(); BlockDeclRefExpr *BDRE = - new (CGF.getContext()) BlockDeclRefExpr(Self, Self->getType(), + new (CGF.getContext()) BlockDeclRefExpr(Self, Self->getType(), VK_RValue, SourceLocation(), false); Info.DeclRefs.push_back(BDRE); CGF.AllocateBlockDecl(BDRE); @@ -344,26 +344,26 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { if (BDRE->getCopyConstructorExpr()) { E = BDRE->getCopyConstructorExpr(); PushDestructorCleanup(E->getType(), Addr); - } - else { - E = new (getContext()) DeclRefExpr(const_cast(VD), - VD->getType().getNonReferenceType(), - SourceLocation()); - if (VD->getType()->isReferenceType()) { - E = new (getContext()) - UnaryOperator(const_cast(E), UO_AddrOf, - getContext().getPointerType(E->getType()), - SourceLocation()); - } + } else { + E = new (getContext()) DeclRefExpr(const_cast(VD), + VD->getType().getNonReferenceType(), + Expr::getValueKindForType(VD->getType()), + SourceLocation()); + if (VD->getType()->isReferenceType()) { + E = new (getContext()) + UnaryOperator(const_cast(E), UO_AddrOf, + getContext().getPointerType(E->getType()), + VK_RValue, OK_Ordinary, SourceLocation()); } } } + } if (BDRE->isByRef()) { E = new (getContext()) UnaryOperator(const_cast(E), UO_AddrOf, getContext().getPointerType(E->getType()), - SourceLocation()); + VK_RValue, OK_Ordinary, SourceLocation()); } RValue r = EmitAnyExpr(E, AggValueSlot::forAddr(Addr, false, true)); @@ -932,7 +932,7 @@ CharUnits BlockFunction::getBlockOffset(CharUnits Size, CharUnits Align) { 0, QualType(PadTy), 0, SC_None, SC_None); Expr *E = new (getContext()) DeclRefExpr(PadDecl, PadDecl->getType(), - SourceLocation()); + VK_LValue, SourceLocation()); BlockLayout.push_back(E); } diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 7c2dfe8b23b..13f4d8f7965 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -393,9 +393,9 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, SourceLocation Loc = PD->getLocation(); ValueDecl *Self = OMD->getSelfDecl(); ObjCIvarDecl *Ivar = PID->getPropertyIvarDecl(); - DeclRefExpr Base(Self, Self->getType(), Loc); + DeclRefExpr Base(Self, Self->getType(), VK_RValue, Loc); ParmVarDecl *ArgDecl = *OMD->param_begin(); - DeclRefExpr Arg(ArgDecl, ArgDecl->getType(), Loc); + DeclRefExpr Arg(ArgDecl, ArgDecl->getType(), VK_LValue, Loc); ObjCIvarRefExpr IvarRef(Ivar, Ivar->getType(), Loc, &Base, true, true); // The property type can differ from the ivar type in some situations with @@ -406,11 +406,11 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, Ivar->getType(), CK_BitCast, &Arg, VK_RValue); BinaryOperator Assign(&IvarRef, &ArgCasted, BO_Assign, - Ivar->getType(), Loc); + Ivar->getType(), VK_RValue, OK_Ordinary, Loc); EmitStmt(&Assign); } else { BinaryOperator Assign(&IvarRef, &Arg, BO_Assign, - Ivar->getType(), Loc); + Ivar->getType(), VK_RValue, OK_Ordinary, Loc); EmitStmt(&Assign); } } -- cgit v1.2.3