diff options
| author | Julie Hockett <juliehockett@google.com> | 2018-02-13 15:40:40 +0000 |
|---|---|---|
| committer | Julie Hockett <juliehockett@google.com> | 2018-02-13 15:40:40 +0000 |
| commit | 9a26bf935c7ad4284762f047bc63f38e35dad1ff (patch) | |
| tree | 6e2e4e694b7603cec2c2c5fbfe69c0a30c46f4b1 | |
| parent | cfbe6ba20cbba9d4a53fa426dadb9efafccb4605 (diff) | |
| download | bcm5719-llvm-9a26bf935c7ad4284762f047bc63f38e35dad1ff.tar.gz bcm5719-llvm-9a26bf935c7ad4284762f047bc63f38e35dad1ff.zip | |
[clang-tidy] Update fuchsia-multiple-inheritance to not fail
Updating the fuchsia-multiple-inheritance to gracefully handle unknown
record types (e.g. templatized classes) by simply continuing, rather
than asserting and failing.
Fixes PR36052.
Differential Revision: https://reviews.llvm.org/D43223
llvm-svn: 325015
| -rw-r--r-- | clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp | 8 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-tidy/fuchsia-multiple-inheritance.cpp | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp index f0cc31fd50b..4893b2152e0 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp @@ -66,7 +66,7 @@ bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) { for (const auto &I : Node->bases()) { if (I.isVirtual()) continue; const auto *Ty = I.getType()->getAs<RecordType>(); - assert(Ty && "RecordType of base class is unknown"); + if (!Ty) continue; const RecordDecl *D = Ty->getDecl()->getDefinition(); if (!D) continue; const auto *Base = cast<CXXRecordDecl>(D); @@ -96,9 +96,9 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) { // concrete classes unsigned NumConcrete = 0; for (const auto &I : D->bases()) { - if (I.isVirtual() || I.getType()->getAs<TemplateTypeParmType>()) continue; + if (I.isVirtual()) continue; const auto *Ty = I.getType()->getAs<RecordType>(); - assert(Ty && "RecordType of base class is unknown"); + if (!Ty) continue; const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition()); if (!isInterface(Base)) NumConcrete++; } @@ -107,7 +107,7 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) { // non-virtual base. for (const auto &V : D->vbases()) { const auto *Ty = V.getType()->getAs<RecordType>(); - assert(Ty && "RecordType of base class is unknown"); + if (!Ty) continue; const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition()); if (!isInterface(Base)) NumConcrete++; } diff --git a/clang-tools-extra/test/clang-tidy/fuchsia-multiple-inheritance.cpp b/clang-tools-extra/test/clang-tidy/fuchsia-multiple-inheritance.cpp index 31eacdcf57b..e61e1299bac 100644 --- a/clang-tools-extra/test/clang-tidy/fuchsia-multiple-inheritance.cpp +++ b/clang-tools-extra/test/clang-tidy/fuchsia-multiple-inheritance.cpp @@ -131,3 +131,6 @@ struct D8 : V13, V14 {}; template<typename T> struct A : T {}; template<typename T> struct B : virtual T {}; + +template<typename> struct C {}; +template<typename T> struct D : C<T> {}; |

