diff --git a/chore/_xtool/llcppsigfetch/parse/cvt.go b/chore/_xtool/llcppsigfetch/parse/cvt.go index c92afa49..e5d34eb2 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt.go @@ -237,6 +237,8 @@ func (ct *Converter) ProcessType(t clang.Type) ast.Expr { switch t.Kind { case clang.TypePointer: expr = &ast.PointerType{X: ct.ProcessType(t.PointeeType())} + case clang.TypeLValueReference, clang.TypeRValueReference: + expr = &ast.LvalueRefType{X: ct.ProcessType(t.NonReferenceType())} case clang.TypeFunctionProto: // function type will only collect return type, params will be collected in ProcessFunc ret := ct.ProcessType(t.ResultType()) diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go index 646427ce..9a555bbc 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/func.go @@ -18,6 +18,9 @@ func TestFuncDecl() { `void foo(char str[]);`, `void foo(int arr[3][4]);`, + + `void foo(int& a);`, + `void foo(int&& a);`, } test.RunTest("TestFuncDecl", testCases) } diff --git a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect index 900c5d07..1769dc0f 100644 --- a/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect +++ b/chore/_xtool/llcppsigfetch/parse/cvt_test/decl_test/func_test/llgo.expect @@ -384,6 +384,96 @@ TestFuncDecl Case 8: } } +TestFuncDecl Case 9: +{ + "temp.h": { + "decls": [{ + "Loc": { + "File": "temp.h" + }, + "Doc": { + "List": [] + }, + "Parent": null, + "Name": { + "Name": "foo" + }, + "Type": { + "Params": { + "List": [{ + "Type": { + "X": { + "Kind": 6, + "Flags": 0 + } + }, + "Doc": { + "List": [] + }, + "Comment": { + "List": [] + }, + "Names": [{ + "Name": "a" + }] + }] + }, + "Ret": { + "Kind": 0, + "Flags": 0 + } + } + }], + "includes": [], + "macros": [] + } +} + +TestFuncDecl Case 10: +{ + "temp.h": { + "decls": [{ + "Loc": { + "File": "temp.h" + }, + "Doc": { + "List": [] + }, + "Parent": null, + "Name": { + "Name": "foo" + }, + "Type": { + "Params": { + "List": [{ + "Type": { + "X": { + "Kind": 6, + "Flags": 0 + } + }, + "Doc": { + "List": [] + }, + "Comment": { + "List": [] + }, + "Names": [{ + "Name": "a" + }] + }] + }, + "Ret": { + "Kind": 0, + "Flags": 0 + } + } + }], + "includes": [], + "macros": [] + } +} + #stderr diff --git a/chore/_xtool/llcppsigfetch/parse/dump.go b/chore/_xtool/llcppsigfetch/parse/dump.go index 2f2e71dd..0f8024d0 100644 --- a/chore/_xtool/llcppsigfetch/parse/dump.go +++ b/chore/_xtool/llcppsigfetch/parse/dump.go @@ -146,6 +146,10 @@ func MarshalASTExpr(t ast.Expr) *cjson.JSON { case *ast.BasicLit: root.SetItem(c.Str("Kind"), cjson.Number(float64(d.Kind))) root.SetItem(c.Str("Value"), cjson.String(c.AllocaCStr(d.Value))) + case *ast.LvalueRefType: + root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) + case *ast.RvalueRefType: + root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) case *ast.PointerType: root.SetItem(c.Str("X"), MarshalASTExpr(d.X)) case *ast.ArrayType: