index declaration vs definition

This commit is contained in:
Jacob Dufault 2017-02-19 23:51:31 -08:00
parent 657260eeab
commit 0dabbb3093
49 changed files with 252 additions and 51 deletions

View File

@ -70,7 +70,16 @@ struct TypeDef {
std::string usr;
std::string short_name;
std::string qualified_name;
std::optional<clang::SourceLocation> declaration; // Forward decl. TODO: remove
// While a class/type can technically have a separate declaration/definition,
// it doesn't really happen in practice. The declaration never contains
// comments or insightful information. The user always wants to jump from
// the declaration to the definition - never the other way around like in
// functions and (less often) variables.
//
// It's also difficult to identify a `class Foo;` statement with the clang
// indexer API (it's doable using cursor AST traversal), so we don't bother
// supporting the feature.
std::optional<clang::SourceLocation> definition;
// If set, then this is the same underlying type as the given value (ie, this
@ -141,6 +150,9 @@ struct VarDef {
std::string short_name;
std::string qualified_name;
std::optional<clang::SourceLocation> declaration;
// TODO: definitions should be a list of locations, since there can be more
// than one.
std::optional<clang::SourceLocation> definition;
// Type of the variable.
std::optional<TypeId> variable_type;
@ -360,7 +372,6 @@ std::string ParsingDatabase::ToString() {
WRITE(usr);
WRITE(short_name);
WRITE(qualified_name);
WRITE(declaration);
WRITE(definition);
WRITE(alias_of);
WRITE(parents);
@ -406,6 +417,7 @@ std::string ParsingDatabase::ToString() {
WRITE(short_name);
WRITE(qualified_name);
WRITE(declaration);
WRITE(definition);
WRITE(variable_type);
WRITE(declaring_type);
//WRITE(initializations);
@ -1303,7 +1315,11 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
var_def->qualified_name = ns->QualifiedName(decl->semanticContainer, var_def->short_name);
//}
var_def->declaration = decl->loc;
if (decl->isDefinition)
var_def->definition = decl->loc;
else
var_def->declaration = decl->loc;
var_def->all_uses.push_back(decl->loc);
// Declaring variable type information.
@ -1351,6 +1367,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
if (decl->isDefinition)
func_def->definition = decl->loc;
else
func_def->declaration = decl->loc;
func_def->all_uses.push_back(decl->loc);
@ -1464,6 +1482,7 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
type_def->qualified_name = ns->QualifiedName(decl->semanticContainer, type_def->short_name);
// }
assert(decl->isDefinition);
type_def->definition = decl->loc;
type_def->all_uses.push_back(decl->loc);
@ -1796,6 +1815,7 @@ int main(int argc, char** argv) {
for (std::string path : GetFilesInFolder("tests")) {
// TODO: Fix all existing tests.
//if (path != "tests/declaration_vs_definition/method.cc") continue;
//if (path == "tests/usage/type_usage_declare_extern.cc") continue;
//if (path != "tests/constructors/destructor.cc") continue;
//if (path != "tests/usage/usage_inside_of_call.cc") continue;

View File

@ -45,7 +45,7 @@ OUTPUT:
"usr": "c:constructor.cc@56@F@foo#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/constructors/constructor.cc:7:7",
"definition": "tests/constructors/constructor.cc:7:7",
"variable_type": 0,
"all_uses": ["tests/constructors/constructor.cc:7:7"]
}, {
@ -53,7 +53,7 @@ OUTPUT:
"usr": "c:constructor.cc@66@F@foo#@f2",
"short_name": "f2",
"qualified_name": "f2",
"declaration": "tests/constructors/constructor.cc:8:8",
"definition": "tests/constructors/constructor.cc:8:8",
"variable_type": 0,
"all_uses": ["tests/constructors/constructor.cc:8:8"]
}]

View File

@ -57,7 +57,7 @@ OUTPUT:
"usr": "c:destructor.cc@70@F@foo#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/constructors/destructor.cc:8:7",
"definition": "tests/constructors/destructor.cc:8:7",
"variable_type": 0,
"all_uses": ["tests/constructors/destructor.cc:8:7"]
}]

View File

@ -0,0 +1,22 @@
class Foo;
class Foo;
class Foo {};
class Foo;
/*
// NOTE: Separate decl/definition are not supported for classes. See source
// for comments.
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "tests/declaration_vs_definition/class.cc:3:7",
"all_uses": ["tests/declaration_vs_definition/class.cc:1:7", "tests/declaration_vs_definition/class.cc:2:7", "tests/declaration_vs_definition/class.cc:3:7", "tests/declaration_vs_definition/class.cc:4:7"]
}],
"functions": [],
"variables": []
}
*/

View File

@ -0,0 +1,28 @@
class Foo {
int foo;
};
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "tests/declaration_vs_definition/class_member.cc:1:7",
"vars": [0],
"all_uses": ["tests/declaration_vs_definition/class_member.cc:1:7"]
}],
"functions": [],
"variables": [{
"id": 0,
"usr": "c:@S@Foo@FI@foo",
"short_name": "foo",
"qualified_name": "Foo::foo",
"definition": "tests/declaration_vs_definition/class_member.cc:2:7",
"declaring_type": 0,
"all_uses": ["tests/declaration_vs_definition/class_member.cc:2:7"]
}]
}
*/

