[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
Mon Aug 26 15:16:35 PDT 2019


xazax.hun abandoned this revision.
xazax.hun added a comment.

It looks like this solution is not going to work in general. The problem is that it can be really hard to tell when it is valid to create a gsl::Pointer from an unannotated local type.

For example the code below is definitely buggy:

  reference_wrapper<int> f() {
    int i;
    return i; // Invalid!
  }

While the code below can be safe:

  some_iterator f() {
    MyUnannotatedSpan local = ...;
    return std::begin(local); // this is fine
  }

Note that, this problem will be solved once we have function annotations, as each constructor can be annotated what it actually does.


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