@@ -8551,6 +8551,10 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
8551
8551
static bool EvaluateArrayNewInitList(EvalInfo &Info, LValue &This,
8552
8552
APValue &Result, const InitListExpr *ILE,
8553
8553
QualType AllocType);
8554
+ static bool EvaluateArrayNewConstructExpr(EvalInfo &Info, LValue &This,
8555
+ APValue &Result,
8556
+ const CXXConstructExpr *CCE,
8557
+ QualType AllocType);
8554
8558
8555
8559
bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
8556
8560
if (!Info.getLangOpts().CPlusPlus2a)
@@ -8600,6 +8604,7 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
8600
8604
8601
8605
const Expr *Init = E->getInitializer();
8602
8606
const InitListExpr *ResizedArrayILE = nullptr;
8607
+ const CXXConstructExpr *ResizedArrayCCE = nullptr;
8603
8608
8604
8609
QualType AllocType = E->getAllocatedType();
8605
8610
if (Optional<const Expr*> ArraySize = E->getArraySize()) {
@@ -8643,7 +8648,7 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
8643
8648
// -- the new-initializer is a braced-init-list and the number of
8644
8649
// array elements for which initializers are provided [...]
8645
8650
// exceeds the number of elements to initialize
8646
- if (Init) {
8651
+ if (Init && !isa<CXXConstructExpr>(Init) ) {
8647
8652
auto *CAT = Info.Ctx.getAsConstantArrayType(Init->getType());
8648
8653
assert(CAT && "unexpected type for array initializer");
8649
8654
@@ -8666,6 +8671,8 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
8666
8671
// special handling for this case when we initialize.
8667
8672
if (InitBound != AllocBound)
8668
8673
ResizedArrayILE = cast<InitListExpr>(Init);
8674
+ } else if (Init) {
8675
+ ResizedArrayCCE = cast<CXXConstructExpr>(Init);
8669
8676
}
8670
8677
8671
8678
AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
@@ -8730,6 +8737,10 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
8730
8737
if (!EvaluateArrayNewInitList(Info, Result, *Val, ResizedArrayILE,
8731
8738
AllocType))
8732
8739
return false;
8740
+ } else if (ResizedArrayCCE) {
8741
+ if (!EvaluateArrayNewConstructExpr(Info, Result, *Val, ResizedArrayCCE,
8742
+ AllocType))
8743
+ return false;
8733
8744
} else if (Init) {
8734
8745
if (!EvaluateInPlace(*Val, Info, Result, Init))
8735
8746
return false;
@@ -9554,6 +9565,16 @@ static bool EvaluateArrayNewInitList(EvalInfo &Info, LValue &This,
9554
9565
.VisitInitListExpr(ILE, AllocType);
9555
9566
}
9556
9567
9568
+ static bool EvaluateArrayNewConstructExpr(EvalInfo &Info, LValue &This,
9569
+ APValue &Result,
9570
+ const CXXConstructExpr *CCE,
9571
+ QualType AllocType) {
9572
+ assert(CCE->isRValue() && CCE->getType()->isArrayType() &&
9573
+ "not an array rvalue");
9574
+ return ArrayExprEvaluator(Info, This, Result)
9575
+ .VisitCXXConstructExpr(CCE, This, &Result, AllocType);
9576
+ }
9577
+
9557
9578
// Return true iff the given array filler may depend on the element index.
9558
9579
static bool MaybeElementDependentArrayFiller(const Expr *FillerExpr) {
9559
9580
// For now, just whitelist non-class value-initialization and initialization
0 commit comments