llcppsigfetch:func inline & static
This commit is contained in:
@@ -296,37 +296,44 @@ func (ct *Converter) ProcessFuncDecl(cursor clang.Cursor) *ast.FuncDecl {
|
|||||||
Type: funcType,
|
Type: funcType,
|
||||||
}
|
}
|
||||||
|
|
||||||
// other info of function&method
|
if cursor.IsFunctionInlined() != 0 {
|
||||||
if cursor.Kind == clang.CursorDestructor {
|
fn.IsInline = true
|
||||||
fn.IsDestructor = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cursor.Kind == clang.CursorConstructor {
|
if cursor.Kind == clang.CursorCXXMethod || cursor.Kind == clang.CursorDestructor || cursor.Kind == clang.CursorConstructor {
|
||||||
fn.IsConstructor = true
|
if cursor.Kind == clang.CursorDestructor {
|
||||||
if cursor.IsExplicit() != 0 {
|
fn.IsDestructor = true
|
||||||
fn.IsExplicit = 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
|
return fn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ func TestClassDecl() {
|
|||||||
A();
|
A();
|
||||||
explicit A();
|
explicit A();
|
||||||
~A();
|
~A();
|
||||||
|
static inline void foo();
|
||||||
};`,
|
};`,
|
||||||
`class Base {
|
`class Base {
|
||||||
Base();
|
Base();
|
||||||
|
|||||||
@@ -276,6 +276,36 @@ TestClassDecl Case 3:
|
|||||||
"IsDestructor": true,
|
"IsDestructor": true,
|
||||||
"IsVirtual": false,
|
"IsVirtual": false,
|
||||||
"IsOverride": 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();`,
|
||||||
`void foo(int a);`,
|
`void foo(int a);`,
|
||||||
`float* foo(int a,double b);`,
|
`float* foo(int a,double b);`,
|
||||||
|
`static inline int add(int a, int b);`,
|
||||||
}
|
}
|
||||||
test.RunTest("TestFuncDecl", testCases)
|
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
|
#stderr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user