Add AST matchers for handling bit-fields and narrowing based on their width.
llvm-svn: 274652
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 7deed85..28b462e 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1366,6 +1366,14 @@
memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
}
+TEST(Member, BitFields) {
+ EXPECT_TRUE(matches("class C { int a : 2; int b; };",
+ fieldDecl(isBitField(), hasName("a"))));
+ EXPECT_TRUE(notMatches("class C { int a : 2; int b; };",
+ fieldDecl(isBitField(), hasName("b"))));
+ EXPECT_TRUE(matches("class C { int a : 2; int b : 4; };",
+ fieldDecl(isBitField(), hasBitWidth(2), hasName("a"))));
+}
TEST(Member, UnderstandsAccess) {
EXPECT_TRUE(matches(