Browse Source

update

pull/2/head
Jacob Dufault 8 years ago
parent
commit
ca9918b8c4
  1. 81
      main.cpp
  2. 3
      tests/usage/func_usage_call_method.cc
  3. 3
      tests/usage/func_usage_forward_decl_method.cc
  4. 35
      tests/usage/type_usage_declare_param_prototype.cc
  5. 78
      tests/usage/type_usage_declare_qualifiers.cc
  6. 21
      tests/usage/type_usage_declare_static.cc
  7. 8
      tests/usage/type_usage_on_extern.cc
  8. 8
      tests/usage/type_usage_on_local.cc
  9. 8
      tests/usage/type_usage_on_parameter.cc
  10. 35
      tests/usage/type_usage_on_prototype_parameter.cc
  11. 8
      tests/usage/type_usage_on_static.cc
  12. 77
      tests/usage/type_usage_qualifiers.cc
  13. 72
      tests/usage/type_usage_typedef_and_using.cc
  14. 40
      tests/usage/var_usage_call_function.cc
  15. 83
      tests/usage/var_usage_class_member.cc
  16. 22
      tests/usage/var_usage_extern.cc
  17. 21
      tests/usage/var_usage_func_parameter.cc
  18. 22
      tests/usage/var_usage_local.cc
  19. 8
      tests/usage/var_usage_shadowed_class_member.cc
  20. 35
      tests/usage/var_usage_shadowed_local.cc
  21. 35
      tests/usage/var_usage_shadowed_parameter.cc
  22. 24
      tests/usage/var_usage_static.cc

81
main.cpp

