208struct ExportSection {
209 std::vector<Architecture> Architectures;
210 std::vector<FlowStringRef> AllowableClients;
211 std::vector<FlowStringRef> ReexportedLibraries;
212 std::vector<FlowStringRef> Symbols;
213 std::vector<FlowStringRef> Classes;
214 std::vector<FlowStringRef> ClassEHs;
215 std::vector<FlowStringRef> IVars;
216 std::vector<FlowStringRef> WeakDefSymbols;
217 std::vector<FlowStringRef> TLVSymbols;
220struct UndefinedSection {
221 std::vector<Architecture> Architectures;
222 std::vector<FlowStringRef> Symbols;
223 std::vector<FlowStringRef> Classes;
224 std::vector<FlowStringRef> ClassEHs;
225 std::vector<FlowStringRef> IVars;
226 std::vector<FlowStringRef> WeakRefSymbols;
230struct SymbolSection {
232 std::vector<FlowStringRef> Symbols;
233 std::vector<FlowStringRef> Classes;
234 std::vector<FlowStringRef> ClassEHs;
235 std::vector<FlowStringRef> Ivars;
236 std::vector<FlowStringRef> WeakSymbols;
237 std::vector<FlowStringRef> TlvSymbols;
240struct MetadataSection {
241 enum Option { Clients, Libraries };
242 std::vector<Target> Targets;
243 std::vector<FlowStringRef> Values;
246struct UmbrellaSection {
247 std::vector<Target> Targets;
248 std::string Umbrella;
257 UUIDv4(
const Target &TargetID,
const std::string &
Value)
276 static void mapping(IO &IO, ExportSection &Section) {
277 const auto *Ctx =
reinterpret_cast<TextAPIContext *
>(IO.getContext());
278 assert((!Ctx || Ctx->FileKind != FileType::Invalid) &&
279 "File type is not set in YAML context");
281 IO.mapRequired(
"archs", Section.Architectures);
282 if (Ctx->FileKind == FileType::TBD_V1)
283 IO.mapOptional(
"allowed-clients", Section.AllowableClients);
285 IO.mapOptional(
"allowable-clients", Section.AllowableClients);
286 IO.mapOptional(
"re-exports", Section.ReexportedLibraries);
287 IO.mapOptional(
"symbols", Section.Symbols);
288 IO.mapOptional(
"objc-classes", Section.Classes);
289 if (Ctx->FileKind == FileType::TBD_V3)
290 IO.mapOptional(
"objc-eh-types", Section.ClassEHs);
291 IO.mapOptional(
"objc-ivars", Section.IVars);
292 IO.mapOptional(
"weak-def-symbols", Section.WeakDefSymbols);
293 IO.mapOptional(
"thread-local-symbols", Section.TLVSymbols);
298 static void mapping(IO &IO, UndefinedSection &Section) {
299 const auto *Ctx =
reinterpret_cast<TextAPIContext *
>(IO.getContext());
300 assert((!Ctx || Ctx->FileKind != FileType::Invalid) &&
301 "File type is not set in YAML context");
303 IO.mapRequired(
"archs", Section.Architectures);
304 IO.mapOptional(
"symbols", Section.Symbols);
305 IO.mapOptional(
"objc-classes", Section.Classes);
306 if (Ctx->FileKind == FileType::TBD_V3)
307 IO.mapOptional(
"objc-eh-types", Section.ClassEHs);
308 IO.mapOptional(
"objc-ivars", Section.IVars);
309 IO.mapOptional(
"weak-ref-symbols", Section.WeakRefSymbols);
314 static void mapping(IO &IO, SymbolSection &Section) {
315 IO.mapRequired(
"targets", Section.Targets);
316 IO.mapOptional(
"symbols", Section.Symbols);
317 IO.mapOptional(
"objc-classes", Section.Classes);
318 IO.mapOptional(
"objc-eh-types", Section.ClassEHs);
319 IO.mapOptional(
"objc-ivars", Section.Ivars);
320 IO.mapOptional(
"weak-symbols", Section.WeakSymbols);
321 IO.mapOptional(
"thread-local-symbols", Section.TlvSymbols);
326 static void mapping(IO &IO, UmbrellaSection &Section) {
327 IO.mapRequired(
"targets", Section.Targets);
328 IO.mapRequired(
"umbrella", Section.Umbrella);
334 IO.mapRequired(
"target",
UUID.TargetID);
335 IO.mapRequired(
"value",
UUID.Value);
340struct MappingContextTraits<MetadataSection, MetadataSection::Option> {
341 static void mapping(IO &IO, MetadataSection &Section,
342 MetadataSection::Option &OptionKind) {
343 IO.mapRequired(
"targets", Section.Targets);
344 switch (OptionKind) {
345 case MetadataSection::Option::Clients:
346 IO.mapRequired(
"clients", Section.Values);
348 case MetadataSection::Option::Libraries:
349 IO.mapRequired(
"libraries", Section.Values);
358 IO.bitSetCase(Flags,
"flat_namespace", TBDFlags::FlatNamespace);
359 IO.bitSetCase(Flags,
"not_app_extension_safe",
360 TBDFlags::NotApplicationExtensionSafe);
361 IO.bitSetCase(Flags,
"installapi", TBDFlags::InstallAPI);
362 IO.bitSetCase(Flags,
"not_for_dyld_shared_cache",
363 TBDFlags::OSLibNotForSharedCache);
370 switch (
Value.Platform) {
371#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
373 case PLATFORM_##platform: \
374 OS << #tapi_target; \
376#include "llvm/BinaryFormat/MachO.def"
384 return "unparsable target";
389 return "unknown architecture";
390 if (
Value.Platform == PLATFORM_UNKNOWN)
391 return "unknown platform";
400 struct NormalizedTBD {
403 Architectures = File->getArchitectures();
404 Platforms = File->getPlatforms();
405 InstallName = File->getInstallName();
407 CompatibilityVersion =
PackedVersion(File->getCompatibilityVersion());
408 SwiftABIVersion = File->getSwiftABIVersion();
409 ObjCConstraint = File->getObjCConstraint();
411 Flags = TBDFlags::None;
412 if (!File->isApplicationExtensionSafe())
413 Flags |= TBDFlags::NotApplicationExtensionSafe;
415 if (!File->isTwoLevelNamespace())
416 Flags |= TBDFlags::FlatNamespace;
418 if (!File->umbrellas().empty())
419 ParentUmbrella = File->umbrellas().begin()->second;
421 std::set<ArchitectureSet> ArchSet;
422 for (
const auto &Library : File->allowableClients())
423 ArchSet.insert(Library.getArchitectures());
425 for (
const auto &Library : File->reexportedLibraries())
426 ArchSet.insert(Library.getArchitectures());
428 std::map<const Symbol *, ArchitectureSet> SymbolToArchSet;
429 for (
const auto *
Symbol : File->symbols()) {
431 SymbolToArchSet[
Symbol] = Architectures;
432 ArchSet.insert(Architectures);
435 for (
auto Architectures : ArchSet) {
436 ExportSection Section;
437 Section.Architectures = Architectures;
439 for (
const auto &Library : File->allowableClients())
440 if (Library.getArchitectures() == Architectures)
441 Section.AllowableClients.emplace_back(Library.getInstallName());
443 for (
const auto &Library : File->reexportedLibraries())
444 if (Library.getArchitectures() == Architectures)
445 Section.ReexportedLibraries.emplace_back(Library.getInstallName());
447 for (
const auto &SymArch : SymbolToArchSet) {
448 if (SymArch.second != Architectures)
451 const auto *
Symbol = SymArch.first;
453 case EncodeKind::GlobalSymbol:
461 case EncodeKind::ObjectiveCClass:
462 if (File->getFileType() != FileType::TBD_V3)
463 Section.Classes.emplace_back(
468 case EncodeKind::ObjectiveCClassEHType:
469 if (File->getFileType() != FileType::TBD_V3)
470 Section.Symbols.emplace_back(
475 case EncodeKind::ObjectiveCInstanceVariable:
476 if (File->getFileType() != FileType::TBD_V3)
477 Section.IVars.emplace_back(
490 Exports.emplace_back(std::move(Section));
494 SymbolToArchSet.clear();
496 for (
const auto *
Symbol : File->undefineds()) {
498 SymbolToArchSet[
Symbol] = Architectures;
499 ArchSet.insert(Architectures);
502 for (
auto Architectures : ArchSet) {
503 UndefinedSection Section;
504 Section.Architectures = Architectures;
506 for (
const auto &SymArch : SymbolToArchSet) {
507 if (SymArch.second != Architectures)
510 const auto *
Symbol = SymArch.first;
512 case EncodeKind::GlobalSymbol:
518 case EncodeKind::ObjectiveCClass:
519 if (File->getFileType() != FileType::TBD_V3)
520 Section.Classes.emplace_back(
525 case EncodeKind::ObjectiveCClassEHType:
526 if (File->getFileType() != FileType::TBD_V3)
527 Section.Symbols.emplace_back(
532 case EncodeKind::ObjectiveCInstanceVariable:
533 if (File->getFileType() != FileType::TBD_V3)
534 Section.IVars.emplace_back(
546 Undefineds.emplace_back(std::move(Section));
559 for (
auto Platform : Platforms) {
563 if ((
Architecture == AK_i386) && (Platform == PLATFORM_MACCATALYST))
577 File->setPath(Ctx->Path);
578 File->setFileType(Ctx->FileKind);
579 File->addTargets(synthesizeTargets(Architectures, Platforms));
580 File->setInstallName(InstallName);
581 File->setCurrentVersion(CurrentVersion);
582 File->setCompatibilityVersion(CompatibilityVersion);
583 File->setSwiftABIVersion(SwiftABIVersion);
584 File->setObjCConstraint(ObjCConstraint);
585 for (
const auto &
Target : File->targets())
586 File->addParentUmbrella(
Target, ParentUmbrella);
588 if (Ctx->FileKind == FileType::TBD_V1) {
589 File->setTwoLevelNamespace();
590 File->setApplicationExtensionSafe();
592 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
593 File->setApplicationExtensionSafe(
594 !(Flags & TBDFlags::NotApplicationExtensionSafe));
600 const auto Flags = SymbolFlags::Data;
602 for (
const auto &Section : Exports) {
604 synthesizeTargets(Section.Architectures, Platforms);
606 for (
const auto &
Lib : Section.AllowableClients)
607 for (
const auto &
Target : Targets)
610 for (
const auto &
Lib : Section.ReexportedLibraries)
611 for (
const auto &
Target : Targets)
614 for (
const auto &
Symbol : Section.Symbols) {
615 if (Ctx->FileKind != FileType::TBD_V3 &&
617 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
618 Symbol.value.drop_front(15), Targets, Flags);
620 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets, Flags);
622 for (
auto &
Symbol : Section.Classes) {
624 if (Ctx->FileKind != FileType::TBD_V3)
626 File->addSymbol(EncodeKind::ObjectiveCClass,
Name, Targets, Flags);
628 for (
auto &
Symbol : Section.ClassEHs)
629 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
Symbol, Targets,
631 for (
auto &
Symbol : Section.IVars) {
633 if (Ctx->FileKind != FileType::TBD_V3)
635 File->addSymbol(EncodeKind::ObjectiveCInstanceVariable,
Name, Targets,
638 for (
auto &
Symbol : Section.WeakDefSymbols)
639 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
640 SymbolFlags::WeakDefined | Flags);
641 for (
auto &
Symbol : Section.TLVSymbols)
642 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
643 SymbolFlags::ThreadLocalValue | Flags);
646 for (
const auto &Section : Undefineds) {
648 synthesizeTargets(Section.Architectures, Platforms);
649 for (
auto &
Symbol : Section.Symbols) {
650 if (Ctx->FileKind != FileType::TBD_V3 &&
652 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
653 Symbol.value.drop_front(15), Targets,
654 SymbolFlags::Undefined | Flags);
656 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
657 SymbolFlags::Undefined | Flags);
659 for (
auto &
Symbol : Section.Classes) {
661 if (Ctx->FileKind != FileType::TBD_V3)
663 File->addSymbol(EncodeKind::ObjectiveCClass,
Name, Targets,
664 SymbolFlags::Undefined | Flags);
666 for (
auto &
Symbol : Section.ClassEHs)
667 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
Symbol, Targets,
668 SymbolFlags::Undefined | Flags);
669 for (
auto &
Symbol : Section.IVars) {
671 if (Ctx->FileKind != FileType::TBD_V3)
673 File->addSymbol(EncodeKind::ObjectiveCInstanceVariable,
Name, Targets,
674 SymbolFlags::Undefined | Flags);
676 for (
auto &
Symbol : Section.WeakRefSymbols)
677 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
678 SymbolFlags::Undefined | SymbolFlags::WeakReferenced |
701 SwiftVersion SwiftABIVersion{0};
710 if (IO.mapTag(
"!tapi-tbd",
false))
712 else if (IO.mapTag(
"!tapi-tbd-v3",
false))
714 else if (IO.mapTag(
"!tapi-tbd-v2",
false))
716 else if (IO.mapTag(
"!tapi-tbd-v1",
false) ||
717 IO.mapTag(
"tag:yaml.org,2002:map",
false))
727 assert((!Ctx || !IO.outputting() ||
728 (Ctx && Ctx->FileKind != FileType::Invalid)) &&
729 "File type is not set in YAML context");
731 if (!IO.outputting()) {
732 setFileTypeForInput(Ctx, IO);
733 switch (Ctx->FileKind) {
736 case FileType::TBD_V4:
737 mapKeysToValuesV4(IO, File);
739 case FileType::Invalid:
740 IO.setError(
"unsupported file type");
745 switch (Ctx->FileKind) {
748 case FileType::TBD_V4:
749 mapKeysToValuesV4(IO, File);
751 case FileType::TBD_V3:
752 IO.mapTag(
"!tapi-tbd-v3",
true);
754 case FileType::TBD_V2:
755 IO.mapTag(
"!tapi-tbd-v2",
true);
757 case FileType::TBD_V1:
762 mapKeysToValues(Ctx->FileKind, IO, File);
766 struct NormalizedTBD_V4 {
771 TBDVersion = Ctx->FileKind >> 4;
772 Targets.insert(Targets.begin(), File->targets().begin(),
773 File->targets().end());
774 InstallName = File->getInstallName();
775 CurrentVersion = File->getCurrentVersion();
776 CompatibilityVersion = File->getCompatibilityVersion();
777 SwiftABIVersion = File->getSwiftABIVersion();
779 Flags = TBDFlags::None;
780 if (!File->isApplicationExtensionSafe())
781 Flags |= TBDFlags::NotApplicationExtensionSafe;
783 if (!File->isTwoLevelNamespace())
784 Flags |= TBDFlags::FlatNamespace;
786 if (File->isOSLibNotForSharedCache())
787 Flags |= TBDFlags::OSLibNotForSharedCache;
790 std::map<std::string, TargetList> valueToTargetList;
791 for (
const auto &it : File->umbrellas())
792 valueToTargetList[it.second].emplace_back(it.first);
794 for (
const auto &it : valueToTargetList) {
795 UmbrellaSection CurrentSection;
796 CurrentSection.Targets.insert(CurrentSection.Targets.begin(),
797 it.second.begin(), it.second.end());
798 CurrentSection.Umbrella = it.first;
799 ParentUmbrellas.emplace_back(std::move(CurrentSection));
803 assignTargetsToLibrary(File->allowableClients(), AllowableClients);
804 assignTargetsToLibrary(File->reexportedLibraries(), ReexportedLibraries);
809 std::set<TargetList> TargetSet;
810 std::map<const Symbol *, TargetList> SymbolToTargetList;
811 for (
const auto *
Symbol : Symbols) {
813 SymbolToTargetList[
Symbol] = Targets;
814 TargetSet.emplace(std::move(Targets));
816 for (
const auto &TargetIDs : TargetSet) {
817 SymbolSection CurrentSection;
818 CurrentSection.Targets.
insert(CurrentSection.Targets.begin(),
819 TargetIDs.begin(), TargetIDs.end());
821 for (
const auto &
IT : SymbolToTargetList) {
822 if (
IT.second != TargetIDs)
827 case EncodeKind::GlobalSymbol:
835 case EncodeKind::ObjectiveCClass:
838 case EncodeKind::ObjectiveCClassEHType:
841 case EncodeKind::ObjectiveCInstanceVariable:
846 sort(CurrentSection.Symbols);
847 sort(CurrentSection.Classes);
848 sort(CurrentSection.ClassEHs);
849 sort(CurrentSection.Ivars);
850 sort(CurrentSection.WeakSymbols);
851 sort(CurrentSection.TlvSymbols);
852 CurrentSections.emplace_back(std::move(CurrentSection));
856 handleSymbols(Exports, File->exports());
857 handleSymbols(Reexports, File->reexports());
858 handleSymbols(Undefineds, File->undefineds());
866 File->setPath(Ctx->Path);
867 File->setFileType(Ctx->FileKind);
868 File->addTargets(Targets);
869 File->setInstallName(InstallName);
870 File->setCurrentVersion(CurrentVersion);
871 File->setCompatibilityVersion(CompatibilityVersion);
872 File->setSwiftABIVersion(SwiftABIVersion);
873 for (
const auto &CurrentSection : ParentUmbrellas)
874 for (
const auto &target : CurrentSection.Targets)
875 File->addParentUmbrella(target, CurrentSection.Umbrella);
876 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
877 File->setApplicationExtensionSafe(
878 !(Flags & TBDFlags::NotApplicationExtensionSafe));
879 File->setOSLibNotForSharedCache(
880 (Flags & TBDFlags::OSLibNotForSharedCache));
882 for (
const auto &CurrentSection : AllowableClients) {
883 for (
const auto &lib : CurrentSection.Values)
884 for (
const auto &
Target : CurrentSection.Targets)
885 File->addAllowableClient(lib,
Target);
888 for (
const auto &CurrentSection : ReexportedLibraries) {
889 for (
const auto &
Lib : CurrentSection.Values)
890 for (
const auto &
Target : CurrentSection.Targets)
894 auto handleSymbols = [File](
const SectionList &CurrentSections,
899 const SymbolFlags Flag = InputFlag | SymbolFlags::Data;
901 for (
const auto &CurrentSection : CurrentSections) {
902 for (
auto &sym : CurrentSection.Symbols)
903 File->addSymbol(EncodeKind::GlobalSymbol, sym,
904 CurrentSection.Targets, Flag);
906 for (
auto &sym : CurrentSection.Classes)
907 File->addSymbol(EncodeKind::ObjectiveCClass, sym,
908 CurrentSection.Targets, Flag);
910 for (
auto &sym : CurrentSection.ClassEHs)
911 File->addSymbol(EncodeKind::ObjectiveCClassEHType, sym,
912 CurrentSection.Targets, Flag);
914 for (
auto &sym : CurrentSection.Ivars)
915 File->addSymbol(EncodeKind::ObjectiveCInstanceVariable, sym,
916 CurrentSection.Targets, Flag);
919 ((Flag & SymbolFlags::Undefined) == SymbolFlags::Undefined)
920 ? SymbolFlags::WeakReferenced
921 : SymbolFlags::WeakDefined;
922 for (
auto &sym : CurrentSection.WeakSymbols) {
923 File->addSymbol(EncodeKind::GlobalSymbol, sym,
924 CurrentSection.Targets, Flag | SymFlag);
927 for (
auto &sym : CurrentSection.TlvSymbols)
928 File->addSymbol(EncodeKind::GlobalSymbol, sym,
929 CurrentSection.Targets,
930 Flag | SymbolFlags::ThreadLocalValue);
934 handleSymbols(Exports);
935 handleSymbols(Reexports, SymbolFlags::Rexported);
936 handleSymbols(Undefineds, SymbolFlags::Undefined);
947 SwiftVersion SwiftABIVersion{0};
957 void assignTargetsToLibrary(
const std::vector<InterfaceFileRef> &Libraries,
958 std::vector<MetadataSection> &Section) {
959 std::set<TargetList> targetSet;
960 std::map<const InterfaceFileRef *, TargetList> valueToTargetList;
961 for (
const auto &
library : Libraries) {
963 valueToTargetList[&
library] = targets;
964 targetSet.emplace(std::move(targets));
967 for (
const auto &targets : targetSet) {
968 MetadataSection CurrentSection;
969 CurrentSection.Targets.
insert(CurrentSection.Targets.begin(),
970 targets.begin(), targets.end());
972 for (
const auto &it : valueToTargetList) {
973 if (it.second != targets)
976 CurrentSection.Values.emplace_back(it.first->getInstallName());
979 Section.emplace_back(std::move(CurrentSection));
986 MappingNormalization<NormalizedTBD, const InterfaceFile *> Keys(IO, File);
987 std::vector<UUID> EmptyUUID;
988 IO.mapRequired(
"archs", Keys->Architectures);
989 if (FileKind != FileType::TBD_V1)
990 IO.mapOptional(
"uuids", EmptyUUID);
991 IO.mapRequired(
"platform", Keys->Platforms);
992 if (FileKind != FileType::TBD_V1)
993 IO.mapOptional(
"flags", Keys->Flags, TBDFlags::None);
994 IO.mapRequired(
"install-name", Keys->InstallName);
995 IO.mapOptional(
"current-version", Keys->CurrentVersion,
997 IO.mapOptional(
"compatibility-version", Keys->CompatibilityVersion,
999 if (FileKind != FileType::TBD_V3)
1000 IO.mapOptional(
"swift-version", Keys->SwiftABIVersion, SwiftVersion(0));
1002 IO.mapOptional(
"swift-abi-version", Keys->SwiftABIVersion,
1004 IO.mapOptional(
"objc-constraint", Keys->ObjCConstraint,
1005 (FileKind == FileType::TBD_V1)
1006 ? ObjCConstraintType::None
1007 : ObjCConstraintType::Retain_Release);
1008 if (FileKind != FileType::TBD_V1)
1009 IO.mapOptional(
"parent-umbrella", Keys->ParentUmbrella,
StringRef());
1010 IO.mapOptional(
"exports", Keys->Exports);
1011 if (FileKind != FileType::TBD_V1)
1012 IO.mapOptional(
"undefineds", Keys->Undefineds);
1016 MappingNormalization<NormalizedTBD_V4, const InterfaceFile *> Keys(IO,
1018 std::vector<UUIDv4> EmptyUUID;
1019 IO.mapTag(
"!tapi-tbd",
true);
1020 IO.mapRequired(
"tbd-version", Keys->TBDVersion);
1021 IO.mapRequired(
"targets", Keys->Targets);
1022 IO.mapOptional(
"uuids", EmptyUUID);
1023 IO.mapOptional(
"flags", Keys->Flags, TBDFlags::None);
1024 IO.mapRequired(
"install-name", Keys->InstallName);
1025 IO.mapOptional(
"current-version", Keys->CurrentVersion,
1027 IO.mapOptional(
"compatibility-version", Keys->CompatibilityVersion,
1029 IO.mapOptional(
"swift-abi-version", Keys->SwiftABIVersion, SwiftVersion(0));
1030 IO.mapOptional(
"parent-umbrella", Keys->ParentUmbrellas);
1031 auto OptionKind = MetadataSection::Option::Clients;
1032 IO.mapOptionalWithContext(
"allowable-clients", Keys->AllowableClients,
1034 OptionKind = MetadataSection::Option::Libraries;
1035 IO.mapOptionalWithContext(
"reexported-libraries", Keys->ReexportedLibraries,
1037 IO.mapOptional(
"exports", Keys->Exports);
1038 IO.mapOptional(
"reexports", Keys->Reexports);
1039 IO.mapOptional(
"undefineds", Keys->Undefineds);
1044struct DocumentListTraits<
std::vector<const MachO::InterfaceFile *>> {
1045 static size_t size(IO &IO, std::vector<const MachO::InterfaceFile *> &Seq) {
1050 if (
Index >= Seq.size())
1051 Seq.resize(
Index + 1);
1069 NewDiag.
print(
nullptr, S);
1070 File->ErrorMessage = (
"malformed file\n" + Message).str();
1075 if (TAPIFile.starts_with(
"{") && TAPIFile.ends_with(
"}"))
1078 if (!TAPIFile.ends_with(
"..."))
1081 if (TAPIFile.starts_with(
"--- !tapi-tbd"))
1084 if (TAPIFile.starts_with(
"--- !tapi-tbd-v3"))
1087 if (TAPIFile.starts_with(
"--- !tapi-tbd-v2"))
1090 if (TAPIFile.starts_with(
"--- !tapi-tbd-v1") ||
1091 TAPIFile.starts_with(
"---\narchs:"))
1101 if (
auto FTOrErr =
canRead(InputBuffer))
1104 return FTOrErr.takeError();
1110 return FileOrErr.takeError();
1112 (*FileOrErr)->setPath(Ctx.
Path);
1113 return std::move(*FileOrErr);
1118 std::vector<const InterfaceFile *> Files;
1123 auto File = std::unique_ptr<InterfaceFile>(
1128 std::shared_ptr<InterfaceFile>(
const_cast<InterfaceFile *
>(FI)));
1131 return make_error<StringError>(Ctx.
ErrorMessage, YAMLIn.error());
1133 return std::move(File);
1137 const FileType FileKind,
bool Compact) {
1139 Ctx.
Path = std::string(File.getPath());
1151 llvm::yaml::Output YAMLOut(
OS, &Ctx, 80);
1153 std::vector<const InterfaceFile *> Files;
1154 Files.emplace_back(&File);
1156 for (
const auto &
Document : File.documents())
1157 Files.emplace_back(
Document.get());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
This file defines the BumpPtrAllocator interface.
Replace intrinsics with calls to vector library
This file defines the SmallString class.
std::pair< llvm::MachO::Target, std::string > UUID
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type)
Allocate memory in an ever growing pool, as if by bump-pointer.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Defines the interface file.
bool isWeakDefined() const
const_target_range targets() const
bool isThreadLocalValue() const
ArchitectureSet getArchitectures() const
StringRef getName() const
EncodeKind getKind() const
bool isWeakReferenced() const
static LLVM_ABI llvm::Expected< Target > create(StringRef Target)
static LLVM_ABI Expected< FileType > canRead(MemoryBufferRef InputBuffer)
Determine whether input can be interpreted as TAPI text file.
static LLVM_ABI Expected< std::unique_ptr< InterfaceFile > > get(MemoryBufferRef InputBuffer)
Parse and get an InterfaceFile that represents the full library.
static LLVM_ABI Error writeToStream(raw_ostream &OS, const InterfaceFile &File, const FileType FileKind=FileType::Invalid, bool Compact=false)
Write TAPI text file contents into stream.
StringRef getBufferIdentifier() const
StringRef getBuffer() const
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
LLVM_ABI void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true, bool ShowLocation=true) const
SourceMgr::DiagKind getKind() const
StringRef getLineContents() const
StringRef getMessage() const
ArrayRef< SMFixIt > getFixIts() const
ArrayRef< std::pair< unsigned, unsigned > > getRanges() const
const SourceMgr * getSourceMgr() const
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
reference emplace_back(ArgTypes &&... Args)
iterator insert(iterator I, T &&Elt)
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
Target - Wrapper for Target specific information.
LLVM Value Representation.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
A YAML Stream is a sequence of Documents.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
FileType
Defines the file type TextAPI files can represent.
@ Invalid
Invalid file type.
@ TBD_V1
Text-based stub file (.tbd) version 1.0.
@ TBD_V3
Text-based stub file (.tbd) version 3.0.
@ TBD_V5
Text-based stub file (.tbd) version 5.0.
@ TBD_V4
Text-based stub file (.tbd) version 4.0.
@ TBD_V2
Text-based stub file (.tbd) version 2.0.
Error serializeInterfaceFileToJSON(raw_ostream &OS, const InterfaceFile &File, const FileType FileKind, bool Compact)
ObjCConstraintType
Defines a list of Objective-C constraints.
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
LLVM_ABI PlatformType mapToPlatformType(PlatformType Platform, bool WantSim)
Expected< std::unique_ptr< InterfaceFile > > getInterfaceFileFromJSON(StringRef JSON)
constexpr StringLiteral ObjC2EHTypePrefix
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void sort(IteratorTy Start, IteratorTy End)
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
static const InterfaceFile *& element(IO &IO, std::vector< const InterfaceFile * > &Seq, size_t Index)
static size_t size(IO &IO, std::vector< const MachO::InterfaceFile * > &Seq)
static void mapping(IO &IO, MetadataSection &Section, MetadataSection::Option &OptionKind)
static void mapping(IO &IO, ExportSection &Section)
static void mapping(IO &IO, SymbolSection &Section)
static void mapping(IO &IO, UUIDv4 &UUID)
static void mapping(IO &IO, UmbrellaSection &Section)
static void mapping(IO &IO, UndefinedSection &Section)
std::vector< UmbrellaSection > ParentUmbrellas
PackedVersion CurrentVersion
std::vector< UUIDv4 > UUIDs
std::vector< MetadataSection > AllowableClients
PackedVersion CompatibilityVersion
std::vector< MetadataSection > ReexportedLibraries
const InterfaceFile * denormalize(IO &IO)
NormalizedTBD_V4(IO &IO, const InterfaceFile *&File)
std::vector< UndefinedSection > Undefineds
NormalizedTBD(IO &IO, const InterfaceFile *&File)
StringRef copyString(StringRef String)
TargetList synthesizeTargets(ArchitectureSet Architectures, const PlatformSet &Platforms)
std::vector< UUID > UUIDs
const InterfaceFile * denormalize(IO &IO)
std::vector< Architecture > Architectures
llvm::BumpPtrAllocator Allocator
PackedVersion CurrentVersion
std::vector< ExportSection > Exports
PackedVersion CompatibilityVersion
static void mapKeysToValuesV4(IO &IO, const InterfaceFile *&File)
static void setFileTypeForInput(TextAPIContext *Ctx, IO &IO)
std::vector< SymbolSection > SectionList
static void mapping(IO &IO, const InterfaceFile *&File)
static void mapKeysToValues(FileType FileKind, IO &IO, const InterfaceFile *&File)
static void bitset(IO &IO, TBDFlags &Flags)
static StringRef input(StringRef Scalar, void *, Target &Value)
static void output(const Target &Value, void *, raw_ostream &OS)
static QuotingType mustQuote(StringRef)