[PATCH] D71973: [clang-tidy] Add bugprone-suspicious-memory-comparison check
Eugene Zelenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 29 14:31:52 PST 2019
Eugene.Zelenko added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:38
+
+ if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
+ const auto NonEmptyBaseIt = llvm::find_if(CXXRD->bases(), IsNotEmptyBase);
----------------
You could use const auto * because type is specified in same statement.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:44
+
+ const auto *BaseRD = NonEmptyBaseIt->getType()->getAsCXXRecordDecl();
+ const uint64_t SizeOfBase = Ctx.getTypeSize(BaseRD->getTypeForDecl());
----------------
Please don't use auto when type is not specified in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:128
+ assert(SizeExpr != nullptr);
+ const auto ComparedBits = tryEvaluateSizeExpr(SizeExpr, Ctx);
+
----------------
Please don't use auto when type is not specified in same statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp:139
+ if (RD != nullptr) {
+ if (const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD)) {
+ if (!CXXDecl->isStandardLayout()) {
----------------
You could use const auto * because type is specified in same statement.
================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:103
+
+- New alias :doc:`cert-exp42-c
+ <clang-tidy/checks/cert-exp42-c>` to
----------------
Please move into aliases section (in alphabetical order)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71973/new/
https://reviews.llvm.org/D71973
More information about the cfe-commits
mailing list