[cfe-commits] r92350 - in /cfe/trunk: lib/Sema/SemaCXXScopeSpec.cpp test/FixIt/typo.cpp
Douglas Gregor
dgregor at apple.com
Thu Dec 31 00:26:35 PST 2009
Author: dgregor
Date: Thu Dec 31 02:26:35 2009
New Revision: 92350
URL: http://llvm.org/viewvc/llvm-project?rev=92350&view=rev
Log:
Typo correction for identifiers within nested name specifiers, e.g.,
typo.cpp:18:1: error: use of undeclared identifier 'other_std'; did
you mean 'otherstd'?
other_std::strng str1;
^~~~~~~~~
otherstd
Modified:
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/test/FixIt/typo.cpp
Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=92350&r1=92349&r2=92350&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Thu Dec 31 02:26:35 2009
@@ -428,6 +428,28 @@
}
// FIXME: Deal with ambiguities cleanly.
+
+ if (Found.empty() && !ErrorRecoveryLookup) {
+ // We haven't found anything, and we're not recovering from a
+ // different kind of error, so look for typos.
+ DeclarationName Name = Found.getLookupName();
+ if (CorrectTypo(Found, S, &SS, LookupCtx, EnteringContext) &&
+ Found.isSingleResult() &&
+ isAcceptableNestedNameSpecifier(Found.getAsSingle<NamedDecl>())) {
+ if (LookupCtx)
+ Diag(Found.getNameLoc(), diag::err_no_member_suggest)
+ << Name << LookupCtx << Found.getLookupName() << SS.getRange()
+ << CodeModificationHint::CreateReplacement(Found.getNameLoc(),
+ Found.getLookupName().getAsString());
+ else
+ Diag(Found.getNameLoc(), diag::err_undeclared_var_use_suggest)
+ << Name << Found.getLookupName()
+ << CodeModificationHint::CreateReplacement(Found.getNameLoc(),
+ Found.getLookupName().getAsString());
+ } else
+ Found.clear();
+ }
+
NamedDecl *SD = Found.getAsSingle<NamedDecl>();
if (isAcceptableNestedNameSpecifier(SD)) {
if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) {
Modified: cfe/trunk/test/FixIt/typo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo.cpp?rev=92350&r1=92349&r2=92350&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/typo.cpp (original)
+++ cfe/trunk/test/FixIt/typo.cpp Thu Dec 31 02:26:35 2009
@@ -15,7 +15,8 @@
using namespace std;
-otherstd::strng str1; // expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
+other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
+// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
float area(float radius, float pi) {
More information about the cfe-commits
mailing list