[PATCH] D131750: [clang-format] Distinguish logical and after bracket from reference
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 15:24:23 PDT 2022
owenpan added inline comments.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2368-2376
+ // Before token annotation, clang-format will split the declaration into
+ // multiple lines in the struct, union, class, and enum cases. For instance,
+ // `struct {int n} &&ptr={};` will be separated as `struct {`, `int n;` and
+ // `} &&ptr={};`. So, the matching `{` will be NULL, and we can leverage
+ // this to indicate whether `&&` is a reference operator or not.
+ if (PrevToken->is(tok::r_brace) && Tok.is(tok::ampamp) &&
+ !PrevToken->MatchingParen)
----------------
Removing it would suffice.
================
Comment at: clang/unittests/Format/FormatTest.cpp:10477
Style);
+ verifyFormat("bool b = 3 == int{3} && true;");
----------------
Can you add a similar test in TokenAnnotatorTest.cpp?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131750/new/
https://reviews.llvm.org/D131750
More information about the cfe-commits
mailing list