Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions _xtool/llcppsymg/internal/symg/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions _xtool/llcppsymg/internal/symg/testdata/c/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down
3 changes: 3 additions & 0 deletions _xtool/llcppsymg/internal/symg/testdata/c/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Binary file modified _xtool/llcppsymg/internal/symg/testdata/c/darwin/libc.a
Binary file not shown.
5 changes: 5 additions & 0 deletions _xtool/llcppsymg/internal/symg/testdata/c/expect.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,10 @@
"mangle": "Foo_ignoreFunc",
"c++": "Foo_ignoreFunc()",
"go": "-"
},
{
"mangle": "Foo_ignoreFunc2",
"c++": "Foo_ignoreFunc2()",
"go": "-"
}
]
Binary file modified _xtool/llcppsymg/internal/symg/testdata/c/linux/libc.a
Binary file not shown.
1 change: 1 addition & 0 deletions _xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Foo_Delete":"Delete",
"Foo_ParseWithSize":".ParseWithSize",
"Foo_ignoreFunc":"-",
"Foo_ignoreFunc2":"-",
"Foo_ForBar":"Bar",
"Foo_Bar2":"Bar2",
"Foo_ForBar2":"Bar2",
Expand Down
Loading