Skip to content

Commit 0f09410

Browse files
author
git apple-llvm automerger
committed
Merge commit 'caef7619d5fd' from llvm.org/release/21.x into stable/21.x
2 parents 272e683 + caef761 commit 0f09410

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() {
9393
auto &Tok = *Tokens.back();
9494
const auto NewlinesBefore = Tok.NewlinesBefore;
9595
switch (FormatOff) {
96-
case FO_CurrentLine:
97-
if (NewlinesBefore == 0)
98-
Tok.Finalized = true;
99-
else
100-
FormatOff = FO_None;
101-
break;
10296
case FO_NextLine:
10397
if (NewlinesBefore > 1) {
10498
FormatOff = FO_None;
@@ -107,6 +101,13 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() {
107101
FormatOff = FO_CurrentLine;
108102
}
109103
break;
104+
case FO_CurrentLine:
105+
if (NewlinesBefore == 0) {
106+
Tok.Finalized = true;
107+
break;
108+
}
109+
FormatOff = FO_None;
110+
[[fallthrough]];
110111
default:
111112
if (!FormattingDisabled && FormatOffRegex.match(Tok.TokenText)) {
112113
if (Tok.is(tok::comment) &&

clang/unittests/Format/FormatTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25081,6 +25081,11 @@ TEST_F(FormatTest, OneLineFormatOffRegex) {
2508125081
" } while (0 )",
2508225082
Style);
2508325083

25084+
Style.OneLineFormatOffRegex = "MACRO_TEST";
25085+
verifyNoChange(" MACRO_TEST1 ( ) ;\n"
25086+
" MACRO_TEST2( );",
25087+
Style);
25088+
2508425089
Style.ColumnLimit = 50;
2508525090
Style.OneLineFormatOffRegex = "^LogErrorPrint$";
2508625091
verifyFormat(" myproject::LogErrorPrint(logger, \"Don't split me!\");\n"

0 commit comments

Comments
 (0)