This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] pr37152: Fix operator delete[] array-type-sub-expression handling.
ClosedPublic

Authored by NoQ on Apr 26 2018, 3:11 PM.

Details

Summary

When operator delete[] receives a sub-expression of array type, it destroys the array correctly. Even if it's multi-dimensional, simply because in this case it's an array of array-type objects and destroying such array would mean properly destroying each object, where the object itself is an array, so properly destroying it means destroying its objects, etc.

In this case the AST is saying that the destroyed type is an array type - and we weren't prepared for that.

For now there's no actual calling multiple destructors; at least we're trying not to crash.

Diff Detail

Repository
rL LLVM

Event Timeline

NoQ created this revision.Apr 26 2018, 3:11 PM
alexfh added a subscriber: alexfh.Apr 26 2018, 3:15 PM
alexfh added inline comments.
lib/StaticAnalyzer/Core/ExprEngine.cpp
1089–1091 ↗(On Diff #144212)

Maybe add a FIXME to model multiple destructor calls?

NoQ added inline comments.Apr 26 2018, 3:41 PM
lib/StaticAnalyzer/Core/ExprEngine.cpp
1089–1091 ↗(On Diff #144212)

Yep, we already have one a few lines above, for all kinds of destructors. The new code is not about supporting array delete in general; it's about supporting the situation when the sub-expression of the delete operator is of an array type, so there's nothing new here with respect to actually calling multiple destructors.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 26 2018, 7:19 PM
This revision was automatically updated to reflect the committed changes.