Skip to content

Commit 62a6469

Browse files
committed
[Serialization] Move deserialization safety behind an env var or flag
1 parent 09b06a8 commit 62a6469

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ namespace swift {
366366

367367
/// Enable early skipping deserialization of decls that are marked as
368368
/// unsafe to read.
369-
bool EnableDeserializationSafety = false;
369+
bool EnableDeserializationSafety =
370+
::getenv("SWIFT_ENABLE_DESERIALIZATION_SAFETY");
370371

371372
/// Whether to enable the new operator decl and precedencegroup lookup
372373
/// behavior. This is a staging flag, and will be removed in the future.

test/Serialization/Safety/skip-reading-internal-details.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
// RUN: -enable-deserialization-safety 2>&1 \
2424
// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN,SAFE %s
2525

26+
/// Disabled by default.
27+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
28+
// RUN: -verify -Xllvm -debug-only=Serialization \
29+
// RUN: -disable-deserialization-safety 2>&1 \
30+
// RUN: | %FileCheck --check-prefixes=NEEDED,UNSAFE %s
31+
32+
/// Enable with env var.
33+
// RUN: env SWIFT_ENABLE_DESERIALIZATION_SAFETY=true \
34+
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
35+
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \
36+
// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN,SAFE %s
37+
2638
/// Build against the swiftinterface.
2739
// RUN: rm %t/Lib.swiftmodule
2840
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \

0 commit comments

Comments
 (0)