r301402 - -Wdocumentation should not check the @returns command for Objective-C

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 26 06:09:28 PDT 2017


Author: arphaman
Date: Wed Apr 26 08:09:28 2017
New Revision: 301402

URL: http://llvm.org/viewvc/llvm-project?rev=301402&view=rev
Log:
-Wdocumentation should not check the @returns command for Objective-C
function/block pointer properties

The commit r300981 allowed @param/@return commands for function/block
pointer property declarations. This meant that -Wdocumentation started warning
about @return that was used to document properties whose function/block type
returned void. However, prior to that commit, we allowed @return for all
property declarations, because it can be used to document the value that's
returned by the property getter. This commit restores the previous behaviour:
now the @return command can be used to document all properties without warnings.

rdar://24978538

Modified:
    cfe/trunk/lib/AST/CommentSema.cpp
    cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=301402&r1=301401&r2=301402&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Wed Apr 26 08:09:28 2017
@@ -584,6 +584,10 @@ void Sema::checkReturnsCommand(const Blo
 
   assert(ThisDeclInfo && "should not call this check on a bare comment");
 
+  // We allow the return command for all @properties because it can be used
+  // to document the value that the property getter returns.
+  if (isObjCPropertyDecl())
+    return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
     if (ThisDeclInfo->ReturnType->isVoidType()) {
       unsigned DiagKind;
@@ -610,8 +614,6 @@ void Sema::checkReturnsCommand(const Blo
     }
     return;
   }
-  else if (isObjCPropertyDecl())
-    return;
 
   Diag(Command->getLocation(),
        diag::warn_doc_returns_not_attached_to_a_function_decl)

Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=301402&r1=301401&r2=301402&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Wed Apr 26 08:09:28 2017
@@ -290,4 +290,12 @@ void (^_Nullable blockPointerVariableTha
  */
 @property int (^blockPointerProperty)(int i);
 
+/**
+ * blockReturnsNothing
+ *
+ * \returns Nothing, but can allow this as this pattern is used to document the
+ * value that the property getter returns.
+ */
+ at property void (^blockReturnsNothing)();
+
 @end




More information about the cfe-commits mailing list