Changeset 4d2434a for src/ResolvExpr
- Timestamp:
- Aug 2, 2016, 6:37:08 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, 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:
- 8a443f4
- Parents:
- 39f84a4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/Resolver.cc ¶
r39f84a4 r4d2434a 54 54 virtual void visit( BranchStmt *branchStmt ); 55 55 virtual void visit( ReturnStmt *returnStmt ); 56 virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt );57 56 58 57 virtual void visit( SingleInit *singleInit ); … … 436 435 437 436 void Resolver::visit( ListInit * listInit ) { 438 InitIterator iter = listInit->begin _initializers();439 InitIterator end = listInit->end _initializers();437 InitIterator iter = listInit->begin(); 438 InitIterator end = listInit->end(); 440 439 441 440 if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) { … … 539 538 ctorInit->set_ctor( NULL ); 540 539 } 541 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_ ctor() ) ) {540 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_dtor() ) ) { 542 541 delete ctorInit->get_dtor(); 543 542 ctorInit->set_dtor( NULL ); 544 543 } 545 }546 547 void Resolver::visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) {548 // before resolving ctor/dtor, need to remove type qualifiers from the first argument (the object being constructed).549 // Do this through a cast expression to greatly simplify the code.550 Expression * callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );551 assert( callExpr );552 Expression *& constructee = InitTweak::getCallArg( callExpr, 0 );553 554 // the first argument will always be &<expr>555 AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );556 assert( addrExpr );557 558 // need to find the type of the first argument. In the case of an array,559 // need to remove one ArrayType layer from the type for each subscript expression.560 Expression * addressee = addrExpr->get_arg();561 int numLayers = 0;562 while ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( addressee ) ) {563 assert( InitTweak::getFunctionName( untypedExpr ) == "?[?]" );564 addressee = InitTweak::getCallArg( untypedExpr, 0 );565 numLayers++;566 }567 assert( addressee->get_results().size() == 1 );568 Type * type = addressee->get_results().front();569 for ( int i = 0; i < numLayers; i++ ) {570 type = InitTweak::getPointerBase( type );571 assert( type && "Expected pointer or array type. May have generated too many ?[?] calls." );572 }573 574 // cast to T* with qualifiers removed.575 // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument576 // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever577 // remove lvalue as a qualifier, this can change to578 // type->get_qualifiers() = Type::Qualifiers();579 assert( type );580 type = type->clone();581 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);582 type = new PointerType( Type::Qualifiers(), type );583 constructee = new CastExpr( constructee, type );584 585 // finally, resolve the ctor/dtor586 impCtorDtorStmt->get_callStmt()->accept( *this );587 544 } 588 545 } // namespace ResolvExpr
Note: See TracChangeset
for help on using the changeset viewer.