diff options
author | Manuel Klimek <klimek@google.com> | 2017-11-14 09:19:53 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2017-11-14 09:19:53 +0000 |
commit | 45ab559ee7b1586b12cf6b81480003ba4d80c295 (patch) | |
tree | f116a0fe745c332cd389447cb0319cc88c75e039 /clang/lib/Format/ContinuationIndenter.h | |
parent | 926b95c4dd9c49fbec7f4a0b5ce1cfdfa588520a (diff) | |
download | bcm5719-llvm-45ab559ee7b1586b12cf6b81480003ba4d80c295.tar.gz bcm5719-llvm-45ab559ee7b1586b12cf6b81480003ba4d80c295.zip |
Refactor ContinuationIndenter's breakProtrudingToken logic.
Create more orthogonal pieces. The restructuring made it easy to try out
several alternatives to D33589, and while none of the alternatives
turned out to be the right solution, the underlying simplification of
the structure is helpful.
Differential Revision: https://reviews.llvm.org/D39900
llvm-svn: 318141
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.h')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.h b/clang/lib/Format/ContinuationIndenter.h index 3bc9929b3df..5bdd555109a 100644 --- a/clang/lib/Format/ContinuationIndenter.h +++ b/clang/lib/Format/ContinuationIndenter.h @@ -29,6 +29,7 @@ class SourceManager; namespace format { class AnnotatedLine; +class BreakableToken; struct FormatToken; struct LineState; struct ParenState; @@ -105,11 +106,20 @@ private: /// /// \returns An extra penalty induced by reformatting the token. unsigned reformatRawStringLiteral(const FormatToken &Current, - unsigned StartColumn, LineState &State, - StringRef Delimiter, + LineState &State, const FormatStyle &RawStringStyle, bool DryRun); + /// \brief If the current token is at the end of the current line, handle + /// the transition to the next line. + unsigned handleEndOfLine(const FormatToken &Current, LineState &State, + bool DryRun, bool AllowBreak); + + /// \brief If \p Current is a raw string that is configured to be reformatted, + /// return the style to be used. + llvm::Optional<FormatStyle> getRawStringStyle(const FormatToken &Current, + const LineState &State); + /// \brief If the current token sticks out over the end of the line, break /// it if possible. /// @@ -120,7 +130,13 @@ private: /// penalty for the column limit violation in the last line (and in single /// line tokens) is handled in \c addNextStateToQueue. unsigned breakProtrudingToken(const FormatToken &Current, LineState &State, - bool DryRun); + bool AllowBreak, bool DryRun); + + /// \brief Returns the \c BreakableToken starting at \p Current, or nullptr + /// if the current token cannot be broken. + std::unique_ptr<BreakableToken> + createBreakableToken(const FormatToken &Current, LineState &State, + bool AllowBreak); /// \brief Appends the next token to \p State and updates information /// necessary for indentation. |