Don't try and symbolicate unions; we don't reason

about them yet.  Fixes crash reported in PR 9049.

llvm-svn: 124228
This commit is contained in:
Ted Kremenek 2011-01-25 21:08:47 +00:00
parent 2992efa403
commit fedad3c668
2 changed files with 23 additions and 1 deletions

View File

@ -233,13 +233,15 @@ QualType SymbolRegionValue::getType(ASTContext& C) const {
SymbolManager::~SymbolManager() {}
bool SymbolManager::canSymbolicate(QualType T) {
T = T.getCanonicalType();
if (Loc::IsLocType(T))
return true;
if (T->isIntegerType())
return T->isScalarType();
if (T->isRecordType())
if (T->isRecordType() && !T->isUnionType())
return true;
return false;

View File

@ -1217,3 +1217,23 @@ int rdar8848957(int index) {
vals[index] = foo_rdar8848957();
return vals[index].x; // no-warning
}
// PR 9049 - crash on symbolicating unions. This test exists solely to
// test that the analyzer doesn't crash.
typedef struct pr9048_cdev *pr9048_cdev_t;
typedef union pr9048_abstracted_disklabel { void *opaque; } pr9048_disklabel_t;
struct pr9048_diskslice { pr9048_disklabel_t ds_label; };
struct pr9048_diskslices {
int dss_secmult;
struct pr9048_diskslice dss_slices[16];
};
void pr9048(pr9048_cdev_t dev, struct pr9048_diskslices * ssp, unsigned int slice)
{
pr9048_disklabel_t lp;
struct pr9048_diskslice *sp;
sp = &ssp->dss_slices[slice];
if (ssp->dss_secmult == 1) {
} else if ((lp = sp->ds_label).opaque != ((void *) 0)) {
}
}