-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Track Clang function types in the AST #27479
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
Track Clang function types in the AST #27479
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ah, there is a compilation failure due to the removed |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ah we are crashing when compiling SwiftPM 🙁 |
We're compiling SwiftPM properly on Linux but not on OS X? 😦 |
This comment has been minimized.
This comment has been minimized.
The SwiftPM compilation crash is because of a type mismatch issue; we have a Clang type in one case and none in the other. Think I should put a more descriptive crash message there instead of just an |
Minimal test case. Only
|
Think I understand what the issue is. It has nothing to do with SIG_DFL and probably has everything to do with (de)serialization. We're not (de)serializing Clang types yet, so decls loaded from a different module don't have it. 🤦♂ The only way I see is disabling the clang function pointer check when comparing types. However, that doesn't explain why code like Update: I talked to Robert about this and it is definitely puzzling behavior that the code with |
This comment has been minimized.
This comment has been minimized.
I still need to add more test cases utilizing the new flag, but the core logic should be good now. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The LLDB failure was fixed here: swiftlang/llvm-project#24 @swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test Linux platform |
Build failed |
@swift-ci please smoke test Linux platform |
@swift-ci please test Linux platform |
Build failed |
@swift-ci please clean test Linux platform |
Build failed |
I don't understand why we'd see such an error because of this change.
@swift-ci please test Linux platform |
Yasssss! Tests are passing. @rjmccall time for you to give this PR your blessings. |
@@ -0,0 +1,36 @@ | |||
//- ClangSwiftTypeCorrespondence.cpp - Relations between Clang & Swift types -// |
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.
This isn't a .cpp
file, and there's a standard form of these header comments.
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.
there's a standard form of these header comments
I ran out of characters to add ==
signs around.
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.
If you have any suggestions for rephrasing, I can do that. This is the best I could come up with to fit in 80 chars.
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.
I think you're overthinking the filename and it could just be something like ClangTypeInfo.h - Swift-related properties of Clang types
.
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.
I think Info
is very generic and doesn't hint at anything in particular.
We still don't store compute or store the type anywhere; we will do so in later commits.
Note: The change in ASTBuilder::createFunctionType is functionally minor, but we need the FunctionType::Params computed _before_ the ExtInfo, so we need to shuffle a bunch of code around.
This should be a non-functional change because we shouldn't be converting protocols which aren't ObjC.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@rjmccall is this good to merge? |
See my comment in the other PR about |
The 3rd commit introduces a bunch of TODOs, most of which are resolved in the 4th commit.
Things that are implemented:
Questions:
It is not clear who/what should be maintaining ownership of the ClangTypeConverter in the ASTBuilder. There are a couple of TODOs related to this. ("Is this too expensive?").How should I further be testing this change?Things that are not implemented yet but I plan to do as part of this PR (unless someone says I should make a follow-up PR about it):
right now, the main "test" is the whole test suite passes, i.e. we don't mess up type equality anywhere.added some trickier test casesSetting the clang types in SILFunctionType.(punted to future PR)Reporting differences in the clang type in diagnostics.(punted to future PR)Since it has taken me much more time than anticipated to get to this point, I figured I'd try to get feedback sooner rather than later (even though a bunch of things are not implemented), especially given that this is a relatively large PR 😐.