Changeset 52c14b3 for src/InitTweak
- Timestamp:
- Feb 8, 2017, 9:51:14 AM (8 years ago)
- 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:
- 4fbdd1e3, 84e2523, b7b8674
- Parents:
- 35b1bf4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r35b1bf4 r52c14b3 104 104 virtual void visit( CompoundStmt *compoundStmt ) override; 105 105 virtual void visit( DeclStmt *stmt ) override; 106 107 // don't go into other functions 108 virtual void visit( FunctionDecl *decl ) override {} 109 106 110 protected: 107 111 ObjectSet curVars; … … 166 170 typedef std::list< OrderedDecls > OrderedDeclsStack; 167 171 168 InsertDtors( LabelFinder & finder ) : labelVars( finder.vars ) {}172 InsertDtors( LabelFinder & finder ) : finder( finder ), labelVars( finder.vars ) {} 169 173 170 174 using Parent::visit; 171 175 172 176 virtual void visit( ObjectDecl * objDecl ) override; 177 virtual void visit( FunctionDecl * funcDecl ) override; 173 178 174 179 virtual void visit( CompoundStmt * compoundStmt ) override; … … 178 183 void handleGoto( BranchStmt * stmt ); 179 184 185 LabelFinder & finder; 180 186 LabelFinder::LabelMap & labelVars; 181 187 OrderedDeclsStack reverseDeclOrder; … … 318 324 LabelFinder finder; 319 325 InsertDtors inserter( finder ); 320 acceptAll( translationUnit, finder );321 326 acceptAll( translationUnit, inserter ); 322 327 } … … 778 783 } 779 784 780 void ObjDeclCollector::visit( CompoundStmt * compoundStmt ) {785 void ObjDeclCollector::visit( CompoundStmt * compoundStmt ) { 781 786 std::set< ObjectDecl * > prevVars = curVars; 782 787 Parent::visit( compoundStmt ); … … 784 789 } 785 790 786 void ObjDeclCollector::visit( DeclStmt * stmt ) {791 void ObjDeclCollector::visit( DeclStmt * stmt ) { 787 792 // keep track of all variables currently in scope 788 793 if ( ObjectDecl * objDecl = dynamic_cast< ObjectDecl * > ( stmt->get_decl() ) ) { … … 828 833 } // if 829 834 Parent::visit( objDecl ); 835 } 836 837 template< typename Visitor > 838 void handleFuncDecl( FunctionDecl * funcDecl, Visitor & visitor ) { 839 maybeAccept( funcDecl->get_functionType(), visitor ); 840 acceptAll( funcDecl->get_oldDecls(), visitor ); 841 maybeAccept( funcDecl->get_statements(), visitor ); 842 } 843 844 void InsertDtors::visit( FunctionDecl * funcDecl ) { 845 // each function needs to have its own set of labels 846 ValueGuard< LabelFinder::LabelMap > oldLabels( labelVars ); 847 labelVars.clear(); 848 handleFuncDecl( funcDecl, finder ); 849 850 // all labels for this function have been collected, insert destructors as appropriate. 851 // can't be Parent::mutate, because ObjDeclCollector bottoms out on FunctionDecl 852 handleFuncDecl( funcDecl, *this ); 830 853 } 831 854
Note: See TracChangeset
for help on using the changeset viewer.