diff options
-rw-r--r-- | lib/StaticAnalyzer/SymbolManager.cpp | 4 | ||||
-rw-r--r-- | test/Analysis/misc-ps-region-store.m | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/SymbolManager.cpp b/lib/StaticAnalyzer/SymbolManager.cpp index 08677dafcf..518bb172d5 100644 --- a/lib/StaticAnalyzer/SymbolManager.cpp +++ b/lib/StaticAnalyzer/SymbolManager.cpp @@ -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; diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index 13a2c1fbe9..6bf79f5011 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -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)) { + } +} + |