[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type
Denys Petrov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 1 05:34:19 PDT 2021
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: aaron.ballman, martong, steakhal, NoQ, r.stahl.
ASDenysPetrov added a project: clang.
Herald added subscribers: manas, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.
Fixed cases in which RegionStore is able to get a stored value of a constant array through a pointer of inappropriate type. Adjust `RegionStoreManager::getBindingForElement` to the C++20 Standard.
Example:
const int arr[42] = {1,2,3};
int x1 = ((unsigned*)arr)[0]; // valid
int x2 = ((short*)arr)[0]; // invalid
int x3 = ((char*)arr)[0]; // valid
int x4 = ((char*)arr)[1]; // invalid
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110927
Files:
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/test/Analysis/initialization.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110927.376485.patch
Type: text/x-patch
Size: 6298 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211001/002cd06b/attachment.bin>
More information about the cfe-commits
mailing list