</pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDependentScopeMemberExpr0')"><a name="cxxDependentScopeMemberExpr0Anchor">cxxDependentScopeMemberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>>...</td></tr>
+<tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
+resolved because the base expression or the member name was dependent.
+
+Given
+ template <class T> void f() { T t; t.g(); }
+cxxDependentScopeMemberExpr()
+ matches t.g
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
matches foo<T>() </pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedMemberExpr0')"><a name="unresolvedMemberExpr0Anchor">unresolvedMemberExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>>...</td></tr>
+<tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
+
+Given
+ struct X {
+ template <class T> void f();
+ void g();
+ };
+ template <class T> void h() { X x; x.f<T>(); x.g(); }
+unresolvedMemberExpr()
+ matches x.f<T>
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('userDefinedLiteral0')"><a name="userDefinedLiteral0Anchor">userDefinedLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
short i = 1;
int j = 42;
decltype(i + j) result = i + j;
-decltypeType()
+decltypeType()
matches "decltype(i + j)"
</pre></td></tr>
/// matches this->x, x, y.x, a, this->b
extern const internal::VariadicDynCastAllOfMatcher<Stmt, MemberExpr> memberExpr;
+/// Matches unresolved member expressions.
+///
+/// Given
+/// \code
+/// struct X {
+/// template <class T> void f();
+/// void g();
+/// };
+/// template <class T> void h() { X x; x.f<T>(); x.g(); }
+/// \endcode
+/// unresolvedMemberExpr()
+/// matches x.f<T>
+extern const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedMemberExpr>
+ unresolvedMemberExpr;
+
+/// Matches member expressions where the actual member referenced could not be
+/// resolved because the base expression or the member name was dependent.
+///
+/// Given
+/// \code
+/// template <class T> void f() { T t; t.g(); }
+/// \endcode
+/// cxxDependentScopeMemberExpr()
+/// matches t.g
+extern const internal::VariadicDynCastAllOfMatcher<Stmt,
+ CXXDependentScopeMemberExpr>
+ cxxDependentScopeMemberExpr;
+
/// Matches call expressions.
///
/// Example matches x.y() and y()
const internal::VariadicAllOfMatcher<Stmt> stmt;
const internal::VariadicDynCastAllOfMatcher<Stmt, DeclStmt> declStmt;
const internal::VariadicDynCastAllOfMatcher<Stmt, MemberExpr> memberExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, UnresolvedMemberExpr>
+ unresolvedMemberExpr;
+const internal::VariadicDynCastAllOfMatcher<Stmt, CXXDependentScopeMemberExpr>
+ cxxDependentScopeMemberExpr;
const internal::VariadicDynCastAllOfMatcher<Stmt, CallExpr> callExpr;
const internal::VariadicDynCastAllOfMatcher<Stmt, LambdaExpr> lambdaExpr;
const internal::VariadicDynCastAllOfMatcher<Stmt, CXXMemberCallExpr>
REGISTER_MATCHER(cxxCtorInitializer);
REGISTER_MATCHER(cxxDefaultArgExpr);
REGISTER_MATCHER(cxxDeleteExpr);
+ REGISTER_MATCHER(cxxDependentScopeMemberExpr);
REGISTER_MATCHER(cxxDestructorDecl);
REGISTER_MATCHER(cxxDynamicCastExpr);
REGISTER_MATCHER(cxxForRangeStmt);
REGISTER_MATCHER(unaryTransformType);
REGISTER_MATCHER(unless);
REGISTER_MATCHER(unresolvedLookupExpr);
+ REGISTER_MATCHER(unresolvedMemberExpr);
REGISTER_MATCHER(unresolvedUsingTypenameDecl);
REGISTER_MATCHER(unresolvedUsingValueDecl);
REGISTER_MATCHER(userDefinedLiteral);
functionTemplateDecl());
}
-const internal::VariadicDynCastAllOfMatcher<Expr, CXXDependentScopeMemberExpr>
- cxxDependentScopeMemberExpr;
-
TEST_P(ImportExpr, ImportCXXDependentScopeMemberExpr) {
MatchVerifier<Decl> Verifier;
testImport(
cxxRecordDecl(has(typedefDecl(has(dependentNameType())))))));
}
-const internal::VariadicDynCastAllOfMatcher<Expr, UnresolvedMemberExpr>
- unresolvedMemberExpr;
-
TEST_P(ImportExpr, UnresolvedMemberExpr) {
MatchVerifier<Decl> Verifier;
testImport("struct S { template <typename T> void mem(); };"
TEST(MemberExpression, DoesNotMatchClasses) {
EXPECT_TRUE(notMatches("class Y { void x() {} };", memberExpr()));
+ EXPECT_TRUE(notMatches("class Y { void x() {} };", unresolvedMemberExpr()));
+ EXPECT_TRUE(
+ notMatches("class Y { void x() {} };", cxxDependentScopeMemberExpr()));
}
TEST(MemberExpression, MatchesMemberFunctionCall) {
EXPECT_TRUE(matches("class Y { void x() { x(); } };", memberExpr()));
+ EXPECT_TRUE(matches("class Y { template <class T> void x() { x<T>(); } };",
+ unresolvedMemberExpr()));
+ EXPECT_TRUE(matches("template <class T> void x() { T t; t.f(); }",
+ cxxDependentScopeMemberExpr()));
}
TEST(MemberExpression, MatchesVariable) {
matches("class Y { void x() { y; } int y; };", memberExpr()));
EXPECT_TRUE(
matches("class Y { void x() { Y y; y.y; } int y; };", memberExpr()));
+ EXPECT_TRUE(matches("template <class T>"
+ "class X : T { void f() { this->T::v; } };",
+ cxxDependentScopeMemberExpr()));
+ EXPECT_TRUE(matches("template <class T> class X : T { void f() { T::v; } };",
+ cxxDependentScopeMemberExpr()));
+ EXPECT_TRUE(matches("template <class T> void x() { T t; t.v; }",
+ cxxDependentScopeMemberExpr()));
}
TEST(MemberExpression, MatchesStaticVariable) {