summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-07-27 17:26:11 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-07-27 17:26:11 +0000
commit079275b4dc23d6eb5fd539b2a48e4182cdfe8a59 (patch)
tree05bc476e11590ea3d18badb5c3e9d5f396ce9c2f /clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
parentfaea2d31304709b17cff19be8403952c0b3395cb (diff)
downloadbcm5719-llvm-079275b4dc23d6eb5fd539b2a48e4182cdfe8a59.tar.gz
bcm5719-llvm-079275b4dc23d6eb5fd539b2a48e4182cdfe8a59.zip
[ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration.
ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher is required to support it. Adding a hasDeclaration support as well, as it's not very useful without it. Differential Revision: https://reviews.llvm.org/D49701 llvm-svn: 338137
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 7426dd926d8..1e7b10e99e7 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1354,6 +1354,16 @@ TEST(Matcher, HandlesNullQualTypes) {
))))));
}
+TEST(ObjCIvarRefExprMatcher, IvarExpr) {
+ std::string ObjCString =
+ "@interface A @end "
+ "@implementation A { A *x; } - (void) func { x = 0; } @end";
+ EXPECT_TRUE(matchesObjC(ObjCString, objcIvarRefExpr()));
+ EXPECT_TRUE(matchesObjC(ObjCString, objcIvarRefExpr(
+ hasDeclaration(namedDecl(hasName("x"))))));
+ EXPECT_FALSE(matchesObjC(ObjCString, objcIvarRefExpr(
+ hasDeclaration(namedDecl(hasName("y"))))));
+}
TEST(StatementCountIs, FindsNoStatementsInAnEmptyCompoundStatement) {
EXPECT_TRUE(matches("void f() { }",
OpenPOWER on IntegriCloud