diff options
author | Daniel Jasper <djasper@google.com> | 2014-01-09 13:42:56 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-01-09 13:42:56 +0000 |
commit | 0160347b2210ef3cd9b074cbe1ae9ecc5ed8f3fa (patch) | |
tree | c46d3556267393c4a4c0f0c5c433ea33b8f6b114 /clang/lib/Format/FormatToken.h | |
parent | 3587b32e1cc978d997602d4c0784cdcedda7de3f (diff) | |
download | bcm5719-llvm-0160347b2210ef3cd9b074cbe1ae9ecc5ed8f3fa.tar.gz bcm5719-llvm-0160347b2210ef3cd9b074cbe1ae9ecc5ed8f3fa.zip |
clang-format: Some tweaks to braces list formatting:
- Format a braced list with one element per line if it has nested
braced lists.
- Use a column layout only when the list has 6+ elements (instead of the
current 4+ elements).
llvm-svn: 198869
Diffstat (limited to 'clang/lib/Format/FormatToken.h')
-rw-r--r-- | clang/lib/Format/FormatToken.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 391f9ee8000..dff2942c004 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -398,10 +398,21 @@ public: /// \brief Apply the special formatting that the given role demands. /// + /// Assumes that the token having this role is already formatted. + /// /// Continues formatting from \p State leaving indentation to \p Indenter and /// returns the total penalty that this formatting incurs. - virtual unsigned format(LineState &State, ContinuationIndenter *Indenter, - bool DryRun) { + virtual unsigned formatFromToken(LineState &State, + ContinuationIndenter *Indenter, + bool DryRun) { + return 0; + } + + /// \brief Same as \c formatFromToken, but assumes that the first token has + /// already been set thereby deciding on the first line break. + virtual unsigned formatAfterToken(LineState &State, + ContinuationIndenter *Indenter, + bool DryRun) { return 0; } @@ -414,12 +425,17 @@ protected: class CommaSeparatedList : public TokenRole { public: - CommaSeparatedList(const FormatStyle &Style) : TokenRole(Style) {} + CommaSeparatedList(const FormatStyle &Style) + : TokenRole(Style), HasNestedBracedList(false) {} virtual void precomputeFormattingInfos(const FormatToken *Token); - virtual unsigned format(LineState &State, ContinuationIndenter *Indenter, - bool DryRun); + virtual unsigned formatAfterToken(LineState &State, + ContinuationIndenter *Indenter, + bool DryRun); + + virtual unsigned formatFromToken(LineState &State, + ContinuationIndenter *Indenter, bool DryRun); /// \brief Adds \p Token as the next comma to the \c CommaSeparated list. virtual void CommaFound(const FormatToken *Token) { Commas.push_back(Token); } @@ -454,6 +470,8 @@ private: /// \brief Precomputed formats that can be used for this list. SmallVector<ColumnFormat, 4> Formats; + + bool HasNestedBracedList; }; } // namespace format |