summaryrefslogtreecommitdiffstats
path: root/clang/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
commit6fe2f009df1a85efc588229676f2ffff0c1231f3 (patch)
tree097e47a8cdb8da8b25fef7e6a64d7e0979e43d3b /clang/lib/Format/WhitespaceManager.h
parenta04337e22b8b170a758011ddb78645a1d41be827 (diff)
downloadbcm5719-llvm-6fe2f009df1a85efc588229676f2ffff0c1231f3.tar.gz
bcm5719-llvm-6fe2f009df1a85efc588229676f2ffff0c1231f3.zip
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. llvm-svn: 180253
Diffstat (limited to 'clang/lib/Format/WhitespaceManager.h')
-rw-r--r--clang/lib/Format/WhitespaceManager.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/clang/lib/Format/WhitespaceManager.h b/clang/lib/Format/WhitespaceManager.h
index 2833e249c42..5f3dc55edac 100644
--- a/clang/lib/Format/WhitespaceManager.h
+++ b/clang/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;
OpenPOWER on IntegriCloud