Changes in / [b1d4d60:28c9ff3]
- Location:
- src
- Files:
-
- 2 edited
-
Common/PassVisitor.h (modified) (1 diff)
-
InitTweak/FixInit.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
rb1d4d60 r28c9ff3 26 26 27 27 template< typename... Args > 28 PassVisitor(Args &&... args) 28 PassVisitor(Args &&... args) 29 29 : pass( std::forward<Args>( args )... ) 30 30 {} 31 31 32 32 virtual ~PassVisitor() = default; 33 33 private: 34 34 pass_type pass; 35 36 public: 35 37 36 38 virtual void visit( ObjectDecl *objectDecl ) override final; -
src/InitTweak/FixInit.cc
rb1d4d60 r28c9ff3 192 192 }; 193 193 194 class FixInit {194 class FixInit final : public GenPoly::PolyMutator { 195 195 public: 196 196 /// expand each object declaration to use its constructor after it is declared. 197 197 static void fixInitializers( std::list< Declaration * > &translationUnit ); 198 198 199 DeclarationWithType * postmutate( ObjectDecl *objDecl ); 199 typedef GenPoly::PolyMutator Parent; 200 using Parent::mutate; 201 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override; 200 202 201 203 std::list< Declaration * > staticDtorDecls; 202 std::list< Statement * > stmtsToAddAfter; // found by PassVisitor203 204 }; 204 205 … … 311 312 312 313 void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) { 313 PassVisitor<FixInit>fixer;314 FixInit fixer; 314 315 315 316 // can't use mutateAll, because need to insert declarations at top-level … … 319 320 try { 320 321 *i = maybeMutate( *i, fixer ); 321 translationUnit.splice( i, fixer. pass.staticDtorDecls );322 translationUnit.splice( i, fixer.staticDtorDecls ); 322 323 } catch( SemanticError &e ) { 323 324 e.set_location( (*i)->location ); … … 695 696 } 696 697 697 DeclarationWithType *FixInit::postmutate( ObjectDecl *objDecl ) { 698 // since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate) 698 DeclarationWithType *FixInit::mutate( ObjectDecl *objDecl ) { 699 // first recursively handle pieces of ObjectDecl so that they aren't missed by other visitors when the init 700 // is removed from the ObjectDecl 701 objDecl = dynamic_cast< ObjectDecl * >( Parent::mutate( objDecl ) ); 699 702 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 700 703 // a decision should have been made by the resolver, so ctor and init are not both non-NULL
Note:
See TracChangeset
for help on using the changeset viewer.