From 4688434c082ae1e1023d0ab039abee320fb49e34 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Mon, 9 Sep 2024 10:42:01 +0800 Subject: [PATCH] llcppsymg:parse with language config --- chore/_xtool/llcppsymg/llcppsymg.go | 2 +- chore/_xtool/llcppsymg/parse/parse.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chore/_xtool/llcppsymg/llcppsymg.go b/chore/_xtool/llcppsymg/llcppsymg.go index 3be917a9..cfc842e5 100644 --- a/chore/_xtool/llcppsymg/llcppsymg.go +++ b/chore/_xtool/llcppsymg/llcppsymg.go @@ -61,7 +61,7 @@ func main() { check(err) filepaths := genHeaderFilePath(conf.CFlags, conf.Include) - headerInfos, err := parse.ParseHeaderFile(filepaths, conf.TrimPrefixes) + headerInfos, err := parse.ParseHeaderFile(filepaths, conf.TrimPrefixes, conf.Cplusplus) check(err) symbolInfo := getCommonSymbols(symbols, headerInfos, conf.TrimPrefixes) diff --git a/chore/_xtool/llcppsymg/parse/parse.go b/chore/_xtool/llcppsymg/parse/parse.go index 408e8419..55abd1a9 100644 --- a/chore/_xtool/llcppsymg/parse/parse.go +++ b/chore/_xtool/llcppsymg/parse/parse.go @@ -134,14 +134,14 @@ func visit(cursor, parent clang.Cursor, clientData c.Pointer) clang.ChildVisitRe } func ParseHeaderFile(filepaths []string, prefixes []string, isCpp bool) (map[string]string, error) { - context = newContext(prefixes) - + index := clang.CreateIndex(0, 0) for _, filename := range filepaths { - index, unit, err := clangutils.CreateTranslationUnit(&clangutils.Config{ + _, unit, err := clangutils.CreateTranslationUnit(&clangutils.Config{ File: filename, Temp: false, IsCpp: isCpp, + Index: index, }) if err != nil { return nil, errors.New("Unable to parse translation unit for file " + filename) @@ -151,7 +151,7 @@ func ParseHeaderFile(filepaths []string, prefixes []string, isCpp bool) (map[str context.setCurrentFile(filename) clang.VisitChildren(cursor, visit, nil) unit.Dispose() - index.Dispose() } + index.Dispose() return context.symbolMap, nil }