[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 28 08:40:00 PDT 2020


NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:148
+    if (InnerPointVal && InnerPointVal->isZeroConstant()) {
+      reportBug(C, Call);
+    }
----------------
This doesn't seem to be guarded by `ShouldCheckSmartPtrDereference`.

Consider adding a LIT test for the flag to make sure we're not leaking our project to the public until it's ready ^.^ Say, you could make two run-lines in your test like this:
```
// RUN: %clang_analyze_cc1 -verify=expected -analyzer-config cplusplus.SmartPtr:CheckSmartPtrDereference=true \
// RUN: ...
// RUN: %clang_analyze_cc1 -verify=unexpected \
// RUN: ...

// unexpected-no-diagnostics
```
(see https://clang.llvm.org/doxygen/classclang_1_1VerifyDiagnosticConsumer.html for more fancy tricks with `-verify`)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81315/new/

https://reviews.llvm.org/D81315





More information about the cfe-commits mailing list