[clang-tools-extra] Symbol tags in SymbolInformation, WorkspaceSymbol, CallHierarchyItem and TypeHierarchyItem (PR #170103)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 17 06:04:16 PDT 2026
================
@@ -153,6 +202,63 @@ bool isUniqueDefinition(const NamedDecl *Decl) {
isa<TemplateTemplateParmDecl>(Decl) || isa<ObjCCategoryDecl>(Decl) ||
isa<ObjCImplDecl>(Decl);
}
+
+// Filter symbol tags based on the presence of other tags and the kind of
+// symbol. This is needed to avoid redundant tags, e.g. final implies override,
+// override implies virtual, etc.
+SymbolTags filterSymbolTags(const NamedDecl &ND, const SymbolTags ST) {
----------------
timon-ul wrote:
Okay let me desrcribe what I mean a bit more detailed:
For the first thing I was thinking about for example the case that we have a `final` method. So the bits for `virtual` `override` and `final` are set. Currently you check `override` before `final`, so since the `override` check is performed first we unset `virtual` and are done with the `if`. Then we reach the `final` check and now we unset the `override` bit, but also the already unset `virtual` bit. So essentially double the work which is not needed. So I think this could be done a bit more efficient.
For the second thing I was thinking about the fact that every single time you are calling this function you are calling `toSymbolTagBitmask(SymbolTag)` even though they all all constants, basically recomputing the constants all the time. That being said I am not sure if this really matters, the compiler might already optimize this out so it might be fine. I have no strong opinion on this right now.
https://github.com/llvm/llvm-project/pull/170103
More information about the cfe-commits
mailing list