@@ -511,6 +511,58 @@ bool ByteCodeExprGen<Emitter>::VisitArraySubscriptExpr(
511
511
return this ->emitArrayElemPtrPop (IndexT, E);
512
512
}
513
513
514
+ template <class Emitter >
515
+ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
516
+ const Expr *E) {
517
+ assert (E->getType ()->isRecordType ());
518
+ const Record *R = getRecord (E->getType ());
519
+
520
+ unsigned InitIndex = 0 ;
521
+ for (const Expr *Init : Inits) {
522
+ if (!this ->emitDupPtr (E))
523
+ return false ;
524
+
525
+ if (std::optional<PrimType> T = classify (Init)) {
526
+ const Record::Field *FieldToInit = R->getField (InitIndex);
527
+ if (!this ->visit (Init))
528
+ return false ;
529
+ if (!this ->emitInitField (*T, FieldToInit->Offset , E))
530
+ return false ;
531
+ if (!this ->emitPopPtr (E))
532
+ return false ;
533
+ ++InitIndex;
534
+ } else {
535
+ // Initializer for a direct base class.
536
+ if (const Record::Base *B = R->getBase (Init->getType ())) {
537
+ if (!this ->emitGetPtrBasePop (B->Offset , Init))
538
+ return false ;
539
+
540
+ if (!this ->visitInitializer (Init))
541
+ return false ;
542
+
543
+ if (!this ->emitPopPtr (E))
544
+ return false ;
545
+ // Base initializers don't increase InitIndex, since they don't count
546
+ // into the Record's fields.
547
+ } else {
548
+ const Record::Field *FieldToInit = R->getField (InitIndex);
549
+ // Non-primitive case. Get a pointer to the field-to-initialize
550
+ // on the stack and recurse into visitInitializer().
551
+ if (!this ->emitGetPtrField (FieldToInit->Offset , Init))
552
+ return false ;
553
+
554
+ if (!this ->visitInitializer (Init))
555
+ return false ;
556
+
557
+ if (!this ->emitPopPtr (E))
558
+ return false ;
559
+ ++InitIndex;
560
+ }
561
+ }
562
+ }
563
+ return true ;
564
+ }
565
+
514
566
template <class Emitter >
515
567
bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
516
568
// Handle discarding first.
@@ -530,56 +582,8 @@ bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
530
582
}
531
583
532
584
QualType T = E->getType ();
533
- if (T->isRecordType ()) {
534
- const Record *R = getRecord (T);
535
-
536
- unsigned InitIndex = 0 ;
537
- for (const Expr *Init : E->inits ()) {
538
- if (!this ->emitDupPtr (E))
539
- return false ;
540
-
541
- if (std::optional<PrimType> T = classify (Init)) {
542
- const Record::Field *FieldToInit = R->getField (InitIndex);
543
- if (!this ->visit (Init))
544
- return false ;
545
-
546
- if (!this ->emitInitField (*T, FieldToInit->Offset , E))
547
- return false ;
548
-
549
- if (!this ->emitPopPtr (E))
550
- return false ;
551
- ++InitIndex;
552
- } else {
553
- // Initializer for a direct base class.
554
- if (const Record::Base *B = R->getBase (Init->getType ())) {
555
- if (!this ->emitGetPtrBasePop (B->Offset , Init))
556
- return false ;
557
-
558
- if (!this ->visitInitializer (Init))
559
- return false ;
560
-
561
- if (!this ->emitPopPtr (E))
562
- return false ;
563
- // Base initializers don't increase InitIndex, since they don't count
564
- // into the Record's fields.
565
- } else {
566
- const Record::Field *FieldToInit = R->getField (InitIndex);
567
- // Non-primitive case. Get a pointer to the field-to-initialize
568
- // on the stack and recurse into visitInitializer().
569
- if (!this ->emitGetPtrField (FieldToInit->Offset , Init))
570
- return false ;
571
-
572
- if (!this ->visitInitializer (Init))
573
- return false ;
574
-
575
- if (!this ->emitPopPtr (E))
576
- return false ;
577
- ++InitIndex;
578
- }
579
- }
580
- }
581
- return true ;
582
- }
585
+ if (T->isRecordType ())
586
+ return this ->visitInitList (E->inits (), E);
583
587
584
588
if (T->isArrayType ()) {
585
589
// FIXME: Array fillers.
@@ -612,6 +616,21 @@ bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
612
616
return false ;
613
617
}
614
618
619
+ template <class Emitter >
620
+ bool ByteCodeExprGen<Emitter>::VisitCXXParenListInitExpr(
621
+ const CXXParenListInitExpr *E) {
622
+ if (DiscardResult) {
623
+ for (const Expr *Init : E->getInitExprs ()) {
624
+ if (!this ->discard (Init))
625
+ return false ;
626
+ }
627
+ return true ;
628
+ }
629
+
630
+ assert (E->getType ()->isRecordType ());
631
+ return this ->visitInitList (E->getInitExprs (), E);
632
+ }
633
+
615
634
template <class Emitter >
616
635
bool ByteCodeExprGen<Emitter>::VisitSubstNonTypeTemplateParmExpr(
617
636
const SubstNonTypeTemplateParmExpr *E) {
0 commit comments