[PATCH] D98726: [analyzer] Enabling MallocChecker to take up after SmartPtrModelling

Deep Majumder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 4 01:02:40 PDT 2021


RedDocMD added a comment.

In D98726#2719100 <https://reviews.llvm.org/D98726#2719100>, @RedDocMD wrote:

> Judging by this line <https://github.com/llvm/llvm-project/blob/ebe408ad8003c946ef871b955ab18e64e82697cb/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp#L2730> in the `LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor()` method, it seems that the bug report is squelched when the visitor encounters an  `ExplodedNode` which corresponds to a `LocationContext`, whose associated `Decl` lies in **std** namespace. I guess, by default, the option to suppress warnings from the std library is enabled. Which makes sense, except in this case since `unique_ptr` is in std and it is being used in that function, the bug report is suppressed.

This is what causes the false suppression. To be more specific, the analyzer tries to follow the logic of the //destructor// of `unique_ptr` into the standard library. And since that is in the `std` namespace, it causes `LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor()`  to squelch the report. Now there are two problems here:

- Why does the analyzer try to follow the logic into the standard library? Is it because we haven't explicitly modeled it? (Then, as you said, modelling this method will solve the issue).
- Why is there a bug in `unique_ptr.h`? (This is the worse of the two, IMO). I am going to take a look at the standard library code (sigh) and see if that's an actual bug or another false positive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98726



More information about the cfe-commits mailing list