mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-26 13:26:22 +00:00
[Format/ObjC] Avoid breaking between unary operators and operands
Summary: Test Plan: New tests added. Ran tests with: % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests Confirmed tests failed before change and passed after change. Reviewers: krasimir, djasper, sammccall, klimek Reviewed By: sammccall Subscribers: klimek, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64775 llvm-svn: 366592
This commit is contained in:
parent
870f49e690
commit
86383e6626
@ -2429,6 +2429,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
|
||||
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))
|
||||
|
@ -886,6 +886,18 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
|
||||
" 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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user