[llvm] 6a9d0e5 - [llvm-cov] Prevent assertion failure in sumMCDCPairs

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 21:57:10 PST 2025


Author: NAKAMURA Takumi
Date: 2025-01-28T14:56:58+09:00
New Revision: 6a9d0e53ae04a60222c8e39d8ced3183aa30588a

URL: https://github.com/llvm/llvm-project/commit/6a9d0e53ae04a60222c8e39d8ced3183aa30588a
DIFF: https://github.com/llvm/llvm-project/commit/6a9d0e53ae04a60222c8e39d8ced3183aa30588a.diff

LOG: [llvm-cov] Prevent assertion failure in sumMCDCPairs

Since #112694, MCDCRecord::isCondFolded() has returned true for
"partially folded" conditions. Besides,
isConditionIndependencePairCovered() returns true if the unfolded
condition is satisfied. This might break consistency
(CoveredPairs <= NumPairs).

Added: 
    

Modified: 
    llvm/tools/llvm-cov/CoverageSummaryInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
index 5c002a694f66ae..be9aef8416e8da 100644
--- a/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
+++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.cpp
@@ -53,10 +53,11 @@ auto sumMCDCPairs(const ArrayRef<MCDCRecord> &Records) {
   for (const auto &Record : Records) {
     const auto NumConditions = Record.getNumConditions();
     for (unsigned C = 0; C < NumConditions; C++) {
-      if (!Record.isCondFolded(C))
+      if (!Record.isCondFolded(C)) {
         ++NumPairs;
-      if (Record.isConditionIndependencePairCovered(C))
-        ++CoveredPairs;
+        if (Record.isConditionIndependencePairCovered(C))
+          ++CoveredPairs;
+      }
     }
   }
   return MCDCCoverageInfo(CoveredPairs, NumPairs);


        


More information about the llvm-commits mailing list