Skip to content

Commit

Permalink
Ensure that remapped records also have their constructors remapped
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Dec 26, 2021
1 parent 0b16bec commit 79523c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,15 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
}

var name = GetRemappedCursorName(functionDecl);

var cxxMethodDecl = functionDecl as CXXMethodDecl;
var isCxxMethodDecl = cxxMethodDecl is not null;

if (isCxxMethodDecl && (cxxMethodDecl is CXXConstructorDecl))
{
name = GetRemappedCursorName(cxxMethodDecl.Parent);
}

var isManualImport = _config.WithManualImports.Contains(name);

var className = name;
Expand All @@ -484,11 +493,9 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)

var accessSppecifier = GetAccessSpecifier(functionDecl);

var cxxMethodDecl = functionDecl as CXXMethodDecl;
var body = functionDecl.Body;
var hasBody = body is not null;

var isCxxMethodDecl = cxxMethodDecl is not null;
var isVirtual = isCxxMethodDecl && cxxMethodDecl.IsVirtual;
var escapedName = isVirtual ? PrefixAndStripName(name, GetOverloadIndex(cxxMethodDecl)) : EscapeAndStripName(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1598,9 +1598,16 @@ private void VisitMemberExpr(MemberExpr memberExpr)
var outputBuilder = StartCSharpCode();
var isForDerivedType = false;

if ((memberExpr.MemberDecl is CXXMethodDecl cxxMethodDecl) && (_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != cxxMethodDecl.Parent) && HasField(cxxMethodDecl.Parent))
if ((memberExpr.Base is ImplicitCastExpr implicitCastExpr) && (implicitCastExpr.CastKind is CX_CastKind.CX_CK_DerivedToBase or CX_CastKind.CX_CK_DerivedToBaseMemberPointer or CX_CastKind.CX_CK_UncheckedDerivedToBase))
{
isForDerivedType = true;
if (memberExpr.MemberDecl is CXXMethodDecl cxxMethodDecl)
{
isForDerivedType = (_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != cxxMethodDecl.Parent) && HasField(cxxMethodDecl.Parent);
}
else if (memberExpr.MemberDecl is FieldDecl fieldDecl)
{
isForDerivedType = (_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != fieldDecl.Parent);
}
}

if (!memberExpr.IsImplicitAccess || isForDerivedType)
Expand Down

0 comments on commit 79523c9

Please sign in to comment.