Skip to content

Update Swift-side tests for Clang providing an unversioned SwiftName. #9414

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
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
12 changes: 6 additions & 6 deletions lib/IDE/ModuleInterfacePrinting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ void swift::ide::printSubmoduleInterface(

// Sort imported declarations in source order *within a submodule*.
for (auto &P : ClangDecls) {
std::sort(P.second.begin(), P.second.end(),
[&](std::pair<Decl *, clang::SourceLocation> LHS,
std::pair<Decl *, clang::SourceLocation> RHS) -> bool {
return ClangSourceManager.isBeforeInTranslationUnit(LHS.second,
RHS.second);
});
std::stable_sort(P.second.begin(), P.second.end(),
[&](std::pair<Decl *, clang::SourceLocation> LHS,
std::pair<Decl *, clang::SourceLocation> RHS) -> bool {
return ClangSourceManager.isBeforeInTranslationUnit(LHS.second,
RHS.second);
});
}

// Sort Swift declarations so that we print them in a consistent order.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ SwiftVersions:
- Name: acceptDoublePointer
SwiftName: 'acceptPointer(_:)'
Nullability: [ O ]
- Name: normallyUnchanged
SwiftName: normallyUnchangedButChangedInSwift3()
- Name: normallyChangedOriginal
SwiftName: normallyChangedButSpecialInSwift3()
Tags:
- Name: SomeCStruct
SwiftName: ImportantCStruct
- Name: InnerInSwift4
SwiftName: InnerInSwift4
- Name: NormallyUnchangedWrapper
SwiftName: NormallyUnchangedButChangedInSwift3Wrapper
- Name: NormallyChangedOriginalWrapper
SwiftName: NormallyChangedButSpecialInSwift3Wrapper
Typedefs:
- Name: SomeCAlias
SwiftName: ImportantCAlias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ void acceptDoublePointer(double* _Nonnull ptr) __attribute__((swift_name("accept

void oldAcceptDoublePointer(double* _Nonnull ptr) __attribute__((availability(swift, unavailable, replacement="acceptDoublePointer")));

void normallyUnchanged(void);
void normallyChangedOriginal(void) __attribute__((swift_name("normallyChanged()")));

#ifdef __OBJC__

__attribute__((objc_root_class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ struct __attribute__((swift_name("VeryImportantCStruct"))) SomeCStruct {

typedef int __attribute__((swift_name("VeryImportantCAlias"))) SomeCAlias;

struct NormallyUnchangedWrapper {
int value;
};
struct NormallyChangedOriginalWrapper{
int value;
} __attribute__((swift_name("NormallyChangedWrapper")));

#pragma clang assume_nonnull end
8 changes: 4 additions & 4 deletions test/APINotes/versioned-objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ func testNonGeneric() {
}

func testRenamedGeneric() {
// CHECK-DIAGS-3:[[@LINE+1]]:{{[0-9]+}}: error: 'RenamedGeneric' has been renamed to 'OldRenamedGeneric'
// CHECK-DIAGS-3-NOT: 'RenamedGeneric' has been renamed to 'OldRenamedGeneric'
let _: OldRenamedGeneric<Base> = RenamedGeneric<Base>()
// CHECK-DIAGS-4:[[@LINE-1]]:{{[0-9]+}}: error: 'OldRenamedGeneric' has been renamed to 'RenamedGeneric'

// CHECK-DIAGS-3:[[@LINE+1]]:{{[0-9]+}}: error: 'RenamedGeneric' has been renamed to 'OldRenamedGeneric'
// CHECK-DIAGS-3-NOT: 'RenamedGeneric' has been renamed to 'OldRenamedGeneric'
let _: RenamedGeneric<Base> = OldRenamedGeneric<Base>()
// CHECK-DIAGS-4:[[@LINE-1]]:{{[0-9]+}}: error: 'OldRenamedGeneric' has been renamed to 'RenamedGeneric'

class SwiftClass {}

// CHECK-DIAGS-3:[[@LINE+1]]:{{[0-9]+}}: error: 'OldRenamedGeneric' requires that 'SwiftClass' inherit from 'Base'
// CHECK-DIAGS-3:[[@LINE+1]]:{{[0-9]+}}: error: 'RenamedGeneric' requires that 'SwiftClass' inherit from 'Base'
let _: OldRenamedGeneric<SwiftClass> = RenamedGeneric<SwiftClass>()
// CHECK-DIAGS-4:[[@LINE-1]]:{{[0-9]+}}: error: 'RenamedGeneric' requires that 'SwiftClass' inherit from 'Base'

// CHECK-DIAGS-3:[[@LINE+1]]:{{[0-9]+}}: error: 'OldRenamedGeneric' requires that 'SwiftClass' inherit from 'Base'
// CHECK-DIAGS-3:[[@LINE+1]]:{{[0-9]+}}: error: 'RenamedGeneric' requires that 'SwiftClass' inherit from 'Base'
let _: RenamedGeneric<SwiftClass> = OldRenamedGeneric<SwiftClass>()
// CHECK-DIAGS-4:[[@LINE-1]]:{{[0-9]+}}: error: 'RenamedGeneric' requires that 'SwiftClass' inherit from 'Base'
}
Expand Down
36 changes: 36 additions & 0 deletions test/APINotes/versioned.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@
// CHECK-SWIFT-4: func accept(_ ptr: UnsafeMutablePointer<Double>)
// CHECK-SWIFT-3: func acceptPointer(_ ptr: UnsafeMutablePointer<Double>?)

// CHECK-SWIFT-4: func normallyUnchanged()
// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "normallyUnchanged()")
// CHECK-SWIFT-4-NEXT: func normallyUnchangedButChangedInSwift3()
// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "normallyUnchangedButChangedInSwift3()")
// CHECK-SWIFT-3-NEXT: func normallyUnchanged()
// CHECK-SWIFT-3: func normallyUnchangedButChangedInSwift3()


// CHECK-SWIFT-4: func normallyChanged()
// CHECK-SWIFT-4-NEXT: @available(swift, obsoleted: 4, renamed: "normallyChanged()")
// CHECK-SWIFT-4-NEXT: func normallyChangedButSpecialInSwift3()
// CHECK-SWIFT-4-NEXT: @available(swift, obsoleted: 3, renamed: "normallyChanged()")
// CHECK-SWIFT-4-NEXT: func normallyChangedOriginal()
// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "normallyChangedButSpecialInSwift3()")
// CHECK-SWIFT-3-NEXT: func normallyChanged()
// CHECK-SWIFT-3-NEXT: func normallyChangedButSpecialInSwift3()
// CHECK-SWIFT-3-NEXT: @available(swift, obsoleted: 3, renamed: "normallyChangedButSpecialInSwift3()")
// CHECK-SWIFT-3-NEXT: func normallyChangedOriginal()

// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "NormallyUnchangedWrapper")
// CHECK-SWIFT-4-NEXT: typealias NormallyUnchangedButChangedInSwift3Wrapper = NormallyUnchangedWrapper
// CHECK-SWIFT-4: struct NormallyUnchangedWrapper {
// CHECK-SWIFT-3: typealias NormallyUnchangedButChangedInSwift3Wrapper = NormallyUnchangedWrapper
// CHECK-SWIFT-3-NEXT: struct NormallyUnchangedWrapper {

// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "NormallyChangedWrapper")
// CHECK-SWIFT-4-NEXT: typealias NormallyChangedButSpecialInSwift3Wrapper = NormallyChangedWrapper
// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "NormallyChangedWrapper")
// CHECK-SWIFT-4-NEXT: typealias NormallyChangedOriginalWrapper = NormallyChangedWrapper
// CHECK-SWIFT-4: struct NormallyChangedWrapper {
// CHECK-SWIFT-3: typealias NormallyChangedButSpecialInSwift3Wrapper = NormallyChangedWrapper
// CHECK-SWIFT-3-NEXT: @available(swift, obsoleted: 3, renamed: "NormallyChangedButSpecialInSwift3Wrapper")
// CHECK-SWIFT-3-NEXT: typealias NormallyChangedOriginalWrapper = NormallyChangedButSpecialInSwift3Wrapper
// CHECK-SWIFT-3-NEXT: struct NormallyChangedWrapper {


// RUN: not %target-swift-frontend -typecheck -F %S/Inputs/custom-frameworks -swift-version 4 %s 2>&1 | %FileCheck -check-prefix=CHECK-DIAGS -check-prefix=CHECK-DIAGS-4 %s
// RUN: not %target-swift-frontend -typecheck -F %S/Inputs/custom-frameworks -swift-version 3 %s 2>&1 | %FileCheck -check-prefix=CHECK-DIAGS -check-prefix=CHECK-DIAGS-3 %s

Expand Down
6 changes: 3 additions & 3 deletions test/ClangImporter/Inputs/SwiftPrivateAttr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ struct NSOptions : OptionSet {
static var __PrivA: NSOptions { get }
static var B: NSOptions { get }
}
@available(swift, obsoleted: 3, renamed: "__PrivCFType")
typealias __PrivCFTypeRef = __PrivCFType
class __PrivCFType : _CFObject {
}
@available(swift, obsoleted: 3, renamed: "__PrivCFType")
typealias __PrivCFTypeRef = __PrivCFType
typealias __PrivCFSub = __PrivCFType
@available(swift, obsoleted: 3, renamed: "__PrivCFSub")
typealias __PrivCFSubRef = __PrivCFSub
typealias __PrivCFSub = __PrivCFType
typealias __PrivInt = Int32