Changeset c13e8dc8 for src/InitTweak/FixInit.cc
- Timestamp:
- Dec 5, 2017, 2:35:03 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f9feab8
- Parents:
- 9c35431 (diff), 65197c2 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r9c35431 rc13e8dc8 49 49 #include "SynTree/Expression.h" // for UniqueExpr, VariableExpr, Unty... 50 50 #include "SynTree/Initializer.h" // for ConstructorInit, SingleInit 51 #include "SynTree/Label.h" // for Label, noLabels,operator<51 #include "SynTree/Label.h" // for Label, operator< 52 52 #include "SynTree/Mutator.h" // for mutateAll, Mutator, maybeMutate 53 53 #include "SynTree/Statement.h" // for ExprStmt, CompoundStmt, Branch... … … 547 547 // add all temporary declarations and their constructors 548 548 for ( ObjectDecl * obj : tempDecls ) { 549 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );549 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 550 550 } // for 551 551 for ( ObjectDecl * obj : returnDecls ) { 552 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );552 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 553 553 } // for 554 554 555 555 // add destructors after current statement 556 556 for ( Expression * dtor : dtors ) { 557 stmtsToAddAfter.push_back( new ExprStmt( noLabels,dtor ) );557 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 558 558 } // for 559 559 … … 601 601 if ( ! result->isVoid() ) { 602 602 for ( ObjectDecl * obj : stmtExpr->get_returnDecls() ) { 603 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );603 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 604 604 } // for 605 605 // add destructors after current statement 606 606 for ( Expression * dtor : stmtExpr->get_dtors() ) { 607 stmtsToAddAfter.push_back( new ExprStmt( noLabels,dtor ) );607 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 608 608 } // for 609 609 // must have a non-empty body, otherwise it wouldn't have a result 610 610 assert( ! stmts.empty() ); 611 611 assert( ! stmtExpr->get_returnDecls().empty() ); 612 stmts.push_back( new ExprStmt( n oLabels, new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );612 stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->get_returnDecls().front() ) ) ); 613 613 stmtExpr->get_returnDecls().clear(); 614 614 stmtExpr->get_dtors().clear(); … … 739 739 740 740 // generate body of if 741 CompoundStmt * initStmts = new CompoundStmt( noLabels);741 CompoundStmt * initStmts = new CompoundStmt(); 742 742 std::list< Statement * > & body = initStmts->get_kids(); 743 743 body.push_back( ctor ); 744 body.push_back( new ExprStmt( noLabels,setTrue ) );744 body.push_back( new ExprStmt( setTrue ) ); 745 745 746 746 // put it all together 747 IfStmt * ifStmt = new IfStmt( n oLabels, new VariableExpr( isUninitializedVar ), initStmts, 0 );748 stmtsToAddAfter.push_back( new DeclStmt( noLabels,isUninitializedVar ) );747 IfStmt * ifStmt = new IfStmt( new VariableExpr( isUninitializedVar ), initStmts, 0 ); 748 stmtsToAddAfter.push_back( new DeclStmt( isUninitializedVar ) ); 749 749 stmtsToAddAfter.push_back( ifStmt ); 750 750 … … 761 761 762 762 // void __objName_dtor_atexitN(...) {...} 763 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels) );763 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 764 764 dtorCaller->fixUniqueId(); 765 765 dtorCaller->get_statements()->push_back( dtorStmt ); … … 769 769 callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) ); 770 770 771 body.push_back( new ExprStmt( noLabels,callAtexit ) );771 body.push_back( new ExprStmt( callAtexit ) ); 772 772 773 773 // hoist variable and dtor caller decls to list of decls that will be added into global scope
Note: See TracChangeset
for help on using the changeset viewer.