]> granicus.if.org Git - clang/commitdiff
Use CharUnits for the offset amount of RegionRawOffset.
authorKen Dyck <kd@kendyck.com>
Mon, 24 Jan 2011 01:55:39 +0000 (01:55 +0000)
committerKen Dyck <kd@kendyck.com>
Mon, 24 Jan 2011 01:55:39 +0000 (01:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124093 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/PathSensitive/MemRegion.h
lib/StaticAnalyzer/MemRegion.cpp
lib/StaticAnalyzer/RegionStore.cpp
lib/StaticAnalyzer/SimpleSValBuilder.cpp
lib/StaticAnalyzer/Store.cpp

index 6e5790456c15ffdb39bb88a3fa3c3dd8c0f0de38..e18e681e77596cde314713895dc50ab0120529d0 100644 (file)
@@ -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 @@ private:
   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;
index d3d72b51a73a2987f86243a48b47661e10987d57..eca7619d3fc49eb0c5810eb9558e53a2fea89b45 100644 (file)
@@ -469,7 +469,7 @@ void RegionRawOffset::dump() const {
 }
 
 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 @@ RegionRawOffset ElementRegion::getAsArrayOffset() const {
   }
 
   assert(superR && "super region cannot be NULL");
-  return RegionRawOffset(superR, offset.getQuantity());
+  return RegionRawOffset(superR, offset);
 }
 
 RegionOffset MemRegion::getAsOffset() const {
index 3c048064f6e3a43bef855ac9ee6c67bb4482f51e..986278e628493a34525d514d47a2dd16872ed4b4 100644 (file)
@@ -86,7 +86,7 @@ BindingKey BindingKey::Make(const MemRegion *R, Kind k) {
     // 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);
index a6432121f5441423406e99e1aeeb3dc0983371c3..6c65da4635be5a164b79073d3f8640abc4cc56c3 100644 (file)
@@ -724,8 +724,8 @@ SVal SimpleSValBuilder::evalBinOpLL(const GRState *state,
 
       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:
index d162eed24773e06b7695b8bcb9be7814840a64c7..fa671a3bb0e88d4312ed1c1f46812ba6c5e04c37 100644 (file)
@@ -147,7 +147,7 @@ const MemRegion *StoreManager::CastRegion(const MemRegion *R, QualType CastToTy)
       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