diff options
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp index fc49a46..1d8ef99 100644 --- a/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefBranchChecker.cpp @@ -37,12 +37,10 @@ class UndefBranchChecker : public Checker<check::BranchCondition> { if (!MatchesCriteria(Ex)) return nullptr; - for (Stmt::const_child_iterator I = Ex->child_begin(), - E = Ex->child_end();I!=E;++I) - if (const Expr *ExI = dyn_cast_or_null<Expr>(*I)) { - const Expr *E2 = FindExpr(ExI); - if (E2) return E2; - } + for (const Stmt *SubStmt : Ex->children()) + if (const Expr *ExI = dyn_cast_or_null<Expr>(SubStmt)) + if (const Expr *E2 = FindExpr(ExI)) + return E2; return Ex; } @@ -98,11 +96,11 @@ void UndefBranchChecker::checkBranchCondition(const Stmt *Condition, Ex = FindIt.FindExpr(Ex); // Emit the bug report. - BugReport *R = new BugReport(*BT, BT->getDescription(), N); + auto R = llvm::make_unique<BugReport>(*BT, BT->getDescription(), N); bugreporter::trackNullOrUndefValue(N, Ex, *R); R->addRange(Ex->getSourceRange()); - Ctx.emitReport(R); + Ctx.emitReport(std::move(R)); } } } |