diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2019-10-08 15:07:36 +0000 |
---|---|---|
committer | Cyndy Ishida <cyndy_ishida@apple.com> | 2019-10-08 15:07:36 +0000 |
commit | 5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a (patch) | |
tree | 970df30c81781ed512b1c3ff3d9850ff8fb3e372 /llvm/lib/TextAPI/MachO/TextStubCommon.cpp | |
parent | 6b06ead19be79fd6e2d2abdda4c4cbb7c8f3c7c0 (diff) | |
download | llvm-5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a.zip llvm-5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a.tar.gz llvm-5d566c5a46aeaa1fa0e5c0b823c9d5f84036dc9a.tar.bz2 |
[TextAPI] Introduce TBDv4
Summary:
This format introduces new features and platforms
The motivation for this format is to support more than 1 platform since previous versions only supported additional architectures and 1 platform,
for example ios + ios-simulator and macCatalyst.
Reviewers: ributzka, steven_wu
Reviewed By: ributzka
Subscribers: mgorny, hiraditya, mgrang, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67529
llvm-svn: 374058
Diffstat (limited to 'llvm/lib/TextAPI/MachO/TextStubCommon.cpp')
-rw-r--r-- | llvm/lib/TextAPI/MachO/TextStubCommon.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp index cfd9ac8..183c5d5 100644 --- a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp +++ b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp @@ -172,14 +172,25 @@ void ScalarTraits<SwiftVersion>::output(const SwiftVersion &Value, void *, break; } } -StringRef ScalarTraits<SwiftVersion>::input(StringRef Scalar, void *, +StringRef ScalarTraits<SwiftVersion>::input(StringRef Scalar, void *IO, SwiftVersion &Value) { - Value = StringSwitch<SwiftVersion>(Scalar) - .Case("1.0", 1) - .Case("1.1", 2) - .Case("2.0", 3) - .Case("3.0", 4) - .Default(0); + const auto *Ctx = reinterpret_cast<TextAPIContext *>(IO); + assert((!Ctx || Ctx->FileKind != FileType::Invalid) && + "File type is not set in context"); + + if (Ctx->FileKind == FileType::TBD_V4) { + if (Scalar.getAsInteger(10, Value)) + return "invalid Swift ABI version."; + return {}; + } else { + Value = StringSwitch<SwiftVersion>(Scalar) + .Case("1.0", 1) + .Case("1.1", 2) + .Case("2.0", 3) + .Case("3.0", 4) + .Default(0); + } + if (Value != SwiftVersion(0)) return {}; |