View File

@ -0,0 +1,31 @@
class Foo {
static int foo;
};
int Foo::foo;
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "tests/declaration_vs_definition/class_member_static.cc:1:7",
"vars": [0],
"all_uses": ["tests/declaration_vs_definition/class_member_static.cc:1:7", "tests/declaration_vs_definition/class_member_static.cc:5:5"]
}],
"functions": [],
"variables": [{
"id": 0,
"usr": "c:@S@Foo@foo",
"short_name": "foo",
"qualified_name": "Foo::foo",
"declaration": "tests/declaration_vs_definition/class_member_static.cc:2:14",
"definition": "tests/declaration_vs_definition/class_member_static.cc:5:10",
"declaring_type": 0,
"all_uses": ["tests/declaration_vs_definition/class_member_static.cc:2:14", "tests/declaration_vs_definition/class_member_static.cc:5:10"]
}]
}
*/

View File

@ -0,0 +1,23 @@
void foo();
void foo();
void foo() {}
void foo();
/*
// Note: we always use the latest seen ("most local") definition/declaration.
OUTPUT:
{
"types": [],
"functions": [{
"id": 0,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/declaration_vs_definition/func.cc:4:6",
"definition": "tests/declaration_vs_definition/func.cc:3:6",
"all_uses": ["tests/declaration_vs_definition/func.cc:1:6", "tests/declaration_vs_definition/func.cc:2:6", "tests/declaration_vs_definition/func.cc:3:6", "tests/declaration_vs_definition/func.cc:4:6"]
}],
"variables": []
}
*/

View File

@ -0,0 +1,48 @@
class Foo {
void declonly();
virtual void purevirtual() = 0;
void def();
};
void Foo::def() {}
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "tests/declaration_vs_definition/method.cc:1:7",
"funcs": [1, 2],
"all_uses": ["tests/declaration_vs_definition/method.cc:1:7", "tests/declaration_vs_definition/method.cc:7:6"]
}],
"functions": [{
"id": 0,
"usr": "c:@S@Foo@F@declonly#",
"short_name": "declonly",
"qualified_name": "Foo::declonly",
"declaration": "tests/declaration_vs_definition/method.cc:2:8",
"all_uses": ["tests/declaration_vs_definition/method.cc:2:8"]
}, {
"id": 1,
"usr": "c:@S@Foo@F@purevirtual#",
"short_name": "purevirtual",
"qualified_name": "Foo::purevirtual",
"declaration": "tests/declaration_vs_definition/method.cc:3:16",
"declaring_type": 0,
"all_uses": ["tests/declaration_vs_definition/method.cc:3:16"]
}, {
"id": 2,
"usr": "c:@S@Foo@F@def#",
"short_name": "def",
"qualified_name": "Foo::def",
"declaration": "tests/declaration_vs_definition/method.cc:4:8",
"definition": "tests/declaration_vs_definition/method.cc:7:11",
"declaring_type": 0,
"all_uses": ["tests/declaration_vs_definition/method.cc:4:8", "tests/declaration_vs_definition/method.cc:7:11"]
}],
"variables": []
}
*/

View File

@ -15,6 +15,7 @@ OUTPUT:
"usr": "c:@F@called#I#",
"short_name": "called",
"qualified_name": "called",
"declaration": "tests/foobar.cc:1:6",
"callers": ["2@tests/foobar.cc:6:3"],
"all_uses": ["tests/foobar.cc:1:6", "tests/foobar.cc:6:3"]
}, {

View File

@ -9,6 +9,7 @@ OUTPUT:
"usr": "c:@F@foo#I#I#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/function_declaration.cc:1:6",
"all_uses": ["tests/function_declaration.cc:1:6"]
}],
"variables": []

View File

@ -11,6 +11,7 @@ OUTPUT:
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/function_declaration_definition.cc:1:6",
"definition": "tests/function_declaration_definition.cc:3:6",
"all_uses": ["tests/function_declaration_definition.cc:1:6", "tests/function_declaration_definition.cc:3:6"]
}],

View File

@ -31,6 +31,7 @@ OUTPUT:
"usr": "c:@S@Root@F@foo#",
"short_name": "foo",
"qualified_name": "Root::foo",
"declaration": "tests/inheritance/function_override.cc:2:16",
"derived": [1],
"all_uses": ["tests/inheritance/function_override.cc:2:16"]
}, {

View File

@ -25,6 +25,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@foo#",
"short_name": "foo",
"qualified_name": "Foo::foo",
"declaration": "tests/method_declaration.cc:2:8",
"all_uses": ["tests/method_declaration.cc:2:8"]
}],
"variables": []

View File

@ -21,6 +21,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@foo#",
"short_name": "foo",
"qualified_name": "Foo::foo",
"declaration": "tests/method_definition.cc:2:8",
"definition": "tests/method_definition.cc:5:11",
"declaring_type": 0,
"all_uses": ["tests/method_definition.cc:2:8", "tests/method_definition.cc:5:11"]

View File

@ -11,6 +11,7 @@ OUTPUT:
"usr": "c:anonymous_function.cc@aN@F@foo#",
"short_name": "foo",
"qualified_name": "::foo",
"declaration": "tests/namespaces/anonymous_function.cc:2:6",
"all_uses": ["tests/namespaces/anonymous_function.cc:2:6"]
}],
"variables": []

View File

@ -11,6 +11,7 @@ OUTPUT:
"usr": "c:@N@hello@F@foo#I#I#",
"short_name": "foo",
"qualified_name": "hello::foo",
"declaration": "tests/namespaces/function_declaration.cc:2:6",
"all_uses": ["tests/namespaces/function_declaration.cc:2:6"]
}],
"variables": []

View File

@ -20,6 +20,7 @@ OUTPUT:
"usr": "c:@N@hello@S@Foo@F@foo#",
"short_name": "foo",
"qualified_name": "hello::Foo::foo",
"declaration": "tests/namespaces/method_declaration.cc:3:8",
"all_uses": ["tests/namespaces/method_declaration.cc:3:8"]
}],
"variables": []

View File

@ -23,10 +23,11 @@ OUTPUT:
"usr": "c:@N@hello@S@Foo@F@foo#",
"short_name": "foo",
"qualified_name": "hello::Foo::foo",
"declaration": "tests/namespaces/method_definition.cc:3:8",
"definition": "tests/namespaces/method_definition.cc:6:11",
"declaring_type": 0,
"all_uses": ["tests/namespaces/method_definition.cc:3:8", "tests/namespaces/method_definition.cc:6:11"]
}],
}],
"variables": []
}
*/

View File

@ -41,7 +41,7 @@ OUTPUT:
"usr": "c:func_usage_addr_func.cc@61@F@user#@x",
"short_name": "x",
"qualified_name": "x",
"declaration": "tests/usage/func_usage_addr_func.cc:6:8",
"definition": "tests/usage/func_usage_addr_func.cc:6:8",
"all_uses": ["tests/usage/func_usage_addr_func.cc:6:8"]
}]
}

View File

@ -23,6 +23,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Used#",
"short_name": "Used",
"qualified_name": "Foo::Used",
"declaration": "tests/usage/func_usage_addr_method.cc:2:8",
"callers": ["1@tests/usage/func_usage_addr_method.cc:6:18"],
"all_uses": ["tests/usage/func_usage_addr_method.cc:2:8", "tests/usage/func_usage_addr_method.cc:6:18"]
}, {
@ -39,7 +40,7 @@ OUTPUT:
"usr": "c:func_usage_addr_method.cc@53@F@user#@x",
"short_name": "x",
"qualified_name": "x",
"declaration": "tests/usage/func_usage_addr_method.cc:6:8",
"definition": "tests/usage/func_usage_addr_method.cc:6:8",
"all_uses": ["tests/usage/func_usage_addr_method.cc:6:8"]
}]
}

View File

@ -24,6 +24,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Used#",
"short_name": "Used",
"qualified_name": "Foo::Used",
"declaration": "tests/usage/func_usage_call_method.cc:2:8",
"callers": ["1@tests/usage/func_usage_call_method.cc:7:6"],
"all_uses": ["tests/usage/func_usage_call_method.cc:2:8", "tests/usage/func_usage_call_method.cc:7:6"]
}, {
@ -40,7 +41,7 @@ OUTPUT:
"usr": "c:func_usage_call_method.cc@53@F@user#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/func_usage_call_method.cc:6:8",
"definition": "tests/usage/func_usage_call_method.cc:6:8",
"variable_type": 0,
"all_uses": ["tests/usage/func_usage_call_method.cc:6:8", "tests/usage/func_usage_call_method.cc:7:3"]
}]

View File

@ -31,7 +31,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@x",
"short_name": "x",
"qualified_name": "Foo::x",
"declaration": "tests/usage/func_usage_class_inline_var_def.cc:6:7",
"definition": "tests/usage/func_usage_class_inline_var_def.cc:6:7",
"declaring_type": 0,
"all_uses": ["tests/usage/func_usage_class_inline_var_def.cc:6:7"]
}]

View File

@ -12,6 +12,7 @@ OUTPUT:
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/usage/func_usage_forward_decl_func.cc:1:6",
"callers": ["1@tests/usage/func_usage_forward_decl_func.cc:4:3"],
"all_uses": ["tests/usage/func_usage_forward_decl_func.cc:1:6", "tests/usage/func_usage_forward_decl_func.cc:4:3"]
}, {

View File

@ -23,6 +23,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@foo#",
"short_name": "foo",
"qualified_name": "Foo::foo",
"declaration": "tests/usage/func_usage_forward_decl_method.cc:2:8",
"callers": ["1@tests/usage/func_usage_forward_decl_method.cc:7:6"],
"all_uses": ["tests/usage/func_usage_forward_decl_method.cc:2:8", "tests/usage/func_usage_forward_decl_method.cc:7:6"]
}, {
@ -39,7 +40,7 @@ OUTPUT:
"usr": "c:func_usage_forward_decl_method.cc@53@F@usage#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/func_usage_forward_decl_method.cc:6:8",
"definition": "tests/usage/func_usage_forward_decl_method.cc:6:8",
"variable_type": 0,
"all_uses": ["tests/usage/func_usage_forward_decl_method.cc:6:8", "tests/usage/func_usage_forward_decl_method.cc:7:3"]
}]

View File

@ -37,7 +37,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@a",
"short_name": "a",
"qualified_name": "Foo::a",
"declaration": "tests/usage/type_usage_declare_field.cc:5:16",
"definition": "tests/usage/type_usage_declare_field.cc:5:16",
"variable_type": 0,
"declaring_type": 2,
"all_uses": ["tests/usage/type_usage_declare_field.cc:5:16"]
@ -46,7 +46,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@b",
"short_name": "b",
"qualified_name": "Foo::b",
"declaration": "tests/usage/type_usage_declare_field.cc:6:19",
"definition": "tests/usage/type_usage_declare_field.cc:6:19",
"variable_type": 1,
"declaring_type": 2,
"all_uses": ["tests/usage/type_usage_declare_field.cc:6:19"]

View File

@ -36,7 +36,7 @@ OUTPUT:
"usr": "c:type_usage_declare_local.cc@67@F@Foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/type_usage_declare_local.cc:5:16",
"definition": "tests/usage/type_usage_declare_local.cc:5:16",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_local.cc:5:16"]
}, {
@ -44,7 +44,7 @@ OUTPUT:
"usr": "c:type_usage_declare_local.cc@86@F@Foo#@b",
"short_name": "b",
"qualified_name": "b",
"declaration": "tests/usage/type_usage_declare_local.cc:6:19",
"definition": "tests/usage/type_usage_declare_local.cc:6:19",
"variable_type": 1,
"all_uses": ["tests/usage/type_usage_declare_local.cc:6:19"]
}]

View File

@ -33,7 +33,7 @@ OUTPUT:
"usr": "c:type_usage_declare_param.cc@60@F@foo#*$@S@ForwardType#$@S@ImplementedType#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/type_usage_declare_param.cc:4:23",
"definition": "tests/usage/type_usage_declare_param.cc:4:23",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_param.cc:4:23"]
}, {
@ -41,7 +41,7 @@ OUTPUT:
"usr": "c:type_usage_declare_param.cc@76@F@foo#*$@S@ForwardType#$@S@ImplementedType#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/type_usage_declare_param.cc:4:42",
"definition": "tests/usage/type_usage_declare_param.cc:4:42",
"variable_type": 1,
"all_uses": ["tests/usage/type_usage_declare_param.cc:4:42"]
}]

View File

@ -22,6 +22,7 @@ OUTPUT:
"usr": "c:@F@foo#*$@S@Foo#S0_#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/usage/type_usage_declare_param_prototype.cc:3:6",
"definition": "tests/usage/type_usage_declare_param_prototype.cc:4:6",
"all_uses": ["tests/usage/type_usage_declare_param_prototype.cc:3:6", "tests/usage/type_usage_declare_param_prototype.cc:4:6"]
}],
@ -30,7 +31,7 @@ OUTPUT:
"usr": "c:type_usage_declare_param_prototype.cc@49@F@foo#*$@S@Foo#S0_#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/type_usage_declare_param_prototype.cc:4:15",
"definition": "tests/usage/type_usage_declare_param_prototype.cc:4:15",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_param_prototype.cc:4:15"]
}]

View File

@ -31,7 +31,7 @@ OUTPUT:
"usr": "c:type_usage_declare_qualifiers.cc@28@F@foo#&$@S@Type#&1S1_#@a0",
"short_name": "a0",
"qualified_name": "a0",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:3:16",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:3:16",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:16"]
}, {
@ -39,7 +39,7 @@ OUTPUT:
"usr": "c:type_usage_declare_qualifiers.cc@38@F@foo#&$@S@Type#&1S1_#@a1",
"short_name": "a1",
"qualified_name": "a1",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:3:32",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:3:32",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:32"]
}, {
@ -47,7 +47,7 @@ OUTPUT:
"usr": "c:type_usage_declare_qualifiers.cc@59@F@foo#&$@S@Type#&1S1_#@a2",
"short_name": "a2",
"qualified_name": "a2",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:4:8",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:4:8",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:4:8"]
}, {
@ -55,7 +55,7 @@ OUTPUT:
"usr": "c:type_usage_declare_qualifiers.cc@71@F@foo#&$@S@Type#&1S1_#@a3",
"short_name": "a3",
"qualified_name": "a3",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:5:9",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:5:9",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:5:9"]
}, {
@ -63,7 +63,7 @@ OUTPUT:
"usr": "c:type_usage_declare_qualifiers.cc@84@F@foo#&$@S@Type#&1S1_#@a4",
"short_name": "a4",
"qualified_name": "a4",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:6:15",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:6:15",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:6:15"]
}, {
@ -71,7 +71,7 @@ OUTPUT:
"usr": "c:type_usage_declare_qualifiers.cc@103@F@foo#&$@S@Type#&1S1_#@a5",
"short_name": "a5",
"qualified_name": "a5",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:7:21",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:7:21",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:7:21"]
}]

View File

@ -15,7 +15,7 @@ OUTPUT:
"usr": "c:type_usage_declare_static.cc@t",
"short_name": "t",
"qualified_name": "t",
"declaration": "tests/usage/type_usage_declare_static.cc:2:13",
"definition": "tests/usage/type_usage_declare_static.cc:2:13",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_static.cc:2:13"]
}]

View File

@ -39,6 +39,7 @@ OUTPUT:
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/usage/type_usage_on_return_type.cc:4:7",
"definition": "tests/usage/type_usage_on_return_type.cc:5:7",
"all_uses": ["tests/usage/type_usage_on_return_type.cc:3:7", "tests/usage/type_usage_on_return_type.cc:4:7", "tests/usage/type_usage_on_return_type.cc:5:7"]
}, {
@ -46,6 +47,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Get#I#",
"short_name": "Get",
"qualified_name": "Foo::Get",
"declaration": "tests/usage/type_usage_on_return_type.cc:8:9",
"definition": "tests/usage/type_usage_on_return_type.cc:12:12",
"declaring_type": 1,
"all_uses": ["tests/usage/type_usage_on_return_type.cc:8:9", "tests/usage/type_usage_on_return_type.cc:12:12"]
@ -54,6 +56,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Empty#",
"short_name": "Empty",
"qualified_name": "Foo::Empty",
"declaration": "tests/usage/type_usage_on_return_type.cc:9:8",
"definition": "tests/usage/type_usage_on_return_type.cc:13:11",
"declaring_type": 1,
"all_uses": ["tests/usage/type_usage_on_return_type.cc:9:8", "tests/usage/type_usage_on_return_type.cc:13:11"]
@ -62,12 +65,14 @@ OUTPUT:
"usr": "c:@F@external#",
"short_name": "external",
"qualified_name": "external",
"declaration": "tests/usage/type_usage_on_return_type.cc:15:20",
"all_uses": ["tests/usage/type_usage_on_return_type.cc:15:20"]
}, {
"id": 4,
"usr": "c:type_usage_on_return_type.cc@F@bar#",
"short_name": "bar",
"qualified_name": "bar",
"declaration": "tests/usage/type_usage_on_return_type.cc:17:14",
"definition": "tests/usage/type_usage_on_return_type.cc:18:14",
"all_uses": ["tests/usage/type_usage_on_return_type.cc:17:14", "tests/usage/type_usage_on_return_type.cc:18:14"]
}],

View File

@ -27,6 +27,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@make#",
"short_name": "make",
"qualified_name": "Foo::make",
"declaration": "tests/usage/type_usage_various.cc:2:8",
"definition": "tests/usage/type_usage_various.cc:5:11",
"declaring_type": 0,
"all_uses": ["tests/usage/type_usage_various.cc:2:8", "tests/usage/type_usage_various.cc:5:11"]
@ -36,7 +37,7 @@ OUTPUT:
"usr": "c:type_usage_various.cc@58@S@Foo@F@make#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/type_usage_various.cc:6:7",
"definition": "tests/usage/type_usage_various.cc:6:7",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_various.cc:6:7"]
}, {

View File

@ -31,6 +31,7 @@ OUTPUT:
"usr": "c:@F@called#I#",
"short_name": "called",
"qualified_name": "called",
"declaration": "tests/usage/usage_inside_of_call.cc:1:6",
"callers": ["2@tests/usage/usage_inside_of_call.cc:14:3"],
"all_uses": ["tests/usage/usage_inside_of_call.cc:1:6", "tests/usage/usage_inside_of_call.cc:14:3"]
}, {
@ -38,6 +39,7 @@ OUTPUT:
"usr": "c:@F@gen#",
"short_name": "gen",
"qualified_name": "gen",
"declaration": "tests/usage/usage_inside_of_call.cc:3:5",
"callers": ["2@tests/usage/usage_inside_of_call.cc:14:14"],
"all_uses": ["tests/usage/usage_inside_of_call.cc:3:5", "tests/usage/usage_inside_of_call.cc:14:14"]
}, {
@ -54,7 +56,8 @@ OUTPUT:
"usr": "c:@S@Foo@static_var",
"short_name": "static_var",
"qualified_name": "Foo::static_var",
"declaration": "tests/usage/usage_inside_of_call.cc:10:10",
"declaration": "tests/usage/usage_inside_of_call.cc:6:14",
"definition": "tests/usage/usage_inside_of_call.cc:10:10",
"declaring_type": 0,
"all_uses": ["tests/usage/usage_inside_of_call.cc:6:14", "tests/usage/usage_inside_of_call.cc:10:10", "tests/usage/usage_inside_of_call.cc:14:45"]
}, {
@ -62,7 +65,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@field_var",
"short_name": "field_var",
"qualified_name": "Foo::field_var",
"declaration": "tests/usage/usage_inside_of_call.cc:7:7",
"definition": "tests/usage/usage_inside_of_call.cc:7:7",
"declaring_type": 0,
"all_uses": ["tests/usage/usage_inside_of_call.cc:7:7", "tests/usage/usage_inside_of_call.cc:14:28"]
}, {
@ -70,7 +73,7 @@ OUTPUT:
"usr": "c:usage_inside_of_call.cc@145@F@foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/usage_inside_of_call.cc:13:7",
"definition": "tests/usage/usage_inside_of_call.cc:13:7",
"all_uses": ["tests/usage/usage_inside_of_call.cc:13:7", "tests/usage/usage_inside_of_call.cc:14:10"]
}]
}

View File

@ -15,6 +15,7 @@ OUTPUT:
"usr": "c:@F@called#I#",
"short_name": "called",
"qualified_name": "called",
"declaration": "tests/usage/usage_inside_of_call_simple.cc:1:6",
"callers": ["2@tests/usage/usage_inside_of_call_simple.cc:6:3"],
"all_uses": ["tests/usage/usage_inside_of_call_simple.cc:1:6", "tests/usage/usage_inside_of_call_simple.cc:6:3"]
}, {

View File

@ -33,7 +33,7 @@ OUTPUT:
"usr": "c:var_usage_call_function.cc@39@F@caller#@x",
"short_name": "x",
"qualified_name": "x",
"declaration": "tests/usage/var_usage_call_function.cc:4:8",
"definition": "tests/usage/var_usage_call_function.cc:4:8",
"all_uses": ["tests/usage/var_usage_call_function.cc:4:8", "tests/usage/var_usage_call_function.cc:5:3"]
}]
}

View File

