nit: This is a case of clang-format failing to understand what is happening inside a macro.
https://releases.llvm.org/17.0.1/tools/clang/docs/ClangFormatStyleOptions.html#cpp11bracedliststyle
https://github.com/bitcoin/bitcoin/blob/fada379589a17e86396aa7c2ce458ff2ff602b84/src/.clang-format#L87
If I in the same commit change this to…
0 throw NonFatalCheckError{"Unreachable code reached (non-fatal)", std::source_location::current()}
…and also add…
0void Func_NONFATAL_UNREACHABLE()
1{
2 throw NonFatalCheckError { "Unreachable code reached (non-fatal)", std::source_location::current() };
3}
Then run this afterwards…
0₿ git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
…it results in:
0 #define NONFATAL_UNREACHABLE() \
1- throw NonFatalCheckError{"Unreachable code reached (non-fatal)", std::source_location::current()}
2+ throw NonFatalCheckError { "Unreachable code reached (non-fatal)", std::source_location::current() }
3
4 void Func_NONFATAL_UNREACHABLE()
5 {
6- throw NonFatalCheckError { "Unreachable code reached (non-fatal)", std::source_location::current() };
7+ throw NonFatalCheckError{"Unreachable code reached (non-fatal)", std::source_location::current()};
8 }
Proving what clang-format is aiming to do when it better understands the context. (I’m running 19.1.7 which seems to have the same behavior as PR author’s).