Author: aaronballman
Date: Fri Mar  2 11:14:21 2018
New Revision: 326604

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.


Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Mar  2 11:14:21 2018
@@ -2843,8 +2843,10 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee,
     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

cfe-commits mailing list

Reply via email to