forked from OSchip/llvm-project
[clang-format] Handle "// clang-format off" for RemoveBracesLLVM
Differential Revision: https://reviews.llvm.org/D121352
This commit is contained in:
parent
19c6098097
commit
e2b219bded
|
@ -1808,7 +1808,8 @@ private:
|
||||||
removeBraces(Line->Children, Result);
|
removeBraces(Line->Children, Result);
|
||||||
if (!Line->Affected)
|
if (!Line->Affected)
|
||||||
continue;
|
continue;
|
||||||
for (FormatToken *Token = Line->First; Token; Token = Token->Next) {
|
for (FormatToken *Token = Line->First; Token && !Token->Finalized;
|
||||||
|
Token = Token->Next) {
|
||||||
if (!Token->Optional)
|
if (!Token->Optional)
|
||||||
continue;
|
continue;
|
||||||
assert(Token->isOneOf(tok::l_brace, tok::r_brace));
|
assert(Token->isOneOf(tok::l_brace, tok::r_brace));
|
||||||
|
|
|
@ -24805,6 +24805,19 @@ TEST_F(FormatTest, RemoveBraces) {
|
||||||
"}",
|
"}",
|
||||||
Style);
|
Style);
|
||||||
|
|
||||||
|
verifyFormat("// clang-format off\n"
|
||||||
|
"// comment\n"
|
||||||
|
"while (i > 0) { --i; }\n"
|
||||||
|
"// clang-format on\n"
|
||||||
|
"while (j < 0)\n"
|
||||||
|
" ++j;",
|
||||||
|
"// clang-format off\n"
|
||||||
|
"// comment\n"
|
||||||
|
"while (i > 0) { --i; }\n"
|
||||||
|
"// clang-format on\n"
|
||||||
|
"while (j < 0) { ++j; }",
|
||||||
|
Style);
|
||||||
|
|
||||||
verifyFormat("if (a)\n"
|
verifyFormat("if (a)\n"
|
||||||
" b; // comment\n"
|
" b; // comment\n"
|
||||||
"else if (c)\n"
|
"else if (c)\n"
|
||||||
|
|
Loading…
Reference in New Issue