// Pre-allocate storage for the structured initializer list.
unsigned NumElements = 0;
unsigned NumInits = 0;
- if (!StructuredList)
+ bool GotNumInits = false;
+ if (!StructuredList) {
NumInits = IList->getNumInits();
- else if (Index < IList->getNumInits()) {
- if (InitListExpr *SubList = dyn_cast<InitListExpr>(IList->getInit(Index)))
+ GotNumInits = true;
+ } else if (Index < IList->getNumInits()) {
+ if (InitListExpr *SubList = dyn_cast<InitListExpr>(IList->getInit(Index))) {
NumInits = SubList->getNumInits();
+ GotNumInits = true;
+ }
}
if (const ArrayType *AType
NumElements = CAType->getSize().getZExtValue();
// Simple heuristic so that we don't allocate a very large
// initializer with many empty entries at the end.
- if (NumInits && NumElements > NumInits)
+ if (GotNumInits && NumElements > NumInits)
NumElements = 0;
}
} else if (const VectorType *VType = CurrentObjectType->getAs<VectorType>())
// rdar://9275920 - We would create millions of Exprs to fill out the initializer.
double data[1000000] = {0};
+double data_empty_init[1000000] = {};
struct S {
S(int);
};
S data2[1000000] = {0};
+S data_empty_init2[1000000] = {};
// CHECK: TOTAL = {{.*}} (0.{{.*}} MBytes)