diff options
| author | Csaba Dabis <dabis.csaba98@gmail.com> | 2019-08-22 00:06:58 +0000 |
|---|---|---|
| committer | Csaba Dabis <dabis.csaba98@gmail.com> | 2019-08-22 00:06:58 +0000 |
| commit | b73a5711f63466d829f815ed0f1b14f03cef0b05 (patch) | |
| tree | 5df26841d0c7f3d5b4be7061c31151e4a0bf10db | |
| parent | edb08da450391e9683ec4fd71c490c9bd12e17a3 (diff) | |
| download | bcm5719-llvm-b73a5711f63466d829f815ed0f1b14f03cef0b05.tar.gz bcm5719-llvm-b73a5711f63466d829f815ed0f1b14f03cef0b05.zip | |
[analyzer] TrackConstraintBRVisitor: Do not track unknown values
Summary: -
Reviewers: NoQ, Szelethus
Reviewed By: NoQ, Szelethus
Differential Revision: https://reviews.llvm.org/D66267
llvm-svn: 369604
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 7 | ||||
| -rw-r--r-- | clang/test/Analysis/cast-value.cpp | 12 |
2 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 973580ed00a..20af02842c1 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -1992,9 +1992,10 @@ bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode, 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. diff --git a/clang/test/Analysis/cast-value.cpp b/clang/test/Analysis/cast-value.cpp index a67ffe2c083..fcf145365ea 100644 --- a/clang/test/Analysis/cast-value.cpp +++ b/clang/test/Analysis/cast-value.cpp @@ -152,8 +152,7 @@ void evalReferences(const Shape &S) { void evalNonNullParamNonNullReturnReference(const Shape &S) { const auto *C = dyn_cast_or_null<Circle>(S); // expected-note@-1 {{Assuming dynamic cast from 'Shape' to 'Circle' succeeds}} - // expected-note@-2 {{Assuming pointer value is null}} - // expected-note@-3 {{'C' initialized here}} + // expected-note@-2 {{'C' initialized here}} (void)(1 / !(bool)C); // expected-note@-1 {{'C' is non-null}} @@ -165,8 +164,7 @@ void evalNonNullParamNonNullReturnReference(const Shape &S) { void evalNonNullParamNonNullReturn(const Shape *S) { const auto *C = cast<Circle>(S); // expected-note@-1 {{Checked cast from 'Shape' to 'Circle' succeeds}} - // expected-note@-2 {{Assuming pointer value is null}} - // expected-note@-3 {{'C' initialized here}} + // expected-note@-2 {{'C' initialized here}} (void)(1 / !(bool)C); // expected-note@-1 {{'C' is non-null}} @@ -178,7 +176,6 @@ void evalNonNullParamNonNullReturn(const Shape *S) { void evalNonNullParamNullReturn(const Shape *S) { const auto *C = dyn_cast_or_null<Circle>(S); // expected-note@-1 {{Assuming dynamic cast from 'Shape' to 'Circle' fails}} - // expected-note@-2 {{Assuming pointer value is null}} if (const auto *T = dyn_cast_or_null<Triangle>(S)) { // expected-note@-1 {{Assuming dynamic cast from 'Shape' to 'Triangle' succeeds}} @@ -207,9 +204,8 @@ void evalNullParamNullReturn(const Shape *S) { void evalZeroParamNonNullReturnPointer(const Shape *S) { const auto *C = S->castAs<Circle>(); - // expected-note@-1 {{Assuming pointer value is null}} - // expected-note@-2 {{Checked cast to 'Circle' succeeds}} - // expected-note@-3 {{'C' initialized here}} + // expected-note@-1 {{Checked cast to 'Circle' succeeds}} + // expected-note@-2 {{'C' initialized here}} (void)(1 / !(bool)C); // expected-note@-1 {{'C' is non-null}} |

