Ignore:
Timestamp:
Oct 17, 2018, 4:16:18 PM (3 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
fbecee5
Parents:
da48183
Message:

Fix memory bugs in deferred resolution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Alternative.cc

    rda48183 r2c187378  
    2020#include <utility>                       // for move
    2121
    22 #include "Common/utility.h"              // for maybeClone
     22#include "Common/utility.h"              // for cloneAll
    2323#include "ResolvExpr/Cost.h"             // for Cost, Cost::zero, operator<<
    2424#include "ResolvExpr/TypeEnvironment.h"  // for TypeEnvironment
     
    3535        Alternative::Alternative( const Alternative &o, Expression *expr, const Cost &cost )
    3636        : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( o.env ), openVars( o.openVars ),
    37           need( o.need ) {}
     37          need() { cloneAll( o.need, need ); }
    3838
    3939        Alternative::Alternative( Expression *expr, const TypeEnvironment &env,
    40                 const OpenVarSet& openVars, const AssertionList& need, const Cost& cost )
     40                const OpenVarSet& openVars, const AssertionList& oneed, const Cost& cost )
    4141        : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( env ), openVars( openVars ),
    42           need( need ) {}
     42          need() { cloneAll( oneed, need ); }
    4343
    4444        Alternative::Alternative( Expression *expr, const TypeEnvironment &env,
    45                 const OpenVarSet& openVars, const AssertionList& need, const Cost& cost,
     45                const OpenVarSet& openVars, const AssertionList& oneed, const Cost& cost,
    4646                const Cost &cvtCost )
    4747        : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ), openVars( openVars ),
    48           need( need ) {}
     48          need() { cloneAll( oneed, need ); }
     49       
     50        Alternative::Alternative( Expression *expr, const TypeEnvironment &env,
     51                const OpenVarSet &openVars, const AssertionSet &oneed, const Cost &cost)
     52        : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( env ), openVars( openVars ),
     53          need() { cloneAll( oneed, need ); }
     54       
     55        Alternative::Alternative( Expression *expr, const TypeEnvironment &env,
     56                const OpenVarSet &openVars, const AssertionSet &oneed, const Cost &cost,
     57                const Cost& cvtCost )
     58        : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ), openVars( openVars ),
     59          need() { cloneAll( oneed, need ); }
     60       
     61        Alternative::Alternative( Expression *expr, TypeEnvironment &&env, OpenVarSet &&openVars,
     62                AssertionSet &&needSet, const Cost &cost )
     63        : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( std::move(env) ),
     64          openVars( std::move(openVars) ), need( needSet.begin(), needSet.end() ) {}
     65       
     66        Alternative::Alternative( Expression *expr, TypeEnvironment &&env, OpenVarSet &&openVars,
     67                AssertionSet &&needSet, const Cost &cost, const Cost &cvtCost )
     68        : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( std::move(env) ),
     69          openVars( std::move(openVars) ), need( needSet.begin(), needSet.end() ) {}
    4970
    5071        Alternative::Alternative( const Alternative &other )
    5172        : cost( other.cost ), cvtCost( other.cvtCost ), expr( maybeClone( other.expr ) ),
    52           env( other.env ), openVars( other.openVars ), need( other.need ) {}
     73          env( other.env ), openVars( other.openVars ), need() { cloneAll( other.need, need ); }
    5374
    5475        Alternative &Alternative::operator=( const Alternative &other ) {
     
    6081                env = other.env;
    6182                openVars = other.openVars;
    62                 need = other.need;
     83                need.clear();
     84                cloneAll( other.need, need );
    6385                return *this;
    6486        }
     
    6789        : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ),
    6890          env( std::move( other.env ) ), openVars( std::move( other.openVars ) ),
    69           need( std::move( other.need ) ) {
    70                 other.expr = nullptr;
    71         }
     91          need( std::move( other.need ) ) { other.expr = nullptr; }
    7292
    7393        Alternative & Alternative::operator=( Alternative && other ) {
Note: See TracChangeset for help on using the changeset viewer.