[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs
authorBalazs Benics <balazs.benics@sigmatechnology.se>
Wed, 25 Aug 2021 14:12:17 +0000 (16:12 +0200)
committerBalazs Benics <balazs.benics@sigmatechnology.se>
Wed, 25 Aug 2021 14:12:17 +0000 (16:12 +0200)
commit360ced3b8fd2cfb9f2a26deb739e6c381e98b9a5
treedf0d3503398ee9b2f517ce91e88f0755bef3fb4d
parentba0af885e700fa939734820ce355933f1556119c
[analyzer] Ignore IncompleteArrayTypes in getStaticSize() for FAMs

Currently only `ConstantArrayType` is considered for flexible array
members (FAMs) in `getStaticSize()`.
However, `IncompleteArrayType` also shows up in practice as FAMs.

This patch will ignore the `IncompleteArrayType` and return Unknown
for that case as well. This way it will be at least consistent with
the current behavior until we start modeling them accurately.

I'm expecting that this will resolve a bunch of false-positives
internally, caused by the `ArrayBoundV2`.

Reviewed By: ASDenysPetrov

Differential Revision: https://reviews.llvm.org/D105184
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/test/Analysis/flexible-array-members.c [new file with mode: 0644]