[Basic][Serialization] Intro and use isCurrentCompilerTagged

This commit is contained in:
Alexis Laferrière
2022-05-17 13:17:33 -07:00
parent 3523adbb53
commit c341010fbd
3 changed files with 15 additions and 2 deletions

View File

@@ -184,6 +184,11 @@ std::string getSwiftFullVersion(Version effectiveLanguageVersion =
/// this Swift was built.
StringRef getSwiftRevision();
/// Is the running compiler built with a version tag for distribution?
/// When true, \c Version::getCurrentCompilerVersion returns a valid version
/// and \c getSwiftRevision returns the version tuple in string format.
bool isCurrentCompilerTagged();
} // end namespace version
} // end namespace swift

View File

@@ -446,5 +446,13 @@ StringRef getSwiftRevision() {
#endif
}
bool isCurrentCompilerTagged() {
#ifdef SWIFT_COMPILER_VERSION
return true;
#else
return false;
#endif
}
} // end namespace version
} // end namespace swift

View File

@@ -313,7 +313,7 @@ static ValidationInfo validateControlBlock(
// env var is set (for testing).
static const char* forceDebugPreSDKRestriction =
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_PER_SDK");
if (version::Version::getCurrentCompilerVersion().empty() &&
if (!version::isCurrentCompilerTagged() &&
!forceDebugPreSDKRestriction) {
break;
}
@@ -354,7 +354,7 @@ static ValidationInfo validateControlBlock(
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_REVISION");
bool isCompilerTagged = forcedDebugRevision ||
!version::Version::getCurrentCompilerVersion().empty();
version::isCurrentCompilerTagged();
StringRef moduleRevision = blobData;
if (isCompilerTagged) {