Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 1d2cdfe

Browse files
committed
Reland "[TextAPI] Introduce TBDv4"
Original Patch broke for compilations w/ gcc and exposed asan fail. This reland repairs those bugs. Differential Revision: https://reviews.llvm.org/D67529 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374277 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 910a8c5 commit 1d2cdfe

File tree

8 files changed

+1104
-34
lines changed

8 files changed

+1104
-34
lines changed

include/llvm/TextAPI/MachO/InterfaceFile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ enum FileType : unsigned {
6767
/// Text-based stub file (.tbd) version 3.0
6868
TBD_V3 = 1U << 2,
6969

70+
/// Text-based stub file (.tbd) version 4.0
71+
TBD_V4 = 1U << 3,
72+
7073
All = ~0U,
7174

7275
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/All),

include/llvm/TextAPI/MachO/Symbol.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ enum class SymbolFlags : uint8_t {
3838
/// Undefined
3939
Undefined = 1U << 3,
4040

41-
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Undefined),
41+
/// Rexported
42+
Rexported = 1U << 4,
43+
44+
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Rexported),
4245
};
4346

4447
// clang-format on
@@ -50,7 +53,7 @@ enum class SymbolKind : uint8_t {
5053
ObjectiveCInstanceVariable,
5154
};
5255

53-
using TargetList = SmallVector<Target, 20>;
56+
using TargetList = SmallVector<Target, 5>;
5457
class Symbol {
5558
public:
5659
Symbol(SymbolKind Kind, StringRef Name, TargetList Targets, SymbolFlags Flags)
@@ -81,6 +84,10 @@ class Symbol {
8184
return (Flags & SymbolFlags::Undefined) == SymbolFlags::Undefined;
8285
}
8386

87+
bool isReexported() const {
88+
return (Flags & SymbolFlags::Rexported) == SymbolFlags::Rexported;
89+
}
90+
8491
using const_target_iterator = TargetList::const_iterator;
8592
using const_target_range = llvm::iterator_range<const_target_iterator>;
8693
const_target_range targets() const { return {Targets}; }

include/llvm/TextAPI/MachO/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class Target {
2929
explicit Target(const llvm::Triple &Triple)
3030
: Arch(mapToArchitecture(Triple)), Platform(mapToPlatformKind(Triple)) {}
3131

32+
static llvm::Expected<Target> create(StringRef Target);
33+
3234
operator std::string() const;
3335

3436
Architecture Arch;

lib/TextAPI/MachO/Target.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,36 @@
1717
namespace llvm {
1818
namespace MachO {
1919

20+
Expected<Target> Target::create(StringRef TargetValue) {
21+
auto Result = TargetValue.split('-');
22+
auto ArchitectureStr = Result.first;
23+
auto Architecture = getArchitectureFromName(ArchitectureStr);
24+
auto PlatformStr = Result.second;
25+
PlatformKind Platform;
26+
Platform = StringSwitch<PlatformKind>(PlatformStr)
27+
.Case("macos", PlatformKind::macOS)
28+
.Case("ios", PlatformKind::iOS)
29+
.Case("tvos", PlatformKind::tvOS)
30+
.Case("watchos", PlatformKind::watchOS)
31+
.Case("bridgeos", PlatformKind::bridgeOS)
32+
.Case("maccatalyst", PlatformKind::macCatalyst)
33+
.Case("ios-simulator", PlatformKind::iOSSimulator)
34+
.Case("tvos-simulator", PlatformKind::tvOSSimulator)
35+
.Case("watchos-simulator", PlatformKind::watchOSSimulator)
36+
.Default(PlatformKind::unknown);
37+
38+
if (Platform == PlatformKind::unknown) {
39+
if (PlatformStr.startswith("<") && PlatformStr.endswith(">")) {
40+
PlatformStr = PlatformStr.drop_front().drop_back();
41+
unsigned long long RawValue;
42+
if (!PlatformStr.getAsInteger(10, RawValue))
43+
Platform = (PlatformKind)RawValue;
44+
}
45+
}
46+
47+
return Target{Architecture, Platform};
48+
}
49+
2050
Target::operator std::string() const {
2151
return (getArchitectureName(Arch) + " (" + getPlatformName(Platform) + ")")
2252
.str();
@@ -42,4 +72,4 @@ ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets) {
4272
}
4373

4474
} // end namespace MachO.
45-
} // end namespace llvm.
75+
} // end namespace llvm.

0 commit comments

Comments
 (0)