mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 17:11:59 +00:00
enable-ctors
This commit is contained in:
parent
161aab3a09
commit
8b534175f5
29
main.cpp
29
main.cpp
@ -628,16 +628,11 @@ clang::VisiterResult VarDeclVisitor(clang::Cursor cursor, clang::Cursor parent,
|
||||
}
|
||||
return clang::VisiterResult::Continue;
|
||||
|
||||
case CXCursor_CallExpr:
|
||||
case CXCursor_UnexposedExpr:
|
||||
case CXCursor_UnaryOperator:
|
||||
return clang::VisiterResult::Continue;
|
||||
/*
|
||||
|
||||
case CXCursor_CallExpr:
|
||||
// TODO: Add a test for parameters inside the call? We should probably recurse.
|
||||
InsertReference(param->db, param->func_id, cursor);
|
||||
return clang::VisiterResult::Continue;
|
||||
*/
|
||||
default:
|
||||
std::cerr << "VarDeclVisitor unhandled " << cursor.ToString() << std::endl;
|
||||
return clang::VisiterResult::Continue;
|
||||
@ -762,8 +757,25 @@ clang::VisiterResult VisitFuncDefinition(clang::Cursor cursor, clang::Cursor par
|
||||
*/
|
||||
|
||||
case CXCursor_CallExpr:
|
||||
// The called element is handled by DeclRefExpr below.
|
||||
//InsertReference(param->db, param->func_id, cursor);
|
||||
// When CallExpr points to a constructor, it does not have a child
|
||||
// DeclRefExpr which also points to the constructor. Normal function calls
|
||||
// (to a function of any type) look like this:
|
||||
//
|
||||
// CallExpr func_name
|
||||
// ... (setup this pointer)
|
||||
// *RefExpr func_name
|
||||
// ... (setup arguments)
|
||||
//
|
||||
// Constructors, on the other hand, look like this:
|
||||
//
|
||||
// CallExpr func_name
|
||||
// ... (setup arguments)
|
||||
//
|
||||
// We can't check the parent for a VarDecl, because a normal CallExpr could
|
||||
// point to that. We simply check if the cursor references a constructor,
|
||||
// and if so, insert the reference now, since it won't happen later.
|
||||
if (cursor.get_referenced().get_kind() == CXCursor_Constructor)
|
||||
InsertReference(param->db, param->func_id, cursor);
|
||||
return clang::VisiterResult::Recurse;
|
||||
|
||||
case CXCursor_MemberRefExpr:
|
||||
@ -1117,6 +1129,7 @@ int main(int argc, char** argv) {
|
||||
for (std::string path : GetFilesInFolder("tests")) {
|
||||
// TODO: Fix all existing tests.
|
||||
//if (path != "tests/constructors/constructor.cc") continue;
|
||||
//if (path != "tests/usage/type_usage_declare_local.cc") continue;
|
||||
//if (path != "tests/usage/func_usage_addr_func.cc") continue;
|
||||
//if (path != "tests/usage/type_usage_on_return_type.cc") continue;
|
||||
|
||||
|
@ -1,18 +1,14 @@
|
||||
// TODO: Reenable
|
||||
#if false
|
||||
class Foo {
|
||||
public:
|
||||
Foo() {}
|
||||
~Foo() {}
|
||||
};
|
||||
|
||||
void foo() {
|
||||
Foo f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
O2UTPUT:
|
||||
OUTPUT:
|
||||
{
|
||||
"types": [{
|
||||
"id": 0,
|
||||
@ -20,8 +16,8 @@ O2UTPUT:
|
||||
"short_name": "Foo",
|
||||
"qualified_name": "Foo",
|
||||
"definition": "tests/constructors/constructor.cc:1:7",
|
||||
"funcs": [0, 1],
|
||||
"uses": ["tests/constructors/constructor.cc:8:3"]
|
||||
"funcs": [0],
|
||||
"uses": ["tests/constructors/constructor.cc:7:3"]
|
||||
}],
|
||||
"functions": [{
|
||||
"id": 0,
|
||||
@ -30,38 +26,24 @@ O2UTPUT:
|
||||
"qualified_name": "Foo::Foo",
|
||||
"definition": "tests/constructors/constructor.cc:3:3",
|
||||
"declaring_type": 0,
|
||||
"callers": ["2@tests/constructors/constructor.cc:8:7"],
|
||||
"uses": ["tests/constructors/constructor.cc:8:7"]
|
||||
"callers": ["1@tests/constructors/constructor.cc:7:7"],
|
||||
"uses": ["tests/constructors/constructor.cc:7:7"]
|
||||
}, {
|
||||
"id": 1,
|
||||
"usr": "c:@S@Foo@F@~Foo#",
|
||||
"short_name": "~Foo",
|
||||
"qualified_name": "Foo::~Foo",
|
||||
"definition": "tests/constructors/constructor.cc:4:3",
|
||||
"declaring_type": 0
|
||||
}, {
|
||||
"id": 2,
|
||||
"usr": "c:@F@foo#",
|
||||
"short_name": "foo",
|
||||
"qualified_name": "foo",
|
||||
"definition": "tests/constructors/constructor.cc:7:6",
|
||||
"callees": ["0@tests/constructors/constructor.cc:8:7"]
|
||||
"definition": "tests/constructors/constructor.cc:6:6",
|
||||
"callees": ["0@tests/constructors/constructor.cc:7:7"]
|
||||
}],
|
||||
"variables": [{
|
||||
"id": 0,
|
||||
"usr": "c:constructor.cc@69@F@foo#@f",
|
||||
"usr": "c:constructor.cc@56@F@foo#@f",
|
||||
"short_name": "f",
|
||||
"qualified_name": "f",
|
||||
"declaration": "tests/constructors/constructor.cc:8:7",
|
||||
"initializations": ["tests/constructors/constructor.cc:8:7"],
|
||||
"declaration": "tests/constructors/constructor.cc:7:7",
|
||||
"initializations": ["tests/constructors/constructor.cc:7:7"],
|
||||
"variable_type": 0
|
||||
}]
|
||||
}
|
||||
|
||||
OUTPUT:
|
||||
{
|
||||
"types": [],
|
||||
"functions": [],
|
||||
"variables": []
|
||||
}
|
||||
*/
|
@ -29,7 +29,13 @@ OUTPUT:
|
||||
"usr": "c:@F@Foo#",
|
||||
"short_name": "Foo",
|
||||
"qualified_name": "Foo",
|
||||
"definition": "tests/usage/type_usage_declare_local.cc:4:6"
|
||||
"definition": "tests/usage/type_usage_declare_local.cc:4:6",
|
||||
"callees": ["1@tests/usage/type_usage_declare_local.cc:6:19"]
|
||||
}, {
|
||||
"id": 1,
|
||||
"usr": "c:@S@ImplementedType@F@ImplementedType#",
|
||||
"callers": ["0@tests/usage/type_usage_declare_local.cc:6:19"],
|
||||
"uses": ["tests/usage/type_usage_declare_local.cc:6:19"]
|
||||
}],
|
||||
"variables": [{
|
||||
"id": 0,
|
||||
|
@ -22,7 +22,13 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#&$@S@Type#&1S1_#",
|
||||
"short_name": "foo",
|
||||
"qualified_name": "foo",
|
||||
"definition": "tests/usage/type_usage_declare_qualifiers.cc:3:6"
|
||||
"definition": "tests/usage/type_usage_declare_qualifiers.cc:3:6",
|
||||
"callees": ["1@tests/usage/type_usage_declare_qualifiers.cc:4:8"]
|
||||
}, {
|
||||
"id": 1,
|
||||
"usr": "c:@S@Type@F@Type#",
|
||||
"callers": ["0@tests/usage/type_usage_declare_qualifiers.cc:4:8"],
|
||||
"uses": ["tests/usage/type_usage_declare_qualifiers.cc:4:8"]
|
||||
}],
|
||||
"variables": [{
|
||||
"id": 0,
|
||||
|
@ -45,8 +45,16 @@ OUTPUT:
|
||||
"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"]
|
||||
"callees": ["0@tests/usage/usage_inside_of_call.cc:12:3", "1@tests/usage/usage_inside_of_call.cc:12:14", "3@tests/usage/usage_inside_of_call.cc:12:22"]
|
||||
}, {
|
||||
"id": 3,
|
||||
"usr": "c:@S@Foo@F@Foo#",
|
||||
"callers": ["2@tests/usage/usage_inside_of_call.cc:12:22"],
|
||||
"uses": ["tests/usage/usage_inside_of_call.cc:12:22"]
|
||||
}],
|
||||
|
||||
|
||||
|
||||
"variables": [{
|
||||
"id": 0,
|
||||
"usr": "c:@S@Foo@static_var",
|
||||
|
@ -51,7 +51,12 @@ OUTPUT:
|
||||
"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"]
|
||||
"callees": ["3@tests/usage/var_usage_class_member.cc:11:7", "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"]
|
||||
}, {
|
||||
"id": 3,
|
||||
"usr": "c:@S@Foo@F@Foo#",
|
||||
"callers": ["2@tests/usage/var_usage_class_member.cc:11:7"],
|
||||
"uses": ["tests/usage/var_usage_class_member.cc:11:7"]
|
||||
}],
|
||||
"variables": [{
|
||||
"id": 0,
|
||||
|
Loading…
Reference in New Issue
Block a user