diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-11 00:11:10 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-11 00:11:10 +0000 |
commit | 1670e403c48f3af4fceff3f6773a0e1cfc6c4eb3 (patch) | |
tree | 3b1044513e874e7285fa3b8a874122286b97066b /lib/Analysis/BasicStore.cpp | |
parent | c2112181b96349eb595dc5e8b7073b81ecdec0db (diff) |
Implement analyzer support for OSCompareAndSwap. This required pushing "tagged"
ProgramPoints all the way through to GRCoreEngine.
NSString.m now fails with RegionStoreManager because of the void** cast.
Disabling use of region store for that test for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicStore.cpp')
-rw-r--r-- | lib/Analysis/BasicStore.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index 41776edbbb..566c1971b7 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -282,6 +282,23 @@ SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base, return UnknownVal(); } +static bool isHigherOrderVoidPtr(QualType T, ASTContext &C) { + bool foundPointer = false; + while (1) { + const PointerType *PT = T->getAsPointerType(); + if (!PT) { + if (!foundPointer) + return false; + + QualType X = C.getCanonicalType(T).getUnqualifiedType(); + return X == C.VoidTy; + } + + foundPointer = true; + T = PT->getPointeeType(); + } +} + SVal BasicStoreManager::Retrieve(const GRState* state, Loc loc, QualType T) { if (isa<UnknownVal>(loc)) @@ -294,6 +311,20 @@ SVal BasicStoreManager::Retrieve(const GRState* state, Loc loc, QualType T) { case loc::MemRegionKind: { const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion(); + if (const TypedViewRegion *TR = dyn_cast<TypedViewRegion>(R)) { + // Just support void**, void***, etc., for now. This is needed + // to handle OSCompareAndSwapPtr(). + ASTContext &Ctx = StateMgr.getContext(); + QualType T = TR->getLValueType(Ctx); + + if (!isHigherOrderVoidPtr(T, Ctx)) + return UnknownVal(); + + // Otherwise, strip the views. + // FIXME: Should we layer a TypedView on the result? + R = TR->removeViews(); + } + if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R))) return UnknownVal(); |