@@ -1910,7 +1910,7 @@ bool TypeSystemSwiftTypeRef::IsImportedType(opaque_compiler_type_t type,
1910
1910
StringRef ident = GetObjCTypeName (node);
1911
1911
if (ident.empty ())
1912
1912
return {};
1913
- if (original_type && GetModule () )
1913
+ if (original_type)
1914
1914
if (TypeSP clang_type = LookupClangType (m_swift_ast_context, ident))
1915
1915
*original_type = clang_type->GetForwardCompilerType ();
1916
1916
return true ;
@@ -2091,48 +2091,46 @@ bool TypeSystemSwiftTypeRef::IsPointerOrReferenceType(
2091
2091
llvm::Optional<size_t >
2092
2092
TypeSystemSwiftTypeRef::GetTypeBitAlign (opaque_compiler_type_t type,
2093
2093
ExecutionContextScope *exe_scope) {
2094
- auto impl = [&]() -> llvm::Optional<size_t > {
2095
- // Clang types can be resolved even without a process.
2096
- if (CompilerType clang_type = GetAsClangTypeOrNull (type)) {
2097
- // Swift doesn't know pointers: return the size alignment of the
2098
- // object pointer instead of the underlying object.
2099
- if (Flags (clang_type.GetTypeInfo ()).AllSet (eTypeIsObjC | eTypeIsClass))
2100
- return GetPointerByteSize () * 8 ;
2101
- return clang_type.GetTypeBitAlign (exe_scope);
2102
- }
2103
- if (!exe_scope) {
2104
- LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
2105
- " Couldn't compute alignment of type %s without an execution "
2106
- " context." ,
2107
- AsMangledName (type));
2108
- return {};
2109
- }
2110
- if (auto *runtime =
2111
- SwiftLanguageRuntime::Get (exe_scope->CalculateProcess ())) {
2112
- if (auto result = runtime->GetBitAlignment ({this , type}, exe_scope))
2113
- return result;
2114
- // If this is an expression context, perhaps the type was
2115
- // defined in the expression. In that case we don't have debug
2116
- // info for it, so defer to SwiftASTContext.
2117
- if (llvm::isa<SwiftASTContextForExpressions>(m_swift_ast_context))
2118
- return ReconstructType ({this , type}).GetTypeBitAlign (exe_scope);
2119
- }
2120
-
2121
- // If there is no process, we can still try to get the static
2122
- // alignment information out of DWARF. Because it is stored in the
2123
- // Type object we need to look that up by name again.
2124
- if (TypeSP type_sp = LookupTypeInModule (type))
2125
- return type_sp->GetLayoutCompilerType ().GetTypeBitAlign (exe_scope);
2094
+ // This method doesn't use VALIDATE_AND_RETURN because except for
2095
+ // fixed-size types the SwiftASTContext implementation forwards to
2096
+ // SwiftLanguageRuntime anyway and for many fixed-size types the
2097
+ // fixed layout still returns an incorrect default alignment of 0.
2098
+ //
2099
+ // Clang types can be resolved even without a process.
2100
+ if (CompilerType clang_type = GetAsClangTypeOrNull (type)) {
2101
+ // Swift doesn't know pointers: return the size alignment of the
2102
+ // object pointer instead of the underlying object.
2103
+ if (Flags (clang_type.GetTypeInfo ()).AllSet (eTypeIsObjC | eTypeIsClass))
2104
+ return GetPointerByteSize () * 8 ;
2105
+ return clang_type.GetTypeBitAlign (exe_scope);
2106
+ }
2107
+ if (!exe_scope) {
2126
2108
LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
2127
- " Couldn't compute alignment of type %s without a process." ,
2109
+ " Couldn't compute alignment of type %s without an execution "
2110
+ " context." ,
2128
2111
AsMangledName (type));
2129
2112
return {};
2130
- };
2131
- if (exe_scope && exe_scope->CalculateProcess ())
2132
- VALIDATE_AND_RETURN (impl, GetTypeBitAlign, type,
2133
- (ReconstructType (type), exe_scope));
2134
- else
2135
- return impl ();
2113
+ }
2114
+ if (auto *runtime =
2115
+ SwiftLanguageRuntime::Get (exe_scope->CalculateProcess ())) {
2116
+ if (auto result = runtime->GetBitAlignment ({this , type}, exe_scope))
2117
+ return result;
2118
+ // If this is an expression context, perhaps the type was
2119
+ // defined in the expression. In that case we don't have debug
2120
+ // info for it, so defer to SwiftASTContext.
2121
+ if (llvm::isa<SwiftASTContextForExpressions>(m_swift_ast_context))
2122
+ return ReconstructType ({this , type}).GetTypeBitAlign (exe_scope);
2123
+ }
2124
+
2125
+ // If there is no process, we can still try to get the static
2126
+ // alignment information out of DWARF. Because it is stored in the
2127
+ // Type object we need to look that up by name again.
2128
+ if (TypeSP type_sp = LookupTypeInModule (type))
2129
+ return type_sp->GetLayoutCompilerType ().GetTypeBitAlign (exe_scope);
2130
+ LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
2131
+ " Couldn't compute alignment of type %s without a process." ,
2132
+ AsMangledName (type));
2133
+ return {};
2136
2134
}
2137
2135
bool TypeSystemSwiftTypeRef::IsTypedefType (opaque_compiler_type_t type) {
2138
2136
return m_swift_ast_context->IsTypedefType (ReconstructType (type));
0 commit comments