From 8ca2dc05a385dab66978d9aad06b768bed270823 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Mon, 8 Feb 2010 08:43:02 +0000 Subject: [PATCH] Like for symbolic region, automatically create a element zero region for alloca region. llvm-svn: 95539 --- clang/lib/Checker/RegionStore.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp index 93905a29dacf..c08be0cff620 100644 --- a/clang/lib/Checker/RegionStore.cpp +++ b/clang/lib/Checker/RegionStore.cpp @@ -354,8 +354,7 @@ public: // Part of public interface to class. Store CopyLazyBindings(nonloc::LazyCompoundVal V, Store store, const TypedRegion *R); - const ElementRegion *GetElementZeroRegion(const SymbolicRegion *SR, - QualType T); + const ElementRegion *GetElementZeroRegion(const MemRegion *R, QualType T); //===------------------------------------------------------------------===// // State pruning. @@ -927,11 +926,11 @@ static bool IsReinterpreted(QualType RTy, QualType UsedTy, ASTContext &Ctx) { } const ElementRegion * -RegionStoreManager::GetElementZeroRegion(const SymbolicRegion *SR, QualType T) { +RegionStoreManager::GetElementZeroRegion(const MemRegion *R, QualType T) { ASTContext &Ctx = getContext(); SVal idx = ValMgr.makeZeroArrayIndex(); assert(!T.isNull()); - return MRMgr.getElementRegion(T, idx, SR, Ctx); + return MRMgr.getElementRegion(T, idx, R, Ctx); } SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) { @@ -945,17 +944,8 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) { const MemRegion *MR = cast(L).getRegion(); - // FIXME: return symbolic value for these cases. - // Example: - // void f(int* p) { int x = *p; } - // char* p = alloca(); - // read(p); - // c = *p; - if (isa(MR)) - return UnknownVal(); - - if (const SymbolicRegion *SR = dyn_cast(MR)) - MR = GetElementZeroRegion(SR, T); + if (isa(MR) || isa(MR)) + MR = GetElementZeroRegion(MR, T); if (isa(MR)) return UnknownVal();