@@ -5549,7 +5549,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5549
5549
bool IsInstanceMethod,
5550
5550
QualType ReturnType,
5551
5551
ASTContext &Context,
5552
- const KnownMethodsMap &KnownMethods ,
5552
+ VisitedSelectorSet &KnownSelectors ,
5553
5553
ResultBuilder &Results) {
5554
5554
IdentifierInfo *PropName = Property->getIdentifier ();
5555
5555
if (!PropName || PropName->getLength () == 0 )
@@ -5595,7 +5595,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5595
5595
5596
5596
// Add the normal accessor -(type)key.
5597
5597
if (IsInstanceMethod &&
5598
- !KnownMethods. count (Selectors.getNullarySelector (PropName)) &&
5598
+ KnownSelectors. insert (Selectors.getNullarySelector (PropName)) &&
5599
5599
ReturnTypeMatchesProperty && !Property->getGetterMethodDecl ()) {
5600
5600
if (ReturnType.isNull ())
5601
5601
AddObjCPassingTypeChunk (Property->getType (), Context, Builder);
@@ -5615,7 +5615,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5615
5615
Property->getType ()->isBooleanType ())))) {
5616
5616
std::string SelectorName = (llvm::Twine (" is" ) + UpperKey).str ();
5617
5617
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5618
- if (!KnownMethods. count (Selectors.getNullarySelector (SelectorId))) {
5618
+ if (KnownSelectors. insert (Selectors.getNullarySelector (SelectorId))) {
5619
5619
if (ReturnType.isNull ()) {
5620
5620
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5621
5621
Builder.AddTextChunk (" BOOL" );
@@ -5634,7 +5634,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5634
5634
!Property->getSetterMethodDecl ()) {
5635
5635
std::string SelectorName = (llvm::Twine (" set" ) + UpperKey).str ();
5636
5636
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5637
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
5637
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
5638
5638
if (ReturnType.isNull ()) {
5639
5639
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5640
5640
Builder.AddTextChunk (" void" );
@@ -5685,7 +5685,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5685
5685
(ReturnType.isNull () || ReturnType->isIntegerType ())) {
5686
5686
std::string SelectorName = (llvm::Twine (" countOf" ) + UpperKey).str ();
5687
5687
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5688
- if (!KnownMethods. count (Selectors.getNullarySelector (SelectorId))) {
5688
+ if (KnownSelectors. insert (Selectors.getNullarySelector (SelectorId))) {
5689
5689
if (ReturnType.isNull ()) {
5690
5690
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5691
5691
Builder.AddTextChunk (" NSUInteger" );
@@ -5708,7 +5708,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5708
5708
std::string SelectorName
5709
5709
= (llvm::Twine (" objectIn" ) + UpperKey + " AtIndex" ).str ();
5710
5710
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5711
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
5711
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
5712
5712
if (ReturnType.isNull ()) {
5713
5713
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5714
5714
Builder.AddTextChunk (" id" );
@@ -5735,7 +5735,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5735
5735
std::string SelectorName
5736
5736
= (llvm::Twine (Property->getName ()) + " AtIndexes" ).str ();
5737
5737
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5738
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
5738
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
5739
5739
if (ReturnType.isNull ()) {
5740
5740
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5741
5741
Builder.AddTextChunk (" NSArray *" );
@@ -5760,7 +5760,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5760
5760
&Context.Idents .get (" range" )
5761
5761
};
5762
5762
5763
- if (!KnownMethods. count (Selectors.getSelector (2 , SelectorIds))) {
5763
+ if (KnownSelectors. insert (Selectors.getSelector (2 , SelectorIds))) {
5764
5764
if (ReturnType.isNull ()) {
5765
5765
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5766
5766
Builder.AddTextChunk (" void" );
@@ -5794,7 +5794,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5794
5794
&Context.Idents .get (SelectorName)
5795
5795
};
5796
5796
5797
- if (!KnownMethods. count (Selectors.getSelector (2 , SelectorIds))) {
5797
+ if (KnownSelectors. insert (Selectors.getSelector (2 , SelectorIds))) {
5798
5798
if (ReturnType.isNull ()) {
5799
5799
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5800
5800
Builder.AddTextChunk (" void" );
@@ -5826,7 +5826,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5826
5826
&Context.Idents .get (" atIndexes" )
5827
5827
};
5828
5828
5829
- if (!KnownMethods. count (Selectors.getSelector (2 , SelectorIds))) {
5829
+ if (KnownSelectors. insert (Selectors.getSelector (2 , SelectorIds))) {
5830
5830
if (ReturnType.isNull ()) {
5831
5831
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5832
5832
Builder.AddTextChunk (" void" );
@@ -5854,7 +5854,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5854
5854
std::string SelectorName
5855
5855
= (llvm::Twine (" removeObjectFrom" ) + UpperKey + " AtIndex" ).str ();
5856
5856
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5857
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
5857
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
5858
5858
if (ReturnType.isNull ()) {
5859
5859
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5860
5860
Builder.AddTextChunk (" void" );
@@ -5876,7 +5876,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5876
5876
std::string SelectorName
5877
5877
= (llvm::Twine (" remove" ) + UpperKey + " AtIndexes" ).str ();
5878
5878
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5879
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
5879
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
5880
5880
if (ReturnType.isNull ()) {
5881
5881
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5882
5882
Builder.AddTextChunk (" void" );
@@ -5902,7 +5902,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5902
5902
&Context.Idents .get (" withObject" )
5903
5903
};
5904
5904
5905
- if (!KnownMethods. count (Selectors.getSelector (2 , SelectorIds))) {
5905
+ if (KnownSelectors. insert (Selectors.getSelector (2 , SelectorIds))) {
5906
5906
if (ReturnType.isNull ()) {
5907
5907
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5908
5908
Builder.AddTextChunk (" void" );
@@ -5935,7 +5935,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5935
5935
&Context.Idents .get (SelectorName2)
5936
5936
};
5937
5937
5938
- if (!KnownMethods. count (Selectors.getSelector (2 , SelectorIds))) {
5938
+ if (KnownSelectors. insert (Selectors.getSelector (2 , SelectorIds))) {
5939
5939
if (ReturnType.isNull ()) {
5940
5940
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5941
5941
Builder.AddTextChunk (" void" );
@@ -5968,7 +5968,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5968
5968
->getName () == " NSEnumerator" ))) {
5969
5969
std::string SelectorName = (llvm::Twine (" enumeratorOf" ) + UpperKey).str ();
5970
5970
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5971
- if (!KnownMethods. count (Selectors.getNullarySelector (SelectorId))) {
5971
+ if (KnownSelectors. insert (Selectors.getNullarySelector (SelectorId))) {
5972
5972
if (ReturnType.isNull ()) {
5973
5973
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5974
5974
Builder.AddTextChunk (" NSEnumerator *" );
@@ -5986,7 +5986,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
5986
5986
(ReturnType.isNull () || ReturnType->isObjCObjectPointerType ())) {
5987
5987
std::string SelectorName = (llvm::Twine (" memberOf" ) + UpperKey).str ();
5988
5988
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
5989
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
5989
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
5990
5990
if (ReturnType.isNull ()) {
5991
5991
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
5992
5992
Builder.AddPlaceholderChunk (" object-type" );
@@ -6016,7 +6016,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
6016
6016
std::string SelectorName
6017
6017
= (llvm::Twine (" add" ) + UpperKey + llvm::Twine (" Object" )).str ();
6018
6018
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
6019
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
6019
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
6020
6020
if (ReturnType.isNull ()) {
6021
6021
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
6022
6022
Builder.AddTextChunk (" void" );
@@ -6038,7 +6038,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
6038
6038
if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6039
6039
std::string SelectorName = (llvm::Twine (" add" ) + UpperKey).str ();
6040
6040
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
6041
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
6041
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
6042
6042
if (ReturnType.isNull ()) {
6043
6043
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
6044
6044
Builder.AddTextChunk (" void" );
@@ -6060,7 +6060,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
6060
6060
std::string SelectorName
6061
6061
= (llvm::Twine (" remove" ) + UpperKey + llvm::Twine (" Object" )).str ();
6062
6062
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
6063
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
6063
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
6064
6064
if (ReturnType.isNull ()) {
6065
6065
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
6066
6066
Builder.AddTextChunk (" void" );
@@ -6082,7 +6082,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
6082
6082
if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6083
6083
std::string SelectorName = (llvm::Twine (" remove" ) + UpperKey).str ();
6084
6084
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
6085
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
6085
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
6086
6086
if (ReturnType.isNull ()) {
6087
6087
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
6088
6088
Builder.AddTextChunk (" void" );
@@ -6103,7 +6103,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
6103
6103
if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6104
6104
std::string SelectorName = (llvm::Twine (" intersect" ) + UpperKey).str ();
6105
6105
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
6106
- if (!KnownMethods. count (Selectors.getUnarySelector (SelectorId))) {
6106
+ if (KnownSelectors. insert (Selectors.getUnarySelector (SelectorId))) {
6107
6107
if (ReturnType.isNull ()) {
6108
6108
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
6109
6109
Builder.AddTextChunk (" void" );
@@ -6131,7 +6131,7 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property,
6131
6131
std::string SelectorName
6132
6132
= (llvm::Twine (" keyPathsForValuesAffecting" ) + UpperKey).str ();
6133
6133
IdentifierInfo *SelectorId = &Context.Idents .get (SelectorName);
6134
- if (!KnownMethods. count (Selectors.getNullarySelector (SelectorId))) {
6134
+ if (KnownSelectors. insert (Selectors.getNullarySelector (SelectorId))) {
6135
6135
if (ReturnType.isNull ()) {
6136
6136
Builder.AddChunk (CodeCompletionString::CK_LeftParen);
6137
6137
Builder.AddTextChunk (" NSSet *" );
@@ -6271,6 +6271,13 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S,
6271
6271
llvm::SmallVector<ObjCContainerDecl *, 4 > Containers;
6272
6272
Containers.push_back (SearchDecl);
6273
6273
6274
+ VisitedSelectorSet KnownSelectors;
6275
+ for (KnownMethodsMap::iterator M = KnownMethods.begin (),
6276
+ MEnd = KnownMethods.end ();
6277
+ M != MEnd; ++M)
6278
+ KnownSelectors.insert (M->first );
6279
+
6280
+
6274
6281
ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(SearchDecl);
6275
6282
if (!IFace)
6276
6283
if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(SearchDecl))
@@ -6287,7 +6294,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S,
6287
6294
PEnd = Containers[I]->prop_end ();
6288
6295
P != PEnd; ++P) {
6289
6296
AddObjCKeyValueCompletions (*P, IsInstanceMethod, ReturnType, Context,
6290
- KnownMethods , Results);
6297
+ KnownSelectors , Results);
6291
6298
}
6292
6299
}
6293
6300
}
0 commit comments