This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] readability-implicit-bool-conversion: support implicit conversion to std::optional<bool>
Needs ReviewPublic

Authored by huangperry on Aug 9 2022, 12:40 PM.

Details

Summary

GitHub Issue #56009
Show implicit conversion warning to and from std::optional objects when running clang-tidy.
Examples:
std::optional<bool> a = 5;
std::optional<int> b = false;

Diff Detail

Event Timeline

huangperry created this revision.Aug 9 2022, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 12:40 PM
huangperry requested review of this revision.Aug 9 2022, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 12:40 PM
Eugene.Zelenko retitled this revision from implicit conversion to std::optional<bool> to [clang-tidy] readability-implicit-bool-conversion: supportimplicit conversion to std::optional<bool>.Aug 9 2022, 12:46 PM
Eugene.Zelenko retitled this revision from [clang-tidy] readability-implicit-bool-conversion: supportimplicit conversion to std::optional<bool> to [clang-tidy] readability-implicit-bool-conversion: support implicit conversion to std::optional<bool>.Aug 9 2022, 12:47 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Please mention changes in Release Notes and add test case, but don't rely on STL implementation, see other tests as example for mock implementations.

huangperry added a comment.EditedAug 9 2022, 1:13 PM

Please mention changes in Release Notes and add test case, but don't rely on STL implementation, see other tests as example for mock implementations.

Will do! Should I be using gMock to mock std::optional?

LegalizeAdulthood resigned from this revision.Mar 29 2023, 8:27 AM