This commit is contained in:
Jacob Dufault 2017-02-19 18:00:58 -08:00
parent d87d74083c
commit 7701822aa9
13 changed files with 181 additions and 100 deletions

View File

@ -1069,6 +1069,42 @@ CXIdxClientContainer startedTranslationUnit(CXClientData client_data, void *rese
struct FindChildOfKindParam {
CXCursorKind target_kind;
std::optional<clang::Cursor> result;
FindChildOfKindParam(CXCursorKind target_kind) : target_kind(target_kind) {}
};
clang::VisiterResult FindChildOfKindVisitor(clang::Cursor cursor, clang::Cursor parent, FindChildOfKindParam* param) {
if (cursor.get_kind() == param->target_kind) {
param->result = cursor;
return clang::VisiterResult::Break;
}
return clang::VisiterResult::Recurse;
}
std::optional<clang::Cursor> FindChildOfKind(clang::Cursor cursor, CXCursorKind kind) {
FindChildOfKindParam param(kind);
cursor.VisitChildren(&FindChildOfKindVisitor, &param);
return param.result;
}
struct NamespaceHelper { struct NamespaceHelper {
std::unordered_map<std::string, std::string> container_usr_to_qualified_name; std::unordered_map<std::string, std::string> container_usr_to_qualified_name;
@ -1138,6 +1174,15 @@ std::string GetNamespacePrefx(const CXIdxDeclInfo* decl) {
// * it doesn't seem like we get any template specialization logic // * it doesn't seem like we get any template specialization logic
// * we get two decls to the same template... resolved by checking parent? maybe this will break. not sure. // * we get two decls to the same template... resolved by checking parent? maybe this will break. not sure.
// Insert a reference to |type_id| using the location of the first TypeRef under |cursor|.
void InsertInterestingTypeReference(ParsingDatabase* db, TypeId type_id, clang::Cursor cursor) {
std::optional<clang::Cursor> child = FindChildOfKind(cursor, CXCursor_TypeRef);
assert(child.has_value()); // If this assert ever fails just use |cursor| loc.
TypeDef* def = db->Resolve(type_id);
def->interesting_uses.push_back(child.value().get_source_location());
}
bool IsTypeDefinition(const CXIdxContainerInfo* container) { bool IsTypeDefinition(const CXIdxContainerInfo* container) {
if (!container) if (!container)
return false; return false;
@ -1179,10 +1224,12 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
var_def->declaration = decl->loc; var_def->declaration = decl->loc;
var_def->all_uses.push_back(decl->loc); var_def->all_uses.push_back(decl->loc);
clang::Type var_type = clang::Cursor(decl->cursor).get_type().strip_qualifiers(); std::string var_type_usr = clang::Cursor(decl->cursor).get_type().strip_qualifiers().get_usr();
std::string var_type_usr = var_type.get_usr(); if (var_type_usr != "") {
if (var_type_usr != "") TypeId var_type_id = db->ToTypeId(var_type_usr);
var_def->variable_type = db->ToTypeId(var_type_usr); var_def->variable_type = var_type_id;
InsertInterestingTypeReference(db, var_type_id, decl->cursor);
}
if (decl->isDefinition && IsTypeDefinition(decl->semanticContainer)) { if (decl->isDefinition && IsTypeDefinition(decl->semanticContainer)) {
TypeId declaring_type_id = db->ToTypeId(decl->semanticContainer->cursor); TypeId declaring_type_id = db->ToTypeId(decl->semanticContainer->cursor);
@ -1232,7 +1279,11 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
// (before visiting another declaration). If we only want to mark the // (before visiting another declaration). If we only want to mark the
// return type on the definition interesting, we could only compute this // return type on the definition interesting, we could only compute this
// if we're parsing the definition declaration. // if we're parsing the definition declaration.
func_def->needs_return_type_index = !clang::Cursor(decl->cursor).get_type().get_return_type().is_fundamental(); //func_def->needs_return_type_index = !clang::Cursor(decl->cursor).get_type().get_return_type().is_fundamental();
std::string return_type_usr = clang::Cursor(decl->cursor).get_type().get_return_type().strip_qualifiers().get_usr();
if (return_type_usr != "")
InsertInterestingTypeReference(db, db->ToTypeId(return_type_usr), decl->cursor);
/* /*
std::optional<FuncId> base; std::optional<FuncId> base;
@ -1324,6 +1375,7 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
break; break;
} }
case CXIdxEntity_CXXStaticMethod:
case CXIdxEntity_CXXInstanceMethod: case CXIdxEntity_CXXInstanceMethod:
case CXIdxEntity_Function: case CXIdxEntity_Function:
{ {
@ -1334,6 +1386,7 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
// } // }
// Don't report duplicate usages. // Don't report duplicate usages.
// TODO: search full history?
clang::SourceLocation loc = ref->loc; clang::SourceLocation loc = ref->loc;
if (param->last_func_usage_location == loc) break; if (param->last_func_usage_location == loc) break;
param->last_func_usage_location = loc; param->last_func_usage_location = loc;
@ -1381,11 +1434,23 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
// } // }
// //
clang::SourceLocation loc = ref->loc; clang::SourceLocation loc = ref->loc;
if (param->last_type_usage_location == loc) break; //if (param->last_type_usage_location == loc) break;
param->last_type_usage_location = loc; //param->last_type_usage_location = loc;
// TODO: initializer list can many type refs...
bool do_break = false;
for (int i = referenced_def->all_uses.size() - 1; i >= 0; --i) {
if (referenced_def->all_uses[i] == loc) {
do_break = true;
break;
}
}
if (do_break)
break;
referenced_def->all_uses.push_back(loc); referenced_def->all_uses.push_back(loc);
/*
// //
// Variable declarations have an embedded TypeRef. // Variable declarations have an embedded TypeRef.
// //
@ -1416,6 +1481,7 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
referenced_def->interesting_uses.push_back(loc); referenced_def->interesting_uses.push_back(loc);
} }
} }
*/
break; break;
} }
@ -1591,11 +1657,12 @@ int main(int argc, char** argv) {
// TODO: Fix all existing tests. // TODO: Fix all existing tests.
//if (path == "tests/usage/type_usage_declare_extern.cc") continue; //if (path == "tests/usage/type_usage_declare_extern.cc") continue;
if (path == "tests/constructors/constructor.cc") continue; if (path == "tests/constructors/constructor.cc") continue;
if (path != "tests/usage/type_usage_on_return_type.cc") continue;
//if (path != "tests/usage/type_usage_declare_local.cc") continue; //if (path != "tests/usage/type_usage_declare_local.cc") continue;
//if (path != "tests/usage/func_usage_addr_method.cc") continue; //if (path != "tests/usage/func_usage_addr_method.cc") continue;
//if (path != "tests/usage/func_usage_template_func.cc") continue; //if (path != "tests/usage/func_usage_template_func.cc") continue;
//if (path != "tests/usage/func_usage_class_inline_var_def.cc") continue; //if (path != "tests/usage/func_usage_class_inline_var_def.cc") continue;
if (path != "tests/foobar.cc") continue; //if (path != "tests/foobar.cc") continue;
// Parse expected output from the test, parse it into JSON document. // Parse expected output from the test, parse it into JSON document.
std::string expected_output; std::string expected_output;

View File

@ -19,15 +19,23 @@ OUTPUT:
"short_name": "Foo", "short_name": "Foo",
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/foobar.cc:1:8", "definition": "tests/foobar.cc:1:8",
"all_uses": ["tests/foobar.cc:1:8", "tests/foobar.cc:2:10", "tests/foobar.cc:6:3", "tests/foobar.cc:6:12", "tests/foobar.cc:6:3", "tests/foobar.cc:6:12"], "all_uses": ["tests/foobar.cc:1:8", "tests/foobar.cc:2:10", "tests/foobar.cc:6:3", "tests/foobar.cc:6:12"],
"interesting_uses": ["tests/foobar.cc:6:3", "tests/foobar.cc:6:12"] "interesting_uses": ["tests/foobar.cc:2:10", "tests/foobar.cc:6:3"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
"usr": "c:@S@Foo@F@Used#S",
"short_name": "Used",
"qualified_name": "Foo::Used",
"callers": ["1@tests/foobar.cc:6:17"],
"all_uses": ["tests/foobar.cc:2:15", "tests/foobar.cc:6:17"]
}, {
"id": 1,
"usr": "c:@F@user#", "usr": "c:@F@user#",
"short_name": "user", "short_name": "user",
"qualified_name": "user", "qualified_name": "user",
"definition": "tests/foobar.cc:5:6", "definition": "tests/foobar.cc:5:6",
"callees": ["0@tests/foobar.cc:6:17"],
"all_uses": ["tests/foobar.cc:5:6"] "all_uses": ["tests/foobar.cc:5:6"]
}], }],
"variables": [{ "variables": [{

View File

@ -16,7 +16,8 @@ OUTPUT:
"short_name": "Foo", "short_name": "Foo",
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/usage/func_usage_call_method.cc:1:8", "definition": "tests/usage/func_usage_call_method.cc:1:8",
"all_uses": ["tests/usage/func_usage_call_method.cc:1:8", "tests/usage/func_usage_call_method.cc:6:3"] "all_uses": ["tests/usage/func_usage_call_method.cc:1:8", "tests/usage/func_usage_call_method.cc:6:3"],
"interesting_uses": ["tests/usage/func_usage_call_method.cc:6:3"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,

View File

@ -15,7 +15,8 @@ OUTPUT:
"short_name": "Foo", "short_name": "Foo",
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/usage/func_usage_forward_decl_method.cc:1:8", "definition": "tests/usage/func_usage_forward_decl_method.cc:1:8",
"all_uses": ["tests/usage/func_usage_forward_decl_method.cc:1:8", "tests/usage/func_usage_forward_decl_method.cc:6:3"] "all_uses": ["tests/usage/func_usage_forward_decl_method.cc:1:8", "tests/usage/func_usage_forward_decl_method.cc:6:3"],
"interesting_uses": ["tests/usage/func_usage_forward_decl_method.cc:6:3"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,

View File

@ -10,7 +10,8 @@ OUTPUT:
"short_name": "T", "short_name": "T",
"qualified_name": "T", "qualified_name": "T",
"definition": "tests/usage/type_usage_declare_extern.cc:1:8", "definition": "tests/usage/type_usage_declare_extern.cc:1:8",
"all_uses": ["tests/usage/type_usage_declare_extern.cc:1:8", "tests/usage/type_usage_declare_extern.cc:3:8"] "all_uses": ["tests/usage/type_usage_declare_extern.cc:1:8", "tests/usage/type_usage_declare_extern.cc:3:8"],
"interesting_uses": ["tests/usage/type_usage_declare_extern.cc:3:8"]
}], }],
"functions": [], "functions": [],
"variables": [{ "variables": [{
@ -19,6 +20,7 @@ OUTPUT:
"short_name": "t", "short_name": "t",
"qualified_name": "t", "qualified_name": "t",
"declaration": "tests/usage/type_usage_declare_extern.cc:3:10", "declaration": "tests/usage/type_usage_declare_extern.cc:3:10",
"variable_type": 0,
"all_uses": ["tests/usage/type_usage_declare_extern.cc:3:10"] "all_uses": ["tests/usage/type_usage_declare_extern.cc:3:10"]
}] }]
} }

View File

@ -12,24 +12,24 @@ OUTPUT:
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@ForwardType", "usr": "c:@S@ForwardType",
"short_name": "ForwardType", "all_uses": ["tests/usage/type_usage_declare_field.cc:1:8", "tests/usage/type_usage_declare_field.cc:5:3"],
"qualified_name": "ForwardType", "interesting_uses": ["tests/usage/type_usage_declare_field.cc:5:3"]
"declaration": "tests/usage/type_usage_declare_field.cc:1:8",
"uses": ["tests/usage/type_usage_declare_field.cc:5:3"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@S@ImplementedType", "usr": "c:@S@ImplementedType",
"short_name": "ImplementedType", "short_name": "ImplementedType",
"qualified_name": "ImplementedType", "qualified_name": "ImplementedType",
"definition": "tests/usage/type_usage_declare_field.cc:2:8", "definition": "tests/usage/type_usage_declare_field.cc:2:8",
"uses": ["tests/usage/type_usage_declare_field.cc:6:3"] "all_uses": ["tests/usage/type_usage_declare_field.cc:2:8", "tests/usage/type_usage_declare_field.cc:6:3"],
"interesting_uses": ["tests/usage/type_usage_declare_field.cc:6:3"]
}, { }, {
"id": 2, "id": 2,
"usr": "c:@S@Foo", "usr": "c:@S@Foo",
"short_name": "Foo", "short_name": "Foo",
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/usage/type_usage_declare_field.cc:4:8", "definition": "tests/usage/type_usage_declare_field.cc:4:8",
"vars": [0, 1] "vars": [0, 1],
"all_uses": ["tests/usage/type_usage_declare_field.cc:4:8"]
}], }],
"functions": [], "functions": [],
"variables": [{ "variables": [{
@ -38,18 +38,18 @@ OUTPUT:
"short_name": "a", "short_name": "a",
"qualified_name": "Foo::a", "qualified_name": "Foo::a",
"declaration": "tests/usage/type_usage_declare_field.cc:5:16", "declaration": "tests/usage/type_usage_declare_field.cc:5:16",
"initializations": ["tests/usage/type_usage_declare_field.cc:5:16"],
"variable_type": 0, "variable_type": 0,
"declaring_type": 2 "declaring_type": 2,
"all_uses": ["tests/usage/type_usage_declare_field.cc:5:16"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@S@Foo@FI@b", "usr": "c:@S@Foo@FI@b",
"short_name": "b", "short_name": "b",
"qualified_name": "Foo::b", "qualified_name": "Foo::b",
"declaration": "tests/usage/type_usage_declare_field.cc:6:19", "declaration": "tests/usage/type_usage_declare_field.cc:6:19",
"initializations": ["tests/usage/type_usage_declare_field.cc:6:19"],
"variable_type": 1, "variable_type": 1,
"declaring_type": 2 "declaring_type": 2,
"all_uses": ["tests/usage/type_usage_declare_field.cc:6:19"]
}] }]
} }
*/ */

