[clang-format] version 17 trips up on templated base class uniform initialization.
Running clang-format test.cpp (i.e. default style rules) with version 17 on the following reproducer:
template <int Dim>
struct Base{};
template <int Dim>
struct Derived : public Base<Dim>{
Derived() : Base<Dim>{} {
// Derived ctor impl
}
};
produces:
template <int Dim> struct Base {};
template <int Dim> struct Derived : public Base<Dim> {
Derived() : Base<Dim> {}
{
// Derived ctor impl
}
};
but it ought to produce:
template <int Dim> struct Base {};
template <int Dim> struct Derived : public Base<Dim> {
Derived() : Base<Dim>{} {
// Derived ctor impl
}
};
Version 16 produces this correct output.
I played around with this reproducer a little. I think its the combination of the <Dim> template argument and the {} uniform initialization of the derived class which is confusing clang-format. Removing the former or replacing the latter with () produces expected output.
Both the versions mentioned here are from the downstream DPC++ project:
Working: clang-format version 17.0.0 (https://github.com/intel/llvm.git 21ca00fb1cc5408b2428e3c386aa5137ed551fdb)
Broken: clang-format version 16.0.0 (https://github.com/intel/llvm.git 751acf357ed192a2f9de5171ccdf4a69510cff37)
@llvm/issue-subscribers-clang-format
I've bisected this to 6dcde658b2380d7ca1451ea5d1099af3e294ea16
I've submitted a fix for review here: https://reviews.llvm.org/D156705
Sorry for the regression!
/cherry-pick
/cherry-pick 0a6c271
@owenca for next time - you need to specify the sha or multiple sha's with the command.
Failed to cherry-pick: 0a6c271
https://github.com/llvm/llvm-project/actions/runs/5900206633
Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:
/branch <user>/<repo>/<branch>
/cherry-pick 400da11
/cherry-pick 0a6c271
@owenca for next time - you need to specify the sha or multiple sha's with the command.
Oops! Thanks for pointing out. Fixed above.
/branch llvm/llvm-project-release-prs/issue64134
Failed to cherry-pick: 0a6c271
https://github.com/llvm/llvm-project/actions/runs/5900335578
Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:
/branch <user>/<repo>/<branch>
/pull-request llvm/llvm-project-release-prs#607