</pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasDefinition0')"><a name="hasDefinition0Anchor">hasDefinition</a></td><td></td></tr>
+<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined.
+
+Example matches x (matcher = cxxRecordDecl(hasDefinition()))
+class x {};
+class y;
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr>
<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
</pre></td></tr>
InnerMatcher.matches(*Node.getArraySize(), Finder, Builder);
}
+/// \brief Matches a class declaration that is defined.
+///
+/// Example matches x (matcher = cxxRecordDecl(hasDefinition()))
+/// \code
+/// class x {};
+/// class y;
+/// \endcode
+AST_MATCHER(CXXRecordDecl, hasDefinition) {
+ return Node.hasDefinition();
+}
+
} // namespace ast_matchers
} // namespace clang
REGISTER_MATCHER(hasDeclContext);
REGISTER_MATCHER(hasDeducedType);
REGISTER_MATCHER(hasDefaultArgument);
+ REGISTER_MATCHER(hasDefinition);
REGISTER_MATCHER(hasDescendant);
REGISTER_MATCHER(hasDestinationType);
REGISTER_MATCHER(hasDynamicExceptionSpec);
cxxNewExpr(hasArraySize(integerLiteral(equals(10))))));
}
+TEST(HasDefinition, MatchesStructDefinition) {
+ EXPECT_TRUE(matches("struct x {};",
+ cxxRecordDecl(hasDefinition())));
+ EXPECT_TRUE(notMatches("struct x;",
+ cxxRecordDecl(hasDefinition())));
+}
+
+TEST(HasDefinition, MatchesClassDefinition) {
+ EXPECT_TRUE(matches("class x {};",
+ cxxRecordDecl(hasDefinition())));
+ EXPECT_TRUE(notMatches("class x;",
+ cxxRecordDecl(hasDefinition())));
+}
+
+TEST(HasDefinition, MatchesUnionDefinition) {
+ EXPECT_TRUE(matches("union x {};",
+ cxxRecordDecl(hasDefinition())));
+ EXPECT_TRUE(notMatches("union x;",
+ cxxRecordDecl(hasDefinition())));
+}
+
} // namespace ast_matchers
} // namespace clang