Changeset 85521c7 for src/SynTree/Expression.cc
- Timestamp:
- Feb 1, 2018, 5:40:01 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0188a0b
- Parents:
- d0a045c7 (diff), 33c0ce8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
rd0a045c7 r85521c7 597 597 598 598 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) { 599 assert( statements ); 600 std::list< Statement * > & body = statements->get_kids(); 601 if ( ! body.empty() ) { 602 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 603 result = maybeClone( exprStmt->expr->result ); 604 } 605 } 606 // ensure that StmtExpr has a result type 607 if ( ! result ) { 608 result = new VoidType( Type::Qualifiers() ); 609 } 599 computeResult(); 610 600 } 611 601 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) { … … 617 607 deleteAll( dtors ); 618 608 deleteAll( returnDecls ); 609 } 610 void StmtExpr::computeResult() { 611 assert( statements ); 612 std::list< Statement * > & body = statements->kids; 613 delete result; 614 result = nullptr; 615 if ( ! returnDecls.empty() ) { 616 // prioritize return decl for result type, since if a return decl exists, then 617 // the StmtExpr is currently in an intermediate state where the body will always 618 // give a void result type. 619 result = returnDecls.front()->get_type()->clone(); 620 } else if ( ! body.empty() ) { 621 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 622 result = maybeClone( exprStmt->expr->result ); 623 } 624 } 625 // ensure that StmtExpr has a result type 626 if ( ! result ) { 627 result = new VoidType( Type::Qualifiers() ); 628 } 619 629 } 620 630 void StmtExpr::print( std::ostream &os, Indenter indent ) const {
Note: See TracChangeset
for help on using the changeset viewer.