Changes in src/AST/Convert.cpp [37cdd97:07d867b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r37cdd97 r07d867b 20 20 21 21 #include "AST/Attribute.hpp" 22 #include "AST/Copy.hpp" 22 23 #include "AST/Decl.hpp" 23 24 #include "AST/Expr.hpp" … … 587 588 assert( tgtResnSlots.empty() ); 588 589 589 if ( srcInferred. mode == ast::Expr::InferUnion::Params ) {590 if ( srcInferred.data.inferParams ) { 590 591 const ast::InferredParams &srcParams = srcInferred.inferParams(); 591 592 for (auto & srcParam : srcParams) { … … 593 594 srcParam.second.decl, 594 595 get<Declaration>().accept1(srcParam.second.declptr), 595 get<Type>().accept1(srcParam.second.actualType) ,596 get<Type>().accept1(srcParam.second.formalType) ,597 get<Expression>().accept1(srcParam.second.expr) 596 get<Type>().accept1(srcParam.second.actualType)->clone(), 597 get<Type>().accept1(srcParam.second.formalType)->clone(), 598 get<Expression>().accept1(srcParam.second.expr)->clone() 598 599 )); 599 600 assert(res.second); 600 601 } 601 } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots ) { 602 } 603 if ( srcInferred.data.resnSlots ) { 602 604 const ast::ResnSlots &srcSlots = srcInferred.resnSlots(); 603 605 for (auto srcSlot : srcSlots) { … … 620 622 621 623 tgt->result = get<Type>().accept1(src->result); 624 // Unconditionally use a clone of the result type. 625 // We know this will leak some objects: much of the immediate conversion result. 626 // In some cases, using the conversion result directly gives unintended object sharing. 627 // A parameter (ObjectDecl, a child of a FunctionType) is shared by the weak-ref cache. 628 // But tgt->result must be fully owned privately by tgt. 629 // Applying these conservative copies here means 630 // - weak references point at the declaration's copy, not these expr.result copies (good) 631 // - we copy more objects than really needed (bad, tolerated) 632 if (tgt->result) { 633 tgt->result = tgt->result->clone(); 634 } 622 635 return visitBaseExpr_skipResultType(src, tgt); 623 636 } … … 979 992 980 993 const ast::Expr * visit( const ast::StmtExpr * node ) override final { 994 auto stmts = node->stmts; 995 // disable sharing between multiple StmtExprs explicitly. 996 if (inCache(stmts)) { 997 stmts = ast::deepCopy(stmts.get()); 998 } 981 999 auto rslt = new StmtExpr( 982 get<CompoundStmt>().accept1( node->stmts)1000 get<CompoundStmt>().accept1(stmts) 983 1001 ); 984 1002 … … 1986 2004 1987 2005 assert( oldInferParams.empty() || oldResnSlots.empty() ); 1988 assert( newInferred.mode == ast::Expr::InferUnion::Empty );2006 // assert( newInferred.mode == ast::Expr::InferUnion::Empty ); 1989 2007 1990 2008 if ( !oldInferParams.empty() ) { … … 2117 2135 old->location, 2118 2136 GET_ACCEPT_1(member, DeclWithType), 2119 GET_ACCEPT_1(aggregate, Expr) 2137 GET_ACCEPT_1(aggregate, Expr), 2138 ast::MemberExpr::NoOpConstructionChosen 2120 2139 ) 2121 2140 );
Note: See TracChangeset
for help on using the changeset viewer.