HomePhabricator

[clang-format] Fixed typedef enum brace wrapping

Description

[clang-format] Fixed typedef enum brace wrapping

Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - Typedef enum part

Problem:

Clang format does not allow the flag BraceWrapping.AfterEnum control the case when our enum is preceded by typedef keyword (what is common in C language).

Patch description:

Added case to the "AfterEnum" flag when our enum does not start a line - is preceded by typedef keyword.

After fix:

CONFIG:

BreakBeforeBraces: Custom
BraceWrapping: {
AfterClass: true, AfterControlStatement: true, AfterEnum: true, AfterFunction: true, AfterNamespace: false, AfterStruct: true, AfterUnion: true, BeforeCatch: true, BeforeElse: true
}

BEFORE:

typedef enum
{
    a,
    b,
    c
} SomeEnum;

AFTER:

typedef enum
{
    a,
    b,
    c
} SomeEnum;

Contributed by @PriMee!

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D37143

Details