[cfe-commits] r168277 - in /cfe/trunk: include/clang/Basic/DiagnosticCommentKinds.td lib/AST/CommentParser.cpp test/Sema/warn-documentation.cpp

NAKAMURA Takumi geek4civic at gmail.com
Sat Nov 17 18:37:41 PST 2012


2012/11/18 Dmitri Gribenko <gribozavr at gmail.com>:
> Author: gribozavr
> Date: Sat Nov 17 18:30:31 2012
> New Revision: 168277
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168277&view=rev
> Log:
> Documentation parsing: propely handle a lone '\endverbatim' and emit a warning.
>
> We actually used to assert on this.
>
> Thanks to NAKAMURA Takumi for noticing this!
>
> Modified:
>     cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
>     cfe/trunk/lib/AST/CommentParser.cpp
>     cfe/trunk/test/Sema/warn-documentation.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=168277&r1=168276&r2=168277&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td Sat Nov 17 18:30:31 2012
> @@ -131,5 +131,11 @@
>  def note_add_deprecation_attr : Note<
>    "add a deprecation attribute to the declaration to silence this warning">;
>
> +// verbatim block commands
> +
> +def warn_verbatim_block_end_without_start : Warning<
> +  "'\\%0' command does not terminate a verbatim text block">,
> +  InGroup<Documentation>, DefaultIgnore;
> +
>  } // end of documentation issue category
>  } // end of AST component
>
> Modified: cfe/trunk/lib/AST/CommentParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentParser.cpp?rev=168277&r1=168276&r2=168277&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/CommentParser.cpp (original)
> +++ cfe/trunk/lib/AST/CommentParser.cpp Sat Nov 17 18:30:31 2012
> @@ -554,6 +554,14 @@
>            return parseBlockCommand();
>          break; // Block command ahead, finish this parapgaph.
>        }
> +      if (Info->IsVerbatimBlockEndCommand) {
> +        Diag(Tok.getLocation(),
> +             diag::warn_verbatim_block_end_without_start)
> +          << Info->Name
> +          << SourceRange(Tok.getLocation(), Tok.getEndLocation());
> +        consumeToken();
> +        continue;
> +      }
>        if (Info->IsUnknownCommand) {
>          Content.push_back(S.actOnUnknownCommand(Tok.getLocation(),
>                                                  Tok.getEndLocation(),
>
> Modified: cfe/trunk/test/Sema/warn-documentation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=168277&r1=168276&r2=168277&view=diff
> ==============================================================================
> --- cfe/trunk/test/Sema/warn-documentation.cpp (original)
> +++ cfe/trunk/test/Sema/warn-documentation.cpp Sat Nov 17 18:30:31 2012
> @@ -502,6 +502,24 @@
>  namespace test_returns_wrong_decl_10 { };
>
>
> +// expected-warning at +1 {{'\endverbatim' command does not terminate a verbatim text block}}
> +/// \endverbatim
> +int test_verbatim_1();
> +
> +// expected-warning at +1 {{'\endcode' command does not terminate a verbatim text block}}
> +/// \endcode
> +int test_verbatim_2();
> +
> +// FIXME: we give a bad diagnostic here because we throw away non-documentation
> +// comments early.
> +//
> +// expected-warning at +2 {{'\endcode' command does not terminate a verbatim text block}}
> +/// \code
> +//  foo
> +/// \endcode
> +int test_verbatim_3();

Did you run the test actually? @+2 doesn't point \endcode.
Fixed in r168278.



More information about the cfe-commits mailing list