summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2015-12-15 08:35:45 +0000
committerGabor Horvath <xazax.hun@gmail.com>2015-12-15 08:35:45 +0000
commit009c5d52e3e2e713e5cf943bb1ba6d5050388a4e (patch)
tree2f26b201e30b19183b2b1688f06863779167bbe8
parente3556420c1c02f1e34ad87acac458348e7d29389 (diff)
downloadbcm5719-llvm-009c5d52e3e2e713e5cf943bb1ba6d5050388a4e.tar.gz
bcm5719-llvm-009c5d52e3e2e713e5cf943bb1ba6d5050388a4e.zip
Add a new matcher to match character types.
llvm-svn: 255627
-rw-r--r--clang/include/clang/ASTMatchers/ASTMatchers.h14
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp8
2 files changed, 22 insertions, 0 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 6a5f5ee57c5..6fcae748d82 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3533,6 +3533,20 @@ AST_MATCHER(QualType, isInteger) {
return Node->isIntegerType();
}
+/// \brief Matches QualType nodes that are of character type.
+///
+/// Given
+/// \code
+/// void a(char);
+/// void b(wchar_t);
+/// void c(double);
+/// \endcode
+/// functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
+/// matches "a(char)", "b(wchar_t)", but not "c(double)".
+AST_MATCHER(QualType, isAnyCharacter) {
+ return Node->isAnyCharacterType();
+}
+
/// \brief Matches QualType nodes that are const-qualified, i.e., that
/// include "top-level" const.
///
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 9aefb078091..80f234338a3 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1469,6 +1469,14 @@ TEST(IsInteger, ReportsNoFalsePositives) {
to(varDecl(hasType(isInteger()))))))));
}
+TEST(IsAnyCharacter, MatchesCharacters) {
+ EXPECT_TRUE(matches("char i = 0;", varDecl(hasType(isAnyCharacter()))));
+}
+
+TEST(IsAnyCharacter, ReportsNoFalsePositives) {
+ EXPECT_TRUE(notMatches("int i;", varDecl(hasType(isAnyCharacter()))));
+}
+
TEST(IsArrow, MatchesMemberVariablesViaArrow) {
EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
memberExpr(isArrow())));
OpenPOWER on IntegriCloud