Index: docs/LibASTMatchersReference.html =================================================================== --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -2235,6 +2235,23 @@ +
Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+ class Y {
+ void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+ int a;
+ static int b;
+ };
+memberExpr(isArrow())
+ matches this->x, x, y.x, a, this->b
+Matches if the given method declaration is const. @@ -3886,6 +3903,23 @@
Matches member expressions that are called with '->' as opposed
+to '.'.
+
+Member calls on the implicit this pointer match as called with '->'.
+
+Given
+ class Y {
+ void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
+ int a;
+ static int b;
+ };
+memberExpr(isArrow())
+ matches this->x, x, y.x, a, this->b
+Matches a variable declaration that has automatic storage duration.
Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4703,7 +4703,9 @@
/// \endcode
/// memberExpr(isArrow())
/// matches this->x, x, y.x, a, this->b
-AST_MATCHER(MemberExpr, isArrow) {
+AST_POLYMORPHIC_MATCHER(
+ isArrow, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
+ CXXDependentScopeMemberExpr)) {
return Node.isArrow();
}
Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -765,6 +765,11 @@
memberExpr(isArrow())));
EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
memberExpr(isArrow())));
+ EXPECT_TRUE(matches("template class Y { void x() { this->m; } };",
+ cxxDependentScopeMemberExpr(isArrow())));
+ EXPECT_TRUE(
+ notMatches("template class Y { void x() { (*this).m; } };",
+ cxxDependentScopeMemberExpr(isArrow())));
}
TEST(IsArrow, MatchesStaticMemberVariablesViaArrow) {
@@ -783,6 +788,14 @@
memberExpr(isArrow())));
EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
memberExpr(isArrow())));
+ EXPECT_TRUE(
+ matches("class Y { template void x() { this->x(); } };",
+ unresolvedMemberExpr(isArrow())));
+ EXPECT_TRUE(matches("class Y { template void x() { x(); } };",
+ unresolvedMemberExpr(isArrow())));
+ EXPECT_TRUE(
+ notMatches("class Y { template void x() { (*this).x(); } };",
+ unresolvedMemberExpr(isArrow())));
}
TEST(ConversionDeclaration, IsExplicit) {
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -27,7 +27,7 @@
nullptr));
// Do not accept non-toplevel matchers.
- EXPECT_FALSE(Finder.addDynamicMatcher(isArrow(), nullptr));
+ EXPECT_FALSE(Finder.addDynamicMatcher(isMain(), nullptr));
EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), nullptr));
}
Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===================================================================
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -440,7 +440,8 @@
Error.get()).isNull());
EXPECT_EQ("Incorrect type for arg 1. "
"(Expected = Matcher) != "
- "(Actual = Matcher&Matcher)",
+ "(Actual = Matcher&Matcher"
+ ")",
Error->toString());
}