зеркало из https://github.com/microsoft/clang-1.git
doc. parsing. Improve on diagnostics on my last patch.
// rdar://13094352. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176525 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f32e11dcec
Коммит
99a7057098
|
@ -206,7 +206,8 @@ public:
|
|||
void resolveParamCommandIndexes(const FullComment *FC);
|
||||
|
||||
bool isFunctionDecl();
|
||||
bool isCallbackDecl();
|
||||
bool isFunctionPointerVarDecl();
|
||||
bool isObjCMethodDecl();
|
||||
bool isObjCPropertyDecl();
|
||||
bool isTemplateOrSpecialization();
|
||||
|
||||
|
|
|
@ -74,8 +74,18 @@ def warn_doc_param_not_attached_to_a_function_decl : Warning<
|
|||
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<
|
||||
|
|
|
@ -90,12 +90,17 @@ ParamCommandComment *Sema::actOnParamCommandStart(
|
|||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -685,8 +690,15 @@ bool Sema::isFunctionDecl() {
|
|||
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)
|
||||
|
|
|
@ -549,13 +549,13 @@ namespace test_returns_wrong_decl_10 { };
|
|||
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;
|
||||
|
|
|
@ -98,7 +98,7 @@ int b;
|
|||
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
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче