[PATCH] D127306: [analyzer] Treat system globals as mutable if they are not const
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 8 07:10:41 PDT 2022
steakhal created this revision.
steakhal added reviewers: NoQ, martong, ASDenysPetrov, balazske, Szelethus, gamesh411.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Previously, system globals were treated as immutable regions, unless it
was the `errno` which is known to be frequently modified.
D124244 <https://reviews.llvm.org/D124244> wants to add a check for stores to immutable regions.
It would basically turn all stores to system globals into an error even
though we have no reason to believe that those mutable sys globals
should be treated as if they were immutable. And this leads to
false-positives if we apply D124244 <https://reviews.llvm.org/D124244>.
In this patch, I'm proposing to treat mutable sys globals actually
mutable, hence allocate them into the `GlobalSystemSpaceRegion`, UNLESS
they were declared as `const` (and a primitive arithmetic type), in
which case, we should use `GlobalImmutableSpaceRegion`.
In any other cases, I'm using the `GlobalInternalSpaceRegion`, which is
no different than the previous behavior.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127306
Files:
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/test/Analysis/Inputs/some_system_globals.h
clang/test/Analysis/Inputs/some_user_globals.h
clang/test/Analysis/global-region-invalidation.c
clang/test/Analysis/globals-are-not-always-immutable.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127306.435147.patch
Type: text/x-patch
Size: 5269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220608/784646d1/attachment.bin>
More information about the cfe-commits
mailing list