Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    raff3af4 r134322e  
    192192                };
    193193
    194                 class FixInit {
     194                class FixInit final : public GenPoly::PolyMutator {
    195195                  public:
    196196                        /// expand each object declaration to use its constructor after it is declared.
    197197                        static void fixInitializers( std::list< Declaration * > &translationUnit );
    198198
    199                         DeclarationWithType * postmutate( ObjectDecl *objDecl );
     199                        typedef GenPoly::PolyMutator Parent;
     200                        using Parent::mutate;
     201                        virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override;
    200202
    201203                        std::list< Declaration * > staticDtorDecls;
    202                         std::list< Statement * > stmtsToAddAfter; // found by PassVisitor
    203204                };
    204205
     
    311312
    312313                void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) {
    313                         PassVisitor<FixInit> fixer;
     314                        FixInit fixer;
    314315
    315316                        // can't use mutateAll, because need to insert declarations at top-level
     
    319320                                try {
    320321                                        *i = maybeMutate( *i, fixer );
    321                                         translationUnit.splice( i, fixer.pass.staticDtorDecls );
     322                                        translationUnit.splice( i, fixer.staticDtorDecls );
    322323                                } catch( SemanticError &e ) {
    323324                                        e.set_location( (*i)->location );
     
    695696                }
    696697
    697                 DeclarationWithType *FixInit::postmutate( ObjectDecl *objDecl ) {
    698                         // since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate)
     698                DeclarationWithType *FixInit::mutate( ObjectDecl *objDecl ) {
     699                        // first recursively handle pieces of ObjectDecl so that they aren't missed by other visitors when the init
     700                        // is removed from the ObjectDecl
     701                        objDecl = dynamic_cast< ObjectDecl * >( Parent::mutate( objDecl ) );
    699702                        if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
    700703                                // a decision should have been made by the resolver, so ctor and init are not both non-NULL
Note: See TracChangeset for help on using the changeset viewer.