forked from OSchip/llvm-project
clang-format: Fix label-in-if statement in macros where it is actually used.
Before: #define A \ if (a) \ label: \ f() After: #define A \ if (a) \ label: \ f() llvm-svn: 265557
This commit is contained in:
parent
3768f7005d
commit
2cce7b728b
|
@ -1573,8 +1573,10 @@ void UnwrappedLineParser::parseLabel() {
|
|||
addUnwrappedLine();
|
||||
}
|
||||
Line->Level = OldLineLevel;
|
||||
if (FormatTok->isNot(tok::l_brace))
|
||||
if (FormatTok->isNot(tok::l_brace)) {
|
||||
parseStructuralElement();
|
||||
addUnwrappedLine();
|
||||
}
|
||||
}
|
||||
|
||||
void UnwrappedLineParser::parseCaseLabel() {
|
||||
|
|
|
@ -296,6 +296,7 @@ TEST_F(FormatTest, FormatIfWithoutCompoundStatement) {
|
|||
verifyFormat("if (a)\n if (b) {\n f();\n }\ng();");
|
||||
|
||||
FormatStyle AllowsMergedIf = getLLVMStyle();
|
||||
AllowsMergedIf.AlignEscapedNewlinesLeft = true;
|
||||
AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true;
|
||||
verifyFormat("if (a)\n"
|
||||
" // comment\n"
|
||||
|
@ -307,6 +308,11 @@ TEST_F(FormatTest, FormatIfWithoutCompoundStatement) {
|
|||
" f();\n"
|
||||
"}",
|
||||
AllowsMergedIf);
|
||||
verifyFormat("#define A \\\n"
|
||||
" if (a) \\\n"
|
||||
" label: \\\n"
|
||||
" f()",
|
||||
AllowsMergedIf);
|
||||
verifyFormat("if (a)\n"
|
||||
" ;",
|
||||
AllowsMergedIf);
|
||||
|
|
Loading…
Reference in New Issue