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