This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] pr37688: Fix a crash on trying to evaluate a deleted destructor of a union.
ClosedPublic

Authored by NoQ on Jan 17 2019, 8:21 PM.

Details

Summary

This is a slow quick fix for https://bugs.llvm.org/show_bug.cgi?id=37688 - add a defensive check against an invalid destructor in the CFG.

Unions with fields with destructors have their own destructor implicitly deleted. Due to a bug in the CFG we're still trying to evaluate them at the end of the object's lifetime and crash because we are unable to find the declaration.

Add a FIXME test for the CFG that demonstrates the bug and a normal test that demonstrates that we've fixed the crash and are even trying to continue the analysis beyond that point.

I've no idea why did this require a noexcept specification. I also don't know why does it require that many levels of structure nestedness; it might be that Clang doesn't emit an error in this case but in fact the code is invalid - an error about attempting to rely upon a deleted destructor is emitted in many simpler cases.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Jan 17 2019, 8:21 PM
george.karpenkov accepted this revision.Jan 18 2019, 2:24 PM

The code is fine, but I obviously would prefer a proper fix in a CFG

This revision is now accepted and ready to land.Jan 18 2019, 2:24 PM
This revision was automatically updated to reflect the committed changes.