r296638 - [clang-format] Don't add namespace end comments for unbalanced right braces after namespace end
Krasimir Georgiev via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 1 08:38:08 PST 2017
Author: krasimir
Date: Wed Mar 1 10:38:08 2017
New Revision: 296638
URL: http://llvm.org/viewvc/llvm-project?rev=296638&view=rev
Log:
[clang-format] Don't add namespace end comments for unbalanced right braces after namespace end
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=296638&r1=296637&r2=296638&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Mar 1 10:38:08 2017
@@ -2048,6 +2048,7 @@ void UnwrappedLineParser::addUnwrappedLi
});
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()),
Modified: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp?rev=296638&r1=296637&r2=296638&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp (original)
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp Wed Mar 1 10:38:08 2017
@@ -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
More information about the cfe-commits
mailing list