[PATCH] D126186: [clang-tidy] Extend cert-oop57-cpp to check non-zero memset values
Endre Fülöp via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 23 03:44:28 PDT 2022
gamesh411 updated this revision to Diff 431319.
gamesh411 added a comment.
Added a release note
Also generated the full context (arcanist could validate the site certificate, that's why I had to resort to manual diff creation. Was there a certificate change on the reviews.llmv.org site maybe?)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126186/new/
https://reviews.llvm.org/D126186
Files:
clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
docs/ReleaseNotes.rst
test/clang-tidy/checkers/cert-oop57-cpp.cpp
Index: test/clang-tidy/checkers/cert-oop57-cpp.cpp
===================================================================
--- test/clang-tidy/checkers/cert-oop57-cpp.cpp
+++ test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -88,3 +88,10 @@
mymemcmp(&Data, &Other, sizeof(Data));
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'mymemcmp'
}
+
+void nonNullSetValue() {
+ NonTrivial Data;
+ // Check non-null-valued second argument.
+ std::memset(&Data, 1, sizeof(Data));
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+}
Index: docs/ReleaseNotes.rst
===================================================================
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -198,6 +198,9 @@
<clang-tidy/checks/readability-simplify-boolean-expr>` to simplify expressions
using DeMorgan's Theorem.
+- Made :doc:`cert-oop57-cpp <clang-tidy/checks/cert-oop57-cpp>` more sensitive
+ by checking for non-zero integer literal memset arguments as well.
+
Removed checks
^^^^^^^^^^^^^^
Index: clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
===================================================================
--- clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
+++ clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
@@ -90,7 +90,7 @@
callExpr(callee(namedDecl(hasAnyName(
utils::options::parseListPair(BuiltinMemSet, MemSetNames)))),
ArgChecker(unless(isTriviallyDefaultConstructible()),
- expr(integerLiteral(equals(0)))))
+ expr(integerLiteral())))
.bind("lazyConstruct"),
this);
Finder->addMatcher(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126186.431319.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220523/3fde7163/attachment-0001.bin>
More information about the cfe-commits
mailing list