Comment diagnostics: \return in void function: specialize diagnostic text for
ObjC methods. llvm-svn: 161324
This commit is contained in:
parent
e998267282
commit
558babc53b
|
@ -979,6 +979,9 @@ struct DeclInfo {
|
||||||
/// Never true if \c IsFunctionDecl is true.
|
/// Never true if \c IsFunctionDecl is true.
|
||||||
unsigned IsTemplatePartialSpecialization : 1;
|
unsigned IsTemplatePartialSpecialization : 1;
|
||||||
|
|
||||||
|
/// Is \c ThisDecl an ObjCMethodDecl.
|
||||||
|
unsigned IsObjCMethod : 1;
|
||||||
|
|
||||||
/// Is \c ThisDecl a non-static member function of C++ class or
|
/// Is \c ThisDecl a non-static member function of C++ class or
|
||||||
/// instance method of ObjC class.
|
/// instance method of ObjC class.
|
||||||
/// Can be true only if \c IsFunctionDecl is true.
|
/// Can be true only if \c IsFunctionDecl is true.
|
||||||
|
|
|
@ -102,12 +102,13 @@ def note_doc_tparam_name_suggestion : Note<
|
||||||
|
|
||||||
def warn_doc_returns_not_attached_to_a_function_decl : Warning<
|
def warn_doc_returns_not_attached_to_a_function_decl : Warning<
|
||||||
"'\\%0' command used in a comment that is not attached to "
|
"'\\%0' command used in a comment that is not attached to "
|
||||||
"a function declaration">,
|
"a function or method declaration">,
|
||||||
InGroup<Documentation>, DefaultIgnore;
|
InGroup<Documentation>, DefaultIgnore;
|
||||||
|
|
||||||
def warn_doc_returns_attached_to_a_void_function : Warning<
|
def warn_doc_returns_attached_to_a_void_function : Warning<
|
||||||
"'\\%0' command used in a comment that is attached to a "
|
"'\\%0' command used in a comment that is attached to a "
|
||||||
"%select{void function|constructor|destructor}1">,
|
"%select{function returning void|constructor|destructor|"
|
||||||
|
"method returning void}1">,
|
||||||
InGroup<Documentation>, DefaultIgnore;
|
InGroup<Documentation>, DefaultIgnore;
|
||||||
|
|
||||||
} // end of documentation issue category
|
} // end of documentation issue category
|
||||||
|
|
|
@ -145,6 +145,7 @@ void DeclInfo::fill() {
|
||||||
IsTemplateDecl = false;
|
IsTemplateDecl = false;
|
||||||
IsTemplateSpecialization = false;
|
IsTemplateSpecialization = false;
|
||||||
IsTemplatePartialSpecialization = false;
|
IsTemplatePartialSpecialization = false;
|
||||||
|
IsObjCMethod = false;
|
||||||
IsInstanceMethod = false;
|
IsInstanceMethod = false;
|
||||||
IsClassMethod = false;
|
IsClassMethod = false;
|
||||||
ParamVars = ArrayRef<const ParmVarDecl *>();
|
ParamVars = ArrayRef<const ParmVarDecl *>();
|
||||||
|
@ -193,6 +194,7 @@ void DeclInfo::fill() {
|
||||||
ParamVars = ArrayRef<const ParmVarDecl *>(MD->param_begin(),
|
ParamVars = ArrayRef<const ParmVarDecl *>(MD->param_begin(),
|
||||||
MD->param_size());
|
MD->param_size());
|
||||||
ResultType = MD->getResultType();
|
ResultType = MD->getResultType();
|
||||||
|
IsObjCMethod = true;
|
||||||
IsInstanceMethod = MD->isInstanceMethod();
|
IsInstanceMethod = MD->isInstanceMethod();
|
||||||
IsClassMethod = !IsInstanceMethod;
|
IsClassMethod = !IsInstanceMethod;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -481,6 +481,9 @@ void Sema::checkReturnsCommand(const BlockCommandComment *Command) {
|
||||||
unsigned DiagKind;
|
unsigned DiagKind;
|
||||||
switch (ThisDeclInfo->ThisDecl->getKind()) {
|
switch (ThisDeclInfo->ThisDecl->getKind()) {
|
||||||
default:
|
default:
|
||||||
|
if (ThisDeclInfo->IsObjCMethod)
|
||||||
|
DiagKind = 3;
|
||||||
|
else
|
||||||
DiagKind = 0;
|
DiagKind = 0;
|
||||||
break;
|
break;
|
||||||
case Decl::CXXConstructor:
|
case Decl::CXXConstructor:
|
||||||
|
|
|
@ -286,37 +286,37 @@ int test_returns_right_decl_4(int aaa);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T test_returns_right_decl_5(T aaa);
|
T test_returns_right_decl_5(T aaa);
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
int test_returns_wrong_decl_1;
|
int test_returns_wrong_decl_1;
|
||||||
|
|
||||||
// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \return Aaa
|
/// \return Aaa
|
||||||
int test_returns_wrong_decl_2;
|
int test_returns_wrong_decl_2;
|
||||||
|
|
||||||
// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \result Aaa
|
/// \result Aaa
|
||||||
int test_returns_wrong_decl_3;
|
int test_returns_wrong_decl_3;
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a void function}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
void test_returns_wrong_decl_4(int);
|
void test_returns_wrong_decl_4(int);
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a void function}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void test_returns_wrong_decl_5(T aaa);
|
void test_returns_wrong_decl_5(T aaa);
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a void function}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
template<>
|
template<>
|
||||||
void test_returns_wrong_decl_5(int aaa);
|
void test_returns_wrong_decl_5(int aaa);
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
struct test_returns_wrong_decl_6 { };
|
struct test_returns_wrong_decl_6 { };
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
class test_returns_wrong_decl_7 {
|
class test_returns_wrong_decl_7 {
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
|
||||||
|
@ -328,15 +328,15 @@ class test_returns_wrong_decl_7 {
|
||||||
~test_returns_wrong_decl_7();
|
~test_returns_wrong_decl_7();
|
||||||
};
|
};
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
enum test_returns_wrong_decl_8 {
|
enum test_returns_wrong_decl_8 {
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
test_returns_wrong_decl_9
|
test_returns_wrong_decl_9
|
||||||
};
|
};
|
||||||
|
|
||||||
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function declaration}}
|
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
|
||||||
/// \returns Aaa
|
/// \returns Aaa
|
||||||
namespace test_returns_wrong_decl_10 { };
|
namespace test_returns_wrong_decl_10 { };
|
||||||
|
|
||||||
|
|
|
@ -82,3 +82,12 @@ int a;
|
||||||
|
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
|
@interface TestReturns1
|
||||||
|
/// \returns Aaa
|
||||||
|
- (int)test1:(NSString *)aaa;
|
||||||
|
|
||||||
|
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a method returning void}}
|
||||||
|
/// \returns Aaa
|
||||||
|
- (void)test2:(NSString *)aaa;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue