Skip to content

[ClangImporter] Do not import DynamicRangePointerType and ValueTerminatedType #77910

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 4 commits into from
Dec 4, 2024

Conversation

rapidsna
Copy link
Contributor

@rapidsna rapidsna commented Dec 3, 2024

DynamicRangePointerType and ValueTerminatedType are new Clang types for -fbounds-safety, annotated with the 'ended_by' and the 'terminated_by' attributes. This adds visitors for these types in ClangImporter so Swift continues to build with the Clang version that will introduce these new types.

This should unblock swiftlang/llvm-project#9665

@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

@swift-ci test

…atedType

DynamicRangePointerType and ValueTerminatedType are new Clang
types for -fbounds-safety, annotated  with the 'ended_by' and the
'terminated_by' attributes. This adds visitors for these types in
ClangImporter so Swift still builds with Clang that has these new
types.
@rapidsna rapidsna force-pushed the handle_clang_bounds_safety_types branch from 6b5262c to 866a834 Compare December 3, 2024 01:27
// DynamicRangePointerType is a clang type representing a pointer with
// an "ended_by" type attribute for -fbounds-safety. For now, we don't
// import these into Swift.
return Type();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we recurse on the wrapped type here, since it's okay to ignore the ended_by attribute? We'll be gathering this information separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Though this is to make them consistent with how CountAttributedType is handled in this codebase and downstream. @hnrklssn's WIP PR will fix the visitor for CountAttributedType later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you prefer, I can make DynamicRangePointerType and ValueTerminatedType to be handled like other SUGAR_TYPE here. Please let me know.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer that they be handled like other SUGAR_TYPE. The bounds-safety annotations shouldn't break interop, even when they aren't being used to improve it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Contributor Author

@rapidsna rapidsna Dec 3, 2024

Choose a reason for hiding this comment

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

@hnrklssn You will have to remove SUGAR_TYPE(CountAttributed) in your patch and reintroduce your Visit CountAttributedType. I fixed it anyway knowing that your patch won't be landing in the release branch, but this will be.

Copy link
Contributor Author

@rapidsna rapidsna Dec 3, 2024

Choose a reason for hiding this comment

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

@DougGregor actually, I couldn't land SUGAR_TYPE(DynamicRangePointer) because DynamicRangePointerType doesn't exist in Clang yet. I will revert back to return Type() and then open up a follow up patch to fix that right after I land swiftlang/llvm-project#9665.

swift/lib/ClangImporter/ImportType.cpp:943:5: error: member access into incomplete type 'const clang::DynamicRangePointerType'
  943 |     SUGAR_TYPE(DynamicRangePointer)
      |     ^
swift/lib/ClangImporter/ImportType.cpp:930:24: note: expanded from macro 'SUGAR_TYPE'
  930 |       return Visit(type->desugar());                                           \
      |                        ^

@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

@swift-ci test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Thank you!

@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

@DougGregor Thanks for the quick review!

@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

@swift-ci test

@rapidsna rapidsna changed the title [ClangImporter] Do not import DynamicRangePointerType and ValueTerminatedType [ClangImporter] Treat CountAttributedType and other bounds attributed types as sugar types Dec 3, 2024
@rapidsna rapidsna changed the title [ClangImporter] Treat CountAttributedType and other bounds attributed types as sugar types [ClangImporter] Do not import DynamicRangePointerType and ValueTerminatedType Dec 3, 2024
@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

@swift-ci test

@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

Linux test failure seemed unrelated:

error: unknown or missing subcommand 'swift-legacy-driver'

@rapidsna
Copy link
Contributor Author

rapidsna commented Dec 3, 2024

@swift-ci test

@rapidsna rapidsna enabled auto-merge (squash) December 3, 2024 23:23
@rapidsna rapidsna merged commit 66321f7 into main Dec 4, 2024
4 of 5 checks passed
@rapidsna rapidsna deleted the handle_clang_bounds_safety_types branch December 4, 2024 08:43
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