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 | e0f1a0f0d84932c9764ec5a5a3d953adc51cbe7d (patch) | |
| tree | 98f6c217f815aba9b41df110a575f5bce59b6221 /clang/lib/StaticAnalyzer | |
| parent | 313b101e274ec72e8717b1b38c9d84e8e1f61354 (diff) | |
| download | bcm5719-llvm-e0f1a0f0d84932c9764ec5a5a3d953adc51cbe7d.tar.gz bcm5719-llvm-e0f1a0f0d84932c9764ec5a5a3d953adc51cbe7d.zip | |
[analyzer] BugReporterVisitors: handle the case where a ternary operator is wrapped in a cast.
llvm-svn: 177205
Diffstat (limited to 'clang/lib/StaticAnalyzer')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index d5b4714451d..6e5f6b8f2c0 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/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(); + } } } |

