summaryrefslogtreecommitdiff
path: root/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersNodeTest.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 58c26eafd7e0d..59fadadbedc75 100644
--- a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1184,6 +1184,10 @@ TEST(TypeMatching, MatchesAutoTypes) {
EXPECT_TRUE(matches("int v[] = { 2, 3 }; void f() { for (int i : v) {} }",
autoType()));
+ EXPECT_TRUE(matches("auto i = 2;", varDecl(hasType(isInteger()))));
+ EXPECT_TRUE(matches("struct X{}; auto x = X{};",
+ varDecl(hasType(recordDecl(hasName("X"))))));
+
// FIXME: Matching against the type-as-written can't work here, because the
// type as written was not deduced.
//EXPECT_TRUE(matches("auto a = 1;",
@@ -1586,7 +1590,7 @@ TEST(ObjCMessageExprMatcher, SimpleExprs) {
)));
}
-TEST(ObjCDeclMacher, CoreDecls) {
+TEST(ObjCDeclMatcher, CoreDecls) {
std::string ObjCString =
"@protocol Proto "
"- (void)protoDidThing; "
@@ -1601,6 +1605,9 @@ TEST(ObjCDeclMacher, CoreDecls) {
"{ id _ivar; } "
"- (void)anything {} "
"@end "
+ "@implementation Thing (ABC) "
+ "- (void)abc_doThing {} "
+ "@end "
;
EXPECT_TRUE(matchesObjC(
@@ -1608,9 +1615,15 @@ TEST(ObjCDeclMacher, CoreDecls) {
objcProtocolDecl(hasName("Proto"))));
EXPECT_TRUE(matchesObjC(
ObjCString,
+ objcImplementationDecl(hasName("Thing"))));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
objcCategoryDecl(hasName("ABC"))));
EXPECT_TRUE(matchesObjC(
ObjCString,
+ objcCategoryImplDecl(hasName("ABC"))));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
objcMethodDecl(hasName("protoDidThing"))));
EXPECT_TRUE(matchesObjC(
ObjCString,
@@ -1626,5 +1639,28 @@ TEST(ObjCDeclMacher, CoreDecls) {
objcPropertyDecl(hasName("enabled"))));
}
+TEST(ObjCStmtMatcher, ExceptionStmts) {
+ std::string ObjCString =
+ "void f(id obj) {"
+ " @try {"
+ " @throw obj;"
+ " } @catch (...) {"
+ " } @finally {}"
+ "}";
+
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
+ objcTryStmt()));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
+ objcThrowStmt()));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
+ objcCatchStmt()));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
+ objcFinallyStmt()));
+}
+
} // namespace ast_matchers
} // namespace clang