Re: [PATCH] D13099: [Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)
Sean Eveson via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 03:23:19 PDT 2015
seaneveson added a comment.
I've realized that the patch doesn't handle pointers correctly, since a const method can modify the memory pointed at by a member. While pointer members should not be invalidated by const methods (if they are not mutable), the memory they point to should still be invalidated. I'll address this in the next version.
In http://reviews.llvm.org/D13099#253111, @zaks.anna wrote:
> The analyzer has a notion of ConstPointerEscape, see checkConstPointerEscape callback.
> All the pointers to const parameters are escaped this way. The implementation for that is in CallEvent::invalidateRegions, right below the code you've added:
> I think we should const escape all non-mutable fields as well as 'this'.
> (A motivation behind this callback is that one can call delete on pointers of const *void type.)
I think I understand, but to clarify:
The fields that shouldn't be invalidated should still be added to ValuesToInvalidate, but with RegionAndSymbolInvalidationTraits::TK_PreserveContents set. This will result in checkConstPointerEscape being called properly.
Is that correct?
More information about the cfe-commits