Use CharUnits for the offset amount of RegionRawOffset.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124093 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/StaticAnalyzer/PathSensitive/MemRegion.h b/include/clang/StaticAnalyzer/PathSensitive/MemRegion.h
index 6e57904..e18e681 100644
--- a/include/clang/StaticAnalyzer/PathSensitive/MemRegion.h
+++ b/include/clang/StaticAnalyzer/PathSensitive/MemRegion.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_CLANG_GR_MEMREGION_H
 #define LLVM_CLANG_GR_MEMREGION_H
 
+#include "clang/AST/CharUnits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/StaticAnalyzer/PathSensitive/SVals.h"
@@ -778,14 +779,14 @@
   friend class ElementRegion;
 
   const MemRegion *Region;
-  int64_t Offset;
+  CharUnits Offset;
 
-  RegionRawOffset(const MemRegion* reg, int64_t offset = 0)
+  RegionRawOffset(const MemRegion* reg, CharUnits offset = CharUnits::Zero())
     : Region(reg), Offset(offset) {}
 
 public:
   // FIXME: Eventually support symbolic offsets.
-  int64_t getByteOffset() const { return Offset; }
+  CharUnits getOffset() const { return Offset; }
   const MemRegion *getRegion() const { return Region; }
 
   void dumpToStream(llvm::raw_ostream& os) const;
diff --git a/lib/StaticAnalyzer/MemRegion.cpp b/lib/StaticAnalyzer/MemRegion.cpp
index d3d72b5..eca7619 100644
--- a/lib/StaticAnalyzer/MemRegion.cpp
+++ b/lib/StaticAnalyzer/MemRegion.cpp
@@ -469,7 +469,7 @@
 }
 
 void RegionRawOffset::dumpToStream(llvm::raw_ostream& os) const {
-  os << "raw_offset{" << getRegion() << ',' << getByteOffset() << '}';
+  os << "raw_offset{" << getRegion() << ',' << getOffset().getQuantity() << '}';
 }
 
 void StaticGlobalSpaceRegion::dumpToStream(llvm::raw_ostream &os) const {
@@ -855,7 +855,7 @@
   }
 
   assert(superR && "super region cannot be NULL");
-  return RegionRawOffset(superR, offset.getQuantity());
+  return RegionRawOffset(superR, offset);
 }
 
 RegionOffset MemRegion::getAsOffset() const {
diff --git a/lib/StaticAnalyzer/RegionStore.cpp b/lib/StaticAnalyzer/RegionStore.cpp
index 3c04806..986278e 100644
--- a/lib/StaticAnalyzer/RegionStore.cpp
+++ b/lib/StaticAnalyzer/RegionStore.cpp
@@ -86,7 +86,7 @@
     // FIXME: There are some ElementRegions for which we cannot compute
     // raw offsets yet, including regions with symbolic offsets. These will be
     // ignored by the store.
-    return BindingKey(O.getRegion(), O.getByteOffset(), k);
+    return BindingKey(O.getRegion(), O.getOffset().getQuantity(), k);
   }
 
   return BindingKey(R, 0, k);
diff --git a/lib/StaticAnalyzer/SimpleSValBuilder.cpp b/lib/StaticAnalyzer/SimpleSValBuilder.cpp
index a643212..6c65da4 100644
--- a/lib/StaticAnalyzer/SimpleSValBuilder.cpp
+++ b/lib/StaticAnalyzer/SimpleSValBuilder.cpp
@@ -724,8 +724,8 @@
 
       if (LeftOffset.getRegion() != NULL &&
           LeftOffset.getRegion() == RightOffset.getRegion()) {
-        int64_t left = LeftOffset.getByteOffset();
-        int64_t right = RightOffset.getByteOffset();
+        CharUnits left = LeftOffset.getOffset();
+        CharUnits right = RightOffset.getOffset();
 
         switch (op) {
         default:
diff --git a/lib/StaticAnalyzer/Store.cpp b/lib/StaticAnalyzer/Store.cpp
index d162eed..fa671a3 100644
--- a/lib/StaticAnalyzer/Store.cpp
+++ b/lib/StaticAnalyzer/Store.cpp
@@ -147,7 +147,7 @@
       if (!baseR)
         return NULL;
 
-      CharUnits off = CharUnits::fromQuantity(rawOff.getByteOffset());
+      CharUnits off = rawOff.getOffset();
 
       if (off.isZero()) {
         // Edge case: we are at 0 bytes off the beginning of baseR.  We