Changes in / [63238a4:28f3a19]


Ignore:
Location:
src
Files:
4 added
90 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r63238a4 r28f3a19  
    11881188unsigned Indenter::tabsize = 2;
    11891189
    1190 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
    1191         if ( node ) {
    1192                 node->print( out );
    1193         } else {
    1194                 out << "nullptr";
    1195         }
    1196         return out;
    1197 }
    1198 
    11991190// Local Variables: //
    12001191// tab-width: 4 //
  • src/CodeGen/FixMain.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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 std::move(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 std::move(name);
  • src/CodeGen/Generate.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    153153        virtual void visit( Subrange * subrange ) override final;
    154154
    155         virtual void visit( Constant * constant ) override final;
     155        virtual void visit( Constant * constant ) final;
    156156
    157157        virtual void visit( Attribute * attribute ) override final;
     158
     159        virtual void visit( TypeSubstitution * sub ) final;
    158160
    159161        virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) override final;
     
    253255        virtual Subrange * mutate( Subrange * subrange ) override final;
    254256
    255         virtual Constant * mutate( Constant * constant ) override final;
     257        virtual Constant * mutate( Constant * constant ) final;
    256258
    257259        virtual Attribute * mutate( Attribute * attribute ) override final;
  • src/Common/PassVisitor.impl.h

    r63238a4 r28f3a19  
    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                        // function body needs to have the same scope as parameters - CompoundStmt will not enter
     
    431431                        auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    432432                        // implicit add __func__ identifier as specified in the C manual 6.4.2.2
    433                         static ObjectDecl func(
     433                        static ObjectDecl* func = new_static_root<ObjectDecl>(
    434434                                "__func__", noStorageClasses, LinkageSpec::C, nullptr,
    435435                                new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
    436436                                nullptr
    437437                        );
    438                         indexerAddId( &func );
     438                        indexerAddId( func );
    439439                        maybeMutate_impl( node->type, *this );
    440440                        // function body needs to have the same scope as parameters - CompoundStmt will not enter
     
    12341234        indexerScopedAccept( node->result, *this );
    12351235
     1236        // xxx - not quite sure why this doesn't visit( node->function );
    12361237        for ( auto expr : node->args ) {
    12371238                visitExpression( expr );
     
    26942695// TypeSubstitution
    26952696template< typename pass_type >
     2697void PassVisitor< pass_type >::visit( TypeSubstitution * node ) {
     2698        VISIT_START( node );
     2699
     2700        for ( auto & p : node->typeEnv ) {
     2701                indexerScopedAccept( p.second, *this );
     2702        }
     2703        for ( auto & p : node->varEnv ) {
     2704                indexerScopedAccept( p.second, *this );
     2705        }
     2706
     2707        VISIT_END( node );
     2708}
     2709
     2710template< typename pass_type >
    26962711TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
    26972712        MUTATE_START( node );
  • src/Common/module.mk

    r63238a4 r28f3a19  
    66## file "LICENCE" distributed with Cforall.
    77##
    8 ## module.mk --
     8## module.mk -- 
    99##
    1010## Author           : Richard C. Bilson
     
    1818       Common/UniqueName.cc \
    1919       Common/DebugMalloc.cc \
     20       Common/GC.cc \
    2021       Common/Assert.cc \
    2122       Common/Heap.cc
  • src/Common/utility.h

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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        //-----------------------------------------------------------------------------
     
    288284                        // convert (thread &)t to (thread_desc &)*get_thread(t), etc.
    289285                        if( !type_decl ) SemanticError( cast, context_error );
    290                         Expression * arg = cast->arg;
    291                         cast->arg = nullptr;
    292                         delete cast;
    293286                        return new CastExpr(
    294287                                UntypedExpr::createDeref(
    295                                         new UntypedExpr( new NameExpr( getter_name ), { arg } )
     288                                        new UntypedExpr( new NameExpr( getter_name ), { cast->arg } )
    296289                                ),
    297290                                new ReferenceType(
     
    318311                StructDecl * forward = decl->clone();
    319312                forward->set_body( false );
    320                 deleteAll( forward->get_members() );
    321313                forward->get_members().clear();
    322314
     
    382374                        fixupGenerics(main_type, decl);
    383375                }
    384 
    385                 delete this_decl;
    386376
    387377                declsToAddBefore.push_back( forward );
  • src/Concurrency/Waitfor.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    445445                Type * newType = arg->clone();
    446446                if ( env ) env->apply( newType );
    447                 std::unique_ptr<Type> manager( newType );
    448447                // if the argument's type is polymorphic, we don't need to box again!
    449448                return ! isPolyType( newType );
  • src/GenPoly/InstantiateGeneric.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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 );
     
    174173                                        return ret;
    175174                                }
    176                                 delete result;
    177175                        }
    178176                        return appExpr;
     
    233231                                                        Type * baseType = InitTweak::getPointerBase( arg->result );
    234232                                                        assertf( baseType, "parameter is reference, arg must be pointer or reference: %s", toString( arg->result ).c_str() );
    235                                                         PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() );
    236                                                         delete arg->result;
    237                                                         arg->result = ptrType;
     233                                                        arg->set_result( new PointerType( Type::Qualifiers(), baseType->clone() ) );
    238234                                                        arg = mkDeref( arg );
    239235                                                        // assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );
     
    407403                                }
    408404                                ret->env = castExpr->env;
    409                                 delete ret->result;
    410405                                ret->result = castExpr->result;
    411406                                castExpr->env = nullptr;
    412407                                castExpr->arg = nullptr;
    413408                                castExpr->result = nullptr;
    414                                 delete castExpr;
    415409                                return ret;
    416410                        } else if ( diff < 0 ) {
     
    428422                                }
    429423                                ret->env = castExpr->env;
    430                                 delete ret->result;
    431424                                ret->result = castExpr->result;
    432425                                ret->result->set_lvalue( true ); // ensure result is lvalue
     
    434427                                castExpr->arg = nullptr;
    435428                                castExpr->result = nullptr;
    436                                 delete castExpr;
    437429                                return ret;
    438430                        } else {
     
    449441                                        castExpr->arg = nullptr;
    450442                                        std::swap( castExpr->env, ret->env );
    451                                         delete castExpr;
    452443                                        return ret;
    453444                                }
     
    460451                        Type::Qualifiers qualifiers = refType->get_qualifiers();
    461452                        refType->base = nullptr;
    462                         delete refType;
    463453                        return new PointerType( qualifiers, base );
    464454                }
     
    472462                                ret->env = expr->env;
    473463                                expr->env = nullptr;
    474                                 delete expr;
    475464                                return ret;
    476465                        } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( arg ) ) {
     
    481470                                ret->env = expr->env;
    482471                                expr->env = nullptr;
    483                                 delete expr;
    484472
    485473                                // conditional expr type may not be either of the argument types, need to unify
     
    514502                                        arg0 = nullptr;
    515503                                        addrExpr->env = nullptr;
    516                                         delete addrExpr;
    517504                                        return ret;
    518505                                }
     
    544531                                                addrExpr->arg = nullptr;
    545532                                                appExpr->env = nullptr;
    546                                                 delete appExpr;
    547533                                                return ret;
    548534                                        }
  • src/GenPoly/ScrubTyVars.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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        Common/driver_cfa_cpp-Heap.$(OBJEXT) \
     
    250251        SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \
    251252        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
     253        SynTree/driver_cfa_cpp-BaseSyntaxNode.$(OBJEXT) \
    252254        SynTree/driver_cfa_cpp-DeclReplacer.$(OBJEXT) \
    253255        Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \
     
    486488        CodeTools/TrackLoc.cc Concurrency/Keywords.cc \
    487489        Concurrency/Waitfor.cc Common/SemanticError.cc \
    488         Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \
    489         Common/Heap.cc ControlStruct/LabelGenerator.cc \
    490         ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \
    491         ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \
     490        Common/UniqueName.cc Common/DebugMalloc.cc Common/GC.cc \
     491        Common/Assert.cc Common/Heap.cc \
     492        ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \
     493        ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \
     494        ControlStruct/ForExprMutator.cc \
    492495        ControlStruct/ExceptTranslate.cc GenPoly/Box.cc \
    493496        GenPoly/GenPoly.cc GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc \
     
    527530        SynTree/NamedTypeDecl.cc SynTree/TypeDecl.cc \
    528531        SynTree/Initializer.cc SynTree/TypeSubstitution.cc \
    529         SynTree/Attribute.cc SynTree/DeclReplacer.cc \
    530         Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
    531         Tuples/Explode.cc Virtual/ExpandCasts.cc
     532        SynTree/Attribute.cc SynTree/BaseSyntaxNode.cc \
     533        SynTree/DeclReplacer.cc Tuples/TupleAssignment.cc \
     534        Tuples/TupleExpansion.cc Tuples/Explode.cc \
     535        Virtual/ExpandCasts.cc
    532536MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    533537        ${cfa_cpplib_PROGRAMS}}
     
    671675        Common/$(DEPDIR)/$(am__dirstamp)
    672676Common/driver_cfa_cpp-DebugMalloc.$(OBJEXT): Common/$(am__dirstamp) \
     677        Common/$(DEPDIR)/$(am__dirstamp)
     678Common/driver_cfa_cpp-GC.$(OBJEXT): Common/$(am__dirstamp) \
    673679        Common/$(DEPDIR)/$(am__dirstamp)
    674680Common/driver_cfa_cpp-Assert.$(OBJEXT): Common/$(am__dirstamp) \
     
    915921SynTree/driver_cfa_cpp-Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \
    916922        SynTree/$(DEPDIR)/$(am__dirstamp)
     923SynTree/driver_cfa_cpp-BaseSyntaxNode.$(OBJEXT):  \
     924        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
    917925SynTree/driver_cfa_cpp-DeclReplacer.$(OBJEXT):  \
    918926        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
     
    976984@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Assert.Po@am__quote@
    977985@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-DebugMalloc.Po@am__quote@
     986@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-GC.Po@am__quote@
    978987@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-Heap.Po@am__quote@
    979988@AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@
     
    10391048@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-AttrType.Po@am__quote@
    10401049@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Attribute.Po@am__quote@
     1050@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Po@am__quote@
    10411051@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-BasicType.Po@am__quote@
    10421052@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-CommaExpr.Po@am__quote@
     
    12981308@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`
    12991309
     1310Common/driver_cfa_cpp-GC.o: Common/GC.cc
     1311@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
     1312@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo Common/$(DEPDIR)/driver_cfa_cpp-GC.Po
     1313@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Common/GC.cc' object='Common/driver_cfa_cpp-GC.o' libtool=no @AMDEPBACKSLASH@
     1314@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1315@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
     1316
     1317Common/driver_cfa_cpp-GC.obj: Common/GC.cc
     1318@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`
     1319@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) Common/$(DEPDIR)/driver_cfa_cpp-GC.Tpo Common/$(DEPDIR)/driver_cfa_cpp-GC.Po
     1320@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='Common/GC.cc' object='Common/driver_cfa_cpp-GC.obj' libtool=no @AMDEPBACKSLASH@
     1321@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1322@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`
     1323
    13001324Common/driver_cfa_cpp-Assert.o: Common/Assert.cc
    13011325@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
     
    25152539@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    25162540@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`
     2541
     2542SynTree/driver_cfa_cpp-BaseSyntaxNode.o: SynTree/BaseSyntaxNode.cc
     2543@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
     2544@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Po
     2545@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/BaseSyntaxNode.cc' object='SynTree/driver_cfa_cpp-BaseSyntaxNode.o' libtool=no @AMDEPBACKSLASH@
     2546@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2547@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
     2548
     2549SynTree/driver_cfa_cpp-BaseSyntaxNode.obj: SynTree/BaseSyntaxNode.cc
     2550@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`
     2551@am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-BaseSyntaxNode.Po
     2552@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/BaseSyntaxNode.cc' object='SynTree/driver_cfa_cpp-BaseSyntaxNode.obj' libtool=no @AMDEPBACKSLASH@
     2553@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     2554@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`
    25172555
    25182556SynTree/driver_cfa_cpp-DeclReplacer.o: SynTree/DeclReplacer.cc
  • src/Parser/DeclarationNode.cc

    r63238a4 r28f3a19  
    9494
    9595        delete assert.condition;
    96         delete assert.message;
    9796}
    9897
     
    10021001                                        obj->location = cur->location;
    10031002                                        * out++ = obj;
    1004                                         delete agg;
    10051003                                } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
    10061004                                        UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );
  • src/Parser/ExpressionNode.cc

    r63238a4 r28f3a19  
    408408        Type * targetType = maybeMoveBuildType( decl_node );
    409409        if ( dynamic_cast< VoidType * >( targetType ) ) {
    410                 delete targetType;
    411410                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
    412411        } else {
     
    436435
    437436Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
    438         Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );
    439         delete member;
    440         return ret;
     437        return new UntypedOffsetofExpr{ maybeMoveBuildType( decl_node ), member->get_name() };
    441438} // build_offsetOf
    442439
  • src/Parser/ParseNode.h

    r63238a4 r28f3a19  
    128128
    129129        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    130                 os << expr.get() << std::endl;
     130                os << expr << std::endl;
    131131        }
    132132        void printOneLine( __attribute__((unused)) std::ostream &os, __attribute__((unused)) int indent = 0 ) const {}
    133133
    134134        template<typename T>
    135         bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); }
    136 
    137         Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); }
     135        bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr); }
     136
     137        Expression * build() const { return expr; }
    138138  private:
    139139        bool extension = false;
    140         std::unique_ptr<Expression> expr;
     140        Expression* expr;
    141141}; // ExpressionNode
    142142
     
    364364
    365365        virtual StatementNode * clone() const final { assert( false ); return nullptr; }
    366         Statement * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }
     366        Statement * build() const { return stmt; }
    367367
    368368        virtual StatementNode * add_label( const std::string * name, DeclarationNode * attr = nullptr ) {
     
    376376
    377377        virtual void print( std::ostream &os, __attribute__((unused)) int indent = 0 ) const override {
    378                 os << stmt.get() << std::endl;
     378                os << stmt << std::endl;
    379379        }
    380380  private:
    381         std::unique_ptr<Statement> stmt;
     381        Statement* stmt;
    382382}; // StatementNode
    383383
  • src/Parser/StatementNode.cc

    r63238a4 r28f3a19  
    5050                agg = decl;
    5151        } // if
    52         stmt.reset( new DeclStmt( maybeMoveBuild< Declaration >(agg) ) );
     52        stmt = new DeclStmt{ maybeMoveBuild< Declaration >(agg) };
    5353} // StatementNode::StatementNode
    5454
     
    5858        for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) {
    5959                StatementNode * node = strict_dynamic_cast< StatementNode * >(curr);
    60                 assert( dynamic_cast< CaseStmt * >(node->stmt.get()) );
     60                assert( dynamic_cast< CaseStmt * >(node->stmt) );
    6161                prev = curr;
    6262        } // for
     
    6666        buildMoveList( stmt, stmts );
    6767        // splice any new Statements to end of current Statements
    68         CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt.get());
     68        CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt);
    6969        caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts );
    7070        return this;
  • src/ResolvExpr/AdjustExprType.cc

    r63238a4 r28f3a19  
    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
  • src/ResolvExpr/Alternative.cc

    r63238a4 r28f3a19  
    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;
     39       
     40        Alternative::Alternative( const Alternative& o )
     41                : cost( o.cost ), cvtCost( o.cvtCost ), expr( maybeClone( o.expr ) ), env( o.env ) {}
     42       
     43        Alternative & Alternative::operator= ( const Alternative& o ) {
     44                if ( &o == this ) return *this;
     45                cost = o.cost;
     46                cvtCost = o.cvtCost;
     47                expr = maybeClone( o.expr );
     48                env = o.env;
    4749                return *this;
    48         }
    49 
    50         Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( std::move( 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 = std::move( other.env );
    61                 other.expr = nullptr;
    62                 return *this;
    63         }
    64 
    65         Alternative::~Alternative() {
    66                 delete expr;
    6750        }
    6851
     
    9679        }
    9780
     81        const GC& operator<< ( const GC& gc, const Alternative& alt ) {
     82                PassVisitor<GcTracer> tracer{ gc };
     83                maybeAccept( alt.expr, tracer );
     84                tracer << alt.env;
     85                return gc;
     86        }
     87
    9888} // namespace ResolvExpr
    9989
  • src/ResolvExpr/Alternative.h

    r63238a4 r28f3a19  
    2424class Expression;
    2525
     26class GC;
     27
    2628namespace ResolvExpr {
    2729        struct Alternative {
     
    3032                Alternative( Expression *expr, const TypeEnvironment &env, const Cost &cost, const Cost &cvtCost );
    3133                Alternative( const Alternative &other );
    32                 Alternative &operator=( const Alternative &other );
    33                 Alternative( Alternative && other );
    34                 Alternative &operator=( Alternative && other );
    35                 ~Alternative();
     34                Alternative & operator= ( const Alternative &other );
     35                Alternative( Alternative&& other ) = default;
     36                Alternative & operator= ( Alternative&& other ) = default;
    3637
    3738                void print( std::ostream &os, Indenter indent = {} ) const;
    3839
    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 
    4640                Cost cost;
    4741                Cost cvtCost;
    48                 Expression *expr;
     42                Expression * expr;
    4943                TypeEnvironment env;
    5044        };
     
    6256                return os;
    6357        }
     58
     59        const GC& operator<< ( const GC&, const Alternative& );
    6460} // namespace ResolvExpr
    6561
  • src/ResolvExpr/AlternativeFinder.cc

    r63238a4 r28f3a19  
    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
     
    166167                                        candidate->env.apply( newType );
    167168                                        mangleName = SymTab::Mangler::mangle( newType );
    168                                         delete newType;
    169169                                }
    170170                                std::map< std::string, PruneStruct >::iterator mapPlace = selected.find( mangleName );
     
    308308                // adds anonymous member interpretations whenever an aggregate value type is seen.
    309309                // 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
    310                 std::unique_ptr<Expression> aggrExpr( alt.expr->clone() );
     310                Expression* aggrExpr = alt.expr->clone();
    311311                alt.env.apply( aggrExpr->result );
    312312                Type * aggrType = aggrExpr->result;
    313313                if ( dynamic_cast< ReferenceType * >( aggrType ) ) {
    314314                        aggrType = aggrType->stripReferences();
    315                         aggrExpr.reset( new CastExpr( aggrExpr.release(), aggrType->clone() ) );
     315                        aggrExpr = new CastExpr{ aggrExpr, aggrType->clone() };
    316316                }
    317317
    318318                if ( StructInstType *structInst = dynamic_cast< StructInstType* >( aggrExpr->result ) ) {
    319                         addAggMembers( structInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, "" );
     319                        addAggMembers( structInst, aggrExpr, alt.cost+Cost::safe, alt.env, "" );
    320320                } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( aggrExpr->result ) ) {
    321                         addAggMembers( unionInst, aggrExpr.get(), alt.cost+Cost::safe, alt.env, "" );
     321                        addAggMembers( unionInst, aggrExpr, alt.cost+Cost::safe, alt.env, "" );
    322322                } // if
    323323        }
     
    354354
    355355        void AlternativeFinder::Finder::postvisit( ApplicationExpr *applicationExpr ) {
    356                 alternatives.push_back( Alternative( applicationExpr->clone(), env, Cost::zero ) );
     356                alternatives.push_back( Alternative( applicationExpr, env, Cost::zero ) );
    357357        }
    358358
     
    560560
    561561                                Expression *varExpr = data.combine( newerAlt.cvtCost );
    562                                 delete varExpr->get_result();
    563562                                varExpr->set_result( adjType->clone() );
    564563                                PRINT(
     
    574573                                        inferParameters = (*inferParameters)[ id ].inferParams.get();
    575574                                }
    576                                 // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    577                                 (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
     575                               
     576                                (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType, curDecl->get_type(), varExpr );
    578577                                inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    579                         } else {
    580                                 delete adjType;
    581578                        }
    582579                }
     
    627624        struct ArgPack {
    628625                std::size_t parent;                ///< Index of parent pack
    629                 std::unique_ptr<Expression> expr;  ///< The argument stored here
     626                Expression* expr;                  ///< The argument stored here
    630627                Cost cost;                         ///< The cost of this argument
    631628                TypeEnvironment env;               ///< Environment for this pack
     
    639636
    640637                ArgPack()
    641                         : parent(0), expr(), cost(Cost::zero), env(), need(), have(), openVars(), nextArg(0),
    642                           tupleStart(0), nextExpl(0), explAlt(0) {}
     638                        : parent(0), expr(nullptr), cost(Cost::zero), env(), need(), have(), openVars(),
     639                          nextArg(0), tupleStart(0), nextExpl(0), explAlt(0) {}
    643640
    644641                ArgPack(const TypeEnvironment& env, const AssertionSet& need, const AssertionSet& have,
    645642                                const OpenVarSet& openVars)
    646                         : parent(0), expr(), cost(Cost::zero), env(env), need(need), have(have),
     643                        : parent(0), expr(nullptr), cost(Cost::zero), env(env), need(need), have(have),
    647644                          openVars(openVars), nextArg(0), tupleStart(0), nextExpl(0), explAlt(0) {}
    648645
     
    651648                                unsigned tupleStart = 0, Cost cost = Cost::zero, unsigned nextExpl = 0,
    652649                                unsigned explAlt = 0 )
    653                         : parent(parent), expr(expr->clone()), cost(cost), env(move(env)), need(move(need)),
     650                        : parent(parent), expr(expr), cost(cost), env(move(env)), need(move(need)),
    654651                          have(move(have)), openVars(move(openVars)), nextArg(nextArg), tupleStart(tupleStart),
    655652                          nextExpl(nextExpl), explAlt(explAlt) {}
     
    657654                ArgPack(const ArgPack& o, TypeEnvironment&& env, AssertionSet&& need, AssertionSet&& have,
    658655                                OpenVarSet&& openVars, unsigned nextArg, Cost added )
    659                         : parent(o.parent), expr(o.expr ? o.expr->clone() : nullptr), cost(o.cost + added),
    660                           env(move(env)), need(move(need)), have(move(have)), openVars(move(openVars)),
    661                           nextArg(nextArg), tupleStart(o.tupleStart), nextExpl(0), explAlt(0) {}
     656                        : parent(o.parent), expr(o.expr), cost(o.cost + added), env(move(env)),
     657                          need(move(need)), have(move(have)), openVars(move(openVars)), nextArg(nextArg),
     658                          tupleStart(o.tupleStart), nextExpl(0), explAlt(0) {}
    662659
    663660                /// true iff this pack is in the middle of an exploded argument
     
    674671                        std::list<Expression*> exprs;
    675672                        const ArgPack* pack = this;
    676                         if ( expr ) { exprs.push_front( expr.release() ); }
     673                        if ( expr ) { exprs.push_front( expr ); }
    677674                        while ( pack->tupleStart == 0 ) {
    678675                                pack = &packs[pack->parent];
    679                                 exprs.push_front( pack->expr->clone() );
     676                                exprs.push_front( pack->expr );
    680677                                cost += pack->cost;
    681678                        }
    682679                        // reset pack to appropriate tuple
    683                         expr.reset( new TupleExpr( exprs ) );
     680                        expr = new TupleExpr{ exprs };
    684681                        tupleStart = pack->tupleStart - 1;
    685682                        parent = pack->parent;
     
    734731
    735732                                                results.emplace_back(
    736                                                         i, expl.exprs[results[i].nextExpl].get(), copy(results[i].env),
     733                                                        i, expl.exprs[results[i].nextExpl], copy(results[i].env),
    737734                                                        copy(results[i].need), copy(results[i].have),
    738735                                                        copy(results[i].openVars), nextArg, nTuples, Cost::zero, nextExpl,
     
    755752                                                        newResult.parent = i;
    756753                                                        std::list<Expression*> emptyList;
    757                                                         newResult.expr.reset( new TupleExpr( emptyList ) );
     754                                                        newResult.expr = new TupleExpr{ emptyList };
    758755                                                        argType = newResult.expr->get_result();
    759756                                                } else {
     
    762759                                                        newResult.cost = results[i].cost;
    763760                                                        newResult.tupleStart = results[i].tupleStart;
    764                                                         newResult.expr.reset( results[i].expr->clone() );
     761                                                        newResult.expr = results[i].expr;
    765762                                                        argType = newResult.expr->get_result();
    766763
     
    812809                                                // add new result
    813810                                                results.emplace_back(
    814                                                         i, expl.exprs.front().get(), move(env), copy(results[i].need),
     811                                                        i, expl.exprs.front(), move(env), copy(results[i].need),
    815812                                                        copy(results[i].have), move(openVars), nextArg + 1,
    816813                                                        nTuples, expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     
    838835                        if ( results[i].hasExpl() ) {
    839836                                const ExplodedActual& expl = results[i].getExpl( args );
    840                                 Expression* expr = expl.exprs[results[i].nextExpl].get();
     837                                Expression* expr = expl.exprs[results[i].nextExpl];
    841838
    842839                                TypeEnvironment env = results[i].env;
     
    909906
    910907                                // consider only first exploded actual
    911                                 Expression* expr = expl.exprs.front().get();
     908                                Expression* expr = expl.exprs.front();
    912909                                Type* actualType = expr->result->clone();
    913910
     
    937934
    938935        template<typename OutputIterator>
    939         void AlternativeFinder::Finder::validateFunctionAlternative( const Alternative &func, ArgPack& result,
    940                         const std::vector<ArgPack>& results, OutputIterator out ) {
    941                 ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() );
     936        void AlternativeFinder::Finder::validateFunctionAlternative( const Alternative &func,
     937                        ArgPack& result, const std::vector<ArgPack>& results, OutputIterator out ) {
     938                ApplicationExpr *appExpr = new ApplicationExpr( func.expr );
    942939                // sum cost and accumulate actuals
    943940                std::list<Expression*>& args = appExpr->args;
     
    945942                const ArgPack* pack = &result;
    946943                while ( pack->expr ) {
    947                         args.push_front( pack->expr->clone() );
     944                        args.push_front( pack->expr );
    948945                        cost += pack->cost;
    949946                        pack = &results[pack->parent];
     
    10121009
    10131010                                                results.emplace_back(
    1014                                                         i, expl.exprs[results[i].nextExpl].get(), copy(results[i].env),
     1011                                                        i, expl.exprs[results[i].nextExpl], copy(results[i].env),
    10151012                                                        copy(results[i].need), copy(results[i].have),
    10161013                                                        copy(results[i].openVars), nextArg, 0, Cost::zero, nextExpl,
     
    10481045                                                // add new result
    10491046                                                results.emplace_back(
    1050                                                         i, expl.exprs.front().get(), move(env), copy(results[i].need),
     1047                                                        i, expl.exprs.front(), move(env), copy(results[i].need),
    10511048                                                        copy(results[i].have), move(openVars), nextArg + 1, 0,
    10521049                                                        expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     
    10831080
    10841081                // find function operators
    1085                 static NameExpr *opExpr = new NameExpr( "?()" );
     1082                static auto *opExpr = new_static_root<NameExpr>( "?()" );
    10861083                AlternativeFinder funcOpFinder( indexer, env );
    10871084                // it's ok if there aren't any defined function ops
     
    11151112                                )
    11161113                                // check if the type is pointer to function
    1117                                 if ( PointerType *pointer = dynamic_cast< PointerType* >( func->expr->result->stripReferences() ) ) {
    1118                                         if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->base ) ) {
     1114                                if ( PointerType *pointer = dynamic_cast< PointerType* >( func->expr->get_result()->stripReferences() ) ) {
     1115                                        if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) {
    11191116                                                Alternative newFunc( *func );
    11201117                                                referenceToRvalueConversion( newFunc.expr, newFunc.cost );
     
    11521149                                        // check if type is a pointer to function
    11531150                                        if ( PointerType* pointer = dynamic_cast<PointerType*>(
    1154                                                         funcOp->expr->result->stripReferences() ) ) {
     1151                                                        funcOp->expr->get_result()->stripReferences() ) ) {
    11551152                                                if ( FunctionType* function =
    1156                                                                 dynamic_cast<FunctionType*>( pointer->base ) ) {
     1153                                                                dynamic_cast<FunctionType*>( pointer->get_base() ) ) {
    11571154                                                        Alternative newFunc( *funcOp );
    11581155                                                        referenceToRvalueConversion( newFunc.expr, newFunc.cost );
     
    11761173                        PRINT(
    11771174                                ApplicationExpr *appExpr = strict_dynamic_cast< ApplicationExpr* >( withFunc.expr );
    1178                                 PointerType *pointer = strict_dynamic_cast< PointerType* >( appExpr->function->result );
    1179                                 FunctionType *function = strict_dynamic_cast< FunctionType* >( pointer->base );
    1180                                 std::cerr << "Case +++++++++++++ " << appExpr->function << std::endl;
     1175                                PointerType *pointer = strict_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() );
     1176                                FunctionType *function = strict_dynamic_cast< FunctionType* >( pointer->get_base() );
     1177                                std::cerr << "Case +++++++++++++ " << appExpr->get_function() << std::endl;
    11811178                                std::cerr << "formals are:" << std::endl;
    1182                                 printAll( function->parameters, std::cerr, 8 );
     1179                                printAll( function->get_parameters(), std::cerr, 8 );
    11831180                                std::cerr << "actuals are:" << std::endl;
    1184                                 printAll( appExpr->args, std::cerr, 8 );
     1181                                printAll( appExpr->get_args(), std::cerr, 8 );
    11851182                                std::cerr << "bindings are:" << std::endl;
    11861183                                withFunc.env.print( std::cerr, 8 );
     
    12231220        bool isLvalue( Expression *expr ) {
    12241221                // xxx - recurse into tuples?
    1225                 return expr->result && ( expr->result->get_lvalue() || dynamic_cast< ReferenceType * >( expr->result ) );
     1222                return expr->result && ( expr->get_result()->get_lvalue() || dynamic_cast< ReferenceType * >( expr->get_result() ) );
    12261223        }
    12271224
     
    12321229                        if ( isLvalue( alt.expr ) ) {
    12331230                                alternatives.push_back(
    1234                                         Alternative{ new AddressExpr( alt.expr->clone() ), alt.env, alt.cost } );
     1231                                        Alternative{ new AddressExpr( alt.expr ), alt.env, alt.cost } );
    12351232                        } // if
    12361233                } // for
     
    12381235
    12391236        void AlternativeFinder::Finder::postvisit( LabelAddressExpr * expr ) {
    1240                 alternatives.push_back( Alternative{ expr->clone(), env, Cost::zero } );
     1237                alternatives.push_back( Alternative{ expr, env, Cost::zero } );
    12411238        }
    12421239
     
    12581255                                componentExprs.push_back( restructureCast( idx, toType->getComponent( i ), isGenerated ) );
    12591256                        }
    1260                         delete argExpr;
    12611257                        assert( componentExprs.size() > 0 );
    12621258                        // produce the tuple of casts
     
    13341330                for ( Alternative & alt : finder.alternatives ) {
    13351331                        alternatives.push_back( Alternative(
    1336                                 new VirtualCastExpr( alt.expr->clone(), castExpr->get_result()->clone() ),
     1332                                new VirtualCastExpr( alt.expr, castExpr->get_result()->clone() ),
    13371333                                alt.env, alt.cost ) );
    13381334                }
     
    13561352                        Expression * aggrExpr = agg->expr->clone();
    13571353                        referenceToRvalueConversion( aggrExpr, cost );
    1358                         std::unique_ptr<Expression> guard( aggrExpr );
    13591354
    13601355                        // find member of the given type
     
    13701365
    13711366        void AlternativeFinder::Finder::postvisit( MemberExpr *memberExpr ) {
    1372                 alternatives.push_back( Alternative( memberExpr->clone(), env, Cost::zero ) );
     1367                alternatives.push_back( Alternative( memberExpr, env, Cost::zero ) );
    13731368        }
    13741369
     
    14051400
    14061401        void AlternativeFinder::Finder::postvisit( ConstantExpr *constantExpr ) {
    1407                 alternatives.push_back( Alternative( constantExpr->clone(), env, Cost::zero ) );
     1402                alternatives.push_back( Alternative( constantExpr, env, Cost::zero ) );
    14081403        }
    14091404
     
    14251420                        Alternative &choice = winners.front();
    14261421                        referenceToRvalueConversion( choice.expr, choice.cost );
    1427                         alternatives.push_back( Alternative( new SizeofExpr( choice.expr->clone() ), choice.env, Cost::zero ) );
     1422                        alternatives.push_back( Alternative( new SizeofExpr( choice.expr ), choice.env, Cost::zero ) );
    14281423                } // if
    14291424        }
     
    14461441                        Alternative &choice = winners.front();
    14471442                        referenceToRvalueConversion( choice.expr, choice.cost );
    1448                         alternatives.push_back( Alternative( new AlignofExpr( choice.expr->clone() ), choice.env, Cost::zero ) );
     1443                        alternatives.push_back( Alternative( new AlignofExpr( choice.expr ), choice.env, Cost::zero ) );
    14491444                } // if
    14501445        }
     
    14751470
    14761471        void AlternativeFinder::Finder::postvisit( OffsetofExpr *offsetofExpr ) {
    1477                 alternatives.push_back( Alternative( offsetofExpr->clone(), env, Cost::zero ) );
     1472                alternatives.push_back( Alternative( offsetofExpr, env, Cost::zero ) );
    14781473        }
    14791474
    14801475        void AlternativeFinder::Finder::postvisit( OffsetPackExpr *offsetPackExpr ) {
    1481                 alternatives.push_back( Alternative( offsetPackExpr->clone(), env, Cost::zero ) );
     1476                alternatives.push_back( Alternative( offsetPackExpr, env, Cost::zero ) );
    14821477        }
    14831478
     
    15571552                                compositeEnv.simpleCombine( second.env );
    15581553
    1559                                 LogicalExpr *newExpr = new LogicalExpr( first.expr->clone(), second.expr->clone(), logicalExpr->get_isAnd() );
     1554                                LogicalExpr *newExpr = new LogicalExpr( first.expr, second.expr, logicalExpr->get_isAnd() );
    15601555                                alternatives.push_back( Alternative( newExpr, compositeEnv, first.cost + second.cost ) );
    15611556                        }
     
    15901585                                        Type* commonType = nullptr;
    15911586                                        if ( unify( second.expr->result, third.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    1592                                                 ConditionalExpr *newExpr = new ConditionalExpr( first.expr->clone(), second.expr->clone(), third.expr->clone() );
     1587                                                ConditionalExpr *newExpr = new ConditionalExpr( first.expr, second.expr, third.expr );
    15931588                                                newExpr->result = commonType ? commonType : second.expr->result->clone();
    15941589                                                // convert both options to the conditional result type
     
    16091604                secondFinder.findWithAdjustment( commaExpr->get_arg2() );
    16101605                for ( const Alternative & alt : secondFinder.alternatives ) {
    1611                         alternatives.push_back( Alternative( new CommaExpr( newFirstArg->clone(), alt.expr->clone() ), alt.env, alt.cost ) );
     1606                        alternatives.push_back( Alternative( new CommaExpr( newFirstArg, alt.expr ), alt.env, alt.cost ) );
    16121607                } // for
    1613                 delete newFirstArg;
    16141608        }
    16151609
     
    16321626                                Type* commonType = nullptr;
    16331627                                if ( unify( first.expr->result, second.expr->result, newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
    1634                                         RangeExpr * newExpr = new RangeExpr( first.expr->clone(), second.expr->clone() );
     1628                                        RangeExpr * newExpr = new RangeExpr( first.expr, second.expr );
    16351629                                        newExpr->result = commonType ? commonType : first.expr->result->clone();
    16361630                                        newAlt.expr = newExpr;
     
    16601654
    16611655        void AlternativeFinder::Finder::postvisit( TupleExpr *tupleExpr ) {
    1662                 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) );
     1656                alternatives.push_back( Alternative( tupleExpr, env, Cost::zero ) );
    16631657        }
    16641658
    16651659        void AlternativeFinder::Finder::postvisit( ImplicitCopyCtorExpr * impCpCtorExpr ) {
    1666                 alternatives.push_back( Alternative( impCpCtorExpr->clone(), env, Cost::zero ) );
     1660                alternatives.push_back( Alternative( impCpCtorExpr, env, Cost::zero ) );
    16671661        }
    16681662
     
    16731667                finder.findWithoutPrune( ctorExpr->get_callExpr() );
    16741668                for ( Alternative & alt : finder.alternatives ) {
    1675                         alternatives.push_back( Alternative( new ConstructorExpr( alt.expr->clone() ), alt.env, alt.cost ) );
     1669                        alternatives.push_back( Alternative( new ConstructorExpr( alt.expr ), alt.env, alt.cost ) );
    16761670                }
    16771671        }
    16781672
    16791673        void AlternativeFinder::Finder::postvisit( TupleIndexExpr *tupleExpr ) {
    1680                 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) );
     1674                alternatives.push_back( Alternative( tupleExpr, env, Cost::zero ) );
    16811675        }
    16821676
    16831677        void AlternativeFinder::Finder::postvisit( TupleAssignExpr *tupleAssignExpr ) {
    1684                 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) );
     1678                alternatives.push_back( Alternative( tupleAssignExpr, env, Cost::zero ) );
    16851679        }
    16861680
     
    16901684                for ( Alternative & alt : finder.alternatives ) {
    16911685                        // ensure that the id is passed on to the UniqueExpr alternative so that the expressions are "linked"
    1692                         UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr->clone(), unqExpr->get_id() );
     1686                        UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr, unqExpr->get_id() );
    16931687                        alternatives.push_back( Alternative( newUnqExpr, alt.env, alt.cost ) );
    16941688                }
     
    17411735                                        // count one safe conversion for each value that is thrown away
    17421736                                        thisCost.incSafe( discardedValues );
    1743                                         Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType, true ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
     1737                                        Alternative newAlt( new InitExpr( restructureCast( alt.expr, toType, true ), initAlt.designation ), newEnv, alt.cost, thisCost );
    17441738                                        inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
    17451739                                }
  • src/ResolvExpr/ConversionCost.cc

    r63238a4 r28f3a19  
    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
     
    357358        void ConversionCost::postvisit( EnumInstType * ) {
    358359                static Type::Qualifiers q;
    359                 static BasicType integer( q, BasicType::SignedInt );
    360                 cost = costFunc( &integer, dest, indexer, env );  // safe if dest >= int
     360                static BasicType* integer = new_static_root<BasicType>( q, BasicType::SignedInt );
     361                cost = costFunc( integer, dest, indexer, env );  // safe if dest >= int
    361362                if ( cost < Cost::unsafe ) {
    362363                        cost.incSafe();
  • src/ResolvExpr/ExplodedActual.h

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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
     
    158159                                        castExpr->arg = nullptr;
    159160                                        std::swap( expr->env, castExpr->env );
    160                                         delete castExpr;
    161161                                }
    162162                        }
     
    167167                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) {
    168168                        assertf( untyped, "expected a non-null expression." );
     169
     170                        auto guard = new_generation();  // set up GC generation for this top-level expression
     171
    169172                        TypeEnvironment env;
    170173                        AlternativeFinder finder( indexer, env );
     
    207210                        Alternative & choice = winners.front();
    208211                        if ( findDeletedExpr( choice.expr ) ) {
     212                                trace( choice.expr );
    209213                                SemanticError( untyped->location, choice.expr, "Unique best alternative includes deleted identifier in " );
    210214                        }
    211215                        alt = std::move( choice );
     216                        trace( alt );
    212217                }
    213218
     
    218223                        findUnfinishedKindExpression( untyped, choice, indexer, kindStr, pred, adjust, prune, failFast );
    219224                        finishExpr( choice.expr, choice.env, untyped->env );
    220                         delete untyped;
    221225                        untyped = choice.expr;
    222226                        choice.expr = nullptr;
     
    241245                assertf( expr, "expected a non-null expression." );
    242246
    243                 static CastExpr untyped( nullptr ); // cast to void
    244                 untyped.location = expr->location;
     247                auto untyped = new CastExpr{ expr }; // cast to void
     248                untyped->location = expr->location;
    245249
    246250                // set up and resolve expression cast to void
    247                 untyped.arg = expr;
    248251                Alternative choice;
    249                 findUnfinishedKindExpression( &untyped, choice, indexer, "", standardAlternativeFilter, true );
     252                findUnfinishedKindExpression( untyped, choice, indexer, "", standardAlternativeFilter, true );
    250253                CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( choice.expr );
    251254                env = std::move( choice.env );
    252255
    253256                // clean up resolved expression
    254                 Expression * ret = castExpr->arg;
    255                 castExpr->arg = nullptr;
    256 
    257                 // unlink the arg so that it isn't deleted twice at the end of the program
    258                 untyped.arg = nullptr;
    259                 return ret;
     257                return castExpr->arg;
    260258        }
    261259
     
    265263                Expression * newExpr = resolveInVoidContext( untyped, indexer, env );
    266264                finishExpr( newExpr, env, untyped->env );
    267                 delete untyped;
    268265                untyped = newExpr;
    269266        }
     
    449446                                castExpr->arg = nullptr;
    450447                                std::swap( newExpr->env, castExpr->env );
    451                                 delete castExpr;
    452448                        }
    453449                        caseStmt->condition = newExpr;
     
    747743                // and newExpr may already have inferParams of its own, so a simple swap is not sufficient.
    748744                newExpr->spliceInferParams( initExpr );
    749                 delete initExpr;
    750745
    751746                // get the actual object's type (may not exactly match what comes back from the resolver due to conversions)
     
    765760                                                        ce->set_arg( nullptr );
    766761                                                        std::swap( ce->env, newExpr->env );
    767                                                         delete ce;
    768762                                                }
    769763                                        }
     
    816810                // could not find valid constructor, or found an intrinsic constructor
    817811                // fall back on C-style initializer
    818                 delete ctorInit->get_ctor();
    819                 ctorInit->set_ctor( NULL );
    820                 delete ctorInit->get_dtor();
    821                 ctorInit->set_dtor( NULL );
     812                ctorInit->set_ctor( nullptr );
     813                ctorInit->set_dtor( nullptr );
    822814                maybeAccept( ctorInit->get_init(), *visitor );
    823815        }
     
    845837
    846838                // found a constructor - can get rid of C-style initializer
    847                 delete ctorInit->init;
    848839                ctorInit->init = nullptr;
    849840
     
    852843                // to clean up generated code.
    853844                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->ctor ) ) {
    854                         delete ctorInit->ctor;
    855845                        ctorInit->ctor = nullptr;
    856846                }
    857847
    858848                if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->dtor ) ) {
    859                         delete ctorInit->dtor;
    860849                        ctorInit->dtor = nullptr;
    861850                }
  • src/ResolvExpr/TypeEnvironment.cc

    r63238a4 r28f3a19  
    1717#include <algorithm>                   // for copy, set_intersection
    1818#include <iterator>                    // for ostream_iterator, insert_iterator
    19 #include <memory>                      // for unique_ptr
    2019#include <utility>                     // for pair, move
    2120
     21#include "Common/PassVisitor.h"        // for PassVisitor<GcTracer>
    2222#include "Common/utility.h"            // for maybeClone
     23#include "SynTree/GcTracer.h"          // for PassVisitor<GcTracer>
    2324#include "SynTree/Type.h"              // for Type, FunctionType, Type::Fora...
    2425#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     
    7778        EqvClass &EqvClass::operator=( const EqvClass &other ) {
    7879                if ( this == &other ) return *this;
    79                 delete type;
    8080                initialize( other, *this );
    8181                return *this;
     
    8484        EqvClass &EqvClass::operator=( EqvClass &&other ) {
    8585                if ( this == &other ) return *this;
    86                 delete type;
    8786               
    8887                vars = std::move(other.vars);
    8988                type = other.type;
    90                 other.type = nullptr;
    9189                allowWidening = std::move(other.allowWidening);
    9290                data = std::move(other.data);
     
    9593        }
    9694
    97         EqvClass::~EqvClass() {
    98                 delete type;
    99         }
    100 
    101         void EqvClass::set_type( Type* ty ) {
    102                 if ( ty == type ) return;
    103                 delete type;
    104                 type = ty;
    105         }
     95        void EqvClass::set_type( Type* ty ) { type = ty; }
    10696
    10797        void EqvClass::print( std::ostream &os, Indenter indent ) const {
     
    175165                                        TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->data.kind == TypeDecl::Ftype );
    176166                                        sub.add( *theVar, newTypeInst );
    177                                         delete newTypeInst;
    178167                                } // if
    179168                        } // for
     
    261250                                Type *common = 0;
    262251                                // attempt to unify equivalence class type (which has qualifiers stripped, so they must be restored) with the type to bind to
    263                                 std::unique_ptr< Type > newType( curClass->type->clone() );
     252                                Type *newType = curClass->type->clone();
    264253                                newType->get_qualifiers() = typeInst->get_qualifiers();
    265                                 if ( unifyInexact( newType.get(), bindTo, *this, need, have, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) {
     254                                if ( unifyInexact( newType, bindTo, *this, need, have, openVars, widenMode & WidenMode( curClass->allowWidening, true ), indexer, common ) ) {
    266255                                        if ( common ) {
    267256                                                common->get_qualifiers() = Type::Qualifiers{};
     
    319308                if ( type1 && type2 ) {
    320309                        // both classes bound, merge if bound types can be unified
    321                         std::unique_ptr<Type> newType1{ type1->clone() }, newType2{ type2->clone() };
     310                        Type *newType1 = type1->clone(), *newType2 = type2->clone();
    322311                        WidenMode newWidenMode{ widen1, widen2 };
    323312                        Type *common = 0;
    324                         if ( unifyInexact( newType1.get(), newType2.get(), *this, need, have, openVars, newWidenMode, indexer, common ) ) {
     313                        if ( unifyInexact( newType1, newType2, *this, need, have, openVars, newWidenMode, indexer, common ) ) {
    325314                                class1->vars.insert( class2->vars.begin(), class2->vars.end() );
    326315                                class1->allowWidening = widen1 && widen2;
     
    370359                return out;
    371360        }
     361
     362        PassVisitor<GcTracer> & operator<<( PassVisitor<GcTracer> & gc, const TypeEnvironment & env ) {
     363                for ( const EqvClass & c : env ) {
     364                        maybeAccept( c.type, gc );
     365                }
     366                return gc;
     367        }
    372368} // namespace ResolvExpr
    373369
  • src/ResolvExpr/TypeEnvironment.h

    r63238a4 r28f3a19  
    2929#include "SynTree/Type.h"              // for Type, Type::ForallList
    3030#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     31
     32template< typename Pass >
     33class PassVisitor;
     34class GcTracer;
    3135
    3236namespace ResolvExpr {
     
    8387                EqvClass &operator=( const EqvClass &other );
    8488                EqvClass &operator=( EqvClass &&other );
    85                 ~EqvClass();
    8689                void print( std::ostream &os, Indenter indent = {} ) const;
    8790
     
    148151
    149152        std::ostream & operator<<( std::ostream & out, const TypeEnvironment & env );
     153
     154        PassVisitor<GcTracer> & operator<<( PassVisitor<GcTracer> & gc, const TypeEnvironment & env );
    150155} // namespace ResolvExpr
    151156
  • src/ResolvExpr/Unify.cc

    r63238a4 r28f3a19  
    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
     
    134127                findOpenVars( type2, openVars, closedVars, needAssertions, haveAssertions, true );
    135128                Type *commonType = 0;
    136                 if ( unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType ) ) {
    137                         if ( commonType ) {
    138                                 delete commonType;
    139                         } // if
    140                         return true;
    141                 } else {
    142                         return false;
    143                 } // if
     129                return unifyInexact( type1, type2, env, needAssertions, haveAssertions, openVars, WidenMode( true, true ), indexer, commonType );
    144130        }
    145131
     
    335321
    336322        template< typename Iterator, typename Func >
    337         std::unique_ptr<Type> combineTypes( Iterator begin, Iterator end, Func & toType ) {
     323        Type* combineTypes( Iterator begin, Iterator end, Func & toType ) {
    338324                std::list< Type * > types;
    339325                for ( ; begin != end; ++begin ) {
     
    341327                        flatten( toType( *begin ), back_inserter( types ) );
    342328                }
    343                 return std::unique_ptr<Type>( new TupleType( Type::Qualifiers(), types ) );
     329                return new TupleType{ Type::Qualifiers(), types };
    344330        }
    345331
     
    356342                        if ( isTtype1 && ! isTtype2 ) {
    357343                                // combine all of the things in list2, then unify
    358                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     344                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    359345                        } else if ( isTtype2 && ! isTtype1 ) {
    360346                                // combine all of the things in list1, then unify
    361                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     347                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    362348                        } else if ( ! unifyExact( t1, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    363349                                return false;
     
    369355                        Type * t1 = (*list1Begin)->get_type();
    370356                        if ( Tuples::isTtype( t1 ) ) {
    371                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     357                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    372358                        } else return false;
    373359                } else if ( list2Begin != list2End ) {
     
    375361                        Type * t2 = (*list2Begin)->get_type();
    376362                        if ( Tuples::isTtype( t2 ) ) {
    377                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     363                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    378364                        } else return false;
    379365                } else {
     
    394380                                // expand ttype parameter into its actual type
    395381                                if ( eqvClass->data.kind == TypeDecl::Ttype && eqvClass->type ) {
    396                                         delete typeInst;
    397382                                        return eqvClass->type->clone();
    398383                                }
     
    418403                                dst.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::C, nullptr, t, nullptr ) );
    419404                        }
    420                         delete dcl;
    421405                }
    422406        }
     
    427411                        // flatten the parameter lists for both functions so that tuple structure
    428412                        // doesn't affect unification. Must be a clone so that the types don't change.
    429                         std::unique_ptr<FunctionType> flatFunc( functionType->clone() );
    430                         std::unique_ptr<FunctionType> flatOther( otherFunction->clone() );
     413                        FunctionType* flatFunc = functionType->clone();
     414                        FunctionType* flatOther = otherFunction->clone();
    431415                        flattenList( flatFunc->get_parameters(), flatFunc->get_parameters(), env );
    432416                        flattenList( flatOther->get_parameters(), flatOther->get_parameters(), env );
     
    569553                        if ( isTtype1 && ! isTtype2 ) {
    570554                                // combine all of the things in list2, then unify
    571                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     555                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    572556                        } else if ( isTtype2 && ! isTtype1 ) {
    573557                                // combine all of the things in list1, then unify
    574                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     558                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    575559                        } else if ( ! unifyExact( t1, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ) ) {
    576560                                return false;
     
    582566                        Type * t1 = *list1Begin;
    583567                        if ( Tuples::isTtype( t1 ) ) {
    584                                 return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ).get(), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     568                                return unifyExact( t1, combineTypes( list2Begin, list2End, get_type ), env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    585569                        } else return false;
    586570                } else if ( list2Begin != list2End ) {
     
    588572                        Type * t2 = *list2Begin;
    589573                        if ( Tuples::isTtype( t2 ) ) {
    590                                 return unifyExact( combineTypes( list1Begin, list1End, get_type ).get(), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
     574                                return unifyExact( combineTypes( list1Begin, list1End, get_type ), t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    591575                        } else return false;
    592576                } else {
     
    597581        void Unify::postvisit(TupleType *tupleType) {
    598582                if ( TupleType *otherTuple = dynamic_cast< TupleType* >( type2 ) ) {
    599                         std::unique_ptr<TupleType> flat1( tupleType->clone() );
    600                         std::unique_ptr<TupleType> flat2( otherTuple->clone() );
     583                        TupleType* flat1 = tupleType->clone();
     584                        TupleType* flat2 = otherTuple->clone();
    601585                        std::list<Type *> types1, types2;
    602586
     
    605589                        flat2->acceptMutator( expander );
    606590
    607                         flatten( flat1.get(), back_inserter( types1 ) );
    608                         flatten( flat2.get(), back_inserter( types2 ) );
     591                        flatten( flat1, back_inserter( types1 ) );
     592                        flatten( flat2, back_inserter( types2 ) );
    609593
    610594                        result = unifyList( types1.begin(), types1.end(), types2.begin(), types2.end(), env, needAssertions, haveAssertions, openVars, indexer );
  • src/ResolvExpr/Unify.h

    r63238a4 r28f3a19  
    5454        bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
    5555                std::list< Type* > commonTypes;
    56                 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
    57                         deleteAll( commonTypes );
    58                         return true;
    59                 } else {
    60                         return false;
    61                 } // if
     56                return unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes );
    6257        }
    6358
  • src/SymTab/Autogen.cc

    r63238a4 r28f3a19  
    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 & ) {
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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 "ControlStruct/Mutate.h"      // for ForExprMutator
    5152#include "Common/PassVisitor.h"        // for PassVisitor, WithDeclsToAdd
     
    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;
     
    313313                } // if
    314314                // Always remove the hoisted aggregate from the inner structure.
    315                 GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist, false ); } );
     315                GuardAction( [aggregateDecl]() { filter( aggregateDecl->members, shouldHoist ); } );
    316316        }
    317317
     
    374374                        // one void is the only thing in the list; remove it.
    375375                        if ( containsVoid ) {
    376                                 delete dwts.front();
    377376                                dwts.clear();
    378377                        }
     
    501500                                }
    502501                        }
    503                         deleteAll( td->assertions );
    504502                        td->assertions.clear();
    505503                } // for
     
    617615                                        // expand trait instance into all of its members
    618616                                        expandAssertions( traitInst, back_inserter( type->assertions ) );
    619                                         delete traitInst;
    620617                                } else {
    621618                                        // pass other assertions through
     
    689686                        // grab and remember declaration of size_t
    690687                        SizeType = eliminator.pass.typedefNames["size_t"].first->get_base()->clone();
     688                        GC::get().register_static_root( SizeType );
    691689                } else {
    692690                        // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong
    693691                        // eventually should have a warning for this case.
    694                         SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    695                 }
    696                 filter( translationUnit, isTypedef, true );
     692                        SizeType =
     693                                new_static_root<BasicType>( Type::Qualifiers(), BasicType::LongUnsignedInt );
     694                }
     695                filter( translationUnit, isTypedef );
    697696        }
    698697
     
    708707                                ret->attributes.splice( ret->attributes.end(), typeInst->attributes );
    709708                        } else {
    710                                 deleteAll( ret->attributes );
    711709                                ret->attributes.clear();
    712710                        }
     
    721719                                mutateAll( rtt->parameters, *visitor );  // recursively fix typedefs on parameters
    722720                        } // if
    723                         delete typeInst;
    724721                        return ret;
    725722                } else {
     
    763760                        }
    764761                } else {
    765                         typedefNames[ tyDecl->get_name() ] = std::make_pair( TypedefDeclPtr( tyDecl ), scopeLevel );
     762                        typedefNames[ tyDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
    766763                } // if
    767764
     
    807804                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( objDecl->get_type() ) ) { // function type?
    808805                        // replace the current object declaration with a function declaration
    809                         FunctionDecl * newDecl = new FunctionDecl( objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(), funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() );
    810                         objDecl->get_attributes().clear();
    811                         objDecl->set_type( nullptr );
    812                         delete objDecl;
    813                         return newDecl;
     806                        return new FunctionDecl{
     807                                objDecl->get_name(), objDecl->get_storageClasses(), objDecl->get_linkage(),
     808                                funtype, 0, objDecl->get_attributes(), objDecl->get_funcSpec() };
    814809                } // if
    815810                return objDecl;
     
    835830                        } // if
    836831                        return false;
    837                 }, true);
     832                } );
    838833                return compoundStmt;
    839834        }
     
    843838        template<typename AggDecl>
    844839        AggDecl *EliminateTypedef::handleAggregate( AggDecl * aggDecl ) {
    845                 filter( aggDecl->members, isTypedef, true );
     840                filter( aggDecl->members, isTypedef );
    846841                return aggDecl;
    847842        }
     
    858853                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    859854                        } // if
    860                         TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() ) );
    861                         typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
     855                        TypedefDecl* tyDecl = new TypedefDecl{ aggDecl->get_name(), aggDecl->location, Type::StorageClasses(), type, aggDecl->get_linkage() };
     856                        typedefNames[ aggDecl->get_name() ] = std::make_pair( tyDecl, scopeLevel );
    862857                } // if
    863858        }
     
    973968                static UniqueName indexName( "_compLit" );
    974969
    975                 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() );
    976                 compLitExpr->set_result( nullptr );
    977                 compLitExpr->set_initializer( nullptr );
    978                 delete compLitExpr;
     970                ObjectDecl * tempvar = new ObjectDecl{
     971                        indexName.newName(), storageClasses, LinkageSpec::C, nullptr, compLitExpr->get_result(), compLitExpr->get_initializer() };
    979972                declsToAddBefore.push_back( tempvar );                                  // add modified temporary to current block
    980973                return new VariableExpr( tempvar );
     
    10121005                        // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false.
    10131006                        ObjectDecl * newRet = new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
    1014                         deleteAll( retVals );
    10151007                        retVals.clear();
    10161008                        retVals.push_back( newRet );
     
    10531045                        if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( inner->arg ) ) {
    10541046                                if ( labels.count( nameExpr->name ) ) {
    1055                                         Label name = nameExpr->name;
    1056                                         delete addrExpr;
    1057                                         return new LabelAddressExpr( name );
     1047                                        return new LabelAddressExpr{ nameExpr->name };
    10581048                                }
    10591049                        }
  • src/SynTree/AddressExpr.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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 
    5144ParamEntry::ParamEntry( ParamEntry && other ) :
    5245                decl( other.decl ), actualType( other.actualType ), formalType( other.formalType ), expr( other.expr ), inferParams( std::move( other.inferParams ) ) {
     
    5851ParamEntry & ParamEntry::operator=( ParamEntry && other ) {
    5952        if ( &other == this ) return *this;
    60         delete actualType;
    61         delete formalType;
    62         delete expr;
    6353        decl = other.decl;
    6454        actualType = other.actualType;
     
    8676}
    8777
    88 ApplicationExpr::~ApplicationExpr() {
    89         delete function;
    90         deleteAll( args );
    91 }
    92 
    9378void ApplicationExpr::print( std::ostream &os, Indenter indent ) const {
    9479        os << "Application of" << std::endl << indent+1;
  • src/SynTree/ArrayType.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    3838}
    3939
    40 Declaration::~Declaration() {
    41 }
    42 
    4340void Declaration::fixUniqueId() {
    4441        // don't need to set unique ID twice
     
    6865}
    6966
    70 AsmDecl::~AsmDecl() {
    71         delete stmt;
    72 }
    73 
    7467void AsmDecl::print( std::ostream &os, Indenter indent ) const {
    7568        stmt->print( os, indent );
     
    8578
    8679StaticAssertDecl::StaticAssertDecl( const StaticAssertDecl & other ) : Declaration( other ), condition( maybeClone( other.condition ) ), message( maybeClone( other.message ) )  {
    87 }
    88 
    89 StaticAssertDecl::~StaticAssertDecl() {
    90         delete condition;
    91         delete message;
    9280}
    9381
  • src/SynTree/Declaration.h

    r63238a4 r28f3a19  
    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; }
     
    8887        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    8988        DeclarationWithType( const DeclarationWithType &other );
    90         virtual ~DeclarationWithType();
    91 
     89       
    9290        std::string get_mangleName() const { return mangleName; }
    9391        DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
     
    127125                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    128126        ObjectDecl( const ObjectDecl &other );
    129         virtual ~ObjectDecl();
    130127
    131128        virtual Type * get_type() const override { return type; }
     
    157154                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    158155        FunctionDecl( const FunctionDecl &other );
    159         virtual ~FunctionDecl();
    160156
    161157        virtual Type * get_type() const override { return type; }
     
    185181        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    186182        NamedTypeDecl( const NamedTypeDecl &other );
    187         virtual ~NamedTypeDecl();
    188183
    189184        Type *get_base() const { return base; }
     
    220215        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    221216        TypeDecl( const TypeDecl &other );
    222         virtual ~TypeDecl();
    223217
    224218        Kind get_kind() const { return kind; }
     
    269263        AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    270264        AggregateDecl( const AggregateDecl &other );
    271         virtual ~AggregateDecl();
    272 
     265       
    273266        std::list<Declaration*>& get_members() { return members; }
    274267        std::list<TypeDecl*>& get_parameters() { return parameters; }
     
    354347        AsmDecl( AsmStmt *stmt );
    355348        AsmDecl( const AsmDecl &other );
    356         virtual ~AsmDecl();
    357349
    358350        AsmStmt *get_stmt() { return stmt; }
     
    373365        StaticAssertDecl( Expression * condition, ConstantExpr * message );
    374366        StaticAssertDecl( const StaticAssertDecl & other );
    375         virtual ~StaticAssertDecl();
    376367
    377368        virtual StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
  • src/SynTree/DeclarationWithType.cc

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

    r63238a4 r28f3a19  
    5959Expression::~Expression() {
    6060        delete env;
    61         delete result;
    6261}
    6362
     
    8180ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
    8281}
    83 
    84 ConstantExpr::~ConstantExpr() {}
    8582
    8683void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     
    127124}
    128125
    129 VariableExpr::~VariableExpr() {
    130         // don't delete the declaration, since it points somewhere else in the tree
    131 }
    132 
    133126VariableExpr * VariableExpr::functionPointer( FunctionDecl * func ) {
    134127        VariableExpr * funcExpr = new VariableExpr( func );
     
    157150}
    158151
    159 SizeofExpr::~SizeofExpr() {
    160         delete expr;
    161         delete type;
    162 }
    163 
    164152void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    165153        os << "Sizeof Expression on: ";
     
    183171}
    184172
    185 AlignofExpr::~AlignofExpr() {
    186         delete expr;
    187         delete type;
    188 }
    189 
    190173void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    191174        os << "Alignof Expression on: ";
     
    203186UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
    204187        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    205 
    206 UntypedOffsetofExpr::~UntypedOffsetofExpr() {
    207         delete type;
    208 }
    209188
    210189void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     
    224203        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    225204
    226 OffsetofExpr::~OffsetofExpr() {
    227         delete type;
    228 }
    229 
    230205void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
    231206        os << "Offsetof Expression on member " << member->name << " of ";
     
    241216OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    242217
    243 OffsetPackExpr::~OffsetPackExpr() { delete type; }
    244 
    245218void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
    246219        os << "Offset pack expression on ";
     
    259232AttrExpr::AttrExpr( const AttrExpr &other ) :
    260233                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    261 }
    262 
    263 AttrExpr::~AttrExpr() {
    264         delete attr;
    265         delete expr;
    266         delete type;
    267234}
    268235
     
    287254
    288255CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    289 }
    290 
    291 CastExpr::~CastExpr() {
    292         delete arg;
    293256}
    294257
     
    312275}
    313276
    314 KeywordCastExpr::~KeywordCastExpr() {
    315         delete arg;
    316 }
    317 
    318277const std::string & KeywordCastExpr::targetString() const {
    319278        static const std::string targetStrs[] = {
     
    340299
    341300VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    342 }
    343 
    344 VirtualCastExpr::~VirtualCastExpr() {
    345         delete arg;
    346301}
    347302
     
    368323}
    369324
    370 UntypedMemberExpr::~UntypedMemberExpr() {
    371         delete aggregate;
    372         delete member;
    373 }
    374 
    375325void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    376326        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    399349}
    400350
    401 MemberExpr::~MemberExpr() {
    402         // don't delete the member declaration, since it points somewhere else in the tree
    403         delete aggregate;
    404 }
    405 
    406351void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    407352        os << "Member Expression, with field: " << std::endl;
     
    419364                Expression( other ), function( maybeClone( other.function ) ) {
    420365        cloneAll( other.args, args );
    421 }
    422 
    423 UntypedExpr::~UntypedExpr() {
    424         delete function;
    425         deleteAll( args );
    426366}
    427367
     
    472412}
    473413
    474 NameExpr::~NameExpr() {}
    475 
    476414void NameExpr::print( std::ostream &os, Indenter indent ) const {
    477415        os << "Name: " << get_name();
     
    486424LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
    487425                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    488 }
    489 
    490 LogicalExpr::~LogicalExpr() {
    491         delete arg1;
    492         delete arg2;
    493426}
    494427
     
    506439ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
    507440                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
    508 }
    509 
    510 ConditionalExpr::~ConditionalExpr() {
    511         delete arg1;
    512         delete arg2;
    513         delete arg3;
    514441}
    515442
     
    549476ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    550477        set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
    551         delete callExpr;
    552         deleteAll( tempDecls );
    553         deleteAll( returnDecls );
    554         deleteAll( dtors );
    555478}
    556479
     
    577500}
    578501
    579 ConstructorExpr::~ConstructorExpr() {
    580         delete callExpr;
    581 }
    582 
    583502void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    584503        os <<  "Constructor Expression: " << std::endl << indent+1;
     
    595514
    596515CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    597 
    598 CompoundLiteralExpr::~CompoundLiteralExpr() {
    599         delete initializer;
    600 }
    601516
    602517void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     
    625540        cloneAll( other.dtors, dtors );
    626541}
    627 StmtExpr::~StmtExpr() {
    628         delete statements;
    629         deleteAll( dtors );
    630         deleteAll( returnDecls );
    631 }
    632542void StmtExpr::computeResult() {
    633543        assert( statements );
    634544        std::list< Statement * > & body = statements->kids;
    635         delete result;
    636545        result = nullptr;
    637546        if ( ! returnDecls.empty() ) {
     
    676585UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    677586}
    678 UniqueExpr::~UniqueExpr() {
    679         delete expr;
    680         delete object;
    681         delete var;
    682 }
     587
    683588void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    684589        os << "Unique Expression with id:" << id << std::endl << indent+1;
     
    693598InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
    694599InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
    695 InitAlternative::~InitAlternative() {
    696         delete type;
    697         delete designation;
    698 }
    699600
    700601UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
    701602UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
    702 UntypedInitExpr::~UntypedInitExpr() {
    703         delete expr;
    704 }
    705603
    706604void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     
    720618}
    721619InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
    722 InitExpr::~InitExpr() {
    723         delete expr;
    724         delete designation;
    725 }
    726620
    727621void InitExpr::print( std::ostream & os, Indenter indent ) const {
     
    737631}
    738632DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
    739 DeletedExpr::~DeletedExpr() {
    740         delete expr;
    741 }
    742633
    743634void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
     
    754645}
    755646DefaultArgExpr::DefaultArgExpr( const DefaultArgExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ) {}
    756 DefaultArgExpr::~DefaultArgExpr() {
    757         delete expr;
    758 }
    759647
    760648void DefaultArgExpr::print( std::ostream & os, Indenter indent ) const {
     
    766654GenericExpr::Association::Association( Expression * expr ) : type( nullptr ), expr( expr ), isDefault( true ) {}
    767655GenericExpr::Association::Association( const Association & other ) : type( maybeClone( other.type ) ), expr( maybeClone( other.expr ) ), isDefault( other.isDefault ) {}
    768 GenericExpr::Association::~Association() {
    769         delete type;
    770         delete expr;
    771 }
    772656
    773657GenericExpr::GenericExpr( Expression * control, const std::list<Association> & assoc ) : Expression(), control( control ), associations( assoc ) {}
    774 GenericExpr::GenericExpr( const GenericExpr & other ) : Expression(other), control( maybeClone( other.control ) ), associations( other.associations ) {
    775 }
    776 GenericExpr::~GenericExpr() {
    777         delete control;
    778 }
     658GenericExpr::GenericExpr( const GenericExpr & other ) : Expression(other), control( maybeClone( other.control ) ), associations( other.associations ) {}
     659GenericExpr::~GenericExpr() {}
    779660
    780661void GenericExpr::print( std::ostream & os, Indenter indent ) const {
  • src/SynTree/Expression.h

    r63238a4 r28f3a19  
    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( ParamEntry && other );
    44         ~ParamEntry();
     43        ParamEntry( ParamEntry&& other );
    4544        ParamEntry & operator=( const ParamEntry & other );
    4645        ParamEntry & operator=( ParamEntry && other );
     
    5554/// Expression is the root type for all expressions
    5655class Expression : public BaseSyntaxNode {
     56  protected:
     57        virtual ~Expression();
     58
    5759  public:
    5860        Type * result;
     
    6365        Expression();
    6466        Expression( const Expression & other );
    65         virtual ~Expression();
    6667
    6768        Type *& get_result() { return result; }
     
    9495        ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    9596        ApplicationExpr( const ApplicationExpr & other );
    96         virtual ~ApplicationExpr();
    9797
    9898        Expression * get_function() const { return function; }
     
    116116        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    117117        UntypedExpr( const UntypedExpr & other );
    118         virtual ~UntypedExpr();
    119118
    120119        Expression * get_function() const { return function; }
     
    141140        NameExpr( std::string name );
    142141        NameExpr( const NameExpr & other );
    143         virtual ~NameExpr();
    144142
    145143        const std::string & get_name() const { return name; }
     
    162160        AddressExpr( Expression * arg );
    163161        AddressExpr( const AddressExpr & other );
    164         virtual ~AddressExpr();
    165162
    166163        Expression * get_arg() const { return arg; }
     
    181178        LabelAddressExpr( const Label &arg );
    182179        LabelAddressExpr( const LabelAddressExpr & other );
    183         virtual ~LabelAddressExpr();
    184180
    185181        virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); }
     
    199195        CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor
    200196        CastExpr( const CastExpr & other );
    201         virtual ~CastExpr();
    202197
    203198        Expression * get_arg() const { return arg; }
     
    220215        KeywordCastExpr( Expression * arg, Target target );
    221216        KeywordCastExpr( const KeywordCastExpr & other );
    222         virtual ~KeywordCastExpr();
    223217
    224218        const std::string & targetString() const;
     
    237231        VirtualCastExpr( Expression * arg, Type * toType );
    238232        VirtualCastExpr( const VirtualCastExpr & other );
    239         virtual ~VirtualCastExpr();
    240233
    241234        Expression * get_arg() const { return arg; }
     
    256249        UntypedMemberExpr( Expression * member, Expression * aggregate );
    257250        UntypedMemberExpr( const UntypedMemberExpr & other );
    258         virtual ~UntypedMemberExpr();
    259251
    260252        Expression * get_member() const { return member; }
     
    278270        MemberExpr( DeclarationWithType * member, Expression * aggregate );
    279271        MemberExpr( const MemberExpr & other );
    280         virtual ~MemberExpr();
    281272
    282273        DeclarationWithType * get_member() const { return member; }
     
    299290        VariableExpr( DeclarationWithType * var );
    300291        VariableExpr( const VariableExpr & other );
    301         virtual ~VariableExpr();
    302292
    303293        DeclarationWithType * get_var() const { return var; }
     
    319309        ConstantExpr( Constant constant );
    320310        ConstantExpr( const ConstantExpr & other );
    321         virtual ~ConstantExpr();
    322311
    323312        Constant * get_constant() { return & constant; }
     
    343332        SizeofExpr( const SizeofExpr & other );
    344333        SizeofExpr( Type * type );
    345         virtual ~SizeofExpr();
    346334
    347335        Expression * get_expr() const { return expr; }
     
    368356        AlignofExpr( const AlignofExpr & other );
    369357        AlignofExpr( Type * type );
    370         virtual ~AlignofExpr();
    371358
    372359        Expression * get_expr() const { return expr; }
     
    391378        UntypedOffsetofExpr( Type * type, const std::string & member );
    392379        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
    393         virtual ~UntypedOffsetofExpr();
    394380
    395381        std::string get_member() const { return member; }
     
    412398        OffsetofExpr( Type * type, DeclarationWithType * member );
    413399        OffsetofExpr( const OffsetofExpr & other );
    414         virtual ~OffsetofExpr();
    415400
    416401        Type * get_type() const { return type; }
     
    432417        OffsetPackExpr( StructInstType * type );
    433418        OffsetPackExpr( const OffsetPackExpr & other );
    434         virtual ~OffsetPackExpr();
    435419
    436420        StructInstType * get_type() const { return type; }
     
    454438        AttrExpr( const AttrExpr & other );
    455439        AttrExpr( Expression * attr, Type * type );
    456         virtual ~AttrExpr();
    457440
    458441        Expression * get_attr() const { return attr; }
     
    479462        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true );
    480463        LogicalExpr( const LogicalExpr & other );
    481         virtual ~LogicalExpr();
    482464
    483465        bool get_isAnd() const { return isAnd; }
     
    505487        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 );
    506488        ConditionalExpr( const ConditionalExpr & other );
    507         virtual ~ConditionalExpr();
    508489
    509490        Expression * get_arg1() const { return arg1; }
     
    528509        CommaExpr( Expression * arg1, Expression * arg2 );
    529510        CommaExpr( const CommaExpr & other );
    530         virtual ~CommaExpr();
    531511
    532512        Expression * get_arg1() const { return arg1; }
     
    548528        TypeExpr( Type * type );
    549529        TypeExpr( const TypeExpr & other );
    550         virtual ~TypeExpr();
    551530
    552531        Type * get_type() const { return type; }
     
    568547        AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    569548        AsmExpr( const AsmExpr & other );
    570         virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
    571549
    572550        Expression * get_inout() const { return inout; }
     
    590568/// along with a set of copy constructor calls, one for each argument.
    591569class ImplicitCopyCtorExpr : public Expression {
     570protected:
     571        virtual ~ImplicitCopyCtorExpr();
     572
    592573public:
    593574        ApplicationExpr * callExpr;
     
    598579        ImplicitCopyCtorExpr( ApplicationExpr * callExpr );
    599580        ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );
    600         virtual ~ImplicitCopyCtorExpr();
    601581
    602582        ApplicationExpr * get_callExpr() const { return callExpr; }
     
    620600        ConstructorExpr( Expression * callExpr );
    621601        ConstructorExpr( const ConstructorExpr & other );
    622         ~ConstructorExpr();
    623602
    624603        Expression * get_callExpr() const { return callExpr; }
     
    638617        CompoundLiteralExpr( Type * type, Initializer * initializer );
    639618        CompoundLiteralExpr( const CompoundLiteralExpr & other );
    640         virtual ~CompoundLiteralExpr();
    641619
    642620        Initializer * get_initializer() const { return initializer; }
     
    675653        UntypedTupleExpr( const std::list< Expression * > & exprs );
    676654        UntypedTupleExpr( const UntypedTupleExpr & other );
    677         virtual ~UntypedTupleExpr();
    678655
    679656        std::list<Expression*>& get_exprs() { return exprs; }
     
    692669        TupleExpr( const std::list< Expression * > & exprs );
    693670        TupleExpr( const TupleExpr & other );
    694         virtual ~TupleExpr();
    695671
    696672        std::list<Expression*>& get_exprs() { return exprs; }
     
    710686        TupleIndexExpr( Expression * tuple, unsigned int index );
    711687        TupleIndexExpr( const TupleIndexExpr & other );
    712         virtual ~TupleIndexExpr();
    713688
    714689        Expression * get_tuple() const { return tuple; }
     
    730705        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls );
    731706        TupleAssignExpr( const TupleAssignExpr & other );
    732         virtual ~TupleAssignExpr();
    733707
    734708        TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; }
     
    750724        StmtExpr( CompoundStmt * statements );
    751725        StmtExpr( const StmtExpr & other );
    752         virtual ~StmtExpr();
    753726
    754727        CompoundStmt * get_statements() const { return statements; }
     
    775748        UniqueExpr( Expression * expr, long long idVal = -1 );
    776749        UniqueExpr( const UniqueExpr & other );
    777         ~UniqueExpr();
    778750
    779751        Expression * get_expr() const { return expr; }
     
    805777        InitAlternative( const InitAlternative & other );
    806778        InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it
    807         ~InitAlternative();
    808779};
    809780
     
    815786        UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts );
    816787        UntypedInitExpr( const UntypedInitExpr & other );
    817         ~UntypedInitExpr();
    818788
    819789        Expression * get_expr() const { return expr; }
     
    835805        InitExpr( Expression * expr, Designation * designation );
    836806        InitExpr( const InitExpr & other );
    837         ~InitExpr();
    838807
    839808        Expression * get_expr() const { return expr; }
     
    857826        DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
    858827        DeletedExpr( const DeletedExpr & other );
    859         ~DeletedExpr();
    860828
    861829        virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
     
    872840        DefaultArgExpr( Expression * expr );
    873841        DefaultArgExpr( const DefaultArgExpr & other );
    874         ~DefaultArgExpr();
    875842
    876843        virtual DefaultArgExpr * clone() const { return new DefaultArgExpr( * this ); }
     
    892859                Association( const Association & other );
    893860                Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it
    894                 ~Association();
    895861        };
    896862
     
    900866        GenericExpr( Expression * control, const std::list<Association> & assoc );
    901867        GenericExpr( const GenericExpr & other );
    902         virtual ~GenericExpr();
     868        ~GenericExpr();
    903869
    904870        virtual GenericExpr * clone() const { return new GenericExpr( * this ); }
  • src/SynTree/FunctionDecl.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

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

    r63238a4 r28f3a19  
    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
     
    129116ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    130117
    131 ReturnStmt::~ReturnStmt() {
    132         delete expr;
    133 }
    134 
    135118void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
    136119        os << "Return Statement, returning: ";
     
    148131        Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {
    149132        cloneAll( other.initialization, initialization );
    150 }
    151 
    152 IfStmt::~IfStmt() {
    153         deleteAll( initialization );
    154         delete condition;
    155         delete thenPart;
    156         delete elsePart;
    157133}
    158134
     
    192168}
    193169
    194 SwitchStmt::~SwitchStmt() {
    195         delete condition;
    196         // destroy statements
    197         deleteAll( statements );
    198 }
    199 
    200170void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
    201171        os << "Switch on condition: ";
     
    216186        Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
    217187        cloneAll( other.stmts, stmts );
    218 }
    219 
    220 CaseStmt::~CaseStmt() {
    221         delete condition;
    222         deleteAll( stmts );
    223188}
    224189
     
    251216}
    252217
    253 WhileStmt::~WhileStmt() {
    254         delete body;
    255         delete condition;
    256 }
    257 
    258218void WhileStmt::print( std::ostream &os, Indenter indent ) const {
    259219        os << "While on condition: " << endl ;
     
    273233                cloneAll( other.initialization, initialization );
    274234
    275 }
    276 
    277 ForStmt::~ForStmt() {
    278         deleteAll( initialization );
    279         delete condition;
    280         delete increment;
    281         delete body;
    282235}
    283236
     
    319272ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
    320273        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    321 }
    322 
    323 ThrowStmt::~ThrowStmt() {
    324         delete expr;
    325         delete target;
    326274}
    327275
     
    344292}
    345293
    346 TryStmt::~TryStmt() {
    347         delete block;
    348         deleteAll( handlers );
    349         delete finallyBlock;
    350 }
    351 
    352294void TryStmt::print( std::ostream &os, Indenter indent ) const {
    353295        os << "Try Statement" << endl;
     
    378320}
    379321
    380 CatchStmt::~CatchStmt() {
    381         delete decl;
    382         delete body;
    383 }
    384 
    385322void CatchStmt::print( std::ostream &os, Indenter indent ) const {
    386323        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
     
    405342
    406343FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {
    407 }
    408 
    409 FinallyStmt::~FinallyStmt() {
    410         delete block;
    411344}
    412345
     
    440373        orelse .statement = other.orelse .statement->clone();
    441374        orelse .condition = other.orelse .condition->clone();
    442 }
    443 
    444 WaitForStmt::~WaitForStmt() {
    445         for( auto & clause : clauses ) {
    446                 delete clause.target.function;
    447                 deleteAll( clause.target.arguments );
    448                 delete clause.statement;
    449                 delete clause.condition;
    450         }
    451 
    452         delete timeout.time;
    453         delete timeout.statement;
    454         delete timeout.condition;
    455 
    456         delete orelse.statement;
    457         delete orelse.condition;
    458375}
    459376
     
    497414        cloneAll( other.exprs, exprs );
    498415}
    499 WithStmt::~WithStmt() {
    500         deleteAll( exprs );
    501         delete stmt;
    502 }
    503416
    504417void WithStmt::print( std::ostream & os, Indenter indent ) const {
     
    526439}
    527440
    528 ImplicitCtorDtorStmt::~ImplicitCtorDtorStmt() {
    529         delete callStmt;
    530 }
    531 
    532441void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const {
    533442        os << "Implicit Ctor Dtor Statement" << endl;
  • src/SynTree/Statement.h

    r63238a4 r28f3a19  
    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; }
     
    149145                        std::list<Statement *> initialization = std::list<Statement *>() );
    150146        IfStmt( const IfStmt &other );
    151         virtual ~IfStmt();
    152147
    153148        std::list<Statement *> &get_initialization() { return initialization; }
     
    172167        SwitchStmt( Expression *condition, const std::list<Statement *> &statements );
    173168        SwitchStmt( const SwitchStmt &other );
    174         virtual ~SwitchStmt();
    175169
    176170        Expression *get_condition() { return condition; }
     
    194188        CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw (SemanticErrorException);
    195189        CaseStmt( const CaseStmt &other );
    196         virtual ~CaseStmt();
    197190
    198191        static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() );
     
    226219               Statement *body, std::list<Statement *> & initialization, bool isDoWhile = false );
    227220        WhileStmt( const WhileStmt &other );
    228         virtual ~WhileStmt();
    229221
    230222        Expression *get_condition() { return condition; }
     
    251243             Expression *condition = 0, Expression *increment = 0, Statement *body = 0 );
    252244        ForStmt( const ForStmt &other );
    253         virtual ~ForStmt();
    254245
    255246        std::list<Statement *> &get_initialization() { return initialization; }
     
    304295        ReturnStmt( Expression *expr );
    305296        ReturnStmt( const ReturnStmt &other );
    306         virtual ~ReturnStmt();
    307297
    308298        Expression *get_expr() { return expr; }
     
    325315        ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr );
    326316        ThrowStmt( const ThrowStmt &other );
    327         virtual ~ThrowStmt();
    328317
    329318        Kind get_kind() { return kind; }
     
    347336        TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );
    348337        TryStmt( const TryStmt &other );
    349         virtual ~TryStmt();
    350338
    351339        CompoundStmt *get_block() const { return block; }
     
    374362                   Expression *cond, Statement *body );
    375363        CatchStmt( const CatchStmt &other );
    376         virtual ~CatchStmt();
    377364
    378365        Kind get_kind() { return kind; }
     
    396383        FinallyStmt( CompoundStmt *block );
    397384        FinallyStmt( const FinallyStmt &other );
    398         virtual ~FinallyStmt();
    399385
    400386        CompoundStmt *get_block() const { return block; }
     
    423409        WaitForStmt();
    424410        WaitForStmt( const WaitForStmt & );
    425         virtual ~WaitForStmt();
    426411
    427412        std::vector<Clause> clauses;
     
    452437        WithStmt( const std::list< Expression * > & exprs, Statement * stmt );
    453438        WithStmt( const WithStmt & other );
    454         virtual ~WithStmt();
    455439
    456440        virtual WithStmt * clone() const override { return new WithStmt( *this ); }
     
    468452        DeclStmt( Declaration *decl );
    469453        DeclStmt( const DeclStmt &other );
    470         virtual ~DeclStmt();
    471454
    472455        Declaration *get_decl() const { return decl; }
     
    490473        ImplicitCtorDtorStmt( Statement * callStmt );
    491474        ImplicitCtorDtorStmt( const ImplicitCtorDtorStmt & other );
    492         virtual ~ImplicitCtorDtorStmt();
    493475
    494476        Statement *get_callStmt() const { return callStmt; }
  • src/SynTree/TupleExpr.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    6363}
    6464
    65 Type::~Type() {
    66         deleteAll( forall );
    67         deleteAll( attributes );
    68 }
    69 
    7065// These must remain in the same order as the corresponding bit fields.
    7166const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
  • src/SynTree/Type.h

    r63238a4 r28f3a19  
    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; }
     
    263262        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    264263        PointerType( const PointerType& );
    265         virtual ~PointerType();
    266264
    267265        Type *get_base() { return base; }
     
    293291        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    294292        ArrayType( const ArrayType& );
    295         virtual ~ArrayType();
    296293
    297294        Type *get_base() { return base; }
     
    321318        ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    322319        ReferenceType( const ReferenceType & );
    323         virtual ~ReferenceType();
    324320
    325321        Type *get_base() { return base; }
     
    354350        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    355351        FunctionType( const FunctionType& );
    356         virtual ~FunctionType();
    357352
    358353        std::list<DeclarationWithType*> & get_returnVals() { return returnVals; }
     
    378373        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    379374        ReferenceToType( const ReferenceToType & other );
    380         virtual ~ReferenceToType();
    381375
    382376        const std::string & get_name() const { return name; }
     
    505499        TraitInstType( const Type::Qualifiers & tq, TraitDecl * baseTrait, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    506500        TraitInstType( const TraitInstType & other );
    507         ~TraitInstType();
    508501
    509502        virtual bool isComplete() const override;
     
    527520        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    528521        TypeInstType( const TypeInstType & other );
    529         ~TypeInstType();
    530522
    531523        TypeDecl *get_baseType() const { return baseType; }
     
    551543        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    552544        TupleType( const TupleType& );
    553         virtual ~TupleType();
    554545
    555546        typedef std::list<Type*> value_type;
     
    585576        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    586577        TypeofType( const TypeofType& );
    587         virtual ~TypeofType();
    588578
    589579        Expression *get_expr() const { return expr; }
     
    608598        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    609599        AttrType( const AttrType& );
    610         virtual ~AttrType();
    611600
    612601        const std::string & get_name() const { return name; }
  • src/SynTree/TypeDecl.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    126126
    127127        virtual void visit( Attribute * attribute ) = 0;
     128
     129        virtual void visit( TypeSubstitution * sub ) = 0;
    128130};
    129131
  • src/SynTree/module.mk

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

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
    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                                }
     
    8484                                // tuple type, but not tuple expr - recursively index into its components.
    8585                                // if expr type is reference, convert to value type
    86                                 Expression * arg = expr->clone();
     86                                Expression * arg = expr;
    8787                                if ( Tuples::maybeImpureIgnoreUnique( arg ) ) {
    8888                                        // expressions which may contain side effects require a single unique instance of the expression.
     
    9494                                }
    9595                                for ( unsigned int i = 0; i < tupleType->size(); i++ ) {
    96                                         TupleIndexExpr * idx = new TupleIndexExpr( arg->clone(), i );
     96                                        TupleIndexExpr * idx = new TupleIndexExpr( arg, i );
    9797                                        explodeUnique( idx, alt, indexer, std::forward<Output>(out), isTupleAssign );
    98                                         delete idx;
    9998                                }
    100                                 delete arg;
    10199                        }
    102100                } else {
    103                         // atomic (non-tuple) type - output a clone of the expression in a new alternative
    104                         append( std::forward<Output>(out), expr->clone(), alt.env, alt.cost, alt.cvtCost );
     101                        // atomic (non-tuple) type - output the expression in a new alternative
     102                        append( std::forward<Output>(out), expr, alt.env, alt.cost, alt.cvtCost );
    105103                }
    106104        }
  • src/Tuples/TupleExpansion.cc

    r63238a4 r28f3a19  
    4646
    4747                        std::map< int, Expression * > decls; // not vector, because order added may not be increasing order
    48 
    49                         ~UniqueExprExpander() {
    50                                 for ( std::pair<const int, Expression *> & p : decls ) {
    51                                         delete p.second;
    52                                 }
    53                         }
    5448                };
    5549
     
    112106                                UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( memberExpr->member, inner );
    113107                                inner->location = newMemberExpr->location = loc;
    114                                 memberExpr->member = nullptr;
    115                                 memberExpr->aggregate = nullptr;
    116                                 delete memberExpr;
    117108                                return newMemberExpr->acceptMutator( expander );
    118109                        } else {
     
    134125                                expr->location = memberExpr->location;
    135126                        }
    136                         delete aggr;
    137127                        tupleExpr->location = memberExpr->location;
    138128                        return tupleExpr;
     
    180170                        decls[id] = condExpr;
    181171                }
    182                 delete unqExpr;
    183172                return decls[id]->clone();
    184173        }
     
    190179                ret->set_env( assnExpr->get_env() );
    191180                assnExpr->set_env( nullptr );
    192                 delete assnExpr;
    193181                return ret;
    194182        }
     
    221209                        newType->get_parameters().push_back( new TypeExpr( t->clone() ) );
    222210                }
    223                 delete tupleType;
    224211                return newType;
    225212        }
     
    232219                TypeSubstitution * env = tupleExpr->env;
    233220                tupleExpr->env = nullptr;
    234                 delete tupleExpr;
    235221
    236222                if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * > ( tuple ) ) {
     
    242228                                ret->env = env;
    243229                                expr = nullptr; // remove from list so it can safely be deleted
    244                                 delete tupleExpr;
    245230                                return ret;
    246231                        }
     
    287272                TypeSubstitution * env = tupleExpr->get_env();
    288273
    289                 // remove data from shell and delete it
     274                // remove data from shell
    290275                tupleExpr->set_result( nullptr );
    291276                tupleExpr->get_exprs().clear();
    292277                tupleExpr->set_env( nullptr );
    293                 delete tupleExpr;
    294278
    295279                return replaceTupleExpr( result, exprs, env );
  • src/Virtual/ExpandCasts.cc

    r63238a4 r28f3a19  
    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

    r63238a4 r28f3a19  
     1
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     
    3536#include "CodeTools/TrackLoc.h"             // for fillLocations
    3637#include "Common/CompilerError.h"           // for CompilerError
     38#include "Common/GC.h"                      // for GC
    3739#include "Common/Heap.h"
    3840#include "Common/PassVisitor.h"
     
    5759#include "SymTab/Validate.h"                // for validate
    5860#include "SynTree/Declaration.h"            // for Declaration
     61#include "SynTree/GcTracer.h"               // for GC << TranslationUnit
    5962#include "SynTree/Visitor.h"                // for acceptAll
    6063#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
     
    178181        signal( SIGABRT, sigAbortHandler );
    179182
    180         // std::cout << "main" << std::endl;
    181         // for ( int i = 0; i < argc; i += 1 ) {
    182         //      std::cout << '\t' << argv[i] << std::endl;
    183         // } // for
    184 
    185183        parse_cmdline( argc, argv, filename );                          // process command-line arguments
    186184        CodeGen::FixMain::setReplaceMain( !nomainp );
     
    241239                delete parseTree;
    242240                parseTree = nullptr;
     241                collect( translationUnit );
    243242
    244243                if ( astp ) {
     
    249248                // add the assignment statement after the initialization of a type parameter
    250249                PASS( "validate", SymTab::validate( translationUnit, symtabp ) );
    251                 if ( symtabp ) {
    252                         deleteAll( translationUnit );
    253                         return 0;
    254                 } // if
     250                if ( symtabp ) return 0;
     251                collect( translationUnit );
    255252
    256253                if ( expraltp ) {
     
    269266                PASS( "genInit", InitTweak::genInit( translationUnit ) );
    270267                PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) );
     268                collect( translationUnit );
    271269                if ( libcfap ) {
    272270                        // generate the bodies of cfa library functions
     
    276274                if ( declstatsp ) {
    277275                        CodeTools::printDeclStats( translationUnit );
    278                         deleteAll( translationUnit );
    279276                        return 0;
    280277                }
     
    288285
    289286                PASS( "resolve", ResolvExpr::resolve( translationUnit ) );
     287                collect( translationUnit );
    290288                if ( exprp ) {
    291289                        dump( translationUnit );
     
    295293                // fix ObjectDecl - replaces ConstructorInit nodes
    296294                PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
     295                collect( translationUnit );
    297296                if ( ctorinitp ) {
    298297                        dump ( translationUnit );
     
    309308
    310309                PASS( "expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
    311 
     310                collect( translationUnit );
    312311                if ( tuplep ) {
    313312                        dump( translationUnit );
     
    318317
    319318                PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) );
     319                collect( translationUnit );
    320320                if ( genericsp ) {
    321321                        dump( translationUnit );
     
    323323                }
    324324                PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) );
    325 
    326 
     325                collect( translationUnit );
    327326                if ( bboxp ) {
    328327                        dump( translationUnit );
     
    330329                } // if
    331330                PASS( "box", GenPoly::box( translationUnit ) );
    332 
     331                collect( translationUnit );
    333332                if ( bcodegenp ) {
    334333                        dump( translationUnit );
     
    386385        }// try
    387386
    388         deleteAll( translationUnit );
    389387        if(!libcfap && !treep) HeapStats::printStats();
    390388        return 0;
     
    601599                printAll( decls, out );
    602600        }
    603         deleteAll( translationUnit );
    604601} // dump
    605602
Note: See TracChangeset for help on using the changeset viewer.