Skip to content

[Serialization] Enable deserialization safety by default #63116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace swift {

/// Enable early skipping deserialization of decls that are marked as
/// unsafe to read.
bool EnableDeserializationSafety = false;
bool EnableDeserializationSafety = true;

/// Whether to enable the new operator decl and precedencegroup lookup
/// behavior. This is a staging flag, and will be removed in the future.
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/type_layout_dumper_all.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/type_layout_dumper_other.swiftmodule -module-name=type_layout_dumper_other %S/Inputs/type_layout_dumper_other.swift

// RUN: %target-swift-frontend -dump-type-info -I %t %s | %FileCheck %s
// RUN: %target-swift-frontend -dump-type-info -I %t %s -disable-deserialization-safety | %FileCheck %s

// REQUIRES: CPU=x86_64
// REQUIRES: OS=macosx
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/type_layout_dumper_resilient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/type_layout_dumper_other.swiftmodule -module-name=type_layout_dumper_other %S/Inputs/type_layout_dumper_other.swift

// RUN: %target-swift-frontend -dump-type-info -type-info-dump-filter=resilient -I %t %s | %FileCheck %s
// RUN: %target-swift-frontend -dump-type-info -type-info-dump-filter=resilient -I %t %s -disable-deserialization-safety | %FileCheck %s

// REQUIRES: CPU=x86_64
// REQUIRES: OS=macosx
Expand Down
6 changes: 2 additions & 4 deletions test/Serialization/Safety/override-internal-func.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
// RUN: -emit-module-interface-path %t/Lib.swiftinterface

/// Build against the swiftmodule.
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
// RUN: -enable-deserialization-safety
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t

/// Build against the swiftinterface.
// RUN: rm %t/Lib.swiftmodule
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
// RUN: -enable-deserialization-safety
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t

//--- Lib.swift

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

/// Build client.
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
// RUN: -verify -Xllvm -debug-only=Serialization \
// RUN: -enable-deserialization-safety 2>&1 \
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \
// RUN: | %FileCheck --check-prefixes=SAFE %s

/// Decls skips by the deserialization safety logic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
// RUN: | %FileCheck --check-prefixes=NEEDED,UNSAFE %s

// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
// RUN: -verify -Xllvm -debug-only=Serialization \
// RUN: -enable-deserialization-safety 2>&1 \
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \
// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN,SAFE %s

/// Build against the swiftinterface.
Expand Down
5 changes: 1 addition & 4 deletions test/Serialization/Safety/unsafe-decls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@

// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-library-evolution -swift-version 5 \
// RUN: -enable-deserialization-safety \
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,SAFETY-INTERNAL %s

// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-library-evolution -swift-version 5 \
// RUN: -enable-deserialization-safety \
// RUN: -Xllvm -debug-only=Serialization \
// RUN: -enable-testing 2>&1 \
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,NO-SAFETY-INTERNAL-NOT %s

/// Don't mark decls as unsafe when private import is enabled.
// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-library-evolution -swift-version 5 \
// RUN: -enable-deserialization-safety \
// RUN: -Xllvm -debug-only=Serialization \
// RUN: -enable-private-imports 2>&1 \
// RUN: | %FileCheck --check-prefixes=DISABLED %s

/// Don't mark decls as unsafe without library evolution.
// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-deserialization-safety -swift-version 5 \
// RUN: -swift-version 5 \
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
// RUN: | %FileCheck --check-prefixes=DISABLED %s

Expand Down
5 changes: 1 addition & 4 deletions test/Serialization/Safety/unsafe-extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@

// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-library-evolution -swift-version 5 \
// RUN: -enable-deserialization-safety \
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,SAFETY-INTERNAL %s

// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-library-evolution -swift-version 5 \
// RUN: -enable-deserialization-safety \
// RUN: -Xllvm -debug-only=Serialization \
// RUN: -enable-testing 2>&1 \
// RUN: | %FileCheck --check-prefixes=SAFETY-PRIVATE,NO-SAFETY-INTERNAL %s

/// Don't mark decls as unsafe when private import is enabled.
// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-library-evolution -swift-version 5 \
// RUN: -enable-deserialization-safety \
// RUN: -Xllvm -debug-only=Serialization \
// RUN: -enable-private-imports 2>&1 \
// RUN: | %FileCheck --check-prefixes=DISABLED %s

/// Don't mark decls as unsafe without library evolution.
// RUN: %target-swift-frontend -emit-module %s \
// RUN: -enable-deserialization-safety -swift-version 5 \
// RUN: -swift-version 5 \
// RUN: -Xllvm -debug-only=Serialization 2>&1 \
// RUN: | %FileCheck --check-prefixes=DISABLED %s

Expand Down