Changeset 3d618a0 for src/ResolvExpr/CandidateFinder.cpp
- Timestamp:
- Sep 9, 2024, 6:16:09 PM (5 weeks ago)
- Branches:
- master
- Children:
- aa14aafe
- Parents:
- d93b813 (diff), f5dbc8d (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
rd93b813 r3d618a0 10 10 // Created On : Wed Jun 5 14:30:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 22 08:07:26202413 // Update Count : 412 // Last Modified On : Mon Sep 9 11:30:11 2024 13 // Update Count : 5 14 14 // 15 15 … … 1239 1239 CandidateList matches; 1240 1240 Cost minExprCost = Cost::infinity; 1241 Cost minCastCost = Cost::infinity;1241 // Cost minCastCost = Cost::infinity; 1242 1242 for ( CandidateRef & cand : finder.candidates ) { 1243 1243 ast::ptr< ast::Type > fromType = cand->expr->result; … … 1482 1482 1483 1483 void Finder::postvisit( const ast::SizeofExpr * sizeofExpr ) { 1484 if ( sizeofExpr->type ) { 1485 addCandidate( 1486 new ast::SizeofExpr{ 1487 sizeofExpr->location, resolveTypeof( sizeofExpr->type, context ) }, 1488 tenv ); 1489 } else { 1490 // find all candidates for the argument to sizeof 1491 CandidateFinder finder( context, tenv ); 1492 finder.find( sizeofExpr->expr ); 1493 // find the lowest-cost candidate, otherwise ambiguous 1494 CandidateList winners = findMinCost( finder.candidates ); 1495 if ( winners.size() != 1 ) { 1496 SemanticError( 1497 sizeofExpr->expr.get(), "Ambiguous expression in sizeof operand: " ); 1498 } 1499 // return the lowest-cost candidate 1500 CandidateRef & choice = winners.front(); 1501 choice->expr = referenceToRvalueConversion( choice->expr, choice->cost ); 1502 choice->cost = Cost::zero; 1503 addCandidate( *choice, new ast::SizeofExpr{ sizeofExpr->location, choice->expr } ); 1504 } 1484 addCandidate( 1485 new ast::SizeofExpr{ 1486 sizeofExpr->location, resolveTypeof( sizeofExpr->type, context ) }, 1487 tenv ); 1505 1488 } 1506 1489 … … 1537 1520 1538 1521 void Finder::postvisit( const ast::AlignofExpr * alignofExpr ) { 1539 if ( alignofExpr->type ) { 1540 addCandidate( 1541 new ast::AlignofExpr{ 1542 alignofExpr->location, resolveTypeof( alignofExpr->type, context ) }, 1543 tenv ); 1544 } else { 1545 // find all candidates for the argument to alignof 1546 CandidateFinder finder( context, tenv ); 1547 finder.find( alignofExpr->expr ); 1548 // find the lowest-cost candidate, otherwise ambiguous 1549 CandidateList winners = findMinCost( finder.candidates ); 1550 if ( winners.size() != 1 ) { 1551 SemanticError( 1552 alignofExpr->expr.get(), "Ambiguous expression in alignof operand: " ); 1553 } 1554 // return the lowest-cost candidate 1555 CandidateRef & choice = winners.front(); 1556 choice->expr = referenceToRvalueConversion( choice->expr, choice->cost ); 1557 choice->cost = Cost::zero; 1558 addCandidate( 1559 *choice, new ast::AlignofExpr{ alignofExpr->location, choice->expr } ); 1560 } 1522 addCandidate( 1523 new ast::AlignofExpr{ 1524 alignofExpr->location, resolveTypeof( alignofExpr->type, context ) }, 1525 tenv ); 1561 1526 } 1562 1527
Note: See TracChangeset
for help on using the changeset viewer.