[cfe-commits] r70836 - in /cfe/trunk: lib/Analysis/BasicStore.cpp lib/Analysis/Store.cpp test/Analysis/no-outofbounds.c test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c test/Analysis/xfail_regionstore_wine_crash.c
Ted Kremenek
kremenek at apple.com
Mon May 4 00:04:36 PDT 2009
Author: kremenek
Date: Mon May 4 02:04:36 2009
New Revision: 70836
URL: http://llvm.org/viewvc/llvm-project?rev=70836&view=rev
Log:
BasicStore: 'ElementRegion' is the new 'TypedViewRegion'.
StoreManager: Handle casts from one element region to another.
Update test cases.
Added:
cfe/trunk/test/Analysis/no-outofbounds.c
- copied, changed from r70834, cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c
Removed:
cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c
Modified:
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/Store.cpp
cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=70836&r1=70835&r2=70836&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Mon May 4 02:04:36 2009
@@ -217,7 +217,7 @@
// char buf[100];
// char *q = &buf[1]; // p points to ElementRegion(buf,Unknown)
// &q[10]
- assert(cast<ElementRegion>(R)->getIndex().isUnknown());
+ //assert(cast<ElementRegion>(R)->getIndex().isUnknown());
return Base;
}
@@ -287,18 +287,18 @@
case loc::MemRegionKind: {
const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
- if (const TypedViewRegion *TR = dyn_cast<TypedViewRegion>(R)) {
+ if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
// Just support void**, void***, intptr_t*, intptr_t**, etc., for now.
// This is needed to handle OSCompareAndSwapPtr() and friends.
ASTContext &Ctx = StateMgr.getContext();
- QualType T = TR->getLValueType(Ctx);
+ QualType T = ER->getLValueType(Ctx);
if (!isHigherOrderRawPtr(T, Ctx))
return UnknownVal();
- // Otherwise, strip the views.
- // FIXME: Should we layer a TypedView on the result?
- R = TR->removeViews();
+ // FIXME: Should check for element 0.
+ // Otherwise, strip the element region.
+ R = ER->getSuperRegion();
}
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
@@ -333,11 +333,12 @@
// a cast to intXX_t*, void*, etc. This is needed to handle
// OSCompareAndSwap32Barrier/OSCompareAndSwap64Barrier.
if (isa<Loc>(V) || isa<nonloc::LocAsInteger>(V))
- if (const TypedViewRegion *TR = dyn_cast<TypedViewRegion>(R)) {
- QualType T = TR->getLValueType(C);
+ if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
+ // FIXME: Should check for index 0.
+ QualType T = ER->getLValueType(C);
if (isHigherOrderRawPtr(T, C))
- R = TR->removeViews();
+ R = ER->getSuperRegion();
}
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
Modified: cfe/trunk/lib/Analysis/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Store.cpp?rev=70836&r1=70835&r2=70836&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Store.cpp (original)
+++ cfe/trunk/lib/Analysis/Store.cpp Mon May 4 02:04:36 2009
@@ -68,7 +68,12 @@
// FIXME: We should have a standard query function to get the size
// of the array index.
SVal Idx = ValMgr.makeZeroVal(ValMgr.getContext().VoidPtrTy);
- ElementRegion* ER = MRMgr.getElementRegion(Pointee, Idx, TR);
+
+ // If the super region is an element region, strip it away.
+ // FIXME: Is this the right thing to do in all cases?
+ const TypedRegion *Base = isa<ElementRegion>(TR) ?
+ cast<TypedRegion>(TR->getSuperRegion()) : TR;
+ ElementRegion* ER = MRMgr.getElementRegion(Pointee, Idx, Base);
return CastResult(state, ER);
}
}
Copied: cfe/trunk/test/Analysis/no-outofbounds.c (from r70834, cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/no-outofbounds.c?p2=cfe/trunk/test/Analysis/no-outofbounds.c&p1=cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c&r1=70834&r2=70836&rev=70836&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c (original)
+++ cfe/trunk/test/Analysis/no-outofbounds.c Mon May 4 02:04:36 2009
@@ -1,8 +1,5 @@
-// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region -verify %s
-// XFAIL
-
-// What we are seeing: Load or store into an out-of-bound memory position
-// This is bogus.
+// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region -verify %s &&
+// RUN: clang-cc -checker-cfref -analyze -analyzer-store=basic -verify %s
void f() {
long x = 0;
Removed: cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c?rev=70835&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c (original)
+++ cfe/trunk/test/Analysis/xfail_regionstore_bogus_array_bounds_failure.c (removed)
@@ -1,11 +0,0 @@
-// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region -verify %s
-// XFAIL
-
-// What we are seeing: Load or store into an out-of-bound memory position
-// This is bogus.
-
-void f() {
- long x = 0;
- char *y = (char*) &x;
- char c = y[0] + y[1] + y[2]; // no-warning
-}
Modified: cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c?rev=70836&r1=70835&r2=70836&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c (original)
+++ cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c Mon May 4 02:04:36 2009
@@ -1,5 +1,4 @@
-// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region %s &&
-// RUN: clang-cc -checker-cfref -analyze -analyzer-store=basic %s
+// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region -verify %s
// XFAIL
// When this test passes we should put it in the misc-ps.m test file.
More information about the cfe-commits
mailing list