LLVM 17.0.0git
TextStub.cpp
Go to the documentation of this file.
1//===- TextStub.cpp -------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implements the text stub file reader/writer.
10//
11//===----------------------------------------------------------------------===//
12
13#include "TextAPIContext.h"
14#include "TextStubCommon.h"
17#include "llvm/ADT/StringRef.h"
28#include <algorithm>
29#include <set>
30
31// clang-format off
32/*
33
34 YAML Format specification.
35
36 The TBD v1 format only support two level address libraries and is per
37 definition application extension safe.
38
39--- # the tag !tapi-tbd-v1 is optional and
40 # shouldn't be emitted to support older linker.
41archs: [ armv7, armv7s, arm64 ] # the list of architecture slices that are
42 # supported by this file.
43platform: ios # Specifies the platform (macosx, ios, etc)
44install-name: /u/l/libfoo.dylib #
45current-version: 1.2.3 # Optional: defaults to 1.0
46compatibility-version: 1.0 # Optional: defaults to 1.0
47swift-version: 0 # Optional: defaults to 0
48objc-constraint: none # Optional: defaults to none
49exports: # List of export sections
50...
51
52Each export section is defined as following:
53
54 - archs: [ arm64 ] # the list of architecture slices
55 allowed-clients: [ client ] # Optional: List of clients
56 re-exports: [ ] # Optional: List of re-exports
57 symbols: [ _sym ] # Optional: List of symbols
58 objc-classes: [] # Optional: List of Objective-C classes
59 objc-ivars: [] # Optional: List of Objective C Instance
60 # Variables
61 weak-def-symbols: [] # Optional: List of weak defined symbols
62 thread-local-symbols: [] # Optional: List of thread local symbols
63*/
64
65/*
66
67 YAML Format specification.
68
69--- !tapi-tbd-v2
70archs: [ armv7, armv7s, arm64 ] # the list of architecture slices that are
71 # supported by this file.
72uuids: [ armv7:... ] # Optional: List of architecture and UUID pairs.
73platform: ios # Specifies the platform (macosx, ios, etc)
74flags: [] # Optional:
75install-name: /u/l/libfoo.dylib #
76current-version: 1.2.3 # Optional: defaults to 1.0
77compatibility-version: 1.0 # Optional: defaults to 1.0
78swift-version: 0 # Optional: defaults to 0
79objc-constraint: retain_release # Optional: defaults to retain_release
80parent-umbrella: # Optional:
81exports: # List of export sections
82...
83undefineds: # List of undefineds sections
84...
85
86Each export section is defined as following:
87
88- archs: [ arm64 ] # the list of architecture slices
89 allowed-clients: [ client ] # Optional: List of clients
90 re-exports: [ ] # Optional: List of re-exports
91 symbols: [ _sym ] # Optional: List of symbols
92 objc-classes: [] # Optional: List of Objective-C classes
93 objc-ivars: [] # Optional: List of Objective C Instance
94 # Variables
95 weak-def-symbols: [] # Optional: List of weak defined symbols
96 thread-local-symbols: [] # Optional: List of thread local symbols
97
98Each undefineds section is defined as following:
99- archs: [ arm64 ] # the list of architecture slices
100 symbols: [ _sym ] # Optional: List of symbols
101 objc-classes: [] # Optional: List of Objective-C classes
102 objc-ivars: [] # Optional: List of Objective C Instance Variables
103 weak-ref-symbols: [] # Optional: List of weak defined symbols
104*/
105
106/*
107
108 YAML Format specification.
109
110--- !tapi-tbd-v3
111archs: [ armv7, armv7s, arm64 ] # the list of architecture slices that are
112 # supported by this file.
113uuids: [ armv7:... ] # Optional: List of architecture and UUID pairs.
114platform: ios # Specifies the platform (macosx, ios, etc)
115flags: [] # Optional:
116install-name: /u/l/libfoo.dylib #
117current-version: 1.2.3 # Optional: defaults to 1.0
118compatibility-version: 1.0 # Optional: defaults to 1.0
119swift-abi-version: 0 # Optional: defaults to 0
120objc-constraint: retain_release # Optional: defaults to retain_release
121parent-umbrella: # Optional:
122exports: # List of export sections
123...
124undefineds: # List of undefineds sections
125...
126
127Each export section is defined as following:
128
129- archs: [ arm64 ] # the list of architecture slices
130 allowed-clients: [ client ] # Optional: List of clients
131 re-exports: [ ] # Optional: List of re-exports
132 symbols: [ _sym ] # Optional: List of symbols
133 objc-classes: [] # Optional: List of Objective-C classes
134 objc-eh-types: [] # Optional: List of Objective-C classes
135 # with EH
136 objc-ivars: [] # Optional: List of Objective C Instance
137 # Variables
138 weak-def-symbols: [] # Optional: List of weak defined symbols
139 thread-local-symbols: [] # Optional: List of thread local symbols
140
141Each undefineds section is defined as following:
142- archs: [ arm64 ] # the list of architecture slices
143 symbols: [ _sym ] # Optional: List of symbols
144 objc-classes: [] # Optional: List of Objective-C classes
145 objc-eh-types: [] # Optional: List of Objective-C classes
146 # with EH
147 objc-ivars: [] # Optional: List of Objective C Instance Variables
148 weak-ref-symbols: [] # Optional: List of weak defined symbols
149*/
150
151/*
152
153 YAML Format specification.
154
155--- !tapi-tbd
156tbd-version: 4 # The tbd version for format
157targets: [ armv7-ios, x86_64-maccatalyst ] # The list of applicable tapi supported target triples
158uuids: # Optional: List of target and UUID pairs.
159 - target: armv7-ios
160 value: ...
161 - target: x86_64-maccatalyst
162 value: ...
163flags: [] # Optional:
164install-name: /u/l/libfoo.dylib #
165current-version: 1.2.3 # Optional: defaults to 1.0
166compatibility-version: 1.0 # Optional: defaults to 1.0
167swift-abi-version: 0 # Optional: defaults to 0
168parent-umbrella: # Optional:
169allowable-clients:
170 - targets: [ armv7-ios ] # Optional:
171 clients: [ clientA ]
172exports: # List of export sections
173...
174re-exports: # List of reexport sections
175...
176undefineds: # List of undefineds sections
177...
178
179Each export and reexport section is defined as following:
180
181- targets: [ arm64-macos ] # The list of target triples associated with symbols
182 symbols: [ _symA ] # Optional: List of symbols
183 objc-classes: [] # Optional: List of Objective-C classes
184 objc-eh-types: [] # Optional: List of Objective-C classes
185 # with EH
186 objc-ivars: [] # Optional: List of Objective C Instance
187 # Variables
188 weak-symbols: [] # Optional: List of weak defined symbols
189 thread-local-symbols: [] # Optional: List of thread local symbols
190- targets: [ arm64-macos, x86_64-maccatalyst ] # Optional: Targets for applicable additional symbols
191 symbols: [ _symB ] # Optional: List of symbols
192
193Each undefineds section is defined as following:
194- targets: [ arm64-macos ] # The list of target triples associated with symbols
195 symbols: [ _symC ] # Optional: List of symbols
196 objc-classes: [] # Optional: List of Objective-C classes
197 objc-eh-types: [] # Optional: List of Objective-C classes
198 # with EH
199 objc-ivars: [] # Optional: List of Objective C Instance Variables
200 weak-symbols: [] # Optional: List of weak defined symbols
201*/
202// clang-format on
203
204using namespace llvm;
205using namespace llvm::yaml;
206using namespace llvm::MachO;
207
208namespace {
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;
219};
220
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;
228};
229
230// Sections for direct target mapping in TBDv4
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;
239};
240
241struct MetadataSection {
242 enum Option { Clients, Libraries };
243 std::vector<Target> Targets;
244 std::vector<FlowStringRef> Values;
245};
246
247struct UmbrellaSection {
248 std::vector<Target> Targets;
249 std::string Umbrella;
250};
251
252// UUID's for TBDv4 are mapped to target not arch
253struct UUIDv4 {
254 Target TargetID;
255 std::string Value;
256
257 UUIDv4() = default;
258 UUIDv4(const Target &TargetID, const std::string &Value)
259 : TargetID(TargetID), Value(Value) {}
260};
261} // end anonymous namespace.
262
264LLVM_YAML_IS_SEQUENCE_VECTOR(ExportSection)
265LLVM_YAML_IS_SEQUENCE_VECTOR(UndefinedSection)
266// Specific to TBDv4
267LLVM_YAML_IS_SEQUENCE_VECTOR(SymbolSection)
268LLVM_YAML_IS_SEQUENCE_VECTOR(MetadataSection)
269LLVM_YAML_IS_SEQUENCE_VECTOR(UmbrellaSection)
272
273namespace llvm {
274namespace yaml {
275
276template <> struct MappingTraits<ExportSection> {
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");
281
282 IO.mapRequired("archs", Section.Architectures);
283 if (Ctx->FileKind == FileType::TBD_V1)
284 IO.mapOptional("allowed-clients", Section.AllowableClients);
285 else
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);
295 }
296};
297
298template <> struct MappingTraits<UndefinedSection> {
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");
303
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);
311 }
312};
313
314template <> struct MappingTraits<SymbolSection> {
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);
323 }
324};
325
326template <> struct MappingTraits<UmbrellaSection> {
327 static void mapping(IO &IO, UmbrellaSection &Section) {
328 IO.mapRequired("targets", Section.Targets);
329 IO.mapRequired("umbrella", Section.Umbrella);
330 }
331};
332
333template <> struct MappingTraits<UUIDv4> {
334 static void mapping(IO &IO, UUIDv4 &UUID) {
335 IO.mapRequired("target", UUID.TargetID);
336 IO.mapRequired("value", UUID.Value);
337 }
338};
339
340template <>
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);
348 return;
349 case MetadataSection::Option::Libraries:
350 IO.mapRequired("libraries", Section.Values);
351 return;
352 }
353 llvm_unreachable("unexpected option for metadata");
354 }
355};
356
357template <> struct ScalarBitSetTraits<TBDFlags> {
358 static void bitset(IO &IO, TBDFlags &Flags) {
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 }
364};
365
366template <> struct ScalarTraits<Target> {
367 static void output(const Target &Value, void *, raw_ostream &OS) {
368 OS << Value.Arch << "-";
369 switch (Value.Platform) {
370 default:
371 OS << "unknown";
372 break;
373 case PLATFORM_MACOS:
374 OS << "macos";
375 break;
376 case PLATFORM_IOS:
377 OS << "ios";
378 break;
379 case PLATFORM_TVOS:
380 OS << "tvos";
381 break;
382 case PLATFORM_WATCHOS:
383 OS << "watchos";
384 break;
386 OS << "bridgeos";
387 break;
389 OS << "maccatalyst";
390 break;
392 OS << "ios-simulator";
393 break;
395 OS << "tvos-simulator";
396 break;
398 OS << "watchos-simulator";
399 break;
401 OS << "driverkit";
402 break;
403 }
404 }
405
406 static StringRef input(StringRef Scalar, void *, Target &Value) {
407 auto Result = Target::create(Scalar);
408 if (!Result) {
409 consumeError(Result.takeError());
410 return "unparsable target";
411 }
412
413 Value = *Result;
414 if (Value.Arch == AK_unknown)
415 return "unknown architecture";
416 if (Value.Platform == PLATFORM_UNKNOWN)
417 return "unknown platform";
418
419 return {};
420 }
421
422 static QuotingType mustQuote(StringRef) { return QuotingType::None; }
423};
424
425template <> struct MappingTraits<const InterfaceFile *> {
426 struct NormalizedTBD {
427 explicit NormalizedTBD(IO &IO) {}
428 NormalizedTBD(IO &IO, const InterfaceFile *&File) {
429 Architectures = File->getArchitectures();
430 UUIDs = File->uuids();
431 Platforms = File->getPlatforms();
432 InstallName = File->getInstallName();
433 CurrentVersion = PackedVersion(File->getCurrentVersion());
434 CompatibilityVersion = PackedVersion(File->getCompatibilityVersion());
435 SwiftABIVersion = File->getSwiftABIVersion();
436 ObjCConstraint = File->getObjCConstraint();
437
438 Flags = TBDFlags::None;
439 if (!File->isApplicationExtensionSafe())
440 Flags |= TBDFlags::NotApplicationExtensionSafe;
441
442 if (!File->isTwoLevelNamespace())
443 Flags |= TBDFlags::FlatNamespace;
444
445 if (File->isInstallAPI())
446 Flags |= TBDFlags::InstallAPI;
447
448 if (!File->umbrellas().empty())
449 ParentUmbrella = File->umbrellas().begin()->second;
450
451 std::set<ArchitectureSet> ArchSet;
452 for (const auto &Library : File->allowableClients())
453 ArchSet.insert(Library.getArchitectures());
454
455 for (const auto &Library : File->reexportedLibraries())
456 ArchSet.insert(Library.getArchitectures());
457
458 std::map<const Symbol *, ArchitectureSet> SymbolToArchSet;
459 for (const auto *Symbol : File->symbols()) {
460 auto Architectures = Symbol->getArchitectures();
461 SymbolToArchSet[Symbol] = Architectures;
462 ArchSet.insert(Architectures);
463 }
464
465 for (auto Architectures : ArchSet) {
466 ExportSection Section;
467 Section.Architectures = Architectures;
468
469 for (const auto &Library : File->allowableClients())
470 if (Library.getArchitectures() == Architectures)
471 Section.AllowableClients.emplace_back(Library.getInstallName());
472
473 for (const auto &Library : File->reexportedLibraries())
474 if (Library.getArchitectures() == Architectures)
475 Section.ReexportedLibraries.emplace_back(Library.getInstallName());
476
477 for (const auto &SymArch : SymbolToArchSet) {
478 if (SymArch.second != Architectures)
479 continue;
480
481 const auto *Symbol = SymArch.first;
482 switch (Symbol->getKind()) {
483 case SymbolKind::GlobalSymbol:
484 if (Symbol->isWeakDefined())
485 Section.WeakDefSymbols.emplace_back(Symbol->getName());
486 else if (Symbol->isThreadLocalValue())
487 Section.TLVSymbols.emplace_back(Symbol->getName());
488 else
489 Section.Symbols.emplace_back(Symbol->getName());
490 break;
491 case SymbolKind::ObjectiveCClass:
492 if (File->getFileType() != FileType::TBD_V3)
493 Section.Classes.emplace_back(
494 copyString("_" + Symbol->getName().str()));
495 else
496 Section.Classes.emplace_back(Symbol->getName());
497 break;
498 case SymbolKind::ObjectiveCClassEHType:
499 if (File->getFileType() != FileType::TBD_V3)
500 Section.Symbols.emplace_back(
501 copyString("_OBJC_EHTYPE_$_" + Symbol->getName().str()));
502 else
503 Section.ClassEHs.emplace_back(Symbol->getName());
504 break;
505 case SymbolKind::ObjectiveCInstanceVariable:
506 if (File->getFileType() != FileType::TBD_V3)
507 Section.IVars.emplace_back(
508 copyString("_" + Symbol->getName().str()));
509 else
510 Section.IVars.emplace_back(Symbol->getName());
511 break;
512 }
513 }
514 llvm::sort(Section.Symbols);
515 llvm::sort(Section.Classes);
516 llvm::sort(Section.ClassEHs);
517 llvm::sort(Section.IVars);
518 llvm::sort(Section.WeakDefSymbols);
519 llvm::sort(Section.TLVSymbols);
520 Exports.emplace_back(std::move(Section));
521 }
522
523 ArchSet.clear();
524 SymbolToArchSet.clear();
525
526 for (const auto *Symbol : File->undefineds()) {
527 auto Architectures = Symbol->getArchitectures();
528 SymbolToArchSet[Symbol] = Architectures;
529 ArchSet.insert(Architectures);
530 }
531
532 for (auto Architectures : ArchSet) {
533 UndefinedSection Section;
534 Section.Architectures = Architectures;
535
536 for (const auto &SymArch : SymbolToArchSet) {
537 if (SymArch.second != Architectures)
538 continue;
539
540 const auto *Symbol = SymArch.first;
541 switch (Symbol->getKind()) {
542 case SymbolKind::GlobalSymbol:
544 Section.WeakRefSymbols.emplace_back(Symbol->getName());
545 else
546 Section.Symbols.emplace_back(Symbol->getName());
547 break;
548 case SymbolKind::ObjectiveCClass:
549 if (File->getFileType() != FileType::TBD_V3)
550 Section.Classes.emplace_back(
551 copyString("_" + Symbol->getName().str()));
552 else
553 Section.Classes.emplace_back(Symbol->getName());
554 break;
555 case SymbolKind::ObjectiveCClassEHType:
556 if (File->getFileType() != FileType::TBD_V3)
557 Section.Symbols.emplace_back(
558 copyString("_OBJC_EHTYPE_$_" + Symbol->getName().str()));
559 else
560 Section.ClassEHs.emplace_back(Symbol->getName());
561 break;
562 case SymbolKind::ObjectiveCInstanceVariable:
563 if (File->getFileType() != FileType::TBD_V3)
564 Section.IVars.emplace_back(
565 copyString("_" + Symbol->getName().str()));
566 else
567 Section.IVars.emplace_back(Symbol->getName());
568 break;
569 }
570 }
571 llvm::sort(Section.Symbols);
572 llvm::sort(Section.Classes);
573 llvm::sort(Section.ClassEHs);
574 llvm::sort(Section.IVars);
575 llvm::sort(Section.WeakRefSymbols);
576 Undefineds.emplace_back(std::move(Section));
577 }
578 }
579
580 // TBD v1 - TBD v3 files only support one platform and several
581 // architectures. It is possible to have more than one platform for TBD v3
582 // files, but the architectures don't apply to all
583 // platforms, specifically to filter out the i386 slice from
584 // platform macCatalyst.
586 const PlatformSet &Platforms) {
588
589 for (auto Platform : Platforms) {
590 Platform = mapToPlatformType(Platform, Architectures.hasX86());
591
592 for (const auto &&Architecture : Architectures) {
593 if ((Architecture == AK_i386) && (Platform == PLATFORM_MACCATALYST))
594 continue;
595
596 Targets.emplace_back(Architecture, Platform);
597 }
598 }
599 return Targets;
600 }
601
602 const InterfaceFile *denormalize(IO &IO) {
603 auto Ctx = reinterpret_cast<TextAPIContext *>(IO.getContext());
604 assert(Ctx);
605
606 auto *File = new InterfaceFile;
607 File->setPath(Ctx->Path);
608 File->setFileType(Ctx->FileKind);
609 File->addTargets(synthesizeTargets(Architectures, Platforms));
610 for (auto &ID : UUIDs)
611 File->addUUID(ID.first, ID.second);
612 File->setInstallName(InstallName);
613 File->setCurrentVersion(CurrentVersion);
614 File->setCompatibilityVersion(CompatibilityVersion);
615 File->setSwiftABIVersion(SwiftABIVersion);
616 File->setObjCConstraint(ObjCConstraint);
617 for (const auto &Target : File->targets())
618 File->addParentUmbrella(Target, ParentUmbrella);
619
620 if (Ctx->FileKind == FileType::TBD_V1) {
621 File->setTwoLevelNamespace();
622 File->setApplicationExtensionSafe();
623 } else {
624 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
625 File->setApplicationExtensionSafe(
626 !(Flags & TBDFlags::NotApplicationExtensionSafe));
627 File->setInstallAPI(Flags & TBDFlags::InstallAPI);
628 }
629
630 for (const auto &Section : Exports) {
631 const auto Targets =
632 synthesizeTargets(Section.Architectures, Platforms);
633
634 for (const auto &Lib : Section.AllowableClients)
635 for (const auto &Target : Targets)
636 File->addAllowableClient(Lib, Target);
637
638 for (const auto &Lib : Section.ReexportedLibraries)
639 for (const auto &Target : Targets)
640 File->addReexportedLibrary(Lib, Target);
641
642 for (const auto &Symbol : Section.Symbols) {
643 if (Ctx->FileKind != FileType::TBD_V3 &&
644 Symbol.value.startswith("_OBJC_EHTYPE_$_"))
645 File->addSymbol(SymbolKind::ObjectiveCClassEHType,
646 Symbol.value.drop_front(15), Targets);
647 else
648 File->addSymbol(SymbolKind::GlobalSymbol, Symbol, Targets);
649 }
650 for (auto &Symbol : Section.Classes) {
651 auto Name = Symbol.value;
652 if (Ctx->FileKind != FileType::TBD_V3)
653 Name = Name.drop_front();
654 File->addSymbol(SymbolKind::ObjectiveCClass, Name, Targets);
655 }
656 for (auto &Symbol : Section.ClassEHs)
657 File->addSymbol(SymbolKind::ObjectiveCClassEHType, Symbol, Targets);
658 for (auto &Symbol : Section.IVars) {
659 auto Name = Symbol.value;
660 if (Ctx->FileKind != FileType::TBD_V3)
661 Name = Name.drop_front();
662 File->addSymbol(SymbolKind::ObjectiveCInstanceVariable, Name,
663 Targets);
664 }
665 for (auto &Symbol : Section.WeakDefSymbols)
666 File->addSymbol(SymbolKind::GlobalSymbol, Symbol, Targets,
667 SymbolFlags::WeakDefined);
668 for (auto &Symbol : Section.TLVSymbols)
669 File->addSymbol(SymbolKind::GlobalSymbol, Symbol, Targets,
670 SymbolFlags::ThreadLocalValue);
671 }
672
673 for (const auto &Section : Undefineds) {
674 const auto Targets =
675 synthesizeTargets(Section.Architectures, Platforms);
676 for (auto &Symbol : Section.Symbols) {
677 if (Ctx->FileKind != FileType::TBD_V3 &&
678 Symbol.value.startswith("_OBJC_EHTYPE_$_"))
679 File->addSymbol(SymbolKind::ObjectiveCClassEHType,
680 Symbol.value.drop_front(15), Targets,
681 SymbolFlags::Undefined);
682 else
683 File->addSymbol(SymbolKind::GlobalSymbol, Symbol, Targets,
684 SymbolFlags::Undefined);
685 }
686 for (auto &Symbol : Section.Classes) {
687 auto Name = Symbol.value;
688 if (Ctx->FileKind != FileType::TBD_V3)
689 Name = Name.drop_front();
690 File->addSymbol(SymbolKind::ObjectiveCClass, Name, Targets,
691 SymbolFlags::Undefined);
692 }
693 for (auto &Symbol : Section.ClassEHs)
694 File->addSymbol(SymbolKind::ObjectiveCClassEHType, Symbol, Targets,
695 SymbolFlags::Undefined);
696 for (auto &Symbol : Section.IVars) {
697 auto Name = Symbol.value;
698 if (Ctx->FileKind != FileType::TBD_V3)
699 Name = Name.drop_front();
700 File->addSymbol(SymbolKind::ObjectiveCInstanceVariable, Name, Targets,
701 SymbolFlags::Undefined);
702 }
703 for (auto &Symbol : Section.WeakRefSymbols)
704 File->addSymbol(SymbolKind::GlobalSymbol, Symbol, Targets,
705 SymbolFlags::Undefined | SymbolFlags::WeakReferenced);
706 }
707
708 return File;
709 }
710
713 if (String.empty())
714 return {};
715
716 void *Ptr = Allocator.Allocate(String.size(), 1);
717 memcpy(Ptr, String.data(), String.size());
718 return StringRef(reinterpret_cast<const char *>(Ptr), String.size());
719 }
720
721 std::vector<Architecture> Architectures;
722 std::vector<UUID> UUIDs;
727 SwiftVersion SwiftABIVersion{0};
728 ObjCConstraintType ObjCConstraint{ObjCConstraintType::None};
729 TBDFlags Flags{TBDFlags::None};
731 std::vector<ExportSection> Exports;
732 std::vector<UndefinedSection> Undefineds;
733 };
734
735 static void setFileTypeForInput(TextAPIContext *Ctx, IO &IO) {
736 if (IO.mapTag("!tapi-tbd", false))
737 Ctx->FileKind = FileType::TBD_V4;
738 else if (IO.mapTag("!tapi-tbd-v3", false))
739 Ctx->FileKind = FileType::TBD_V3;
740 else if (IO.mapTag("!tapi-tbd-v2", false))
741 Ctx->FileKind = FileType::TBD_V2;
742 else if (IO.mapTag("!tapi-tbd-v1", false) ||
743 IO.mapTag("tag:yaml.org,2002:map", false))
744 Ctx->FileKind = FileType::TBD_V1;
745 else {
746 Ctx->FileKind = FileType::Invalid;
747 return;
748 }
749 }
750
751 static void mapping(IO &IO, const InterfaceFile *&File) {
752 auto *Ctx = reinterpret_cast<TextAPIContext *>(IO.getContext());
753 assert((!Ctx || !IO.outputting() ||
754 (Ctx && Ctx->FileKind != FileType::Invalid)) &&
755 "File type is not set in YAML context");
756
757 if (!IO.outputting()) {
758 setFileTypeForInput(Ctx, IO);
759 switch (Ctx->FileKind) {
760 default:
761 break;
762 case FileType::TBD_V4:
763 mapKeysToValuesV4(IO, File);
764 return;
765 case FileType::Invalid:
766 IO.setError("unsupported file type");
767 return;
768 }
769 } else {
770 // Set file type when writing.
771 switch (Ctx->FileKind) {
772 default:
773 llvm_unreachable("unexpected file type");
774 case FileType::TBD_V4:
775 mapKeysToValuesV4(IO, File);
776 return;
777 case FileType::TBD_V3:
778 IO.mapTag("!tapi-tbd-v3", true);
779 break;
780 case FileType::TBD_V2:
781 IO.mapTag("!tapi-tbd-v2", true);
782 break;
783 case FileType::TBD_V1:
784 // Don't write the tag into the .tbd file for TBD v1
785 break;
786 }
787 }
788 mapKeysToValues(Ctx->FileKind, IO, File);
789 }
790
791 using SectionList = std::vector<SymbolSection>;
792 struct NormalizedTBD_V4 {
793 explicit NormalizedTBD_V4(IO &IO) {}
794 NormalizedTBD_V4(IO &IO, const InterfaceFile *&File) {
795 auto Ctx = reinterpret_cast<TextAPIContext *>(IO.getContext());
796 assert(Ctx);
797 TBDVersion = Ctx->FileKind >> 1;
798 Targets.insert(Targets.begin(), File->targets().begin(),
799 File->targets().end());
800 for (const auto &IT : File->uuids())
801 UUIDs.emplace_back(IT.first, IT.second);
802 InstallName = File->getInstallName();
803 CurrentVersion = File->getCurrentVersion();
804 CompatibilityVersion = File->getCompatibilityVersion();
805 SwiftABIVersion = File->getSwiftABIVersion();
806
807 Flags = TBDFlags::None;
808 if (!File->isApplicationExtensionSafe())
809 Flags |= TBDFlags::NotApplicationExtensionSafe;
810
811 if (!File->isTwoLevelNamespace())
812 Flags |= TBDFlags::FlatNamespace;
813
814 if (File->isInstallAPI())
815 Flags |= TBDFlags::InstallAPI;
816
817 {
818 std::map<std::string, TargetList> valueToTargetList;
819 for (const auto &it : File->umbrellas())
820 valueToTargetList[it.second].emplace_back(it.first);
821
822 for (const auto &it : valueToTargetList) {
823 UmbrellaSection CurrentSection;
824 CurrentSection.Targets.insert(CurrentSection.Targets.begin(),
825 it.second.begin(), it.second.end());
826 CurrentSection.Umbrella = it.first;
827 ParentUmbrellas.emplace_back(std::move(CurrentSection));
828 }
829 }
830
831 assignTargetsToLibrary(File->allowableClients(), AllowableClients);
832 assignTargetsToLibrary(File->reexportedLibraries(), ReexportedLibraries);
833
834 auto handleSymbols =
835 [](SectionList &CurrentSections,
837 std::set<TargetList> TargetSet;
838 std::map<const Symbol *, TargetList> SymbolToTargetList;
839 for (const auto *Symbol : Symbols) {
841 SymbolToTargetList[Symbol] = Targets;
842 TargetSet.emplace(std::move(Targets));
843 }
844 for (const auto &TargetIDs : TargetSet) {
845 SymbolSection CurrentSection;
846 CurrentSection.Targets.insert(CurrentSection.Targets.begin(),
847 TargetIDs.begin(), TargetIDs.end());
848
849 for (const auto &IT : SymbolToTargetList) {
850 if (IT.second != TargetIDs)
851 continue;
852
853 const auto *Symbol = IT.first;
854 switch (Symbol->getKind()) {
855 case SymbolKind::GlobalSymbol:
856 if (Symbol->isWeakDefined())
857 CurrentSection.WeakSymbols.emplace_back(Symbol->getName());
858 else if (Symbol->isThreadLocalValue())
859 CurrentSection.TlvSymbols.emplace_back(Symbol->getName());
860 else
861 CurrentSection.Symbols.emplace_back(Symbol->getName());
862 break;
863 case SymbolKind::ObjectiveCClass:
864 CurrentSection.Classes.emplace_back(Symbol->getName());
865 break;
866 case SymbolKind::ObjectiveCClassEHType:
867 CurrentSection.ClassEHs.emplace_back(Symbol->getName());
868 break;
869 case SymbolKind::ObjectiveCInstanceVariable:
870 CurrentSection.Ivars.emplace_back(Symbol->getName());
871 break;
872 }
873 }
874 sort(CurrentSection.Symbols);
875 sort(CurrentSection.Classes);
876 sort(CurrentSection.ClassEHs);
877 sort(CurrentSection.Ivars);
878 sort(CurrentSection.WeakSymbols);
879 sort(CurrentSection.TlvSymbols);
880 CurrentSections.emplace_back(std::move(CurrentSection));
881 }
882 };
883
884 handleSymbols(Exports, File->exports());
885 handleSymbols(Reexports, File->reexports());
886 handleSymbols(Undefineds, File->undefineds());
887 }
888
889 const InterfaceFile *denormalize(IO &IO) {
890 auto Ctx = reinterpret_cast<TextAPIContext *>(IO.getContext());
891 assert(Ctx);
892
893 auto *File = new InterfaceFile;
894 File->setPath(Ctx->Path);
895 File->setFileType(Ctx->FileKind);
896 for (auto &id : UUIDs)
897 File->addUUID(id.TargetID, id.Value);
898 File->addTargets(Targets);
899 File->setInstallName(InstallName);
900 File->setCurrentVersion(CurrentVersion);
901 File->setCompatibilityVersion(CompatibilityVersion);
902 File->setSwiftABIVersion(SwiftABIVersion);
903 for (const auto &CurrentSection : ParentUmbrellas)
904 for (const auto &target : CurrentSection.Targets)
905 File->addParentUmbrella(target, CurrentSection.Umbrella);
906 File->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
907 File->setApplicationExtensionSafe(
908 !(Flags & TBDFlags::NotApplicationExtensionSafe));
909 File->setInstallAPI(Flags & TBDFlags::InstallAPI);
910
911 for (const auto &CurrentSection : AllowableClients) {
912 for (const auto &lib : CurrentSection.Values)
913 for (const auto &Target : CurrentSection.Targets)
914 File->addAllowableClient(lib, Target);
915 }
916
917 for (const auto &CurrentSection : ReexportedLibraries) {
918 for (const auto &Lib : CurrentSection.Values)
919 for (const auto &Target : CurrentSection.Targets)
920 File->addReexportedLibrary(Lib, Target);
921 }
922
923 auto handleSymbols = [File](const SectionList &CurrentSections,
924 SymbolFlags Flag = SymbolFlags::None) {
925 for (const auto &CurrentSection : CurrentSections) {
926 for (auto &sym : CurrentSection.Symbols)
927 File->addSymbol(SymbolKind::GlobalSymbol, sym,
928 CurrentSection.Targets, Flag);
929
930 for (auto &sym : CurrentSection.Classes)
931 File->addSymbol(SymbolKind::ObjectiveCClass, sym,
932 CurrentSection.Targets, Flag);
933
934 for (auto &sym : CurrentSection.ClassEHs)
935 File->addSymbol(SymbolKind::ObjectiveCClassEHType, sym,
936 CurrentSection.Targets, Flag);
937
938 for (auto &sym : CurrentSection.Ivars)
939 File->addSymbol(SymbolKind::ObjectiveCInstanceVariable, sym,
940 CurrentSection.Targets, Flag);
941
942 SymbolFlags SymFlag = (Flag == SymbolFlags::Undefined)
943 ? SymbolFlags::WeakReferenced
944 : SymbolFlags::WeakDefined;
945 for (auto &sym : CurrentSection.WeakSymbols) {
946 File->addSymbol(SymbolKind::GlobalSymbol, sym,
947 CurrentSection.Targets, Flag | SymFlag);
948 }
949
950 for (auto &sym : CurrentSection.TlvSymbols)
951 File->addSymbol(SymbolKind::GlobalSymbol, sym,
952 CurrentSection.Targets,
953 Flag | SymbolFlags::ThreadLocalValue);
954 }
955 };
956
957 handleSymbols(Exports);
958 handleSymbols(Reexports, SymbolFlags::Rexported);
959 handleSymbols(Undefineds, SymbolFlags::Undefined);
960
961 return File;
962 }
963
964 unsigned TBDVersion;
965 std::vector<UUIDv4> UUIDs;
970 SwiftVersion SwiftABIVersion{0};
971 std::vector<MetadataSection> AllowableClients;
972 std::vector<MetadataSection> ReexportedLibraries;
973 TBDFlags Flags{TBDFlags::None};
974 std::vector<UmbrellaSection> ParentUmbrellas;
978
979 private:
980 void assignTargetsToLibrary(const std::vector<InterfaceFileRef> &Libraries,
981 std::vector<MetadataSection> &Section) {
982 std::set<TargetList> targetSet;
983 std::map<const InterfaceFileRef *, TargetList> valueToTargetList;
984 for (const auto &library : Libraries) {
985 TargetList targets(library.targets());
986 valueToTargetList[&library] = targets;
987 targetSet.emplace(std::move(targets));
988 }
989
990 for (const auto &targets : targetSet) {
991 MetadataSection CurrentSection;
992 CurrentSection.Targets.insert(CurrentSection.Targets.begin(),
993 targets.begin(), targets.end());
994
995 for (const auto &it : valueToTargetList) {
996 if (it.second != targets)
997 continue;
998
999 CurrentSection.Values.emplace_back(it.first->getInstallName());
1000 }
1001 llvm::sort(CurrentSection.Values);
1002 Section.emplace_back(std::move(CurrentSection));
1003 }
1004 }
1005 };
1006
1007 static void mapKeysToValues(FileType FileKind, IO &IO,
1008 const InterfaceFile *&File) {
1009 MappingNormalization<NormalizedTBD, const InterfaceFile *> Keys(IO, File);
1010 IO.mapRequired("archs", Keys->Architectures);
1011 if (FileKind != FileType::TBD_V1)
1012 IO.mapOptional("uuids", Keys->UUIDs);
1013 IO.mapRequired("platform", Keys->Platforms);
1014 if (FileKind != FileType::TBD_V1)
1015 IO.mapOptional("flags", Keys->Flags, TBDFlags::None);
1016 IO.mapRequired("install-name", Keys->InstallName);
1017 IO.mapOptional("current-version", Keys->CurrentVersion,
1018 PackedVersion(1, 0, 0));
1019 IO.mapOptional("compatibility-version", Keys->CompatibilityVersion,
1020 PackedVersion(1, 0, 0));
1021 if (FileKind != FileType::TBD_V3)
1022 IO.mapOptional("swift-version", Keys->SwiftABIVersion, SwiftVersion(0));
1023 else
1024 IO.mapOptional("swift-abi-version", Keys->SwiftABIVersion,
1025 SwiftVersion(0));
1026 IO.mapOptional("objc-constraint", Keys->ObjCConstraint,
1027 (FileKind == FileType::TBD_V1)
1028 ? ObjCConstraintType::None
1029 : ObjCConstraintType::Retain_Release);
1030 if (FileKind != FileType::TBD_V1)
1031 IO.mapOptional("parent-umbrella", Keys->ParentUmbrella, StringRef());
1032 IO.mapOptional("exports", Keys->Exports);
1033 if (FileKind != FileType::TBD_V1)
1034 IO.mapOptional("undefineds", Keys->Undefineds);
1035 }
1036
1037 static void mapKeysToValuesV4(IO &IO, const InterfaceFile *&File) {
1038 MappingNormalization<NormalizedTBD_V4, const InterfaceFile *> Keys(IO,
1039 File);
1040 IO.mapTag("!tapi-tbd", true);
1041 IO.mapRequired("tbd-version", Keys->TBDVersion);
1042 IO.mapRequired("targets", Keys->Targets);
1043 IO.mapOptional("uuids", Keys->UUIDs);
1044 IO.mapOptional("flags", Keys->Flags, TBDFlags::None);
1045 IO.mapRequired("install-name", Keys->InstallName);
1046 IO.mapOptional("current-version", Keys->CurrentVersion,
1047 PackedVersion(1, 0, 0));
1048 IO.mapOptional("compatibility-version", Keys->CompatibilityVersion,
1049 PackedVersion(1, 0, 0));
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,
1054 OptionKind);
1055 OptionKind = MetadataSection::Option::Libraries;
1056 IO.mapOptionalWithContext("reexported-libraries", Keys->ReexportedLibraries,
1057 OptionKind);
1058 IO.mapOptional("exports", Keys->Exports);
1059 IO.mapOptional("reexports", Keys->Reexports);
1060 IO.mapOptional("undefineds", Keys->Undefineds);
1061 }
1062};
1063
1064template <>
1065struct DocumentListTraits<std::vector<const MachO::InterfaceFile *>> {
1066 static size_t size(IO &IO, std::vector<const MachO::InterfaceFile *> &Seq) {
1067 return Seq.size();
1068 }
1069 static const InterfaceFile *&
1070 element(IO &IO, std::vector<const InterfaceFile *> &Seq, size_t Index) {
1071 if (Index >= Seq.size())
1072 Seq.resize(Index + 1);
1073 return Seq[Index];
1074 }
1075};
1076
1077} // end namespace yaml.
1078} // namespace llvm
1079
1080static void DiagHandler(const SMDiagnostic &Diag, void *Context) {
1081 auto *File = static_cast<TextAPIContext *>(Context);
1082 SmallString<1024> Message;
1083 raw_svector_ostream S(Message);
1084
1085 SMDiagnostic NewDiag(*Diag.getSourceMgr(), Diag.getLoc(), File->Path,
1086 Diag.getLineNo(), Diag.getColumnNo(), Diag.getKind(),
1087 Diag.getMessage(), Diag.getLineContents(),
1088 Diag.getRanges(), Diag.getFixIts());
1089
1090 NewDiag.print(nullptr, S);
1091 File->ErrorMessage = ("malformed file\n" + Message).str();
1092}
1093
1094namespace {
1095
1096Expected<FileType> canReadFileType(MemoryBufferRef InputBuffer) {
1097 auto TAPIFile = InputBuffer.getBuffer().trim();
1098 if (TAPIFile.startswith("{") && TAPIFile.endswith("}"))
1099 return FileType::TBD_V5;
1100
1101 if (!TAPIFile.endswith("..."))
1102 return createStringError(std::errc::not_supported, "unsupported file type");
1103
1104 if (TAPIFile.startswith("--- !tapi-tbd\n"))
1105 return FileType::TBD_V4;
1106
1107 if (TAPIFile.startswith("--- !tapi-tbd-v3\n"))
1108 return FileType::TBD_V3;
1109
1110 if (TAPIFile.startswith("--- !tapi-tbd-v2\n"))
1111 return FileType::TBD_V2;
1112
1113 if (TAPIFile.startswith("--- !tapi-tbd-v1\n") ||
1114 TAPIFile.startswith("---\narchs:"))
1115 return FileType::TBD_V1;
1116
1117 return createStringError(std::errc::not_supported, "unsupported file type");
1118}
1119} // namespace
1120
1123 TextAPIContext Ctx;
1124 Ctx.Path = std::string(InputBuffer.getBufferIdentifier());
1125 if (auto FTOrErr = canReadFileType(InputBuffer))
1126 Ctx.FileKind = *FTOrErr;
1127 else
1128 return FTOrErr.takeError();
1129
1130 // Handle JSON Format.
1131 if (Ctx.FileKind >= FileType::TBD_V5) {
1132 auto FileOrErr = getInterfaceFileFromJSON(InputBuffer.getBuffer());
1133 if (!FileOrErr)
1134 return FileOrErr.takeError();
1135 return std::move(*FileOrErr);
1136 }
1137 yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx);
1138
1139 // Fill vector with interface file objects created by parsing the YAML file.
1140 std::vector<const InterfaceFile *> Files;
1141 YAMLIn >> Files;
1142
1143 // YAMLIn dynamically allocates for Interface file and in case of error,
1144 // memory leak will occur unless wrapped around unique_ptr
1145 auto File = std::unique_ptr<InterfaceFile>(
1146 const_cast<InterfaceFile *>(Files.front()));
1147
1148 for (const InterfaceFile *FI : llvm::drop_begin(Files))
1149 File->addDocument(
1150 std::shared_ptr<InterfaceFile>(const_cast<InterfaceFile *>(FI)));
1151
1152 if (YAMLIn.error())
1153 return make_error<StringError>(Ctx.ErrorMessage, YAMLIn.error());
1154
1155 return std::move(File);
1156}
1157
1159 bool Compact) {
1160 TextAPIContext Ctx;
1161 Ctx.Path = std::string(File.getPath());
1162 Ctx.FileKind = File.getFileType();
1163
1164 // Write out in JSON format.
1165 if (Ctx.FileKind >= FileType::TBD_V5) {
1166 return serializeInterfaceFileToJSON(OS, File, Compact);
1167 }
1168
1169 llvm::yaml::Output YAMLOut(OS, &Ctx, /*WrapColumn=*/80);
1170
1171 std::vector<const InterfaceFile *> Files;
1172 Files.emplace_back(&File);
1173
1174 for (auto Document : File.documents())
1175 Files.emplace_back(Document.get());
1176
1177 // Stream out yaml.
1178 YAMLOut << Files;
1179
1180 return Error::success();
1181}
aarch64 promote const
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.
std::string Name
LLVMContext & Context
Basic Register Allocator
Replace intrinsics with calls to vector library
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallString class.
std::pair< llvm::MachO::Target, std::string > UUID
TBDFlags
std::array< StringRef, 64 > Keys
Definition: TextStubV5.cpp:123
@ Targets
Definition: TextStubV5.cpp:90
@ CurrentVersion
Definition: TextStubV5.cpp:96
@ Undefineds
Definition: TextStubV5.cpp:110
@ InstallName
Definition: TextStubV5.cpp:95
@ AllowableClients
Definition: TextStubV5.cpp:103
@ Umbrella
Definition: TextStubV5.cpp:102
@ TBDVersion
Definition: TextStubV5.cpp:86
@ CompatibilityVersion
Definition: TextStubV5.cpp:97
@ Exports
Definition: TextStubV5.cpp:108
@ Reexports
Definition: TextStubV5.cpp:109
@ Flags
Definition: TextStubV5.cpp:93
@ Clients
Definition: TextStubV5.cpp:104
@ ParentUmbrella
Definition: TextStubV5.cpp:101
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
Definition: TextStub.cpp:1080
#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.
Definition: Allocator.h:66
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
static ErrorSuccess success()
Create a success value.
Definition: Error.h:330
Tagged union holding either a T or a Error.
Definition: Error.h:470
Defines the interface file.
bool isWeakDefined() const
Definition: Symbol.h:81
const_target_range targets() const
Definition: Symbol.h:112
bool isThreadLocalValue() const
Definition: Symbol.h:89
SymbolKind getKind() const
Definition: Symbol.h:74
ArchitectureSet getArchitectures() const
Definition: Symbol.h:76
StringRef getName() const
Definition: Symbol.h:75
bool isWeakReferenced() const
Definition: Symbol.h:85
static llvm::Expected< Target > create(StringRef Target)
Definition: Target.cpp:17
static Expected< std::unique_ptr< InterfaceFile > > get(MemoryBufferRef InputBuffer)
Definition: TextStub.cpp:1122
static Error writeToStream(raw_ostream &OS, const InterfaceFile &File, bool Compact=false)
Definition: TextStub.cpp:1158
StringRef getBufferIdentifier() const
StringRef getBuffer() const
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
SourceMgr::DiagKind getKind() const
Definition: SourceMgr.h:310
int getLineNo() const
Definition: SourceMgr.h:308
StringRef getLineContents() const
Definition: SourceMgr.h:312
SMLoc getLoc() const
Definition: SourceMgr.h:306
StringRef getMessage() const
Definition: SourceMgr.h:311
ArrayRef< SMFixIt > getFixIts() const
Definition: SourceMgr.h:317
ArrayRef< std::pair< unsigned, unsigned > > getRanges() const
Definition: SourceMgr.h:313
const SourceMgr * getSourceMgr() const
Definition: SourceMgr.h:305
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) const
Definition: SourceMgr.cpp:484
int getColumnNo() const
Definition: SourceMgr.h:309
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
iterator insert(iterator I, T &&Elt)
Definition: SmallVector.h:809
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
Definition: StringRef.h:813
Target - Wrapper for Target specific information.
LLVM Value Representation.
Definition: Value.h:74
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:672
A YAML Stream is a sequence of Documents.
Definition: YAMLParser.h:531
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:53
@ TBD_V5
Text-based stub file (.tbd) version 5.0.
Definition: InterfaceFile.h:70
@ PLATFORM_MACCATALYST
Definition: MachO.h:504
@ PLATFORM_DRIVERKIT
Definition: MachO.h:508
@ PLATFORM_WATCHOS
Definition: MachO.h:502
@ PLATFORM_UNKNOWN
Definition: MachO.h:498
@ PLATFORM_WATCHOSSIMULATOR
Definition: MachO.h:507
@ PLATFORM_IOS
Definition: MachO.h:500
@ PLATFORM_TVOS
Definition: MachO.h:501
@ PLATFORM_TVOSSIMULATOR
Definition: MachO.h:506
@ PLATFORM_BRIDGEOS
Definition: MachO.h:503
@ PLATFORM_MACOS
Definition: MachO.h:499
@ PLATFORM_IOSSIMULATOR
Definition: MachO.h:505
ObjCConstraintType
Defines a list of Objective-C constraints.
Definition: InterfaceFile.h:33
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
Definition: Architecture.h:27
PlatformType mapToPlatformType(PlatformType Platform, bool WantSim)
Definition: Platform.cpp:21
Error serializeInterfaceFileToJSON(raw_ostream &OS, const InterfaceFile &File, bool Compact)
Expected< std::unique_ptr< InterfaceFile > > getInterfaceFileFromJSON(StringRef JSON)
Definition: TextStubV5.cpp:702
SymbolFlags
Symbol flags.
Definition: Symbol.h:24
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition: STLExtras.h:413
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1246
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1744
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1043
Definition: BitVector.h:858
static const InterfaceFile *& element(IO &IO, std::vector< const InterfaceFile * > &Seq, size_t Index)
Definition: TextStub.cpp:1070
static size_t size(IO &IO, std::vector< const MachO::InterfaceFile * > &Seq)
Definition: TextStub.cpp:1066
static void mapping(IO &IO, MetadataSection &Section, MetadataSection::Option &OptionKind)
Definition: TextStub.cpp:342
static void mapping(IO &IO, ExportSection &Section)
Definition: TextStub.cpp:277
static void mapping(IO &IO, SymbolSection &Section)
Definition: TextStub.cpp:315
static void mapping(IO &IO, UUIDv4 &UUID)
Definition: TextStub.cpp:334
static void mapping(IO &IO, UmbrellaSection &Section)
Definition: TextStub.cpp:327
static void mapping(IO &IO, UndefinedSection &Section)
Definition: TextStub.cpp:299
TargetList synthesizeTargets(ArchitectureSet Architectures, const PlatformSet &Platforms)
Definition: TextStub.cpp:585
static void mapKeysToValuesV4(IO &IO, const InterfaceFile *&File)
Definition: TextStub.cpp:1037
static void setFileTypeForInput(TextAPIContext *Ctx, IO &IO)
Definition: TextStub.cpp:735
static void mapping(IO &IO, const InterfaceFile *&File)
Definition: TextStub.cpp:751
static void mapKeysToValues(FileType FileKind, IO &IO, const InterfaceFile *&File)
Definition: TextStub.cpp:1007
static void bitset(IO &IO, TBDFlags &Flags)
Definition: TextStub.cpp:358
static StringRef input(StringRef Scalar, void *, Target &Value)
Definition: TextStub.cpp:406
static void output(const Target &Value, void *, raw_ostream &OS)
Definition: TextStub.cpp:367
static QuotingType mustQuote(StringRef)
Definition: TextStub.cpp:422