209struct ExportSection {
210 std::vector<Architecture> Architectures;
211 std::vector<FlowStringRef> AllowableClients;
212 std::vector<FlowStringRef> ReexportedLibraries;
213 std::vector<FlowStringRef> Symbols;
214 std::vector<FlowStringRef> Classes;
215 std::vector<FlowStringRef> ClassEHs;
216 std::vector<FlowStringRef> IVars;
217 std::vector<FlowStringRef> WeakDefSymbols;
218 std::vector<FlowStringRef> TLVSymbols;
221struct UndefinedSection {
222 std::vector<Architecture> Architectures;
223 std::vector<FlowStringRef> Symbols;
224 std::vector<FlowStringRef> Classes;
225 std::vector<FlowStringRef> ClassEHs;
226 std::vector<FlowStringRef> IVars;
227 std::vector<FlowStringRef> WeakRefSymbols;
231struct SymbolSection {
233 std::vector<FlowStringRef> Symbols;
234 std::vector<FlowStringRef> Classes;
235 std::vector<FlowStringRef> ClassEHs;
236 std::vector<FlowStringRef> Ivars;
237 std::vector<FlowStringRef> WeakSymbols;
238 std::vector<FlowStringRef> TlvSymbols;
241struct MetadataSection {
242 enum Option { Clients, Libraries };
243 std::vector<Target> Targets;
244 std::vector<FlowStringRef> Values;
247struct UmbrellaSection {
248 std::vector<Target> Targets;
249 std::string Umbrella;
258 UUIDv4(
const Target &TargetID,
const std::string &
Value)
277 static void mapping(IO &IO, ExportSection &Section) {
278 const auto *Ctx =
reinterpret_cast<TextAPIContext *
>(IO.getContext());
279 assert((!Ctx || Ctx->FileKind != FileType::Invalid) &&
280 "File type is not set in YAML context");
282 IO.mapRequired(
"archs", Section.Architectures);
283 if (Ctx->FileKind == FileType::TBD_V1)
284 IO.mapOptional(
"allowed-clients", Section.AllowableClients);
286 IO.mapOptional(
"allowable-clients", Section.AllowableClients);
287 IO.mapOptional(
"re-exports", Section.ReexportedLibraries);
288 IO.mapOptional(
"symbols", Section.Symbols);
289 IO.mapOptional(
"objc-classes", Section.Classes);
290 if (Ctx->FileKind == FileType::TBD_V3)
291 IO.mapOptional(
"objc-eh-types", Section.ClassEHs);
292 IO.mapOptional(
"objc-ivars", Section.IVars);
293 IO.mapOptional(
"weak-def-symbols", Section.WeakDefSymbols);
294 IO.mapOptional(
"thread-local-symbols", Section.TLVSymbols);
299 static void mapping(IO &IO, UndefinedSection &Section) {
300 const auto *Ctx =
reinterpret_cast<TextAPIContext *
>(IO.getContext());
301 assert((!Ctx || Ctx->FileKind != FileType::Invalid) &&
302 "File type is not set in YAML context");
304 IO.mapRequired(
"archs", Section.Architectures);
305 IO.mapOptional(
"symbols", Section.Symbols);
306 IO.mapOptional(
"objc-classes", Section.Classes);
307 if (Ctx->FileKind == FileType::TBD_V3)
308 IO.mapOptional(
"objc-eh-types", Section.ClassEHs);
309 IO.mapOptional(
"objc-ivars", Section.IVars);
310 IO.mapOptional(
"weak-ref-symbols", Section.WeakRefSymbols);
315 static void mapping(IO &IO, SymbolSection &Section) {
316 IO.mapRequired(
"targets", Section.Targets);
317 IO.mapOptional(
"symbols", Section.Symbols);
318 IO.mapOptional(
"objc-classes", Section.Classes);
319 IO.mapOptional(
"objc-eh-types", Section.ClassEHs);
320 IO.mapOptional(
"objc-ivars", Section.Ivars);
321 IO.mapOptional(
"weak-symbols", Section.WeakSymbols);
322 IO.mapOptional(
"thread-local-symbols", Section.TlvSymbols);
327 static void mapping(IO &IO, UmbrellaSection &Section) {
328 IO.mapRequired(
"targets", Section.Targets);
329 IO.mapRequired(
"umbrella", Section.Umbrella);
335 IO.mapRequired(
"target",
UUID.TargetID);
336 IO.mapRequired(
"value",
UUID.Value);
341struct MappingContextTraits<MetadataSection, MetadataSection::Option> {
342 static void mapping(IO &IO, MetadataSection &Section,
343 MetadataSection::Option &OptionKind) {
344 IO.mapRequired(
"targets", Section.Targets);
345 switch (OptionKind) {
346 case MetadataSection::Option::Clients:
347 IO.mapRequired(
"clients", Section.Values);
349 case MetadataSection::Option::Libraries:
350 IO.mapRequired(
"libraries", Section.Values);
359 IO.bitSetCase(Flags,
"flat_namespace", TBDFlags::FlatNamespace);
360 IO.bitSetCase(Flags,
"not_app_extension_safe",
361 TBDFlags::NotApplicationExtensionSafe);
362 IO.bitSetCase(Flags,
"installapi", TBDFlags::InstallAPI);
363 IO.bitSetCase(Flags,
"not_for_dyld_shared_cache",
364 TBDFlags::OSLibNotForSharedCache);
371 switch (
Value.Platform) {
372#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
374 case PLATFORM_##platform: \
375 OS << #tapi_target; \
377#include "llvm/BinaryFormat/MachO.def"
385 return "unparsable target";
390 return "unknown architecture";
391 if (
Value.Platform == PLATFORM_UNKNOWN)
392 return "unknown platform";
401 struct NormalizedTBD {
404 Architectures = File->getArchitectures();
405 Platforms = File->getPlatforms();
406 InstallName = File->getInstallName();
408 CompatibilityVersion =
PackedVersion(File->getCompatibilityVersion());
409 SwiftABIVersion = File->getSwiftABIVersion();
410 ObjCConstraint = File->getObjCConstraint();
412 Flags = TBDFlags::None;
413 if (!File->isApplicationExtensionSafe())
414 Flags |= TBDFlags::NotApplicationExtensionSafe;
416 if (!File->isTwoLevelNamespace())
417 Flags |= TBDFlags::FlatNamespace;
419 if (!File->umbrellas().empty())
420 ParentUmbrella = File->umbrellas().begin()->second;
422 std::set<ArchitectureSet> ArchSet;
423 for (
const auto &Library : File->allowableClients())
424 ArchSet.insert(Library.getArchitectures());
426 for (
const auto &Library : File->reexportedLibraries())
427 ArchSet.insert(Library.getArchitectures());
429 std::map<const Symbol *, ArchitectureSet> SymbolToArchSet;
430 for (
const auto *
Symbol : File->symbols()) {
432 SymbolToArchSet[
Symbol] = Architectures;
433 ArchSet.insert(Architectures);
436 for (
auto Architectures : ArchSet) {
437 ExportSection Section;
438 Section.Architectures = Architectures;
440 for (
const auto &Library : File->allowableClients())
441 if (Library.getArchitectures() == Architectures)
442 Section.AllowableClients.emplace_back(Library.getInstallName());
444 for (
const auto &Library : File->reexportedLibraries())
445 if (Library.getArchitectures() == Architectures)
446 Section.ReexportedLibraries.emplace_back(Library.getInstallName());
448 for (
const auto &SymArch : SymbolToArchSet) {
449 if (SymArch.second != Architectures)
452 const auto *
Symbol = SymArch.first;
454 case EncodeKind::GlobalSymbol:
462 case EncodeKind::ObjectiveCClass:
463 if (File->getFileType() != FileType::TBD_V3)
464 Section.Classes.emplace_back(
469 case EncodeKind::ObjectiveCClassEHType:
470 if (File->getFileType() != FileType::TBD_V3)
471 Section.Symbols.emplace_back(
476 case EncodeKind::ObjectiveCInstanceVariable:
477 if (File->getFileType() != FileType::TBD_V3)
478 Section.IVars.emplace_back(
491 Exports.emplace_back(std::move(Section));
495 SymbolToArchSet.clear();
497 for (
const auto *
Symbol : File->undefineds()) {
499 SymbolToArchSet[
Symbol] = Architectures;
500 ArchSet.insert(Architectures);
503 for (
auto Architectures : ArchSet) {
504 UndefinedSection Section;
505 Section.Architectures = Architectures;
507 for (
const auto &SymArch : SymbolToArchSet) {
508 if (SymArch.second != Architectures)
511 const auto *
Symbol = SymArch.first;
513 case EncodeKind::GlobalSymbol:
519 case EncodeKind::ObjectiveCClass:
520 if (File->getFileType() != FileType::TBD_V3)
521 Section.Classes.emplace_back(
526 case EncodeKind::ObjectiveCClassEHType:
527 if (File->getFileType() != FileType::TBD_V3)
528 Section.Symbols.emplace_back(
533 case EncodeKind::ObjectiveCInstanceVariable:
534 if (File->getFileType() != FileType::TBD_V3)
535 Section.IVars.emplace_back(
547 Undefineds.emplace_back(std::move(Section));
560 for (
auto Platform : Platforms) {
564 if ((
Architecture == AK_i386) && (Platform == PLATFORM_MACCATALYST))
578 File->setPath(Ctx->Path);
579 File->setFileType(Ctx->FileKind);
580 File->addTargets(synthesizeTargets(Architectures, Platforms));
581 File->setInstallName(InstallName);
582 File->setCurrentVersion(CurrentVersion);
583 File->setCompatibilityVersion(CompatibilityVersion);
584 File->setSwiftABIVersion(SwiftABIVersion);
585 File->setObjCConstraint(ObjCConstraint);
586 for (
const auto &
Target : File->targets())
587 File->addParentUmbrella(
Target, ParentUmbrella);
589 if (Ctx->FileKind == FileType::TBD_V1) {
590 File->setTwoLevelNamespace();
591 File->setApplicationExtensionSafe();
593 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
594 File->setApplicationExtensionSafe(
595 !(Flags & TBDFlags::NotApplicationExtensionSafe));
601 const auto Flags = SymbolFlags::Data;
603 for (
const auto &Section : Exports) {
605 synthesizeTargets(Section.Architectures, Platforms);
607 for (
const auto &
Lib : Section.AllowableClients)
608 for (
const auto &
Target : Targets)
611 for (
const auto &
Lib : Section.ReexportedLibraries)
612 for (
const auto &
Target : Targets)
615 for (
const auto &
Symbol : Section.Symbols) {
616 if (Ctx->FileKind != FileType::TBD_V3 &&
618 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
619 Symbol.value.drop_front(15), Targets, Flags);
621 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets, Flags);
623 for (
auto &
Symbol : Section.Classes) {
625 if (Ctx->FileKind != FileType::TBD_V3)
627 File->addSymbol(EncodeKind::ObjectiveCClass,
Name, Targets, Flags);
629 for (
auto &
Symbol : Section.ClassEHs)
630 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
Symbol, Targets,
632 for (
auto &
Symbol : Section.IVars) {
634 if (Ctx->FileKind != FileType::TBD_V3)
636 File->addSymbol(EncodeKind::ObjectiveCInstanceVariable,
Name, Targets,
639 for (
auto &
Symbol : Section.WeakDefSymbols)
640 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
641 SymbolFlags::WeakDefined | Flags);
642 for (
auto &
Symbol : Section.TLVSymbols)
643 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
644 SymbolFlags::ThreadLocalValue | Flags);
647 for (
const auto &Section : Undefineds) {
649 synthesizeTargets(Section.Architectures, Platforms);
650 for (
auto &
Symbol : Section.Symbols) {
651 if (Ctx->FileKind != FileType::TBD_V3 &&
653 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
654 Symbol.value.drop_front(15), Targets,
655 SymbolFlags::Undefined | Flags);
657 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
658 SymbolFlags::Undefined | Flags);
660 for (
auto &
Symbol : Section.Classes) {
662 if (Ctx->FileKind != FileType::TBD_V3)
664 File->addSymbol(EncodeKind::ObjectiveCClass,
Name, Targets,
665 SymbolFlags::Undefined | Flags);
667 for (
auto &
Symbol : Section.ClassEHs)
668 File->addSymbol(EncodeKind::ObjectiveCClassEHType,
Symbol, Targets,
669 SymbolFlags::Undefined | Flags);
670 for (
auto &
Symbol : Section.IVars) {
672 if (Ctx->FileKind != FileType::TBD_V3)
674 File->addSymbol(EncodeKind::ObjectiveCInstanceVariable,
Name, Targets,
675 SymbolFlags::Undefined | Flags);
677 for (
auto &
Symbol : Section.WeakRefSymbols)
678 File->addSymbol(EncodeKind::GlobalSymbol,
Symbol, Targets,
679 SymbolFlags::Undefined | SymbolFlags::WeakReferenced |
702 SwiftVersion SwiftABIVersion{0};
711 if (IO.mapTag(
"!tapi-tbd",
false))
713 else if (IO.mapTag(
"!tapi-tbd-v3",
false))
715 else if (IO.mapTag(
"!tapi-tbd-v2",
false))
717 else if (IO.mapTag(
"!tapi-tbd-v1",
false) ||
718 IO.mapTag(
"tag:yaml.org,2002:map",
false))
728 assert((!Ctx || !IO.outputting() ||
729 (Ctx && Ctx->FileKind != FileType::Invalid)) &&
730 "File type is not set in YAML context");
732 if (!IO.outputting()) {
733 setFileTypeForInput(Ctx, IO);
734 switch (Ctx->FileKind) {
737 case FileType::TBD_V4:
738 mapKeysToValuesV4(IO, File);
740 case FileType::Invalid:
741 IO.setError(
"unsupported file type");
746 switch (Ctx->FileKind) {
749 case FileType::TBD_V4:
750 mapKeysToValuesV4(IO, File);
752 case FileType::TBD_V3:
753 IO.mapTag(
"!tapi-tbd-v3",
true);
755 case FileType::TBD_V2:
756 IO.mapTag(
"!tapi-tbd-v2",
true);
758 case FileType::TBD_V1:
763 mapKeysToValues(Ctx->FileKind, IO, File);
767 struct NormalizedTBD_V4 {
772 TBDVersion = Ctx->FileKind >> 4;
773 Targets.insert(Targets.begin(), File->targets().begin(),
774 File->targets().end());
775 InstallName = File->getInstallName();
776 CurrentVersion = File->getCurrentVersion();
777 CompatibilityVersion = File->getCompatibilityVersion();
778 SwiftABIVersion = File->getSwiftABIVersion();
780 Flags = TBDFlags::None;
781 if (!File->isApplicationExtensionSafe())
782 Flags |= TBDFlags::NotApplicationExtensionSafe;
784 if (!File->isTwoLevelNamespace())
785 Flags |= TBDFlags::FlatNamespace;
787 if (File->isOSLibNotForSharedCache())
788 Flags |= TBDFlags::OSLibNotForSharedCache;
791 std::map<std::string, TargetList> valueToTargetList;
792 for (
const auto &it : File->umbrellas())
793 valueToTargetList[it.second].emplace_back(it.first);
795 for (
const auto &it : valueToTargetList) {
796 UmbrellaSection CurrentSection;
797 CurrentSection.Targets.insert(CurrentSection.Targets.begin(),
798 it.second.begin(), it.second.end());
799 CurrentSection.Umbrella = it.first;
800 ParentUmbrellas.emplace_back(std::move(CurrentSection));
804 assignTargetsToLibrary(File->allowableClients(), AllowableClients);
805 assignTargetsToLibrary(File->reexportedLibraries(), ReexportedLibraries);
810 std::set<TargetList> TargetSet;
811 std::map<const Symbol *, TargetList> SymbolToTargetList;
812 for (
const auto *
Symbol : Symbols) {
814 SymbolToTargetList[
Symbol] = Targets;
815 TargetSet.emplace(std::move(Targets));
817 for (
const auto &TargetIDs : TargetSet) {
818 SymbolSection CurrentSection;
819 CurrentSection.Targets.
insert(CurrentSection.Targets.begin(),
820 TargetIDs.begin(), TargetIDs.end());
822 for (
const auto &
IT : SymbolToTargetList) {
823 if (
IT.second != TargetIDs)
828 case EncodeKind::GlobalSymbol:
836 case EncodeKind::ObjectiveCClass:
839 case EncodeKind::ObjectiveCClassEHType:
842 case EncodeKind::ObjectiveCInstanceVariable:
847 sort(CurrentSection.Symbols);
848 sort(CurrentSection.Classes);
849 sort(CurrentSection.ClassEHs);
850 sort(CurrentSection.Ivars);
851 sort(CurrentSection.WeakSymbols);
852 sort(CurrentSection.TlvSymbols);
853 CurrentSections.emplace_back(std::move(CurrentSection));
857 handleSymbols(Exports, File->exports());
858 handleSymbols(Reexports, File->reexports());
859 handleSymbols(Undefineds, File->undefineds());
867 File->setPath(Ctx->Path);
868 File->setFileType(Ctx->FileKind);
869 File->addTargets(Targets);
870 File->setInstallName(InstallName);
871 File->setCurrentVersion(CurrentVersion);
872 File->setCompatibilityVersion(CompatibilityVersion);
873 File->setSwiftABIVersion(SwiftABIVersion);
874 for (
const auto &CurrentSection : ParentUmbrellas)
875 for (
const auto &target : CurrentSection.Targets)
876 File->addParentUmbrella(target, CurrentSection.Umbrella);
877 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
878 File->setApplicationExtensionSafe(
879 !(Flags & TBDFlags::NotApplicationExtensionSafe));
880 File->setOSLibNotForSharedCache(
881 (Flags & TBDFlags::OSLibNotForSharedCache));
883 for (
const auto &CurrentSection : AllowableClients) {
884 for (
const auto &lib : CurrentSection.Values)
885 for (
const auto &
Target : CurrentSection.Targets)
886 File->addAllowableClient(lib,
Target);
889 for (
const auto &CurrentSection : ReexportedLibraries) {
890 for (
const auto &
Lib : CurrentSection.Values)
891 for (
const auto &
Target : CurrentSection.Targets)
895 auto handleSymbols = [File](
const SectionList &CurrentSections,
900 const SymbolFlags Flag = InputFlag | SymbolFlags::Data;
902 for (
const auto &CurrentSection : CurrentSections) {
903 for (
auto &sym : CurrentSection.Symbols)
904 File->addSymbol(EncodeKind::GlobalSymbol, sym,
905 CurrentSection.Targets, Flag);
907 for (
auto &sym : CurrentSection.Classes)
908 File->addSymbol(EncodeKind::ObjectiveCClass, sym,
909 CurrentSection.Targets, Flag);
911 for (
auto &sym : CurrentSection.ClassEHs)
912 File->addSymbol(EncodeKind::ObjectiveCClassEHType, sym,
913 CurrentSection.Targets, Flag);
915 for (
auto &sym : CurrentSection.Ivars)
916 File->addSymbol(EncodeKind::ObjectiveCInstanceVariable, sym,
917 CurrentSection.Targets, Flag);
920 ((Flag & SymbolFlags::Undefined) == SymbolFlags::Undefined)
921 ? SymbolFlags::WeakReferenced
922 : SymbolFlags::WeakDefined;
923 for (
auto &sym : CurrentSection.WeakSymbols) {
924 File->addSymbol(EncodeKind::GlobalSymbol, sym,
925 CurrentSection.Targets, Flag | SymFlag);
928 for (
auto &sym : CurrentSection.TlvSymbols)
929 File->addSymbol(EncodeKind::GlobalSymbol, sym,
930 CurrentSection.Targets,
931 Flag | SymbolFlags::ThreadLocalValue);
935 handleSymbols(Exports);
936 handleSymbols(Reexports, SymbolFlags::Rexported);
937 handleSymbols(Undefineds, SymbolFlags::Undefined);
948 SwiftVersion SwiftABIVersion{0};
958 void assignTargetsToLibrary(
const std::vector<InterfaceFileRef> &Libraries,
959 std::vector<MetadataSection> &Section) {
960 std::set<TargetList> targetSet;
961 std::map<const InterfaceFileRef *, TargetList> valueToTargetList;
962 for (
const auto &
library : Libraries) {
964 valueToTargetList[&
library] = targets;
965 targetSet.emplace(std::move(targets));
968 for (
const auto &targets : targetSet) {
969 MetadataSection CurrentSection;
970 CurrentSection.Targets.
insert(CurrentSection.Targets.begin(),
971 targets.begin(), targets.end());
973 for (
const auto &it : valueToTargetList) {
974 if (it.second != targets)
977 CurrentSection.Values.emplace_back(it.first->getInstallName());
980 Section.emplace_back(std::move(CurrentSection));
987 MappingNormalization<NormalizedTBD, const InterfaceFile *> Keys(IO, File);
988 std::vector<UUID> EmptyUUID;
989 IO.mapRequired(
"archs", Keys->Architectures);
990 if (FileKind != FileType::TBD_V1)
991 IO.mapOptional(
"uuids", EmptyUUID);
992 IO.mapRequired(
"platform", Keys->Platforms);
993 if (FileKind != FileType::TBD_V1)
994 IO.mapOptional(
"flags", Keys->Flags, TBDFlags::None);
995 IO.mapRequired(
"install-name", Keys->InstallName);
996 IO.mapOptional(
"current-version", Keys->CurrentVersion,
998 IO.mapOptional(
"compatibility-version", Keys->CompatibilityVersion,
1000 if (FileKind != FileType::TBD_V3)
1001 IO.mapOptional(
"swift-version", Keys->SwiftABIVersion, SwiftVersion(0));
1003 IO.mapOptional(
"swift-abi-version", Keys->SwiftABIVersion,
1005 IO.mapOptional(
"objc-constraint", Keys->ObjCConstraint,
1006 (FileKind == FileType::TBD_V1)
1007 ? ObjCConstraintType::None
1008 : ObjCConstraintType::Retain_Release);
1009 if (FileKind != FileType::TBD_V1)
1010 IO.mapOptional(
"parent-umbrella", Keys->ParentUmbrella,
StringRef());
1011 IO.mapOptional(
"exports", Keys->Exports);
1012 if (FileKind != FileType::TBD_V1)
1013 IO.mapOptional(
"undefineds", Keys->Undefineds);
1017 MappingNormalization<NormalizedTBD_V4, const InterfaceFile *> Keys(IO,
1019 std::vector<UUIDv4> EmptyUUID;
1020 IO.mapTag(
"!tapi-tbd",
true);
1021 IO.mapRequired(
"tbd-version", Keys->TBDVersion);
1022 IO.mapRequired(
"targets", Keys->Targets);
1023 IO.mapOptional(
"uuids", EmptyUUID);
1024 IO.mapOptional(
"flags", Keys->Flags, TBDFlags::None);
1025 IO.mapRequired(
"install-name", Keys->InstallName);
1026 IO.mapOptional(
"current-version", Keys->CurrentVersion,
1028 IO.mapOptional(
"compatibility-version", Keys->CompatibilityVersion,
1030 IO.mapOptional(
"swift-abi-version", Keys->SwiftABIVersion, SwiftVersion(0));
1031 IO.mapOptional(
"parent-umbrella", Keys->ParentUmbrellas);
1032 auto OptionKind = MetadataSection::Option::Clients;
1033 IO.mapOptionalWithContext(
"allowable-clients", Keys->AllowableClients,
1035 OptionKind = MetadataSection::Option::Libraries;
1036 IO.mapOptionalWithContext(
"reexported-libraries", Keys->ReexportedLibraries,
1038 IO.mapOptional(
"exports", Keys->Exports);
1039 IO.mapOptional(
"reexports", Keys->Reexports);
1040 IO.mapOptional(
"undefineds", Keys->Undefineds);
1045struct DocumentListTraits<
std::
vector<const MachO::InterfaceFile *>> {
1046 static size_t size(IO &IO, std::vector<const MachO::InterfaceFile *> &Seq) {
1051 if (
Index >= Seq.size())
1052 Seq.resize(
Index + 1);
1070 NewDiag.
print(
nullptr, S);
1071 File->ErrorMessage = (
"malformed file\n" + Message).str();
1076 if (TAPIFile.starts_with(
"{") && TAPIFile.ends_with(
"}"))
1079 if (!TAPIFile.ends_with(
"..."))
1082 if (TAPIFile.starts_with(
"--- !tapi-tbd"))
1085 if (TAPIFile.starts_with(
"--- !tapi-tbd-v3"))
1088 if (TAPIFile.starts_with(
"--- !tapi-tbd-v2"))
1091 if (TAPIFile.starts_with(
"--- !tapi-tbd-v1") ||
1092 TAPIFile.starts_with(
"---\narchs:"))
1102 if (
auto FTOrErr =
canRead(InputBuffer))
1105 return FTOrErr.takeError();
1111 return FileOrErr.takeError();
1113 (*FileOrErr)->setPath(Ctx.
Path);
1114 return std::move(*FileOrErr);
1119 std::vector<const InterfaceFile *> Files;
1124 auto File = std::unique_ptr<InterfaceFile>(
1129 std::shared_ptr<InterfaceFile>(
const_cast<InterfaceFile *
>(FI)));
1132 return make_error<StringError>(Ctx.
ErrorMessage, YAMLIn.error());
1134 return std::move(File);
1138 const FileType FileKind,
bool Compact) {
1140 Ctx.
Path = std::string(File.getPath());
1152 llvm::yaml::Output YAMLOut(
OS, &Ctx, 80);
1154 std::vector<const InterfaceFile *> Files;
1155 Files.emplace_back(&File);
1157 for (
const auto &
Document : File.documents())
1158 Files.emplace_back(
Document.get());
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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::Expected< Target > create(StringRef Target)
static Expected< FileType > canRead(MemoryBufferRef InputBuffer)
Determine whether input can be interpreted as TAPI text file.
static Expected< std::unique_ptr< InterfaceFile > > get(MemoryBufferRef InputBuffer)
Parse and get an InterfaceFile that represents the full library.
static 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...
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.
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)