View File

@ -12,17 +12,16 @@ OUTPUT:
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@ForwardType", "usr": "c:@S@ForwardType",
"short_name": "ForwardType", "all_uses": ["tests/usage/type_usage_declare_local.cc:1:8", "tests/usage/type_usage_declare_local.cc:5:3"],
"qualified_name": "ForwardType", "interesting_uses": ["tests/usage/type_usage_declare_local.cc:5:3"]
"declaration": "tests/usage/type_usage_declare_local.cc:1:8",
"uses": ["tests/usage/type_usage_declare_local.cc:5:3"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@S@ImplementedType", "usr": "c:@S@ImplementedType",
"short_name": "ImplementedType", "short_name": "ImplementedType",
"qualified_name": "ImplementedType", "qualified_name": "ImplementedType",
"definition": "tests/usage/type_usage_declare_local.cc:2:8", "definition": "tests/usage/type_usage_declare_local.cc:2:8",
"uses": ["tests/usage/type_usage_declare_local.cc:6:3"] "all_uses": ["tests/usage/type_usage_declare_local.cc:2:8", "tests/usage/type_usage_declare_local.cc:6:3"],
"interesting_uses": ["tests/usage/type_usage_declare_local.cc:6:3"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
@ -30,12 +29,7 @@ OUTPUT:
"short_name": "Foo", "short_name": "Foo",
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/usage/type_usage_declare_local.cc:4:6", "definition": "tests/usage/type_usage_declare_local.cc:4:6",
"callees": ["1@tests/usage/type_usage_declare_local.cc:6:19"] "all_uses": ["tests/usage/type_usage_declare_local.cc:4:6"]
}, {
"id": 1,
"usr": "c:@S@ImplementedType@F@ImplementedType#",
"callers": ["0@tests/usage/type_usage_declare_local.cc:6:19"],
"uses": ["tests/usage/type_usage_declare_local.cc:6:19"]
}], }],
"variables": [{ "variables": [{
"id": 0, "id": 0,
@ -43,16 +37,16 @@ OUTPUT:
"short_name": "a", "short_name": "a",
"qualified_name": "a", "qualified_name": "a",
"declaration": "tests/usage/type_usage_declare_local.cc:5:16", "declaration": "tests/usage/type_usage_declare_local.cc:5:16",
"initializations": ["tests/usage/type_usage_declare_local.cc:5:16"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_local.cc:5:16"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:type_usage_declare_local.cc@86@F@Foo#@b", "usr": "c:type_usage_declare_local.cc@86@F@Foo#@b",
"short_name": "b", "short_name": "b",
"qualified_name": "b", "qualified_name": "b",
"declaration": "tests/usage/type_usage_declare_local.cc:6:19", "declaration": "tests/usage/type_usage_declare_local.cc:6:19",
"initializations": ["tests/usage/type_usage_declare_local.cc:6:19"], "variable_type": 1,
"variable_type": 1 "all_uses": ["tests/usage/type_usage_declare_local.cc:6:19"]
}] }]
} }
*/ */