@ -72,6 +72,10 @@ struct TypeDef {
std::optional<clang::SourceLocation> declaration; // Forward decl.
std::optional<clang::SourceLocation> definition;
// If set, then this is the same underlying type as the given value (ie, this
// type comes from a using or typedef statement).
std::optional<TypeId> alias_of;
// Immediate parent and immediate derived types.
std::vector<TypeId> parents;
std::vector<TypeId> derived;
@ -332,6 +336,7 @@ std::string ParsingDatabase::ToString() {
WRITE(qualified_name);
WRITE(declaration);
WRITE(definition);
WRITE(alias_of);
WRITE(parents);
WRITE(derived);
WRITE(types);
@ -636,6 +641,8 @@ void InsertReference(ParsingDatabase* db, FuncId func_id, clang::Cursor referenc
break;
}
case CXCursor_ParmDecl:
case CXCursor_FieldDecl:
case CXCursor_VarDecl:
{
VarId referenced_id = db->ToVarId(referenced.get_usr());
@ -651,6 +658,11 @@ void InsertReference(ParsingDatabase* db, FuncId func_id, clang::Cursor referenc
}
}
// TODO: Should we declare variables on prototypes? ie,
//
// foo(int* x);
//
// I'm inclined to say yes if we want a rename refactoring.
struct FuncDefinitionParam {
@ -682,7 +694,7 @@ clang::VisiterResult VisitFuncDefinition(clang::Cursor cursor, clang::Cursor par
case CXCursor_MemberRefExpr:
case CXCursor_DeclRefExpr:
InsertReference(param->db, param->func_id, cursor);
return clang::VisiterResult::Continue;
return clang::VisiterResult::Recurse;
case CXCursor_VarDecl:
case CXCursor_ParmDecl:
@ -758,6 +770,31 @@ void HandleFunc(ParsingDatabase* db, NamespaceStack* ns, clang::Cursor func, std
}
struct UsingParam {
ParsingDatabase* db;
TypeId active_type;
UsingParam(ParsingDatabase* db, TypeId active_type)
: db(db), active_type(active_type) {}
};
clang::VisiterResult VisitUsing(clang::Cursor cursor, clang::Cursor parent, UsingParam* param) {
ParsingDatabase* db = param->db;
switch (cursor.get_kind()) {
case CXCursor_TypeRef:
{
TypeId source_type = db->ToTypeId(cursor.get_referenced().get_usr());
db->Resolve(param->active_type)->alias_of = source_type;
return clang::VisiterResult::Break;
}
default:
std::cerr << "Unhandled VisitClassDecl kind " << clang::ToString(cursor.get_kind()) << std::endl;
break;
}
return clang::VisiterResult::Continue;
}
@ -774,6 +811,9 @@ clang::VisiterResult VisitClassDecl(clang::Cursor cursor, clang::Cursor parent,
ParsingDatabase* db = param->db;
switch (cursor.get_kind()) {
case CXCursor_CXXAccessSpecifier:
break;
case CXCursor_CXXMethod:
HandleFunc(param->db, param->ns, cursor, param->active_type);
break;
@ -791,25 +831,31 @@ clang::VisiterResult VisitClassDecl(clang::Cursor cursor, clang::Cursor parent,
return clang::VisiterResult::Continue;
}
void HandleClassDecl(clang::Cursor cursor, ParsingDatabase* db, NamespaceStack* ns) {
TypeId func_id = db->ToTypeId(cursor.get_usr());
TypeDef* func_def = db->Resolve(func_id);
void HandleClassDecl(clang::Cursor cursor, ParsingDatabase* db, NamespaceStack* ns, bool is_alias) {
TypeId type_id = db->ToTypeId(cursor.get_usr());
TypeDef* type_def = db->Resolve(type_id);
func_def->short_name = cursor.get_spelling();
type_def->short_name = cursor.get_spelling();
// TODO: Support nested classes (pass in declaring type insteaad of nullopt!)
func_def->qualified_name =
ns->ComputeQualifiedName(db, std::nullopt, func_def->short_name);
type_def->qualified_name =
ns->ComputeQualifiedName(db, std::nullopt, type_def->short_name);
if (!cursor.is_definition()) {
if (!func_def->declaration)
func_def->declaration = cursor.get_source_location();
if (!type_def->declaration)
type_def->declaration = cursor.get_source_location();
return;
}
func_def->definition = cursor.get_source_location();
type_def->definition = cursor.get_source_location();
ClassDeclParam classDeclParam(db, ns, func_id);
cursor.VisitChildren(&VisitClassDecl, &classDeclParam);
if (is_alias) {
UsingParam usingParam(db, type_id);
cursor.VisitChildren(&VisitUsing, &usingParam);
}
else {
ClassDeclParam classDeclParam(db, ns, type_id);
cursor.VisitChildren(&VisitClassDecl, &classDeclParam);
}
}
@ -817,6 +863,8 @@ void HandleClassDecl(clang::Cursor cursor, ParsingDatabase* db, NamespaceStack*
struct FileParam {
ParsingDatabase* db;
NamespaceStack* ns;
@ -834,10 +882,15 @@ clang::VisiterResult VisitFile(clang::Cursor cursor, clang::Cursor parent, FileP
param->ns->Pop();
break;
case CXCursor_TypeAliasDecl:
case CXCursor_TypedefDecl:
HandleClassDecl(cursor, param->db, param->ns, true /*is_alias*/);
break;
case CXCursor_StructDecl:
case CXCursor_ClassDecl:
// TODO: Cleanup Handle* param order.
HandleClassDecl(cursor, param->db, param->ns);
HandleClassDecl(cursor, param->db, param->ns, false /*is_alias*/);
break;
case CXCursor_CXXMethod:
@ -972,7 +1025,7 @@ void DiffDocuments(rapidjson::Document& expected, rapidjson::Document& actual) {
int main(int argc, char** argv) {
for (std::string path : GetFilesInFolder("tests")) {
// TODO: Fix all existing tests.
//if (path != "tests/usage/func_usage_addr_func.cc") continue;
//if (path != "tests/usage/var_usage_func_parameter.cc") continue;
// Parse expected output from the test, parse it into JSON document.
std::string expected_output;

3
tests/usage/func_usage_call_method.cc

@ -43,7 +43,8 @@ OUTPUT:
"qualified_name": "f",
"declaration": "tests/usage/func_usage_call_method.cc:6:8",
"initializations": ["tests/usage/func_usage_call_method.cc:6:8"],
"variable_type": 0
"variable_type": 0,
"uses": ["tests/usage/func_usage_call_method.cc:7:3"]
}]
}
*/

3
tests/usage/func_usage_forward_decl_method.cc

@ -42,7 +42,8 @@ OUTPUT:
"qualified_name": "f",
"declaration": "tests/usage/func_usage_forward_decl_method.cc:6:8",
"initializations": ["tests/usage/func_usage_forward_decl_method.cc:6:8"],
"variable_type": 0
"variable_type": 0,
"uses": ["tests/usage/func_usage_forward_decl_method.cc:7:3"]
}]
}
*/

35
tests/usage/type_usage_declare_param_prototype.cc

@ -0,0 +1,35 @@
struct Foo;
void foo(Foo* f, Foo*);
void foo(Foo* f, Foo*) {}
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"declaration": "tests/usage/type_usage_declare_param_prototype.cc:1:8",
"uses": ["tests/usage/type_usage_declare_param_prototype.cc:3:15", "tests/usage/type_usage_declare_param_prototype.cc:3:22", "tests/usage/type_usage_declare_param_prototype.cc:4:15", "tests/usage/type_usage_declare_param_prototype.cc:4:22"]
}],
"functions": [{
"id": 0,
"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"
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/type_usage_declare_param_prototype.cc:4:15"],
"variable_type": 0
}]
}
*/

78
tests/usage/type_usage_declare_qualifiers.cc

@ -0,0 +1,78 @@
struct Type {};
void foo(Type& a0, const Type& a1) {
Type a2;
Type* a3;
const Type* a4;
const Type const* a5;
}
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Type",
"short_name": "Type",
"qualified_name": "Type",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:1:8",
"uses": ["tests/usage/type_usage_declare_qualifiers.cc:3:16", "tests/usage/type_usage_declare_qualifiers.cc:3:32", "tests/usage/type_usage_declare_qualifiers.cc:4:8", "tests/usage/type_usage_declare_qualifiers.cc:5:9", "tests/usage/type_usage_declare_qualifiers.cc:6:15", "tests/usage/type_usage_declare_qualifiers.cc:7:21"]
}],
"functions": [{
"id": 0,
"usr": "c:@F@foo#&$@S@Type#&1S1_#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/type_usage_declare_qualifiers.cc:3:6"
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:3:16"],
"variable_type": 0
}, {
"id": 1,
"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",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:3:32"],
"variable_type": 0
}, {
"id": 2,
"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",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:4:8"],
"variable_type": 0
}, {
"id": 3,
"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",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:5:9"],
"variable_type": 0
}, {
"id": 4,
"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",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:6:15"],
"variable_type": 0
}, {
"id": 5,
"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",
"initializations": ["tests/usage/type_usage_declare_qualifiers.cc:7:21"],
"variable_type": 0
}]
}
*/

21
tests/usage/type_usage_declare_static.cc

@ -1,8 +1,25 @@
struct Type;
static Type t;
/*
OUTPUT:
{
"types": [],
"types": [{
"id": 0,
"usr": "c:@S@Type",
"short_name": "Type",
"qualified_name": "Type",
"declaration": "tests/usage/type_usage_declare_static.cc:1:8",
"uses": ["tests/usage/type_usage_declare_static.cc:2:13"]
}],
"functions": [],
"variables": []
"variables": [{
"id": 0,
"usr": "c:type_usage_declare_static.cc@t",
"short_name": "t",
"qualified_name": "t",
"declaration": "tests/usage/type_usage_declare_static.cc:2:13",
"initializations": ["tests/usage/type_usage_declare_static.cc:2:13"],
"variable_type": 0
}]
}
*/

8
tests/usage/type_usage_on_extern.cc

@ -1,8 +0,0 @@
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
}
*/

