Skip to content

Commit 47c3114

Browse files
committed
[Basic][Serialization] Intro and use isCurrentCompilerTagged
1 parent 091bbf2 commit 47c3114

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

include/swift/Basic/Version.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ std::string getSwiftFullVersion(Version effectiveLanguageVersion =
184184
/// this Swift was built.
185185
StringRef getSwiftRevision();
186186

187+
/// Is the running compiler built with a version tag for distribution?
188+
/// When true, \c Version::getCurrentCompilerVersion returns a valid version
189+
/// and \c getSwiftRevision returns the version tuple in string format.
190+
bool isCurrentCompilerTagged();
191+
187192
} // end namespace version
188193
} // end namespace swift
189194

lib/Basic/Version.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,5 +446,13 @@ StringRef getSwiftRevision() {
446446
#endif
447447
}
448448

449+
bool isCurrentCompilerTagged() {
450+
#ifdef SWIFT_COMPILER_VERSION
451+
return true;
452+
#else
453+
return false;
454+
#endif
455+
}
456+
449457
} // end namespace version
450458
} // end namespace swift

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static ValidationInfo validateControlBlock(
313313
// env var is set (for testing).
314314
static const char* forceDebugPreSDKRestriction =
315315
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_PER_SDK");
316-
if (version::Version::getCurrentCompilerVersion().empty() &&
316+
if (!version::isCurrentCompilerTagged() &&
317317
!forceDebugPreSDKRestriction) {
318318
break;
319319
}
@@ -354,7 +354,7 @@ static ValidationInfo validateControlBlock(
354354
::getenv("SWIFT_DEBUG_FORCE_SWIFTMODULE_REVISION");
355355

356356
bool isCompilerTagged = forcedDebugRevision ||
357-
!version::Version::getCurrentCompilerVersion().empty();
357+
version::isCurrentCompilerTagged();
358358

359359
StringRef moduleRevision = blobData;
360360
if (isCompilerTagged) {

0 commit comments

Comments
 (0)