Coverage: Fix iterated type for LineCoverageIterator

LineCoverageIterator is not providing access to a mutable object. Fix it
to iterate over `const LineCoverageStats` so that `operator->()`
compiles again after 6b9b86db9d.
This commit is contained in:
Duncan P. N. Exon Smith 2021-11-16 14:33:10 -08:00
parent ae389b2450
commit 77898a4c0c
2 changed files with 6 additions and 4 deletions

View File

@ -693,8 +693,9 @@ public:
/// An iterator over the \c LineCoverageStats objects for lines described by
/// a \c CoverageData instance.
class LineCoverageIterator
: public iterator_facade_base<
LineCoverageIterator, std::forward_iterator_tag, LineCoverageStats> {
: public iterator_facade_base<LineCoverageIterator,
std::forward_iterator_tag,
const LineCoverageStats> {
public:
LineCoverageIterator(const CoverageData &CD)
: LineCoverageIterator(CD, CD.begin()->Line) {}
@ -711,8 +712,6 @@ public:
const LineCoverageStats &operator*() const { return Stats; }
LineCoverageStats &operator*() { return Stats; }
LineCoverageIterator &operator++();
LineCoverageIterator getEnd() const {

View File

@ -693,6 +693,9 @@ TEST_P(CoverageMappingTest, test_line_coverage_iterator) {
++Line;
}
ASSERT_EQ(11U, Line);
// Check that operator->() works / compiles.
ASSERT_EQ(1U, LineCoverageIterator(Data)->getLine());
}
TEST_P(CoverageMappingTest, uncovered_function) {