Better working destructors on windows #2663
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tries to solve #1725 and #2092.
I found that clang can only generate one entry when calling
clang_Cursor_getCXXManglings
with the Microsoft ABI. Also the conditions for "group 1" destructors don't apply at all on the MS ABI, having a completely different mangling format.Also, it seems like the entry from
clang_Cursor_getCXXManglings
will always be the regular "base" destructor that is most interesting usually, while the entry fromclang_Cursor_getMangling
will always be the "vbase destructor" that's supposed to be able to destroy anything. However, only the base destructor is always available, the other ones being generated on the fly when the code actually needs it.So far, the code always chose the vbase dtor that happened to never exist, and this is why the code always failed with a link error.
What I wish I figured out how to do was to get the information from clang under which ABI we operate at the moment, but I couldn't find a way to do this, so I just checked if we run under Windows instead. I suspect this might not work well with the MinGW target.
With the
main
branch unmodified I get one failed test under WSL and over 500 under Windows. I did not see whether I could have Windows only tests, but it looked like a lot of effort to get all tests working under Windows at this point, so I don't know if I could add any tests at the moment.Here is the manual test I performed. Most usual things seems to work fine, except for classes that use virtual inheritance (the vbase destructor) because it's not the correct destructor to call directly. It seems to crash in a deterministic fashion on my machine from a null pointer access, so it might be fine? This is just trying to make the best of out of a bad situation.
Is there anything I could do make it better? Sorry for the rambly description.