8
tests/usage/type_usage_on_local.cc

@ -1,8 +0,0 @@
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
}
*/

8
tests/usage/type_usage_on_parameter.cc

@ -1,8 +0,0 @@
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
}
*/

35
tests/usage/type_usage_on_prototype_parameter.cc

@ -1,35 +0,0 @@
struct Foo;
void foo(Foo* f);
void foo(Foo* f) {}
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"declaration": "tests/usage/type_usage_on_prototype_parameter.cc:1:8",
"uses": ["tests/usage/type_usage_on_prototype_parameter.cc:2:15", "tests/usage/type_usage_on_prototype_parameter.cc:4:15"]
}],
"functions": [{
"id": 0,
"usr": "c:@F@foo#*$@S@Foo#",
"short_name": "foo",
"qualified_name": "foo",
"declaration": "tests/usage/type_usage_on_prototype_parameter.cc:2:6",
"definition": "tests/usage/type_usage_on_prototype_parameter.cc:4:6"
}],
"variables": [{
"id": 0,
"usr": "c:type_usage_on_prototype_parameter.cc@43@F@foo#*$@S@Foo#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/usage/type_usage_on_prototype_parameter.cc:4:15",
"initializations": ["tests/usage/type_usage_on_prototype_parameter.cc:4:15"],
"variable_type": 0
}]
}
*/

