================
@@ -135,6 +138,42 @@ bool isFinal(const Decl *D) {
return false;
}
+// 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)
+bool isOverrides(const NamedDecl *ND) {
+ if (const auto *MD = llvm::dyn_cast<CXXMethodDecl>(ND)) {
+ 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;
+}
+
+// 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
+bool isImplements(const NamedDecl *ND) {
+ if (const auto *MD = llvm::dyn_cast<CXXMethodDecl>(ND)) {
+ if (MD->size_overridden_methods() == 0 || MD->isPureVirtual())
----------------
ArcsinX wrote:
Same here. I think we don't need to check `MD->size_overridden_methods()`
https://github.com/llvm/llvm-project/pull/170103
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits