This fixes formatting unnamed bitfields (llvm.org/PR21999).
Before:
struct MyStruct {
uchar data;
uchar:
8;
uchar:
8;
uchar other;
};
After:
struct MyStruct {
uchar data;
uchar : 8;
uchar : 8;
uchar other;
};
llvm-svn: 234318
if (Line->Tokens.size() == 1 &&
// JS doesn't have macros, and within classes colons indicate fields,
// not labels.
- (Style.Language != FormatStyle::LK_JavaScript ||
- !Line->MustBeDeclaration)) {
- if (FormatTok->Tok.is(tok::colon)) {
+ Style.Language != FormatStyle::LK_JavaScript) {
+ if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) {
parseLabel();
return;
}
" some_more_code();\n"
" }\n"
"}");
- verifyFormat("some_code();\n"
+ verifyFormat("{\n"
+ " some_code();\n"
"test_label:\n"
- "some_other_code();");
+ " some_other_code();\n"
+ "}");
}
//===----------------------------------------------------------------------===//
" int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : 1,\n"
" bbbbbbbbbbbbbbbbbbbbbbbbb;\n"
"};");
+ verifyFormat("struct MyStruct {\n"
+ " uchar data;\n"
+ " uchar : 8;\n"
+ " uchar : 8;\n"
+ " uchar other;\n"
+ "};");
}
TEST_F(FormatTest, FormatsNamespaces) {