c2compiler icon indicating copy to clipboard operation
c2compiler copied to clipboard

Style all (non-clang) code with clang-format

Open bvdberg opened this issue 7 years ago • 12 comments

Does anyone see issues with the current .clang-format file?

bvdberg avatar Nov 08 '18 08:11 bvdberg

I'll have a look. Appears that there's a plugin for AppCode that swaps the auto format of AppCode with clang-format.

lerno avatar Nov 08 '18 09:11 lerno

If we use clang-format (and I don't see why not), add a passage in "working on C2" that we use it and if working on AppCode one can use the ClangFormatJ plugin.

lerno avatar Nov 08 '18 09:11 lerno

What do you mean with adding a passage?

I meant using clang-format for the c2c code written in c++, not using it to style c2 code. For c2 I think we need to create a c2format or c2style tool.

bvdberg avatar Nov 08 '18 09:11 bvdberg

A few bugs:

SmallVector <IdentifierInfo *, 32> Parameters => SmallVector < IdentifierInfo * , 32 > Parameters IdentifierInfo* II and IdentifierInfo *II => IdentifierInfo * II

do {
    foo();
} while (true);

Became

do {
    foo();
}
while (true);

There might be more.

lerno avatar Nov 08 '18 10:11 lerno

I mean add some text on the github wiki or in the docs about it.

By the way, is there a way to get wiki access? I was thinking of documenting the parser as I go along.

lerno avatar Nov 09 '18 02:11 lerno

I tried to give access to a specific list of persons (like you), but couldn't find anything like that. It's only possible to give write access to 'Collaborators'. Those are people who also have write access to the git archive itself..

On Fri, Nov 9, 2018 at 3:33 AM Christoffer Lerno [email protected] wrote:

I mean add some text on the github wiki or in the docs about it.

By the way, is there a way to get wiki access? I was thinking of documenting the parser as I go along.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/c2lang/c2compiler/issues/63#issuecomment-437229354, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC1mqqcv418jsr2HfIpC83TQf_30H2wks5utOl2gaJpZM4YUOPM .

bvdberg avatar Nov 09 '18 09:11 bvdberg

Yea, you either need to open the wiki for everyone to edit, or add those people as collaborators, neither of which particularly fits the case.

luciusmagn avatar Nov 09 '18 09:11 luciusmagn

Are collaborators the only ones that can be assigned to tasks as well? It's a bit weird not being able to get assigned to something you're working on.

lerno avatar Nov 09 '18 20:11 lerno

@lerno Yeah, one can only assign the owner, collaborators or organization members afaik, on Github

luciusmagn avatar Nov 10 '18 11:11 luciusmagn

@bvdberg I humbly pray for a different switch format. I find

switch (foo) {
case 1:
}

Inconsistent (the only construct that doesn't respect indent!) and near impossible to read (can't rely on indent to see where we are)

I know the idea is that case is a label (so it does not create a new scope – unlike C2!), but I really think there is a huge readability loss. The 4 characters you gain horizontally isn't enough to pay for it.

(I also indent labels, but labels are not common enough for it to become a problem for me, although I suggest C2 code style would be indenting labels as well. Consider defer where the labels inside the defer cannot be jumped to. It would be unsuitable to use them without indent.

lerno avatar Dec 03 '18 22:12 lerno

Clang style is still 3 spaces? @bvdberg

lerno avatar Dec 16 '18 14:12 lerno

I updated the clang-format file to 4 spaces instead of 3. That matches the current code better and I think 4 spaces is easier on the eyes...

NOTE: I haven't actually applied the clang format file yet..

bvdberg avatar Dec 18 '18 10:12 bvdberg