[cfe-dev] [clang-format] New line after multi-line if statements

Kim Walisch via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 19 02:51:41 PDT 2018


Hi,

I have set up clang-format using "BreakBeforeBraces: Stroustrup", this
formats if
statements as follows:

if (str == "some string") {
    process(str);
    str = "update str";
}

This is great, it's the coding convention we use in our C++ code base.
However in
our code base we allow the opening brace to be on a new line for multi-line
if
statements because this improves the code readability:

if (str1 == "some string" ||
    str2 == "some string" ||
    str3 == "some string")
{
    process(str);
    str = "update str";
}

Is there a way to configure clang-format so that it accepts the "new line
before
opening brace" for multi-line if statements (while still using "no new line
before
opening brace" by default)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180319/cecac5a7/attachment.html>


More information about the cfe-dev mailing list