diff options
| author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-04-01 08:20:27 +0000 |
|---|---|---|
| committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-04-01 08:20:27 +0000 |
| commit | 640aad76674b9e580f50123dd05d6da5580857fe (patch) | |
| tree | 1f31e6c99bfb86f910d89cd4c5102cbe83180767 /clang/lib/Checker | |
| parent | 920070cfe7c3c03f77acc41f45fbf6337ff08abd (diff) | |
| download | bcm5719-llvm-640aad76674b9e580f50123dd05d6da5580857fe.tar.gz bcm5719-llvm-640aad76674b9e580f50123dd05d6da5580857fe.zip | |
Use the element type to compute the array size when the base region is a VarRegion.
Patch by Jordy Rose.
llvm-svn: 100099
Diffstat (limited to 'clang/lib/Checker')
| -rw-r--r-- | clang/lib/Checker/RegionStore.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp index b333a5d2830..c97da33aaac 100644 --- a/clang/lib/Checker/RegionStore.cpp +++ b/clang/lib/Checker/RegionStore.cpp @@ -787,9 +787,12 @@ DefinedOrUnknownSVal RegionStoreManager::getSizeInElements(const GRState *state, return ValMgr.makeIntVal(CAT->getSize(), false); } - // Clients can use ordinary variables as if they were arrays. These - // essentially are arrays of size 1. - return ValMgr.makeIntVal(1, false); + // Clients can reinterpret ordinary variables as arrays, possibly of + // another type. The width is rounded down to ensure that an access is + // entirely within bounds. + CharUnits VarSize = getContext().getTypeSizeInChars(T); + CharUnits EleSize = getContext().getTypeSizeInChars(EleTy); + return ValMgr.makeIntVal(VarSize / EleSize, false); } } |

