From c493157539b92787b3ced53b701cc0b6a429ddde Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 26 Sep 2026 05:47:38 +0800 Subject: [PATCH 1/3] cl typeName: add removePrefix param to resolve name conflict --- cl/ctx.go | 7 +- cl/enum.go | 8 +- tool/_testc/llvm-22.1.8/Index.go | 188 +++++++++++++-------------- tool/_testc/llvm-22.1.8/Index/out.go | 188 +++++++++++++-------------- tool/_testc/llvm-22.1.8/llcppg.cfg | 4 +- tool/gen_test.go | 2 +- 6 files changed, 202 insertions(+), 195 deletions(-) diff --git a/cl/ctx.go b/cl/ctx.go index fcd184cc..1b329990 100644 --- a/cl/ctx.go +++ b/cl/ctx.go @@ -236,8 +236,11 @@ func (p *pkgCtx) macroName(name string) string { return p.cstyleToGo(name, true) } -func (p *pkgCtx) typeName(name string, _ bool) string { - return p.cstyleToGo(rmPrefix(name, p.typePrefix), true) +func (p *pkgCtx) typeName(name string, removePrefix bool) string { + if removePrefix { + name = rmPrefix(name, p.typePrefix) + } + return p.cstyleToGo(name, true) } func (p *pkgCtx) enumvalName(name string) string { diff --git a/cl/enum.go b/cl/enum.go index 131ed99a..fed440ed 100644 --- a/cl/enum.go +++ b/cl/enum.go @@ -58,10 +58,14 @@ func loadEnum(ctx *pkgCtx, decl clang.Cursor, ns string) { if doc := ctx.docCommentGroup(decl); doc != nil { typDefs.SetComments(doc) } - // C enums decay to int; use the same C int type the rest of the - // generator uses so enum-typed values interoperate with C APIs. typeName := ctx.typeName(origName, true) + if pkgTypes.Scope().Lookup(typeName) != nil { + // fallback to the original name if the prefix-stripped name is already taken + typeName = ctx.typeName(origName, false) + } typDecl := typDefs.NewType(typeName, goNode(ctx, decl)) + // C enums decay to int; use the same C int type the rest of the + // generator uses so enum-typed values interoperate with C APIs. typNamed := typDecl.InitType(pkg, ctx.basicTyp(cInt)) ctx.addType(tagEnum, decl, typNamed) enumType = typNamed diff --git a/tool/_testc/llvm-22.1.8/Index.go b/tool/_testc/llvm-22.1.8/Index.go index 8997962a..cb8b0ad2 100644 --- a/tool/_testc/llvm-22.1.8/Index.go +++ b/tool/_testc/llvm-22.1.8/Index.go @@ -1863,69 +1863,69 @@ const ( // Represents the C++ access control level to a base class for a // cursor with kind CX_CXXBaseSpecifier. -type X_CXXAccessSpecifier c.Int +type CXXAccessSpecifier c.Int const ( - X_CXXInvalidAccessSpecifier X_CXXAccessSpecifier = 0 - X_CXXPublic X_CXXAccessSpecifier = 1 - X_CXXProtected X_CXXAccessSpecifier = 2 - X_CXXPrivate X_CXXAccessSpecifier = 3 + CXXInvalidAccessSpecifier CXXAccessSpecifier = 0 + CXXPublic CXXAccessSpecifier = 1 + CXXProtected CXXAccessSpecifier = 2 + CXXPrivate CXXAccessSpecifier = 3 ) // Represents the storage classes as declared in the source. CX_SC_Invalid // was added for the case that the passed cursor in not a declaration. -type X_StorageClass c.Int +type StorageClass c.Int const ( - X_SC_Invalid X_StorageClass = 0 - X_SC_None X_StorageClass = 1 - X_SC_Extern X_StorageClass = 2 - X_SC_Static X_StorageClass = 3 - X_SC_PrivateExtern X_StorageClass = 4 - X_SC_OpenCLWorkGroupLocal X_StorageClass = 5 - X_SC_Auto X_StorageClass = 6 - X_SC_Register X_StorageClass = 7 + SC_Invalid StorageClass = 0 + SC_None StorageClass = 1 + SC_Extern StorageClass = 2 + SC_Static StorageClass = 3 + SC_PrivateExtern StorageClass = 4 + SC_OpenCLWorkGroupLocal StorageClass = 5 + SC_Auto StorageClass = 6 + SC_Register StorageClass = 7 ) // Represents a specific kind of binary operator which can appear at a cursor. -type X_BinaryOperatorKind c.Int +type BinaryOperatorKind c.Int const ( - X_BO_Invalid X_BinaryOperatorKind = 0 - X_BO_PtrMemD X_BinaryOperatorKind = 1 - X_BO_PtrMemI X_BinaryOperatorKind = 2 - X_BO_Mul X_BinaryOperatorKind = 3 - X_BO_Div X_BinaryOperatorKind = 4 - X_BO_Rem X_BinaryOperatorKind = 5 - X_BO_Add X_BinaryOperatorKind = 6 - X_BO_Sub X_BinaryOperatorKind = 7 - X_BO_Shl X_BinaryOperatorKind = 8 - X_BO_Shr X_BinaryOperatorKind = 9 - X_BO_Cmp X_BinaryOperatorKind = 10 - X_BO_LT X_BinaryOperatorKind = 11 - X_BO_GT X_BinaryOperatorKind = 12 - X_BO_LE X_BinaryOperatorKind = 13 - X_BO_GE X_BinaryOperatorKind = 14 - X_BO_EQ X_BinaryOperatorKind = 15 - X_BO_NE X_BinaryOperatorKind = 16 - X_BO_And X_BinaryOperatorKind = 17 - X_BO_Xor X_BinaryOperatorKind = 18 - X_BO_Or X_BinaryOperatorKind = 19 - X_BO_LAnd X_BinaryOperatorKind = 20 - X_BO_LOr X_BinaryOperatorKind = 21 - X_BO_Assign X_BinaryOperatorKind = 22 - X_BO_MulAssign X_BinaryOperatorKind = 23 - X_BO_DivAssign X_BinaryOperatorKind = 24 - X_BO_RemAssign X_BinaryOperatorKind = 25 - X_BO_AddAssign X_BinaryOperatorKind = 26 - X_BO_SubAssign X_BinaryOperatorKind = 27 - X_BO_ShlAssign X_BinaryOperatorKind = 28 - X_BO_ShrAssign X_BinaryOperatorKind = 29 - X_BO_AndAssign X_BinaryOperatorKind = 30 - X_BO_XorAssign X_BinaryOperatorKind = 31 - X_BO_OrAssign X_BinaryOperatorKind = 32 - X_BO_Comma X_BinaryOperatorKind = 33 - X_BO_LAST X_BinaryOperatorKind = 33 + BO_Invalid BinaryOperatorKind = 0 + BO_PtrMemD BinaryOperatorKind = 1 + BO_PtrMemI BinaryOperatorKind = 2 + BO_Mul BinaryOperatorKind = 3 + BO_Div BinaryOperatorKind = 4 + BO_Rem BinaryOperatorKind = 5 + BO_Add BinaryOperatorKind = 6 + BO_Sub BinaryOperatorKind = 7 + BO_Shl BinaryOperatorKind = 8 + BO_Shr BinaryOperatorKind = 9 + BO_Cmp BinaryOperatorKind = 10 + BO_LT BinaryOperatorKind = 11 + BO_GT BinaryOperatorKind = 12 + BO_LE BinaryOperatorKind = 13 + BO_GE BinaryOperatorKind = 14 + BO_EQ BinaryOperatorKind = 15 + BO_NE BinaryOperatorKind = 16 + BO_And BinaryOperatorKind = 17 + BO_Xor BinaryOperatorKind = 18 + BO_Or BinaryOperatorKind = 19 + BO_LAnd BinaryOperatorKind = 20 + BO_LOr BinaryOperatorKind = 21 + BO_Assign BinaryOperatorKind = 22 + BO_MulAssign BinaryOperatorKind = 23 + BO_DivAssign BinaryOperatorKind = 24 + BO_RemAssign BinaryOperatorKind = 25 + BO_AddAssign BinaryOperatorKind = 26 + BO_SubAssign BinaryOperatorKind = 27 + BO_ShlAssign BinaryOperatorKind = 28 + BO_ShrAssign BinaryOperatorKind = 29 + BO_AndAssign BinaryOperatorKind = 30 + BO_XorAssign BinaryOperatorKind = 31 + BO_OrAssign BinaryOperatorKind = 32 + BO_Comma BinaryOperatorKind = 33 + BO_LAST BinaryOperatorKind = 33 ) // Describes how the traversal of the children of a particular @@ -2686,79 +2686,79 @@ const ( type FieldVisitor = func(_llcppg_param1 Cursor, _llcppg_param2 ClientData) VisitorResult // Describes the kind of binary operators. -type BinaryOperatorKind c.Int +type CXBinaryOperatorKind c.Int const ( // This value describes cursors which are not binary operators. - BinaryOperator_Invalid BinaryOperatorKind = 0 + BinaryOperator_Invalid CXBinaryOperatorKind = 0 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemD BinaryOperatorKind = 1 + BinaryOperator_PtrMemD CXBinaryOperatorKind = 1 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemI BinaryOperatorKind = 2 + BinaryOperator_PtrMemI CXBinaryOperatorKind = 2 // Multiplication operator. - BinaryOperator_Mul BinaryOperatorKind = 3 + BinaryOperator_Mul CXBinaryOperatorKind = 3 // Division operator. - BinaryOperator_Div BinaryOperatorKind = 4 + BinaryOperator_Div CXBinaryOperatorKind = 4 // Remainder operator. - BinaryOperator_Rem BinaryOperatorKind = 5 + BinaryOperator_Rem CXBinaryOperatorKind = 5 // Addition operator. - BinaryOperator_Add BinaryOperatorKind = 6 + BinaryOperator_Add CXBinaryOperatorKind = 6 // Subtraction operator. - BinaryOperator_Sub BinaryOperatorKind = 7 + BinaryOperator_Sub CXBinaryOperatorKind = 7 // Bitwise shift left operator. - BinaryOperator_Shl BinaryOperatorKind = 8 + BinaryOperator_Shl CXBinaryOperatorKind = 8 // Bitwise shift right operator. - BinaryOperator_Shr BinaryOperatorKind = 9 + BinaryOperator_Shr CXBinaryOperatorKind = 9 // C++ three-way comparison (spaceship) operator. - BinaryOperator_Cmp BinaryOperatorKind = 10 + BinaryOperator_Cmp CXBinaryOperatorKind = 10 // Less than operator. - BinaryOperator_LT BinaryOperatorKind = 11 + BinaryOperator_LT CXBinaryOperatorKind = 11 // Greater than operator. - BinaryOperator_GT BinaryOperatorKind = 12 + BinaryOperator_GT CXBinaryOperatorKind = 12 // Less or equal operator. - BinaryOperator_LE BinaryOperatorKind = 13 + BinaryOperator_LE CXBinaryOperatorKind = 13 // Greater or equal operator. - BinaryOperator_GE BinaryOperatorKind = 14 + BinaryOperator_GE CXBinaryOperatorKind = 14 // Equal operator. - BinaryOperator_EQ BinaryOperatorKind = 15 + BinaryOperator_EQ CXBinaryOperatorKind = 15 // Not equal operator. - BinaryOperator_NE BinaryOperatorKind = 16 + BinaryOperator_NE CXBinaryOperatorKind = 16 // Bitwise AND operator. - BinaryOperator_And BinaryOperatorKind = 17 + BinaryOperator_And CXBinaryOperatorKind = 17 // Bitwise XOR operator. - BinaryOperator_Xor BinaryOperatorKind = 18 + BinaryOperator_Xor CXBinaryOperatorKind = 18 // Bitwise OR operator. - BinaryOperator_Or BinaryOperatorKind = 19 + BinaryOperator_Or CXBinaryOperatorKind = 19 // Logical AND operator. - BinaryOperator_LAnd BinaryOperatorKind = 20 + BinaryOperator_LAnd CXBinaryOperatorKind = 20 // Logical OR operator. - BinaryOperator_LOr BinaryOperatorKind = 21 + BinaryOperator_LOr CXBinaryOperatorKind = 21 // Assignment operator. - BinaryOperator_Assign BinaryOperatorKind = 22 + BinaryOperator_Assign CXBinaryOperatorKind = 22 // Multiplication assignment operator. - BinaryOperator_MulAssign BinaryOperatorKind = 23 + BinaryOperator_MulAssign CXBinaryOperatorKind = 23 // Division assignment operator. - BinaryOperator_DivAssign BinaryOperatorKind = 24 + BinaryOperator_DivAssign CXBinaryOperatorKind = 24 // Remainder assignment operator. - BinaryOperator_RemAssign BinaryOperatorKind = 25 + BinaryOperator_RemAssign CXBinaryOperatorKind = 25 // Addition assignment operator. - BinaryOperator_AddAssign BinaryOperatorKind = 26 + BinaryOperator_AddAssign CXBinaryOperatorKind = 26 // Subtraction assignment operator. - BinaryOperator_SubAssign BinaryOperatorKind = 27 + BinaryOperator_SubAssign CXBinaryOperatorKind = 27 // Bitwise shift left assignment operator. - BinaryOperator_ShlAssign BinaryOperatorKind = 28 + BinaryOperator_ShlAssign CXBinaryOperatorKind = 28 // Bitwise shift right assignment operator. - BinaryOperator_ShrAssign BinaryOperatorKind = 29 + BinaryOperator_ShrAssign CXBinaryOperatorKind = 29 // Bitwise AND assignment operator. - BinaryOperator_AndAssign BinaryOperatorKind = 30 + BinaryOperator_AndAssign CXBinaryOperatorKind = 30 // Bitwise XOR assignment operator. - BinaryOperator_XorAssign BinaryOperatorKind = 31 + BinaryOperator_XorAssign CXBinaryOperatorKind = 31 // Bitwise OR assignment operator. - BinaryOperator_OrAssign BinaryOperatorKind = 32 + BinaryOperator_OrAssign CXBinaryOperatorKind = 32 // Comma operator. - BinaryOperator_Comma BinaryOperatorKind = 33 + BinaryOperator_Comma CXBinaryOperatorKind = 33 // Comma operator. - BinaryOperator_Last BinaryOperatorKind = 33 + BinaryOperator_Last CXBinaryOperatorKind = 33 ) // Describes the kind of unary operators. @@ -4600,7 +4600,7 @@ func GetOffsetOfBase(Parent Cursor, Base Cursor) c.LongLong // specifier or access specifier, the specifier itself is returned. // // llgo:link Cursor.CXXAccessSpecifier C.clang_getCXXAccessSpecifier -func (_llcppg_param1 Cursor) CXXAccessSpecifier() X_CXXAccessSpecifier { +func (_llcppg_param1 Cursor) CXXAccessSpecifier() CXXAccessSpecifier { return 0 } @@ -4609,7 +4609,7 @@ func (_llcppg_param1 Cursor) CXXAccessSpecifier() X_CXXAccessSpecifier { // @deprecated: use clang_getCursorBinaryOperatorKind instead. // // llgo:link Cursor.BinaryOpcode C.clang_Cursor_getBinaryOpcode -func (C Cursor) BinaryOpcode() X_BinaryOperatorKind { +func (C Cursor) BinaryOpcode() BinaryOperatorKind { return 0 } @@ -4617,8 +4617,8 @@ func (C Cursor) BinaryOpcode() X_BinaryOperatorKind { // // @deprecated: use clang_getBinaryOperatorKindSpelling instead // -// llgo:link X_BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr -func (Op X_BinaryOperatorKind) CursorGetBinaryOpcodeStr() String { +// llgo:link BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr +func (Op BinaryOperatorKind) CursorGetBinaryOpcodeStr() String { return String{} } @@ -4628,7 +4628,7 @@ func (Op X_BinaryOperatorKind) CursorGetBinaryOpcodeStr() String { // CX_SC_Invalid is returned else the storage class. // // llgo:link Cursor.StorageClass C.clang_Cursor_getStorageClass -func (_llcppg_param1 Cursor) StorageClass() X_StorageClass { +func (_llcppg_param1 Cursor) StorageClass() StorageClass { return 0 } @@ -6444,8 +6444,8 @@ func (T Type) VisitCXXMethods(visitor FieldVisitor, client_data ClientData) c.Ui // Retrieve the spelling of a given CXBinaryOperatorKind. // -// llgo:link BinaryOperatorKind.Spelling C.clang_getBinaryOperatorKindSpelling -func (kind BinaryOperatorKind) Spelling() String { +// llgo:link CXBinaryOperatorKind.BinaryOperatorKindSpelling C.clang_getBinaryOperatorKindSpelling +func (kind CXBinaryOperatorKind) BinaryOperatorKindSpelling() String { return String{} } @@ -6454,7 +6454,7 @@ func (kind BinaryOperatorKind) Spelling() String { // If this cursor is not a binary operator then returns Invalid. // // llgo:link Cursor.BinaryOperatorKind C.clang_getCursorBinaryOperatorKind -func (cursor Cursor) BinaryOperatorKind() BinaryOperatorKind { +func (cursor Cursor) BinaryOperatorKind() CXBinaryOperatorKind { return 0 } diff --git a/tool/_testc/llvm-22.1.8/Index/out.go b/tool/_testc/llvm-22.1.8/Index/out.go index d5566b7e..a55662fa 100644 --- a/tool/_testc/llvm-22.1.8/Index/out.go +++ b/tool/_testc/llvm-22.1.8/Index/out.go @@ -1870,69 +1870,69 @@ const ( // Represents the C++ access control level to a base class for a // cursor with kind CX_CXXBaseSpecifier. -type X_CXXAccessSpecifier c.Int +type CXXAccessSpecifier c.Int const ( - X_CXXInvalidAccessSpecifier X_CXXAccessSpecifier = 0 - X_CXXPublic X_CXXAccessSpecifier = 1 - X_CXXProtected X_CXXAccessSpecifier = 2 - X_CXXPrivate X_CXXAccessSpecifier = 3 + CXXInvalidAccessSpecifier CXXAccessSpecifier = 0 + CXXPublic CXXAccessSpecifier = 1 + CXXProtected CXXAccessSpecifier = 2 + CXXPrivate CXXAccessSpecifier = 3 ) // Represents the storage classes as declared in the source. CX_SC_Invalid // was added for the case that the passed cursor in not a declaration. -type X_StorageClass c.Int +type StorageClass c.Int const ( - X_SC_Invalid X_StorageClass = 0 - X_SC_None X_StorageClass = 1 - X_SC_Extern X_StorageClass = 2 - X_SC_Static X_StorageClass = 3 - X_SC_PrivateExtern X_StorageClass = 4 - X_SC_OpenCLWorkGroupLocal X_StorageClass = 5 - X_SC_Auto X_StorageClass = 6 - X_SC_Register X_StorageClass = 7 + SC_Invalid StorageClass = 0 + SC_None StorageClass = 1 + SC_Extern StorageClass = 2 + SC_Static StorageClass = 3 + SC_PrivateExtern StorageClass = 4 + SC_OpenCLWorkGroupLocal StorageClass = 5 + SC_Auto StorageClass = 6 + SC_Register StorageClass = 7 ) // Represents a specific kind of binary operator which can appear at a cursor. -type X_BinaryOperatorKind c.Int +type BinaryOperatorKind c.Int const ( - X_BO_Invalid X_BinaryOperatorKind = 0 - X_BO_PtrMemD X_BinaryOperatorKind = 1 - X_BO_PtrMemI X_BinaryOperatorKind = 2 - X_BO_Mul X_BinaryOperatorKind = 3 - X_BO_Div X_BinaryOperatorKind = 4 - X_BO_Rem X_BinaryOperatorKind = 5 - X_BO_Add X_BinaryOperatorKind = 6 - X_BO_Sub X_BinaryOperatorKind = 7 - X_BO_Shl X_BinaryOperatorKind = 8 - X_BO_Shr X_BinaryOperatorKind = 9 - X_BO_Cmp X_BinaryOperatorKind = 10 - X_BO_LT X_BinaryOperatorKind = 11 - X_BO_GT X_BinaryOperatorKind = 12 - X_BO_LE X_BinaryOperatorKind = 13 - X_BO_GE X_BinaryOperatorKind = 14 - X_BO_EQ X_BinaryOperatorKind = 15 - X_BO_NE X_BinaryOperatorKind = 16 - X_BO_And X_BinaryOperatorKind = 17 - X_BO_Xor X_BinaryOperatorKind = 18 - X_BO_Or X_BinaryOperatorKind = 19 - X_BO_LAnd X_BinaryOperatorKind = 20 - X_BO_LOr X_BinaryOperatorKind = 21 - X_BO_Assign X_BinaryOperatorKind = 22 - X_BO_MulAssign X_BinaryOperatorKind = 23 - X_BO_DivAssign X_BinaryOperatorKind = 24 - X_BO_RemAssign X_BinaryOperatorKind = 25 - X_BO_AddAssign X_BinaryOperatorKind = 26 - X_BO_SubAssign X_BinaryOperatorKind = 27 - X_BO_ShlAssign X_BinaryOperatorKind = 28 - X_BO_ShrAssign X_BinaryOperatorKind = 29 - X_BO_AndAssign X_BinaryOperatorKind = 30 - X_BO_XorAssign X_BinaryOperatorKind = 31 - X_BO_OrAssign X_BinaryOperatorKind = 32 - X_BO_Comma X_BinaryOperatorKind = 33 - X_BO_LAST X_BinaryOperatorKind = 33 + BO_Invalid BinaryOperatorKind = 0 + BO_PtrMemD BinaryOperatorKind = 1 + BO_PtrMemI BinaryOperatorKind = 2 + BO_Mul BinaryOperatorKind = 3 + BO_Div BinaryOperatorKind = 4 + BO_Rem BinaryOperatorKind = 5 + BO_Add BinaryOperatorKind = 6 + BO_Sub BinaryOperatorKind = 7 + BO_Shl BinaryOperatorKind = 8 + BO_Shr BinaryOperatorKind = 9 + BO_Cmp BinaryOperatorKind = 10 + BO_LT BinaryOperatorKind = 11 + BO_GT BinaryOperatorKind = 12 + BO_LE BinaryOperatorKind = 13 + BO_GE BinaryOperatorKind = 14 + BO_EQ BinaryOperatorKind = 15 + BO_NE BinaryOperatorKind = 16 + BO_And BinaryOperatorKind = 17 + BO_Xor BinaryOperatorKind = 18 + BO_Or BinaryOperatorKind = 19 + BO_LAnd BinaryOperatorKind = 20 + BO_LOr BinaryOperatorKind = 21 + BO_Assign BinaryOperatorKind = 22 + BO_MulAssign BinaryOperatorKind = 23 + BO_DivAssign BinaryOperatorKind = 24 + BO_RemAssign BinaryOperatorKind = 25 + BO_AddAssign BinaryOperatorKind = 26 + BO_SubAssign BinaryOperatorKind = 27 + BO_ShlAssign BinaryOperatorKind = 28 + BO_ShrAssign BinaryOperatorKind = 29 + BO_AndAssign BinaryOperatorKind = 30 + BO_XorAssign BinaryOperatorKind = 31 + BO_OrAssign BinaryOperatorKind = 32 + BO_Comma BinaryOperatorKind = 33 + BO_LAST BinaryOperatorKind = 33 ) // Describes how the traversal of the children of a particular @@ -2693,79 +2693,79 @@ const ( type FieldVisitor = func(_llcppg_param1 Cursor, _llcppg_param2 ClientData) VisitorResult // Describes the kind of binary operators. -type BinaryOperatorKind c.Int +type CXBinaryOperatorKind c.Int const ( // This value describes cursors which are not binary operators. - BinaryOperator_Invalid BinaryOperatorKind = 0 + BinaryOperator_Invalid CXBinaryOperatorKind = 0 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemD BinaryOperatorKind = 1 + BinaryOperator_PtrMemD CXBinaryOperatorKind = 1 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemI BinaryOperatorKind = 2 + BinaryOperator_PtrMemI CXBinaryOperatorKind = 2 // Multiplication operator. - BinaryOperator_Mul BinaryOperatorKind = 3 + BinaryOperator_Mul CXBinaryOperatorKind = 3 // Division operator. - BinaryOperator_Div BinaryOperatorKind = 4 + BinaryOperator_Div CXBinaryOperatorKind = 4 // Remainder operator. - BinaryOperator_Rem BinaryOperatorKind = 5 + BinaryOperator_Rem CXBinaryOperatorKind = 5 // Addition operator. - BinaryOperator_Add BinaryOperatorKind = 6 + BinaryOperator_Add CXBinaryOperatorKind = 6 // Subtraction operator. - BinaryOperator_Sub BinaryOperatorKind = 7 + BinaryOperator_Sub CXBinaryOperatorKind = 7 // Bitwise shift left operator. - BinaryOperator_Shl BinaryOperatorKind = 8 + BinaryOperator_Shl CXBinaryOperatorKind = 8 // Bitwise shift right operator. - BinaryOperator_Shr BinaryOperatorKind = 9 + BinaryOperator_Shr CXBinaryOperatorKind = 9 // C++ three-way comparison (spaceship) operator. - BinaryOperator_Cmp BinaryOperatorKind = 10 + BinaryOperator_Cmp CXBinaryOperatorKind = 10 // Less than operator. - BinaryOperator_LT BinaryOperatorKind = 11 + BinaryOperator_LT CXBinaryOperatorKind = 11 // Greater than operator. - BinaryOperator_GT BinaryOperatorKind = 12 + BinaryOperator_GT CXBinaryOperatorKind = 12 // Less or equal operator. - BinaryOperator_LE BinaryOperatorKind = 13 + BinaryOperator_LE CXBinaryOperatorKind = 13 // Greater or equal operator. - BinaryOperator_GE BinaryOperatorKind = 14 + BinaryOperator_GE CXBinaryOperatorKind = 14 // Equal operator. - BinaryOperator_EQ BinaryOperatorKind = 15 + BinaryOperator_EQ CXBinaryOperatorKind = 15 // Not equal operator. - BinaryOperator_NE BinaryOperatorKind = 16 + BinaryOperator_NE CXBinaryOperatorKind = 16 // Bitwise AND operator. - BinaryOperator_And BinaryOperatorKind = 17 + BinaryOperator_And CXBinaryOperatorKind = 17 // Bitwise XOR operator. - BinaryOperator_Xor BinaryOperatorKind = 18 + BinaryOperator_Xor CXBinaryOperatorKind = 18 // Bitwise OR operator. - BinaryOperator_Or BinaryOperatorKind = 19 + BinaryOperator_Or CXBinaryOperatorKind = 19 // Logical AND operator. - BinaryOperator_LAnd BinaryOperatorKind = 20 + BinaryOperator_LAnd CXBinaryOperatorKind = 20 // Logical OR operator. - BinaryOperator_LOr BinaryOperatorKind = 21 + BinaryOperator_LOr CXBinaryOperatorKind = 21 // Assignment operator. - BinaryOperator_Assign BinaryOperatorKind = 22 + BinaryOperator_Assign CXBinaryOperatorKind = 22 // Multiplication assignment operator. - BinaryOperator_MulAssign BinaryOperatorKind = 23 + BinaryOperator_MulAssign CXBinaryOperatorKind = 23 // Division assignment operator. - BinaryOperator_DivAssign BinaryOperatorKind = 24 + BinaryOperator_DivAssign CXBinaryOperatorKind = 24 // Remainder assignment operator. - BinaryOperator_RemAssign BinaryOperatorKind = 25 + BinaryOperator_RemAssign CXBinaryOperatorKind = 25 // Addition assignment operator. - BinaryOperator_AddAssign BinaryOperatorKind = 26 + BinaryOperator_AddAssign CXBinaryOperatorKind = 26 // Subtraction assignment operator. - BinaryOperator_SubAssign BinaryOperatorKind = 27 + BinaryOperator_SubAssign CXBinaryOperatorKind = 27 // Bitwise shift left assignment operator. - BinaryOperator_ShlAssign BinaryOperatorKind = 28 + BinaryOperator_ShlAssign CXBinaryOperatorKind = 28 // Bitwise shift right assignment operator. - BinaryOperator_ShrAssign BinaryOperatorKind = 29 + BinaryOperator_ShrAssign CXBinaryOperatorKind = 29 // Bitwise AND assignment operator. - BinaryOperator_AndAssign BinaryOperatorKind = 30 + BinaryOperator_AndAssign CXBinaryOperatorKind = 30 // Bitwise XOR assignment operator. - BinaryOperator_XorAssign BinaryOperatorKind = 31 + BinaryOperator_XorAssign CXBinaryOperatorKind = 31 // Bitwise OR assignment operator. - BinaryOperator_OrAssign BinaryOperatorKind = 32 + BinaryOperator_OrAssign CXBinaryOperatorKind = 32 // Comma operator. - BinaryOperator_Comma BinaryOperatorKind = 33 + BinaryOperator_Comma CXBinaryOperatorKind = 33 // Comma operator. - BinaryOperator_Last BinaryOperatorKind = 33 + BinaryOperator_Last CXBinaryOperatorKind = 33 ) // Describes the kind of unary operators. @@ -4607,7 +4607,7 @@ func GetOffsetOfBase(Parent Cursor, Base Cursor) c.LongLong // specifier or access specifier, the specifier itself is returned. // // llgo:link Cursor.CXXAccessSpecifier C.clang_getCXXAccessSpecifier -func (_llcppg_param1 Cursor) CXXAccessSpecifier() X_CXXAccessSpecifier { +func (_llcppg_param1 Cursor) CXXAccessSpecifier() CXXAccessSpecifier { return 0 } @@ -4616,7 +4616,7 @@ func (_llcppg_param1 Cursor) CXXAccessSpecifier() X_CXXAccessSpecifier { // @deprecated: use clang_getCursorBinaryOperatorKind instead. // // llgo:link Cursor.BinaryOpcode C.clang_Cursor_getBinaryOpcode -func (C Cursor) BinaryOpcode() X_BinaryOperatorKind { +func (C Cursor) BinaryOpcode() BinaryOperatorKind { return 0 } @@ -4624,8 +4624,8 @@ func (C Cursor) BinaryOpcode() X_BinaryOperatorKind { // // @deprecated: use clang_getBinaryOperatorKindSpelling instead // -// llgo:link X_BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr -func (Op X_BinaryOperatorKind) CursorGetBinaryOpcodeStr() CXString.String { +// llgo:link BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr +func (Op BinaryOperatorKind) CursorGetBinaryOpcodeStr() CXString.String { return CXString.String{} } @@ -4635,7 +4635,7 @@ func (Op X_BinaryOperatorKind) CursorGetBinaryOpcodeStr() CXString.String { // CX_SC_Invalid is returned else the storage class. // // llgo:link Cursor.StorageClass C.clang_Cursor_getStorageClass -func (_llcppg_param1 Cursor) StorageClass() X_StorageClass { +func (_llcppg_param1 Cursor) StorageClass() StorageClass { return 0 } @@ -6451,8 +6451,8 @@ func (T Type) VisitCXXMethods(visitor FieldVisitor, client_data ClientData) c.Ui // Retrieve the spelling of a given CXBinaryOperatorKind. // -// llgo:link BinaryOperatorKind.Spelling C.clang_getBinaryOperatorKindSpelling -func (kind BinaryOperatorKind) Spelling() CXString.String { +// llgo:link CXBinaryOperatorKind.BinaryOperatorKindSpelling C.clang_getBinaryOperatorKindSpelling +func (kind CXBinaryOperatorKind) BinaryOperatorKindSpelling() CXString.String { return CXString.String{} } @@ -6461,7 +6461,7 @@ func (kind BinaryOperatorKind) Spelling() CXString.String { // If this cursor is not a binary operator then returns Invalid. // // llgo:link Cursor.BinaryOperatorKind C.clang_getCursorBinaryOperatorKind -func (cursor Cursor) BinaryOperatorKind() BinaryOperatorKind { +func (cursor Cursor) BinaryOperatorKind() CXBinaryOperatorKind { return 0 } diff --git a/tool/_testc/llvm-22.1.8/llcppg.cfg b/tool/_testc/llvm-22.1.8/llcppg.cfg index 3f17bb62..2c616591 100644 --- a/tool/_testc/llvm-22.1.8/llcppg.cfg +++ b/tool/_testc/llvm-22.1.8/llcppg.cfg @@ -6,8 +6,8 @@ "Class": [], "NonClass": ["CXClientData", "CXCursorVisitorBlock", "CXCursorAndRangeVisitorBlock"], "FuncPrefix": ["clang_"], - "EnumPrefix": ["CX"], - "TypePrefix": ["CX"], + "EnumPrefix": ["CX_", "CX"], + "TypePrefix": ["CX_", "CX"], "TypeAbbr": { "SourceLocation": "Location", "SourceRange": "Range" diff --git a/tool/gen_test.go b/tool/gen_test.go index 367a8ee3..171f5f76 100644 --- a/tool/gen_test.go +++ b/tool/gen_test.go @@ -38,7 +38,7 @@ import ( func init() { cl.SetDebug(cl.DbgFlagAll) - tool.SetDebug(tool.DbgFlagAll) + // tool.SetDebug(tool.DbgFlagAll) } func testDiff(t *testing.T, dir string, outfname string, b *bytes.Buffer, exp any) { From bdcd456f621a34c05d20045874c887637b37a40f Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 26 Sep 2026 06:08:59 +0800 Subject: [PATCH 2/3] cl typeName: global rename for special case --- cl/ctx.go | 8 +- cl/enum.go | 4 - tool/_testc/llvm-22.1.8/Index.go | 156 ++++++++++++++--------------- tool/_testc/llvm-22.1.8/llcppg.cfg | 1 + 4 files changed, 83 insertions(+), 86 deletions(-) diff --git a/cl/ctx.go b/cl/ctx.go index 1b329990..6998e954 100644 --- a/cl/ctx.go +++ b/cl/ctx.go @@ -236,11 +236,11 @@ func (p *pkgCtx) macroName(name string) string { return p.cstyleToGo(name, true) } -func (p *pkgCtx) typeName(name string, removePrefix bool) string { - if removePrefix { - name = rmPrefix(name, p.typePrefix) +func (p *pkgCtx) typeName(name string, _ bool) string { + if v, ok := p.rename[name]; ok { + return v } - return p.cstyleToGo(name, true) + return p.cstyleToGo(rmPrefix(name, p.typePrefix), true) } func (p *pkgCtx) enumvalName(name string) string { diff --git a/cl/enum.go b/cl/enum.go index fed440ed..8748cbbe 100644 --- a/cl/enum.go +++ b/cl/enum.go @@ -59,10 +59,6 @@ func loadEnum(ctx *pkgCtx, decl clang.Cursor, ns string) { typDefs.SetComments(doc) } typeName := ctx.typeName(origName, true) - if pkgTypes.Scope().Lookup(typeName) != nil { - // fallback to the original name if the prefix-stripped name is already taken - typeName = ctx.typeName(origName, false) - } typDecl := typDefs.NewType(typeName, goNode(ctx, decl)) // C enums decay to int; use the same C int type the rest of the // generator uses so enum-typed values interoperate with C APIs. diff --git a/tool/_testc/llvm-22.1.8/Index.go b/tool/_testc/llvm-22.1.8/Index.go index cb8b0ad2..a02d5b95 100644 --- a/tool/_testc/llvm-22.1.8/Index.go +++ b/tool/_testc/llvm-22.1.8/Index.go @@ -1888,44 +1888,44 @@ const ( ) // Represents a specific kind of binary operator which can appear at a cursor. -type BinaryOperatorKind c.Int +type X_BinaryOperatorKind c.Int const ( - BO_Invalid BinaryOperatorKind = 0 - BO_PtrMemD BinaryOperatorKind = 1 - BO_PtrMemI BinaryOperatorKind = 2 - BO_Mul BinaryOperatorKind = 3 - BO_Div BinaryOperatorKind = 4 - BO_Rem BinaryOperatorKind = 5 - BO_Add BinaryOperatorKind = 6 - BO_Sub BinaryOperatorKind = 7 - BO_Shl BinaryOperatorKind = 8 - BO_Shr BinaryOperatorKind = 9 - BO_Cmp BinaryOperatorKind = 10 - BO_LT BinaryOperatorKind = 11 - BO_GT BinaryOperatorKind = 12 - BO_LE BinaryOperatorKind = 13 - BO_GE BinaryOperatorKind = 14 - BO_EQ BinaryOperatorKind = 15 - BO_NE BinaryOperatorKind = 16 - BO_And BinaryOperatorKind = 17 - BO_Xor BinaryOperatorKind = 18 - BO_Or BinaryOperatorKind = 19 - BO_LAnd BinaryOperatorKind = 20 - BO_LOr BinaryOperatorKind = 21 - BO_Assign BinaryOperatorKind = 22 - BO_MulAssign BinaryOperatorKind = 23 - BO_DivAssign BinaryOperatorKind = 24 - BO_RemAssign BinaryOperatorKind = 25 - BO_AddAssign BinaryOperatorKind = 26 - BO_SubAssign BinaryOperatorKind = 27 - BO_ShlAssign BinaryOperatorKind = 28 - BO_ShrAssign BinaryOperatorKind = 29 - BO_AndAssign BinaryOperatorKind = 30 - BO_XorAssign BinaryOperatorKind = 31 - BO_OrAssign BinaryOperatorKind = 32 - BO_Comma BinaryOperatorKind = 33 - BO_LAST BinaryOperatorKind = 33 + BO_Invalid X_BinaryOperatorKind = 0 + BO_PtrMemD X_BinaryOperatorKind = 1 + BO_PtrMemI X_BinaryOperatorKind = 2 + BO_Mul X_BinaryOperatorKind = 3 + BO_Div X_BinaryOperatorKind = 4 + BO_Rem X_BinaryOperatorKind = 5 + BO_Add X_BinaryOperatorKind = 6 + BO_Sub X_BinaryOperatorKind = 7 + BO_Shl X_BinaryOperatorKind = 8 + BO_Shr X_BinaryOperatorKind = 9 + BO_Cmp X_BinaryOperatorKind = 10 + BO_LT X_BinaryOperatorKind = 11 + BO_GT X_BinaryOperatorKind = 12 + BO_LE X_BinaryOperatorKind = 13 + BO_GE X_BinaryOperatorKind = 14 + BO_EQ X_BinaryOperatorKind = 15 + BO_NE X_BinaryOperatorKind = 16 + BO_And X_BinaryOperatorKind = 17 + BO_Xor X_BinaryOperatorKind = 18 + BO_Or X_BinaryOperatorKind = 19 + BO_LAnd X_BinaryOperatorKind = 20 + BO_LOr X_BinaryOperatorKind = 21 + BO_Assign X_BinaryOperatorKind = 22 + BO_MulAssign X_BinaryOperatorKind = 23 + BO_DivAssign X_BinaryOperatorKind = 24 + BO_RemAssign X_BinaryOperatorKind = 25 + BO_AddAssign X_BinaryOperatorKind = 26 + BO_SubAssign X_BinaryOperatorKind = 27 + BO_ShlAssign X_BinaryOperatorKind = 28 + BO_ShrAssign X_BinaryOperatorKind = 29 + BO_AndAssign X_BinaryOperatorKind = 30 + BO_XorAssign X_BinaryOperatorKind = 31 + BO_OrAssign X_BinaryOperatorKind = 32 + BO_Comma X_BinaryOperatorKind = 33 + BO_LAST X_BinaryOperatorKind = 33 ) // Describes how the traversal of the children of a particular @@ -2686,79 +2686,79 @@ const ( type FieldVisitor = func(_llcppg_param1 Cursor, _llcppg_param2 ClientData) VisitorResult // Describes the kind of binary operators. -type CXBinaryOperatorKind c.Int +type BinaryOperatorKind c.Int const ( // This value describes cursors which are not binary operators. - BinaryOperator_Invalid CXBinaryOperatorKind = 0 + BinaryOperator_Invalid BinaryOperatorKind = 0 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemD CXBinaryOperatorKind = 1 + BinaryOperator_PtrMemD BinaryOperatorKind = 1 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemI CXBinaryOperatorKind = 2 + BinaryOperator_PtrMemI BinaryOperatorKind = 2 // Multiplication operator. - BinaryOperator_Mul CXBinaryOperatorKind = 3 + BinaryOperator_Mul BinaryOperatorKind = 3 // Division operator. - BinaryOperator_Div CXBinaryOperatorKind = 4 + BinaryOperator_Div BinaryOperatorKind = 4 // Remainder operator. - BinaryOperator_Rem CXBinaryOperatorKind = 5 + BinaryOperator_Rem BinaryOperatorKind = 5 // Addition operator. - BinaryOperator_Add CXBinaryOperatorKind = 6 + BinaryOperator_Add BinaryOperatorKind = 6 // Subtraction operator. - BinaryOperator_Sub CXBinaryOperatorKind = 7 + BinaryOperator_Sub BinaryOperatorKind = 7 // Bitwise shift left operator. - BinaryOperator_Shl CXBinaryOperatorKind = 8 + BinaryOperator_Shl BinaryOperatorKind = 8 // Bitwise shift right operator. - BinaryOperator_Shr CXBinaryOperatorKind = 9 + BinaryOperator_Shr BinaryOperatorKind = 9 // C++ three-way comparison (spaceship) operator. - BinaryOperator_Cmp CXBinaryOperatorKind = 10 + BinaryOperator_Cmp BinaryOperatorKind = 10 // Less than operator. - BinaryOperator_LT CXBinaryOperatorKind = 11 + BinaryOperator_LT BinaryOperatorKind = 11 // Greater than operator. - BinaryOperator_GT CXBinaryOperatorKind = 12 + BinaryOperator_GT BinaryOperatorKind = 12 // Less or equal operator. - BinaryOperator_LE CXBinaryOperatorKind = 13 + BinaryOperator_LE BinaryOperatorKind = 13 // Greater or equal operator. - BinaryOperator_GE CXBinaryOperatorKind = 14 + BinaryOperator_GE BinaryOperatorKind = 14 // Equal operator. - BinaryOperator_EQ CXBinaryOperatorKind = 15 + BinaryOperator_EQ BinaryOperatorKind = 15 // Not equal operator. - BinaryOperator_NE CXBinaryOperatorKind = 16 + BinaryOperator_NE BinaryOperatorKind = 16 // Bitwise AND operator. - BinaryOperator_And CXBinaryOperatorKind = 17 + BinaryOperator_And BinaryOperatorKind = 17 // Bitwise XOR operator. - BinaryOperator_Xor CXBinaryOperatorKind = 18 + BinaryOperator_Xor BinaryOperatorKind = 18 // Bitwise OR operator. - BinaryOperator_Or CXBinaryOperatorKind = 19 + BinaryOperator_Or BinaryOperatorKind = 19 // Logical AND operator. - BinaryOperator_LAnd CXBinaryOperatorKind = 20 + BinaryOperator_LAnd BinaryOperatorKind = 20 // Logical OR operator. - BinaryOperator_LOr CXBinaryOperatorKind = 21 + BinaryOperator_LOr BinaryOperatorKind = 21 // Assignment operator. - BinaryOperator_Assign CXBinaryOperatorKind = 22 + BinaryOperator_Assign BinaryOperatorKind = 22 // Multiplication assignment operator. - BinaryOperator_MulAssign CXBinaryOperatorKind = 23 + BinaryOperator_MulAssign BinaryOperatorKind = 23 // Division assignment operator. - BinaryOperator_DivAssign CXBinaryOperatorKind = 24 + BinaryOperator_DivAssign BinaryOperatorKind = 24 // Remainder assignment operator. - BinaryOperator_RemAssign CXBinaryOperatorKind = 25 + BinaryOperator_RemAssign BinaryOperatorKind = 25 // Addition assignment operator. - BinaryOperator_AddAssign CXBinaryOperatorKind = 26 + BinaryOperator_AddAssign BinaryOperatorKind = 26 // Subtraction assignment operator. - BinaryOperator_SubAssign CXBinaryOperatorKind = 27 + BinaryOperator_SubAssign BinaryOperatorKind = 27 // Bitwise shift left assignment operator. - BinaryOperator_ShlAssign CXBinaryOperatorKind = 28 + BinaryOperator_ShlAssign BinaryOperatorKind = 28 // Bitwise shift right assignment operator. - BinaryOperator_ShrAssign CXBinaryOperatorKind = 29 + BinaryOperator_ShrAssign BinaryOperatorKind = 29 // Bitwise AND assignment operator. - BinaryOperator_AndAssign CXBinaryOperatorKind = 30 + BinaryOperator_AndAssign BinaryOperatorKind = 30 // Bitwise XOR assignment operator. - BinaryOperator_XorAssign CXBinaryOperatorKind = 31 + BinaryOperator_XorAssign BinaryOperatorKind = 31 // Bitwise OR assignment operator. - BinaryOperator_OrAssign CXBinaryOperatorKind = 32 + BinaryOperator_OrAssign BinaryOperatorKind = 32 // Comma operator. - BinaryOperator_Comma CXBinaryOperatorKind = 33 + BinaryOperator_Comma BinaryOperatorKind = 33 // Comma operator. - BinaryOperator_Last CXBinaryOperatorKind = 33 + BinaryOperator_Last BinaryOperatorKind = 33 ) // Describes the kind of unary operators. @@ -4609,7 +4609,7 @@ func (_llcppg_param1 Cursor) CXXAccessSpecifier() CXXAccessSpecifier { // @deprecated: use clang_getCursorBinaryOperatorKind instead. // // llgo:link Cursor.BinaryOpcode C.clang_Cursor_getBinaryOpcode -func (C Cursor) BinaryOpcode() BinaryOperatorKind { +func (C Cursor) BinaryOpcode() X_BinaryOperatorKind { return 0 } @@ -4617,8 +4617,8 @@ func (C Cursor) BinaryOpcode() BinaryOperatorKind { // // @deprecated: use clang_getBinaryOperatorKindSpelling instead // -// llgo:link BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr -func (Op BinaryOperatorKind) CursorGetBinaryOpcodeStr() String { +// llgo:link X_BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr +func (Op X_BinaryOperatorKind) CursorGetBinaryOpcodeStr() String { return String{} } @@ -6444,8 +6444,8 @@ func (T Type) VisitCXXMethods(visitor FieldVisitor, client_data ClientData) c.Ui // Retrieve the spelling of a given CXBinaryOperatorKind. // -// llgo:link CXBinaryOperatorKind.BinaryOperatorKindSpelling C.clang_getBinaryOperatorKindSpelling -func (kind CXBinaryOperatorKind) BinaryOperatorKindSpelling() String { +// llgo:link BinaryOperatorKind.Spelling C.clang_getBinaryOperatorKindSpelling +func (kind BinaryOperatorKind) Spelling() String { return String{} } @@ -6454,7 +6454,7 @@ func (kind CXBinaryOperatorKind) BinaryOperatorKindSpelling() String { // If this cursor is not a binary operator then returns Invalid. // // llgo:link Cursor.BinaryOperatorKind C.clang_getCursorBinaryOperatorKind -func (cursor Cursor) BinaryOperatorKind() CXBinaryOperatorKind { +func (cursor Cursor) BinaryOperatorKind() BinaryOperatorKind { return 0 } diff --git a/tool/_testc/llvm-22.1.8/llcppg.cfg b/tool/_testc/llvm-22.1.8/llcppg.cfg index 2c616591..6109feee 100644 --- a/tool/_testc/llvm-22.1.8/llcppg.cfg +++ b/tool/_testc/llvm-22.1.8/llcppg.cfg @@ -13,6 +13,7 @@ "SourceRange": "Range" }, "Rename": { + "CX_BinaryOperatorKind": "X_BinaryOperatorKind", "CXRewriter": "Rewriter", "getCString": "CStr" }, From faded8de1b4b7fa808f4bfee1804162a746580e6 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 26 Sep 2026 06:10:09 +0800 Subject: [PATCH 3/3] tool test: CX_BinaryOperatorKind => X_BinaryOperatorKind --- tool/_testc/llvm-22.1.8/Index/out.go | 156 +++++++++++++-------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/tool/_testc/llvm-22.1.8/Index/out.go b/tool/_testc/llvm-22.1.8/Index/out.go index a55662fa..8ab061e4 100644 --- a/tool/_testc/llvm-22.1.8/Index/out.go +++ b/tool/_testc/llvm-22.1.8/Index/out.go @@ -1895,44 +1895,44 @@ const ( ) // Represents a specific kind of binary operator which can appear at a cursor. -type BinaryOperatorKind c.Int +type X_BinaryOperatorKind c.Int const ( - BO_Invalid BinaryOperatorKind = 0 - BO_PtrMemD BinaryOperatorKind = 1 - BO_PtrMemI BinaryOperatorKind = 2 - BO_Mul BinaryOperatorKind = 3 - BO_Div BinaryOperatorKind = 4 - BO_Rem BinaryOperatorKind = 5 - BO_Add BinaryOperatorKind = 6 - BO_Sub BinaryOperatorKind = 7 - BO_Shl BinaryOperatorKind = 8 - BO_Shr BinaryOperatorKind = 9 - BO_Cmp BinaryOperatorKind = 10 - BO_LT BinaryOperatorKind = 11 - BO_GT BinaryOperatorKind = 12 - BO_LE BinaryOperatorKind = 13 - BO_GE BinaryOperatorKind = 14 - BO_EQ BinaryOperatorKind = 15 - BO_NE BinaryOperatorKind = 16 - BO_And BinaryOperatorKind = 17 - BO_Xor BinaryOperatorKind = 18 - BO_Or BinaryOperatorKind = 19 - BO_LAnd BinaryOperatorKind = 20 - BO_LOr BinaryOperatorKind = 21 - BO_Assign BinaryOperatorKind = 22 - BO_MulAssign BinaryOperatorKind = 23 - BO_DivAssign BinaryOperatorKind = 24 - BO_RemAssign BinaryOperatorKind = 25 - BO_AddAssign BinaryOperatorKind = 26 - BO_SubAssign BinaryOperatorKind = 27 - BO_ShlAssign BinaryOperatorKind = 28 - BO_ShrAssign BinaryOperatorKind = 29 - BO_AndAssign BinaryOperatorKind = 30 - BO_XorAssign BinaryOperatorKind = 31 - BO_OrAssign BinaryOperatorKind = 32 - BO_Comma BinaryOperatorKind = 33 - BO_LAST BinaryOperatorKind = 33 + BO_Invalid X_BinaryOperatorKind = 0 + BO_PtrMemD X_BinaryOperatorKind = 1 + BO_PtrMemI X_BinaryOperatorKind = 2 + BO_Mul X_BinaryOperatorKind = 3 + BO_Div X_BinaryOperatorKind = 4 + BO_Rem X_BinaryOperatorKind = 5 + BO_Add X_BinaryOperatorKind = 6 + BO_Sub X_BinaryOperatorKind = 7 + BO_Shl X_BinaryOperatorKind = 8 + BO_Shr X_BinaryOperatorKind = 9 + BO_Cmp X_BinaryOperatorKind = 10 + BO_LT X_BinaryOperatorKind = 11 + BO_GT X_BinaryOperatorKind = 12 + BO_LE X_BinaryOperatorKind = 13 + BO_GE X_BinaryOperatorKind = 14 + BO_EQ X_BinaryOperatorKind = 15 + BO_NE X_BinaryOperatorKind = 16 + BO_And X_BinaryOperatorKind = 17 + BO_Xor X_BinaryOperatorKind = 18 + BO_Or X_BinaryOperatorKind = 19 + BO_LAnd X_BinaryOperatorKind = 20 + BO_LOr X_BinaryOperatorKind = 21 + BO_Assign X_BinaryOperatorKind = 22 + BO_MulAssign X_BinaryOperatorKind = 23 + BO_DivAssign X_BinaryOperatorKind = 24 + BO_RemAssign X_BinaryOperatorKind = 25 + BO_AddAssign X_BinaryOperatorKind = 26 + BO_SubAssign X_BinaryOperatorKind = 27 + BO_ShlAssign X_BinaryOperatorKind = 28 + BO_ShrAssign X_BinaryOperatorKind = 29 + BO_AndAssign X_BinaryOperatorKind = 30 + BO_XorAssign X_BinaryOperatorKind = 31 + BO_OrAssign X_BinaryOperatorKind = 32 + BO_Comma X_BinaryOperatorKind = 33 + BO_LAST X_BinaryOperatorKind = 33 ) // Describes how the traversal of the children of a particular @@ -2693,79 +2693,79 @@ const ( type FieldVisitor = func(_llcppg_param1 Cursor, _llcppg_param2 ClientData) VisitorResult // Describes the kind of binary operators. -type CXBinaryOperatorKind c.Int +type BinaryOperatorKind c.Int const ( // This value describes cursors which are not binary operators. - BinaryOperator_Invalid CXBinaryOperatorKind = 0 + BinaryOperator_Invalid BinaryOperatorKind = 0 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemD CXBinaryOperatorKind = 1 + BinaryOperator_PtrMemD BinaryOperatorKind = 1 // C++ Pointer - to - member operator. - BinaryOperator_PtrMemI CXBinaryOperatorKind = 2 + BinaryOperator_PtrMemI BinaryOperatorKind = 2 // Multiplication operator. - BinaryOperator_Mul CXBinaryOperatorKind = 3 + BinaryOperator_Mul BinaryOperatorKind = 3 // Division operator. - BinaryOperator_Div CXBinaryOperatorKind = 4 + BinaryOperator_Div BinaryOperatorKind = 4 // Remainder operator. - BinaryOperator_Rem CXBinaryOperatorKind = 5 + BinaryOperator_Rem BinaryOperatorKind = 5 // Addition operator. - BinaryOperator_Add CXBinaryOperatorKind = 6 + BinaryOperator_Add BinaryOperatorKind = 6 // Subtraction operator. - BinaryOperator_Sub CXBinaryOperatorKind = 7 + BinaryOperator_Sub BinaryOperatorKind = 7 // Bitwise shift left operator. - BinaryOperator_Shl CXBinaryOperatorKind = 8 + BinaryOperator_Shl BinaryOperatorKind = 8 // Bitwise shift right operator. - BinaryOperator_Shr CXBinaryOperatorKind = 9 + BinaryOperator_Shr BinaryOperatorKind = 9 // C++ three-way comparison (spaceship) operator. - BinaryOperator_Cmp CXBinaryOperatorKind = 10 + BinaryOperator_Cmp BinaryOperatorKind = 10 // Less than operator. - BinaryOperator_LT CXBinaryOperatorKind = 11 + BinaryOperator_LT BinaryOperatorKind = 11 // Greater than operator. - BinaryOperator_GT CXBinaryOperatorKind = 12 + BinaryOperator_GT BinaryOperatorKind = 12 // Less or equal operator. - BinaryOperator_LE CXBinaryOperatorKind = 13 + BinaryOperator_LE BinaryOperatorKind = 13 // Greater or equal operator. - BinaryOperator_GE CXBinaryOperatorKind = 14 + BinaryOperator_GE BinaryOperatorKind = 14 // Equal operator. - BinaryOperator_EQ CXBinaryOperatorKind = 15 + BinaryOperator_EQ BinaryOperatorKind = 15 // Not equal operator. - BinaryOperator_NE CXBinaryOperatorKind = 16 + BinaryOperator_NE BinaryOperatorKind = 16 // Bitwise AND operator. - BinaryOperator_And CXBinaryOperatorKind = 17 + BinaryOperator_And BinaryOperatorKind = 17 // Bitwise XOR operator. - BinaryOperator_Xor CXBinaryOperatorKind = 18 + BinaryOperator_Xor BinaryOperatorKind = 18 // Bitwise OR operator. - BinaryOperator_Or CXBinaryOperatorKind = 19 + BinaryOperator_Or BinaryOperatorKind = 19 // Logical AND operator. - BinaryOperator_LAnd CXBinaryOperatorKind = 20 + BinaryOperator_LAnd BinaryOperatorKind = 20 // Logical OR operator. - BinaryOperator_LOr CXBinaryOperatorKind = 21 + BinaryOperator_LOr BinaryOperatorKind = 21 // Assignment operator. - BinaryOperator_Assign CXBinaryOperatorKind = 22 + BinaryOperator_Assign BinaryOperatorKind = 22 // Multiplication assignment operator. - BinaryOperator_MulAssign CXBinaryOperatorKind = 23 + BinaryOperator_MulAssign BinaryOperatorKind = 23 // Division assignment operator. - BinaryOperator_DivAssign CXBinaryOperatorKind = 24 + BinaryOperator_DivAssign BinaryOperatorKind = 24 // Remainder assignment operator. - BinaryOperator_RemAssign CXBinaryOperatorKind = 25 + BinaryOperator_RemAssign BinaryOperatorKind = 25 // Addition assignment operator. - BinaryOperator_AddAssign CXBinaryOperatorKind = 26 + BinaryOperator_AddAssign BinaryOperatorKind = 26 // Subtraction assignment operator. - BinaryOperator_SubAssign CXBinaryOperatorKind = 27 + BinaryOperator_SubAssign BinaryOperatorKind = 27 // Bitwise shift left assignment operator. - BinaryOperator_ShlAssign CXBinaryOperatorKind = 28 + BinaryOperator_ShlAssign BinaryOperatorKind = 28 // Bitwise shift right assignment operator. - BinaryOperator_ShrAssign CXBinaryOperatorKind = 29 + BinaryOperator_ShrAssign BinaryOperatorKind = 29 // Bitwise AND assignment operator. - BinaryOperator_AndAssign CXBinaryOperatorKind = 30 + BinaryOperator_AndAssign BinaryOperatorKind = 30 // Bitwise XOR assignment operator. - BinaryOperator_XorAssign CXBinaryOperatorKind = 31 + BinaryOperator_XorAssign BinaryOperatorKind = 31 // Bitwise OR assignment operator. - BinaryOperator_OrAssign CXBinaryOperatorKind = 32 + BinaryOperator_OrAssign BinaryOperatorKind = 32 // Comma operator. - BinaryOperator_Comma CXBinaryOperatorKind = 33 + BinaryOperator_Comma BinaryOperatorKind = 33 // Comma operator. - BinaryOperator_Last CXBinaryOperatorKind = 33 + BinaryOperator_Last BinaryOperatorKind = 33 ) // Describes the kind of unary operators. @@ -4616,7 +4616,7 @@ func (_llcppg_param1 Cursor) CXXAccessSpecifier() CXXAccessSpecifier { // @deprecated: use clang_getCursorBinaryOperatorKind instead. // // llgo:link Cursor.BinaryOpcode C.clang_Cursor_getBinaryOpcode -func (C Cursor) BinaryOpcode() BinaryOperatorKind { +func (C Cursor) BinaryOpcode() X_BinaryOperatorKind { return 0 } @@ -4624,8 +4624,8 @@ func (C Cursor) BinaryOpcode() BinaryOperatorKind { // // @deprecated: use clang_getBinaryOperatorKindSpelling instead // -// llgo:link BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr -func (Op BinaryOperatorKind) CursorGetBinaryOpcodeStr() CXString.String { +// llgo:link X_BinaryOperatorKind.CursorGetBinaryOpcodeStr C.clang_Cursor_getBinaryOpcodeStr +func (Op X_BinaryOperatorKind) CursorGetBinaryOpcodeStr() CXString.String { return CXString.String{} } @@ -6451,8 +6451,8 @@ func (T Type) VisitCXXMethods(visitor FieldVisitor, client_data ClientData) c.Ui // Retrieve the spelling of a given CXBinaryOperatorKind. // -// llgo:link CXBinaryOperatorKind.BinaryOperatorKindSpelling C.clang_getBinaryOperatorKindSpelling -func (kind CXBinaryOperatorKind) BinaryOperatorKindSpelling() CXString.String { +// llgo:link BinaryOperatorKind.Spelling C.clang_getBinaryOperatorKindSpelling +func (kind BinaryOperatorKind) Spelling() CXString.String { return CXString.String{} } @@ -6461,7 +6461,7 @@ func (kind CXBinaryOperatorKind) BinaryOperatorKindSpelling() CXString.String { // If this cursor is not a binary operator then returns Invalid. // // llgo:link Cursor.BinaryOperatorKind C.clang_getCursorBinaryOperatorKind -func (cursor Cursor) BinaryOperatorKind() CXBinaryOperatorKind { +func (cursor Cursor) BinaryOperatorKind() BinaryOperatorKind { return 0 }