Changeset 45a4ea7


Ignore:
Timestamp:
May 5, 2017, 11:05:45 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
4f9636f
Parents:
262f085f
Message:

fix out-of-order traversal in PolyMutator?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/PolyMutator.cc

    r262f085f r45a4ea7  
    5050
    5151        Statement * PolyMutator::mutateStatement( Statement *stmt ) {
     52                // don't want statements from outer CompoundStmts to be added to this CompoundStmt
     53                ValueGuard< std::list< Statement* > > oldStmtsToAdd( stmtsToAdd );
     54                ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter );
     55                ValueGuard< TypeSubstitution * > oldEnv( env );
     56                stmtsToAdd.clear();
     57                stmtsToAddAfter.clear();
     58
    5259                Statement *newStmt = maybeMutate( stmt, *this );
    5360                if ( ! stmtsToAdd.empty() || ! stmtsToAddAfter.empty() ) {
     
    8390
    8491        Statement * PolyMutator::mutate(IfStmt *ifStmt) {
     92                ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
    8593                ifStmt->set_thenPart(  mutateStatement( ifStmt->get_thenPart() ) );
    8694                ifStmt->set_elsePart(  mutateStatement( ifStmt->get_elsePart() ) );
    87                 ifStmt->set_condition(  mutateExpression( ifStmt->get_condition() ) );
    8895                return ifStmt;
    8996        }
    9097
    9198        Statement * PolyMutator::mutate(WhileStmt *whileStmt) {
     99                whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
    92100                whileStmt->set_body(  mutateStatement( whileStmt->get_body() ) );
    93                 whileStmt->set_condition(  mutateExpression( whileStmt->get_condition() ) );
    94101                return whileStmt;
    95102        }
    96103
    97104        Statement * PolyMutator::mutate(ForStmt *forStmt) {
    98                 forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
    99105                mutateAll( forStmt->get_initialization(), *this );
    100106                forStmt->set_condition(  mutateExpression( forStmt->get_condition() ) );
    101107                forStmt->set_increment(  mutateExpression( forStmt->get_increment() ) );
     108                forStmt->set_body(  mutateStatement( forStmt->get_body() ) );
    102109                return forStmt;
    103110        }
    104111
    105112        Statement * PolyMutator::mutate(SwitchStmt *switchStmt) {
     113                switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
    106114                mutateStatementList( switchStmt->get_statements() );
    107                 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) );
    108115                return switchStmt;
    109116        }
    110117
    111118        Statement * PolyMutator::mutate(CaseStmt *caseStmt) {
     119                caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
    112120                mutateStatementList( caseStmt->get_statements() );
    113                 caseStmt->set_condition(  mutateExpression( caseStmt->get_condition() ) );
    114121                return caseStmt;
    115122        }
Note: See TracChangeset for help on using the changeset viewer.