From 1b8011a878de0836a802c28150c5b21c7fe8eb2b Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Tue, 8 Sep 2015 10:11:26 +0000 Subject: [PATCH] Fix documentation of numSelectorArgs. Currently, the documentation for numSelectorArgs includes an incorrect example. It shows a case where an argument of 1 will match a property getter, but a getter will be matched only when N == 0. This diff corrects the documentation and adds a test for numSelectorArgs(0). Patch by Dave Lee. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246998 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/ASTMatchers/ASTMatchers.h | 2 +- unittests/ASTMatchers/ASTMatchersTest.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index cb10daf89e..29f0da557e 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -2151,7 +2151,7 @@ AST_MATCHER(ObjCMessageExpr, hasKeywordSelector) { /// \brief Matches when the selector has the specified number of arguments /// -/// matcher = objCMessageExpr(numSelectorArgs(1)); +/// matcher = objCMessageExpr(numSelectorArgs(0)); /// matches self.bodyView in the code below /// /// matcher = objCMessageExpr(numSelectorArgs(2)); diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index b4435583d5..b0cd8476f7 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -4888,6 +4888,9 @@ TEST(ObjCMessageExprMatcher, SimpleExprs) { EXPECT_TRUE(matchesObjC( Objc1String, objcMessageExpr(hasSelector("contents"), hasUnarySelector()))); + EXPECT_TRUE(matchesObjC( + Objc1String, + objcMessageExpr(hasSelector("contents"), numSelectorArgs(0)))); EXPECT_TRUE(matchesObjC( Objc1String, objcMessageExpr(matchesSelector("uppercase*"), -- 2.40.0