This is an archive of the discontinued LLVM Phabricator instance.

[clang-format][NFCish] Alphabetical sort Format.(h|pp)
ClosedPublic

Authored by HazardyKnusperkeks on Nov 4 2022, 4:49 AM.

Details

Summary

I've:

  • Sorted the members of FormatStyle alphabetical. The enums and structs are kept close to the member.
  • Sorted the yaml io functions, based on the type they operate on.
  • Sorted the initializers in getLLVMStyle(), except that penalities are kept at the end.
  • Sorted the io of FormatStyle, this changes the --dump-config behavior.
  • Moved the deprecated options into the only input case, this also changes --dump-config, it does not put the not directly used options in the .clang-format anymore.
  • Sorted the comparisons in operator==.
  • Added WhiteSpaceMacros in operator==, I've not actively looked if all other members are compared.
  • This showed flawed tests (or in my opinion a flawed io operation, but that is another discussion and change).

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 4:49 AM
HazardyKnusperkeks requested review of this revision.Nov 4 2022, 4:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 4:49 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MyDeveloperDay accepted this revision.Nov 7 2022, 12:30 AM
MyDeveloperDay added inline comments.
clang/unittests/Format/FormatTest.cpp
23323–23326

related?

This revision is now accepted and ready to land.Nov 7 2022, 12:30 AM

Don't forget to run dump_format_style.py before landing. :)

This revision was landed with ongoing or failed builds.Nov 8 2022, 12:46 PM
This revision was automatically updated to reflect the committed changes.
clang/unittests/Format/FormatTest.cpp
23323–23326

Sadly yes.
Because WhiteSensitiveMacros were not handled in operator== we basically tested nothing here.
When I wrote the tests I assumed (and still think it should be that way) that WhiteSensitiveMacros would only contain what is posted in the .clang-format. But that's not the case, the vector gets filled with whatever getLLVMStyle() does and then overwrites them in order, extending when there is not enough room.

That will hold for all std::vectors and so.