Changes in src/InitTweak/FixInit.cc [b3fc977:6dfa2e1]
- File:
-
- 1 edited
-
src/InitTweak/FixInit.cc (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
rb3fc977 r6dfa2e1 197 197 }; 198 198 199 struct GenStructMemberCalls final : public WithGuards, public WithShortCircuiting, public WithIndexer , public WithVisitorRef<GenStructMemberCalls>{199 struct GenStructMemberCalls final : public WithGuards, public WithShortCircuiting, public WithIndexer { 200 200 /// generate default/copy ctor and dtor calls for user-defined struct ctor/dtors 201 201 /// for any member that is missing a corresponding ctor/dtor call. … … 203 203 static void generate( std::list< Declaration * > & translationUnit ); 204 204 205 void premutate( FunctionDecl * funcDecl ); 206 DeclarationWithType * postmutate( FunctionDecl * funcDecl ); 207 208 void premutate( MemberExpr * memberExpr ); 209 void premutate( ApplicationExpr * appExpr ); 210 211 /// Note: this post mutate used to be in a separate visitor. If this pass breaks, one place to examine is whether it is 212 /// okay for this part of the recursion to occur alongside the rest. 213 Expression * postmutate( UntypedExpr * expr ); 205 void previsit( FunctionDecl * funcDecl ); 206 void postvisit( FunctionDecl * funcDecl ); 207 208 void previsit( MemberExpr * memberExpr ); 209 void previsit( ApplicationExpr * appExpr ); 214 210 215 211 SemanticError errors; … … 224 220 bool isCtor = false; // true if current function is a constructor 225 221 StructDecl * structDecl = nullptr; 222 }; 223 224 // very simple resolver-like mutator class - used to 225 // resolve UntypedExprs that are found within newly 226 // generated constructor/destructor calls 227 class MutatingResolver final : public Mutator { 228 public: 229 MutatingResolver( SymTab::Indexer & indexer ) : indexer( indexer ) {} 230 231 using Mutator::mutate; 232 virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ) override; 233 virtual Expression* mutate( UntypedExpr *untypedExpr ) override; 234 235 private: 236 SymTab::Indexer & indexer; 226 237 }; 227 238 … … 304 315 void GenStructMemberCalls::generate( std::list< Declaration * > & translationUnit ) { 305 316 PassVisitor<GenStructMemberCalls> warner; 306 mutateAll( translationUnit, warner );317 acceptAll( translationUnit, warner ); 307 318 } 308 319 … … 939 950 } 940 951 941 void GenStructMemberCalls::pre mutate( FunctionDecl * funcDecl ) {952 void GenStructMemberCalls::previsit( FunctionDecl * funcDecl ) { 942 953 GuardValue( function ); 943 954 GuardValue( unhandled ); … … 973 984 } 974 985 975 DeclarationWithType * GenStructMemberCalls::postmutate( FunctionDecl * funcDecl ) {986 void GenStructMemberCalls::postvisit( FunctionDecl * funcDecl ) { 976 987 // remove the unhandled objects from usedUninit, because a call is inserted 977 988 // to handle them - only objects that are later constructed are used uninitialized. … … 1027 1038 Statement * callStmt = stmt.front(); 1028 1039 1040 MutatingResolver resolver( indexer ); 1029 1041 try { 1030 callStmt->acceptMutator( *visitor );1042 callStmt->acceptMutator( resolver ); 1031 1043 if ( isCtor ) { 1032 1044 function->get_statements()->push_front( callStmt ); … … 1044 1056 throw errors; 1045 1057 } 1046 return funcDecl;1047 1058 } 1048 1059 … … 1070 1081 } 1071 1082 1072 void GenStructMemberCalls::pre mutate( ApplicationExpr * appExpr ) {1083 void GenStructMemberCalls::previsit( ApplicationExpr * appExpr ) { 1073 1084 if ( ! checkWarnings( function ) ) { 1074 1085 visit_children = false; … … 1095 1106 } 1096 1107 1097 void GenStructMemberCalls::pre mutate( MemberExpr * memberExpr ) {1108 void GenStructMemberCalls::previsit( MemberExpr * memberExpr ) { 1098 1109 if ( ! checkWarnings( function ) || ! isCtor ) { 1099 1110 visit_children = false; … … 1123 1134 } 1124 1135 1125 Expression * GenStructMemberCalls::postmutate( UntypedExpr * untypedExpr ) { 1136 DeclarationWithType * MutatingResolver::mutate( ObjectDecl * objectDecl ) { 1137 // add object to the indexer assumes that there will be no name collisions 1138 // in generated code. If this changes, add mutate methods for entities with 1139 // scope and call {enter,leave}Scope explicitly. 1140 indexer.addId( objectDecl ); 1141 return objectDecl; 1142 } 1143 1144 Expression * MutatingResolver::mutate( UntypedExpr * untypedExpr ) { 1126 1145 Expression * newExpr = untypedExpr; 1127 1146 ResolvExpr::findVoidExpression( newExpr, indexer );
Note:
See TracChangeset
for help on using the changeset viewer.