diff options
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp index dd45ca3ced92..5c29334222df 100644 --- a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1494,15 +1494,32 @@ TEST(TypedefNameDeclMatcher, Match) { typedefNameDecl(hasName("typedefNameDeclTest2")))); } +TEST(TypeAliasTemplateDeclMatcher, Match) { + std::string Code = R"( + template <typename T> + class X { T t; }; + + template <typename T> + using typeAliasTemplateDecl = X<T>; + + using typeAliasDecl = X<int>; + )"; + EXPECT_TRUE( + matches(Code, typeAliasTemplateDecl(hasName("typeAliasTemplateDecl")))); + EXPECT_TRUE( + notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl")))); +} + TEST(ObjCMessageExprMatcher, SimpleExprs) { // don't find ObjCMessageExpr where none are present EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything()))); std::string Objc1String = "@interface Str " - " - (Str *)uppercaseString:(Str *)str;" + " - (Str *)uppercaseString;" "@end " "@interface foo " + "- (void)contents;" "- (void)meth:(Str *)text;" "@end " " " @@ -1540,5 +1557,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 |