-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Debugger support for opaque types. #24445
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
We could introduce non-nominal-type context descriptors, such as those for opaque declarations, which are also interesting to be able to look up for reflection or remote purposes. This should be a backward compatible change with old runtimes, which always ignore any context descriptor kind they don't know about.
If -enable-anonymous-context-mangled-names is enabled, meaning that we assign names to anonymous context descriptors for discovery by RemoteAST, then include opaque type descriptors in the type metadata record table so that they can also be found at runtime by RemoteAST for debugger support.
When we formed a mangled name key to look up opaque return type decls during interface parsing, we were accidentally including the `Global` demangle node inside the `OpaqueReturnTypeOf` node, which ended up including the `$s` prefix in the mangling. Other type reconstruction clients like lldb which provided well-formed mangling trees did not include the Global node, causing the prefix to get left off and lookups to fail. Fix Sema to remove the Global node before looking up the opaque type, and have type reconstruction consistently apply the prefix to the lookup key.
@swift-ci Please test |
4a0146b
to
81e520e
Compare
@swift-ci Please test |
Build failed |
Build failed |
@@ -826,14 +826,16 @@ void IRGenModule::addObjCClass(llvm::Constant *classPtr, bool nonlazy) { | |||
ObjCNonLazyClasses.push_back(classPtr); | |||
} | |||
|
|||
void IRGenModule::addRuntimeResolvableType(NominalTypeDecl *nominal) { | |||
void IRGenModule::addRuntimeResolvableType(GenericTypeDecl *type) { | |||
// Collect the nominal type records we emit into a special section. |
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.
Can you assert that type is an OpaqueTypeDecl or NominalTypeDecl (and not TypeAliasDecl which is the other subclass of GenericTypeDecl), and fix this comment?
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.
We already have that assertion deeper in the pipe, when you try to emit a context descriptor.
@@ -879,19 +879,29 @@ void IRGenModule::emitStructDecl(StructDecl *st) { | |||
emitNestedTypeDecls(st->getMembers()); | |||
} | |||
|
|||
void IRGenModule::maybeEmitOpaqueTypeDecl(OpaqueTypeDecl *opaque) { | |||
if (IRGen.Opts.EnableAnonymousContextMangledNames) { |
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.
Perhaps fold this check into hasLazyMetadata()?
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.
I'm not sure that buys much, since there's not much to gain from putting these in RuntimeResolvableTypes if we aren't also putting the name info in anonymous contexts, so the condition would be still be here, and still be worth factoring out of the individual emit
methods below.
@swift-ci Please test Linux |
Build failed |
When building for debug, the opaque return type context is nested under an anonymous context for the defining function. Demangle the anonymous context name to reconstruct the mangling for the opaque type.
…types. They aren't normally decl contexts, but if one has an opaque type, we want to be able to record the property as a context so that we can reconstruct it in RemoteAST.
40f5381
to
edd3015
Compare
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test OS X |
rdar://problem/46138166