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...
throw NonFatalCheckError{"Unreachable code reached (non-fatal)", std::source_location::current()}
...and also add...
void Func_NONFATAL_UNREACHABLE()
{
throw NonFatalCheckError { "Unreachable code reached (non-fatal)", std::source_location::current() };
}
Then run this afterwards...
₿ git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
...it results in:
#define NONFATAL_UNREACHABLE() \
- throw NonFatalCheckError{"Unreachable code reached (non-fatal)", std::source_location::current()}
+ throw NonFatalCheckError { "Unreachable code reached (non-fatal)", std::source_location::current() }
void Func_NONFATAL_UNREACHABLE()
{
- throw NonFatalCheckError { "Unreachable code reached (non-fatal)", std::source_location::current() };
+ throw NonFatalCheckError{"Unreachable code reached (non-fatal)", std::source_location::current()};
}
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).