diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2023-02-22 13:43:04 -0800 |
---|---|---|
committer | Cyndy Ishida <cyndy_ishida@apple.com> | 2023-02-22 15:46:06 -0800 |
commit | 9b29de1c793c9268be20387514e62b224071e78f (patch) | |
tree | baf38ec4ac133b1015f8506baa5121a716d12c3f /llvm/unittests/TextAPI | |
parent | 74b67e53c638fae6542372681cc181f1f4e23f12 (diff) | |
download | llvm-9b29de1c793c9268be20387514e62b224071e78f.zip llvm-9b29de1c793c9268be20387514e62b224071e78f.tar.gz llvm-9b29de1c793c9268be20387514e62b224071e78f.tar.bz2 |
[llvm][TextAPI] Clean up minor bugs in YAML TextStub
* Always print out maccatalyst in format
* Traverse symbols via InterfaceFile symbol APIs
* Properly track addition of flags.
Reviewed By: ributzka
Differential Revision: https://reviews.llvm.org/D144428
Diffstat (limited to 'llvm/unittests/TextAPI')
-rw-r--r-- | llvm/unittests/TextAPI/TextStubV3Tests.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/TextAPI/TextStubV4Tests.cpp | 31 | ||||
-rw-r--r-- | llvm/unittests/TextAPI/TextStubV5Tests.cpp | 2 |
3 files changed, 22 insertions, 13 deletions
diff --git a/llvm/unittests/TextAPI/TextStubV3Tests.cpp b/llvm/unittests/TextAPI/TextStubV3Tests.cpp index 55751f0..b97b6a2 100644 --- a/llvm/unittests/TextAPI/TextStubV3Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV3Tests.cpp @@ -495,7 +495,7 @@ TEST(TBDv3, Platform_bridgeOS) { 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 index 17815a9..39dac0a 100644 --- a/llvm/unittests/TextAPI/TextStubV4Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV4Tests.cpp @@ -64,7 +64,7 @@ TEST(TBDv4, ReadFile) { " 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 @@ TEST(TBDv4, ReadFile) { " 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 @@ TEST(TBDv4, ReadFile) { 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 @@ TEST(TBDv4, ReadFile) { 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()); diff --git a/llvm/unittests/TextAPI/TextStubV5Tests.cpp b/llvm/unittests/TextAPI/TextStubV5Tests.cpp index 2536a5a..3deb38a 100644 --- a/llvm/unittests/TextAPI/TextStubV5Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV5Tests.cpp @@ -877,7 +877,7 @@ TEST(TBDv5, WriteMultipleDocuments) { 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))); |