Skip to content

Commit 27459a3

Browse files
committed
[TextAPI] Update missing enum cases & utility functions
* Expand understood `FileType`s that InterfaceFile class can represent. * Add `hasTarget` function. * Cleanup symbol `<` comparator to account for SymbolSet operations.
1 parent 33b00b4 commit 27459a3

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

llvm/include/llvm/TextAPI/InterfaceFile.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,31 @@ enum FileType : unsigned {
5555
/// Invalid file type.
5656
Invalid = 0U,
5757

58+
/// \brief MachO Dynamic Library file.
59+
MachO_DynamicLibrary = 1U << 0,
60+
61+
/// \brief MachO Dynamic Library Stub file.
62+
MachO_DynamicLibrary_Stub = 1U << 1,
63+
64+
/// \brief MachO Bundle file.
65+
MachO_Bundle = 1U << 2,
66+
5867
/// Text-based stub file (.tbd) version 1.0
59-
TBD_V1 = 1U << 0,
68+
TBD_V1 = 1U << 3,
6069

6170
/// Text-based stub file (.tbd) version 2.0
62-
TBD_V2 = 1U << 1,
71+
TBD_V2 = 1U << 4,
6372

6473
/// Text-based stub file (.tbd) version 3.0
65-
TBD_V3 = 1U << 2,
74+
TBD_V3 = 1U << 5,
6675

6776
/// Text-based stub file (.tbd) version 4.0
68-
TBD_V4 = 1U << 3,
77+
TBD_V4 = 1U << 6,
6978

7079
/// Text-based stub file (.tbd) version 5.0
71-
TBD_V5 = 1U << 4,
80+
TBD_V5 = 1U << 7,
7281

73-
All = ~0U,
82+
All = ~0U,
7483

7584
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/All),
7685
};
@@ -95,6 +104,10 @@ class InterfaceFileRef {
95104
addTarget(Target(Target));
96105
}
97106

107+
bool hasTarget(Target &Targ) const {
108+
return llvm::is_contained(Targets, Targ);
109+
}
110+
98111
using const_target_iterator = TargetList::const_iterator;
99112
using const_target_range = llvm::iterator_range<const_target_iterator>;
100113
const_target_range targets() const { return {Targets}; }
@@ -173,6 +186,13 @@ class InterfaceFile {
173186
/// \param Target the target to add into.
174187
void addTarget(const Target &Target);
175188

189+
/// Determine if target triple slice exists in file.
190+
///
191+
/// \param Target the value to find.
192+
bool hasTarget(const Target &Targ) const {
193+
return llvm::is_contained(Targets, Targ);
194+
}
195+
176196
/// Set and add targets.
177197
///
178198
/// Add the subset of llvm::triples that is supported by Tapi

llvm/include/llvm/TextAPI/Symbol.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class Symbol {
125125
return mapToArchitectureSet(Targets).contains(Arch);
126126
}
127127

128+
bool hasTarget(const Target &Targ) const {
129+
return llvm::is_contained(Targets, Targ);
130+
}
131+
128132
using const_target_iterator = TargetList::const_iterator;
129133
using const_target_range = llvm::iterator_range<const_target_iterator>;
130134
const_target_range targets() const { return {Targets}; }
@@ -146,8 +150,7 @@ class Symbol {
146150
bool operator!=(const Symbol &O) const { return !(*this == O); }
147151

148152
bool operator<(const Symbol &O) const {
149-
return std::tie(Name, Kind, Targets, Flags) <
150-
std::tie(O.Name, O.Kind, O.Targets, O.Flags);
153+
return std::tie(Kind, Name) < std::tie(O.Kind, O.Name);
151154
}
152155

153156
private:

llvm/lib/TextAPI/TextStub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ template <> struct MappingTraits<const InterfaceFile *> {
787787
NormalizedTBD_V4(IO &IO, const InterfaceFile *&File) {
788788
auto Ctx = reinterpret_cast<TextAPIContext *>(IO.getContext());
789789
assert(Ctx);
790-
TBDVersion = Ctx->FileKind >> 1;
790+
TBDVersion = Ctx->FileKind >> 4;
791791
Targets.insert(Targets.begin(), File->targets().begin(),
792792
File->targets().end());
793793
InstallName = File->getInstallName();

0 commit comments

Comments
 (0)