diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2017-03-15 20:14:25 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2017-03-15 20:14:25 +0000 |
commit | 219029ad97df7d75a12bdc390877379e72b463b5 (patch) | |
tree | 811cab76968c17cc5ec9472eb9794d01e008acce /unittests/ASTMatchers/ASTMatchersNodeTest.cpp | |
parent | 023b8ac9959be26fa8ad4e898fb583bcb179c78e (diff) |
Add AST matchers for ObjCProtocolDecl, ObjCCategoryDecl, ObjCMethodDecl, ObjCIvarDecl, and ObjCPropertyDecl.
Patch by Dave Lee.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297882 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp index dd45ca3ced..4c13acfaf0 100644 --- a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1500,9 +1500,10 @@ TEST(ObjCMessageExprMatcher, SimpleExprs) { std::string Objc1String = "@interface Str " - " - (Str *)uppercaseString:(Str *)str;" + " - (Str *)uppercaseString;" "@end " "@interface foo " + "- (void)contents;" "- (void)meth:(Str *)text;" "@end " " " @@ -1540,5 +1541,45 @@ TEST(ObjCMessageExprMatcher, SimpleExprs) { ))); } +TEST(ObjCDeclMacher, CoreDecls) { + std::string ObjCString = + "@protocol Proto " + "- (void)protoDidThing; " + "@end " + "@interface Thing " + "@property int enabled; " + "@end " + "@interface Thing (ABC) " + "- (void)abc_doThing; " + "@end " + "@implementation Thing " + "{ id _ivar; } " + "- (void)anything {} " + "@end " + ; + + EXPECT_TRUE(matchesObjC( + ObjCString, + objcProtocolDecl(hasName("Proto")))); + EXPECT_TRUE(matchesObjC( + ObjCString, + objcCategoryDecl(hasName("ABC")))); + EXPECT_TRUE(matchesObjC( + ObjCString, + objcMethodDecl(hasName("protoDidThing")))); + EXPECT_TRUE(matchesObjC( + ObjCString, + objcMethodDecl(hasName("abc_doThing")))); + EXPECT_TRUE(matchesObjC( + ObjCString, + objcMethodDecl(hasName("anything")))); + EXPECT_TRUE(matchesObjC( + ObjCString, + objcIvarDecl(hasName("_ivar")))); + EXPECT_TRUE(matchesObjC( + ObjCString, + objcPropertyDecl(hasName("enabled")))); +} + } // namespace ast_matchers } // namespace clang |