From ee78b527ae820dbd5a9c3a36a722935838736f3e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 19 Dec 2017 22:20:44 -0800 Subject: [PATCH] [indexer] Treat empty short_name as implicit call which should not be included in all_symbols std::vector a = f(); // besides f, there is an implicit move constructor vector(vector&&) We expect finding references on `f` takes us to `f`, not to `vector(vector&&)` --- src/indexer.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index b8aa24b3..b8df8278 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1478,12 +1478,16 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { // or implicit), but libclang only supports implicit for objective-c. bool is_implicit = CanBeCalledImplicitly(ref->referencedEntity->kind) && - // For explicit destructor call, ref->cursor may be "~" while called->def.short_name is "~A" - // "~A" is not a substring of ref->cursor, but we should take this case as not `is_implicit`. - called->def.short_name.size() && called->def.short_name[0] != '~' && - - !CursorSpellingContainsString(ref->cursor, param->tu->cx_tu, - called->def.short_name); + // Treats empty short_name as an implicit call like implicit move + // constructor in `vector a = f();` + (called->def.short_name.empty() || + // For explicit destructor call, ref->cursor may be "~" while + // called->def.short_name is "~A" + // "~A" is not a substring of ref->cursor, but we should take this + // case as not `is_implicit`. + (called->def.short_name[0] != '~' && + !CursorSpellingContainsString(ref->cursor, param->tu->cx_tu, + called->def.short_name))); if (IsFunctionCallContext(ref->container->cursor.kind)) { IndexFuncId caller_id = db->ToFuncId(ref->container->cursor);