@@ -74,31 +74,31 @@ public enum ClassType
7474 // Represents a C++ record decl.
7575 public class Class : DeclarationContext
7676 {
77- public List < BaseClassSpecifier > Bases ;
78- public List < Field > Fields ;
79- public List < Property > Properties ;
80- public List < Method > Methods ;
81- public List < AccessSpecifierDecl > Specifiers ;
77+ public List < BaseClassSpecifier > Bases = new ( ) ;
78+ public List < Field > Fields = new ( ) ;
79+ public List < Property > Properties = new ( ) ;
80+ public List < Method > Methods = new ( ) ;
81+ public List < AccessSpecifierDecl > Specifiers = new ( ) ;
8282
8383 // True if the record is a POD (Plain Old Data) type.
84- public bool IsPOD ;
84+ public bool IsPOD = false ;
8585
8686 // Semantic type of the class.
87- public ClassType Type ;
87+ public ClassType Type = ClassType . RefType ;
8888
8989 // ABI-specific class layout.
90- public ClassLayout Layout ;
90+ public ClassLayout Layout = new ( ) ;
9191
9292 // True if class provides pure virtual methods.
93- public bool IsAbstract ;
93+ public bool IsAbstract = false ;
9494
9595 // True if the type is to be treated as a union.
96- public bool IsUnion ;
96+ public bool IsUnion = false ;
9797
9898 public TagKind TagKind { get ; set ; }
9999
100100 // True if the class is final / sealed.
101- public bool IsFinal { get ; set ; }
101+ public bool IsFinal { get ; set ; } = false ;
102102
103103 private bool ? isOpaque ;
104104
@@ -129,23 +129,6 @@ public bool IsOpaque
129129 // True if the class represents a static class.
130130 public bool IsStatic ;
131131
132- public Class ( )
133- {
134- Bases = new List < BaseClassSpecifier > ( ) ;
135- Fields = new List < Field > ( ) ;
136- Properties = new List < Property > ( ) ;
137- Methods = new List < Method > ( ) ;
138- Specifiers = new List < AccessSpecifierDecl > ( ) ;
139- IsAbstract = false ;
140- IsUnion = false ;
141- IsFinal = false ;
142- IsPOD = false ;
143- Type = ClassType . RefType ;
144- Layout = new ClassLayout ( ) ;
145- templateParameters = new List < Declaration > ( ) ;
146- specializations = new List < ClassTemplateSpecialization > ( ) ;
147- }
148-
149132 public bool HasBase => Bases . Count > 0 ;
150133
151134 public bool HasBaseClass => BaseClass != null ;
@@ -296,7 +279,7 @@ public override T Visit<T>(IDeclVisitor<T> visitor)
296279 return visitor . VisitClassDecl ( this ) ;
297280 }
298281
299- private List < Declaration > templateParameters ;
300- private List < ClassTemplateSpecialization > specializations ;
282+ private readonly List < Declaration > templateParameters = new ( ) ;
283+ private readonly List < ClassTemplateSpecialization > specializations = new ( ) ;
301284 }
302285}
0 commit comments