[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)

2023-12-17 Thread Owen Pan via cfe-commits

https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/75731
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)

2023-12-17 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/75731
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)

2023-12-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #36620.
Fixes #75719.

---
Full diff: https://github.com/llvm/llvm-project/pull/75731.diff


2 Files Affected:

- (modified) clang/lib/Format/Format.cpp (-5) 
- (modified) clang/unittests/Format/FormatTest.cpp (+7) 


``diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 668e959a9416ba..28271181e07d0c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1315,7 +1315,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.SplitEmptyFunction = true;
 Expanded.BraceWrapping.SplitEmptyRecord = false;
 break;
@@ -1335,7 +1334,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1350,7 +1348,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 Expanded.BraceWrapping.AfterObjCDeclaration = true;
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1375,7 +1372,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 /*SplitEmptyFunction=*/true,
 /*SplitEmptyRecord=*/true,
 /*SplitEmptyNamespace=*/true};
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 break;
   case FormatStyle::BS_WebKit:
 Expanded.BraceWrapping.AfterFunction = true;
@@ -1909,7 +1905,6 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind 
Language) {
   Style.BraceWrapping.AfterObjCDeclaration = true;
   Style.BraceWrapping.AfterStruct = true;
   Style.BraceWrapping.AfterExternBlock = true;
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.BraceWrapping.BeforeWhile = false;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 24b2fd599dc397..0e08723aa9e947 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4571,6 +4571,13 @@ TEST_F(FormatTest, IndentExternBlockStyle) {
"}",
Style);
 
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "int i;\n"
+   "}",
+   Style);
+
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = true;
   Style.IndentExternBlock = FormatStyle::IEBS_Indent;

``




https://github.com/llvm/llvm-project/pull/75731
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)

2023-12-16 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/75731

Fixes #36620.
Fixes #75719.

>From 9e54c990db8e597a85239b1efea06b597acf6beb Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Sat, 16 Dec 2023 22:50:27 -0800
Subject: [PATCH] [clang-format] Fix a bug in `IndentExternBlock: NoIndent`

Fixes #36620.
Fixes #75719.
---
 clang/lib/Format/Format.cpp   | 5 -
 clang/unittests/Format/FormatTest.cpp | 7 +++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 668e959a9416ba..28271181e07d0c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1315,7 +1315,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.SplitEmptyFunction = true;
 Expanded.BraceWrapping.SplitEmptyRecord = false;
 break;
@@ -1335,7 +1334,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterUnion = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1350,7 +1348,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 Expanded.BraceWrapping.AfterObjCDeclaration = true;
 Expanded.BraceWrapping.AfterStruct = true;
 Expanded.BraceWrapping.AfterExternBlock = true;
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
 Expanded.BraceWrapping.BeforeLambdaBody = true;
@@ -1375,7 +1372,6 @@ static void expandPresetsBraceWrapping(FormatStyle 
) {
 /*SplitEmptyFunction=*/true,
 /*SplitEmptyRecord=*/true,
 /*SplitEmptyNamespace=*/true};
-Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 break;
   case FormatStyle::BS_WebKit:
 Expanded.BraceWrapping.AfterFunction = true;
@@ -1909,7 +1905,6 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind 
Language) {
   Style.BraceWrapping.AfterObjCDeclaration = true;
   Style.BraceWrapping.AfterStruct = true;
   Style.BraceWrapping.AfterExternBlock = true;
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.BraceWrapping.BeforeWhile = false;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 24b2fd599dc397..0e08723aa9e947 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4571,6 +4571,13 @@ TEST_F(FormatTest, IndentExternBlockStyle) {
"}",
Style);
 
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "int i;\n"
+   "}",
+   Style);
+
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = true;
   Style.IndentExternBlock = FormatStyle::IEBS_Indent;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits