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

Jessica Paquette via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 17:22:55 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)) {
----------------
ornata wrote:

I feel like it'd be easier to follow this if it was factored out into two functions. E.g.

```
if (isLAnd(E))
    assignCondIDsForLAnd(E);
else
   assignCondIDsForLOr(E);
pushRHS(E);
```

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


More information about the cfe-commits mailing list