Skip to content

clang-format 14 and 15 producing incompatible formatted code #59062

@lucasperin

Description

@lucasperin

I have noticed that my CI using clang-format 14 cannot validate the code I format with clang-format 15. This is an issue since the CI will block PRs that are not well formatted.

Consider the two examples of code below that will be formatted differently when using Google style formatting.

clang-format 14

typedef const struct { int32_t vec32[4]; } data_t;

#define TEST_CASE(test_func)                                                   \
  { #test_func, test_func, NULL, NULL, OPTION_NONE, NULL }

clang-format 15

typedef const struct {
  int32_t vec32[4];
} data_t;

#define TEST_CASE(test_func)                             \
  {                                                      \
#test_func, test_func, NULL, NULL, OPTION_NONE, NULL \
  }

I use this website to confirm and reproduce the issue
https://clang-format-configurator.site/

I have also tried clang-format --style=Google --dump-config to diff the style file from both versions, but I cannot find a way to make both versions compatible. Perhaps there is an option missing similar to the other AllowShort... so that structs can be declared in a single line or not, for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatobsoleteIssues with old (unsupported) versions of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions