[PATCH] D125064: [clang-format][NFC] Make all TokenAnnotator member functions const
This revision was automatically updated to reflect the committed changes. Closed by commit rGaf4cf1c6b8ed: [clang-format][NFC] Make all TokenAnnotator member functions const (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125064/new/ https://reviews.llvm.org/D125064 Files: clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/TokenAnnotator.h Index: clang/lib/Format/TokenAnnotator.h === --- clang/lib/Format/TokenAnnotator.h +++ clang/lib/Format/TokenAnnotator.h @@ -161,43 +161,46 @@ /// Adapts the indent levels of comment lines to the indent of the /// subsequent line. // FIXME: Can/should this be done in the UnwrappedLineParser? - void setCommentLineLevels(SmallVectorImpl &Lines); + void setCommentLineLevels(SmallVectorImpl &Lines) const; - void annotate(AnnotatedLine &Line); - void calculateFormattingInformation(AnnotatedLine &Line); + void annotate(AnnotatedLine &Line) const; + void calculateFormattingInformation(AnnotatedLine &Line) const; private: /// Calculate the penalty for splitting before \c Tok. unsigned splitPenalty(const AnnotatedLine &Line, const FormatToken &Tok, -bool InFunctionDecl); +bool InFunctionDecl) const; bool spaceRequiredBeforeParens(const FormatToken &Right) const; bool spaceRequiredBetween(const AnnotatedLine &Line, const FormatToken &Left, -const FormatToken &Right); +const FormatToken &Right) const; - bool spaceRequiredBefore(const AnnotatedLine &Line, const FormatToken &Right); + bool spaceRequiredBefore(const AnnotatedLine &Line, + const FormatToken &Right) const; - bool mustBreakBefore(const AnnotatedLine &Line, const FormatToken &Right); + bool mustBreakBefore(const AnnotatedLine &Line, + const FormatToken &Right) const; - bool canBreakBefore(const AnnotatedLine &Line, const FormatToken &Right); + bool canBreakBefore(const AnnotatedLine &Line, + const FormatToken &Right) const; bool mustBreakForReturnType(const AnnotatedLine &Line) const; - void printDebugInfo(const AnnotatedLine &Line); + void printDebugInfo(const AnnotatedLine &Line) const; - void calculateUnbreakableTailLengths(AnnotatedLine &Line); + void calculateUnbreakableTailLengths(AnnotatedLine &Line) const; - void calculateArrayInitializerColumnList(AnnotatedLine &Line); + void calculateArrayInitializerColumnList(AnnotatedLine &Line) const; FormatToken *calculateInitializerColumnList(AnnotatedLine &Line, FormatToken *CurrentToken, - unsigned Depth); + unsigned Depth) const; FormatStyle::PointerAlignmentStyle - getTokenReferenceAlignment(const FormatToken &PointerOrReference); + getTokenReferenceAlignment(const FormatToken &PointerOrReference) const; - FormatStyle::PointerAlignmentStyle - getTokenPointerOrReferenceAlignment(const FormatToken &PointerOrReference); + FormatStyle::PointerAlignmentStyle getTokenPointerOrReferenceAlignment( + const FormatToken &PointerOrReference) const; const FormatStyle &Style; Index: clang/lib/Format/TokenAnnotator.cpp === --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -2523,7 +2523,7 @@ } // end anonymous namespace void TokenAnnotator::setCommentLineLevels( -SmallVectorImpl &Lines) { +SmallVectorImpl &Lines) const { const AnnotatedLine *NextNonCommentLine = nullptr; for (AnnotatedLine *Line : llvm::reverse(Lines)) { assert(Line->First); @@ -2558,7 +2558,7 @@ return Result; } -void TokenAnnotator::annotate(AnnotatedLine &Line) { +void TokenAnnotator::annotate(AnnotatedLine &Line) const { for (auto &Child : Line.Children) annotate(*Child); @@ -2725,7 +2725,7 @@ return false; } -void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { +void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { for (AnnotatedLine *ChildLine : Line.Children) calculateFormattingInformation(*ChildLine); @@ -2845,7 +2845,8 @@ LLVM_DEBUG({ printDebugInfo(Line); }); } -void TokenAnnotator::calculateUnbreakableTailLengths(AnnotatedLine &Line) { +void TokenAnnotator::calculateUnbreakableTailLengths( +AnnotatedLine &Line) const { unsigned UnbreakableTailLength = 0; FormatToken *Current = Line.Last; while (Current) { @@ -2861,7 +2862,8 @@ } } -void TokenAnnotator::calculateArrayInitializerColumnList(AnnotatedLine &Line) { +void TokenAnnotator::calculateArrayInitializerColumnList( +AnnotatedLine &Line) const { if (Line.First == Line.Last) return; aut
[PATCH] D125064: [clang-format][NFC] Make all TokenAnnotator member functions const
curdeius accepted this revision. curdeius added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125064/new/ https://reviews.llvm.org/D125064 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D125064: [clang-format][NFC] Make all TokenAnnotator member functions const
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D125064 Files: clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/TokenAnnotator.h Index: clang/lib/Format/TokenAnnotator.h === --- clang/lib/Format/TokenAnnotator.h +++ clang/lib/Format/TokenAnnotator.h @@ -161,43 +161,46 @@ /// Adapts the indent levels of comment lines to the indent of the /// subsequent line. // FIXME: Can/should this be done in the UnwrappedLineParser? - void setCommentLineLevels(SmallVectorImpl &Lines); + void setCommentLineLevels(SmallVectorImpl &Lines) const; - void annotate(AnnotatedLine &Line); - void calculateFormattingInformation(AnnotatedLine &Line); + void annotate(AnnotatedLine &Line) const; + void calculateFormattingInformation(AnnotatedLine &Line) const; private: /// Calculate the penalty for splitting before \c Tok. unsigned splitPenalty(const AnnotatedLine &Line, const FormatToken &Tok, -bool InFunctionDecl); +bool InFunctionDecl) const; bool spaceRequiredBeforeParens(const FormatToken &Right) const; bool spaceRequiredBetween(const AnnotatedLine &Line, const FormatToken &Left, -const FormatToken &Right); +const FormatToken &Right) const; - bool spaceRequiredBefore(const AnnotatedLine &Line, const FormatToken &Right); + bool spaceRequiredBefore(const AnnotatedLine &Line, + const FormatToken &Right) const; - bool mustBreakBefore(const AnnotatedLine &Line, const FormatToken &Right); + bool mustBreakBefore(const AnnotatedLine &Line, + const FormatToken &Right) const; - bool canBreakBefore(const AnnotatedLine &Line, const FormatToken &Right); + bool canBreakBefore(const AnnotatedLine &Line, + const FormatToken &Right) const; bool mustBreakForReturnType(const AnnotatedLine &Line) const; - void printDebugInfo(const AnnotatedLine &Line); + void printDebugInfo(const AnnotatedLine &Line) const; - void calculateUnbreakableTailLengths(AnnotatedLine &Line); + void calculateUnbreakableTailLengths(AnnotatedLine &Line) const; - void calculateArrayInitializerColumnList(AnnotatedLine &Line); + void calculateArrayInitializerColumnList(AnnotatedLine &Line) const; FormatToken *calculateInitializerColumnList(AnnotatedLine &Line, FormatToken *CurrentToken, - unsigned Depth); + unsigned Depth) const; FormatStyle::PointerAlignmentStyle - getTokenReferenceAlignment(const FormatToken &PointerOrReference); + getTokenReferenceAlignment(const FormatToken &PointerOrReference) const; - FormatStyle::PointerAlignmentStyle - getTokenPointerOrReferenceAlignment(const FormatToken &PointerOrReference); + FormatStyle::PointerAlignmentStyle getTokenPointerOrReferenceAlignment( + const FormatToken &PointerOrReference) const; const FormatStyle &Style; Index: clang/lib/Format/TokenAnnotator.cpp === --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -2523,7 +2523,7 @@ } // end anonymous namespace void TokenAnnotator::setCommentLineLevels( -SmallVectorImpl &Lines) { +SmallVectorImpl &Lines) const { const AnnotatedLine *NextNonCommentLine = nullptr; for (AnnotatedLine *Line : llvm::reverse(Lines)) { assert(Line->First); @@ -2558,7 +2558,7 @@ return Result; } -void TokenAnnotator::annotate(AnnotatedLine &Line) { +void TokenAnnotator::annotate(AnnotatedLine &Line) const { for (auto &Child : Line.Children) annotate(*Child); @@ -2725,7 +2725,7 @@ return false; } -void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { +void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { for (AnnotatedLine *ChildLine : Line.Children) calculateFormattingInformation(*ChildLine); @@ -2845,7 +2845,8 @@ LLVM_DEBUG({ printDebugInfo(Line); }); } -void TokenAnnotator::calculateUnbreakableTailLengths(AnnotatedLine &Line) { +void TokenAnnotator::calculateUnbreakableTailLengths( +AnnotatedLine &Line) const { unsigned UnbreakableTailLength = 0; FormatToken *Current = Line.Last; while (Current) { @@ -2861,7 +2862,8 @@ } } -void TokenAnnotator::calculateArrayInitializerColumnList(AnnotatedLine &Line) { +void TokenAnnotator::calculateArrayInitializerColumnList( +AnnotatedLine &Line) const { if (Line.First == Line.Last)