[PATCH] D89651: [clang-tidy] Add bugprone-suspicious-memory-comparison check
Gabor Bencze via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 18 10:26:04 PDT 2020
gbencze created this revision.
gbencze added reviewers: aaron.ballman, JonasToth, Charusso.
gbencze added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.
gbencze requested review of this revision.
The check warns on suspicious calls to memcmp.
It currently checks for comparing types that do not have unique object representations or are non-standard-layout.
Based on
https://wiki.sei.cmu.edu/confluence/display/c/EXP42-C.+Do+not+compare+padding+data
https://wiki.sei.cmu.edu/confluence/display/c/FLP37-C.+Do+not+use+object+representations+to+compare+floating-point+values
and part of
https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions
Add alias cert-exp42-c and cert-flp37-c.
Some tests are currently failing at head, the check depends on D89649 <https://reviews.llvm.org/D89649>.
Originally started in D71973 <https://reviews.llvm.org/D71973>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89651
Files:
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.h
clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-memory-comparison.rst
clang-tools-extra/docs/clang-tidy/checks/cert-exp42-c.rst
clang-tools-extra/docs/clang-tidy/checks/cert-flp37-c.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.c
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89651.298885.patch
Type: text/x-patch
Size: 28189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201018/a54dbd47/attachment-0001.bin>
More information about the cfe-commits
mailing list