Fix some noisy warnings that often show up in ObjC binding generation
diff --git a/lib/src/header_parser/clang_bindings/clang_bindings.dart b/lib/src/header_parser/clang_bindings/clang_bindings.dart index 8185f34..5bb0d63 100644 --- a/lib/src/header_parser/clang_bindings/clang_bindings.dart +++ b/lib/src/header_parser/clang_bindings/clang_bindings.dart
@@ -2522,6 +2522,32 @@ static const int CXTypeNullability_Invalid = 3; } +/// List the possible error codes for \c clang_Type_getSizeOf, +/// \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and +/// \c clang_Cursor_getOffsetOf. +/// +/// A value of this enumeration type can be returned if the target type is not +/// a valid argument to sizeof, alignof or offsetof. +abstract class CXTypeLayoutError { + /// Type is of kind CXType_Invalid. + static const int CXTypeLayoutError_Invalid = -1; + + /// The type is an incomplete Type. + static const int CXTypeLayoutError_Incomplete = -2; + + /// The type is a dependent Type. + static const int CXTypeLayoutError_Dependent = -3; + + /// The type is not a constant size type. + static const int CXTypeLayoutError_NotConstantSize = -4; + + /// The Field name is not valid for this record. + static const int CXTypeLayoutError_InvalidFieldName = -5; + + /// The type is undeduced. + static const int CXTypeLayoutError_Undeduced = -6; +} + /// Describes how the traversal of the children of a particular /// cursor should proceed after visiting a particular child cursor. ///
diff --git a/lib/src/header_parser/sub_parsers/compounddecl_parser.dart b/lib/src/header_parser/sub_parsers/compounddecl_parser.dart index 9e284b2..81c9761 100644 --- a/lib/src/header_parser/sub_parsers/compounddecl_parser.dart +++ b/lib/src/header_parser/sub_parsers/compounddecl_parser.dart
@@ -38,7 +38,8 @@ flexibleArrayMember || bitFieldMember || (dartHandleMember && config.useDartHandle) || - incompleteCompoundMember; + incompleteCompoundMember || + alignment == clang_types.CXTypeLayoutError.CXTypeLayoutError_Incomplete; // A struct without any attribute is definitely not packed. #pragma pack(...) // also adds an attribute, but it's unexposed and cannot be travesed. @@ -60,7 +61,7 @@ /// Returns pack value of a struct depending on config, returns null for no /// packing. int? get packValue { - if (compound.isStruct && _isPacked) { + if (compound.isStruct && _isPacked && !isIncomplete) { if (strings.packingValuesMap.containsKey(alignment)) { return alignment; } else {
diff --git a/lib/src/header_parser/sub_parsers/enumdecl_parser.dart b/lib/src/header_parser/sub_parsers/enumdecl_parser.dart index 1353f2d..b33e3e7 100644 --- a/lib/src/header_parser/sub_parsers/enumdecl_parser.dart +++ b/lib/src/header_parser/sub_parsers/enumdecl_parser.dart
@@ -96,6 +96,9 @@ case clang_types.CXCursorKind.CXCursor_EnumConstantDecl: _addEnumConstantToEnumClass(cursor); break; + case clang_types.CXCursorKind.CXCursor_UnexposedAttr: + // Ignore. + break; default: _logger.fine('invalid enum constant'); }
diff --git a/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart b/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart index 879dfea..320e084 100644 --- a/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart +++ b/lib/src/header_parser/sub_parsers/unnamed_enumdecl_parser.dart
@@ -47,6 +47,9 @@ _addUnNamedEnumConstant(cursor); } break; + case clang_types.CXCursorKind.CXCursor_UnexposedAttr: + // Ignore. + break; default: _logger.severe('Invalid enum constant.'); }
diff --git a/tool/libclang_config.yaml b/tool/libclang_config.yaml index b2ea7b4..339c52c 100644 --- a/tool/libclang_config.yaml +++ b/tool/libclang_config.yaml
@@ -41,6 +41,7 @@ - CXEvalResultKind - CXObjCPropertyAttrKind - CXTypeNullabilityKind + - CXTypeLayoutError structs: include: