diff --git a/c/clang/_wrap/cursor.cpp b/c/clang/_wrap/cursor.cpp index db550aae..c4251ce4 100644 --- a/c/clang/_wrap/cursor.cpp +++ b/c/clang/_wrap/cursor.cpp @@ -111,6 +111,8 @@ long long wrap_clang_getArraySize(CXType *arrayTyp) { return clang_getArraySize( void wrap_clang_Type_getNamedType(CXType *typ, CXType *namedTyp) { *namedTyp = clang_Type_getNamedType(*typ); } +long long wrap_clang_Type_getSizeOf(CXType *typ) { return clang_Type_getSizeOf(*typ); } + unsigned wrap_clang_Cursor_isAnonymous(CXCursor *cursor) { return clang_Cursor_isAnonymous(*cursor); } unsigned wrap_clang_Cursor_isAnonymousRecordDecl(CXCursor *cursor) { diff --git a/c/clang/clang.go b/c/clang/clang.go index 0f3e25f0..556b3664 100644 --- a/c/clang/clang.go +++ b/c/clang/clang.go @@ -2148,6 +2148,61 @@ func (t Type) NamedType() (ret Type) { return } +/** + * 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. + */ +type LayoutError c.Int + +const ( + /** + * Type is of kind CXType_Invalid. + */ + LayoutErrorInvalid LayoutError = -1 + /** + * The type is an incomplete Type. + */ + LayoutErrorIncomplete LayoutError = -2 + /** + * The type is a dependent Type. + */ + LayoutErrorDependent LayoutError = -3 + /** + * The type is not a constant size type. + */ + LayoutErrorNotConstantSize LayoutError = -4 + /** + * The Field name is not valid for this record. + */ + LayoutErrorInvalidFieldName LayoutError = -5 + /** + * The type is undeduced. + */ + LayoutErrorUndeduced LayoutError = -6 +) + +/** + * Return the size of a type in bytes as per C++[expr.sizeof] standard. + * + * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + * is returned. + * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + * returned. + */ +// llgo:link (*Type).wrapSizeOf C.wrap_clang_Type_getSizeOf +func (t *Type) wrapSizeOf() (ret c.LongLong) { + return 0 +} + +func (t Type) SizeOf() (ret c.LongLong) { + return t.wrapSizeOf() +} + /** * Determine whether the given cursor represents an anonymous * tag or namespace