This is an archive of the discontinued LLVM Phabricator instance.

[Syntax] Merge overlapping top-level macros in TokenBuffer
ClosedPublic

Authored by sammccall on Apr 6 2020, 5:58 PM.

Details

Summary

Our previous definition of "top-level" was too informal, and didn't
allow for overlapping macros that each directly produce expanded tokens.
See D77507 for previous discussion.

Fixes http://bugs.llvm.org/show_bug.cgi?id=45428

Diff Detail

Event Timeline

sammccall created this revision.Apr 6 2020, 5:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2020, 5:58 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
kadircet accepted this revision.Apr 7 2020, 2:17 AM

LGTM, thanks!

clang/lib/Tooling/Syntax/Tokens.cpp
452

instead of saying A and B maybe say something like, a the last token for a top-level macro expansion must be inside a file and invert the following condition:

if(!Range.getEnd().isFileID()) return;

462

maybe put As and Bs in parentheses, i.e:

// If the macro invocation (B) starts in a macro (A) but ends in a file, we'll
    // create a merged mapping (for A & B) by overwriting the endpoint for parent's (A's)
    // startpoint.
This revision is now accepted and ready to land.Apr 7 2020, 2:17 AM
sammccall marked 3 inline comments as done.Apr 7 2020, 2:55 AM
sammccall added inline comments.
clang/lib/Tooling/Syntax/Tokens.cpp
462

Done, except for "parent" - the point here is there isn't really a parent/child relationship here: the arg list isn't part of the A expansion in any sense.

This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.