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 | 7cb267af75e7f8de9d721f4d7bd801003784a6df (patch) | |
tree | 3d29f004e8f6835c8846f0f1ce2199d7c0f90b81 /clang/lib/Format/UnwrappedLineParser.cpp | |
parent | cf8396e4aa1cae7ea8b7f651bc52ec5159378958 (diff) | |
download | bcm5719-llvm-7cb267af75e7f8de9d721f4d7bd801003784a6df.tar.gz bcm5719-llvm-7cb267af75e7f8de9d721f4d7bd801003784a6df.zip |
[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
llvm-svn: 296341
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index ab343d8bbed..9a536ad6019 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -428,6 +428,8 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel, parseParens(); addUnwrappedLine(); + size_t OpeningLineIndex = + Lines.empty() ? (UnwrappedLine::kInvalidIndex) : (Lines.size() - 1); ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, MustBeDeclaration); @@ -453,6 +455,7 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel, if (MunchSemi && FormatTok->Tok.is(tok::semi)) nextToken(); Line->Level = InitialLevel; + Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; } static bool isGoogScope(const UnwrappedLine &Line) { |