Changeset ea156ae for src/InitTweak
- Timestamp:
- Sep 27, 2017, 5:31:02 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:
- 549c006
- Parents:
- 12914e9 (diff), fa16264 (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
-
FixInit.cc (modified) (5 diffs)
-
InitTweak.cc (modified) (1 diff)
-
InitTweak.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r12914e9 rea156ae 214 214 void emit( CodeLocation, const Params &... params ); 215 215 216 FunctionDecl * function = 0;216 FunctionDecl * function = nullptr; 217 217 std::set< DeclarationWithType * > unhandled; 218 218 std::map< DeclarationWithType *, CodeLocation > usedUninit; 219 ObjectDecl * thisParam = 0;219 ObjectDecl * thisParam = nullptr; 220 220 bool isCtor = false; // true if current function is a constructor 221 StructDecl * structDecl = 0;221 StructDecl * structDecl = nullptr; 222 222 }; 223 223 … … 624 624 } 625 625 626 DeclarationWithType * FixInit::postmutate( ObjectDecl *objDecl ) {626 DeclarationWithType * FixInit::postmutate( ObjectDecl *objDecl ) { 627 627 // since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate) 628 628 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { … … 722 722 } else { 723 723 ImplicitCtorDtorStmt * implicit = strict_dynamic_cast< ImplicitCtorDtorStmt * > ( ctor ); 724 ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit-> get_callStmt());724 ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->callStmt ); 725 725 ApplicationExpr * ctorCall = nullptr; 726 if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt-> get_expr())) && ctorCall->get_args().size() == 2 ) {726 if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->expr )) && ctorCall->get_args().size() == 2 ) { 727 727 // clean up intrinsic copy constructor calls by making them into SingleInits 728 objDecl-> set_init( new SingleInit( ctorCall->get_args().back()) );729 ctorCall-> get_args().pop_back();728 objDecl->init = new SingleInit( ctorCall->args.back() ); 729 ctorCall->args.pop_back(); 730 730 } else { 731 731 stmtsToAddAfter.push_back( ctor ); 732 objDecl-> set_init( nullptr );733 ctorInit-> set_ctor( nullptr );732 objDecl->init = nullptr; 733 ctorInit->ctor = nullptr; 734 734 } 735 735 } // if 736 } else if ( Initializer * init = ctorInit-> get_init()) {737 objDecl-> set_init( init );738 ctorInit-> set_init( nullptr );736 } else if ( Initializer * init = ctorInit->init ) { 737 objDecl->init = init; 738 ctorInit->init = nullptr; 739 739 } else { 740 740 // no constructor and no initializer, which is okay 741 objDecl-> set_init( nullptr );741 objDecl->init = nullptr; 742 742 } // if 743 743 delete ctorInit; … … 912 912 } 913 913 914 void addIds( SymTab::Indexer & indexer, const std::list< DeclarationWithType * > & decls ) { 915 for ( auto d : decls ) { 916 indexer.addId( d ); 917 } 918 } 919 920 void addTypes( SymTab::Indexer & indexer, const std::list< TypeDecl * > & tds ) { 921 for ( auto td : tds ) { 922 indexer.addType( td ); 923 addIds( indexer, td->assertions ); 924 } 925 } 926 914 927 void GenStructMemberCalls::previsit( FunctionDecl * funcDecl ) { 915 GuardValue( func Decl);928 GuardValue( function ); 916 929 GuardValue( unhandled ); 917 930 GuardValue( usedUninit ); … … 946 959 } 947 960 948 void addIds( SymTab::Indexer & indexer, const std::list< DeclarationWithType * > & decls ) {949 for ( auto d : decls ) {950 indexer.addId( d );951 }952 }953 954 void addTypes( SymTab::Indexer & indexer, const std::list< TypeDecl * > & tds ) {955 for ( auto td : tds ) {956 indexer.addType( td );957 addIds( indexer, td->assertions );958 }959 }960 961 961 void GenStructMemberCalls::postvisit( FunctionDecl * funcDecl ) { 962 962 // remove the unhandled objects from usedUninit, because a call is inserted -
src/InitTweak/InitTweak.cc
r12914e9 rea156ae 270 270 } 271 271 272 Type * getThisType( FunctionType * ftype ) { 273 assertf( ftype, "getThisType: nullptr ftype" ); 274 ObjectDecl * thisParam = getThisParam( ftype ); 275 ReferenceType * refType = strict_dynamic_cast< ReferenceType * >( thisParam->type ); 276 return refType->base; 277 } 278 279 ObjectDecl * getThisParam( FunctionType * ftype ) { 280 assertf( ftype, "getThisParam: nullptr ftype" ); 281 auto & params = ftype->parameters; 282 assertf( ! params.empty(), "getThisParam: ftype with 0 parameters: %s", toString( ftype ).c_str() ); 283 return strict_dynamic_cast< ObjectDecl * >( params.front() ); 284 } 285 272 286 bool tryConstruct( DeclarationWithType * dwt ) { 273 287 ObjectDecl * objDecl = dynamic_cast< ObjectDecl * >( dwt ); -
src/InitTweak/InitTweak.h
r12914e9 rea156ae 29 29 FunctionDecl * isCopyConstructor( Declaration * decl ); 30 30 FunctionDecl * isCopyFunction( Declaration * decl, const std::string & fname ); 31 32 /// returns the base type of the first parameter to a constructor/destructor/assignment function 33 Type * getThisType( FunctionType * ftype ); 34 35 /// returns the first parameter of a constructor/destructor/assignment function 36 ObjectDecl * getThisParam( FunctionType * ftype ); 31 37 32 38 /// transform Initializer into an argument list that can be passed to a call expression
Note:
See TracChangeset
for help on using the changeset viewer.