[clang] [llvm] [clang][CoverageMapping] Refactor when setting MC/DC True/False (PR #78202)

Alan Phipps via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 10:49:17 PST 2024


================
@@ -746,21 +781,52 @@ struct MCDCCoverageBuilder {
     // assign that ID to its LHS node.  Its RHS will receive a new ID.
     if (CondIDs.contains(CodeGenFunction::stripCond(E))) {
       // If Stmt has an ID, assign its ID to LHS
-      CondIDs[CodeGenFunction::stripCond(E->getLHS())] = CondIDs[E];
+      setCondID(E->getLHS(), getCondID(E));
 
       // Since the operator's LHS assumes the operator's same ID, pop the
       // operator from the RHS stack so that if LHS short-circuits, it won't be
       // incorrectly re-used as the node executed next.
       popRHSifTop(E);
     } else {
       // Otherwise, assign ID+1 to LHS.
-      CondIDs[CodeGenFunction::stripCond(E->getLHS())] = NextID++;
+      setCondID(E->getLHS(), NextID++);
     }
 
     // Assign ID+1 to RHS.
-    CondIDs[CodeGenFunction::stripCond(E->getRHS())] = NextID++;
+    setCondID(E->getRHS(), NextID++);
+
+    // Assign the True and False condition IDs for the LHS and RHS.
+    if (isLAnd(E)) {
----------------
evodius96 wrote:

It's much easier to assigned the True/False as we push onto the stack rather than popping. Popping led to off-by-one errors.

https://github.com/llvm/llvm-project/pull/78202


More information about the cfe-commits mailing list