[analyzer] PR43102: Fix an assertion and an out-of-bounds error for diagnostic locati...
authorKristof Umann <kristof.umann@ericsson.com>
Wed, 18 Sep 2019 22:24:26 +0000 (22:24 +0000)
committerKristof Umann <kristof.umann@ericsson.com>
Wed, 18 Sep 2019 22:24:26 +0000 (22:24 +0000)
commitb8ac93c73b618dd9bec20dc2d94ec9afb0140780
treee17b1103be778612e2b4b917b244ec9fd5b3436b
parentbdad30a8b8fa48a62a37e7400b3ae5a99a6aca53
[analyzer] PR43102: Fix an assertion and an out-of-bounds error for diagnostic location construction

Summary:
https://bugs.llvm.org/show_bug.cgi?id=43102

In today's edition of "Is this any better now that it isn't crashing?", I'd like to show you a very interesting test case with loop widening.

Looking at the included test case, it's immediately obvious that this is not only a false positive, but also a very bad bug report in general. We can see how the analyzer mistakenly invalidated `b`, instead of its pointee, resulting in it reporting a null pointer dereference error. Not only that, the point at which this change of value is noted at is at the loop, rather then at the method call.

It turns out that `FindLastStoreVisitor` works correctly, rather the supplied explodedgraph is faulty, because `BlockEdge` really is the `ProgramPoint` where this happens.
{F9855739}
So it's fair to say that this needs improving on multiple fronts. In any case, at least the crash is gone.

Full ExplodedGraph: {F9855743}

Reviewers: NoQ, xazax.hun, baloghadamsoftware, Charusso, dcoughlin, rnkovacs, TWeaver

Subscribers: JesperAntonsson, uabelho, Ka-Ka, bjope, whisperity, szepet, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, gamesh411, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66716

llvm-svn: 372269
clang/lib/Analysis/PathDiagnostic.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/test/Analysis/loop-widening.cpp [new file with mode: 0644]