summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-31 05:20:13 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-31 05:20:13 +0000
commit598b08f8182e51759e1ebca4ecd560092890be65 (patch)
tree6ff03a77ab79a564e1944330488eba708960f2f8 /clang/lib/Sema/SemaLookup.cpp
parent5639af4eac2bb44aa96c7c3cd3cdef30f9c80590 (diff)
downloadbcm5719-llvm-598b08f8182e51759e1ebca4ecd560092890be65.tar.gz
bcm5719-llvm-598b08f8182e51759e1ebca4ecd560092890be65.zip
Implement typo correction for id-expressions, e.g.,
typo.cpp:22:10: error: use of undeclared identifier 'radious'; did you mean 'radius'? return radious * pi; ^~~~~~~ radius This was super-easy, since we already had decent recovery by looking for names in dependent base classes. llvm-svn: 92341
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 72779c339d0..9abbd575dcc 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2134,11 +2134,14 @@ void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding) {
/// \param SS the nested-name-specifier that precedes the name we're
/// looking for, if present.
///
+/// \param EnteringContext whether we're entering the context described by
+/// the nested-name-specifier SS.
+///
/// \returns true if the typo was corrected, in which case the \p Res
/// structure will contain the results of name lookup for the
/// corrected name. Otherwise, returns false.
bool Sema::CorrectTypo(LookupResult &Res, Scope *S, const CXXScopeSpec *SS,
- bool AllowBuiltinCreation, bool EnteringContext) {
+ bool EnteringContext) {
// We only attempt to correct typos for identifiers.
IdentifierInfo *Typo = Res.getLookupName().getAsIdentifierInfo();
if (!Typo)
@@ -2190,6 +2193,12 @@ bool Sema::CorrectTypo(LookupResult &Res, Scope *S, const CXXScopeSpec *SS,
// success if we found something that was not ambiguous.
Res.clear();
Res.setLookupName(BestName);
- LookupParsedName(Res, S, SS, AllowBuiltinCreation, EnteringContext);
- return Res.getResultKind() != LookupResult::NotFound && !Res.isAmbiguous();
+ LookupParsedName(Res, S, SS, /*AllowBuiltinCreation=*/false, EnteringContext);
+
+ if (Res.isAmbiguous()) {
+ Res.suppressDiagnostics();
+ return false;
+ }
+
+ return Res.getResultKind() != LookupResult::NotFound;
}
OpenPOWER on IntegriCloud