Finds calls of memory manipulation functions memset(), memcpy() and memmove() on not TriviallyCopyable objects, as these always result in an undefined behavior.
Moved to module bugprone created by D32700.
Hits on LLVM codebase:
Paths
| Differential D35051
[clang-tidy] Add bugprone-undefined-memory-manipulation check. ClosedPublic Authored by rnkovacs on Jul 6 2017, 5:50 AM.
Details Summary
Diff Detail Event TimelineHerald added subscribers: whisperity, JDevlieghere, mgorny. · View Herald TranscriptJul 6 2017, 5:50 AM Comment Actions As usual, please run the check at least on LLVM+Clang and include a brief summary of results into the description of the patch. Comment Actions Another thing is that at this point I'd already create a bugprone module (if nobody has a better name) and place the check there (together with the other memset-related check). rnkovacs retitled this revision from [clang-tidy] Add misc-undefined-memory-manipulation check. to [clang-tidy] Add bugprone-undefined-memory-manipulation check.. Comment Actions
rnkovacs added a parent revision: D32700: [clang-tidy] Add bugprone-suspicious-memset-usage check..Jul 12 2017, 5:28 AM alexfh added inline comments. This revision now requires changes to proceed.Jul 12 2017, 8:28 AM Comment Actions LG
This revision is now accepted and ready to land.Jul 12 2017, 9:01 AM Closed by commit rL308021: [clang-tidy] Add bugprone-undefined-memory-manipulation check (authored by xazax). · Explain WhyJul 14 2017, 5:20 AM This revision was automatically updated to reflect the committed changes. Comment Actions FYI, bugprone-undefined-memory-manipulation crashes on some of our code. I guess, this happens with dependent types, but I don't have an isolated repro yet. Comment Actions The top of stack trace is: clang::CXXRecordDecl::isTriviallyCopyable() (unknown) clang::tidy::bugprone::(anonymous namespace)::internal::matcher_isNotTriviallyCopyableMatcher::matches() Comment Actions Dependent types seem to work, but we did manage to produce a crash on incomplete types. I created D35790 for that. I hope it's the same problem you encountered.
Revision Contents
Diff 106185 clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tidy/bugprone/CMakeLists.txt
clang-tidy/bugprone/UndefinedMemoryManipulationCheck.h
clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp
docs/ReleaseNotes.rst
docs/clang-tidy/checks/bugprone-undefined-memory-manipulation.rst
docs/clang-tidy/checks/list.rst
test/clang-tidy/bugprone-undefined-memory-manipulation.cpp
|
nit: No need for the parentheses.