[analyzer] Fix invalidation on C++ const methods with arrow syntax.
authorArtem Dergachev <artem.dergachev@gmail.com>
Mon, 25 Jun 2018 23:43:45 +0000 (23:43 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Mon, 25 Jun 2018 23:43:45 +0000 (23:43 +0000)
commitf74ef4b1e634f094654de3b7b3567fa747c7e8a8
tree9f0e183dfd3aa861f944b27870dea6734ca7bcac
parenta157b8bef546f96d2c1940a9a27626c9f0da5074
[analyzer] Fix invalidation on C++ const methods with arrow syntax.

Conservative evaluation of a C++ method call would invalidate the object,
as long as the method is not const or the object has mutable fields.

When checking for mutable fields, we need to scan the type of the object on
which the method is called, which may be more specific than the type of the
object on which the method is defined, hence we look up the type from the
this-argument expression.

If arrow syntax or implicit-this syntax is used, this-argument expression
has pointer type, not record type, and lookup accidentally failed for that
reason. Obtain object type correctly.

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

llvm-svn: 335555
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/test/Analysis/const-method-call.cpp