8
tests/usage/type_usage_on_static.cc

@ -1,8 +0,0 @@
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
}
*/

77
tests/usage/type_usage_qualifiers.cc

@ -1,77 +0,0 @@
struct Type {};
void foo(Type& a0, const Type& a1) {
Type a2;
Type* a3;
const Type* a4;
const Type const* a5;
}
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@S@Type",
"short_name": "Type",
"qualified_name": "Type",
"definition": "tests/usage/type_usage_qualifiers.cc:1:8",
"uses": ["tests/usage/type_usage_qualifiers.cc:3:16", "tests/usage/type_usage_qualifiers.cc:3:32", "tests/usage/type_usage_qualifiers.cc:4:8", "tests/usage/type_usage_qualifiers.cc:5:9", "tests/usage/type_usage_qualifiers.cc:6:15", "tests/usage/type_usage_qualifiers.cc:7:21"]
}],
"functions": [{
"id": 0,
"usr": "c:@F@foo#&$@S@Type#&1S1_#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/type_usage_qualifiers.cc:3:6"
}],
"variables": [{
"id": 0,
"usr": "c:type_usage_qualifiers.cc@28@F@foo#&$@S@Type#&1S1_#@a0",
"short_name": "a0",
"qualified_name": "a0",
"declaration": "tests/usage/type_usage_qualifiers.cc:3:16",
"initializations": ["tests/usage/type_usage_qualifiers.cc:3:16"],
"variable_type": 0
}, {
"id": 1,
"usr": "c:type_usage_qualifiers.cc@38@F@foo#&$@S@Type#&1S1_#@a1",
"short_name": "a1",
"qualified_name": "a1",
"declaration": "tests/usage/type_usage_qualifiers.cc:3:32",
"initializations": ["tests/usage/type_usage_qualifiers.cc:3:32"],
"variable_type": 0
}, {
"id": 2,
"usr": "c:type_usage_qualifiers.cc@59@F@foo#&$@S@Type#&1S1_#@a2",
"short_name": "a2",
"qualified_name": "a2",
"declaration": "tests/usage/type_usage_qualifiers.cc:4:8",
"initializations": ["tests/usage/type_usage_qualifiers.cc:4:8"],
"variable_type": 0
}, {
"id": 3,
"usr": "c:type_usage_qualifiers.cc@71@F@foo#&$@S@Type#&1S1_#@a3",
"short_name": "a3",
"qualified_name": "a3",
"declaration": "tests/usage/type_usage_qualifiers.cc:5:9",
"initializations": ["tests/usage/type_usage_qualifiers.cc:5:9"],
"variable_type": 0
}, {
"id": 4,
"usr": "c:type_usage_qualifiers.cc@84@F@foo#&$@S@Type#&1S1_#@a4",
"short_name": "a4",
"qualified_name": "a4",
"declaration": "tests/usage/type_usage_qualifiers.cc:6:15",
"initializations": ["tests/usage/type_usage_qualifiers.cc:6:15"],
"variable_type": 0
}, {
"id": 5,
"usr": "c:type_usage_qualifiers.cc@103@F@foo#&$@S@Type#&1S1_#@a5",
"short_name": "a5",
"qualified_name": "a5",
"declaration": "tests/usage/type_usage_qualifiers.cc:7:21",
"initializations": ["tests/usage/type_usage_qualifiers.cc:7:21"],
"variable_type": 0
}]
}
*/

72
tests/usage/type_usage_typedef_and_using.cc

