Skip to content

[Modules] Handle tag types and complain about bad merges in C/Objective-C mode #542

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 9, 2020
Merged

[Modules] Handle tag types and complain about bad merges in C/Objective-C mode #542

merged 1 commit into from
Jan 9, 2020

Conversation

bcardosolopes
Copy link

@bcardosolopes bcardosolopes commented Jan 9, 2020

Summary:
Take struct Z {...} defined differently and imported from both modules
X and Y. While in C/ObjC mode, clang used to pick one of the definitions
and ignore the other even though they might not be structurally
equivalent.

  • Instead of using the structural equivalence code for checking
    compatibility, use the ODR hash mechanism. This should significantly
    speed up the checks.
  • Hook the necessary name lookup bits to allow this logic in C.
  • Teach diagnoseOdrViolations to check the differences.

Instead of silently compiling, clang now emits:

In module 'Y' imported from t.m:2:
./y.h:3:10: error: 'Z::m' from module 'Y' is not present in definition
of 'struct Z' in module 'X'
  double m;
         ^
./x.h:3:7: note: declaration of 'm' does not match
  int m;
      ^

rdar://problem/56764293

Reviewers: rsmith, arphaman, vsapsai, martong, jdoerfert

Subscribers: rnkovacs, jkorous, dexonsmith, ributzka, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71734

Summary:
Take `struct Z {...}` defined differently and imported from both modules
X and Y. While in C/ObjC mode, clang used to pick one of the definitions
and ignore the other even though they might not be structurally
equivalent.

- Instead of using the structural equivalence code for checking
compatibility, use the ODR hash mechanism. This should significantly
speed up the checks.
- Hook the necessary name lookup bits to allow this logic in C.
- Teach diagnoseOdrViolations to check the differences.

Instead of silently compiling, clang now emits:

In module 'Y' imported from t.m:2:
./y.h:3:10: error: 'Z::m' from module 'Y' is not present in definition
of 'struct Z' in module 'X'
  double m;
         ^
./x.h:3:7: note: declaration of 'm' does not match
  int m;
      ^

rdar://problem/56764293

Reviewers: rsmith, arphaman, vsapsai, martong, jdoerfert

Subscribers: rnkovacs, jkorous, dexonsmith, ributzka, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71734
@bcardosolopes
Copy link
Author

@swift-ci please test

@bcardosolopes
Copy link
Author

Failures don't seem related
@swift-ci please test

@bcardosolopes
Copy link
Author

@swift-ci please test

@hyp hyp merged commit 76a5546 into swiftlang:apple/stable/20200108 Jan 9, 2020
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