Skip to content

Commit

Permalink
Add asserts to the type manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-perron committed Jul 17, 2024
1 parent 6248fda commit 0e8808d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/opt/type_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ std::pair<Type*, std::unique_ptr<Pointer>> 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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0e8808d

Please sign in to comment.