[PATCH] D125709: [analyzer][Casting] Support isa, cast, dyn_cast of SVals

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 17 07:17:37 PDT 2022


steakhal added a comment.

In D125709#3518242 <https://reviews.llvm.org/D125709#3518242>, @martong wrote:

>> I'm not sure, shall I add tests?
>
> Yes, please. Unit tests for `dyn_cast` and `isa` should be easy. However, I am not sure how to test `cast` for the failure cases.

What if we were using the 'new' casting style at some places. If it compiles, it should be fine.
It feels weird to check stuff, only in `static_asserts`.

In D125709#3519033 <https://reviews.llvm.org/D125709#3519033>, @bzcheeseman wrote:

> In D125709#3518096 <https://reviews.llvm.org/D125709#3518096>, @steakhal wrote:
>
>> I had to fix the `doCast` to return `To` instead of `Optional<To>` to make it work.
>
> That's fine (or it should be!), you could dereference the optional if you wanted to

Currently, we expect that casts result in regular SVal objects, instead of pointer-like objects , thus this code to compile:
`NonLoc N = llvm::cast<NonLoc>(V)`, where `V` is of type `SVal`. I believe that is why I decided to make that change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125709



More information about the cfe-commits mailing list