Changeset 5363fdf for src


Ignore:
Timestamp:
Sep 27, 2017, 4:25:28 PM (7 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:
fa16264
Parents:
1189946
git-author:
Rob Schluntz <rschlunt@…> (09/27/17 16:11:50)
git-committer:
Rob Schluntz <rschlunt@…> (09/27/17 16:25:28)
Message:

Cleanup FixInit? code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r1189946 r5363fdf  
    214214                        void emit( CodeLocation, const Params &... params );
    215215
    216                         FunctionDecl * function = 0;
     216                        FunctionDecl * function = nullptr;
    217217                        std::set< DeclarationWithType * > unhandled;
    218218                        std::map< DeclarationWithType *, CodeLocation > usedUninit;
    219                         ObjectDecl * thisParam = 0;
     219                        ObjectDecl * thisParam = nullptr;
    220220                        bool isCtor = false; // true if current function is a constructor
    221                         StructDecl * structDecl = 0;
     221                        StructDecl * structDecl = nullptr;
    222222                };
    223223
     
    624624                }
    625625
    626                 DeclarationWithType *FixInit::postmutate( ObjectDecl *objDecl ) {
     626                DeclarationWithType * FixInit::postmutate( ObjectDecl *objDecl ) {
    627627                        // since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate)
    628628                        if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
     
    722722                                        } else {
    723723                                                ImplicitCtorDtorStmt * implicit = strict_dynamic_cast< ImplicitCtorDtorStmt * > ( ctor );
    724                                                 ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->get_callStmt() );
     724                                                ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->callStmt );
    725725                                                ApplicationExpr * ctorCall = nullptr;
    726                                                 if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->get_expr() )) && ctorCall->get_args().size() == 2 ) {
     726                                                if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->expr )) && ctorCall->get_args().size() == 2 ) {
    727727                                                        // clean up intrinsic copy constructor calls by making them into SingleInits
    728                                                         objDecl->set_init( new SingleInit( ctorCall->get_args().back() ) );
    729                                                         ctorCall->get_args().pop_back();
     728                                                        objDecl->init = new SingleInit( ctorCall->args.back() );
     729                                                        ctorCall->args.pop_back();
    730730                                                } else {
    731731                                                        stmtsToAddAfter.push_back( ctor );
    732                                                         objDecl->set_init( nullptr );
    733                                                         ctorInit->set_ctor( nullptr );
     732                                                        objDecl->init = nullptr;
     733                                                        ctorInit->ctor = nullptr;
    734734                                                }
    735735                                        } // if
    736                                 } else if ( Initializer * init = ctorInit->get_init() ) {
    737                                         objDecl->set_init( init );
    738                                         ctorInit->set_init( nullptr );
     736                                } else if ( Initializer * init = ctorInit->init ) {
     737                                        objDecl->init = init;
     738                                        ctorInit->init = nullptr;
    739739                                } else {
    740740                                        // no constructor and no initializer, which is okay
    741                                         objDecl->set_init( nullptr );
     741                                        objDecl->init = nullptr;
    742742                                } // if
    743743                                delete ctorInit;
     
    912912                }
    913913
     914                void addIds( SymTab::Indexer & indexer, const std::list< DeclarationWithType * > & decls ) {
     915                        for ( auto d : decls ) {
     916                                indexer.addId( d );
     917                        }
     918                }
     919
     920                void addTypes( SymTab::Indexer & indexer, const std::list< TypeDecl * > & tds ) {
     921                        for ( auto td : tds ) {
     922                                indexer.addType( td );
     923                                addIds( indexer, td->assertions );
     924                        }
     925                }
     926
    914927                void GenStructMemberCalls::previsit( FunctionDecl * funcDecl ) {
    915                         GuardValue( funcDecl );
     928                        GuardValue( function );
    916929                        GuardValue( unhandled );
    917930                        GuardValue( usedUninit );
     
    946959                }
    947960
    948                 void addIds( SymTab::Indexer & indexer, const std::list< DeclarationWithType * > & decls ) {
    949                         for ( auto d : decls ) {
    950                                 indexer.addId( d );
    951                         }
    952                 }
    953 
    954                 void addTypes( SymTab::Indexer & indexer, const std::list< TypeDecl * > & tds ) {
    955                         for ( auto td : tds ) {
    956                                 indexer.addType( td );
    957                                 addIds( indexer, td->assertions );
    958                         }
    959                 }
    960 
    961961                void GenStructMemberCalls::postvisit( FunctionDecl * funcDecl ) {
    962962                        // remove the unhandled objects from usedUninit, because a call is inserted
Note: See TracChangeset for help on using the changeset viewer.