@@ -2931,9 +2931,12 @@ class LLVM_LIBRARY_VISIBILITY SILGenBorrowedBaseVisitor
29312931public:
29322932 SILGenLValue &SGL;
29332933 SILGenFunction &SGF;
2934+ AbstractionPattern Orig;
29342935
2935- SILGenBorrowedBaseVisitor (SILGenLValue &SGL, SILGenFunction &SGF)
2936- : SGL(SGL), SGF(SGF) {}
2936+ SILGenBorrowedBaseVisitor (SILGenLValue &SGL,
2937+ SILGenFunction &SGF,
2938+ AbstractionPattern Orig)
2939+ : SGL(SGL), SGF(SGF), Orig(Orig) {}
29372940
29382941 static bool isNonCopyableBaseBorrow (SILGenFunction &SGF, Expr *e) {
29392942 if (auto *m = dyn_cast<MemberRefExpr>(e)) {
@@ -2982,9 +2985,14 @@ class LLVM_LIBRARY_VISIBILITY SILGenBorrowedBaseVisitor
29822985 return false ;
29832986 }
29842987
2988+ // / For any other Expr's that this SILGenBorrowedBaseVisitor doesn't already
2989+ // / define a visitor stub, defer back to SILGenLValue's visitRec as it is
2990+ // / most-likely a non-lvalue root expression.
29852991 LValue visitExpr (Expr *e, SGFAccessKind accessKind, LValueOptions options) {
2986- e->dump (llvm::errs ());
2987- llvm::report_fatal_error (" Unimplemented node!" );
2992+ assert (!isNonCopyableBaseBorrow (SGF, e)
2993+ && " unexpected recursion in SILGenLValue::visitRec!" );
2994+
2995+ return SGL.visitRec (e, accessKind, options, Orig);
29882996 }
29892997
29902998 LValue visitMemberRefExpr (MemberRefExpr *e, SGFAccessKind accessKind,
@@ -3074,10 +3082,10 @@ LValue SILGenLValue::visitRec(Expr *e, SGFAccessKind accessKind,
30743082 // apply the lvalue within a formal access to the original value instead of
30753083 // an actual loaded copy.
30763084 if (SILGenBorrowedBaseVisitor::isNonCopyableBaseBorrow (SGF, e)) {
3077- SILGenBorrowedBaseVisitor visitor (*this , SGF);
3085+ SILGenBorrowedBaseVisitor visitor (*this , SGF, orig );
30783086 auto accessKind = SGFAccessKind::BorrowedObjectRead;
3079- if ( e->getType ()->is <LValueType>() )
3080- accessKind = SGFAccessKind::BorrowedAddressRead;
3087+ assert (! e->getType ()->is <LValueType>()
3088+ && " maybe need SGFAccessKind::BorrowedAddressRead ? " ) ;
30813089 return visitor.visit (e, accessKind, options);
30823090 }
30833091
0 commit comments