diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 15 |
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) |

