This is an archive of the discontinued LLVM Phabricator instance.

[clang-format[PR43144] Add support for SpaceAroundBraces style
AbandonedPublic

Authored by MyDeveloperDay on Sep 19 2019, 12:52 PM.

Details

Summary

This is to address a request made in https://bugs.llvm.org/show_bug.cgi?id=43144

Add the ability to not have a space before and after brace (limited to if,else,for,while,do keyword (for now))

if (x){
}else if{
}else{
}
do{
}while(x)
while(x){
}
for(int i=0;i<size();i++){
}

nb. I have not affiliation with the 3sfs project (https://github.com/s3fs-fuse/s3fs-fuse) but noticed on reading this request they don't have a .clang-format file in their Github repo. Perhaps this is because without this feature we can't support their style at all. My aim here is to further the reach of clang-format whilst increasing my knowledge of the workings for clang-format.

Diff Detail

Repository
rC Clang

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2019, 12:52 PM
gaul added a subscriber: gaul.Sep 19 2019, 4:54 PM
MyDeveloperDay added a project: Restricted Project.Sep 25 2019, 1:16 AM
mitchell-stellar requested changes to this revision.Oct 4 2019, 8:42 AM

This needs to be more thought out. At the very least it needs to cover more keywords like do, switch, try, and catch. There may be more. Consideration also needs to be made for class, functions, namespace, etc. Otherwise this is an experimental feature at best. There is also confusion with how it may interact with SpaceBeforeCpp11BracedList. The name SpacesAroundBraces is just too generic in that regard considering the fact that braces play multiple roles in C++.

This revision now requires changes to proceed.Oct 4 2019, 8:42 AM

This needs to be more thought out. At the very least it needs to cover more keywords like do, switch, try, and catch. There may be more. Consideration also needs to be made for class, functions, namespace, etc. Otherwise this is an experimental feature at best. There is also confusion with how it may interact with SpaceBeforeCpp11BracedList. The name SpacesAroundBraces is just too generic in that regard considering the fact that braces play multiple roles in C++.

Agreed

MyDeveloperDay abandoned this revision.Feb 24 2020, 4:11 AM