Changeset 5f95b5f for src


Ignore:
Timestamp:
Feb 6, 2018, 10:29:52 AM (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:
69ce455
Parents:
7323573 (diff), 6bfe5cc (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

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    r7323573 r5f95b5f  
    998998template< typename pass_type >
    999999void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
    1000         VISIT_BODY( node );
     1000        VISIT_START( node );
     1001
     1002        maybeAccept_impl( node->block, *this );
     1003
     1004        VISIT_END( node );
    10011005}
    10021006
    10031007template< typename pass_type >
    10041008Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
    1005         MUTATE_BODY( Statement, node );
     1009        MUTATE_START( node );
     1010
     1011        maybeMutate_impl( node->block, *this );
     1012
     1013        MUTATE_END( Statement, node );
    10061014}
    10071015
  • src/GenPoly/Box.cc

    r7323573 r5f95b5f  
    988988
    989989                Expression *Pass1::handleIntrinsics( ApplicationExpr *appExpr ) {
    990                         if ( VariableExpr *varExpr = dynamic_cast< VariableExpr *>( appExpr->get_function() ) ) {
    991                                 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
    992                                         if ( varExpr->get_var()->get_name() == "?[?]" ) {
     990                        if ( VariableExpr *varExpr = dynamic_cast< VariableExpr *>( appExpr->function ) ) {
     991                                if ( varExpr->var->linkage == LinkageSpec::Intrinsic ) {
     992                                        if ( varExpr->var->name == "?[?]" ) {
    993993                                                assert( appExpr->result );
    994994                                                assert( appExpr->get_args().size() == 2 );
    995                                                 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env );
    996                                                 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env );
     995                                                Type *baseType1 = isPolyPtr( appExpr->args.front()->result, scopeTyVars, env );
     996                                                Type *baseType2 = isPolyPtr( appExpr->args.back()->result, scopeTyVars, env );
    997997                                                assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers
    998998                                                UntypedExpr *ret = 0;
     
    15551555                        // only mutate member expressions for polymorphic types
    15561556                        int tyDepth;
    1557                         Type *objectType = hasPolyBase( memberExpr->get_aggregate()->get_result(), scopeTyVars, &tyDepth );
     1557                        Type *objectType = hasPolyBase( memberExpr->aggregate->result, scopeTyVars, &tyDepth );
    15581558                        if ( ! objectType ) return memberExpr;
    15591559                        findGeneric( objectType ); // ensure layout for this type is available
    15601560
    15611561                        // replace member expression with dynamically-computed layout expression
    1562                         Expression *newMemberExpr = 0;
     1562                        Expression *newMemberExpr = nullptr;
    15631563                        if ( StructInstType *structType = dynamic_cast< StructInstType* >( objectType ) ) {
    15641564                                // look up offset index
    1565                                 long i = findMember( memberExpr->get_member(), structType->get_baseStruct()->get_members() );
     1565                                long i = findMember( memberExpr->member, structType->baseStruct->members );
    15661566                                if ( i == -1 ) return memberExpr;
    15671567
    15681568                                // replace member expression with pointer to base plus offset
    15691569                                UntypedExpr *fieldLoc = new UntypedExpr( new NameExpr( "?+?" ) );
    1570                                 Expression * aggr = memberExpr->get_aggregate()->clone();
    1571                                 delete aggr->get_env(); // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it
    1572                                 aggr->set_env( nullptr );
     1570                                Expression * aggr = memberExpr->aggregate->clone();
     1571                                delete aggr->env; // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it
     1572                                aggr->env = nullptr;
    15731573                                fieldLoc->get_args().push_back( aggr );
    15741574                                fieldLoc->get_args().push_back( makeOffsetIndex( objectType, i ) );
    1575                                 fieldLoc->set_result( memberExpr->get_result()->clone() );
     1575                                fieldLoc->set_result( memberExpr->result->clone() );
    15761576                                newMemberExpr = fieldLoc;
    15771577                        } else if ( dynamic_cast< UnionInstType* >( objectType ) ) {
    15781578                                // union members are all at offset zero, so just use the aggregate expr
    1579                                 Expression * aggr = memberExpr->get_aggregate()->clone();
    1580                                 delete aggr->get_env(); // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it
    1581                                 aggr->set_env( nullptr );
     1579                                Expression * aggr = memberExpr->aggregate->clone();
     1580                                delete aggr->env; // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it
     1581                                aggr->env= nullptr;
    15821582                                newMemberExpr = aggr;
    1583                                 newMemberExpr->set_result( memberExpr->get_result()->clone() );
     1583                                newMemberExpr->result = memberExpr->result->clone();
    15841584                        } else return memberExpr;
    15851585                        assert( newMemberExpr );
    15861586
    1587                         Type *memberType = memberExpr->get_member()->get_type();
     1587                        Type *memberType = memberExpr->member->get_type();
    15881588                        if ( ! isPolyType( memberType, scopeTyVars ) ) {
    15891589                                // Not all members of a polymorphic type are themselves of polymorphic type; in this case the member expression should be wrapped and dereferenced to form an lvalue
     
    15981598
    15991599                ObjectDecl *PolyGenericCalculator::makeVar( const std::string &name, Type *type, Initializer *init ) {
    1600                         ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, 0, type, init );
     1600                        ObjectDecl *newObj = new ObjectDecl( name, Type::StorageClasses(), LinkageSpec::C, nullptr, type, init );
    16011601                        stmtsToAddBefore.push_back( new DeclStmt( newObj ) );
    16021602                        return newObj;
  • src/GenPoly/InstantiateGeneric.cc

    r7323573 r5f95b5f  
    476476                        DeclarationWithType * field = strict_dynamic_cast< DeclarationWithType * >( member );
    477477                        MemberExpr * ret = new MemberExpr( field, memberExpr->aggregate->clone() );
     478                        ResolvExpr::adjustExprType( ret->result ); // pointer decay
    478479                        std::swap( ret->env, memberExpr->env );
    479480                        delete memberExpr;
  • src/ResolvExpr/AdjustExprType.cc

    r7323573 r5f95b5f  
    2424        class AdjustExprType : public WithShortCircuiting {
    2525          public:
    26                 AdjustExprType( const TypeEnvironment &env, const SymTab::Indexer &indexer );
     26                AdjustExprType( const TypeEnvironment & env, const SymTab::Indexer & indexer );
    2727                void premutate( VoidType * ) { visit_children = false; }
    2828                void premutate( BasicType * ) { visit_children = false; }
     
    4545
    4646          private:
    47                 const TypeEnvironment &env;
    48                 const SymTab::Indexer &indexer;
     47                const TypeEnvironment & env;
     48                const SymTab::Indexer & indexer;
    4949        };
    5050
     
    5353                Type *newType = type->acceptMutator( adjuster );
    5454                type = newType;
     55        }
     56
     57        void adjustExprType( Type *& type ) {
     58                TypeEnvironment env;
     59                SymTab::Indexer indexer;
     60                adjustExprType( type, env, indexer );
    5561        }
    5662
  • src/ResolvExpr/Resolver.cc

    r7323573 r5f95b5f  
    280280                        std::list< Statement * > newStmts;
    281281                        resolveWithExprs( functionDecl->withExprs, newStmts );
    282                         functionDecl->statements->kids.splice( functionDecl->statements->kids.begin(), newStmts );
     282                        if ( functionDecl->statements ) {
     283                                functionDecl->statements->kids.splice( functionDecl->statements->kids.begin(), newStmts );
     284                        } else {
     285                                assertf( functionDecl->withExprs.empty() && newStmts.empty(), "Function %s without a body has with-clause and/or generated with declarations.", functionDecl->name.c_str() );
     286                        }
    283287                }
    284288        }
  • src/ResolvExpr/typeops.h

    r7323573 r5f95b5f  
    5555        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
    5656        void adjustExprType( Type *&type, const TypeEnvironment &env, const SymTab::Indexer &indexer );
     57
     58        /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function using empty TypeEnvironment and Indexer
     59        void adjustExprType( Type *& type );
    5760
    5861        template< typename ForwardIterator >
  • src/driver/cfa.cc

    r7323573 r5f95b5f  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  1 22:26:10 2018
    13 // Update Count     : 163
     12// Last Modified On : Mon Feb  5 22:05:28 2018
     13// Update Count     : 166
    1414//
    1515
     
    258258                #endif
    259259
     260                args[nargs] = "-Xlinker";
     261                nargs += 1;
     262                args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
     263                nargs += 1;
     264                args[nargs] = "-Xlinker";
     265                nargs += 1;
     266                args[nargs] = "--undefined=__cfaabi_interpose_startup";
     267                nargs += 1;
     268
    260269                // include the cfa library in case it's needed
    261270                args[nargs] = "-L" CFA_LIBDIR;
     
    273282                args[nargs] = "-lrt";
    274283                nargs += 1;
    275                 args[nargs] = "-Xlinker";
    276                 nargs += 1;
    277                 args[nargs] = "--undefined=__cfaabi_dbg_bits_write";
    278                 nargs += 1;
    279                 args[nargs] = "-Xlinker";
    280                 nargs += 1;
    281                 args[nargs] = "--undefined=__cfaabi_interpose_startup";
    282                 nargs += 1;
    283 
    284         } // if
    285 #endif //HAVE_LIBCFA
     284        } // if
     285#endif // HAVE_LIBCFA
    286286
    287287        // Add exception flags (unconditionally)
     
    333333                nargs += 1;
    334334        } // if
     335
     336    args[nargs] = "-Xlinker";                                                   // used by backtrace
     337    nargs += 1;
     338    args[nargs] = "-export-dynamic";
     339    nargs += 1;
    335340
    336341        // execute the compilation command
  • src/libcfa/interpose.c

    r7323573 r5f95b5f  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:27:33 2017
    13 // Update Count     : 1
     12// Last Modified On : Mon Feb  5 23:40:04 2018
     13// Update Count     : 17
    1414//
    1515
     
    3232#include "bits/signal.h"
    3333#include "startup.h"
    34 
    35 void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
    3634
    3735typedef void (*generic_fptr_t)(void);
     
    9290void sigHandler_abort( __CFA_SIGPARMS__ );
    9391
    94 void __cfaabi_interpose_startup() {
    95         const char *version = NULL;
    96 
    97         INIT_REALRTN( abort, version );
    98         INIT_REALRTN( exit, version );
    99 
    100         __kernel_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO );      // Failure handler
    101         __kernel_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO );      // Failure handler
    102         __kernel_sigaction( SIGABRT, sigHandler_abort, SA_SIGINFO );      // Failure handler
     92extern "C" {
     93        void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
     94        void __cfaabi_interpose_startup( void ) {
     95                const char *version = NULL;
     96
     97                INIT_REALRTN( abort, version );
     98                INIT_REALRTN( exit, version );
     99
     100                __kernel_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); // Failure handler
     101                __kernel_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO ); // Failure handler
     102                __kernel_sigaction( SIGABRT, sigHandler_abort, SA_SIGINFO ); // Failure handler
     103        }
    103104}
    104105
     
    108109
    109110extern "C" {
    110         void abort (void) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     111        void abort( void ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    111112                abortf( NULL );
    112113        }
    113114
    114         void exit (int __status) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     115        void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    115116                libc_exit(__status);
    116117        }
     
    121122}
    122123
    123 void * kernel_abort    (void) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; }
    124 void   kernel_abort_msg(void * data, char * buffer, int size) __attribute__ ((__nothrow__, __leaf__, __weak__)) {}
     124void * kernel_abort    ( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; }
     125void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ ((__nothrow__, __leaf__, __weak__)) {}
    125126
    126127enum { abort_text_size = 1024 };
     
    133134                int len;
    134135
    135                 if( fmt ) {
     136                if ( fmt ) {
    136137                        va_list args;
    137138                        va_start( args, fmt );
     
    142143
    143144                        __cfaabi_dbg_bits_write( abort_text, len );
    144                         __cfaabi_dbg_bits_write( "\n", 1 );
     145                        //__cfaabi_dbg_bits_write( "\n", 1 );
    145146                }
    146147
     
    162163        enum { Frames = 50 };
    163164        void * array[Frames];
    164         int size = backtrace( array, Frames );
     165        size_t size = backtrace( array, Frames );
    165166        char ** messages = backtrace_symbols( array, size );
    166167
     
    176177
    177178                for ( char *p = messages[i]; *p; ++p ) {
     179                        //__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
    178180                        // find parantheses and +offset
    179181                        if ( *p == '(' ) {
Note: See TracChangeset for help on using the changeset viewer.