summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-31 08:11:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-31 08:11:17 +0000
commitff18cc1141117b74a8b3eeb61b2d0f43cd83698b (patch)
tree8196bd694f0082c64617bccff1f695fc2b2a8855 /clang/lib/Sema
parent5f8a005d38fa8c8794c2f4d58ea2afb76894c017 (diff)
downloadbcm5719-llvm-ff18cc1141117b74a8b3eeb61b2d0f43cd83698b.tar.gz
bcm5719-llvm-ff18cc1141117b74a8b3eeb61b2d0f43cd83698b.zip
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 llvm-svn: 92348
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 3dd02430919..8c6aa6a7d4a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud