[PATCH] D86027: [analyzer] Add bool operator modeling for unque_ptr

Nithin VR via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 25 05:47:28 PDT 2020


vrnithinkumar marked an inline comment as done.
vrnithinkumar added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:494-496
+      OS << "Smart pointer";
+      checkAndPrettyPrintRegion(OS, ThisRegion);
+      OS << " is non-null";
----------------
NoQ wrote:
> Because these note tags aren't specific to the bug report at hand, they have to be marked as //prunable// (i.e., the optional `getNoteTag()`'s parameter "`IsPrunable`" should be set to true). That'd reduce bug report clutter by not bringing in stack frames that aren't otherwise interesting for the bug report.
> 
> Something like this may act as a test (i didn't try):
> ```lang=c++
> struct S {
>   std::unique_ptr<int> P;
> 
>   void foo() {
>     if (!P) { // no-note because foo() is pruned
>       return;
>     }
>   }
> 
>   int bar() {
>     P = new int(0);
>     foo();
>     return 1 / *P; // warning: division by zero
>   }
> 
> }
> 
> ```
Marked these tags as prunable and added the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86027



More information about the cfe-commits mailing list