[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D71973#1817941 , @gbencze wrote: > Another option that came to my mind is using a BitVector to (recursively) > flag bits that are occupied by the fields. This solution would be slightly > slower and uses more memory but

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-24 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze added a comment. ping CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-13 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze added a comment. Another option that came to my mind is using a BitVector to (recursively) flag bits that are occupied by the fields. This solution would be slightly slower and uses more memory but is probably a lot easier to understand, maintain and more robust than the currently propo

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-12 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:82-83 + +static bool hasPadding(const ASTContext &Ctx, const RecordDecl *RD, + uint64_t ComparedBits) { + assert(RD && RD->isCompleteDefini

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-12 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 237529. gbencze added a comment. Address (most of the) comments by @aaron.ballman - remove top-level `const` on locals - move declaration into `if` - pass `TagDecl` to diag - added test for `operator void *` - fixed `[[no_unique_address]]` - remove assertio

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:30 + uint64_t ComparedBits, uint64_t &TotalSize) { + const auto IsNotEmptyBase = [](const CXXBaseSpecifier &Base) { +return

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-07 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze added a comment. ping @aaron.ballman - any thoughts on the patch? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze marked 4 inline comments as done. gbencze added a comment. Thanks for all the feedback @JonasToth :) Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-memory-comparison.rst:10 +This check corresponds to the CERT C Coding Standard rule +`EXP42-C.

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 235965. gbencze added a comment. Punctuation in comment CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp clang-tools-extra/clang-tidy/bu

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment. LG from my side, besides the small nits. Please let @aaron.ballman have a look as well. thanks for the patch :) Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:45 + + // check if comparing padding in base +

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 235915. gbencze added a comment. Tests: Split C/C++ tests and add 32/64bit specific test. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments. Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp:1 +// RUN: %check_clang_tidy %s bugprone-suspicious-memory-comparison %t + gbencze wrote: > JonasToth wrote: > > We should explicitl

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze marked 18 inline comments as done. gbencze added inline comments. Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp:1 +// RUN: %check_clang_tidy %s bugprone-suspicious-memory-comparison %t + JonasToth wrote:

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-01-02 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 235900. gbencze added a comment. Coding guide and better diagnostic message for padding comparison CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyM

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-30 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:19 + +static constexpr llvm::StringLiteral CallExprName = "call"; + I think you can remove the constant and hardcode it in the matcher. that is

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-30 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 235564. gbencze added a comment. ReleaseNotes: move alias after new checks CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp clang-tools-

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/docs/ReleaseNotes.rst:103 + +- New alias :doc:`cert-exp42-c + ` to gbencze wrote: > Eugene.Zelenko wrote: > > Please move into aliases section (in alphabetical order) > I'm not quite sure where

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-29 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze marked 5 inline comments as done. gbencze added inline comments. Comment at: clang-tools-extra/docs/ReleaseNotes.rst:103 + +- New alias :doc:`cert-exp42-c + ` to Eugene.Zelenko wrote: > Please move into aliases section (in alphabetical order) I'm not qui

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-29 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 235526. gbencze added a comment. Update style based on comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71973/new/ https://reviews.llvm.org/D71973 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp clang-tools-extra/clan

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:38 + + if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) { +const auto NonEmptyBaseIt = llvm::find_if(CXXRD->bases(), IsNotEmptyBase); Y

[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2019-12-29 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze created this revision. gbencze added reviewers: aaron.ballman, alexfh, JonasToth, Charusso. gbencze added projects: clang-tools-extra, clang. Herald added subscribers: cfe-commits, xazax.hun, whisperity, mgorny. The check warns on suspicious calls to memcmp. It currently checks for compari