View File

@ -9,24 +9,24 @@ OUTPUT:
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@ForwardType", "usr": "c:@S@ForwardType",
"short_name": "ForwardType", "all_uses": ["tests/usage/type_usage_declare_param.cc:1:8", "tests/usage/type_usage_declare_param.cc:4:10"],
"qualified_name": "ForwardType", "interesting_uses": ["tests/usage/type_usage_declare_param.cc:4:10"]
"declaration": "tests/usage/type_usage_declare_param.cc:1:8",
"uses": ["tests/usage/type_usage_declare_param.cc:4:10"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@S@ImplementedType", "usr": "c:@S@ImplementedType",
"short_name": "ImplementedType", "short_name": "ImplementedType",
"qualified_name": "ImplementedType", "qualified_name": "ImplementedType",
"definition": "tests/usage/type_usage_declare_param.cc:2:8", "definition": "tests/usage/type_usage_declare_param.cc:2:8",
"uses": ["tests/usage/type_usage_declare_param.cc:4:26"] "all_uses": ["tests/usage/type_usage_declare_param.cc:2:8", "tests/usage/type_usage_declare_param.cc:4:26"],
"interesting_uses": ["tests/usage/type_usage_declare_param.cc:4:26"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
"usr": "c:@F@foo#*$@S@ForwardType#$@S@ImplementedType#", "usr": "c:@F@foo#*$@S@ForwardType#$@S@ImplementedType#",
"short_name": "foo", "short_name": "foo",
"qualified_name": "foo", "qualified_name": "foo",
"definition": "tests/usage/type_usage_declare_param.cc:4:6" "definition": "tests/usage/type_usage_declare_param.cc:4:6",
"all_uses": ["tests/usage/type_usage_declare_param.cc:4:6"]
}], }],
"variables": [{ "variables": [{
"id": 0, "id": 0,
@ -34,16 +34,16 @@ OUTPUT:
"short_name": "f", "short_name": "f",
"qualified_name": "f", "qualified_name": "f",
"declaration": "tests/usage/type_usage_declare_param.cc:4:23", "declaration": "tests/usage/type_usage_declare_param.cc:4:23",
"initializations": ["tests/usage/type_usage_declare_param.cc:4:23"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_param.cc:4:23"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:type_usage_declare_param.cc@76@F@foo#*$@S@ForwardType#$@S@ImplementedType#@a", "usr": "c:type_usage_declare_param.cc@76@F@foo#*$@S@ForwardType#$@S@ImplementedType#@a",
"short_name": "a", "short_name": "a",
"qualified_name": "a", "qualified_name": "a",
"declaration": "tests/usage/type_usage_declare_param.cc:4:42", "declaration": "tests/usage/type_usage_declare_param.cc:4:42",
"initializations": ["tests/usage/type_usage_declare_param.cc:4:42"], "variable_type": 1,
"variable_type": 1 "all_uses": ["tests/usage/type_usage_declare_param.cc:4:42"]
}] }]
} }
*/ */

