@@ -2642,14 +2642,17 @@ TEST(TransferTest, ResultObjectLocation) {
2642
2642
};
2643
2643
2644
2644
void target() {
2645
- A();
2645
+ 0, A();
2646
2646
(void)0; // [[p]]
2647
2647
}
2648
2648
)" ;
2649
+ using ast_matchers::binaryOperator;
2649
2650
using ast_matchers::cxxBindTemporaryExpr;
2650
2651
using ast_matchers::cxxTemporaryObjectExpr;
2651
2652
using ast_matchers::exprWithCleanups;
2652
2653
using ast_matchers::has;
2654
+ using ast_matchers::hasOperatorName;
2655
+ using ast_matchers::hasRHS;
2653
2656
using ast_matchers::match;
2654
2657
using ast_matchers::selectFirst;
2655
2658
using ast_matchers::traverse;
@@ -2659,26 +2662,33 @@ TEST(TransferTest, ResultObjectLocation) {
2659
2662
ASTContext &ASTCtx) {
2660
2663
const Environment &Env = getEnvironmentAtAnnotation (Results, " p" );
2661
2664
2662
- // The expresssion ` A()` in the code above produces the following
2663
- // structure, consisting of three prvalues of record type.
2665
+ // The expression `0, A()` in the code above produces the following
2666
+ // structure, consisting of four prvalues of record type.
2664
2667
// `Env.getResultObjectLocation()` should return the same location for
2665
2668
// all of these.
2666
2669
auto MatchResult = match (
2667
2670
traverse (TK_AsIs,
2668
2671
exprWithCleanups (
2669
- has (cxxBindTemporaryExpr (
2670
- has (cxxTemporaryObjectExpr ().bind (" toe" )))
2671
- .bind (" bte" )))
2672
+ has (binaryOperator (
2673
+ hasOperatorName (" ," ),
2674
+ hasRHS (cxxBindTemporaryExpr (
2675
+ has (cxxTemporaryObjectExpr ().bind (
2676
+ " toe" )))
2677
+ .bind (" bte" )))
2678
+ .bind (" comma" )))
2672
2679
.bind (" ewc" )),
2673
2680
ASTCtx);
2674
2681
auto *TOE = selectFirst<CXXTemporaryObjectExpr>(" toe" , MatchResult);
2675
2682
ASSERT_NE (TOE, nullptr );
2683
+ auto *Comma = selectFirst<BinaryOperator>(" comma" , MatchResult);
2684
+ ASSERT_NE (Comma, nullptr );
2676
2685
auto *EWC = selectFirst<ExprWithCleanups>(" ewc" , MatchResult);
2677
2686
ASSERT_NE (EWC, nullptr );
2678
2687
auto *BTE = selectFirst<CXXBindTemporaryExpr>(" bte" , MatchResult);
2679
2688
ASSERT_NE (BTE, nullptr );
2680
2689
2681
2690
RecordStorageLocation &Loc = Env.getResultObjectLocation (*TOE);
2691
+ EXPECT_EQ (&Loc, &Env.getResultObjectLocation (*Comma));
2682
2692
EXPECT_EQ (&Loc, &Env.getResultObjectLocation (*EWC));
2683
2693
EXPECT_EQ (&Loc, &Env.getResultObjectLocation (*BTE));
2684
2694
});
0 commit comments