9#ifndef LLVM_CLANG_AST_INTERP_INIT_MAP_H
10#define LLVM_CLANG_AST_INTERP_INIT_MAP_H
27 static constexpr uint64_t PER_FIELD =
sizeof(T) *
CHAR_BIT;
31 unsigned UninitFields;
32 unsigned DeadFields = 0;
33 std::unique_ptr<T[]> Data;
38 : NumElems(N), UninitFields(N),
39 Data(
std::make_unique<T[]>(numFields(N))) {}
40 explicit InitMap(
unsigned N,
bool AllInitialized)
41 : NumElems(N), UninitFields(AllInitialized ? 0 : N),
42 Data(
std::make_unique<T[]>(numFields(N))) {
44 for (
unsigned I = 0; I != (numFields(N) / 2); ++I)
45 Data[I] = std::numeric_limits<T>::max();
53 unsigned LifetimeIndex = (NumElems + I);
54 unsigned Bucket = numFields(NumElems) / 2 + (I / PER_FIELD);
55 return !(data()[Bucket] & (
T(1) << (LifetimeIndex % PER_FIELD)));
68 T *data() {
return Data.get(); }
69 const T *data()
const {
return Data.get(); }
71 static constexpr size_t numFields(
unsigned N) {
72 return ((N + PER_FIELD - 1) / PER_FIELD) * 2;
95 assert(IM !=
nullptr);
102 delete (operator->)();
109 return reinterpret_cast<InitMap *
>(
V);
115 delete (operator->)();
119static_assert(
sizeof(InitMapPtr) ==
sizeof(
void *));
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
void deleteInitMap()
Delete the InitMap if one exists.
void noteAllInitialized()
bool allInitialized() const
Are all elements in the array already initialized?
void setInitMap(const InitMap *IM)
static constexpr intptr_t AllInitializedValue
V's value after the initmap has been destroyed because all its elements have already been initialized...
InitMap * operator->()
Access the underlying InitMap directly.
static constexpr intptr_t NoInitMapValue
V's value before an initmap has been created.
Bitfield tracking the initialisation status of elements of primitive arrays.
InitMap(unsigned N)
Initializes the map with no fields set.
InitMap(unsigned N, bool AllInitialized)
void startElementLifetime(unsigned I)
void endElementLifetime(unsigned I)
bool allElementsAlive() const
bool isElementInitialized(unsigned I) const
Checks if an element was initialized.
bool initializeElement(unsigned I)
Initializes an element. Returns true when object if fully initialized.
bool isElementAlive(unsigned I) const