@@ -2709,6 +2709,7 @@ bool Compiler<Emitter>::VisitMemberExpr(const MemberExpr *E) {
27092709
27102710template <class Emitter >
27112711bool Compiler<Emitter>::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E) {
2712+ assert (!DiscardResult);
27122713 // ArrayIndex might not be set if a ArrayInitIndexExpr is being evaluated
27132714 // stand-alone, e.g. via EvaluateAsInt().
27142715 if (!ArrayIndex)
@@ -2753,12 +2754,17 @@ bool Compiler<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
27532754 if (!SourceExpr)
27542755 return false ;
27552756
2756- if (Initializing)
2757+ if (Initializing) {
2758+ assert (!DiscardResult);
27572759 return this ->visitInitializer (SourceExpr);
2760+ }
27582761
27592762 PrimType SubExprT = classify (SourceExpr).value_or (PT_Ptr);
2760- if (auto It = OpaqueExprs.find (E); It != OpaqueExprs.end ())
2763+ if (auto It = OpaqueExprs.find (E); It != OpaqueExprs.end ()) {
2764+ if (DiscardResult)
2765+ return true ;
27612766 return this ->emitGetLocal (SubExprT, It->second , E);
2767+ }
27622768
27632769 if (!this ->visit (SourceExpr))
27642770 return false ;
@@ -2770,16 +2776,13 @@ bool Compiler<Emitter>::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
27702776 if (!this ->emitSetLocal (SubExprT, LocalIndex, E))
27712777 return false ;
27722778
2773- // Here the local variable is created but the value is removed from the stack,
2774- // so we put it back if the caller needs it.
2775- if (!DiscardResult) {
2776- if (!this ->emitGetLocal (SubExprT, LocalIndex, E))
2777- return false ;
2778- }
2779-
27802779 // This is cleaned up when the local variable is destroyed.
27812780 OpaqueExprs.insert ({E, LocalIndex});
27822781
2782+ // Here the local variable is created but the value is removed from the stack,
2783+ // so we put it back if the caller needs it.
2784+ if (!DiscardResult)
2785+ return this ->emitGetLocal (SubExprT, LocalIndex, E);
27832786 return true ;
27842787}
27852788
0 commit comments