forked from OSchip/llvm-project
Add a new matcher to match character types.
llvm-svn: 255627
This commit is contained in:
parent
e3556420c1
commit
009c5d52e3
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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())));
|
||||
|
|
Loading…
Reference in New Issue