diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-11-09 02:11:43 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-11-09 02:11:43 +0000 |
| commit | dcf85a8d18e003a6053ca45078fc109339e07db3 (patch) | |
| tree | a5a94fb4446ba32ee4fb2fa151dfe5d524c2ef14 /clang/lib/Checker/AttrNonNullChecker.cpp | |
| parent | 16e6026f019e1117e71e19e450c23c8beabe462d (diff) | |
| download | bcm5719-llvm-dcf85a8d18e003a6053ca45078fc109339e07db3.tar.gz bcm5719-llvm-dcf85a8d18e003a6053ca45078fc109339e07db3.zip | |
Teach AttrNonNullChecker about transparent unions. Fixes crash reported in <rdar://problem/8642434>.
llvm-svn: 118473
Diffstat (limited to 'clang/lib/Checker/AttrNonNullChecker.cpp')
| -rw-r--r-- | clang/lib/Checker/AttrNonNullChecker.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Checker/AttrNonNullChecker.cpp b/clang/lib/Checker/AttrNonNullChecker.cpp index d0bccb27b40..54b7b72d43b 100644 --- a/clang/lib/Checker/AttrNonNullChecker.cpp +++ b/clang/lib/Checker/AttrNonNullChecker.cpp @@ -67,6 +67,28 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C, if (!DV) continue; + if (!isa<Loc>(*DV)) { + // If the argument is a union type, we want to handle a potential + // transparent_unoin GCC extension. + QualType T = (*I)->getType(); + const RecordType *UT = T->getAsUnionType(); + if (!UT || !UT->getDecl()->hasAttr<TransparentUnionAttr>()) + continue; + if (nonloc::CompoundVal *CSV = dyn_cast<nonloc::CompoundVal>(DV)) { + nonloc::CompoundVal::iterator CSV_I = CSV->begin(); + assert(CSV_I != CSV->end()); + V = *CSV_I; + DV = dyn_cast<DefinedSVal>(&V); + assert(++CSV_I == CSV->end()); + if (!DV) + continue; + } + else { + // FIXME: Handle LazyCompoundVals? + continue; + } + } + ConstraintManager &CM = C.getConstraintManager(); const GRState *stateNotNull, *stateNull; llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, *DV); |

