Skip to content

Commit 162a8bc

Browse files
Merge pull request swiftlang#2002 from adrian-prantl/unxfail-main
Fix some regressions uncovered by swiftlang#1997
2 parents e7b3fd9 + 66359bb commit 162a8bc

File tree

4 files changed

+38
-44
lines changed

4 files changed

+38
-44
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,6 @@ MaterializeVariable(SwiftASTManipulatorBase::VariableInfo &variable,
998998
});
999999
actual_type =
10001000
ToCompilerType(transformed_type->mapTypeOutOfContext().getPointer());
1001-
// CompilerType return_ast_type =
1002-
// ToCompilerType(result_type->mapTypeOutOfContext());
10031001
auto *swift_ast_ctx =
10041002
llvm::cast<SwiftASTContext>(actual_type.GetTypeSystem());
10051003

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ bool TypeSystemSwiftTypeRef::IsImportedType(opaque_compiler_type_t type,
19101910
StringRef ident = GetObjCTypeName(node);
19111911
if (ident.empty())
19121912
return {};
1913-
if (original_type && GetModule())
1913+
if (original_type)
19141914
if (TypeSP clang_type = LookupClangType(m_swift_ast_context, ident))
19151915
*original_type = clang_type->GetForwardCompilerType();
19161916
return true;
@@ -2091,48 +2091,46 @@ bool TypeSystemSwiftTypeRef::IsPointerOrReferenceType(
20912091
llvm::Optional<size_t>
20922092
TypeSystemSwiftTypeRef::GetTypeBitAlign(opaque_compiler_type_t type,
20932093
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) {
21262108
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.",
21282111
AsMangledName(type));
21292112
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 {};
21362134
}
21372135
bool TypeSystemSwiftTypeRef::IsTypedefType(opaque_compiler_type_t type) {
21382136
return m_swift_ast_context->IsTypedefType(ReconstructType(type));

lldb/test/API/lang/swift/dwarfimporter/C/TestSwiftDWARFImporterC.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def test_dwarf_importer(self):
6767
target.Clear()
6868
lldb.SBDebugger.MemoryPressureDetected()
6969

70-
@expectedFailureAll #FIXME: This regressed silently due to 2c911bceb06ed376801251bdfd992905a66f276c
7170
@skipIf(archs=['ppc64le'], bugnumber='SR-10214')
7271
@swiftTest
7372
# This test needs a working Remote Mirrors implementation.

lldb/test/API/lang/swift/optionset/TestSwiftOptionSetType.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
lldbinline.MakeInlineTest(__file__, globals(),
1616
decorators=[swiftTest,skipUnlessDarwin,
17-
expectedFailureAll, #FIXME: This regressed silently due to 2c911bceb06ed376801251bdfd992905a66f276c
1817
expectedFailureAll(bugnumber="rdar://60396797",
1918
setting=('symbols.use-swift-clangimporter', 'false'))
2019
])

0 commit comments

Comments
 (0)