[PATCH] D66486: [LifetimeAnalysis] Detect more cases when the address of a local variable escapes

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 16:24:23 PDT 2019


xazax.hun added a comment.

In D66486#1640203 <https://reviews.llvm.org/D66486#1640203>, @mgehre wrote:

> In the false-positive example, after the `DerivedToBase`, we see a constructor call which I think is the copy constructor.


Yeah, but we do not have problems with the copy constructors.

> 1. We should consider `MutableArrayRef` to be a gsl::Pointer according to the paper, because it publicly derives from one.

So as soon as the user annotate a type as gsl::Pointer, this annotation should be applied to all derived classes? It would solve this particular issue. Also it feels a bit weird to change the ownership semantics in a derived class, I bet that would violate the Liskov substitution principle.

> 2. Also in the paper, the copy constructor does should copies the pset of the argument instead of making the pointer point at the argument.

This is exactly what the warnings are doing now. If the first gsl::Pointer is constructed from a second gsl::Pointer, we will just check if the second gsl::Pointer will dangle at the and of the expression and so on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66486





More information about the cfe-commits mailing list