LLVM 19.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
16#include <array>
17#include <cassert>
18#include <type_traits>
19#include <variant>
20
21namespace llvm::coverage::mcdc {
22
23/// The ID for MCDCBranch.
24using ConditionID = int16_t;
25using ConditionIDs = std::array<ConditionID, 2>;
26
28 /// Byte Index of Bitmap Coverage Object for a Decision Region.
29 unsigned BitmapIdx;
30
31 /// Number of Conditions used for a Decision Region.
33
37};
38
40 /// IDs used to represent a branch region and other branch regions
41 /// evaluated based on True and False branches.
44
45 BranchParameters() = delete;
47 : ID(ID), Conds(Conds) {}
48};
49
50/// The type of MC/DC-specific parameters.
52 std::variant<std::monostate, DecisionParameters, BranchParameters>;
53
54/// Check and get underlying params in MCDCParams.
55/// \tparam MaybeConstInnerParameters Type to get. May be const.
56/// \tparam MaybeConstMCDCParameters Expected inferred. May be const.
57/// \param MCDCParams May be const.
58template <class MaybeConstInnerParameters, class MaybeConstMCDCParameters>
59static auto &getParams(MaybeConstMCDCParameters &MCDCParams) {
60 using InnerParameters =
61 typename std::remove_const<MaybeConstInnerParameters>::type;
62 MaybeConstInnerParameters *Params = std::get_if<InnerParameters>(&MCDCParams);
63 assert(Params && "InnerParameters unavailable");
64 return *Params;
65}
66
67} // namespace llvm::coverage::mcdc
68
69#endif // LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static auto & getParams(MaybeConstMCDCParameters &MCDCParams)
Check and get underlying params in MCDCParams.
Definition: MCDCTypes.h:59
std::variant< std::monostate, DecisionParameters, BranchParameters > Parameters
The type of MC/DC-specific parameters.
Definition: MCDCTypes.h:52
int16_t ConditionID
The ID for MCDCBranch.
Definition: MCDCTypes.h:24
std::array< ConditionID, 2 > ConditionIDs
Definition: MCDCTypes.h:25
BranchParameters(ConditionID ID, const ConditionIDs &Conds)
Definition: MCDCTypes.h:46
ConditionID ID
IDs used to represent a branch region and other branch regions evaluated based on True and False bran...
Definition: MCDCTypes.h:42
unsigned BitmapIdx
Byte Index of Bitmap Coverage Object for a Decision Region.
Definition: MCDCTypes.h:29
DecisionParameters(unsigned BitmapIdx, unsigned NumConditions)
Definition: MCDCTypes.h:35
uint16_t NumConditions
Number of Conditions used for a Decision Region.
Definition: MCDCTypes.h:32