mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
PrintAsClang is supposed to emit declarations in the same order regardless of the compiler’s internal state, but we have repeatedly found that our current criteria are inadequate, resulting in non-functionality-affecting changes to generated header content. Add a diagnostic that’s emitted when this happens soliciting a bug report. Since there *should* be no cases where the compiler fails to order declarations, this diagnostic is never actually emitted. Instead, we test this change by enabling `-verify` on nearly all PrintAsClang tests to make sure they are unaffected. This did demonstrate a missing criterion that only mattered in C++ mode: extensions that varied only in their generic signature were not sorted stably. Add a sort criterion for this.
48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %t/use-cxx-types.swift -module-name UseCxxTy -typecheck -verify -emit-clang-header-path %t/UseCxxTy.h -I %t -enable-experimental-cxx-interop -disable-availability-checking -Xcc -DSIMD_NO_CODE
|
|
|
|
// RUN: %FileCheck %s < %t/UseCxxTy.h
|
|
|
|
// FIXME: remove once https://github.com/apple/swift/pull/60971 lands.
|
|
// RUN: echo "#include \"header.h\"" > %t/full-cxx-swift-cxx-bridging.h
|
|
// RUN: cat %t/UseCxxTy.h >> %t/full-cxx-swift-cxx-bridging.h
|
|
|
|
// RUN: %check-interop-cxx-header-in-clang(%t/full-cxx-swift-cxx-bridging.h -Wno-reserved-identifier -DSIMD_NO_CODE)
|
|
|
|
// This is required to verify that `Struct` is returned and passed directly.
|
|
// REQUIRES: OS=macosx
|
|
// REQUIRES: PTRSIZE=64
|
|
|
|
//--- header.h
|
|
|
|
#include <simd.h>
|
|
|
|
using simd_float4x4 = float4x4;
|
|
|
|
//--- module.modulemap
|
|
module CxxTest {
|
|
header "header.h"
|
|
requires cplusplus
|
|
}
|
|
|
|
//--- use-cxx-types.swift
|
|
import CxxTest
|
|
|
|
public struct Struct {
|
|
private let transform: simd_float4x4
|
|
|
|
public init() {
|
|
transform = simd_float4x4()
|
|
}
|
|
}
|
|
|
|
public func passStruct(_ x : Struct) {
|
|
|
|
}
|
|
|
|
// CHECK: class SWIFT_SYMBOL("s:8UseCxxTy6StructV") Struct final {
|
|
// CHECK-NOT: init(
|
|
// CHECK: // Unavailable in C++: Swift global function 'passStruct(_:)'
|