mark type definition as interesting

This commit is contained in:
Jacob Dufault 2017-02-20 21:55:48 -08:00
parent a7f5231e4c
commit 6a95d2f46f
47 changed files with 70 additions and 68 deletions

View File

@ -92,6 +92,12 @@ bool IsEqualTo(const Location& o) {
return (wrapper.value >> 1) == (o.wrapper.value >> 1);
}
Location WithInteresting(bool interesting) {
Location result = *this;
result.interesting = interesting;
return result;
}
END_BITFIELD_TYPE()
struct FileDb {
@ -1058,8 +1064,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
type_def->short_name = decl->entityInfo->name;
type_def->qualified_name = ns->QualifiedName(decl->semanticContainer, type_def->short_name);
Location decl_loc = db->file_db.Resolve(decl->loc, false /*interesting*/);
type_def->definition = decl_loc;
Location decl_loc = db->file_db.Resolve(decl->loc, true /*interesting*/);
type_def->definition = decl_loc.WithInteresting(false);
type_def->AddUsage(decl_loc);
break;
}
@ -1082,8 +1088,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
// }
assert(decl->isDefinition);
Location decl_loc = db->file_db.Resolve(decl->loc, false /*interesting*/);
type_def->definition = decl_loc;
Location decl_loc = db->file_db.Resolve(decl->loc, true /*interesting*/);
type_def->definition = decl_loc.WithInteresting(false);
type_def->AddUsage(decl_loc);
//type_def->alias_of

View File

@ -12,7 +12,7 @@ OUTPUT:
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "1:3:7",
"uses": ["1:1:7", "1:2:7", "1:3:7", "1:4:7"]
"uses": ["1:1:7", "1:2:7", "*1:3:7", "1:4:7"]
}],
"functions": [],
"variables": []

View File

@ -18,7 +18,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0],
"uses": ["1:1:7", "1:3:3", "*1:7:3", "*1:8:3", "*1:8:17"]
"uses": ["*1:1:7", "1:3:3", "*1:7:3", "*1:8:3", "*1:8:17"]
}],
"functions": [{
"id": 0,

View File

@ -23,7 +23,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0, 1],
"uses": ["1:1:7", "1:3:3", "1:4:3", "*1:8:3"]
"uses": ["*1:1:7", "1:3:3", "1:4:3", "*1:8:3"]
}],
"functions": [{
"id": 0,

View File

@ -14,7 +14,7 @@ OUTPUT:
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "1:3:7",
"uses": ["1:1:7", "1:2:7", "1:3:7", "1:4:7"]
"uses": ["1:1:7", "1:2:7", "*1:3:7", "1:4:7"]
}],
"functions": [],
"variables": []

View File

@ -12,7 +12,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0],
"uses": ["1:1:7"]
"uses": ["*1:1:7"]
}],
"functions": [],
"variables": [{

View File

@ -14,7 +14,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0],
"uses": ["1:1:7", "1:5:5"]
"uses": ["*1:1:7", "1:5:5"]
}],
"functions": [],
"variables": [{

View File

@ -16,7 +16,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0, 1, 2],
"uses": ["1:1:7", "1:7:6"]
"uses": ["*1:1:7", "1:7:6"]
}],
"functions": [{
"id": 0,

View File

@ -13,7 +13,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:12",
"vars": [0, 1],
"uses": ["1:1:12"]
"uses": ["*1:1:12"]
}],
"functions": [],
"variables": [{

View File

@ -13,7 +13,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:6",
"vars": [0, 1],
"uses": ["1:1:6"]
"uses": ["*1:1:6"]
}],
"functions": [],
"variables": [{

View File

@ -13,7 +13,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:6",
"vars": [0, 1],
"uses": ["1:1:6"]
"uses": ["*1:1:6"]
}],
"functions": [],
"variables": [{

View File

@ -15,7 +15,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:12",
"vars": [0, 1],
"uses": ["1:1:12", "*1:6:1", "1:6:9"]
"uses": ["*1:1:12", "*1:6:1", "1:6:9"]
}],
"functions": [],
"variables": [{

View File

@ -11,7 +11,7 @@ OUTPUT:
"qualified_name": "Parent",
"definition": "1:1:7",
"derived": [1],
"uses": ["1:1:7", "*1:2:24"]
"uses": ["*1:1:7", "*1:2:24"]
}, {
"id": 1,
"usr": "c:@S@Derived",
@ -19,7 +19,7 @@ OUTPUT:
"qualified_name": "Derived",
"definition": "1:2:7",
"parents": [0],
"uses": ["1:2:7"]
"uses": ["*1:2:7"]
}],
"functions": [],
"variables": []

View File

@ -22,7 +22,7 @@ OUTPUT:
"qualified_name": "Base1",
"definition": "1:2:7",
"derived": [2, 5],
"uses": ["1:2:7", "*1:8:18", "*1:13:17"]
"uses": ["*1:2:7", "*1:8:18", "*1:13:17"]
}, {
"id": 1,
"usr": "c:@ST>1#T@Base2",
@ -30,7 +30,7 @@ OUTPUT:
"qualified_name": "Base2",
"definition": "1:5:7",
"derived": [3, 5],
"uses": ["1:5:7", "*1:11:18", "*1:13:27"]
"uses": ["*1:5:7", "*1:11:18", "*1:13:27"]
}, {
"id": 2,
"usr": "c:@ST>1#Ni@Derived1",
@ -39,7 +39,7 @@ OUTPUT:
"definition": "1:8:7",
"parents": [0],
"derived": [5],
"uses": ["1:8:7", "*1:13:43"]
"uses": ["*1:8:7", "*1:13:43"]
}, {
"id": 3,
"usr": "c:@ST>1#T@Derived2",
@ -48,7 +48,7 @@ OUTPUT:
"definition": "1:11:7",
"parents": [1],
"derived": [5],
"uses": ["1:11:7", "*1:13:56"]
"uses": ["*1:11:7", "*1:13:56"]
}, {
"id": 4,
"usr": "c:class_inherit_templated_parent.cc@154",
@ -60,7 +60,7 @@ OUTPUT:
"qualified_name": "Derived",
"definition": "1:13:7",
"parents": [0, 1, 2, 3],
"uses": ["1:13:7", "*1:13:33", "*1:13:65"]
"uses": ["*1:13:7", "*1:13:33", "*1:13:65"]
}],
"functions": [],
"variables": []

View File

@ -13,7 +13,7 @@ OUTPUT:
"qualified_name": "Root",
"definition": "1:1:7",
"derived": [1, 2],
"uses": ["1:1:7", "*1:2:24", "*1:3:24"]
"uses": ["*1:1:7", "*1:2:24", "*1:3:24"]
}, {
"id": 1,
"usr": "c:@S@MiddleA",
@ -22,7 +22,7 @@ OUTPUT:
"definition": "1:2:7",
"parents": [0],
"derived": [3],
"uses": ["1:2:7", "*1:4:24"]
"uses": ["*1:2:7", "*1:4:24"]
}, {
"id": 2,
"usr": "c:@S@MiddleB",
@ -31,7 +31,7 @@ OUTPUT:
"definition": "1:3:7",
"parents": [0],
"derived": [3],
"uses": ["1:3:7", "*1:4:40"]
"uses": ["*1:3:7", "*1:4:40"]
}, {
"id": 3,
"usr": "c:@S@Derived",
@ -39,7 +39,7 @@ OUTPUT:
"qualified_name": "Derived",
"definition": "1:4:7",
"parents": [1, 2],
"uses": ["1:4:7"]
"uses": ["*1:4:7"]
}],
"functions": [],
"variables": []

View File

