Changeset bd7e609 for src


Ignore:
Timestamp:
Oct 19, 2017, 11:13:11 AM (6 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:
189d800
Parents:
6137fbb
git-author:
Rob Schluntz <rschlunt@…> (10/11/17 16:04:22)
git-committer:
Rob Schluntz <rschlunt@…> (10/19/17 11:13:11)
Message:

Make ReturnFixer? idempotent and rearrange passes in Validate in anticipation of autogen changes

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    r6137fbb rbd7e609  
    129129                // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address
    130130                // is being returned
    131                 if ( returnStmt->get_expr() && returnVals.size() == 1 && isConstructable( returnVals.front()->get_type() ) ) {
     131                if ( returnStmt->expr && returnVals.size() == 1 && isConstructable( returnVals.front()->get_type() ) ) {
    132132                        // explicitly construct the return value using the return expression and the retVal object
    133133                        assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() );
    134134
    135                         stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) );
     135                        ObjectDecl * retVal = strict_dynamic_cast< ObjectDecl * >( returnVals.front() );
     136                        if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( returnStmt->expr ) ) {
     137                                // return statement has already been mutated - don't need to do it again
     138                                if ( varExpr->var == retVal ) return;
     139                        }
     140                        stmtsToAddBefore.push_back( genCtorDtor( "?{}", retVal, returnStmt->get_expr() ) );
    136141
    137142                        // return the retVal object
  • src/SymTab/Validate.cc

    r6137fbb rbd7e609  
    153153                void previsit( ObjectDecl * object );
    154154                void previsit( FunctionDecl * func );
     155                void previsit( StructDecl * aggrDecl );
     156                void previsit( UnionDecl * aggrDecl );
    155157        };
    156158
     
    270272                acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist
    271273                VerifyCtorDtorAssign::verify( translationUnit );  // must happen before autogen, because autogen examines existing ctor/dtors
     274                ReturnChecker::checkFunctionReturns( translationUnit );
     275                InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen
    272276                Concurrency::applyKeywords( translationUnit );
     277                acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution
    273278                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay
    274279                Concurrency::implementMutexFuncs( translationUnit );
    275280                Concurrency::implementThreadStarter( translationUnit );
    276                 ReturnChecker::checkFunctionReturns( translationUnit );
    277281                mutateAll( translationUnit, compoundliteral );
    278                 acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines
    279282                ArrayLength::computeLength( translationUnit );
    280                 acceptAll( translationUnit, finder );
     283                acceptAll( translationUnit, finder ); // xxx - remove this pass soon
    281284                mutateAll( translationUnit, labelAddrFixer );
    282285        }
     
    620623        }
    621624
     625        void ForallPointerDecay::previsit( StructDecl * aggrDecl ) {
     626                forallFixer( aggrDecl->parameters, aggrDecl );
     627        }
     628
     629        void ForallPointerDecay::previsit( UnionDecl * aggrDecl ) {
     630                forallFixer( aggrDecl->parameters, aggrDecl );
     631        }
     632
    622633        void ReturnChecker::checkFunctionReturns( std::list< Declaration * > & translationUnit ) {
    623634                PassVisitor<ReturnChecker> checker;
Note: See TracChangeset for help on using the changeset viewer.