Changeset 92f5279


Ignore:
Timestamp:
Jun 25, 2019, 2:51:50 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b604426
Parents:
bcb311b
Message:

Deeper clone on forall-lists on types to fix weak-ref error

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    rbcb311b r92f5279  
    201201        TypeDecl * clone() const override { return new TypeDecl{ *this }; }
    202202        MUTATE_FRIEND
     203        friend class ParameterizedType;  // to allow deep clones
    203204};
    204205
  • src/AST/Type.hpp

    rbcb311b r92f5279  
    268268public:
    269269        using ForallList = std::vector<ptr<TypeDecl>>;
    270 
     270       
    271271        ForallList forall;
    272272
     
    277277        ParameterizedType( CV::Qualifiers q, std::vector<ptr<Attribute>> && as = {} )
    278278        : Type(q, std::move(as)), forall() {}
     279
     280        ParameterizedType( const ParameterizedType & o ) : Type( o ), forall() {
     281                // one-level deep clone to avoid weak-reference errors
     282                forall.reserve( o.forall.size() );
     283                for ( const TypeDecl * d : o.forall ) { forall.emplace_back( d->clone() ); }
     284        }
     285
     286        ParameterizedType( ParameterizedType && ) = default;
     287
     288        // no need to change destructor, and operator= deleted in Node
    279289
    280290private:
Note: See TracChangeset for help on using the changeset viewer.