This code formats poorly: namespace n { void foo() { { { { statement(); if (false) { } } } { } } } } Formatter output (default settings, HEAD, reproduced here: https://zed0.co.uk/clang-format-configurator/): namespace n { void foo() { { {{statement(); if (false) { } } } {} } } }
I think more worrying is that this get the namespace matching incorrect unless I'm mistaken it thinks the namespace is the first scope level inside the foo() namespace n { void foo() { { <<<--- namespace } match to the { {{statement(); if (false) { } } } {} } // namespace n } } I'm not saying I can explain what is going on here, other than clang-format must be confused. Doing some experiments to try and break it down, we know this is good namespace n { void foo() { { statement(); if (false) { } } } // namespace n And this namespace n { void foo() { { { statement(); if (false) { } } } } // namespace n Even this is good namespace n { void foo() { { { statement(); if (false) { } } {} } } // namespace n but this namespace n { void foo() { { { statement(); if (false) { } } } {} } // namespace n would produce this.. namespace n { void foo() { {{statement(); if (false) { } } } {} } // namespace n To reduce it more I think the if is irrelevant namespace n { void foo(){{statement(); } } {} } // namespace n This probably needs a greater looks