Skip to content

Add a test case for AST verification of loaded modules in WMO. #14278

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 1 commit into from
Jan 31, 2018
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: 2 additions & 0 deletions validation-test/Sema/Inputs/rdar36801676.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Cocoa
extension Notification.Name {}
1 change: 1 addition & 0 deletions validation-test/Sema/Inputs/rdar36801676_empty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Empty swift source file.
26 changes: 26 additions & 0 deletions validation-test/Sema/wmo_verify_loaded.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: %target-swift-frontend -swift-version 4 -emit-module -o %t/rdar36801676.swiftmodule %S/Inputs/rdar36801676.swift
// RUN: %target-swift-frontend -swift-version 4 -emit-silgen -enable-objc-interop -I %t -emit-silgen %S/Inputs/rdar36801676_empty.swift %s | %FileCheck %s
// REQUIRES: OS=macosx

// If AST loaded module verification is run after type checking the empty source
// file (rdar36801676_empty.swift), but before type checking this source file,
// then the importer caches the declaration for PasteboardType's constructor
// without synthesizing it's body. Eventually, the SILVerifier will raise a linkage error:
// SIL verification failed: external declarations of SILFunctions with shared
// visibility is not allowed: SingleFunction ||
// !hasSharedVisibility(RefF->getLinkage()) || RefF->hasForeignBody()

import Cocoa
import rdar36801676

let objCSynthesizedEnum = NSPasteboard.PasteboardType(rawValue: "MyPboardType")
extension Notification.Name {}

// NSPasteboardType.init(rawValue:)
// - just make sure it has a body.
// CHECK-LABEL: sil shared [transparent] [serializable] @$SSo16NSPasteboardTypea8rawValueABSS_tcfC : $@convention(method) (@owned String, @thin NSPasteboard.PasteboardType.Type) -> @owned NSPasteboard.PasteboardType {
// CHECK: bb0(%0 : $String, %1 : $@thin NSPasteboard.PasteboardType.Type):
// CHECK: return %{{.*}} : $NSPasteboard.PasteboardType
// CHECK-LABEL: } // end sil function '$SSo16NSPasteboardTypea8rawValueABSS_tcfC'