mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +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.
84 lines
2.0 KiB
Swift
84 lines
2.0 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %target-swift-frontend %t/TestFmSwift.swift -module-name TestFm -enable-experimental-cxx-interop -typecheck -verify -emit-clang-header-path %t/TestFm.framework/Headers/TestFm-Swift.h
|
|
|
|
// RUN: %target-swift-frontend %t/SecondSwift.swift -module-name Second -enable-experimental-cxx-interop -typecheck -verify -emit-clang-header-path %t/Second.framework/Headers/Second-Swift.h
|
|
|
|
// RUN: %target-interop-build-clangxx -std=gnu++17 -fmodules -fcxx-modules -c %t/consumer.cpp -F %t -fsyntax-only -Werror=non-modular-include-in-framework-module
|
|
|
|
// Check that a client C++ file can use Swift stdlib APIs from two
|
|
// mixed-language C++ and Swift frameworks.
|
|
|
|
// This will only pass on Darwin with -Werror=non-modular-include-in-framework-module,
|
|
// as the SDK is not modularized on other platforms.
|
|
// REQUIRES: OS=macosx
|
|
|
|
//--- TestFm.framework/Headers/TestFm.h
|
|
#pragma once
|
|
|
|
class CxxClass {
|
|
public:
|
|
int testMethod() const {
|
|
return 42;
|
|
}
|
|
};
|
|
|
|
//--- TestFm.framework/Modules/module.modulemap
|
|
framework module TestFm {
|
|
umbrella header "TestFm.h"
|
|
|
|
export *
|
|
module * { export * }
|
|
}
|
|
|
|
module TestFm.Swift {
|
|
header "TestFm-Swift.h"
|
|
}
|
|
|
|
//--- TestFmSwift.swift
|
|
|
|
public func testSwiftFunc() -> String {
|
|
return ""
|
|
}
|
|
|
|
//--- Second.framework/Headers/Second.h
|
|
#pragma once
|
|
|
|
class CxxSecondClass {
|
|
public:
|
|
int testMethodTwo() const {
|
|
return 42;
|
|
}
|
|
};
|
|
|
|
//--- Second.framework/Modules/module.modulemap
|
|
framework module Second {
|
|
umbrella header "Second.h"
|
|
|
|
export *
|
|
module * { export * }
|
|
}
|
|
|
|
module Second.Swift {
|
|
header "Second-Swift.h"
|
|
}
|
|
|
|
//--- SecondSwift.swift
|
|
|
|
public func testSwiftFuncTwo() -> String {
|
|
return ""
|
|
}
|
|
|
|
//--- consumer.cpp
|
|
|
|
#pragma clang module import TestFm
|
|
#pragma clang module import Second
|
|
|
|
void testUseSwiftStdlibAPIsFromTwoFrameworksImportedViaModules() {
|
|
auto swiftString = TestFm::testSwiftFunc();
|
|
auto c1 = swiftString.getCount();
|
|
auto swiftString2 = Second::testSwiftFuncTwo();
|
|
auto c2 = swiftString.getCount();
|
|
}
|