[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 17 21:10:51 PDT 2021


NoQ added a comment.

By tracking the call-expression you're basically tracking the raw pointer value because that's what operators `*` and `->` return. Of course operator `*` returns an lvalue reference rather than a pointer but we don't make a difference when it comes to `SVal` representation.

F15896979: 525m0x.jpg <https://reviews.llvm.org/F15896979>

So you're saying that simply by always tracking the (final) raw pointer value and checking whether the raw value is interesting upon `.get()` you dodge the communication problem entirely. I think this is quite a statement! I'd like a stronger evidence for that than passing a couple of tests. Does the following test work?:

  void test(std::unique_ptr<A> P) {
    A *a = P.get(); // unlike your positive test this doesn't deserve a note
                    // because we weren't looking at 'a' when we concluded
                    // that the pointer is null
    if (!P) {
      P->foo();
    }
  }



> Essentially, when a `unique_ptr` is moved and subsequently used, it triggers two warnings - one from `SmartPointerModelling` and another from `MoveChecker`

Do i understand correctly that this doesn't happen anymore when you stopped creating a new node?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183



More information about the cfe-commits mailing list