From b6b889bff66e2ae759a935a7cda064c55c479765 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 10 Oct 2024 14:43:54 +0800 Subject: [PATCH] llcppsigfetch:remove leading underscores --- chore/_xtool/llcppsigfetch/parse/cvt.go | 4 +--- .../cvt_test/decl_test/class_test/llgo.expect | 24 +++++++++---------- .../decl_test/comment_test/llgo.expect | 20 ++++++++-------- .../cvt_test/decl_test/func_test/llgo.expect | 10 ++++---- .../cvt_test/decl_test/scope_test/llgo.expect | 10 ++++---- 5 files changed, 33 insertions(+), 35 deletions(-) diff --git a/chore/_xtool/llcppsigfetch/parse/cvt.go b/chore/_xtool/llcppsigfetch/parse/cvt.go index 0cf35879..fbeba192 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt.go @@ -414,9 +414,7 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl { funcType.Params = params mangledNameStr := c.GoString(mangledName.CStr()) - if len(mangledNameStr) >= 1 && mangledNameStr[0] == '_' { - mangledNameStr = mangledNameStr[1:] - } + mangledNameStr = strings.TrimLeft(mangledNameStr, "_") funcDecl := &ast.FuncDecl{ DeclBase: ct.CreateDeclBase(cursor), diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect index c75368df..65f75cd7 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/class_test/llgo.expect @@ -128,7 +128,7 @@ TestClassDecl Case 2: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN1A3fooEid", + "MangledName": "ZN1A3fooEid", "Type": { "_Type": "FuncType", "Params": { @@ -225,7 +225,7 @@ TestClassDecl Case 3: "_Type": "Ident", "Name": "A" }, - "MangledName": "_ZN1AC1Ev", + "MangledName": "ZN1AC1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -261,7 +261,7 @@ TestClassDecl Case 3: "_Type": "Ident", "Name": "A" }, - "MangledName": "_ZN1AC1Ev", + "MangledName": "ZN1AC1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -297,7 +297,7 @@ TestClassDecl Case 3: "_Type": "Ident", "Name": "~A" }, - "MangledName": "_ZN1AD1Ev", + "MangledName": "ZN1AD1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -333,7 +333,7 @@ TestClassDecl Case 3: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN1A3fooEv", + "MangledName": "ZN1A3fooEv", "Type": { "_Type": "FuncType", "Params": { @@ -400,7 +400,7 @@ TestClassDecl Case 4: "_Type": "Ident", "Name": "Base" }, - "MangledName": "_ZN4BaseC1Ev", + "MangledName": "ZN4BaseC1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -436,7 +436,7 @@ TestClassDecl Case 4: "_Type": "Ident", "Name": "~Base" }, - "MangledName": "_ZN4BaseD1Ev", + "MangledName": "ZN4BaseD1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -472,7 +472,7 @@ TestClassDecl Case 4: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN4Base3fooEv", + "MangledName": "ZN4Base3fooEv", "Type": { "_Type": "FuncType", "Params": { @@ -529,7 +529,7 @@ TestClassDecl Case 4: "_Type": "Ident", "Name": "Derived" }, - "MangledName": "_ZN7DerivedC1Ev", + "MangledName": "ZN7DerivedC1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -565,7 +565,7 @@ TestClassDecl Case 4: "_Type": "Ident", "Name": "~Derived" }, - "MangledName": "_ZN7DerivedD1Ev", + "MangledName": "ZN7DerivedD1Ev", "Type": { "_Type": "FuncType", "Params": { @@ -601,7 +601,7 @@ TestClassDecl Case 4: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN7Derived3fooEv", + "MangledName": "ZN7Derived3fooEv", "Type": { "_Type": "FuncType", "Params": { @@ -680,7 +680,7 @@ TestClassDecl Case 5: "_Type": "Ident", "Name": "bar" }, - "MangledName": "_ZN1A3Foo3barEv", + "MangledName": "ZN1A3Foo3barEv", "Type": { "_Type": "FuncType", "Params": { diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect index 6c769412..13076294 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/comment_test/llgo.expect @@ -15,7 +15,7 @@ TestDoc Case 1: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -58,7 +58,7 @@ TestDoc Case 2: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -107,7 +107,7 @@ TestDoc Case 3: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -156,7 +156,7 @@ TestDoc Case 4: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -205,7 +205,7 @@ TestDoc Case 5: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -257,7 +257,7 @@ TestDoc Case 6: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -309,7 +309,7 @@ TestDoc Case 7: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -361,7 +361,7 @@ TestDoc Case 8: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -419,7 +419,7 @@ TestDoc Case 9: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -707,7 +707,7 @@ TestDoc Case 11: "_Type": "Ident", "Name": "Foo" }, - "MangledName": "_ZN3Doc3FooEv", + "MangledName": "ZN3Doc3FooEv", "Type": { "_Type": "FuncType", "Params": { diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect index 383660fb..e573491a 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect @@ -15,7 +15,7 @@ TestFuncDecl Case 1: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -58,7 +58,7 @@ TestFuncDecl Case 2: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3fooi", + "MangledName": "Z3fooi", "Type": { "_Type": "FuncType", "Params": { @@ -116,7 +116,7 @@ TestFuncDecl Case 3: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3fooiz", + "MangledName": "Z3fooiz", "Type": { "_Type": "FuncType", "Params": { @@ -184,7 +184,7 @@ TestFuncDecl Case 4: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3fooid", + "MangledName": "Z3fooid", "Type": { "_Type": "FuncType", "Params": { @@ -260,7 +260,7 @@ TestFuncDecl Case 5: "_Type": "Ident", "Name": "add" }, - "MangledName": "_ZL3addii", + "MangledName": "ZL3addii", "Type": { "_Type": "FuncType", "Params": { diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect index 66093d7f..e903e0f8 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/scope_test/llgo.expect @@ -15,7 +15,7 @@ TestScope Case 1: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_Z3foov", + "MangledName": "Z3foov", "Type": { "_Type": "FuncType", "Params": { @@ -61,7 +61,7 @@ TestScope Case 2: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN1a3fooEv", + "MangledName": "ZN1a3fooEv", "Type": { "_Type": "FuncType", "Params": { @@ -114,7 +114,7 @@ TestScope Case 3: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN1a1b3fooEv", + "MangledName": "ZN1a1b3fooEv", "Type": { "_Type": "FuncType", "Params": { @@ -179,7 +179,7 @@ TestScope Case 4: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN1a3fooEv", + "MangledName": "ZN1a3fooEv", "Type": { "_Type": "FuncType", "Params": { @@ -256,7 +256,7 @@ TestScope Case 5: "_Type": "Ident", "Name": "foo" }, - "MangledName": "_ZN1a1b3fooEv", + "MangledName": "ZN1a1b3fooEv", "Type": { "_Type": "FuncType", "Params": {