Changes in / [b368dd8:518e97d]
- Location:
- src
- Files:
-
- 4 edited
-
ResolvExpr/Alternative.cc (modified) (3 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (3 diffs)
-
ResolvExpr/TypeEnvironment.cc (modified) (2 diffs)
-
SynTree/ReferenceToType.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Alternative.cc
rb368dd8 r518e97d 27 27 28 28 namespace ResolvExpr { 29 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0) {}29 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( nullptr ) {} 30 30 31 31 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost ) … … 48 48 } 49 49 50 Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env) {50 Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( std::move( other.env ) ) { 51 51 other.expr = nullptr; 52 52 } … … 58 58 cvtCost = other.cvtCost; 59 59 expr = other.expr; 60 env = other.env;60 env = std::move( other.env ); 61 61 other.expr = nullptr; 62 62 return *this; -
src/ResolvExpr/AlternativeFinder.cc
rb368dd8 r518e97d 324 324 aggInst->lookup( name, members ); 325 325 326 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) { 327 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( *i ) ) { 328 alternatives.push_back( Alternative( new MemberExpr( dwt, expr->clone() ), env, newCost ) ); 329 renameTypes( alternatives.back().expr ); 330 addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression. 326 for ( Declaration * decl : members ) { 327 if ( DeclarationWithType *dwt = dynamic_cast< DeclarationWithType* >( decl ) ) { 328 // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so 329 // can't construct in place and use vector::back 330 Alternative newAlt( new MemberExpr( dwt, expr->clone() ), env, newCost ); 331 renameTypes( newAlt.expr ); 332 addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a member expression. 333 alternatives.push_back( std::move(newAlt) ); 331 334 } else { 332 335 assert( false ); … … 1379 1382 Cost cost = Cost::zero; 1380 1383 Expression * newExpr = data.combine( cost ); 1381 alternatives.push_back( Alternative( newExpr, env, Cost::zero, cost ) ); 1384 1385 // addAnonAlternatives uses vector::push_back, which invalidates references to existing elements, so 1386 // can't construct in place and use vector::back 1387 Alternative newAlt( newExpr, env, Cost::zero, cost ); 1382 1388 PRINT( 1383 1389 std::cerr << "decl is "; … … 1388 1394 std::cerr << std::endl; 1389 1395 ) 1390 renameTypes( alternatives.back().expr ); 1391 addAnonConversions( alternatives.back() ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression. 1396 renameTypes( newAlt.expr ); 1397 addAnonConversions( newAlt ); // add anonymous member interpretations whenever an aggregate value type is seen as a name expression. 1398 alternatives.push_back( std::move(newAlt) ); 1392 1399 } // for 1393 1400 } -
src/ResolvExpr/TypeEnvironment.cc
rb368dd8 r518e97d 50 50 } 51 51 52 EqvClass::EqvClass() : type( 0), allowWidening( true ) {52 EqvClass::EqvClass() : type( nullptr ), allowWidening( true ) { 53 53 } 54 54 … … 159 159 160 160 void TypeEnvironment::print( std::ostream &os, Indenter indent ) const { 161 for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i) {162 i->print( os, indent );161 for ( const EqvClass & theClass : env ) { 162 theClass.print( os, indent ); 163 163 } // for 164 164 } -
src/SynTree/ReferenceToType.cc
rb368dd8 r518e97d 50 50 51 51 namespace { 52 void doLookup( const std::list< Declaration * > &members, const std::string &name, std::list< Declaration* > &foundDecls ) {53 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i) {54 if ( (*i)->get_name()== name ) {55 foundDecls.push_back( *i);52 void doLookup( const std::list< Declaration * > & members, const std::string & name, std::list< Declaration* > & foundDecls ) { 53 for ( Declaration * decl : members ) { 54 if ( decl->name == name ) { 55 foundDecls.push_back( decl ); 56 56 } // if 57 57 } // for … … 60 60 61 61 StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes ) : 62 Parent( tq, baseStruct-> get_name(), attributes ), baseStruct( baseStruct ) {}62 Parent( tq, baseStruct->name, attributes ), baseStruct( baseStruct ) {} 63 63 64 64 std::string StructInstType::typeString() const { return "struct"; } … … 84 84 void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 85 85 assert( baseStruct ); 86 doLookup( baseStruct-> get_members(), name, foundDecls );86 doLookup( baseStruct->members, name, foundDecls ); 87 87 } 88 88 … … 103 103 104 104 UnionInstType::UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes ) : 105 Parent( tq, baseUnion-> get_name(), attributes ), baseUnion( baseUnion ) {}105 Parent( tq, baseUnion->name, attributes ), baseUnion( baseUnion ) {} 106 106 107 107 std::string UnionInstType::typeString() const { return "union"; } … … 127 127 void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 128 128 assert( baseUnion ); 129 doLookup( baseUnion-> get_members(), name, foundDecls );129 doLookup( baseUnion->members, name, foundDecls ); 130 130 } 131 131
Note:
See TracChangeset
for help on using the changeset viewer.