]> granicus.if.org Git - clang/commitdiff
fix a missing check in my last patch.
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 5 Mar 2013 23:20:29 +0000 (23:20 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 5 Mar 2013 23:20:29 +0000 (23:20 +0000)
// rdar://13094352

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176529 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/CommentSema.h
lib/AST/CommentSema.cpp

index 8eb49f65bad15298f58fa4ef4f794f89564a8a81..1d8112fa566a7a069d77ef2ab9b29a4161c483da 100644 (file)
@@ -206,6 +206,7 @@ public:
   void resolveParamCommandIndexes(const FullComment *FC);
 
   bool isFunctionDecl();
+  bool isAnyFunctionDecl();
   bool isFunctionPointerVarDecl();
   bool isObjCMethodDecl();
   bool isObjCPropertyDecl();
index 23e27a3fe5bfd2c70283dc72e38f251e672c9c21..a834bb4b030fa24174b4217cf43c5ab333c7dff5 100644 (file)
@@ -94,9 +94,12 @@ void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) {
     return;
   StringRef Name = Info->Name;
   unsigned DiagKind = llvm::StringSwitch<unsigned>(Name)
-  .Case("function", diag::warn_doc_function_not_attached_to_a_function_decl)
-  .Case("method", diag::warn_doc_method_not_attached_to_a_objc_method_decl)
-  .Case("callback", diag::warn_doc_callback_not_attached_to_a_function_ptr_decl)
+  .Case("function", !isAnyFunctionDecl() ?
+                    diag::warn_doc_function_not_attached_to_a_function_decl : 0)
+  .Case("method", !isObjCMethodDecl() ?
+                  diag::warn_doc_method_not_attached_to_a_objc_method_decl : 0)
+  .Case("callback", !isFunctionPointerVarDecl() ?
+        diag::warn_doc_callback_not_attached_to_a_function_ptr_decl : 0)
   .Default(0);
   
   if (DiagKind)
@@ -691,6 +694,11 @@ bool Sema::isFunctionDecl() {
   return ThisDeclInfo->getKind() == DeclInfo::FunctionKind;
 }
 
+bool Sema::isAnyFunctionDecl() {
+  return isFunctionDecl() && ThisDeclInfo->CurrentDecl &&
+         isa<FunctionDecl>(ThisDeclInfo->CurrentDecl);
+}
+  
 bool Sema::isObjCMethodDecl() {
   return isFunctionDecl() && ThisDeclInfo->CurrentDecl &&
          isa<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl);