[PATCH] D66267: [analyzer] TrackConstraintBRVisitor: Do not track unknown values

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 17:10:01 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369604: [analyzer] TrackConstraintBRVisitor: Do not track unknown values (authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66267?vs=215525&id=216528#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66267

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/test/Analysis/cast-value.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1992,9 +1992,10 @@
       report.markInteresting(V, TKind);
       report.addVisitor(std::make_unique<UndefOrNullArgVisitor>(R));
 
-      // If the contents are symbolic, find out when they became null.
-      if (V.getAsLocSymbol(/*IncludeBaseRegions*/ true))
-        report.addVisitor(std::make_unique<TrackConstraintBRVisitor>(
+      // If the contents are symbolic and null, find out when they became null.
+      if (V.getAsLocSymbol(/*IncludeBaseRegions=*/true))
+        if (LVState->isNull(V).isConstrainedTrue())
+          report.addVisitor(std::make_unique<TrackConstraintBRVisitor>(
               V.castAs<DefinedSVal>(), false));
 
       // Add visitor, which will suppress inline defensive checks.
Index: cfe/trunk/test/Analysis/cast-value.cpp
===================================================================
--- cfe/trunk/test/Analysis/cast-value.cpp
+++ cfe/trunk/test/Analysis/cast-value.cpp
@@ -152,8 +152,7 @@
 void evalNonNullParamNonNullReturnReference(const Shape &S) {
   const auto *C = dyn_cast_or_null<Circle>(S);
   // expected-note at -1 {{Assuming dynamic cast from 'Shape' to 'Circle' succeeds}}
-  // expected-note at -2 {{Assuming pointer value is null}}
-  // expected-note at -3 {{'C' initialized here}}
+  // expected-note at -2 {{'C' initialized here}}
 
   (void)(1 / !(bool)C);
   // expected-note at -1 {{'C' is non-null}}
@@ -165,8 +164,7 @@
 void evalNonNullParamNonNullReturn(const Shape *S) {
   const auto *C = cast<Circle>(S);
   // expected-note at -1 {{Checked cast from 'Shape' to 'Circle' succeeds}}
-  // expected-note at -2 {{Assuming pointer value is null}}
-  // expected-note at -3 {{'C' initialized here}}
+  // expected-note at -2 {{'C' initialized here}}
 
   (void)(1 / !(bool)C);
   // expected-note at -1 {{'C' is non-null}}
@@ -178,7 +176,6 @@
 void evalNonNullParamNullReturn(const Shape *S) {
   const auto *C = dyn_cast_or_null<Circle>(S);
   // expected-note at -1 {{Assuming dynamic cast from 'Shape' to 'Circle' fails}}
-  // expected-note at -2 {{Assuming pointer value is null}}
 
   if (const auto *T = dyn_cast_or_null<Triangle>(S)) {
     // expected-note at -1 {{Assuming dynamic cast from 'Shape' to 'Triangle' succeeds}}
@@ -207,9 +204,8 @@
 
 void evalZeroParamNonNullReturnPointer(const Shape *S) {
   const auto *C = S->castAs<Circle>();
-  // expected-note at -1 {{Assuming pointer value is null}}
-  // expected-note at -2 {{Checked cast to 'Circle' succeeds}}
-  // expected-note at -3 {{'C' initialized here}}
+  // expected-note at -1 {{Checked cast to 'Circle' succeeds}}
+  // expected-note at -2 {{'C' initialized here}}
 
   (void)(1 / !(bool)C);
   // expected-note at -1 {{'C' is non-null}}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66267.216528.patch
Type: text/x-patch
Size: 2892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190822/22c98cac/attachment-0001.bin>


More information about the cfe-commits mailing list