Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r7b3f66b rec79847  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 13 11:44:26 2016
     12// Last Modified On : Mon May 09 12:36:02 2016
    1313// Update Count     : 30
    1414//
     
    1717#include <list>
    1818#include "FixInit.h"
    19 #include "InitTweak.h"
    2019#include "ResolvExpr/Resolver.h"
    2120#include "ResolvExpr/typeops.h"
     
    2827#include "SymTab/Indexer.h"
    2928#include "GenPoly/PolyMutator.h"
     29#include "GenPoly/GenPoly.h"
    3030
    3131bool ctordtorp = false;
     
    398398        }
    399399
     400        bool isInstrinsicSingleArgCallStmt( Statement * stmt ) {
     401                if ( stmt == NULL ) return false;
     402                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
     403                        ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( exprStmt->get_expr() );
     404                        assert( appExpr );
     405                        VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
     406                        assert( function );
     407                        // check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor
     408                        // will call all member dtors, and some members may have a user defined dtor.
     409                        FunctionType * funcType = GenPoly::getFunctionType( function->get_var()->get_type() );
     410                        assert( funcType );
     411                        return function->get_var()->get_linkage() == LinkageSpec::Intrinsic && funcType->get_parameters().size() == 1;
     412                } else if ( CompoundStmt * compoundStmt = dynamic_cast< CompoundStmt * >( stmt ) ) {
     413                        // could also be a compound statement with a loop, in the case of an array
     414                        assert( compoundStmt->get_kids().size() == 2 ); // loop variable and loop
     415                        ForStmt * forStmt = dynamic_cast< ForStmt * >( compoundStmt->get_kids().back() );
     416                        assert( forStmt && forStmt->get_body() );
     417                        return isInstrinsicSingleArgCallStmt( forStmt->get_body() );
     418                } else {
     419                        // should never get here
     420                        assert( false && "encountered unknown call statement" );
     421                }
     422        }
     423
    400424        namespace {
    401425                template<typename Iterator, typename OutputIterator>
     
    404428                                // remove if instrinsic destructor statement. Note that this is only called
    405429                                // on lists of implicit dtors, so if the user manually calls an intrinsic
    406                                 // dtor then the call must (and will) still be generated since the argument
    407                                 // may contain side effects.
     430                                // dtor then the call will still be generated
    408431                                if ( ! isInstrinsicSingleArgCallStmt( *it ) ) {
    409432                                        // don't need to call intrinsic dtor, because it does nothing, but
Note: See TracChangeset for help on using the changeset viewer.