llcppsigfetch:TypedefDecl & Elaborated Type Refer

This commit is contained in:
luoliwoshang
2024-08-21 18:25:51 +08:00
parent 815fe25f2c
commit e09c5fcb3c
4 changed files with 237 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ func main() {
TestClassDecl()
TestUnionDecl()
TestEnumDecl()
TestTypeDefDecl()
}
func TestFuncDecl() {
@@ -153,3 +154,20 @@ func TestEnumDecl() {
}
test.RunTest("TestEnumDecl", testCases)
}
func TestTypeDefDecl() {
testCases := []string{
`typedef int INT;`,
`typedef int INT;
typedef INT STANDARD_INT;`,
`struct StructFoo {};
union UnionFoo {};
class ClassFoo {};
enum EnumFoo {};
typedef StructFoo STRUCT_FOO;
typedef UnionFoo UNION_FOO;
typedef ClassFoo CLASS_FOO;
typedef EnumFoo ENUM_FOO;`,
}
test.RunTest("TestTypeDefDecl", testCases)
}

View File

@@ -1599,6 +1599,198 @@ TestEnumDecl Case 3:
}
}
TestTypeDefDecl Case 1:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "INT"
},
"Type": {
"Kind": 6,
"Flags": 0
}
}],
"includes": [],
"macros": []
}
}
TestTypeDefDecl Case 2:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "INT"
},
"Type": {
"Kind": 6,
"Flags": 0
}
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "STANDARD_INT"
},
"Type": {
"Name": "INT"
}
}],
"includes": [],
"macros": []
}
}
TestTypeDefDecl Case 3:
{
"temp.h": {
"path": "temp.h",
"decls": [{
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Tag": 0,
"Name": {
"Name": "StructFoo"
},
"Fields": {
"List": []
},
"Methods": []
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Tag": 1,
"Name": {
"Name": "UnionFoo"
},
"Fields": {
"List": []
},
"Methods": []
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": {
"Name": "ClassFoo"
},
"Tag": 3,
"Name": {
"Name": "ClassFoo"
},
"Fields": {
"List": []
},
"Methods": []
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "EnumFoo"
},
"Items": []
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "STRUCT_FOO"
},
"Type": {
"Name": "StructFoo"
}
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "UNION_FOO"
},
"Type": {
"Name": "UnionFoo"
}
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "CLASS_FOO"
},
"Type": {
"Name": "ClassFoo"
}
}, {
"Loc": {
"File": "temp.h"
},
"Doc": {
"List": []
},
"Parent": null,
"Name": {
"Name": "ENUM_FOO"
},
"Type": {
"Name": "EnumFoo"
}
}],
"includes": [],
"macros": []
}
}
#stderr