From 1725aee3382f5f73964f35794b001bcef1cbdcc6 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Tue, 17 Mar 2015 18:03:42 +0000 Subject: [PATCH] Comment parsing: move a diagnostic to the correct group. Based on a patch by LE GARREC Vincent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232511 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticCommentKinds.td | 2 +- lib/Sema/SemaDecl.cpp | 7 +++++-- test/Sema/warn-documentation-fixits.cpp | 7 ++++--- test/Sema/warn-documentation-unknown-command.cpp | 11 +++++++++++ 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 test/Sema/warn-documentation-unknown-command.cpp diff --git a/include/clang/Basic/DiagnosticCommentKinds.td b/include/clang/Basic/DiagnosticCommentKinds.td index 6dc8b27a2a..ab24582c11 100644 --- a/include/clang/Basic/DiagnosticCommentKinds.td +++ b/include/clang/Basic/DiagnosticCommentKinds.td @@ -166,7 +166,7 @@ def warn_unknown_comment_command_name : Warning< def warn_correct_comment_command_name : Warning< "unknown command tag name '%0'; did you mean '%1'?">, - InGroup, DefaultIgnore; + InGroup, DefaultIgnore; } // end of documentation issue category } // end of AST component diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7a70cddf9d..01bd42ce80 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9827,9 +9827,12 @@ void Sema::ActOnDocumentableDecl(Decl *D) { void Sema::ActOnDocumentableDecls(ArrayRef Group) { // Don't parse the comment if Doxygen diagnostics are ignored. if (Group.empty() || !Group[0]) - return; + return; - if (Diags.isIgnored(diag::warn_doc_param_not_found, Group[0]->getLocation())) + if (Diags.isIgnored(diag::warn_doc_param_not_found, + Group[0]->getLocation()) && + Diags.isIgnored(diag::warn_unknown_comment_command_name, + Group[0]->getLocation())) return; if (Group.size() >= 2) { diff --git a/test/Sema/warn-documentation-fixits.cpp b/test/Sema/warn-documentation-fixits.cpp index 675d86c366..95c0e93507 100644 --- a/test/Sema/warn-documentation-fixits.cpp +++ b/test/Sema/warn-documentation-fixits.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}} /// \param ZZZZZZZZZZ Blah blah. @@ -67,6 +67,7 @@ int FooBar(); /// \fooba bbb IS_DOXYGEN_END int gorf(); +// expected-warning@+1 {{unknown command tag name}} /// \t bbb IS_DOXYGEN_END int Bar(); @@ -88,4 +89,4 @@ int PR18051(); // CHECK: fix-it:"{{.*}}":{58:30-58:30}:" MY_ATTR_DEPRECATED" // CHECK: fix-it:"{{.*}}":{63:6-63:11}:"return" // CHECK: fix-it:"{{.*}}":{67:6-67:11}:"foobar" -// CHECK: fix-it:"{{.*}}":{75:6-75:12}:"endcode" +// CHECK: fix-it:"{{.*}}":{76:6-76:12}:"endcode" diff --git a/test/Sema/warn-documentation-unknown-command.cpp b/test/Sema/warn-documentation-unknown-command.cpp new file mode 100644 index 0000000000..3674a9c680 --- /dev/null +++ b/test/Sema/warn-documentation-unknown-command.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation-unknown-command -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Werror -Wno-documentation-unknown-command %s + +// expected-warning@+1 {{unknown command tag name}} +/// aaa \unknown +int test_unknown_comand_1; + +// expected-warning@+1 {{unknown command tag name 'retur'; did you mean 'return'?}} +/// \retur aaa +int test_unknown_comand_2(); + -- 2.40.0