Ignore:
Timestamp:
Nov 24, 2017, 8:57:00 PM (6 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:
2b716ec
Parents:
50abab9 (diff), 3de176d (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/SymTab/Autogen.h

    r50abab9 rf5478c8  
    5656        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    5757        template< typename OutputIterator >
    58         Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );
     58        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast = nullptr, bool forward = true );
    5959
    6060        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
    6161        /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
    6262        template< typename OutputIterator >
    63         Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, bool addCast = false ) {
     63        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, Type * addCast = nullptr ) {
    6464                bool isReferenceCtorDtor = false;
    6565                if ( dynamic_cast< ReferenceType * >( type ) && CodeGen::isCtorDtor( fname ) ) {
     
    6868                        fname = "?=?";
    6969                        dstParam = new AddressExpr( dstParam );
    70                         addCast = false;
     70                        addCast = nullptr;
    7171                        isReferenceCtorDtor = true;
    7272                }
     
    8383                        // remove lvalue as a qualifier, this can change to
    8484                        //   type->get_qualifiers() = Type::Qualifiers();
    85                         assert( type );
    86                         Type * castType = type->clone();
     85                        Type * castType = addCast->clone();
    8786                        castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    8887                        // castType->set_lvalue( true ); // xxx - might not need this
     
    115114        /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
    116115        template< typename OutputIterator >
    117         void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
     116        void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, Type * addCast = nullptr, bool forward = true ) {
    118117                static UniqueName indexName( "_index" );
    119118
    120119                // for a flexible array member nothing is done -- user must define own assignment
    121                 if ( ! array->get_dimension() ) return ;
     120                if ( ! array->get_dimension() ) return;
     121
     122                if ( addCast ) {
     123                        // peel off array layer from cast
     124                        ArrayType * at = strict_dynamic_cast< ArrayType * >( addCast );
     125                        addCast = at->base;
     126                }
    122127
    123128                Expression * begin, * end, * update, * cmp;
     
    171176
    172177        template< typename OutputIterator >
    173         Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
     178        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast, bool forward ) {
    174179                if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    175180                        genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
     
    191196                if ( isUnnamedBitfield( obj ) ) return;
    192197
    193                 bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) );
     198                Type * addCast = nullptr;
     199                if ( (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) ) ) {
     200                        assert( dstParam->result );
     201                        addCast = dstParam->result;
     202                }
    194203                std::list< Statement * > stmts;
    195204                genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->type, addCast, forward );
Note: See TracChangeset for help on using the changeset viewer.