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