[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declaration of pointer to struct

Jack Huang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 19 07:59:37 PDT 2022


jackhong12 updated this revision to Diff 438194.
jackhong12 edited the summary of this revision.
jackhong12 added a comment.

Just like mentioned above, UnwrappedLineParser will split the input into multiple lines. And `MatchingParen` will be reset before annotating(code <https://github.com/llvm/llvm-project/blob/main/clang/lib/Format/TokenAnnotator.cpp#L1509>). So when defining a struct, union, or class, the `MatchingParen` of the right brace will be NULL. If we want to access the left matching brace from the right brace, we need to add new member data, which saves the address of the left brace token, in class `FormatToken`.
In my opinion, it will be too complicated. Instead of `MatchingParen`, I categorize the tokens by checking whether it is a template because `&&` will be a binary operator only in a template. In the other cases, `&&` is likely a reference operator.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127873/new/

https://reviews.llvm.org/D127873

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127873.438194.patch
Type: text/x-patch
Size: 5039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220619/e75be272/attachment.bin>


More information about the cfe-commits mailing list