Changeset bfeb37a6 for src/AST/Util.cpp


Ignore:
Timestamp:
Sep 13, 2023, 11:46:22 AM (10 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
efe420f3
Parents:
1ed5e9e
Message:

Added another check to the invariants for SizeofExpr/AlignofExpr?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Util.cpp

    r1ed5e9e rbfeb37a6  
    104104        }
    105105        assertf( false, "Member not found." );
     106}
     107
     108template<typename node_t>
     109void oneOfExprOrType( const node_t * node ) {
     110        if ( node->expr ) {
     111                assertf( node->expr && !node->type, "Exactly one of expr or type should be set." );
     112        } else {
     113                assertf( !node->expr && node->type, "Exactly one of expr or type should be set." );
     114        }
    106115}
    107116
     
    152161        }
    153162
     163        void previsit( const SizeofExpr * node ) {
     164                previsit( (const ParseNode *)node );
     165                oneOfExprOrType( node );
     166        }
     167
     168        void previsit( const AlignofExpr * node ) {
     169                previsit( (const ParseNode *)node );
     170                oneOfExprOrType( node );
     171        }
     172
    154173        void previsit( const StructInstType * node ) {
    155174                previsit( (const Node *)node );
     
    181200/// referring to is in scope by the structural rules of code.
    182201// Any escapes marked with a bug should be removed once the bug is fixed.
     202// This is a separate pass because of it changes the visit pattern and
     203// must always be run on the entire translation unit.
    183204struct InScopeCore : public ast::WithShortCircuiting {
    184205        ScopedSet<DeclWithType const *> typedDecls;
Note: See TracChangeset for help on using the changeset viewer.