[PATCH] D75697: [analyzer] Allow null false positive suppression for conditions

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 10:22:54 PST 2020


Szelethus created this revision.
Szelethus added reviewers: NoQ, baloghadamsoftware, balazske, martong, xazax.hun, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, steakhal, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, whisperity.

If the a value has received its value through suspicious means, we suppress it. Tracked conditions are very much relevant to the occurrence of a bug, if their value is fishy, the entire bug report probably is as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75697

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/inlining/inline-defensive-checks.m


Index: clang/test/Analysis/inlining/inline-defensive-checks.m
===================================================================
--- clang/test/Analysis/inlining/inline-defensive-checks.m
+++ clang/test/Analysis/inlining/inline-defensive-checks.m
@@ -108,11 +108,9 @@
   unsigned zero = 0;
   fPtr = retNil();
   // On a path where fPtr is nil, mem should be nil.
-  // The warning is not suppressed because the receiver being nil is not
-  // directly related to the value that triggers the warning.
   Foo *mem = [fPtr getFooPtr];
   if (!mem)
-    return 5/zero; // expected-warning {{Division by zero}}
+    return 5/zero;
   return 0;
 }
 
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1813,7 +1813,7 @@
       if (BR.addTrackedCondition(N)) {
         bugreporter::trackExpressionValue(
             N, Condition, BR, bugreporter::TrackingKind::Condition,
-            /*EnableNullFPSuppression=*/false);
+            /*EnableNullFPSuppression=*/true);
         return constructDebugPieceForTrackedCondition(Condition, N, BRC);
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75697.248526.patch
Type: text/x-patch
Size: 1254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200305/e427da50/attachment-0001.bin>


More information about the cfe-commits mailing list