Changes in src/AST/Convert.cpp [ef9988b:37cdd97]
- File:
-
- 1 edited
-
src/AST/Convert.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
ref9988b r37cdd97 20 20 21 21 #include "AST/Attribute.hpp" 22 #include "AST/Copy.hpp"23 22 #include "AST/Decl.hpp" 24 23 #include "AST/Expr.hpp" … … 167 166 LinkageSpec::Spec( node->linkage.val ), 168 167 bfwd, 169 type ->clone(),168 type, 170 169 init, 171 170 attr, … … 588 587 assert( tgtResnSlots.empty() ); 589 588 590 if ( srcInferred. data.inferParams ) {589 if ( srcInferred.mode == ast::Expr::InferUnion::Params ) { 591 590 const ast::InferredParams &srcParams = srcInferred.inferParams(); 592 591 for (auto & srcParam : srcParams) { … … 594 593 srcParam.second.decl, 595 594 get<Declaration>().accept1(srcParam.second.declptr), 596 get<Type>().accept1(srcParam.second.actualType) ->clone(),597 get<Type>().accept1(srcParam.second.formalType) ->clone(),598 get<Expression>().accept1(srcParam.second.expr) ->clone()595 get<Type>().accept1(srcParam.second.actualType), 596 get<Type>().accept1(srcParam.second.formalType), 597 get<Expression>().accept1(srcParam.second.expr) 599 598 )); 600 599 assert(res.second); 601 600 } 602 } 603 if ( srcInferred.data.resnSlots ) { 601 } else if ( srcInferred.mode == ast::Expr::InferUnion::Slots ) { 604 602 const ast::ResnSlots &srcSlots = srcInferred.resnSlots(); 605 603 for (auto srcSlot : srcSlots) { … … 622 620 623 621 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 means630 // - 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 }635 622 return visitBaseExpr_skipResultType(src, tgt); 636 623 } … … 992 979 993 980 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 }999 981 auto rslt = new StmtExpr( 1000 get<CompoundStmt>().accept1( stmts)982 get<CompoundStmt>().accept1(node->stmts) 1001 983 ); 1002 984 … … 2004 1986 2005 1987 assert( oldInferParams.empty() || oldResnSlots.empty() ); 2006 //assert( newInferred.mode == ast::Expr::InferUnion::Empty );1988 assert( newInferred.mode == ast::Expr::InferUnion::Empty ); 2007 1989 2008 1990 if ( !oldInferParams.empty() ) { … … 2135 2117 old->location, 2136 2118 GET_ACCEPT_1(member, DeclWithType), 2137 GET_ACCEPT_1(aggregate, Expr), 2138 ast::MemberExpr::NoOpConstructionChosen 2119 GET_ACCEPT_1(aggregate, Expr) 2139 2120 ) 2140 2121 );
Note:
See TracChangeset
for help on using the changeset viewer.