diff options
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/BugReporter.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 97e97ef8c4d68..e4db64fe34e02 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1250,10 +1250,8 @@ static void reversePropagateIntererstingSymbols(BugReport &R, // Fall through. case Stmt::BinaryOperatorClass: case Stmt::UnaryOperatorClass: { - for (Stmt::const_child_iterator CI = Ex->child_begin(), - CE = Ex->child_end(); - CI != CE; ++CI) { - if (const Expr *child = dyn_cast_or_null<Expr>(*CI)) { + for (const Stmt *SubStmt : Ex->children()) { + if (const Expr *child = dyn_cast_or_null<Expr>(SubStmt)) { IE.insert(child); SVal ChildV = State->getSVal(child, LCtx); R.markInteresting(ChildV); @@ -3224,10 +3222,7 @@ void BugReporter::Register(BugType *BT) { BugTypes = F.add(BugTypes, BT); } -void BugReporter::emitReport(BugReport* R) { - // To guarantee memory release. - std::unique_ptr<BugReport> UniqueR(R); - +void BugReporter::emitReport(std::unique_ptr<BugReport> R) { if (const ExplodedNode *E = R->getErrorNode()) { const AnalysisDeclContext *DeclCtx = E->getLocationContext()->getAnalysisDeclContext(); @@ -3258,11 +3253,11 @@ void BugReporter::emitReport(BugReport* R) { BugReportEquivClass* EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos); if (!EQ) { - EQ = new BugReportEquivClass(std::move(UniqueR)); + EQ = new BugReportEquivClass(std::move(R)); EQClasses.InsertNode(EQ, InsertPos); EQClassesVector.push_back(EQ); } else - EQ->AddReport(std::move(UniqueR)); + EQ->AddReport(std::move(R)); } @@ -3462,12 +3457,12 @@ void BugReporter::EmitBasicReport(const Decl *DeclWithIssue, // 'BT' is owned by BugReporter. BugType *BT = getBugTypeForName(CheckName, name, category); - BugReport *R = new BugReport(*BT, str, Loc); + auto R = llvm::make_unique<BugReport>(*BT, str, Loc); R->setDeclWithIssue(DeclWithIssue); for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end(); I != E; ++I) R->addRange(*I); - emitReport(R); + emitReport(std::move(R)); } BugType *BugReporter::getBugTypeForName(CheckName CheckName, StringRef name, |