View File

@ -4,23 +4,26 @@ void foo(Foo* f, Foo*);
void foo(Foo* f, Foo*) {} void foo(Foo* f, Foo*) {}
/* /*
// TODO: No interesting usage on prototype. But maybe that's ok!
// TODO: We should have the same variable declared for both prototype and
// declaration. So it should have a usage marker on both. Then we could
// rename parameters!
OUTPUT: OUTPUT:
{ {
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@Foo", "usr": "c:@S@Foo",
"short_name": "Foo", "all_uses": ["tests/usage/type_usage_declare_param_prototype.cc:1:8", "tests/usage/type_usage_declare_param_prototype.cc:3:10", "tests/usage/type_usage_declare_param_prototype.cc:3:18", "tests/usage/type_usage_declare_param_prototype.cc:4:10", "tests/usage/type_usage_declare_param_prototype.cc:4:18"],
"qualified_name": "Foo", "interesting_uses": ["tests/usage/type_usage_declare_param_prototype.cc:4:10"]
"declaration": "tests/usage/type_usage_declare_param_prototype.cc:1:8",
"uses": ["tests/usage/type_usage_declare_param_prototype.cc:3:10", "tests/usage/type_usage_declare_param_prototype.cc:3:18", "tests/usage/type_usage_declare_param_prototype.cc:4:10", "tests/usage/type_usage_declare_param_prototype.cc:4:18"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
"usr": "c:@F@foo#*$@S@Foo#S0_#", "usr": "c:@F@foo#*$@S@Foo#S0_#",
"short_name": "foo", "short_name": "foo",
"qualified_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",
"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"]
}], }],
"variables": [{ "variables": [{
"id": 0, "id": 0,
@ -28,8 +31,8 @@ OUTPUT:
"short_name": "f", "short_name": "f",
"qualified_name": "f", "qualified_name": "f",
"declaration": "tests/usage/type_usage_declare_param_prototype.cc:4:15", "declaration": "tests/usage/type_usage_declare_param_prototype.cc:4:15",
"initializations": ["tests/usage/type_usage_declare_param_prototype.cc:4:15"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_param_prototype.cc:4:15"]
}] }]
} }
*/ */

