From c08ce0cfcf5ab93405ad9d1c5e185b55a672bccb Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 2 Mar 2018 19:14:21 +0000 Subject: [PATCH] Fix the hasType() AST matcher to not assert when the QualType is invalid. There's not a particularly good way to test this with the AST matchers unit tests because the only way to get an invalid type (that I can devise) involves creating parse errors, which the test harness always treats as a failure. Instead, a clang-tidy test case will be added in a follow-up commit based on the original bug report. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326604 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/ASTMatchers/ASTMatchers.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index b9ce286294..6279172732 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -2843,8 +2843,10 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher, InnerMatcher, AST_POLYMORPHIC_MATCHER_P_OVERLOAD( hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefNameDecl, ValueDecl), internal::Matcher, InnerMatcher, 0) { - return InnerMatcher.matches(internal::getUnderlyingType(Node), - Finder, Builder); + QualType QT = internal::getUnderlyingType(Node); + if (!QT.isNull()) + return InnerMatcher.matches(QT, Finder, Builder); + return false; } /// \brief Overloaded to match the declaration of the expression's or value -- 2.40.0