Skip to content

Commit d8ab030

Browse files
committed
Check for null destructor in PInvokeGenerator.VisitDecl.cs
* Add a diagnostic if the destructor property is null despite other bool properties suggesting the precense of a destructor.
1 parent df0ab63 commit d8ab030

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
717717
{
718718
outputBuilder.Write("Base");
719719
}
720-
720+
721721
outputBuilder.Write('.');
722722
outputBuilder.Write(name);
723723
outputBuilder.Write('(');
@@ -1817,7 +1817,11 @@ private void VisitRecordDecl(RecordDecl recordDecl)
18171817
{
18181818
var cxxDestructorDecl = cxxRecordDecl.Destructor;
18191819

1820-
if (!cxxDestructorDecl.IsVirtual && !IsExcluded(cxxDestructorDecl))
1820+
if (cxxDestructorDecl == null)
1821+
{
1822+
AddDiagnostic(DiagnosticLevel.Warning, "Record has user declared destructor, but Destructor property was null. Generated bindings may be incomplete.", cxxRecordDecl);
1823+
}
1824+
else if (!cxxDestructorDecl.IsVirtual && !IsExcluded(cxxDestructorDecl))
18211825
{
18221826
Visit(cxxDestructorDecl);
18231827
_outputBuilder.WriteDivider();

0 commit comments

Comments
 (0)