Changeset ba3706f for src/InitTweak


Ignore:
Timestamp:
Nov 30, 2017, 4:43:59 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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
Message:

Remove label lists from various Statement constructors

Location:
src/InitTweak
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixGlobalInit.cc

    r4429b04 rba3706f  
    2929#include "SynTree/Expression.h"    // for ConstantExpr, Expression (ptr only)
    3030#include "SynTree/Initializer.h"   // for ConstructorInit, Initializer
    31 #include "SynTree/Label.h"         // for Label, noLabels
     31#include "SynTree/Label.h"         // for Label
    3232#include "SynTree/Statement.h"     // for CompoundStmt, Statement (ptr only)
    3333#include "SynTree/Type.h"          // for Type, Type::StorageClasses, Functi...
     
    9292                        dtorParameters.push_back( new ConstantExpr( Constant::from_int( 102 ) ) );
    9393                }
    94                 initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
     94                initFunction = new FunctionDecl( "_init_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
    9595                initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) );
    96                 destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ) );
     96                destroyFunction = new FunctionDecl( "_destroy_" + fixedName, Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
    9797                destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) );
    9898        }
  • src/InitTweak/FixInit.cc

    r4429b04 rba3706f  
    4949#include "SynTree/Expression.h"        // for UniqueExpr, VariableExpr, Unty...
    5050#include "SynTree/Initializer.h"       // for ConstructorInit, SingleInit
    51 #include "SynTree/Label.h"             // for Label, noLabels, operator<
     51#include "SynTree/Label.h"             // for Label, operator<
    5252#include "SynTree/Mutator.h"           // for mutateAll, Mutator, maybeMutate
    5353#include "SynTree/Statement.h"         // for ExprStmt, CompoundStmt, Branch...
     
    544544                        // add all temporary declarations and their constructors
    545545                        for ( ObjectDecl * obj : tempDecls ) {
    546                                 stmtsToAddBefore.push_back( new DeclStmt( noLabels, obj ) );
     546                                stmtsToAddBefore.push_back( new DeclStmt( obj ) );
    547547                        } // for
    548548                        for ( ObjectDecl * obj : returnDecls ) {
    549                                 stmtsToAddBefore.push_back( new DeclStmt( noLabels, obj ) );
     549                                stmtsToAddBefore.push_back( new DeclStmt( obj ) );
    550550                        } // for
    551551
    552552                        // add destructors after current statement
    553553                        for ( Expression * dtor : dtors ) {
    554                                 stmtsToAddAfter.push_back( new ExprStmt( noLabels, dtor ) );
     554                                stmtsToAddAfter.push_back( new ExprStmt( dtor ) );
    555555                        } // for
    556556
     
    598598                        if ( ! result->isVoid() ) {
    599599                                for ( ObjectDecl * obj : stmtExpr->get_returnDecls() ) {
    600                                         stmtsToAddBefore.push_back( new DeclStmt( noLabels, obj ) );
     600                                        stmtsToAddBefore.push_back( new DeclStmt( obj ) );
    601601                                } // for
    602602                                // add destructors after current statement
    603603                                for ( Expression * dtor : stmtExpr->get_dtors() ) {
    604                                         stmtsToAddAfter.push_back( new ExprStmt( noLabels, dtor ) );
     604                                        stmtsToAddAfter.push_back( new ExprStmt( dtor ) );
    605605                                } // for
    606606                                // must have a non-empty body, otherwise it wouldn't have a result
    607607                                assert( ! stmts.empty() );
    608608                                assert( ! stmtExpr->get_returnDecls().empty() );
    609                                 stmts.push_back( new ExprStmt( noLabels, new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );
     609                                stmts.push_back( new ExprStmt( new VariableExpr( stmtExpr->get_returnDecls().front() ) ) );
    610610                                stmtExpr->get_returnDecls().clear();
    611611                                stmtExpr->get_dtors().clear();
     
    685685
    686686                                                // generate body of if
    687                                                 CompoundStmt * initStmts = new CompoundStmt( noLabels );
     687                                                CompoundStmt * initStmts = new CompoundStmt();
    688688                                                std::list< Statement * > & body = initStmts->get_kids();
    689689                                                body.push_back( ctor );
    690                                                 body.push_back( new ExprStmt( noLabels, setTrue ) );
     690                                                body.push_back( new ExprStmt( setTrue ) );
    691691
    692692                                                // put it all together
    693                                                 IfStmt * ifStmt = new IfStmt( noLabels, 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 ) );
    695695                                                stmtsToAddAfter.push_back( ifStmt );
    696696
     
    707707
    708708                                                        // 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() );
    710710                                                        dtorCaller->fixUniqueId();
    711711                                                        dtorCaller->get_statements()->push_back( dtorStmt );
     
    715715                                                        callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) );
    716716
    717                                                         body.push_back( new ExprStmt( noLabels, callAtexit ) );
     717                                                        body.push_back( new ExprStmt( callAtexit ) );
    718718
    719719                                                        // hoist variable and dtor caller decls to list of decls that will be added into global scope
  • src/InitTweak/InitTweak.cc

    r4429b04 rba3706f  
    1919#include "SynTree/Expression.h"    // for Expression, UntypedExpr, Applicati...
    2020#include "SynTree/Initializer.h"   // for Initializer, ListInit, Designation
    21 #include "SynTree/Label.h"         // for Label, noLabels
     21#include "SynTree/Label.h"         // for Label
    2222#include "SynTree/Statement.h"     // for CompoundStmt, ExprStmt, BranchStmt
    2323#include "SynTree/Type.h"          // for FunctionType, ArrayType, PointerType
     
    195195                        callExpr->get_args().splice( callExpr->get_args().end(), args );
    196196
    197                         *out++ = new IfStmt( noLabels, cond, new ExprStmt( noLabels, callExpr ), nullptr );
     197                        *out++ = new IfStmt( cond, new ExprStmt( callExpr ), nullptr );
    198198
    199199                        UntypedExpr * increment = new UntypedExpr( new NameExpr( "++?" ) );
    200200                        increment->get_args().push_back( index->clone() );
    201                         *out++ = new ExprStmt( noLabels, increment );
     201                        *out++ = new ExprStmt( increment );
    202202                }
    203203
     
    244244                                        std::list< Statement * > stmts;
    245245                                        build( callExpr, idx, idxEnd, init, back_inserter( stmts ) );
    246                                         stmts.push_back( new BranchStmt( noLabels, switchLabel, BranchStmt::Break ) );
    247                                         CaseStmt * caseStmt = new CaseStmt( noLabels, condition, stmts );
     246                                        stmts.push_back( new BranchStmt( switchLabel, BranchStmt::Break ) );
     247                                        CaseStmt * caseStmt = new CaseStmt( condition, stmts );
    248248                                        branches.push_back( caseStmt );
    249249                                }
    250                                 *out++ = new SwitchStmt( noLabels, index->clone(), branches );
    251                                 *out++ = new NullStmt( std::list<Label>{ switchLabel } );
     250                                *out++ = new SwitchStmt( index->clone(), branches );
     251                                *out++ = new NullStmt( { switchLabel } );
    252252                        }
    253253                }
     
    262262        Statement * InitImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) {
    263263                if ( ! init ) return nullptr;
    264                 CompoundStmt * block = new CompoundStmt( noLabels );
     264                CompoundStmt * block = new CompoundStmt();
    265265                build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) );
    266266                if ( block->get_kids().empty() ) {
Note: See TracChangeset for help on using the changeset viewer.