clang-format BreakBeforeBraces: Custom

Hi All,

learning curve is steep :slight_smile:

From
CX08$ more c1.c
struct yo {
int i;
int j;
};

int f(int i, int j)
{ if(i){i++;} else {j++;}
return(i+j);
}

I’d like to get
CX08$ more c1.c
struct yo
{ int i;
int j;
};

int f(int i, int j)
{ if(i)
{ i++;
}
else
{ j++;
return(i+j);
}
}

I found BreakBeforeBraces Allman about ok but has an extra line I don’t want

CX08$ /home/phi/llvmbuild/bin/clang-format c.c
struct yo

{ <----- don’t want this \n

int i;
int j;
};

int f(int i, int j)
{<----- don’t want this \n
if (i)
{<----- don’t want this \n
i++;
}
else
{<----- don’t want this \n
j++;
}
return (i + j);
}

Any ideas how to tweak .clang-format

Try and fail on all option is a bit slow :slight_smile:

I don’t think you can, clang-format tries to support the most common styles well, not every conceivable style :slight_smile: