================
@@ -208,21 +266,103 @@ SymbolTags computeSymbolTags(const NamedDecl &ND) {
return Result;
}
+// Filter symbol tags based on the presence of other tags and the kind of
+// symbol. This is needed to avoid redundant tags.
+SymbolTags filterSymbolTags(const NamedDecl &ND, const SymbolTags ST) {
+ SymbolTags Result = ST;
+
+ if (not isa<CXXMethodDecl>(ND))
+ return Result;
+
+ if (ST & toSymbolTagBitmask(SymbolTag::Overrides)) {
+ // Overrides means that ND overrides an existing implementation of a
virtual
+ // method in a base class. If a symbol is marked as Overrides, the tags
+ // Virtual, Declaration and Definition should be removed, as the Overrides
+ // tag implies that the symbol has/is virtual/declaration/definition.
+ Result &= ~toSymbolTagBitmask(SymbolTag::Virtual);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Declaration);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Definition);
+ }
+ if (ST & toSymbolTagBitmask(SymbolTag::Implements)) {
+ // Implements means that ND implements an existing pure virtual method in a
+ // base class. If a symbol is marked as Implements, the tags Virtual,
+ // Declaration, Definition and Overrides should be removed, as the
+ // Implements tag implies that the symbol is virtual, is a declaration, is
a
+ // definition, and overrides a method.
+ Result &= ~toSymbolTagBitmask(SymbolTag::Virtual);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Declaration);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Definition);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Overrides);
+ }
+ if (ST & toSymbolTagBitmask(SymbolTag::Virtual)) {
+ // Virtual means that ND is a virtual method that does not override any
+ // method in a base class. If a symbol is marked as Virtual, the tags
+ // Declaration and Definition should be removed, as the Virtual tag implies
+ // that the symbol is a declaration/definition.
+ Result &= ~toSymbolTagBitmask(SymbolTag::Declaration);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Definition);
+ }
+ if (ST & toSymbolTagBitmask(SymbolTag::Abstract)) {
+ // Abstract means that ND is a pure virtual method. If a symbol is marked
as
+ // Abstract, the tags Virtual, Declaration and Definition should be
removed,
+ // as the Abstract tag implies that the symbol is virtual and a
+ // declaration/definition.
+ Result &= ~toSymbolTagBitmask(SymbolTag::Virtual);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Declaration);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Definition);
+ }
+ if (ST & toSymbolTagBitmask(SymbolTag::Final)) {
+ // Final means that ND is a method that cannot be overridden by any method
+ // in a derived class. If a symbol is marked as Final, the tags Virtual and
+ // Overrides should be removed, as the Final tag implies that the symbol is
+ // virtual.
+ Result &= ~toSymbolTagBitmask(SymbolTag::Virtual);
+ Result &= ~toSymbolTagBitmask(SymbolTag::Overrides);
+ }
+ return Result;
+}
+
+std::vector<SymbolTag> expandTagBitmask(const SymbolTags symbolTags) {
+ std::vector<SymbolTag> Tags;
+
+ if (symbolTags == 0)
+ return Tags;
+
+ // No filtering required since this function is only used for Symbols from
the
+ // index, which have already been filtered in getSymbolTags(const NamedDecl
+ // &ND).
+
----------------
ratzdi wrote:
done.
https://github.com/llvm/llvm-project/pull/170103
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits