diff --git a/llvm/lib/TextAPI/TextStub.cpp b/llvm/lib/TextAPI/TextStub.cpp --- a/llvm/lib/TextAPI/TextStub.cpp +++ b/llvm/lib/TextAPI/TextStub.cpp @@ -456,7 +456,7 @@ ArchSet.insert(Library.getArchitectures()); std::map SymbolToArchSet; - for (const auto *Symbol : File->exports()) { + for (const auto *Symbol : File->symbols()) { auto Architectures = Symbol->getArchitectures(); SymbolToArchSet[Symbol] = Architectures; ArchSet.insert(Architectures); @@ -833,13 +833,10 @@ auto handleSymbols = [](SectionList &CurrentSections, - InterfaceFile::const_filtered_symbol_range Symbols, - std::function Pred) { + InterfaceFile::const_filtered_symbol_range Symbols) { std::set TargetSet; std::map SymbolToTargetList; for (const auto *Symbol : Symbols) { - if (!Pred(Symbol)) - continue; TargetList Targets(Symbol->targets()); SymbolToTargetList[Symbol] = Targets; TargetSet.emplace(std::move(Targets)); @@ -884,14 +881,9 @@ } }; - handleSymbols(Exports, File->exports(), [](const Symbol *Symbol) { - return !Symbol->isReexported(); - }); - handleSymbols(Reexports, File->exports(), [](const Symbol *Symbol) { - return Symbol->isReexported(); - }); - handleSymbols(Undefineds, File->undefineds(), - [](const Symbol *Symbol) { return true; }); + handleSymbols(Exports, File->exports()); + handleSymbols(Reexports, File->reexports()); + handleSymbols(Undefineds, File->undefineds()); } const InterfaceFile *denormalize(IO &IO) { @@ -937,24 +929,28 @@ for (auto &sym : CurrentSection.Classes) File->addSymbol(SymbolKind::ObjectiveCClass, sym, - CurrentSection.Targets); + CurrentSection.Targets, Flag); for (auto &sym : CurrentSection.ClassEHs) File->addSymbol(SymbolKind::ObjectiveCClassEHType, sym, - CurrentSection.Targets); + CurrentSection.Targets, Flag); for (auto &sym : CurrentSection.Ivars) File->addSymbol(SymbolKind::ObjectiveCInstanceVariable, sym, - CurrentSection.Targets); + CurrentSection.Targets, Flag); - for (auto &sym : CurrentSection.WeakSymbols) + for (auto &sym : CurrentSection.WeakSymbols) { + SymbolFlags SymFlag = (Flag == SymbolFlags::Undefined) + ? SymbolFlags::WeakReferenced + : SymbolFlags::WeakDefined; File->addSymbol(SymbolKind::GlobalSymbol, sym, - CurrentSection.Targets, SymbolFlags::WeakDefined); + CurrentSection.Targets, Flag | SymFlag); + } for (auto &sym : CurrentSection.TlvSymbols) File->addSymbol(SymbolKind::GlobalSymbol, sym, CurrentSection.Targets, - SymbolFlags::ThreadLocalValue); + Flag | SymbolFlags::ThreadLocalValue); } }; diff --git a/llvm/lib/TextAPI/TextStubCommon.cpp b/llvm/lib/TextAPI/TextStubCommon.cpp --- a/llvm/lib/TextAPI/TextStubCommon.cpp +++ b/llvm/lib/TextAPI/TextStubCommon.cpp @@ -82,7 +82,7 @@ OS << "bridgeos"; break; case PLATFORM_MACCATALYST: - OS << "iosmac"; + OS << "maccatalyst"; break; case PLATFORM_DRIVERKIT: OS << "driverkit"; @@ -112,6 +112,7 @@ .Case("tvos", PLATFORM_TVOS) .Case("bridgeos", PLATFORM_BRIDGEOS) .Case("iosmac", PLATFORM_MACCATALYST) + .Case("maccatalyst", PLATFORM_MACCATALYST) .Case("driverkit", PLATFORM_DRIVERKIT) .Default(PLATFORM_UNKNOWN); diff --git a/llvm/unittests/TextAPI/TextStubV3Tests.cpp b/llvm/unittests/TextAPI/TextStubV3Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV3Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV3Tests.cpp @@ -495,7 +495,7 @@ TEST(TBDv3, Platform_macCatalyst) { static const char TBDv3PlatformiOSmac[] = "--- !tapi-tbd-v3\n" "archs: [ armv7k ]\n" - "platform: iosmac\n" + "platform: maccatalyst\n" "install-name: Test.dylib\n" "...\n"; diff --git a/llvm/unittests/TextAPI/TextStubV4Tests.cpp b/llvm/unittests/TextAPI/TextStubV4Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV4Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV4Tests.cpp @@ -64,7 +64,7 @@ " objc-classes: []\n" " objc-eh-types: []\n" " objc-ivars: []\n" - " weak-symbols: []\n" + " weak-symbols: [weakReexport]\n" " thread-local-symbols: []\n" "undefineds:\n" " - targets: [ i386-macos ]\n" @@ -72,7 +72,7 @@ " objc-classes: []\n" " objc-eh-types: []\n" " objc-ivars: []\n" - " weak-symbols: []\n" + " weak-symbols: [weakReference]\n" " thread-local-symbols: []\n" "...\n"; @@ -114,16 +114,23 @@ EXPECT_EQ(reexport, File->reexportedLibraries().front()); ExportedSymbolSeq Exports, Reexports, Undefineds; - ExportedSymbol temp; for (const auto *Sym : File->symbols()) { - temp = ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), - Sym->isWeakDefined(), Sym->isThreadLocalValue()}; - EXPECT_FALSE(Sym->isWeakReferenced()); - if (Sym->isUndefined()) - Undefineds.emplace_back(std::move(temp)); - else - Sym->isReexported() ? Reexports.emplace_back(std::move(temp)) - : Exports.emplace_back(std::move(temp)); + ExportedSymbol Temp = + ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), + Sym->isWeakDefined() || Sym->isWeakReferenced(), + Sym->isThreadLocalValue()}; + if (Sym->isUndefined()) { + EXPECT_FALSE(Sym->isWeakDefined()); + Undefineds.emplace_back(std::move(Temp)); + } + // Check that defined symbols cannot be set as weak referenced. + else if (Sym->isReexported()) { + EXPECT_FALSE(Sym->isWeakReferenced()); + Reexports.emplace_back(std::move(Temp)); + } else { + EXPECT_FALSE(Sym->isWeakReferenced()); + Exports.emplace_back(std::move(Temp)); + } } llvm::sort(Exports); llvm::sort(Reexports); @@ -137,10 +144,12 @@ static ExportedSymbol ExpectedReexportedSymbols[] = { {SymbolKind::GlobalSymbol, "_symC", false, false}, + {SymbolKind::GlobalSymbol, "weakReexport", true, false}, }; static ExportedSymbol ExpectedUndefinedSymbols[] = { {SymbolKind::GlobalSymbol, "_symD", false, false}, + {SymbolKind::GlobalSymbol, "weakReference", true, false}, }; EXPECT_EQ(std::size(ExpectedExportedSymbols), Exports.size());