[clang-tools-extra] [clang-tidy] Fix virtual inheritance FP in misc-multiple-inheritance (PR #186103)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 13 06:05:29 PDT 2026


================
@@ -58,16 +58,35 @@ void MultipleInheritanceCheck::registerMatchers(MatchFinder *Finder) {
 
 void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
   const auto &D = *Result.Nodes.getNodeAs<CXXRecordDecl>("decl");
-  // Check to see if the class inherits from multiple concrete classes.
-  unsigned NumConcrete =
-      llvm::count_if(D.bases(), [&](const CXXBaseSpecifier &I) {
-        return !I.isVirtual() && !isInterface(I);
-      });
+  // Collect the direct and virtual concrete bases of the class.
----------------
zeyi2 wrote:

The initial thought was that IMO the number of base classes rarely exceeds 3, so we might get less heap allocs with it. But looking at the inline comments in `SmallVector.h` it is indeed unnecessary. Thanks.

https://github.com/llvm/llvm-project/pull/186103


More information about the cfe-commits mailing list