diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-31 08:11:17 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-31 08:11:17 +0000 |
commit | bfea239cafdb13256982eb891b151c5c07c1e7a9 (patch) | |
tree | 96e490ce3141c3e87de79d0d580222dfe9a57493 /lib/Sema/SemaTemplate.cpp | |
parent | 2dcc01195b7850692b9e25c65f77978e6a5a69a5 (diff) |
Typo correction for template names, e.g.,
typo.cpp:27:8: error: no template named 'basic_sting' in namespace 'std';
did you mean 'basic_string'?
std::basic_sting<char> b2;
~~~~~^~~~~~~~~~~
basic_string
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 3dd0243091..8c6aa6a7d4 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -102,7 +102,8 @@ TemplateNameKind Sema::isTemplateName(Scope *S, QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr); - LookupResult R(*this, TName, SourceLocation(), LookupOrdinaryName); + LookupResult R(*this, TName, Name.getSourceRange().getBegin(), + LookupOrdinaryName); R.suppressDiagnostics(); LookupTemplateName(R, S, SS, ObjectType, EnteringContext); if (R.empty()) @@ -202,6 +203,29 @@ void Sema::LookupTemplateName(LookupResult &Found, assert(!Found.isAmbiguous() && "Cannot handle template name-lookup ambiguities"); + if (Found.empty()) { + // If we did not find any names, attempt to correct any typos. + DeclarationName Name = Found.getLookupName(); + if (CorrectTypo(Found, S, &SS, LookupCtx)) { + FilterAcceptableTemplateNames(Context, Found); + if (!Found.empty() && isa<TemplateDecl>(*Found.begin())) { + if (LookupCtx) + Diag(Found.getNameLoc(), diag::err_no_member_template_suggest) + << Name << LookupCtx << Found.getLookupName() << SS.getRange() + << CodeModificationHint::CreateReplacement(Found.getNameLoc(), + Found.getLookupName().getAsString()); + else + Diag(Found.getNameLoc(), diag::err_no_template_suggest) + << Name << Found.getLookupName() + << CodeModificationHint::CreateReplacement(Found.getNameLoc(), + Found.getLookupName().getAsString()); + } else + Found.clear(); + } else { + Found.clear(); + } + } + FilterAcceptableTemplateNames(Context, Found); if (Found.empty()) return; |