|
@@ -4996,7 +4996,9 @@ FunctionCallFilterCCC::FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs,
|
|
: NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
|
|
: NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
|
|
CurContext(SemaRef.CurContext), MemberFn(ME) {
|
|
CurContext(SemaRef.CurContext), MemberFn(ME) {
|
|
WantTypeSpecifiers = false;
|
|
WantTypeSpecifiers = false;
|
|
- WantFunctionLikeCasts = SemaRef.getLangOpts().CPlusPlus && NumArgs == 1;
|
|
|
|
|
|
+ WantFunctionLikeCasts = SemaRef.getLangOpts().CPlusPlus &&
|
|
|
|
+ !HasExplicitTemplateArgs && NumArgs == 1;
|
|
|
|
+ WantCXXNamedCasts = HasExplicitTemplateArgs && NumArgs == 1;
|
|
WantRemainingKeywords = false;
|
|
WantRemainingKeywords = false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5025,6 +5027,13 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // A typo for a function-style cast can look like a function call in C++.
|
|
|
|
+ if ((HasExplicitTemplateArgs ? getAsTypeTemplateDecl(ND) != nullptr
|
|
|
|
+ : isa<TypeDecl>(ND)) &&
|
|
|
|
+ CurContext->getParentASTContext().getLangOpts().CPlusPlus)
|
|
|
|
+ // Only a class or class template can take two or more arguments.
|
|
|
|
+ return NumArgs <= 1 || HasExplicitTemplateArgs || isa<CXXRecordDecl>(ND);
|
|
|
|
+
|
|
// Skip the current candidate if it is not a FunctionDecl or does not accept
|
|
// Skip the current candidate if it is not a FunctionDecl or does not accept
|
|
// the current number of arguments.
|
|
// the current number of arguments.
|
|
if (!FD || !(FD->getNumParams() >= NumArgs &&
|
|
if (!FD || !(FD->getNumParams() >= NumArgs &&
|