From 050e163ae8b4bb6eb252b59e2f8f36e68ae9239d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 13 Jan 2016 19:58:01 +0000 Subject: Vendor import of llvm trunk r257626: https://llvm.org/svn/llvm-project/llvm/trunk@257626 --- lib/ProfileData/CoverageMappingReader.cpp | 36 ++++++++++++------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'lib/ProfileData/CoverageMappingReader.cpp') diff --git a/lib/ProfileData/CoverageMappingReader.cpp b/lib/ProfileData/CoverageMappingReader.cpp index 32c692d8073a..89e1cf42c577 100644 --- a/lib/ProfileData/CoverageMappingReader.cpp +++ b/lib/ProfileData/CoverageMappingReader.cpp @@ -319,21 +319,14 @@ static std::error_code readCoverageMappingData( if (Buf + sizeof(CovMapHeader) > End) return coveragemap_error::malformed; auto CovHeader = reinterpret_cast(Buf); - uint32_t NRecords = - endian::byte_swap(CovHeader->NRecords); - uint32_t FilenamesSize = - endian::byte_swap(CovHeader->FilenamesSize); - uint32_t CoverageSize = - endian::byte_swap(CovHeader->CoverageSize); - uint32_t Version = endian::byte_swap(CovHeader->Version); + uint32_t NRecords = CovHeader->getNRecords(); + uint32_t FilenamesSize = CovHeader->getFilenamesSize(); + uint32_t CoverageSize = CovHeader->getCoverageSize(); + uint32_t Version = CovHeader->getVersion(); Buf = reinterpret_cast(++CovHeader); - switch (Version) { - case CoverageMappingVersion1: - break; - default: + if (Version > coverage::CoverageMappingCurrentVersion) return coveragemap_error::unsupported_version; - } // Skip past the function records, saving the start and end for later. const char *FunBuf = Buf; @@ -364,11 +357,8 @@ static std::error_code readCoverageMappingData( reinterpret_cast *>(FunBuf); while ((const char *)CFR < FunEnd) { // Read the function information - T NamePtr = endian::byte_swap(CFR->NamePtr); - uint32_t NameSize = endian::byte_swap(CFR->NameSize); - uint32_t DataSize = endian::byte_swap(CFR->DataSize); - uint64_t FuncHash = endian::byte_swap(CFR->FuncHash); - CFR++; + uint32_t DataSize = CFR->template getDataSize(); + uint64_t FuncHash = CFR->template getFuncHash(); // Now use that to read the coverage data. if (CovBuf + DataSize > CovEnd) @@ -379,16 +369,18 @@ static std::error_code readCoverageMappingData( // Ignore this record if we already have a record that points to the same // function name. This is useful to ignore the redundant records for the // functions with ODR linkage. - if (!UniqueFunctionMappingData.insert(NamePtr).second) + T NameRef = CFR->template getFuncNameRef(); + if (!UniqueFunctionMappingData.insert(NameRef).second) continue; - // Finally, grab the name and create a record. - StringRef FuncName = ProfileNames.getFuncName(NamePtr, NameSize); - if (NameSize && FuncName.empty()) - return coveragemap_error::malformed; + StringRef FuncName; + if (std::error_code EC = + CFR->template getFuncName(ProfileNames, FuncName)) + return EC; Records.push_back(BinaryCoverageReader::ProfileMappingRecord( CoverageMappingVersion(Version), FuncName, FuncHash, Mapping, FilenamesBegin, Filenames.size() - FilenamesBegin)); + CFR++; } } -- cgit v1.3