[cfe-commits] r158940 - in /cfe/trunk: lib/AST/RawCommentList.cpp test/Index/Inputs/annotate-comments-preprocessor.h test/Index/annotate-comments-preprocessor.c
Douglas Gregor
dgregor at apple.com
Fri Jun 29 11:44:05 PDT 2012
On Jun 29, 2012, at 11:36 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> On Fri, Jun 29, 2012 at 11:24 AM, Douglas Gregor <dgregor at apple.com> wrote:
>> On Jun 29, 2012, at 11:18 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>>> On Fri, Jun 29, 2012 at 11:15 AM, Douglas Gregor <dgregor at apple.com> wrote:
>>>> On Jun 21, 2012, at 3:04 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>>>>> Author: gribozavr
>>>>> Date: Thu Jun 21 17:04:37 2012
>>>>> New Revision: 158940
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=158940&view=rev
>>>>> Log:
>>>>> Handle include directive with comments. It turns out that in this case comments are not coming in source order. Instead of trying to std::sort() comments (which can be costly), just remove comments that are not in order.
>>>>
>>>> Can we just fix the ordering of comments as produced by the lexer?
>>>
>>> I looked into that and I don't think it would be easy: preprocessor
>>> wants to parse a complete directive before switching to another source
>>> file.
>>
>> Can we just queue up the comment tokens when parsing the complete #include directive, so that the callbacks for them come after the #include is handled?
>
> The lexer could stash all comments from PP directive somewhere, but we
> need to handle them after lexing tok::eod, during lexing next token.
> This would add a check to Lexer::LexTokenInternal(). I don't think it
> is a good idea since it does not buy us anything -- comments after
> include directive are never going to be documentation comments.
If this is only a concern for include directives, then Preprocessor::HandleComment could cache the comments and the comment handlers could see these callbacks when we pop the include macro stack at the end of the included file. That shouldn't introduce a performance penalty.
I agree that it's not important because these comments aren't going to be documentation comments.
- Doug
More information about the cfe-commits
mailing list