diff options
author | Anna Zaks <ganna@apple.com> | 2013-03-15 23:34:25 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-03-15 23:34:25 +0000 |
commit | f510f5cd57fa9b7ea6f6e103c65c0df95a55d986 (patch) | |
tree | c303571e0a19bb19b87ba3f0a1edf43631e918c0 /lib/StaticAnalyzer/Core | |
parent | f8ba81e8bbc4d0d424c3b4c3581a9467e972c4de (diff) |
[analyzer] BugReporterVisitors: handle the case where a ternary operator is wrapped in a cast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177205 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core')
-rw-r--r-- | lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index d5b4714451..6e5f6b8f2c 100644 --- a/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -787,14 +787,17 @@ bool bugreporter::trackNullOrUndefValue(const ExplodedNode *N, S = OVE->getSourceExpr(); // Peel off the ternary operator. - if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(S)) { - ProgramStateRef State = N->getState(); - SVal CondVal = State->getSVal(CO->getCond(), N->getLocationContext()); - if (State->isNull(CondVal).isConstrainedTrue()) { - S = CO->getTrueExpr(); - } else { - assert(State->isNull(CondVal).isConstrainedFalse()); - S = CO->getFalseExpr(); + if (const Expr *Ex = dyn_cast<Expr>(S)) { + Ex = Ex->IgnoreParenCasts(); + if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(Ex)) { + ProgramStateRef State = N->getState(); + SVal CondVal = State->getSVal(CO->getCond(), N->getLocationContext()); + if (State->isNull(CondVal).isConstrainedTrue()) { + S = CO->getTrueExpr(); + } else { + assert(State->isNull(CondVal).isConstrainedFalse()); + S = CO->getFalseExpr(); + } } } |