Changeset 620cb95 for src/InitTweak


Ignore:
Timestamp:
Mar 3, 2016, 4:50:48 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
972e6f7
Parents:
071a31a
Message:

separate Autogen from Validate, call default ctor/dtors on array elements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/RemoveInit.cc

    r071a31a r620cb95  
    2323#include "SynTree/Initializer.h"
    2424#include "SynTree/Mutator.h"
     25#include "SymTab/Autogen.h"
    2526#include "GenPoly/PolyMutator.h"
    2627
     
    194195                                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) {
    195196                                        // call into makeArrayFunction from validate.cc to generate calls to ctor/dtor for each element of array
     197                                        // TODO: walk initializer and generate appropriate copy ctor if element has initializer
     198                                        SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "?{}", back_inserter( stmtsToAddAfter ) );
     199                                        SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "^?{}", front_inserter( destructorStmts ), false );
    196200                                } else {
    197201                                        // it's sufficient to attempt to call the ctor/dtor for the given object and its initializer
     
    228232
    229233        CompoundStmt * CtorDtor::mutate( CompoundStmt * compoundStmt ) {
     234                // don't want to dump all destructors when block is left,
     235                // just the destructors associated with variables defined in this block
     236                std::list< Statement * > oldDestructorStmts = destructorStmts;
     237                destructorStmts = std::list<Statement *>();
     238
    230239                CompoundStmt * ret = PolyMutator::mutate( compoundStmt );
    231240                std::list< Statement * > &statements = ret->get_kids();
     
    235244                        statements.splice( statements.end(), destructorStmts );
    236245                } // if
     246
     247                destructorStmts = oldDestructorStmts;
    237248                return ret;
    238249        }
Note: See TracChangeset for help on using the changeset viewer.