Changeset cf18eea for src/InitTweak


Ignore:
Timestamp:
Apr 25, 2016, 3:53:15 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:
5382492
Parents:
add371c
Message:

don't copy construct function type arguments or va_list type arguments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    radd371c rcf18eea  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 25 14:44:21 2016
     12// Last Modified On : Mon Apr 25 15:16:12 2016
    1313// Update Count     : 30
    1414//
     
    2727#include "SymTab/Indexer.h"
    2828#include "GenPoly/PolyMutator.h"
     29#include "GenPoly/GenPoly.h"
    2930
    3031bool ctordtorp = false;
     
    5859                /// create and resolve ctor/dtor expression: fname(var, [cpArg])
    5960                ApplicationExpr * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
     61                /// true if type does not need to be copy constructed to ensure correctness
     62                bool skipCopyConstruct( Type * );
    6063        };
    6164
     
    150153        }
    151154
     155        bool ResolveCopyCtors::skipCopyConstruct( Type * type ) {
     156                return dynamic_cast< VarArgsType * >( type ) || GenPoly::getFunctionType( type );
     157        }
     158
    152159        ApplicationExpr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
    153160                assert( var );
     
    180187                        // xxx - need to handle tuple arguments
    181188                        assert( ! arg->get_results().empty() );
    182                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, arg->get_results().front()->clone(), 0 );
     189                        Type * result = arg->get_results().front();
     190                        if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types
     191                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result->clone(), 0 );
    183192                        tmp->get_type()->set_isConst( false );
    184193
Note: See TracChangeset for help on using the changeset viewer.