[PATCH] D96976: [analyzer] Fix reinterpret_cast handling for pointer-to-member

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 24 10:25:48 PDT 2021


steakhal requested changes to this revision.
steakhal added a comment.
This revision now requires changes to proceed.

This patch does not model faithfully how reinterpretcasting member pointers should work.

The base specifiers represent the history for the member pointer (aka. mptr), describing how it was transformed to point wherever it currently points to.
If and only if the `PointerToMemberData` is `null`, then the represented member pointer is `null`.

`class PointerToMemberData` could have a bool `IsValid` field, representing whether or not this mptr is safely dereferancable or not.
Depending on this, loading a value via this mptr should result in `Undefined` or the associated value from the //store//.
Whenever you encounter a `reinterpret_cast` expression casting a valid mptr to a different type, the resulting `PointerToMemberData` should be the same as before **BUT** the `IsValid` field set to `false`!
Later, if it's cast back to the original type (which is probably the `NamedDecl` inside the `PointerToMemberData`, I don't know).

You should also change the way how the abstract machine loads a value from the //store// using an invalid mptr - as that should return `Undefined` instead of the actual associated value.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96976/new/

https://reviews.llvm.org/D96976



More information about the cfe-commits mailing list