Skip to content

Commit fc2a938

Browse files
committed
Fix forward include collector to consider value class semantics in function returns.
1 parent c4f96ab commit fc2a938

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Generator/AST/ASTRecord.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ public static bool IsEnumNestedInClass(this ASTRecord<Declaration> record)
163163
return false;
164164
}
165165

166+
public static bool IsClassReturn(this ASTRecord record)
167+
{
168+
var ancestors = new Stack<object>();
169+
if(!record.GetAncestors<Function>(ref ancestors))
170+
return false;
171+
172+
var function = (Function)ancestors.Pop();
173+
var tagType = function.ReturnType.Type.Desugar() as TagType;
174+
175+
return tagType?.Declaration is Class;
176+
}
177+
166178
public static bool IsDelegate(this ASTRecord record)
167179
{
168180
var typedef = record.Object as TypedefDecl;

src/Generator/Generators/CLI/CLITypeReferences.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public bool IsIncludeInHeader(ASTRecord<Declaration> record)
164164
return false;
165165

166166
return record.IsBaseClass() || record.IsFieldValueType() || record.IsDelegate()
167-
|| record.IsEnumNestedInClass();
167+
|| record.IsEnumNestedInClass() || record.IsClassReturn();
168168
}
169169

170170
public override bool VisitDeclaration(Declaration decl)

0 commit comments

Comments
 (0)