hanchenye-llvm-project/clang/test/Analysis/rdar-6442306-1.m

32 lines
848 B
Mathematica
Raw Normal View History

MemRegion: - Overhauled the notion of "types" for TypedRegions. We now distinguish between the "lvalue" of a region (via getLValueRegion()) and the "rvalue" of a region (va getRValueRegion()). Since a region represents a chunk of memory it has both, but we were conflating these concepts in some cases, leading to some insidious bugs. - Removed AnonPointeeType, partially because it is unused and because it doesn't have a clear notion of lvalue vs rvalue type. We can add it back once there is a need for it and we can resolve its role with these concepts. StoreManager: - Overhauled StoreManager::CastRegion. It expects an *lvalue* type for a region. This is actually what motivated the overhaul to the MemRegion type mechanism. It also no longer returns an SVal; we can just return a MemRegion*. - BasicStoreManager::CastRegion now overlays an "AnonTypedRegion" for pointer-pointer casts. This matches with the MemRegion changes. - Similar changes to RegionStore, except I've added a bunch of FIXMEs where it wasn't 100% clear where we should use TypedRegion::getRValueRegion() or TypedRegion::getLValueRegion(). AuditCFNumberCreate check: - Now blasts through AnonTypedRegions that may layer the original memory region, thus checking if the actually memory block is of the appropriate type. This change was needed to work with the changes to StoreManager::CastRegion. GRExprEngine::VisitCast: - Conform to the new interface of StoreManager::CastRegion. Tests: - None of the analysis tests fail now for using the "basic store". - Disabled the tests 'array-struct.c' and 'rdar-6442306-1.m' pending further testing and bug fixing. llvm-svn: 60995
2008-12-14 05:49:13 +08:00
// RUN: clang -checker-cfref %s --analyzer-store-basic -verify
// DISABLE: clang -checker-cfref %s --analyzer-store-region -verify
typedef int bar_return_t;
typedef struct {
unsigned char int_rep;
} Foo_record_t;
extern Foo_record_t Foo_record;
struct QuxSize {};
typedef struct QuxSize QuxSize;
typedef struct {
Foo_record_t Foo;
QuxSize size;
} __Request__SetPortalSize_t;
static __inline__ bar_return_t
__Beeble_check__Request__SetPortalSize_t(__attribute__((__unused__)) __Request__SetPortalSize_t *In0P) {
if (In0P->Foo.int_rep != Foo_record.int_rep) {
do {
int __i__, __C__ = (2);
for (__i__ = 0;
__i__ < __C__;
__i__++) do {
*(&((double *)(&In0P->size))[__i__]) =
__Foo_READSWAP__double(&((double *)(&In0P->size))[__i__]);
}
while (0);
}
while (0);
}
}