]> granicus.if.org Git - clang/commitdiff
[clang-format] Don't add namespace end comments for unbalanced right braces after...
authorKrasimir Georgiev <krasimir@google.com>
Wed, 1 Mar 2017 16:38:08 +0000 (16:38 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Wed, 1 Mar 2017 16:38:08 +0000 (16:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296638 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/NamespaceEndCommentsFixerTest.cpp

index 9efb6812673f2c74b84260db58d934319d4a18b6..6590f38bda03f6b4ac0f56b1aba99a37f8cf19b3 100644 (file)
@@ -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()),
index 09f21929c375604f659b890061816b3b7c456149..c24894e7d4e7b61dc27e66300a0b7855f1bb114a 100644 (file)
@@ -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