[cfe-dev] clang-format version incompatibility

Renato Golin via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 14 13:17:08 PDT 2020


Hi folks,

A recent issue [1] on our Github project has highlighted a problem we've
been having with clang-format.

Basically, when using different versions of clang-format, with the same
configuration files [2], we get different results (between 9 and 10).

Previously, the main issue was new versions supported more stuff (ex.
AfterCaseLabel [3]) and old ones would not work, so we had to define a
minimal version, but newer versions of clang-format were supposed to yield
the same results based on the same configuration file.

Or perhaps, the default has changed and we didn't have a specific config?
If so, the fix is easy, just add the option to the config file. If not,
we'll have to continue hard-coding clang-format-9 in the CMake, which is
not practical as more people try to build it.

Examples:

https://github.com/microsoft/verona/blob/master/src/mlir/dialect/Typechecker.cc#L79

clang-format-9:
    Rule(F f)
      ->Rule<
        typename rule_traits<decltype(&F::operator())>::Left,
        typename rule_traits<decltype(&F::operator())>::Right,
        F>;

clang-format-10:
    Rule(F f) -> Rule<
      typename rule_traits<decltype(&F::operator())>::Left,
      typename rule_traits<decltype(&F::operator())>::Right,
      F>;

https://github.com/microsoft/verona/blob/master/src/mlir/dialect/VeronaTypes.cc#L487

clang-format-9:
      return {MeetType::get(ctx, readElements),
              JoinType::get(ctx, writeElements)};

clang-format-10:
      return {
        MeetType::get(ctx, readElements), JoinType::get(ctx,
writeElements)};

https://github.com/microsoft/verona/blob/master/src/mlir/dialect/VeronaTypes.cc#L513

clang-format-9:
    return {JoinType::get(ctx, readElements),
            MeetType::get(ctx, writeElements)};

clang-format-10:
    return {
      JoinType::get(ctx, readElements), MeetType::get(ctx, writeElements)};

thanks!
--renato

[1] https://github.com/microsoft/verona/issues/324
[2] https://github.com/microsoft/verona/blob/master/.clang-format
[3] https://github.com/microsoft/verona/blob/master/CMakeLists.txt#L19
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201014/7e69f709/attachment.html>


More information about the cfe-dev mailing list