Unify the BlockDeclRefExpr and DeclRefExpr paths so that

we correctly emit loads of BlockDeclRefExprs even when they
don't qualify as ODR-uses.  I think I'm adequately convinced
that BlockDeclRefExpr can die.

llvm-svn: 152479
This commit is contained in:
John McCall
2012-03-10 03:05:10 +00:00
parent b785a6691b
commit 7133505936
6 changed files with 285 additions and 52 deletions

View File

@@ -111,8 +111,24 @@ public:
}
// l-values.
ComplexPairTy VisitDeclRefExpr(const Expr *E) { return EmitLoadOfLValue(E); }
ComplexPairTy VisitBlockDeclRefExpr(const Expr *E) { return EmitLoadOfLValue(E); }
ComplexPairTy emitDeclRef(ValueDecl *VD, Expr *refExpr) {
if (CodeGenFunction::ConstantEmission result
= CGF.tryEmitAsConstant(VD, refExpr)) {
if (result.isReference())
return EmitLoadOfLValue(result.getReferenceLValue(CGF, refExpr));
llvm::ConstantStruct *pair =
cast<llvm::ConstantStruct>(result.getValue());
return ComplexPairTy(pair->getOperand(0), pair->getOperand(1));
}
return EmitLoadOfLValue(refExpr);
}
ComplexPairTy VisitDeclRefExpr(DeclRefExpr *E) {
return emitDeclRef(E->getDecl(), E);
}
ComplexPairTy VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
return emitDeclRef(E->getDecl(), E);
}
ComplexPairTy VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
return EmitLoadOfLValue(E);
}