LLVM 22.0.0git
MCDCTypes.h
Go to the documentation of this file.
1//===- MCDCTypes.h - Types related to MC/DC Coverage ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Types related to MC/DC Coverage.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
14#define LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
15
17#include <array>
18#include <cassert>
19#include <type_traits>
20#include <variant>
21
22namespace llvm::coverage::mcdc {
23
24/// The ID for MCDCBranch.
25using ConditionID = int16_t;
26using ConditionIDs = std::array<ConditionID, 2>;
27
29 /// Byte Index of Bitmap Coverage Object for a Decision Region.
30 unsigned BitmapIdx;
31
32 /// Number of Conditions used for a Decision Region.
34
39 }
40};
41
43 /// IDs used to represent a branch region and other branch regions
44 /// evaluated based on True and False branches.
47
48 BranchParameters() = delete;
50 : ID(ID), Conds(Conds) {
51 assert(ID >= 0);
52 }
53};
54
55/// The type of MC/DC-specific parameters.
57 std::variant<std::monostate, DecisionParameters, BranchParameters>;
58
59/// Check and get underlying params in MCDCParams.
60/// \tparam MaybeConstInnerParameters Type to get. May be const.
61/// \tparam MaybeConstMCDCParameters Expected inferred. May be const.
62/// \param MCDCParams May be const.
63template <class MaybeConstInnerParameters, class MaybeConstMCDCParameters>
64static auto &getParams(MaybeConstMCDCParameters &MCDCParams) {
65 using InnerParameters =
66 typename std::remove_const<MaybeConstInnerParameters>::type;
67 MaybeConstInnerParameters *Params = std::get_if<InnerParameters>(&MCDCParams);
68 assert(Params && "InnerParameters unavailable");
69 return *Params;
70}
71
72} // namespace llvm::coverage::mcdc
73
74#endif // LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static auto & getParams(MaybeConstMCDCParameters &MCDCParams)
Check and get underlying params in MCDCParams.
Definition: MCDCTypes.h:64
std::variant< std::monostate, DecisionParameters, BranchParameters > Parameters
The type of MC/DC-specific parameters.
Definition: MCDCTypes.h:57
int16_t ConditionID
The ID for MCDCBranch.
Definition: MCDCTypes.h:25
std::array< ConditionID, 2 > ConditionIDs
Definition: MCDCTypes.h:26
BranchParameters(ConditionID ID, const ConditionIDs &Conds)
Definition: MCDCTypes.h:49
ConditionID ID
IDs used to represent a branch region and other branch regions evaluated based on True and False bran...
Definition: MCDCTypes.h:45
unsigned BitmapIdx
Byte Index of Bitmap Coverage Object for a Decision Region.
Definition: MCDCTypes.h:30
DecisionParameters(unsigned BitmapIdx, unsigned NumConditions)
Definition: MCDCTypes.h:36
uint16_t NumConditions
Number of Conditions used for a Decision Region.
Definition: MCDCTypes.h:33