summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprAgg.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-05-19 17:51:16 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-05-19 17:51:16 +0000
commitf23b6fa41fb28f632249ef65754b22116f86f59f (patch)
tree2042fb46e0ceb0450614dc8d0f8c1b908acb07a1 /clang/lib/CodeGen/CGExprAgg.cpp
parentf767e44ed6196d43f4a0094df8e778d20dff8497 (diff)
downloadbcm5719-llvm-f23b6fa41fb28f632249ef65754b22116f86f59f.tar.gz
bcm5719-llvm-f23b6fa41fb28f632249ef65754b22116f86f59f.zip
Fix the emission of expressions like char a[10] = "asdf"; previously,
they were causing bad code to be emitted. There are two fixes here: one makes sure we emit a string that is long enough, and one makes sure we properly handle string initialization in init lists. llvm-svn: 51259
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprAgg.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 6b68705af73..c7c250ee7be 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -53,7 +53,7 @@ public:
void EmitAggregateClear(llvm::Value *DestPtr, QualType Ty);
void EmitNonConstInit(InitListExpr *E);
-
+
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
@@ -336,7 +336,6 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) {
}
}
-
void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
if (E->isConstantExpr(CGF.getContext(), 0)) {
// FIXME: call into const expr emitter so that we can emit
@@ -355,6 +354,14 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
cast<llvm::ArrayType>(APType->getElementType());
uint64_t NumInitElements = E->getNumInits();
+
+ if (E->getNumInits() > 0 &&
+ E->getType().getCanonicalType().getUnqualifiedType() ==
+ E->getInit(0)->getType().getCanonicalType().getUnqualifiedType()) {
+ EmitAggLoadOfLValue(E->getInit(0));
+ return;
+ }
+
uint64_t NumArrayElements = AType->getNumElements();
QualType ElementType = E->getType()->getAsArrayType()->getElementType();
OpenPOWER on IntegriCloud