-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add error reporting when looking up types by demangled name. #33585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c598c14
to
de3efaf
Compare
@swift-ci please benchmark |
Build failed before running benchmark. |
de3efaf
to
0854fb6
Compare
@swift-ci please benchmark |
Build failed before running benchmark. |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
0854fb6
to
1dec952
Compare
@swift-ci please clean test |
Build failed |
Build failed |
1dec952
to
aa800c6
Compare
@swift-ci please test |
Build failed |
Build failed |
@@ -1183,14 +1184,14 @@ class MetadataReader { | |||
MangledNameKind::Type, Dem); | |||
} | |||
|
|||
BuiltType | |||
TypeLookupErrorOr<typename BuilderType::BuiltType> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ErrorOr" happens to be my personal favorite name for this pattern. 😄
@swift-ci please benchmark |
Build failed before running benchmark. |
@swift-ci please benchmark |
Build failed before running benchmark. |
aa800c6
to
fd6922f
Compare
@swift-ci please test |
@swift-ci please benchmark |
Build failed |
Build failed |
@swift-ci please benchmark |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -OnoneCode size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
When mangled name lookups fail, it can be pretty hard to track down the cause. There are many places where it can fail, and when nested generics are involved you can end up recursing a lot. My technique so far has involved adding lots and lots of ad-hoc logging calls to track down the failure.
This PR plumbs error reporting through the whole structure. Errors are recorded as a function pointer and a context pointer, allowing errors to gather relevant information, but also avoiding the overhead of string building on paths where the caller is going to have some sort of fallback instead of reporting the error.
For an example of what this does, here's an error I debugged the other day:
failed to demangle witness for associated type 'Body' in conformance 'Syndrome.ProcessPaymentButton: View' from mangled name '+�'
And here's what that error looks like with this PR:
failed to demangle witness for associated type 'Body' in conformance 'Syndrome.ProcessPaymentButton: View' from mangled name '+�' - _gatherGenericParameters: context: $s7SwiftUI12ProgressViewVMn 0x1a214efd0 <SwiftUI.EmptyView> parent: <null> - incorrect number of generic args (1), 2 local params, 2 total params
This would have saved a huge amount of debugging time (and hopefully will save a huge amount in the future!).