Skip to content

Commit 401f039

Browse files
authored
[clang-format] Fix a bug in IndentExternBlock: NoIndent (#75731)
Fixes #36620. Fixes #75719.
1 parent 68c976b commit 401f039

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

clang/lib/Format/Format.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,6 @@ static void expandPresetsBraceWrapping(FormatStyle &Expanded) {
13151315
Expanded.BraceWrapping.AfterStruct = true;
13161316
Expanded.BraceWrapping.AfterUnion = true;
13171317
Expanded.BraceWrapping.AfterExternBlock = true;
1318-
Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
13191318
Expanded.BraceWrapping.SplitEmptyFunction = true;
13201319
Expanded.BraceWrapping.SplitEmptyRecord = false;
13211320
break;
@@ -1335,7 +1334,6 @@ static void expandPresetsBraceWrapping(FormatStyle &Expanded) {
13351334
Expanded.BraceWrapping.AfterStruct = true;
13361335
Expanded.BraceWrapping.AfterUnion = true;
13371336
Expanded.BraceWrapping.AfterExternBlock = true;
1338-
Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
13391337
Expanded.BraceWrapping.BeforeCatch = true;
13401338
Expanded.BraceWrapping.BeforeElse = true;
13411339
Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1350,7 +1348,6 @@ static void expandPresetsBraceWrapping(FormatStyle &Expanded) {
13501348
Expanded.BraceWrapping.AfterObjCDeclaration = true;
13511349
Expanded.BraceWrapping.AfterStruct = true;
13521350
Expanded.BraceWrapping.AfterExternBlock = true;
1353-
Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
13541351
Expanded.BraceWrapping.BeforeCatch = true;
13551352
Expanded.BraceWrapping.BeforeElse = true;
13561353
Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1375,7 +1372,6 @@ static void expandPresetsBraceWrapping(FormatStyle &Expanded) {
13751372
/*SplitEmptyFunction=*/true,
13761373
/*SplitEmptyRecord=*/true,
13771374
/*SplitEmptyNamespace=*/true};
1378-
Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
13791375
break;
13801376
case FormatStyle::BS_WebKit:
13811377
Expanded.BraceWrapping.AfterFunction = true;
@@ -1909,7 +1905,6 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language) {
19091905
Style.BraceWrapping.AfterObjCDeclaration = true;
19101906
Style.BraceWrapping.AfterStruct = true;
19111907
Style.BraceWrapping.AfterExternBlock = true;
1912-
Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
19131908
Style.BraceWrapping.BeforeCatch = true;
19141909
Style.BraceWrapping.BeforeElse = true;
19151910
Style.BraceWrapping.BeforeWhile = false;

clang/unittests/Format/FormatTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4571,6 +4571,13 @@ TEST_F(FormatTest, IndentExternBlockStyle) {
45714571
"}",
45724572
Style);
45734573

4574+
Style.BreakBeforeBraces = FormatStyle::BS_Allman;
4575+
verifyFormat("extern \"C\"\n"
4576+
"{\n"
4577+
"int i;\n"
4578+
"}",
4579+
Style);
4580+
45744581
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
45754582
Style.BraceWrapping.AfterExternBlock = true;
45764583
Style.IndentExternBlock = FormatStyle::IEBS_Indent;

0 commit comments

Comments
 (0)