llcppsymg:use clang's displayname with semantic parent to construct func proto for c/c++

This commit is contained in:
luoliwoshang
2024-09-09 14:24:36 +08:00
parent 4688434c08
commit 78f0177ac4
3 changed files with 45 additions and 23 deletions

View File

@@ -70,3 +70,16 @@ func CreateTranslationUnit(config *Config) (*clang.Index, *clang.TranslationUnit
return index, unit, nil
}
// Traverse up the semantic parents
func BuildScopingParts(cursor clang.Cursor) []string {
var parts []string
for cursor.IsNull() != 1 && cursor.Kind != clang.CursorTranslationUnit {
name := cursor.String()
qualified := c.GoString(name.CStr())
parts = append([]string{qualified}, parts...)
cursor = cursor.SemanticParent()
name.Dispose()
}
return parts
}