summaryrefslogtreecommitdiffstats
path: root/clang/lib/Checker
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-04-01 08:20:27 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-04-01 08:20:27 +0000
commit640aad76674b9e580f50123dd05d6da5580857fe (patch)
tree1f31e6c99bfb86f910d89cd4c5102cbe83180767 /clang/lib/Checker
parent920070cfe7c3c03f77acc41f45fbf6337ff08abd (diff)
downloadbcm5719-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.cpp9
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);
}
}
OpenPOWER on IntegriCloud