diff --git a/src/command_line.cc b/src/command_line.cc index b7b49526..088691cc 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -171,6 +171,8 @@ void EmitSemanticHighlighting(QueryDatabase* db, QueryFunc* func = &db->funcs[sym.idx.idx]; if (!func->def) continue; // applies to for loop + if (func->def->is_operator) + continue; // applies to for loop is_type_member = func->def->declaring_type.has_value(); break; } diff --git a/src/indexer.cc b/src/indexer.cc index 02df4eb4..6b321b51 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1188,6 +1188,9 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { if (!is_template_specialization) { func->def.short_name = decl->entityInfo->name; + // Set the |is_operator| flag to true if the function name starts with "operator" + func->def.is_operator = func->def.short_name.compare(0, 8, "operator") == 0; + // Build detailed name. The type desc looks like void (void *). We // insert the qualified name before the first '('. std::string qualified_name = diff --git a/src/indexer.h b/src/indexer.h index 3d880493..3230eb38 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -267,6 +267,9 @@ struct FuncDefDefinitionData { // Functions that this function calls. std::vector callees; + // Used for semantic highlighting + bool is_operator = false; + FuncDefDefinitionData() {} // For reflection. FuncDefDefinitionData(const std::string& usr) : usr(usr) { // assert(usr.size() > 0); @@ -308,6 +311,7 @@ void Reflect( REFLECT_MEMBER(base); REFLECT_MEMBER(locals); REFLECT_MEMBER(callees); + REFLECT_MEMBER(is_operator); REFLECT_MEMBER_END(); } diff --git a/src/query.cc b/src/query.cc index b43eee68..03d27477 100644 --- a/src/query.cc +++ b/src/query.cc @@ -50,6 +50,7 @@ optional ToQuery(const IdMap& id_map, result.base = id_map.ToQuery(func.base); result.locals = id_map.ToQuery(func.locals); result.callees = id_map.ToQuery(func.callees); + result.is_operator = func.is_operator; return result; } diff --git a/src/serializer.cc b/src/serializer.cc index 34397a98..17ebf222 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -118,6 +118,7 @@ template void Reflect(TVisitor& visitor, IndexFunc& value) { REFLECT_MEMBER_START(); REFLECT_MEMBER2("id", value.id); + REFLECT_MEMBER2("is_operator", value.def.is_operator); REFLECT_MEMBER2("usr", value.def.usr); REFLECT_MEMBER2("short_name", value.def.short_name); REFLECT_MEMBER2("detailed_name", value.def.detailed_name);