LLVM: include/llvm/TextAPI/InterfaceFile.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_TEXTAPI_INTERFACEFILE_H
15#define LLVM_TEXTAPI_INTERFACEFILE_H
16
30
31namespace llvm {
33
34
36
38
39
41
42
44
45
47
48
50};
51
52
54public:
56
58
60 : InstallName(InstallName), Targets(std::move(Targets)) {}
61
63
65 template void addTargets(RangeT &&Targets) {
66 for (const auto &Target : Targets)
68 }
69
73
77
81
83
85 return std::tie(InstallName, Targets) == std::tie(O.InstallName, O.Targets);
86 }
87
89 return std::tie(InstallName, Targets) != std::tie(O.InstallName, O.Targets);
90 }
91
93 return std::tie(InstallName, Targets) < std::tie(O.InstallName, O.Targets);
94 }
95
96private:
97 std::string InstallName;
99};
100
101}
102
103namespace MachO {
104
105
107public:
109 : SymbolsSet(std::move(InputSymbols)) {}
110
112
113
114
116
117
118
119
121
122
123
124
125
126
127
129
130
131
132
134
135
136
137
141
142
143
144
146
147
148
149
151
152
153
154
158
159
160
161
162
163
164 template void addTargets(RangeT &&Targets) {
165 for (const auto &Target_ : Targets)
167 }
168
172
175 std::function<bool(const Target &)>>;
179
180
182 InstallName = std::string(InstallName_);
183 }
184
185
187
188
190
191
193
194
196 CompatibilityVersion = Version;
197 }
198
199
201
202
204
205
207
208
210
211
213
214
216 IsOSLibNotForSharedCache = V;
217 }
218
219
221
222
224
225
227
228
230
231
233
234
236 ObjcConstraint = Constraint;
237 }
238
239
241
242
243
244
246
247
248
249
250
251 const std::vector<std::pair<Target, std::string>> &umbrellas() const {
252 return ParentUmbrellas;
253 }
254
255
256
257
258
259
260
261
262
263
264
266
267
268
269
271 return AllowableClients;
272 }
273
274
275
276
277
280
281
282
283
285 return ReexportedLibraries;
286 }
287
288
289
290
292
293
295
296
297
298
299 const std::vector<std::shared_ptr> &documents() const {
300 return Documents;
301 }
302
303
304
305
307
308
309
310
311 const std::vector<std::pair<Target, std::string>> &rpaths() const {
312 return RPaths;
313 }
314
315
316
317
318
319
320 std::optional<const Symbol *>
323 if (auto *Sym = SymbolsSet->findSymbol(Kind, Name, ObjCIF))
324 return Sym;
325 return std::nullopt;
326 }
327
328
329 template <typename RangeT, typename ElT = std::remove_reference_t<
330 decltype(*std::begin(std::declval()))>>
333 SymbolsSet->addGlobal(Kind, Name, Flags, Targets);
334 }
335
336
337
338
339
340
341
344 SymbolsSet->addGlobal(Kind, Name, Flags, Targets);
345 }
346
347
348
349
350
351
352
355 SymbolsSet->addGlobal(Kind, Name, Flags, Target);
356 }
357
358
359
360 size_t symbolsCount() const { return SymbolsSet->size(); }
361
364
368 return SymbolsSet->reexports();
369 };
371 return SymbolsSet->undefineds();
372 };
373
374
375
376
377
380
381
382
383
384
387
388
389
390
391
392
393
394
397
398
399
400
401
403 bool Overwrite = false);
404
405
406
407
408
409
412
413
414
415
416
418
420
421private:
425 return {};
426
429 return StringRef(reinterpret_cast<const char *>(Ptr), String.size());
430 }
431
433 std::string Path;
435 std::string InstallName;
436 PackedVersion CurrentVersion;
437 PackedVersion CompatibilityVersion;
438 uint8_t SwiftABIVersion{0};
439 bool IsTwoLevelNamespace{false};
440 bool IsOSLibNotForSharedCache{false};
441 bool IsAppExtensionSafe{false};
442 bool HasSimSupport{false};
444 std::vector<std::pair<Target, std::string>> ParentUmbrellas;
445 std::vector AllowableClients;
446 std::vector ReexportedLibraries;
447 std::vector<std::shared_ptr> Documents;
448 std::vector<std::pair<Target, std::string>> RPaths;
449 std::unique_ptr SymbolsSet;
451};
452
453
454template
457 return O.getInstallName() < InstallName;
458 });
459 if (I != Container.end() && I->getInstallName() == InstallName)
460 return I;
461
462 return Container.emplace(I, InstallName);
463}
464
465}
466}
467
468#endif
This file defines the BumpPtrAllocator interface.
Implements the TAPI Record Collection Type.
Tagged union holding either a T or a Error.
Reference to an interface file.
Definition InterfaceFile.h:53
InterfaceFileRef(StringRef InstallName, const TargetList Targets)
Definition InterfaceFile.h:59
bool hasTarget(Target &Targ) const
Definition InterfaceFile.h:70
bool operator!=(const InterfaceFileRef &O) const
Definition InterfaceFile.h:88
void addTargets(RangeT &&Targets)
Definition InterfaceFile.h:65
PlatformSet getPlatforms() const
Definition InterfaceFile.h:82
LLVM_ABI void addTarget(const Target &Target)
const_target_range targets() const
Definition InterfaceFile.h:76
StringRef getInstallName() const
Definition InterfaceFile.h:62
TargetList::const_iterator const_target_iterator
Definition InterfaceFile.h:74
bool operator==(const InterfaceFileRef &O) const
Definition InterfaceFile.h:84
ArchitectureSet getArchitectures() const
Definition InterfaceFile.h:78
InterfaceFileRef(StringRef InstallName)
Definition InterfaceFile.h:57
InterfaceFileRef()=default
llvm::iterator_range< const_target_iterator > const_target_range
Definition InterfaceFile.h:75
bool operator<(const InterfaceFileRef &O) const
Definition InterfaceFile.h:92
Defines the interface file.
Definition InterfaceFile.h:106
std::optional< const Symbol * > getSymbol(EncodeKind Kind, StringRef Name, ObjCIFSymbolKind ObjCIF=ObjCIFSymbolKind::None) const
Get symbol if exists in file.
Definition InterfaceFile.h:321
LLVM_ABI void addDocument(std::shared_ptr< InterfaceFile > &&Document)
Add a library for inlining to top level library.
InterfaceFile()
Definition InterfaceFile.h:111
SymbolSet::const_filtered_symbol_range const_filtered_symbol_range
Definition InterfaceFile.h:363
StringRef getPath() const
Get the path from which this file was generated (if applicable).
Definition InterfaceFile.h:120
LLVM_ABI void addReexportedLibrary(StringRef InstallName, const Target &Target)
Add a re-exported library.
void setPath(StringRef Path_)
Set the path from which this file was generated (if applicable).
Definition InterfaceFile.h:115
LLVM_ABI void setFromBinaryAttrs(const RecordsSlice::BinaryAttrs &BA, const Target &Targ)
Set InterfaceFile properties from pre-gathered binary attributes, if they are not set already.
LLVM_ABI void addParentUmbrella(const Target &Target_, StringRef Parent)
Set the parent umbrella frameworks.
const_target_range targets() const
Definition InterfaceFile.h:171
void setOSLibNotForSharedCache(bool V=true)
Specify if the library is an OS library but not shared cache eligible.
Definition InterfaceFile.h:215
llvm::iterator_range< const_filtered_target_iterator > const_filtered_target_range
Definition InterfaceFile.h:176
bool isOSLibNotForSharedCache() const
Check if the library is an OS library that is not shared cache eligible.
Definition InterfaceFile.h:220
const_filtered_symbol_range reexports() const
Definition InterfaceFile.h:367
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > remove(Architecture Arch) const
Remove architecture slice from Interface.
void setObjCConstraint(ObjCConstraintType Constraint)
Set the Objective-C constraint.
Definition InterfaceFile.h:235
bool isTwoLevelNamespace() const
Check if the library uses two-level namespace.
Definition InterfaceFile.h:212
LLVM_ABI bool operator==(const InterfaceFile &O) const
The equality is determined by attributes that impact linking compatibilities.
PackedVersion getCompatibilityVersion() const
Get the compatibility version of the library.
Definition InterfaceFile.h:200
SymbolSet::const_symbol_range const_symbol_range
Definition InterfaceFile.h:362
size_t symbolsCount() const
Get size of symbol set.
Definition InterfaceFile.h:360
bool operator!=(const InterfaceFile &O) const
Definition InterfaceFile.h:419
llvm::iterator_range< const_target_iterator > const_target_range
Definition InterfaceFile.h:170
LLVM_ABI void addTarget(const Target &Target)
Set and add target.
const_filtered_symbol_range exports() const
Definition InterfaceFile.h:366
bool isApplicationExtensionSafe() const
Check if the library is application extension safe.
Definition InterfaceFile.h:226
void addSymbol(EncodeKind Kind, StringRef Name, TargetList &&Targets, SymbolFlags Flags=SymbolFlags::None)
Add Symbol with multiple targets.
Definition InterfaceFile.h:342
llvm::filter_iterator< const_target_iterator, std::function< bool(const Target &)> > const_filtered_target_iterator
Definition InterfaceFile.h:173
void setSimulatorSupport(bool V=true)
Specify if the library has simulator support.
Definition InterfaceFile.h:232
PlatformSet getPlatforms() const
Get the platforms.
Definition InterfaceFile.h:145
const std::vector< std::pair< Target, std::string > > & rpaths() const
Get the list of runpath search paths.
Definition InterfaceFile.h:311
const std::vector< InterfaceFileRef > & allowableClients() const
Get the list of allowable clients.
Definition InterfaceFile.h:270
void addSymbol(EncodeKind Kind, StringRef Name, RangeT &&Targets, SymbolFlags Flags=SymbolFlags::None)
Add a symbol to the symbols list or extend an existing one.
Definition InterfaceFile.h:331
void setInstallName(StringRef InstallName_)
Set the install name of the library.
Definition InterfaceFile.h:181
void addTargets(RangeT &&Targets)
Set and add targets.
Definition InterfaceFile.h:164
const std::vector< std::shared_ptr< InterfaceFile > > & documents() const
Get the list of inlined libraries.
Definition InterfaceFile.h:299
const std::vector< std::pair< Target, std::string > > & umbrellas() const
Get the list of Parent Umbrella frameworks.
Definition InterfaceFile.h:251
InterfaceFile(std::unique_ptr< SymbolSet > &&InputSymbols)
Definition InterfaceFile.h:108
const std::vector< InterfaceFileRef > & reexportedLibraries() const
Get the list of re-exported libraries.
Definition InterfaceFile.h:284
InterfaceFile * getParent() const
Returns the pointer to parent document if exists or nullptr otherwise.
Definition InterfaceFile.h:294
const_symbol_range symbols() const
Definition InterfaceFile.h:365
void setFileType(FileType Kind)
Set the file type.
Definition InterfaceFile.h:128
uint8_t getSwiftABIVersion() const
Get the Swift ABI version of the library.
Definition InterfaceFile.h:206
PackedVersion getCurrentVersion() const
Get the current version of the library.
Definition InterfaceFile.h:192
void addSymbol(EncodeKind Kind, StringRef Name, Target &Target, SymbolFlags Flags=SymbolFlags::None)
Add Symbol with single target.
Definition InterfaceFile.h:353
LLVM_ABI void addRPath(StringRef RPath, const Target &InputTarget)
Set the runpath search paths.
const_filtered_symbol_range undefineds() const
Definition InterfaceFile.h:370
void setCompatibilityVersion(PackedVersion Version)
Set the compatibility version of the library.
Definition InterfaceFile.h:195
ArchitectureSet getArchitectures() const
Get the architectures.
Definition InterfaceFile.h:138
StringRef getInstallName() const
Get the install name of the library.
Definition InterfaceFile.h:186
LLVM_ABI llvm::Expected< std::unique_ptr< InterfaceFile > > merge(const InterfaceFile *O) const
Merge Interfaces for the same library.
ObjCConstraintType getObjCConstraint() const
Get the Objective-C constraint.
Definition InterfaceFile.h:240
FileType getFileType() const
Get the file type.
Definition InterfaceFile.h:133
void setApplicationExtensionSafe(bool V=true)
Specify if the library is application extension safe (or not).
Definition InterfaceFile.h:223
LLVM_ABI void addAllowableClient(StringRef InstallName, const Target &Target)
Add an allowable client.
LLVM_ABI void inlineLibrary(std::shared_ptr< InterfaceFile > Library, bool Overwrite=false)
Inline reexported library into Interface.
bool hasTarget(const Target &Targ) const
Determine if target triple slice exists in file.
Definition InterfaceFile.h:155
void setSwiftABIVersion(uint8_t Version)
Set the Swift ABI version of the library.
Definition InterfaceFile.h:203
void setCurrentVersion(PackedVersion Version)
Set the current version of the library.
Definition InterfaceFile.h:189
TargetList::const_iterator const_target_iterator
Definition InterfaceFile.h:169
void setTwoLevelNamespace(bool V=true)
Specify if the library uses two-level namespace (or flat namespace).
Definition InterfaceFile.h:209
bool hasSimulatorSupport() const
Check if the library has simulator support.
Definition InterfaceFile.h:229
iterator_range< const_filtered_symbol_iterator > const_filtered_symbol_range
iterator_range< const_symbol_iterator > const_symbol_range
StringRef - Represent a constant reference to a string, i.e.
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
FileType
Defines the file type TextAPI files can represent.
@ Invalid
Invalid file type.
C::iterator addEntry(C &Container, StringRef InstallName)
Definition InterfaceFile.h:455
LLVM_ABI PlatformSet mapToPlatformSet(ArrayRef< Triple > Targets)
SmallSet< PlatformType, 3 > PlatformSet
ObjCConstraintType
Defines a list of Objective-C constraints.
Definition InterfaceFile.h:35
@ None
No constraint.
Definition InterfaceFile.h:37
@ Retain_Release_For_Simulator
Retain/Release for Simulator.
Definition InterfaceFile.h:43
@ GC
Garbage Collection.
Definition InterfaceFile.h:49
@ Retain_Release_Or_GC
Retain/Release or Garbage Collection.
Definition InterfaceFile.h:46
@ Retain_Release
Retain/Release.
Definition InterfaceFile.h:40
Architecture
Defines the architecture slices that are supported by Text-based Stub files.
ObjCIFSymbolKind
ObjC Interface symbol mappings.
EncodeKind
Mapping of entry types in TextStubs.
SmallVector< Target, 5 > TargetList
LLVM_ABI ArchitectureSet mapToArchitectureSet(ArrayRef< Target > Targets)
This is an optimization pass for GlobalISel generic memory operations.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
filter_iterator_impl< WrappedIteratorT, PredicateT, detail::fwd_or_bidi_tag< WrappedIteratorT > > filter_iterator
Defines filter_iterator to a suitable specialization of filter_iterator_impl, based on the underlying...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Implement std::hash so that hash_code can be used in STL containers.