Skip to content

Commit

Permalink
[fix] Fixed inner types for unnamed structs.
Browse files Browse the repository at this point in the history
  • Loading branch information
S1eGa committed Oct 12, 2023
1 parent c9c1419 commit 90f39cb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/Core/TypeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ KType *TypeManager::getWrappedType(llvm::Type *type) {
if (typesMap.count(type) == 0) {
types.emplace_back(new KType(type, this));
typesMap.emplace(type, types.back().get());
if (type && type->isPointerTy()) {
getWrappedType(type->getPointerElementType());
}
if (type && type->isArrayTy()) {
getWrappedType(type->getArrayElementType());
}
}
return typesMap[type];
}
Expand All @@ -61,15 +67,21 @@ void TypeManager::initTypesFromStructs() {
* and pull types to top.
*/

std::vector<llvm::StructType *> collectedStructTypes =
parent->module->getIdentifiedStructTypes();
for (auto &structType : collectedStructTypes) {
for (auto &structType : parent->module->getIdentifiedStructTypes()) {
getWrappedType(structType);
}

std::unordered_set<llvm::StructType *> collectedStructTypes;
for (const auto &it : typesMap) {
if (llvm::StructType *itStruct =
llvm::dyn_cast<llvm::StructType>(it.first)) {
collectedStructTypes.insert(itStruct);
}
}

for (auto &typesToOffsets : typesMap) {
if (llvm::isa<llvm::StructType>(typesToOffsets.first)) {
collectedStructTypes.emplace_back(
collectedStructTypes.insert(
llvm::cast<llvm::StructType>(typesToOffsets.first));
}
}
Expand Down

0 comments on commit 90f39cb

Please sign in to comment.