AST: Extend @_originallyDefinedIn to allow specifying module name for linker directive purposes

The module name changes the symbol mangling, and also causes
TBDGen to emit linker directives. To separate out these two
behaviors, introduce a terrible hack. If the module name
contains a semicolon (`;`), the part before the semicolon
is the module name for mangling, and the part after the
semicolon is the module name for linker directives.

If there is no semicolon, both module names are identical,
and the behavior is the same as before.
This commit is contained in:
Slava Pestov
2025-03-05 15:35:54 -05:00
parent 37d867f21c
commit 0155b41b50
12 changed files with 118 additions and 25 deletions

View File

@@ -3094,7 +3094,9 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
Moved, std::optional<llvm::VersionTuple>(theAttr->MovedVersion));
auto abbrCode = S.DeclTypeAbbrCodes[OriginallyDefinedInDeclAttrLayout::Code];
llvm::SmallString<32> blob;
blob.append(theAttr->OriginalModuleName.str());
blob.append(theAttr->ManglingModuleName.str());
blob.push_back('\0');
blob.append(theAttr->LinkerModuleName.str());
blob.push_back('\0');
OriginallyDefinedInDeclAttrLayout::emitRecord(
S.Out, S.ScratchRecord, abbrCode,