From 161aab3a09ba7b3cf30d540d7ed12676750e732e Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sun, 19 Feb 2017 01:17:37 -0800 Subject: [PATCH] wip --- main.cpp | 9 +--- tests/usage/usage_inside_of_call.cc | 77 +++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 tests/usage/usage_inside_of_call.cc diff --git a/main.cpp b/main.cpp index 2a44649b..47ab5c0f 100644 --- a/main.cpp +++ b/main.cpp @@ -588,13 +588,6 @@ void Dump(clang::Cursor cursor) { -// TODO: See if we can improve type usage reporting, for example -// void foo() { -// Foo x; -// } -// The usage on |Foo| will be reported at the |x| variable location. We should -// report it at the start of |Foo| instead. - void InsertTypeUsageAtLocation(ParsingDatabase* db, clang::Type type, const clang::SourceLocation& location) { clang::Type raw_type = type.strip_qualifiers(); @@ -1160,4 +1153,4 @@ int main(int argc, char** argv) { return 0; } -// TODO: ctor/dtor, copy ctor \ No newline at end of file +// TODO: ctor/dtor, copy ctor, class inheritance, method inheritance \ No newline at end of file diff --git a/tests/usage/usage_inside_of_call.cc b/tests/usage/usage_inside_of_call.cc new file mode 100644 index 00000000..21491cf5 --- /dev/null +++ b/tests/usage/usage_inside_of_call.cc @@ -0,0 +1,77 @@ +void called(int a); + +int gen(); + +struct Foo { + static int static_var; + int field_var; +}; + +void foo() { + int a = 5; + called(a + gen() + Foo().field_var + Foo::static_var); +} + +/* +OUTPUT: +{ + "types": [{ + "id": 0, + "usr": "c:@S@Foo", + "short_name": "Foo", + "qualified_name": "Foo", + "definition": "tests/usage/usage_inside_of_call.cc:5:8", + "vars": [0, 1] + }], + "functions": [{ + "id": 0, + "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:12:3"], + "uses": ["tests/usage/usage_inside_of_call.cc:12:3"] + }, { + "id": 1, + "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:12:14"], + "uses": ["tests/usage/usage_inside_of_call.cc:12:14"] + }, { + "id": 2, + "usr": "c:@F@foo#", + "short_name": "foo", + "qualified_name": "foo", + "definition": "tests/usage/usage_inside_of_call.cc:10:6", + "callees": ["0@tests/usage/usage_inside_of_call.cc:12:3", "1@tests/usage/usage_inside_of_call.cc:12:14"] + }], + "variables": [{ + "id": 0, + "usr": "c:@S@Foo@static_var", + "short_name": "static_var", + "qualified_name": "Foo::static_var", + "declaration": "tests/usage/usage_inside_of_call.cc:6:14", + "declaring_type": 0, + "uses": ["tests/usage/usage_inside_of_call.cc:12:45"] + }, { + "id": 1, + "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", + "initializations": ["tests/usage/usage_inside_of_call.cc:7:7"], + "declaring_type": 0, + "uses": ["tests/usage/usage_inside_of_call.cc:12:28"] + }, { + "id": 2, + "usr": "c:usage_inside_of_call.cc@117@F@foo#@a", + "short_name": "a", + "qualified_name": "a", + "declaration": "tests/usage/usage_inside_of_call.cc:11:7", + "initializations": ["tests/usage/usage_inside_of_call.cc:11:7"], + "uses": ["tests/usage/usage_inside_of_call.cc:12:10"] + }] +} +*/ \ No newline at end of file