[clang-tidy] Exclude forward decls from fuchsia-multiple-inheritance
authorJulie Hockett <juliehockett@google.com>
Wed, 17 Jul 2019 17:40:53 +0000 (17:40 +0000)
committerJulie Hockett <juliehockett@google.com>
Wed, 17 Jul 2019 17:40:53 +0000 (17:40 +0000)
Addresses b39770.

Differential Revision: https://reviews.llvm.org/D64813

llvm-svn: 366354

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
clang-tools-extra/test/clang-tidy/fuchsia-multiple-inheritance.cpp

index a5f9d6e..404b4be 100644 (file)
@@ -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) {
index fd2ed14..c786976 100644 (file)
@@ -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 {};