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

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
This commit is contained in:
Augusto Noronha
2024-08-23 17:06:45 -07:00
parent db0b5db54e
commit 141c96fee1
8 changed files with 221 additions and 46 deletions

View File

@@ -1956,6 +1956,11 @@ Identifier ModuleDecl::getABIName() const {
return getName();
}
void ModuleDecl::setABIName(Identifier name) {
getASTContext().moduleABINameWillChange(this, name);
ModuleABIName = name;
}
StringRef ModuleDecl::getModuleFilename() const {
// FIXME: Audit uses of this function and figure out how to migrate them to
// per-file names. Modules can consist of more than one file.