Improve VarDef::type for textDocument/typeDefinition

This commit is contained in:
Fangrui Song 2018-09-19 13:05:52 -07:00
parent 08645d64c1
commit f515b4b466
10 changed files with 78 additions and 339 deletions

View File

@ -31,23 +31,6 @@ OUTPUT:
"vars": [], "vars": [],
"instances": [], "instances": [],
"uses": ["9:5-9:6|0|1|4|-1"] "uses": ["9:5-9:6|0|1|4|-1"]
}, {
"usr": 7074603899792463171,
"detailed_name": "Inner",
"qual_name_offset": 0,
"short_name": "Inner",
"kind": 26,
"declarations": [],
"spell": "6:10-6:15|0|1|2|-1",
"extent": "6:3-6:18|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [16721564935990383768],
"uses": []
}, { }, {
"usr": 10528472276654770367, "usr": 10528472276654770367,
"detailed_name": "struct Foo {}", "detailed_name": "struct Foo {}",
@ -63,25 +46,8 @@ OUTPUT:
"types": [13938528237873543349], "types": [13938528237873543349],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [],
"uses": ["9:1-9:4|0|1|4|-1", "10:1-10:4|0|1|4|-1"]
}, {
"usr": 11976530632376795217,
"detailed_name": "Foo",
"qual_name_offset": 0,
"short_name": "Foo",
"kind": 26,
"declarations": [],
"spell": "5:8-5:11|0|1|2|-1",
"extent": "4:1-7:2|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [12028309045033782423], "instances": [12028309045033782423],
"uses": [] "uses": ["9:1-9:4|0|1|4|-1", "10:1-10:4|0|1|4|-1"]
}, { }, {
"usr": 13892793056005362145, "usr": 13892793056005362145,
"detailed_name": "enum B {}", "detailed_name": "enum B {}",
@ -114,7 +80,7 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [16721564935990383768],
"uses": ["9:9-9:14|0|1|4|-1"] "uses": ["9:9-9:14|0|1|4|-1"]
}], }],
"usr2var": [{ "usr2var": [{
@ -125,7 +91,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "10:8-10:9|0|1|2|-1", "spell": "10:8-10:9|0|1|2|-1",
"extent": "10:1-10:9|0|1|0|-1", "extent": "10:1-10:9|0|1|0|-1",
"type": 11976530632376795217, "type": 10528472276654770367,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -137,7 +103,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "9:15-9:16|0|1|2|-1", "spell": "9:15-9:16|0|1|2|-1",
"extent": "9:1-9:16|0|1|0|-1", "extent": "9:1-9:16|0|1|0|-1",
"type": 7074603899792463171, "type": 13938528237873543349,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0

View File

@ -65,10 +65,8 @@ OUTPUT:
"detailed_name": "", "detailed_name": "",
"qual_name_offset": 0, "qual_name_offset": 0,
"short_name": "", "short_name": "",
"kind": 26, "kind": 0,
"declarations": [], "declarations": [],
"spell": "4:22-4:23|4259594751088586730|3|2|-1",
"extent": "4:22-4:23|4259594751088586730|3|0|-1",
"alias_of": 0, "alias_of": 0,
"bases": [], "bases": [],
"derived": [], "derived": [],

View File

@ -13,40 +13,6 @@ OUTPUT:
"skipped_ranges": [], "skipped_ranges": [],
"usr2func": [], "usr2func": [],
"usr2type": [{ "usr2type": [{
"usr": 3948666349864691553,
"detailed_name": "Foo",
"qual_name_offset": 0,
"short_name": "Foo",
"kind": 26,
"declarations": [],
"spell": "3:9-3:12|11072669167287398027|2|2|-1",
"extent": "2:3-3:15|11072669167287398027|2|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [3182917058194750998],
"uses": []
}, {
"usr": 8224244241460152567,
"detailed_name": "Foo",
"qual_name_offset": 0,
"short_name": "Foo",
"kind": 26,
"declarations": [],
"spell": "3:9-3:12|11072669167287398027|2|2|-1",
"extent": "2:3-3:15|11072669167287398027|2|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [15768138241775955040],
"uses": []
}, {
"usr": 11072669167287398027, "usr": 11072669167287398027,
"detailed_name": "namespace ns {}", "detailed_name": "namespace ns {}",
"qual_name_offset": 10, "qual_name_offset": 10,
@ -82,7 +48,7 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [15768138241775955040, 3182917058194750998],
"uses": ["5:3-5:6|11072669167287398027|2|4|-1", "6:3-6:6|11072669167287398027|2|4|-1"] "uses": ["5:3-5:6|11072669167287398027|2|4|-1", "6:3-6:6|11072669167287398027|2|4|-1"]
}], }],
"usr2var": [{ "usr2var": [{
@ -93,7 +59,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "6:13-6:14|11072669167287398027|2|1026|-1", "spell": "6:13-6:14|11072669167287398027|2|1026|-1",
"extent": "6:3-6:14|11072669167287398027|2|0|-1", "extent": "6:3-6:14|11072669167287398027|2|0|-1",
"type": 3948666349864691553, "type": 14042997404480181958,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -105,7 +71,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "5:12-5:13|11072669167287398027|2|1026|-1", "spell": "5:12-5:13|11072669167287398027|2|1026|-1",
"extent": "5:3-5:13|11072669167287398027|2|0|-1", "extent": "5:3-5:13|11072669167287398027|2|0|-1",
"type": 8224244241460152567, "type": 14042997404480181958,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0

View File

@ -132,7 +132,7 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [2933643612409209903],
"uses": ["7:1-7:9|0|1|4|-1"] "uses": ["7:1-7:9|0|1|4|-1"]
}, { }, {
"usr": 1663022413889915338, "usr": 1663022413889915338,
@ -151,23 +151,6 @@ OUTPUT:
"vars": [], "vars": [],
"instances": [15931696253641284761], "instances": [15931696253641284761],
"uses": ["26:7-26:13|0|1|4|-1", "33:1-33:7|0|1|4|-1"] "uses": ["26:7-26:13|0|1|4|-1", "33:1-33:7|0|1|4|-1"]
}, {
"usr": 3231449734830406187,
"detailed_name": "function",
"qual_name_offset": 0,
"short_name": "function",
"kind": 26,
"declarations": [],
"spell": "5:7-5:15|0|1|2|-1",
"extent": "4:1-5:30|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [2933643612409209903],
"uses": []
}, { }, {
"usr": 5760043510674081814, "usr": 5760043510674081814,
"detailed_name": "struct Z1 {}", "detailed_name": "struct Z1 {}",
@ -200,7 +183,7 @@ OUTPUT:
"types": [], "types": [],
"funcs": [18107614608385228556], "funcs": [18107614608385228556],
"vars": [], "vars": [],
"instances": [], "instances": [5792869548777559988],
"uses": ["21:16-21:22|0|1|4|-1", "30:1-30:7|0|1|4|-1", "32:1-32:7|0|1|4|-1"] "uses": ["21:16-21:22|0|1|4|-1", "30:1-30:7|0|1|4|-1", "32:1-32:7|0|1|4|-1"]
}, { }, {
"usr": 9201299975592934124, "usr": 9201299975592934124,
@ -236,40 +219,6 @@ OUTPUT:
"vars": [], "vars": [],
"instances": [], "instances": [],
"uses": ["26:14-26:16|0|1|4|-1", "33:8-33:10|0|1|4|-1"] "uses": ["26:14-26:16|0|1|4|-1", "33:8-33:10|0|1|4|-1"]
}, {
"usr": 11153492883079050853,
"detailed_name": "vector",
"qual_name_offset": 0,
"short_name": "vector",
"kind": 26,
"declarations": [],
"spell": "17:7-17:13|0|1|2|-1",
"extent": "16:1-17:20|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [86949563628772958],
"uses": []
}, {
"usr": 13322943937025195708,
"detailed_name": "vector",
"qual_name_offset": 0,
"short_name": "vector",
"kind": 26,
"declarations": [],
"spell": "12:7-12:13|0|1|2|-1",
"extent": "11:1-14:2|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [5792869548777559988],
"uses": []
}, { }, {
"usr": 14111105212951082474, "usr": 14111105212951082474,
"detailed_name": "T", "detailed_name": "T",
@ -304,13 +253,11 @@ OUTPUT:
"uses": [] "uses": []
}, { }, {
"usr": 15440970074034693939, "usr": 15440970074034693939,
"detailed_name": "vector", "detailed_name": "",
"qual_name_offset": 0, "qual_name_offset": 0,
"short_name": "vector", "short_name": "",
"kind": 26, "kind": 0,
"declarations": [], "declarations": [],
"spell": "21:16-21:22|0|1|2|-1",
"extent": "21:1-21:26|0|1|0|-1",
"alias_of": 0, "alias_of": 0,
"bases": [], "bases": [],
"derived": [], "derived": [],
@ -349,7 +296,7 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [86949563628772958],
"uses": ["31:1-31:7|0|1|4|-1"] "uses": ["31:1-31:7|0|1|4|-1"]
}], }],
"usr2var": [{ "usr2var": [{
@ -360,7 +307,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "31:14-31:17|0|1|2|-1", "spell": "31:14-31:17|0|1|2|-1",
"extent": "31:1-31:17|0|1|0|-1", "extent": "31:1-31:17|0|1|0|-1",
"type": 11153492883079050853, "type": 16155717907537731864,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -372,7 +319,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "7:21-7:22|0|1|2|-1", "spell": "7:21-7:22|0|1|2|-1",
"extent": "7:1-7:22|0|1|0|-1", "extent": "7:1-7:22|0|1|0|-1",
"type": 3231449734830406187, "type": 218068462278884837,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -409,7 +356,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "30:14-30:16|0|1|2|-1", "spell": "30:14-30:16|0|1|2|-1",
"extent": "30:1-30:16|0|1|0|-1", "extent": "30:1-30:16|0|1|0|-1",
"type": 13322943937025195708, "type": 7440942986741176606,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0

View File

@ -50,23 +50,6 @@ OUTPUT:
"vars": [], "vars": [],
"instances": [], "instances": [],
"uses": ["9:5-9:6|0|1|4|-1"] "uses": ["9:5-9:6|0|1|4|-1"]
}, {
"usr": 7074603899792463171,
"detailed_name": "Inner",
"qual_name_offset": 0,
"short_name": "Inner",
"kind": 26,
"declarations": [],
"spell": "6:10-6:15|0|1|2|-1",
"extent": "6:3-6:18|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [16721564935990383768],
"uses": []
}, { }, {
"usr": 10528472276654770367, "usr": 10528472276654770367,
"detailed_name": "struct Foo {}", "detailed_name": "struct Foo {}",
@ -116,25 +99,8 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [16721564935990383768, 12028309045033782423],
"uses": ["9:9-9:14|0|1|4|-1", "10:9-10:14|0|1|4|-1"] "uses": ["9:9-9:14|0|1|4|-1", "10:9-10:14|0|1|4|-1"]
}, {
"usr": 15961308565836244174,
"detailed_name": "Inner",
"qual_name_offset": 0,
"short_name": "Inner",
"kind": 26,
"declarations": [],
"spell": "6:10-6:15|0|1|2|-1",
"extent": "6:3-6:18|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [12028309045033782423],
"uses": []
}], }],
"usr2var": [{ "usr2var": [{
"usr": 12028309045033782423, "usr": 12028309045033782423,
@ -144,7 +110,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "10:15-10:16|0|1|2|-1", "spell": "10:15-10:16|0|1|2|-1",
"extent": "10:1-10:16|0|1|0|-1", "extent": "10:1-10:16|0|1|0|-1",
"type": 15961308565836244174, "type": 13938528237873543349,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -156,7 +122,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "9:15-9:16|0|1|2|-1", "spell": "9:15-9:16|0|1|2|-1",
"extent": "9:1-9:16|0|1|0|-1", "extent": "9:1-9:16|0|1|0|-1",
"type": 7074603899792463171, "type": 13938528237873543349,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0

View File

@ -11,23 +11,6 @@ OUTPUT:
"skipped_ranges": [], "skipped_ranges": [],
"usr2func": [], "usr2func": [],
"usr2type": [{ "usr2type": [{
"usr": 5123806965838456033,
"detailed_name": "Foo",
"qual_name_offset": 0,
"short_name": "Foo",
"kind": 26,
"declarations": [],
"spell": "2:7-2:10|0|1|2|-1",
"extent": "1:1-2:13|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [16721564935990383768],
"uses": []
}, {
"usr": 10528472276654770367, "usr": 10528472276654770367,
"detailed_name": "class Foo {}", "detailed_name": "class Foo {}",
"qual_name_offset": 6, "qual_name_offset": 6,
@ -42,25 +25,8 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [16721564935990383768, 12028309045033782423],
"uses": ["4:1-4:4|0|1|4|-1", "5:1-5:4|0|1|4|-1"] "uses": ["4:1-4:4|0|1|4|-1", "5:1-5:4|0|1|4|-1"]
}, {
"usr": 14134940367505932005,
"detailed_name": "Foo",
"qual_name_offset": 0,
"short_name": "Foo",
"kind": 26,
"declarations": [],
"spell": "2:7-2:10|0|1|2|-1",
"extent": "1:1-2:13|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [12028309045033782423],
"uses": []
}], }],
"usr2var": [{ "usr2var": [{
"usr": 12028309045033782423, "usr": 12028309045033782423,
@ -70,7 +36,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "5:11-5:12|0|1|2|-1", "spell": "5:11-5:12|0|1|2|-1",
"extent": "5:1-5:12|0|1|0|-1", "extent": "5:1-5:12|0|1|0|-1",
"type": 14134940367505932005, "type": 10528472276654770367,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -82,7 +48,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "4:10-4:11|0|1|2|-1", "spell": "4:10-4:11|0|1|2|-1",
"extent": "4:1-4:11|0|1|0|-1", "extent": "4:1-4:11|0|1|0|-1",
"type": 5123806965838456033, "type": 10528472276654770367,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0

View File

@ -46,25 +46,8 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [12857919739649552168, 18075066956054788088, 3364438781074774169],
"uses": ["6:8-6:18|0|1|4|-1", "7:8-7:18|0|1|4|-1", "9:1-9:11|0|1|4|-1", "10:3-10:13|16359708726068806331|3|4|-1"] "uses": ["6:8-6:18|0|1|4|-1", "7:8-7:18|0|1|4|-1", "9:1-9:11|0|1|4|-1", "10:3-10:13|16359708726068806331|3|4|-1"]
}, {
"usr": 4186953406371619898,
"detailed_name": "unique_ptr",
"qual_name_offset": 0,
"short_name": "unique_ptr",
"kind": 26,
"declarations": [],
"spell": "2:7-2:17|0|1|2|-1",
"extent": "1:1-2:20|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [18075066956054788088, 3364438781074774169],
"uses": []
}, { }, {
"usr": 4750332761459066907, "usr": 4750332761459066907,
"detailed_name": "struct S {}", "detailed_name": "struct S {}",
@ -82,23 +65,6 @@ OUTPUT:
"vars": [], "vars": [],
"instances": [], "instances": [],
"uses": ["7:19-7:20|0|1|4|-1", "9:12-9:13|0|1|4|-1", "10:14-10:15|16359708726068806331|3|4|-1"] "uses": ["7:19-7:20|0|1|4|-1", "9:12-9:13|0|1|4|-1", "10:14-10:15|16359708726068806331|3|4|-1"]
}, {
"usr": 16848604152578034754,
"detailed_name": "unique_ptr",
"qual_name_offset": 0,
"short_name": "unique_ptr",
"kind": 26,
"declarations": [],
"spell": "2:7-2:17|0|1|2|-1",
"extent": "1:1-2:20|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [12857919739649552168],
"uses": []
}], }],
"usr2var": [{ "usr2var": [{
"usr": 3364438781074774169, "usr": 3364438781074774169,
@ -108,7 +74,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "10:18-10:23|16359708726068806331|3|2|-1", "spell": "10:18-10:23|16359708726068806331|3|2|-1",
"extent": "10:3-10:23|16359708726068806331|3|0|-1", "extent": "10:3-10:23|16359708726068806331|3|0|-1",
"type": 4186953406371619898, "type": 3286534761799572592,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -120,7 +86,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "6:25-6:27|0|1|2|-1", "spell": "6:25-6:27|0|1|2|-1",
"extent": "6:1-6:27|0|1|0|-1", "extent": "6:1-6:27|0|1|0|-1",
"type": 16848604152578034754, "type": 3286534761799572592,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 2 "storage": 2
@ -132,7 +98,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "7:22-7:24|0|1|2|-1", "spell": "7:22-7:24|0|1|2|-1",
"extent": "7:1-7:24|0|1|0|-1", "extent": "7:1-7:24|0|1|0|-1",
"type": 4186953406371619898, "type": 3286534761799572592,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 2 "storage": 2

View File

@ -202,7 +202,7 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [], "instances": [2933643612409209903, 500112618220246],
"uses": [] "uses": []
}, { }, {
"usr": 15041163540773201510, "usr": 15041163540773201510,
@ -223,20 +223,18 @@ OUTPUT:
"uses": ["79:21-79:24|0|1|4|-1"] "uses": ["79:21-79:24|0|1|4|-1"]
}, { }, {
"usr": 18153735331422331128, "usr": 18153735331422331128,
"detailed_name": "unique_ptr", "detailed_name": "template<> class unique_ptr<unique_ptr<S1, S2>, S2>",
"qual_name_offset": 0, "qual_name_offset": 17,
"short_name": "unique_ptr", "short_name": "unique_ptr",
"kind": 5, "kind": 5,
"declarations": [], "declarations": [],
"spell": "2:7-2:17|0|1|2|-1",
"extent": "1:1-2:17|0|1|0|-1",
"alias_of": 0, "alias_of": 0,
"bases": [], "bases": [],
"derived": [], "derived": [],
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [2933643612409209903, 500112618220246], "instances": [],
"uses": ["15:8-15:18|0|1|4|-1", "33:1-33:11|0|1|4|-1", "54:3-54:13|18320186404467436976|3|4|-1"] "uses": ["15:8-15:18|0|1|4|-1", "33:1-33:11|0|1|4|-1", "54:3-54:13|18320186404467436976|3|4|-1"]
}], }],
"usr2var": [{ "usr2var": [{
@ -247,7 +245,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "54:39-54:44|18320186404467436976|3|2|-1", "spell": "54:39-54:44|18320186404467436976|3|2|-1",
"extent": "54:3-54:44|18320186404467436976|3|0|-1", "extent": "54:3-54:44|18320186404467436976|3|0|-1",
"type": 18153735331422331128, "type": 14209198335088845323,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 0 "storage": 0
@ -257,7 +255,7 @@ OUTPUT:
"qual_name_offset": 42, "qual_name_offset": 42,
"short_name": "f", "short_name": "f",
"declarations": ["15:43-15:44|15:1-15:44|0|1|1|-1"], "declarations": ["15:43-15:44|15:1-15:44|0|1|1|-1"],
"type": 18153735331422331128, "type": 14209198335088845323,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 1 "storage": 1

View File

@ -26,25 +26,8 @@ OUTPUT:
"types": [], "types": [],
"funcs": [], "funcs": [],
"vars": [], "vars": [],
"instances": [],
"uses": ["6:8-6:18|0|1|4|-1"]
}, {
"usr": 4186953406371619898,
"detailed_name": "unique_ptr",
"qual_name_offset": 0,
"short_name": "unique_ptr",
"kind": 26,
"declarations": [],
"spell": "2:7-2:17|0|1|2|-1",
"extent": "1:1-2:20|0|1|0|-1",
"alias_of": 0,
"bases": [],
"derived": [],
"types": [],
"funcs": [],
"vars": [],
"instances": [3398408600781120939], "instances": [3398408600781120939],
"uses": [] "uses": ["6:8-6:18|0|1|4|-1"]
}, { }, {
"usr": 4750332761459066907, "usr": 4750332761459066907,
"detailed_name": "struct S", "detailed_name": "struct S",
@ -69,7 +52,7 @@ OUTPUT:
"declarations": [], "declarations": [],
"spell": "6:22-6:25|0|1|2|-1", "spell": "6:22-6:25|0|1|2|-1",
"extent": "6:1-6:25|0|1|0|-1", "extent": "6:1-6:25|0|1|0|-1",
"type": 4186953406371619898, "type": 3286534761799572592,
"uses": [], "uses": [],
"kind": 13, "kind": 13,
"storage": 2 "storage": 2

View File

@ -283,41 +283,6 @@ try_again:
return D; return D;
} }
const Decl *GetSpecialized(const Decl *D) {
if (!D)
return D;
Decl *Template = nullptr;
if (const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
if (const ClassTemplatePartialSpecializationDecl *PartialSpec =
dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord))
Template = PartialSpec->getSpecializedTemplate();
else if (const ClassTemplateSpecializationDecl *ClassSpec =
dyn_cast<ClassTemplateSpecializationDecl>(CXXRecord)) {
llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
Result = ClassSpec->getSpecializedTemplateOrPartial();
if (Result.is<ClassTemplateDecl *>())
Template = Result.get<ClassTemplateDecl *>();
else
Template = Result.get<ClassTemplatePartialSpecializationDecl *>();
} else
Template = CXXRecord->getInstantiatedFromMemberClass();
} else if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
Template = Function->getPrimaryTemplate();
if (!Template)
Template = Function->getInstantiatedFromMemberFunction();
} else if (const VarDecl *Var = dyn_cast<VarDecl>(D)) {
if (Var->isStaticDataMember())
Template = Var->getInstantiatedFromStaticDataMember();
} else if (const RedeclarableTemplateDecl *Tmpl =
dyn_cast<RedeclarableTemplateDecl>(D))
Template = Tmpl->getInstantiatedFromMemberTemplate();
else
return nullptr;
return Template;
}
bool ValidateRecord(const RecordDecl *RD) { bool ValidateRecord(const RecordDecl *RD) {
for (const auto *I : RD->fields()) { for (const auto *I : RD->fields()) {
QualType FQT = I->getType(); QualType FQT = I->getType();
@ -778,19 +743,30 @@ public:
var->def.type = usr1; var->def.type = usr1;
db->ToType(usr1).instances.push_back(usr); db->ToType(usr1).instances.push_back(usr);
} else { } else {
for (const Decl *D1 = GetTypeDecl(T); D1; D1 = GetSpecialized(D1)) { for (const Decl *D1 = GetTypeDecl(T); D1; ) {
IndexParam::DeclInfo *info1; if (auto *R1 = dyn_cast<CXXRecordDecl>(D1)) {
Usr usr1 = GetUsr(D1, &info1); if (auto *S1 = dyn_cast<ClassTemplateSpecializationDecl>(D1)) {
auto it = db->usr2type.find(usr1); if (!S1->getTypeAsWritten()) {
if (it != db->usr2type.end()) { llvm::PointerUnion<ClassTemplateDecl *,
var->def.type = usr1; ClassTemplatePartialSpecializationDecl *>
it->second.instances.push_back(usr); Result = S1->getSpecializedTemplateOrPartial();
break; if (Result.is<ClassTemplateDecl *>())
D1 = Result.get<ClassTemplateDecl *>();
else
D1 = Result.get<ClassTemplatePartialSpecializationDecl *>();
continue;
} }
} else if (auto *D2 = R1->getInstantiatedFromMemberClass()) {
D1 = D2;
continue;
}
} else if (auto *TP1 = dyn_cast<TemplateTypeParmDecl>(D1)) {
// e.g. TemplateTypeParmDecl is not handled by // e.g. TemplateTypeParmDecl is not handled by
// handleDeclOccurence. // handleDeclOccurence.
SourceRange R1 = D1->getSourceRange(); SourceRange R1 = D1->getSourceRange();
if (SM.getFileID(R1.getBegin()) == LocFID) { if (SM.getFileID(R1.getBegin()) == LocFID) {
IndexParam::DeclInfo *info1;
Usr usr1 = GetUsr(D1, &info1);
IndexType &type1 = db->ToType(usr1); IndexType &type1 = db->ToType(usr1);
SourceLocation L1 = D1->getLocation(); SourceLocation L1 = D1->getLocation();
type1.def.spell = type1.def.spell =
@ -806,6 +782,13 @@ public:
break; break;
} }
} }
IndexParam::DeclInfo *info1;
Usr usr1 = GetUsr(D1, &info1);
var->def.type = usr1;
db->ToType(usr1).instances.push_back(usr);
break;
}
} }
} }
} else if (!var->def.spell && var->declarations.empty()) { } else if (!var->def.spell && var->declarations.empty()) {