@ -35,6 +35,7 @@ OUTPUT:
"usr": "c:@F@accept#I#",
"short_name": "accept",
"qualified_name": "accept",
"declaration": "tests/usage/var_usage_class_member.cc:7:6",
"callers": ["2@tests/usage/var_usage_class_member.cc:14:3", "2@tests/usage/var_usage_class_member.cc:15:3", "2@tests/usage/var_usage_class_member.cc:17:3"],
"all_uses": ["tests/usage/var_usage_class_member.cc:7:6", "tests/usage/var_usage_class_member.cc:14:3", "tests/usage/var_usage_class_member.cc:15:3", "tests/usage/var_usage_class_member.cc:17:3"]
}, {
@ -42,6 +43,7 @@ OUTPUT:
"usr": "c:@F@accept#*I#",
"short_name": "accept",
"qualified_name": "accept",
"declaration": "tests/usage/var_usage_class_member.cc:8:6",
"callers": ["2@tests/usage/var_usage_class_member.cc:16:3"],
"all_uses": ["tests/usage/var_usage_class_member.cc:8:6", "tests/usage/var_usage_class_member.cc:16:3"]
}, {
@ -58,7 +60,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@x",
"short_name": "x",
"qualified_name": "Foo::x",
"declaration": "tests/usage/var_usage_class_member.cc:3:7",
"definition": "tests/usage/var_usage_class_member.cc:3:7",
"declaring_type": 0,
"all_uses": ["tests/usage/var_usage_class_member.cc:3:7", "tests/usage/var_usage_class_member.cc:12:5", "tests/usage/var_usage_class_member.cc:13:5", "tests/usage/var_usage_class_member.cc:14:12", "tests/usage/var_usage_class_member.cc:15:12", "tests/usage/var_usage_class_member.cc:16:13"]
}, {
@ -66,7 +68,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@y",
"short_name": "y",
"qualified_name": "Foo::y",
"declaration": "tests/usage/var_usage_class_member.cc:4:7",
"definition": "tests/usage/var_usage_class_member.cc:4:7",
"declaring_type": 0,
"all_uses": ["tests/usage/var_usage_class_member.cc:4:7", "tests/usage/var_usage_class_member.cc:17:12"]
}, {
@ -74,7 +76,7 @@ OUTPUT:
"usr": "c:var_usage_class_member.cc@105@F@foo#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/var_usage_class_member.cc:11:7",
"definition": "tests/usage/var_usage_class_member.cc:11:7",
"variable_type": 0,
"all_uses": ["tests/usage/var_usage_class_member.cc:11:7", "tests/usage/var_usage_class_member.cc:12:3", "tests/usage/var_usage_class_member.cc:13:3", "tests/usage/var_usage_class_member.cc:14:10", "tests/usage/var_usage_class_member.cc:15:10", "tests/usage/var_usage_class_member.cc:16:11", "tests/usage/var_usage_class_member.cc:17:10"]
}]

View File

@ -24,6 +24,7 @@ OUTPUT:
"usr": "c:@F@accept#I#",
"short_name": "accept",
"qualified_name": "accept",
"declaration": "tests/usage/var_usage_class_member_static.cc:5:6",
"callers": ["1@tests/usage/var_usage_class_member_static.cc:8:3"],
"all_uses": ["tests/usage/var_usage_class_member_static.cc:5:6", "tests/usage/var_usage_class_member_static.cc:8:3"]
}, {

View File

@ -18,7 +18,7 @@ OUTPUT:
"usr": "c:var_usage_func_parameter.cc@9@F@foo#I#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_func_parameter.cc:1:14",
"definition": "tests/usage/var_usage_func_parameter.cc:1:14",
"all_uses": ["tests/usage/var_usage_func_parameter.cc:1:14", "tests/usage/var_usage_func_parameter.cc:2:3"]
}]
}

View File

@ -19,7 +19,7 @@ OUTPUT:
"usr": "c:var_usage_local.cc@16@F@foo#@x",
"short_name": "x",
"qualified_name": "x",
"declaration": "tests/usage/var_usage_local.cc:2:7",
"definition": "tests/usage/var_usage_local.cc:2:7",
"all_uses": ["tests/usage/var_usage_local.cc:2:7", "tests/usage/var_usage_local.cc:3:3"]
}]
}

View File

@ -24,14 +24,14 @@ OUTPUT:
"usr": "c:var_usage_shadowed_local.cc@16@F@foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_shadowed_local.cc:2:7",
"definition": "tests/usage/var_usage_shadowed_local.cc:2:7",
"all_uses": ["tests/usage/var_usage_shadowed_local.cc:2:7", "tests/usage/var_usage_shadowed_local.cc:3:3", "tests/usage/var_usage_shadowed_local.cc:8:3"]
}, {
"id": 1,
"usr": "c:var_usage_shadowed_local.cc@43@F@foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_shadowed_local.cc:5:9",
"definition": "tests/usage/var_usage_shadowed_local.cc:5:9",
"all_uses": ["tests/usage/var_usage_shadowed_local.cc:5:9", "tests/usage/var_usage_shadowed_local.cc:6:5"]
}]
}

View File

@ -24,14 +24,14 @@ OUTPUT:
"usr": "c:var_usage_shadowed_parameter.cc@9@F@foo#I#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_shadowed_parameter.cc:1:14",
"definition": "tests/usage/var_usage_shadowed_parameter.cc:1:14",
"all_uses": ["tests/usage/var_usage_shadowed_parameter.cc:1:14", "tests/usage/var_usage_shadowed_parameter.cc:2:3", "tests/usage/var_usage_shadowed_parameter.cc:7:3"]
}, {
"id": 1,
"usr": "c:var_usage_shadowed_parameter.cc@38@F@foo#I#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_shadowed_parameter.cc:4:9",
"definition": "tests/usage/var_usage_shadowed_parameter.cc:4:9",
"all_uses": ["tests/usage/var_usage_shadowed_parameter.cc:4:9", "tests/usage/var_usage_shadowed_parameter.cc:5:5"]
}]
}

