diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs
index 13baae63..c0cf56b3 100644
--- a/src/Generator/Driver.cs
+++ b/src/Generator/Driver.cs
@@ -131,7 +131,6 @@ namespace CppSharp
{
Passes.CleanInvalidDeclNames();
Passes.CheckIgnoredDecls();
- Passes.CheckTypeReferences();
Passes.CheckFlagEnums();
Passes.CheckAmbiguousOverloads();
Generator.SetupPasses(Passes);
diff --git a/src/Generator/Passes/CheckTypeReferencesPass.cs b/src/Generator/Passes/CheckTypeReferencesPass.cs
deleted file mode 100644
index 64617bdd..00000000
--- a/src/Generator/Passes/CheckTypeReferencesPass.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using CppSharp.AST;
-
-namespace CppSharp.Passes
-{
- public class CheckTypeReferencesPass : TranslationUnitPass
- {
- TypeRefsVisitor typeRefs;
-
- public override bool VisitTranslationUnit(TranslationUnit unit)
- {
- if (unit.Ignore)
- return false;
-
- if (unit.IsSystemHeader)
- return false;
-
- typeRefs = new TypeRefsVisitor();
- return typeRefs.VisitTranslationUnit(unit);
- }
- }
-
- public static class CheckTypeReferencesExtensions
- {
- public static void CheckTypeReferences(this PassBuilder builder)
- {
- var pass = new CheckTypeReferencesPass();
- builder.AddPass(pass);
- }
- }
-}
diff --git a/src/Generator/Types/Types.cs b/src/Generator/Types/Types.cs
index 5d79ed1b..21f5f221 100644
--- a/src/Generator/Types/Types.cs
+++ b/src/Generator/Types/Types.cs
@@ -117,151 +117,4 @@ namespace CppSharp
}
}
- public struct TypeReference
- {
- public Declaration Declaration;
- public Namespace Namespace;
- }
-
- ///
- /// This is used to get the declarations that each file needs to forward
- /// reference or include from other header files. Since in C++ everything
- /// that is referenced needs to have been declared previously, it can happen
- /// that a file needs to be reference something that has not been declared
- /// yet. In that case, we need to declare it before referencing it.
- ///
- public class TypeRefsVisitor : AstVisitor
- {
- public ISet References;
- public ISet Bases;
- private TranslationUnit unit;
- private Namespace currentNamespace;
-
- public TypeRefsVisitor()
- {
- References = new HashSet();
- Bases = new HashSet();
- }
-
- public void Collect(Declaration declaration)
- {
- var @namespace = declaration.Namespace;
-
- if (@namespace != null)
- if (@namespace.TranslationUnit.IsSystemHeader)
- return;
-
- References.Add(new TypeReference()
- {
- Declaration = declaration,
- Namespace = currentNamespace
- });
- }
-
- public bool VisitTranslationUnit(TranslationUnit unit)
- {
- this.unit = unit;
- unit.TypeReferences = this;
-
- VisitNamespace(unit);
-
- foreach (var @namespace in unit.Namespaces)
- VisitNamespace(@namespace);
-
- return true;
- }
-
- public override bool VisitNamespace(Namespace @namespace)
- {
- currentNamespace = @namespace;
- return base.VisitNamespace(@namespace);
- }
-
- public override bool VisitClassDecl(Class @class)
- {
- if (@class.Ignore)
- {
- Visited.Add(@class);
- return false;
- }
-
- if (Visited.Contains(@class))
- return References.Any(reference => reference.Declaration == @class);
-
- Collect(@class);
-
- // If the class is incomplete, then we cannot process the record
- // members, else it will add references to declarations that
- // should have not been found.
- if (@class.IsIncomplete)
- goto OutVisited;
-
- if (string.IsNullOrWhiteSpace(@class.Name))
- goto OutVisited;
-
- var unitClass = unit.FindClass(@class.Name);
- if (unitClass == null || unitClass.IsIncomplete)
- goto OutVisited;
-
- foreach (var @base in @class.Bases)
- {
- if (!@base.IsClass)
- continue;
-
- Bases.Add(@base.Class);
- }
-
- return base.VisitClassDecl(@class);
-
- OutVisited:
-
- Visited.Add(@class);
- return true;
- }
-
- public override bool VisitEnumDecl(Enumeration @enum)
- {
- Collect(@enum);
- return true;
- }
-
- public override bool VisitFieldDecl(Field field)
- {
- if (base.VisitFieldDecl(field))
- Collect(field);
-
- return true;
- }
-
- public override bool VisitTypedefType(TypedefType typedef,
- TypeQualifiers quals)
- {
- var decl = typedef.Declaration;
-
- if (decl.Type == null)
- return false;
-
- FunctionType function;
- if (decl.Type.IsPointerTo(out function))
- {
- Collect(decl);
- return true;
- }
-
- return decl.Type.Visit(this);
- }
-
- public override bool VisitTagType(TagType tag, TypeQualifiers quals)
- {
- Collect(tag.Declaration);
- return true;
- }
-
- public override bool VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals)
- {
- Collect(template.Template);
- return base.VisitTemplateSpecializationType(template, quals);
- }
-
- }
}