[PATCH] D64775: [Format/ObjC] Avoid breaking between unary operators and ObjC method invocations
Ben Hamilton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 07:29:51 PDT 2019
benhamilton updated this revision to Diff 210095.
benhamilton marked an inline comment as done.
benhamilton added a comment.
- Rebase.
- Change to just avoid breaking when the left-hand side is a unary operator
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64775/new/
https://reviews.llvm.org/D64775
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestObjC.cpp
Index: clang/unittests/Format/FormatTestObjC.cpp
===================================================================
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -886,6 +886,18 @@
" bb:42\n"
" cc:42];");
+ // Avoid breaking between unary operators and ObjC method expressions.
+ Style.ColumnLimit = 45;
+ verifyFormat("if (a012345678901234567890123 &&\n"
+ " ![foo bar]) {\n"
+ "}");
+ verifyFormat("if (a012345678901234567890123 &&\n"
+ " +[foo bar]) {\n"
+ "}");
+ verifyFormat("if (a012345678901234567890123 &&\n"
+ " -[foo bar]) {\n"
+ "}");
+
Style.ColumnLimit = 70;
verifyFormat(
"void f() {\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,8 @@
if (Left.is(TT_JavaAnnotation))
return 50;
+ if (Left.is(TT_UnaryOperator))
+ return 60;
if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
Left.Previous->isLabelString() &&
(Left.NextOperator || Left.OperatorIndex != 0))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64775.210095.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190716/3be09dc9/attachment-0001.bin>
More information about the cfe-commits
mailing list