This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy][docs] Update check options with boolean values instead of non-zero/0/1
ClosedPublic

Authored by njames93 on Dec 4 2020, 5:35 AM.

Details

Summary

Using bools instead of integers better conveys the expected value of the option.

Diff Detail

Event Timeline

njames93 created this revision.Dec 4 2020, 5:35 AM
njames93 requested review of this revision.Dec 4 2020, 5:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2020, 5:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
njames93 updated this revision to Diff 309519.Dec 4 2020, 5:37 AM

Whoops missed one

Eugene.Zelenko accepted this revision.Dec 4 2020, 7:12 AM

Looks OK for me.

This revision is now accepted and ready to land.Dec 4 2020, 7:12 AM

Thanks for doing that :)

aaron.ballman added inline comments.Dec 4 2020, 10:33 AM
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
59–60

This edit loses information about also accepting Yes and y -- is that intentional (or were those unsupported before)?

FWIW, I'd be fine dropping support for alternate spellings of true.

129–130

"An integer true value" is a bit of a strange beast. How about "The value true specifies that the target environment..."?

clang-tools-extra/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
50

Drive-by since we're changing this line already: If option is set -> If the option is set

clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
185–186

Drive-by since we're already changing the line: If option -> If the option

njames93 marked 3 inline comments as done.Dec 4 2020, 12:10 PM
njames93 added a subscriber: Charusso.
njames93 added inline comments.
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
59–60

Having looked throughout the NotNullTerminatedResultCheck header/impl files, I can't find any reference to AreSafeFunctionsAvailable.
I can only guess this is meant to say WantToUseSafeFunctions. If that is the case, Yes and y were never supported spellings.

Should this be changed to use that option name instead? cc @Charusso

FWIW I intend (in the near future) to extend boolean parsing for check options to:
y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON
n|N|no|No|NO|false|False|FALSE|off|Off|OFF.

Reason for this is we claim to use YAML for config format and according to its specification, this is what is accepted as a boolean value. Ref https://yaml.org/type/bool.html.
Still need to keep the old integer method of specifying bools for backwards compatibility reasons.

njames93 updated this revision to Diff 309605.Dec 4 2020, 12:10 PM

Address comments

aaron.ballman accepted this revision.Dec 4 2020, 12:27 PM

LGTM, thank you for this cleanup!

clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
59–60

Should this be changed to use that option name instead? cc @Charusso

I think so, but that can be done in an NFC followup if you'd like.

Reason for this is we claim to use YAML for config format and according to its specification, this is what is accepted as a boolean value.

Oh, that's a good reason to support those spellings, thank you for clarifying.

Charusso added inline comments.Dec 4 2020, 1:46 PM
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
59–60

Hey, nice catch and cool patch! Sorry for the extra work. WantToUseSafeFunctions is wanted to be here as a zero or non-zero value [1]. It would be great if you could rewrite this variable name because I do not write LLVM code any more. Thanks!

[1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone-not-null-terminated-result.html#options

njames93 removed a subscriber: Charusso.Dec 4 2020, 2:36 PM
njames93 added inline comments.
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
59–60

No worries, I just wanted to make sure that was your initial intention :)

njames93 updated this revision to Diff 309661.Dec 4 2020, 2:38 PM

Update bugprone-not-null-terminated-result incorrect option name