diff options
author | Daniel Jasper <djasper@google.com> | 2013-09-05 09:29:45 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-09-05 09:29:45 +0000 |
commit | 9fe0e8dacdb36520bd93ed720afd4ce045931a44 (patch) | |
tree | 09b4fbe966995901e7e0b5efec445ce081402ed3 /clang/lib/Format/ContinuationIndenter.h | |
parent | 5bd1fc5993190288ac0640a23302e492b4dc87e7 (diff) | |
download | bcm5719-llvm-9fe0e8dacdb36520bd93ed720afd4ce045931a44.tar.gz bcm5719-llvm-9fe0e8dacdb36520bd93ed720afd4ce045931a44.zip |
clang-format: Enable formatting of nested blocks.
Among other things, this enables (better) formatting lambdas and
constructs like:
MACRO({
long_statement();
long_statement_2();
},
{
long_statement();
long_statement_2();
},
{ short_statement(); }, "");
This fixes llvm.org/PR15381.
llvm-svn: 190038
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.h')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.h b/clang/lib/Format/ContinuationIndenter.h index 70b87bb2fbd..5d3da4ccf8f 100644 --- a/clang/lib/Format/ContinuationIndenter.h +++ b/clang/lib/Format/ContinuationIndenter.h @@ -35,14 +35,13 @@ public: /// \brief Constructs a \c ContinuationIndenter to format \p Line starting in /// column \p FirstIndent. ContinuationIndenter(const FormatStyle &Style, SourceManager &SourceMgr, - const AnnotatedLine &Line, unsigned FirstIndent, WhitespaceManager &Whitespaces, encoding::Encoding Encoding, bool BinPackInconclusiveFunctions); - /// \brief Get the initial state, i.e. the state after placing the line's - /// first token. - LineState getInitialState(); + /// \brief Get the initial state, i.e. the state after placing \p Line's + /// first token at \p FirstIndent. + LineState getInitialState(unsigned FirstIndent, const AnnotatedLine *Line); // FIXME: canBreak and mustBreak aren't strictly indentation-related. Find a // better home. @@ -65,7 +64,7 @@ public: /// \brief Get the column limit for this line. This is the style's column /// limit, potentially reduced for preprocessor definitions. - unsigned getColumnLimit() const; + unsigned getColumnLimit(const LineState &State) const; private: /// \brief Mark the next token as consumed in \p State and modify its stacks @@ -101,8 +100,6 @@ private: FormatStyle Style; SourceManager &SourceMgr; - const AnnotatedLine &Line; - const unsigned FirstIndent; WhitespaceManager &Whitespaces; encoding::Encoding Encoding; bool BinPackInconclusiveFunctions; @@ -271,6 +268,14 @@ struct LineState { /// FIXME: Come up with a better algorithm instead. bool IgnoreStackForComparison; + /// \brief The indent of the first token. + unsigned FirstIndent; + + /// \brief The line that is being formatted. + /// + /// Does not need to be considered for memoization because it doesn't change. + const AnnotatedLine *Line; + /// \brief Comparison operator to be able to used \c LineState in \c map. bool operator<(const LineState &Other) const { if (NextToken != Other.NextToken) |