Changeset 83794e1 for src/GenPoly/Box.cc


Ignore:
Timestamp:
Aug 8, 2017, 8:22:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
b1bead1
Parents:
e25707d
Message:

Add unused attributes to assertion parameters and adapters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    re25707d r83794e1  
    755755
    756756                void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) {
    757                         assert( arg->has_result() );
     757                        assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() );
    758758                        if ( isPolyType( param, exprTyVars ) ) {
    759759                                if ( isPolyType( arg->get_result() ) ) {
     
    10271027                                                } // if
    10281028                                                if ( baseType1 || baseType2 ) {
    1029                                                         Type * baseType = InitTweak::getPointerBase( appExpr->get_result() );
    1030                                                         assert( baseType );
    1031                                                         ret->set_result( baseType->clone() );
     1029                                                        delete ret->get_result();
     1030                                                        ret->set_result( appExpr->get_result()->clone() );
    10321031                                                        if ( appExpr->get_env() ) {
    10331032                                                                ret->set_env( appExpr->get_env() );
     
    10411040                                                assert( appExpr->has_result() );
    10421041                                                assert( ! appExpr->get_args().empty() );
    1043                                                 if ( isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { // dereference returns a reference type
     1042                                                if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) {
    10441043                                                        // remove dereference from polymorphic types since they are boxed.
    10451044                                                        Expression *ret = appExpr->get_args().front();
    1046                                                         // fix expr type to remove reference
     1045                                                        // fix expr type to remove pointer
    10471046                                                        delete ret->get_result();
    1048                                                         Type * baseType = InitTweak::getPointerBase( appExpr->get_result() );
    1049                                                         assert( baseType );
    1050                                                         ret->set_result( baseType->clone() );
     1047                                                        ret->set_result( appExpr->get_result()->clone() );
    10511048                                                        if ( appExpr->get_env() ) {
    10521049                                                                ret->set_env( appExpr->get_env() );
     
    11361133
    11371134                        assert( appExpr->get_function()->has_result() );
    1138                         PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
    1139                         FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
     1135                        FunctionType * function = getFunctionType( appExpr->get_function()->get_result() );
     1136                        assertf( function, "ApplicationExpr has non-function type: %s", toString( appExpr->get_function()->get_result() ).c_str() );
    11401137
    11411138                        if ( Expression *newExpr = handleIntrinsics( appExpr ) ) {
     
    12141211                                                        if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) {
    12151212                                                                assert( appExpr->get_function()->has_result() );
    1216                                                                 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() );
    1217                                                                 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() );
     1213                                                                FunctionType *function = getFunctionType( appExpr->get_function()->get_result() );
     1214                                                                assert( function );
    12181215                                                                needs = needsAdapter( function, scopeTyVars );
    12191216                                                        } // if
     
    12931290                                if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) {
    12941291                                        std::string adapterName = makeAdapterName( mangleName );
    1295                                         paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0 ) );
     1292                                        // adapter may not be used in body, pass along with unused attribute.
     1293                                        paramList.push_front( new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0, { new Attribute( "unused" ) } ) );
    12961294                                        adaptersDone.insert( adaptersDone.begin(), mangleName );
    12971295                                }
     
    13991397                        std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin();
    14001398                        std::list< DeclarationWithType *> inferredParams;
    1401                         ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
     1399                        // size/align/offset parameters may not be used in body, pass along with unused attribute.
     1400                        ObjectDecl newObj( "", Type::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0,
     1401                                           { new Attribute( "unused" ) } );
    14021402                        ObjectDecl newPtr( "", Type::StorageClasses(), LinkageSpec::C, 0,
    14031403                                           new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 );
     
    14221422                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
    14231423//      *assert = (*assert)->acceptMutator( *this );
     1424                                        // assertion parameters may not be used in body, pass along with unused attribute.
     1425                                        (*assert)->get_attributes().push_back( new Attribute( "unused" ) );
    14241426                                        inferredParams.push_back( *assert );
    14251427                                }
Note: See TracChangeset for help on using the changeset viewer.