summaryrefslogtreecommitdiffstats
path: root/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index dff81e3..97e97ef 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2702,22 +2702,22 @@ const Stmt *BugReport::getStmt() const {
return S;
}
-std::pair<BugReport::ranges_iterator, BugReport::ranges_iterator>
-BugReport::getRanges() {
- // If no custom ranges, add the range of the statement corresponding to
- // the error node.
- if (Ranges.empty()) {
- if (const Expr *E = dyn_cast_or_null<Expr>(getStmt()))
- addRange(E->getSourceRange());
- else
- return std::make_pair(ranges_iterator(), ranges_iterator());
- }
+llvm::iterator_range<BugReport::ranges_iterator> BugReport::getRanges() {
+ // If no custom ranges, add the range of the statement corresponding to
+ // the error node.
+ if (Ranges.empty()) {
+ if (const Expr *E = dyn_cast_or_null<Expr>(getStmt()))
+ addRange(E->getSourceRange());
+ else
+ return llvm::make_range(ranges_iterator(), ranges_iterator());
+ }
- // User-specified absence of range info.
- if (Ranges.size() == 1 && !Ranges.begin()->isValid())
- return std::make_pair(ranges_iterator(), ranges_iterator());
+ // User-specified absence of range info.
+ if (Ranges.size() == 1 && !Ranges.begin()->isValid())
+ return llvm::make_range(ranges_iterator(), ranges_iterator());
- return std::make_pair(Ranges.begin(), Ranges.end());
+ return llvm::iterator_range<BugReport::ranges_iterator>(Ranges.begin(),
+ Ranges.end());
}
PathDiagnosticLocation BugReport::getLocation(const SourceManager &SM) const {
@@ -2763,9 +2763,7 @@ void BugReporter::FlushReports() {
// warnings and new BugTypes.
// FIXME: Only NSErrorChecker needs BugType's FlushReports.
// Turn NSErrorChecker into a proper checker and remove this.
- SmallVector<const BugType*, 16> bugTypes;
- for (BugTypesTy::iterator I=BugTypes.begin(), E=BugTypes.end(); I!=E; ++I)
- bugTypes.push_back(*I);
+ SmallVector<const BugType *, 16> bugTypes(BugTypes.begin(), BugTypes.end());
for (SmallVectorImpl<const BugType *>::iterator
I = bugTypes.begin(), E = bugTypes.end(); I != E; ++I)
const_cast<BugType*>(*I)->FlushReports(*this);
@@ -3055,8 +3053,7 @@ static void CompactPathDiagnostic(PathPieces &path, const SourceManager& SM) {
// Now take the pieces and construct a new PathDiagnostic.
path.clear();
- for (PiecesTy::iterator I=Pieces.begin(), E=Pieces.end(); I!=E; ++I)
- path.push_back(*I);
+ path.insert(path.end(), Pieces.begin(), Pieces.end());
}
bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD,
@@ -3434,10 +3431,8 @@ void BugReporter::FlushReport(BugReport *exampleReport,
PathDiagnosticLocation L = exampleReport->getLocation(getSourceManager());
auto piece = llvm::make_unique<PathDiagnosticEventPiece>(
L, exampleReport->getDescription());
- BugReport::ranges_iterator Beg, End;
- std::tie(Beg, End) = exampleReport->getRanges();
- for ( ; Beg != End; ++Beg)
- piece->addRange(*Beg);
+ for (const SourceRange &Range : exampleReport->getRanges())
+ piece->addRange(Range);
D->setEndOfPath(std::move(piece));
}
OpenPOWER on IntegriCloud