llcppsigfetch:func mangled name
This commit is contained in:
@@ -434,10 +434,11 @@ func (ct *Converter) ProcessUnderlyingType(cursor clang.Cursor) ast.Expr {
|
||||
}
|
||||
|
||||
// converts functions, methods, constructors, destructors (including out-of-class decl) to ast.FuncDecl nodes.
|
||||
// todo(zzy): manglename (c++)
|
||||
func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
||||
name := cursor.String()
|
||||
mangledName := cursor.Mangling()
|
||||
defer name.Dispose()
|
||||
defer mangledName.Dispose()
|
||||
|
||||
// function type will only collect return type
|
||||
// ProcessType can't get the field names,will collect in follows
|
||||
@@ -448,10 +449,17 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
||||
}
|
||||
params := ct.ProcessFieldList(cursor)
|
||||
funcType.Params = params
|
||||
|
||||
mangledNameStr := c.GoString(mangledName.CStr())
|
||||
if len(mangledNameStr) >= 1 && mangledNameStr[0] == '_' {
|
||||
mangledNameStr = mangledNameStr[1:]
|
||||
}
|
||||
|
||||
funcDecl := &ast.FuncDecl{
|
||||
DeclBase: ct.CreateDeclBase(cursor),
|
||||
Name: &ast.Ident{Name: c.GoString(name.CStr())},
|
||||
Type: funcType,
|
||||
MangledName: mangledNameStr,
|
||||
}
|
||||
|
||||
if cursor.IsFunctionInlined() != 0 {
|
||||
|
||||
@@ -128,6 +128,7 @@ TestClassDecl Case 2:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN1A3fooEid",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -224,6 +225,7 @@ TestClassDecl Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "A"
|
||||
},
|
||||
"MangledName": "_ZN1AC1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -259,6 +261,7 @@ TestClassDecl Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "A"
|
||||
},
|
||||
"MangledName": "_ZN1AC1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -294,6 +297,7 @@ TestClassDecl Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "~A"
|
||||
},
|
||||
"MangledName": "_ZN1AD1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -329,6 +333,7 @@ TestClassDecl Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN1A3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -395,6 +400,7 @@ TestClassDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "Base"
|
||||
},
|
||||
"MangledName": "_ZN4BaseC1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -430,6 +436,7 @@ TestClassDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "~Base"
|
||||
},
|
||||
"MangledName": "_ZN4BaseD1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -465,6 +472,7 @@ TestClassDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN4Base3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -521,6 +529,7 @@ TestClassDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "Derived"
|
||||
},
|
||||
"MangledName": "_ZN7DerivedC1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -556,6 +565,7 @@ TestClassDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "~Derived"
|
||||
},
|
||||
"MangledName": "_ZN7DerivedD1Ev",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -591,6 +601,7 @@ TestClassDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN7Derived3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -669,6 +680,7 @@ TestClassDecl Case 5:
|
||||
"_Type": "Ident",
|
||||
"Name": "bar"
|
||||
},
|
||||
"MangledName": "_ZN1A3Foo3barEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
|
||||
@@ -15,6 +15,7 @@ TestDoc Case 1:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -57,6 +58,7 @@ TestDoc Case 2:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -105,6 +107,7 @@ TestDoc Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -153,6 +156,7 @@ TestDoc Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -201,6 +205,7 @@ TestDoc Case 5:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -252,6 +257,7 @@ TestDoc Case 6:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -303,6 +309,7 @@ TestDoc Case 7:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -354,6 +361,7 @@ TestDoc Case 8:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -411,6 +419,7 @@ TestDoc Case 9:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -698,6 +707,7 @@ TestDoc Case 11:
|
||||
"_Type": "Ident",
|
||||
"Name": "Foo"
|
||||
},
|
||||
"MangledName": "_ZN3Doc3FooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
|
||||
@@ -15,6 +15,7 @@ TestFuncDecl Case 1:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -57,6 +58,7 @@ TestFuncDecl Case 2:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3fooi",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -114,6 +116,7 @@ TestFuncDecl Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3fooiz",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -181,6 +184,7 @@ TestFuncDecl Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3fooid",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -256,6 +260,7 @@ TestFuncDecl Case 5:
|
||||
"_Type": "Ident",
|
||||
"Name": "add"
|
||||
},
|
||||
"MangledName": "_ZL3addii",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
|
||||
@@ -15,6 +15,7 @@ TestScope Case 1:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_Z3foov",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -60,6 +61,7 @@ TestScope Case 2:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN1a3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -112,6 +114,7 @@ TestScope Case 3:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN1a1b3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -176,6 +179,7 @@ TestScope Case 4:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN1a3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
@@ -252,6 +256,7 @@ TestScope Case 5:
|
||||
"_Type": "Ident",
|
||||
"Name": "foo"
|
||||
},
|
||||
"MangledName": "_ZN1a1b3fooEv",
|
||||
"Type": {
|
||||
"_Type": "FuncType",
|
||||
"Params": {
|
||||
|
||||
@@ -124,6 +124,7 @@ func MarshalASTDecl(decl ast.Decl) *cjson.JSON {
|
||||
root.SetItem(c.Str("_Type"), stringField("FuncDecl"))
|
||||
MarshalASTDeclBase(d.DeclBase, root)
|
||||
root.SetItem(c.Str("Name"), MarshalASTExpr(d.Name))
|
||||
root.SetItem(c.Str("MangledName"), stringField(d.MangledName))
|
||||
root.SetItem(c.Str("Type"), MarshalASTExpr(d.Type))
|
||||
root.SetItem(c.Str("IsInline"), boolField(d.IsInline))
|
||||
root.SetItem(c.Str("IsStatic"), boolField(d.IsStatic))
|
||||
|
||||
Reference in New Issue
Block a user