[llvm] [MC/DC] Introduce `class TestVector` with a pair of `BitVector` (PR #82174)

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 18 19:53:26 PST 2024


================
@@ -380,7 +380,70 @@ struct MCDCRecord {
   /// are effectively ignored.
   enum CondState { MCDC_DontCare = -1, MCDC_False = 0, MCDC_True = 1 };
 
-  using TestVector = llvm::SmallVector<CondState>;
+  /// Emulate SmallVector<CondState> with a pair of BitVector.
+  ///
+  ///          True  False DontCare (Impossible)
+  /// Values:  True  False False    True
+  /// Visited: True  True  False    False
+  class TestVector {
+    BitVector Values;  /// True/False (False when DontCare)
+    BitVector Visited; /// ~DontCare
+
+  public:
+    /// Assume filling DontCare.
+    TestVector(unsigned n, CondState Cond = MCDC_DontCare) {
+      assert(Cond == MCDC_DontCare);
+      Values.resize(n);
+      Visited.resize(n);
+    }
+
+    /// Emulate RHS SmallVector::operator[]
+    MCDCRecord::CondState operator[](int I) const {
----------------
ornata wrote:

Can you expand on this comment?

E.g.

> For the condition at index \p I:
> \returns MCDC_True when the condition has been visited
> \returns MCDC_False when a condition has not been visited
> \returns MCDC_DontCare when the condition does not impact MC/DC coverage


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


More information about the llvm-commits mailing list