@@ -1630,6 +1630,84 @@ void opFree()
1630
1630
cxxOperatorCallExpr (forFunction (functionDecl (hasName (" opFree" ))),
1631
1631
hasAnyOperatorName (" +" , " !" ),
1632
1632
hasUnaryOperand (s1Expr)))));
1633
+
1634
+ Code = R"cpp(
1635
+ struct HasIncOperatorsMem
1636
+ {
1637
+ HasIncOperatorsMem& operator++();
1638
+ HasIncOperatorsMem operator++(int);
1639
+ };
1640
+ struct HasIncOperatorsFree
1641
+ {
1642
+ };
1643
+ HasIncOperatorsFree& operator++(HasIncOperatorsFree&);
1644
+ HasIncOperatorsFree operator++(HasIncOperatorsFree&, int);
1645
+
1646
+ void prefixIncOperatorMem()
1647
+ {
1648
+ HasIncOperatorsMem s1;
1649
+ ++s1;
1650
+ }
1651
+ void prefixIncOperatorFree()
1652
+ {
1653
+ HasIncOperatorsFree s1;
1654
+ ++s1;
1655
+ }
1656
+ void postfixIncOperatorMem()
1657
+ {
1658
+ HasIncOperatorsMem s1;
1659
+ s1++;
1660
+ }
1661
+ void postfixIncOperatorFree()
1662
+ {
1663
+ HasIncOperatorsFree s1;
1664
+ s1++;
1665
+ }
1666
+
1667
+ struct HasOpPlusInt
1668
+ {
1669
+ HasOpPlusInt& operator+(int);
1670
+ };
1671
+ void plusIntOperator()
1672
+ {
1673
+ HasOpPlusInt s1;
1674
+ s1+1;
1675
+ }
1676
+ )cpp" ;
1677
+
1678
+ EXPECT_TRUE (matches (
1679
+ Code,
1680
+ traverse (TK_IgnoreUnlessSpelledInSource,
1681
+ cxxOperatorCallExpr (
1682
+ forFunction (functionDecl (hasName (" prefixIncOperatorMem" ))),
1683
+ hasOperatorName (" ++" ), hasUnaryOperand (declRefExpr ())))));
1684
+
1685
+ EXPECT_TRUE (matches (
1686
+ Code,
1687
+ traverse (TK_IgnoreUnlessSpelledInSource,
1688
+ cxxOperatorCallExpr (
1689
+ forFunction (functionDecl (hasName (" prefixIncOperatorFree" ))),
1690
+ hasOperatorName (" ++" ), hasUnaryOperand (declRefExpr ())))));
1691
+
1692
+ EXPECT_TRUE (matches (
1693
+ Code,
1694
+ traverse (TK_IgnoreUnlessSpelledInSource,
1695
+ cxxOperatorCallExpr (
1696
+ forFunction (functionDecl (hasName (" postfixIncOperatorMem" ))),
1697
+ hasOperatorName (" ++" ), hasUnaryOperand (declRefExpr ())))));
1698
+
1699
+ EXPECT_TRUE (matches (
1700
+ Code,
1701
+ traverse (TK_IgnoreUnlessSpelledInSource,
1702
+ cxxOperatorCallExpr (
1703
+ forFunction (functionDecl (hasName (" postfixIncOperatorFree" ))),
1704
+ hasOperatorName (" ++" ), hasUnaryOperand (declRefExpr ())))));
1705
+
1706
+ EXPECT_FALSE (matches (
1707
+ Code, traverse (TK_IgnoreUnlessSpelledInSource,
1708
+ cxxOperatorCallExpr (
1709
+ forFunction (functionDecl (hasName (" plusIntOperator" ))),
1710
+ hasOperatorName (" +" ), hasUnaryOperand (expr ())))));
1633
1711
}
1634
1712
1635
1713
TEST (Matcher, UnaryOperatorTypes) {
0 commit comments