mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] When crashing, note if mix-and-match may be to blame.
That is, a Swift 3 target imported into a Swift 4 context or vice versa. This requires serializing the compatibility mode explicitly, instead of including it in the textual version string that's only for debugging.
This commit is contained in:
@@ -709,10 +709,14 @@ void Serializer::writeHeader(const SerializationOptions &options) {
|
||||
llvm::raw_svector_ostream versionString(versionStringBuf);
|
||||
versionString << Version::getCurrentLanguageVersion();
|
||||
size_t shortVersionStringLength = versionString.tell();
|
||||
versionString << '/' << version::getSwiftFullVersion(
|
||||
M->getASTContext().LangOpts.EffectiveLanguageVersion);
|
||||
versionString << '('
|
||||
<< M->getASTContext().LangOpts.EffectiveLanguageVersion;
|
||||
size_t compatibilityVersionStringLength =
|
||||
versionString.tell() - shortVersionStringLength - 1;
|
||||
versionString << ")/" << version::getSwiftFullVersion();
|
||||
Metadata.emit(ScratchRecord,
|
||||
VERSION_MAJOR, VERSION_MINOR, shortVersionStringLength,
|
||||
compatibilityVersionStringLength,
|
||||
versionString.str());
|
||||
|
||||
Target.emit(ScratchRecord, M->getASTContext().LangOpts.Target.str());
|
||||
@@ -772,7 +776,7 @@ void Serializer::writeDocHeader() {
|
||||
auto& LangOpts = M->getASTContext().LangOpts;
|
||||
Metadata.emit(ScratchRecord,
|
||||
VERSION_MAJOR, VERSION_MINOR,
|
||||
/*short version string length*/0,
|
||||
/*short version string length*/0, /*compatibility length*/0,
|
||||
version::getSwiftFullVersion(
|
||||
LangOpts.EffectiveLanguageVersion));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user