@ -1,9 +1,73 @@
// TODO: Verify using and typedef are treated as separate types for usage info.
struct Foo;
using Foo1 = Foo;
typedef Foo Foo2;
using Foo3 = Foo1;
void accept(Foo*);
void accept1(Foo1*);
void accept2(Foo2*);
void accept3(Foo3*);
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"declaration": "tests/usage/type_usage_typedef_and_using.cc:1:8",
"uses": ["tests/usage/type_usage_typedef_and_using.cc:6:17"]
}, {
"id": 1,
"usr": "c:@Foo1",
"short_name": "Foo1",
"qualified_name": "Foo1",
"definition": "tests/usage/type_usage_typedef_and_using.cc:2:7",
"alias_of": 0,
"uses": ["tests/usage/type_usage_typedef_and_using.cc:7:19"]
}, {
"id": 2,
"usr": "c:type_usage_typedef_and_using.cc@T@Foo2",
"short_name": "Foo2",
"qualified_name": "Foo2",
"definition": "tests/usage/type_usage_typedef_and_using.cc:3:13",
"alias_of": 0,
"uses": ["tests/usage/type_usage_typedef_and_using.cc:8:19"]
}, {
"id": 3,
"usr": "c:@Foo3",
"short_name": "Foo3",
"qualified_name": "Foo3",
"definition": "tests/usage/type_usage_typedef_and_using.cc:4:7",
"alias_of": 1,
"uses": ["tests/usage/type_usage_typedef_and_using.cc:9:19"]
}],
"functions": [{
"id": 0,
"usr": "c:@F@accept#*$@S@Foo#",
"short_name": "accept",
"qualified_name": "accept",
"declaration": "tests/usage/type_usage_typedef_and_using.cc:6:6"
}, {
"id": 1,
"usr": "c:@F@accept1#*$@S@Foo#",
"short_name": "accept1",
"qualified_name": "accept1",
"declaration": "tests/usage/type_usage_typedef_and_using.cc:7:6"
}, {
"id": 2,
"usr": "c:@F@accept2#*$@S@Foo#",
"short_name": "accept2",
"qualified_name": "accept2",
"declaration": "tests/usage/type_usage_typedef_and_using.cc:8:6"
}, {
"id": 3,
"usr": "c:@F@accept3#*$@S@Foo#",
"short_name": "accept3",
"qualified_name": "accept3",
"declaration": "tests/usage/type_usage_typedef_and_using.cc:9:6"
}],
"variables": []
}
*/

40
tests/usage/var_usage_call_function.cc

@ -0,0 +1,40 @@
void called() {}
void caller() {
auto x = &called;
x();
called();
}
/*
OUTPUT:
{
"types": [],
"functions": [{
"id": 0,
"usr": "c:@F@called#",
"short_name": "called",
"qualified_name": "called",
"definition": "tests/usage/var_usage_call_function.cc:1:6",
"callers": ["1@tests/usage/var_usage_call_function.cc:4:13", "1@tests/usage/var_usage_call_function.cc:7:3"],
"uses": ["tests/usage/var_usage_call_function.cc:4:13", "tests/usage/var_usage_call_function.cc:7:3"]
}, {
"id": 1,
"usr": "c:@F@caller#",
"short_name": "caller",
"qualified_name": "caller",
"definition": "tests/usage/var_usage_call_function.cc:3:6",
"callees": ["0@tests/usage/var_usage_call_function.cc:4:13", "0@tests/usage/var_usage_call_function.cc:7:3"]
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/var_usage_call_function.cc:4:8"],
"uses": ["tests/usage/var_usage_call_function.cc:5:3"]
}]
}
*/

83
tests/usage/var_usage_class_member.cc

