Changeset ea23d10 for src/InitTweak
- Timestamp:
- Feb 8, 2017, 2:35:08 PM (9 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:
- e994912, f923b5f
- Parents:
- 424931d (diff), 4fbdd1e3 (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. - File:
-
- 1 edited
-
src/InitTweak/FixInit.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r424931d rea23d10 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 … … 952 975 std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ) ); 953 976 for ( DeclarationWithType * member : diff ) { 954 emit( "in ", CodeGen::gen Type( function->get_functionType(), function->get_name(), false), ", field ", member->get_name(), " used before being constructed" );977 emit( "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", member->get_name(), " used before being constructed" ); 955 978 } 956 979 … … 997 1020 } 998 1021 } catch ( SemanticError & error ) { 999 emit( "in ", CodeGen::gen Type( function->get_functionType(), function->get_name(), false), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed", " and no ", isCtor ? "default constructor" : "destructor", " found" );1022 emit( "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed", " and no ", isCtor ? "default constructor" : "destructor", " found" ); 1000 1023 } 1001 1024 }
Note:
See TracChangeset
for help on using the changeset viewer.