This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Deprecate FAM analyzer-config, recommend -fstrict-flex-arrays instead
ClosedPublic

Authored by steakhal on Nov 24 2022, 4:46 AM.

Details

Summary

By default, clang assumes that all trailing array objects could be a
FAM. So, an array of undefined size, size 0, size 1, or even size 42 is
considered as FAMs for optimizations at least.

One needs to override the default behavior by supplying the
-fstrict-flex-arrays=<N> flag, with N > 0 value to reduce the set of
FAM candidates. Value 3 is the most restrictive and 0 is the most
permissive on this scale.

0: all trailing arrays are FAMs
1: only incomplete, zero and one-element arrays are FAMs
2: only incomplete, zero-element arrays are FAMs
3: only incomplete arrays are FAMs

If the user is happy with considering single-element arrays as FAMs, they
just need to remove the
consider-single-element-arrays-as-flexible-array-members from the
command line.
Otherwise, if they don't want to recognize such cases as FAMs, they
should specify -fstrict-flex-arrays anyway, which will be picked up by
CSA.

Any use of the deprecated analyzer-config value will trigger a warning
explaining what to use instead.
The -analyzer-config-help is updated accordingly.

Depends on D138657

Diff Detail

Event Timeline

steakhal created this revision.Nov 24 2022, 4:46 AM
Herald added a project: Restricted Project. · View Herald Transcript
steakhal requested review of this revision.Nov 24 2022, 4:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 24 2022, 4:46 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
xazax.hun accepted this revision.Nov 24 2022, 10:16 AM
This revision is now accepted and ready to land.Nov 24 2022, 10:16 AM
This revision was landed with ongoing or failed builds.Nov 25 2022, 1:25 AM
This revision was automatically updated to reflect the committed changes.