This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG717cd16e85fa: [clang-format] Fix namespace end comments
fixer with anonymous namespaces. (authored by curdeius).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117289/new/
https://reviews.llvm.org/D117289
Files:
clang/lib/Format/NamespaceEndCommentsFixer.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===================================================================
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -256,6 +256,15 @@
"int j;\n"
"};}",
CompactNamespacesStyle));
+ EXPECT_EQ("namespace out { namespace {\n"
+ "int i;\n"
+ "int j;\n"
+ "}}// namespace out",
+ fixNamespaceEndComments("namespace out { namespace {\n"
+ "int i;\n"
+ "int j;\n"
+ "}}",
+ CompactNamespacesStyle));
// Adds an end comment after a semicolon.
EXPECT_EQ("namespace {\n"
@@ -609,6 +618,11 @@
"}// banamespace in\n"
"} // namespace out",
CompactNamespacesStyle));
+ EXPECT_EQ("namespace out { namespace {\n"
+ "}} // namespace out",
+ fixNamespaceEndComments("namespace out { namespace {\n"
+ "}} // namespace out::",
+ CompactNamespacesStyle));
}
TEST_F(NamespaceEndCommentsFixerTest, UpdatesInvalidMacroEndLineComment) {
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===================================================================
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -261,7 +261,8 @@
updateEndComment(EndCommentPrevTok, std::string(), SourceMgr,
&Fixes);
}
++CompactedNamespacesCount;
- AllNamespaceNames = "::" + NamespaceName + AllNamespaceNames;
+ if (!NamespaceName.empty())
+ AllNamespaceNames = "::" + NamespaceName + AllNamespaceNames;
continue;
}
NamespaceName += AllNamespaceNames;
Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===================================================================
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -256,6 +256,15 @@
"int j;\n"
"};}",
CompactNamespacesStyle));
+ EXPECT_EQ("namespace out { namespace {\n"
+ "int i;\n"
+ "int j;\n"
+ "}}// namespace out",
+ fixNamespaceEndComments("namespace out { namespace {\n"
+ "int i;\n"
+ "int j;\n"
+ "}}",
+ CompactNamespacesStyle));
// Adds an end comment after a semicolon.
EXPECT_EQ("namespace {\n"
@@ -609,6 +618,11 @@
"}// banamespace in\n"
"} // namespace out",
CompactNamespacesStyle));
+ EXPECT_EQ("namespace out { namespace {\n"
+ "}} // namespace out",
+ fixNamespaceEndComments("namespace out { namespace {\n"
+ "}} // namespace out::",
+ CompactNamespacesStyle));
}
TEST_F(NamespaceEndCommentsFixerTest, UpdatesInvalidMacroEndLineComment) {
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===================================================================
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -261,7 +261,8 @@
updateEndComment(EndCommentPrevTok, std::string(), SourceMgr, &Fixes);
}
++CompactedNamespacesCount;
- AllNamespaceNames = "::" + NamespaceName + AllNamespaceNames;
+ if (!NamespaceName.empty())
+ AllNamespaceNames = "::" + NamespaceName + AllNamespaceNames;
continue;
}
NamespaceName += AllNamespaceNames;
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits