Skip to content

Commit dbf96dc

Browse files
authored
fix(llcppsymg):avoid ignore flag process overload (#523)
* fix(llcppsymg):avoid ignore flag prcess overload * mac .a
1 parent c7417b0 commit dbf96dc

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

_xtool/llcppsymg/internal/symg/parse.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,15 @@ func (p *SymbolProcessor) beRecv(cur clang.Cursor) (ok bool, isPtr bool, typeNam
130130

131131
// sqlite3_finalize -> .Close -> method
132132
// sqlite3_open -> Open -> function
133-
func (p *SymbolProcessor) customGoName(mangled string) (goName string, isMethod bool, ok bool) {
133+
func (p *SymbolProcessor) customGoName(mangled string) (goName string, isMethod bool, isIgnore bool, ok bool) {
134134
if customName, ok := p.customSymMap[mangled]; ok {
135+
if customName == "-" {
136+
return "-", false, true, true
137+
}
135138
name, found := strings.CutPrefix(customName, ".")
136-
return name, found, true
139+
return name, found, false, true
137140
}
138-
return "", false, false
141+
return "", false, false, false
139142
}
140143

141144
func (p *SymbolProcessor) genGoName(cursor clang.Cursor, symbolName string) string {
@@ -148,7 +151,12 @@ func (p *SymbolProcessor) genGoName(cursor clang.Cursor, symbolName string) stri
148151
convertedName = name.GoName(originName, p.prefixes, p.inCurPkg(cursor))
149152
}
150153

151-
customGoName, toMethod, isCustom := p.customGoName(symbolName)
154+
customGoName, toMethod, isIgnore, isCustom := p.customGoName(symbolName)
155+
156+
// Early return if symbol should be ignored
157+
if isIgnore {
158+
return customGoName
159+
}
152160

153161
// 1. for class method,gen method name
154162
if parent := cursor.SemanticParent(); parent.Kind == clang.CursorClassDecl {

_xtool/llcppsymg/internal/symg/testdata/c/c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Foo *Foo_ParseWithLength(const char *value, size_t buffer_length) {}
1010
Foo *Foo_ParseWithSize(const char *value, size_t buffer_length) {}
1111

1212
Foo *Foo_ignoreFunc() {}
13+
Foo *Foo_ignoreFunc2() {}
1314

1415
// config Foo_ForBar to Bar,so Foo_Bar to Bar__1
1516
void Foo_Bar() {}

_xtool/llcppsymg/internal/symg/testdata/c/c.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Foo *Foo_ParseWithLength(const char *value, size_t buffer_length);
1717
Foo *Foo_ParseWithSize(const char *value, size_t buffer_length);
1818

1919
Foo *Foo_ignoreFunc();
20+
// https://github.com/goplus/llcppg/issues/522
21+
Foo *Foo_ignoreFunc2();
22+
2023

2124
// config Foo_ForBar to Bar,so Foo_Bar to Bar__1
2225
void Foo_Bar();
88 Bytes
Binary file not shown.

_xtool/llcppsymg/internal/symg/testdata/c/expect.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,10 @@
7373
"mangle": "Foo_ignoreFunc",
7474
"c++": "Foo_ignoreFunc()",
7575
"go": "-"
76+
},
77+
{
78+
"mangle": "Foo_ignoreFunc2",
79+
"c++": "Foo_ignoreFunc2()",
80+
"go": "-"
7681
}
7782
]
104 Bytes
Binary file not shown.

_xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"Foo_Delete":"Delete",
1111
"Foo_ParseWithSize":".ParseWithSize",
1212
"Foo_ignoreFunc":"-",
13+
"Foo_ignoreFunc2":"-",
1314
"Foo_ForBar":"Bar",
1415
"Foo_Bar2":"Bar2",
1516
"Foo_ForBar2":"Bar2",

0 commit comments

Comments
 (0)