[PATCH] D127036: [clang-tidy] Warn about arrays in `bugprone-undefined-memory-manipulation`
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 4 11:54:36 PDT 2022
JonasToth added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp:27
void UndefinedMemoryManipulationCheck::registerMatchers(MatchFinder *Finder) {
- const auto NotTriviallyCopyableObject =
- hasType(ast_matchers::hasCanonicalType(
- pointsTo(cxxRecordDecl(isNotTriviallyCopyable()))));
+ const auto ArrayOfNotTriviallyCopyable = arrayType(
+ hasElementType(hasDeclaration(cxxRecordDecl(isNotTriviallyCopyable()))));
----------------
you can factor the `hasDeclaration(cxxRecordDecl(isNotTriviallyCopyable()))` out to avoid the copy&paste.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-undefined-memory-manipulation.cpp:129
+ types::Copy ca[10];
+ memset(ca, 0, sizeof(ca));
----------------
could you please add a test with a typedef to array to ensure that those are matched as well.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127036/new/
https://reviews.llvm.org/D127036
More information about the cfe-commits
mailing list