This is an archive of the discontinued LLVM Phabricator instance.

[clang-format][doc] SortIncludes documentation: remove contradiction in its description
ClosedPublic

Authored by michael-g-matthews on Apr 9 2023, 3:28 PM.

Details

Summary

The style option SortIncludes contains a contradiction between its initial description and the list of possible values.

Currently the description incorrectly states:

If CaseInsensitive, includes are sorted in an ASCIIbetical or case insensitive fashion. If CaseSensitive, includes are sorted in an alphabetical or case sensitive fashion

And the possible values section correctly states:

SI_CaseSensitive (in configuration: CaseSensitive) Includes are sorted in an ASCIIbetical or case sensitive fashion.
SI_CaseInsensitive (in configuration: CaseInsensitive) Includes are sorted in an alphabetical or case insensitive fashion

This patch shortens the initial description to read:

Controls if and how clang-format will sort #includes.

This removes the contradiction and ensures there is only a singular explanation for how this style option works.

Fixes https://github.com/llvm/llvm-project/issues/62033.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 9 2023, 3:28 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
NOTE: Clang-Format Team Automated Review Comment

Your review contains a change to ClangFormatStyleOptions.rst but not a change to clang/include/clang/Format/Format.h

ClangFormatStyleOptions.rst is auto generated from Format.h via clang/docs/tools/dump_format_style.py, please run this to regenerate the .rst

You can validate that the rst is valid by running.

./docs/tools/dump_format_style.py
mkdir -p html
/usr/bin/sphinx-build -n ./docs ./html
NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please try to ensure all code changes have a unit test (unless this is an NFC or refactoring, adding documentation etc..)

Add your unit tests in clang/unittests/Format and you can build with ninja FormatTests. We recommend using the verifyFormat(xxx) format of unit tests rather than EXPECT_EQ as this will ensure you change is tolerant to random whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can happen if you are trying to improve the annotation phase to ensure we are correctly identifying the type of a token, please add a token annotator test in TokenAnnotatorTest.cpp

michael-g-matthews requested review of this revision.Apr 9 2023, 3:28 PM

Amended commit to include change to clang/include/clang/Format/Format.h

MyDeveloperDay requested changes to this revision.EditedApr 10 2023, 1:23 AM

Sorry I don’t get how this change helps. Removing the option values doesn’t make it clearer IMHO

This revision now requires changes to proceed.Apr 10 2023, 1:23 AM

Sorry I don’t get how this change helps. Removing the option values does make it clearer IMHO

What options?

michael-g-matthews added a comment.EditedApr 10 2023, 8:33 PM

I am also a little confused by what you mean @MyDeveloperDay. The options that were removed contained incorrect documentation (listing ASCIIbetical as CaseInsensitive). The enum documentation immediately after was however correct, so the documentation was self-contradictory. Instead of removing the options, I could have just fixed the typo, but then you have redundant documentation. In that case, if there are changes in the future, a dev will have to make documentation changes in two places instead of one. In my opinion, this was the cleaner fix, but I am willing to acquiesce if fixing the typo is preferable

MyDeveloperDay accepted this revision.Apr 10 2023, 11:34 PM

Yes I didn’t see them repeated below

This revision is now accepted and ready to land.Apr 10 2023, 11:34 PM
owenpan accepted this revision.Apr 11 2023, 1:27 PM
owenpan retitled this revision from [clang-format] SortIncludes documentation: remove contradiction in its description to [clang-format][doc] SortIncludes documentation: remove contradiction in its description.Apr 11 2023, 1:33 PM
owenpan edited the summary of this revision. (Show Details)

If this is considered fully approved, would someone with commit access be able to commit this on my behalf? This is my first contribution so I do not have access. My name and email are Mike Matthews and michael.g.matthews3@gmail.com. Thank you!

This revision was landed with ongoing or failed builds.May 26 2023, 1:59 AM
This revision was automatically updated to reflect the committed changes.