@@ -77,6 +77,25 @@ public override bool VisitClassDecl(Class @class)
7777 if ( @class . IsDependent )
7878 return false ;
7979
80+ // Polymorphic classes are currently not supported.
81+ // TODO: We could support this if the base class is also static, since it's composition then.
82+ if ( @class . IsPolymorphic )
83+ return false ;
84+
85+ // Make sure we have at least one accessible static method or field
86+ if ( ! @class . Methods . Any ( m => m . Kind == CXXMethodKind . Normal && m . Access != AccessSpecifier . Private && m . IsStatic )
87+ && @class . Variables . All ( v => v . Access == AccessSpecifier . Private ) )
88+ return false ;
89+
90+ // Check for any non-static fields or methods, in which case we
91+ // assume the class is not meant to be static.
92+ // Note: Static fields are represented as variables in the AST.
93+ if ( @class . Fields . Count != 0 )
94+ return false ;
95+
96+ if ( @class . Methods . Any ( m => m . Kind == CXXMethodKind . Normal && ! m . IsStatic ) )
97+ return false ;
98+
8099 if ( @class . Constructors . Any ( m =>
81100 {
82101 // Implicit constructors are not user-defined, so assume this was unintentional.
@@ -97,13 +116,6 @@ public override bool VisitClassDecl(Class @class)
97116 {
98117 return false ;
99118 }
100- // Check for any non-static fields or methods, in which case we
101- // assume the class is not meant to be static.
102- // Note: Static fields are represented as variables in the AST.
103- if ( @class . Fields . Any ( ) ||
104- @class . Methods . Any ( m => m . Kind == CXXMethodKind . Normal
105- && ! m . IsStatic ) )
106- return false ;
107119
108120 // Check for any static function that return a pointer to the class.
109121 // If one exists, we assume it's a factory function and the class is
0 commit comments