summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprAgg.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-03-10 03:05:10 +0000
committerJohn McCall <rjmccall@apple.com>2012-03-10 03:05:10 +0000
commit713350593697f52c6e4412794169287b8e0177d9 (patch)
treea3f8bba7cc3aa8f75b7818d41be9e713ca258634 /clang/lib/CodeGen/CGExprAgg.cpp
parentb785a6691b01861da88ba2a1beb88a0a171993e1 (diff)
downloadbcm5719-llvm-713350593697f52c6e4412794169287b8e0177d9.tar.gz
bcm5719-llvm-713350593697f52c6e4412794169287b8e0177d9.zip
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
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 899577c4ede..f7c640adacf 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -109,7 +109,28 @@ public:
}
// l-values.
- void VisitDeclRefExpr(DeclRefExpr *DRE) { EmitAggLoadOfLValue(DRE); }
+ void emitDeclRef(ValueDecl *VD, Expr *refExpr) {
+ // For aggregates, we should always be able to emit the variable
+ // as an l-value unless it's a reference. This is due to the fact
+ // that we can't actually ever see a normal l2r conversion on an
+ // aggregate in C++, and in C there's no language standard
+ // actively preventing us from listing variables in the captures
+ // list of a block.
+ if (VD->getType()->isReferenceType()) {
+ if (CodeGenFunction::ConstantEmission result
+ = CGF.tryEmitAsConstant(VD, refExpr)) {
+ EmitFinalDestCopy(refExpr, result.getReferenceLValue(CGF, refExpr));
+ return;
+ }
+ }
+
+ EmitAggLoadOfLValue(refExpr);
+ }
+ void VisitDeclRefExpr(DeclRefExpr *E) { emitDeclRef(E->getDecl(), E); }
+ void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
+ emitDeclRef(E->getDecl(), E);
+ }
+
void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
void VisitUnaryDeref(UnaryOperator *E) { EmitAggLoadOfLValue(E); }
void VisitStringLiteral(StringLiteral *E) { EmitAggLoadOfLValue(E); }
@@ -117,9 +138,6 @@ public:
void VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
EmitAggLoadOfLValue(E);
}
- void VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) {
- EmitAggLoadOfLValue(E);
- }
void VisitPredefinedExpr(const PredefinedExpr *E) {
EmitAggLoadOfLValue(E);
}
OpenPOWER on IntegriCloud