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/Symbol.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/Symbol.cpp')
-rw-r--r-- | llvm/lib/TextAPI/Symbol.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/llvm/lib/TextAPI/Symbol.cpp b/llvm/lib/TextAPI/Symbol.cpp index e67627e..c899821 100644 --- a/llvm/lib/TextAPI/Symbol.cpp +++ b/llvm/lib/TextAPI/Symbol.cpp @@ -72,30 +72,23 @@ bool Symbol::operator==(const Symbol &O) const { std::tie(O.Name, O.Kind, O.Targets, RHSFlags); } -SimpleSymbol parseSymbol(StringRef SymName, const SymbolFlags Flags) { +SimpleSymbol parseSymbol(StringRef SymName) { if (SymName.starts_with(ObjC1ClassNamePrefix)) return {SymName.drop_front(ObjC1ClassNamePrefix.size()), - EncodeKind::ObjectiveCClass}; + EncodeKind::ObjectiveCClass, ObjCIFSymbolKind::Class}; if (SymName.starts_with(ObjC2ClassNamePrefix)) return {SymName.drop_front(ObjC2ClassNamePrefix.size()), - EncodeKind::ObjectiveCClass}; + EncodeKind::ObjectiveCClass, ObjCIFSymbolKind::Class}; if (SymName.starts_with(ObjC2MetaClassNamePrefix)) return {SymName.drop_front(ObjC2MetaClassNamePrefix.size()), - EncodeKind::ObjectiveCClass}; - if (SymName.starts_with(ObjC2EHTypePrefix)) { - // When classes without ehtype are used in try/catch blocks - // a weak-defined symbol is exported. In those cases, treat these as a - // global instead. - if ((Flags & SymbolFlags::WeakDefined) == SymbolFlags::WeakDefined) - return {SymName, EncodeKind::GlobalSymbol}; + EncodeKind::ObjectiveCClass, ObjCIFSymbolKind::MetaClass}; + if (SymName.starts_with(ObjC2EHTypePrefix)) return {SymName.drop_front(ObjC2EHTypePrefix.size()), - EncodeKind::ObjectiveCClassEHType}; - } - + EncodeKind::ObjectiveCClassEHType, ObjCIFSymbolKind::EHType}; if (SymName.starts_with(ObjC2IVarPrefix)) return {SymName.drop_front(ObjC2IVarPrefix.size()), - EncodeKind::ObjectiveCInstanceVariable}; - return {SymName, EncodeKind::GlobalSymbol}; + EncodeKind::ObjectiveCInstanceVariable, ObjCIFSymbolKind::None}; + return {SymName, EncodeKind::GlobalSymbol, ObjCIFSymbolKind::None}; } } // end namespace MachO. |