using namespace clang::interp;
template <typename T>
-static void ctorTy(Block *, char *Ptr, bool, bool, bool, Descriptor *) {
+static void ctorTy(Block *, char *Ptr, bool, bool, bool, const Descriptor *) {
new (Ptr) T();
}
-template <typename T> static void dtorTy(Block *, char *Ptr, Descriptor *) {
+template <typename T>
+static void dtorTy(Block *, char *Ptr, const Descriptor *) {
reinterpret_cast<T *>(Ptr)->~T();
}
template <typename T>
-static void moveTy(Block *, char *Src, char *Dst, Descriptor *) {
+static void moveTy(Block *, char *Src, char *Dst, const Descriptor *) {
auto *SrcPtr = reinterpret_cast<T *>(Src);
auto *DstPtr = reinterpret_cast<T *>(Dst);
new (DstPtr) T(std::move(*SrcPtr));
}
template <typename T>
-static void ctorArrayTy(Block *, char *Ptr, bool, bool, bool, Descriptor *D) {
+static void ctorArrayTy(Block *, char *Ptr, bool, bool, bool,
+ const Descriptor *D) {
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
new (&reinterpret_cast<T *>(Ptr)[I]) T();
}
}
template <typename T>
-static void dtorArrayTy(Block *, char *Ptr, Descriptor *D) {
+static void dtorArrayTy(Block *, char *Ptr, const Descriptor *D) {
InitMap *IM = *reinterpret_cast<InitMap **>(Ptr);
if (IM != (InitMap *)-1)
free(IM);
}
template <typename T>
-static void moveArrayTy(Block *, char *Src, char *Dst, Descriptor *D) {
+static void moveArrayTy(Block *, char *Src, char *Dst, const Descriptor *D) {
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
auto *SrcPtr = &reinterpret_cast<T *>(Src)[I];
auto *DstPtr = &reinterpret_cast<T *>(Dst)[I];
}
static void ctorArrayDesc(Block *B, char *Ptr, bool IsConst, bool IsMutable,
- bool IsActive, Descriptor *D) {
+ bool IsActive, const Descriptor *D) {
const unsigned NumElems = D->getNumElems();
const unsigned ElemSize =
D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
}
}
-static void dtorArrayDesc(Block *B, char *Ptr, Descriptor *D) {
+static void dtorArrayDesc(Block *B, char *Ptr, const Descriptor *D) {
const unsigned NumElems = D->getNumElems();
const unsigned ElemSize =
D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
}
}
-static void moveArrayDesc(Block *B, char *Src, char *Dst, Descriptor *D) {
+static void moveArrayDesc(Block *B, char *Src, char *Dst, const Descriptor *D) {
const unsigned NumElems = D->getNumElems();
const unsigned ElemSize =
D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
}
static void ctorRecord(Block *B, char *Ptr, bool IsConst, bool IsMutable,
- bool IsActive, Descriptor *D) {
+ bool IsActive, const Descriptor *D) {
const bool IsUnion = D->ElemRecord->isUnion();
auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase) {
auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + SubOff) - 1;
CtorSub(V.Offset, V.Desc, /*isBase=*/true);
}
-static void dtorRecord(Block *B, char *Ptr, Descriptor *D) {
+static void dtorRecord(Block *B, char *Ptr, const Descriptor *D) {
auto DtorSub = [=](unsigned SubOff, Descriptor *F) {
if (auto Fn = F->DtorFn)
Fn(B, Ptr + SubOff, F);
DtorSub(F.Offset, F.Desc);
}
-static void moveRecord(Block *B, char *Src, char *Dst, Descriptor *D) {
+static void moveRecord(Block *B, char *Src, char *Dst, const Descriptor *D) {
for (const auto &F : D->ElemRecord->fields()) {
auto FieldOff = F.Offset;
auto FieldDesc = F.Desc;
/// all the fields which contain non-trivial types.
using BlockCtorFn = void (*)(Block *Storage, char *FieldPtr, bool IsConst,
bool IsMutable, bool IsActive,
- Descriptor *FieldDesc);
+ const Descriptor *FieldDesc);
/// Invoked when a block is destroyed. Invokes the destructors of all
/// non-trivial nested fields of arrays and records.
using BlockDtorFn = void (*)(Block *Storage, char *FieldPtr,
- Descriptor *FieldDesc);
+ const Descriptor *FieldDesc);
/// Invoked when a block with pointers referencing it goes out of scope. Such
/// blocks are persisted: the move function copies all inline descriptors and
/// non-trivial fields, as existing pointers might need to reference those
/// descriptors. Data is not copied since it cannot be legally read.
using BlockMoveFn = void (*)(Block *Storage, char *SrcFieldPtr,
- char *DstFieldPtr, Descriptor *FieldDesc);
+ char *DstFieldPtr, const Descriptor *FieldDesc);
/// Inline descriptor embedded in structures and arrays.
///