Skip to content
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

Add support for (inlined) destructors #12

Closed
PathogenDavid opened this issue Sep 4, 2020 · 2 comments
Closed

Add support for (inlined) destructors #12

PathogenDavid opened this issue Sep 4, 2020 · 2 comments
Labels
Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Concept-Correctness Issues concerning the correctness of the translation from an ABI perspective Concept-CppFeatures Issues concerning unsupported C++ features Concept-OutputUsability Issues concerning whether or not the output from Biohazrd is actually usable Language-C# Issues specific to C#

Comments

@PathogenDavid
Copy link
Member

PathogenDavid commented Sep 4, 2020

There isn't a way I'm aware of to convince MSVC or Clang to export an inline destructor without modifying its definition.

Destructors were disabled from module definition generation entirely (even non-inline ones) in the prototype and it's unclear exactly why that is.

Worth noting: Virtual destructors are always available in the output.

@PathogenDavid PathogenDavid added Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Concept-Correctness Issues concerning the correctness of the translation from an ABI perspective Concept-CppFeatures Issues concerning unsupported C++ features Concept-OutputUsability Issues concerning whether or not the output from Biohazrd is actually usable Language-C# Issues specific to C# labels Sep 21, 2020
@PathogenDavid PathogenDavid mentioned this issue Nov 9, 2020
6 tasks
@PathogenDavid PathogenDavid mentioned this issue Dec 21, 2020
8 tasks
@PathogenDavid
Copy link
Member Author

Found out why destructors were disabled. clang_Cursor_getMangling returns the wrong mangling for destructors on Windows. You have to use clang_Cursor_getCXXManglings instead. In theory constructors have the same problem, but Microsoft's mangling doesn't differ between different types of constructors.


Details from my notes:

This originally came up because Clang is returning the wrong mangling for the ImFont destructor. Clang returns ??_DImFont@@QEAAXXZ, but the exported symbol is ??1ImFont@@QEAA@XZ.

Looking at mangleCXXDtorType, the difference between the two is that ?_D is for a vbase destructor and ?1 is for a normal destructor.

We use clang_Cursor_getMangling to get the mangling. This function is effectively implemented by ASTNameGenerator::Implementation::writeName, which for function declarations is implemented by writeFuncOrVarName which for a destructor always uses the Dtor_Complete destructor type, which will be the ?_D mangling.

Looking at libclang, there's a separate clang_Cursor_getCXXManglings which returns multiple strings. This function effectively calls ASTNameGenerator::Implementation::getAllManglings. With a Microsoft ABI this will only return a single value for destructors, Dtor_Base (which is the ?1 version we expected.)

PathogenDavid added a commit that referenced this issue Feb 21, 2021
PathogenDavid added a commit that referenced this issue Feb 21, 2021
…tors, destructors, operator overloads, and conversion overloads.

Relates to #78 and #12
@PathogenDavid
Copy link
Member Author

Between 756b969 and 23c4edd, I am calling this done.

Better support for deletion is tracked by #159

Improving friendliness of constructing/destructing C++ objects is tracked by #161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-OutputGeneration Issues concerning the process of generating output from Biohazrd Concept-Correctness Issues concerning the correctness of the translation from an ABI perspective Concept-CppFeatures Issues concerning unsupported C++ features Concept-OutputUsability Issues concerning whether or not the output from Biohazrd is actually usable Language-C# Issues specific to C#
Projects
None yet
Development

No branches or pull requests

1 participant