aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/Store.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/Store.cpp')
-rw-r--r--lib/Analysis/Store.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index f0ecda73de..d1abd57640 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -27,7 +27,7 @@ StoreManager::MakeElementRegion(const GRState *state, const MemRegion *region,
// Create a new ElementRegion.
SVal idx = ValMgr.makeArrayIndex(index);
return CastResult(state, MRMgr.getElementRegion(pointeeTy, idx, region,
- ValMgr.getContext()));
+ ValMgr.getContext()));
}
// FIXME: Merge with the implementation of the same method in MemRegion.cpp
@@ -37,16 +37,16 @@ static bool IsCompleteType(ASTContext &Ctx, QualType Ty) {
if (!D->getDefinition(Ctx))
return false;
}
-
+
return true;
}
StoreManager::CastResult
StoreManager::CastRegion(const GRState *state, const MemRegion* R,
QualType CastToTy) {
-
+
ASTContext& Ctx = StateMgr.getContext();
-
+
// Handle casts to Objective-C objects.
if (CastToTy->isObjCObjectPointerType())
return CastResult(state, R->getBaseRegion());
@@ -55,7 +55,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// FIXME: We may need different solutions, depending on the symbol
// involved. Blocks can be casted to/from 'id', as they can be treated
// as Objective-C objects. This could possibly be handled by enhancing
- // our reasoning of downcasts of symbolic objects.
+ // our reasoning of downcasts of symbolic objects.
if (isa<CodeTextRegion>(R) || isa<SymbolicRegion>(R))
return CastResult(state, R);
@@ -72,7 +72,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// Handle casts to void*. We just pass the region through.
if (CanonPointeeTy.getUnqualifiedType() == Ctx.VoidTy)
return CastResult(state, R);
-
+
// Handle casts from compatible types.
if (R->isBoundable())
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
@@ -90,7 +90,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
case MemRegion::END_TYPED_REGIONS: {
assert(0 && "Invalid region cast");
break;
- }
+ }
case MemRegion::CodeTextRegionKind: {
// CodeTextRegion should be cast to only a function or block pointer type,
// although they can in practice be casted to anything, e.g, void*,
@@ -98,7 +98,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// Just pass the region through.
break;
}
-
+
case MemRegion::StringRegionKind:
case MemRegion::ObjCObjectRegionKind:
// FIXME: Need to handle arbitrary downcasts.
@@ -107,9 +107,9 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
case MemRegion::CompoundLiteralRegionKind:
case MemRegion::FieldRegionKind:
case MemRegion::ObjCIvarRegionKind:
- case MemRegion::VarRegionKind:
+ case MemRegion::VarRegionKind:
return MakeElementRegion(state, R, PointeeTy, CastToTy);
-
+
case MemRegion::ElementRegionKind: {
// If we are casting from an ElementRegion to another type, the
// algorithm is as follows:
@@ -117,51 +117,51 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// (1) Compute the "raw offset" of the ElementRegion from the
// base region. This is done by calling 'getAsRawOffset()'.
//
- // (2a) If we get a 'RegionRawOffset' after calling
+ // (2a) If we get a 'RegionRawOffset' after calling
// 'getAsRawOffset()', determine if the absolute offset
- // can be exactly divided into chunks of the size of the
- // casted-pointee type. If so, create a new ElementRegion with
+ // can be exactly divided into chunks of the size of the
+ // casted-pointee type. If so, create a new ElementRegion with
// the pointee-cast type as the new ElementType and the index
// being the offset divded by the chunk size. If not, create
// a new ElementRegion at offset 0 off the raw offset region.
//
// (2b) If we don't a get a 'RegionRawOffset' after calling
// 'getAsRawOffset()', it means that we are at offset 0.
- //
+ //
// FIXME: Handle symbolic raw offsets.
-
+
const ElementRegion *elementR = cast<ElementRegion>(R);
const RegionRawOffset &rawOff = elementR->getAsRawOffset();
const MemRegion *baseR = rawOff.getRegion();
-
+
// If we cannot compute a raw offset, throw up our hands and return
// a NULL MemRegion*.
if (!baseR)
return CastResult(state, NULL);
-
+
int64_t off = rawOff.getByteOffset();
-
+
if (off == 0) {
// Edge case: we are at 0 bytes off the beginning of baseR. We
// check to see if type we are casting to is the same as the base
- // region. If so, just return the base region.
+ // region. If so, just return the base region.
if (const TypedRegion *TR = dyn_cast<TypedRegion>(baseR)) {
QualType ObjTy = Ctx.getCanonicalType(TR->getValueType(Ctx));
QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
if (CanonPointeeTy == ObjTy)
return CastResult(state, baseR);
}
-
+
// Otherwise, create a new ElementRegion at offset 0.
return MakeElementRegion(state, baseR, PointeeTy, CastToTy, 0);
}
-
+
// We have a non-zero offset from the base region. We want to determine
// if the offset can be evenly divided by sizeof(PointeeTy). If so,
// we create an ElementRegion whose index is that value. Otherwise, we
// create two ElementRegions, one that reflects a raw offset and the other
// that reflects the cast.
-
+
// Compute the index for the new ElementRegion.
int64_t newIndex = 0;
const MemRegion *newSuperR = 0;
@@ -179,18 +179,18 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
newSuperR = baseR;
}
}
-
+
if (!newSuperR) {
// Create an intermediate ElementRegion to represent the raw byte.
// This will be the super region of the final ElementRegion.
SVal idx = ValMgr.makeArrayIndex(off);
newSuperR = MRMgr.getElementRegion(Ctx.CharTy, idx, baseR, Ctx);
}
-
+
return MakeElementRegion(state, newSuperR, PointeeTy, CastToTy, newIndex);
}
}
-
+
return CastResult(state, R);
}
@@ -204,8 +204,8 @@ SValuator::CastResult StoreManager::CastRetrievedVal(SVal V,
QualType castTy) {
if (castTy.isNull())
return SValuator::CastResult(state, V);
-
- ASTContext &Ctx = ValMgr.getContext();
+
+ ASTContext &Ctx = ValMgr.getContext();
return ValMgr.getSValuator().EvalCast(V, state, castTy, R->getValueType(Ctx));
}