@@ -2794,7 +2794,7 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
2794
2794
size_t data_byte_size, uint32_t bitfield_bit_size,
2795
2795
uint32_t bitfield_bit_offset, ExecutionContextScope *exe_scope,
2796
2796
bool is_base_class) {
2797
- auto impl = [&]() -> llvm::Optional< bool > {
2797
+ auto impl = [&]() -> bool {
2798
2798
if (!type)
2799
2799
return false ;
2800
2800
@@ -2894,7 +2894,13 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
2894
2894
}
2895
2895
}
2896
2896
2897
- return {};
2897
+ // No result available from the runtime, fallback to the AST.
2898
+ // This can happen in two cases:
2899
+ // 1. MultiPayloadEnums not currently supported by Swift reflection
2900
+ // 2. Some clang imported enums
2901
+ return m_swift_ast_context->DumpTypeValue (
2902
+ ReconstructType (type), s, format, data, data_offset, data_byte_size,
2903
+ bitfield_bit_size, bitfield_bit_offset, exe_scope, is_base_class);
2898
2904
}
2899
2905
default :
2900
2906
assert (false && " Unhandled node kind" );
@@ -2906,34 +2912,17 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
2906
2912
};
2907
2913
2908
2914
#ifndef NDEBUG
2909
- auto result = impl ();
2910
- if (!result) {
2911
- if (!m_swift_ast_context)
2912
- return false ;
2913
- // Swift reflection provided no result, fallback to the AST.
2914
- return m_swift_ast_context->DumpTypeValue (
2915
- ReconstructType (type), s, format, data, data_offset, data_byte_size,
2916
- bitfield_bit_size, bitfield_bit_offset, exe_scope, is_base_class);
2917
- }
2918
- auto ast_type = ReconstructType (type);
2919
- if (!ast_type)
2920
- return false ; /* missing .swiftmodule */
2921
2915
StreamString ast_s;
2922
- bool eq_result =
2923
- Equivalent (result, m_swift_ast_context->DumpTypeValue (
2924
- ast_type, &ast_s, format, data, data_offset,
2925
- data_byte_size, bitfield_bit_size,
2926
- bitfield_bit_offset, exe_scope, is_base_class));
2927
- bool eq_stream = Equivalent (ConstString (ast_s.GetString ()),
2928
- ConstString (((StreamString *)s)->GetString ()));
2929
- if (!eq_result || !eq_stream)
2930
- llvm::dbgs () << " failing type was " << (const char *)type << " \n " ;
2931
- assert (eq_result && eq_stream &&
2932
- " TypeSystemSwiftTypeRef diverges from SwiftASTContext" );
2933
- return *result;
2934
- #else
2935
- return impl ().getValueOr (false );
2916
+ auto defer = llvm::make_scope_exit ([&] {
2917
+ assert (Equivalent (ConstString (ast_s.GetString ()),
2918
+ ConstString (((StreamString *)s)->GetString ())) &&
2919
+ " TypeSystemSwiftTypeRef diverges from SwiftASTContext" );
2920
+ });
2936
2921
#endif
2922
+ VALIDATE_AND_RETURN (impl, DumpTypeValue, type,
2923
+ (ReconstructType (type), &ast_s, format, data, data_offset,
2924
+ data_byte_size, bitfield_bit_size, bitfield_bit_offset,
2925
+ exe_scope, is_base_class));
2937
2926
}
2938
2927
2939
2928
void TypeSystemSwiftTypeRef::DumpTypeDescription (opaque_compiler_type_t type,
0 commit comments