Detects cases where the result of a resource allocation is used as a bool.
Fixes: #64461
Paths
| Differential D157188
[clang-tidy] Add bugprone-allocation-bool-conversion Needs ReviewPublic Authored by PiotrZSL on Aug 5 2023, 2:42 AM.
Details
Summary Detects cases where the result of a resource allocation is used as a bool. Fixes: #64461
Diff Detail
Event TimelineComment Actions Shouldn't C-style allocation be checked too? Same for custom allocators via configuration option. Comment Actions
In theory it could, but in such case name of check would need to change... Comment Actions
Something like bugprone-resource-bool-conversion should be generic enough. Comment Actions
Maybe bugprone-allocation-bool-conversion? PiotrZSL retitled this revision from [clang-tidy] Add bugprone-new-bool-conversion to [clang-tidy] Add bugprone-allocation-bool-conversion. Comment ActionsChange check anme, add configuration option. PiotrZSL marked an inline comment as done. Comment ActionsFormating + fix tests
Comment Actions TODO: Fix CI, Add support for allocators that return 'integer', hardcode most of functions, change config into AdditionalAllocationFunctions PiotrZSL marked an inline comment as done. Comment ActionsRebase, add support for integer returnign functions, fixes in tests.
Revision Contents
Diff 547587 clang-tools-extra/clang-tidy/bugprone/AllocationBoolConversionCheck.h
clang-tools-extra/clang-tidy/bugprone/AllocationBoolConversionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone/allocation-bool-conversion.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone/allocation-bool-conversion.cpp
|
POSIX open, openat, creat, pthread_create should be added too.