[analyzer] Fix crash for array-delete of UnknownVal values.
authorTomasz Kamiński <tomasz.kamiński@sonarsource.com>
Wed, 9 Nov 2022 13:31:49 +0000 (14:31 +0100)
committerTomasz Kamiński <tomasz.kamiński@sonarsource.com>
Wed, 9 Nov 2022 14:06:46 +0000 (15:06 +0100)
commit2fb3bec932ede7704724abb71e8270e0b4c201f6
treedb442e79e6132447aee50e6a4fe045751b60afe7
parent3dbda5ff88518912bbb72f03d95805634507ac17
[analyzer] Fix crash for array-delete of UnknownVal values.

We now skip the destruction of array elements for `delete[] p`,
if the value of `p` is UnknownVal and does not have corresponding region.
This eliminate the crash in `getDynamicElementCount` on that
region and matches the behavior for deleting the array of
non-constant range.

Reviewed By: isuckatcs

Differential Revision: https://reviews.llvm.org/D136671
clang/lib/StaticAnalyzer/Core/DynamicExtent.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/Analysis/dtor-array.cpp