[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 22 15:31:38 PDT 2021


NoQ added a comment.

In D104616#2830349 <https://reviews.llvm.org/D104616#2830349>, @xazax.hun wrote:

> In D104616#2829705 <https://reviews.llvm.org/D104616#2829705>, @RedDocMD wrote:
>
>> If `(ptr1 == ptr2)` is false, we can't say anything really.
>
> Well, I think it depends. If one of the pointers is null, for some platforms, we can. E.g. null < non-null is probably true on most architectures, and similarly non-null < null is false. Also null <= anyptr is probably true on the platforms we care about.
>
>> If they are not the same, the only way == can return true if the two smart pointers were initialized from the same raw pointer. This is of course a fatal bug in itself.
>
> Is it? E.g. two default constructed unique_ptrs both should have null as the underlying pointer, they should be considered equal, are not the same object, and this is not a fatal bug.

Why not simply delegate this job to `assume(evalBinOp(...))` over raw pointer values, which already has all this logic written down nicely?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104616



More information about the cfe-commits mailing list