[PATCH] Mimic MSVC whitespace collapse for incompatible token pasting

Will Wilson will at indefiant.com
Mon Apr 13 16:17:37 PDT 2015


Hi Reid,

I was going to pick your brain on this in person but it seems you're not
over in London for the conference. Anyhow, I've tried a few variations but
I've been unable to find a way to better handle this edge case without
doing some heavy refactoring.

Do you have fundamental objections to the approach taken (and I admit it's
not pretty) or is it simply that the comment leaves something to be desired
- such as a clearer comment?

- Will.

On 11 April 2015 at 01:06, Will Wilson <will at indefiant.com> wrote:

> Hi Reid,
>
> On 11 April 2015 at 00:29, Reid Kleckner <rnk at google.com> wrote:
>>
>> I still think a local fix would be better. As a reader, it's hard to
>> convince myself that the comment is correct:
>> +  // MSVC: If previous token was pasted, this must be a recovery from an
>> invalid
>> +  // paste operation. Ignore spaces before this token to mimic MSVC
>> output.
>> +  // Required for generating valid UUID strings in some MS headers.
>>
>> Why is it that we only come here for invalid token pastes?
>>
>
> The doc for PasteTokens() gives the general premise of the function:
>
>
> Tok is the LHS of a ## operator, and CurToken is the ##
> operator.  Read the ## and RHS, and paste the LHS/RHS together.  If there
> are more ## after it, chomp them iteratively.
>
> Basically, if an invalid paste is attempted, the iteration is aborted and
> the concatenated token is returned without doing any more pasting.
> Therefore, assuming a successful PasteTokens() call would have consumed all
> ## operators, the only reason PasteTokens() would be called with an earlier
> ## in the Tokens array would be if the iteration were previously aborted.
> At least, this is my understanding of it.
>
> It's not pretty, but without rewriting the iteration logic to deal cleanly
> with the MSVC pasting logic I'm not sure how to improve it... Any ideas?
>
> - Will.
>



-- 
*Indefiant *: http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150414/bb516e53/attachment.html>


More information about the cfe-commits mailing list