std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
// Remove empty lines before "}" where applicable.
if (RootToken.is(tok::r_brace) &&
+ // Look for "}", "} // comment", "};" or "}; // comment".
(!RootToken.Next ||
- (RootToken.Next->is(tok::semi) && !RootToken.Next->Next)))
+ (RootToken.Next->is(tok::comment) && !RootToken.Next->Next) ||
+ (RootToken.Next->is(tok::semi) &&
+ (!RootToken.Next->Next || (RootToken.Next->Next->is(tok::comment) &&
+ !RootToken.Next->Next->Next)))))
Newlines = std::min(Newlines, 1u);
// Remove empty lines at the start of nested blocks (lambdas/arrow functions)
if (PreviousLine == nullptr && Line.Level > 0)
"\n"
"}"));
- // FIXME: This is slightly inconsistent.
FormatStyle LLVMWithNoNamespaceFix = getLLVMStyle();
LLVMWithNoNamespaceFix.FixNamespaceComments = false;
EXPECT_EQ("namespace {\n"
"}"));
EXPECT_EQ("namespace {\n"
"int i;\n"
- "\n"
+ "};",
+ format("namespace {\n"
+ "int i;\n"
+ "\n"
+ "};"));
+ EXPECT_EQ("namespace {\n"
+ "int i;\n"
"} // namespace",
format("namespace {\n"
"int i;\n"
"\n"
"} // namespace"));
+ EXPECT_EQ("namespace {\n"
+ "int i;\n"
+ "}; // namespace",
+ format("namespace {\n"
+ "int i;\n"
+ "\n"
+ "}; // namespace"));
FormatStyle Style = getLLVMStyle();
Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;