aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/WhitespaceManager.h
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-04-25 08:56:26 +0000
committerDaniel Jasper <djasper@google.com>2013-04-25 08:56:26 +0000
commit2972d049637349bb82f52a27ad3337cf4ab769b4 (patch)
treed4dc0797bebb5d5fb4ae934f2fe4268c5784f257 /lib/Format/WhitespaceManager.h
parentf1ed9febdd4bc4746c2a9fdaa0700014900b1326 (diff)
Add option to align escaped newlines left.
This enables formattings like: #define A \ int aaaa; \ int b; \ int ccc; \ int dddddddddd; Enabling this for Google/Chromium styles only as I don't know whether it is desired for Clang/LLVM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180253 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/WhitespaceManager.h')
-rw-r--r--lib/Format/WhitespaceManager.h34
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;