[PATCH] D117421: [clang-format] Fix incorrect alignment of operator= overloads.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 16 10:08:33 PST 2022
curdeius added a comment.
Thanks for working on this!
I'll have a closer look tomorrow or on Tuesday.
================
Comment at: clang/lib/Format/WhitespaceManager.cpp:735
+ // Do not align operator= overloads.
+ if (C.Tok->Previous && C.Tok->Previous->is(tok::kw_operator)) {
+ auto *Next = C.Tok->Next;
----------------
Maybe `getPreviousNonComment`? Cf. test comment.
================
Comment at: clang/lib/Format/WhitespaceManager.cpp:736
+ if (C.Tok->Previous && C.Tok->Previous->is(tok::kw_operator)) {
+ auto *Next = C.Tok->Next;
+ while (Next && Next->NewlinesBefore == 0) {
----------------
Please spell out the type instead of auto.
================
Comment at: clang/unittests/Format/FormatTest.cpp:16172
+ "int &operator() = default;\n"
+ "int &operator=() {",
+ Alignment);
----------------
Are other operators impacted too by this bug? Like ==, <=, !=.
================
Comment at: clang/unittests/Format/FormatTest.cpp:16174
+ Alignment);
+ verifyFormat("int() = default; // comment\n"
+ "int &operator() = default; // comment\n"
----------------
What happens if there's a block comment between `operator` and `=`?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117421/new/
https://reviews.llvm.org/D117421
More information about the cfe-commits
mailing list