This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] pr37166, pr37139: Disable constructor inlining when lifetime extension through aggregate initialization occurs.
ClosedPublic

Authored by NoQ on Apr 24 2018, 6:20 PM.

Details

Summary

This hotfix is similar to D43689 (and needs a follow-up similar to D44238 and D44239). CFG again doesn't provide us with correct automatic destructors, this time it's in the following code:

struct A {
  const C &c;
};

void foo() {
  A a = { C() };
}

In this code a is an aggregate, so it doesn't require construction or destruction. Instead, C() is lifetime-extended until the end of a's scope.

Additionally, we used to crash on my defensive "i know C++" assertion (no, i don't).

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Apr 24 2018, 6:20 PM
NoQ updated this revision to Diff 143850.Apr 24 2018, 6:33 PM

Add a test similar to pr37166. It should be actually fixed now with this patch. Essentially, we may also be lifetime-extended by an array of aggregate structures (with arbitrary amounts of interleaving array and aggregate structure brace-initializers).

pirama added a subscriber: pirama.Apr 25 2018, 11:02 AM
NoQ edited the summary of this revision. (Show Details)Apr 25 2018, 3:51 PM
This revision was not accepted when it landed; it landed in state Needs Review.Apr 25 2018, 4:05 PM
This revision was automatically updated to reflect the committed changes.