[PATCH] D134618: [Syntax] Fix macro-arg handling in TokenBuffer::spelledForExpanded
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 25 18:34:42 PDT 2022
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.
A few cases were not handled correctly. Notably:
#define ID(X) X
#define HIDE a ID(b)
HIDE
spelledForExpanded() would claim HIDE is an equivalent range of the 'b' it
contains, despite the fact that HIDE also covers 'a'.
While trying to fix this bug, I found findCommonRangeForMacroArgs hard
to understand (both the implementation and how it's used in spelledForExpanded).
It relies on details of the SourceLocation graph that are IMO fairly obscure.
So I've added/revised quite a lot of comments and made some naming tweaks.
Fixes https://github.com/clangd/clangd/issues/1289
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134618
Files:
clang/lib/Tooling/Syntax/Tokens.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134618.462781.patch
Type: text/x-patch
Size: 14857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/50ec5637/attachment.bin>
More information about the cfe-commits
mailing list