[clang-tools-extra] Symbol tags in SymbolInformation, WorkspaceSymbol, CallHierarchyItem and TypeHierarchyItem (PR #170103)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 25 05:33:13 PDT 2026
================
@@ -159,6 +172,45 @@ SymbolTags toSymbolTagBitmask(const SymbolTag ST) {
return (1 << static_cast<unsigned>(ST));
}
+bool isOverrides(const NamedDecl *ND) {
+ if (const auto *MD = llvm::dyn_cast<CXXMethodDecl>(ND)) {
+ // A method "overrides" if:
+ // 1. It overrides at least one method
+ // 2. At least one of the overridden methods is virtual (but NOT pure
+ // virtual)
+
+ if (MD->size_overridden_methods() == 0)
+ return false;
+
+ for (const auto Overridden : MD->overridden_methods()) {
+ // Check if the overridden method is virtual but not pure virtual
+ if (Overridden->isVirtual() && !Overridden->isPureVirtual())
+ return true;
+ }
+ return false;
+ }
+ return false;
+}
+
+bool isImplements(const NamedDecl *ND) {
+ if (const auto *MD = llvm::dyn_cast<CXXMethodDecl>(ND)) {
+ // A method "implements" pure virtual methods from base classes if:
+ // 1. It overrides at least one method
+ // 2. It is NOT itself pure virtual (i.e., it has a concrete implementation)
+ // 3. ALL overridden methods are pure virtual
----------------
timon-ul wrote:
I am a bit confused by this third requirement. Let's say we overwrite 2 functions, one pure virtual and one not. Wouldn't it be both, an overriding and an implementing function? Or is there a good reason to not classify it as such?
https://github.com/llvm/llvm-project/pull/170103
More information about the cfe-commits
mailing list