Changeset aff3af4
- Timestamp:
- Jun 1, 2017, 7:26:04 PM (7 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:
- b1d4d60
- Parents:
- 676cc8c
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r676cc8c raff3af4 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 private: 33 34 34 pass_type pass; 35 36 public:37 35 38 36 virtual void visit( ObjectDecl *objectDecl ) override final; -
src/InitTweak/FixInit.cc
r676cc8c raff3af4 192 192 }; 193 193 194 class FixInit final : public GenPoly::PolyMutator{194 class FixInit { 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 typedef GenPoly::PolyMutator Parent; 200 using Parent::mutate; 201 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override; 199 DeclarationWithType * postmutate( ObjectDecl *objDecl ); 202 200 203 201 std::list< Declaration * > staticDtorDecls; 202 std::list< Statement * > stmtsToAddAfter; // found by PassVisitor 204 203 }; 205 204 … … 312 311 313 312 void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) { 314 FixInitfixer;313 PassVisitor<FixInit> fixer; 315 314 316 315 // can't use mutateAll, because need to insert declarations at top-level … … 320 319 try { 321 320 *i = maybeMutate( *i, fixer ); 322 translationUnit.splice( i, fixer. staticDtorDecls );321 translationUnit.splice( i, fixer.pass.staticDtorDecls ); 323 322 } catch( SemanticError &e ) { 324 323 e.set_location( (*i)->location ); … … 696 695 } 697 696 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 ) ); 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) 702 699 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 703 700 // 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.