From f26054f0fb53f65dbfbfc01954dc3b2028582cde Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Wed, 11 Jul 2012 21:38:39 +0000 Subject: Enable comment parsing and semantic analysis to emit diagnostics. A few diagnostics implemented -- see testcases. I created a new TableGen file for comment diagnostics, DiagnosticCommentKinds.td, because comment diagnostics don't logically fit into AST diagnostics file. But I don't feel strongly about it. This also implements support for self-closing HTML tags in comment lexer and parser (for example,
). In order to issue precise diagnostics CommentSema needs to know the declaration the comment is attached to. There is no easy way to find a decl by comment, so we match comments and decls in lockstep: after parsing one declgroup we check if we have any new, not yet attached comments. If we do -- then we do the usual comment-finding process. It is interesting that this automatically handles trailing comments. We pick up not only comments that precede the declaration, but also comments that *follow* the declaration -- thanks to the lookahead in the lexer: after parsing the declgroup we've consumed the semicolon and looked ahead through comments. Added -Wdocumentation-html flag for semantic HTML errors to allow the user to disable only HTML warnings (but not HTML parse errors, which we emit as warnings in -Wdocumentation). llvm-svn: 160078 --- clang/test/Sema/warn-documentation-almost-trailing.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 clang/test/Sema/warn-documentation-almost-trailing.c (limited to 'clang/test/Sema/warn-documentation-almost-trailing.c') diff --git a/clang/test/Sema/warn-documentation-almost-trailing.c b/clang/test/Sema/warn-documentation-almost-trailing.c new file mode 100644 index 00000000000..fa17cac83a9 --- /dev/null +++ b/clang/test/Sema/warn-documentation-almost-trailing.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: cp %s %t +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fixit %t +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Werror %t + +struct a { + int x; //< comment // expected-warning {{not a Doxygen trailing comment}} + int y; /*< comment */ // expected-warning {{not a Doxygen trailing comment}} +}; + +// CHECK: fix-it:"{{.*}}":{8:10-8:13}:"///<" +// CHECK: fix-it:"{{.*}}":{9:10-9:13}:"/**<" + -- cgit v1.2.3