Skip to content

Commit

Permalink
[format] Use int8_t as the underlying type of all enums in FormatStyle
Browse files Browse the repository at this point in the history
It was requested here (https://reviews.llvm.org/D120398#3353053) to make
the underlying type of all enums in `FormatStyle` an `int8_t`.

Originally the type was changed in https://reviews.llvm.org/D93758.

Reviewed By: HazardyKnusperkeks, curdeius, owenpan

Differential Revision: https://reviews.llvm.org/D120884
  • Loading branch information
kwk committed Mar 21, 2022
1 parent f8a32f3 commit 063bd3b
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions clang/include/clang/Format/Format.h
Expand Up @@ -62,7 +62,7 @@ struct FormatStyle {
int AccessModifierOffset;

/// Different styles for aligning after open brackets.
enum BracketAlignmentStyle : unsigned char {
enum BracketAlignmentStyle : int8_t {
/// Align parameters on the open bracket, e.g.:
/// \code
/// someLongFunction(argument1,
Expand Down Expand Up @@ -105,7 +105,7 @@ struct FormatStyle {
BracketAlignmentStyle AlignAfterOpenBracket;

/// Different style for aligning array initializers.
enum ArrayInitializerAlignmentStyle {
enum ArrayInitializerAlignmentStyle : int8_t {
/// Align array column and left justify the columns e.g.:
/// \code
/// struct test demo[] =
Expand Down Expand Up @@ -296,7 +296,7 @@ struct FormatStyle {
AlignConsecutiveStyle AlignConsecutiveDeclarations;

/// Different styles for aligning escaped newlines.
enum EscapedNewlineAlignmentStyle : unsigned char {
enum EscapedNewlineAlignmentStyle : int8_t {
/// Don't align escaped newlines.
/// \code
/// #define A \
Expand Down Expand Up @@ -331,7 +331,7 @@ struct FormatStyle {
EscapedNewlineAlignmentStyle AlignEscapedNewlines;

/// Different styles for aligning operands.
enum OperandAlignmentStyle : unsigned char {
enum OperandAlignmentStyle : int8_t {
/// Do not align operands of binary and ternary expressions.
/// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
/// the start of the line.
Expand Down Expand Up @@ -434,7 +434,7 @@ struct FormatStyle {

/// Different styles for merging short blocks containing at most one
/// statement.
enum ShortBlockStyle : unsigned char {
enum ShortBlockStyle : int8_t {
/// Never merge blocks into a single line.
/// \code
/// while (true) {
Expand Down Expand Up @@ -481,7 +481,7 @@ struct FormatStyle {

/// Different styles for merging short functions containing at most one
/// statement.
enum ShortFunctionStyle : unsigned char {
enum ShortFunctionStyle : int8_t {
/// Never merge functions into a single line.
SFS_None,
/// Only merge functions defined inside a class. Same as "inline",
Expand Down Expand Up @@ -533,7 +533,7 @@ struct FormatStyle {
ShortFunctionStyle AllowShortFunctionsOnASingleLine;

/// Different styles for handling short if statements.
enum ShortIfStyle : unsigned char {
enum ShortIfStyle : int8_t {
/// Never put short ifs on the same line.
/// \code
/// if (a)
Expand Down Expand Up @@ -605,7 +605,7 @@ struct FormatStyle {

/// Different styles for merging short lambdas containing at most one
/// statement.
enum ShortLambdaStyle : unsigned char {
enum ShortLambdaStyle : int8_t {
/// Never merge lambdas into a single line.
SLS_None,
/// Only merge empty lambdas.
Expand Down Expand Up @@ -644,7 +644,7 @@ struct FormatStyle {

/// Different ways to break after the function definition return type.
/// This option is **deprecated** and is retained for backwards compatibility.
enum DefinitionReturnTypeBreakingStyle : unsigned char {
enum DefinitionReturnTypeBreakingStyle : int8_t {
/// Break after return type automatically.
/// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
DRTBS_None,
Expand All @@ -656,7 +656,7 @@ struct FormatStyle {

/// Different ways to break after the function definition or
/// declaration return type.
enum ReturnTypeBreakingStyle : unsigned char {
enum ReturnTypeBreakingStyle : int8_t {
/// Break after return type automatically.
/// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
/// \code
Expand Down Expand Up @@ -750,7 +750,7 @@ struct FormatStyle {
bool AlwaysBreakBeforeMultilineStrings;

/// Different ways to break after the template declaration.
enum BreakTemplateDeclarationsStyle : unsigned char {
enum BreakTemplateDeclarationsStyle : int8_t {
/// Do not force break before declaration.
/// ``PenaltyBreakTemplateDeclaration`` is taken into account.
/// \code
Expand Down Expand Up @@ -828,7 +828,7 @@ struct FormatStyle {
bool BinPackArguments;

/// The style of inserting trailing commas into container literals.
enum TrailingCommaStyle : unsigned char {
enum TrailingCommaStyle : int8_t {
/// Do not insert trailing commas.
TCS_None,
/// Insert trailing commas in container literals that were wrapped over
Expand Down Expand Up @@ -874,7 +874,7 @@ struct FormatStyle {

/// The style of wrapping parameters on the same line (bin-packed) or
/// on one line each.
enum BinPackStyle : unsigned char {
enum BinPackStyle : int8_t {
/// Automatically determine parameter bin-packing behavior.
BPS_Auto,
/// Always bin-pack parameters.
Expand All @@ -884,7 +884,7 @@ struct FormatStyle {
};

/// The style of breaking before or after binary operators.
enum BinaryOperatorStyle : unsigned char {
enum BinaryOperatorStyle : int8_t {
/// Break after operators.
/// \code
/// LooooooooooongType loooooooooooooooooooooongVariable =
Expand Down Expand Up @@ -928,7 +928,7 @@ struct FormatStyle {
BinaryOperatorStyle BreakBeforeBinaryOperators;

/// Different ways to attach braces to their surrounding context.
enum BraceBreakingStyle : unsigned char {
enum BraceBreakingStyle : int8_t {
/// Always attach braces to surrounding context.
/// \code
/// namespace N {
Expand Down Expand Up @@ -1363,7 +1363,7 @@ struct FormatStyle {
BraceBreakingStyle BreakBeforeBraces;

/// Different ways to wrap braces after control statements.
enum BraceWrappingAfterControlStatementStyle : unsigned char {
enum BraceWrappingAfterControlStatementStyle : int8_t {
/// Never wrap braces after a control statement.
/// \code
/// if (foo()) {
Expand Down Expand Up @@ -1641,7 +1641,7 @@ struct FormatStyle {
BraceWrappingFlags BraceWrapping;

/// Different ways to break before concept declarations.
enum BreakBeforeConceptDeclarationsStyle {
enum BreakBeforeConceptDeclarationsStyle : int8_t {
/// Keep the template declaration line together with ``concept``.
/// \code
/// template <typename T> concept C = ...;
Expand Down Expand Up @@ -1680,7 +1680,7 @@ struct FormatStyle {
bool BreakBeforeTernaryOperators;

/// Different ways to break initializers.
enum BreakConstructorInitializersStyle : unsigned char {
enum BreakConstructorInitializersStyle : int8_t {
/// Break constructor initializers before the colon and after the commas.
/// \code
/// Constructor()
Expand Down Expand Up @@ -1752,7 +1752,7 @@ struct FormatStyle {
std::string CommentPragmas;

/// Different specifiers and qualifiers alignment styles.
enum QualifierAlignmentStyle {
enum QualifierAlignmentStyle : int8_t {
/// Don't change specifiers/qualifiers to either Left or Right alignment
/// (default).
/// \code
Expand Down Expand Up @@ -1820,7 +1820,7 @@ struct FormatStyle {
std::vector<std::string> QualifierOrder;

/// Different ways to break inheritance list.
enum BreakInheritanceListStyle : unsigned char {
enum BreakInheritanceListStyle : int8_t {
/// Break inheritance list before the colon and after the commas.
/// \code
/// class Foo
Expand Down Expand Up @@ -1947,7 +1947,7 @@ struct FormatStyle {
/// Different styles for empty line after access modifiers.
/// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
/// empty lines between two access modifiers.
enum EmptyLineAfterAccessModifierStyle : unsigned char {
enum EmptyLineAfterAccessModifierStyle : int8_t {
/// Remove all empty lines after access modifiers.
/// \code
/// struct foo {
Expand Down Expand Up @@ -1996,7 +1996,7 @@ struct FormatStyle {
EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;

/// Different styles for empty line before access modifiers.
enum EmptyLineBeforeAccessModifierStyle : unsigned char {
enum EmptyLineBeforeAccessModifierStyle : int8_t {
/// Remove all empty lines before access modifiers.
/// \code
/// struct foo {
Expand Down Expand Up @@ -2072,7 +2072,7 @@ struct FormatStyle {
bool ExperimentalAutoDetectBinPacking;

/// Different ways to try to fit all constructor initializers on a line.
enum PackConstructorInitializersStyle : unsigned char {
enum PackConstructorInitializersStyle : int8_t {
/// Always put each constructor initializer on its own line.
/// \code
/// Constructor()
Expand Down Expand Up @@ -2317,7 +2317,7 @@ struct FormatStyle {
bool IndentGotoLabels;

/// Options for indenting preprocessor directives.
enum PPDirectiveIndentStyle : unsigned char {
enum PPDirectiveIndentStyle : int8_t {
/// Does not indent any directives.
/// \code
/// #if FOO
Expand Down Expand Up @@ -2352,7 +2352,7 @@ struct FormatStyle {
PPDirectiveIndentStyle IndentPPDirectives;

/// Indents extern blocks
enum IndentExternBlockStyle : unsigned char {
enum IndentExternBlockStyle : int8_t {
/// Backwards compatible with AfterExternBlock's indenting.
/// \code
/// IndentExternBlock: AfterExternBlock
Expand Down Expand Up @@ -2509,7 +2509,7 @@ struct FormatStyle {

/// Quotation styles for JavaScript strings. Does not affect template
/// strings.
enum JavaScriptQuoteStyle : unsigned char {
enum JavaScriptQuoteStyle : int8_t {
/// Leave string quotes as they are.
/// \code{.js}
/// string1 = "foo";
Expand Down Expand Up @@ -2567,7 +2567,7 @@ struct FormatStyle {
/// When stored in a configuration file, specifies the language, that the
/// configuration targets. When passed to the ``reformat()`` function, enables
/// syntax features specific to the language.
enum LanguageKind : unsigned char {
enum LanguageKind : int8_t {
/// Do not use.
LK_None,
/// Should be used for C, C++.
Expand Down Expand Up @@ -2601,7 +2601,7 @@ struct FormatStyle {
LanguageKind Language;

/// Indentation logic for lambda bodies.
enum LambdaBodyIndentationKind : unsigned char {
enum LambdaBodyIndentationKind : int8_t {
/// Align lambda body relative to the lambda signature. This is the default.
/// \code
/// someMethod(
Expand Down Expand Up @@ -2681,7 +2681,7 @@ struct FormatStyle {
unsigned MaxEmptyLinesToKeep;

/// Different ways to indent namespace contents.
enum NamespaceIndentationKind : unsigned char {
enum NamespaceIndentationKind : int8_t {
/// Don't indent in namespaces.
/// \code
/// namespace out {
Expand Down Expand Up @@ -2839,7 +2839,7 @@ struct FormatStyle {
unsigned PenaltyIndentedWhitespace;

/// The ``&``, ``&&`` and ``*`` alignment style.
enum PointerAlignmentStyle : unsigned char {
enum PointerAlignmentStyle : int8_t {
/// Align pointer to the left.
/// \code
/// int* a;
Expand Down Expand Up @@ -2937,7 +2937,7 @@ struct FormatStyle {
std::vector<RawStringFormat> RawStringFormats;

/// \brief The ``&`` and ``&&`` alignment style.
enum ReferenceAlignmentStyle {
enum ReferenceAlignmentStyle : int8_t {
/// Align reference like ``PointerAlignment``.
RAS_Pointer,
/// Align reference to the left.
Expand Down Expand Up @@ -3036,7 +3036,7 @@ struct FormatStyle {
/// \brief The possible positions for the requires clause. The
/// ``IndentRequires`` option is only used if the ``requires`` is put on the
/// start of a line.
enum RequiresClausePositionStyle {
enum RequiresClausePositionStyle : int8_t {
/// Always put the ``requires`` clause on its own line.
/// \code
/// template <typename T>
Expand Down Expand Up @@ -3115,7 +3115,7 @@ struct FormatStyle {
RequiresClausePositionStyle RequiresClausePosition;

/// \brief The style if definition blocks should be separated.
enum SeparateDefinitionStyle {
enum SeparateDefinitionStyle : int8_t {
/// Leave definition blocks as they are.
SDS_Leave,
/// Insert an empty line between definition blocks.
Expand Down Expand Up @@ -3195,7 +3195,7 @@ struct FormatStyle {
unsigned ShortNamespaceLines;

/// Include sorting options.
enum SortIncludesOptions : unsigned char {
enum SortIncludesOptions : int8_t {
/// Includes are never sorted.
/// \code
/// #include "B/A.h"
Expand Down Expand Up @@ -3235,7 +3235,7 @@ struct FormatStyle {
SortIncludesOptions SortIncludes;

/// Position for Java Static imports.
enum SortJavaStaticImportOptions : unsigned char {
enum SortJavaStaticImportOptions : int8_t {
/// Static imports are placed before non-static imports.
/// \code{.java}
/// import static org.example.function1;
Expand Down Expand Up @@ -3300,7 +3300,7 @@ struct FormatStyle {
bool SpaceAfterTemplateKeyword;

/// Different ways to put a space before opening parentheses.
enum SpaceAroundPointerQualifiersStyle : unsigned char {
enum SpaceAroundPointerQualifiersStyle : int8_t {
/// Don't ensure spaces around pointer qualifiers and use PointerAlignment
/// instead.
/// \code
Expand Down Expand Up @@ -3381,7 +3381,7 @@ struct FormatStyle {
bool SpaceBeforeInheritanceColon;

/// Different ways to put a space before opening parentheses.
enum SpaceBeforeParensStyle : unsigned char {
enum SpaceBeforeParensStyle : int8_t {
/// Never put a space before opening parentheses.
/// \code
/// void f() {
Expand Down Expand Up @@ -3612,7 +3612,7 @@ struct FormatStyle {

/// Styles for adding spacing after ``<`` and before ``>`
/// in template argument lists.
enum SpacesInAnglesStyle : unsigned char {
enum SpacesInAnglesStyle : int8_t {
/// Remove spaces after ``<`` and before ``>``.
/// \code
/// static_cast<int>(arg);
Expand Down Expand Up @@ -3731,7 +3731,7 @@ struct FormatStyle {
bool SpaceBeforeSquareBrackets;

/// Styles for adding spacing around ``:`` in bitfield definitions.
enum BitFieldColonSpacingStyle : unsigned char {
enum BitFieldColonSpacingStyle : int8_t {
/// Add one space on each side of the ``:``
/// \code
/// unsigned bf : 2;
Expand Down Expand Up @@ -3767,7 +3767,7 @@ struct FormatStyle {
///
/// The correct way to spell a specific language version is e.g. ``c++11``.
/// The historical aliases ``Cpp03`` and ``Cpp11`` are deprecated.
enum LanguageStandard : unsigned char {
enum LanguageStandard : int8_t {
/// Parse and format as C++03.
/// ``Cpp03`` is a deprecated alias for ``c++03``
LS_Cpp03, // c++03
Expand Down Expand Up @@ -3816,7 +3816,7 @@ struct FormatStyle {
unsigned TabWidth;

/// Different ways to use tab in formatting.
enum UseTabStyle : unsigned char {
enum UseTabStyle : int8_t {
/// Never use tab.
UT_Never,
/// Use tabs only for indentation.
Expand Down

0 comments on commit 063bd3b

Please sign in to comment.