llvm.org GIT mirror llvm / 49f93f7
[Coverage] Get rid of an input/output parameter (NFC) readFunctionRecords is used to iterate through the entries of the coverage mapping section. Instead of expecting the function to update the iterator through a `const char *&` parameter, just return the updated iterator. This will help us experiment with zlib-compressing coverage mapping data. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273052 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 4 years ago
1 changed file(s) with 17 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
349349
350350 namespace {
351351 struct CovMapFuncRecordReader {
352 // The interface to read coverage mapping function records for
353 // a module. \p Buf is a reference to the buffer pointer pointing
354 // to the \c CovHeader of coverage mapping data associated with
355 // the module.
356 virtual Error readFunctionRecords(const char *&Buf, const char *End) = 0;
352 // The interface to read coverage mapping function records for a module.
353 //
354 // \p Buf points to the buffer containing the \c CovHeader of the coverage
355 // mapping data associated with the module.
356 //
357 // Returns a pointer to the next \c CovHeader if it exists, or a pointer
358 // greater than \p End if not.
359 virtual Expected readFunctionRecords(const char *Buf,
360 const char *End) = 0;
357361 virtual ~CovMapFuncRecordReader() {}
358362 template
359363 static Expected>
429433 : ProfileNames(P), Filenames(F), Records(R) {}
430434 ~VersionedCovMapFuncRecordReader() override {}
431435
432 Error readFunctionRecords(const char *&Buf, const char *End) override {
436 Expected readFunctionRecords(const char *Buf,
437 const char *End) override {
433438 using namespace support;
434439 if (Buf + sizeof(CovMapHeader) > End)
435440 return make_error(coveragemap_error::malformed);
451456 size_t FilenamesBegin = Filenames.size();
452457 RawCoverageFilenamesReader Reader(StringRef(Buf, FilenamesSize), Filenames);
453458 if (auto Err = Reader.read())
454 return Err;
459 return std::move(Err);
455460 Buf += FilenamesSize;
456461
457462 // We'll read the coverage mapping records in the loop below.
478483
479484 if (Error Err =
480485 insertFunctionRecordIfNeeded(CFR, Mapping, FilenamesBegin))
481 return Err;
486 return std::move(Err);
482487 CFR++;
483488 }
484 return Error::success();
489 return Buf;
485490 }
486491 };
487492 } // end anonymous namespace
525530 return E;
526531 auto Reader = std::move(ReaderExpected.get());
527532 for (const char *Buf = Data.data(), *End = Buf + Data.size(); Buf < End;) {
528 if (Error E = Reader->readFunctionRecords(Buf, End))
533 auto NextHeaderOrErr = Reader->readFunctionRecords(Buf, End);
534 if (auto E = NextHeaderOrErr.takeError())
529535 return E;
536 Buf = NextHeaderOrErr.get();
530537 }
531538 return Error::success();
532539 }