do not index namespace ref

This commit is contained in:
Jacob Dufault 2017-03-05 22:34:17 -08:00
parent f7e2b20059
commit 49c6f7787a
4 changed files with 63 additions and 107 deletions

View File

@ -509,7 +509,7 @@ optional<TypeId> AddDeclUsages(IndexedFile* db, clang::Cursor decl_cursor,
// The second TypeRef is an uninteresting usage.
bool process_last_type_ref = true;
if (IsTypeDefinition(semantic_container) && !IsTypeDefinition(lexical_container)) {
//
// In some code, such as the following example, we receive a cursor which is not
// a definition and is not associated with a definition due to an error condition.
@ -549,7 +549,7 @@ optional<TypeId> AddDeclUsages(IndexedFile* db, clang::Cursor decl_cursor,
is_interesting == false ||
param.previous_cursor.has_value() == false ||
(param.previous_cursor.value().get_kind() == CXCursor_TypeRef ||
param.previous_cursor.value().get_kind() == CXCursor_TemplateRef));
param.previous_cursor.value().get_kind() == CXCursor_TemplateRef));
}
return param.initial_type;
@ -639,7 +639,7 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
IndexedFuncDef* func_def = db->Resolve(func_id);
Location decl_loc = db->id_cache.Resolve(decl->loc, false /*interesting*/);
func_def->uses.push_back(decl_loc);
// We don't actually need to know the return type, but we need to mark it
// as an interesting usage.
@ -866,6 +866,12 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re
clang::Cursor cursor(ref->cursor);
switch (ref->referencedEntity->kind) {
case CXIdxEntity_CXXNamespace:
{
// We don't index namespace usages.
break;
}
case CXIdxEntity_EnumConstant:
case CXIdxEntity_CXXStaticVariable:
case CXIdxEntity_Variable:

View File

@ -97,7 +97,7 @@ int main(int argc, char** argv) {
//if (path != "tests/templates/specialized_func_definition.cc") continue;
//if (path != "tests/constructors/invalid_reference.cc") continue;
//if (path == "tests/inheritance/class_inherit_templated_parent.cc") continue;
//if (path != "tests/foobar.cc") continue;
//if (path != "tests/namespaces/namespace_reference.cc") continue;
if (path == "tests/stl.cc") continue;
//if (path != "tests/templates/template_class_type_usage_folded_into_one.cc") continue;

View File

@ -60,106 +60,4 @@ OUTPUT:
}]
}
*/
#if false
namespace ns {
enum VarType {};
template<typename _>
struct Holder {
static constexpr VarType static_var = (VarType)0x0;
};
template<typename _>
const typename VarType Holder<_>::static_var;
int Foo = Holder<int>::static_var;
int Foo2 = Holder<int>::static_var;
}
#endif
/*
OUTPUT:
{
"types": [{
"id": 0,
"usr": "c:@N@ns@E@VarType",
"short_name": "VarType",
"qualified_name": "ns::VarType",
"definition": "1:2:8",
"uses": ["*1:2:8", "*1:6:22", "1:6:44", "*1:10:18"]
}, {
"id": 1,
"usr": "c:@N@ns@ST>1#T@Holder",
"short_name": "Holder",
"qualified_name": "ns::Holder",
"definition": "1:5:10",
"vars": [0],
"uses": ["*1:5:10", "*1:10:26", "1:13:13", "1:14:14"]
}],
"functions": [],
"variables": [{
"id": 0,
"usr": "c:@N@ns@ST>1#T@Holder@static_var",
"short_name": "static_var",
"qualified_name": "ns::Holder::static_var",
"declaration": "1:6:30",
"definition": "1:10:37",
"variable_type": 0,
"declaring_type": 1,
"uses": ["1:6:30", "1:10:37"]
}, {
"id": 1,
"usr": "c:@N@ns@Foo",
"short_name": "Foo",
"qualified_name": "ns::Foo",
"definition": "1:13:7",
"uses": ["1:13:7"]
}, {
"id": 2,
"usr": "c:@N@ns@S@Holder>#I@static_var",
"short_name": "static_var",
"qualified_name": "static_var",
"definition": "1:10:37",
"variable_type": 0,
"declaring_type": 2,
"uses": ["1:13:26", "1:10:37", "1:14:27"]
}, {
"id": 3,
"usr": "c:@N@ns@Foo2",
"short_name": "Foo2",
"qualified_name": "ns::Foo2",
"definition": "1:14:7",
"uses": ["1:14:7"]
}]
}
*/
*/

View File

@ -0,0 +1,52 @@
namespace ns {
int Foo;
void Accept(int a) {}
}
void Runner() {
ns::Accept(ns::Foo);
using namespace ns;
Accept(Foo);
}
/*
OUTPUT:
{
"types": [],
"functions": [{
"id": 0,
"usr": "c:@N@ns@F@Accept#I#",
"short_name": "Accept",
"qualified_name": "ns::Accept",
"definition": "1:3:8",
"callers": ["1@1:7:7", "1@1:9:3"],
"uses": ["1:3:8", "1:7:7", "1:9:3"]
}, {
"id": 1,
"usr": "c:@F@Runner#",
"short_name": "Runner",
"qualified_name": "Runner",
"definition": "1:6:6",
"callees": ["0@1:7:7", "0@1:9:3"],
"uses": ["1:6:6"]
}],
"variables": [{
"id": 0,
"usr": "c:@N@ns@Foo",
"short_name": "Foo",
"qualified_name": "ns::Foo",
"definition": "1:2:7",
"uses": ["1:2:7", "1:7:18", "1:9:10"]
}, {
"id": 1,
"usr": "c:namespace_reference.cc@42@N@ns@F@Accept#I#@a",
"short_name": "a",
"qualified_name": "a",
"definition": "1:3:19",
"uses": ["1:3:19"]
}]
}
*/