diff --git a/src/CppAst/CppModelBuilder.cs b/src/CppAst/CppModelBuilder.cs index aa38164..8da1f61 100644 --- a/src/CppAst/CppModelBuilder.cs +++ b/src/CppAst/CppModelBuilder.cs @@ -325,43 +325,10 @@ private CXChildVisitResult VisitMember(CXCursor cursor, CXCursor parent, void* d case CXCursorKind.CXCursor_StructDecl: case CXCursorKind.CXCursor_UnionDecl: { - bool isAnonymous = cursor.IsAnonymous; var cppClass = VisitClassDecl(cursor, data); var containerContext = GetOrCreateDeclarationContainer(parent, data); - // Empty struct/class/union declaration are considered as fields - if (isAnonymous) - { - cppClass.Name = string.Empty; - Debug.Assert(string.IsNullOrEmpty(cppClass.Name)); - - // We try to recover the offset from the previous field - // Might not be always correct (with alignment rules), - // but not sure how to recover the offset without recalculating the entire offsets - var offset = 0; - var cppClassContainer = containerContext.Container as CppClass; - if (cppClassContainer is object && cppClassContainer.Fields.Count > 0) - { - var lastField = cppClassContainer.Fields[cppClassContainer.Fields.Count - 1]; - offset = (int)lastField.Offset + lastField.Type.SizeOf; - } - - // Create an anonymous field for the type - var cppField = new CppField(cppClass, string.Empty) - { - Visibility = containerContext.CurrentVisibility, - StorageQualifier = GetStorageQualifier(cursor), - IsAnonymous = true, - Offset = offset, - }; - ParseAttributes(cursor, cppField, true); - containerContext.DeclarationContainer.Fields.Add(cppField); - element = cppField; - } - else - { - cppClass.Visibility = containerContext.CurrentVisibility; - element = cppClass; - } + cppClass.Visibility = containerContext.CurrentVisibility; + element = cppClass; break; }