void resolveParamCommandIndexes(const FullComment *FC);
bool isFunctionDecl();
- bool isCallbackDecl();
+ bool isFunctionPointerVarDecl();
+ bool isObjCMethodDecl();
bool isObjCPropertyDecl();
bool isTemplateOrSpecialization();
InGroup<Documentation>, DefaultIgnore;
def warn_doc_function_not_attached_to_a_function_decl : Warning<
- "'%select{\\|@}0%1' command used in a comment that is attached to a non-%2 "
- "declaration immediately following it">,
+ "'%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">,
InGroup<Documentation>, DefaultIgnore;
def warn_doc_param_duplicate : Warning<
void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) {
const CommandInfo *Info = Traits.getCommandInfo(Comment->getCommandID());
- if (Info->IsFunctionDeclarationCommand &&
- !isFunctionDecl() && !isCallbackDecl())
- Diag(Comment->getLocation(),
- diag::warn_doc_function_not_attached_to_a_function_decl)
- << Comment->getCommandMarker()
- << Info->Name << Info->Name
+ if (!Info->IsFunctionDeclarationCommand)
+ 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)
+ .Default(0);
+
+ if (DiagKind)
+ Diag(Comment->getLocation(), DiagKind) << Comment->getCommandMarker()
<< Comment->getSourceRange();
}
inspectThisDecl();
return ThisDeclInfo->getKind() == DeclInfo::FunctionKind;
}
+
+bool Sema::isObjCMethodDecl() {
+ return isFunctionDecl() && ThisDeclInfo->CurrentDecl &&
+ isa<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl);
+}
-bool Sema::isCallbackDecl() {
+/// isFunctionPointerVarDecl - returns 'true' if declaration is a pointer to
+/// function decl.
+bool Sema::isFunctionPointerVarDecl() {
if (!ThisDeclInfo)
return false;
if (!ThisDeclInfo->IsFilled)
typedef unsigned int test_returns_wrong_decl_11;
// rdar://13094352
-// expected-warning@+1 {{'@function' command used in a comment that is attached to a non-function declaration immediately following it}}
+// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
/*! @function test_function
*/
typedef unsigned int Base64Flags;
unsigned test_function(Base64Flags inFlags);
-// expected-warning@+1 {{'@callback' command used in a comment that is attached to a non-callback declaration immediately following it}}
+// expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
/*! @callback test_callback
*/
typedef unsigned int BaseFlags;
typedef int (^test_param1)(int aaa, int ccc);
// rdar://13094352
-// expected-warning@+2 {{'@method' command used in a comment that is attached to a non-method declaration immediately following it}}
+// expected-warning@+2 {{'@method' command should be used in a comment attached to an objective-c method declaration}}
@interface I
/*! @method Base64EncodeEx
*/