diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-11-08 21:12:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-11-08 21:12:30 +0000 |
commit | dc520b0f082a235cbbc020d7330f0ec603fc1a18 (patch) | |
tree | 006bccdfe46988e023960a77083c8128d9fb40e1 /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 023270e453f31ff419f8097b2495b8fbc48b186e (diff) | |
download | bcm5719-llvm-dc520b0f082a235cbbc020d7330f0ec603fc1a18.tar.gz bcm5719-llvm-dc520b0f082a235cbbc020d7330f0ec603fc1a18.zip |
If an instance method messages is sending to an expression of type Class,
and we statically can compute a bound on the actual type (e.g.,
because it's a send to the the magic "class" instance method), code
complete as if we were performing a class message send to that class.
llvm-svn: 118443
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index c245e38bb40..90b005ddc31 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4695,6 +4695,21 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver, Context.getObjCInterfaceType(Super)) : Context.getObjCIdType(); + // If we're messaging an expression with type "id" or "Class", check + // whether we know something special about the receiver that allows + // us to assume a more-specific receiver type. + if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType()) + if (ObjCInterfaceDecl *IFace = GetAssumedMessageSendExprType(RecExpr)) { + if (ReceiverType->isObjCClassType()) + return CodeCompleteObjCClassMessage(S, + ParsedType::make(Context.getObjCInterfaceType(IFace)), + SelIdents, NumSelIdents, + AtArgumentExpression, Super); + + ReceiverType = Context.getObjCObjectPointerType( + Context.getObjCInterfaceType(IFace)); + } + // Build the set of methods we can see. ResultBuilder Results(*this, CodeCompletionContext::CCC_Other); Results.EnterNewScope(); @@ -4712,14 +4727,6 @@ void Sema::CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver, // others. if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) Results.setPreferredSelector(CurMethod->getSelector()); - - // If we're messaging an expression with type "id" or "Class", check - // whether we know something special about the receiver that allows - // us to assume a more-specific receiver type. - if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType()) - if (ObjCInterfaceDecl *IFace = GetAssumedMessageSendExprType(RecExpr)) - ReceiverType = Context.getObjCObjectPointerType( - Context.getObjCInterfaceType(IFace)); // Keep track of the selectors we've already added. VisitedSelectorSet Selectors; |