When typo-correcting a function name, consider correcting to a type name
for a function-style cast.
llvm-svn: 360302
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 2b7924d..001a06f 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -4996,7 +4996,9 @@
: NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
CurContext(SemaRef.CurContext), MemberFn(ME) {
WantTypeSpecifiers = false;
- WantFunctionLikeCasts = SemaRef.getLangOpts().CPlusPlus && NumArgs == 1;
+ WantFunctionLikeCasts = SemaRef.getLangOpts().CPlusPlus &&
+ !HasExplicitTemplateArgs && NumArgs == 1;
+ WantCXXNamedCasts = HasExplicitTemplateArgs && NumArgs == 1;
WantRemainingKeywords = false;
}
@@ -5025,6 +5027,13 @@
}
}
+ // 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
// the current number of arguments.
if (!FD || !(FD->getNumParams() >= NumArgs &&