Skip to content

[ClangImporter] Don't expect unmodularized structs to appear in 2 modules #40091

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
Nov 15, 2021

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Nov 8, 2021

The clang fix at swiftlang/llvm-project#3497 implements better decl merging, this affects how unmodularized types are imported. This fix triggers an old test explicitly supporting unmodularized code. We believe this test should be updated as the new behavior will prevent possible miscompilations.

We should add an expected error here once the clang fix lands, until them just makes sure the test works both with and without the clang fix.

@xymus xymus requested review from vsapsai and beccadax November 8, 2021 20:56
@xymus
Copy link
Contributor Author

xymus commented Nov 8, 2021

Let's test with the clang fix first.

swiftlang/llvm-project#3497

@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Nov 8, 2021

@swift-ci Please smoke test

Copy link
Contributor

@beccadax beccadax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble reasoning about this change. What will the test eventually look like once we're relying on the clang change?

@xymus
Copy link
Contributor Author

xymus commented Nov 10, 2021

With the clang fix the test should be updated with the following for both importation order.

let viaStruct: Redeclaration.FooStruct1 = AppKit.FooStruct1() // expected-error {{module 'AppKit' has no member named 'FooStruct1'}}

The type FooStruct1 is defined in both modules in a unmodular fashion and clang will merge them. It's not ideal as it does break some clients relying on poorly modularized code but it prevents miscompiles that have been previously observed.

@beccadax
Copy link
Contributor

I think it'd be better to leave the code unchanged and add a modified version of the error expectation:

expected-error * {{module 'AppKit' has no member named 'FooStruct1'}}

Along with a comment explaining that the "*" is transitional (and maybe referencing a relevant bug). That will accept either behavior for now.

@xymus xymus force-pushed the twice-the-imported-struct branch from eb72e77 to c8c3f9b Compare November 12, 2021 20:44
@xymus
Copy link
Contributor Author

xymus commented Nov 12, 2021

That makes sense, thank you @beccadax for the suggestions. I've applied the changes, testing again.

swiftlang/llvm-project#3497
@swift-ci Please smoke test

@xymus
Copy link
Contributor Author

xymus commented Nov 12, 2021

The swift-corelibs-foundation failure on Linux is expected with the clang fix.

@swift-ci Please smoke test

@xymus xymus requested a review from beccadax November 12, 2021 23:42
@xymus xymus merged commit 008317b into swiftlang:main Nov 15, 2021
@xymus xymus deleted the twice-the-imported-struct branch November 15, 2021 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants