clang-format if-statements, braced initialization and function calls

Viewed 74

I am trying to write a .clang-format file that is as close as possible to my personal preference. It works pretty well, except for a few flaws that I really don't appreciate.

I've uploaded code-snippet examples for before- and after clang-format comparison. Below is a summary of what I want changed, otherwise I would like to preserve the format as close as possible to what it currently does.

Any idea of what options I need to adjust to achieve the following?

// What the .clang-format does:
if (
   a_arg1.i == 10 && a_arg2.i == 10 && a_arg3.i == 10 &&
   a_arg4.i == 10 )
{
   return a_arg4;
}

// What I want:
if ( a_arg1.i == 10 &&
     a_arg2.i == 10 &&
     a_arg3.i == 10 &&
     a_arg4.i == 10 )
{
   return a_arg4;
}


// What the .clang-format does:
clang_format::test::SuperDuper::UltraMega::LongLong::TypeName
   arr[] = { { 1 }, { 2 }, { 3 }, { 4 } };

// What I want:
clang_format::test::SuperDuper::UltraMega::LongLong::TypeName arr[] = {
   { 1 },
   { 2 },
   { 3 },
   { 4 } };


// What the .clang-format does:
const auto result =
   clang_format::test::function( arr[ 0 ], arr[ 1 ], arr[ 2 ], arr[ 3 ] );

// What I want:
const auto result = clang_format::test::function(
   arr[ 0 ],
   arr[ 1 ],
   arr[ 2 ],
   arr[ 3 ] );
0 Answers
Related