-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Serialization] Prepare the infrastructure for the deserialization safety feature #62886
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c76dab7
[Serialization] Debug print decls being read
xymus d1343c8
[Frontend] Intro flags to control deserialization safety
xymus 940b7d9
[Tools] Explicitly disable deserialization safety in some testing tools
xymus 2c508d9
[Serialization] Intro the DESERIALIZATION_SAFETY record format
xymus 294b5d0
[Serialization] Raise an error (to recover from) when reading an unsa…
xymus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: split-file %s %t | ||
|
||
// REQUIRES: asserts | ||
|
||
// RUN: %target-swift-frontend -emit-module %t/HiddenLib.swift \ | ||
// RUN: -enable-library-evolution \ | ||
// RUN: -emit-module-path %t/HiddenLib.swiftmodule | ||
|
||
// RUN: %target-swift-frontend -emit-module %t/Lib.swift -I %t \ | ||
// RUN: -enable-library-evolution \ | ||
// RUN: -emit-module-path %t/Lib.swiftmodule \ | ||
// RUN: -emit-module-interface-path %t/Lib.swiftinterface | ||
|
||
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ | ||
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \ | ||
// RUN: | %FileCheck --check-prefixes=NEEDED,UNSAFE %s | ||
|
||
// RUN: rm %t/Lib.swiftmodule | ||
|
||
// RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \ | ||
// RUN: -verify -Xllvm -debug-only=Serialization 2>&1 \ | ||
// RUN: | %FileCheck --check-prefixes=NEEDED,CLEAN %s | ||
|
||
/// Decls part of the API needed by the client. | ||
// NEEDED-NOT: Deserialized: 'refToIOI()' | ||
// NEEDED: Deserialized: 'PublicStruct' | ||
// NEEDED: Deserialized: 'publicFunc()' | ||
|
||
/// Internal details dangerous to load. | ||
// UNSAFE: Deserialized: 'internalFunc()' | ||
// UNSAFE: Deserialized: 'privateFunc()' | ||
// UNSAFE: Deserialized: 'fileprivateFunc()' | ||
|
||
/// Decls removed by rebuilding from the swiftinterface. | ||
// CLEAN-NOT: Deserialized: 'internalFunc()' | ||
// CLEAN-NOT: Deserialized: 'privateFunc()' | ||
// CLEAN-NOT: Deserialized: 'fileprivateFunc()' | ||
|
||
//--- HiddenLib.swift | ||
|
||
public struct HiddenStruct { | ||
public init() {} | ||
} | ||
|
||
//--- Lib.swift | ||
|
||
@_implementationOnly import HiddenLib | ||
|
||
public class PublicStruct { | ||
public init() {} | ||
|
||
public func publicFunc() {} | ||
internal func internalFunc() {} | ||
private func privateFunc() {} | ||
fileprivate func fileprivateFunc() {} | ||
|
||
internal func refToIOI() -> HiddenStruct { | ||
return HiddenStruct(); | ||
} | ||
} | ||
|
||
//--- Client.swift | ||
|
||
import Lib | ||
|
||
var x = PublicStruct() | ||
|
||
// Trigger a typo correction that reads all members. | ||
x.notAMember() // expected-error {{value of type 'PublicStruct' has no member 'notAMember'}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this isn't actually true since we need it enabled in order to have
EnableDeserializationSafety
work. Plus at the very least LLDB would like want this regardless.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, thanks for pointing it out, it should say
This flag should only be disabled in testing.
. We always want this enabled unless we want to cause a crash.