summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-08 21:08:07 +0000
committerChris Lattner <sabre@nondot.org>2010-03-08 21:08:07 +0000
commite18aaf2c4b0cfbf0d6c87c07bdf53032661631c5 (patch)
treeb3757efd3937c1f16fca00055be2a0f8543b90f1 /clang/lib/CodeGen
parent5967649780ccd723cfd7a7303bc63348d27691de (diff)
downloadbcm5719-llvm-e18aaf2c4b0cfbf0d6c87c07bdf53032661631c5.tar.gz
bcm5719-llvm-e18aaf2c4b0cfbf0d6c87c07bdf53032661631c5.zip
add a codegen hack to work around an AST bug, allowing us to compile the
code in PR6537. This should be reverted when the ast bug is fixed. llvm-svn: 97981
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 5af6f91d148..4847ca3f824 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -662,6 +662,16 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
return;
}
+
+ // If we're initializing the whole aggregate, just do it in place.
+ // FIXME: This is a hack around an AST bug (PR6537).
+ if (NumInitElements == 1 && E->getType() == E->getInit(0)->getType()) {
+ EmitInitializationToLValue(E->getInit(0),
+ LValue::MakeAddr(DestPtr, Qualifiers()),
+ E->getType());
+ return;
+ }
+
// Here we iterate over the fields; this makes it simpler to both
// default-initialize fields and skip over unnamed fields.
@@ -680,8 +690,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
// We never generate write-barries for initialized fields.
LValue::SetObjCNonGC(FieldLoc, true);
if (CurInitVal < NumInitElements) {
- // Store the initializer into the field
- EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc,
+ // Store the initializer into the field.
+ EmitInitializationToLValue(E->getInit(CurInitVal++), FieldLoc,
Field->getType());
} else {
// We're out of initalizers; default-initialize to null
OpenPOWER on IntegriCloud