@@ -100,7 +100,9 @@ class TargetReflectionContext : public ReflectionContextInterface {
100
100
std::shared_ptr<swift::reflection::MemoryReader> reader,
101
101
SwiftMetadataCache *swift_metadata_cache)
102
102
: m_reflection_ctx(reader, swift_metadata_cache, &m_forwader),
103
- m_type_converter (m_reflection_ctx.getBuilder()) {}
103
+ m_type_converter (m_reflection_ctx.getBuilder()) {
104
+ m_type_converter.enableErrorCache ();
105
+ }
104
106
105
107
std::optional<uint32_t > AddImage (
106
108
llvm::function_ref<std::pair<swift::remote::RemoteRef<void >, uint64_t >(
@@ -180,8 +182,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
180
182
auto *rti =
181
183
m_type_converter.getClassInstanceTypeInfo (&type_ref, *start, provider);
182
184
if (!rti)
183
- return llvm::createStringError (
184
- " converter returned nullptr typeinfo but no error" );
185
+ return llvm::createStringError (m_type_converter.takeLastError ());
185
186
return *rti;
186
187
}
187
188
@@ -201,23 +202,21 @@ class TargetReflectionContext : public ReflectionContextInterface {
201
202
provider ? provider->getId () : 0 , ss.str ());
202
203
}
203
204
204
- auto type_info = m_reflection_ctx.getTypeInfo (&type_ref, provider);
205
- if (!type_info) {
206
- std::stringstream ss;
207
- ss << " Could not find type info for " ;
208
- type_ref.dump (ss);
209
- ss << " in reflection metadata" ;
210
- return llvm::createStringError (ss.str ());
211
- }
205
+ auto type_info_or_err = m_reflection_ctx.getTypeInfo (type_ref, provider);
206
+ if (!type_info_or_err)
207
+ return llvm::joinErrors (
208
+ llvm::createStringError (
209
+ " Could not find reflection metadata for type" ),
210
+ type_info_or_err.takeError ());
212
211
213
212
if (log && log->GetVerbose ()) {
214
213
std::stringstream ss;
215
- type_info ->dump (ss);
214
+ type_info_or_err ->dump (ss);
216
215
LLDB_LOG (log,
217
216
" [TargetReflectionContext::getTypeInfo] Found type info {0}" ,
218
217
ss.str ());
219
218
}
220
- return *type_info ;
219
+ return *type_info_or_err ;
221
220
}
222
221
223
222
llvm::Expected<const swift::reflection::TypeInfo &> GetTypeInfoFromInstance (
0 commit comments