summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/RegionStore.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-05-08 02:00:55 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-05-08 02:00:55 +0000
commitc0c074655de8f6f5719a116017db660051f98646 (patch)
tree6332a8945518d72db5617ac19afa5d802022e14f /clang/lib/Analysis/RegionStore.cpp
parent1ba79dfeea7fb57ec51432f6bd70878c43343658 (diff)
downloadbcm5719-llvm-c0c074655de8f6f5719a116017db660051f98646.tar.gz
bcm5719-llvm-c0c074655de8f6f5719a116017db660051f98646.zip
Replace getTypeWidth() with ASTContext::getTypeSize().
llvm-svn: 71205
Diffstat (limited to 'clang/lib/Analysis/RegionStore.cpp')
-rw-r--r--clang/lib/Analysis/RegionStore.cpp49
1 files changed, 5 insertions, 44 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp
index 74e20698331..ea42c465aa5 100644
--- a/clang/lib/Analysis/RegionStore.cpp
+++ b/clang/lib/Analysis/RegionStore.cpp
@@ -312,45 +312,6 @@ StoreManager* clang::CreateRegionStoreManager(GRStateManager& StMgr) {
return new RegionStoreManager(StMgr);
}
-// getTypeWidth - compute the width of the type. Should pass in
-// canonical type.
-static unsigned getTypeWidth(ASTContext& Ctx, QualType T) {
- TargetInfo& Target = Ctx.Target;
- QualType CanT = Ctx.getCanonicalType(T);
-
- if (CanT->isPointerType())
- return Target.getPointerWidth(0);
-
- if (CanT->isCharType())
- return Target.getCharWidth();
-
- if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanT)) {
- switch (BT->getKind()) {
- case BuiltinType::Char_U:
- case BuiltinType::UChar:
- case BuiltinType::Char_S:
- case BuiltinType::SChar:
- return Target.getCharWidth();
-
- case BuiltinType::UShort:
- case BuiltinType::Short:
- return Target.getShortWidth();
-
- case BuiltinType::UInt:
- case BuiltinType::Int:
- return Target.getIntWidth();
-
- case BuiltinType::ULong:
- case BuiltinType::Long:
- return Target.getLongWidth();
- default:
- assert(0 && "Unprocessed builtin type.");
- }
- }
-
- assert(0 && "Unprocessed type.");
-}
-
SubRegionMap* RegionStoreManager::getSubRegionMap(const GRState *state) {
RegionBindingsTy B = GetRegionBindings(state->getStore());
RegionStoreSubRegionMap *M = new RegionStoreSubRegionMap();
@@ -542,17 +503,17 @@ SVal RegionStoreManager::getSizeInElements(const GRState* St,
return NonLoc::MakeVal(getBasicVals(), CAT->getSize(), false);
}
- // If the VarRegion is cast to other type, compute the size with respect to
- // that type.
GRStateRef state(St, StateMgr);
const QualType* CastTy = state.get<RegionCasts>(VR);
+ // If the VarRegion is cast to other type, compute the size with respect to
+ // that type.
if (CastTy) {
QualType EleTy =cast<PointerType>(CastTy->getTypePtr())->getPointeeType();
QualType VarTy = VR->getRValueType(getContext());
- unsigned EleWidth = getTypeWidth(getContext(), EleTy);
- unsigned VarWidth = getTypeWidth(getContext(), VarTy);
- return NonLoc::MakeIntVal(getBasicVals(), VarWidth / EleWidth, false);
+ uint64_t EleSize = getContext().getTypeSize(EleTy);
+ uint64_t VarSize = getContext().getTypeSize(VarTy);
+ return NonLoc::MakeIntVal(getBasicVals(), VarSize / EleSize, false);
}
// Clients can use ordinary variables as if they were arrays. These
OpenPOWER on IntegriCloud