summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulie Hockett <juliehockett@google.com>2019-07-17 17:40:53 +0000
committerJulie Hockett <juliehockett@google.com>2019-07-17 17:40:53 +0000
commit01846a88da163e528702de3f21b4eee541942463 (patch)
tree9efecdfe78d6a9042f43038c1473bc48b74139ce
parentf7df160af848f034251bcb296885db5fec5fcc4c (diff)
[clang-tidy] Exclude forward decls from fuchsia-multiple-inheritance
Addresses b39770. Differential Revision: https://reviews.llvm.org/D64813 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@366354 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clang-tidy/fuchsia/MultipleInheritanceCheck.cpp3
-rw-r--r--test/clang-tidy/fuchsia-multiple-inheritance.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
index a5f9d6ed..404b4bed 100644
--- a/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
+++ b/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
@@ -93,7 +93,8 @@ void MultipleInheritanceCheck::registerMatchers(MatchFinder *Finder) {
return;
// Match declarations which have bases.
- Finder->addMatcher(cxxRecordDecl(hasBases()).bind("decl"), this);
+ Finder->addMatcher(
+ cxxRecordDecl(allOf(hasBases(), isDefinition())).bind("decl"), this);
}
void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
diff --git a/test/clang-tidy/fuchsia-multiple-inheritance.cpp b/test/clang-tidy/fuchsia-multiple-inheritance.cpp
index fd2ed145..c7869761 100644
--- a/test/clang-tidy/fuchsia-multiple-inheritance.cpp
+++ b/test/clang-tidy/fuchsia-multiple-inheritance.cpp
@@ -41,6 +41,9 @@ public:
virtual int baz() = 0;
};
+// Shouldn't warn on forward declarations.
+class Bad_Child1;
+
// Inherits from multiple concrete classes.
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting mulitple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};