r176147 - comment parsing: Properties are considered like methods, and people

Fariborz Jahanian fjahanian at apple.com
Tue Feb 26 16:46:06 PST 2013


Author: fjahanian
Date: Tue Feb 26 18:46:06 2013
New Revision: 176147

URL: http://llvm.org/viewvc/llvm-project?rev=176147&view=rev
Log:
comment parsing: Properties are considered like methods, and people 
think of them as having return values that may be computed. Don't
warn when using @return in their comment. // rdar://13189938

Added:
    cfe/trunk/test/Sema/nowarn-documentation-property.m
Modified:
    cfe/trunk/include/clang/AST/CommentSema.h
    cfe/trunk/lib/AST/CommentSema.cpp

Modified: cfe/trunk/include/clang/AST/CommentSema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=176147&r1=176146&r2=176147&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentSema.h (original)
+++ cfe/trunk/include/clang/AST/CommentSema.h Tue Feb 26 18:46:06 2013
@@ -201,6 +201,7 @@ public:
   void resolveParamCommandIndexes(const FullComment *FC);
 
   bool isFunctionDecl();
+  bool isObjCPropertyDecl();
   bool isTemplateOrSpecialization();
 
   ArrayRef<const ParmVarDecl *> getParamVars();

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=176147&r1=176146&r2=176147&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Tue Feb 26 18:46:06 2013
@@ -465,6 +465,9 @@ void Sema::checkReturnsCommand(const Blo
     }
     return;
   }
+  else if (isObjCPropertyDecl())
+    return;
+  
   Diag(Command->getLocation(),
        diag::warn_doc_returns_not_attached_to_a_function_decl)
     << Command->getCommandName(Traits)
@@ -652,6 +655,14 @@ bool Sema::isFunctionDecl() {
     inspectThisDecl();
   return ThisDeclInfo->getKind() == DeclInfo::FunctionKind;
 }
+  
+bool Sema::isObjCPropertyDecl() {
+  if (!ThisDeclInfo)
+    return false;
+  if (!ThisDeclInfo->IsFilled)
+    inspectThisDecl();
+  return ThisDeclInfo->CurrentDecl->getKind() == Decl::ObjCProperty;
+}
 
 bool Sema::isTemplateOrSpecialization() {
   if (!ThisDeclInfo)

Added: cfe/trunk/test/Sema/nowarn-documentation-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/nowarn-documentation-property.m?rev=176147&view=auto
==============================================================================
--- cfe/trunk/test/Sema/nowarn-documentation-property.m (added)
+++ cfe/trunk/test/Sema/nowarn-documentation-property.m Tue Feb 26 18:46:06 2013
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -Wdocumentation -verify %s
+// expected-no-diagnostics
+// rdar://13189938
+
+ at interface NSPredicate
+///     The full predicate to be used for drawing objects from the store.
+///     It is an AND of the parent's `prefixPredicate` (e.g., the selection for
+///     volume number) and the `filterPredicate` (selection by matching the name).
+///     @return `nil` if there is no search string, and no prefix.
+
+ at property(readonly) NSPredicate *andPredicate;
+///     The predicate that matches the string to be searched for. This
+///     @return `nil` if there is no search string.
+ at property(readonly) NSPredicate *filterPredicate;
+ at end





More information about the cfe-commits mailing list