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
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