Changeset 4073b16


Ignore:
Timestamp:
May 22, 2019, 1:35:55 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
37eef7a
Parents:
15934a6
Message:

Cache statement conversions for ImplicitCtorDtorStmt?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r15934a6 r4073b16  
    265265                stmt->location = node->location;
    266266                stmt->labels = makeLabelL( stmt, node->labels );
     267                cache.emplace( node, stmt );
    267268                this->node = stmt;
    268269                return nullptr;
     
    270271
    271272        const ast::CompoundStmt * visit( const ast::CompoundStmt * node ) override final {
     273                if ( inCache( node ) ) return nullptr;
    272274                auto stmt = new CompoundStmt( get<Statement>().acceptL( node->kids ) );
    273275                stmtPostamble( stmt, node );
     
    276278
    277279        const ast::Stmt * visit( const ast::ExprStmt * node ) override final {
     280                if ( inCache( node ) ) return nullptr;
    278281                auto stmt = new ExprStmt( get<Expression>().accept1( node->expr ) );
    279282                return stmtPostamble( stmt, node );
     
    281284
    282285        const ast::Stmt * visit( const ast::AsmStmt * node ) override final {
     286                if ( inCache( node ) ) return nullptr;
    283287                auto stmt = new AsmStmt(
    284288                        node->isVolatile,
     
    293297
    294298        const ast::Stmt * visit( const ast::DirectiveStmt * node ) override final {
     299                if ( inCache( node ) ) return nullptr;
    295300                auto stmt = new DirectiveStmt( node->directive );
    296301                return stmtPostamble( stmt, node );
     
    298303
    299304        const ast::Stmt * visit( const ast::IfStmt * node ) override final {
     305                if ( inCache( node ) ) return nullptr;
    300306                auto stmt = new IfStmt(
    301307                        get<Expression>().accept1( node->cond ),
     
    308314
    309315        const ast::Stmt * visit( const ast::SwitchStmt * node ) override final {
     316                if ( inCache( node ) ) return nullptr;
    310317                auto stmt = new SwitchStmt(
    311318                        get<Expression>().accept1( node->cond ),
     
    316323
    317324        const ast::Stmt * visit( const ast::CaseStmt * node ) override final {
     325                if ( inCache( node ) ) return nullptr;
    318326                auto stmt = new CaseStmt(
    319327                        get<Expression>().accept1( node->cond ),
     
    325333
    326334        const ast::Stmt * visit( const ast::WhileStmt * node ) override final {
     335                if ( inCache( node ) ) return nullptr;
    327336                auto inits = get<Statement>().acceptL( node->inits );
    328337                auto stmt = new WhileStmt(
     
    336345
    337346        const ast::Stmt * visit( const ast::ForStmt * node ) override final {
     347                if ( inCache( node ) ) return nullptr;
    338348                auto stmt = new ForStmt(
    339349                        get<Statement>().acceptL( node->inits ),
     
    346356
    347357        const ast::Stmt * visit( const ast::BranchStmt * node ) override final {
     358                if ( inCache( node ) ) return nullptr;
    348359                BranchStmt * stmt;
    349360                if (node->computedTarget) {
     
    375386
    376387        const ast::Stmt * visit( const ast::ReturnStmt * node ) override final {
     388                if ( inCache( node ) ) return nullptr;
    377389                auto stmt = new ReturnStmt( get<Expression>().accept1( node->expr ) );
    378390                return stmtPostamble( stmt, node );
     
    380392
    381393        const ast::Stmt * visit( const ast::ThrowStmt * node ) override final {
     394                if ( inCache( node ) ) return nullptr;
    382395                ThrowStmt::Kind kind;
    383396                switch (node->kind) {
     
    400413
    401414        const ast::Stmt * visit( const ast::TryStmt * node ) override final {
     415                if ( inCache( node ) ) return nullptr;
    402416                auto handlers = get<CatchStmt>().acceptL( node->handlers );
    403417                auto stmt = new TryStmt(
     
    410424
    411425        const ast::Stmt * visit( const ast::CatchStmt * node ) override final {
     426                if ( inCache( node ) ) return nullptr;
    412427                CatchStmt::Kind kind;
    413428                switch (node->kind) {
     
    431446
    432447        const ast::Stmt * visit( const ast::FinallyStmt * node ) override final {
     448                if ( inCache( node ) ) return nullptr;
    433449                auto stmt = new FinallyStmt( get<CompoundStmt>().accept1( node->body ) );
    434450                return stmtPostamble( stmt, node );
     
    436452
    437453        const ast::Stmt * visit( const ast::WaitForStmt * node ) override final {
     454                if ( inCache( node ) ) return nullptr;
    438455                auto stmt = new WaitForStmt;
    439456                stmt->clauses.reserve( node->clauses.size() );
     
    460477
    461478        const ast::Stmt * visit( const ast::WithStmt * node ) override final {
     479                if ( inCache( node ) ) return nullptr;
    462480                auto stmt = new WithStmt(
    463481                        get<Expression>().acceptL( node->exprs ),
     
    468486
    469487        const ast::NullStmt * visit( const ast::NullStmt * node ) override final {
     488                if ( inCache( node ) ) return nullptr;
    470489                auto stmt = new NullStmt();
    471490                stmtPostamble( stmt, node );
     
    474493
    475494        const ast::Stmt * visit( const ast::DeclStmt * node ) override final {
     495                if ( inCache( node ) ) return nullptr;
    476496                auto stmt = new DeclStmt( get<Declaration>().accept1( node->decl ) );
    477497                return stmtPostamble( stmt, node );
     
    479499
    480500        const ast::Stmt * visit( const ast::ImplicitCtorDtorStmt * node ) override final {
    481                 (void)node;
    482                 return nullptr;
     501                if ( inCache( node ) ) return nullptr;
     502                auto stmt = new ImplicitCtorDtorStmt{
     503                        get<Statement>().accept1( node->callStmt )
     504                };
     505                return stmtPostamble( stmt, node );
    483506        }
    484507
     
    15641587
    15651588        virtual void visit( CompoundStmt * old ) override final {
     1589                if ( inCache( old ) ) return;
    15661590                auto stmt = new ast::CompoundStmt(
    15671591                        old->location,
     
    15711595
    15721596                this->node = stmt;
     1597                cache.emplace( old, this->node );
    15731598        }
    15741599
    15751600        virtual void visit( ExprStmt * old ) override final {
     1601                if ( inCache( old ) ) return;
    15761602                this->node = new ast::ExprStmt(
    15771603                        old->location,
     
    15791605                        GET_LABELS_V(old->labels)
    15801606                );
     1607                cache.emplace( old, this->node );
    15811608        }
    15821609
    15831610        virtual void visit( AsmStmt * old ) override final {
     1611                if ( inCache( old ) ) return;
    15841612                this->node = new ast::AsmStmt(
    15851613                        old->location,
     
    15921620                        GET_LABELS_V(old->labels)
    15931621                );
     1622                cache.emplace( old, this->node );
    15941623        }
    15951624
    15961625        virtual void visit( DirectiveStmt * old ) override final {
     1626                if ( inCache( old ) ) return;
    15971627                this->node = new ast::DirectiveStmt(
    15981628                        old->location,
     
    16001630                        GET_LABELS_V(old->labels)
    16011631                );
     1632                cache.emplace( old, this->node );
    16021633        }
    16031634
    16041635        virtual void visit( IfStmt * old ) override final {
     1636                if ( inCache( old ) ) return;
    16051637                this->node = new ast::IfStmt(
    16061638                        old->location,
     
    16111643                        GET_LABELS_V(old->labels)
    16121644                );
     1645                cache.emplace( old, this->node );
    16131646        }
    16141647
    16151648        virtual void visit( SwitchStmt * old ) override final {
     1649                if ( inCache( old ) ) return;
    16161650                this->node = new ast::SwitchStmt(
    16171651                        old->location,
     
    16201654                        GET_LABELS_V(old->labels)
    16211655                );
     1656                cache.emplace( old, this->node );
    16221657        }
    16231658
    16241659        virtual void visit( CaseStmt * old ) override final {
     1660                if ( inCache( old ) ) return;
    16251661                this->node = new ast::CaseStmt(
    16261662                        old->location,
     
    16291665                        GET_LABELS_V(old->labels)
    16301666                );
     1667                cache.emplace( old, this->node );
    16311668        }
    16321669
    16331670        virtual void visit( WhileStmt * old ) override final {
     1671                if ( inCache( old ) ) return;
    16341672                this->node = new ast::WhileStmt(
    16351673                        old->location,
     
    16401678                        GET_LABELS_V(old->labels)
    16411679                );
     1680                cache.emplace( old, this->node );
    16421681        }
    16431682
    16441683        virtual void visit( ForStmt * old ) override final {
     1684                if ( inCache( old ) ) return;
    16451685                this->node = new ast::ForStmt(
    16461686                        old->location,
     
    16511691                        GET_LABELS_V(old->labels)
    16521692                );
     1693                cache.emplace( old, this->node );
    16531694        }
    16541695
    16551696        virtual void visit( BranchStmt * old ) override final {
     1697                if ( inCache( old ) ) return;
    16561698                if (old->computedTarget) {
    16571699                        this->node = new ast::BranchStmt(
     
    16871729                        this->node = stmt;
    16881730                }
     1731                cache.emplace( old, this->node );
    16891732        }
    16901733
    16911734        virtual void visit( ReturnStmt * old ) override final {
     1735                if ( inCache( old ) ) return;
    16921736                this->node = new ast::ReturnStmt(
    16931737                        old->location,
     
    16951739                        GET_LABELS_V(old->labels)
    16961740                );
     1741                cache.emplace( old, this->node );
    16971742        }
    16981743
    16991744        virtual void visit( ThrowStmt * old ) override final {
     1745                if ( inCache( old ) ) return;
    17001746                ast::ThrowStmt::Kind kind;
    17011747                switch (old->kind) {
     
    17171763                        GET_LABELS_V(old->labels)
    17181764                );
     1765                cache.emplace( old, this->node );
    17191766        }
    17201767
    17211768        virtual void visit( TryStmt * old ) override final {
     1769                if ( inCache( old ) ) return;
    17221770                this->node = new ast::TryStmt(
    17231771                        old->location,
     
    17271775                        GET_LABELS_V(old->labels)
    17281776                );
     1777                cache.emplace( old, this->node );
    17291778        }
    17301779
    17311780        virtual void visit( CatchStmt * old ) override final {
     1781                if ( inCache( old ) ) return;
    17321782                ast::CatchStmt::Kind kind;
    17331783                switch (old->kind) {
     
    17501800                        GET_LABELS_V(old->labels)
    17511801                );
     1802                cache.emplace( old, this->node );
    17521803        }
    17531804
    17541805        virtual void visit( FinallyStmt * old ) override final {
     1806                if ( inCache( old ) ) return;
    17551807                this->node = new ast::FinallyStmt(
    17561808                        old->location,
     
    17581810                        GET_LABELS_V(old->labels)
    17591811                );
     1812                cache.emplace( old, this->node );
    17601813        }
    17611814
    17621815        virtual void visit( WaitForStmt * old ) override final {
     1816                if ( inCache( old ) ) return;
    17631817                ast::WaitForStmt * stmt = new ast::WaitForStmt(
    17641818                        old->location,
     
    17881842
    17891843                this->node = stmt;
     1844                cache.emplace( old, this->node );
    17901845        }
    17911846
    17921847        virtual void visit( WithStmt * old ) override final {
     1848                if ( inCache( old ) ) return;
    17931849                this->node = new ast::WithStmt(
    17941850                        old->location,
     
    17971853                        GET_LABELS_V(old->labels)
    17981854                );
     1855                cache.emplace( old, this->node );
    17991856        }
    18001857
    18011858        virtual void visit( NullStmt * old ) override final {
     1859                if ( inCache( old ) ) return;
    18021860                this->node = new ast::NullStmt(
    18031861                        old->location,
    18041862                        GET_LABELS_V(old->labels)
    18051863                );
     1864                cache.emplace( old, this->node );
    18061865        }
    18071866
    18081867        virtual void visit( DeclStmt * old ) override final {
     1868                if ( inCache( old ) ) return;
    18091869                this->node = new ast::DeclStmt(
    18101870                        old->location,
     
    18121872                        GET_LABELS_V(old->labels)
    18131873                );
     1874                cache.emplace( old, this->node );
    18141875        }
    18151876
    18161877        virtual void visit( ImplicitCtorDtorStmt * old ) override final {
     1878                if ( inCache( old ) ) return;
    18171879                this->node = new ast::ImplicitCtorDtorStmt(
    18181880                        old->location,
     
    18201882                        GET_LABELS_V(old->labels)
    18211883                );
     1884                cache.emplace( old, this->node );
    18221885        }
    18231886
Note: See TracChangeset for help on using the changeset viewer.