add support for DfArray in check-structures-sanity

develop
Ben Lubar 2020-02-05 19:06:14 -06:00
parent d7d0923044
commit d9abe02b2e
No known key found for this signature in database
GPG Key ID: 92939677AB59EDA4
1 changed files with 31 additions and 1 deletions

@ -51,6 +51,7 @@ class Checker
void check_container(void *, container_identity *); void check_container(void *, container_identity *);
void check_vector(void *, container_identity *, type_identity *); void check_vector(void *, container_identity *, type_identity *);
void check_deque(void *, container_identity *, type_identity *); void check_deque(void *, container_identity *, type_identity *);
void check_dfarray(void *, container_identity *, type_identity *);
void check_bit_container(void *, container_identity *); void check_bit_container(void *, container_identity *);
void check_virtual(void *, virtual_identity *); void check_virtual(void *, virtual_identity *);
void check_primitive(void *, type_identity *); void check_primitive(void *, type_identity *);
@ -436,6 +437,10 @@ void Checker::check_container(void *base, container_identity *identity)
{ {
check_deque(base, identity, item_identity); check_deque(base, identity, item_identity);
} }
else if (void_name == "DfArray<void>")
{
check_dfarray(base, identity, item_identity);
}
else else
{ {
FAIL("TODO: " << void_name); FAIL("TODO: " << void_name);
@ -452,7 +457,7 @@ void Checker::check_vector(void *base, container_identity *identity, type_identi
uintptr_t end_of_storage; uintptr_t end_of_storage;
}; };
if (identity->byte_size() != sizeof(vector_data) || identity->getFullName().find("vector<") != 0) if (identity->byte_size() != sizeof(vector_data))
{ {
UNEXPECTED; UNEXPECTED;
return; return;
@ -506,6 +511,31 @@ void Checker::check_deque(void *base, container_identity *identity, type_identit
// TODO: check deque? // TODO: check deque?
} }
void Checker::check_dfarray(void *base, container_identity *identity, type_identity *item_identity)
{
struct dfarray_data
{
uintptr_t start;
unsigned short size;
};
if (identity->byte_size() != sizeof(dfarray_data))
{
UNEXPECTED;
return;
}
dfarray_data dfarray = *reinterpret_cast<dfarray_data *>(base);
size_t length = dfarray.size;
size_t item_size = item_identity->byte_size();
if (check_access(reinterpret_cast<void *>(dfarray.start), identity, item_size * length))
{
check_static_array(reinterpret_cast<void *>(dfarray.start), item_identity, length);
}
}
void Checker::check_bit_container(void *base, container_identity *identity) void Checker::check_bit_container(void *base, container_identity *identity)
{ {
if (identity->getFullName() == "BitArray<>") if (identity->getFullName() == "BitArray<>")