Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - "extern C part"
Problem:
Due to the lack of "brace wrapping extern" flag, clang format does parse the block after extern keyword moving the opening bracket to the header line always!
Patch description:
Added if statement handling the case when our "extern block" has the opening bracket in "non-header" line. Then forcing break before bracket.
After fix:
CONFIG:
BreakBeforeBraces: Custom BraceWrapping: { AfterClass: true, AfterControlStatement: true, AfterEnum: true, AfterFunction: true, AfterNamespace: false, AfterStruct: true, AfterUnion: true, BeforeCatch: true, BeforeElse: true }
BEFORE:
extern "C" { #include <SomeInclude.h> }
AFTER:
extern "C" { #include <SomeInclude.h> }
Remains the same!
There is no brace wrapping flag that let us control opening brace's position. In case of other keywords (class, function, control statement etc.) we have opportunity to decide how should it look like. Here, we can't do it similarly. What we want is leaving braces unformatted (leave them as in the input), but what's more we still want to call parseBlock function. The only option is to set MustBreakBefore flag manually (only when needed, when the left brace is on non-header line, parseBlock does move it by default).