Changes in / [9d5fb67:1cdfa82]


Ignore:
Location:
src
Files:
4 added
90 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r9d5fb67 r1cdfa82  
    11451145unsigned Indenter::tabsize = 2;
    11461146
    1147 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
    1148         if ( node ) {
    1149                 node->print( out );
    1150         } else {
    1151                 out << "nullptr";
    1152         }
    1153         return out;
    1154 }
    1155 
    11561147// Local Variables: //
    11571148// tab-width: 4 //
  • src/CodeGen/FixMain.cc

    r9d5fb67 r1cdfa82  
    2929namespace CodeGen {
    3030        bool FixMain::replace_main = false;
    31         std::unique_ptr<FunctionDecl> FixMain::main_signature = nullptr;
     31        FunctionDecl* FixMain::main_signature = nullptr;
    3232
    3333        template<typename container>
     
    4141                        SemanticError(functionDecl, "Multiple definition of main routine\n");
    4242                }
    43                 main_signature.reset( functionDecl->clone() );
     43                main_signature = functionDecl;
    4444        }
    4545
  • src/CodeGen/FixMain.h

    r9d5fb67 r1cdfa82  
    4040          private:
    4141                static bool replace_main;
    42                 static std::unique_ptr<FunctionDecl> main_signature;
     42                static FunctionDecl* main_signature;
    4343        };
    4444};
  • src/CodeGen/FixNames.cc

    r9d5fb67 r1cdfa82  
    1616#include "FixNames.h"
    1717
    18 #include <memory>                  // for unique_ptr
    1918#include <string>                  // for string, operator!=, operator==
    2019
     
    4746        std::string mangle_main() {
    4847                FunctionType* main_type;
    49                 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
    50                                                                                                                                    main_type = new FunctionType( Type::Qualifiers(), true ), nullptr )
    51                                 };
     48                FunctionDecl* mainDecl = new FunctionDecl{
     49                        "main", Type::StorageClasses(), LinkageSpec::Cforall,
     50                        main_type = new FunctionType{ Type::Qualifiers(), true }, nullptr };
    5251                main_type->get_returnVals().push_back(
    5352                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
    5453                );
    5554
    56                 auto && name = SymTab::Mangler::mangle( mainDecl.get() );
     55                auto && name = SymTab::Mangler::mangle( mainDecl );
    5756                // std::cerr << name << std::endl;
    5857                return name;
     
    6059        std::string mangle_main_args() {
    6160                FunctionType* main_type;
    62                 std::unique_ptr<FunctionDecl> mainDecl { new FunctionDecl( "main", Type::StorageClasses(), LinkageSpec::Cforall,
    63                                                                                                                                    main_type = new FunctionType( Type::Qualifiers(), false ), nullptr )
    64                                 };
     61                FunctionDecl* mainDecl = new FunctionDecl{
     62                        "main", Type::StorageClasses(), LinkageSpec::Cforall,
     63                        main_type = new FunctionType{ Type::Qualifiers(), false }, nullptr };
    6564                main_type->get_returnVals().push_back(
    6665                        new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr )
     
    7776                );
    7877
    79                 auto&& name = SymTab::Mangler::mangle( mainDecl.get() );
     78                auto&& name = SymTab::Mangler::mangle( mainDecl );
    8079                // std::cerr << name << std::endl;
    8180                return name;
  • src/CodeGen/Generate.cc

    r9d5fb67 r1cdfa82  
    4141                void cleanTree( std::list< Declaration * > & translationUnit ) {
    4242                        PassVisitor<TreeCleaner> cleaner;
    43                         filter( translationUnit, [](Declaration * decl) { return TreeCleaner::shouldClean(decl); }, false );
     43                        filter( translationUnit, [](Declaration * decl) { return TreeCleaner::shouldClean(decl); } );
    4444                        mutateAll( translationUnit, cleaner );
    4545                } // cleanTree
     
    7979                                }
    8080                                return false;
    81                         }, false );
     81                        } );
    8282                }
    8383
     
    8585                        Statement * callStmt = nullptr;
    8686                        std::swap( stmt->callStmt, callStmt );
    87                         delete stmt;
    8887                        return callStmt;
    8988                }
  • src/Common/PassVisitor.h

    r9d5fb67 r1cdfa82  
    150150        virtual void visit( Subrange * subrange ) override final;
    151151
    152         virtual void visit( Constant * constant ) override final;
     152        virtual void visit( Constant * constant ) final;
    153153
    154154        virtual void visit( Attribute * attribute ) override final;
     155
     156        virtual void visit( TypeSubstitution * sub ) final;
    155157
    156158        virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) override final;
     
    247249        virtual Subrange * mutate( Subrange * subrange ) override final;
    248250
    249         virtual Constant * mutate( Constant * constant ) override final;
     251        virtual Constant * mutate( Constant * constant ) final;
    250252
    251253        virtual Attribute * mutate( Attribute * attribute ) override final;
  • src/Common/PassVisitor.impl.h

    r9d5fb67 r1cdfa82  
    3838        MUTATE_END( type, node );      \
    3939
    40 
     40#include "Common/GC.h"
    4141
    4242template<typename T>
     
    397397                        auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    398398                        // implicit add __func__ identifier as specified in the C manual 6.4.2.2
    399                         static ObjectDecl func(
     399                        static ObjectDecl* func = new_static_root<ObjectDecl>(
    400400                                "__func__", noStorageClasses, LinkageSpec::C, nullptr,
    401401                                new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
    402402                                nullptr
    403403                        );
    404                         indexerAddId( &func );
     404                        indexerAddId( func );
    405405                        maybeAccept_impl( node->type, *this );
    406406                        maybeAccept_impl( node->statements, *this );
     
    427427                        auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    428428                        // implicit add __func__ identifier as specified in the C manual 6.4.2.2
    429                         static ObjectDecl func(
     429                        static ObjectDecl* func = new_static_root<ObjectDecl>(
    430430                                "__func__", noStorageClasses, LinkageSpec::C, nullptr,
    431431                                new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
    432432                                nullptr
    433433                        );
    434                         indexerAddId( &func );
     434                        indexerAddId( func );
    435435                        maybeMutate_impl( node->type, *this );
    436436                        maybeMutate_impl( node->statements, *this );
     
    11931193        indexerScopedAccept( node->result, *this );
    11941194
     1195        // xxx - not quite sure why this doesn't visit( node->function );
    11951196        for ( auto expr : node->args ) {
    11961197                visitExpression( expr );
     
    25992600// TypeSubstitution
    26002601template< typename pass_type >
     2602void PassVisitor< pass_type >::visit( TypeSubstitution * node ) {
     2603        VISIT_START( node );
     2604
     2605        for ( auto & p : node->typeEnv ) {
     2606                indexerScopedAccept( p.second, *this );
     2607        }
     2608        for ( auto & p : node->varEnv ) {
     2609                indexerScopedAccept( p.second, *this );
     2610        }
     2611
     2612        VISIT_END( node );
     2613}
     2614
     2615template< typename pass_type >
    26012616TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
    26022617        MUTATE_START( node );
  • src/Common/module.mk

    r9d5fb67 r1cdfa82  
    1818       Common/UniqueName.cc \
    1919       Common/DebugMalloc.cc \
     20       Common/GC.cc \
    2021       Common/Assert.cc
  • src/Common/utility.h

    r9d5fb67 r1cdfa82  
    190190
    191191template <typename E, typename UnaryPredicate, template< typename, typename...> class Container, typename... Args >
    192 void filter( Container< E *, Args... > & container, UnaryPredicate pred, bool doDelete ) {
     192void filter( Container< E *, Args... > & container, UnaryPredicate pred ) {
    193193        auto i = begin( container );
    194194        while ( i != end( container ) ) {
    195195                auto it = next( i );
    196196                if ( pred( *i ) ) {
    197                         if ( doDelete ) {
    198                                 delete *i;
    199                         } // if
    200197                        container.erase( i );
    201198                } // if
  • src/Concurrency/Keywords.cc

    r9d5fb67 r1cdfa82  
    1919#include <string>                  // for string, operator==
    2020
     21#include "Common/GC.h"             // for new_static_root
    2122#include "Common/PassVisitor.h"    // for PassVisitor
    2223#include "Common/SemanticError.h"  // for SemanticError
     
    206207                StructDecl* dtor_guard_decl = nullptr;
    207208
    208                 static std::unique_ptr< Type > generic_func;
     209                static Type* generic_func;
    209210        };
    210211
    211         std::unique_ptr< Type > MutexKeyword::generic_func = std::unique_ptr< Type >(
    212                 new FunctionType(
    213                         noQualifiers,
    214                         true
    215                 )
    216         );
     212        Type* MutexKeyword::generic_func = new_static_root<FunctionType>( noQualifiers, true );
    217213
    218214        //-----------------------------------------------------------------------------
     
    318314                StructDecl * forward = decl->clone();
    319315                forward->set_body( false );
    320                 deleteAll( forward->get_members() );
    321316                forward->get_members().clear();
    322317
     
    382377                        fixupGenerics(main_type, decl);
    383378                }
    384 
    385                 delete this_decl;
    386379
    387380                declsToAddBefore.push_back( forward );
  • src/Concurrency/Waitfor.cc

    r9d5fb67 r1cdfa82  
    137137                StructDecl          * decl_acceptable = nullptr;
    138138                StructDecl          * decl_monitor    = nullptr;
    139 
    140                 static std::unique_ptr< Type > generic_func;
    141139
    142140                UniqueName namer_acc = "__acceptables_"s;
     
    476474                }
    477475
    478                 delete setter;
    479 
    480476                return new VariableExpr( timeout );
    481477        }
  • src/ControlStruct/ExceptTranslate.cc

    r9d5fb67 r1cdfa82  
    104104                // Types used in translation, make sure to use clone.
    105105                // void (*function)();
    106                 FunctionType try_func_t;
     106                FunctionType * try_func_t;
    107107                // void (*function)(int, exception);
    108                 FunctionType catch_func_t;
     108                FunctionType * catch_func_t;
    109109                // int (*function)(exception);
    110                 FunctionType match_func_t;
     110                FunctionType * match_func_t;
    111111                // bool (*function)(exception);
    112                 FunctionType handle_func_t;
     112                FunctionType * handle_func_t;
    113113                // void (*function)(__attribute__((unused)) void *);
    114                 FunctionType finally_func_t;
     114                FunctionType * finally_func_t;
    115115
    116116                StructInstType * create_except_type() {
     
    125125                        handler_except_decl( nullptr ),
    126126                        except_decl( nullptr ), node_decl( nullptr ), hook_decl( nullptr ),
    127                         try_func_t( noQualifiers, false ),
    128                         catch_func_t( noQualifiers, false ),
    129                         match_func_t( noQualifiers, false ),
    130                         handle_func_t( noQualifiers, false ),
    131                         finally_func_t( noQualifiers, false )
     127                        try_func_t( new FunctionType(noQualifiers, false) ),
     128                        catch_func_t( new FunctionType(noQualifiers, false) ),
     129                        match_func_t( new FunctionType(noQualifiers, false) ),
     130                        handle_func_t( new FunctionType(noQualifiers, false) ),
     131                        finally_func_t( new FunctionType(noQualifiers, false) )
    132132                {}
    133133
     
    141141                assert( except_decl );
    142142
    143                 ObjectDecl index_obj(
     143                auto index_obj = new ObjectDecl(
    144144                        "__handler_index",
    145145                        Type::StorageClasses(),
     
    149149                        /*init*/ NULL
    150150                        );
    151                 ObjectDecl exception_obj(
     151                auto exception_obj = new ObjectDecl(
    152152                        "__exception_inst",
    153153                        Type::StorageClasses(),
     
    160160                        /*init*/ NULL
    161161                        );
    162                 ObjectDecl bool_obj(
     162                auto bool_obj = new ObjectDecl(
    163163                        "__ret_bool",
    164164                        Type::StorageClasses(),
     
    169169                        std::list<Attribute *>{ new Attribute( "unused" ) }
    170170                        );
    171                 ObjectDecl voidptr_obj(
     171                auto voidptr_obj = new ObjectDecl(
    172172                        "__hook",
    173173                        Type::StorageClasses(),
     
    184184                        );
    185185
    186                 ObjectDecl * unused_index_obj = index_obj.clone();
     186                ObjectDecl * unused_index_obj = index_obj->clone();
    187187                unused_index_obj->attributes.push_back( new Attribute( "unused" ) );
    188188
    189                 catch_func_t.get_parameters().push_back( index_obj.clone() );
    190                 catch_func_t.get_parameters().push_back( exception_obj.clone() );
    191                 match_func_t.get_returnVals().push_back( unused_index_obj );
    192                 match_func_t.get_parameters().push_back( exception_obj.clone() );
    193                 handle_func_t.get_returnVals().push_back( bool_obj.clone() );
    194                 handle_func_t.get_parameters().push_back( exception_obj.clone() );
    195                 finally_func_t.get_parameters().push_back( voidptr_obj.clone() );
     189                catch_func_t->get_parameters().push_back( index_obj );
     190                catch_func_t->get_parameters().push_back( exception_obj->clone() );
     191                match_func_t->get_returnVals().push_back( unused_index_obj );
     192                match_func_t->get_parameters().push_back( exception_obj->clone() );
     193                handle_func_t->get_returnVals().push_back( bool_obj );
     194                handle_func_t->get_parameters().push_back( exception_obj );
     195                finally_func_t->get_parameters().push_back( voidptr_obj );
    196196        }
    197197
     
    204204                call->get_args().push_back( throwStmt->get_expr() );
    205205                throwStmt->set_expr( nullptr );
    206                 delete throwStmt;
    207206                return new ExprStmt( call );
    208207        }
     
    234233                        new UntypedExpr( new NameExpr( "__cfaabi_ehm__rethrow_terminate" ) )
    235234                        ) );
    236                 delete throwStmt;
    237235                return result;
    238236        }
     
    251249                        );
    252250                result->labels = throwStmt->labels;
    253                 delete throwStmt;
    254251                return result;
    255252        }
     
    267264
    268265                return new FunctionDecl( "try", Type::StorageClasses(),
    269                         LinkageSpec::Cforall, try_func_t.clone(), body );
     266                        LinkageSpec::Cforall, try_func_t->clone(), body );
    270267        }
    271268
     
    274271                std::list<CaseStmt *> handler_wrappers;
    275272
    276                 FunctionType *func_type = catch_func_t.clone();
     273                FunctionType *func_type = catch_func_t->clone();
    277274                DeclarationWithType * index_obj = func_type->get_parameters().front();
    278275                DeclarationWithType * except_obj = func_type->get_parameters().back();
     
    384381                modded_handler->set_cond( nullptr );
    385382                modded_handler->set_body( nullptr );
    386                 delete modded_handler;
    387383                return block;
    388384        }
     
    396392                CompoundStmt * body = new CompoundStmt();
    397393
    398                 FunctionType * func_type = match_func_t.clone();
     394                FunctionType * func_type = match_func_t->clone();
    399395                DeclarationWithType * except_obj = func_type->get_parameters().back();
    400396
     
    450446                CompoundStmt * body = new CompoundStmt();
    451447
    452                 FunctionType * func_type = handle_func_t.clone();
     448                FunctionType * func_type = handle_func_t->clone();
    453449                DeclarationWithType * except_obj = func_type->get_parameters().back();
    454450
     
    530526                CompoundStmt * body = finally->get_block();
    531527                finally->set_block( nullptr );
    532                 delete finally;
    533528                tryStmt->set_finally( nullptr );
    534529
    535530                return new FunctionDecl("finally", Type::StorageClasses(),
    536                         LinkageSpec::Cforall, finally_func_t.clone(), body);
     531                        LinkageSpec::Cforall, finally_func_t->clone(), body);
    537532        }
    538533
  • src/ControlStruct/MLEMutator.cc

    r9d5fb67 r1cdfa82  
    226226
    227227                // transform break/continue statements into goto to simplify later handling of branches
    228                 delete branchStmt;
    229228                return new BranchStmt( exitLabel, BranchStmt::Goto );
    230229        }
  • src/GenPoly/Box.cc

    r9d5fb67 r1cdfa82  
    281281        /// Adds parameters for otype layout to a function type
    282282        void addOtypeParams( FunctionType *layoutFnType, std::list< TypeDecl* > &otypeParams ) {
    283                 BasicType sizeAlignType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    284 
    285                 for ( std::list< TypeDecl* >::const_iterator param = otypeParams.begin(); param != otypeParams.end(); ++param ) {
    286                         TypeInstType paramType( Type::Qualifiers(), (*param)->get_name(), *param );
    287                         std::string paramName = mangleType( &paramType );
    288                         layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
    289                         layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType.clone(), 0 ) );
     283                auto sizeAlignType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     284
     285                for ( std::list< TypeDecl* >::const_iterator param = otypeParams.begin();
     286                                param != otypeParams.end(); ++param ) {
     287                        auto paramType = new TypeInstType( Type::Qualifiers(), (*param)->get_name(), *param );
     288                        std::string paramName = mangleType( paramType );
     289                        layoutFnType->get_parameters().push_back( new ObjectDecl( sizeofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType->clone(), 0 ) );
     290                        layoutFnType->get_parameters().push_back( new ObjectDecl( alignofName( paramName ), Type::StorageClasses(), LinkageSpec::Cforall, 0, sizeAlignType->clone(), 0 ) );
    290291                }
    291292        }
     
    742743                                Type * newType = param->clone();
    743744                                if ( env ) env->apply( newType );
    744                                 ObjectDecl *newObj = ObjectDecl::newObject( tempNamer.newName(), newType, nullptr );
     745                                ObjectDecl *newObj = ObjectDecl::newObject(
     746                                        tempNamer.newName(), newType, nullptr );
    745747                                newObj->get_type()->get_qualifiers() = Type::Qualifiers(); // TODO: is this right???
    746748                                stmtsToAddBefore.push_back( new DeclStmt( newObj ) );
     
    862864                        // do not carry over attributes to real type parameters/return values
    863865                        for ( DeclarationWithType * dwt : realType->parameters ) {
    864                                 deleteAll( dwt->get_type()->attributes );
    865866                                dwt->get_type()->attributes.clear();
    866867                        }
    867868                        for ( DeclarationWithType * dwt : realType->returnVals ) {
    868                                 deleteAll( dwt->get_type()->attributes );
    869869                                dwt->get_type()->attributes.clear();
    870870                        }
     
    987987                        } // if
    988988                        appExpr->get_args().clear();
    989                         delete appExpr;
    990989                        return addAssign;
    991990                }
     
    10181017                                                } // if
    10191018                                                if ( baseType1 || baseType2 ) {
    1020                                                         delete ret->get_result();
    10211019                                                        ret->set_result( appExpr->get_result()->clone() );
    10221020                                                        if ( appExpr->get_env() ) {
     
    10251023                                                        } // if
    10261024                                                        appExpr->get_args().clear();
    1027                                                         delete appExpr;
    10281025                                                        return ret;
    10291026                                                } // if
     
    10351032                                                        Expression *ret = appExpr->get_args().front();
    10361033                                                        // fix expr type to remove pointer
    1037                                                         delete ret->get_result();
    10381034                                                        ret->set_result( appExpr->get_result()->clone() );
    10391035                                                        if ( appExpr->get_env() ) {
     
    10421038                                                        } // if
    10431039                                                        appExpr->get_args().clear();
    1044                                                         delete appExpr;
    10451040                                                        return ret;
    10461041                                                } // if
     
    11821177                                                Expression *ret = expr->args.front();
    11831178                                                expr->args.clear();
    1184                                                 delete expr;
    11851179                                                return ret;
    11861180                                        } // if
     
    12161210                        if ( polytype || needs ) {
    12171211                                Expression *ret = addrExpr->arg;
    1218                                 delete ret->result;
    12191212                                ret->result = addrExpr->result->clone();
    12201213                                addrExpr->arg = nullptr;
    1221                                 delete addrExpr;
    12221214                                return ret;
    12231215                        } else {
     
    12291221                        if ( retval && returnStmt->expr ) {
    12301222                                assert( returnStmt->expr->result && ! returnStmt->expr->result->isVoid() );
    1231                                 delete returnStmt->expr;
    12321223                                returnStmt->expr = nullptr;
    12331224                        } // if
     
    12721263                                }
    12731264                        }
    1274 //  deleteAll( functions );
    12751265                }
    12761266
     
    12921282                        for ( Declaration * param : functionDecl->type->parameters ) {
    12931283                                if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( param ) ) {
    1294                                         delete obj->init;
    12951284                                        obj->init = nullptr;
    12961285                                }
     
    13401329                        std::list< DeclarationWithType *> inferredParams;
    13411330                        // size/align/offset parameters may not be used in body, pass along with unused attribute.
    1342                         ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
    1343                                            { new Attribute( "unused" ) } );
    1344                         ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
    1345                                            new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
    1346                         for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
     1331                        auto newObj = new ObjectDecl(
     1332                                "", Type::StorageClasses(), LinkageSpec::C, 0,
     1333                                new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
     1334                            { new Attribute( "unused" ) } );
     1335                        auto newPtr = new ObjectDecl(
     1336                                "", Type::StorageClasses(), LinkageSpec::C, 0,
     1337                            new PointerType( Type::Qualifiers(),
     1338                                        new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
     1339                        for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin();
     1340                                        tyParm != funcType->get_forall().end(); ++tyParm ) {
    13471341                                ObjectDecl *sizeParm, *alignParm;
    13481342                                // add all size and alignment parameters to parameter list
    13491343                                if ( (*tyParm)->isComplete() ) {
    1350                                         TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm );
    1351                                         std::string parmName = mangleType( &parmType );
    1352 
    1353                                         sizeParm = newObj.clone();
     1344                                        auto parmType = new TypeInstType(
     1345                                                Type::Qualifiers(), (*tyParm)->get_name(), *tyParm );
     1346                                        std::string parmName = mangleType( parmType );
     1347
     1348                                        sizeParm = newObj->clone();
    13541349                                        sizeParm->set_name( sizeofName( parmName ) );
    13551350                                        last = funcType->get_parameters().insert( last, sizeParm );
    13561351                                        ++last;
    13571352
    1358                                         alignParm = newObj.clone();
     1353                                        alignParm = newObj->clone();
    13591354                                        alignParm->set_name( alignofName( parmName ) );
    13601355                                        last = funcType->get_parameters().insert( last, alignParm );
     
    13791374
    13801375                                        ObjectDecl *sizeParm, *alignParm, *offsetParm;
    1381                                         sizeParm = newObj.clone();
     1376                                        sizeParm = newObj->clone();
    13821377                                        sizeParm->set_name( sizeofName( typeName ) );
    13831378                                        last = funcType->get_parameters().insert( last, sizeParm );
    13841379                                        ++last;
    13851380
    1386                                         alignParm = newObj.clone();
     1381                                        alignParm = newObj->clone();
    13871382                                        alignParm->set_name( alignofName( typeName ) );
    13881383                                        last = funcType->get_parameters().insert( last, alignParm );
     
    13921387                                                // NOTE zero-length arrays are illegal in C, so empty structs have no offset array
    13931388                                                if ( ! polyBaseStruct->get_baseStruct()->get_members().empty() ) {
    1394                                                         offsetParm = newPtr.clone();
     1389                                                        offsetParm = newPtr->clone();
    13951390                                                        offsetParm->set_name( offsetofName( typeName ) );
    13961391                                                        last = funcType->get_parameters().insert( last, offsetParm );
     
    14431438                        if ( Type * base = typeDecl->base ) {
    14441439                                // add size/align variables for opaque type declarations
    1445                                 TypeInstType inst( Type::Qualifiers(), typeDecl->name, typeDecl );
    1446                                 std::string typeName = mangleType( &inst );
     1440                                auto inst = new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl );
     1441                                std::string typeName = mangleType( inst );
    14471442                                Type *layoutType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    14481443
     
    15011496                                                        // polymorphic aggregate members should be converted into monomorphic members.
    15021497                                                        // Using char[size_T] here respects the expected sizing rules of an aggregate type.
    1503                                                         Type * newType = polyToMonoType( field->type );
    1504                                                         delete field->type;
    1505                                                         field->type = newType;
     1498                                                        field->type = polyToMonoType( field->type );
    15061499                                                }
    15071500                                        }
     
    15261519                                        stmtsToAddBefore.push_back( new DeclStmt( newBuf ) );
    15271520
    1528                                         delete objectDecl->get_init();
    15291521                                        objectDecl->set_init( new SingleInit( new VariableExpr( newBuf ) ) );
    15301522                                }
     
    16051597                        }
    16061598
    1607                         delete memberType;
    1608                         delete memberExpr;
    16091599                        return newMemberExpr;
    16101600                }
     
    16261616                                                addrExpr->arg = nullptr;
    16271617                                                std::swap( addrExpr->env, ret->env );
    1628                                                 delete addrExpr;
    16291618                                                return ret;
    16301619                                        }
     
    16351624
    16361625                ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) {
    1637                         ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, nullptr, type, init );
     1626                        ObjectDecl *newObj = new ObjectDecl(
     1627                                name, Type::StorageClasses(), LinkageSpec::C, nullptr, type, init );
    16381628                        stmtsToAddBefore.push_back( new DeclStmt( newObj ) );
    16391629                        return newObj;
     
    17681758                       
    17691759                        Expression * gen = genSizeof( ty );
    1770                         if ( gen ) {
    1771                                 delete sizeofExpr;
    1772                                 return gen;
    1773                         } else return sizeofExpr;
     1760                        return gen ? gen : sizeofExpr;
    17741761                }
    17751762
     
    17771764                        Type *ty = alignofExpr->get_isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result();
    17781765                        if ( findGeneric( ty ) ) {
    1779                                 Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) );
    1780                                 delete alignofExpr;
    1781                                 return ret;
     1766                                return new NameExpr( alignofName( mangleType( ty ) ) );
    17821767                        }
    17831768                        return alignofExpr;
     
    17941779                                if ( i == -1 ) return offsetofExpr;
    17951780
    1796                                 Expression *offsetInd = makeOffsetIndex( ty, i );
    1797                                 delete offsetofExpr;
    1798                                 return offsetInd;
     1781                                return makeOffsetIndex( ty, i );
    17991782                        } else if ( dynamic_cast< UnionInstType* >( ty ) ) {
    18001783                                // all union members are at offset zero
    1801                                 delete offsetofExpr;
    18021784                                return new ConstantExpr( Constant::from_ulong( 0 ) );
    18031785                        } else return offsetofExpr;
     
    18391821                        }
    18401822
    1841                         delete offsetPackExpr;
    18421823                        return ret;
    18431824                }
  • src/GenPoly/GenPoly.cc

    r9d5fb67 r1cdfa82  
    441441                Type * newType = arg->clone();
    442442                if ( env ) env->apply( newType );
    443                 std::unique_ptr<Type> manager( newType );
    444443                // if the argument's type is polymorphic, we don't need to box again!
    445444                return ! isPolyType( newType );
  • src/GenPoly/InstantiateGeneric.cc

    r9d5fb67 r1cdfa82  
    5858
    5959                TypeList& operator= ( const TypeList &that ) {
    60                         deleteAll( params );
    61 
    6260                        params.clear();
    6361                        cloneAll( that.params, params );
     
    6765
    6866                TypeList& operator= ( TypeList &&that ) {
    69                         deleteAll( params );
    70 
    7167                        params = std::move( that.params );
    7268
     
    7470                }
    7571
    76                 ~TypeList() { deleteAll( params ); }
     72                ~TypeList() {}
    7773
    7874                bool operator== ( const TypeList& that ) const {
     
    293289        /// Strips the instances's type parameters
    294290        void stripInstParams( ReferenceToType *inst ) {
    295                 deleteAll( inst->get_parameters() );
    296291                inst->get_parameters().clear();
    297292        }
     
    300295                substituteMembers( base->get_members(), baseParams, typeSubs );
    301296
    302                 // xxx - can't delete type parameters because they may have assertions that are used
    303                 // deleteAll( baseParams );
    304297                baseParams.clear();
    305298
     
    380373                        newInst->set_baseStruct( concDecl );
    381374
    382                         delete inst;
    383375                        inst = newInst;
    384376                        break;
     
    390382                }
    391383
    392                 deleteAll( typeSubs );
    393384                return inst;
    394385        }
     
    430421                        newInst->set_baseUnion( concDecl );
    431422
    432                         delete inst;
    433423                        inst = newInst;
    434424                        break;
     
    439429                }
    440430
    441                 deleteAll( typeSubs );
    442431                return inst;
    443432        }
     
    477466                        ResolvExpr::adjustExprType( ret->result ); // pointer decay
    478467                        std::swap( ret->env, memberExpr->env );
    479                         delete memberExpr;
    480468                        return ret;
    481469                }
  • src/GenPoly/Lvalue.cc

    r9d5fb67 r1cdfa82  
    5151                                assertf( base, "expected pointer type in dereference (type was %s)", toString( arg->result ).c_str() );
    5252                                ApplicationExpr * ret = new ApplicationExpr( deref, { arg } );
    53                                 delete ret->result;
    5453                                ret->result = base->clone();
    5554                                ret->result->set_lvalue( true );
     
    176175                                        return ret;
    177176                                }
    178                                 delete result;
    179177                        }
    180178                        return appExpr;
     
    235233                                                        Type * baseType = InitTweak::getPointerBase( arg->result );
    236234                                                        assertf( baseType, "parameter is reference, arg must be pointer or reference: %s", toString( arg->result ).c_str() );
    237                                                         PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() );
    238                                                         delete arg->result;
    239                                                         arg->result = ptrType;
     235                                                        arg->set_result( new PointerType( Type::Qualifiers(), baseType->clone() ) );
    240236                                                        arg = mkDeref( arg );
    241237                                                        // assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );
     
    409405                                }
    410406                                ret->env = castExpr->env;
    411                                 delete ret->result;
    412407                                ret->result = castExpr->result;
    413408                                castExpr->env = nullptr;
    414409                                castExpr->arg = nullptr;
    415410                                castExpr->result = nullptr;
    416                                 delete castExpr;
    417411                                return ret;
    418412                        } else if ( diff < 0 ) {
     
    430424                                }
    431425                                ret->env = castExpr->env;
    432                                 delete ret->result;
    433426                                ret->result = castExpr->result;
    434427                                ret->result->set_lvalue( true ); // ensure result is lvalue
     
    436429                                castExpr->arg = nullptr;
    437430                                castExpr->result = nullptr;
    438                                 delete castExpr;
    439431                                return ret;
    440432                        } else {
     
    451443                                        castExpr->arg = nullptr;
    452444                                        std::swap( castExpr->env, ret->env );
    453                                         delete castExpr;
    454445                                        return ret;
    455446                                }
     
    462453                        Type::Qualifiers qualifiers = refType->get_qualifiers();
    463454                        refType->base = nullptr;
    464                         delete refType;
    465455                        return new PointerType( qualifiers, base );
    466456                }
     
    474464                                ret->env = expr->env;
    475465                                expr->env = nullptr;
    476                                 delete expr;
    477466                                return ret;
    478467                        } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( arg ) ) {
     
    483472                                ret->env = expr->env;
    484473                                expr->env = nullptr;
    485                                 delete expr;
    486474
    487475                                // conditional expr type may not be either of the argument types, need to unify
     
    516504                                        arg0 = nullptr;
    517505                                        addrExpr->env = nullptr;
    518                                         delete addrExpr;
    519506                                        return ret;
    520507                                }
     
    546533                                                addrExpr->arg = nullptr;
    547534                                                appExpr->env = nullptr;
    548                                                 delete appExpr;
    549535                                                return ret;
    550536                                        }
  • src/GenPoly/ScrubTyVars.cc

    r9d5fb67 r1cdfa82  
    2828                if ( ! tyVars ) {
    2929                        if ( typeInst->get_isFtype() ) {
    30                                 delete typeInst;
    31                                 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     30                                return new PointerType{ Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) };
    3231                        } else {
    33                                 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
    34                                 delete typeInst;
    35                                 return ret;
     32                                return new PointerType{ Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) };
    3633                        }
    3734                }
     
    4239                          case TypeDecl::Dtype:
    4340                          case TypeDecl::Ttype:
    44                                 {
    45                                         PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
    46                                         delete typeInst;
    47                                         return ret;
    48                                 }
     41                                return new PointerType{ Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) };
    4942                          case TypeDecl::Ftype:
    50                                 delete typeInst;
    51                                 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     43                                return new PointerType{ Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) };
    5244                        } // switch
    5345                } // if
     
    5749        Type * ScrubTyVars::mutateAggregateType( Type * ty ) {
    5850                if ( shouldScrub( ty ) ) {
    59                         PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) );
    60                         delete ty;
    61                         return ret;
     51                        return new PointerType{ Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) };
    6252                }
    6353                return ty;
     
    10494                        Type * ret = dynType->acceptMutator( *visitor );
    10595                        ret->get_qualifiers() |= pointer->get_qualifiers();
    106                         pointer->base = nullptr;
    107                         delete pointer;
    10896                        return ret;
    10997                }
  • src/GenPoly/Specialize.cc

    r9d5fb67 r1cdfa82  
    1717#include <iterator>                      // for back_insert_iterator, back_i...
    1818#include <map>                           // for _Rb_tree_iterator, _Rb_tree_...
    19 #include <memory>                        // for unique_ptr
    2019#include <string>                        // for string
    2120#include <tuple>                         // for get
     
    193192                                explodeSimple( new TupleIndexExpr( expr->clone(), i ), out );
    194193                        }
    195                         delete expr;
    196194                } else {
    197195                        // non-tuple type - output a clone of the expression
     
    226224                        env->apply( actualType );
    227225                }
    228                 std::unique_ptr< FunctionType > actualTypeManager( actualType ); // for RAII
    229226                std::list< DeclarationWithType * >::iterator actualBegin = actualType->get_parameters().begin();
    230227                std::list< DeclarationWithType * >::iterator actualEnd = actualType->get_parameters().end();
  • src/InitTweak/FixGlobalInit.cc

    r9d5fb67 r1cdfa82  
    5757                GlobalFixer & fixer = visitor.pass;
    5858                // don't need to include function if it's empty
    59                 if ( fixer.initFunction->get_statements()->get_kids().empty() ) {
    60                         delete fixer.initFunction;
    61                 } else {
     59                if ( ! fixer.initFunction->get_statements()->get_kids().empty() ) {
    6260                        translationUnit.push_back( fixer.initFunction );
    6361                } // if
    6462
    65                 if ( fixer.destroyFunction->get_statements()->get_kids().empty() ) {
    66                         delete fixer.destroyFunction;
    67                 } else {
     63                if ( ! fixer.destroyFunction->get_statements()->get_kids().empty() ) {
    6864                        translationUnit.push_back( fixer.destroyFunction );
    6965                } // if
     
    130126                                objDecl->set_init( NULL );
    131127                        } // if
    132                         delete ctorInit;
    133128                } // if
    134129        }
  • src/InitTweak/FixInit.cc

    r9d5fb67 r1cdfa82  
    454454                                resolved->env = nullptr;
    455455                        } // if
    456                         delete stmt;
    457456                        if ( TupleAssignExpr * assign = dynamic_cast< TupleAssignExpr * >( resolved ) ) {
    458457                                // fix newly generated StmtExpr
     
    554553                                result = result->clone();
    555554                                env->apply( result );
    556                                 if ( ! InitTweak::isConstructable( result ) ) {
    557                                         delete result;
    558                                         return;
    559                                 }
     555                                if ( ! InitTweak::isConstructable( result ) ) return;
    560556
    561557                                // create variable that will hold the result of the stmt expr
     
    652648                        std::swap( impCpCtorExpr->env, callExpr->env );
    653649                        assert( impCpCtorExpr->env == nullptr );
    654                         delete impCpCtorExpr;
    655650
    656651                        if ( returnDecl ) {
     
    711706                        if ( unqMap.count( unqExpr->get_id() ) ) {
    712707                                // take data from other UniqueExpr to ensure consistency
    713                                 delete unqExpr->get_expr();
    714708                                unqExpr->set_expr( unqMap[unqExpr->get_id()]->get_expr()->clone() );
    715                                 delete unqExpr->get_result();
    716709                                unqExpr->set_result( maybeClone( unqExpr->get_expr()->get_result() ) );
    717710                                if ( unqCount[ unqExpr->get_id() ] == 0 ) {  // insert destructor after the last use of the unique expression
     
    824817                                                        // create a new object which is never used
    825818                                                        static UniqueName dummyNamer( "_dummy" );
    826                                                         ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );
    827                                                         delete ctorInit;
    828                                                         return dummy;
     819                                                        return new ObjectDecl{
     820                                                                dummyNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0,
     821                                                                new PointerType{ Type::Qualifiers(), new VoidType( Type::Qualifiers() ) },
     822                                                                0, std::list< Attribute * >{ new Attribute("unused") } };
    829823                                                }
    830824                                        } else {
     
    852846                                        objDecl->init = nullptr;
    853847                                } // if
    854                                 delete ctorInit;
    855848                        } // if
    856849                        return objDecl;
     
    12281221                        ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), callExpr->args.front()->result->clone(), nullptr );
    12291222                        declsToAddBefore.push_back( tmp );
    1230                         delete ctorExpr;
    12311223
    12321224                        // build assignment and replace constructor's first argument with new temporary
     
    12371229                        // resolve assignment and dispose of new env
    12381230                        ResolvExpr::findVoidExpression( assign, indexer );
    1239                         delete assign->env;
    12401231                        assign->env = nullptr;
    12411232
  • src/InitTweak/GenInit.cc

    r9d5fb67 r1cdfa82  
    258258                                        // generic parameters should not play a role in determining whether a generic type is constructed - construct all generic types, so that
    259259                                        // polymorphic constructors make generic types managed types
    260                                         StructInstType inst( Type::Qualifiers(), aggregateDecl );
    261                                         managedTypes.insert( SymTab::Mangler::mangleConcrete( &inst ) );
     260                                        auto inst = new StructInstType( Type::Qualifiers(), aggregateDecl );
     261                                        managedTypes.insert( SymTab::Mangler::mangleConcrete( inst ) );
    262262                                        break;
    263263                                }
  • src/InitTweak/InitTweak.cc

    r9d5fb67 r1cdfa82  
    55#include <memory>                  // for __shared_ptr
    66
     7#include "Common/GC.h"             // for new_static_root
    78#include "Common/PassVisitor.h"
    89#include "Common/SemanticError.h"  // for SemanticError
     
    122123        public:
    123124                ExprImpl( Expression * expr ) : arg( expr ) {}
    124                 virtual ~ExprImpl() { delete arg; }
     125                virtual ~ExprImpl() = default;
    125126
    126127                virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
     
    166167
    167168        void InitExpander::clearArrayIndices() {
    168                 deleteAll( indices );
    169169                indices.clear();
    170170        }
     
    263263                build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) );
    264264                if ( block->get_kids().empty() ) {
    265                         delete block;
    266265                        return nullptr;
    267266                } else {
     
    525524                        // This operator could easily exist as a real function, but it's tricky because nothing should resolve to this function.
    526525                        TypeDecl * td = new TypeDecl( "T", noStorageClasses, nullptr, TypeDecl::Dtype, true );
    527                         assign = new FunctionDecl( "?=?", noStorageClasses, LinkageSpec::Intrinsic, SymTab::genAssignType( new TypeInstType( noQualifiers, td->name, td ) ), nullptr );
     526                        assign = new_static_root<FunctionDecl>(
     527                                "?=?", noStorageClasses, LinkageSpec::Intrinsic,
     528                                SymTab::genAssignType( new TypeInstType( noQualifiers, td->name, td ) ), nullptr );
    528529                }
    529530                if ( dynamic_cast< ReferenceType * >( dst->result ) ) {
  • src/MakeLibCfa.cc

    r9d5fb67 r1cdfa82  
    6565                struct ZeroOneReplacer {
    6666                        ZeroOneReplacer( Type * t ) : type( t ) {}
    67                         ~ZeroOneReplacer() { delete type; }
    6867                        Type * type = nullptr;
    6968
    7069                        Type * common( Type * t ) {
    7170                                if ( ! type ) return t;
    72                                 delete t;
    7371                                return type->clone();
    7472                        }
  • src/Makefile.in

    r9d5fb67 r1cdfa82  
    163163        Common/driver_cfa_cpp-UniqueName.$(OBJEXT) \
    164164        Common/driver_cfa_cpp-DebugMalloc.$(OBJEXT) \
     165        Common/driver_cfa_cpp-GC.$(OBJEXT) \
    165166        Common/driver_cfa_cpp-Assert.$(OBJEXT) \
    166167        ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) \
     
    249250        SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \
    250251        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
     252        SynTree/driver_cfa_cpp-BaseSyntaxNode.$(OBJEXT) \
    251253        SynTree/driver_cfa_cpp-DeclReplacer.$(OBJEXT) \
    252254        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
     
    485487        CodeTools/TrackLoc.cc Concurrency/Keywords.cc \
    486488        Concurrency/Waitfor.cc Common/SemanticError.cc \
    487         Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \
    488         ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
    489         ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
    490         ControlStruct/ForExprMutator.cc \
     489        Common/UniqueName.cc Common/DebugMalloc.cc Common/GC.cc \
     490        Common/Assert.cc ControlStruct/LabelGenerator.cc \
     491        ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \
     492        ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \
    491493        ControlStruct/ExceptTranslate.cc GenPoly/Box.cc \
    492494        GenPoly/GenPoly.cc GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc \
     
    526528        SynTree/NamedTypeDecl.cc SynTree/TypeDecl.cc \
    527529        SynTree/Initializer.cc SynTree/TypeSubstitution.cc \
    528         SynTree/Attribute.cc SynTree/DeclReplacer.cc \
    529         Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
    530         Tuples/Explode.cc Virtual/ExpandCasts.cc
     530        SynTree/Attribute.cc SynTree/BaseSyntaxNode.cc \
     531        SynTree/DeclReplacer.cc Tuples/TupleAssignment.cc \
     532        Tuples/TupleExpansion.cc Tuples/Explode.cc \
     533        Virtual/ExpandCasts.cc
    531534MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    532535        ${cfa_cpplib_PROGRAMS}}
     
    670673        Common/$(DEPDIR)/$(am__dirstamp)
    671674Common/driver_cfa_cpp-DebugMalloc.$(OBJEXT): Common/$(am__dirstamp) \
     675        Common/$(DEPDIR)/$(am__dirstamp)
     676Common/driver_cfa_cpp-GC.$(OBJEXT): Common/$(am__dirstamp) \
    672677        Common/$(DEPDIR)/$(am__dirstamp)
    673678Common/driver_cfa_cpp-Assert.$(OBJEXT): Common/$(am__dirstamp) \
     
    912917SynTree/driver_cfa_cpp-Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \
    913918        SynTree/$(DEPDIR)/$(am__dirstamp)
     919SynTree/driver_cfa_cpp-BaseSyntaxNode.$(OBJEXT):  \
     920        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    914921SynTree/driver_cfa_cpp-DeclReplacer.$(OBJEXT):  \
    915922        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
     
    973980@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Assert.Po@am__quote@
    974981@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-DebugMalloc.Po@am__quote@
     982@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-GC.Po@am__quote@
    975983@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@
    976984@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@
     
    10351043@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-AttrType.Po@am__quote@
    10361044@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Attribute.Po@am__quote@
     1045@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Po@am__quote@
    10371046@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-BasicType.Po@am__quote@
    10381047@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-CommaExpr.Po@am__quote@
     
    12941303@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-DebugMalloc.obj `if test -f 'Common/DebugMalloc.cc'; then $(CYGPATH_W) 'Common/DebugMalloc.cc'; else $(CYGPATH_W) '$(srcdir)/Common/DebugMalloc.cc'; fi`
    12951304
     1305Common/driver_cfa_cpp-GC.o: Common/GC.cc
     1306@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-GC.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo -c -o Common/driver_cfa_cpp-GC.o `test -f 'Common/GC.cc' || echo '$(srcdir)/'`Common/GC.cc
     1307@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo Common/$(DEPDIR)/driver_cfa_cpp-GC.Po
     1308@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Common/GC.cc' object='Common/driver_cfa_cpp-GC.o' libtool=no @AMDEPBACKSLASH@
     1309@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1310@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-GC.o `test -f 'Common/GC.cc' || echo '$(srcdir)/'`Common/GC.cc
     1311
     1312Common/driver_cfa_cpp-GC.obj: Common/GC.cc
     1313@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-GC.obj -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo -c -o Common/driver_cfa_cpp-GC.obj `if test -f 'Common/GC.cc'; then $(CYGPATH_W) 'Common/GC.cc'; else $(CYGPATH_W) '$(srcdir)/Common/GC.cc'; fi`
     1314@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo Common/$(DEPDIR)/driver_cfa_cpp-GC.Po
     1315@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Common/GC.cc' object='Common/driver_cfa_cpp-GC.obj' libtool=no @AMDEPBACKSLASH@
     1316@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1317@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Common/driver_cfa_cpp-GC.obj `if test -f 'Common/GC.cc'; then $(CYGPATH_W) 'Common/GC.cc'; else $(CYGPATH_W) '$(srcdir)/Common/GC.cc'; fi`
     1318
    12961319Common/driver_cfa_cpp-Assert.o: Common/Assert.cc
    12971320@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Common/driver_cfa_cpp-Assert.o -MD -MP -MF Common/$(DEPDIR)/driver_cfa_cpp-Assert.Tpo -c -o Common/driver_cfa_cpp-Assert.o `test -f 'Common/Assert.cc' || echo '$(srcdir)/'`Common/Assert.cc
     
    24972520@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    24982521@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Attribute.obj `if test -f 'SynTree/Attribute.cc'; then $(CYGPATH_W) 'SynTree/Attribute.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Attribute.cc'; fi`
     2522
     2523SynTree/driver_cfa_cpp-BaseSyntaxNode.o: SynTree/BaseSyntaxNode.cc
     2524@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-BaseSyntaxNode.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Tpo -c -o SynTree/driver_cfa_cpp-BaseSyntaxNode.o `test -f 'SynTree/BaseSyntaxNode.cc' || echo '$(srcdir)/'`SynTree/BaseSyntaxNode.cc
     2525@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Po
     2526@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/BaseSyntaxNode.cc' object='SynTree/driver_cfa_cpp-BaseSyntaxNode.o' libtool=no @AMDEPBACKSLASH@
     2527@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2528@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-BaseSyntaxNode.o `test -f 'SynTree/BaseSyntaxNode.cc' || echo '$(srcdir)/'`SynTree/BaseSyntaxNode.cc
     2529
     2530SynTree/driver_cfa_cpp-BaseSyntaxNode.obj: SynTree/BaseSyntaxNode.cc
     2531@am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-BaseSyntaxNode.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Tpo -c -o SynTree/driver_cfa_cpp-BaseSyntaxNode.obj `if test -f 'SynTree/BaseSyntaxNode.cc'; then $(CYGPATH_W) 'SynTree/BaseSyntaxNode.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/BaseSyntaxNode.cc'; fi`
     2532@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Po
     2533@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/BaseSyntaxNode.cc' object='SynTree/driver_cfa_cpp-BaseSyntaxNode.obj' libtool=no @AMDEPBACKSLASH@
     2534@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2535@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-BaseSyntaxNode.obj `if test -f 'SynTree/BaseSyntaxNode.cc'; then $(CYGPATH_W) 'SynTree/BaseSyntaxNode.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/BaseSyntaxNode.cc'; fi`
    24992536
    25002537SynTree/driver_cfa_cpp-DeclReplacer.o: SynTree/DeclReplacer.cc
  • src/Parser/DeclarationNode.cc

    r9d5fb67 r1cdfa82  
    10091009                                        obj->location = cur->location;
    10101010                                        * out++ = obj;
    1011                                         delete agg;
    10121011                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    10131012                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
  • src/Parser/ExpressionNode.cc

    r9d5fb67 r1cdfa82  
    407407        Type * targetType = maybeMoveBuildType( decl_node );
    408408        if ( dynamic_cast< VoidType * >( targetType ) ) {
    409                 delete targetType;
    410409                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
    411410        } else {
     
    435434
    436435Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
    437         Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );
    438         delete member;
    439         return ret;
     436        return new UntypedOffsetofExpr{ maybeMoveBuildType( decl_node ), member->get_name() };
    440437} // build_offsetOf
    441438
  • src/Parser/ParseNode.h

    r9d5fb67 r1cdfa82  
    124124
    125125        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    126                 os << expr.get() << std::endl;
     126                os << expr << std::endl;
    127127        }
    128128        void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    129129
    130130        template<typename T>
    131         bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
    132 
    133         Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
     131        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr); }
     132
     133        Expression * build() const { return expr; }
    134134  private:
    135135        bool extension = false;
    136         std::unique_ptr<Expression> expr;
     136        Expression* expr;
    137137}; // ExpressionNode
    138138
     
    360360
    361361        virtual StatementNode * clone() const final { assert( false ); return nullptr; }
    362         Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }
     362        Statement * build() const { return stmt; }
    363363
    364364        virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) {
     
    372372
    373373        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    374                 os << stmt.get() << std::endl;
     374                os << stmt << std::endl;
    375375        }
    376376  private:
    377         std::unique_ptr<Statement> stmt;
     377        Statement* stmt;
    378378}; // StatementNode
    379379
  • src/Parser/StatementNode.cc

    r9d5fb67 r1cdfa82  
    1616#include <cassert>                 // for assert, strict_dynamic_cast, assertf
    1717#include <list>                    // for list
    18 #include <memory>                  // for unique_ptr
    1918#include <string>                  // for string
    2019
     
    5049                agg = decl;
    5150        } // if
    52         stmt.reset( new DeclStmt( maybeMoveBuild< Declaration >(agg) ) );
     51        stmt = new DeclStmt{ maybeMoveBuild< Declaration >(agg) };
    5352} // StatementNode::StatementNode
    5453
     
    5857        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    5958                StatementNode *node = strict_dynamic_cast< StatementNode * >(curr);
    60                 assert( dynamic_cast< CaseStmt * >(node->stmt.get()) );
     59                assert( dynamic_cast< CaseStmt * >(node->stmt) );
    6160                prev = curr;
    6261        } // for
     
    6665        buildMoveList( stmt, stmts );
    6766        // splice any new Statements to end of current Statements
    68         CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt.get());
     67        CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt);
    6968        caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts );
    7069        return this;
  • src/ResolvExpr/AdjustExprType.cc

    r9d5fb67 r1cdfa82  
    6666
    6767        Type * AdjustExprType::postmutate( ArrayType * arrayType ) {
    68                 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base );
    69                 arrayType->base = nullptr;
    70                 delete arrayType;
    71                 return pointerType;
     68                return new PointerType{ arrayType->get_qualifiers(), arrayType->base };
    7269        }
    7370
    7471        Type * AdjustExprType::postmutate( FunctionType * functionType ) {
    75                 return new PointerType( Type::Qualifiers(), functionType );
     72                return new PointerType{ Type::Qualifiers(), functionType };
    7673        }
    7774
     
    8077                if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    8178                        if ( eqvClass.data.kind == TypeDecl::Ftype ) {
    82                                 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    83                                 return pointerType;
     79                                return new PointerType{ Type::Qualifiers(), typeInst };
    8480                        }
    8581                } else if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) {
    8682                        if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) {
    8783                                if ( tyDecl->get_kind() == TypeDecl::Ftype ) {
    88                                         PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    89                                         return pointerType;
     84                                        return new PointerType{ Type::Qualifiers(), typeInst };
    9085                                } // if
    9186                        } // if
  • src/ResolvExpr/Alternative.cc

    r9d5fb67 r1cdfa82  
    2020#include <utility>                       // for move
    2121
     22#include "Common/GC.h"
     23#include "Common/PassVisitor.h"
    2224#include "Common/utility.h"              // for maybeClone
    2325#include "ResolvExpr/Cost.h"             // for Cost, Cost::zero, operator<<
    2426#include "ResolvExpr/TypeEnvironment.h"  // for TypeEnvironment
    2527#include "SynTree/Expression.h"          // for Expression
     28#include "SynTree/GcTracer.h"
    2629#include "SynTree/Type.h"                // for Type
    2730
     
    3437        Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost, const Cost &cvtCost )
    3538                : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ) {}
    36 
    37         Alternative::Alternative( const Alternative &other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( maybeClone( other.expr ) ), env( other.env ) {
    38         }
    39 
    40         Alternative &Alternative::operator=( const Alternative &other ) {
    41                 if ( &other == this ) return *this;
    42                 delete expr;
    43                 cost = other.cost;
    44                 cvtCost = other.cvtCost;
    45                 expr = maybeClone( other.expr );
    46                 env = other.env;
    47                 return *this;
    48         }
    49 
    50         Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env ) {
    51                 other.expr = nullptr;
    52         }
    53 
    54         Alternative & Alternative::operator=( Alternative && other ) {
    55                 if ( &other == this )  return *this;
    56                 delete expr;
    57                 cost = other.cost;
    58                 cvtCost = other.cvtCost;
    59                 expr = other.expr;
    60                 env = other.env;
    61                 other.expr = nullptr;
    62                 return *this;
    63         }
    64 
    65         Alternative::~Alternative() {
    66                 delete expr;
    67         }
    6839
    6940        void Alternative::print( std::ostream &os, Indenter indent ) const {
     
    9667        }
    9768
     69        const GC& operator<< ( const GC& gc, const Alternative& alt ) {
     70                PassVisitor<GcTracer> tracer{ gc };
     71                maybeAccept( alt.expr, tracer );
     72                tracer << alt.env;
     73                return gc;
     74        }
     75
    9876} // namespace ResolvExpr
    9977
  • src/ResolvExpr/Alternative.h

    r9d5fb67 r1cdfa82  
    2424class Expression;
    2525
     26class GC;
     27
    2628namespace ResolvExpr {
    2729        struct Alternative {
     
    2931                Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost );
    3032                Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost, const Cost &cvtCost );
    31                 Alternative( const Alternative &other );
    32                 Alternative &operator=( const Alternative &other );
    33                 Alternative( Alternative && other );
    34                 Alternative &operator=( Alternative && other );
    35                 ~Alternative();
     33                Alternative( const Alternative &other ) = default;
     34                Alternative &operator=( const Alternative &other ) = default;
    3635
    3736                void print( std::ostream &os, Indenter indent = {} ) const;
    3837
    39                 /// Returns the stored expression, but released from management of this Alternative
    40                 Expression* release_expr() {
    41                         Expression* tmp = expr;
    42                         expr = nullptr;
    43                         return tmp;
    44                 }
    45 
    4638                Cost cost;
    4739                Cost cvtCost;
    48                 Expression *expr;
     40                Expression * expr;
    4941                TypeEnvironment env;
    5042        };
     
    6254                return os;
    6355        }
     56
     57        const GC& operator<< ( const GC&, const Alternative& );
    6458} // namespace ResolvExpr
    6559
  • src/ResolvExpr/AlternativeFinder.cc

    r9d5fb67 r1cdfa82  
    2121#include <list>                    // for _List_iterator, list, _List_const_...
    2222#include <map>                     // for _Rb_tree_iterator, map, _Rb_tree_c...
    23 #include <memory>                  // for allocator_traits<>::value_type, unique_ptr
     23#include <memory>                  // for allocator_traits<>::value_type
    2424#include <utility>                 // for pair
    2525#include <vector>                  // for vector
     
    3535#include "ResolveTypeof.h"         // for resolveTypeof
    3636#include "Resolver.h"              // for resolveStmtExpr
     37#include "Common/GC.h"             // for new_static_root
    3738#include "SymTab/Indexer.h"        // for Indexer
    3839#include "SymTab/Mangler.h"        // for Mangler
     
    101102                void addAnonConversions( const Alternative & alt );
    102103                /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member
    103                 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     104                template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string & name );
    104105                /// Adds alternatives for member expressions where the left side has tuple type
    105106                void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member );
     
    165166                                        candidate->env.apply( newType );
    166167                                        mangleName = SymTab::Mangler::mangle( newType );
    167                                         delete newType;
    168168                                }
    169169                                std::map< std::string, PruneStruct >::iterator mapPlace = selected.find( mangleName );
     
    297297                // adds anonymous member interpretations whenever an aggregate value type is seen.
    298298                // it's okay for the aggregate expression to have reference type -- cast it to the base type to treat the aggregate as the referenced value
    299                 std::unique_ptr<Expression> aggrExpr( alt.expr->clone() );
     299                Expression* aggrExpr = alt.expr->clone();
    300300                alt.env.apply( aggrExpr->get_result() );
    301301                Type * aggrType = aggrExpr->get_result();
    302302                if ( dynamic_cast< ReferenceType * >( aggrType ) ) {
    303303                        aggrType = aggrType->stripReferences();
    304                         aggrExpr.reset( new CastExpr( aggrExpr.release(), aggrType->clone() ) );
     304                        aggrExpr = new CastExpr{ aggrExpr, aggrType->clone() };
    305305                }
    306306
    307307                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
    308                         NameExpr nameExpr( "" );
    309                         addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     308                        addAggMembers( structInst, aggrExpr, alt.cost+Cost::safe, alt.env, "" );
    310309                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->get_result() ) ) {
    311                         NameExpr nameExpr( "" );
    312                         addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, &nameExpr );
     310                        addAggMembers( unionInst, aggrExpr, alt.cost+Cost::safe, alt.env, "" );
    313311                } // if
    314312        }
    315313
    316314        template< typename StructOrUnionType >
    317         void AlternativeFinder::Finder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) {
    318                 // by this point, member must be a name expr
    319                 NameExpr * nameExpr = dynamic_cast< NameExpr * >( member );
    320                 if ( ! nameExpr ) return;
    321                 const std::string & name = nameExpr->get_name();
     315        void AlternativeFinder::Finder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string & name ) {
    322316                std::list< Declaration* > members;
    323317                aggInst->lookup( name, members );
     
    568562
    569563                                Expression *varExpr = data.combine( newerAlt.cvtCost );
    570                                 delete varExpr->get_result();
    571564                                varExpr->set_result( adjType->clone() );
    572565                                PRINT(
     
    585578                                (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    586579                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, /*newNeedParents,*/ level, indexer, out );
    587                         } else {
    588                                 delete adjType;
    589580                        }
    590581                }
     
    634625        struct ArgPack {
    635626                std::size_t parent;                ///< Index of parent pack
    636                 std::unique_ptr<Expression> expr;  ///< The argument stored here
     627                Expression* expr;                  ///< The argument stored here
    637628                Cost cost;                         ///< The cost of this argument
    638629                TypeEnvironment env;               ///< Environment for this pack
     
    681672                        std::list<Expression*> exprs;
    682673                        const ArgPack* pack = this;
    683                         if ( expr ) { exprs.push_front( expr.release() ); }
     674                        if ( expr ) { exprs.push_front( expr ); }
    684675                        while ( pack->tupleStart == 0 ) {
    685676                                pack = &packs[pack->parent];
     
    688679                        }
    689680                        // reset pack to appropriate tuple
    690                         expr.reset( new TupleExpr( exprs ) );
     681                        expr = new TupleExpr{ exprs };
    691682                        tupleStart = pack->tupleStart - 1;
    692683                        parent = pack->parent;
     
    740731
    741732                                                results.emplace_back(
    742                                                         i, expl.exprs[results[i].nextExpl].get(), copy(results[i].env),
     733                                                        i, expl.exprs[results[i].nextExpl], copy(results[i].env),
    743734                                                        copy(results[i].need), copy(results[i].have),
    744735                                                        copy(results[i].openVars), nextArg, nTuples, Cost::zero, nextExpl,
     
    761752                                                        newResult.parent = i;
    762753                                                        std::list<Expression*> emptyList;
    763                                                         newResult.expr.reset( new TupleExpr( emptyList ) );
     754                                                        newResult.expr = new TupleExpr{ emptyList };
    764755                                                        argType = newResult.expr->get_result();
    765756                                                } else {
     
    768759                                                        newResult.cost = results[i].cost;
    769760                                                        newResult.tupleStart = results[i].tupleStart;
    770                                                         newResult.expr.reset( results[i].expr->clone() );
     761                                                        newResult.expr = results[i].expr->clone();
    771762                                                        argType = newResult.expr->get_result();
    772763
     
    818809                                                // add new result
    819810                                                results.emplace_back(
    820                                                         i, expl.exprs.front().get(), move(env), copy(results[i].need),
     811                                                        i, expl.exprs.front(), move(env), copy(results[i].need),
    821812                                                        copy(results[i].have), move(openVars), nextArg + 1,
    822813                                                        nTuples, expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     
    844835                        if ( results[i].hasExpl() ) {
    845836                                const ExplodedActual& expl = results[i].getExpl( args );
    846                                 Expression* expr = expl.exprs[results[i].nextExpl].get();
     837                                Expression* expr = expl.exprs[results[i].nextExpl];
    847838
    848839                                TypeEnvironment env = results[i].env;
     
    915906
    916907                                // consider only first exploded actual
    917                                 Expression* expr = expl.exprs.front().get();
     908                                Expression* expr = expl.exprs.front();
    918909                                Type* actualType = expr->get_result()->clone();
    919910
     
    10181009
    10191010                                                results.emplace_back(
    1020                                                         i, expl.exprs[results[i].nextExpl].get(), copy(results[i].env),
     1011                                                        i, expl.exprs[results[i].nextExpl], copy(results[i].env),
    10211012                                                        copy(results[i].need), copy(results[i].have),
    10221013                                                        copy(results[i].openVars), nextArg, 0, Cost::zero, nextExpl,
     
    10541045                                                // add new result
    10551046                                                results.emplace_back(
    1056                                                         i, expl.exprs.front().get(), move(env), copy(results[i].need),
     1047                                                        i, expl.exprs.front(), move(env), copy(results[i].need),
    10571048                                                        copy(results[i].have), move(openVars), nextArg + 1, 0,
    10581049                                                        expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     
    10881079
    10891080                // find function operators
    1090                 static NameExpr *opExpr = new NameExpr( "?()" );
     1081                static auto *opExpr = new_static_root<NameExpr>( "?()" );
    10911082                AlternativeFinder funcOpFinder( indexer, env );
    10921083                // it's ok if there aren't any defined function ops
    1093                 funcOpFinder.maybeFind( opExpr);
     1084                funcOpFinder.maybeFind( opExpr );
    10941085                PRINT(
    10951086                        std::cerr << "known function ops:" << std::endl;
     
    12641255                                componentExprs.push_back( restructureCast( idx, toType->getComponent( i ), isGenerated ) );
    12651256                        }
    1266                         delete argExpr;
    12671257                        assert( componentExprs.size() > 0 );
    12681258                        // produce the tuple of casts
     
    13431333        }
    13441334
     1335        namespace {
     1336                /// Gets name from untyped member expression (member must be NameExpr)
     1337                const std::string& get_member_name( UntypedMemberExpr *memberExpr ) {
     1338                        NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() );
     1339                        assert( nameExpr );
     1340                        return nameExpr->get_name();
     1341                }
     1342        }
     1343
    13451344        void AlternativeFinder::Finder::postvisit( UntypedMemberExpr *memberExpr ) {
    13461345                AlternativeFinder funcFinder( indexer, env );
     
    13511350                        Expression * aggrExpr = agg->expr->clone();
    13521351                        referenceToRvalueConversion( aggrExpr, cost );
    1353                         std::unique_ptr<Expression> guard( aggrExpr );
    13541352
    13551353                        // find member of the given type
    13561354                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->get_result() ) ) {
    1357                                 addAggMembers( structInst, aggrExpr, cost, agg->env, memberExpr->get_member() );
     1355                                addAggMembers( structInst, aggrExpr, cost, agg->env, get_member_name(memberExpr) );
    13581356                        } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->get_result() ) ) {
    1359                                 addAggMembers( unionInst, aggrExpr, cost, agg->env, memberExpr->get_member() );
     1357                                addAggMembers( unionInst, aggrExpr, cost, agg->env, get_member_name(memberExpr) );
    13601358                        } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( aggrExpr->get_result() ) ) {
    13611359                                addTupleMembers( tupleType, aggrExpr, cost, agg->env, memberExpr->get_member() );
     
    16021600                        alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) );
    16031601                } // for
    1604                 delete newFirstArg;
    16051602        }
    16061603
  • src/ResolvExpr/ConversionCost.cc

    r9d5fb67 r1cdfa82  
    2020#include <string>                        // for operator==, string
    2121
     22#include "Common/GC.h"                   // for new_static_root
    2223#include "ResolvExpr/Cost.h"             // for Cost
    2324#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass, TypeEnvironment
     
    351352        void ConversionCost::postvisit( EnumInstType * ) {
    352353                static Type::Qualifiers q;
    353                 static BasicType integer( q, BasicType::SignedInt );
    354                 cost = costFunc( &integer, dest, indexer, env );  // safe if dest >= int
     354                static BasicType* integer = new_static_root<BasicType>( q, BasicType::SignedInt );
     355                cost = costFunc( integer, dest, indexer, env );  // safe if dest >= int
    355356                if ( cost < Cost::unsafe ) {
    356357                        cost.incSafe();
  • src/ResolvExpr/ExplodedActual.h

    r9d5fb67 r1cdfa82  
    1616#pragma once
    1717
    18 #include <memory>
    1918#include <vector>
    2019
     
    2928                TypeEnvironment env;
    3029                Cost cost;
    31                 std::vector< std::unique_ptr<Expression> > exprs;
     30                std::vector< Expression* > exprs;
    3231
    3332                ExplodedActual() : env(), cost(Cost::zero), exprs() {}
  • src/ResolvExpr/ResolveTypeof.cc

    r9d5fb67 r1cdfa82  
    7070                        Expression * newExpr = resolveInVoidContext( typeofType->expr, indexer );
    7171                        assert( newExpr->result && ! newExpr->result->isVoid() );
    72                         Type * newType = newExpr->result;
    73                         newExpr->result = nullptr;
    74                         delete typeofType;
    75                         delete newExpr;
    76                         return newType;
     72                        return newExpr->result;
    7773                } // if
    7874                return typeofType;
  • src/ResolvExpr/Resolver.cc

    r9d5fb67 r1cdfa82  
    2222#include "Alternative.h"                 // for Alternative, AltList
    2323#include "AlternativeFinder.h"           // for AlternativeFinder, resolveIn...
     24#include "Common/GC.h"                   // for new_generation, collect_young
    2425#include "Common/PassVisitor.h"          // for PassVisitor
    2526#include "Common/SemanticError.h"        // for SemanticError
     
    139140                                        castExpr->arg = nullptr;
    140141                                        std::swap( expr->env, castExpr->env );
    141                                         delete castExpr;
    142142                                }
    143143                        }
     
    148148                void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) {
    149149                        assertf( untyped, "expected a non-null expression." );
     150
     151                        auto guard = new_generation();  // set up GC generation for this top-level expression
     152
    150153                        TypeEnvironment env;
    151154                        AlternativeFinder finder( indexer, env );
     
    175178                        findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) );
    176179                        if ( winners.size() == 0 ) {
    177                                 SemanticError( untyped, toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: ") );
     180                                SemanticError( untyped, toString(
     181                                        "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""),
     182                                        "expression: ") );
    178183                        } else if ( winners.size() != 1 ) {
    179184                                std::ostringstream stream;
    180                                 stream << "Cannot choose between " << winners.size() << " alternatives for " << kindStr << (kindStr != "" ? " " : "") << "expression\n";
     185                                stream << "Cannot choose between " << winners.size() << " alternatives for "
     186                                        << kindStr << (kindStr != "" ? " " : "") << "expression\n";
    181187                                untyped->print( stream );
    182188                                stream << " Alternatives are:\n";
    183189                                printAlts( winners, stream, 1 );
     190                               
    184191                                SemanticError( untyped->location, stream.str() );
    185192                        }
     
    188195                        Alternative & choice = winners.front();
    189196                        if ( findDeletedExpr( choice.expr ) ) {
    190                                 SemanticError( choice.expr, "Unique best alternative includes deleted identifier in " );
     197                                trace( choice.expr );
     198                                SemanticError( choice.expr,
     199                                        "Unique best alternative includes deleted identifier in " );
    191200                        }
    192201                        alt = std::move( choice );
     202                        trace( alt );
    193203                }
    194204
     
    199209                        findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, adjust, prune, failFast );
    200210                        finishExpr( choice.expr, choice.env, untyped->env );
    201                         delete untyped;
    202211                        untyped = choice.expr;
    203212                        choice.expr = nullptr;
     
    222231                assertf( expr, "expected a non-null expression." );
    223232
    224                 static CastExpr untyped( nullptr ); // cast to void
     233                auto untyped = new CastExpr{ expr }; // cast to void
    225234
    226235                // set up and resolve expression cast to void
    227                 untyped.arg = expr;
    228236                Alternative choice;
    229                 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, true );
     237                findUnfinishedKindExpression( untyped, choice, indexer, "", standardAlternativeFilter, true );
    230238                CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr );
    231239                env = std::move( choice.env );
    232240
    233241                // clean up resolved expression
    234                 Expression * ret = castExpr->arg;
    235                 castExpr->arg = nullptr;
    236 
    237                 // unlink the arg so that it isn't deleted twice at the end of the program
    238                 untyped.arg = nullptr;
    239                 return ret;
     242                return castExpr->arg;
    240243        }
    241244
     
    245248                Expression * newExpr = resolveInVoidContext( untyped, indexer, env );
    246249                finishExpr( newExpr, env, untyped->env );
    247                 delete untyped;
    248250                untyped = newExpr;
    249251        }
     
    423425                        caseStmt->condition = castExpr->arg;
    424426                        castExpr->arg = nullptr;
    425                         delete castExpr;
    426427                }
    427428        }
     
    705706                std::swap( initExpr->env, newExpr->env );
    706707                std::swap( initExpr->inferParams, newExpr->inferParams ) ;
    707                 delete initExpr;
    708708
    709709                // get the actual object's type (may not exactly match what comes back from the resolver due to conversions)
     
    723723                                                        ce->set_arg( nullptr );
    724724                                                        std::swap( ce->env, newExpr->env );
    725                                                         delete ce;
    726725                                                }
    727726                                        }
     
    774773                // could not find valid constructor, or found an intrinsic constructor
    775774                // fall back on C-style initializer
    776                 delete ctorInit->get_ctor();
    777                 ctorInit->set_ctor( NULL );
    778                 delete ctorInit->get_dtor();
    779                 ctorInit->set_dtor( NULL );
     775                ctorInit->set_ctor( nullptr );
     776                ctorInit->set_dtor( nullptr );
    780777                maybeAccept( ctorInit->get_init(), *visitor );
    781778        }
     
    803800
    804801                // found a constructor - can get rid of C-style initializer
    805                 delete ctorInit->init;
    806802                ctorInit->init = nullptr;
    807803
     
    810806                // to clean up generated code.
    811807                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->ctor ) ) {
    812                         delete ctorInit->ctor;
    813808                        ctorInit->ctor = nullptr;
    814809                }
    815810
    816811                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->dtor ) ) {
    817                         delete ctorInit->dtor;
    818812                        ctorInit->dtor = nullptr;
    819813                }
  • src/ResolvExpr/TypeEnvironment.cc

    r9d5fb67 r1cdfa82  
    1919#include <utility>                     // for pair
    2020
     21#include "Common/PassVisitor.h"        // for PassVisitor<GcTracer>
    2122#include "Common/utility.h"            // for maybeClone
     23#include "SynTree/GcTracer.h"          // for PassVisitor<GcTracer>
    2224#include "SynTree/Type.h"              // for Type, FunctionType, Type::Fora...
    2325#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     
    5961        EqvClass &EqvClass::operator=( const EqvClass &other ) {
    6062                if ( this == &other ) return *this;
    61                 delete type;
    6263                initialize( other, *this );
    6364                return *this;
    64         }
    65 
    66         EqvClass::~EqvClass() {
    67                 delete type;
    6865        }
    6966
     
    147144///         std::cerr << " bound to variable " << *theClass->vars.begin() << std::endl;
    148145                                        sub.add( *theVar, newTypeInst );
    149                                         delete newTypeInst;
    150146                                } // if
    151147                        } // for
     
    188184                                        if ( secondClass->type ) {
    189185                                                if ( newClass.type ) {
    190                                                         Type *newType = combineFunc( newClass.type, secondClass->type );
    191                                                         delete newClass.type;
    192                                                         newClass.type = newType;
     186                                                        newClass.type = combineFunc( newClass.type, secondClass->type );
    193187                                                        newClass.allowWidening = newClass.allowWidening && secondClass->allowWidening;
    194188                                                } else {
     
    230224                return out;
    231225        }
     226
     227        PassVisitor<GcTracer> & operator<<( PassVisitor<GcTracer> & gc, const TypeEnvironment & env ) {
     228                for ( const EqvClass & c : env ) {
     229                        maybeAccept( c.type, gc );
     230                }
     231                return gc;
     232        }
    232233} // namespace ResolvExpr
    233234
  • src/ResolvExpr/TypeEnvironment.h

    r9d5fb67 r1cdfa82  
    2626#include "SynTree/Type.h"              // for Type, Type::ForallList
    2727#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     28
     29template< typename Pass >
     30class PassVisitor;
     31class GcTracer;
    2832
    2933namespace ResolvExpr {
     
    6771                EqvClass( const EqvClass &other );
    6872                EqvClass &operator=( const EqvClass &other );
    69                 ~EqvClass();
    7073                void print( std::ostream &os, Indenter indent = {} ) const;
    7174        };
     
    117120
    118121        std::ostream & operator<<( std::ostream & out, const TypeEnvironment & env );
     122
     123        PassVisitor<GcTracer> & operator<<( PassVisitor<GcTracer> & gc, const TypeEnvironment & env );
    119124} // namespace ResolvExpr
    120125
  • src/ResolvExpr/Unify.cc

    r9d5fb67 r1cdfa82  
    1717#include <iterator>               // for back_insert_iterator, back_inserter
    1818#include <map>                    // for _Rb_tree_const_iterator, _Rb_tree_i...
    19 #include <memory>                 // for unique_ptr
    2019#include <set>                    // for set
    2120#include <string>                 // for string, operator==, operator!=, bas...
     
    9998                findOpenVars( newSecond, openVars, closedVars, needAssertions, haveAssertions, true );
    10099
    101                 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    102                 delete newFirst;
    103                 delete newSecond;
    104                 return result;
     100                return unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    105101        }
    106102
     
    123119///   newSecond->print( std::cerr );
    124120///   std::cerr << std::endl;
    125                 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    126                 delete newFirst;
    127                 delete newSecond;
    128                 return result;
     121                return unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    129122        }
    130123
     
    171164                                Type *common = 0;
    172165                                // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
    173                                 std::unique_ptr< Type > newType( curClass.type->clone() );
     166                                Type* newType = curClass.type->clone();
    174167                                newType->get_qualifiers() = typeInst->get_qualifiers();
    175                                 if ( unifyInexact( newType.get(), other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
     168                                if ( unifyInexact( newType, other, env, needAssertions, haveAssertions, openVars, widenMode & WidenMode( curClass.allowWidening, true ), indexer, common ) ) {
    176169                                        if ( common ) {
    177170                                                common->get_qualifiers() = Type::Qualifiers();
    178                                                 delete curClass.type;
    179171                                                curClass.type = common;
    180172                                                env.add( curClass );
     
    239231                                if ( common ) {
    240232                                        common->get_qualifiers() = Type::Qualifiers();
    241                                         delete class1.type;
    242233                                        class1.type = common;
    243234                                } // if
     
    272263                        env.add( newClass );
    273264                } // if
    274                 delete type1;
    275                 delete type2;
    276265                return result;
    277266        }
     
    282271                findOpenVars( type2, openVars, closedVars, needAssertions, haveAssertions, true );
    283272                Type *commonType = 0;
    284                 if ( unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ) ) {
    285                         if ( commonType ) {
    286                                 delete commonType;
    287                         } // if
    288                         return true;
    289                 } else {
    290                         return false;
    291                 } // if
     273                return unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType );
    292274        }
    293275
     
    483465
    484466        template< typename Iterator, typename Func >
    485         std::unique_ptr<Type> combineTypes( Iterator begin, Iterator end, Func & toType ) {
     467        Type* combineTypes( Iterator begin, Iterator end, Func & toType ) {
    486468                std::list< Type * > types;
    487469                for ( ; begin != end; ++begin ) {
     
    489471                        flatten( toType( *begin ), back_inserter( types ) );
    490472                }
    491                 return std::unique_ptr<Type>( new TupleType( Type::Qualifiers(), types ) );
     473                return new TupleType{ Type::Qualifiers(), types };
    492474        }
    493475
     
    504486                        if ( isTtype1 && ! isTtype2 ) {
    505487                                // combine all of the things in list2, then unify
    506                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     488                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    507489                        } else if ( isTtype2 && ! isTtype1 ) {
    508490                                // combine all of the things in list1, then unify
    509                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     491                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    510492                        } else if ( ! unifyExact( t1, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    511493                                return false;
     
    517499                        Type * t1 = (*list1Begin)->get_type();
    518500                        if ( Tuples::isTtype( t1 ) ) {
    519                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     501                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    520502                        } else return false;
    521503                } else if ( list2Begin != list2End ) {
     
    523505                        Type * t2 = (*list2Begin)->get_type();
    524506                        if ( Tuples::isTtype( t2 ) ) {
    525                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     507                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    526508                        } else return false;
    527509                } else {
     
    544526                                        // expand ttype parameter into its actual type
    545527                                        if ( eqvClass.type ) {
    546                                                 delete typeInst;
    547528                                                return eqvClass.type->clone();
    548529                                        }
     
    569550                                dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) );
    570551                        }
    571                         delete dcl;
    572552                }
    573553        }
     
    578558                        // flatten the parameter lists for both functions so that tuple structure
    579559                        // doesn't affect unification. Must be a clone so that the types don't change.
    580                         std::unique_ptr<FunctionType> flatFunc( functionType->clone() );
    581                         std::unique_ptr<FunctionType> flatOther( otherFunction->clone() );
     560                        FunctionType* flatFunc = functionType->clone();
     561                        FunctionType* flatOther = otherFunction->clone();
    582562                        flattenList( flatFunc->get_parameters(), flatFunc->get_parameters(), env );
    583563                        flattenList( flatOther->get_parameters(), flatOther->get_parameters(), env );
     
    720700                        if ( isTtype1 && ! isTtype2 ) {
    721701                                // combine all of the things in list2, then unify
    722                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     702                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    723703                        } else if ( isTtype2 && ! isTtype1 ) {
    724704                                // combine all of the things in list1, then unify
    725                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     705                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    726706                        } else if ( ! unifyExact( t1, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    727707                                return false;
     
    733713                        Type * t1 = *list1Begin;
    734714                        if ( Tuples::isTtype( t1 ) ) {
    735                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     715                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    736716                        } else return false;
    737717                } else if ( list2Begin != list2End ) {
     
    739719                        Type * t2 = *list2Begin;
    740720                        if ( Tuples::isTtype( t2 ) ) {
    741                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     721                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    742722                        } else return false;
    743723                } else {
     
    748728        void Unify::postvisit(TupleType *tupleType) {
    749729                if ( TupleType *otherTuple = dynamic_cast< TupleType* >( type2 ) ) {
    750                         std::unique_ptr<TupleType> flat1( tupleType->clone() );
    751                         std::unique_ptr<TupleType> flat2( otherTuple->clone() );
     730                        TupleType* flat1 = tupleType->clone();
     731                        TupleType* flat2 = otherTuple->clone();
    752732                        std::list<Type *> types1, types2;
    753733
     
    756736                        flat2->acceptMutator( expander );
    757737
    758                         flatten( flat1.get(), back_inserter( types1 ) );
    759                         flatten( flat2.get(), back_inserter( types2 ) );
     738                        flatten( flat1, back_inserter( types1 ) );
     739                        flatten( flat2, back_inserter( types2 ) );
    760740
    761741                        result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer );
  • src/ResolvExpr/Unify.h

    r9d5fb67 r1cdfa82  
    6464        bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
    6565                std::list< Type* > commonTypes;
    66                 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
    67                         deleteAll( commonTypes );
    68                         return true;
    69                 } else {
    70                         return false;
    71                 } // if
     66                return unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes );
    7267        }
    7368
  • src/SymTab/Autogen.cc

    r9d5fb67 r1cdfa82  
    214214        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
    215215                FunctionDecl * decl = functionDecl->clone();
    216                 delete decl->statements;
    217216                decl->statements = nullptr;
    218217                declsToAdd.push_back( decl );
     
    333332                } catch ( SemanticErrorException err ) {
    334333                        // okay if decl does not resolve - that means the function should not be generated
    335                         delete dcl;
    336334                }
    337335        }
     
    373371                        // do not carry over field's attributes to parameter type
    374372                        Type * paramType = field->get_type()->clone();
    375                         deleteAll( paramType->attributes );
    376373                        paramType->attributes.clear();
    377374                        // add a parameter corresponding to this field
     
    383380                        resolve( ctor );
    384381                }
    385                 delete memCtorType;
    386382        }
    387383
     
    511507                        // do not carry over field's attributes to parameter type
    512508                        Type * paramType = field->get_type()->clone();
    513                         deleteAll( paramType->attributes );
    514509                        paramType->attributes.clear();
    515510                        // add a parameter corresponding to this field
     
    524519                        break;
    525520                }
    526                 delete memCtorType;
    527521        }
    528522
     
    594588                // must visit children (enum constants) to add them to the indexer
    595589                if ( enumDecl->has_body() ) {
    596                         EnumInstType enumInst( Type::Qualifiers(), enumDecl->get_name() );
    597                         enumInst.set_baseEnum( enumDecl );
    598                         EnumFuncGenerator gen( &enumInst, data, functionNesting, indexer );
     590                        auto enumInst = new EnumInstType{ Type::Qualifiers(), enumDecl->get_name() };
     591                        enumInst->set_baseEnum( enumDecl );
     592                        EnumFuncGenerator gen( enumInst, data, functionNesting, indexer );
    599593                        generateFunctions( gen, declsToAddAfter );
    600594                }
     
    604598                visit_children = false;
    605599                if ( structDecl->has_body() ) {
    606                         StructInstType structInst( Type::Qualifiers(), structDecl->name );
    607                         structInst.set_baseStruct( structDecl );
     600                        auto structInst = new StructInstType{ Type::Qualifiers(), structDecl->name };
     601                        structInst->set_baseStruct( structDecl );
    608602                        for ( TypeDecl * typeDecl : structDecl->parameters ) {
    609                                 structInst.parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
    610                         }
    611                         StructFuncGenerator gen( structDecl, &structInst, data, functionNesting, indexer );
     603                                structInst->parameters.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->name, typeDecl ) ) );
     604                        }
     605                        StructFuncGenerator gen( structDecl, structInst, data, functionNesting, indexer );
    612606                        generateFunctions( gen, declsToAddAfter );
    613607                } // if
     
    617611                visit_children = false;
    618612                if ( unionDecl->has_body()  ) {
    619                         UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
    620                         unionInst.set_baseUnion( unionDecl );
     613                        auto unionInst = new UnionInstType{ Type::Qualifiers(), unionDecl->get_name() };
     614                        unionInst->set_baseUnion( unionDecl );
    621615                        for ( TypeDecl * typeDecl : unionDecl->get_parameters() ) {
    622                                 unionInst.get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );
    623                         }
    624                         UnionFuncGenerator gen( unionDecl, &unionInst, data, functionNesting, indexer );
     616                                unionInst->get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) );
     617                        }
     618                        UnionFuncGenerator gen( unionDecl, unionInst, data, functionNesting, indexer );
    625619                        generateFunctions( gen, declsToAddAfter );
    626620                } // if
     
    631625                if ( ! typeDecl->base ) return;
    632626
    633                 TypeInstType refType( Type::Qualifiers(), typeDecl->name, typeDecl );
    634                 TypeFuncGenerator gen( typeDecl, &refType, data, functionNesting, indexer );
     627                auto refType = new TypeInstType{ Type::Qualifiers(), typeDecl->name, typeDecl };
     628                TypeFuncGenerator gen( typeDecl, refType, data, functionNesting, indexer );
    635629                generateFunctions( gen, declsToAddAfter );
    636630
  • src/SymTab/Autogen.h

    r9d5fb67 r1cdfa82  
    9797                // return if adding reference fails - will happen on default constructor and destructor
    9898                if ( isReferenceCtorDtor && ! srcParam.addReference() ) {
    99                         delete fExpr;
    10099                        return listInit;
    101100                }
  • src/SymTab/FixFunction.cc

    r9d5fb67 r1cdfa82  
    2828
    2929        DeclarationWithType * FixFunction::postmutate(FunctionDecl *functionDecl) {
    30                 // can't delete function type because it may contain assertions, so transfer ownership to new object
    31                 ObjectDecl *pointer = new ObjectDecl( functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr, new PointerType( Type::Qualifiers(), functionDecl->type ), nullptr, functionDecl->attributes );
    32                 functionDecl->attributes.clear();
    33                 functionDecl->type = nullptr;
    34                 delete functionDecl;
    35                 return pointer;
     30                return new ObjectDecl{
     31                        functionDecl->name, functionDecl->get_storageClasses(), functionDecl->linkage, nullptr,
     32                        new PointerType{ Type::Qualifiers(), functionDecl->type },
     33                        nullptr, functionDecl->attributes };
    3634        }
    3735
     
    4240        Type * FixFunction::postmutate(ArrayType *arrayType) {
    4341                // need to recursively mutate the base type in order for multi-dimensional arrays to work.
    44                 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic );
    45                 arrayType->base = nullptr;
    46                 arrayType->dimension = nullptr;
    47                 delete arrayType;
    48                 return pointerType;
     42                return new PointerType{ arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->isVarLen, arrayType->isStatic };
    4943        }
    5044
  • src/SymTab/Validate.cc

    r9d5fb67 r1cdfa82  
    4848#include "CodeGen/CodeGenerator.h"     // for genName
    4949#include "CodeGen/OperatorTable.h"     // for isCtorDtor, isCtorDtorAssign
     50#include "Common/GC.h"                 // for new_static_root, register_static_root
    5051#include "Common/PassVisitor.h"        // for PassVisitor, WithDeclsToAdd
    5152#include "Common/ScopedMap.h"          // for ScopedMap
     
    199200                void addImplicitTypedef( AggDecl * aggDecl );
    200201
    201                 typedef std::unique_ptr<TypedefDecl> TypedefDeclPtr;
    202                 typedef ScopedMap< std::string, std::pair< TypedefDeclPtr, int > > TypedefMap;
     202                typedef ScopedMap< std::string, std::pair< TypedefDecl*, int > > TypedefMap;
    203203                typedef std::map< std::string, TypeDecl * > TypeDeclMap;
    204204                TypedefMap typedefNames;
     
    373373                        // one void is the only thing in the list; remove it.
    374374                        if ( containsVoid ) {
    375                                 delete dwts.front();
    376375                                dwts.clear();
    377376                        }
     
    500499                                }
    501500                        }
    502                         deleteAll( td->assertions );
    503501                        td->assertions.clear();
    504502                } // for
     
    616614                                        // expand trait instance into all of its members
    617615                                        expandAssertions( traitInst, back_inserter( type->assertions ) );
    618                                         delete traitInst;
    619616                                } else {
    620617                                        // pass other assertions through
     
    688685                        // grab and remember declaration of size_t
    689686                        SizeType = eliminator.pass.typedefNames["size_t"].first->get_base()->clone();
     687                        GC::get().register_static_root( SizeType );
    690688                } else {
    691689                        // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong
    692690                        // eventually should have a warning for this case.
    693                         SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     691                        SizeType =
     692                                new_static_root<BasicType>( Type::Qualifiers(), BasicType::LongUnsignedInt );
    694693                }
    695694                filter( translationUnit, isTypedef, true );
     
    707706                                ret->attributes.splice( ret->attributes.end(), typeInst->attributes );
    708707                        } else {
    709                                 deleteAll( ret->attributes );
    710708                                ret->attributes.clear();
    711709                        }
     
    720718                                mutateAll( rtt->parameters, *visitor );  // recursively fix typedefs on parameters
    721719                        } // if
    722                         delete typeInst;
    723720                        return ret;
    724721                } else {
     
    762759                        }
    763760                } else {
    764                         typedefNames[ tyDecl->get_name() ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );
     761                        typedefNames[ tyDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
    765762                } // if
    766763
     
    806803                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type?
    807804                        // replace the current object declaration with a function declaration
    808                         FunctionDecl * newDecl = new FunctionDecl( objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() );
    809                         objDecl->get_attributes().clear();
    810                         objDecl->set_type( nullptr );
    811                         delete objDecl;
    812                         return newDecl;
     805                        return new FunctionDecl{
     806                                objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(),
     807                                funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() };
    813808                } // if
    814809                return objDecl;
     
    857852                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    858853                        } // if
    859                         TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() ) );
    860                         typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
     854                        TypedefDecl* tyDecl = new TypedefDecl{ aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() };
     855                        typedefNames[ aggDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
    861856                } // if
    862857        }
     
    972967                static UniqueName indexName( "_compLit" );
    973968
    974                 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() );
    975                 compLitExpr->set_result( nullptr );
    976                 compLitExpr->set_initializer( nullptr );
    977                 delete compLitExpr;
     969                ObjectDecl * tempvar = new ObjectDecl{
     970                        indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() };
    978971                declsToAddBefore.push_back( tempvar );                                  // add modified temporary to current block
    979972                return new VariableExpr( tempvar );
     
    10111004                        // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false.
    10121005                        ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
    1013                         deleteAll( retVals );
    10141006                        retVals.clear();
    10151007                        retVals.push_back( newRet );
     
    10521044                        if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( inner->arg ) ) {
    10531045                                if ( labels.count( nameExpr->name ) ) {
    1054                                         Label name = nameExpr->name;
    1055                                         delete addrExpr;
    1056                                         return new LabelAddressExpr( name );
     1046                                        return new LabelAddressExpr{ nameExpr->name };
    10571047                                }
    10581048                        }
  • src/SynTree/AddressExpr.cc

    r9d5fb67 r1cdfa82  
    5858}
    5959
    60 AddressExpr::~AddressExpr() {
    61         delete arg;
    62 }
    63 
    6460void AddressExpr::print( std::ostream &os, Indenter indent ) const {
    6561        os << "Address of:" << std::endl;
     
    7571}
    7672LabelAddressExpr::LabelAddressExpr( const LabelAddressExpr & other ) : Expression( other ), arg( other.arg ) {}
    77 LabelAddressExpr::~LabelAddressExpr() {}
    7873
    7974void LabelAddressExpr::print( std::ostream & os, Indenter ) const {
  • src/SynTree/AggregateDecl.cc

    r9d5fb67 r1cdfa82  
    3333        cloneAll( other.attributes, attributes );
    3434        body = other.body;
    35 }
    36 
    37 AggregateDecl::~AggregateDecl() {
    38         deleteAll( attributes );
    39         deleteAll( parameters );
    40         deleteAll( members );
    4135}
    4236
  • src/SynTree/ApplicationExpr.cc

    r9d5fb67 r1cdfa82  
    1717#include <list>                  // for list
    1818#include <map>                   // for _Rb_tree_const_iterator, map, map<>:...
    19 #include <memory>                // for unique_ptr
    2019#include <ostream>               // for operator<<, ostream, basic_ostream
    2120#include <string>                // for operator<<, string, char_traits
     
    4342}
    4443
    45 ParamEntry::~ParamEntry() {
    46         delete actualType;
    47         delete formalType;
    48         delete expr;
    49 }
    50 
    5144ApplicationExpr::ApplicationExpr( Expression *funcExpr, const std::list<Expression *> & args ) : function( funcExpr ), args( args ) {
    5245        PointerType *pointer = strict_dynamic_cast< PointerType* >( funcExpr->get_result() );
     
    6154                Expression( other ), function( maybeClone( other.function ) ) {
    6255        cloneAll( other.args, args );
    63 }
    64 
    65 ApplicationExpr::~ApplicationExpr() {
    66         delete function;
    67         deleteAll( args );
    6856}
    6957
  • src/SynTree/ArrayType.cc

    r9d5fb67 r1cdfa82  
    3434}
    3535
    36 ArrayType::~ArrayType() {
    37         delete base;
    38         delete dimension;
    39 }
    40 
    4136void ArrayType::print( std::ostream &os, Indenter indent ) const {
    4237        Type::print( os, indent );
  • src/SynTree/AttrType.cc

    r9d5fb67 r1cdfa82  
    3737}
    3838
    39 AttrType::~AttrType() {
    40         delete expr;
    41         delete type;
    42 }
    43 
    4439void AttrType::print( std::ostream &os, Indenter indent ) const {
    4540        Type::print( os, indent );
  • src/SynTree/Attribute.cc

    r9d5fb67 r1cdfa82  
    2323Attribute::Attribute( const Attribute &other ) : name( other.name ) {
    2424        cloneAll( other.parameters, parameters );
    25 }
    26 
    27 Attribute::~Attribute() {
    28         deleteAll( parameters );
    2925}
    3026
  • src/SynTree/Attribute.h

    r9d5fb67 r1cdfa82  
    3636        Attribute( std::string name = "", const std::list< Expression * > & parameters = std::list< Expression * >() ) : name( name ), parameters( parameters ) {}
    3737        Attribute( const Attribute &other );
    38         virtual ~Attribute();
    3938
    4039        std::string get_name() const { return name; }
  • src/SynTree/BaseSyntaxNode.h

    r9d5fb67 r1cdfa82  
    1717
    1818#include "Common/CodeLocation.h"
     19#include "Common/GC.h"
    1920#include "Common/Indenter.h"
     21
    2022class Visitor;
    2123class Mutator;
    2224
    23 class BaseSyntaxNode {
    24   public:
     25class BaseSyntaxNode : public GC_Object {
     26  friend class GcTracer;
     27public:
    2528        CodeLocation location;
    26 
    27         virtual ~BaseSyntaxNode() {}
    2829
    2930        virtual BaseSyntaxNode * clone() const = 0;
  • src/SynTree/CommaExpr.cc

    r9d5fb67 r1cdfa82  
    3434}
    3535
    36 CommaExpr::~CommaExpr() {
    37         delete arg1;
    38         delete arg2;
    39 }
    40 
    4136void CommaExpr::print( std::ostream &os, Indenter indent ) const {
    4237        os << "Comma Expression:" << std::endl;
  • src/SynTree/CompoundStmt.cc

    r9d5fb67 r1cdfa82  
    6868}
    6969
    70 CompoundStmt::~CompoundStmt() {
    71         deleteAll( kids );
    72 }
    73 
    7470void CompoundStmt::print( std::ostream &os, Indenter indent ) const {
    7571        os << "CompoundStmt" << endl;
  • src/SynTree/Constant.cc

    r9d5fb67 r1cdfa82  
    2727        type = other.type->clone();
    2828}
    29 
    30 Constant::~Constant() { delete type; }
    3129
    3230Constant Constant::from_bool( bool b ) {
  • src/SynTree/Constant.h

    r9d5fb67 r1cdfa82  
    1919#include <string>     // for string
    2020
    21 #include "BaseSyntaxNode.h"
    2221#include "Mutator.h"  // for Mutator
    2322#include "Visitor.h"  // for Visitor
    2423
     24#include "Common/Indenter.h"  // for Indenter
     25
    2526class Type;
    2627
    27 class Constant : public BaseSyntaxNode {
     28class Constant {
    2829  public:
    2930        Constant( Type * type, std::string rep, unsigned long long val );
    3031        Constant( Type * type, std::string rep, double val );
    3132        Constant( const Constant & other );
    32         virtual ~Constant();
    33 
     33       
    3434        virtual Constant * clone() const { return new Constant( *this ); }
    3535
  • src/SynTree/DeclStmt.cc

    r9d5fb67 r1cdfa82  
    2929}
    3030
    31 DeclStmt::~DeclStmt() {
    32         delete decl;
    33 }
    34 
    3531void DeclStmt::print( std::ostream &os, Indenter indent ) const {
    3632        assert( decl != 0 );
  • src/SynTree/Declaration.cc

    r9d5fb67 r1cdfa82  
    3838}
    3939
    40 Declaration::~Declaration() {
    41 }
    42 
    4340void Declaration::fixUniqueId() {
    4441        // don't need to set unique ID twice
     
    6663
    6764AsmDecl::AsmDecl( const AsmDecl &other ) : Declaration( other ), stmt( maybeClone( other.stmt ) ) {
    68 }
    69 
    70 AsmDecl::~AsmDecl() {
    71         delete stmt;
    7265}
    7366
  • src/SynTree/Declaration.h

    r9d5fb67 r1cdfa82  
    4545        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    4646        Declaration( const Declaration &other );
    47         virtual ~Declaration();
    4847
    4948        const std::string &get_name() const { return name; }
     
    8786        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    8887        DeclarationWithType( const DeclarationWithType &other );
    89         virtual ~DeclarationWithType();
    90 
     88       
    9189        std::string get_mangleName() const { return mangleName; }
    9290        DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
     
    126124                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    127125        ObjectDecl( const ObjectDecl &other );
    128         virtual ~ObjectDecl();
    129126
    130127        virtual Type * get_type() const override { return type; }
     
    156153                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    157154        FunctionDecl( const FunctionDecl &other );
    158         virtual ~FunctionDecl();
    159155
    160156        virtual Type * get_type() const override { return type; }
     
    184180        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    185181        NamedTypeDecl( const NamedTypeDecl &other );
    186         virtual ~NamedTypeDecl();
    187182
    188183        Type *get_base() const { return base; }
     
    219214        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    220215        TypeDecl( const TypeDecl &other );
    221         virtual ~TypeDecl();
    222216
    223217        Kind get_kind() const { return kind; }
     
    268262        AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    269263        AggregateDecl( const AggregateDecl &other );
    270         virtual ~AggregateDecl();
    271 
     264       
    272265        std::list<Declaration*>& get_members() { return members; }
    273266        std::list<TypeDecl*>& get_parameters() { return parameters; }
     
    353346        AsmDecl( AsmStmt *stmt );
    354347        AsmDecl( const AsmDecl &other );
    355         virtual ~AsmDecl();
    356348
    357349        AsmStmt *get_stmt() { return stmt; }
  • src/SynTree/DeclarationWithType.cc

    r9d5fb67 r1cdfa82  
    3434}
    3535
    36 DeclarationWithType::~DeclarationWithType() {
    37         deleteAll( attributes );
    38         delete asmName;
    39 }
    40 
    4136// Local Variables: //
    4237// tab-width: 4 //
  • src/SynTree/Expression.cc

    r9d5fb67 r1cdfa82  
    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
     
    280247
    281248CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    282 }
    283 
    284 CastExpr::~CastExpr() {
    285         delete arg;
    286249}
    287250
     
    335298}
    336299
    337 VirtualCastExpr::~VirtualCastExpr() {
    338         delete arg;
    339 }
    340 
    341300void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
    342301        os << "Virtual Cast of:" << std::endl << indent+1;
     
    361320}
    362321
    363 UntypedMemberExpr::~UntypedMemberExpr() {
    364         delete aggregate;
    365         delete member;
    366 }
    367 
    368322void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    369323        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    392346}
    393347
    394 MemberExpr::~MemberExpr() {
    395         // don't delete the member declaration, since it points somewhere else in the tree
    396         delete aggregate;
    397 }
    398 
    399348void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    400349        os << "Member Expression, with field: " << std::endl;
     
    412361                Expression( other ), function( maybeClone( other.function ) ) {
    413362        cloneAll( other.args, args );
    414 }
    415 
    416 UntypedExpr::~UntypedExpr() {
    417         delete function;
    418         deleteAll( args );
    419363}
    420364
     
    465409}
    466410
    467 NameExpr::~NameExpr() {}
    468 
    469411void NameExpr::print( std::ostream &os, Indenter indent ) const {
    470412        os << "Name: " << get_name();
     
    479421LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
    480422                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    481 }
    482 
    483 LogicalExpr::~LogicalExpr() {
    484         delete arg1;
    485         delete arg2;
    486423}
    487424
     
    499436ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
    500437                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;
    507438}
    508439
     
    542473ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    543474        set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
    544         delete callExpr;
    545         deleteAll( tempDecls );
    546         deleteAll( returnDecls );
    547         deleteAll( dtors );
    548475}
    549476
     
    570497}
    571498
    572 ConstructorExpr::~ConstructorExpr() {
    573         delete callExpr;
    574 }
    575 
    576499void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    577500        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    588511
    589512CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    590 
    591 CompoundLiteralExpr::~CompoundLiteralExpr() {
    592         delete initializer;
    593 }
    594513
    595514void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     
    618537        cloneAll( other.dtors, dtors );
    619538}
    620 StmtExpr::~StmtExpr() {
    621         delete statements;
    622         deleteAll( dtors );
    623         deleteAll( returnDecls );
    624 }
    625539void StmtExpr::computeResult() {
    626540        assert( statements );
    627541        std::list< Statement * > & body = statements->kids;
    628         delete result;
    629542        result = nullptr;
    630543        if ( ! returnDecls.empty() ) {
     
    669582UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    670583}
    671 UniqueExpr::~UniqueExpr() {
    672         delete expr;
    673         delete object;
    674         delete var;
    675 }
     584
    676585void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    677586        os << "Unique Expression with id:" << id << std::endl << indent+1;
     
    686595InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
    687596InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
    688 InitAlternative::~InitAlternative() {
    689         delete type;
    690         delete designation;
    691 }
    692597
    693598UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
    694599UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
    695 UntypedInitExpr::~UntypedInitExpr() {
    696         delete expr;
    697 }
    698600
    699601void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     
    713615}
    714616InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
    715 InitExpr::~InitExpr() {
    716         delete expr;
    717         delete designation;
    718 }
    719617
    720618void InitExpr::print( std::ostream & os, Indenter indent ) const {
     
    730628}
    731629DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
    732 DeletedExpr::~DeletedExpr() {
    733         delete expr;
    734 }
    735630
    736631void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
  • src/SynTree/Expression.h

    r9d5fb67 r1cdfa82  
    4141        ParamEntry( UniqueId decl, Type * actualType, Type * formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ), inferParams( new InferredParams ) {}
    4242        ParamEntry( const ParamEntry & other );
    43         ~ParamEntry();
    4443        ParamEntry & operator=( const ParamEntry & other );
    4544
     
    5352/// Expression is the root type for all expressions
    5453class Expression : public BaseSyntaxNode {
     54  protected:
     55        virtual ~Expression();
     56
    5557  public:
    5658        Type * result;
     
    6163        Expression();
    6264        Expression( const Expression & other );
    63         virtual ~Expression();
    6465
    6566        Type *& get_result() { return result; }
     
    8990        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    9091        ApplicationExpr( const ApplicationExpr & other );
    91         virtual ~ApplicationExpr();
    9292
    9393        Expression * get_function() const { return function; }
     
    111111        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    112112        UntypedExpr( const UntypedExpr & other );
    113         virtual ~UntypedExpr();
    114113
    115114        Expression * get_function() const { return function; }
     
    136135        NameExpr( std::string name );
    137136        NameExpr( const NameExpr & other );
    138         virtual ~NameExpr();
    139137
    140138        const std::string & get_name() const { return name; }
     
    157155        AddressExpr( Expression * arg );
    158156        AddressExpr( const AddressExpr & other );
    159         virtual ~AddressExpr();
    160157
    161158        Expression * get_arg() const { return arg; }
     
    176173        LabelAddressExpr( const Label &arg );
    177174        LabelAddressExpr( const LabelAddressExpr & other );
    178         virtual ~LabelAddressExpr();
    179175
    180176        virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); }
     
    194190        CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor
    195191        CastExpr( const CastExpr & other );
    196         virtual ~CastExpr();
    197192
    198193        Expression * get_arg() const { return arg; }
     
    232227        VirtualCastExpr( Expression * arg, Type * toType );
    233228        VirtualCastExpr( const VirtualCastExpr & other );
    234         virtual ~VirtualCastExpr();
    235229
    236230        Expression * get_arg() const { return arg; }
     
    251245        UntypedMemberExpr( Expression * member, Expression * aggregate );
    252246        UntypedMemberExpr( const UntypedMemberExpr & other );
    253         virtual ~UntypedMemberExpr();
    254247
    255248        Expression * get_member() const { return member; }
     
    273266        MemberExpr( DeclarationWithType * member, Expression * aggregate );
    274267        MemberExpr( const MemberExpr & other );
    275         virtual ~MemberExpr();
    276268
    277269        DeclarationWithType * get_member() const { return member; }
     
    294286        VariableExpr( DeclarationWithType * var );
    295287        VariableExpr( const VariableExpr & other );
    296         virtual ~VariableExpr();
    297288
    298289        DeclarationWithType * get_var() const { return var; }
     
    314305        ConstantExpr( Constant constant );
    315306        ConstantExpr( const ConstantExpr & other );
    316         virtual ~ConstantExpr();
    317307
    318308        Constant * get_constant() { return & constant; }
     
    338328        SizeofExpr( const SizeofExpr & other );
    339329        SizeofExpr( Type * type );
    340         virtual ~SizeofExpr();
    341330
    342331        Expression * get_expr() const { return expr; }
     
    363352        AlignofExpr( const AlignofExpr & other );
    364353        AlignofExpr( Type * type );
    365         virtual ~AlignofExpr();
    366354
    367355        Expression * get_expr() const { return expr; }
     
    386374        UntypedOffsetofExpr( Type * type, const std::string & member );
    387375        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
    388         virtual ~UntypedOffsetofExpr();
    389376
    390377        std::string get_member() const { return member; }
     
    407394        OffsetofExpr( Type * type, DeclarationWithType * member );
    408395        OffsetofExpr( const OffsetofExpr & other );
    409         virtual ~OffsetofExpr();
    410396
    411397        Type * get_type() const { return type; }
     
    427413        OffsetPackExpr( StructInstType * type );
    428414        OffsetPackExpr( const OffsetPackExpr & other );
    429         virtual ~OffsetPackExpr();
    430415
    431416        StructInstType * get_type() const { return type; }
     
    449434        AttrExpr( const AttrExpr & other );
    450435        AttrExpr( Expression * attr, Type * type );
    451         virtual ~AttrExpr();
    452436
    453437        Expression * get_attr() const { return attr; }
     
    474458        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true );
    475459        LogicalExpr( const LogicalExpr & other );
    476         virtual ~LogicalExpr();
    477460
    478461        bool get_isAnd() const { return isAnd; }
     
    500483        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 );
    501484        ConditionalExpr( const ConditionalExpr & other );
    502         virtual ~ConditionalExpr();
    503485
    504486        Expression * get_arg1() const { return arg1; }
     
    523505        CommaExpr( Expression * arg1, Expression * arg2 );
    524506        CommaExpr( const CommaExpr & other );
    525         virtual ~CommaExpr();
    526507
    527508        Expression * get_arg1() const { return arg1; }
     
    543524        TypeExpr( Type * type );
    544525        TypeExpr( const TypeExpr & other );
    545         virtual ~TypeExpr();
    546526
    547527        Type * get_type() const { return type; }
     
    563543        AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    564544        AsmExpr( const AsmExpr & other );
    565         virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    566545
    567546        Expression * get_inout() const { return inout; }
     
    585564/// along with a set of copy constructor calls, one for each argument.
    586565class ImplicitCopyCtorExpr : public Expression {
     566protected:
     567        virtual ~ImplicitCopyCtorExpr();
     568
    587569public:
    588570        ApplicationExpr * callExpr;
     
    593575        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    594576        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
    595         virtual ~ImplicitCopyCtorExpr();
    596577
    597578        ApplicationExpr * get_callExpr() const { return callExpr; }
     
    615596        ConstructorExpr( Expression * callExpr );
    616597        ConstructorExpr( const ConstructorExpr & other );
    617         ~ConstructorExpr();
    618598
    619599        Expression * get_callExpr() const { return callExpr; }
     
    633613        CompoundLiteralExpr( Type * type, Initializer * initializer );
    634614        CompoundLiteralExpr( const CompoundLiteralExpr & other );
    635         virtual ~CompoundLiteralExpr();
    636615
    637616        Initializer * get_initializer() const { return initializer; }
     
    670649        UntypedTupleExpr( const std::list< Expression * > & exprs );
    671650        UntypedTupleExpr( const UntypedTupleExpr & other );
    672         virtual ~UntypedTupleExpr();
    673651
    674652        std::list<Expression*>& get_exprs() { return exprs; }
     
    687665        TupleExpr( const std::list< Expression * > & exprs );
    688666        TupleExpr( const TupleExpr & other );
    689         virtual ~TupleExpr();
    690667
    691668        std::list<Expression*>& get_exprs() { return exprs; }
     
    705682        TupleIndexExpr( Expression * tuple, unsigned int index );
    706683        TupleIndexExpr( const TupleIndexExpr & other );
    707         virtual ~TupleIndexExpr();
    708684
    709685        Expression * get_tuple() const { return tuple; }
     
    725701        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls );
    726702        TupleAssignExpr( const TupleAssignExpr & other );
    727         virtual ~TupleAssignExpr();
    728703
    729704        TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; }
     
    745720        StmtExpr( CompoundStmt * statements );
    746721        StmtExpr( const StmtExpr & other );
    747         virtual ~StmtExpr();
    748722
    749723        CompoundStmt * get_statements() const { return statements; }
     
    770744        UniqueExpr( Expression * expr, long long idVal = -1 );
    771745        UniqueExpr( const UniqueExpr & other );
    772         ~UniqueExpr();
    773746
    774747        Expression * get_expr() const { return expr; }
     
    800773        InitAlternative( const InitAlternative & other );
    801774        InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it
    802         ~InitAlternative();
    803775};
    804776
     
    810782        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    811783        UntypedInitExpr( const UntypedInitExpr & other );
    812         ~UntypedInitExpr();
    813784
    814785        Expression * get_expr() const { return expr; }
     
    830801        InitExpr( Expression * expr, Designation * designation );
    831802        InitExpr( const InitExpr & other );
    832         ~InitExpr();
    833803
    834804        Expression * get_expr() const { return expr; }
     
    852822        DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
    853823        DeletedExpr( const DeletedExpr & other );
    854         ~DeletedExpr();
    855824
    856825        virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
  • src/SynTree/FunctionDecl.cc

    r9d5fb67 r1cdfa82  
    5252        }
    5353        cloneAll( other.withExprs, withExprs );
    54 }
    55 
    56 FunctionDecl::~FunctionDecl() {
    57         delete type;
    58         delete statements;
    59         deleteAll( withExprs );
    6054}
    6155
  • src/SynTree/FunctionType.cc

    r9d5fb67 r1cdfa82  
    3131        cloneAll( other.returnVals, returnVals );
    3232        cloneAll( other.parameters, parameters );
    33 }
    34 
    35 FunctionType::~FunctionType() {
    36         deleteAll( returnVals );
    37         deleteAll( parameters );
    3833}
    3934
  • src/SynTree/Initializer.cc

    r9d5fb67 r1cdfa82  
    3232}
    3333
    34 Designation::~Designation() {
    35         // std::cerr << "destroying designation" << std::endl;
    36         deleteAll( designators );
    37         // std::cerr << "finished destroying designation" << std::endl;
    38 }
    39 
    4034void Designation::print( std::ostream &os, Indenter indent ) const {
    4135        if ( ! designators.empty() ) {
     
    5246Initializer::Initializer( const Initializer & other ) : BaseSyntaxNode( other ), maybeConstructed( other.maybeConstructed ) {
    5347}
    54 Initializer::~Initializer() {}
    5548
    5649SingleInit::SingleInit( Expression *v, bool maybeConstructed ) : Initializer( maybeConstructed ), value ( v ) {
     
    5851
    5952SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) {
    60 }
    61 
    62 SingleInit::~SingleInit() {
    63         delete value;
    6453}
    6554
     
    8776}
    8877
    89 ListInit::~ListInit() {
    90         deleteAll( initializers );
    91         deleteAll( designations );
    92 }
    93 
    9478void ListInit::print( std::ostream &os, Indenter indent ) const {
    9579        os << "Compound initializer: " << std::endl;
     
    11094ConstructorInit::ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init ) : Initializer( true ), ctor( ctor ), dtor( dtor ), init( init ) {}
    11195ConstructorInit::ConstructorInit( const ConstructorInit &other ) : Initializer( other ), ctor( maybeClone( other.ctor ) ), dtor( maybeClone( other.dtor ) ), init( maybeClone( other.init ) ) {
    112 }
    113 
    114 ConstructorInit::~ConstructorInit() {
    115         delete ctor;
    116         delete dtor;
    117         delete init;
    11896}
    11997
  • src/SynTree/Initializer.h

    r9d5fb67 r1cdfa82  
    3333        Designation( const std::list< Expression * > & designators );
    3434        Designation( const Designation & other );
    35         virtual ~Designation();
    3635
    3736        std::list< Expression * > & get_designators() { return designators; }
     
    5049        Initializer( bool maybeConstructed );
    5150        Initializer( const Initializer & other );
    52         virtual ~Initializer();
    5351
    5452        bool get_maybeConstructed() { return maybeConstructed; }
     
    7068        SingleInit( Expression *value, bool maybeConstructed = false );
    7169        SingleInit( const SingleInit &other );
    72         virtual ~SingleInit();
    7370
    7471        Expression *get_value() { return value; }
     
    9188                          const std::list<Designation *> &designators = {}, bool maybeConstructed = false );
    9289        ListInit( const ListInit & other );
    93         virtual ~ListInit();
    9490
    9591        std::list<Designation *> & get_designations() { return designations; }
     
    123119        ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );
    124120        ConstructorInit( const ConstructorInit &other );
    125         virtual ~ConstructorInit();
    126121
    127122        void set_ctor( Statement * newValue ) { ctor = newValue; }
  • src/SynTree/NamedTypeDecl.cc

    r9d5fb67 r1cdfa82  
    3030        cloneAll( other.parameters, parameters );
    3131        cloneAll( other.assertions, assertions );
    32 }
    33 
    34 NamedTypeDecl::~NamedTypeDecl() {
    35         delete base;
    36         deleteAll( parameters );
    37         deleteAll( assertions );
    3832}
    3933
  • src/SynTree/ObjectDecl.cc

    r9d5fb67 r1cdfa82  
    3232ObjectDecl::ObjectDecl( const ObjectDecl &other )
    3333        : Parent( other ), type( maybeClone( other.type ) ), init( maybeClone( other.init ) ), bitfieldWidth( maybeClone( other.bitfieldWidth ) ) {
    34 }
    35 
    36 ObjectDecl::~ObjectDecl() {
    37         delete type;
    38         delete init;
    39         delete bitfieldWidth;
    4034}
    4135
  • src/SynTree/PointerType.cc

    r9d5fb67 r1cdfa82  
    3636}
    3737
    38 PointerType::~PointerType() {
    39         delete base;
    40         delete dimension;
    41 }
    42 
    4338void PointerType::print( std::ostream &os, Indenter indent ) const {
    4439        Type::print( os, indent );
  • src/SynTree/ReferenceToType.cc

    r9d5fb67 r1cdfa82  
    3232ReferenceToType::ReferenceToType( const ReferenceToType &other ) : Type( other ), name( other.name ), hoistType( other.hoistType ) {
    3333        cloneAll( other.parameters, parameters );
    34 }
    35 
    36 ReferenceToType::~ReferenceToType() {
    37         deleteAll( parameters );
    3834}
    3935
     
    170166}
    171167
    172 TraitInstType::~TraitInstType() {
    173 }
    174 
    175168bool TraitInstType::isComplete() const { assert( false ); }
    176169
     
    183176
    184177TypeInstType::TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {
    185 }
    186 
    187 
    188 TypeInstType::~TypeInstType() {
    189         // delete baseType; //This is shared and should not be deleted
    190178}
    191179
  • src/SynTree/ReferenceType.cc

    r9d5fb67 r1cdfa82  
    2828}
    2929
    30 ReferenceType::~ReferenceType() {
    31         delete base;
    32 }
    33 
    3430int ReferenceType::referenceDepth() const {
    3531        return base->referenceDepth()+1;
  • src/SynTree/Statement.cc

    r9d5fb67 r1cdfa82  
    4444}
    4545
    46 Statement::~Statement() {}
    47 
    4846ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}
    4947
    5048ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    51 
    52 ExprStmt::~ExprStmt() {
    53         delete expr;
    54 }
    5549
    5650void ExprStmt::print( std::ostream &os, Indenter indent ) const {
     
    6660  cloneAll( other.input, input );
    6761  cloneAll( other.clobber, clobber );
    68 }
    69 
    70 AsmStmt::~AsmStmt() {
    71         delete instruction;
    72         deleteAll( output );
    73         deleteAll( input );
    74         deleteAll( clobber );
    7562}
    7663
     
    122109ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    123110
    124 ReturnStmt::~ReturnStmt() {
    125         delete expr;
    126 }
    127 
    128111void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
    129112        os << "Return Statement, returning: ";
     
    141124        Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {
    142125        cloneAll( other.initialization, initialization );
    143 }
    144 
    145 IfStmt::~IfStmt() {
    146         deleteAll( initialization );
    147         delete condition;
    148         delete thenPart;
    149         delete elsePart;
    150126}
    151127
     
    185161}
    186162
    187 SwitchStmt::~SwitchStmt() {
    188         delete condition;
    189         // destroy statements
    190         deleteAll( statements );
    191 }
    192 
    193163void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
    194164        os << "Switch on condition: ";
     
    209179        Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
    210180        cloneAll( other.stmts, stmts );
    211 }
    212 
    213 CaseStmt::~CaseStmt() {
    214         delete condition;
    215         deleteAll( stmts );
    216181}
    217182
     
    244209}
    245210
    246 WhileStmt::~WhileStmt() {
    247         delete body;
    248         delete condition;
    249 }
    250 
    251211void WhileStmt::print( std::ostream &os, Indenter indent ) const {
    252212        os << "While on condition: " << endl ;
     
    266226                cloneAll( other.initialization, initialization );
    267227
    268 }
    269 
    270 ForStmt::~ForStmt() {
    271         deleteAll( initialization );
    272         delete condition;
    273         delete increment;
    274         delete body;
    275228}
    276229
     
    312265ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
    313266        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    314 }
    315 
    316 ThrowStmt::~ThrowStmt() {
    317         delete expr;
    318         delete target;
    319267}
    320268
     
    337285}
    338286
    339 TryStmt::~TryStmt() {
    340         delete block;
    341         deleteAll( handlers );
    342         delete finallyBlock;
    343 }
    344 
    345287void TryStmt::print( std::ostream &os, Indenter indent ) const {
    346288        os << "Try Statement" << endl;
     
    371313}
    372314
    373 CatchStmt::~CatchStmt() {
    374         delete decl;
    375         delete body;
    376 }
    377 
    378315void CatchStmt::print( std::ostream &os, Indenter indent ) const {
    379316        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
     
    398335
    399336FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {
    400 }
    401 
    402 FinallyStmt::~FinallyStmt() {
    403         delete block;
    404337}
    405338
     
    435368}
    436369
    437 WaitForStmt::~WaitForStmt() {
    438         for( auto & clause : clauses ) {
    439                 delete clause.target.function;
    440                 deleteAll( clause.target.arguments );
    441                 delete clause.statement;
    442                 delete clause.condition;
    443         }
    444 
    445         delete timeout.time;
    446         delete timeout.statement;
    447         delete timeout.condition;
    448 
    449         delete orelse.statement;
    450         delete orelse.condition;
    451 }
    452 
    453370void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
    454371        os << "Waitfor Statement" << endl;
     
    461378WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) {
    462379        cloneAll( other.exprs, exprs );
    463 }
    464 WithStmt::~WithStmt() {
    465         deleteAll( exprs );
    466         delete stmt;
    467380}
    468381
     
    491404}
    492405
    493 ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() {
    494         delete callStmt;
    495 }
    496 
    497406void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const {
    498407        os << "Implicit Ctor Dtor Statement" << endl;
  • src/SynTree/Statement.h

    r9d5fb67 r1cdfa82  
    3838
    3939        Statement( const std::list<Label> & labels = {} );
    40         virtual ~Statement();
    4140
    4241        std::list<Label> & get_labels() { return labels; }
     
    5655        CompoundStmt( std::list<Statement *> stmts );
    5756        CompoundStmt( const CompoundStmt &other );
    58         virtual ~CompoundStmt();
    5957
    6058        std::list<Statement*>& get_kids() { return kids; }
     
    8482        ExprStmt( Expression *expr );
    8583        ExprStmt( const ExprStmt &other );
    86         virtual ~ExprStmt();
    8784
    8885        Expression *get_expr() { return expr; }
     
    105102        AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    106103        AsmStmt( const AsmStmt &other );
    107         virtual ~AsmStmt();
    108104
    109105        bool get_voltile() { return voltile; }
     
    136132                        std::list<Statement *> initialization = std::list<Statement *>() );
    137133        IfStmt( const IfStmt &other );
    138         virtual ~IfStmt();
    139134
    140135        std::list<Statement *> &get_initialization() { return initialization; }
     
    159154        SwitchStmt( Expression *condition, const std::list<Statement *> &statements );
    160155        SwitchStmt( const SwitchStmt &other );
    161         virtual ~SwitchStmt();
    162156
    163157        Expression *get_condition() { return condition; }
     
    181175        CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException);
    182176        CaseStmt( const CaseStmt &other );
    183         virtual ~CaseStmt();
    184177
    185178        static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() );
     
    212205               Statement *body, bool isDoWhile = false );
    213206        WhileStmt( const WhileStmt &other );
    214         virtual ~WhileStmt();
    215207
    216208        Expression *get_condition() { return condition; }
     
    237229             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
    238230        ForStmt( const ForStmt &other );
    239         virtual ~ForStmt();
    240231
    241232        std::list<Statement *> &get_initialization() { return initialization; }
     
    290281        ReturnStmt( Expression *expr );
    291282        ReturnStmt( const ReturnStmt &other );
    292         virtual ~ReturnStmt();
    293283
    294284        Expression *get_expr() { return expr; }
     
    311301        ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr );
    312302        ThrowStmt( const ThrowStmt &other );
    313         virtual ~ThrowStmt();
    314303
    315304        Kind get_kind() { return kind; }
     
    333322        TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    334323        TryStmt( const TryStmt &other );
    335         virtual ~TryStmt();
    336324
    337325        CompoundStmt *get_block() const { return block; }
     
    360348                   Expression *cond, Statement *body );
    361349        CatchStmt( const CatchStmt &other );
    362         virtual ~CatchStmt();
    363350
    364351        Kind get_kind() { return kind; }
     
    382369        FinallyStmt( CompoundStmt *block );
    383370        FinallyStmt( const FinallyStmt &other );
    384         virtual ~FinallyStmt();
    385371
    386372        CompoundStmt *get_block() const { return block; }
     
    409395        WaitForStmt();
    410396        WaitForStmt( const WaitForStmt & );
    411         virtual ~WaitForStmt();
    412397
    413398        std::vector<Clause> clauses;
     
    438423        WithStmt( const std::list< Expression * > & exprs, Statement * stmt );
    439424        WithStmt( const WithStmt & other );
    440         virtual ~WithStmt();
    441425
    442426        virtual WithStmt * clone() const override { return new WithStmt( *this ); }
     
    454438        DeclStmt( Declaration *decl );
    455439        DeclStmt( const DeclStmt &other );
    456         virtual ~DeclStmt();
    457440
    458441        Declaration *get_decl() const { return decl; }
     
    476459        ImplicitCtorDtorStmt( Statement * callStmt );
    477460        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
    478         virtual ~ImplicitCtorDtorStmt();
    479461
    480462        Statement *get_callStmt() const { return callStmt; }
  • src/SynTree/TupleExpr.cc

    r9d5fb67 r1cdfa82  
    3535}
    3636
    37 UntypedTupleExpr::~UntypedTupleExpr() {
    38         deleteAll( exprs );
    39 }
    40 
    4137void UntypedTupleExpr::print( std::ostream &os, Indenter indent ) const {
    4238        os << "Untyped Tuple:" << std::endl;
     
    5147TupleExpr::TupleExpr( const TupleExpr &other ) : Expression( other ) {
    5248        cloneAll( other.exprs, exprs );
    53 }
    54 
    55 TupleExpr::~TupleExpr() {
    56         deleteAll( exprs );
    5749}
    5850
     
    7264
    7365TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
    74 }
    75 
    76 TupleIndexExpr::~TupleIndexExpr() {
    77         delete tuple;
    7866}
    7967
     
    10593}
    10694
    107 TupleAssignExpr::~TupleAssignExpr() {
    108         delete stmtExpr;
    109 }
    110 
    11195void TupleAssignExpr::print( std::ostream &os, Indenter indent ) const {
    11296        os << "Tuple Assignment Expression, with stmt expr:" << std::endl;
  • src/SynTree/TupleType.cc

    r9d5fb67 r1cdfa82  
    4343}
    4444
    45 TupleType::~TupleType() {
    46         deleteAll( types );
    47         deleteAll( members );
    48 }
    49 
    5045void TupleType::print( std::ostream &os, Indenter indent ) const {
    5146        Type::print( os, indent );
  • src/SynTree/Type.cc

    r9d5fb67 r1cdfa82  
    5757}
    5858
    59 Type::~Type() {
    60         deleteAll( forall );
    61         deleteAll( attributes );
    62 }
    63 
    6459// These must remain in the same order as the corresponding bit fields.
    6560const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
  • src/SynTree/Type.h

    r9d5fb67 r1cdfa82  
    141141        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
    142142        Type( const Type & other );
    143         virtual ~Type();
    144143
    145144        Qualifiers & get_qualifiers() { return tq; }
     
    261260        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    262261        PointerType( const PointerType& );
    263         virtual ~PointerType();
    264262
    265263        Type *get_base() { return base; }
     
    291289        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    292290        ArrayType( const ArrayType& );
    293         virtual ~ArrayType();
    294291
    295292        Type *get_base() { return base; }
     
    319316        ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    320317        ReferenceType( const ReferenceType & );
    321         virtual ~ReferenceType();
    322318
    323319        Type *get_base() { return base; }
     
    352348        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    353349        FunctionType( const FunctionType& );
    354         virtual ~FunctionType();
    355350
    356351        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
     
    376371        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    377372        ReferenceToType( const ReferenceToType & other );
    378         virtual ~ReferenceToType();
    379373
    380374        const std::string & get_name() const { return name; }
     
    503497        TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    504498        TraitInstType( const TraitInstType & other );
    505         ~TraitInstType();
    506499
    507500        virtual bool isComplete() const override;
     
    525518        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    526519        TypeInstType( const TypeInstType & other );
    527         ~TypeInstType();
    528520
    529521        TypeDecl *get_baseType() const { return baseType; }
     
    549541        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    550542        TupleType( const TupleType& );
    551         virtual ~TupleType();
    552543
    553544        typedef std::list<Type*> value_type;
     
    583574        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    584575        TypeofType( const TypeofType& );
    585         virtual ~TypeofType();
    586576
    587577        Expression *get_expr() const { return expr; }
     
    606596        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    607597        AttrType( const AttrType& );
    608         virtual ~AttrType();
    609598
    610599        const std::string & get_name() const { return name; }
  • src/SynTree/TypeDecl.cc

    r9d5fb67 r1cdfa82  
    2525
    2626TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) {
    27 }
    28 
    29 TypeDecl::~TypeDecl() {
    30   delete init;
    3127}
    3228
  • src/SynTree/TypeExpr.cc

    r9d5fb67 r1cdfa82  
    2626}
    2727
    28 TypeExpr::~TypeExpr() {
    29         delete type;
    30 }
    31 
    3228void TypeExpr::print( std::ostream &os, Indenter indent ) const {
    3329        if ( type ) type->print( os, indent );
  • src/SynTree/TypeSubstitution.cc

    r9d5fb67 r1cdfa82  
    2626}
    2727
    28 TypeSubstitution::~TypeSubstitution() {
    29         for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {
    30                 delete( i->second );
    31         }
    32         for ( VarEnvType::iterator i = varEnv.begin(); i != varEnv.end(); ++i ) {
    33                 delete( i->second );
    34         }
    35 }
    36 
    3728TypeSubstitution &TypeSubstitution::operator=( const TypeSubstitution &other ) {
    3829        if ( this == &other ) return *this;
     
    5748
    5849void TypeSubstitution::add( std::string formalType, Type *actualType ) {
    59         TypeEnvType::iterator i = typeEnv.find( formalType );
    60         if ( i != typeEnv.end() ) {
    61                 delete i->second;
    62         } // if
    6350        typeEnv[ formalType ] = actualType->clone();
    6451}
    6552
    6653void TypeSubstitution::remove( std::string formalType ) {
    67         TypeEnvType::iterator i = typeEnv.find( formalType );
    68         if ( i != typeEnv.end() ) {
    69                 delete i->second;
    70                 typeEnv.erase( formalType );
    71         } // if
     54        typeEnv.erase( formalType );
    7255}
    7356
     
    161144                Type * newtype = i->second->clone();
    162145                newtype->get_qualifiers() |= inst->get_qualifiers();
    163                 delete inst;
    164146                // Note: need to recursively apply substitution to the new type because normalize does not substitute bound vars, but bound vars must be substituted when not in freeOnly mode.
    165147                return newtype->acceptMutator( *visitor );
     
    173155        } else {
    174156                subCount++;
    175                 delete nameExpr;
    176157                return i->second->clone();
    177158        } // if
  • src/SynTree/TypeSubstitution.h

    r9d5fb67 r1cdfa82  
    3535        TypeSubstitution( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin );
    3636        TypeSubstitution( const TypeSubstitution &other );
    37         virtual ~TypeSubstitution();
    3837
    3938        TypeSubstitution &operator=( const TypeSubstitution &other );
     
    6059        void normalize();
    6160
     61        void accept( Visitor& v ) { v.visit( this ); }
    6262        TypeSubstitution * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    6363
     
    101101                        if ( TypeExpr *actual = dynamic_cast< TypeExpr* >( *actualIt ) ) {
    102102                                if ( formal->get_name() != "" ) {
    103                                         TypeEnvType::iterator i = typeEnv.find( formal->get_name() );
    104                                         if ( i != typeEnv.end() ) {
    105                                                 delete i->second;
    106                                         } // if
    107103                                        typeEnv[ formal->get_name() ] = actual->get_type()->clone();
    108104                                } // if
  • src/SynTree/TypeofType.cc

    r9d5fb67 r1cdfa82  
    2929}
    3030
    31 TypeofType::~TypeofType() {
    32         delete expr;
    33 }
    34 
    3531void TypeofType::print( std::ostream &os, Indenter indent ) const {
    3632        Type::print( os, indent );
  • src/SynTree/Visitor.h

    r9d5fb67 r1cdfa82  
    123123
    124124        virtual void visit( Attribute * attribute ) = 0;
     125
     126        virtual void visit( TypeSubstitution * sub ) = 0;
    125127};
    126128
  • src/SynTree/module.mk

    r9d5fb67 r1cdfa82  
    4848       SynTree/TypeSubstitution.cc \
    4949       SynTree/Attribute.cc \
     50       SynTree/BaseSyntaxNode.cc \
    5051       SynTree/DeclReplacer.cc
    5152
  • src/Tuples/Explode.cc

    r9d5fb67 r1cdfa82  
    7070                                // should now be a tuple of references rather than a reference to a tuple.
    7171                                // Still, this code is a bit awkward, and could use some improvement.
    72                                 UniqueExpr * newUniqueExpr = new UniqueExpr( applyCast( uniqueExpr->get_expr() ), uniqueExpr->get_id() );
    73                                 delete uniqueExpr;
     72                                UniqueExpr * newUniqueExpr = new UniqueExpr{ applyCast( uniqueExpr->get_expr() ), uniqueExpr->get_id() };
    7473                                if ( castAdded ) {
    7574                                        // if a cast was added by applyCast, then unique expr now has one more layer of reference
     
    8887                                // field is consistent with the type of the tuple expr, since the field
    8988                                // may have changed from type T to T&.
    90                                 Expression * expr = tupleExpr->get_tuple();
    91                                 tupleExpr->set_tuple( nullptr );
    92                                 TupleIndexExpr * ret = new TupleIndexExpr( expr, tupleExpr->get_index() );
    93                                 delete tupleExpr;
    94                                 return ret;
     89                                return new TupleIndexExpr( tupleExpr->get_tuple(), tupleExpr->get_index() );
    9590                        }
    9691                };
  • src/Tuples/Explode.h

    r9d5fb67 r1cdfa82  
    2727namespace SymTab {
    2828class Indexer;
    29 }  // namespace SymTab
     29}  // namespace SymTabf
    3030
    3131namespace Tuples {
     
    6767                                for ( ResolvExpr::Alternative & alt : alts ) {
    6868                                        // distribute reference cast over all components
    69                                         append( std::forward<Output>(out), distributeReference( alt.release_expr() ),
     69                                        append( std::forward<Output>(out), distributeReference( alt.expr ),
    7070                                                alt.env, alt.cost, alt.cvtCost );
    7171                                }
     
    9696                                        TupleIndexExpr * idx = new TupleIndexExpr( arg->clone(), i );
    9797                                        explodeUnique( idx, alt, indexer, std::forward<Output>(out), isTupleAssign );
    98                                         delete idx;
    9998                                }
    100                                 delete arg;
    10199                        }
    102100                } else {
  • src/Tuples/TupleExpansion.cc

    r9d5fb67 r1cdfa82  
    4545
    4646                        std::map< int, Expression * > decls; // not vector, because order added may not be increasing order
    47 
    48                         ~UniqueExprExpander() {
    49                                 for ( std::pair<const int, Expression *> & p : decls ) {
    50                                         delete p.second;
    51                                 }
    52                         }
    5347                };
    5448
     
    111105                                UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( memberExpr->member, inner );
    112106                                inner->location = newMemberExpr->location = loc;
    113                                 memberExpr->member = nullptr;
    114                                 memberExpr->aggregate = nullptr;
    115                                 delete memberExpr;
    116107                                return newMemberExpr->acceptMutator( expander );
    117108                        } else {
     
    135126                                expr->location = memberExpr->location;
    136127                        }
    137                         delete aggr;
    138128                        tupleExpr->location = memberExpr->location;
    139129                        return tupleExpr;
     
    181171                        decls[id] = condExpr;
    182172                }
    183                 delete unqExpr;
    184173                return decls[id]->clone();
    185174        }
     
    191180                ret->set_env( assnExpr->get_env() );
    192181                assnExpr->set_env( nullptr );
    193                 delete assnExpr;
    194182                return ret;
    195183        }
     
    222210                        newType->get_parameters().push_back( new TypeExpr( t->clone() ) );
    223211                }
    224                 delete tupleType;
    225212                return newType;
    226213        }
     
    233220                TypeSubstitution * env = tupleExpr->get_env();
    234221                tupleExpr->set_env( nullptr );
    235                 delete tupleExpr;
    236222
    237223                StructInstType * type = strict_dynamic_cast< StructInstType * >( tuple->get_result() );
     
    275261                TypeSubstitution * env = tupleExpr->get_env();
    276262
    277                 // remove data from shell and delete it
    278                 tupleExpr->set_result( nullptr );
    279                 tupleExpr->get_exprs().clear();
     263                // remove data from shell
    280264                tupleExpr->set_env( nullptr );
    281                 delete tupleExpr;
    282265
    283266                return replaceTupleExpr( result, exprs, env );
  • src/Virtual/ExpandCasts.cc

    r9d5fb67 r1cdfa82  
    139139                ObjectDecl * table = found->second;
    140140
    141                 Expression * result = new CastExpr(
     141                return new CastExpr{
    142142                        //new ApplicationExpr(
    143143                                //new AddressExpr( new VariableExpr( vcast_decl ) ),
     
    158158                                } ),
    159159                        castExpr->get_result()->clone()
    160                         );
    161 
    162                 castExpr->set_arg( nullptr );
    163                 castExpr->set_result( nullptr );
    164                 delete castExpr;
    165                 return result;
     160                };
    166161        }
    167162
  • src/main.cc

    r9d5fb67 r1cdfa82  
    3737#include "Common/PassVisitor.h"
    3838#include "Common/CompilerError.h"           // for CompilerError
     39#include "Common/GC.h"                                          // for GC
    3940#include "Common/SemanticError.h"           // for SemanticError
    4041#include "Common/UnimplementedError.h"      // for UnimplementedError
     
    5758#include "SymTab/Validate.h"                // for validate
    5859#include "SynTree/Declaration.h"            // for Declaration
     60#include "SynTree/GcTracer.h"               // for GC << TranslationUnit
    5961#include "SynTree/Visitor.h"                // for acceptAll
    6062#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
     
    6466
    6567#define OPTPRINT(x) if ( errorp ) cerr << x << endl;
    66 
    6768
    6869LinkageSpec::Spec linkage = LinkageSpec::Cforall;
     
    233234                delete parseTree;
    234235                parseTree = nullptr;
     236                collect( translationUnit );
    235237
    236238                if ( astp ) {
     
    242244                OPTPRINT( "validate" )
    243245                SymTab::validate( translationUnit, symtabp );
    244                 if ( symtabp ) {
    245                         deleteAll( translationUnit );
    246                         return 0;
    247                 } // if
     246                if ( symtabp ) return 0;
     247                collect( translationUnit );
    248248
    249249                if ( expraltp ) {
     
    266266                OPTPRINT( "expandMemberTuples" );
    267267                Tuples::expandMemberTuples( translationUnit );
     268                collect( translationUnit );
    268269                if ( libcfap ) {
    269270                        // generate the bodies of cfa library functions
     
    273274                if ( declstatsp ) {
    274275                        CodeTools::printDeclStats( translationUnit );
    275                         deleteAll( translationUnit );
    276276                        return 0;
    277277                }
     
    286286                OPTPRINT( "resolve" )
    287287                ResolvExpr::resolve( translationUnit );
     288                collect( translationUnit );
    288289                if ( exprp ) {
    289290                        dump( translationUnit );
     
    294295                OPTPRINT( "fixInit" )
    295296                InitTweak::fix( translationUnit, filename, libcfap || treep );
     297                collect( translationUnit );
    296298                if ( ctorinitp ) {
    297299                        dump ( translationUnit );
     
    313315                OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
    314316                Tuples::expandTuples( translationUnit );
     317                collect( translationUnit );
    315318                if ( tuplep ) {
    316319                        dump( translationUnit );
     
    323326                OPTPRINT("instantiateGenerics")
    324327                GenPoly::instantiateGeneric( translationUnit );
     328                collect( translationUnit );
    325329                if ( genericsp ) {
    326330                        dump( translationUnit );
    327331                        return 0;
    328332                }
     333
    329334                OPTPRINT( "convertLvalue" )
    330335                GenPoly::convertLvalue( translationUnit );
    331 
    332 
     336                collect( translationUnit );
    333337                if ( bboxp ) {
    334338                        dump( translationUnit );
    335339                        return 0;
    336340                } // if
     341
    337342                OPTPRINT( "box" )
    338343                GenPoly::box( translationUnit );
    339 
     344                collect( translationUnit );
    340345                if ( bcodegenp ) {
    341346                        dump( translationUnit );
     
    383388        } // try
    384389
    385         deleteAll( translationUnit );
    386390        return 0;
    387391} // main
     
    568572                printAll( decls, out );
    569573        }
    570         deleteAll( translationUnit );
    571574} // dump
    572575
Note: See TracChangeset for help on using the changeset viewer.