diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-10-15 16:49:56 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-10-15 16:49:56 +0000 |
| commit | 26c5578d849a5f9cdc3044ae67e2857bbe038215 (patch) | |
| tree | aad8426c82d2ac8d3b6222004bf36badc26919a0 /clang/lib/Sema | |
| parent | 8f6fca7f304bc97b0de806349bc9bd6222704070 (diff) | |
| download | bcm5719-llvm-26c5578d849a5f9cdc3044ae67e2857bbe038215.tar.gz bcm5719-llvm-26c5578d849a5f9cdc3044ae67e2857bbe038215.zip | |
When performing typo correction, keep track of whether the last lookup
we did was an acceptable lookup. If it is, then we can re-use that
lookup result. If it isn't, we have to perform the lookup again. This
is almost surely the cause behind the mysterious typo.m failures on
some builders; we were getting the wrong lookup results returned.
llvm-svn: 116586
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 9056e79574e..6cd0207c800 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -3051,6 +3051,7 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, return DeclarationName(); // Weed out any names that could not be found by name lookup. + bool LastLookupWasAccepted = false; for (TypoCorrectionConsumer::iterator I = Consumer.begin(), IEnd = Consumer.end(); I != IEnd; /* Increment in loop. */) { @@ -3103,12 +3104,14 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, Consumer.erase(I); I = Next; } + LastLookupWasAccepted = false; break; case LookupResult::Found: case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: ++I; + LastLookupWasAccepted = false; break; } @@ -3121,8 +3124,41 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, } // If only a single name remains, return that result. - if (Consumer.size() == 1) + if (Consumer.size() == 1) { + IdentifierInfo *Name = &Context.Idents.get(Consumer.begin()->getKey()); + if (!LastLookupWasAccepted) { + // Perform name lookup on this name. + Res.suppressDiagnostics(); + Res.clear(); + Res.setLookupName(Name); + if (MemberContext) + LookupQualifiedName(Res, MemberContext); + else { + LookupParsedName(Res, S, SS, /*AllowBuiltinCreation=*/false, + EnteringContext); + + // Fake ivar lookup; this should really be part of + // LookupParsedName. + if (ObjCMethodDecl *Method = getCurMethodDecl()) { + if (Method->isInstanceMethod() && Method->getClassInterface() && + (Res.empty() || + (Res.isSingleResult() && + Res.getFoundDecl()->isDefinedOutsideFunctionOrMethod()))) { + ObjCInterfaceDecl *ClassDeclared = 0; + if (ObjCIvarDecl *IV + = Method->getClassInterface()->lookupInstanceVariable(Name, + ClassDeclared)) { + Res.clear(); + Res.addDecl(IV); + Res.resolveKind(); + } + } + } + } + } + return &Context.Idents.get(Consumer.begin()->getKey()); + } else if (Consumer.size() > 1 && CTC == CTC_ObjCMessageReceiver && Consumer["super"]) { // Prefix 'super' when we're completing in a message-receiver |

