diff --git a/lib/Model/Binary.cpp b/lib/Model/Binary.cpp index e58a53f48..9735a7894 100644 --- a/lib/Model/Binary.cpp +++ b/lib/Model/Binary.cpp @@ -461,11 +461,12 @@ std::set model::Binary::collectAllTypeSizes() const { // support (which includes all the pointers sizes). std::set ByteSizes = { 1, 2, 4, 8, 10, 12, 16 }; + VerifyHelper SizeCache; for (const model::UpcastableTypeDefinition &Type : this->TypeDefinitions()) { // This takes care of all the type definitions, meaning we don't have to // look at defined types anymore. - if (uint64_t ByteSize = Type->size().value_or(0)) - ByteSizes.insert(ByteSize); + if (std::optional MaybeSize = Type->size(SizeCache)) + ByteSizes.insert(MaybeSize.value()); for (const model::Type *Edge : Type->edges()) { // Since primitives, pointers and defined types are already taken care of, @@ -480,8 +481,8 @@ std::set model::Binary::collectAllTypeSizes() const { Edge = Pointer->PointeeType().get(); } else if (const auto *Array = llvm::dyn_cast(Edge)) { - if (uint64_t ByteSize = Edge->trySize().value_or(0)) - ByteSizes.insert(ByteSize); + if (std::optional MaybeSize = Edge->trySize(SizeCache)) + ByteSizes.insert(MaybeSize.value()); // Keep going deeper on an array in case it's a nested one. Edge = Array->ElementType().get(); @@ -495,10 +496,9 @@ std::set model::Binary::collectAllTypeSizes() const { if (const auto *RFT = Type->getRawFunction()) { uint64_t ReturnTypeSize = 0; for (const auto &RV : RFT->ReturnValues()) { - uint64_t ByteSize = RV.Type()->trySize().value_or(0); - revng_assert(ByteSize); - ByteSizes.insert(ByteSize); - ReturnTypeSize += ByteSize; + std::optional MaybeSize = RV.Type()->trySize(SizeCache); + revng_assert(MaybeSize.has_value()); + ReturnTypeSize += MaybeSize.value(); } if (ReturnTypeSize)