Skip to content

Commit 88b8b46

Browse files
committed
[clang-tidy] Moved Multiple Inheritence check from fuchsia to misc module
Resolves: [#171136](#171136) Referred the issue tagged in the issue mentioned.
1 parent b3a5ad1 commit 88b8b46

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ add_clang_library(clangTidyFuchsiaModule STATIC
77
DefaultArgumentsCallsCheck.cpp
88
DefaultArgumentsDeclarationsCheck.cpp
99
FuchsiaTidyModule.cpp
10-
MultipleInheritanceCheck.cpp
1110
OverloadedOperatorCheck.cpp
1211
StaticallyConstructedObjectsCheck.cpp
1312
TemporaryObjectsCheck.cpp

clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
1212
#include "../google/UnnamedNamespaceInHeaderCheck.h"
13+
#include "../misc/MultipleInheritanceCheck.h"
1314
#include "DefaultArgumentsCallsCheck.h"
1415
#include "DefaultArgumentsDeclarationsCheck.h"
15-
#include "MultipleInheritanceCheck.h"
1616
#include "OverloadedOperatorCheck.h"
1717
#include "StaticallyConstructedObjectsCheck.h"
1818
#include "TemporaryObjectsCheck.h"
@@ -34,7 +34,7 @@ class FuchsiaModule : public ClangTidyModule {
3434
"fuchsia-default-arguments-declarations");
3535
CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
3636
"fuchsia-header-anon-namespaces");
37-
CheckFactories.registerCheck<MultipleInheritanceCheck>(
37+
CheckFactories.registerCheck<misc::MultipleInheritanceCheck>(
3838
"fuchsia-multiple-inheritance");
3939
CheckFactories.registerCheck<OverloadedOperatorCheck>(
4040
"fuchsia-overloaded-operator");

clang-tools-extra/clang-tidy/misc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_clang_library(clangTidyMiscModule STATIC
2828
MisleadingBidirectionalCheck.cpp
2929
MisleadingIdentifierCheck.cpp
3030
MisplacedConstCheck.cpp
31+
MultipleInheritanceCheck.cpp
3132
NewDeleteOverloadsCheck.cpp
3233
NoRecursionCheck.cpp
3334
NonCopyableObjectsCheck.cpp

clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "MisleadingBidirectionalCheck.h"
1919
#include "MisleadingIdentifierCheck.h"
2020
#include "MisplacedConstCheck.h"
21+
#include "MultipleInheritanceCheck.h"
2122
#include "NewDeleteOverloadsCheck.h"
2223
#include "NoRecursionCheck.h"
2324
#include "NonCopyableObjectsCheck.h"
@@ -57,6 +58,8 @@ class MiscModule : public ClangTidyModule {
5758
CheckFactories.registerCheck<MisleadingIdentifierCheck>(
5859
"misc-misleading-identifier");
5960
CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
61+
CheckFactories.registerCheck<MultipleInheritanceCheck>(
62+
"misc-multiple-inheritance");
6063
CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
6164
"misc-new-delete-overloads");
6265
CheckFactories.registerCheck<NoRecursionCheck>("misc-no-recursion");

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp renamed to clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using namespace clang;
1414
using namespace clang::ast_matchers;
1515

16-
namespace clang::tidy::fuchsia {
16+
namespace clang::tidy::misc {
1717

1818
namespace {
1919
AST_MATCHER(CXXRecordDecl, hasBases) {
@@ -74,4 +74,4 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
7474
"pure virtual is discouraged");
7575
}
7676

77-
} // namespace clang::tidy::fuchsia
77+
} // namespace clang::tidy::misc

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h renamed to clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

14-
namespace clang::tidy::fuchsia {
14+
namespace clang::tidy::misc {
1515

1616
/// Multiple implementation inheritance is discouraged.
1717
///
@@ -38,6 +38,6 @@ class MultipleInheritanceCheck : public ClangTidyCheck {
3838
llvm::DenseMap<const CXXRecordDecl *, bool> InterfaceMap;
3939
};
4040

41-
} // namespace clang::tidy::fuchsia
41+
} // namespace clang::tidy::misc
4242

43-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
43+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H

clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp renamed to clang-tools-extra/test/clang-tidy/checkers/misc/multiple-inheritance.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
1+
// RUN: %check_clang_tidy %s misc-multiple-inheritance %t
22

33
class Base_A {
44
public:
@@ -45,16 +45,16 @@ class Interface_with_A_Parent : public Base_A {
4545
class Bad_Child1;
4646

4747
// Inherits from multiple concrete classes.
48-
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
48+
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
4949
// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
5050
class Bad_Child1 : public Base_A, Base_B {};
5151

52-
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
52+
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
5353
class Bad_Child2 : public Base_A, Interface_A_with_member {
5454
virtual int foo() override { return 0; }
5555
};
5656

57-
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
57+
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
5858
// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
5959
class Bad_Child3 : public Interface_with_A_Parent, Base_B {
6060
virtual int baz() override { return 0; }
@@ -83,7 +83,7 @@ class Good_Child3 : public Base_A_child, Interface_C, Interface_B {
8383

8484
struct B1 { int x; };
8585
struct B2 { int x;};
86-
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
86+
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
8787
// CHECK-NEXT: struct D : B1, B2 {};
8888
struct D1 : B1, B2 {};
8989

@@ -100,7 +100,7 @@ struct D3 : V3, V4 {};
100100
struct Base3 {};
101101
struct V5 : virtual Base3 { virtual void f(); };
102102
struct V6 : virtual Base3 { virtual void g(); };
103-
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
103+
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
104104
// CHECK-NEXT: struct D4 : V5, V6 {};
105105
struct D4 : V5, V6 {};
106106

@@ -118,7 +118,7 @@ struct Base6 { virtual void f(); };
118118
struct Base7 { virtual void g(); };
119119
struct V15 : virtual Base6 { virtual void f() = 0; };
120120
struct V16 : virtual Base7 { virtual void g() = 0; };
121-
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
121+
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
122122
// CHECK-NEXT: struct D9 : V15, V16 {};
123123
struct D9 : V15, V16 {};
124124

@@ -159,7 +159,7 @@ namespace N {
159159
struct S1 { int i; };
160160
struct S2 { int i; };
161161

162-
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
162+
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
163163
struct S3 : S1, S2 {};
164164

165165
} // namespace N

0 commit comments

Comments
 (0)