Changeset dbf5e18 for src/AST/Util.cpp


Ignore:
Timestamp:
Jul 17, 2023, 9:24:46 AM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
7ed01be
Parents:
847ab8f (diff), 0d7fc00 (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Util.cpp

    r847ab8f rdbf5e18  
    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.