summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/TextAPI/MachO/TextStubCommon.cpp')
-rw-r--r--llvm/lib/TextAPI/MachO/TextStubCommon.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/llvm/lib/TextAPI/MachO/TextStubCommon.cpp
index cfd9ac8d0cf..183c5d5a93b 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 {};
OpenPOWER on IntegriCloud