diff options
Diffstat (limited to 'lib/Format/WhitespaceManager.h')
-rw-r--r-- | lib/Format/WhitespaceManager.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/Format/WhitespaceManager.h b/lib/Format/WhitespaceManager.h index 2833e249c4..5f3dc55eda 100644 --- a/lib/Format/WhitespaceManager.h +++ b/lib/Format/WhitespaceManager.h @@ -1,4 +1,4 @@ -//===--- WhitespaceManager.h - Format C++ code ----------------------------===// +//===--- WhitespaceManager.h - Format C++ code ------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -68,31 +68,45 @@ public: /// \brief Try to align all stashed comments. void alignComments(); + /// \brief Try to align all stashed escaped newlines. + void alignEscapedNewlines(); private: std::string getNewLineText(unsigned NewLines, unsigned Spaces); std::string getNewLineText(unsigned NewLines, unsigned Spaces, - unsigned WhitespaceStartColumn); - - /// \brief Structure to store a comment for later layout and alignment. - struct StoredComment { - FormatToken Tok; + unsigned WhitespaceStartColumn, + unsigned EscapedNewlineColumn); + + /// \brief Structure to store tokens for later layout and alignment. + struct StoredToken { + StoredToken(SourceLocation ReplacementLoc, unsigned ReplacementLength, + unsigned MinColumn, unsigned MaxColumn, unsigned NewLines, + unsigned Spaces) + : ReplacementLoc(ReplacementLoc), ReplacementLength(ReplacementLength), + MinColumn(MinColumn), MaxColumn(MaxColumn), NewLines(NewLines), + Spaces(Spaces), Untouchable(false) {} + SourceLocation ReplacementLoc; + unsigned ReplacementLength; unsigned MinColumn; unsigned MaxColumn; unsigned NewLines; unsigned Spaces; bool Untouchable; + std::string Prefix; + std::string Postfix; }; - SmallVector<StoredComment, 16> Comments; - typedef SmallVector<StoredComment, 16>::iterator comment_iterator; + SmallVector<StoredToken, 16> Comments; + SmallVector<StoredToken, 16> EscapedNewlines; + typedef SmallVector<StoredToken, 16>::iterator token_iterator; /// \brief Put all the comments between \p I and \p E into \p Column. - void alignComments(comment_iterator I, comment_iterator E, unsigned Column); + void alignComments(token_iterator I, token_iterator E, unsigned Column); /// \brief Stores \p Text as the replacement for the whitespace in front of /// \p Tok. - void storeReplacement(const FormatToken &Tok, const std::string Text); + void storeReplacement(SourceLocation Loc, unsigned Length, + const std::string Text); SourceManager &SourceMgr; tooling::Replacements Replaces; |