@ -1,8 +1,85 @@
class Foo {
public:
int x;
int y;
};
void accept(int);
void accept(int*);
void foo() {
Foo f;
f.x = 3;
f.x += 5;
accept(f.x);
accept(f.x + 20);
accept(&f.x);
accept(f.y);
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"types": [{
"id": 0,
"usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "tests/usage/var_usage_class_member.cc:1:7",
"vars": [0, 1],
"uses": ["tests/usage/var_usage_class_member.cc:11:7"]
}],
"functions": [{
"id": 0,
"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"],
"uses": ["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"]
}, {
"id": 1,
"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"],
"uses": ["tests/usage/var_usage_class_member.cc:16:3"]
}, {
"id": 2,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_class_member.cc:10:6",
"callees": ["0@tests/usage/var_usage_class_member.cc:14:3", "0@tests/usage/var_usage_class_member.cc:15:3", "1@tests/usage/var_usage_class_member.cc:16:3", "0@tests/usage/var_usage_class_member.cc:17:3"]
}],
"variables": [{
"id": 0,
"usr": "c:@S@Foo@FI@x",
"short_name": "x",
"qualified_name": "Foo::x",
"declaration": "tests/usage/var_usage_class_member.cc:3:7",
"initializations": ["tests/usage/var_usage_class_member.cc:3:7"],
"declaring_type": 0,
"uses": ["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"]
}, {
"id": 1,
"usr": "c:@S@Foo@FI@y",
"short_name": "y",
"qualified_name": "Foo::y",
"declaration": "tests/usage/var_usage_class_member.cc:4:7",
"initializations": ["tests/usage/var_usage_class_member.cc:4:7"],
"declaring_type": 0,
"uses": ["tests/usage/var_usage_class_member.cc:17:12"]
}, {
"id": 2,
"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",
"initializations": ["tests/usage/var_usage_class_member.cc:11:7"],
"variable_type": 0,
"uses": ["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"]
}]
}
*/

22
tests/usage/var_usage_extern.cc

@ -1,8 +1,26 @@
extern int a;
void foo() {
a = 5;
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"functions": [{
"id": 0,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_extern.cc:3:6"
}],
"variables": [{
"id": 0,
"usr": "c:@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_extern.cc:1:12",
"uses": ["tests/usage/var_usage_extern.cc:4:3"]
}]
}
*/

21
tests/usage/var_usage_func_parameter.cc

@ -1,8 +1,25 @@
void foo(int a) {
a += 10;
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"functions": [{
"id": 0,
"usr": "c:@F@foo#I#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_func_parameter.cc:1:6"
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/var_usage_func_parameter.cc:1:14"],
"uses": ["tests/usage/var_usage_func_parameter.cc:2:3"]
}]
}
*/

22
tests/usage/var_usage_local.cc

@ -1,8 +1,26 @@
void foo() {
int x;
x = 3;
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"functions": [{
"id": 0,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_local.cc:1:6"
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/var_usage_local.cc:2:7"],
"uses": ["tests/usage/var_usage_local.cc:3:3"]
}]
}
*/

8
tests/usage/var_usage_shadowed_class_member.cc

@ -1,8 +0,0 @@
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
}
*/

35
tests/usage/var_usage_shadowed_local.cc

@ -1,8 +1,39 @@
void foo() {
int a;
a = 1;
{
int a;
a = 2;
}
a = 3;
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"functions": [{
"id": 0,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_shadowed_local.cc:1:6"
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/var_usage_shadowed_local.cc:2:7"],
"uses": ["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",
"initializations": ["tests/usage/var_usage_shadowed_local.cc:5:9"],
"uses": ["tests/usage/var_usage_shadowed_local.cc:6:5"]
}]
}
*/

35
tests/usage/var_usage_shadowed_parameter.cc

@ -1,8 +1,39 @@
void foo(int a) {
a = 1;
{
int a;
a = 2;
}
a = 3;
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"functions": [{
"id": 0,
"usr": "c:@F@foo#I#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_shadowed_parameter.cc:1:6"
}],
"variables": [{
"id": 0,
"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",
"initializations": ["tests/usage/var_usage_shadowed_parameter.cc:1:14"],
"uses": ["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",
"initializations": ["tests/usage/var_usage_shadowed_parameter.cc:4:9"],
"uses": ["tests/usage/var_usage_shadowed_parameter.cc:5:5"]
}]
}
*/

24
tests/usage/var_usage_static.cc

@ -1,8 +1,28 @@
static int a;
void foo() {
a = 3;
}
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"functions": [{
"id": 0,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/usage/var_usage_static.cc:3:6"
}],
"variables": [{
"id": 0,
"usr": "c:var_usage_static.cc@a",
"short_name": "a",
"qualified_name": "a",
"declaration": "tests/usage/var_usage_static.cc:1:12",
"initializations": ["tests/usage/var_usage_static.cc:1:12"],
"uses": ["tests/usage/var_usage_static.cc:4:3"]
}]
}
*/
Loading…
Cancel
Save