View File

@ -6,17 +6,15 @@ OUTPUT:
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@ForwardType", "usr": "c:@S@ForwardType",
"short_name": "ForwardType", "all_uses": ["tests/usage/type_usage_declare_param_unnamed.cc:1:8", "tests/usage/type_usage_declare_param_unnamed.cc:2:10"]
"qualified_name": "ForwardType",
"declaration": "tests/usage/type_usage_declare_param_unnamed.cc:1:8",
"uses": ["tests/usage/type_usage_declare_param_unnamed.cc:2:10"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
"usr": "c:@F@foo#*$@S@ForwardType#", "usr": "c:@F@foo#*$@S@ForwardType#",
"short_name": "foo", "short_name": "foo",
"qualified_name": "foo", "qualified_name": "foo",
"definition": "tests/usage/type_usage_declare_param_unnamed.cc:2:6" "definition": "tests/usage/type_usage_declare_param_unnamed.cc:2:6",
"all_uses": ["tests/usage/type_usage_declare_param_unnamed.cc:2:6"]
}], }],
"variables": [] "variables": []
} }

View File

@ -15,7 +15,8 @@ OUTPUT:
"short_name": "Type", "short_name": "Type",
"qualified_name": "Type", "qualified_name": "Type",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:1:8", "definition": "tests/usage/type_usage_declare_qualifiers.cc:1:8",
"uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:10", "tests/usage/type_usage_declare_qualifiers.cc:3:26", "tests/usage/type_usage_declare_qualifiers.cc:4:3", "tests/usage/type_usage_declare_qualifiers.cc:5:3", "tests/usage/type_usage_declare_qualifiers.cc:6:9", "tests/usage/type_usage_declare_qualifiers.cc:7:9"] "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:1:8", "tests/usage/type_usage_declare_qualifiers.cc:3:10", "tests/usage/type_usage_declare_qualifiers.cc:3:26", "tests/usage/type_usage_declare_qualifiers.cc:4:3", "tests/usage/type_usage_declare_qualifiers.cc:5:3", "tests/usage/type_usage_declare_qualifiers.cc:6:9", "tests/usage/type_usage_declare_qualifiers.cc:7:9"],
"interesting_uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:10", "tests/usage/type_usage_declare_qualifiers.cc:3:26", "tests/usage/type_usage_declare_qualifiers.cc:4:3", "tests/usage/type_usage_declare_qualifiers.cc:5:3", "tests/usage/type_usage_declare_qualifiers.cc:6:9", "tests/usage/type_usage_declare_qualifiers.cc:7:9"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
@ -23,12 +24,7 @@ OUTPUT:
"short_name": "foo", "short_name": "foo",
"qualified_name": "foo", "qualified_name": "foo",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:3:6", "definition": "tests/usage/type_usage_declare_qualifiers.cc:3:6",
"callees": ["1@tests/usage/type_usage_declare_qualifiers.cc:4:8"] "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:6"]
}, {
"id": 1,
"usr": "c:@S@Type@F@Type#",
"callers": ["0@tests/usage/type_usage_declare_qualifiers.cc:4:8"],
"uses": ["tests/usage/type_usage_declare_qualifiers.cc:4:8"]
}], }],
"variables": [{ "variables": [{
"id": 0, "id": 0,
@ -36,48 +32,48 @@ OUTPUT:
"short_name": "a0", "short_name": "a0",
"qualified_name": "a0", "qualified_name": "a0",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:3:16", "declaration": "tests/usage/type_usage_declare_qualifiers.cc:3:16",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:3:16"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:16"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:type_usage_declare_qualifiers.cc@38@F@foo#&$@S@Type#&1S1_#@a1", "usr": "c:type_usage_declare_qualifiers.cc@38@F@foo#&$@S@Type#&1S1_#@a1",
"short_name": "a1", "short_name": "a1",
"qualified_name": "a1", "qualified_name": "a1",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:3:32", "declaration": "tests/usage/type_usage_declare_qualifiers.cc:3:32",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:3:32"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:32"]
}, { }, {
"id": 2, "id": 2,
"usr": "c:type_usage_declare_qualifiers.cc@59@F@foo#&$@S@Type#&1S1_#@a2", "usr": "c:type_usage_declare_qualifiers.cc@59@F@foo#&$@S@Type#&1S1_#@a2",
"short_name": "a2", "short_name": "a2",
"qualified_name": "a2", "qualified_name": "a2",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:4:8", "declaration": "tests/usage/type_usage_declare_qualifiers.cc:4:8",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:4:8"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:4:8"]
}, { }, {
"id": 3, "id": 3,
"usr": "c:type_usage_declare_qualifiers.cc@71@F@foo#&$@S@Type#&1S1_#@a3", "usr": "c:type_usage_declare_qualifiers.cc@71@F@foo#&$@S@Type#&1S1_#@a3",
"short_name": "a3", "short_name": "a3",
"qualified_name": "a3", "qualified_name": "a3",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:5:9", "declaration": "tests/usage/type_usage_declare_qualifiers.cc:5:9",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:5:9"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:5:9"]
}, { }, {
"id": 4, "id": 4,
"usr": "c:type_usage_declare_qualifiers.cc@84@F@foo#&$@S@Type#&1S1_#@a4", "usr": "c:type_usage_declare_qualifiers.cc@84@F@foo#&$@S@Type#&1S1_#@a4",
"short_name": "a4", "short_name": "a4",
"qualified_name": "a4", "qualified_name": "a4",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:6:15", "declaration": "tests/usage/type_usage_declare_qualifiers.cc:6:15",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:6:15"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:6:15"]
}, { }, {
"id": 5, "id": 5,
"usr": "c:type_usage_declare_qualifiers.cc@103@F@foo#&$@S@Type#&1S1_#@a5", "usr": "c:type_usage_declare_qualifiers.cc@103@F@foo#&$@S@Type#&1S1_#@a5",
"short_name": "a5", "short_name": "a5",
"qualified_name": "a5", "qualified_name": "a5",
"declaration": "tests/usage/type_usage_declare_qualifiers.cc:7:21", "declaration": "tests/usage/type_usage_declare_qualifiers.cc:7:21",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:7:21"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_qualifiers.cc:7:21"]
}] }]
} }

View File

@ -6,10 +6,8 @@ OUTPUT:
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@Type", "usr": "c:@S@Type",
"short_name": "Type", "all_uses": ["tests/usage/type_usage_declare_static.cc:1:8", "tests/usage/type_usage_declare_static.cc:2:8"],
"qualified_name": "Type", "interesting_uses": ["tests/usage/type_usage_declare_static.cc:2:8"]
"declaration": "tests/usage/type_usage_declare_static.cc:1:8",
"uses": ["tests/usage/type_usage_declare_static.cc:2:8"]
}], }],
"functions": [], "functions": [],
"variables": [{ "variables": [{
@ -18,8 +16,8 @@ OUTPUT:
"short_name": "t", "short_name": "t",
"qualified_name": "t", "qualified_name": "t",
"declaration": "tests/usage/type_usage_declare_static.cc:2:13", "declaration": "tests/usage/type_usage_declare_static.cc:2:13",
"initializations": ["tests/usage/type_usage_declare_static.cc:2:13"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/usage/type_usage_declare_static.cc:2:13"]
}] }]
} }
*/ */

View File

@ -12,9 +12,10 @@ class Foo {
Type* Foo::Get(int) {} Type* Foo::Get(int) {}
void Foo::Empty() {} void Foo::Empty() {}
// TODO: Add static extern const Type& external();
// TODO: Add extern?
// TODO: verify interesting usage is reported static Type* bar();
static Type* bar() {}
/* /*
OUTPUT: OUTPUT:
@ -22,41 +23,53 @@ OUTPUT:
"types": [{ "types": [{
"id": 0, "id": 0,
"usr": "c:@S@Type", "usr": "c:@S@Type",
"short_name": "Type", "all_uses": ["tests/usage/type_usage_on_return_type.cc:1:8", "tests/usage/type_usage_on_return_type.cc:3:1", "tests/usage/type_usage_on_return_type.cc:4:1", "tests/usage/type_usage_on_return_type.cc:5:1", "tests/usage/type_usage_on_return_type.cc:8:3", "tests/usage/type_usage_on_return_type.cc:12:1", "tests/usage/type_usage_on_return_type.cc:15:14", "tests/usage/type_usage_on_return_type.cc:17:8", "tests/usage/type_usage_on_return_type.cc:18:8"],
"qualified_name": "Type", "interesting_uses": ["tests/usage/type_usage_on_return_type.cc:3:1", "tests/usage/type_usage_on_return_type.cc:4:1", "tests/usage/type_usage_on_return_type.cc:5:1", "tests/usage/type_usage_on_return_type.cc:8:3", "tests/usage/type_usage_on_return_type.cc:12:1", "tests/usage/type_usage_on_return_type.cc:15:14", "tests/usage/type_usage_on_return_type.cc:17:8", "tests/usage/type_usage_on_return_type.cc:18:8"]
"declaration": "tests/usage/type_usage_on_return_type.cc:1:8",
"uses": ["tests/usage/type_usage_on_return_type.cc:3:1", "tests/usage/type_usage_on_return_type.cc:4:1", "tests/usage/type_usage_on_return_type.cc:5:1", "tests/usage/type_usage_on_return_type.cc:8:3", "tests/usage/type_usage_on_return_type.cc:12:1"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@S@Foo", "usr": "c:@S@Foo",
"short_name": "Foo", "short_name": "Foo",
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/usage/type_usage_on_return_type.cc:7:7", "definition": "tests/usage/type_usage_on_return_type.cc:7:7",
"funcs": [1, 2] "funcs": [1, 2],
"all_uses": ["tests/usage/type_usage_on_return_type.cc:7:7", "tests/usage/type_usage_on_return_type.cc:12:7", "tests/usage/type_usage_on_return_type.cc:13:6"]
}], }],
"functions": [{ "functions": [{
"id": 0, "id": 0,
"usr": "c:@F@foo#", "usr": "c:@F@foo#",
"short_name": "foo", "short_name": "foo",
"qualified_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",
"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"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@S@Foo@F@Get#I#", "usr": "c:@S@Foo@F@Get#I#",
"short_name": "Get", "short_name": "Get",
"qualified_name": "Foo::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", "definition": "tests/usage/type_usage_on_return_type.cc:12:12",
"declaring_type": 1 "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"]
}, { }, {
"id": 2, "id": 2,
"usr": "c:@S@Foo@F@Empty#", "usr": "c:@S@Foo@F@Empty#",
"short_name": "Empty", "short_name": "Empty",
"qualified_name": "Foo::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", "definition": "tests/usage/type_usage_on_return_type.cc:13:11",
"declaring_type": 1 "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"]
}, {
"id": 3,
"usr": "c:@F@external#",
"short_name": "external",
"qualified_name": "external",
"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",
"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"]
}], }],
"variables": [] "variables": []
} }