Before:
void f() {
bar([]() {}// Does not respect SpacesBeforeTrailingComments
);
}
After:
void f() {
bar([]() {} // Does not respect SpacesBeforeTrailingComments
);
}
This fixes llvm.org/PR19017.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203466
91177308-0d34-0410-b5e6-
96231b3b80d8
bool InFunctionDecl = Line.MightBeFunctionDecl;
while (Current != NULL) {
if (Current->Type == TT_LineComment) {
- if (Current->Previous->BlockKind == BK_BracedInit)
+ if (Current->Previous->BlockKind == BK_BracedInit &&
+ Current->Previous->opensScope())
Current->SpacesRequiredBefore = Style.Cpp11BracedListStyle ? 0 : 1;
else
Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
verifyFormat("double &operator[](int i) { return 0; }\n"
"int i;");
verifyFormat("std::unique_ptr<int[]> foo() {}");
+
+ // Other corner cases.
+ verifyFormat("void f() {\n"
+ " bar([]() {} // Did not respect SpacesBeforeTrailingComments\n"
+ " );\n"
+ "}");
}
TEST_F(FormatTest, FormatsBlocks) {