@@ -398,8 +398,14 @@ public AST.ASTContext Convert()
398
398
for ( uint i = 0 ; i < Context . TranslationUnitsCount ; ++ i )
399
399
{
400
400
var unit = Context . GetTranslationUnits ( i ) ;
401
- var _unit = declConverter . Visit ( unit ) as AST . TranslationUnit ;
401
+ var _unit = ( AST . TranslationUnit ) declConverter . Visit ( unit ) ;
402
402
_ctx . TranslationUnits . Add ( _unit ) ;
403
+ }
404
+
405
+ for ( uint i = 0 ; i < Context . TranslationUnitsCount ; i ++ )
406
+ {
407
+ var unit = Context . GetTranslationUnits ( i ) ;
408
+ var _unit = ( AST . TranslationUnit ) declConverter . Visit ( unit ) ;
403
409
declConverter . VisitDeclContext ( unit , _unit ) ;
404
410
}
405
411
@@ -832,12 +838,10 @@ public override AST.Declaration Visit(Declaration decl)
832
838
833
839
// Check if the declaration was already handled and return its
834
840
// existing instance.
835
- if ( CheckForDuplicates ( decl ) )
836
- if ( Declarations . ContainsKey ( originalPtr ) )
837
- return Declarations [ originalPtr ] ;
841
+ if ( CheckForDuplicates ( decl ) && Declarations . ContainsKey ( originalPtr ) )
842
+ return Declarations [ originalPtr ] ;
838
843
839
- var newDecl = base . Visit ( decl ) ;
840
- return newDecl ;
844
+ return base . Visit ( decl ) ;
841
845
}
842
846
843
847
AST . AccessSpecifier VisitAccessSpecifier ( AccessSpecifier access )
@@ -969,13 +973,10 @@ void VisitDeclaration(Declaration decl, AST.Declaration _decl)
969
973
970
974
public void VisitDeclContext ( DeclarationContext ctx , AST . DeclarationContext _ctx )
971
975
{
972
- var namespaces = new Dictionary < Namespace , AST . Namespace > ( ) ;
973
-
974
976
for ( uint i = 0 ; i < ctx . NamespacesCount ; ++ i )
975
977
{
976
978
var decl = ctx . GetNamespaces ( i ) ;
977
979
var _decl = Visit ( decl ) as AST . Namespace ;
978
- namespaces . Add ( decl , _decl ) ;
979
980
_ctx . Namespaces . Add ( _decl ) ;
980
981
}
981
982
@@ -1036,12 +1037,20 @@ public void VisitDeclContext(DeclarationContext ctx, AST.DeclarationContext _ctx
1036
1037
_ctx . Declarations . Add ( _decl ) ;
1037
1038
}
1038
1039
1039
- foreach ( var @namespace in namespaces )
1040
+ for ( uint i = 0 ; i < ctx . NamespacesCount ; ++ i )
1040
1041
{
1041
- VisitDeclContext ( @namespace . Key , @namespace . Value ) ;
1042
+ var decl = ctx . GetNamespaces ( i ) ;
1043
+ var _decl = ( AST . Namespace ) Visit ( decl ) ;
1044
+ VisitDeclContext ( decl , _decl ) ;
1042
1045
}
1043
1046
1044
- namespaces . Clear ( ) ;
1047
+ for ( uint i = 0 , j = 0 ; i < ctx . ClassesCount ; ++ i )
1048
+ {
1049
+ var decl = ctx . GetClasses ( i ) ;
1050
+ var _decl = ( AST . Class ) Visit ( decl ) ;
1051
+ if ( ! _decl . IsIncomplete || _decl . IsOpaque )
1052
+ VisitClass ( decl , _decl ) ;
1053
+ }
1045
1054
1046
1055
// Anonymous types
1047
1056
}
@@ -1487,7 +1496,6 @@ public override AST.Declaration VisitAccessSpecifier(AccessSpecifierDecl decl)
1487
1496
1488
1497
void VisitClass ( Class @class , AST . Class _class )
1489
1498
{
1490
- VisitDeclaration ( @class , _class ) ;
1491
1499
VisitDeclContext ( @class , _class ) ;
1492
1500
1493
1501
for ( uint i = 0 ; i < @class . BasesCount ; ++ i )
@@ -1536,7 +1544,7 @@ void VisitClass(Class @class, AST.Class _class)
1536
1544
public override AST . Declaration VisitClass ( Class @class )
1537
1545
{
1538
1546
var _class = new AST . Class ( ) ;
1539
- VisitClass ( @class , _class ) ;
1547
+ VisitDeclaration ( @class , _class ) ;
1540
1548
1541
1549
return _class ;
1542
1550
}
@@ -1717,6 +1725,7 @@ public override AST.Declaration VisitClassTemplateSpecialization(
1717
1725
private void VisitClassTemplateSpecialization ( ClassTemplateSpecialization decl ,
1718
1726
AST . ClassTemplateSpecialization _decl )
1719
1727
{
1728
+ VisitDeclaration ( decl , _decl ) ;
1720
1729
VisitClass ( decl , _decl ) ;
1721
1730
_decl . SpecializationKind = VisitSpecializationKind ( decl . SpecializationKind ) ;
1722
1731
_decl . TemplatedDecl = ( AST . ClassTemplate ) Visit ( decl . TemplatedDecl ) ;
0 commit comments