Skip to content

[DebugInfo] Fix handling of @_originallyDefinedIn types #77779

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

augusto2112
Copy link
Contributor

@augusto2112 augusto2112 commented Nov 21, 2024

Emit an imported declaration for @_originallyDefinedIn under the
real module that these types live in.

This patch also changes the mangling for the debugger to respect
@_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn
that should be ignored was still being used when mangling.

rdar://137146961

@augusto2112
Copy link
Contributor Author

@augusto2112 augusto2112 force-pushed the orig-def-in-imported-decl-6 branch from d401976 to 98fb153 Compare November 22, 2024 06:29
@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112 augusto2112 force-pushed the orig-def-in-imported-decl-6 branch from 98fb153 to 5ea0bec Compare November 22, 2024 06:40
@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112 augusto2112 force-pushed the orig-def-in-imported-decl-6 branch from 5ea0bec to e0ce718 Compare November 22, 2024 18:38
@augusto2112
Copy link
Contributor Author

/// Returns true if the type's mangled name is affected by an
/// @_originallyDefinedIn annotation. This annotation can be on the type
/// itself, one of its generic arguments, etc.
bool containsOriginallyDefinedIn(Type T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slavapestov I found the following situations where @_originallyDefinedIn could affect a type's mangled name:

  • The type itself being annotated.
  • The bound generic arguments being annotated.
  • A typealias local to a function could be affected by the types in the function's generic signature.
  • A metatype's type.

Do you know of any other ones?

@augusto2112
Copy link
Contributor Author

Emit an imported declaration for @_originallyDefinedIn under the
real module that these types live in.

This patch also changes the mangling for the debugger to respect
@_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn
that should be ignored was still being used when mangling.

rdar://137146961
@augusto2112 augusto2112 force-pushed the orig-def-in-imported-decl-6 branch from e0ce718 to 43c420e Compare December 3, 2024 20:48
@augusto2112
Copy link
Contributor Author

@augusto2112
Copy link
Contributor Author

swiftlang/llvm-project#9657
@swift-ci test source compatibility

if (auto *MT = llvm::dyn_cast<MetatypeType>(T))
if (containsOriginallyDefinedIn(MT->getInstanceType()))
return true;
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray ;


// If the type is a bound generic, the type of the substituted generic
// arguments might be annotated with @_originallyDefinedIn.
if (auto *BGT = llvm::dyn_cast<BoundGenericType>(T))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected this function to be implemented in terms of a type visitor. For example, does this catch a a tuple containing an originallyDefinedIn type?

@augusto2112
Copy link
Contributor Author

@swift-ci test source compatibility

@augusto2112
Copy link
Contributor Author

Closed in favor of #78104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants