Changeset 96fc67b for src/InitTweak


Ignore:
Timestamp:
Nov 9, 2017, 1:02:01 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
20eacb7
Parents:
7543dec
Message:

Replace variable in array destructor with dereference

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r7543dec r96fc67b  
    676676                        // the original code contains uses of objDecl - replace them with the newly generated 'this' parameter.
    677677                        ObjectDecl * thisParam = getParamThis( dtorFunc->type );
    678                         VarExprReplacer::replace( dtor, { std::make_pair( objDecl, new VariableExpr( thisParam ) ) } );
     678                        Expression * replacement = new VariableExpr( thisParam );
     679                        if ( ArrayType * at = dynamic_cast< ArrayType * >( replacement->result->stripReferences() ) ) {
     680                                // need to cast away reference for array types, since the destructor is generated without the reference type
     681                                replacement = new CastExpr( replacement, at->clone() );
     682                        }
     683                        VarExprReplacer::replace( dtor, { std::make_pair( objDecl, replacement ) } );
    679684                        dtorFunc->statements->push_back( dtor );
    680685
Note: See TracChangeset for help on using the changeset viewer.