Changeset 7bd712d


Ignore:
Timestamp:
Jun 15, 2017, 3:33:44 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
4eb31f2
Parents:
637568b (diff), 7b6ca2e (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    r637568b r7bd712d  
    1616#include <stack>
    1717#include <list>
     18
     19#include "InitTweak.h"
    1820#include "GenInit.h"
    19 #include "InitTweak.h"
     21
     22#include "Common/PassVisitor.h"
     23
    2024#include "SynTree/Declaration.h"
    21 #include "SynTree/Type.h"
    2225#include "SynTree/Expression.h"
    23 #include "SynTree/Statement.h"
    2426#include "SynTree/Initializer.h"
    2527#include "SynTree/Mutator.h"
     28#include "SynTree/Statement.h"
     29#include "SynTree/Type.h"
     30
    2631#include "SymTab/Autogen.h"
    2732#include "SymTab/Mangler.h"
     33
     34#include "GenPoly/DeclMutator.h"
    2835#include "GenPoly/PolyMutator.h"
    29 #include "GenPoly/DeclMutator.h"
    3036#include "GenPoly/ScopedSet.h"
     37
    3138#include "ResolvExpr/typeops.h"
    3239
     
    3744        }
    3845
    39         class ReturnFixer final : public GenPoly::PolyMutator {
     46        class ReturnFixer {
    4047          public:
    4148                /// consistently allocates a temporary variable for the return value
     
    4451                static void makeReturnTemp( std::list< Declaration * > &translationUnit );
    4552
    46                 typedef GenPoly::PolyMutator Parent;
    47                 using Parent::mutate;
    48                 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override;
    49                 virtual Statement * mutate( ReturnStmt * returnStmt ) override;
     53                void premutate( FunctionDecl *functionDecl );
     54                void premutate( ReturnStmt * returnStmt );
     55
     56                at_cleanup_t at_cleanup;
     57                std::list< Statement * > stmtsToAddBefore;
    5058
    5159          protected:
     
    129137
    130138        void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) {
    131                 ReturnFixer fixer;
     139                PassVisitor<ReturnFixer> fixer;
    132140                mutateAll( translationUnit, fixer );
    133141        }
    134142
    135         Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
     143        void ReturnFixer::premutate( ReturnStmt *returnStmt ) {
    136144                std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
    137145                assert( returnVals.size() == 0 || returnVals.size() == 1 );
     
    144152                        construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) );
    145153                        construct->get_args().push_back( returnStmt->get_expr() );
    146                         stmtsToAdd.push_back(new ExprStmt(noLabels, construct));
     154                        stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct));
    147155
    148156                        // return the retVal object
    149157                        returnStmt->set_expr( new VariableExpr( returnVals.front() ) );
    150158                } // if
    151                 return returnStmt;
    152         }
    153 
    154         DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
    155                 ValueGuard< FunctionType * > oldFtype( ftype );
    156                 ValueGuard< std::string > oldFuncName( funcName );
     159        }
     160
     161        void ReturnFixer::premutate( FunctionDecl *functionDecl ) {
     162                GuardValue( this, ftype );
     163                GuardValue( this, funcName );
    157164
    158165                ftype = functionDecl->get_functionType();
    159166                funcName = functionDecl->get_name();
    160                 return Parent::mutate( functionDecl );
    161167        }
    162168
Note: See TracChangeset for help on using the changeset viewer.