Ignore:
Timestamp:
May 13, 2016, 1:18:35 PM (8 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:
d668182
Parents:
fb24492
Message:

Don't construct global extern variables, handle global array construction separately, stub for array initialization list with constructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    rfb24492 r7b3f66b  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon May 09 12:36:02 2016
     12// Last Modified On : Fri May 13 11:44:26 2016
    1313// Update Count     : 30
    1414//
     
    1717#include <list>
    1818#include "FixInit.h"
     19#include "InitTweak.h"
    1920#include "ResolvExpr/Resolver.h"
    2021#include "ResolvExpr/typeops.h"
     
    2728#include "SymTab/Indexer.h"
    2829#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 
    424400        namespace {
    425401                template<typename Iterator, typename OutputIterator>
     
    428404                                // remove if instrinsic destructor statement. Note that this is only called
    429405                                // on lists of implicit dtors, so if the user manually calls an intrinsic
    430                                 // dtor then the call will still be generated
     406                                // dtor then the call must (and will) still be generated since the argument
     407                                // may contain side effects.
    431408                                if ( ! isInstrinsicSingleArgCallStmt( *it ) ) {
    432409                                        // don't need to call intrinsic dtor, because it does nothing, but
Note: See TracChangeset for help on using the changeset viewer.