diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-02-27 13:28:36 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-02-27 13:28:36 +0000 |
commit | 1741253403c8255faa3674bcaaf6663c9a1a1a2e (patch) | |
tree | 8813efb0313821472f71331c8e82b6c6e1e33c55 /lib/Format/UnwrappedLineParser.h | |
parent | 7cf8dd5ce168bed45b57e019149e33300c56f94b (diff) |
[clang-format] Add a NamespaceEndCommentsFixer
Summary:
This patch adds a NamespaceEndCommentsFixer TokenAnalyzer for clang-format,
which fixes end namespace comments.
It currently supports inserting and updating existing wrong comments.
Example source:
```
namespace A {
int i;
}
namespace B {
int j;
} // namespace A
```
after formatting:
```
namespace A {
int i;
} // namespace A
namespace B {
int j;
} // namespace B
```
Reviewers: klimek, djasper
Reviewed By: djasper
Subscribers: klimek, mgorny
Differential Revision: https://reviews.llvm.org/D30269
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296341 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.h')
-rw-r--r-- | lib/Format/UnwrappedLineParser.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Format/UnwrappedLineParser.h b/lib/Format/UnwrappedLineParser.h index 6cea8cdc03..15d1d9cda7 100644 --- a/lib/Format/UnwrappedLineParser.h +++ b/lib/Format/UnwrappedLineParser.h @@ -48,6 +48,14 @@ struct UnwrappedLine { bool InPPDirective; bool MustBeDeclaration; + + /// \brief If this \c UnwrappedLine closes a block in a sequence of lines, + /// \c MatchingOpeningBlockLineIndex stores the index of the corresponding + /// opening line. Otherwise, \c MatchingOpeningBlockLineIndex must be + /// \c kInvalidIndex. + size_t MatchingOpeningBlockLineIndex; + + static const size_t kInvalidIndex = -1; }; class UnwrappedLineConsumer { @@ -234,8 +242,8 @@ struct UnwrappedLineNode { SmallVector<UnwrappedLine, 0> Children; }; -inline UnwrappedLine::UnwrappedLine() - : Level(0), InPPDirective(false), MustBeDeclaration(false) {} +inline UnwrappedLine::UnwrappedLine() : Level(0), InPPDirective(false), + MustBeDeclaration(false), MatchingOpeningBlockLineIndex(kInvalidIndex) {} } // end namespace format } // end namespace clang |