From 1c6319c1978845dd16c26491d6043d6dfb0c91e7 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Tue, 29 Jul 2025 08:05:35 +0000 Subject: [PATCH 1/2] fix(llcppsymg):avoid ignore flag prcess overload --- _xtool/llcppsymg/internal/symg/parse.go | 16 ++++++++++++---- _xtool/llcppsymg/internal/symg/testdata/c/c.c | 1 + _xtool/llcppsymg/internal/symg/testdata/c/c.h | 3 +++ .../internal/symg/testdata/c/darwin/libc.a | Bin 1768 -> 1768 bytes .../internal/symg/testdata/c/expect.json | 5 +++++ .../internal/symg/testdata/c/linux/libc.a | Bin 2624 -> 2728 bytes .../internal/symg/testdata/c/llcppg.cfg | 1 + 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/_xtool/llcppsymg/internal/symg/parse.go b/_xtool/llcppsymg/internal/symg/parse.go index 9e1d3bf1..9076e19e 100644 --- a/_xtool/llcppsymg/internal/symg/parse.go +++ b/_xtool/llcppsymg/internal/symg/parse.go @@ -130,12 +130,15 @@ func (p *SymbolProcessor) beRecv(cur clang.Cursor) (ok bool, isPtr bool, typeNam // sqlite3_finalize -> .Close -> method // sqlite3_open -> Open -> function -func (p *SymbolProcessor) customGoName(mangled string) (goName string, isMethod bool, ok bool) { +func (p *SymbolProcessor) customGoName(mangled string) (goName string, isMethod bool, isIgnore bool, ok bool) { if customName, ok := p.customSymMap[mangled]; ok { + if customName == "-" { + return "-", false, true, true + } name, found := strings.CutPrefix(customName, ".") - return name, found, true + return name, found, false, true } - return "", false, false + return "", false, false, false } func (p *SymbolProcessor) genGoName(cursor clang.Cursor, symbolName string) string { @@ -148,7 +151,12 @@ func (p *SymbolProcessor) genGoName(cursor clang.Cursor, symbolName string) stri convertedName = name.GoName(originName, p.prefixes, p.inCurPkg(cursor)) } - customGoName, toMethod, isCustom := p.customGoName(symbolName) + customGoName, toMethod, isIgnore, isCustom := p.customGoName(symbolName) + + // Early return if symbol should be ignored + if isIgnore { + return customGoName + } // 1. for class method,gen method name if parent := cursor.SemanticParent(); parent.Kind == clang.CursorClassDecl { diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/c.c b/_xtool/llcppsymg/internal/symg/testdata/c/c.c index afb73f89..1e8cfac3 100644 --- a/_xtool/llcppsymg/internal/symg/testdata/c/c.c +++ b/_xtool/llcppsymg/internal/symg/testdata/c/c.c @@ -10,6 +10,7 @@ Foo *Foo_ParseWithLength(const char *value, size_t buffer_length) {} Foo *Foo_ParseWithSize(const char *value, size_t buffer_length) {} Foo *Foo_ignoreFunc() {} +Foo *Foo_ignoreFunc2() {} // config Foo_ForBar to Bar,so Foo_Bar to Bar__1 void Foo_Bar() {} diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/c.h b/_xtool/llcppsymg/internal/symg/testdata/c/c.h index c24f6f08..712fd2af 100644 --- a/_xtool/llcppsymg/internal/symg/testdata/c/c.h +++ b/_xtool/llcppsymg/internal/symg/testdata/c/c.h @@ -17,6 +17,9 @@ Foo *Foo_ParseWithLength(const char *value, size_t buffer_length); Foo *Foo_ParseWithSize(const char *value, size_t buffer_length); Foo *Foo_ignoreFunc(); +// https://github.com/goplus/llcppg/issues/522 +Foo *Foo_ignoreFunc2(); + // config Foo_ForBar to Bar,so Foo_Bar to Bar__1 void Foo_Bar(); diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/darwin/libc.a b/_xtool/llcppsymg/internal/symg/testdata/c/darwin/libc.a index 878c0ee7a614468d5cbdd8d0a7bd20069bf411cd..6fc6a6d9f9f04f935f28680abe8e7a78b9673d58 100644 GIT binary patch delta 18 ZcmaFC`+|3a7$Yk`0|P7nW@*N=tN=121bYAg delta 18 ZcmaFC`+|3a7$Ykm0|N`+W@*N=tN=0$1b6@d diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/expect.json b/_xtool/llcppsymg/internal/symg/testdata/c/expect.json index 40dd0442..f9b377db 100644 --- a/_xtool/llcppsymg/internal/symg/testdata/c/expect.json +++ b/_xtool/llcppsymg/internal/symg/testdata/c/expect.json @@ -73,5 +73,10 @@ "mangle": "Foo_ignoreFunc", "c++": "Foo_ignoreFunc()", "go": "-" + }, + { + "mangle": "Foo_ignoreFunc2", + "c++": "Foo_ignoreFunc2()", + "go": "-" } ] \ No newline at end of file diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/linux/libc.a b/_xtool/llcppsymg/internal/symg/testdata/c/linux/libc.a index 560f84109932f086b8d005453b5353d791b8d5b4..a1620192a3ebf8dd4734ee6993bf807ecaa0bd73 100644 GIT binary patch delta 560 zcmZuuJ4*vW5Z<}HyX-bGr_sF>f}%wt3NZ;@msli08#}vz#0P4Vs9YdmW2s<~FoG5V zNtePxNu@-{FOakfLi`I>+PRy%Yk~vI%zTg8S+*bTOgG|i)J&W=Z+^|~-CD)1A;Ka} zr&IU>b2O7#!%w(1qJ)qJmNk*+$V!FoB@&Uj=hp$I)B|j50teditm9$odt(Bs0`m>|u;)$zDzDAs8aoA7hvNJqEaH2pHm~ai0h#7?RVZ-t|3!H^A#? znTJ-!e{O*G@XBZ*-Ig?9G*}e*O|@jkay1(mRSx; z*k%s2@SWwfZ@@C0!6c9KAAhd=KJM^4!?Rpqn>(5v!VjK}Us4Z@sNH2Khba$JjSSmM FdO&1?1|!2n&FYC;Ub4BQCS@k(Og_;(^&-=7#Jo@ zUdSXYx&+7q0Tu|wAOfU!OfF;+XS@I+CqH1)kp!uhV1y_@R;M#rkXd+g05c1t3y8%k z15^^TIhR?Pk<%E+6k=dvNSVBmMO-oiq8Dz-IjC&TLLxS@F8$`F=> diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg b/_xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg index 202c3828..b6413d35 100644 --- a/_xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg +++ b/_xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg @@ -10,6 +10,7 @@ "Foo_Delete":"Delete", "Foo_ParseWithSize":".ParseWithSize", "Foo_ignoreFunc":"-", + "Foo_ignoreFunc2":"-", "Foo_ForBar":"Bar", "Foo_Bar2":"Bar2", "Foo_ForBar2":"Bar2", From 061600158a668e4187da4cf893db2ed3ad44ba53 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Tue, 29 Jul 2025 16:54:39 +0800 Subject: [PATCH 2/2] mac .a --- .../internal/symg/testdata/c/darwin/libc.a | Bin 1768 -> 1856 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/_xtool/llcppsymg/internal/symg/testdata/c/darwin/libc.a b/_xtool/llcppsymg/internal/symg/testdata/c/darwin/libc.a index 6fc6a6d9f9f04f935f28680abe8e7a78b9673d58..10fcde2c7cd58a4de4cdb45cdafc7f16c1185351 100644 GIT binary patch delta 419 zcmaFCdw_3(gAfBV0~mBLLTCo&i9vRZedOm1WnXDpd4$t=%U z0U{??FlRtT_kj5lEE*6#=L4Wt5Rd`s;dlVF0EpNoN3c{_@&Q>O3KFB(#m6|9HydnR+T$}3htMcbjGbD(^XYLKoylRa7W8EYn2vdRZufXXF8<<>y?=b-!p zP(H|FklqJS{yr!_1j_#o<)=)($@)(*-Yq{rJ~KTpzbMtMG%wkRA*Up_zz|FtfHeRB D#jrVR delta 364 zcmX@W_kwqVgU|&g1~BMggwPk5CI;CtzL_}DUG@V+gy8{HssgB#87LOP!oa{kIgnX+ zG6$oA<^>>65GeY9m4Sf+sFEAV4uI+enGM4HKrA>pka70rKa3`flLMF~7&9h&GRt%3 zKots1p2#FVxq~?aB*(b{MO1@DgHZ-7KY^vf@-I-159%P0vhN^1&<>bmRe*ecpnM8Q z5(w4~;lgA_Hu1?CY~KZQN^%Pf89<}~L=ONk?luVk