Author: Björn Schäpers Date: 2022-01-05T12:31:35+01:00 New Revision: 2ab5d29f556bc3b5510ae495e5bb54b8b5921d1f
URL: https://github.com/llvm/llvm-project/commit/2ab5d29f556bc3b5510ae495e5bb54b8b5921d1f DIFF: https://github.com/llvm/llvm-project/commit/2ab5d29f556bc3b5510ae495e5bb54b8b5921d1f.diff LOG: [clang-format][NFC] Use Prev instead of Current->Previous Differential Revision: https://reviews.llvm.org/D116561 Added: Modified: clang/lib/Format/TokenAnnotator.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index b501c4d37d40..cbe7c096fda8 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2567,9 +2567,9 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { while (Current) { if (isFunctionDeclarationName(Style.isCpp(), *Current, Line)) Current->setType(TT_FunctionDeclarationName); + const FormatToken *Prev = Current->Previous; if (Current->is(TT_LineComment)) { - if (Current->Previous->is(BK_BracedInit) && - Current->Previous->opensScope()) + if (Prev->is(BK_BracedInit) && Prev->opensScope()) Current->SpacesRequiredBefore = (Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1; else @@ -2610,12 +2610,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { Current->CanBreakBefore = Current->MustBreakBefore || canBreakBefore(Line, *Current); unsigned ChildSize = 0; - if (Current->Previous->Children.size() == 1) { - FormatToken &LastOfChild = *Current->Previous->Children[0]->Last; + if (Prev->Children.size() == 1) { + FormatToken &LastOfChild = *Prev->Children[0]->Last; ChildSize = LastOfChild.isTrailingComment() ? Style.ColumnLimit : LastOfChild.TotalLength + 1; } - const FormatToken *Prev = Current->Previous; if (Current->MustBreakBefore || Prev->Children.size() > 1 || (Prev->Children.size() == 1 && Prev->Children[0]->First->MustBreakBefore) || _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits