Skip to content

Commit

Permalink
Revert "[clang-format] Add AlignConsecutiveShortCaseStatements"
Browse files Browse the repository at this point in the history
This reverts commit 4ba0084.
  • Loading branch information
owenca committed Jul 25, 2023
1 parent 1a3da0b commit 87ad34f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 569 deletions.
98 changes: 0 additions & 98 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -789,104 +789,6 @@ the configuration (without a prefix: ``Auto``).
bbb >>= 2;


.. _AlignConsecutiveShortCaseStatements:

**AlignConsecutiveShortCaseStatements** (``ShortCaseStatementsAlignmentStyle``) :versionbadge:`clang-format 17` :ref:`<AlignConsecutiveShortCaseStatements>`
Style of aligning consecutive short case labels.
Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.


.. code-block:: yaml
# Example of usage:
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
Nested configuration flags:

Alignment options.

* ``bool Enabled`` Whether aligning is enabled.

.. code-block:: c++

true:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";
default: return "";
}

false:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";
default: return "";
}

* ``bool AcrossEmptyLines`` Whether to align across empty lines.

.. code-block:: c++

true:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";

default: return "";
}

false:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";

default: return "";
}

* ``bool AcrossComments`` Whether to align across comments.

.. code-block:: c++

true:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";
/* A comment. */
default: return "";
}
false:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";
/* A comment. */
default: return "";
}
* ``bool AlignCaseColons`` Whether aligned case labels are aligned on the colon, or on the
, or on the tokens after the colon.

.. code-block:: c++

true:
switch (level) {
case log::info : return "info:";
case log::warning: return "warning:";
default : return "";
}

false:
switch (level) {
case log::info: return "info:";
case log::warning: return "warning:";
default: return "";
}


.. _AlignEscapedNewlines:

**AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) :versionbadge:`clang-format 5` :ref:`<AlignEscapedNewlines>`
Expand Down
2 changes: 0 additions & 2 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,6 @@ clang-format
- Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file.
- Add ``RemoveParentheses`` to remove redundant parentheses.
- Add ``TypeNames`` to treat listed non-keyword identifiers as type names.
- Add ``AlignConsecutiveShortCaseStatements`` which can be used to align case
labels in conjunction with ``AllowShortCaseLabelsOnASingleLine``.

libclang
--------
Expand Down
99 changes: 0 additions & 99 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,103 +299,6 @@ struct FormatStyle {
/// \version 3.8
AlignConsecutiveStyle AlignConsecutiveDeclarations;

/// Alignment options.
///
struct ShortCaseStatementsAlignmentStyle {
/// Whether aligning is enabled.
/// \code
/// true:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
/// default: return "";
/// }
///
/// false:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
/// default: return "";
/// }
/// \endcode
bool Enabled;
/// Whether to align across empty lines.
/// \code
/// true:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
///
/// default: return "";
/// }
///
/// false:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
///
/// default: return "";
/// }
/// \endcode
bool AcrossEmptyLines;
/// Whether to align across comments.
/// \code
/// true:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
/// /* A comment. */
/// default: return "";
/// }
///
/// false:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
/// /* A comment. */
/// default: return "";
/// }
/// \endcode
bool AcrossComments;
/// Whether aligned case labels are aligned on the colon, or on the
/// , or on the tokens after the colon.
/// \code
/// true:
/// switch (level) {
/// case log::info : return "info:";
/// case log::warning: return "warning:";
/// default : return "";
/// }
///
/// false:
/// switch (level) {
/// case log::info: return "info:";
/// case log::warning: return "warning:";
/// default: return "";
/// }
/// \endcode
bool AlignCaseColons;
bool operator==(const ShortCaseStatementsAlignmentStyle &R) const {
return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines &&
AcrossComments == R.AcrossComments &&
AlignCaseColons == R.AlignCaseColons;
}
};

/// Style of aligning consecutive short case labels.
/// Only applies if ``AllowShortCaseLabelsOnASingleLine`` is ``true``.
///
/// \code{.yaml}
/// # Example of usage:
/// AlignConsecutiveShortCaseStatements:
/// Enabled: true
/// AcrossEmptyLines: true
/// AcrossComments: true
/// AlignCaseColons: false
/// \endcode
/// \version 17
ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements;

/// Different styles for aligning escaped newlines.
enum EscapedNewlineAlignmentStyle : int8_t {
/// Don't align escaped newlines.
Expand Down Expand Up @@ -4454,8 +4357,6 @@ struct FormatStyle {
AlignConsecutiveBitFields == R.AlignConsecutiveBitFields &&
AlignConsecutiveDeclarations == R.AlignConsecutiveDeclarations &&
AlignConsecutiveMacros == R.AlignConsecutiveMacros &&
AlignConsecutiveShortCaseStatements ==
R.AlignConsecutiveShortCaseStatements &&
AlignEscapedNewlines == R.AlignEscapedNewlines &&
AlignOperands == R.AlignOperands &&
AlignTrailingComments == R.AlignTrailingComments &&
Expand Down
14 changes: 0 additions & 14 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,6 @@ template <> struct MappingTraits<FormatStyle::AlignConsecutiveStyle> {
}
};

template <>
struct MappingTraits<FormatStyle::ShortCaseStatementsAlignmentStyle> {
static void mapping(IO &IO,
FormatStyle::ShortCaseStatementsAlignmentStyle &Value) {
IO.mapOptional("Enabled", Value.Enabled);
IO.mapOptional("AcrossEmptyLines", Value.AcrossEmptyLines);
IO.mapOptional("AcrossComments", Value.AcrossComments);
IO.mapOptional("AlignCaseColons", Value.AlignCaseColons);
}
};

template <>
struct ScalarEnumerationTraits<FormatStyle::AttributeBreakingStyle> {
static void enumeration(IO &IO, FormatStyle::AttributeBreakingStyle &Value) {
Expand Down Expand Up @@ -868,8 +857,6 @@ template <> struct MappingTraits<FormatStyle> {
IO.mapOptional("AlignConsecutiveDeclarations",
Style.AlignConsecutiveDeclarations);
IO.mapOptional("AlignConsecutiveMacros", Style.AlignConsecutiveMacros);
IO.mapOptional("AlignConsecutiveShortCaseStatements",
Style.AlignConsecutiveShortCaseStatements);
IO.mapOptional("AlignEscapedNewlines", Style.AlignEscapedNewlines);
IO.mapOptional("AlignOperands", Style.AlignOperands);
IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments);
Expand Down Expand Up @@ -1346,7 +1333,6 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.AlignConsecutiveBitFields = {};
LLVMStyle.AlignConsecutiveDeclarations = {};
LLVMStyle.AlignConsecutiveMacros = {};
LLVMStyle.AlignConsecutiveShortCaseStatements = {};
LLVMStyle.AlignTrailingComments = {};
LLVMStyle.AlignTrailingComments.Kind = FormatStyle::TCAS_Always;
LLVMStyle.AlignTrailingComments.OverEmptyLines = 0;
Expand Down

0 comments on commit 87ad34f

Please sign in to comment.