llcppsigfetch:func inline & static
This commit is contained in:
@@ -296,37 +296,44 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
||||
Type: funcType,
|
||||
}
|
||||
|
||||
// other info of function&method
|
||||
if cursor.Kind == clang.CursorDestructor {
|
||||
fn.IsDestructor = true
|
||||
if cursor.IsFunctionInlined() != 0 {
|
||||
fn.IsInline = true
|
||||
}
|
||||
|
||||
if cursor.Kind == clang.CursorConstructor {
|
||||
fn.IsConstructor = true
|
||||
if cursor.IsExplicit() != 0 {
|
||||
fn.IsExplicit = true
|
||||
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorDestructor || cursor.Kind == clang.CursorConstructor {
|
||||
if cursor.Kind == clang.CursorDestructor {
|
||||
fn.IsDestructor = true
|
||||
}
|
||||
if cursor.Kind == clang.CursorConstructor {
|
||||
fn.IsConstructor = true
|
||||
if cursor.IsExplicit() != 0 {
|
||||
fn.IsExplicit = true
|
||||
}
|
||||
}
|
||||
if cursor.IsStatic() != 0 {
|
||||
fn.IsStatic = true
|
||||
}
|
||||
// virtual & pure virtual
|
||||
if cursor.IsVirtual() != 0 || cursor.IsPureVirtual() != 0 {
|
||||
fn.IsVirtual = true
|
||||
}
|
||||
if cursor.IsConst() != 0 {
|
||||
fn.IsConst = true
|
||||
}
|
||||
|
||||
var numOverridden c.Uint
|
||||
var overridden *clang.Cursor
|
||||
cursor.OverriddenCursors(&overridden, &numOverridden)
|
||||
if numOverridden > 0 {
|
||||
fn.IsOverride = true
|
||||
}
|
||||
overridden.DisposeOverriddenCursors()
|
||||
} else {
|
||||
if cursor.StorageClass() == clang.SCStatic {
|
||||
fn.IsStatic = true
|
||||
}
|
||||
}
|
||||
|
||||
if cursor.IsStatic() != 0 {
|
||||
fn.IsStatic = true
|
||||
}
|
||||
|
||||
// virtual & pure virtual
|
||||
if cursor.IsVirtual() != 0 || cursor.IsPureVirtual() != 0 {
|
||||
fn.IsVirtual = true
|
||||
}
|
||||
|
||||
// todo(zzy):inline & const
|
||||
|
||||
var numOverridden c.Uint
|
||||
var overridden *clang.Cursor
|
||||
cursor.OverriddenCursors(&overridden, &numOverridden)
|
||||
if numOverridden > 0 {
|
||||
fn.IsOverride = true
|
||||
}
|
||||
overridden.DisposeOverriddenCursors()
|
||||
|
||||
return fn
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ func TestClassDecl() {
|
||||
A();
|
||||
explicit A();
|
||||
~A();
|
||||
static inline void foo();
|
||||
};`,
|
||||
`class Base {
|
||||
Base();
|
||||
|
||||
@@ -276,6 +276,36 @@ TestClassDecl Case 3:
|
||||
"IsDestructor": true,
|
||||
"IsVirtual": false,
|
||||
"IsOverride": false
|
||||
}, {
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": {
|
||||
"Name": "A"
|
||||
},
|
||||
"Name": {
|
||||
"Name": "foo"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": []
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 0,
|
||||
"Flags": 0
|
||||
}
|
||||
},
|
||||
"IsInline": true,
|
||||
"IsStatic": true,
|
||||
"IsConst": false,
|
||||
"IsExplicit": false,
|
||||
"IsConstructor": false,
|
||||
"IsDestructor": false,
|
||||
"IsVirtual": false,
|
||||
"IsOverride": false
|
||||
}]
|
||||
}
|
||||
}],
|
||||
|
||||
@@ -11,6 +11,7 @@ func TestFuncDecl() {
|
||||
`void foo();`,
|
||||
`void foo(int a);`,
|
||||
`float* foo(int a,double b);`,
|
||||
`static inline int add(int a, int b);`,
|
||||
}
|
||||
test.RunTest("TestFuncDecl", testCases)
|
||||
}
|
||||
|
||||
@@ -154,6 +154,71 @@ TestFuncDecl Case 3:
|
||||
}
|
||||
}
|
||||
|
||||
TestFuncDecl Case 4:
|
||||
{
|
||||
"temp.h": {
|
||||
"decls": [{
|
||||
"Loc": {
|
||||
"File": "temp.h"
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Parent": null,
|
||||
"Name": {
|
||||
"Name": "add"
|
||||
},
|
||||
"Type": {
|
||||
"Params": {
|
||||
"List": [{
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "a"
|
||||
}]
|
||||
}, {
|
||||
"Type": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
},
|
||||
"Doc": {
|
||||
"List": []
|
||||
},
|
||||
"Comment": {
|
||||
"List": []
|
||||
},
|
||||
"Names": [{
|
||||
"Name": "b"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"Ret": {
|
||||
"Kind": 6,
|
||||
"Flags": 0
|
||||
}
|
||||
},
|
||||
"IsInline": true,
|
||||
"IsStatic": true,
|
||||
"IsConst": false,
|
||||
"IsExplicit": false,
|
||||
"IsConstructor": false,
|
||||
"IsDestructor": false,
|
||||
"IsVirtual": false,
|
||||
"IsOverride": false
|
||||
}],
|
||||
"includes": [],
|
||||
"macros": []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
|
||||
Reference in New Issue
Block a user