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

Fix native crashes / asserts in libClangSharp and CXXRecordDecl Destructor property. #525

Merged
merged 2 commits into from
Feb 5, 2024

Conversation

ceresgalax
Copy link
Contributor

  • Work around a clang crash in clangsharp_Cursor_getLambdaStaticInvoker when CRD->getLambdaCallOperator() returns null and CRD->getLambdaStaticInvoker() is called.

  • clangsharp_Cursor_getNumAttrs: Calling D->getAttrs() will assert if D->hasAttrs() returns false. Fix by checking D->hasAttrs() first.

  • A CXXRecordDecl may return null for getDestructor. Change the C# CXXRecordDecl Destructor property to be nullable to support this case.

Hopefully these changes make inspecting ClangSharp objects in the debugger much less likely to crash.

…uctor property.

* Work around a clang crash in clangsharp_Cursor_getLambdaStaticInvoker when
  CRD->getLambdaCallOperator() returns null and
  CRD->getLambdaStaticInvoker() is called.

* clangsharp_Cursor_getNumAttrs: Calling D->getAttrs() will assert if
  D->hasAttrs() returns false. Fix by checking D->hasAttrs() first.

* A CXXRecordDecl may return null for getDestructor. Change the C# CXXRecordDecl
  Destructor property to be nullable to support this case.
@ceresgalax
Copy link
Contributor Author

@dotnet-policy-service agree

tannergooding
tannergooding previously approved these changes Feb 4, 2024
@tannergooding
Copy link
Member

Looks like there's a compile failure since Destructor is now marked nullable, which means that explicit handling needs to be added

@ceresgalax ceresgalax changed the title Fix native crashes / asserts in libClangSharp and CXXRecordDecl Destuuctor property. Fix native crashes / asserts in libClangSharp and CXXRecordDecl Destuctor property. Feb 5, 2024
* Add a diagnostic if the destructor property is null despite other
  bool properties suggesting the precense of a destructor.
@ceresgalax ceresgalax changed the title Fix native crashes / asserts in libClangSharp and CXXRecordDecl Destuctor property. Fix native crashes / asserts in libClangSharp and CXXRecordDecl Destructor property. Feb 5, 2024
@tannergooding tannergooding merged commit b9479d2 into dotnet:main Feb 5, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants