diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2019-10-10 04:24:44 +0000 |
---|---|---|
committer | Cyndy Ishida <cyndy_ishida@apple.com> | 2019-10-10 04:24:44 +0000 |
commit | f9d8162b573df0765b22927da779537b132365c9 (patch) | |
tree | 930ffa6248d8e39d38ba6a24ac41479f635548c0 /llvm/lib/TextAPI/MachO/TextStubCommon.cpp | |
parent | c752f5bce4cc524c9b808272ed9c7da67db61938 (diff) | |
download | llvm-f9d8162b573df0765b22927da779537b132365c9.zip llvm-f9d8162b573df0765b22927da779537b132365c9.tar.gz llvm-f9d8162b573df0765b22927da779537b132365c9.tar.bz2 |
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
llvm-svn: 374277
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 {}; |