diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -165,8 +165,11 @@ } auto isCallReturningOptional() { - return callExpr(callee(functionDecl(returns(anyOf( - optionalOrAliasType(), referenceType(pointee(optionalOrAliasType()))))))); + // We must extract this to a variable to specify its type, because otherwise + // multiple overloads of `hasType` match. + ast_matchers::internal::Matcher typeMatcher = anyOf( + optionalOrAliasType(), referenceType(pointee(optionalOrAliasType()))); + return callExpr(hasType(typeMatcher)); } /// Creates a symbolic value for an `optional` value using `HasValueVal` as the