diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-09 00:57:24 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-09 00:57:24 +0000 |
commit | 2194fb6ed95595b39ec0132769e021c874adcacc (patch) | |
tree | 18fe9a081f49b4b9b1bdfdd4cf1da319a585d780 /clang/lib/Sema/SemaLookup.cpp | |
parent | c93f56d39e629b7bcd0f4657705264fcd7e47c0d (diff) | |
download | bcm5719-llvm-2194fb6ed95595b39ec0132769e021c874adcacc.tar.gz bcm5719-llvm-2194fb6ed95595b39ec0132769e021c874adcacc.zip |
When typo-correcting a function name, consider correcting to a type name
for a function-style cast.
llvm-svn: 360302
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 2b7924d244e..001a06f0bdf 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -4996,7 +4996,9 @@ FunctionCallFilterCCC::FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, : 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 @@ 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 // the current number of arguments. if (!FD || !(FD->getNumParams() >= NumArgs && |