[cfe-dev] Patch to allow comment translators implementation

Abramo Bagnara abramo.bagnara at gmail.com
Tue Feb 2 10:57:41 PST 2010


Il 02/02/2010 03:20, Chris Lattner ha scritto:
> On Jan 28, 2010, at 2:19 PM, Abramo Bagnara wrote:
>>> I'm sorry for the delay.  I think that #1 is the best approach. 
>>> Comment handles should not be invoked on things in #if 0 blocks,
>>> because #if 0 blocks should be completely skipped according to the
>>> rules of the preprocessor: not doing this would invalidate the
>>> "include once" optimization that is applied to files wrapped in the
>>> "#ifndef FOO_H / #define FOO_H ... #endif" idiom.
>>>
>>> In short, I think that #1 is the right fix.
>>
>> I've attached a (trivial) patch to do that.
> 
> Thanks Abramo,
> 
> Does it work to use a simpler patch that does something like this in
> both places that currently call HandleComment:
> 
>    // Found but did not consume the newline.
> -  if (PP && PP->HandleComment(Result,
> -                              SourceRange(getSourceLocation(BufferPtr),
> -                                          getSourceLocation(CurPtr)))) {
> +  if (PP && !isLexingRawMode() &&
> +      PP->HandleComment(Result, SourceRange(getSourceLocation(BufferPtr),
> +                                            getSourceLocation(CurPtr)))) {
> 
> ?
> 
> If so, please supply a patch (I can't test this) and I'll happily apply
> it for you,

Yes, it works as expected when the lexer is not in raw lexing mode.

I guess you think that it's a good thing that HandleComment is no longer
called during raw lexing... However personally I've no problem with this
choice.

I attach the patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HandleComment.patch
Type: text/x-patch
Size: 1225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100202/e77807b8/attachment.bin>


More information about the cfe-dev mailing list