auto IsRecordSizeOf =
expr(sizeOfExpr(hasArgumentOfType(equalsBoundNode("Record"))));
auto ArgChecker = [&](Matcher<CXXRecordDecl> RecordConstraint,
- BindableMatcher<Stmt> SecondArg = expr()) {
+ BindableMatcher<Stmt> SecondArg) {
return allOf(argumentCountIs(3),
hasArgument(0, IsStructPointer(RecordConstraint, true)),
hasArgument(1, SecondArg), hasArgument(2, IsRecordSizeOf));
Finder->addMatcher(
callExpr(callee(namedDecl(hasAnyName(
utils::options::parseListPair(BuiltinMemSet, MemSetNames)))),
- ArgChecker(unless(isTriviallyDefaultConstructible())))
+ ArgChecker(unless(isTriviallyDefaultConstructible()),
+ expr(integerLiteral(equals(0)))))
.bind("lazyConstruct"),
this);
Finder->addMatcher(
<clang-tidy/checks/bugprone-sizeof-expression>` when `sizeof(...)` is
compared against a `__int128_t`.
-- Made :doc:`cert-oop57-cpp <clang-tidy/checks/cert-oop57-cpp>` more sensitive
- by checking for an arbitrary expression in the second argument of `memset`.
-
- Improved :doc:`cppcoreguidelines-prefer-member-initializer
<clang-tidy/checks/cppcoreguidelines-prefer-member-initializer>` check.
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
-}
-
-void nonLiteralSetValue(char C) {
- NonTrivial Data;
- // Check non-literal second argument.
- std::memset(&Data, C, sizeof(Data));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
-}