[indexer] Treat empty short_name as implicit call which should not be included in all_symbols

std::vector<int> a = f(); // besides f, there is an implicit move constructor vector(vector<T>&&)
We expect finding references on `f` takes us to `f`, not to `vector(vector<T>&&)`
This commit is contained in:
Fangrui Song 2017-12-19 22:20:44 -08:00 committed by Jacob Dufault
parent 1dfa88ed1c
commit ee78b527ae

View File

@ -1478,12 +1478,16 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
// or implicit), but libclang only supports implicit for objective-c. // or implicit), but libclang only supports implicit for objective-c.
bool is_implicit = bool is_implicit =
CanBeCalledImplicitly(ref->referencedEntity->kind) && CanBeCalledImplicitly(ref->referencedEntity->kind) &&
// For explicit destructor call, ref->cursor may be "~" while called->def.short_name is "~A" // Treats empty short_name as an implicit call like implicit move
// "~A" is not a substring of ref->cursor, but we should take this case as not `is_implicit`. // constructor in `vector<int> a = f();`
called->def.short_name.size() && called->def.short_name[0] != '~' && (called->def.short_name.empty() ||
// For explicit destructor call, ref->cursor may be "~" while
!CursorSpellingContainsString(ref->cursor, param->tu->cx_tu, // called->def.short_name is "~A"
called->def.short_name); // "~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)) { if (IsFunctionCallContext(ref->container->cursor.kind)) {
IndexFuncId caller_id = db->ToFuncId(ref->container->cursor); IndexFuncId caller_id = db->ToFuncId(ref->container->cursor);