@@ -2786,7 +2786,7 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
2786
2786
size_t data_byte_size, uint32_t bitfield_bit_size,
2787
2787
uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope,
2788
2788
bool is_base_class) {
2789
- auto impl = [&]() -> bool {
2789
+ auto impl = [&]() -> llvm::Optional< bool > {
2790
2790
if (!type)
2791
2791
return false ;
2792
2792
@@ -2892,17 +2892,34 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
2892
2892
};
2893
2893
2894
2894
#ifndef NDEBUG
2895
+ auto result = impl ();
2896
+ if (!result) {
2897
+ if (!m_swift_ast_context)
2898
+ return false ;
2899
+ // Swift reflection provided no result, fallback to the AST.
2900
+ return m_swift_ast_context->DumpTypeValue (
2901
+ ReconstructType (type), s, format, data, data_offset, data_byte_size,
2902
+ bitfield_bit_size, bitfield_bit_offset, exe_scope, is_base_class);
2903
+ }
2904
+ auto ast_type = ReconstructType (type);
2905
+ if (!ast_type)
2906
+ return false ; /* missing .swiftmodule */
2895
2907
StreamString ast_s;
2896
- auto defer = llvm::make_scope_exit ([&] {
2897
- assert (Equivalent (ConstString (ast_s.GetString ()),
2898
- ConstString (((StreamString *)s)->GetString ())) &&
2899
- " TypeSystemSwiftTypeRef diverges from SwiftASTContext" );
2900
- });
2908
+ bool eq_result =
2909
+ Equivalent (result, m_swift_ast_context->DumpTypeValue (
2910
+ ast_type, &ast_s, format, data, data_offset,
2911
+ data_byte_size, bitfield_bit_size,
2912
+ bitfield_bit_offset, exe_scope, is_base_class));
2913
+ bool eq_stream = Equivalent (ConstString (ast_s.GetString ()),
2914
+ ConstString (((StreamString *)s)->GetString ()));
2915
+ if (!eq_result || !eq_stream)
2916
+ llvm::dbgs () << " failing type was " << (const char *)type << " \n " ;
2917
+ assert (eq_result && eq_stream &&
2918
+ " TypeSystemSwiftTypeRef diverges from SwiftASTContext" );
2919
+ return *result;
2920
+ #else
2921
+ return impl ().getValueOr (false );
2901
2922
#endif
2902
- VALIDATE_AND_RETURN (impl, DumpTypeValue, type,
2903
- (ReconstructType (type), &ast_s, format, data, data_offset,
2904
- data_byte_size, bitfield_bit_size, bitfield_bit_offset,
2905
- exe_scope, is_base_class));
2906
2923
}
2907
2924
2908
2925
void TypeSystemSwiftTypeRef::DumpTypeDescription (opaque_compiler_type_t type,
0 commit comments