Pull the region offset computation logic into a single method.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110102 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/FlatStore.cpp b/lib/Checker/FlatStore.cpp
index 51c537e..e1683e5 100644
--- a/lib/Checker/FlatStore.cpp
+++ b/lib/Checker/FlatStore.cpp
@@ -192,14 +192,13 @@
 
   case MemRegion::ElementRegionKind: 
   case MemRegion::FieldRegionKind: {
-    const TypedRegion *TR = cast<TypedRegion>(R);
-    RegionOffset Offset = TR->getAsOffset();
-    // We cannot compute offset for all ElementRegions, for example, elements
+    RegionOffset Offset = R->getAsOffset();
+    // We cannot compute offset for all regions, for example, elements
     // with symbolic offsets.
     if (!Offset.getRegion())
       return RegionInterval(0, 0, 0);
     uint64_t Start = Offset.getOffset();
-    uint64_t Size = Ctx.getTypeSize(TR->getValueType(Ctx));
+    uint64_t Size = Ctx.getTypeSize(cast<TypedRegion>(R)->getValueType(Ctx));
     return RegionInterval(Offset.getRegion(), Start, Start+Size);
   }