-
Notifications
You must be signed in to change notification settings - Fork 10.6k
AST: Properly disallow isa/cast/dyn_cast on Type
#85487
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
base: main
Are you sure you want to change the base?
Conversation
hamishknight
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
2678ea6 to
74a5939
Compare
|
@swift-ci please smoke test |
slavapestov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
|
FWIW, |
74a5939 to
e54d068
Compare
Yeah, unless you want to declare a local |
|
@swift-ci please smoke test |
|
@swift-ci please smoke test |
(cherry picked from commit ab3a3d5)
[stable/21.x][lldb] Swift: Fix `swift::Type` casts for swiftlang/swift#85487
[next][lldb] Swift: Fix `swift::Type` casts for swiftlang/swift#85487
We currently disallow these by deleting them in the `swift` namespace. This approach has several loopholes, all of which ultimately work because we happen to define specializations of `simplify_type` for `swift::Type`: * `llvm::isa/cast/dyn_cast`. The deleted partial specializations will not be selected because they are not defined in the `llvm` namespace. * The argument is a non-const `Type`. The deleted function templates will not be selected because they all accept a `const Type &`, and there is a better `Y &Val` partial specialization in LLVM. * Other casting function templates such as `isa_and_nonull` and `cast_if_present` are not deleted. Eliminate these loopholes by instead triggering a static assertion failure with a helpful message upon instantiation of `CastInfo` for `swift::Type`.
e54d068 to
dd5ac83
Compare
|
@swift-ci please smoke test |
|
@swift-ci please smoke test |
We currently disallow these by deleting them in the
swiftnamespace. This approach has several loopholes, all of which ultimately work because we happen to define specializations ofsimplify_typeforswift::Type:llvm::isa/cast/dyn_cast. The deleted partial specializations will not be selected because they are not defined in thellvmnamespace.Type. The deleted function templates will not be selected because they all accept aconst Type &, and there is a betterY &Valpartial specialization in LLVM.isa_and_nonullandcast_if_presentare not deleted.Eliminate these loopholes by instead triggering a static assertion failure with a helpful message upon instantiation of
CastInfoforswift::Type.