From 4460fa8814d4c86e1d22f830078d7bad69bc0ecc Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Mon, 29 Jan 2024 18:36:48 -0800 Subject: [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 --- llvm/lib/TextAPI/Symbol.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'llvm/lib/TextAPI/Symbol.cpp') 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. -- cgit v1.1