[llvm] 4588525 - CoverageMappingReader/Writer: MCDCConditionID shouldn't be zero
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 00:55:04 PST 2024
Author: NAKAMURA Takumi
Date: 2024-02-13T17:54:51+09:00
New Revision: 4588525d7edbc0d14c41f5fa8f3e23a3241a502e
URL: https://github.com/llvm/llvm-project/commit/4588525d7edbc0d14c41f5fa8f3e23a3241a502e
DIFF: https://github.com/llvm/llvm-project/commit/4588525d7edbc0d14c41f5fa8f3e23a3241a502e.diff
LOG: CoverageMappingReader/Writer: MCDCConditionID shouldn't be zero
Added:
Modified:
llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
index fc6014c1f7be70..061f0f1bdcd3e2 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -308,6 +308,10 @@ Error RawCoverageMappingReader::readMappingRegionsSubArray(
return Err;
if (auto Err = readIntMax(FID, std::numeric_limits<unsigned>::max()))
return Err;
+ if (ID == 0)
+ return make_error<CoverageMapError>(
+ coveragemap_error::malformed,
+ "MCDCConditionID shouldn't be zero");
break;
case CounterMappingRegion::MCDCDecisionRegion:
Kind = CounterMappingRegion::MCDCDecisionRegion;
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
index 27727f216b0513..248a6a79a145fd 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -251,6 +251,7 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
OS);
writeCounter(MinExpressions, Count, OS);
writeCounter(MinExpressions, FalseCount, OS);
+ assert(I->MCDCParams.ID > 0);
encodeULEB128(unsigned(I->MCDCParams.ID), OS);
encodeULEB128(unsigned(I->MCDCParams.TrueID), OS);
encodeULEB128(unsigned(I->MCDCParams.FalseID), OS);
More information about the llvm-commits
mailing list