diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2024-01-29 18:36:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 18:36:48 -0800 |
commit | 4460fa8814d4c86e1d22f830078d7bad69bc0ecc (patch) | |
tree | 5c72a118743042e8b55ec3f9eda9b2be244d3eef /llvm/lib/TextAPI/SymbolSet.cpp | |
parent | 45188c64db68af92596acdb2d9022527f6aa4502 (diff) | |
download | llvm-4460fa8814d4c86e1d22f830078d7bad69bc0ecc.zip llvm-4460fa8814d4c86e1d22f830078d7bad69bc0ecc.tar.gz llvm-4460fa8814d4c86e1d22f830078d7bad69bc0ecc.tar.bz2 |
[TextAPI] Introduce granularity for handling ObjC Interface symbols (#79928)
ObjCInterfaceRecords roughly align to the objc-classes key in tbd-files.
They condensely represent up to 3 symbols. The problem here is that when
represented this way, we lose granularity when these symbols could have
different linkages or outright don't exist. This can happen frequently
in interoptable code generated by the swift compiler. This adds fields
and utility functions to express unique properties for these symbols. If
the record does represent the same properties across all of its symbols,
it will be treated the same in the TBD. Otherwise it will be printed in
global's section.
Reviewed seperately before by Juergen Ributzka
Diffstat (limited to 'llvm/lib/TextAPI/SymbolSet.cpp')
-rw-r--r-- | llvm/lib/TextAPI/SymbolSet.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/TextAPI/SymbolSet.cpp b/llvm/lib/TextAPI/SymbolSet.cpp index 0cbfa2f..2e0b416 100644 --- a/llvm/lib/TextAPI/SymbolSet.cpp +++ b/llvm/lib/TextAPI/SymbolSet.cpp @@ -28,6 +28,21 @@ Symbol *SymbolSet::addGlobal(EncodeKind Kind, StringRef Name, SymbolFlags Flags, return Sym; } -const Symbol *SymbolSet::findSymbol(EncodeKind Kind, StringRef Name) const { - return Symbols.lookup({Kind, Name}); +const Symbol *SymbolSet::findSymbol(EncodeKind Kind, StringRef Name, + ObjCIFSymbolKind ObjCIF) const { + if (auto result = Symbols.lookup({Kind, Name})) + return result; + if ((ObjCIF == ObjCIFSymbolKind::None) || (ObjCIF > ObjCIFSymbolKind::EHType)) + return nullptr; + assert(ObjCIF <= ObjCIFSymbolKind::EHType && + "expected single ObjCIFSymbolKind enum value"); + // Non-complete ObjC Interfaces are represented as global symbols. + if (ObjCIF == ObjCIFSymbolKind::Class) + return Symbols.lookup( + {EncodeKind::GlobalSymbol, (ObjC2ClassNamePrefix + Name).str()}); + if (ObjCIF == ObjCIFSymbolKind::MetaClass) + return Symbols.lookup( + {EncodeKind::GlobalSymbol, (ObjC2MetaClassNamePrefix + Name).str()}); + return Symbols.lookup( + {EncodeKind::GlobalSymbol, (ObjC2EHTypePrefix + Name).str()}); } |