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.h

    rda48183 r2c187378  
    2222#include "TypeEnvironment.h"  // for TypeEnvironment, AssertionSetValue
    2323
     24#include "Common/utility.h"   // for maybeClone
     25
    2426class Expression;
    2527
     
    3537                AssertionItem( const AssertionSet::value_type& e ) : decl(e.first), info(e.second) {}
    3638                operator AssertionSet::value_type () const { return { decl, info }; }
     39
     40                // to support cloneAll
     41                AssertionItem clone() const { return { maybeClone(decl), info }; }
    3742        };
    3843        /// A list of unresolved assertions
    3944        using AssertionList = std::vector<AssertionItem>;
     45
     46        /// Clones an assertion list into an assertion set
     47        static inline void cloneAll( const AssertionList& src, AssertionSet& dst ) {
     48                for ( const AssertionItem& item : src ) {
     49                        dst.emplace( maybeClone(item.decl), item.info );
     50                }
     51        }
     52
     53        /// Clones an assertion set into an assertion list
     54        static inline void cloneAll( const AssertionSet& src, AssertionList& dst ) {
     55                dst.reserve( dst.size() + src.size() );
     56                for ( const auto& entry : src ) {
     57                        dst.emplace_back( maybeClone(entry.first), entry.second );
     58                }
     59        }
     60
     61        /// Clones an assertion list into an assertion list
     62        static inline void cloneAll( const AssertionList& src, AssertionList& dst ) {
     63                dst.reserve( dst.size() + src.size() );
     64                for ( const AssertionItem& item : src ) {
     65                        dst.emplace_back( maybeClone(item.decl), item.info );
     66                }
     67        }
    4068
    4169        /// One option for resolution of an expression
     
    4876                Alternative( Expression *expr, const TypeEnvironment &env, const OpenVarSet& openVars,
    4977                        const AssertionList& need, const Cost &cost, const Cost &cvtCost );
     78                Alternative( Expression *expr, const TypeEnvironment &env, const OpenVarSet &openVars,
     79                        const AssertionSet &need, const Cost &cost);
     80                Alternative( Expression *expr, const TypeEnvironment &env, const OpenVarSet &openVars,
     81                        const AssertionSet &need, const Cost &cost, const Cost& cvtCost );
     82                Alternative( Expression *expr, TypeEnvironment &&env, OpenVarSet &&openVars,
     83                        AssertionSet &&need, const Cost &cost );
     84                Alternative( Expression *expr, TypeEnvironment &&env, OpenVarSet &&openVars,
     85                        AssertionSet &&need, const Cost &cost, const Cost &cvtCost );
    5086                Alternative( const Alternative &other );
    5187                Alternative &operator=( const Alternative &other );
Note: See TracChangeset for help on using the changeset viewer.