Re: [PATCH] D13099: [Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 05:54:13 PDT 2015
xazax.hun added a comment.
In http://reviews.llvm.org/D13099#260531, @seaneveson wrote:
> There is an issue where pointers to the object (this) should cause it to be invalidated, but don't since TK_PreserveContents has been set.
>
> For example:
>
> class B;
> class A {
> B b;
> const foo();
> };
> class B {
> A *ptr_a;
> }
>
> A a;
> a.b.ptr_a = &a;
> a.foo();
>
>
> The method foo might modify 'this' via the object b, but 'this' will not be invalidated as foo is const.
>
> Again I'm not sure this is worth checking for, based on the assumption that a reasonable const method won't modify the relevant object. What do people think?
I think, this can happen every time, when tehere is a cycle of pointers. Even if you do not deal with this case I think it would be great to have an XFAIL test with a fixme that describes this limitation.
In case we would like to fix this issue in the future, I think TK_PreserveContents is too weak. It would be great to have more control, when to preserve the content. E.g. a trait which describes that, this region can not be invalidated by that pointer. It is a good question whether a more precise solution can be efficient enough though.
http://reviews.llvm.org/D13099
More information about the cfe-commits
mailing list