[cfe-commits] [PATCH] Introduce diagnostics into comment parsing and semantic analysis

Dmitri Gribenko gribozavr at gmail.com
Mon Jul 9 16:52:33 PDT 2012


The attached patch enables 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, <br />).

In order to issue precise diagnostic comment sema needs to know the
declaration.  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.

This patch depends on -verify patches #1 and #2 for testing.  (These
should be committed shortly.)

Please review.


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: comments-diagnostics-v1.patch
Type: application/octet-stream
Size: 61433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120709/707eeb49/attachment.obj>

More information about the cfe-commits mailing list