clang-format closing bracket on a new line

I have code that looks like this:

EXPECT_EQ(
    subsystem->previousTouchscreenState,
    expectedTouchscreenState
);

When I run clang-format, it reformats the snippet to look like this:

EXPECT_EQ(
    subsystem->previousTouchscreenState,
    expectedTouchscreenState );

This is quite counterintuitive; I'd like my multi-line function invocations (although EXPECT_EQ is a macro in this case) to have the closing round bracket on its own line, indented to the level of the name of the function, as it is in the first snippet.

How do I accomplish this with clang-format?

Many thanks.


Solution 1:

I'd like my multi-line function invocations (although EXPECT_EQ is a macro in this case) to have the closing round bracket on its own line, indented to the level of the name of the function, as it is in the first snippet.

How do I accomplish this with clang-format?

That option does not seem to be added yet; either wait or get involved in the clang open source project.

Edit: As pointed out by Catskul, DCzajkowski and Dwayne in the comments: https://reviews.llvm.org/D109557 was accepted

Solution 2:

I found one workaround. If you put a comment at the end of the last argument, clang-format (or any tool) should not fold back the closing parenthesis.

EXPECT_EQ(
    subsystem->previousTouchscreenState,
    expectedTouchscreenState //
);