Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rcdb990a r42107b4  
    5050}
    5151
    52 void Expression::spliceInferParams( Expression * other ) {
    53         if ( ! other ) return;
    54         for ( auto p : other->inferParams ) {
    55                 inferParams[p.first] = std::move( p.second );
    56         }
    57 }
    58 
    5952Expression::~Expression() {
    6053        delete env;
    61         delete result;
    6254}
    6355
     
    8173ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
    8274}
    83 
    84 ConstantExpr::~ConstantExpr() {}
    8575
    8676void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     
    127117}
    128118
    129 VariableExpr::~VariableExpr() {
    130         // don't delete the declaration, since it points somewhere else in the tree
    131 }
    132 
    133119VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
    134120        VariableExpr * funcExpr = new VariableExpr( func );
     
    157143}
    158144
    159 SizeofExpr::~SizeofExpr() {
    160         delete expr;
    161         delete type;
    162 }
    163 
    164145void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    165146        os << "Sizeof Expression on: ";
     
    183164}
    184165
    185 AlignofExpr::~AlignofExpr() {
    186         delete expr;
    187         delete type;
    188 }
    189 
    190166void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    191167        os << "Alignof Expression on: ";
     
    203179UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
    204180        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    205 
    206 UntypedOffsetofExpr::~UntypedOffsetofExpr() {
    207         delete type;
    208 }
    209181
    210182void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     
    224196        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    225197
    226 OffsetofExpr::~OffsetofExpr() {
    227         delete type;
    228 }
    229 
    230198void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
    231199        os << "Offsetof Expression on member " << member->name << " of ";
     
    241209OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    242210
    243 OffsetPackExpr::~OffsetPackExpr() { delete type; }
    244 
    245211void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
    246212        os << "Offset pack expression on ";
     
    259225AttrExpr::AttrExpr( const AttrExpr &other ) :
    260226                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    261 }
    262 
    263 AttrExpr::~AttrExpr() {
    264         delete attr;
    265         delete expr;
    266         delete type;
    267227}
    268228
     
    287247
    288248CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    289 }
    290 
    291 CastExpr::~CastExpr() {
    292         delete arg;
    293249}
    294250
     
    312268}
    313269
    314 KeywordCastExpr::~KeywordCastExpr() {
    315         delete arg;
    316 }
    317 
    318270const std::string & KeywordCastExpr::targetString() const {
    319271        static const std::string targetStrs[] = {
     
    340292
    341293VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    342 }
    343 
    344 VirtualCastExpr::~VirtualCastExpr() {
    345         delete arg;
    346294}
    347295
     
    368316}
    369317
    370 UntypedMemberExpr::~UntypedMemberExpr() {
    371         delete aggregate;
    372         delete member;
    373 }
    374 
    375318void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    376319        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    399342}
    400343
    401 MemberExpr::~MemberExpr() {
    402         // don't delete the member declaration, since it points somewhere else in the tree
    403         delete aggregate;
    404 }
    405 
    406344void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    407345        os << "Member Expression, with field: " << std::endl;
     
    419357                Expression( other ), function( maybeClone( other.function ) ) {
    420358        cloneAll( other.args, args );
    421 }
    422 
    423 UntypedExpr::~UntypedExpr() {
    424         delete function;
    425         deleteAll( args );
    426359}
    427360
     
    472405}
    473406
    474 NameExpr::~NameExpr() {}
    475 
    476407void NameExpr::print( std::ostream &os, Indenter indent ) const {
    477408        os << "Name: " << get_name();
     
    486417LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
    487418                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    488 }
    489 
    490 LogicalExpr::~LogicalExpr() {
    491         delete arg1;
    492         delete arg2;
    493419}
    494420
     
    506432ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
    507433                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
    508 }
    509 
    510 ConditionalExpr::~ConditionalExpr() {
    511         delete arg1;
    512         delete arg2;
    513         delete arg3;
    514434}
    515435
     
    549469ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    550470        set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
    551         delete callExpr;
    552         deleteAll( tempDecls );
    553         deleteAll( returnDecls );
    554         deleteAll( dtors );
    555471}
    556472
     
    577493}
    578494
    579 ConstructorExpr::~ConstructorExpr() {
    580         delete callExpr;
    581 }
    582 
    583495void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    584496        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    595507
    596508CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    597 
    598 CompoundLiteralExpr::~CompoundLiteralExpr() {
    599         delete initializer;
    600 }
    601509
    602510void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     
    625533        cloneAll( other.dtors, dtors );
    626534}
    627 StmtExpr::~StmtExpr() {
    628         delete statements;
    629         deleteAll( dtors );
    630         deleteAll( returnDecls );
    631 }
    632535void StmtExpr::computeResult() {
    633536        assert( statements );
    634537        std::list< Statement * > & body = statements->kids;
    635         delete result;
    636538        result = nullptr;
    637539        if ( ! returnDecls.empty() ) {
     
    676578UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    677579}
    678 UniqueExpr::~UniqueExpr() {
    679         delete expr;
    680         delete object;
    681         delete var;
    682 }
     580
    683581void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    684582        os << "Unique Expression with id:" << id << std::endl << indent+1;
     
    693591InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
    694592InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
    695 InitAlternative::~InitAlternative() {
    696         delete type;
    697         delete designation;
    698 }
    699593
    700594UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
    701595UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
    702 UntypedInitExpr::~UntypedInitExpr() {
    703         delete expr;
    704 }
    705596
    706597void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     
    720611}
    721612InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
    722 InitExpr::~InitExpr() {
    723         delete expr;
    724         delete designation;
    725 }
    726613
    727614void InitExpr::print( std::ostream & os, Indenter indent ) const {
     
    737624}
    738625DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
    739 DeletedExpr::~DeletedExpr() {
    740         delete expr;
    741 }
    742626
    743627void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.