Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r9a705dc8 r68f9c43  
    5252Expression::~Expression() {
    5353        delete env;
    54         delete result;
    5554}
    5655
     
    7473ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
    7574}
    76 
    77 ConstantExpr::~ConstantExpr() {}
    7875
    7976void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     
    120117}
    121118
    122 VariableExpr::~VariableExpr() {
    123         // don't delete the declaration, since it points somewhere else in the tree
    124 }
    125 
    126119VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
    127120        VariableExpr * funcExpr = new VariableExpr( func );
     
    150143}
    151144
    152 SizeofExpr::~SizeofExpr() {
    153         delete expr;
    154         delete type;
    155 }
    156 
    157145void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    158146        os << "Sizeof Expression on: ";
     
    176164}
    177165
    178 AlignofExpr::~AlignofExpr() {
    179         delete expr;
    180         delete type;
    181 }
    182 
    183166void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    184167        os << "Alignof Expression on: ";
     
    196179UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
    197180        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    198 
    199 UntypedOffsetofExpr::~UntypedOffsetofExpr() {
    200         delete type;
    201 }
    202181
    203182void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     
    217196        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    218197
    219 OffsetofExpr::~OffsetofExpr() {
    220         delete type;
    221 }
    222 
    223198void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
    224199        os << "Offsetof Expression on member " << member->name << " of ";
     
    234209OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    235210
    236 OffsetPackExpr::~OffsetPackExpr() { delete type; }
    237 
    238211void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
    239212        os << "Offset pack expression on ";
     
    252225AttrExpr::AttrExpr( const AttrExpr &other ) :
    253226                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    254 }
    255 
    256 AttrExpr::~AttrExpr() {
    257         delete attr;
    258         delete expr;
    259         delete type;
    260227}
    261228
     
    271238}
    272239
    273 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
     240CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    274241        set_result(toType);
    275242}
    276243
    277 CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
     244CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
    278245        set_result( new VoidType( Type::Qualifiers() ) );
    279246}
    280247
    281 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    282 }
    283 
    284 CastExpr::~CastExpr() {
    285         delete arg;
     248CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    286249}
    287250
     
    299262}
    300263
    301 KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) {
    302 }
    303 
    304 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
    305 }
    306 
    307 KeywordCastExpr::~KeywordCastExpr() {
    308         delete arg;
    309 }
    310 
    311 const std::string & KeywordCastExpr::targetString() const {
    312         static const std::string targetStrs[] = {
    313                 "coroutine", "thread", "monitor"
    314         };
    315         static_assert(
    316                 (sizeof(targetStrs) / sizeof(targetStrs[0])) == ((unsigned long)NUMBER_OF_TARGETS),
    317                 "Each KeywordCastExpr::Target should have a corresponding string representation"
    318         );
    319         return targetStrs[(unsigned long)target];
    320 }
    321 
    322 void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const {
    323         os << "Keyword Cast of:" << std::endl << indent+1;
    324         arg->print(os, indent+1);
    325         os << std::endl << indent << "... to: ";
    326         os << targetString();
    327         Expression::print( os, indent );
    328 }
    329 
    330264VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    331265        set_result(toType);
     
    333267
    334268VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    335 }
    336 
    337 VirtualCastExpr::~VirtualCastExpr() {
    338         delete arg;
    339269}
    340270
     
    361291}
    362292
    363 UntypedMemberExpr::~UntypedMemberExpr() {
    364         delete aggregate;
    365         delete member;
    366 }
    367 
    368293void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    369294        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    392317}
    393318
    394 MemberExpr::~MemberExpr() {
    395         // don't delete the member declaration, since it points somewhere else in the tree
    396         delete aggregate;
    397 }
    398 
    399319void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    400320        os << "Member Expression, with field: " << std::endl;
     
    412332                Expression( other ), function( maybeClone( other.function ) ) {
    413333        cloneAll( other.args, args );
    414 }
    415 
    416 UntypedExpr::~UntypedExpr() {
    417         delete function;
    418         deleteAll( args );
    419334}
    420335
     
    465380}
    466381
    467 NameExpr::~NameExpr() {}
    468 
    469382void NameExpr::print( std::ostream &os, Indenter indent ) const {
    470383        os << "Name: " << get_name();
     
    479392LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
    480393                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    481 }
    482 
    483 LogicalExpr::~LogicalExpr() {
    484         delete arg1;
    485         delete arg2;
    486394}
    487395
     
    499407ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
    500408                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
    501 }
    502 
    503 ConditionalExpr::~ConditionalExpr() {
    504         delete arg1;
    505         delete arg2;
    506         delete arg3;
    507409}
    508410
     
    542444ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    543445        set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
    544         delete callExpr;
    545         deleteAll( tempDecls );
    546         deleteAll( returnDecls );
    547         deleteAll( dtors );
    548446}
    549447
     
    570468}
    571469
    572 ConstructorExpr::~ConstructorExpr() {
    573         delete callExpr;
    574 }
    575 
    576470void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    577471        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    588482
    589483CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    590 
    591 CompoundLiteralExpr::~CompoundLiteralExpr() {
    592         delete initializer;
    593 }
    594484
    595485void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     
    618508        cloneAll( other.dtors, dtors );
    619509}
    620 StmtExpr::~StmtExpr() {
    621         delete statements;
    622         deleteAll( dtors );
    623         deleteAll( returnDecls );
    624 }
    625510void StmtExpr::computeResult() {
    626511        assert( statements );
    627512        std::list< Statement * > & body = statements->kids;
    628         delete result;
    629513        result = nullptr;
    630514        if ( ! returnDecls.empty() ) {
     
    669553UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    670554}
    671 UniqueExpr::~UniqueExpr() {
    672         delete expr;
    673         delete object;
    674         delete var;
    675 }
     555
    676556void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    677557        os << "Unique Expression with id:" << id << std::endl << indent+1;
     
    686566InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
    687567InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
    688 InitAlternative::~InitAlternative() {
    689         delete type;
    690         delete designation;
    691 }
    692568
    693569UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
    694570UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
    695 UntypedInitExpr::~UntypedInitExpr() {
    696         delete expr;
    697 }
    698571
    699572void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     
    713586}
    714587InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
    715 InitExpr::~InitExpr() {
    716         delete expr;
    717         delete designation;
    718 }
    719588
    720589void InitExpr::print( std::ostream & os, Indenter indent ) const {
     
    730599}
    731600DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
    732 DeletedExpr::~DeletedExpr() {
    733         delete expr;
    734 }
    735601
    736602void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
Note: See TracChangeset for help on using the changeset viewer.