@@ -3334,14 +3334,35 @@ void Sema::CodeCompletePostfixExpression(Scope *S, ExprResult E) {
3334
3334
// / property name.
3335
3335
typedef llvm::SmallPtrSet<IdentifierInfo*, 16 > AddedPropertiesSet;
3336
3336
3337
- static void AddObjCProperties (ObjCContainerDecl *Container,
3337
+ // / \brief Retrieve the container definition, if any?
3338
+ static ObjCContainerDecl *getContainerDef (ObjCContainerDecl *Container) {
3339
+ if (ObjCInterfaceDecl *Interface = dyn_cast<ObjCInterfaceDecl>(Container)) {
3340
+ if (Interface->hasDefinition ())
3341
+ return Interface->getDefinition ();
3342
+
3343
+ return Interface;
3344
+ }
3345
+
3346
+ if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
3347
+ if (Protocol->hasDefinition ())
3348
+ return Protocol->getDefinition ();
3349
+
3350
+ return Protocol;
3351
+ }
3352
+ return Container;
3353
+ }
3354
+
3355
+ static void AddObjCProperties (ObjCContainerDecl *Container,
3338
3356
bool AllowCategories,
3339
3357
bool AllowNullaryMethods,
3340
3358
DeclContext *CurContext,
3341
3359
AddedPropertiesSet &AddedProperties,
3342
3360
ResultBuilder &Results) {
3343
3361
typedef CodeCompletionResult Result;
3344
3362
3363
+ // Retrieve the definition.
3364
+ Container = getContainerDef (Container);
3365
+
3345
3366
// Add properties in this container.
3346
3367
for (ObjCContainerDecl::prop_iterator P = Container->prop_begin (),
3347
3368
PEnd = Container->prop_end ();
@@ -3617,6 +3638,8 @@ void Sema::CodeCompleteCase(Scope *S) {
3617
3638
// Code-complete the cases of a switch statement over an enumeration type
3618
3639
// by providing the list of
3619
3640
EnumDecl *Enum = type->castAs <EnumType>()->getDecl ();
3641
+ if (EnumDecl *Def = Enum->getDefinition ())
3642
+ Enum = Def;
3620
3643
3621
3644
// Determine which enumerators we have already seen in the switch statement.
3622
3645
// FIXME: Ideally, we would also be able to look *past* the code-completion
@@ -4695,6 +4718,7 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
4695
4718
ResultBuilder &Results,
4696
4719
bool InOriginalClass = true ) {
4697
4720
typedef CodeCompletionResult Result;
4721
+ Container = getContainerDef (Container);
4698
4722
for (ObjCContainerDecl::method_iterator M = Container->meth_begin (),
4699
4723
MEnd = Container->meth_end ();
4700
4724
M != MEnd; ++M) {
@@ -5826,7 +5850,8 @@ void Sema::CodeCompleteObjCPropertyDefinition(Scope *S) {
5826
5850
return ;
5827
5851
5828
5852
// Ignore any properties that have already been implemented.
5829
- for (DeclContext::decl_iterator D = Container->decls_begin (),
5853
+ Container = getContainerDef (Container);
5854
+ for (DeclContext::decl_iterator D = Container->decls_begin (),
5830
5855
DEnd = Container->decls_end ();
5831
5856
D != DEnd; ++D)
5832
5857
if (ObjCPropertyImplDecl *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(*D))
@@ -5959,9 +5984,12 @@ static void FindImplementableMethods(ASTContext &Context,
5959
5984
KnownMethodsMap &KnownMethods,
5960
5985
bool InOriginalClass = true ) {
5961
5986
if (ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(Container)) {
5962
- // Recurse into protocols .
5987
+ // Make sure we have a definition; that's what we'll walk .
5963
5988
if (!IFace->hasDefinition ())
5964
5989
return ;
5990
+
5991
+ IFace = IFace->getDefinition ();
5992
+ Container = IFace;
5965
5993
5966
5994
const ObjCList<ObjCProtocolDecl> &Protocols
5967
5995
= IFace->getReferencedProtocols ();
@@ -6003,16 +6031,20 @@ static void FindImplementableMethods(ASTContext &Context,
6003
6031
}
6004
6032
6005
6033
if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
6006
- if (Protocol->hasDefinition ()) {
6007
- // Recurse into protocols.
6008
- const ObjCList<ObjCProtocolDecl> &Protocols
6009
- = Protocol->getReferencedProtocols ();
6010
- for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin (),
6011
- E = Protocols.end ();
6012
- I != E; ++I)
6013
- FindImplementableMethods (Context, *I, WantInstanceMethods, ReturnType,
6014
- KnownMethods, false );
6015
- }
6034
+ // Make sure we have a definition; that's what we'll walk.
6035
+ if (!Protocol->hasDefinition ())
6036
+ return ;
6037
+ Protocol = Protocol->getDefinition ();
6038
+ Container = Protocol;
6039
+
6040
+ // Recurse into protocols.
6041
+ const ObjCList<ObjCProtocolDecl> &Protocols
6042
+ = Protocol->getReferencedProtocols ();
6043
+ for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin (),
6044
+ E = Protocols.end ();
6045
+ I != E; ++I)
6046
+ FindImplementableMethods (Context, *I, WantInstanceMethods, ReturnType,
6047
+ KnownMethods, false );
6016
6048
}
6017
6049
6018
6050
// Add methods in this container. This operation occurs last because
0 commit comments