diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -62,7 +62,7 @@ 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, @@ -105,7 +105,7 @@ 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[] = @@ -138,116 +138,18 @@ /// \version 13 ArrayInitializerAlignmentStyle AlignArrayOfStructures; - /// Alignment options. - /// - /// They can also be read as a whole for compatibility. The choices are: - /// - None - /// - Consecutive - /// - AcrossEmptyLines - /// - AcrossComments - /// - AcrossEmptyLinesAndComments - /// - /// For example, to align across empty lines and not across comments, either - /// of these work. - /// \code - /// AlignConsecutiveMacros: AcrossEmptyLines - /// - /// AlignConsecutiveMacros: - /// Enabled: true - /// AcrossEmptyLines: true - /// AcrossComments: false - /// \endcode - struct AlignConsecutiveStyle { - /// Whether aligning is enabled. - /// \code - /// #define SHORT_NAME 42 - /// #define LONGER_NAME 0x007f - /// #define EVEN_LONGER_NAME (2) - /// #define foo(x) (x * x) - /// #define bar(y, z) (y + z) - /// - /// int a = 1; - /// int somelongname = 2; - /// double c = 3; - /// - /// int aaaa : 1; - /// int b : 12; - /// int ccc : 8; - /// - /// int aaaa = 12; - /// float b = 23; - /// std::string ccc; - /// \endcode - bool Enabled; - /// Whether to align across empty lines. - /// \code - /// true: - /// int a = 1; - /// int somelongname = 2; - /// double c = 3; - /// - /// int d = 3; - /// - /// false: - /// int a = 1; - /// int somelongname = 2; - /// double c = 3; - /// - /// int d = 3; - /// \endcode - bool AcrossEmptyLines; - /// Whether to align across comments. - /// \code - /// true: - /// int d = 3; - /// /* A comment. */ - /// double e = 4; - /// - /// false: - /// int d = 3; - /// /* A comment. */ - /// double e = 4; - /// \endcode - bool AcrossComments; - /// Only for ``AlignConsecutiveAssignments``. Whether compound assignments - /// like ``+=`` are aligned along with ``=``. - /// \code - /// true: - /// a &= 2; - /// bbb = 2; - /// - /// false: - /// a &= 2; - /// bbb = 2; - /// \endcode - bool AlignCompound; - /// Only for ``AlignConsecutiveAssignments``. Whether short assignment - /// operators are left-padded to the same length as long ones in order to - /// put all assignment operators to the right of the left hand side. - /// \code - /// true: - /// a >>= 2; - /// bbb = 2; - /// - /// a = 2; - /// bbb >>= 2; - /// - /// false: - /// a >>= 2; - /// bbb = 2; - /// - /// a = 2; - /// bbb >>= 2; - /// \endcode - bool PadOperators; - bool operator==(const AlignConsecutiveStyle &R) const { - return Enabled == R.Enabled && AcrossEmptyLines == R.AcrossEmptyLines && - AcrossComments == R.AcrossComments && - AlignCompound == R.AlignCompound && PadOperators == R.PadOperators; - } - bool operator!=(const AlignConsecutiveStyle &R) const { - return !(*this == R); - } + /// Styles for alignment of consecutive tokens. Tokens can be assignment signs + /// (see + /// ``AlignConsecutiveAssignments``), bitfield member separators (see + /// ``AlignConsecutiveBitFields``), names in declarations (see + /// ``AlignConsecutiveDeclarations``) or macro definitions (see + /// ``AlignConsecutiveMacros``). + enum AlignConsecutiveStyle : int8_t { + ACS_None, + ACS_Consecutive, + ACS_AcrossEmptyLines, + ACS_AcrossComments, + ACS_AcrossEmptyLinesAndComments }; /// Style of aligning consecutive macro definitions. @@ -296,7 +198,7 @@ AlignConsecutiveStyle AlignConsecutiveDeclarations; /// Different styles for aligning escaped newlines. - enum EscapedNewlineAlignmentStyle : unsigned char { + enum EscapedNewlineAlignmentStyle : int8_t { /// Don't align escaped newlines. /// \code /// #define A \ @@ -331,7 +233,7 @@ 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. @@ -434,7 +336,7 @@ /// 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) { @@ -481,7 +383,7 @@ /// 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", @@ -533,7 +435,7 @@ 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) @@ -605,7 +507,7 @@ /// 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. @@ -644,7 +546,7 @@ /// 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, @@ -656,7 +558,7 @@ /// 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 @@ -750,7 +652,7 @@ 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 @@ -828,7 +730,7 @@ 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 @@ -874,7 +776,7 @@ /// 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. @@ -884,7 +786,7 @@ }; /// The style of breaking before or after binary operators. - enum BinaryOperatorStyle : unsigned char { + enum BinaryOperatorStyle : int8_t { /// Break after operators. /// \code /// LooooooooooongType loooooooooooooooooooooongVariable = @@ -928,7 +830,7 @@ 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 { @@ -1363,7 +1265,7 @@ 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()) { @@ -1641,7 +1543,7 @@ 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 concept C = ...; @@ -1680,7 +1582,7 @@ 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() @@ -1752,7 +1654,7 @@ 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 @@ -1820,7 +1722,7 @@ std::vector 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 @@ -1947,7 +1849,7 @@ /// 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 { @@ -1996,7 +1898,7 @@ 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 { @@ -2072,7 +1974,7 @@ 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() @@ -2317,7 +2219,7 @@ bool IndentGotoLabels; /// Options for indenting preprocessor directives. - enum PPDirectiveIndentStyle : unsigned char { + enum PPDirectiveIndentStyle : int8_t { /// Does not indent any directives. /// \code /// #if FOO @@ -2352,7 +2254,7 @@ PPDirectiveIndentStyle IndentPPDirectives; /// Indents extern blocks - enum IndentExternBlockStyle : unsigned char { + enum IndentExternBlockStyle : int8_t { /// Backwards compatible with AfterExternBlock's indenting. /// \code /// IndentExternBlock: AfterExternBlock @@ -2509,7 +2411,7 @@ /// 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"; @@ -2567,7 +2469,7 @@ /// 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++. @@ -2601,7 +2503,7 @@ 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( @@ -2681,7 +2583,7 @@ unsigned MaxEmptyLinesToKeep; /// Different ways to indent namespace contents. - enum NamespaceIndentationKind : unsigned char { + enum NamespaceIndentationKind : int8_t { /// Don't indent in namespaces. /// \code /// namespace out { @@ -2839,7 +2741,7 @@ unsigned PenaltyIndentedWhitespace; /// The ``&``, ``&&`` and ``*`` alignment style. - enum PointerAlignmentStyle : unsigned char { + enum PointerAlignmentStyle : int8_t { /// Align pointer to the left. /// \code /// int* a; @@ -2937,7 +2839,7 @@ std::vector RawStringFormats; /// \brief The ``&`` and ``&&`` alignment style. - enum ReferenceAlignmentStyle { + enum ReferenceAlignmentStyle : int8_t { /// Align reference like ``PointerAlignment``. RAS_Pointer, /// Align reference to the left. @@ -3036,7 +2938,7 @@ /// \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 @@ -3115,7 +3017,7 @@ 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. @@ -3195,7 +3097,7 @@ unsigned ShortNamespaceLines; /// Include sorting options. - enum SortIncludesOptions : unsigned char { + enum SortIncludesOptions : int8_t { /// Includes are never sorted. /// \code /// #include "B/A.h" @@ -3235,7 +3137,7 @@ 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; @@ -3300,7 +3202,7 @@ 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 @@ -3381,7 +3283,7 @@ 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() { @@ -3612,7 +3514,7 @@ /// 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(arg); @@ -3731,7 +3633,7 @@ 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; @@ -3767,7 +3669,7 @@ /// /// 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 @@ -3816,7 +3718,7 @@ 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.