From 2db356d619fbf56e342fbc3fd5301e2e539e51b6 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 8 Jan 2013 20:03:18 +0000 Subject: [PATCH] Don't break after unary operators. Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, * aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171890 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 3 +-- unittests/Format/FormatTest.cpp | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 1205c424b1..a371aa3c4a 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1049,9 +1049,8 @@ private: if (Left.ClosesTemplateDeclaration) return true; if (Left.Type == TT_PointerOrReference || Left.Type == TT_TemplateCloser || - Right.Type == TT_ConditionalExpr) { + Left.Type == TT_UnaryOperator || Right.Type == TT_ConditionalExpr) return false; - } if (Left.is(tok::equal) && CurrentLineType == LT_VirtualFunctionDecl) return false; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index d5f74d3daa..339be71530 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -958,7 +958,6 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("InvalidRegions[*R] = 0;"); - // FIXME: Is this desired for LLVM? Fix if not. verifyFormat("A a;"); verifyFormat("A a;"); verifyFormat("A a;"); @@ -967,6 +966,10 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("Type *A = (Type *) P;"); verifyFormat("Type *A = (vector) P;"); + verifyFormat( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + verifyGoogleFormat("int main(int argc, char** argv) {\n}"); verifyGoogleFormat("A a;"); verifyGoogleFormat("A a;"); -- 2.40.0