Changes in / [8b11840:b56c17c]


Ignore:
Location:
src/InitTweak
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r8b11840 rb56c17c  
    5858#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution, operator<<
    5959#include "SynTree/Visitor.h"           // for acceptAll, maybeAccept
    60 #include "Tuples/Tuples.h"             // for isTtype
    6160
    6261bool ctordtorp = false; // print all debug
     
    368367                }
    369368
    370                 bool ResolveCopyCtors::skipCopyConstruct( Type * type ) {
    371                         return dynamic_cast< VarArgsType * >( type ) || dynamic_cast< ReferenceType * >( type ) || GenPoly::getFunctionType( type ) || Tuples::isTtype( type );
    372                 }
     369                bool ResolveCopyCtors::skipCopyConstruct( Type * type ) { return ! isConstructable( type ); }
    373370
    374371                Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
  • src/InitTweak/GenInit.cc

    r8b11840 rb56c17c  
    7575                // that need to be constructed or destructed
    7676                void previsit( StructDecl *aggregateDecl );
    77                 void premutate( AggregateDecl * ) { visit_children = false; }
    78                 void premutate( NamedTypeDecl * ) { visit_children = false; }
     77                void previsit( AggregateDecl * ) { visit_children = false; }
     78                void previsit( NamedTypeDecl * ) { visit_children = false; }
    7979                void previsit( FunctionType * ) { visit_children = false; }
    8080
     
    130130                // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address
    131131                // is being returned
    132                 if ( returnStmt->get_expr() && returnVals.size() == 1 && tryConstruct( returnVals.front() ) ) {
     132                if ( returnStmt->get_expr() && returnVals.size() == 1 && isConstructable( returnVals.front()->get_type() ) ) {
    133133                        // explicitly construct the return value using the return expression and the retVal object
    134134                        assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() );
  • src/InitTweak/InitTweak.cc

    r8b11840 rb56c17c  
    2222#include "SynTree/Type.h"          // for FunctionType, ArrayType, PointerType
    2323#include "SynTree/Visitor.h"       // for Visitor, maybeAccept
     24#include "Tuples/Tuples.h"         // for Tuples::isTtype
    2425
    2526class UntypedValofExpr;
     
    276277                                ( objDecl->get_init() != nullptr && objDecl->get_init()->get_maybeConstructed() ))
    277278                        && ! objDecl->get_storageClasses().is_extern
    278                         && ! dynamic_cast< ReferenceType * >( objDecl->type );
     279                        && isConstructable( objDecl->type );
     280        }
     281
     282        bool isConstructable( Type * type ) {
     283                return ! dynamic_cast< VarArgsType * >( type ) && ! dynamic_cast< ReferenceType * >( type ) && ! dynamic_cast< FunctionType * >( type ) && ! Tuples::isTtype( type );
    279284        }
    280285
  • src/InitTweak/InitTweak.h

    r8b11840 rb56c17c  
    3535        /// True if the resolver should try to construct dwt
    3636        bool tryConstruct( DeclarationWithType * dwt );
     37
     38        /// True if the type can have a user-defined constructor
     39        bool isConstructable( Type * t );
    3740
    3841        /// True if the Initializer contains designations
Note: See TracChangeset for help on using the changeset viewer.