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 && 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 && 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);
369 switch (
Value.Platform) {
392 OS <<
"ios-simulator";
395 OS <<
"tvos-simulator";
398 OS <<
"watchos-simulator";
410 return "unparsable target";
415 return "unknown architecture";
417 return "unknown platform";
426 struct NormalizedTBD {
429 Architectures = File->getArchitectures();
430 Platforms = File->getPlatforms();
431 InstallName = File->getInstallName();
433 CompatibilityVersion =
PackedVersion(File->getCompatibilityVersion());
434 SwiftABIVersion = File->getSwiftABIVersion();
435 ObjCConstraint = File->getObjCConstraint();
437 Flags = TBDFlags::None;
438 if (!File->isApplicationExtensionSafe())
439 Flags |= TBDFlags::NotApplicationExtensionSafe;
441 if (!File->isTwoLevelNamespace())
442 Flags |= TBDFlags::FlatNamespace;
444 if (!File->umbrellas().empty())
445 ParentUmbrella = File->umbrellas().begin()->second;
447 std::set<ArchitectureSet> ArchSet;
448 for (
const auto &Library : File->allowableClients())
449 ArchSet.insert(Library.getArchitectures());
451 for (
const auto &Library : File->reexportedLibraries())
452 ArchSet.insert(Library.getArchitectures());
454 std::map<const Symbol *, ArchitectureSet> SymbolToArchSet;
455 for (
const auto *
Symbol : File->symbols()) {
457 SymbolToArchSet[
Symbol] = Architectures;
458 ArchSet.insert(Architectures);
461 for (
auto Architectures : ArchSet) {
462 ExportSection Section;
463 Section.Architectures = Architectures;
465 for (
const auto &Library : File->allowableClients())
466 if (Library.getArchitectures() == Architectures)
467 Section.AllowableClients.emplace_back(Library.getInstallName());
469 for (
const auto &Library : File->reexportedLibraries())
470 if (Library.getArchitectures() == Architectures)
471 Section.ReexportedLibraries.emplace_back(Library.getInstallName());
473 for (
const auto &SymArch : SymbolToArchSet) {
474 if (SymArch.second != Architectures)
477 const auto *
Symbol = SymArch.first;
479 case SymbolKind::GlobalSymbol:
487 case SymbolKind::ObjectiveCClass:
488 if (File->getFileType() != FileType::TBD_V3)
489 Section.Classes.emplace_back(
494 case SymbolKind::ObjectiveCClassEHType:
495 if (File->getFileType() != FileType::TBD_V3)
496 Section.Symbols.emplace_back(
501 case SymbolKind::ObjectiveCInstanceVariable:
502 if (File->getFileType() != FileType::TBD_V3)
503 Section.IVars.emplace_back(
516 Exports.emplace_back(std::move(Section));
520 SymbolToArchSet.clear();
522 for (
const auto *
Symbol : File->undefineds()) {
524 SymbolToArchSet[
Symbol] = Architectures;
525 ArchSet.insert(Architectures);
528 for (
auto Architectures : ArchSet) {
529 UndefinedSection Section;
530 Section.Architectures = Architectures;
532 for (
const auto &SymArch : SymbolToArchSet) {
533 if (SymArch.second != Architectures)
536 const auto *
Symbol = SymArch.first;
538 case SymbolKind::GlobalSymbol:
544 case SymbolKind::ObjectiveCClass:
545 if (File->getFileType() != FileType::TBD_V3)
546 Section.Classes.emplace_back(
551 case SymbolKind::ObjectiveCClassEHType:
552 if (File->getFileType() != FileType::TBD_V3)
553 Section.Symbols.emplace_back(
558 case SymbolKind::ObjectiveCInstanceVariable:
559 if (File->getFileType() != FileType::TBD_V3)
560 Section.IVars.emplace_back(
572 Undefineds.emplace_back(std::move(Section));
585 for (
auto Platform : Platforms) {
603 File->setPath(Ctx->Path);
604 File->setFileType(Ctx->FileKind);
605 File->addTargets(synthesizeTargets(Architectures, Platforms));
606 File->setInstallName(InstallName);
607 File->setCurrentVersion(CurrentVersion);
608 File->setCompatibilityVersion(CompatibilityVersion);
609 File->setSwiftABIVersion(SwiftABIVersion);
610 File->setObjCConstraint(ObjCConstraint);
611 for (
const auto &
Target : File->targets())
612 File->addParentUmbrella(
Target, ParentUmbrella);
614 if (Ctx->FileKind == FileType::TBD_V1) {
615 File->setTwoLevelNamespace();
616 File->setApplicationExtensionSafe();
618 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
619 File->setApplicationExtensionSafe(
620 !(Flags & TBDFlags::NotApplicationExtensionSafe));
626 const auto Flags = SymbolFlags::Data;
628 for (
const auto &Section : Exports) {
630 synthesizeTargets(Section.Architectures, Platforms);
632 for (
const auto &
Lib : Section.AllowableClients)
633 for (
const auto &
Target : Targets)
636 for (
const auto &
Lib : Section.ReexportedLibraries)
637 for (
const auto &
Target : Targets)
640 for (
const auto &
Symbol : Section.Symbols) {
641 if (Ctx->FileKind != FileType::TBD_V3 &&
643 File->addSymbol(SymbolKind::ObjectiveCClassEHType,
644 Symbol.value.drop_front(15), Targets, Flags);
646 File->addSymbol(SymbolKind::GlobalSymbol,
Symbol, Targets, Flags);
648 for (
auto &
Symbol : Section.Classes) {
650 if (Ctx->FileKind != FileType::TBD_V3)
652 File->addSymbol(SymbolKind::ObjectiveCClass,
Name, Targets, Flags);
654 for (
auto &
Symbol : Section.ClassEHs)
655 File->addSymbol(SymbolKind::ObjectiveCClassEHType,
Symbol, Targets,
657 for (
auto &
Symbol : Section.IVars) {
659 if (Ctx->FileKind != FileType::TBD_V3)
661 File->addSymbol(SymbolKind::ObjectiveCInstanceVariable,
Name, Targets,
664 for (
auto &
Symbol : Section.WeakDefSymbols)
665 File->addSymbol(SymbolKind::GlobalSymbol,
Symbol, Targets,
666 SymbolFlags::WeakDefined | Flags);
667 for (
auto &
Symbol : Section.TLVSymbols)
668 File->addSymbol(SymbolKind::GlobalSymbol,
Symbol, Targets,
669 SymbolFlags::ThreadLocalValue | Flags);
672 for (
const auto &Section : Undefineds) {
674 synthesizeTargets(Section.Architectures, Platforms);
675 for (
auto &
Symbol : Section.Symbols) {
676 if (Ctx->FileKind != FileType::TBD_V3 &&
678 File->addSymbol(SymbolKind::ObjectiveCClassEHType,
679 Symbol.value.drop_front(15), Targets,
680 SymbolFlags::Undefined | Flags);
682 File->addSymbol(SymbolKind::GlobalSymbol,
Symbol, Targets,
683 SymbolFlags::Undefined | Flags);
685 for (
auto &
Symbol : Section.Classes) {
687 if (Ctx->FileKind != FileType::TBD_V3)
689 File->addSymbol(SymbolKind::ObjectiveCClass,
Name, Targets,
690 SymbolFlags::Undefined | Flags);
692 for (
auto &
Symbol : Section.ClassEHs)
693 File->addSymbol(SymbolKind::ObjectiveCClassEHType,
Symbol, Targets,
694 SymbolFlags::Undefined | Flags);
695 for (
auto &
Symbol : Section.IVars) {
697 if (Ctx->FileKind != FileType::TBD_V3)
699 File->addSymbol(SymbolKind::ObjectiveCInstanceVariable,
Name, Targets,
700 SymbolFlags::Undefined | Flags);
702 for (
auto &
Symbol : Section.WeakRefSymbols)
703 File->addSymbol(SymbolKind::GlobalSymbol,
Symbol, Targets,
704 SymbolFlags::Undefined | SymbolFlags::WeakReferenced |
727 SwiftVersion SwiftABIVersion{0};
736 if (IO.mapTag(
"!tapi-tbd",
false))
738 else if (IO.mapTag(
"!tapi-tbd-v3",
false))
740 else if (IO.mapTag(
"!tapi-tbd-v2",
false))
742 else if (IO.mapTag(
"!tapi-tbd-v1",
false) ||
743 IO.mapTag(
"tag:yaml.org,2002:map",
false))
753 assert((!Ctx || !IO.outputting() ||
754 (Ctx && Ctx->FileKind != FileType::Invalid)) &&
755 "File type is not set in YAML context");
757 if (!IO.outputting()) {
758 setFileTypeForInput(Ctx, IO);
759 switch (Ctx->FileKind) {
762 case FileType::TBD_V4:
763 mapKeysToValuesV4(IO, File);
765 case FileType::Invalid:
766 IO.setError(
"unsupported file type");
771 switch (Ctx->FileKind) {
774 case FileType::TBD_V4:
775 mapKeysToValuesV4(IO, File);
777 case FileType::TBD_V3:
778 IO.mapTag(
"!tapi-tbd-v3",
true);
780 case FileType::TBD_V2:
781 IO.mapTag(
"!tapi-tbd-v2",
true);
783 case FileType::TBD_V1:
788 mapKeysToValues(Ctx->FileKind, IO, File);
792 struct NormalizedTBD_V4 {
797 TBDVersion = Ctx->FileKind >> 4;
798 Targets.insert(Targets.begin(), File->targets().begin(),
799 File->targets().end());
800 InstallName = File->getInstallName();
801 CurrentVersion = File->getCurrentVersion();
802 CompatibilityVersion = File->getCompatibilityVersion();
803 SwiftABIVersion = File->getSwiftABIVersion();
805 Flags = TBDFlags::None;
806 if (!File->isApplicationExtensionSafe())
807 Flags |= TBDFlags::NotApplicationExtensionSafe;
809 if (!File->isTwoLevelNamespace())
810 Flags |= TBDFlags::FlatNamespace;
813 std::map<std::string, TargetList> valueToTargetList;
814 for (
const auto &it : File->umbrellas())
815 valueToTargetList[it.second].emplace_back(it.first);
817 for (
const auto &it : valueToTargetList) {
818 UmbrellaSection CurrentSection;
819 CurrentSection.Targets.insert(CurrentSection.Targets.begin(),
820 it.second.begin(), it.second.end());
821 CurrentSection.Umbrella = it.first;
822 ParentUmbrellas.emplace_back(std::move(CurrentSection));
826 assignTargetsToLibrary(File->allowableClients(), AllowableClients);
827 assignTargetsToLibrary(File->reexportedLibraries(), ReexportedLibraries);
832 std::set<TargetList> TargetSet;
833 std::map<const Symbol *, TargetList> SymbolToTargetList;
834 for (
const auto *
Symbol : Symbols) {
836 SymbolToTargetList[
Symbol] = Targets;
837 TargetSet.emplace(std::move(Targets));
839 for (
const auto &TargetIDs : TargetSet) {
840 SymbolSection CurrentSection;
841 CurrentSection.Targets.
insert(CurrentSection.Targets.begin(),
842 TargetIDs.begin(), TargetIDs.end());
844 for (
const auto &
IT : SymbolToTargetList) {
845 if (
IT.second != TargetIDs)
850 case SymbolKind::GlobalSymbol:
858 case SymbolKind::ObjectiveCClass:
861 case SymbolKind::ObjectiveCClassEHType:
864 case SymbolKind::ObjectiveCInstanceVariable:
869 sort(CurrentSection.Symbols);
870 sort(CurrentSection.Classes);
871 sort(CurrentSection.ClassEHs);
872 sort(CurrentSection.Ivars);
873 sort(CurrentSection.WeakSymbols);
874 sort(CurrentSection.TlvSymbols);
875 CurrentSections.emplace_back(std::move(CurrentSection));
879 handleSymbols(Exports, File->exports());
880 handleSymbols(Reexports, File->reexports());
881 handleSymbols(Undefineds, File->undefineds());
889 File->setPath(Ctx->Path);
890 File->setFileType(Ctx->FileKind);
891 File->addTargets(Targets);
892 File->setInstallName(InstallName);
893 File->setCurrentVersion(CurrentVersion);
894 File->setCompatibilityVersion(CompatibilityVersion);
895 File->setSwiftABIVersion(SwiftABIVersion);
896 for (
const auto &CurrentSection : ParentUmbrellas)
897 for (
const auto &target : CurrentSection.Targets)
898 File->addParentUmbrella(target, CurrentSection.Umbrella);
899 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
900 File->setApplicationExtensionSafe(
901 !(Flags & TBDFlags::NotApplicationExtensionSafe));
903 for (
const auto &CurrentSection : AllowableClients) {
904 for (
const auto &lib : CurrentSection.Values)
905 for (
const auto &
Target : CurrentSection.Targets)
906 File->addAllowableClient(lib,
Target);
909 for (
const auto &CurrentSection : ReexportedLibraries) {
910 for (
const auto &
Lib : CurrentSection.Values)
911 for (
const auto &
Target : CurrentSection.Targets)
915 auto handleSymbols = [File](
const SectionList &CurrentSections,
920 const SymbolFlags Flag = InputFlag | SymbolFlags::Data;
922 for (
const auto &CurrentSection : CurrentSections) {
923 for (
auto &sym : CurrentSection.Symbols)
924 File->addSymbol(SymbolKind::GlobalSymbol, sym,
925 CurrentSection.Targets, Flag);
927 for (
auto &sym : CurrentSection.Classes)
928 File->addSymbol(SymbolKind::ObjectiveCClass, sym,
929 CurrentSection.Targets, Flag);
931 for (
auto &sym : CurrentSection.ClassEHs)
932 File->addSymbol(SymbolKind::ObjectiveCClassEHType, sym,
933 CurrentSection.Targets, Flag);
935 for (
auto &sym : CurrentSection.Ivars)
936 File->addSymbol(SymbolKind::ObjectiveCInstanceVariable, sym,
937 CurrentSection.Targets, Flag);
940 ((Flag & SymbolFlags::Undefined) == SymbolFlags::Undefined)
941 ? SymbolFlags::WeakReferenced
942 : SymbolFlags::WeakDefined;
943 for (
auto &sym : CurrentSection.WeakSymbols) {
944 File->addSymbol(SymbolKind::GlobalSymbol, sym,
945 CurrentSection.Targets, Flag | SymFlag);
948 for (
auto &sym : CurrentSection.TlvSymbols)
949 File->addSymbol(SymbolKind::GlobalSymbol, sym,
950 CurrentSection.Targets,
951 Flag | SymbolFlags::ThreadLocalValue);
955 handleSymbols(Exports);
956 handleSymbols(Reexports, SymbolFlags::Rexported);
957 handleSymbols(Undefineds, SymbolFlags::Undefined);
968 SwiftVersion SwiftABIVersion{0};
978 void assignTargetsToLibrary(
const std::vector<InterfaceFileRef> &Libraries,
979 std::vector<MetadataSection> &Section) {
980 std::set<TargetList> targetSet;
981 std::map<const InterfaceFileRef *, TargetList> valueToTargetList;
982 for (
const auto &
library : Libraries) {
984 valueToTargetList[&
library] = targets;
985 targetSet.emplace(std::move(targets));
988 for (
const auto &targets : targetSet) {
989 MetadataSection CurrentSection;
990 CurrentSection.Targets.
insert(CurrentSection.Targets.begin(),
991 targets.begin(), targets.end());
993 for (
const auto &it : valueToTargetList) {
994 if (it.second != targets)
997 CurrentSection.Values.emplace_back(it.first->getInstallName());
1000 Section.emplace_back(std::move(CurrentSection));
1007 MappingNormalization<NormalizedTBD, const InterfaceFile *> Keys(IO, File);
1008 std::vector<UUID> EmptyUUID;
1009 IO.mapRequired(
"archs", Keys->Architectures);
1010 if (FileKind != FileType::TBD_V1)
1011 IO.mapOptional(
"uuids", EmptyUUID);
1012 IO.mapRequired(
"platform", Keys->Platforms);
1013 if (FileKind != FileType::TBD_V1)
1014 IO.mapOptional(
"flags", Keys->Flags, TBDFlags::None);
1015 IO.mapRequired(
"install-name", Keys->InstallName);
1016 IO.mapOptional(
"current-version", Keys->CurrentVersion,
1018 IO.mapOptional(
"compatibility-version", Keys->CompatibilityVersion,
1020 if (FileKind != FileType::TBD_V3)
1021 IO.mapOptional(
"swift-version", Keys->SwiftABIVersion, SwiftVersion(0));
1023 IO.mapOptional(
"swift-abi-version", Keys->SwiftABIVersion,
1025 IO.mapOptional(
"objc-constraint", Keys->ObjCConstraint,
1026 (FileKind == FileType::TBD_V1)
1027 ? ObjCConstraintType::None
1028 : ObjCConstraintType::Retain_Release);
1029 if (FileKind != FileType::TBD_V1)
1030 IO.mapOptional(
"parent-umbrella", Keys->ParentUmbrella,
StringRef());
1031 IO.mapOptional(
"exports", Keys->Exports);
1032 if (FileKind != FileType::TBD_V1)
1033 IO.mapOptional(
"undefineds", Keys->Undefineds);
1037 MappingNormalization<NormalizedTBD_V4, const InterfaceFile *> Keys(IO,
1039 std::vector<UUIDv4> EmptyUUID;
1040 IO.mapTag(
"!tapi-tbd",
true);
1041 IO.mapRequired(
"tbd-version", Keys->TBDVersion);
1042 IO.mapRequired(
"targets", Keys->Targets);
1043 IO.mapOptional(
"uuids", EmptyUUID);
1044 IO.mapOptional(
"flags", Keys->Flags, TBDFlags::None);
1045 IO.mapRequired(
"install-name", Keys->InstallName);
1046 IO.mapOptional(
"current-version", Keys->CurrentVersion,
1048 IO.mapOptional(
"compatibility-version", Keys->CompatibilityVersion,
1050 IO.mapOptional(
"swift-abi-version", Keys->SwiftABIVersion, SwiftVersion(0));
1051 IO.mapOptional(
"parent-umbrella", Keys->ParentUmbrellas);
1052 auto OptionKind = MetadataSection::Option::Clients;
1053 IO.mapOptionalWithContext(
"allowable-clients", Keys->AllowableClients,
1055 OptionKind = MetadataSection::Option::Libraries;
1056 IO.mapOptionalWithContext(
"reexported-libraries", Keys->ReexportedLibraries,
1058 IO.mapOptional(
"exports", Keys->Exports);
1059 IO.mapOptional(
"reexports", Keys->Reexports);
1060 IO.mapOptional(
"undefineds", Keys->Undefineds);
1065struct DocumentListTraits<
std::vector<const MachO::InterfaceFile *>> {
1066 static size_t size(IO &IO, std::vector<const MachO::InterfaceFile *> &Seq) {
1071 if (
Index >= Seq.size())
1072 Seq.resize(
Index + 1);
1090 NewDiag.
print(
nullptr, S);
1091 File->ErrorMessage = (
"malformed file\n" + Message).str();
1096 if (TAPIFile.startswith(
"{") && TAPIFile.endswith(
"}"))
1099 if (!TAPIFile.endswith(
"..."))
1102 if (TAPIFile.startswith(
"--- !tapi-tbd\n"))
1105 if (TAPIFile.startswith(
"--- !tapi-tbd-v3\n"))
1108 if (TAPIFile.startswith(
"--- !tapi-tbd-v2\n"))
1111 if (TAPIFile.startswith(
"--- !tapi-tbd-v1\n") ||
1112 TAPIFile.startswith(
"---\narchs:"))
1122 if (
auto FTOrErr =
canRead(InputBuffer))
1125 return FTOrErr.takeError();
1131 return FileOrErr.takeError();
1133 (*FileOrErr)->setPath(Ctx.
Path);
1134 return std::move(*FileOrErr);
1139 std::vector<const InterfaceFile *> Files;
1144 auto File = std::unique_ptr<InterfaceFile>(
1149 std::shared_ptr<InterfaceFile>(
const_cast<InterfaceFile *
>(FI)));
1152 return make_error<StringError>(Ctx.
ErrorMessage, YAMLIn.error());
1154 return std::move(File);
1158 const FileType FileKind,
bool Compact) {
1160 Ctx.
Path = std::string(File.getPath());
1172 llvm::yaml::Output YAMLOut(
OS, &Ctx, 80);
1174 std::vector<const InterfaceFile *> Files;
1175 Files.emplace_back(&File);
1177 for (
auto Document : File.documents())
1178 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
SymbolKind getKind() const
ArchitectureSet getArchitectures() const
StringRef getName() 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...
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
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) 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 this file represents.
@ 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.
@ PLATFORM_WATCHOSSIMULATOR
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)