Changeset fd236ed


Ignore:
Timestamp:
Nov 30, 2017, 5:11:36 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, with_gc
Children:
1cb934d
Parents:
c50d54d
Message:

Convert HasDesignations? to PassVisitor?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    rc50d54d rfd236ed  
    55#include <memory>                  // for __shared_ptr
    66
     7#include "Common/PassVisitor.h"
    78#include "Common/SemanticError.h"  // for SemanticError
    89#include "Common/UniqueName.h"     // for UniqueName
     
    2930namespace InitTweak {
    3031        namespace {
    31                 class HasDesignations : public Visitor {
     32                class HasDesignations : public WithShortCircuiting {
    3233                public:
    3334                        bool hasDesignations = false;
    34                         virtual void visit( Designation * des ) {
    35                                 if ( ! des->get_designators().empty() ) hasDesignations = true;
    36                                 else Visitor::visit( des );
     35
     36                        void previsit( BaseSyntaxNode * ) {
     37                                // short circuit if we already know there are designations
     38                                if ( hasDesignations ) visit_children = false;
     39                        }
     40
     41                        void previsit( Designation * des ) {
     42                                // short circuit if we already know there are designations
     43                                if ( hasDesignations ) visit_children = false;
     44                                else if ( ! des->get_designators().empty() ) {
     45                                        hasDesignations = true;
     46                                        visit_children = false;
     47                                }
    3748                        }
    3849                };
     
    8697
    8798        bool isDesignated( Initializer * init ) {
    88                 HasDesignations finder;
     99                PassVisitor<HasDesignations> finder;
    89100                maybeAccept( init, finder );
    90                 return finder.hasDesignations;
     101                return finder.pass.hasDesignations;
    91102        }
    92103
Note: See TracChangeset for help on using the changeset viewer.