Changeset a554e5f4 for src/AST


Ignore:
Timestamp:
Feb 9, 2022, 3:33:42 PM (4 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
850aff1
Parents:
21a99cc (diff), c4f81702 (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

Location:
src/AST
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.hpp

    r21a99cc ra554e5f4  
    238238
    239239private:
    240         const ast::Stmt * call_accept( const ast::Stmt * );
    241         const ast::Expr * call_accept( const ast::Expr * );
    242 
    243         // requests WithStmtsToAdd directly add to this statement, as if it is a compound.
    244 
    245         const ast::Stmt * call_accept_as_compound(const ast::Stmt *);
    246 
     240
     241        // Regular nodes
    247242        template< typename node_t >
    248         auto call_accept( const node_t * node ) -> typename std::enable_if<
     243        struct result1 {
     244                bool differs;
     245                const node_t * value;
     246
     247                template< typename object_t, typename super_t, typename field_t >
     248                void apply(object_t *, field_t super_t::* field);
     249        };
     250
     251        result1<ast::Stmt> call_accept( const ast::Stmt * );
     252        result1<ast::Expr> call_accept( const ast::Expr * );
     253
     254        template< typename node_t >
     255        auto call_accept( const node_t * node )
     256                -> typename std::enable_if<
    249257                                !std::is_base_of<ast::Expr, node_t>::value &&
    250258                                !std::is_base_of<ast::Stmt, node_t>::value
    251                         , decltype( node->accept(*this) )
     259                        , result1<
     260                                typename std::remove_pointer< decltype( node->accept(*this) ) >::type
     261                        >
    252262                >::type;
    253263
     264        // requests WithStmtsToAdd directly add to this statement, as if it is a compound.
     265        result1<ast::Stmt> call_accept_as_compound(const ast::Stmt *);
     266
     267        // Container of statements
    254268        template< template <class...> class container_t >
    255         container_t< ptr<Stmt> > call_accept( const container_t< ptr<Stmt> > & );
    256 
     269        struct resultNstmt {
     270                struct delta {
     271                        ptr<Stmt> nval;
     272                        ssize_t old_idx;
     273                        bool is_old;
     274
     275                        delta(const Stmt * s, ssize_t i, bool old) : nval{s}, old_idx{i}, is_old{old} {}
     276                };
     277
     278                bool differs;
     279                container_t< delta > values;
     280
     281                resultNstmt() : differs(false), values{} {}
     282                resultNstmt(bool diff, container_t< delta > && vals) : differs(diff), values(vals) {}
     283
     284                template< typename object_t, typename super_t, typename field_t >
     285                void apply(object_t *, field_t super_t::* field);
     286
     287                template< template <class...> class incontainer_t >
     288                void take_all( incontainer_t<ast::ptr<ast::Stmt>> * stmts ) {
     289                        if(!stmts || stmts->empty()) return;
     290
     291                        std::transform(stmts->begin(), stmts->end(), std::back_inserter( values ), [](ast::ptr<ast::Stmt>& decl) -> delta {
     292                                        return delta( decl.release(), -1, false );
     293                                });
     294                        stmts->clear();
     295                        differs = true;
     296                }
     297
     298                template< template <class...> class incontainer_t >
     299                void take_all( incontainer_t<ast::ptr<ast::Decl>> * decls ) {
     300                        if(!decls || decls->empty()) return;
     301
     302                        std::transform(decls->begin(), decls->end(), std::back_inserter( values ), [](ast::ptr<ast::Decl>& decl) -> auto {
     303                                        auto loc = decl->location;
     304                                        auto stmt = new DeclStmt( loc, decl.release() );
     305                                        return delta( stmt, -1, false );
     306                                });
     307                        decls->clear();
     308                        differs = true;
     309                }
     310        };
     311
     312        template< template <class...> class container_t >
     313        resultNstmt<container_t> call_accept( const container_t< ptr<Stmt> > & );
     314
     315        // Container of something
    257316        template< template <class...> class container_t, typename node_t >
    258         container_t< ptr<node_t> > call_accept( const container_t< ptr<node_t> > & container );
     317        struct resultN {
     318                bool differs;
     319                container_t<ptr<node_t>> values;
     320
     321                template< typename object_t, typename super_t, typename field_t >
     322                void apply(object_t *, field_t super_t::* field);
     323        };
     324
     325        template< template <class...> class container_t, typename node_t >
     326        resultN< container_t, node_t > call_accept( const container_t< ptr<node_t> > & container );
    259327
    260328public:
    261329        /// Logic to call the accept and mutate the parent if needed, delegates call to accept
    262         template<typename node_t, typename parent_t, typename child_t>
    263         void maybe_accept(const node_t * &, child_t parent_t::* child);
    264 
    265         template<typename node_t, typename parent_t, typename child_t>
    266         void maybe_accept_as_compound(const node_t * &, child_t parent_t::* child);
     330        template<typename node_t, typename parent_t, typename field_t>
     331        void maybe_accept(const node_t * &, field_t parent_t::* field);
     332
     333        template<typename node_t, typename parent_t, typename field_t>
     334        void maybe_accept_as_compound(const node_t * &, field_t parent_t::* field);
    267335
    268336private:
  • src/AST/Pass.impl.hpp

    r21a99cc ra554e5f4  
    7979
    8080                template<typename it_t, template <class...> class container_t>
    81                 static inline void take_all( it_t it, container_t<ast::ptr<ast::Stmt>> * decls, bool * mutated = nullptr ) {
    82                         if(empty(decls)) return;
    83 
    84                         std::move(decls->begin(), decls->end(), it);
    85                         decls->clear();
     81                static inline void take_all( it_t it, container_t<ast::ptr<ast::Stmt>> * stmts, bool * mutated = nullptr ) {
     82                        if(empty(stmts)) return;
     83
     84                        std::move(stmts->begin(), stmts->end(), it);
     85                        stmts->clear();
    8686                        if(mutated) *mutated = true;
    8787                }
     
    123123                        return !new_val.empty();
    124124                }
     125        }
     126
     127
     128        template< typename core_t >
     129        template< typename node_t >
     130        template< typename object_t, typename super_t, typename field_t >
     131        void ast::Pass< core_t >::result1< node_t >::apply(object_t * object, field_t super_t::* field) {
     132                object->*field = value;
    125133        }
    126134
     
    131139                                !std::is_base_of<ast::Expr, node_t>::value &&
    132140                                !std::is_base_of<ast::Stmt, node_t>::value
    133                         , decltype( node->accept(*this) )
     141                        , ast::Pass< core_t >::result1<
     142                                typename std::remove_pointer< decltype( node->accept(*this) ) >::type
     143                        >
    134144                >::type
    135145        {
     
    140150                static_assert( !std::is_base_of<ast::Stmt, node_t>::value, "ERROR");
    141151
    142                 return node->accept( *this );
     152                auto nval = node->accept( *this );
     153                ast::Pass< core_t >::result1<
     154                        typename std::remove_pointer< decltype( node->accept(*this) ) >::type
     155                > res;
     156                res.differs = nval != node;
     157                res.value = nval;
     158                return res;
    143159        }
    144160
    145161        template< typename core_t >
    146         const ast::Expr * ast::Pass< core_t >::call_accept( const ast::Expr * expr ) {
     162        typename ast::Pass< core_t >::template result1<ast::Expr> ast::Pass< core_t >::call_accept( const ast::Expr * expr ) {
    147163                __pedantic_pass_assert( __visit_children() );
    148164                __pedantic_pass_assert( expr );
     
    153169                }
    154170
    155                 return expr->accept( *this );
     171                auto nval = expr->accept( *this );
     172                return { nval != expr, nval };
    156173        }
    157174
    158175        template< typename core_t >
    159         const ast::Stmt * ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) {
     176        typename ast::Pass< core_t >::template result1<ast::Stmt> ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) {
    160177                __pedantic_pass_assert( __visit_children() );
    161178                __pedantic_pass_assert( stmt );
    162179
    163                 return stmt->accept( *this );
     180                const ast::Stmt * nval = stmt->accept( *this );
     181                return { nval != stmt, nval };
    164182        }
    165183
    166184        template< typename core_t >
    167         const ast::Stmt * ast::Pass< core_t >::call_accept_as_compound( const ast::Stmt * stmt ) {
     185        typename ast::Pass< core_t >::template result1<ast::Stmt> ast::Pass< core_t >::call_accept_as_compound( const ast::Stmt * stmt ) {
    168186                __pedantic_pass_assert( __visit_children() );
    169187                __pedantic_pass_assert( stmt );
     
    190208                // If the pass doesn't want to add anything then we are done
    191209                if( empty(stmts_before) && empty(stmts_after) && empty(decls_before) && empty(decls_after) ) {
    192                         return nstmt;
     210                        return { nstmt != stmt, nstmt };
    193211                }
    194212
     
    212230                __pass::take_all( std::back_inserter( compound->kids ), stmts_after );
    213231
    214                 return compound;
     232                return {true, compound};
    215233        }
    216234
    217235        template< typename core_t >
    218236        template< template <class...> class container_t >
    219         container_t< ptr<Stmt> > ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {
     237        template< typename object_t, typename super_t, typename field_t >
     238        void ast::Pass< core_t >::resultNstmt<container_t>::apply(object_t * object, field_t super_t::* field) {
     239                auto & container = object->*field;
     240                __pedantic_pass_assert( container.size() <= values.size() );
     241
     242                auto cit = enumerate(container).begin();
     243
     244                container_t<ptr<Stmt>> nvals;
     245                for(delta & d : values) {
     246                        if( d.is_old ) {
     247                                __pedantic_pass_assert( cit.idx <= d.old_idx );
     248                                std::advance( cit, d.old_idx - cit.idx );
     249                                nvals.push_back( std::move( (*cit).val) );
     250                        } else {
     251                                nvals.push_back( std::move(d.nval) );
     252                        }
     253                }
     254
     255                object->*field = std::move(nvals);
     256        }
     257
     258        template< typename core_t >
     259        template< template <class...> class container_t >
     260        typename ast::Pass< core_t >::template resultNstmt<container_t> ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {
    220261                __pedantic_pass_assert( __visit_children() );
    221262                if( statements.empty() ) return {};
     
    244285                pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    245286
    246                 bool mutated = false;
    247                 container_t< ptr<Stmt> > new_kids;
    248                 for( const Stmt * stmt : statements ) {
     287                resultNstmt<container_t> new_kids;
     288                for( auto value : enumerate( statements ) ) {
    249289                        try {
     290                                size_t i = value.idx;
     291                                const Stmt * stmt = value.val;
    250292                                __pedantic_pass_assert( stmt );
    251293                                const ast::Stmt * new_stmt = stmt->accept( *this );
    252294                                assert( new_stmt );
    253                                 if(new_stmt != stmt ) mutated = true;
     295                                if(new_stmt != stmt ) { new_kids.differs = true; }
    254296
    255297                                // Make sure that it is either adding statements or declartions but not both
     
    261303
    262304                                // Take all the statements which should have gone after, N/A for first iteration
    263                                 __pass::take_all( std::back_inserter( new_kids ), decls_before, &mutated );
    264                                 __pass::take_all( std::back_inserter( new_kids ), stmts_before, &mutated );
     305                                new_kids.take_all( decls_before );
     306                                new_kids.take_all( stmts_before );
    265307
    266308                                // Now add the statement if there is one
    267                                 new_kids.emplace_back( new_stmt );
     309                                if(new_stmt != stmt) {
     310                                        new_kids.values.emplace_back( new_stmt, i, false );
     311                                } else {
     312                                        new_kids.values.emplace_back( nullptr, i, true );
     313                                }
    268314
    269315                                // Take all the declarations that go before
    270                                 __pass::take_all( std::back_inserter( new_kids ), decls_after, &mutated );
    271                                 __pass::take_all( std::back_inserter( new_kids ), stmts_after, &mutated );
     316                                new_kids.take_all( decls_after );
     317                                new_kids.take_all( stmts_after );
    272318                        }
    273319                        catch ( SemanticErrorException &e ) {
     
    278324                if ( !errors.isEmpty() ) { throw errors; }
    279325
    280                 return mutated ? new_kids : container_t< ptr<Stmt> >();
     326                return new_kids;
    281327        }
    282328
    283329        template< typename core_t >
    284330        template< template <class...> class container_t, typename node_t >
    285         container_t< ast::ptr<node_t> > ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {
     331        template< typename object_t, typename super_t, typename field_t >
     332        void ast::Pass< core_t >::resultN<container_t, node_t>::apply(object_t * object, field_t super_t::* field) {
     333                auto & container = object->*field;
     334                __pedantic_pass_assert( container.size() == values.size() );
     335
     336                for(size_t i = 0; i < container.size(); i++) {
     337                        // Take all the elements that are different in 'values'
     338                        // and swap them into 'container'
     339                        if( values[i] != nullptr ) std::swap(container[i], values[i]);
     340                }
     341
     342                // Now the original containers should still have the unchanged values
     343                // but also contain the new values
     344        }
     345
     346        template< typename core_t >
     347        template< template <class...> class container_t, typename node_t >
     348        typename ast::Pass< core_t >::template resultN<container_t, node_t> ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {
    286349                __pedantic_pass_assert( __visit_children() );
    287350                if( container.empty() ) return {};
     
    293356
    294357                bool mutated = false;
    295                 container_t< ast::ptr<node_t> > new_kids;
     358                container_t<ptr<node_t>> new_kids;
    296359                for ( const node_t * node : container ) {
    297360                        try {
    298361                                __pedantic_pass_assert( node );
    299362                                const node_t * new_stmt = strict_dynamic_cast< const node_t * >( node->accept( *this ) );
    300                                 if(new_stmt != node ) mutated = true;
    301 
    302                                 new_kids.emplace_back( new_stmt );
     363                                if(new_stmt != node ) {
     364                                        mutated = true;
     365                                        new_kids.emplace_back( new_stmt );
     366                                } else {
     367                                        new_kids.emplace_back( nullptr );
     368                                }
     369
    303370                        }
    304371                        catch( SemanticErrorException &e ) {
     
    306373                        }
    307374                }
     375
     376                __pedantic_pass_assert( new_kids.size() == container.size() );
    308377                pass_visitor_stats.depth--;
    309378                if ( ! errors.isEmpty() ) { throw errors; }
    310379
    311                 return mutated ? new_kids : container_t< ast::ptr<node_t> >();
     380                return ast::Pass< core_t >::resultN<container_t, node_t>{ mutated,  new_kids };
    312381        }
    313382
     
    327396                auto new_val = call_accept( old_val );
    328397
    329                 static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value || std::is_same<int, decltype(old_val)>::value, "ERROR");
    330 
    331                 if( __pass::differs(old_val, new_val) ) {
     398                static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value /* || std::is_same<int, decltype(old_val)>::value */, "ERROR");
     399
     400                if( new_val.differs ) {
    332401                        auto new_parent = __pass::mutate<core_t>(parent);
    333                         new_parent->*child = new_val;
     402                        new_val.apply(new_parent, child);
    334403                        parent = new_parent;
    335404                }
     
    353422                static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value || std::is_same<int, decltype(old_val)>::value, "ERROR");
    354423
    355                 if( __pass::differs(old_val, new_val) ) {
     424                if( new_val.differs ) {
    356425                        auto new_parent = __pass::mutate<core_t>(parent);
    357                         new_parent->*child = new_val;
     426                        new_val.apply( new_parent, child );
    358427                        parent = new_parent;
    359428                }
     
    9411010                        const Expr * func = clause.target.func ? clause.target.func->accept(*this) : nullptr;
    9421011                        if(func != clause.target.func) mutated = true;
     1012                        else func = nullptr;
    9431013
    9441014                        std::vector<ptr<Expr>> new_args;
     
    9461016                        for( const auto & arg : clause.target.args ) {
    9471017                                auto a = arg->accept(*this);
    948                                 new_args.push_back( a );
    949                                 if( a != arg ) mutated = true;
     1018                                if( a != arg ) {
     1019                                        mutated = true;
     1020                                        new_args.push_back( a );
     1021                                } else
     1022                                        new_args.push_back( nullptr );
    9501023                        }
    9511024
    9521025                        const Stmt * stmt = clause.stmt ? clause.stmt->accept(*this) : nullptr;
    9531026                        if(stmt != clause.stmt) mutated = true;
     1027                        else stmt = nullptr;
    9541028
    9551029                        const Expr * cond = clause.cond ? clause.cond->accept(*this) : nullptr;
    9561030                        if(cond != clause.cond) mutated = true;
     1031                        else cond = nullptr;
    9571032
    9581033                        new_clauses.push_back( WaitForStmt::Clause{ {func, std::move(new_args) }, stmt, cond } );
     
    9611036                if(mutated) {
    9621037                        auto n = __pass::mutate<core_t>(node);
    963                         n->clauses = std::move( new_clauses );
     1038                        for(size_t i = 0; i < new_clauses.size(); i++) {
     1039                                if(new_clauses.at(i).target.func != nullptr) std::swap(n->clauses.at(i).target.func, new_clauses.at(i).target.func);
     1040
     1041                                for(size_t j = 0; j < new_clauses.at(i).target.args.size(); j++) {
     1042                                        if(new_clauses.at(i).target.args.at(j) != nullptr) std::swap(n->clauses.at(i).target.args.at(j), new_clauses.at(i).target.args.at(j));
     1043                                }
     1044
     1045                                if(new_clauses.at(i).stmt != nullptr) std::swap(n->clauses.at(i).stmt, new_clauses.at(i).stmt);
     1046                                if(new_clauses.at(i).cond != nullptr) std::swap(n->clauses.at(i).cond, new_clauses.at(i).cond);
     1047                        }
    9641048                        node = n;
    9651049                }
     
    9691053                if(node->field) { \
    9701054                        auto nval = call_accept( node->field ); \
    971                         if(nval != node->field ) { \
     1055                        if(nval.differs ) { \
    9721056                                auto nparent = __pass::mutate<core_t>(node); \
    973                                 nparent->field = nval; \
     1057                                nparent->field = nval.value; \
    9741058                                node = nparent; \
    9751059                        } \
  • src/AST/Stmt.cpp

    r21a99cc ra554e5f4  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May  8 13:00:00 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed May 15 15:53:00 2019
    13 // Update Count     : 2
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Feb  2 19:01:20 2022
     13// Update Count     : 3
    1414//
    1515
     
    5656
    5757// --- BranchStmt
    58 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, std::vector<Label>&& labels )
    59 : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {
     58BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, const std::vector<Label>&& labels )
     59                : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {
    6060        // Make sure a syntax error hasn't slipped through.
    6161        assert( Goto != kind || !target.empty() );
  • src/AST/Stmt.hpp

    r21a99cc ra554e5f4  
    1010// Created On       : Wed May  8 13:00:00 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  1 17:44:46 2022
    13 // Update Count     : 24
     12// Last Modified On : Wed Feb  2 20:06:41 2022
     13// Update Count     : 34
    1414//
    1515
     
    3939        std::vector<Label> labels;
    4040
    41         Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     41        Stmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    4242                : ParseNode(loc), labels(std::move(labels)) {}
    4343
     
    5555        std::list<ptr<Stmt>> kids;
    5656
    57         CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {},
    58                                  std::vector<Label> && labels = {} )
     57        CompoundStmt(const CodeLocation & loc, const std::list<ptr<Stmt>> && ks = {}, const std::vector<Label> && labels = {} )
    5958                : Stmt(loc, std::move(labels)), kids(std::move(ks)) {}
    6059
     
    7473class NullStmt final : public Stmt {
    7574  public:
    76         NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     75        NullStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    7776                : Stmt(loc, std::move(labels)) {}
    7877
     
    8887        ptr<Expr> expr;
    8988
    90         ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} )
     89        ExprStmt( const CodeLocation & loc, const Expr* e, const std::vector<Label> && labels = {} )
    9190                : Stmt(loc, std::move(labels)), expr(e) {}
    9291
     
    107106
    108107        AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction,
    109                          std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input,
    110                          std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels,
    111                          std::vector<Label> && labels = {})
     108                         const std::vector<ptr<Expr>> && output, const std::vector<ptr<Expr>> && input,
     109                         const std::vector<ptr<ConstantExpr>> && clobber, const std::vector<Label> && gotoLabels,
     110                         const std::vector<Label> && labels = {})
    112111                : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction),
    113112                  output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)),
     
    144143
    145144        IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then,
    146                         const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {},
    147                         std::vector<Label> && labels = {} )
     145                        const Stmt * else_ = nullptr, const std::vector<ptr<Stmt>> && inits = {},
     146                        const std::vector<Label> && labels = {} )
    148147                : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_),
    149148                  inits(std::move(inits)) {}
     
    161160        std::vector<ptr<Stmt>> stmts;
    162161
    163         SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
    164                                 std::vector<Label> && labels = {} )
     162        SwitchStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts,
     163                                const std::vector<Label> && labels = {} )
    165164                : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    166165
     
    178177        std::vector<ptr<Stmt>> stmts;
    179178
    180         CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
    181                           std::vector<Label> && labels = {} )
     179        CaseStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts,
     180                          const std::vector<Label> && labels = {} )
    182181                : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    183182
     
    200199
    201200        WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,
    202                            std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
     201                                 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} )
    203202                : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {}
    204203
    205204        WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_,
    206                            std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
     205                                 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} )
    207206                : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {}
    208207
     
    222221        ptr<Stmt> else_;
    223222
    224         ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
    225                          const Expr * inc, const Stmt * body, std::vector<Label> && label = {} )
     223        ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond,
     224                         const Expr * inc, const Stmt * body, const std::vector<Label> && label = {} )
    226225                : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {}
    227226
    228         ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
    229                          const Expr * inc, const Stmt * body, const Stmt * else_, std::vector<Label> && labels = {} )
     227        ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond,
     228                         const Expr * inc, const Stmt * body, const Stmt * else_, const std::vector<Label> && labels = {} )
    230229                : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {}
    231230
     
    247246        Kind kind;
    248247
    249         BranchStmt( const CodeLocation & loc, Kind kind, Label target,
    250                                 std::vector<Label> && labels = {} );
    251         BranchStmt( const CodeLocation & loc, const Expr * computedTarget,
    252                                 std::vector<Label> && labels = {} )
    253                 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc),
    254                   computedTarget(computedTarget), kind(Goto) {}
     248        BranchStmt( const CodeLocation & loc, Kind kind, Label target, const std::vector<Label> && labels = {} );
     249        BranchStmt( const CodeLocation & loc, const Expr * computedTarget, const std::vector<Label> && labels = {} )
     250                : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), computedTarget(computedTarget), kind(Goto) {}
    255251
    256252        const char * kindName() const { return kindNames[kind]; }
     
    269265        ptr<Expr> expr;
    270266
    271         ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} )
     267        ReturnStmt( const CodeLocation & loc, const Expr * expr, const std::vector<Label> && labels = {} )
    272268                : Stmt(loc, std::move(labels)), expr(expr) {}
    273269
     
    288284        ExceptionKind kind;
    289285
    290         ThrowStmt(
    291                 const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target,
    292                 std::vector<Label> && labels = {} )
     286        ThrowStmt( const CodeLocation & loc, ExceptionKind kind, const Expr * expr,
     287                           const Expr * target, const std::vector<Label> && labels = {} )
    293288                : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {}
    294289
     
    306301        ptr<FinallyStmt> finally;
    307302
    308         TryStmt(
    309                 const CodeLocation & loc, const CompoundStmt * body,
    310                 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
    311                 std::vector<Label> && labels = {} )
     303        TryStmt( const CodeLocation & loc, const CompoundStmt * body,
     304                         const std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
     305                         const std::vector<Label> && labels = {} )
    312306                : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {}
    313307
     
    326320        ExceptionKind kind;
    327321
    328         CatchStmt(
    329                 const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
    330                 const Stmt * body, std::vector<Label> && labels = {} )
     322        CatchStmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
     323                           const Stmt * body, const std::vector<Label> && labels = {} )
    331324                : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {}
    332325
     
    358351        enum Type { None, Coroutine, Generator } type = None;
    359352
    360         SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} )
     353        SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, const std::vector<Label> && labels = {} )
    361354                : Stmt(loc, std::move(labels)), then(then), type(type) {}
    362355
     
    396389        OrElse orElse;
    397390
    398         WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     391        WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
    399392                : Stmt(loc, std::move(labels)) {}
    400393
     
    410403        ptr<Decl> decl;
    411404
    412         DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} )
     405        DeclStmt( const CodeLocation & loc, const Decl * decl, const std::vector<Label> && labels = {} )
    413406                : Stmt(loc, std::move(labels)), decl(decl) {}
    414407
     
    441434
    442435        MutexStmt( const CodeLocation & loc, const Stmt * stmt,
    443                            std::vector<ptr<Expr>> && mutexes, std::vector<Label> && labels = {} )
     436                           const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} )
    444437                : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}
    445438
Note: See TracChangeset for help on using the changeset viewer.