@@ -8987,6 +8987,7 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
8987
8987
const Expr *Init = E->getInitializer();
8988
8988
const InitListExpr *ResizedArrayILE = nullptr;
8989
8989
const CXXConstructExpr *ResizedArrayCCE = nullptr;
8990
+ bool ValueInit = false;
8990
8991
8991
8992
QualType AllocType = E->getAllocatedType();
8992
8993
if (Optional<const Expr*> ArraySize = E->getArraySize()) {
@@ -9030,7 +9031,14 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
9030
9031
// -- the new-initializer is a braced-init-list and the number of
9031
9032
// array elements for which initializers are provided [...]
9032
9033
// exceeds the number of elements to initialize
9033
- if (Init && !isa<CXXConstructExpr>(Init)) {
9034
+ if (!Init) {
9035
+ // No initialization is performed.
9036
+ } else if (isa<CXXScalarValueInitExpr>(Init) ||
9037
+ isa<ImplicitValueInitExpr>(Init)) {
9038
+ ValueInit = true;
9039
+ } else if (auto *CCE = dyn_cast<CXXConstructExpr>(Init)) {
9040
+ ResizedArrayCCE = CCE;
9041
+ } else {
9034
9042
auto *CAT = Info.Ctx.getAsConstantArrayType(Init->getType());
9035
9043
assert(CAT && "unexpected type for array initializer");
9036
9044
@@ -9053,8 +9061,6 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
9053
9061
// special handling for this case when we initialize.
9054
9062
if (InitBound != AllocBound)
9055
9063
ResizedArrayILE = cast<InitListExpr>(Init);
9056
- } else if (Init) {
9057
- ResizedArrayCCE = cast<CXXConstructExpr>(Init);
9058
9064
}
9059
9065
9060
9066
AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
@@ -9115,7 +9121,11 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
9115
9121
return false;
9116
9122
}
9117
9123
9118
- if (ResizedArrayILE) {
9124
+ if (ValueInit) {
9125
+ ImplicitValueInitExpr VIE(AllocType);
9126
+ if (!EvaluateInPlace(*Val, Info, Result, &VIE))
9127
+ return false;
9128
+ } else if (ResizedArrayILE) {
9119
9129
if (!EvaluateArrayNewInitList(Info, Result, *Val, ResizedArrayILE,
9120
9130
AllocType))
9121
9131
return false;
0 commit comments