[analyzer] Fix and refactor bugreporter::getDerefExpr() API.
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 27 Sep 2017 09:33:37 +0000 (09:33 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Wed, 27 Sep 2017 09:33:37 +0000 (09:33 +0000)
commit2064e8227723542cd0f1a5ed71f69a5e388e7f5f
tree554a68aec6fc30753d7e12dcbffd5bb8ffb71bc0
parent622c563b5a828764a99eac8d950b833ae1b2c68a
[analyzer] Fix and refactor bugreporter::getDerefExpr() API.

This API is used by checkers (and other entities) in order to track where does
a value originate from, by jumping from an expression value of which is equal
to that value to the expression from which this value has "appeared". For
example, it may be an lvalue from which the rvalue was loaded, or a function
call from which the dereferenced pointer was returned.

The function now avoids incorrectly unwrapping implicit lvalue-to-rvalue casts,
which caused crashes and incorrect intermediate diagnostic pieces. It also no
longer relies on how the expression is written when guessing what it means.

Fixes pr34373 and pr34731.

rdar://problem/33594502

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

llvm-svn: 314287
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/test/Analysis/null-deref-path-notes.c [new file with mode: 0644]
clang/test/Analysis/null-deref-path-notes.cpp [new file with mode: 0644]
clang/test/Analysis/null-deref-path-notes.m