Skip to content

Commit 3365693

Browse files
authored
[clang-format] Rename ExportBlockIndentation -> IndentExportBlock (llvm#123493)
This renames the `ExportBlockIndentation` option and adds a config parse test, as requested in llvm#110381.
1 parent 5d9c717 commit 3365693

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,21 +3946,6 @@ the configuration (without a prefix: ``Auto``).
39463946
This is an experimental flag, that might go away or be renamed. Do
39473947
not use this in config files, etc. Use at your own risk.
39483948

3949-
.. _ExportBlockIndentation:
3950-
3951-
**ExportBlockIndentation** (``Boolean``) :versionbadge:`clang-format 20` :ref:`<ExportBlockIndentation>`
3952-
If ``true``, clang-format will indent the body of an ``export { ... }``
3953-
block. This doesn't affect the formatting of anything else related to
3954-
exported declarations.
3955-
3956-
.. code-block:: c++
3957-
3958-
true: false:
3959-
export { vs. export {
3960-
void foo(); void foo();
3961-
void bar(); void bar();
3962-
} }
3963-
39643949
.. _FixNamespaceComments:
39653950

39663951
**FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5` :ref:`<FixNamespaceComments>`
@@ -4228,6 +4213,21 @@ the configuration (without a prefix: ``Auto``).
42284213
plop(); plop();
42294214
} }
42304215

4216+
.. _IndentExportBlock:
4217+
4218+
**IndentExportBlock** (``Boolean``) :versionbadge:`clang-format 20` :ref:`<IndentExportBlock>`
4219+
If ``true``, clang-format will indent the body of an ``export { ... }``
4220+
block. This doesn't affect the formatting of anything else related to
4221+
exported declarations.
4222+
4223+
.. code-block:: c++
4224+
4225+
true: false:
4226+
export { vs. export {
4227+
void foo(); void foo();
4228+
void bar(); void bar();
4229+
} }
4230+
42314231
.. _IndentExternBlock:
42324232

42334233
**IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 11` :ref:`<IndentExternBlock>`

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ clang-format
12351235
- Adds ``VariableTemplates`` option.
12361236
- Adds support for bash globstar in ``.clang-format-ignore``.
12371237
- Adds ``WrapNamespaceBodyWithEmptyLines`` option.
1238-
- Adds the ``ExportBlockIndentation`` option.
1238+
- Adds the ``IndentExportBlock`` option.
12391239

12401240
libclang
12411241
--------

clang/include/clang/Format/Format.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,19 +2676,6 @@ struct FormatStyle {
26762676
/// \version 3.7
26772677
bool ExperimentalAutoDetectBinPacking;
26782678

2679-
/// If ``true``, clang-format will indent the body of an ``export { ... }``
2680-
/// block. This doesn't affect the formatting of anything else related to
2681-
/// exported declarations.
2682-
/// \code
2683-
/// true: false:
2684-
/// export { vs. export {
2685-
/// void foo(); void foo();
2686-
/// void bar(); void bar();
2687-
/// } }
2688-
/// \endcode
2689-
/// \version 20
2690-
bool ExportBlockIndentation;
2691-
26922679
/// If ``true``, clang-format adds missing namespace end comments for
26932680
/// namespaces and fixes invalid existing ones. This doesn't affect short
26942681
/// namespaces, which are controlled by ``ShortNamespaceLines``.
@@ -2832,6 +2819,19 @@ struct FormatStyle {
28322819
/// \version 10
28332820
bool IndentGotoLabels;
28342821

2822+
/// If ``true``, clang-format will indent the body of an ``export { ... }``
2823+
/// block. This doesn't affect the formatting of anything else related to
2824+
/// exported declarations.
2825+
/// \code
2826+
/// true: false:
2827+
/// export { vs. export {
2828+
/// void foo(); void foo();
2829+
/// void bar(); void bar();
2830+
/// } }
2831+
/// \endcode
2832+
/// \version 20
2833+
bool IndentExportBlock;
2834+
28352835
/// Indents extern blocks
28362836
enum IndentExternBlockStyle : int8_t {
28372837
/// Backwards compatible with AfterExternBlock's indenting.
@@ -5267,7 +5267,6 @@ struct FormatStyle {
52675267
EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
52685268
ExperimentalAutoDetectBinPacking ==
52695269
R.ExperimentalAutoDetectBinPacking &&
5270-
ExportBlockIndentation == R.ExportBlockIndentation &&
52715270
FixNamespaceComments == R.FixNamespaceComments &&
52725271
ForEachMacros == R.ForEachMacros &&
52735272
IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks &&
@@ -5280,6 +5279,7 @@ struct FormatStyle {
52805279
IndentAccessModifiers == R.IndentAccessModifiers &&
52815280
IndentCaseBlocks == R.IndentCaseBlocks &&
52825281
IndentCaseLabels == R.IndentCaseLabels &&
5282+
IndentExportBlock == R.IndentExportBlock &&
52835283
IndentExternBlock == R.IndentExternBlock &&
52845284
IndentGotoLabels == R.IndentGotoLabels &&
52855285
IndentPPDirectives == R.IndentPPDirectives &&

clang/lib/Format/Format.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,6 @@ template <> struct MappingTraits<FormatStyle> {
10401040
Style.EmptyLineBeforeAccessModifier);
10411041
IO.mapOptional("ExperimentalAutoDetectBinPacking",
10421042
Style.ExperimentalAutoDetectBinPacking);
1043-
IO.mapOptional("ExportBlockIndentation", Style.ExportBlockIndentation);
10441043
IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
10451044
IO.mapOptional("ForEachMacros", Style.ForEachMacros);
10461045
IO.mapOptional("IfMacros", Style.IfMacros);
@@ -1052,6 +1051,7 @@ template <> struct MappingTraits<FormatStyle> {
10521051
IO.mapOptional("IndentAccessModifiers", Style.IndentAccessModifiers);
10531052
IO.mapOptional("IndentCaseBlocks", Style.IndentCaseBlocks);
10541053
IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
1054+
IO.mapOptional("IndentExportBlock", Style.IndentExportBlock);
10551055
IO.mapOptional("IndentExternBlock", Style.IndentExternBlock);
10561056
IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels);
10571057
IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives);
@@ -1551,7 +1551,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15511551
LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
15521552
LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
15531553
LLVMStyle.ExperimentalAutoDetectBinPacking = false;
1554-
LLVMStyle.ExportBlockIndentation = true;
15551554
LLVMStyle.FixNamespaceComments = true;
15561555
LLVMStyle.ForEachMacros.push_back("foreach");
15571556
LLVMStyle.ForEachMacros.push_back("Q_FOREACH");
@@ -1567,6 +1566,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15671566
LLVMStyle.IndentAccessModifiers = false;
15681567
LLVMStyle.IndentCaseBlocks = false;
15691568
LLVMStyle.IndentCaseLabels = false;
1569+
LLVMStyle.IndentExportBlock = true;
15701570
LLVMStyle.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
15711571
LLVMStyle.IndentGotoLabels = true;
15721572
LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,8 +3167,7 @@ void UnwrappedLineParser::parseNamespace() {
31673167
}
31683168

31693169
void UnwrappedLineParser::parseCppExportBlock() {
3170-
parseNamespaceOrExportBlock(/*AddLevels=*/Style.ExportBlockIndentation ? 1
3171-
: 0);
3170+
parseNamespaceOrExportBlock(/*AddLevels=*/Style.IndentExportBlock ? 1 : 0);
31723171
}
31733172

31743173
void UnwrappedLineParser::parseNew() {

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
176176
CHECK_PARSE_BOOL(IndentAccessModifiers);
177177
CHECK_PARSE_BOOL(IndentCaseBlocks);
178178
CHECK_PARSE_BOOL(IndentCaseLabels);
179+
CHECK_PARSE_BOOL(IndentExportBlock);
179180
CHECK_PARSE_BOOL(IndentGotoLabels);
180181
CHECK_PARSE_BOOL(IndentRequiresClause);
181182
CHECK_PARSE_BOOL_FIELD(IndentRequiresClause, "IndentRequires");

clang/unittests/Format/FormatTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9059,9 +9059,9 @@ TEST_F(FormatTest, AdaptiveOnePerLineFormatting) {
90599059
Style);
90609060
}
90619061

9062-
TEST_F(FormatTest, ExportBlockIndentation) {
9062+
TEST_F(FormatTest, IndentExportBlock) {
90639063
FormatStyle Style = getLLVMStyleWithColumns(80);
9064-
Style.ExportBlockIndentation = true;
9064+
Style.IndentExportBlock = true;
90659065
verifyFormat("export {\n"
90669066
" int x;\n"
90679067
" int y;\n"
@@ -9072,7 +9072,7 @@ TEST_F(FormatTest, ExportBlockIndentation) {
90729072
"}",
90739073
Style);
90749074

9075-
Style.ExportBlockIndentation = false;
9075+
Style.IndentExportBlock = false;
90769076
verifyFormat("export {\n"
90779077
"int x;\n"
90789078
"int y;\n"
@@ -9086,7 +9086,7 @@ TEST_F(FormatTest, ExportBlockIndentation) {
90869086

90879087
TEST_F(FormatTest, ShortExportBlocks) {
90889088
FormatStyle Style = getLLVMStyleWithColumns(80);
9089-
Style.ExportBlockIndentation = false;
9089+
Style.IndentExportBlock = false;
90909090

90919091
Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
90929092
verifyFormat("export {\n"

0 commit comments

Comments
 (0)