Skip to content

[clang-format] Linebreaks and indentation change when updating from v18.1.8 -> v19.1.5 #117477

@RainerKuemmerle

Description

@RainerKuemmerle

I noticed that in my code, clang-format v19.1.5 behaves very different with the same settings.

An excerpt from the formatting changes.

v18.1.8

namespace g2o {

class G2O_STUFF_API Sampler {
 public:
  /** seed the random number generator */
  static void seedRand(unsigned int seed) {
    std::srand(seed);
  }
};

}  // namespace g2o
...

v19.1.5

namespace g2o {

class G2O_STUFF_API
Sampler{public :
            /** seed the random number generator */
            static void seedRand(unsigned int seed){std::srand(seed);
}
}
;

}  // namespace g2o

The .clang-format file is

BasedOnStyle: Google
DerivePointerAlignment: false

I noticed that formatting stays kind of as expected if I do not close the class definition by }; but just } which is non working syntax however.

Locally I am using Ubuntu 24.10 with apt.llvm.org as additional package source.

$ clang-format --version
Ubuntu clang-format version 19.1.5 (++20241119043710+51dee6b64fda-1~exp1~20241119163724.28)

The same effect can however also be seen when using the pre-commit framework (with a slightly older version of clang-format), e.g., as in this PR of my project:
https://github.com/RainerKuemmerle/g2o/pull/837/files

Please let me know if I should provide additional information. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions