t-rasmud updated this revision to Diff 440766. t-rasmud added a comment. Removes manually added documentation and adds it in the header file.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D128103/new/ https://reviews.llvm.org/D128103 Files: clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/ASTMatchers/ASTMatchersInternal.cpp clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -2352,6 +2352,26 @@ argumentCountIs(0)))); } +TEST(ASTMatchersTestObjC, ObjCStringLiteral) { + + StringRef Objc1String = "@interface NSObject " + "@end " + "@interface NSString " + "@end " + "@interface Test : NSObject " + "+ (void)someFunction:(NSString *)Desc; " + "@end " + "@implementation Test " + "+ (void)someFunction:(NSString *)Desc { " + " return; " + "} " + "- (void) foo { " + " [Test someFunction:@\"Ola!\"]; " + "}\n" + "@end "; + EXPECT_TRUE(matchesObjC(Objc1String, objcStringLiteral())); +} + TEST(ASTMatchersTestObjC, ObjCDecls) { StringRef ObjCString = "@protocol Proto " "- (void)protoDidThing; " Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -505,6 +505,7 @@ REGISTER_MATCHER(objcObjectPointerType); REGISTER_MATCHER(objcPropertyDecl); REGISTER_MATCHER(objcProtocolDecl); + REGISTER_MATCHER(objcStringLiteral); REGISTER_MATCHER(objcThrowStmt); REGISTER_MATCHER(objcTryStmt); REGISTER_MATCHER(ofClass); Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -917,6 +917,7 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBoolLiteralExpr> cxxBoolLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, StringLiteral> stringLiteral; +const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCStringLiteral> objcStringLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, CharacterLiteral> characterLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, IntegerLiteral> Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -1515,6 +1515,15 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCMessageExpr> objcMessageExpr; +/// Matches ObjectiveC String literal expressions. +/// +/// Example matches @"abcd" +/// \code +/// NSString *s = @"abcd"; +/// \endcode +extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCStringLiteral> + objcStringLiteral; + /// Matches Objective-C interface declarations. /// /// Example matches Foo
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -2352,6 +2352,26 @@ argumentCountIs(0)))); } +TEST(ASTMatchersTestObjC, ObjCStringLiteral) { + + StringRef Objc1String = "@interface NSObject " + "@end " + "@interface NSString " + "@end " + "@interface Test : NSObject " + "+ (void)someFunction:(NSString *)Desc; " + "@end " + "@implementation Test " + "+ (void)someFunction:(NSString *)Desc { " + " return; " + "} " + "- (void) foo { " + " [Test someFunction:@\"Ola!\"]; " + "}\n" + "@end "; + EXPECT_TRUE(matchesObjC(Objc1String, objcStringLiteral())); +} + TEST(ASTMatchersTestObjC, ObjCDecls) { StringRef ObjCString = "@protocol Proto " "- (void)protoDidThing; " Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp =================================================================== --- clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -505,6 +505,7 @@ REGISTER_MATCHER(objcObjectPointerType); REGISTER_MATCHER(objcPropertyDecl); REGISTER_MATCHER(objcProtocolDecl); + REGISTER_MATCHER(objcStringLiteral); REGISTER_MATCHER(objcThrowStmt); REGISTER_MATCHER(objcTryStmt); REGISTER_MATCHER(ofClass); Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -917,6 +917,7 @@ const internal::VariadicDynCastAllOfMatcher<Stmt, CXXBoolLiteralExpr> cxxBoolLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, StringLiteral> stringLiteral; +const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCStringLiteral> objcStringLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, CharacterLiteral> characterLiteral; const internal::VariadicDynCastAllOfMatcher<Stmt, IntegerLiteral> Index: clang/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchers.h +++ clang/include/clang/ASTMatchers/ASTMatchers.h @@ -1515,6 +1515,15 @@ extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCMessageExpr> objcMessageExpr; +/// Matches ObjectiveC String literal expressions. +/// +/// Example matches @"abcd" +/// \code +/// NSString *s = @"abcd"; +/// \endcode +extern const internal::VariadicDynCastAllOfMatcher<Stmt, ObjCStringLiteral> + objcStringLiteral; + /// Matches Objective-C interface declarations. /// /// Example matches Foo
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits