comment parsing: Properties are considered like methods, and people
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 27 Feb 2013 00:46:06 +0000 (00:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 27 Feb 2013 00:46:06 +0000 (00:46 +0000)
think of them as having return values that may be computed. Don't
warn when using @return in their comment. // rdar://13189938

llvm-svn: 176147

clang/include/clang/AST/CommentSema.h
clang/lib/AST/CommentSema.cpp
clang/test/Sema/nowarn-documentation-property.m [new file with mode: 0644]

index 97099bf..76957c2 100644 (file)
@@ -201,6 +201,7 @@ public:
   void resolveParamCommandIndexes(const FullComment *FC);
 
   bool isFunctionDecl();
+  bool isObjCPropertyDecl();
   bool isTemplateOrSpecialization();
 
   ArrayRef<const ParmVarDecl *> getParamVars();
index fd2b5b1..73e49e7 100644 (file)
@@ -465,6 +465,9 @@ void Sema::checkReturnsCommand(const BlockCommandComment *Command) {
     }
     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)
diff --git a/clang/test/Sema/nowarn-documentation-property.m b/clang/test/Sema/nowarn-documentation-property.m
new file mode 100644 (file)
index 0000000..af2b062
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -Wdocumentation -verify %s
+// expected-no-diagnostics
+// rdar://13189938
+
+@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.
+
+@property(readonly) NSPredicate *andPredicate;
+///     The predicate that matches the string to be searched for. This
+///     @return `nil` if there is no search string.
+@property(readonly) NSPredicate *filterPredicate;
+@end