Browse Source

dtors

pull/2/head
Jacob Dufault 8 years ago
parent
commit
d26cb81854
  1. 4
      main.cpp
  2. 11
      tests/constructors/constructor.cc
  3. 60
      tests/constructors/destructor.cc

4
main.cpp

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

11
tests/constructors/constructor.cc

@ -17,7 +17,7 @@ OUTPUT:
"qualified_name": "Foo",
"definition": "tests/constructors/constructor.cc:1:7",
"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"]
}],
"functions": [{
@ -28,14 +28,15 @@ OUTPUT:
"definition": "tests/constructors/constructor.cc:3:3",
"declaring_type": 0,
"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,
"usr": "c:@F@foo#",
"short_name": "foo",
"qualified_name": "foo",
"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": [{
"id": 0,
@ -43,8 +44,8 @@ OUTPUT:
"short_name": "f",
"qualified_name": "f",
"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"]
}]
}
*/

60
tests/constructors/destructor.cc

@ -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 normal type. if so, insert dtor
// - scan for statements that look like dtors in function def handler
@ -6,8 +16,50 @@
/*
OUTPUT:
{
"types": [],
"functions": [],
"variables": []
"types": [{
"id": 0,
"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"]
}]
}
*/
Loading…
Cancel
Save