[clang-tools-extra] r324432 - [clang-tidy] Update fuchsia-multiple-inheritance to check for templates

Julie Hockett via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 16:33:51 PST 2018


Author: juliehockett
Date: Tue Feb  6 16:33:50 2018
New Revision: 324432

URL: http://llvm.org/viewvc/llvm-project?rev=324432&view=rev
Log:
[clang-tidy] Update fuchsia-multiple-inheritance to check for templates

Updating fuchsia-multiple-inheritance to not crash when a record
inherits a template.

Fixes PR36052.

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

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

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp?rev=324432&r1=324431&r2=324432&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp Tue Feb  6 16:33:50 2018
@@ -64,7 +64,7 @@ bool MultipleInheritanceCheck::isInterfa
 
   // To be an interface, all base classes must be interfaces as well.
   for (const auto &I : Node->bases()) {
-    if (I.isVirtual()) continue;  
+    if (I.isVirtual()) continue;
     const auto *Ty = I.getType()->getAs<RecordType>();
     assert(Ty && "RecordType of base class is unknown");
     const RecordDecl *D = Ty->getDecl()->getDefinition();
@@ -96,7 +96,7 @@ void MultipleInheritanceCheck::check(con
     // concrete classes
     unsigned NumConcrete = 0;
     for (const auto &I : D->bases()) {
-      if (I.isVirtual()) continue;
+      if (I.isVirtual() || I.getType()->getAs<TemplateTypeParmType>()) continue;
       const auto *Ty = I.getType()->getAs<RecordType>();
       assert(Ty && "RecordType of base class is unknown");
       const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());

Modified: clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp?rev=324432&r1=324431&r2=324432&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-multiple-inheritance.cpp Tue Feb  6 16:33:50 2018
@@ -129,3 +129,5 @@ struct V13 : virtual Static_Base_2 { sta
 struct V14 : virtual Static_Base_2 { static void g(); };
 struct D8 : V13, V14 {};
 
+template<typename T> struct A : T {};
+template<typename T> struct B : virtual T {};




More information about the cfe-commits mailing list