diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py --- a/clang/docs/tools/dump_format_style.py +++ b/clang/docs/tools/dump_format_style.py @@ -144,7 +144,7 @@ comment += clean_comment_line(line) elif line.startswith('enum'): state = State.InEnum - name = re.sub(r'enum\s+(\w+)\s*\{', '\\1', line) + name = re.sub(r'enum\s+(\w+)\s*(:((\s*\w+)+)\s*)?\{', '\\1', line) enum = Enum(name, comment) elif line.startswith('struct'): state = State.InNestedStruct 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 @@ -56,7 +56,7 @@ int AccessModifierOffset; /// Different styles for aligning after open brackets. - enum BracketAlignmentStyle { + enum BracketAlignmentStyle : unsigned char { /// Align parameters on the open bracket, e.g.: /// \code /// someLongFunction(argument1, @@ -131,7 +131,7 @@ bool AlignConsecutiveDeclarations; /// Different styles for aligning escaped newlines. - enum EscapedNewlineAlignmentStyle { + enum EscapedNewlineAlignmentStyle : unsigned char { /// Don't align escaped newlines. /// \code /// #define A \ @@ -165,7 +165,7 @@ EscapedNewlineAlignmentStyle AlignEscapedNewlines; /// Different styles for aligning operands. - enum OperandAlignmentStyle { + enum OperandAlignmentStyle : unsigned char { /// Do not align operands of binary and ternary expressions. /// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from /// the start of the line. @@ -275,7 +275,7 @@ /// Different styles for merging short blocks containing at most one /// statement. - enum ShortBlockStyle { + enum ShortBlockStyle : unsigned char { /// Never merge blocks into a single line. /// \code /// while (true) { @@ -320,7 +320,7 @@ /// Different styles for merging short functions containing at most one /// statement. - enum ShortFunctionStyle { + enum ShortFunctionStyle : unsigned char { /// Never merge functions into a single line. SFS_None, /// Only merge functions defined inside a class. Same as "inline", @@ -371,7 +371,7 @@ ShortFunctionStyle AllowShortFunctionsOnASingleLine; /// Different styles for handling short if lines - enum ShortIfStyle { + enum ShortIfStyle : unsigned char { /// Never put short ifs on the same line. /// \code /// if (a) @@ -405,7 +405,7 @@ /// Different styles for merging short lambdas containing at most one /// statement. - enum ShortLambdaStyle { + enum ShortLambdaStyle : unsigned char { /// Never merge lambdas into a single line. SLS_None, /// Only merge empty lambdas. @@ -442,7 +442,7 @@ /// Different ways to break after the function definition return type. /// This option is **deprecated** and is retained for backwards compatibility. - enum DefinitionReturnTypeBreakingStyle { + enum DefinitionReturnTypeBreakingStyle : unsigned char { /// Break after return type automatically. /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account. DRTBS_None, @@ -454,7 +454,7 @@ /// Different ways to break after the function definition or /// declaration return type. - enum ReturnTypeBreakingStyle { + enum ReturnTypeBreakingStyle : unsigned char { /// Break after return type automatically. /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account. /// \code @@ -545,7 +545,7 @@ bool AlwaysBreakBeforeMultilineStrings; /// Different ways to break after the template declaration. - enum BreakTemplateDeclarationsStyle { + enum BreakTemplateDeclarationsStyle : unsigned char { /// Do not force break before declaration. /// ``PenaltyBreakTemplateDeclaration`` is taken into account. /// \code @@ -620,7 +620,7 @@ bool BinPackArguments; /// The style of inserting trailing commas into container literals. - enum TrailingCommaStyle { + enum TrailingCommaStyle : unsigned char { /// Do not insert trailing commas. TCS_None, /// Insert trailing commas in container literals that were wrapped over @@ -664,7 +664,7 @@ /// The style of wrapping parameters on the same line (bin-packed) or /// on one line each. - enum BinPackStyle { + enum BinPackStyle : unsigned char { /// Automatically determine parameter bin-packing behavior. BPS_Auto, /// Always bin-pack parameters. @@ -674,7 +674,7 @@ }; /// The style of breaking before or after binary operators. - enum BinaryOperatorStyle { + enum BinaryOperatorStyle : unsigned char { /// Break after operators. /// \code /// LooooooooooongType loooooooooooooooooooooongVariable = @@ -717,7 +717,7 @@ BinaryOperatorStyle BreakBeforeBinaryOperators; /// Different ways to attach braces to their surrounding context. - enum BraceBreakingStyle { + enum BraceBreakingStyle : unsigned char { /// Always attach braces to surrounding context. /// \code /// namespace N { @@ -1151,7 +1151,7 @@ BraceBreakingStyle BreakBeforeBraces; /// Different ways to wrap braces after control statements. - enum BraceWrappingAfterControlStatementStyle { + enum BraceWrappingAfterControlStatementStyle : unsigned char { /// Never wrap braces after a control statement. /// \code /// if (foo()) { @@ -1450,7 +1450,7 @@ bool BreakBeforeTernaryOperators; /// Different ways to break initializers. - enum BreakConstructorInitializersStyle { + enum BreakConstructorInitializersStyle : unsigned char { /// Break constructor initializers before the colon and after the commas. /// \code /// Constructor() @@ -1517,7 +1517,7 @@ std::string CommentPragmas; /// Different ways to break inheritance list. - enum BreakInheritanceListStyle { + enum BreakInheritanceListStyle : unsigned char { /// Break inheritance list before the colon and after the commas. /// \code /// class Foo @@ -1816,7 +1816,7 @@ bool IndentPragmas; /// Options for indenting preprocessor directives. - enum PPDirectiveIndentStyle { + enum PPDirectiveIndentStyle : unsigned char { /// Does not indent any directives. /// \code /// #if FOO @@ -1850,7 +1850,7 @@ PPDirectiveIndentStyle IndentPPDirectives; /// Indents extern blocks - enum IndentExternBlockStyle { + enum IndentExternBlockStyle : unsigned char { /// Backwards compatible with AfterExternBlock's indenting. /// \code /// IndentExternBlock: AfterExternBlock @@ -1967,7 +1967,7 @@ /// Quotation styles for JavaScript strings. Does not affect template /// strings. - enum JavaScriptQuoteStyle { + enum JavaScriptQuoteStyle : unsigned char { /// Leave string quotes as they are. /// \code{.js} /// string1 = "foo"; @@ -2022,7 +2022,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 { + enum LanguageKind : unsigned char { /// Do not use. LK_None, /// Should be used for C, C++. @@ -2095,7 +2095,7 @@ unsigned MaxEmptyLinesToKeep; /// Different ways to indent namespace contents. - enum NamespaceIndentationKind { + enum NamespaceIndentationKind : unsigned char { /// Don't indent in namespaces. /// \code /// namespace out { @@ -2234,7 +2234,7 @@ unsigned PenaltyIndentedWhitespace; /// The ``&`` and ``*`` alignment style. - enum PointerAlignmentStyle { + enum PointerAlignmentStyle : unsigned char { /// Align pointer to the left. /// \code /// int* a; @@ -2339,7 +2339,7 @@ bool SortIncludes; /// Position for Java Static imports. - enum SortJavaStaticImportOptions { + enum SortJavaStaticImportOptions : unsigned char { /// Static imports are placed before non-static imports. /// \code{.java} /// import static org.example.function1; @@ -2399,7 +2399,7 @@ bool SpaceAfterTemplateKeyword; /// Different ways to put a space before opening parentheses. - enum SpaceAroundPointerQualifiersStyle { + enum SpaceAroundPointerQualifiersStyle : unsigned char { /// Don't ensure spaces around pointer qualifiers and use PointerAlignment /// instead. /// \code @@ -2465,7 +2465,7 @@ bool SpaceBeforeInheritanceColon; /// Different ways to put a space before opening parentheses. - enum SpaceBeforeParensOptions { + enum SpaceBeforeParensOptions : unsigned char { /// Never put a space before opening parentheses. /// \code /// void f() { @@ -2629,7 +2629,7 @@ bool SpaceBeforeSquareBrackets; /// Styles for adding spacing around ``:`` in bitfield definitions. - enum BitFieldColonSpacingStyle { + enum BitFieldColonSpacingStyle : unsigned char { /// Add one space on each side of the ``:`` /// \code /// unsigned bf : 2; @@ -2664,7 +2664,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 { + enum LanguageStandard : unsigned char { /// Parse and format as C++03. /// ``Cpp03`` is a deprecated alias for ``c++03`` LS_Cpp03, // c++03 @@ -2694,7 +2694,7 @@ unsigned TabWidth; /// Different ways to use tab in formatting. - enum UseTabStyle { + enum UseTabStyle : unsigned char { /// Never use tab. UT_Never, /// Use tabs only for indentation.