[clang] [llvm] [MC/DC] Refactor: Make `MCDCParams` as `std::variant` (PR #81227)

NAKAMURA Takumi via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 10 07:38:11 PST 2024


================
@@ -250,18 +251,27 @@ struct CounterMappingRegion {
   };
 
   using MCDCConditionID = unsigned int;
-  struct MCDCParameters {
+  struct MCDCDecisionParameters {
     /// Byte Index of Bitmap Coverage Object for a Decision Region.
-    unsigned BitmapIdx = 0;
+    unsigned BitmapIdx;
 
     /// Number of Conditions used for a Decision Region.
-    unsigned NumConditions = 0;
+    unsigned NumConditions;
 
+    MCDCDecisionParameters() = delete;
+  };
+
+  struct MCDCBranchParameters {
     /// IDs used to represent a branch region and other branch regions
     /// evaluated based on True and False branches.
-    MCDCConditionID ID = 0, TrueID = 0, FalseID = 0;
+    MCDCConditionID ID, TrueID, FalseID;
+
+    MCDCBranchParameters() = delete;
   };
 
+  using MCDCParameters = std::variant<std::monostate, MCDCDecisionParameters,
+                                      MCDCBranchParameters>;
----------------
chapuni wrote:

FYI, the size of `MCDCParameters` will be `12` (gnu) or `8` (libc++) finally, with shrinking a few members to `int16_t`. (#81257)

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


More information about the cfe-commits mailing list