[cfe-commits] r71205 - /cfe/trunk/lib/Analysis/RegionStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Thu May 7 19:00:55 PDT 2009


Author: zhongxingxu
Date: Thu May  7 21:00:55 2009
New Revision: 71205

URL: http://llvm.org/viewvc/llvm-project?rev=71205&view=rev
Log:
Replace getTypeWidth() with ASTContext::getTypeSize().

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=71205&r1=71204&r2=71205&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu May  7 21:00:55 2009
@@ -312,45 +312,6 @@
   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 @@
       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





More information about the cfe-commits mailing list