summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp1
-rw-r--r--clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp12
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
OpenPOWER on IntegriCloud