diff options
author | Manuel Klimek <klimek@google.com> | 2018-04-23 09:34:26 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2018-04-23 09:34:26 +0000 |
commit | 0dddcf78b89bd062a8de0cd41ce4903ee93b25c0 (patch) | |
tree | 36094549cea8fbbb85914920b955542778e076ee /clang/lib/Format/UnwrappedLineParser.h | |
parent | f0f716df8e758dc43836c70a8e2bcb459b42402d (diff) | |
download | bcm5719-llvm-0dddcf78b89bd062a8de0cd41ce4903ee93b25c0.tar.gz bcm5719-llvm-0dddcf78b89bd062a8de0cd41ce4903ee93b25c0.zip |
Format closing braces when reformatting the line containing the opening brace.
This required a couple of yaks to be shaved:
1. MatchingOpeningBlockLineIndex was misused to also store the
closing index; instead, use a second variable, as this doesn't
work correctly for "} else {".
2. We needed to change the API of AffectedRangeManager to not
use iterators; we always passed in begin / end for the whole
container before, so there was no mismatch in generality.
3. We need an extra check to discontinue formatting at the top
level, as we now sometimes change the indent of the closing
brace, but want to bail out immediately afterwards, for
example:
void f() {
if (a) {
}
void g();
Previously:
void f() {
if (a) {
}
void g();
Now:
void f() {
if (a) {
}
void g();
Differential Revision: https://reviews.llvm.org/D45726
llvm-svn: 330573
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.h')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index b876735ec79..da7529c2ade 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -53,7 +53,11 @@ struct UnwrappedLine { /// \c MatchingOpeningBlockLineIndex stores the index of the corresponding /// opening line. Otherwise, \c MatchingOpeningBlockLineIndex must be /// \c kInvalidIndex. - size_t MatchingOpeningBlockLineIndex; + size_t MatchingOpeningBlockLineIndex = kInvalidIndex; + + /// \brief If this \c UnwrappedLine opens a block, stores the index of the + /// line with the corresponding closing brace. + size_t MatchingClosingBlockLineIndex = kInvalidIndex; static const size_t kInvalidIndex = -1; |