]> granicus.if.org Git - clang/commitdiff
Don't try and symbolicate unions; we don't reason
authorTed Kremenek <kremenek@apple.com>
Tue, 25 Jan 2011 21:08:47 +0000 (21:08 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 25 Jan 2011 21:08:47 +0000 (21:08 +0000)
about them yet.  Fixes crash reported in PR 9049.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124228 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/SymbolManager.cpp
test/Analysis/misc-ps-region-store.m

index 08677dafcfa06c9ac1c1cfc278b8491236b9b37b..518bb172d583dacd9de94eb56a89ac2d4e92e3a2 100644 (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;
index 13a2c1fbe9a72056086ec1ec1c022d390ef280b8..6bf79f5011b2a158f208a9b6f4e7435a62ac3321 100644 (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)) {
+  }
+}
+