r176560 - say objective-C in the warning and streamline
Fariborz Jahanian
fjahanian at apple.com
Wed Mar 6 09:36:51 PST 2013
Author: fjahanian
Date: Wed Mar 6 11:36:51 2013
New Revision: 176560
URL: http://llvm.org/viewvc/llvm-project?rev=176560&view=rev
Log:
say objective-C in the warning and streamline
several diagnostics into one. // rdar://13094352
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=176560&r1=176559&r2=176560&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td Wed Mar 6 11:36:51 2013
@@ -73,19 +73,10 @@ def warn_doc_param_not_attached_to_a_fun
"a function declaration">,
InGroup<Documentation>, DefaultIgnore;
-def warn_doc_function_not_attached_to_a_function_decl : Warning<
- "'%select{\\|@}0function' command should be used in a comment attached to a "
- "function declaration">,
- InGroup<Documentation>, DefaultIgnore;
-
-def warn_doc_callback_not_attached_to_a_function_ptr_decl : Warning<
- "'%select{\\|@}0callback' command should be used in a comment attached to a "
- "pointer to function declaration">,
- InGroup<Documentation>, DefaultIgnore;
-
-def warn_doc_method_not_attached_to_a_objc_method_decl : Warning<
- "'%select{\\|@}0method' command should be used in a comment attached to an "
- "objective-c method declaration">,
+def warn_doc_function_method_decl_mismatch : Warning<
+ "'%select{\\|@}0%select{function|method|callback}1' command should be "
+ "used in a comment attached to "
+ "%select{a function|an objective-C method|a pointer to function}2 declaration">,
InGroup<Documentation>, DefaultIgnore;
def warn_doc_param_duplicate : Warning<
Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=176560&r1=176559&r2=176560&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Wed Mar 6 11:36:51 2013
@@ -93,17 +93,16 @@ void Sema::checkFunctionDeclVerbatimLine
if (!Info->IsFunctionDeclarationCommand)
return;
StringRef Name = Info->Name;
- unsigned DiagKind = llvm::StringSwitch<unsigned>(Name)
- .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)
+ unsigned DiagSelect = llvm::StringSwitch<unsigned>(Name)
+ .Case("function", !isAnyFunctionDecl() ? 1 : 0)
+ .Case("method", !isObjCMethodDecl() ? 2 : 0)
+ .Case("callback", !isFunctionPointerVarDecl() ? 3 : 0)
.Default(0);
- if (DiagKind)
- Diag(Comment->getLocation(), DiagKind) << Comment->getCommandMarker()
+ if (DiagSelect)
+ Diag(Comment->getLocation(), diag::warn_doc_function_method_decl_mismatch)
+ << Comment->getCommandMarker()
+ << (DiagSelect-1) << (DiagSelect-1)
<< Comment->getSourceRange();
}
Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=176560&r1=176559&r2=176560&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Wed Mar 6 11:36:51 2013
@@ -98,7 +98,7 @@ int b;
typedef int (^test_param1)(int aaa, int ccc);
// rdar://13094352
-// expected-warning at +2 {{'@method' command should be used in a comment attached to an objective-c method declaration}}
+// expected-warning at +2 {{'@method' command should be used in a comment attached to an objective-C method declaration}}
@interface I
/*! @method Base64EncodeEx
*/
More information about the cfe-commits
mailing list