<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>I hate to continue bikeshedding here, but why is this not just a single warning with a %select and associated enum { Function, Callback, Method }?</div><div><br></div><div>Also, "Objective-C" should not be lowercase.</div><div><br></div><br><div><div>On Mar 5, 2013, at 14:46 , Fariborz Jahanian <<a href="mailto:fjahanian@apple.com">fjahanian@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">Author: fjahanian<br>Date: Tue Mar 5 16:46:07 2013<br>New Revision: 176525<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=176525&view=rev">http://llvm.org/viewvc/llvm-project?rev=176525&view=rev</a><br>Log:<br>doc. parsing. Improve on diagnostics on my last patch.<br>//<span class="Apple-converted-space"> </span><a href="rdar://13094352">rdar://13094352</a>.<br><br>Modified:<br> cfe/trunk/include/clang/AST/CommentSema.h<br> cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td<br> cfe/trunk/lib/AST/CommentSema.cpp<br> cfe/trunk/test/Sema/warn-documentation.cpp<br> cfe/trunk/test/Sema/warn-documentation.m<br><br>Modified: cfe/trunk/include/clang/AST/CommentSema.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=176525&r1=176524&r2=176525&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=176525&r1=176524&r2=176525&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/AST/CommentSema.h (original)<br>+++ cfe/trunk/include/clang/AST/CommentSema.h Tue Mar 5 16:46:07 2013<br>@@ -206,7 +206,8 @@ public:<br> void resolveParamCommandIndexes(const FullComment *FC);<br><br> bool isFunctionDecl();<br>- bool isCallbackDecl();<br>+ bool isFunctionPointerVarDecl();<br>+ bool isObjCMethodDecl();<br> bool isObjCPropertyDecl();<br> bool isTemplateOrSpecialization();<br><br><br>Modified: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=176525&r1=176524&r2=176525&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=176525&r1=176524&r2=176525&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td (original)<br>+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td Tue Mar 5 16:46:07 2013<br>@@ -74,8 +74,18 @@ def warn_doc_param_not_attached_to_a_fun<br> InGroup<Documentation>, DefaultIgnore;<br><br>def warn_doc_function_not_attached_to_a_function_decl : Warning<<br>- "'%select{\\|@}0%1' command used in a comment that is attached to a non-%2 "<br>- "declaration immediately following it">,<br>+ "'%select{\\|@}0function' command should be used in a comment attached to a "<br>+ "function declaration">,<br>+ InGroup<Documentation>, DefaultIgnore;<br>+ <br>+def warn_doc_callback_not_attached_to_a_function_ptr_decl : Warning<<br>+ "'%select{\\|@}0callback' command should be used in a comment attached to a "<br>+ "pointer to function declaration">,<br>+ InGroup<Documentation>, DefaultIgnore;<br>+<br>+def warn_doc_method_not_attached_to_a_objc_method_decl : Warning<<br>+ "'%select{\\|@}0method' command should be used in a comment attached to an "<br>+ "objective-c method declaration">,<br> InGroup<Documentation>, DefaultIgnore;<br><br>def warn_doc_param_duplicate : Warning<<br><br>Modified: cfe/trunk/lib/AST/CommentSema.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=176525&r1=176524&r2=176525&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=176525&r1=176524&r2=176525&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/AST/CommentSema.cpp (original)<br>+++ cfe/trunk/lib/AST/CommentSema.cpp Tue Mar 5 16:46:07 2013<br>@@ -90,12 +90,17 @@ ParamCommandComment *Sema::actOnParamCom<br><br>void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) {<br> const CommandInfo *Info = Traits.getCommandInfo(Comment->getCommandID());<br>- if (Info->IsFunctionDeclarationCommand &&<br>- !isFunctionDecl() && !isCallbackDecl())<br>- Diag(Comment->getLocation(),<br>- diag::warn_doc_function_not_attached_to_a_function_decl)<br>- << Comment->getCommandMarker()<br>- << Info->Name << Info->Name<br>+ if (!Info->IsFunctionDeclarationCommand)<br>+ return;<br>+ StringRef Name = Info->Name;<br>+ unsigned DiagKind = llvm::StringSwitch<unsigned>(Name)<br>+ .Case("function", diag::warn_doc_function_not_attached_to_a_function_decl)<br>+ .Case("method", diag::warn_doc_method_not_attached_to_a_objc_method_decl)<br>+ .Case("callback", diag::warn_doc_callback_not_attached_to_a_function_ptr_decl)<br>+ .Default(0);<br>+ <br>+ if (DiagKind)<br>+ Diag(Comment->getLocation(), DiagKind) << Comment->getCommandMarker()<br> << Comment->getSourceRange();<br>}<br><br>@@ -685,8 +690,15 @@ bool Sema::isFunctionDecl() {<br> inspectThisDecl();<br> return ThisDeclInfo->getKind() == DeclInfo::FunctionKind;<br>}<br>+<br>+bool Sema::isObjCMethodDecl() {<br>+ return isFunctionDecl() && ThisDeclInfo->CurrentDecl &&<br>+ isa<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl);<br>+}<br><br>-bool Sema::isCallbackDecl() {<br>+/// isFunctionPointerVarDecl - returns 'true' if declaration is a pointer to<br>+/// function decl.<br>+bool Sema::isFunctionPointerVarDecl() {<br> if (!ThisDeclInfo)<br> return false;<br> if (!ThisDeclInfo->IsFilled)<br><br>Modified: cfe/trunk/test/Sema/warn-documentation.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=176525&r1=176524&r2=176525&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=176525&r1=176524&r2=176525&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Sema/warn-documentation.cpp (original)<br>+++ cfe/trunk/test/Sema/warn-documentation.cpp Tue Mar 5 16:46:07 2013<br>@@ -549,13 +549,13 @@ namespace test_returns_wrong_decl_10 { }<br>typedef unsigned int test_returns_wrong_decl_11;<br><br>//<span class="Apple-converted-space"> </span><a href="rdar://13094352">rdar://13094352</a><br>-// expected-warning@+1 {{'@function' command used in a comment that is attached to a non-function declaration immediately following it}}<br>+// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}<br>/*!<span class="Apple-tab-span" style="white-space: pre;"> </span>@function test_function<br>*/<br>typedef unsigned int Base64Flags;<br>unsigned test_function(Base64Flags inFlags);<br><br>-// expected-warning@+1 {{'@callback' command used in a comment that is attached to a non-callback declaration immediately following it}}<br>+// expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}<br>/*! @callback test_callback<br>*/<br>typedef unsigned int BaseFlags;<br><br>Modified: cfe/trunk/test/Sema/warn-documentation.m<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=176525&r1=176524&r2=176525&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=176525&r1=176524&r2=176525&view=diff</a><br>==============================================================================<br>--- cfe/trunk/test/Sema/warn-documentation.m (original)<br>+++ cfe/trunk/test/Sema/warn-documentation.m Tue Mar 5 16:46:07 2013<br>@@ -98,7 +98,7 @@ int b;<br>typedef int (^test_param1)(int aaa, int ccc);<br><br>//<span class="Apple-converted-space"> </span><a href="rdar://13094352">rdar://13094352</a><br>-// expected-warning@+2 {{'@method' command used in a comment that is attached to a non-method declaration immediately following it}}<br>+// expected-warning@+2 {{'@method' command should be used in a comment attached to an objective-c method declaration}}<br>@interface I<br>/*!<span class="Apple-tab-span" style="white-space: pre;"> </span>@method Base64EncodeEx<br>*/<br><br><br>_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></div></blockquote></div><br></body></html>