Summary: Add voidType() matcher.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6656
llvm-svn: 224250
new internal::TypeLocTypeMatcher(InnerMatcher));
}
+/// \brief Matches type \c void.
+///
+/// Given
+/// \code
+/// struct S { void func(); };
+/// \endcode
+/// functionDecl(returns(voidType()))
+/// matches "void func();"
+AST_MATCHER(Type, voidType) {
+ return Node.isVoidType();
+}
+
/// \brief Matches builtin Types.
///
/// Given
REGISTER_MATCHER(valueDecl);
REGISTER_MATCHER(varDecl);
REGISTER_MATCHER(variableArrayType);
+ REGISTER_MATCHER(voidType);
REGISTER_MATCHER(whileStmt);
REGISTER_MATCHER(withInitializer);
}
EXPECT_TRUE(matches("struct S {};", qualType().bind("loc")));
}
+TEST(TypeMatching, MatchesVoid) {
+ EXPECT_TRUE(
+ matches("struct S { void func(); };", methodDecl(returns(voidType()))));
+}
+
TEST(TypeMatching, MatchesArrayTypes) {
EXPECT_TRUE(matches("int a[] = {2,3};", arrayType()));
EXPECT_TRUE(matches("int a[42];", arrayType()));