@ -16,7 +16,7 @@ OUTPUT:
"definition": "1:1:7",
"derived": [1],
"funcs": [0],
"uses": ["1:1:7", "*1:4:24"]
"uses": ["*1:1:7", "*1:4:24"]
}, {
"id": 1,
"usr": "c:@S@Derived",
@ -25,7 +25,7 @@ OUTPUT:
"definition": "1:4:7",
"parents": [0],
"funcs": [1],
"uses": ["1:4:7"]
"uses": ["*1:4:7"]
}],
"functions": [{
"id": 0,

View File

@ -12,7 +12,7 @@ OUTPUT:
"qualified_name": "IFoo",
"definition": "1:1:7",
"funcs": [0],
"uses": ["1:1:7"]
"uses": ["*1:1:7"]
}],
"functions": [{
"id": 0,

View File

@ -16,7 +16,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0],
"uses": ["1:1:7"]
"uses": ["*1:1:7"]
}],
"functions": [{
"id": 0,

View File

@ -14,7 +14,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0],
"uses": ["1:1:7", "1:5:6"]
"uses": ["*1:1:7", "1:5:6"]
}],
"functions": [{
"id": 0,

View File

@ -12,7 +12,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0],
"uses": ["1:1:7"]
"uses": ["*1:1:7"]
}],
"functions": [{
"id": 0,

View File

@ -14,7 +14,7 @@ OUTPUT:
"qualified_name": "hello::Foo",
"definition": "1:2:7",
"funcs": [0],
"uses": ["1:2:7"]
"uses": ["*1:2:7"]
}],
"functions": [{
"id": 0,

View File

@ -16,7 +16,7 @@ OUTPUT:
"qualified_name": "hello::Foo",
"definition": "1:2:7",
"funcs": [0],
"uses": ["1:2:7", "1:6:6"]
"uses": ["*1:2:7", "1:6:6"]
}],
"functions": [{
"id": 0,

View File

@ -14,7 +14,7 @@ OUTPUT:
"qualified_name": "hello::Foo",
"definition": "1:2:7",
"funcs": [0],
"uses": ["1:2:7"]
"uses": ["*1:2:7"]
}],
"functions": [{
"id": 0,

View File

@ -13,7 +13,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0, 1],
"uses": ["1:1:7"]
"uses": ["*1:1:7"]
}],
"functions": [],
"variables": [{

View File

@ -19,7 +19,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0, 1],
"uses": ["1:1:7", "*1:6:1", "*1:8:10"]
"uses": ["*1:1:7", "*1:6:1", "*1:8:10"]
}],
"functions": [{
"id": 0,

View File

@ -17,7 +17,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:8",
"funcs": [0],
"uses": ["1:1:8", "1:6:13"]
"uses": ["*1:1:8", "1:6:13"]
}],
"functions": [{
"id": 0,

View File

@ -17,7 +17,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:8",
"funcs": [0],
"uses": ["1:1:8", "*1:6:3"]
"uses": ["*1:1:8", "*1:6:3"]
}],
"functions": [{
"id": 0,

View File

@ -16,7 +16,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:5:7",
"vars": [0],
"uses": ["1:5:7"]
"uses": ["*1:5:7"]
}],
"functions": [{
"id": 0,

View File

@ -16,7 +16,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:8",
"funcs": [0],
"uses": ["1:1:8", "*1:6:3"]
"uses": ["*1:1:8", "*1:6:3"]
}],
"functions": [{
"id": 0,

View File

@ -23,7 +23,7 @@ OUTPUT:
"short_name": "S",
"qualified_name": "S",
"definition": "1:4:8",
"uses": ["1:4:8", "*1:7:19", "*1:9:12", "*1:10:14"]
"uses": ["*1:4:8", "*1:7:19", "*1:9:12", "*1:10:14"]
}],
"functions": [{
"id": 0,

View File

@ -100,7 +100,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:64:7",
"funcs": [3],
"uses": ["1:64:7", "1:79:21"]
"uses": ["*1:64:7", "1:79:21"]
}],
"functions": [{
"id": 0,

View File

@ -14,7 +14,7 @@ OUTPUT:
"short_name": "unique_ptr",
"qualified_name": "unique_ptr",
"definition": "1:2:7",
"uses": ["1:2:7", "*1:6:8"]
"uses": ["*1:2:7", "*1:6:8"]
}, {
"id": 1,
"usr": "c:@S@S",

View File

@ -10,7 +10,7 @@ OUTPUT:
"short_name": "T",
"qualified_name": "T",
"definition": "1:1:8",
"uses": ["1:1:8", "*1:3:8"]
"uses": ["*1:1:8", "*1:3:8"]
}],
"functions": [],
"variables": [{

View File

@ -19,7 +19,7 @@ OUTPUT:
"short_name": "ImplementedType",
"qualified_name": "ImplementedType",
"definition": "1:2:8",
"uses": ["1:2:8", "*1:6:3"]
"uses": ["*1:2:8", "*1:6:3"]
}, {
"id": 2,
"usr": "c:@S@Foo",
@ -27,7 +27,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:4:8",
"vars": [0, 1],
"uses": ["1:4:8"]
"uses": ["*1:4:8"]
}],
"functions": [],
"variables": [{

View File

@ -19,7 +19,7 @@ OUTPUT:
"short_name": "ImplementedType",
"qualified_name": "ImplementedType",
"definition": "1:2:8",
"uses": ["1:2:8", "*1:6:3"]
"uses": ["*1:2:8", "*1:6:3"]
}],
"functions": [{
"id": 0,

View File

@ -16,7 +16,7 @@ OUTPUT:
"short_name": "ImplementedType",
"qualified_name": "ImplementedType",
"definition": "1:2:8",
"uses": ["1:2:8", "*1:4:26"]
"uses": ["*1:2:8", "*1:4:26"]
}],
"functions": [{
"id": 0,

View File

@ -15,7 +15,7 @@ OUTPUT:
"short_name": "Type",
"qualified_name": "Type",
"definition": "1:1:8",
"uses": ["1:1:8", "*1:3:10", "*1:3:26", "*1:4:3", "*1:5:3", "*1:6:9", "*1:7:9"]
"uses": ["*1:1:8", "*1:3:10", "*1:3:26", "*1:4:3", "*1:5:3", "*1:6:9", "*1:7:9"]
}],
"functions": [{
"id": 0,

View File

@ -31,7 +31,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:7:7",
"funcs": [1, 2],
"uses": ["1:7:7", "1:12:7", "1:13:6"]
"uses": ["*1:7:7", "1:12:7", "1:13:6"]
}],
"functions": [{
"id": 0,

View File

@ -11,10 +11,6 @@ void accept3(Foo3*) {}
/*
// TODO: I think we should mark using Foo1 = foo as an interesting usage on
// Foo1.
// TODO: Also mark class Foo {} as an interesting usage of Foo.
OUTPUT:
{
"types": [{
@ -28,7 +24,7 @@ OUTPUT:
"qualified_name": "Foo1",
"definition": "1:2:7",
"alias_of": 0,
"uses": ["1:2:7", "*1:4:14", "*1:8:14"]
"uses": ["*1:2:7", "*1:4:14", "*1:8:14"]
}, {
"id": 2,
"usr": "c:type_usage_typedef_and_using.cc@T@Foo2",
@ -36,7 +32,7 @@ OUTPUT:
"qualified_name": "Foo2",
"definition": "1:3:13",
"alias_of": 0,
"uses": ["1:3:13", "*1:9:14"]
"uses": ["*1:3:13", "*1:9:14"]
}, {
"id": 3,
"usr": "c:@Foo3",
@ -44,14 +40,14 @@ OUTPUT:
"qualified_name": "Foo3",
"definition": "1:4:7",
"alias_of": 1,
"uses": ["1:4:7", "*1:10:14"]
"uses": ["*1:4:7", "*1:10:14"]
}, {
"id": 4,
"usr": "c:@Foo4",
"short_name": "Foo4",
"qualified_name": "Foo4",
"definition": "1:5:7",
"uses": ["1:5:7"]
"uses": ["*1:5:7"]
}],
"functions": [{
"id": 0,

View File

@ -18,7 +18,7 @@ OUTPUT:
"qualified_name": "Foo1",
"definition": "1:4:7",
"alias_of": 0,
"uses": ["1:4:7", "*1:5:13"]
"uses": ["*1:4:7", "*1:5:13"]
}, {
"id": 2,
"usr": "c:type_usage_typedef_and_using_template.cc@T@Foo2",
@ -26,7 +26,7 @@ OUTPUT:
"qualified_name": "Foo2",
"definition": "1:5:19",
"alias_of": 0,
"uses": ["1:5:19"]
"uses": ["*1:5:19"]
}],
"functions": [],
"variables": []

View File

@ -19,7 +19,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"funcs": [0],
"uses": ["1:1:7", "*1:2:3", "*1:5:1", "1:5:6", "*1:6:3", "*1:10:8"]
"uses": ["*1:1:7", "*1:2:3", "*1:5:1", "1:5:6", "*1:6:3", "*1:10:8"]
}],
"functions": [{
"id": 0,

View File

@ -24,7 +24,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:5:8",
"vars": [1, 0],
"uses": ["1:5:8", "1:10:5", "1:14:22", "1:14:40"]
"uses": ["*1:5:8", "1:10:5", "1:14:22", "1:14:40"]
}],
"functions": [{
"id": 0,

View File

@ -27,7 +27,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0, 1],
"uses": ["1:1:7", "*1:11:3"]
"uses": ["*1:1:7", "*1:11:3"]
}],
"functions": [{
"id": 0,

View File

@ -17,7 +17,7 @@ OUTPUT:
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "1:1:8",
"uses": ["1:1:8", "1:8:10"]
"uses": ["*1:1:8", "1:8:10"]
}],
"functions": [{
"id": 0,

View File

@ -11,7 +11,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0],
"uses": ["1:1:7", "*1:2:3"]
"uses": ["*1:1:7", "*1:2:3"]
}],
"functions": [],
"variables": [{

View File

@ -13,7 +13,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "1:1:7",
"vars": [0],
"uses": ["1:1:7", "*1:2:10", "*1:4:1", "1:4:6"]
"uses": ["*1:1:7", "*1:2:10", "*1:4:1", "1:4:6"]
}],
"functions": [],
"variables": [{

View File

@ -10,7 +10,7 @@ OUTPUT:
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "1:1:7",
"uses": ["1:1:7"]
"uses": ["*1:1:7"]
}],
"functions": [],
"variables": [{