@@ -2169,18 +2169,32 @@ TypeSystemSwiftTypeRef::GetBitSize(opaque_compiler_type_t type,
2169
2169
// info for it, so defer to SwiftASTContext.
2170
2170
if (llvm::isa<SwiftASTContextForExpressions>(m_swift_ast_context))
2171
2171
return ReconstructType ({this , type}).GetBitSize (exe_scope);
2172
+ LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
2173
+ " Couldn't compute size of type %s using SwiftLanguageRuntime." ,
2174
+ AsMangledName (type));
2175
+ return {};
2172
2176
}
2173
2177
2174
2178
// If there is no process, we can still try to get the static size
2175
2179
// information out of DWARF. Because it is stored in the Type
2176
2180
// object we need to look that up by name again.
2177
2181
if (TypeSP type_sp = LookupTypeInModule (type)) {
2178
- if (auto byte_size = type_sp->GetByteSize (exe_scope))
2182
+ struct SwiftType : public Type {
2183
+ // / Avoid a potential infinite recursion because
2184
+ // / Type::GetByteSize() may call into this function again.
2185
+ llvm::Optional<uint64_t > GetStaticByteSize () {
2186
+ if (m_byte_size_has_value)
2187
+ return m_byte_size;
2188
+ return {};
2189
+ }
2190
+ };
2191
+ if (auto byte_size =
2192
+ reinterpret_cast <SwiftType *>(type_sp.get ())->GetStaticByteSize ())
2179
2193
return *byte_size * 8 ;
2180
2194
else return {};
2181
2195
}
2182
2196
LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
2183
- " Couldn't compute size of type %s without a process ." ,
2197
+ " Couldn't compute size of type %s using static debug info ." ,
2184
2198
AsMangledName (type));
2185
2199
return {};
2186
2200
};
@@ -3178,9 +3192,10 @@ TypeSystemSwiftTypeRef::GetTypeBitAlign(opaque_compiler_type_t type,
3178
3192
// alignment information out of DWARF. Because it is stored in the
3179
3193
// Type object we need to look that up by name again.
3180
3194
if (TypeSP type_sp = LookupTypeInModule (type))
3181
- return type_sp->GetLayoutCompilerType ().GetTypeBitAlign (exe_scope);
3195
+ if (type_sp->GetLayoutCompilerType ().GetOpaqueQualType () != type)
3196
+ return type_sp->GetLayoutCompilerType ().GetTypeBitAlign (exe_scope);
3182
3197
LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
3183
- " Couldn't compute alignment of type %s without a process ." ,
3198
+ " Couldn't compute alignment of type %s using static debug info ." ,
3184
3199
AsMangledName (type));
3185
3200
return {};
3186
3201
}
0 commit comments