[PATCH] D68242: [clang-format] [PR42417] clang-format inserts a space after '->' for operator->() overloading
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 06:23:53 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373746: [clang-format] [PR42417] clang-format inserts a space after '->' for operator->… (authored by paulhoad, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D68242?vs=222487&id=223203#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68242/new/
https://reviews.llvm.org/D68242
Files:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -1393,7 +1393,9 @@
Style.Language == FormatStyle::LK_Java) {
Current.Type = TT_LambdaArrow;
} else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
- Current.NestingLevel == 0) {
+ Current.NestingLevel == 0 &&
+ !Current.Previous->is(tok::kw_operator)) {
+ // not auto operator->() -> xxx;
Current.Type = TT_TrailingReturnArrow;
TrailingReturnFound = true;
} else if (Current.is(tok::star) ||
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -4956,6 +4956,10 @@
TEST_F(FormatTest, TrailingReturnType) {
verifyFormat("auto foo() -> int;\n");
+ // correct trailing return type spacing
+ verifyFormat("auto operator->() -> int;\n");
+ verifyFormat("auto operator++(int) -> int;\n");
+
verifyFormat("struct S {\n"
" auto bar() const -> int;\n"
"};");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68242.223203.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191004/1395735b/attachment-0001.bin>
More information about the cfe-commits
mailing list