Changes in / [4563a95:119745e]


Ignore:
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/InitTweak.cc

    r4563a95 r119745e  
    304304
    305305        namespace {
    306                 DeclarationWithType * getCalledFunction( Expression * expr ) {
    307                         assert( expr );
    308                         if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
    309                                 return varExpr->get_var();
    310                         } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( expr ) ) {
    311                                 return memberExpr->get_member();
    312                         } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
    313                                 return getCalledFunction( castExpr->get_arg() );
    314                         }
    315                         return nullptr;
     306                VariableExpr * getCalledFunction( ApplicationExpr * appExpr ) {
     307                        assert( appExpr );
     308                        // xxx - it's possible this can be other things, e.g. MemberExpr, so this is insufficient
     309                        return dynamic_cast< VariableExpr * >( appExpr->get_function() );
    316310                }
    317311        }
     
    320314                ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr );
    321315                if ( ! appExpr ) return NULL;
    322                 DeclarationWithType * function = getCalledFunction( appExpr->get_function() );
     316                VariableExpr * function = getCalledFunction( appExpr );
    323317                assert( function );
    324318                // check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor
    325319                // will call all member dtors, and some members may have a user defined dtor.
    326                 return function->get_linkage() == LinkageSpec::Intrinsic ? appExpr : NULL;
     320                return function->get_var()->get_linkage() == LinkageSpec::Intrinsic ? appExpr : NULL;
    327321        }
    328322
     
    385379                        }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
    386380                                return funcName( castExpr->get_arg() );
    387                         } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) {
    388                                 return memberExpr->get_member()->get_name();
    389381                        } else {
    390382                                assert( false && "Unexpected expression type being called as a function in call expression" );
     
    480472        bool isConstructor( const std::string & str ) { return str == "?{}"; }
    481473        bool isDestructor( const std::string & str ) { return str == "^?{}"; }
    482         bool isAssignment( const std::string & str ) { return str == "?=?"; }
    483474        bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }
    484         bool isCtorDtorAssign( const std::string & str ) { return isCtorDtor( str ) || isAssignment( str ); }
    485 
    486         FunctionDecl * isCopyFunction( Declaration * decl, const std::string & fname ) {
     475
     476        FunctionDecl * isCopyConstructor( Declaration * decl ) {
    487477                FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl );
    488478                if ( ! function ) return 0;
    489                 if ( function->get_name() != fname ) return 0;
     479                if ( ! isConstructor( function->get_name() ) ) return 0;
    490480                FunctionType * ftype = function->get_functionType();
    491481                if ( ftype->get_parameters().size() != 2 ) return 0;
     
    496486                assert( ptrType );
    497487
    498                 if ( ResolvExpr::typesCompatibleIgnoreQualifiers( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
     488                if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
    499489                        return function;
    500490                } else {
    501                         return nullptr;
    502                 }
    503         }
    504 
    505         FunctionDecl * isCopyConstructor( Declaration * decl ) {
    506                 return isCopyFunction( decl, "?{}" );
     491                        return 0;
     492                }
    507493        }
    508494}
  • src/InitTweak/InitTweak.h

    r4563a95 r119745e  
    2828        bool isConstructor( const std::string & );
    2929        bool isDestructor( const std::string & );
    30         bool isAssignment( const std::string & );
    3130        bool isCtorDtor( const std::string & );
    32         bool isCtorDtorAssign( const std::string & );
    3331
    3432        FunctionDecl * isCopyConstructor( Declaration * decl );
    35         FunctionDecl * isCopyFunction( Declaration * decl, const std::string & fname );
    3633
    3734        /// transform Initializer into an argument list that can be passed to a call expression
  • src/SymTab/Indexer.cc

    r4563a95 r119745e  
    105105
    106106        void Indexer::removeSpecialOverrides( const std::string &id, std::list< DeclarationWithType * > & out ) const {
    107                 // only need to perform this step for constructors, destructors, and assignment functions
    108                 if ( ! InitTweak::isCtorDtorAssign( id ) ) return;
     107                // only need to perform this step for constructors and destructors
     108                if ( ! InitTweak::isCtorDtor( id ) ) return;
    109109
    110110                // helpful data structure
     
    127127                                bool isUserDefinedFunc = ! LinkageSpec::isOverridable( function->get_linkage() );
    128128                                bool isDefaultFunc = function->get_functionType()->get_parameters().size() == 1;
    129                                 bool isCopyFunc = InitTweak::isCopyFunction( function, function->get_name() );
     129                                bool isCopyFunc = InitTweak::isCopyConstructor( function );
    130130                                decls.push_back( DeclBall{ function, isUserDefinedFunc, isDefaultFunc, isCopyFunc } );
    131131                                userDefinedFunc = userDefinedFunc || isUserDefinedFunc;
Note: See TracChangeset for help on using the changeset viewer.