aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/CommentLexer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-10-25Fix 'unknown documentation command' warning rangesErik Verbruggen1-4/+6
Warnings generated by -Wdocumentation-unknown-command did only have a start location, not a full source range. This resulted in only the "carret" being show in messages, and IDEs highlighting only the single initial character. llvm-svn: 285056
2016-02-10Fix some Clang-tidy readability-redundant-control-flow warnings; other minor ↵Eugene Zelenko1-5/+11
fixes. Differential revision: http://reviews.llvm.org/D17060 llvm-svn: 260414
2015-04-15Comment parsing: fix an assertion failure on a verbatim block terminated ↵Dmitri Gribenko1-0/+6
with "**/" llvm-svn: 235057
2014-08-30Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper1-2/+2
const from some other StringRefs since its implicitly const already. llvm-svn: 216825
2013-12-07CommentLexer: eliminate an NDEBUG from the headersAlp Toker1-0/+13
Code in headers shouldn't be conditional on the build configuration. llvm-svn: 196656
2013-12-01CommentLexer: When proceeding with a typo corrected name don't clobber the ↵Benjamin Kramer1-5/+6
token. This would crash if the token is used in another diagnostic. PR18051. llvm-svn: 196048
2013-08-23Fix indentationDmitri Gribenko1-1/+1
llvm-svn: 189119
2013-05-09[doc parsing]: make single character command imposturesFariborz Jahanian1-4/+0
warn in pedantic mode. llvm-svn: 181523
2013-05-09[doc parsing]: So, in this patch, single characterFariborz Jahanian1-0/+4
'commands' will not go through typo fixit logic, preserving the old behavior (no typo, no diagnostics). // rdar://12381408 llvm-svn: 181521
2013-05-08Turn off a warning caused by my last patch.Fariborz Jahanian1-1/+1
llvm-svn: 181464
2013-05-08documentation parsing. Patch to do typo correction for Fariborz Jahanian1-2/+12
documentation commands. Patch was reviewed, along with great suggestions for improvement, by Doug. // rdar://12381408 llvm-svn: 181458
2013-05-04[doc parsing]: Make warning about unknown commandFariborz Jahanian1-3/+2
tags off by default for now. Move diagnostic code to DiagnosticCommentKinds.td. // rdar://12381408 llvm-svn: 181081
2013-05-03[Doc parsing] Provide diagnostics for unknown documentation Fariborz Jahanian1-2/+6
commands. // rdar://12381408 llvm-svn: 181071
2013-03-04Comment parsing: refactor handling of command markers in ASTDmitri Gribenko1-4/+6
* Use the term 'command marker', because the semantics of 'backslash' and 'at' commands are the same. (Talking about 'at commands' makes them look like a special entity.) * Sink the flag down into bitfields, reducing the size of AST nodes. * Change the flag into an enum for clarity. Boolean function parameters are not very clear. * Add unittests for new tok::at_command tokens. llvm-svn: 176461
2013-03-02Some refactoring in my patch on documentFariborz Jahanian1-2/+4
command source fidelity. // rdar://13066276 llvm-svn: 176401
2013-03-01comment parsing. Keep the original command format Fariborz Jahanian1-0/+1
in AST for source fidelity and use it in diagnostics to refer to the original format. // rdar://13066276 llvm-svn: 176387
2013-02-10Use static functions instead of an unnamed namespaceDmitri Gribenko1-6/+8
llvm-svn: 174835
2013-02-09Comment parsing: use CharInfo.hDmitri Gribenko1-38/+16
This also gives us 0.2% speedup on '-fsyntax-only -Wdocumentation' time for a testcase that consists of all Clang headers. llvm-svn: 174810
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