diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-31 07:42:17 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-31 07:42:17 +0000 |
commit | 2dcc01195b7850692b9e25c65f77978e6a5a69a5 (patch) | |
tree | 1fb2e30979bee7e6ca902f016cd48ddc13883b23 /lib/Sema/SemaLookup.cpp | |
parent | b94b81a9ab46c99b00c7ad28c5e1e212c63fc9ac (diff) |
Typo correction for member access into classes/structs/unions, e.g.,
s.fnd("hello")
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 9abbd575dc..1419ceb4b6 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -2134,6 +2134,9 @@ void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding) { /// \param SS the nested-name-specifier that precedes the name we're /// looking for, if present. /// +/// \param MemberContext if non-NULL, the context in which to look for +/// a member access expression. +/// /// \param EnteringContext whether we're entering the context described by /// the nested-name-specifier SS. /// @@ -2141,7 +2144,7 @@ void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding) { /// 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 EnteringContext) { + DeclContext *MemberContext, bool EnteringContext) { // We only attempt to correct typos for identifiers. IdentifierInfo *Typo = Res.getLookupName().getAsIdentifierInfo(); if (!Typo) @@ -2158,7 +2161,9 @@ bool Sema::CorrectTypo(LookupResult &Res, Scope *S, const CXXScopeSpec *SS, return false; TypoCorrectionConsumer Consumer(Typo); - if (SS && SS->isSet()) { + if (MemberContext) + LookupVisibleDecls(MemberContext, Res.getLookupKind(), Consumer); + else if (SS && SS->isSet()) { DeclContext *DC = computeDeclContext(*SS, EnteringContext); if (!DC) return false; @@ -2193,7 +2198,11 @@ 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=*/false, EnteringContext); + if (MemberContext) + LookupQualifiedName(Res, MemberContext); + else + LookupParsedName(Res, S, SS, /*AllowBuiltinCreation=*/false, + EnteringContext); if (Res.isAmbiguous()) { Res.suppressDiagnostics(); |