Page MenuHomePhabricator

[clang-format] Added ReferenceAlignmentStyle option - (Update to D31635)
AbandonedPublic

Authored by catskul on Oct 27 2020, 8:14 AM.

Details

Summary

I'm trying to get D31635: [clang-format] Added ReferenceAlignmentStyle option past the finish line so I've adopted it.

This revision:

  • fixes the documentation by running dump_format_style.py
  • adds test for PAS_Right + RAS_Left and commented out '* &' example

(changing your reviewers, clang-format is a project not a reviewer group)

Diff Detail

Event Timeline

catskul created this revision.Oct 27 2020, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2020, 8:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
catskul requested review of this revision.Oct 27 2020, 8:14 AM
MyDeveloperDay added inline comments.
clang/lib/Format/TokenAnnotator.cpp
2832

I get that this is getReferenceOrPointAlignment(Left)... but see below... (to be continued)

3332

this is getPointerAlignment(Left) and... (to be continued)

3336

and this is getReferenceAlignment(Left)

I get it that it was easier to change all the function to the same function probably as a "copy and paste" of `...
Style.PointerAlginment ....`

but do you think it might be worth ensuring we differentiate between Pointer,Reference and PointerOrReference alignment?

clang/unittests/Format/FormatTest.cpp
920

Nit: add FIXME

MyDeveloperDay edited the summary of this revision. (Show Details)Dec 7 2020, 10:36 AM
MyDeveloperDay edited reviewers, added: MyDeveloperDay, curdeius, krasimir, JakeMerdichAMD; removed: Restricted Project.
MyDeveloperDay retitled this revision from Update to D31635 to [clang-format] Added ReferenceAlignmentStyle option - (Update to D31635).
MyDeveloperDay edited the summary of this revision. (Show Details)

Looks almost there, just a few nits really

clang/docs/ClangFormatStyleOptions.rst
2316

Did you generate this file by running clang/doc/tools/dump_style.py or make it by hand? changes in Format.h should make some sort of change here

clang/include/clang/Format/Format.h
1891

wondering why this didn't cause an rst change above

clang/lib/Format/Format.cpp
993

I sort of feel you only need this in the base LLVMStyle?

1185

I sort of feel you only need this in the base LLVMStyle?

1208

I sort of feel you only need this in the base LLVMStyle?

clang/lib/Format/TokenAnnotator.h
192

do you need FormatStyle:: here?

clang/unittests/Format/FormatTest.cpp
889

you shouldn't need these right, lets test the default LLVM style without setting it to something else

@catskul I'm really sorry this disappeared into the ether because it was missing the project and any real reviewers, I tend to go back now and again and do a search for "Lost" clang format reviews and stumbled on this one, hopefully this will bring it to the fore if you are still interested

Hi @catskul, @MyDeveloperDay,

Is there still interest in this feature ?

My organization has had an internal implementation of this for years and I would like to replace it with an upstream version (and this one seems almost approved).

Let me know if I can help getting this revision upstream.

@curdeius , @HazardyKnusperkeks any thoughts, personally I don't have any problems with this even if its not my personal preference. @skirkovski if this is something you need we might need for you to take over the revision and bring it upto date and address the comments? is that something you would be interesting in helping out with?

My personal preference is that someone who wants it should own it, as with all things we need volunteers. @catskul's last comment on D33029: [clang-format] add option for dangling parenthesis was that they are busy, maybe they'd think the same here if someone wants to pick it up.

In my mind justification is that astyle supported seperate align-pointer and align-reference

@curdeius , @HazardyKnusperkeks any thoughts, personally I don't have any problems with this even if its not my personal preference. @skirkovski if this is something you need we might need for you to take over the revision and bring it upto date and address the comments? is that something you would be interesting in helping out with?

Yes, I can do that. I'll pick it up, address the comments and if no one objects in the mean time, will post a revision.

I think this would be a nice addition, and in the past I would have used it. I really like the option Pointer.

If this will be pursued I will be happy to review it.

clang/unittests/Format/FormatTest.cpp
895

I would really like an empty line before changing the style, that way it is more obvious.