-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[cxx-interop] Fix linker errors when using std-vector. #40867
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
[cxx-interop] Fix linker errors when using std-vector. #40867
Conversation
|
CC @plotfi |
|
@guitard0g please verify this fixes the issues using |
|
@swift-ci please smoke test. |
|
@zoecarver Does this drop the need for PR #39551 ? |
lib/IRGen/GenClangDecl.cpp
Outdated
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 believe this is where I was encountering the operator() for the std::functional that wasn't getting added to the stack.
lib/IRGen/GenClangDecl.cpp
Outdated
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.
Ah I see, so this gets to the dtors from the VarDecl's type rather than the ctors it already visited?
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.
Yes. The ctors aren't really important here; they weren't causing problems. We might need to destroy something that we never constructed. Think about it like this: what might cause us to call a destructor? Well, if we have an instance of a C++ type with a dtor, we will have to call its dtor. If that C++ type has bases/fields, same thing. To fix these issues, I look at all the places we might call a dtor, and make we tell clang to generate that symbol.
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.
Good approach. Can you add this as context in a comment on this VarDecl visitor?
Yes, I think so. I'm sorry I wasn't able to review that patch more thoroughly, but I think this patch is a better solution. In that patch you are essentially walking the whole AST tree. It happens that your constructors lead you to the right place, but that is not guaranteed. I think many of these tests cases will fail with your patch, and it won't help the following use case: |
|
@swift-ci please smoke test. |
d63ce3c to
a2f8935
Compare
|
@swift-ci please smoke test. |
Sounds good. I agree I like this patch a lot more, was going about tracking the Decls by walking from the ctors the entire depth is not great. I tested your patch out and it works too; will take a look at default template params for some of the other containers. |
No worries BTW! :-) |
Adds tests for using std-vector and some other interesting types. This patch fixes four mis conceptions that the compiler was previously making: 1. Implicit destructors have no side effects. (Yes, this means we were not cleaning up some objects.) 2. Implicit destructors have bodies. (Technically they do, but the body doesn't include CallExprs that they make when lowered to IR.) 3. Functions other than methods can be uninstantiated templates. 4. Uninstantiated templates may have executable code. (I.e., we can never take the fast path.) And makes sure that we visit the destructor of any VarDecl (including parameters).
a2f8935 to
ba44bfe
Compare
|
@swift-ci please smoke test. |
|
@swift-ci please smoke test Linux. |
Adds tests for using std-vector and some other interesting types.
This patch fixes four mis conceptions that the compiler was previously making: