llcppsymg:parse with language config

This commit is contained in:
luoliwoshang
2024-09-09 10:42:01 +08:00
parent 8913eeb1c1
commit 4688434c08
2 changed files with 5 additions and 5 deletions

View File

@@ -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)

View File

@@ -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
}