]> granicus.if.org Git - clang/commitdiff
Fix the hasType() AST matcher to not assert when the QualType is invalid.
authorAaron Ballman <aaron@aaronballman.com>
Fri, 2 Mar 2018 19:14:21 +0000 (19:14 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 2 Mar 2018 19:14:21 +0000 (19:14 +0000)
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

index b9ce28629422612609dc6d35e1f541338359fc65..6279172732a3fc86474733941e2b6bf878b7b801 100644 (file)
@@ -2843,8 +2843,10 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher<Decl>, InnerMatcher,
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
     hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefNameDecl, ValueDecl),
     internal::Matcher<QualType>, 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