From 0e8808d530cce2e4b2f885222ee695a878a13516 Mon Sep 17 00:00:00 2001 From: Steven Perron Date: Wed, 29 May 2024 10:00:58 -0400 Subject: [PATCH] Add asserts to the type manager. --- source/opt/type_manager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/opt/type_manager.cpp b/source/opt/type_manager.cpp index 79648ad4974..0855c4976b2 100644 --- a/source/opt/type_manager.cpp +++ b/source/opt/type_manager.cpp @@ -57,6 +57,7 @@ std::pair> TypeManager::GetTypeAndPointerType( } uint32_t TypeManager::GetId(const Type* type) const { + assert(type->IsUniqueType() && "Type is not unique."); auto iter = type_to_id_.find(type); if (iter != type_to_id_.end()) { return (*iter).second; @@ -681,6 +682,11 @@ Type* TypeManager::RebuildType(uint32_t type_id, const Type& type) { } void TypeManager::RegisterType(uint32_t id, const Type& type) { + // We do not add non-unique types to the type manager. + if (!type.IsUniqueType()) { + return; + } + // Rebuild |type| so it and all its constituent types are owned by the type // pool. Type* rebuilt = RebuildType(id, type);