Changeset 64071c2 for src/CodeGen


Ignore:
Timestamp:
Jun 6, 2016, 2:16:00 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7baed7d
Parents:
321a2481
Message:

greatly simplify construction of qualified objects using cast expressions, which also reduces gcc warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r321a2481 r64071c2  
    257257                                std::list< Expression* >::iterator arg = applicationExpr->get_args().begin();
    258258                                switch ( opInfo.type ) {
    259                                   case OT_CTOR:
    260                                   case OT_DTOR:
    261                                         {
    262                                                 // if the first argument's type is const then GCC complains. In this
    263                                                 // case, output an explicit ctor/dtor call and exit, rather than following
    264                                                 // the normal path
    265                                                 assert( arg != applicationExpr->get_args().end() );
    266                                                 assert( (*arg)->get_results().size() >= 1 );
    267                                                 Type * baseType = InitTweak::getPointerBase( (*arg)->get_results().front() );
    268                                                 if ( baseType->get_isConst() ) {
    269                                                         // cast away the qualifiers, to eliminate warnings
    270                                                         Type * newType = baseType->clone();
    271                                                         newType->get_qualifiers() = Type::Qualifiers();
    272                                                         *arg = new CastExpr( *arg, new PointerType( Type::Qualifiers(), newType ) );
    273                                                         varExpr->accept( *this );
    274                                                         output << "(";
    275                                                         genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
    276                                                         output << ")";
    277                                                         return;
    278                                                 }
    279                                         }
    280                                         // intentional fallthrough - instrinsic ctor/dtor for non-const objects should
    281                                         // be handled the same way as assignment
    282259                                  case OT_PREFIXASSIGN:
    283260                                  case OT_POSTFIXASSIGN:
    284261                                  case OT_INFIXASSIGN:
     262                                  case OT_CTOR:
     263                                  case OT_DTOR:
    285264                                        {
    286265                                                assert( arg != applicationExpr->get_args().end() );
     
    324303                                        if ( applicationExpr->get_args().size() == 1 ) {
    325304                                                // the expression fed into a single parameter constructor or destructor
    326                                                 // may contain side effects - output as a void expression
    327                                                 output << "((void)(";
     305                                                // may contain side effects, so must still output this expression
     306                                                output << "(";
    328307                                                (*arg++)->accept( *this );
    329                                                 output << ")) /* " << opInfo.inputName << " */";
     308                                                output << ") /* " << opInfo.inputName << " */";
    330309                                        } else if ( applicationExpr->get_args().size() == 2 ) {
    331310                                                // intrinsic two parameter constructors are essentially bitwise assignment
     
    409388                                        if ( untypedExpr->get_args().size() == 1 ) {
    410389                                                // the expression fed into a single parameter constructor or destructor
    411                                                 // may contain side effects - output as a void expression
    412                                                 output << "((void)(";
     390                                                // may contain side effects, so must still output this expression
     391                                                output << "(";
    413392                                                (*arg++)->accept( *this );
    414                                                 output << ")) /* " << opInfo.inputName << " */";
     393                                                output << ") /* " << opInfo.inputName << " */";
    415394                                        } else if ( untypedExpr->get_args().size() == 2 ) {
    416395                                                // intrinsic two parameter constructors are essentially bitwise assignment
Note: See TracChangeset for help on using the changeset viewer.