Skip to content

[clang-format] Rename ExportBlockIndentation -> IndentExportBlock #123493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3946,21 +3946,6 @@ the configuration (without a prefix: ``Auto``).
This is an experimental flag, that might go away or be renamed. Do
not use this in config files, etc. Use at your own risk.

.. _ExportBlockIndentation:

**ExportBlockIndentation** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <ExportBlockIndentation>`
If ``true``, clang-format will indent the body of an ``export { ... }``
block. This doesn't affect the formatting of anything else related to
exported declarations.

.. code-block:: c++

true: false:
export { vs. export {
void foo(); void foo();
void bar(); void bar();
} }

.. _FixNamespaceComments:

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

.. _IndentExportBlock:

**IndentExportBlock** (``Boolean``) :versionbadge:`clang-format 20` :ref:`¶ <IndentExportBlock>`
If ``true``, clang-format will indent the body of an ``export { ... }``
block. This doesn't affect the formatting of anything else related to
exported declarations.

.. code-block:: c++

true: false:
export { vs. export {
void foo(); void foo();
void bar(); void bar();
} }

.. _IndentExternBlock:

**IndentExternBlock** (``IndentExternBlockStyle``) :versionbadge:`clang-format 11` :ref:`¶ <IndentExternBlock>`
Expand Down
2 changes: 1 addition & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ clang-format
- Adds ``VariableTemplates`` option.
- Adds support for bash globstar in ``.clang-format-ignore``.
- Adds ``WrapNamespaceBodyWithEmptyLines`` option.
- Adds the ``ExportBlockIndentation`` option.
- Adds the ``IndentExportBlock`` option.

libclang
--------
Expand Down
28 changes: 14 additions & 14 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2676,19 +2676,6 @@ struct FormatStyle {
/// \version 3.7
bool ExperimentalAutoDetectBinPacking;

/// If ``true``, clang-format will indent the body of an ``export { ... }``
/// block. This doesn't affect the formatting of anything else related to
/// exported declarations.
/// \code
/// true: false:
/// export { vs. export {
/// void foo(); void foo();
/// void bar(); void bar();
/// } }
/// \endcode
/// \version 20
bool ExportBlockIndentation;

/// If ``true``, clang-format adds missing namespace end comments for
/// namespaces and fixes invalid existing ones. This doesn't affect short
/// namespaces, which are controlled by ``ShortNamespaceLines``.
Expand Down Expand Up @@ -2832,6 +2819,19 @@ struct FormatStyle {
/// \version 10
bool IndentGotoLabels;

/// If ``true``, clang-format will indent the body of an ``export { ... }``
/// block. This doesn't affect the formatting of anything else related to
/// exported declarations.
/// \code
/// true: false:
/// export { vs. export {
/// void foo(); void foo();
/// void bar(); void bar();
/// } }
/// \endcode
/// \version 20
bool IndentExportBlock;

/// Indents extern blocks
enum IndentExternBlockStyle : int8_t {
/// Backwards compatible with AfterExternBlock's indenting.
Expand Down Expand Up @@ -5267,7 +5267,6 @@ struct FormatStyle {
EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
ExperimentalAutoDetectBinPacking ==
R.ExperimentalAutoDetectBinPacking &&
ExportBlockIndentation == R.ExportBlockIndentation &&
FixNamespaceComments == R.FixNamespaceComments &&
ForEachMacros == R.ForEachMacros &&
IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks &&
Expand All @@ -5280,6 +5279,7 @@ struct FormatStyle {
IndentAccessModifiers == R.IndentAccessModifiers &&
IndentCaseBlocks == R.IndentCaseBlocks &&
IndentCaseLabels == R.IndentCaseLabels &&
IndentExportBlock == R.IndentExportBlock &&
IndentExternBlock == R.IndentExternBlock &&
IndentGotoLabels == R.IndentGotoLabels &&
IndentPPDirectives == R.IndentPPDirectives &&
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ template <> struct MappingTraits<FormatStyle> {
Style.EmptyLineBeforeAccessModifier);
IO.mapOptional("ExperimentalAutoDetectBinPacking",
Style.ExperimentalAutoDetectBinPacking);
IO.mapOptional("ExportBlockIndentation", Style.ExportBlockIndentation);
IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
IO.mapOptional("ForEachMacros", Style.ForEachMacros);
IO.mapOptional("IfMacros", Style.IfMacros);
Expand All @@ -1052,6 +1051,7 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("IndentAccessModifiers", Style.IndentAccessModifiers);
IO.mapOptional("IndentCaseBlocks", Style.IndentCaseBlocks);
IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
IO.mapOptional("IndentExportBlock", Style.IndentExportBlock);
IO.mapOptional("IndentExternBlock", Style.IndentExternBlock);
IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels);
IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives);
Expand Down Expand Up @@ -1551,7 +1551,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
LLVMStyle.ExperimentalAutoDetectBinPacking = false;
LLVMStyle.ExportBlockIndentation = true;
LLVMStyle.FixNamespaceComments = true;
LLVMStyle.ForEachMacros.push_back("foreach");
LLVMStyle.ForEachMacros.push_back("Q_FOREACH");
Expand All @@ -1567,6 +1566,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.IndentAccessModifiers = false;
LLVMStyle.IndentCaseBlocks = false;
LLVMStyle.IndentCaseLabels = false;
LLVMStyle.IndentExportBlock = true;
LLVMStyle.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
LLVMStyle.IndentGotoLabels = true;
LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3167,8 +3167,7 @@ void UnwrappedLineParser::parseNamespace() {
}

void UnwrappedLineParser::parseCppExportBlock() {
parseNamespaceOrExportBlock(/*AddLevels=*/Style.ExportBlockIndentation ? 1
: 0);
parseNamespaceOrExportBlock(/*AddLevels=*/Style.IndentExportBlock ? 1 : 0);
}

void UnwrappedLineParser::parseNew() {
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Format/ConfigParseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
CHECK_PARSE_BOOL(IndentAccessModifiers);
CHECK_PARSE_BOOL(IndentCaseBlocks);
CHECK_PARSE_BOOL(IndentCaseLabels);
CHECK_PARSE_BOOL(IndentExportBlock);
CHECK_PARSE_BOOL(IndentGotoLabels);
CHECK_PARSE_BOOL(IndentRequiresClause);
CHECK_PARSE_BOOL_FIELD(IndentRequiresClause, "IndentRequires");
Expand Down
8 changes: 4 additions & 4 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9059,9 +9059,9 @@ TEST_F(FormatTest, AdaptiveOnePerLineFormatting) {
Style);
}

TEST_F(FormatTest, ExportBlockIndentation) {
TEST_F(FormatTest, IndentExportBlock) {
FormatStyle Style = getLLVMStyleWithColumns(80);
Style.ExportBlockIndentation = true;
Style.IndentExportBlock = true;
verifyFormat("export {\n"
" int x;\n"
" int y;\n"
Expand All @@ -9072,7 +9072,7 @@ TEST_F(FormatTest, ExportBlockIndentation) {
"}",
Style);

Style.ExportBlockIndentation = false;
Style.IndentExportBlock = false;
verifyFormat("export {\n"
"int x;\n"
"int y;\n"
Expand All @@ -9086,7 +9086,7 @@ TEST_F(FormatTest, ExportBlockIndentation) {

TEST_F(FormatTest, ShortExportBlocks) {
FormatStyle Style = getLLVMStyleWithColumns(80);
Style.ExportBlockIndentation = false;
Style.IndentExportBlock = false;

Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
verifyFormat("export {\n"
Expand Down
Loading