View File

@ -21,7 +21,7 @@ OUTPUT:
"usr": "c:var_usage_static.cc@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_static.cc:1:12",
"definition": "tests/usage/var_usage_static.cc:1:12",
"all_uses": ["tests/usage/var_usage_static.cc:1:12", "tests/usage/var_usage_static.cc:4:3"]
}]
}

View File

@ -20,7 +20,7 @@ OUTPUT:
"usr": "c:@S@Foo@FI@member",
"short_name": "member",
"qualified_name": "Foo::member",
"declaration": "tests/vars/class_member.cc:2:8",
"definition": "tests/vars/class_member.cc:2:8",
"variable_type": 0,
"declaring_type": 0,
"all_uses": ["tests/vars/class_member.cc:2:8"]

View File

@ -25,7 +25,8 @@ OUTPUT:
"usr": "c:@S@Foo@member",
"short_name": "member",
"qualified_name": "Foo::member",
"declaration": "tests/vars/class_static_member.cc:4:11",
"declaration": "tests/vars/class_static_member.cc:2:15",
"definition": "tests/vars/class_static_member.cc:4:11",
"variable_type": 0,
"declaring_type": 0,
"all_uses": ["tests/vars/class_static_member.cc:2:15", "tests/vars/class_static_member.cc:4:11"]

View File

@ -26,7 +26,7 @@ OUTPUT:
"usr": "c:function_local.cc@31@F@foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/vars/function_local.cc:4:8",
"definition": "tests/vars/function_local.cc:4:8",
"variable_type": 0,
"all_uses": ["tests/vars/function_local.cc:4:8"]
}]

View File

@ -24,7 +24,7 @@ OUTPUT:
"usr": "c:function_param.cc@24@F@foo#*$@S@Foo#S0_#@p0",
"short_name": "p0",
"qualified_name": "p0",
"declaration": "tests/vars/function_param.cc:3:15",
"definition": "tests/vars/function_param.cc:3:15",
"variable_type": 0,
"all_uses": ["tests/vars/function_param.cc:3:15"]
}, {
@ -32,7 +32,7 @@ OUTPUT:
"usr": "c:function_param.cc@33@F@foo#*$@S@Foo#S0_#@p1",
"short_name": "p1",
"qualified_name": "p1",
"declaration": "tests/vars/function_param.cc:3:24",
"definition": "tests/vars/function_param.cc:3:24",
"variable_type": 0,
"all_uses": ["tests/vars/function_param.cc:3:24"]
}]

View File

@ -24,14 +24,14 @@ OUTPUT:
"usr": "c:function_shadow_local.cc@16@F@foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/vars/function_shadow_local.cc:2:7",
"definition": "tests/vars/function_shadow_local.cc:2:7",
"all_uses": ["tests/vars/function_shadow_local.cc:2:7", "tests/vars/function_shadow_local.cc:3:3", "tests/vars/function_shadow_local.cc:8:3"]
}, {
"id": 1,
"usr": "c:function_shadow_local.cc@43@F@foo#@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/vars/function_shadow_local.cc:5:9",
"definition": "tests/vars/function_shadow_local.cc:5:9",
"all_uses": ["tests/vars/function_shadow_local.cc:5:9", "tests/vars/function_shadow_local.cc:6:5"]
}]
}

View File

@ -18,14 +18,14 @@ OUTPUT:
"usr": "c:function_shadow_param.cc@9@F@foo#I#@p",
"short_name": "p",
"qualified_name": "p",
"declaration": "tests/vars/function_shadow_param.cc:1:14",
"definition": "tests/vars/function_shadow_param.cc:1:14",
"all_uses": ["tests/vars/function_shadow_param.cc:1:14"]
}, {
"id": 1,
"usr": "c:function_shadow_param.cc@21@F@foo#I#@p",
"short_name": "p",
"qualified_name": "p",
"declaration": "tests/vars/function_shadow_param.cc:2:7",
"definition": "tests/vars/function_shadow_param.cc:2:7",
"all_uses": ["tests/vars/function_shadow_param.cc:2:7"]
}]
}

View File

@ -9,7 +9,7 @@ OUTPUT:
"usr": "c:global_variable.cc@global",
"short_name": "global",
"qualified_name": "global",
"declaration": "tests/vars/global_variable.cc:1:12",
"definition": "tests/vars/global_variable.cc:1:12",
"all_uses": ["tests/vars/global_variable.cc:1:12"]
}]
}