Ignore:
Timestamp:
Aug 25, 2017, 12:11:53 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bf7b9da7
Parents:
135b431 (diff), f676b84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/GenInit.cc

    r135b431 r6b224a52  
    2121#include <list>                    // for _List_iterator, list
    2222
     23#include "CodeGen/OperatorTable.h"
    2324#include "Common/PassVisitor.h"    // for PassVisitor, WithGuards, WithShort...
    2425#include "Common/SemanticError.h"  // for SemanticError
     
    5758
    5859          protected:
    59                 FunctionType * ftype;
     60                FunctionType * ftype = nullptr;
    6061                std::string funcName;
    6162        };
     
    140141                std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
    141142                assert( returnVals.size() == 0 || returnVals.size() == 1 );
    142                 // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
     143                // hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address
    143144                // is being returned
    144                 if ( returnStmt->get_expr() && returnVals.size() == 1 && ! returnVals.front()->get_type()->get_lvalue() ) {
     145                if ( returnStmt->get_expr() && returnVals.size() == 1 && ! dynamic_cast< ReferenceType * >( returnVals.front()->get_type() ) ) {
    145146                        // explicitly construct the return value using the return expression and the retVal object
    146147                        assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() );
    147                         UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) );
    148                         construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) );
    149                         construct->get_args().push_back( returnStmt->get_expr() );
    150                         stmtsToAddBefore.push_back(new ExprStmt(noLabels, construct));
     148
     149                        stmtsToAddBefore.push_back( genCtorDtor( "?{}", dynamic_cast< ObjectDecl *>( returnVals.front() ), returnStmt->get_expr() ) );
    151150
    152151                        // return the retVal object
     
    215214
    216215        bool CtorDtor::isManaged( Type * type ) const {
     216                // at least for now, references are never constructed
     217                if ( dynamic_cast< ReferenceType * >( type ) ) return false;
    217218                // need to clear and reset qualifiers when determining if a type is managed
    218219                ValueGuard< Type::Qualifiers > qualifiers( type->get_qualifiers() );
     
    238239        void CtorDtor::handleDWT( DeclarationWithType * dwt ) {
    239240                // if this function is a user-defined constructor or destructor, mark down the type as "managed"
    240                 if ( ! LinkageSpec::isOverridable( dwt->get_linkage() ) && isCtorDtor( dwt->get_name() ) ) {
     241                if ( ! LinkageSpec::isOverridable( dwt->get_linkage() ) && CodeGen::isCtorDtor( dwt->get_name() ) ) {
    241242                        std::list< DeclarationWithType * > & params = GenPoly::getFunctionType( dwt->get_type() )->get_parameters();
    242243                        assert( ! params.empty() );
    243                         PointerType * type = safe_dynamic_cast< PointerType * >( params.front()->get_type() );
    244                         managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) );
     244                        Type * type = InitTweak::getPointerBase( params.front()->get_type() );
     245                        assert( type );
     246                        managedTypes.insert( SymTab::Mangler::mangle( type ) );
    245247                }
    246248        }
Note: See TracChangeset for help on using the changeset viewer.