Jacob Dufault
8 years ago
5 changed files with 121 additions and 56 deletions
@ -1,51 +1,39 @@ |
|||
struct Foo { |
|||
static Foo* Used(); |
|||
}; |
|||
void called(int a); |
|||
|
|||
void user() { |
|||
Foo* x = Foo::Used(); |
|||
int gen() { return 1; } |
|||
|
|||
void foo() { |
|||
called(gen() * gen()); |
|||
} |
|||
|
|||
/*
|
|||
|
|||
// TODO: Maybe only interesting usage of type is for function return type + variable declaration?
|
|||
// TODO: Checking last location doesn't work for type usage all_uses...
|
|||
|
|||
OUTPUT: |
|||
{ |
|||
"types": [{ |
|||
"id": 0, |
|||
"usr": "c:@S@Foo", |
|||
"short_name": "Foo", |
|||
"qualified_name": "Foo", |
|||
"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"], |
|||
"interesting_uses": ["tests/foobar.cc:2:10", "tests/foobar.cc:6:3"] |
|||
}], |
|||
"types": [], |
|||
"functions": [{ |
|||
"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"] |
|||
"usr": "c:@F@called#I#", |
|||
"short_name": "called", |
|||
"qualified_name": "called", |
|||
"callers": ["2@tests/foobar.cc:6:3"], |
|||
"all_uses": ["tests/foobar.cc:1:6", "tests/foobar.cc:6:3"] |
|||
}, { |
|||
"id": 1, |
|||
"usr": "c:@F@user#", |
|||
"short_name": "user", |
|||
"qualified_name": "user", |
|||
"usr": "c:@F@gen#", |
|||
"short_name": "gen", |
|||
"qualified_name": "gen", |
|||
"definition": "tests/foobar.cc:3:5", |
|||
"callers": ["2@tests/foobar.cc:6:10", "2@tests/foobar.cc:6:18"], |
|||
"all_uses": ["tests/foobar.cc:3:5", "tests/foobar.cc:6:10", "tests/foobar.cc:6:18"] |
|||
}, { |
|||
"id": 2, |
|||
"usr": "c:@F@foo#", |
|||
"short_name": "foo", |
|||
"qualified_name": "foo", |
|||
"definition": "tests/foobar.cc:5:6", |
|||
"callees": ["0@tests/foobar.cc:6:17"], |
|||
"callees": ["0@tests/foobar.cc:6:3", "1@tests/foobar.cc:6:10", "1@tests/foobar.cc:6:18"], |
|||
"all_uses": ["tests/foobar.cc:5:6"] |
|||
}], |
|||
"variables": [{ |
|||
"id": 0, |
|||
"usr": "c:foobar.cc@60@F@user#@x", |
|||
"short_name": "x", |
|||
"qualified_name": "x", |
|||
"declaration": "tests/foobar.cc:6:8", |
|||
"variable_type": 0, |
|||
"all_uses": ["tests/foobar.cc:6:8"] |
|||
}] |
|||
"variables": [] |
|||
} |
|||
*/ |
@ -0,0 +1,39 @@ |
|||
void called(int a); |
|||
|
|||
int gen() { return 1; } |
|||
|
|||
void foo() { |
|||
called(gen() * gen()); |
|||
} |
|||
|
|||
/*
|
|||
OUTPUT: |
|||
{ |
|||
"types": [], |
|||
"functions": [{ |
|||
"id": 0, |
|||
"usr": "c:@F@called#I#", |
|||
"short_name": "called", |
|||
"qualified_name": "called", |
|||
"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"] |
|||
}, { |
|||
"id": 1, |
|||
"usr": "c:@F@gen#", |
|||
"short_name": "gen", |
|||
"qualified_name": "gen", |
|||
"definition": "tests/usage/usage_inside_of_call_simple.cc:3:5", |
|||
"callers": ["2@tests/usage/usage_inside_of_call_simple.cc:6:10", "2@tests/usage/usage_inside_of_call_simple.cc:6:18"], |
|||
"all_uses": ["tests/usage/usage_inside_of_call_simple.cc:3:5", "tests/usage/usage_inside_of_call_simple.cc:6:10", "tests/usage/usage_inside_of_call_simple.cc:6:18"] |
|||
}, { |
|||
"id": 2, |
|||
"usr": "c:@F@foo#", |
|||
"short_name": "foo", |
|||
"qualified_name": "foo", |
|||
"definition": "tests/usage/usage_inside_of_call_simple.cc:5:6", |
|||
"callees": ["0@tests/usage/usage_inside_of_call_simple.cc:6:3", "1@tests/usage/usage_inside_of_call_simple.cc:6:10", "1@tests/usage/usage_inside_of_call_simple.cc:6:18"], |
|||
"all_uses": ["tests/usage/usage_inside_of_call_simple.cc:5:6"] |
|||
}], |
|||
"variables": [] |
|||
} |
|||
*/ |
@ -0,0 +1,47 @@ |
|||
struct Foo { |
|||
static int x; |
|||
}; |
|||
|
|||
void accept(int); |
|||
|
|||
void foo() { |
|||
accept(Foo::x); |
|||
} |
|||
|
|||
/*
|
|||
OUTPUT: |
|||
{ |
|||
"types": [{ |
|||
"id": 0, |
|||
"usr": "c:@S@Foo", |
|||
"short_name": "Foo", |
|||
"qualified_name": "Foo", |
|||
"definition": "tests/usage/var_usage_class_member_static.cc:1:8", |
|||
"all_uses": ["tests/usage/var_usage_class_member_static.cc:1:8", "tests/usage/var_usage_class_member_static.cc:8:10"] |
|||
}], |
|||
"functions": [{ |
|||
"id": 0, |
|||
"usr": "c:@F@accept#I#", |
|||
"short_name": "accept", |
|||
"qualified_name": "accept", |
|||
"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"] |
|||
}, { |
|||
"id": 1, |
|||
"usr": "c:@F@foo#", |
|||
"short_name": "foo", |
|||
"qualified_name": "foo", |
|||
"definition": "tests/usage/var_usage_class_member_static.cc:7:6", |
|||
"callees": ["0@tests/usage/var_usage_class_member_static.cc:8:3"], |
|||
"all_uses": ["tests/usage/var_usage_class_member_static.cc:7:6"] |
|||
}], |
|||
"variables": [{ |
|||
"id": 0, |
|||
"usr": "c:@S@Foo@x", |
|||
"short_name": "x", |
|||
"qualified_name": "Foo::x", |
|||
"declaration": "tests/usage/var_usage_class_member_static.cc:2:14", |
|||
"all_uses": ["tests/usage/var_usage_class_member_static.cc:2:14", "tests/usage/var_usage_class_member_static.cc:8:15"] |
|||
}] |
|||
} |
|||
*/ |
Loading…
Reference in new issue