diff options
author | Anna Zaks <ganna@apple.com> | 2013-03-06 20:26:02 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-03-06 20:26:02 +0000 |
commit | 42773d64f98db0dd5cc80181c3b2d561851668f7 (patch) | |
tree | d7e3e504e7b01a5a4bb04df12940f5a62f718355 /lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp | |
parent | 713e07591995d761f65c7132289dce003a29870f (diff) |
[analyzer] Pass the correct Expr to the bug reporter visitors when dealing with CompoundLiteralExpr
This allows us to trigger the IDC visitor in the added test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176577 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp b/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp index de5e6dca5e..87e218505b 100644 --- a/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp @@ -57,10 +57,11 @@ void AttrNonNullChecker::checkPreCall(const CallEvent &Call, if (!DV) continue; + const Expr *ArgE = Call.getArgExpr(idx); + if (!DV->getAs<Loc>()) { // If the argument is a union type, we want to handle a potential // transparent_union GCC extension. - const Expr *ArgE = Call.getArgExpr(idx); if (!ArgE) continue; @@ -77,7 +78,13 @@ void AttrNonNullChecker::checkPreCall(const CallEvent &Call, DV = V.getAs<DefinedSVal>(); assert(++CSV_I == CSV->end()); if (!DV) - continue; + continue; + // Retrieve the corresponding expression. + if (const CompoundLiteralExpr *CE = dyn_cast<CompoundLiteralExpr>(ArgE)) + if (const InitListExpr *IE = + dyn_cast<InitListExpr>(CE->getInitializer())) + ArgE = dyn_cast<Expr>(*(IE->begin())); + } else { // FIXME: Handle LazyCompoundVals? continue; @@ -106,7 +113,7 @@ void AttrNonNullChecker::checkPreCall(const CallEvent &Call, // Highlight the range of the argument that was null. R->addRange(Call.getArgSourceRange(idx)); - if (const Expr *ArgE = Call.getArgExpr(idx)) + if (ArgE) bugreporter::trackNullOrUndefValue(errorNode, ArgE, *R); // Emit the bug report. C.emitReport(R); |