@@ -1449,27 +1449,30 @@ TEST(TransferTest, BaseClassInitializer) {
1449
1449
TEST (TransferTest, StructModeledFieldsWithAccessor) {
1450
1450
std::string Code = R"(
1451
1451
class S {
1452
- int *P;
1453
- int *Q;
1454
- int X;
1455
- int Y;
1456
- int Z;
1452
+ int *Ptr;
1453
+ int *PtrNonConst;
1454
+ int Int;
1455
+ int IntWithInc;
1456
+ int IntNotAccessed;
1457
+ int IntRef;
1457
1458
public:
1458
- int *getPtr() const { return P ; }
1459
- int *getPtrNonConst() { return Q ; }
1460
- int getInt(int i) const { return X ; }
1461
- int getWithOtherWork (int i) { Y += i; return Y ; }
1462
- int getIntNotCalled () const { return Z ; }
1459
+ int *getPtr() const { return Ptr ; }
1460
+ int *getPtrNonConst() { return PtrNonConst ; }
1461
+ int getInt(int i) const { return Int ; }
1462
+ int getWithInc (int i) { IntWithInc += i; return IntWithInc ; }
1463
+ int getIntNotAccessed () const { return IntNotAccessed ; }
1463
1464
int getIntNoDefinition() const;
1465
+ int &getIntRef() { return IntRef; }
1464
1466
};
1465
1467
1466
1468
void target() {
1467
1469
S s;
1468
- int *p = s.getPtr();
1469
- int *q = s.getPtrNonConst();
1470
- int x = s.getInt(1);
1471
- int y = s.getWithOtherWork(1);
1472
- int w = s.getIntNoDefinition();
1470
+ int *p1 = s.getPtr();
1471
+ int *p2 = s.getPtrNonConst();
1472
+ int i1 = s.getInt(1);
1473
+ int i2 = s.getWithInc(1);
1474
+ int i3 = s.getIntNoDefinition();
1475
+ int &iref = s.getIntRef();
1473
1476
// [[p]]
1474
1477
}
1475
1478
)" ;
@@ -1484,10 +1487,11 @@ TEST(TransferTest, StructModeledFieldsWithAccessor) {
1484
1487
for (auto [Field, _] : SLoc.children ())
1485
1488
Fields.push_back (Field);
1486
1489
// Only the fields that have simple accessor methods (that have a
1487
- // single statement body that returns the member variable) should be modeled.
1490
+ // single statement body that returns the member variable) should be
1491
+ // modeled.
1488
1492
ASSERT_THAT (Fields, UnorderedElementsAre (
1489
- findValueDecl (ASTCtx, " P " ), findValueDecl (ASTCtx, " Q " ),
1490
- findValueDecl (ASTCtx, " X " )));
1493
+ findValueDecl (ASTCtx, " Ptr " ), findValueDecl (ASTCtx, " PtrNonConst " ),
1494
+ findValueDecl (ASTCtx, " Int " ), findValueDecl (ASTCtx, " IntRef " )));
1491
1495
});
1492
1496
}
1493
1497
0 commit comments