diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-03-01 16:38:08 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-03-01 16:38:08 +0000 |
commit | 85c3704c0da1bbc88c45ecfb0a5c8bef1df50d25 (patch) | |
tree | 6e816a4aeb17a95c7b84e51d51762dcc3b39d838 | |
parent | 570c23035770a7ce9438efea7c15f06b782bdf6e (diff) | |
download | bcm5719-llvm-85c3704c0da1bbc88c45ecfb0a5c8bef1df50d25.tar.gz bcm5719-llvm-85c3704c0da1bbc88c45ecfb0a5c8bef1df50d25.zip |
[clang-format] Don't add namespace end comments for unbalanced right braces after namespace end
llvm-svn: 296638
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 1 | ||||
-rw-r--r-- | clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 9efb6812673..6590f38bda0 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2048,6 +2048,7 @@ void UnwrappedLineParser::addUnwrappedLine() { }); CurrentLines->push_back(std::move(*Line)); Line->Tokens.clear(); + Line->MatchingOpeningBlockLineIndex = UnwrappedLine::kInvalidIndex; if (CurrentLines == &Lines && !PreprocessorDirectives.empty()) { CurrentLines->append( std::make_move_iterator(PreprocessorDirectives.begin()), diff --git a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp index 09f21929c37..c24894e7d4e 100644 --- a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp +++ b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp @@ -345,6 +345,18 @@ TEST_F(NamespaceEndCommentsFixerTest, "}\n" "}\n")); } + +TEST_F(NamespaceEndCommentsFixerTest, + DoesNotAddEndCommentForUnbalancedRBracesAfterNamespaceEnd) { + EXPECT_EQ("namespace {\n" + " int i;\n" + "} // namespace\n" + "}", + fixNamespaceEndComments("namespace {\n" + " int i;\n" + "} // namespace\n" + "}")); +} } // end namespace } // end namespace format } // end namespace clang |