ArchSet.insert(Library.getArchitectures());
std::map<const Symbol *, ArchitectureSet> SymbolToArchSet;
- for (const auto *Symbol : File->exports()) {
+ for (const auto *Symbol : File->symbols()) {
auto Architectures = Symbol->getArchitectures();
SymbolToArchSet[Symbol] = Architectures;
ArchSet.insert(Architectures);
auto handleSymbols =
[](SectionList &CurrentSections,
- InterfaceFile::const_filtered_symbol_range Symbols,
- std::function<bool(const Symbol *)> Pred) {
+ InterfaceFile::const_filtered_symbol_range Symbols) {
std::set<TargetList> TargetSet;
std::map<const Symbol *, TargetList> SymbolToTargetList;
for (const auto *Symbol : Symbols) {
- if (!Pred(Symbol))
- continue;
TargetList Targets(Symbol->targets());
SymbolToTargetList[Symbol] = Targets;
TargetSet.emplace(std::move(Targets));
}
};
- 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) {
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)
+ SymbolFlags SymFlag = (Flag == SymbolFlags::Undefined)
+ ? SymbolFlags::WeakReferenced
+ : SymbolFlags::WeakDefined;
+ for (auto &sym : CurrentSection.WeakSymbols) {
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);
}
};
OS << "bridgeos";
break;
case PLATFORM_MACCATALYST:
- OS << "iosmac";
+ OS << "maccatalyst";
break;
case PLATFORM_DRIVERKIT:
OS << "driverkit";
.Case("tvos", PLATFORM_TVOS)
.Case("bridgeos", PLATFORM_BRIDGEOS)
.Case("iosmac", PLATFORM_MACCATALYST)
+ .Case("maccatalyst", PLATFORM_MACCATALYST)
.Case("driverkit", PLATFORM_DRIVERKIT)
.Default(PLATFORM_UNKNOWN);
#include "TextStubCommon.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/JSON.h"
+#include <utility>
// clang-format off
/*
if (Err)
return Err;
- SymbolFlags WeakFlag = SectionFlag | (SectionFlag == SymbolFlags::Undefined
- ? SymbolFlags::WeakReferenced
- : SymbolFlags::WeakDefined);
+ SymbolFlags WeakFlag =
+ SectionFlag |
+ (((SectionFlag & SymbolFlags::Undefined) == SymbolFlags::Undefined)
+ ? SymbolFlags::WeakReferenced
+ : SymbolFlags::WeakDefined);
Err = collectFromArray(
TBDKey::Weak, Segment, [&Result, WeakFlag](StringRef Name) {
JSONSymbol Sym = {SymbolKind::GlobalSymbol, Name.str(), WeakFlag};
} else {
MappedTargets = *TargetsOrErr;
}
- Result.emplace_back(std::make_pair(Targets, std::vector<JSONSymbol>()));
+ Result.emplace_back(
+ std::make_pair(std::move(MappedTargets), std::vector<JSONSymbol>()));
auto *DataSection = Obj->getObject(Keys[TBDKey::Data]);
auto *TextSection = Obj->getObject(Keys[TBDKey::Text]);
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";
" 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"
" objc-classes: []\n"
" objc-eh-types: []\n"
" objc-ivars: []\n"
- " weak-symbols: []\n"
+ " weak-symbols: [weakReference]\n"
" thread-local-symbols: []\n"
"...\n";
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);
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());
NestedFileB.setCurrentVersion(PackedVersion(1, 0, 0));
NestedFileB.setTwoLevelNamespace();
NestedFileB.setApplicationExtensionSafe(true);
- NestedFileB.addSymbol(SymbolKind::GlobalSymbol, "_varFooBaz", AllTargets,
+ NestedFileB.addSymbol(SymbolKind::GlobalSymbol, "_varFooBaz", {AllTargets[0]},
SymbolFlags::Data);
File.addDocument(std::make_shared<InterfaceFile>(std::move(NestedFileB)));