summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-03-12 15:04:53 +0000
committerDaniel Jasper <djasper@google.com>2015-03-12 15:04:53 +0000
commitb754a747bec0ca0db0cc3fb376f08d883abf72d0 (patch)
treef51d8f2e95f80da31c678044c2f12304e0adb54b /clang/lib/Format
parentd5d496a55db9081f3dd89c73af55b3d4eb4f69e9 (diff)
downloadbcm5719-llvm-b754a747bec0ca0db0cc3fb376f08d883abf72d0.tar.gz
bcm5719-llvm-b754a747bec0ca0db0cc3fb376f08d883abf72d0.zip
clang-format: When putting */& next to types, also wrap before them.
Before: LoooooooooooongType * loooooooooooongVariable; After: LoooooooooooongType *loooooooooooongVariable; llvm-svn: 232044
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp2
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp15
2 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 17a007f8b2a..15fc07f62eb 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -580,7 +580,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
return State.Stack.back().StartOfArraySubscripts;
return ContinuationIndent;
}
- if (NextNonComment->is(TT_StartOfName) ||
+ if (NextNonComment->isOneOf(TT_StartOfName, TT_PointerOrReference) ||
Previous.isOneOf(tok::coloncolon, tok::equal)) {
return ContinuationIndent;
}
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 74b7de0001e..caca6458df4 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1537,6 +1537,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return Style.PenaltyReturnTypeOnItsOwnLine;
return 200;
}
+ if (Right.is(TT_PointerOrReference))
+ return 200;
if (Right.is(TT_TrailingReturnArrow))
return 110;
if (Left.is(tok::equal) && Right.is(tok::l_brace))
@@ -1980,6 +1982,14 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return false;
if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation))
return !Right.is(tok::l_paren);
+ if (Left.is(TT_PointerOrReference))
+ return (!Line.IsMultiVariableDeclStmt &&
+ Style.PointerAlignment != FormatStyle::PAS_Right) ||
+ Right.is(TT_FunctionDeclarationName);
+ if (Right.is(TT_PointerOrReference))
+ return Line.IsMultiVariableDeclStmt ||
+ (Style.PointerAlignment == FormatStyle::PAS_Right &&
+ (!Right.Next || Right.Next->isNot(TT_FunctionDeclarationName)));
if (Right.isOneOf(TT_StartOfName, TT_FunctionDeclarationName) ||
Right.is(tok::kw_operator))
return true;
@@ -2016,10 +2026,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return true;
if (Right.is(TT_RangeBasedForLoopColon))
return false;
- if (Right.is(TT_PointerOrReference) && Line.IsMultiVariableDeclStmt)
- return true;
- if (Left.isOneOf(TT_PointerOrReference, TT_TemplateCloser,
- TT_UnaryOperator) ||
+ if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
Left.is(tok::kw_operator))
return false;
if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
OpenPOWER on IntegriCloud