aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/CommentLexer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2013-01-30Comment parsing: resolve more named character referencesDmitri Gribenko1-182/+22
This reimplements r173850 with a better approach: (1) use a TableGen-generated matcher instead of doing a linear search; (2) avoid allocations for new strings by converting code points to string iterals with TableGen. llvm-svn: 173931
2013-01-30Move UTF conversion routines from clang/lib/Basic to llvm/lib/SupportDmitri Gribenko1-3/+3
This is required to use them in TableGen. llvm-svn: 173924
2013-01-30Removed couple of html named character references inFariborz Jahanian1-2/+0
my last patch. llvm-svn: 173856
2013-01-29[Doc parsing] Patch to parse Doxygen-supported HTML character Fariborz Jahanian1-18/+181
references to their UTIF-8 encoding. Reviewed offline by Doug. // rdar://12392215 llvm-svn: 173850
2013-01-19Use llvm::hexDigitValue in comment lexerDmitri Gribenko1-6/+2
llvm-svn: 172924
2012-12-30Comment lexing: replace manual comparison with StringRef::find_first_ofDmitri Gribenko1-9/+6
This gives an about 1.8% improvement on Clang bootstrap with -Wdocumentation llvm-svn: 171262
2012-09-14Comment parsing: don't parse comment marker followed by a digit as a commandDmitri Gribenko1-1/+6
since no Doxygen command starts with a digit. llvm-svn: 163909
2012-09-10Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.Dmitri Gribenko1-14/+21
Now we have a list of all commands. This is a good thing in itself, but it also enables us to easily implement typo correction for command names. With this change we have objects that contain information about each command, so it makes sense to resolve command name just once during lexing (currently we store command names as strings and do a linear search every time some property value is needed). Thus comment token and AST nodes were changed to contain a command ID -- index into a tables of builtin and registered commands. Unknown commands are registered during parsing and thus are also uniformly assigned an ID. Using an ID instead of a StringRef is also a nice memory optimization since ID is a small integer that fits into a common bitfield in Comment class. This change implies that to get any information about a command (even a command name) we need a CommandTraits object to resolve the command ID to CommandInfo*. Currently a fresh temporary CommandTraits object is created whenever it is needed since it does not have any state. But with this change it has state -- new commands can be registered, so a CommandTraits object was added to ASTContext. Also, in libclang CXComment has to be expanded to include a CXTranslationUnit so that all functions working on comment AST nodes can get a CommandTraits object. This breaks binary compatibility of CXComment APIs. Now clang_FullComment_getAsXML(CXTranslationUnit TU, CXComment CXC) doesn't need TU parameter anymore, so it was removed. This is a source-incompatible change for this C API. llvm-svn: 163540
2012-08-31Remove the useless CommentOptions class.Dmitri Gribenko1-2/+2
llvm-svn: 162986
2012-08-31Comment HTML tag name machers: move from StringSwitch to an efficientDmitri Gribenko1-26/+2
TableGen-generated string matcher. llvm-svn: 162969
2012-08-22Comment parsing: parse "<blah" as an HTML tag only if "blah" is a known tagDmitri Gribenko1-2/+38
name. This should reduce the amount of warning false positives about bad HTML in comments when the comment author intended to put a reference to a template. This change will also enable us parse the comment as intended in these cases. Fixes part 1 of PR13374. llvm-svn: 162407
2012-08-09Comment parsing: extract TableGen'able pieces into new CommandTraits class.Dmitri Gribenko1-93/+5
llvm-svn: 161548
2012-07-27Implement resolving of HTML character references (named: &amp;, decimal: &#42;,Dmitri Gribenko1-24/+174
hex: &#x1a;) during comment parsing. Now internal representation of plain text in comment AST does not contain character references, but the characters themselves. llvm-svn: 160891
2012-07-18Comment parsing: don't parse whitespace before \endverbatim as a separate ↵Dmitri Gribenko1-0/+10
line of whitespace. llvm-svn: 160464
2012-07-13Comment parsing: repaint the bikesched: rename 'HTML open tags' to 'HTML ↵Dmitri Gribenko1-17/+17
start tags' and 'HTML close tags' to 'HTML end tags' according to HTML spec. llvm-svn: 160153
2012-07-11Enable comment parsing and semantic analysis to emit diagnostics. A fewDmitri Gribenko1-1/+13
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 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
2012-07-09Comment lexing: fix lexing to actually work in non-error cases.Dmitri Gribenko1-13/+18
llvm-svn: 159963
2012-07-06Implement AST classes for comments, a real parser for Doxygen comments and aDmitri Gribenko1-8/+36
very simple semantic analysis that just builds the AST; minor changes for lexer to pick up source locations I didn't think about before. Comments AST is modelled along the ideas of HTML AST: block and inline content. * Block content is a paragraph or a command that has a paragraph as an argument or verbatim command. * Inline content is placed within some block. Inline content includes plain text, inline commands and HTML as tag soup. llvm-svn: 159790
2012-06-27Fix an infinite loop in comment lexer: we were not advancing in the input ↵Dmitri Gribenko1-0/+5
character stream when we saw a '<' that is not a start of an HTML tag. llvm-svn: 159303
2012-06-27Remove unsigned and a pointer from a comment token (so that each token can ↵Dmitri Gribenko1-8/+19
have only one semantic string value attached to it), at a cost of adding an additional token. llvm-svn: 159270
2012-06-27Comment lexer: counting backwards from token end is thought to be confusing. ↵Dmitri Gribenko1-14/+20
We already have a pointer to the beginning of the token, so use it to extract the text instead. llvm-svn: 159269
2012-06-26Implement a lexer for structured comments.Dmitri Gribenko1-0/+676
llvm-svn: 159223