[PATCH] D104550: [analyzer] Implement getType for SVal

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 23 02:10:46 PDT 2021


NoQ added a comment.

Another thing to mention about `SVal::getType()` in its doxygen comment is that //most of the time you don't need it//. Similarly to how checking whether an `SVal` is a `Loc` or a `NonLoc` results in incorrect code 95% of the time (because such code is unable to discriminate between arbitrary lvalues and pointer rvalues which is typically crucial in order to get everything right but often forgotten / misunderstood), relying on the type of the `SVal` rather than its storage raises similar problems.

The use case in `RegionStore` that I mentioned in the beginning is the rare exception to this rule of thumb because there's no AST expressions to tell us the type of the storage and on top of that type punning makes the storage basically entirely untyped. There's really no other way to obtain such information. Bytes in memory really don't have a type; it's very much a matter of convenient abstraction for us to associate type with them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104550



More information about the cfe-commits mailing list