Changeset b726084 for src/InitTweak
- Timestamp:
- Nov 9, 2016, 2:51:42 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:
- 30b65d8, d073e3c
- Parents:
- 141b786 (diff), 84118d8 (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. - Location:
- src/InitTweak
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r141b786 rb726084 49 49 namespace InitTweak { 50 50 namespace { 51 class InsertImplicitCalls : public GenPoly::PolyMutator {51 class InsertImplicitCalls final : public GenPoly::PolyMutator { 52 52 public: 53 53 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which … … 55 55 static void insert( std::list< Declaration * > & translationUnit ); 56 56 57 virtual Expression * mutate( ApplicationExpr * appExpr ); 57 using GenPoly::PolyMutator::mutate; 58 virtual Expression * mutate( ApplicationExpr * appExpr ) override; 58 59 }; 59 60 60 class ResolveCopyCtors : public SymTab::Indexer {61 class ResolveCopyCtors final : public SymTab::Indexer { 61 62 public: 62 63 /// generate temporary ObjectDecls for each argument and return value of each ImplicitCopyCtorExpr, … … 68 69 using Parent::visit; 69 70 70 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) ;71 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 71 72 virtual void visit( UniqueExpr * unqExpr ); 72 73 … … 88 89 using Parent::visit; 89 90 typedef std::set< ObjectDecl * > ObjectSet; 90 virtual void visit( CompoundStmt *compoundStmt ) ;91 virtual void visit( DeclStmt *stmt ) ;91 virtual void visit( CompoundStmt *compoundStmt ) override; 92 virtual void visit( DeclStmt *stmt ) override; 92 93 protected: 93 94 ObjectSet curVars; … … 109 110 } 110 111 111 class LabelFinder : public ObjDeclCollector {112 class LabelFinder final : public ObjDeclCollector { 112 113 public: 113 114 typedef ObjDeclCollector Parent; … … 123 124 // subclasses are added, there is only one place that the code has to be updated, rather than ensure that 124 125 // every specialized class knows about every new kind of statement that might be added. 125 virtual void visit( CompoundStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 126 virtual void visit( ExprStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 127 virtual void visit( AsmStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 128 virtual void visit( IfStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 129 virtual void visit( WhileStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 130 virtual void visit( ForStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 131 virtual void visit( SwitchStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 132 virtual void visit( CaseStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 133 virtual void visit( BranchStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 134 virtual void visit( ReturnStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 135 virtual void visit( TryStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 136 virtual void visit( CatchStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 137 virtual void visit( FinallyStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 138 virtual void visit( NullStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 139 virtual void visit( DeclStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 140 virtual void visit( ImplicitCtorDtorStmt *stmt ) { handleStmt( stmt ); return Parent::visit( stmt ); } 126 using Parent::visit; 127 virtual void visit( CompoundStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 128 virtual void visit( ExprStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 129 virtual void visit( AsmStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 130 virtual void visit( IfStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 131 virtual void visit( WhileStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 132 virtual void visit( ForStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 133 virtual void visit( SwitchStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 134 virtual void visit( CaseStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 135 virtual void visit( BranchStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 136 virtual void visit( ReturnStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 137 virtual void visit( TryStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 138 virtual void visit( CatchStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 139 virtual void visit( FinallyStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 140 virtual void visit( NullStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 141 virtual void visit( DeclStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 142 virtual void visit( ImplicitCtorDtorStmt *stmt ) override { handleStmt( stmt ); return Parent::visit( stmt ); } 141 143 }; 142 144 143 class InsertDtors : public ObjDeclCollector {145 class InsertDtors final : public ObjDeclCollector { 144 146 public: 145 147 /// insert destructor calls at the appropriate places. must happen before CtorInit nodes are removed … … 153 155 InsertDtors( LabelFinder & finder ) : labelVars( finder.vars ) {} 154 156 155 virtual void visit( ObjectDecl * objDecl ); 156 157 virtual void visit( CompoundStmt * compoundStmt ); 158 virtual void visit( ReturnStmt * returnStmt ); 159 virtual void visit( BranchStmt * stmt ); 157 using Parent::visit; 158 159 virtual void visit( ObjectDecl * objDecl ) override; 160 161 virtual void visit( CompoundStmt * compoundStmt ) override; 162 virtual void visit( ReturnStmt * returnStmt ) override; 163 virtual void visit( BranchStmt * stmt ) override; 160 164 private: 161 165 void handleGoto( BranchStmt * stmt ); … … 165 169 }; 166 170 167 class FixInit : public GenPoly::PolyMutator {171 class FixInit final : public GenPoly::PolyMutator { 168 172 public: 169 173 /// expand each object declaration to use its constructor after it is declared. 170 174 static void fixInitializers( std::list< Declaration * > &translationUnit ); 171 175 172 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ); 176 using GenPoly::PolyMutator::mutate; 177 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override; 173 178 174 179 std::list< Declaration * > staticDtorDecls; 175 180 }; 176 181 177 class FixCopyCtors : public GenPoly::PolyMutator {182 class FixCopyCtors final : public GenPoly::PolyMutator { 178 183 public: 179 184 /// expand ImplicitCopyCtorExpr nodes into the temporary declarations, copy constructors, call expression, … … 181 186 static void fixCopyCtors( std::list< Declaration * > &translationUnit ); 182 187 183 virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ); 184 virtual Expression * mutate( UniqueExpr * unqExpr ); 188 using GenPoly::PolyMutator::mutate; 189 virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 190 virtual Expression * mutate( UniqueExpr * unqExpr ) override; 185 191 }; 186 192 187 class GenStructMemberCalls : public SymTab::Indexer {193 class GenStructMemberCalls final : public SymTab::Indexer { 188 194 public: 189 195 typedef Indexer Parent; … … 193 199 static void generate( std::list< Declaration * > & translationUnit ); 194 200 195 virtual void visit( FunctionDecl * funcDecl ); 196 197 virtual void visit( MemberExpr * memberExpr ); 198 virtual void visit( ApplicationExpr * appExpr ); 201 using Parent::visit; 202 203 virtual void visit( FunctionDecl * funcDecl ) override; 204 205 virtual void visit( MemberExpr * memberExpr ) override; 206 virtual void visit( ApplicationExpr * appExpr ) override; 199 207 200 208 SemanticError errors; … … 214 222 // resolve UntypedExprs that are found within newly 215 223 // generated constructor/destructor calls 216 class MutatingResolver : public Mutator {224 class MutatingResolver final : public Mutator { 217 225 public: 218 226 MutatingResolver( SymTab::Indexer & indexer ) : indexer( indexer ) {} 219 227 220 virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ); 221 222 virtual Expression* mutate( UntypedExpr *untypedExpr ); 223 private: 228 using Mutator::mutate; 229 virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ) override; 230 virtual Expression* mutate( UntypedExpr *untypedExpr ) override; 231 232 private: 224 233 SymTab::Indexer & indexer; 225 234 }; 226 235 227 class FixCtorExprs : public GenPoly::DeclMutator {236 class FixCtorExprs final : public GenPoly::DeclMutator { 228 237 public: 229 238 /// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument 230 239 static void fix( std::list< Declaration * > & translationUnit ); 231 240 232 virtual Expression * mutate( ConstructorExpr * ctorExpr ); 241 using GenPoly::DeclMutator::mutate; 242 virtual Expression * mutate( ConstructorExpr * ctorExpr ) override; 233 243 }; 234 244 } // namespace -
src/InitTweak/GenInit.cc
r141b786 rb726084 37 37 } 38 38 39 class ReturnFixer : public GenPoly::PolyMutator {39 class ReturnFixer final : public GenPoly::PolyMutator { 40 40 public: 41 41 /// consistently allocates a temporary variable for the return value … … 46 46 ReturnFixer(); 47 47 48 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );49 50 virtual Statement * mutate( ReturnStmt * returnStmt ) ;48 using GenPoly::PolyMutator::mutate; 49 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 50 virtual Statement * mutate( ReturnStmt * returnStmt ) override; 51 51 52 52 protected: … … 56 56 }; 57 57 58 class CtorDtor : public GenPoly::PolyMutator {58 class CtorDtor final : public GenPoly::PolyMutator { 59 59 public: 60 60 typedef GenPoly::PolyMutator Parent; … … 66 66 static void generateCtorDtor( std::list< Declaration * > &translationUnit ); 67 67 68 virtual DeclarationWithType * mutate( ObjectDecl * ) ;69 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) ;68 virtual DeclarationWithType * mutate( ObjectDecl * ) override; 69 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 70 70 // should not traverse into any of these declarations to find objects 71 71 // that need to be constructed or destructed 72 virtual Declaration* mutate( StructDecl *aggregateDecl ) ;73 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }74 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }75 virtual Declaration* mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; }76 virtual TypeDecl* mutate( TypeDecl *typeDecl ) { return typeDecl; }77 virtual Declaration* mutate( TypedefDecl *typeDecl ) { return typeDecl; }78 79 virtual Type * mutate( FunctionType *funcType ) { return funcType; }80 81 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) ;72 virtual Declaration* mutate( StructDecl *aggregateDecl ) override; 73 virtual Declaration* mutate( UnionDecl *aggregateDecl ) override { return aggregateDecl; } 74 virtual Declaration* mutate( EnumDecl *aggregateDecl ) override { return aggregateDecl; } 75 virtual Declaration* mutate( TraitDecl *aggregateDecl ) override { return aggregateDecl; } 76 virtual TypeDecl* mutate( TypeDecl *typeDecl ) override { return typeDecl; } 77 virtual Declaration* mutate( TypedefDecl *typeDecl ) override { return typeDecl; } 78 79 virtual Type * mutate( FunctionType *funcType ) override { return funcType; } 80 81 virtual CompoundStmt * mutate( CompoundStmt * compoundStmt ) override; 82 82 83 83 private: … … 93 93 }; 94 94 95 class HoistArrayDimension : public GenPoly::DeclMutator {95 class HoistArrayDimension final : public GenPoly::DeclMutator { 96 96 public: 97 97 typedef GenPoly::DeclMutator Parent; … … 103 103 104 104 private: 105 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ); 106 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 105 using Parent::mutate; 106 107 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) override; 108 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 107 109 // should not traverse into any of these declarations to find objects 108 110 // that need to be constructed or destructed 109 virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }110 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }111 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }112 virtual Declaration* mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; }113 virtual TypeDecl* mutate( TypeDecl *typeDecl ) { return typeDecl; }114 virtual Declaration* mutate( TypedefDecl *typeDecl ) { return typeDecl; }115 116 virtual Type* mutate( FunctionType *funcType ) { return funcType; }111 virtual Declaration* mutate( StructDecl *aggregateDecl ) override { return aggregateDecl; } 112 virtual Declaration* mutate( UnionDecl *aggregateDecl ) override { return aggregateDecl; } 113 virtual Declaration* mutate( EnumDecl *aggregateDecl ) override { return aggregateDecl; } 114 virtual Declaration* mutate( TraitDecl *aggregateDecl ) override { return aggregateDecl; } 115 virtual TypeDecl* mutate( TypeDecl *typeDecl ) override { return typeDecl; } 116 virtual Declaration* mutate( TypedefDecl *typeDecl ) override { return typeDecl; } 117 118 virtual Type* mutate( FunctionType *funcType ) override { return funcType; } 117 119 118 120 void hoist( Type * type ); -
src/InitTweak/InitTweak.h
r141b786 rb726084 100 100 101 101 class ExpanderImpl; 102 typedef std::list< Expression * > IndexList; 102 103 private: 103 104 std::shared_ptr< ExpanderImpl > expander; … … 105 106 106 107 // invariant: list of size 2N (elements come in pairs [index, dimension]) 107 typedef std::list< Expression * > IndexList;108 108 IndexList indices; 109 109 };
Note:
See TracChangeset
for help on using the changeset viewer.