Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r42107b4 rcdb990a  
    5050}
    5151
     52void 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
    5259Expression::~Expression() {
    5360        delete env;
     61        delete result;
    5462}
    5563
     
    7381ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
    7482}
     83
     84ConstantExpr::~ConstantExpr() {}
    7585
    7686void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     
    117127}
    118128
     129VariableExpr::~VariableExpr() {
     130        // don't delete the declaration, since it points somewhere else in the tree
     131}
     132
    119133VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
    120134        VariableExpr * funcExpr = new VariableExpr( func );
     
    143157}
    144158
     159SizeofExpr::~SizeofExpr() {
     160        delete expr;
     161        delete type;
     162}
     163
    145164void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    146165        os << "Sizeof Expression on: ";
     
    164183}
    165184
     185AlignofExpr::~AlignofExpr() {
     186        delete expr;
     187        delete type;
     188}
     189
    166190void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    167191        os << "Alignof Expression on: ";
     
    179203UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
    180204        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
     205
     206UntypedOffsetofExpr::~UntypedOffsetofExpr() {
     207        delete type;
     208}
    181209
    182210void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     
    196224        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    197225
     226OffsetofExpr::~OffsetofExpr() {
     227        delete type;
     228}
     229
    198230void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
    199231        os << "Offsetof Expression on member " << member->name << " of ";
     
    209241OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    210242
     243OffsetPackExpr::~OffsetPackExpr() { delete type; }
     244
    211245void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
    212246        os << "Offset pack expression on ";
     
    225259AttrExpr::AttrExpr( const AttrExpr &other ) :
    226260                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
     261}
     262
     263AttrExpr::~AttrExpr() {
     264        delete attr;
     265        delete expr;
     266        delete type;
    227267}
    228268
     
    247287
    248288CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
     289}
     290
     291CastExpr::~CastExpr() {
     292        delete arg;
    249293}
    250294
     
    268312}
    269313
     314KeywordCastExpr::~KeywordCastExpr() {
     315        delete arg;
     316}
     317
    270318const std::string & KeywordCastExpr::targetString() const {
    271319        static const std::string targetStrs[] = {
     
    292340
    293341VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
     342}
     343
     344VirtualCastExpr::~VirtualCastExpr() {
     345        delete arg;
    294346}
    295347
     
    316368}
    317369
     370UntypedMemberExpr::~UntypedMemberExpr() {
     371        delete aggregate;
     372        delete member;
     373}
     374
    318375void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    319376        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    342399}
    343400
     401MemberExpr::~MemberExpr() {
     402        // don't delete the member declaration, since it points somewhere else in the tree
     403        delete aggregate;
     404}
     405
    344406void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    345407        os << "Member Expression, with field: " << std::endl;
     
    357419                Expression( other ), function( maybeClone( other.function ) ) {
    358420        cloneAll( other.args, args );
     421}
     422
     423UntypedExpr::~UntypedExpr() {
     424        delete function;
     425        deleteAll( args );
    359426}
    360427
     
    405472}
    406473
     474NameExpr::~NameExpr() {}
     475
    407476void NameExpr::print( std::ostream &os, Indenter indent ) const {
    408477        os << "Name: " << get_name();
     
    417486LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
    418487                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
     488}
     489
     490LogicalExpr::~LogicalExpr() {
     491        delete arg1;
     492        delete arg2;
    419493}
    420494
     
    432506ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
    433507                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
     508}
     509
     510ConditionalExpr::~ConditionalExpr() {
     511        delete arg1;
     512        delete arg2;
     513        delete arg3;
    434514}
    435515
     
    469549ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    470550        set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
     551        delete callExpr;
     552        deleteAll( tempDecls );
     553        deleteAll( returnDecls );
     554        deleteAll( dtors );
    471555}
    472556
     
    493577}
    494578
     579ConstructorExpr::~ConstructorExpr() {
     580        delete callExpr;
     581}
     582
    495583void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    496584        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    507595
    508596CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
     597
     598CompoundLiteralExpr::~CompoundLiteralExpr() {
     599        delete initializer;
     600}
    509601
    510602void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     
    533625        cloneAll( other.dtors, dtors );
    534626}
     627StmtExpr::~StmtExpr() {
     628        delete statements;
     629        deleteAll( dtors );
     630        deleteAll( returnDecls );
     631}
    535632void StmtExpr::computeResult() {
    536633        assert( statements );
    537634        std::list< Statement * > & body = statements->kids;
     635        delete result;
    538636        result = nullptr;
    539637        if ( ! returnDecls.empty() ) {
     
    578676UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    579677}
    580 
     678UniqueExpr::~UniqueExpr() {
     679        delete expr;
     680        delete object;
     681        delete var;
     682}
    581683void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    582684        os << "Unique Expression with id:" << id << std::endl << indent+1;
     
    591693InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
    592694InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
     695InitAlternative::~InitAlternative() {
     696        delete type;
     697        delete designation;
     698}
    593699
    594700UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
    595701UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
     702UntypedInitExpr::~UntypedInitExpr() {
     703        delete expr;
     704}
    596705
    597706void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     
    611720}
    612721InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
     722InitExpr::~InitExpr() {
     723        delete expr;
     724        delete designation;
     725}
    613726
    614727void InitExpr::print( std::ostream & os, Indenter indent ) const {
     
    624737}
    625738DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
     739DeletedExpr::~DeletedExpr() {
     740        delete expr;
     741}
    626742
    627743void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.