aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-06 17:30:22 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-06 17:30:22 +0000
commit719770dcfcb3987e8a2377dcca97955301445eb5 (patch)
tree1da28b7f8b75c29bbc67187c5c4c96423db57f14 /lib/Sema/SemaCodeComplete.cpp
parent52d9ae3220c08fcbb80f213a364a88e4e0067242 (diff)
Make code-completion for Objective-C message sends to "id" work in the
presence of precompiled headers by forcibly loading all of the methods we know about from the PCH file before constructing our code-completion list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index d29cab4ca1..ac56fab9e8 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -13,6 +13,7 @@
#include "Sema.h"
#include "Lookup.h"
#include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/ExternalSemaSource.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Lex/MacroInfo.h"
@@ -2977,13 +2978,26 @@ void Sema::CodeCompleteObjCClassMessage(Scope *S, IdentifierInfo *FName,
else if (FName->isStr("id")) {
// We're messaging "id" as a type; provide all class/factory methods.
- // FIXME: Load the entire class method pool from the PCH file
+ // If we have an external source, load the entire class method
+ // pool from the PCH file.
+ if (ExternalSource) {
+ for (uint32_t I = 0, N = ExternalSource->GetNumKnownSelectors(); I != N;
+ ++I) {
+ Selector Sel = ExternalSource->GetSelector(I);
+ if (Sel.isNull() || FactoryMethodPool.count(Sel) ||
+ InstanceMethodPool.count(Sel))
+ continue;
+
+ ReadMethodPool(Sel, /*isInstance=*/false);
+ }
+ }
+
for (llvm::DenseMap<Selector, ObjCMethodList>::iterator
M = FactoryMethodPool.begin(),
MEnd = FactoryMethodPool.end();
M != MEnd;
++M) {
- for (ObjCMethodList *MethList = &M->second; MethList;
+ for (ObjCMethodList *MethList = &M->second; MethList && MethList->Method;
MethList = MethList->Next) {
if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents,
NumSelIdents))
@@ -3056,13 +3070,29 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
}
// Handle messages to "id".
else if (ReceiverType->isObjCIdType()) {
- // FIXME: Load the entire instance method pool from the PCH file
+ // We're messaging "id", so provide all instance methods we know
+ // about as code-completion results.
+
+ // If we have an external source, load the entire class method
+ // pool from the PCH file.
+ if (ExternalSource) {
+ for (uint32_t I = 0, N = ExternalSource->GetNumKnownSelectors(); I != N;
+ ++I) {
+ Selector Sel = ExternalSource->GetSelector(I);
+ if (Sel.isNull() || InstanceMethodPool.count(Sel) ||
+ FactoryMethodPool.count(Sel))
+ continue;
+
+ ReadMethodPool(Sel, /*isInstance=*/true);
+ }
+ }
+
for (llvm::DenseMap<Selector, ObjCMethodList>::iterator
M = InstanceMethodPool.begin(),
MEnd = InstanceMethodPool.end();
M != MEnd;
++M) {
- for (ObjCMethodList *MethList = &M->second; MethList;
+ for (ObjCMethodList *MethList = &M->second; MethList && MethList->Method;
MethList = MethList->Next) {
if (!isAcceptableObjCMethod(MethList->Method, MK_Any, SelIdents,
NumSelIdents))