[cfe-dev] Patch to allow comment translators implementation
abramobagnara at tin.it
Thu Jan 28 14:18:53 PST 2010
Il 27/01/2010 22:48, Chris Lattner ha scritto:
>>> 1) do not call comment handlers when skipping excluded conditional block
>>> 2) have a way inside comment handlers to know that we are inside an
>>> excluded conditional block (so to avoid to call EnterTokenStream)
>>> I think that 2) is better as it is more flexyble.
>> I've not yet heard anything from you, what do you think is the proper
>> way to fix the problem above?
> Hi Abramo,
> 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.
However in his message, some minutes ago Douglas wrote:
>> We have some alternative way to cope with this problem:
>> > 1) make SkipExcludedConditionalBlock to consume also the tokens from
>> > CurTokenLexer
> This seems like the right approach to me.
This was my original choice that Chris thought was inappropriate and he
removed that part of my patch in his commit.
Personally I've no strong preference between a choice or the other,
however I resume here the benefits I see for the two approaches:
Chris method (avoid to call comment handler when skipping):
- performance (we don't have to check from which lexer we are currently
reading the tokens in SkipExcludedConditionalBlock)
Douglas method (make SkipExcludedConditionalBlock to consume also the
tokens from CurTokenLexer):
- possibility to exit from excluded conditional block with tokens
inserted by comment handlers (with Chris method it's impossible)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3523 bytes
Desc: not available
More information about the cfe-dev