This commit is contained in:
Jacob Dufault 2017-02-19 22:31:25 -08:00
parent d01eb6b86f
commit d26cb81854
3 changed files with 66 additions and 11 deletions

View File

@ -1252,6 +1252,7 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
case CXIdxEntity_Function: case CXIdxEntity_Function:
case CXIdxEntity_CXXConstructor: case CXIdxEntity_CXXConstructor:
case CXIdxEntity_CXXDestructor:
case CXIdxEntity_CXXInstanceMethod: case CXIdxEntity_CXXInstanceMethod:
case CXIdxEntity_CXXStaticMethod: case CXIdxEntity_CXXStaticMethod:
{ {
@ -1424,6 +1425,7 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
case CXIdxEntity_CXXStaticMethod: case CXIdxEntity_CXXStaticMethod:
case CXIdxEntity_CXXInstanceMethod: case CXIdxEntity_CXXInstanceMethod:
case CXIdxEntity_Function: case CXIdxEntity_Function:
case CXIdxEntity_CXXConstructor:
{ {
// TODO: Redirect container to constructor for // TODO: Redirect container to constructor for
// int Gen() { return 5; } // int Gen() { return 5; }
@ -1704,7 +1706,7 @@ int main(int argc, char** argv) {
for (std::string path : GetFilesInFolder("tests")) { for (std::string path : GetFilesInFolder("tests")) {
// 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/destructor.cc") continue;
//if (path != "tests/usage/usage_inside_of_call.cc") continue; //if (path != "tests/usage/usage_inside_of_call.cc") continue;
//if (path != "tests/usage/type_usage_typedef_and_using.cc") continue; //if (path != "tests/usage/type_usage_typedef_and_using.cc") continue;
//if (path != "tests/usage/type_usage_declare_local.cc") continue; //if (path != "tests/usage/type_usage_declare_local.cc") continue;

View File

@ -17,7 +17,7 @@ OUTPUT:
"qualified_name": "Foo", "qualified_name": "Foo",
"definition": "tests/constructors/constructor.cc:1:7", "definition": "tests/constructors/constructor.cc:1:7",
"funcs": [0], "funcs": [0],
"all_uses": ["tests/constructors/constructor.cc:7:3"] "all_uses": ["tests/constructors/constructor.cc:1:7", "tests/constructors/constructor.cc:7:3"],
"interesting_uses": ["tests/constructors/constructor.cc:7:3"] "interesting_uses": ["tests/constructors/constructor.cc:7:3"]
}], }],
"functions": [{ "functions": [{
@ -28,14 +28,15 @@ OUTPUT:
"definition": "tests/constructors/constructor.cc:3:3", "definition": "tests/constructors/constructor.cc:3:3",
"declaring_type": 0, "declaring_type": 0,
"callers": ["1@tests/constructors/constructor.cc:7:7"], "callers": ["1@tests/constructors/constructor.cc:7:7"],
"uses": ["tests/constructors/constructor.cc:7:7"] "all_uses": ["tests/constructors/constructor.cc:3:3", "tests/constructors/constructor.cc:7:7"]
}, { }, {
"id": 1, "id": 1,
"usr": "c:@F@foo#", "usr": "c:@F@foo#",
"short_name": "foo", "short_name": "foo",
"qualified_name": "foo", "qualified_name": "foo",
"definition": "tests/constructors/constructor.cc:6:6", "definition": "tests/constructors/constructor.cc:6:6",
"callees": ["0@tests/constructors/constructor.cc:7:7"] "callees": ["0@tests/constructors/constructor.cc:7:7"],
"all_uses": ["tests/constructors/constructor.cc:6:6"]
}], }],
"variables": [{ "variables": [{
"id": 0, "id": 0,
@ -43,8 +44,8 @@ OUTPUT:
"short_name": "f", "short_name": "f",
"qualified_name": "f", "qualified_name": "f",
"declaration": "tests/constructors/constructor.cc:7:7", "declaration": "tests/constructors/constructor.cc:7:7",
"initializations": ["tests/constructors/constructor.cc:7:7"], "variable_type": 0,
"variable_type": 0 "all_uses": ["tests/constructors/constructor.cc:7:7"]
}] }]
} }
*/ */

View File

@ -1,4 +1,14 @@
// TODO: Support destructors. class Foo {
public:
Foo() {}
~Foo() {};
};
void foo() {
Foo f;
}
// TODO: Support destructors (notice how the dtor has no usages listed).
// - check if variable is a pointer. if so, do *not* insert dtor // - check if variable is a pointer. if so, do *not* insert dtor
// - check if variable is normal type. if so, insert dtor // - check if variable is normal type. if so, insert dtor
// - scan for statements that look like dtors in function def handler // - scan for statements that look like dtors in function def handler
@ -6,8 +16,50 @@
/* /*
OUTPUT: OUTPUT:
{ {
"types": [], "types": [{
"functions": [], "id": 0,
"variables": [] "usr": "c:@S@Foo",
"short_name": "Foo",
"qualified_name": "Foo",
"definition": "tests/constructors/destructor.cc:1:7",
"funcs": [0, 1],
"all_uses": ["tests/constructors/destructor.cc:1:7", "tests/constructors/destructor.cc:8:3"],
"interesting_uses": ["tests/constructors/destructor.cc:8:3"]
}],
"functions": [{
"id": 0,
"usr": "c:@S@Foo@F@Foo#",
"short_name": "Foo",
"qualified_name": "Foo::Foo",
"definition": "tests/constructors/destructor.cc:3:3",
"declaring_type": 0,
"callers": ["2@tests/constructors/destructor.cc:8:7"],
"all_uses": ["tests/constructors/destructor.cc:3:3", "tests/constructors/destructor.cc:8:7"]
}, {
"id": 1,
"usr": "c:@S@Foo@F@~Foo#",
"short_name": "~Foo",
"qualified_name": "Foo::~Foo",
"definition": "tests/constructors/destructor.cc:4:3",
"declaring_type": 0,
"all_uses": ["tests/constructors/destructor.cc:4:3"]
}, {
"id": 2,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"definition": "tests/constructors/destructor.cc:7:6",
"callees": ["0@tests/constructors/destructor.cc:8:7"],
"all_uses": ["tests/constructors/destructor.cc:7:6"]
}],
"variables": [{
"id": 0,
"usr": "c:destructor.cc@70@F@foo#@f",
"short_name": "f",
"qualified_name": "f",
"declaration": "tests/constructors/destructor.cc:8:7",
"variable_type": 0,
"all_uses": ["tests/constructors/destructor.cc:8:7"]
}]
} }
*/ */