Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Util.cpp

    r0658672 rb7c53a9d  
    102102}
    103103
     104/// Check for Floating Nodes:
     105/// Every node should be reachable from a root (the TranslationUnit) via a
     106/// chain of structural references (tracked with ptr). This cannot check all
     107/// of that, it just checks if a given node's field has a strong reference.
     108template<typename node_t, typename field_t>
     109void noFloatingNode( const node_t * node, field_t node_t::*field_ptr ) {
     110        const field_t & field = node->*field_ptr;
     111        if ( nullptr == field ) return;
     112        assertf( field->isManaged(), "Floating node found." );
     113}
     114
    104115struct InvariantCore {
    105116        // To save on the number of visits: this is a kind of composed core.
     
    127138        }
    128139
     140        void previsit( const VariableExpr * node ) {
     141                previsit( (const ParseNode *)node );
     142                noFloatingNode( node, &VariableExpr::var );
     143        }
     144
    129145        void previsit( const MemberExpr * node ) {
    130146                previsit( (const ParseNode *)node );
    131147                memberMatchesAggregate( node );
     148        }
     149
     150        void previsit( const StructInstType * node ) {
     151                previsit( (const Node *)node );
     152                noFloatingNode( node, &StructInstType::base );
     153        }
     154
     155        void previsit( const UnionInstType * node ) {
     156                previsit( (const Node *)node );
     157                noFloatingNode( node, &UnionInstType::base );
     158        }
     159
     160        void previsit( const EnumInstType * node ) {
     161                previsit( (const Node *)node );
     162                noFloatingNode( node, &EnumInstType::base );
     163        }
     164
     165        void previsit( const TypeInstType * node ) {
     166                previsit( (const Node *)node );
     167                noFloatingNode( node, &TypeInstType::base );
    132168        }
    133169
Note: See TracChangeset for help on using the changeset viewer.