Ignore:
Timestamp:
May 24, 2019, 10:19:41 AM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
d908563
Parents:
6a9d4b4 (diff), 292642a (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' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    r6a9d4b4 r933f32f  
    2020
    2121#define MUTATE_END( type, node )                \
    22         return call_postmutate< type * >( node ); \
     22        auto __return = call_postmutate< type * >( node ); \
     23        assert( __return ); \
     24        return __return;
    2325
    2426
     
    6769        SemanticErrorException errors;
    6870
     71        pass_visitor_stats.depth++;
     72        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     73        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    6974        for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
     75
     76
    7077                // splice in new declarations after previous decl
    7178                if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); }
     
    8390                if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
    8491        }
     92        pass_visitor_stats.depth--;
    8593        if ( ! errors.isEmpty() ) {
    8694                throw errors;
     
    94102        SemanticErrorException errors;
    95103
     104        pass_visitor_stats.depth++;
     105        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     106        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    96107        for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) {
    97108                // splice in new declarations after previous decl
     
    109120                if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); }
    110121        }
     122        pass_visitor_stats.depth--;
    111123        if ( ! errors.isEmpty() ) {
    112124                throw errors;
     
    126138        if ( ! visitor.get_visit_children() ) return;
    127139        SemanticErrorException errors;
     140
     141        pass_visitor_stats.depth++;
     142        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     143        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    128144        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    129145                try {
     
    135151                }
    136152        }
     153        pass_visitor_stats.depth--;
    137154        if ( ! errors.isEmpty() ) {
    138155                throw errors;
     
    151168template< typename Container, typename pass_type >
    152169inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
     170
    153171        if ( ! mutator.get_visit_children() ) return;
    154172        SemanticErrorException errors;
     173
     174        pass_visitor_stats.depth++;
     175        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     176        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    155177        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    156178                try {
     
    163185                } // try
    164186        } // for
     187        pass_visitor_stats.depth--;
    165188        if ( ! errors.isEmpty() ) {
    166189                throw errors;
     
    185208        DeclList_t* afterDecls  = get_afterDecls();
    186209
     210        pass_visitor_stats.depth++;
     211        pass_visitor_stats.max->push(pass_visitor_stats.depth);
     212        pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    187213        for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
    188214
     
    192218                try {
    193219                        func( *i );
     220                        assert( *i );
    194221                        assert(( empty( beforeStmts ) && empty( afterStmts ))
    195222                            || ( empty( beforeDecls ) && empty( afterDecls )) );
     
    202229                if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); }
    203230        }
     231        pass_visitor_stats.depth--;
    204232
    205233        if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); }
     
    229257
    230258        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    231         ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
     259        ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    232260        ValueGuardPtr< DeclList_t >          oldBeforeDecls( get_beforeDecls() );
    233261        ValueGuardPtr< DeclList_t >          oldAfterDecls ( get_afterDecls () );
     
    19651993
    19661994        // don't want statements from outer CompoundStmts to be added to this StmtExpr
    1967         ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     1995        ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    19681996        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
    19691997        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
     
    19822010
    19832011        // don't want statements from outer CompoundStmts to be added to this StmtExpr
    1984         ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
     2012        ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    19852013        ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
    19862014        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
     
    26782706
    26792707//--------------------------------------------------------------------------
    2680 // Subrange
    2681 template< typename pass_type >
    2682 void PassVisitor< pass_type >::visit( Subrange * node ) {
    2683         VISIT_START( node );
    2684 
    2685         VISIT_END( node );
    2686 }
    2687 
    2688 template< typename pass_type >
    2689 Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
    2690         MUTATE_START( node );
    2691 
    2692         MUTATE_END( Subrange, node );
    2693 }
    2694 
    2695 //--------------------------------------------------------------------------
    26962708// Attribute
    26972709template< typename pass_type >
Note: See TracChangeset for help on using the changeset viewer.