[PATCH] D137474: [clang-format] Defer formatting of operator< to honor paren spacing
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 17 01:39:14 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf6f4b85138f: [clang-format] Defer formatting of operator< to honor paren spacing (authored by rymiel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137474/new/
https://reviews.llvm.org/D137474
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15544,6 +15544,8 @@
Space.SpaceBeforeParens = FormatStyle::SBPO_Always;
verifyFormat("int f ();", Space);
+ verifyFormat("bool operator< ();", Space);
+ verifyFormat("bool operator> ();", Space);
verifyFormat("void f (int a, T b) {\n"
" while (true)\n"
" continue;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3441,7 +3441,9 @@
return false;
return !Style.Cpp11BracedListStyle;
}
- return false;
+ // Don't attempt to format operator<(), as it is handled later.
+ if (Right.isNot(TT_OverloadedOperatorLParen))
+ return false;
}
if (Right.is(tok::ellipsis)) {
return Left.Tok.isLiteral() || (Left.is(tok::identifier) && Left.Previous &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137474.476052.patch
Type: text/x-patch
Size: 1085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221117/baa7373b/attachment-0001.bin>
More information about the cfe-commits
mailing list