From: Fariborz Jahanian Date: Tue, 5 Mar 2013 23:20:29 +0000 (+0000) Subject: fix a missing check in my last patch. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb8f69f094e95d0132e4a6817a2111ad188ab087;p=clang fix a missing check in my last patch. // rdar://13094352 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176529 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h index 8eb49f65ba..1d8112fa56 100644 --- a/include/clang/AST/CommentSema.h +++ b/include/clang/AST/CommentSema.h @@ -206,6 +206,7 @@ public: void resolveParamCommandIndexes(const FullComment *FC); bool isFunctionDecl(); + bool isAnyFunctionDecl(); bool isFunctionPointerVarDecl(); bool isObjCMethodDecl(); bool isObjCPropertyDecl(); diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 23e27a3fe5..a834bb4b03 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -94,9 +94,12 @@ void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) { return; StringRef Name = Info->Name; unsigned DiagKind = llvm::StringSwitch(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(ThisDeclInfo->CurrentDecl); +} + bool Sema::isObjCMethodDecl() { return isFunctionDecl() && ThisDeclInfo->CurrentDecl && isa(ThisDeclInfo->CurrentDecl);