Changeset ba3706f for src/InitTweak/FixInit.cc
- Timestamp:
- Nov 30, 2017, 4:43:59 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:
- c50d54d
- Parents:
- 4429b04
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r4429b04 rba3706f 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... … … 544 544 // add all temporary declarations and their constructors 545 545 for ( ObjectDecl * obj : tempDecls ) { 546 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );546 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 547 547 } // for 548 548 for ( ObjectDecl * obj : returnDecls ) { 549 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );549 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 550 550 } // for 551 551 552 552 // add destructors after current statement 553 553 for ( Expression * dtor : dtors ) { 554 stmtsToAddAfter.push_back( new ExprStmt( noLabels,dtor ) );554 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 555 555 } // for 556 556 … … 598 598 if ( ! result->isVoid() ) { 599 599 for ( ObjectDecl * obj : stmtExpr->get_returnDecls() ) { 600 stmtsToAddBefore.push_back( new DeclStmt( noLabels,obj ) );600 stmtsToAddBefore.push_back( new DeclStmt( obj ) ); 601 601 } // for 602 602 // add destructors after current statement 603 603 for ( Expression * dtor : stmtExpr->get_dtors() ) { 604 stmtsToAddAfter.push_back( new ExprStmt( noLabels,dtor ) );604 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 605 605 } // for 606 606 // must have a non-empty body, otherwise it wouldn't have a result 607 607 assert( ! stmts.empty() ); 608 608 assert( ! stmtExpr->get_returnDecls().empty() ); 609 stmts.push_back( new ExprStmt( n oLabels, new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );609 stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->get_returnDecls().front() ) ) ); 610 610 stmtExpr->get_returnDecls().clear(); 611 611 stmtExpr->get_dtors().clear(); … … 685 685 686 686 // generate body of if 687 CompoundStmt * initStmts = new CompoundStmt( noLabels);687 CompoundStmt * initStmts = new CompoundStmt(); 688 688 std::list< Statement * > & body = initStmts->get_kids(); 689 689 body.push_back( ctor ); 690 body.push_back( new ExprStmt( noLabels,setTrue ) );690 body.push_back( new ExprStmt( setTrue ) ); 691 691 692 692 // put it all together 693 IfStmt * ifStmt = new IfStmt( n oLabels, new VariableExpr( isUninitializedVar ), initStmts, 0 );694 stmtsToAddAfter.push_back( new DeclStmt( noLabels,isUninitializedVar ) );693 IfStmt * ifStmt = new IfStmt( new VariableExpr( isUninitializedVar ), initStmts, 0 ); 694 stmtsToAddAfter.push_back( new DeclStmt( isUninitializedVar ) ); 695 695 stmtsToAddAfter.push_back( ifStmt ); 696 696 … … 707 707 708 708 // void __objName_dtor_atexitN(...) {...} 709 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels) );709 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() ); 710 710 dtorCaller->fixUniqueId(); 711 711 dtorCaller->get_statements()->push_back( dtorStmt ); … … 715 715 callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) ); 716 716 717 body.push_back( new ExprStmt( noLabels,callAtexit ) );717 body.push_back( new ExprStmt( callAtexit ) ); 718 718 719 719 // 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.