clang 23.0.0git
MCDCState.h
Go to the documentation of this file.
1//===---- MCDCState.h - Per-Function MC/DC state ----------------*- 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// Per-Function MC/DC state for PGO
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_CODEGEN_MCDCSTATE_H
14#define LLVM_CLANG_LIB_CODEGEN_MCDCSTATE_H
15
16#include "Address.h"
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/SmallVector.h"
19#include "llvm/ProfileData/Coverage/MCDCTypes.h"
20#include <cassert>
21#include <limits>
22
23namespace clang {
24class Stmt;
25} // namespace clang
26
27namespace clang::CodeGen::MCDC {
28
29using namespace llvm::coverage::mcdc;
30
31/// Per-Function MC/DC state
32struct State {
33 unsigned BitmapBits = 0;
34
35 struct Decision {
37 static constexpr auto InvalidID = std::numeric_limits<unsigned>::max();
38
39 unsigned BitmapIdx;
41 unsigned ID = InvalidID;
43
44 bool isValid() const { return ID != InvalidID; }
45
46 void update(unsigned I, IndicesTy &&X) {
47 assert(isValid());
48 BitmapIdx = I;
49 Indices = std::move(X);
50 }
51 };
52
53 llvm::DenseMap<const Stmt *, Decision> DecisionByStmt;
54
55 struct Branch {
56 ConditionID ID;
58 };
59
60 llvm::DenseMap<const Stmt *, Branch> BranchByStmt;
61};
62
63} // namespace clang::CodeGen::MCDC
64
65#endif // LLVM_CLANG_LIB_CODEGEN_MCDCSTATE_H
#define X(type, name)
Definition Value.h:97
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition Address.h:128
static Address invalid()
Definition Address.h:176
Stmt - This represents one statement.
Definition Stmt.h:86
The JSON file list parser is used to communicate input to InstallAPI.
llvm::SmallVector< std::array< int, 2 > > IndicesTy
Definition MCDCState.h:36
static constexpr auto InvalidID
Definition MCDCState.h:37
void update(unsigned I, IndicesTy &&X)
Definition MCDCState.h:46
Per-Function MC/DC state.
Definition MCDCState.h:32
llvm::DenseMap< const Stmt *, Branch > BranchByStmt
Definition MCDCState.h:60
llvm::DenseMap< const Stmt *, Decision > DecisionByStmt
Definition MCDCState.h:53