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);
}
}
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);
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits