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 | 567dcf95424d69657f75e4bfd028967ca1f9eb8d (patch) | |
tree | b1898d030a92709d3924938628f6243e9a832084 /lib/Format/ContinuationIndenter.h | |
parent | e768c974a696388072effd617e87af3f8716a581 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/ContinuationIndenter.h')
-rw-r--r-- | lib/Format/ContinuationIndenter.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Format/ContinuationIndenter.h b/lib/Format/ContinuationIndenter.h index 70b87bb2fb..5d3da4ccf8 100644 --- a/lib/Format/ContinuationIndenter.h +++ b/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) |