Skip to content

Account for multiple modules when looking up the DeclContext of a type #76065

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

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

augusto2112
Copy link
Contributor

When looking up the decl context of a type, ASTDemangler has to take into account that there are multiple different modules where that type could've come from. This is due to two facts:

  • Thanks to the -module-abi-name flag, multiple modules can share the same ABI name (which is the module name that is usually used when mangling a type).
  • In some situations mangling can use the module's real name, for example, when mangling for the debugger or USRs coupled with @_originallyDefinedIn.

rdar://134095412

@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112 augusto2112 force-pushed the clash-abi-name-demangler branch from 7583e25 to 799bab0 Compare August 24, 2024 00:08
@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112 augusto2112 force-pushed the clash-abi-name-demangler branch from 862a6ac to 31a4839 Compare August 26, 2024 21:52
@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112
Copy link
Contributor Author

@slavapestov ping :)

if (!decl) return nullptr;
for (auto *module : *potentialModules)
if (auto *decl = module->lookupLocalType(mangledName))
return dyn_cast<DeclContext>(decl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be a findModuleContaining(mangledName) helper function that is reused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could put this in a helper but besides iterating over the modules there's nothing in common I could reuse between callers of findPotentialModules.

When looking up the decl context of a type, ASTDemangler has to take
into account that there are multiple different modules where that type
could've come from. This is due to two facts:

- Thanks to the `-module-abi-name` flag, multiple modules can share
the same ABI name (which is the module name that is usually used when
mangling a type).
- In some situations mangling can use the module's real name, for
example, when mangling for the debugger or USRs coupled with @_originallyDefinedIn.

rdar://134095412
@augusto2112 augusto2112 force-pushed the clash-abi-name-demangler branch from 31a4839 to 141c96f Compare September 3, 2024 23:44
@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@swift-ci smoke test

@augusto2112 augusto2112 merged commit 5f851b6 into swiftlang:main Sep 6, 2024
5 checks passed
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