Changeset 695e00d for src/Common


Ignore:
Timestamp:
Sep 19, 2017, 2:14:39 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
Children:
8f98b78
Parents:
e149f77 (diff), e06be49 (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/Common/PassVisitor.impl.h

    re149f77 r695e00d  
    183183
    184184                } catch ( SemanticError &e ) {
     185                        e.set_location( (*i)->location );
    185186                        errors.append( e );
    186187                }
     
    292293//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    293294
     295// A NOTE ON THE ORDER OF TRAVERSAL
     296//
     297// Types and typedefs have their base types visited before they are added to the type table.  This is ok, since there is
     298// no such thing as a recursive type or typedef.
     299//
     300//             typedef struct { T *x; } T; // never allowed
     301//
     302// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
     303// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
     304// declaration).
     305//
     306//             struct T { struct T *x; }; // allowed
     307//
     308// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
     309// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
     310// queried later in this pass.
     311//
     312// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
    294313
    295314//--------------------------------------------------------------------------
     
    449468        indexerAddEnum( node );
    450469
    451         // unlike structs, contexts, and unions, enums inject their members into the global scope
     470        // unlike structs, traits, and unions, enums inject their members into the global scope
    452471        maybeAccept( node->parameters, *this );
    453472        maybeAccept( node->members   , *this );
     
    513532        }
    514533
     534        // see A NOTE ON THE ORDER OF TRAVERSAL, above
     535        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
     536        // and may depend on the type itself
    515537        indexerAddType( node );
    516538
     
    532554        }
    533555
     556        // see A NOTE ON THE ORDER OF TRAVERSAL, above
     557        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
     558        // and may depend on the type itself
    534559        indexerAddType( node );
    535560
     
    658683void PassVisitor< pass_type >::visit( IfStmt * node ) {
    659684        VISIT_START( node );
    660 
    661         visitExpression( node->condition );
    662         node->thenPart = visitStatement( node->thenPart );
    663         node->elsePart = visitStatement( node->elsePart );
    664 
     685        {
     686                // if statements introduce a level of scope (for the initialization)
     687                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     688                acceptAll( node->get_initialization(), *this );
     689                visitExpression( node->condition );
     690                node->thenPart = visitStatement( node->thenPart );
     691                node->elsePart = visitStatement( node->elsePart );
     692        }
    665693        VISIT_END( node );
    666694}
     
    670698        MUTATE_START( node );
    671699        {
    672                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     700                // if statements introduce a level of scope (for the initialization)
     701                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     702                maybeMutateRef( node->get_initialization(), *this );
    673703                node->condition = mutateExpression( node->condition );
    674704                node->thenPart  = mutateStatement ( node->thenPart  );
     
    706736        VISIT_START( node );
    707737        {
     738                // for statements introduce a level of scope (for the initialization)
    708739                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    709740                maybeAccept( node->initialization, *this );
     
    719750        MUTATE_START( node );
    720751        {
     752                // for statements introduce a level of scope (for the initialization)
    721753                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    722754                maybeMutateRef( node->initialization, *this );
     
    847879        VISIT_START( node );
    848880        {
     881                // catch statements introduce a level of scope (for the caught exception)
    849882                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    850883                maybeAccept( node->decl, *this );
     
    859892        MUTATE_START( node );
    860893        {
     894                // catch statements introduce a level of scope (for the caught exception)
    861895                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    862896                maybeMutateRef( node->decl, *this );
Note: See TracChangeset for help on using the changeset viewer.