[clang-tools-extra] [clang-tidy] Moved Multiple Inheritence check from fuchsia to misc module (PR #171565)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 10 00:09:31 PST 2025
https://github.com/Bhuvan1527 updated https://github.com/llvm/llvm-project/pull/171565
>From 88b8b46bc7e4c0d2745d292479cebd387b5e73bd Mon Sep 17 00:00:00 2001
From: bhuvan1527 <balabhuvanvarma at gmail.com>
Date: Wed, 10 Dec 2025 11:28:32 +0530
Subject: [PATCH] [clang-tidy] Moved Multiple Inheritence check from fuchsia to
misc module
Resolves: [#171136](https://github.com/llvm/llvm-project/issues/171136)
Referred the issue tagged in the issue mentioned.
---
.../clang-tidy/fuchsia/CMakeLists.txt | 1 -
.../clang-tidy/fuchsia/FuchsiaTidyModule.cpp | 4 ++--
clang-tools-extra/clang-tidy/misc/CMakeLists.txt | 1 +
.../clang-tidy/misc/MiscTidyModule.cpp | 3 +++
.../MultipleInheritanceCheck.cpp | 4 ++--
.../{fuchsia => misc}/MultipleInheritanceCheck.h | 10 +++++-----
.../{fuchsia => misc}/multiple-inheritance.cpp | 16 ++++++++--------
7 files changed, 21 insertions(+), 18 deletions(-)
rename clang-tools-extra/clang-tidy/{fuchsia => misc}/MultipleInheritanceCheck.cpp (97%)
rename clang-tools-extra/clang-tidy/{fuchsia => misc}/MultipleInheritanceCheck.h (82%)
rename clang-tools-extra/test/clang-tidy/checkers/{fuchsia => misc}/multiple-inheritance.cpp (86%)
diff --git a/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt b/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
index c7234098f094a..b7e278814371e 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
@@ -7,7 +7,6 @@ add_clang_library(clangTidyFuchsiaModule STATIC
DefaultArgumentsCallsCheck.cpp
DefaultArgumentsDeclarationsCheck.cpp
FuchsiaTidyModule.cpp
- MultipleInheritanceCheck.cpp
OverloadedOperatorCheck.cpp
StaticallyConstructedObjectsCheck.cpp
TemporaryObjectsCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp b/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
index c62c43f0c42a3..284f72a8f20fd 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
@@ -10,9 +10,9 @@
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "../google/UnnamedNamespaceInHeaderCheck.h"
+#include "../misc/MultipleInheritanceCheck.h"
#include "DefaultArgumentsCallsCheck.h"
#include "DefaultArgumentsDeclarationsCheck.h"
-#include "MultipleInheritanceCheck.h"
#include "OverloadedOperatorCheck.h"
#include "StaticallyConstructedObjectsCheck.h"
#include "TemporaryObjectsCheck.h"
@@ -34,7 +34,7 @@ class FuchsiaModule : public ClangTidyModule {
"fuchsia-default-arguments-declarations");
CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
"fuchsia-header-anon-namespaces");
- CheckFactories.registerCheck<MultipleInheritanceCheck>(
+ CheckFactories.registerCheck<misc::MultipleInheritanceCheck>(
"fuchsia-multiple-inheritance");
CheckFactories.registerCheck<OverloadedOperatorCheck>(
"fuchsia-overloaded-operator");
diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index e8705aada3f22..86643eb28d65a 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -28,6 +28,7 @@ add_clang_library(clangTidyMiscModule STATIC
MisleadingBidirectionalCheck.cpp
MisleadingIdentifierCheck.cpp
MisplacedConstCheck.cpp
+ MultipleInheritanceCheck.cpp
NewDeleteOverloadsCheck.cpp
NoRecursionCheck.cpp
NonCopyableObjectsCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
index 03f25775de0bf..36e545e06bb6d 100644
--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -18,6 +18,7 @@
#include "MisleadingBidirectionalCheck.h"
#include "MisleadingIdentifierCheck.h"
#include "MisplacedConstCheck.h"
+#include "MultipleInheritanceCheck.h"
#include "NewDeleteOverloadsCheck.h"
#include "NoRecursionCheck.h"
#include "NonCopyableObjectsCheck.h"
@@ -57,6 +58,8 @@ class MiscModule : public ClangTidyModule {
CheckFactories.registerCheck<MisleadingIdentifierCheck>(
"misc-misleading-identifier");
CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
+ CheckFactories.registerCheck<MultipleInheritanceCheck>(
+ "misc-multiple-inheritance");
CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
"misc-new-delete-overloads");
CheckFactories.registerCheck<NoRecursionCheck>("misc-no-recursion");
diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.cpp
similarity index 97%
rename from clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
rename to clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.cpp
index 4a10cb4085a41..557b4559697b9 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.cpp
@@ -13,7 +13,7 @@
using namespace clang;
using namespace clang::ast_matchers;
-namespace clang::tidy::fuchsia {
+namespace clang::tidy::misc {
namespace {
AST_MATCHER(CXXRecordDecl, hasBases) {
@@ -74,4 +74,4 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
"pure virtual is discouraged");
}
-} // namespace clang::tidy::fuchsia
+} // namespace clang::tidy::misc
diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h b/clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.h
similarity index 82%
rename from clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
rename to clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.h
index 4dcbd0c7893c5..5fe1cf7c321c4 100644
--- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h
+++ b/clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H
#include "../ClangTidyCheck.h"
-namespace clang::tidy::fuchsia {
+namespace clang::tidy::misc {
/// Multiple implementation inheritance is discouraged.
///
@@ -38,6 +38,6 @@ class MultipleInheritanceCheck : public ClangTidyCheck {
llvm::DenseMap<const CXXRecordDecl *, bool> InterfaceMap;
};
-} // namespace clang::tidy::fuchsia
+} // namespace clang::tidy::misc
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H
diff --git a/clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/multiple-inheritance.cpp
similarity index 86%
rename from clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp
rename to clang-tools-extra/test/clang-tidy/checkers/misc/multiple-inheritance.cpp
index c60649f52cb94..6004ab3d812ea 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/multiple-inheritance.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
+// RUN: %check_clang_tidy %s misc-multiple-inheritance %t
class Base_A {
public:
@@ -45,16 +45,16 @@ class Interface_with_A_Parent : public Base_A {
class Bad_Child1;
// Inherits from multiple concrete classes.
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
class Bad_Child1 : public Base_A, Base_B {};
-// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
class Bad_Child2 : public Base_A, Interface_A_with_member {
virtual int foo() override { return 0; }
};
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
class Bad_Child3 : public Interface_with_A_Parent, Base_B {
virtual int baz() override { return 0; }
@@ -83,7 +83,7 @@ class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
struct B1 { int x; };
struct B2 { int x;};
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: struct D : B1, B2 {};
struct D1 : B1, B2 {};
@@ -100,7 +100,7 @@ struct D3 : V3, V4 {};
struct Base3 {};
struct V5 : virtual Base3 { virtual void f(); };
struct V6 : virtual Base3 { virtual void g(); };
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: struct D4 : V5, V6 {};
struct D4 : V5, V6 {};
@@ -118,7 +118,7 @@ struct Base6 { virtual void f(); };
struct Base7 { virtual void g(); };
struct V15 : virtual Base6 { virtual void f() = 0; };
struct V16 : virtual Base7 { virtual void g() = 0; };
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: struct D9 : V15, V16 {};
struct D9 : V15, V16 {};
@@ -159,7 +159,7 @@ namespace N {
struct S1 { int i; };
struct S2 { int i; };
-// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
+// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
struct S3 : S1, S2 {};
} // namespace N
More information about the cfe-commits
mailing list