mirror of https://github.com/mono/CppSharp.git
c-sharpdotnetmonobindingsbridgecclangcpluspluscppsharpglueinteropparserparsingpinvokeswigsyntax-treevisitorsxamarinxamarin-bindings
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
using System.Linq; |
|
using CppSharp.AST; |
|
using CppSharp.Utils; |
|
|
|
namespace CppSharp.Passes |
|
{ |
|
/// <summary> |
|
/// This pass checks for vftable entries with duplicated components. |
|
/// This might happen because of bugs in Clang vftable layouting. |
|
/// </summary> |
|
public class CheckVTableComponentsPass : TranslationUnitPass |
|
{ |
|
public override bool VisitClassDecl(AST.Class @class) |
|
{ |
|
foreach (var vfptr in @class.Layout.VFTables) |
|
{ |
|
var uniqueEntries = new OrderedSet<VTableComponent>(); |
|
foreach (var entry in vfptr.Layout.Components) |
|
uniqueEntries.Add(entry); |
|
|
|
// The vftable does not have duplicated components. |
|
if (vfptr.Layout.Components.Count == uniqueEntries.Count) |
|
continue; |
|
|
|
Diagnostics.Warning( |
|
"Class '{0}' found with duplicated vftable components", |
|
@class.Name); |
|
vfptr.Layout.Components = uniqueEntries.ToList(); |
|
} |
|
|
|
return base.VisitClassDecl(@class); |
|
} |
|
} |
|
}
|
|
|