diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -3167,8 +3167,9 @@ AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), internal::Matcher, Base) { // Check if the node is a C++ struct/union/class. - if (const auto *RD = dyn_cast(&Node)) - return Finder->classIsDerivedFrom(RD, Base, Builder, /*Directly=*/false); + if (std::is_convertible::value) + return Finder->classIsDerivedFrom(cast(&Node), Base, Builder, + /*Directly=*/false); // The node must be an Objective-C class. const auto *InterfaceDecl = cast(&Node); @@ -3186,8 +3187,9 @@ const auto M = isDerivedFrom(hasName(BaseName)); - if (const auto *RD = dyn_cast(&Node)) - return Matcher(M).matches(*RD, Finder, Builder); + if (std::is_convertible::value) + return Matcher(M).matches(cast(Node), Finder, + Builder); const auto *InterfaceDecl = cast(&Node); return Matcher(M).matches(*InterfaceDecl, Finder, Builder); @@ -3241,8 +3243,9 @@ internal::Matcher, Base, 0) { const auto M = anyOf(Base, isDerivedFrom(Base)); - if (const auto *RD = dyn_cast(&Node)) - return Matcher(M).matches(*RD, Finder, Builder); + if (std::is_convertible::value) + return Matcher(M).matches(cast(Node), Finder, + Builder); const auto *InterfaceDecl = cast(&Node); return Matcher(M).matches(*InterfaceDecl, Finder, Builder); @@ -3259,8 +3262,9 @@ const auto M = isSameOrDerivedFrom(hasName(BaseName)); - if (const auto *RD = dyn_cast(&Node)) - return Matcher(M).matches(*RD, Finder, Builder); + if (std::is_convertible::value) + return Matcher(M).matches(cast(Node), Finder, + Builder); const auto *InterfaceDecl = cast(&Node); return Matcher(M).matches(*InterfaceDecl, Finder, Builder); @@ -3292,8 +3296,9 @@ AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), internal::Matcher, Base, 0) { // Check if the node is a C++ struct/union/class. - if (const auto *RD = dyn_cast(&Node)) - return Finder->classIsDerivedFrom(RD, Base, Builder, /*Directly=*/true); + if (std::is_convertible::value) + return Finder->classIsDerivedFrom(cast(&Node), Base, Builder, + /*Directly=*/true); // The node must be an Objective-C class. const auto *InterfaceDecl = cast(&Node); @@ -3310,8 +3315,9 @@ return false; const auto M = isDirectlyDerivedFrom(hasName(BaseName)); - if (const auto *RD = dyn_cast(&Node)) - return Matcher(M).matches(*RD, Finder, Builder); + if (std::is_convertible::value) + return Matcher(M).matches(cast(Node), Finder, + Builder); const auto *InterfaceDecl = cast(&Node); return Matcher(M).matches(*InterfaceDecl, Finder, Builder); @@ -6179,12 +6185,14 @@ AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr), internal::Matcher, InnerMatcher) { - if (const auto *E = dyn_cast(&Node)) - if (E->isImplicitAccess()) + if (std::is_convertible::value) { + if (cast(&Node)->isImplicitAccess()) return false; - if (const auto *E = dyn_cast(&Node)) - if (E->isImplicitAccess()) + } else if (std::is_convertible::value) { + if (cast(&Node)->isImplicitAccess()) return false; + } return InnerMatcher.matches(*Node.getBase(), Finder, Builder); } @@ -7345,10 +7353,10 @@ FunctionDecl)) { // This is required because the spelling of the function used to determine // whether inline is specified or not differs between the polymorphic types. - if (const auto *FD = dyn_cast(&Node)) - return FD->isInlineSpecified(); - else if (const auto *NSD = dyn_cast(&Node)) - return NSD->isInline(); + if (std::is_convertible::value) + return cast(&Node)->isInlineSpecified(); + else if (std::is_convertible::value) + return cast(&Node)->isInline(); llvm_unreachable("Not a valid polymorphic type"); }