[PATCH] D32700: [clang-tidy] Add misc-suspicious-memset-usage check.

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 7 03:24:41 PDT 2017


xazax.hun added inline comments.


================
Comment at: clang-tidy/misc/SuspiciousMemsetUsageCheck.cpp:21
+void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
+  const auto HasCtorOrDtor =
+      eachOf(hasMethod(cxxConstructorDecl(unless(anyOf(
----------------
I think this might not be the best approach.

For example, if the constructor is compiler generated, but there is a member of the class with non-trivial constructor, we still want to warn. 

E.g.:

```
struct X { X() { /* something nontrivial */ } };

struct Y { X x; };
```

Maybe we should check instead whether the class is a POD? Other alternative might be something like 
`CXXRecordDecl::hasNonTrivialDefaultConstructor`.


https://reviews.llvm.org/D32700





More information about the cfe-commits mailing list