27 #include "llvm/ADT/DenseSet.h"
28 #include "llvm/ADT/SmallBitVector.h"
29 #include "llvm/ADT/SmallPtrSet.h"
30 #include "llvm/ADT/SmallString.h"
31 #include "llvm/ADT/StringExtras.h"
32 #include "llvm/ADT/StringSwitch.h"
33 #include "llvm/ADT/Twine.h"
38 using namespace clang;
49 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
55 std::vector<Result> Results;
60 llvm::SmallPtrSet<const Decl*, 16> AllDeclsFound;
62 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
67 class ShadowMapEntry {
72 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector*> DeclOrVector;
76 unsigned SingleDeclIndex;
79 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) { }
81 void Add(
const NamedDecl *ND,
unsigned Index) {
82 if (DeclOrVector.isNull()) {
85 SingleDeclIndex = Index;
90 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
93 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
94 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
99 DeclOrVector.get<DeclIndexPairVector*>()->push_back(
100 DeclIndexPair(ND, Index));
104 if (DeclIndexPairVector *Vec
105 = DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
113 iterator begin()
const;
114 iterator end()
const;
120 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
137 bool AllowNestedNameSpecifiers;
148 std::list<ShadowMap> ShadowMaps;
155 bool HasObjectTypeQualifiers;
167 void AdjustResultPriorityForDecl(Result &R);
169 void MaybeAddConstructorResults(Result R);
175 LookupFilter Filter =
nullptr)
176 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
178 AllowNestedNameSpecifiers(
false), HasObjectTypeQualifiers(
false),
179 CompletionContext(CompletionContext),
180 ObjCImplementation(nullptr)
184 switch (CompletionContext.
getKind()) {
191 if (Method->isInstanceMethod())
193 ObjCImplementation = Interface->getImplementation();
202 unsigned getBasePriority(
const NamedDecl *D);
206 bool includeCodePatterns()
const {
212 void setFilter(LookupFilter Filter) {
213 this->Filter = Filter;
216 Result *data() {
return Results.empty()?
nullptr : &Results.front(); }
217 unsigned size()
const {
return Results.size(); }
218 bool empty()
const {
return Results.empty(); }
232 void setObjectTypeQualifiers(
Qualifiers Quals) {
233 ObjectTypeQualifiers = Quals;
234 HasObjectTypeQualifiers =
true;
242 void setPreferredSelector(
Selector Sel) {
243 PreferredSelector = Sel;
249 return CompletionContext;
253 void allowNestedNameSpecifiers(
bool Allow =
true) {
254 AllowNestedNameSpecifiers = Allow;
259 Sema &getSema()
const {
return SemaRef; }
273 bool isInterestingDecl(
const NamedDecl *ND,
274 bool &AsNestedNameSpecifier)
const;
282 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
292 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
309 void AddResult(Result R);
312 void EnterNewScope();
326 bool IsOrdinaryName(
const NamedDecl *ND)
const;
327 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
328 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
329 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
330 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
332 bool IsClassOrStruct(
const NamedDecl *ND)
const;
334 bool IsNamespace(
const NamedDecl *ND)
const;
335 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
337 bool IsMember(
const NamedDecl *ND)
const;
338 bool IsObjCIvar(
const NamedDecl *ND)
const;
339 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
340 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
341 bool IsObjCCollection(
const NamedDecl *ND)
const;
342 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
348 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
349 unsigned SingleDeclIndex;
371 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) { }
374 : DeclOrIterator(Iterator), SingleDeclIndex(0) { }
377 if (DeclOrIterator.is<
const NamedDecl *>()) {
383 const DeclIndexPair *I = DeclOrIterator.get<
const DeclIndexPair*>();
399 return *DeclOrIterator.get<
const DeclIndexPair*>();
407 return X.DeclOrIterator.getOpaqueValue()
408 == Y.DeclOrIterator.getOpaqueValue() &&
409 X.SingleDeclIndex == Y.SingleDeclIndex;
418 ResultBuilder::ShadowMapEntry::begin()
const {
419 if (DeclOrVector.isNull())
423 return iterator(ND, SingleDeclIndex);
425 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
429 ResultBuilder::ShadowMapEntry::end()
const {
430 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
433 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
455 for (
const DeclContext *CommonAncestor = TargetContext;
456 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
457 CommonAncestor = CommonAncestor->getLookupParent()) {
458 if (CommonAncestor->isTransparentContext() ||
459 CommonAncestor->isFunctionOrMethod())
462 TargetParents.push_back(CommonAncestor);
466 while (!TargetParents.empty()) {
467 const DeclContext *Parent = TargetParents.pop_back_val();
469 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
470 if (!Namespace->getIdentifier())
475 else if (
const TagDecl *TD = dyn_cast<TagDecl>(Parent))
489 return Name[0] ==
'_' &&
490 (Name[1] ==
'_' || (Name[1] >=
'A' && Name[1] <=
'Z'));
493 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
494 bool &AsNestedNameSpecifier)
const {
495 AsNestedNameSpecifier =
false;
509 if (isa<ClassTemplateSpecializationDecl>(ND) ||
510 isa<ClassTemplatePartialSpecializationDecl>(ND))
514 if (isa<UsingDecl>(ND))
528 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
529 ((isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND)) &&
530 Filter != &ResultBuilder::IsNamespace &&
531 Filter != &ResultBuilder::IsNamespaceOrAlias &&
533 AsNestedNameSpecifier =
true;
536 if (Filter && !(this->*Filter)(ND)) {
538 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
539 IsNestedNameSpecifier(ND) &&
540 (Filter != &ResultBuilder::IsMember ||
541 (isa<CXXRecordDecl>(ND) &&
542 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
543 AsNestedNameSpecifier =
true;
553 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
573 R.QualifierIsInformative =
false;
578 R.Declaration->getDeclContext());
585 switch (T->getTypeClass()) {
587 switch (cast<BuiltinType>(T)->getKind()) {
588 case BuiltinType::Void:
591 case BuiltinType::NullPtr:
594 case BuiltinType::Overload:
595 case BuiltinType::Dependent:
598 case BuiltinType::ObjCId:
599 case BuiltinType::ObjCClass:
600 case BuiltinType::ObjCSel:
613 case Type::BlockPointer:
616 case Type::LValueReference:
617 case Type::RValueReference:
620 case Type::ConstantArray:
621 case Type::IncompleteArray:
622 case Type::VariableArray:
623 case Type::DependentSizedArray:
626 case Type::DependentSizedExtVector:
628 case Type::ExtVector:
631 case Type::FunctionProto:
632 case Type::FunctionNoProto:
641 case Type::ObjCObject:
642 case Type::ObjCInterface:
643 case Type::ObjCObjectPointer:
663 T = Function->getCallResultType();
664 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
665 T = Method->getSendResultType();
666 else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
671 T =
Value->getType();
685 if (Pointer->getPointeeType()->isFunctionType()) {
699 T = Function->getReturnType();
709 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
718 dyn_cast<ImplicitParamDecl>(ND))
719 if (ImplicitParam->getIdentifier() &&
720 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
727 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC))
731 if (isa<EnumConstantDecl>(ND))
737 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
748 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
751 if (!PreferredSelector.isNull())
752 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
753 if (PreferredSelector == Method->getSelector())
758 if (!PreferredType.isNull()) {
768 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
774 void ResultBuilder::MaybeAddConstructorResults(Result R) {
775 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
783 Record = ClassTemplate->getTemplatedDecl();
784 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
786 if (isa<ClassTemplateSpecializationDecl>(Record))
808 Results.push_back(R);
812 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
813 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
815 if (R.Kind != Result::RK_Declaration) {
817 Results.push_back(R);
823 dyn_cast<UsingShadowDecl>(R.Declaration)) {
824 MaybeAddResult(
Result(Using->getTargetDecl(),
825 getBasePriority(Using->getTargetDecl()),
834 bool AsNestedNameSpecifier =
false;
835 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
839 if (isa<CXXConstructorDecl>(R.Declaration))
842 ShadowMap &
SMap = ShadowMaps.back();
843 ShadowMapEntry::iterator I, IEnd;
844 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
845 if (NamePos != SMap.end()) {
846 I = NamePos->second.begin();
847 IEnd = NamePos->second.end();
850 for (; I != IEnd; ++I) {
852 unsigned Index = I->second;
855 Results[Index].Declaration = R.Declaration;
865 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
867 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
868 ShadowMapEntry::iterator I, IEnd;
869 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
870 if (NamePos != SM->end()) {
871 I = NamePos->second.begin();
872 IEnd = NamePos->second.end();
874 for (; I != IEnd; ++I) {
876 if (I->first->hasTagIdentifierNamespace() &&
884 I->first->getIdentifierNamespace() != IDNS)
888 if (CheckHiddenResult(R, CurContext, I->first))
896 if (!AllDeclsFound.insert(CanonDecl).second)
901 if (AsNestedNameSpecifier) {
902 R.StartsNestedNameSpecifier =
true;
905 AdjustResultPriorityForDecl(R);
908 if (R.QualifierIsInformative && !R.Qualifier &&
909 !R.StartsNestedNameSpecifier) {
910 const DeclContext *Ctx = R.Declaration->getDeclContext();
911 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
914 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
918 R.QualifierIsInformative =
false;
923 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
924 Results.push_back(R);
926 if (!AsNestedNameSpecifier)
927 MaybeAddConstructorResults(R);
930 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
931 NamedDecl *Hiding,
bool InBaseClass =
false) {
932 if (R.Kind != Result::RK_Declaration) {
934 Results.push_back(R);
939 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
940 AddResult(
Result(Using->getTargetDecl(),
941 getBasePriority(Using->getTargetDecl()),
947 bool AsNestedNameSpecifier =
false;
948 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
952 if (isa<CXXConstructorDecl>(R.Declaration))
955 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
959 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
964 if (AsNestedNameSpecifier) {
965 R.StartsNestedNameSpecifier =
true;
968 else if (Filter == &ResultBuilder::IsMember && !R.Qualifier && InBaseClass &&
969 isa<CXXRecordDecl>(R.Declaration->getDeclContext()
970 ->getRedeclContext()))
971 R.QualifierIsInformative =
true;
974 if (R.QualifierIsInformative && !R.Qualifier &&
975 !R.StartsNestedNameSpecifier) {
976 const DeclContext *Ctx = R.Declaration->getDeclContext();
977 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
980 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
984 R.QualifierIsInformative =
false;
991 AdjustResultPriorityForDecl(R);
993 if (HasObjectTypeQualifiers)
994 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
995 if (Method->isInstance()) {
998 if (ObjectTypeQualifiers == MethodQuals)
1000 else if (ObjectTypeQualifiers - MethodQuals) {
1008 Results.push_back(R);
1010 if (!AsNestedNameSpecifier)
1011 MaybeAddConstructorResults(R);
1014 void ResultBuilder::AddResult(Result R) {
1015 assert(R.Kind != Result::RK_Declaration &&
1016 "Declaration results need more context");
1017 Results.push_back(R);
1021 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1024 void ResultBuilder::ExitScope() {
1025 for (ShadowMap::iterator E = ShadowMaps.back().begin(),
1026 EEnd = ShadowMaps.back().end();
1029 E->second.Destroy();
1031 ShadowMaps.pop_back();
1036 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1045 if (isa<ObjCIvarDecl>(ND))
1054 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1056 if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
1063 if (isa<ObjCIvarDecl>(ND))
1070 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1071 if (!IsOrdinaryNonTypeName(ND))
1075 if (VD->getType()->isIntegralOrEnumerationType())
1083 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1091 !isa<ValueDecl>(ND) && !isa<FunctionTemplateDecl>(ND) &&
1092 !isa<ObjCPropertyDecl>(ND);
1097 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1100 ND = ClassTemplate->getTemplatedDecl();
1106 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1107 return isa<EnumDecl>(ND);
1111 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1114 ND = ClassTemplate->getTemplatedDecl();
1117 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1126 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1129 ND = ClassTemplate->getTemplatedDecl();
1131 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1138 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1139 return isa<NamespaceDecl>(ND);
1144 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1145 return isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND);
1149 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1151 ND = Using->getTargetDecl();
1153 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1159 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1161 ND = Using->getTargetDecl();
1163 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1164 isa<ObjCPropertyDecl>(ND);
1170 case Type::ObjCObject:
1171 case Type::ObjCInterface:
1172 case Type::ObjCObjectPointer:
1176 switch (cast<BuiltinType>(T)->getKind()) {
1177 case BuiltinType::ObjCId:
1178 case BuiltinType::ObjCClass:
1179 case BuiltinType::ObjCSel:
1200 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1209 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const {
1210 if (IsObjCMessageReceiver(ND))
1220 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1221 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1222 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1235 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1241 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1242 return isa<ObjCIvarDecl>(ND);
1249 ResultBuilder &Results;
1253 CodeCompletionDeclConsumer(ResultBuilder &Results,
DeclContext *CurContext)
1254 : Results(Results), CurContext(CurContext) { }
1257 bool InBaseClass)
override {
1258 bool Accessible =
true;
1260 Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
1264 Results.AddResult(Result, CurContext, Hiding, InBaseClass);
1271 ResultBuilder &Results) {
1273 Results.AddResult(Result(
"short",
CCP_Type));
1274 Results.AddResult(Result(
"long",
CCP_Type));
1275 Results.AddResult(Result(
"signed",
CCP_Type));
1276 Results.AddResult(Result(
"unsigned",
CCP_Type));
1277 Results.AddResult(Result(
"void",
CCP_Type));
1278 Results.AddResult(Result(
"char",
CCP_Type));
1279 Results.AddResult(Result(
"int",
CCP_Type));
1280 Results.AddResult(Result(
"float",
CCP_Type));
1281 Results.AddResult(Result(
"double",
CCP_Type));
1282 Results.AddResult(Result(
"enum",
CCP_Type));
1283 Results.AddResult(Result(
"struct",
CCP_Type));
1284 Results.AddResult(Result(
"union",
CCP_Type));
1285 Results.AddResult(Result(
"const",
CCP_Type));
1286 Results.AddResult(Result(
"volatile",
CCP_Type));
1290 Results.AddResult(Result(
"_Complex",
CCP_Type));
1291 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1292 Results.AddResult(Result(
"_Bool",
CCP_Type));
1293 Results.AddResult(Result(
"restrict",
CCP_Type));
1297 Results.getCodeCompletionTUInfo());
1298 if (LangOpts.CPlusPlus) {
1300 Results.AddResult(Result(
"bool",
CCP_Type +
1302 Results.AddResult(Result(
"class",
CCP_Type));
1303 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1306 Builder.AddTypedTextChunk(
"typename");
1308 Builder.AddPlaceholderChunk(
"qualifier");
1310 Builder.AddPlaceholderChunk(
"name");
1311 Results.AddResult(Result(
Builder.TakeString()));
1313 if (LangOpts.CPlusPlus11) {
1314 Results.AddResult(Result(
"auto",
CCP_Type));
1315 Results.AddResult(Result(
"char16_t",
CCP_Type));
1316 Results.AddResult(Result(
"char32_t",
CCP_Type));
1318 Builder.AddTypedTextChunk(
"decltype");
1320 Builder.AddPlaceholderChunk(
"expression");
1322 Results.AddResult(Result(
Builder.TakeString()));
1327 if (LangOpts.GNUMode) {
1333 Builder.AddTypedTextChunk(
"typeof");
1335 Builder.AddPlaceholderChunk(
"expression");
1336 Results.AddResult(Result(
Builder.TakeString()));
1338 Builder.AddTypedTextChunk(
"typeof");
1340 Builder.AddPlaceholderChunk(
"type");
1342 Results.AddResult(Result(
Builder.TakeString()));
1346 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1347 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1348 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1353 ResultBuilder &Results) {
1358 Results.AddResult(Result(
"extern"));
1359 Results.AddResult(Result(
"static"));
1364 ResultBuilder &Results) {
1369 if (LangOpts.CPlusPlus) {
1370 Results.AddResult(Result(
"explicit"));
1371 Results.AddResult(Result(
"friend"));
1372 Results.AddResult(Result(
"mutable"));
1373 Results.AddResult(Result(
"virtual"));
1381 if (LangOpts.CPlusPlus || LangOpts.C99)
1382 Results.AddResult(Result(
"inline"));
1401 ResultBuilder &Results,
1404 ResultBuilder &Results,
1407 ResultBuilder &Results,
1413 Results.getCodeCompletionTUInfo());
1414 Builder.AddTypedTextChunk(
"typedef");
1416 Builder.AddPlaceholderChunk(
"type");
1418 Builder.AddPlaceholderChunk(
"name");
1439 return LangOpts.CPlusPlus;
1446 return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
1449 llvm_unreachable(
"Invalid ParserCompletionContext!");
1477 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1478 return BT->getNameAsCString(Policy);
1481 if (
const TagType *TagT = dyn_cast<TagType>(T))
1482 if (
TagDecl *Tag = TagT->getDecl())
1483 if (!Tag->hasNameForLinkage()) {
1484 switch (Tag->getTagKind()) {
1485 case TTK_Struct:
return "struct <anonymous>";
1487 case TTK_Class:
return "class <anonymous>";
1488 case TTK_Union:
return "union <anonymous>";
1489 case TTK_Enum:
return "enum <anonymous>";
1513 Builder.AddTypedTextChunk(
"this");
1521 ResultBuilder &Results) {
1530 if (Results.includeCodePatterns()) {
1532 Builder.AddTypedTextChunk(
"namespace");
1534 Builder.AddPlaceholderChunk(
"identifier");
1536 Builder.AddPlaceholderChunk(
"declarations");
1539 Results.AddResult(Result(
Builder.TakeString()));
1543 Builder.AddTypedTextChunk(
"namespace");
1545 Builder.AddPlaceholderChunk(
"name");
1547 Builder.AddPlaceholderChunk(
"namespace");
1548 Results.AddResult(Result(
Builder.TakeString()));
1551 Builder.AddTypedTextChunk(
"using");
1553 Builder.AddTextChunk(
"namespace");
1555 Builder.AddPlaceholderChunk(
"identifier");
1556 Results.AddResult(Result(
Builder.TakeString()));
1559 Builder.AddTypedTextChunk(
"asm");
1561 Builder.AddPlaceholderChunk(
"string-literal");
1563 Results.AddResult(Result(
Builder.TakeString()));
1565 if (Results.includeCodePatterns()) {
1567 Builder.AddTypedTextChunk(
"template");
1569 Builder.AddPlaceholderChunk(
"declaration");
1570 Results.AddResult(Result(
Builder.TakeString()));
1583 Builder.AddTypedTextChunk(
"using");
1585 Builder.AddPlaceholderChunk(
"qualifier");
1587 Builder.AddPlaceholderChunk(
"name");
1588 Results.AddResult(Result(
Builder.TakeString()));
1592 Builder.AddTypedTextChunk(
"using");
1594 Builder.AddTextChunk(
"typename");
1596 Builder.AddPlaceholderChunk(
"qualifier");
1598 Builder.AddPlaceholderChunk(
"name");
1599 Results.AddResult(Result(
Builder.TakeString()));
1606 Builder.AddTypedTextChunk(
"public");
1607 if (Results.includeCodePatterns())
1609 Results.AddResult(Result(
Builder.TakeString()));
1612 Builder.AddTypedTextChunk(
"protected");
1613 if (Results.includeCodePatterns())
1615 Results.AddResult(Result(
Builder.TakeString()));
1618 Builder.AddTypedTextChunk(
"private");
1619 if (Results.includeCodePatterns())
1621 Results.AddResult(Result(
Builder.TakeString()));
1628 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1630 Builder.AddTypedTextChunk(
"template");
1632 Builder.AddPlaceholderChunk(
"parameters");
1634 Results.AddResult(Result(
Builder.TakeString()));
1661 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1663 Builder.AddTypedTextChunk(
"try");
1665 Builder.AddPlaceholderChunk(
"statements");
1668 Builder.AddTextChunk(
"catch");
1670 Builder.AddPlaceholderChunk(
"declaration");
1673 Builder.AddPlaceholderChunk(
"statements");
1676 Results.AddResult(Result(
Builder.TakeString()));
1681 if (Results.includeCodePatterns()) {
1683 Builder.AddTypedTextChunk(
"if");
1686 Builder.AddPlaceholderChunk(
"condition");
1688 Builder.AddPlaceholderChunk(
"expression");
1691 Builder.AddPlaceholderChunk(
"statements");
1694 Results.AddResult(Result(
Builder.TakeString()));
1697 Builder.AddTypedTextChunk(
"switch");
1700 Builder.AddPlaceholderChunk(
"condition");
1702 Builder.AddPlaceholderChunk(
"expression");
1707 Results.AddResult(Result(
Builder.TakeString()));
1713 Builder.AddTypedTextChunk(
"case");
1715 Builder.AddPlaceholderChunk(
"expression");
1717 Results.AddResult(Result(
Builder.TakeString()));
1720 Builder.AddTypedTextChunk(
"default");
1722 Results.AddResult(Result(
Builder.TakeString()));
1725 if (Results.includeCodePatterns()) {
1727 Builder.AddTypedTextChunk(
"while");
1730 Builder.AddPlaceholderChunk(
"condition");
1732 Builder.AddPlaceholderChunk(
"expression");
1735 Builder.AddPlaceholderChunk(
"statements");
1738 Results.AddResult(Result(
Builder.TakeString()));
1741 Builder.AddTypedTextChunk(
"do");
1743 Builder.AddPlaceholderChunk(
"statements");
1746 Builder.AddTextChunk(
"while");
1748 Builder.AddPlaceholderChunk(
"expression");
1750 Results.AddResult(Result(
Builder.TakeString()));
1753 Builder.AddTypedTextChunk(
"for");
1756 Builder.AddPlaceholderChunk(
"init-statement");
1758 Builder.AddPlaceholderChunk(
"init-expression");
1760 Builder.AddPlaceholderChunk(
"condition");
1762 Builder.AddPlaceholderChunk(
"inc-expression");
1766 Builder.AddPlaceholderChunk(
"statements");
1769 Results.AddResult(Result(
Builder.TakeString()));
1774 Builder.AddTypedTextChunk(
"continue");
1775 Results.AddResult(Result(
Builder.TakeString()));
1780 Builder.AddTypedTextChunk(
"break");
1781 Results.AddResult(Result(
Builder.TakeString()));
1786 bool isVoid =
false;
1788 isVoid = Function->getReturnType()->isVoidType();
1790 = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1791 isVoid = Method->getReturnType()->isVoidType();
1795 Builder.AddTypedTextChunk(
"return");
1798 Builder.AddPlaceholderChunk(
"expression");
1800 Results.AddResult(Result(
Builder.TakeString()));
1803 Builder.AddTypedTextChunk(
"goto");
1805 Builder.AddPlaceholderChunk(
"label");
1806 Results.AddResult(Result(
Builder.TakeString()));
1809 Builder.AddTypedTextChunk(
"using");
1811 Builder.AddTextChunk(
"namespace");
1813 Builder.AddPlaceholderChunk(
"identifier");
1814 Results.AddResult(Result(
Builder.TakeString()));
1827 Builder.AddTypedTextChunk(
"__bridge");
1829 Builder.AddPlaceholderChunk(
"type");
1831 Builder.AddPlaceholderChunk(
"expression");
1832 Results.AddResult(Result(
Builder.TakeString()));
1835 Builder.AddTypedTextChunk(
"__bridge_transfer");
1837 Builder.AddPlaceholderChunk(
"Objective-C type");
1839 Builder.AddPlaceholderChunk(
"expression");
1840 Results.AddResult(Result(
Builder.TakeString()));
1843 Builder.AddTypedTextChunk(
"__bridge_retained");
1845 Builder.AddPlaceholderChunk(
"CF type");
1847 Builder.AddPlaceholderChunk(
"expression");
1848 Results.AddResult(Result(
Builder.TakeString()));
1858 Builder.AddResultTypeChunk(
"bool");
1859 Builder.AddTypedTextChunk(
"true");
1860 Results.AddResult(Result(
Builder.TakeString()));
1863 Builder.AddResultTypeChunk(
"bool");
1864 Builder.AddTypedTextChunk(
"false");
1865 Results.AddResult(Result(
Builder.TakeString()));
1869 Builder.AddTypedTextChunk(
"dynamic_cast");
1871 Builder.AddPlaceholderChunk(
"type");
1874 Builder.AddPlaceholderChunk(
"expression");
1876 Results.AddResult(Result(
Builder.TakeString()));
1880 Builder.AddTypedTextChunk(
"static_cast");
1882 Builder.AddPlaceholderChunk(
"type");
1885 Builder.AddPlaceholderChunk(
"expression");
1887 Results.AddResult(Result(
Builder.TakeString()));
1890 Builder.AddTypedTextChunk(
"reinterpret_cast");
1892 Builder.AddPlaceholderChunk(
"type");
1895 Builder.AddPlaceholderChunk(
"expression");
1897 Results.AddResult(Result(
Builder.TakeString()));
1900 Builder.AddTypedTextChunk(
"const_cast");
1902 Builder.AddPlaceholderChunk(
"type");
1905 Builder.AddPlaceholderChunk(
"expression");
1907 Results.AddResult(Result(
Builder.TakeString()));
1911 Builder.AddResultTypeChunk(
"std::type_info");
1912 Builder.AddTypedTextChunk(
"typeid");
1914 Builder.AddPlaceholderChunk(
"expression-or-type");
1916 Results.AddResult(Result(
Builder.TakeString()));
1920 Builder.AddTypedTextChunk(
"new");
1922 Builder.AddPlaceholderChunk(
"type");
1924 Builder.AddPlaceholderChunk(
"expressions");
1926 Results.AddResult(Result(
Builder.TakeString()));
1929 Builder.AddTypedTextChunk(
"new");
1931 Builder.AddPlaceholderChunk(
"type");
1933 Builder.AddPlaceholderChunk(
"size");
1936 Builder.AddPlaceholderChunk(
"expressions");
1938 Results.AddResult(Result(
Builder.TakeString()));
1941 Builder.AddResultTypeChunk(
"void");
1942 Builder.AddTypedTextChunk(
"delete");
1944 Builder.AddPlaceholderChunk(
"expression");
1945 Results.AddResult(Result(
Builder.TakeString()));
1948 Builder.AddResultTypeChunk(
"void");
1949 Builder.AddTypedTextChunk(
"delete");
1954 Builder.AddPlaceholderChunk(
"expression");
1955 Results.AddResult(Result(
Builder.TakeString()));
1959 Builder.AddResultTypeChunk(
"void");
1960 Builder.AddTypedTextChunk(
"throw");
1962 Builder.AddPlaceholderChunk(
"expression");
1963 Results.AddResult(Result(
Builder.TakeString()));
1970 Builder.AddResultTypeChunk(
"std::nullptr_t");
1971 Builder.AddTypedTextChunk(
"nullptr");
1972 Results.AddResult(Result(
Builder.TakeString()));
1975 Builder.AddResultTypeChunk(
"size_t");
1976 Builder.AddTypedTextChunk(
"alignof");
1978 Builder.AddPlaceholderChunk(
"type");
1980 Results.AddResult(Result(
Builder.TakeString()));
1983 Builder.AddResultTypeChunk(
"bool");
1984 Builder.AddTypedTextChunk(
"noexcept");
1986 Builder.AddPlaceholderChunk(
"expression");
1988 Results.AddResult(Result(
Builder.TakeString()));
1991 Builder.AddResultTypeChunk(
"size_t");
1992 Builder.AddTypedTextChunk(
"sizeof...");
1994 Builder.AddPlaceholderChunk(
"parameter-pack");
1996 Results.AddResult(Result(
Builder.TakeString()));
2005 if (
ID->getSuperClass()) {
2006 std::string SuperType;
2007 SuperType =
ID->getSuperClass()->getNameAsString();
2008 if (Method->isInstanceMethod())
2012 Builder.AddTypedTextChunk(
"super");
2013 Results.AddResult(Result(
Builder.TakeString()));
2022 Builder.AddResultTypeChunk(
"size_t");
2024 Builder.AddTypedTextChunk(
"alignof");
2026 Builder.AddTypedTextChunk(
"_Alignof");
2028 Builder.AddPlaceholderChunk(
"type");
2030 Results.AddResult(Result(
Builder.TakeString()));
2034 Builder.AddResultTypeChunk(
"size_t");
2035 Builder.AddTypedTextChunk(
"sizeof");
2037 Builder.AddPlaceholderChunk(
"expression-or-type");
2039 Results.AddResult(Result(
Builder.TakeString()));
2052 Results.AddResult(Result(
"operator"));
2067 if (isa<CXXConstructorDecl>(ND) || isa<CXXConversionDecl>(ND))
2073 T = Function->getReturnType();
2074 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2076 T = Method->getSendResultType(BaseType);
2078 T = Method->getReturnType();
2079 }
else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
2080 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2081 else if (isa<UnresolvedUsingValueDecl>(ND)) {
2083 }
else if (
const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2085 T = Ivar->getUsageType(BaseType);
2087 T = Ivar->getType();
2089 T =
Value->getType();
2092 T =
Property->getUsageType(BaseType);
2107 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2108 if (Sentinel->getSentinel() == 0) {
2128 Result +=
"bycopy ";
2132 Result +=
"oneway ";
2135 switch (*nullability) {
2137 Result +=
"nonnull ";
2141 Result +=
"nullable ";
2145 Result +=
"null_unspecified ";
2155 bool SuppressName =
false,
2156 bool SuppressBlock =
false,
2157 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2158 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2165 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2172 if (ObjCMethodParam) {
2193 if (!SuppressBlock) {
2196 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2209 TL = AttrTL.getModifiedLoc();
2234 if (ObjCMethodParam) {
2237 Result += Type.
getAsString(Policy) + Result +
")";
2255 if (!ResultType->
isVoidType() || SuppressBlock)
2267 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2281 if (SuppressBlock) {
2283 Result = Result +
" (^";
2290 Result =
'^' + Result;
2306 bool InOptional =
false) {
2307 bool FirstParameter =
true;
2317 if (!FirstParameter)
2325 FirstParameter =
false;
2335 PlaceholderStr +=
", ...";
2344 if (Proto->isVariadic()) {
2345 if (Proto->getNumParams() == 0)
2357 unsigned MaxParameters = 0,
2359 bool InDefaultArg =
false) {
2360 bool FirstParameter =
true;
2369 PEnd = Params->begin() + MaxParameters;
2372 bool HasDefaultArg =
false;
2373 std::string PlaceholderStr;
2375 if (TTP->wasDeclaredWithTypename())
2376 PlaceholderStr =
"typename";
2378 PlaceholderStr =
"class";
2380 if (TTP->getIdentifier()) {
2381 PlaceholderStr +=
' ';
2385 HasDefaultArg = TTP->hasDefaultArgument();
2387 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2388 if (NTTP->getIdentifier())
2389 PlaceholderStr = NTTP->getIdentifier()->getName();
2390 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2391 HasDefaultArg = NTTP->hasDefaultArgument();
2393 assert(isa<TemplateTemplateParmDecl>(*
P));
2398 PlaceholderStr =
"template<...> class";
2400 PlaceholderStr +=
' ';
2407 if (HasDefaultArg && !InDefaultArg) {
2412 if (!FirstParameter)
2415 P - Params->begin(),
true);
2420 InDefaultArg =
false;
2423 FirstParameter =
false;
2438 bool QualifierIsInformative,
2444 std::string PrintedNNS;
2446 llvm::raw_string_ostream OS(PrintedNNS);
2447 Qualifier->
print(OS, Policy);
2449 if (QualifierIsInformative)
2482 std::string QualsStr;
2484 QualsStr +=
" const";
2486 QualsStr +=
" volatile";
2488 QualsStr +=
" restrict";
2502 const char *OperatorName =
nullptr;
2505 case OO_Conditional:
2507 OperatorName =
"operator";
2510 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2511 case OO_##Name: OperatorName = "operator" Spelling; break;
2512 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2513 #include "clang/Basic/OperatorKinds.def"
2515 case OO_New: OperatorName =
"operator new";
break;
2516 case OO_Delete: OperatorName =
"operator delete";
break;
2517 case OO_Array_New: OperatorName =
"operator new[]";
break;
2518 case OO_Array_Delete: OperatorName =
"operator delete[]";
break;
2519 case OO_Call: OperatorName =
"operator()";
break;
2520 case OO_Subscript: OperatorName =
"operator[]";
break;
2544 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2547 Record = InjectedTy->getDecl();
2570 bool IncludeBriefComments) {
2571 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2572 CCTUInfo, IncludeBriefComments);
2587 bool IncludeBriefComments) {
2591 if (
Kind == RK_Pattern) {
2592 Pattern->Priority = Priority;
2593 Pattern->Availability = Availability;
2604 if (M->isPropertyAccessor())
2606 if (PDecl->getGetterName() == M->getSelector() &&
2607 PDecl->getIdentifier() != M->getIdentifier()) {
2624 if (
Kind == RK_Keyword) {
2629 if (
Kind == RK_Macro) {
2672 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2676 if (IncludeBriefComments) {
2681 else if (
const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
2682 if (OMD->isPropertyAccessor())
2688 if (StartsNestedNameSpecifier) {
2700 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
2719 llvm::SmallBitVector Deduced;
2721 unsigned LastDeducibleArgument;
2722 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
2723 --LastDeducibleArgument) {
2724 if (!Deduced[LastDeducibleArgument - 1]) {
2728 bool HasDefaultArg =
false;
2729 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
2730 LastDeducibleArgument - 1);
2732 HasDefaultArg = TTP->hasDefaultArgument();
2734 = dyn_cast<NonTypeTemplateParmDecl>(Param))
2735 HasDefaultArg = NTTP->hasDefaultArgument();
2737 assert(isa<TemplateTemplateParmDecl>(Param));
2739 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
2747 if (LastDeducibleArgument) {
2753 LastDeducibleArgument);
2765 if (
const TemplateDecl *Template = dyn_cast<TemplateDecl>(ND)) {
2776 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2777 Selector Sel = Method->getSelector();
2786 if (StartParameter == 0)
2793 if (Method->param_size() == 1)
2798 PEnd = Method->param_end();
2799 P != PEnd; (void)++
P, ++Idx) {
2801 std::string Keyword;
2802 if (Idx > StartParameter)
2805 Keyword += II->getName();
2807 if (Idx < StartParameter || AllParametersAreInformative)
2814 if (Idx < StartParameter)
2818 QualType ParamType = (*P)->getType();
2835 if (DeclaringEntity || AllParametersAreInformative)
2836 Arg += II->getName();
2839 if (Method->isVariadic() && (
P + 1) == PEnd)
2842 if (DeclaringEntity)
2844 else if (AllParametersAreInformative)
2850 if (Method->isVariadic()) {
2851 if (Method->param_size() == 0) {
2852 if (DeclaringEntity)
2854 else if (AllParametersAreInformative)
2882 unsigned CurrentArg,
2884 bool InOptional =
false) {
2885 bool FirstParameter =
true;
2886 unsigned NumParams = Function ? Function->
getNumParams()
2889 for (
unsigned P = Start;
P != NumParams; ++
P) {
2895 if (!FirstParameter)
2899 CurrentArg,
P,
true);
2905 FirstParameter =
false;
2912 std::string Placeholder;
2918 if (
P == CurrentArg)
2928 if (!FirstParameter)
2931 if (CurrentArg < NumParams)
2932 Opt.AddPlaceholderChunk(
"...");
2934 Opt.AddCurrentParameterChunk(
"...");
2942 unsigned CurrentArg,
Sema &
S,
2945 bool IncludeBriefComments)
const {
2953 if (!FDecl && !Proto) {
2966 if (IncludeBriefComments && CurrentArg < FDecl->getNumParams())
2984 return Result.TakeString();
2989 bool PreferredTypeIsPointer) {
2993 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
2994 MacroName.equals(
"Nil")) {
2996 if (PreferredTypeIsPointer)
3000 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3001 MacroName.equals(
"true") || MacroName.equals(
"false"))
3004 else if (MacroName.equals(
"bool"))
3019 case Decl::Function:
3027 case Decl::ObjCMethod:
3048 case Decl::ClassTemplatePartialSpecialization:
3054 case Decl::UnresolvedUsingValue:
3055 case Decl::UnresolvedUsingTypename:
3058 case Decl::ObjCPropertyImpl:
3059 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3073 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3074 switch (TD->getTagKind()) {
3088 bool IncludeUndefined,
3089 bool TargetTypeIsPointer =
false) {
3092 Results.EnterNewScope();
3098 if (IncludeUndefined || MD) {
3100 if (MI->isUsedForHeaderGuard())
3103 Results.AddResult(Result(M->first,
3106 TargetTypeIsPointer)));
3110 Results.ExitScope();
3115 ResultBuilder &Results) {
3118 Results.EnterNewScope();
3120 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3121 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3122 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3124 Results.ExitScope();
3131 unsigned NumResults) {
3189 llvm_unreachable(
"Invalid ParserCompletionContext!");
3201 ResultBuilder &Results) {
3204 while (isa<BlockDecl>(CurContext))
3214 for (
auto P : Method->
params())
3215 if (!
P->getDeclName())
3223 Results.getCodeCompletionTUInfo());
3232 Overridden->getDeclContext());
3235 llvm::raw_string_ostream OS(Str);
3236 NNS->
print(OS, Policy);
3237 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3239 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3242 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
3243 Overridden->getNameAsString()));
3245 bool FirstParam =
true;
3246 for (
auto P : Method->
params()) {
3253 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3261 Results.Ignore(Overridden);
3268 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3269 CodeCompleter->getCodeCompletionTUInfo(),
3271 Results.EnterNewScope();
3279 PP.getHeaderSearchInfo().collectAllModules(Modules);
3280 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
3282 Builder.getAllocator().CopyString(Modules[I]->Name));
3283 Results.AddResult(Result(
Builder.TakeString(),
3286 Modules[I]->isAvailable()
3290 }
else if (getLangOpts().Modules) {
3292 Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path,
3299 Sub != SubEnd; ++Sub) {
3302 Builder.getAllocator().CopyString((*Sub)->Name));
3303 Results.AddResult(Result(
Builder.TakeString(),
3306 (*Sub)->isAvailable()
3312 Results.ExitScope();
3314 Results.data(),Results.size());
3319 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3320 CodeCompleter->getCodeCompletionTUInfo(),
3322 Results.EnterNewScope();
3327 switch (CompletionContext) {
3330 case PCC_ObjCInterface:
3331 case PCC_ObjCImplementation:
3332 case PCC_ObjCInstanceVariableList:
3334 case PCC_MemberTemplate:
3336 case PCC_LocalDeclarationSpecifiers:
3337 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3341 case PCC_ParenthesizedExpression:
3342 case PCC_Expression:
3346 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3348 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3354 case PCC_RecoveryInFunction:
3361 if (
CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
3362 if (CurMethod->isInstance())
3363 Results.setObjectTypeQualifiers(
3366 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3368 CodeCompleter->includeGlobals());
3371 Results.ExitScope();
3373 switch (CompletionContext) {
3374 case PCC_ParenthesizedExpression:
3375 case PCC_Expression:
3377 case PCC_RecoveryInFunction:
3384 case PCC_ObjCInterface:
3385 case PCC_ObjCImplementation:
3386 case PCC_ObjCInstanceVariableList:
3388 case PCC_MemberTemplate:
3392 case PCC_LocalDeclarationSpecifiers:
3396 if (CodeCompleter->includeMacros())
3400 Results.data(),Results.size());
3406 bool AtArgumentExpression,
3408 ResultBuilder &Results);
3411 bool AllowNonIdentifiers,
3412 bool AllowNestedNameSpecifiers) {
3414 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3415 CodeCompleter->getCodeCompletionTUInfo(),
3416 AllowNestedNameSpecifiers
3419 Results.EnterNewScope();
3422 Results.AddResult(Result(
"const"));
3423 Results.AddResult(Result(
"volatile"));
3424 if (getLangOpts().
C99)
3425 Results.AddResult(Result(
"restrict"));
3428 if (AllowNonIdentifiers) {
3429 Results.AddResult(Result(
"operator"));
3433 if (AllowNestedNameSpecifiers) {
3434 Results.allowNestedNameSpecifiers();
3435 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3436 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3438 CodeCompleter->includeGlobals());
3439 Results.setFilter(
nullptr);
3442 Results.ExitScope();
3448 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3468 Results.getCompletionContext(),
3469 Results.data(), Results.size());
3474 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3475 ObjCCollection(
false) { }
3487 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3488 CodeCompleter->getCodeCompletionTUInfo(),
3491 Results.setFilter(&ResultBuilder::IsObjCCollection);
3493 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3495 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3497 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3503 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
3506 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3508 CodeCompleter->includeGlobals());
3510 Results.EnterNewScope();
3512 Results.ExitScope();
3514 bool PreferredTypeIsPointer =
false;
3525 if (CodeCompleter->includeMacros())
3530 Results.data(),Results.size());
3535 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3536 else if (getLangOpts().ObjC1)
3537 CodeCompleteObjCInstanceMessage(S, E.
get(),
None,
false);
3547 if (Interface->hasDefinition())
3548 return Interface->getDefinition();
3554 if (Protocol->hasDefinition())
3555 return Protocol->getDefinition();
3564 bool AllowCategories,
3565 bool AllowNullaryMethods,
3568 ResultBuilder &Results) {
3576 if (AddedProperties.insert(
P->getIdentifier()).second)
3577 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3581 if (AllowNullaryMethods) {
3584 for (
auto *M : Container->
methods()) {
3585 if (M->getSelector().isUnarySelector())
3586 if (
IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0))
3587 if (AddedProperties.insert(Name).second) {
3589 Results.getCodeCompletionTUInfo());
3593 Results.getAllocator().CopyString(Name->getName()));
3595 Results.MaybeAddResult(Result(
Builder.TakeString(), M,
3605 for (
auto *
P : Protocol->protocols())
3607 CurContext, AddedProperties, Results);
3609 if (AllowCategories) {
3611 for (
auto *Cat : IFace->known_categories())
3613 CurContext, AddedProperties, Results);
3617 for (
auto *I : IFace->all_referenced_protocols())
3619 CurContext, AddedProperties, Results);
3622 if (IFace->getSuperClass())
3624 AllowNullaryMethods, CurContext,
3625 AddedProperties, Results);
3627 = dyn_cast<ObjCCategoryDecl>(Container)) {
3629 for (
auto *
P : Category->protocols())
3631 CurContext, AddedProperties, Results);
3638 if (!Base || !CodeCompleter)
3641 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
3644 Base = ConvertedBase.
get();
3675 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3676 CodeCompleter->getCodeCompletionTUInfo(),
3678 &ResultBuilder::IsMember);
3679 Results.EnterNewScope();
3686 Results.allowNestedNameSpecifiers();
3687 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3689 CodeCompleter->includeGlobals());
3691 if (getLangOpts().CPlusPlus) {
3692 if (!Results.empty()) {
3698 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
3706 Results.AddResult(Result(
"template"));
3716 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
3719 AddedProperties, Results);
3722 for (
auto *I : ObjCPtr->
quals())
3724 CurContext, AddedProperties, Results);
3731 Class = ObjCPtr->getInterfaceDecl();
3737 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3738 Results.setFilter(&ResultBuilder::IsObjCIvar);
3740 CodeCompleter->includeGlobals());
3746 Results.ExitScope();
3750 Results.getCompletionContext(),
3751 Results.data(),Results.size());
3758 ResultBuilder::LookupFilter Filter =
nullptr;
3763 Filter = &ResultBuilder::IsEnum;
3768 Filter = &ResultBuilder::IsUnion;
3775 Filter = &ResultBuilder::IsClassOrStruct;
3780 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
3783 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3784 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
3785 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3788 Results.setFilter(Filter);
3790 CodeCompleter->includeGlobals());
3792 if (CodeCompleter->includeGlobals()) {
3794 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
3799 Results.data(),Results.size());
3803 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3804 CodeCompleter->getCodeCompletionTUInfo(),
3806 Results.EnterNewScope();
3808 Results.AddResult(
"const");
3810 Results.AddResult(
"volatile");
3811 if (getLangOpts().
C99 &&
3813 Results.AddResult(
"restrict");
3814 if (getLangOpts().
C11 &&
3816 Results.AddResult(
"_Atomic");
3817 Results.ExitScope();
3819 Results.getCompletionContext(),
3820 Results.data(), Results.size());
3824 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
3827 SwitchStmt *Switch = getCurFunction()->SwitchStack.back();
3832 CodeCompleteExpression(S, Data);
3846 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
3855 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseVal))
3857 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
3864 EnumeratorsSeen.insert(Enumerator);
3877 Qualifier = DRE->getQualifier();
3881 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
3889 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3890 CodeCompleter->getCodeCompletionTUInfo(),
3892 Results.EnterNewScope();
3894 if (EnumeratorsSeen.count(E))
3898 Results.AddResult(R, CurContext,
nullptr,
false);
3900 Results.ExitScope();
3905 if (CodeCompleter->includeMacros()) {
3912 Results.data(),Results.size());
3916 if (Args.size() && !Args.data())
3919 for (
unsigned I = 0; I != Args.size(); ++I)
3932 if (!CandidateSet.
empty()) {
3935 CandidateSet.
begin(), CandidateSet.
end(),
3941 for (
auto &Candidate : CandidateSet)
3942 if (Candidate.Viable)
3950 ArrayRef<ResultCandidate> Candidates,
3957 for (
auto &Candidate : Candidates) {
3958 if (
auto FType = Candidate.getFunctionType())
3959 if (
auto Proto = dyn_cast<FunctionProtoType>(FType))
3960 if (N < Proto->getNumParams()) {
3962 ParamType = Proto->getParamType(N);
3965 Proto->getParamType(N).getNonReferenceType()))
3976 unsigned CurrentArg,
3977 bool CompleteExpressionWithCurrentArg =
true) {
3979 if (CompleteExpressionWithCurrentArg)
3980 ParamType =
getParamType(SemaRef, Candidates, CurrentArg);
3987 if (!Candidates.empty())
4007 CodeCompleteOrdinaryName(S, PCC_Expression);
4018 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4019 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4021 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4023 if (UME->hasExplicitTemplateArgs()) {
4024 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4025 TemplateArgs = &TemplateArgsBuffer;
4028 ArgExprs.append(Args.begin(), Args.end());
4030 Decls.
append(UME->decls_begin(), UME->decls_end());
4031 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4036 if (
auto MCE = dyn_cast<MemberExpr>(NakedFn))
4038 else if (
auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
4039 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4041 if (!getLangOpts().CPlusPlus ||
4054 if (!RequireCompleteType(Loc, NakedFn->
getType(), 0)) {
4057 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4058 LookupQualifiedName(R, DC);
4061 ArgExprs.append(Args.begin(), Args.end());
4075 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4087 !CandidateSet.
empty());
4096 if (RequireCompleteType(Loc, Type, 0))
4101 CodeCompleteExpression(S, Type);
4110 for (
auto C : LookupConstructors(RD)) {
4111 if (
auto FD = dyn_cast<FunctionDecl>(
C)) {
4116 }
else if (
auto FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
4117 AddTemplateOverloadCandidate(FTD,
4132 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4134 CodeCompleteOrdinaryName(S, PCC_Expression);
4138 CodeCompleteExpression(S, VD->
getType());
4143 if (isa<BlockDecl>(CurContext)) {
4145 ResultType = BSI->ReturnType;
4146 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
4147 ResultType = Function->getReturnType();
4148 else if (
ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4149 ResultType = Method->getReturnType();
4152 CodeCompleteOrdinaryName(S, PCC_Expression);
4154 CodeCompleteExpression(S, ResultType);
4158 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4159 CodeCompleter->getCodeCompletionTUInfo(),
4161 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4162 Results.EnterNewScope();
4164 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4166 CodeCompleter->includeGlobals());
4172 Results.getCodeCompletionTUInfo());
4173 Builder.AddTypedTextChunk(
"else");
4174 if (Results.includeCodePatterns()) {
4178 Builder.AddPlaceholderChunk(
"statements");
4182 Results.AddResult(
Builder.TakeString());
4185 Builder.AddTypedTextChunk(
"else");
4191 Builder.AddPlaceholderChunk(
"condition");
4193 Builder.AddPlaceholderChunk(
"expression");
4195 if (Results.includeCodePatterns()) {
4199 Builder.AddPlaceholderChunk(
"statements");
4203 Results.AddResult(
Builder.TakeString());
4205 Results.ExitScope();
4210 if (CodeCompleter->includeMacros())
4214 Results.data(),Results.size());
4219 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType());
4221 CodeCompleteOrdinaryName(S, PCC_Expression);
4225 bool EnteringContext) {
4229 DeclContext *Ctx = computeDeclContext(SS, EnteringContext);
4235 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4238 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4239 CodeCompleter->getCodeCompletionTUInfo(),
4241 Results.EnterNewScope();
4247 Results.AddResult(
"template");
4254 if (!EnteringContext)
4256 Results.ExitScope();
4258 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4262 Results.getCompletionContext(),
4263 Results.data(),Results.size());
4270 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4271 CodeCompleter->getCodeCompletionTUInfo(),
4273 &ResultBuilder::IsNestedNameSpecifier);
4274 Results.EnterNewScope();
4282 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4284 CodeCompleter->includeGlobals());
4285 Results.ExitScope();
4289 Results.data(),Results.size());
4298 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4299 CodeCompleter->getCodeCompletionTUInfo(),
4301 &ResultBuilder::IsNamespaceOrAlias);
4302 Results.EnterNewScope();
4303 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4305 CodeCompleter->includeGlobals());
4306 Results.ExitScope();
4309 Results.data(),Results.size());
4320 bool SuppressedGlobalResults
4321 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
4323 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4324 CodeCompleter->getCodeCompletionTUInfo(),
4325 SuppressedGlobalResults
4328 &ResultBuilder::IsNamespace);
4330 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
4335 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
4339 OrigToLatest[NS->getOriginalNamespace()] = *NS;
4343 Results.EnterNewScope();
4344 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
4345 NS = OrigToLatest.begin(),
4346 NSEnd = OrigToLatest.end();
4349 NS->second, Results.getBasePriority(NS->second),
4351 CurContext,
nullptr,
false);
4352 Results.ExitScope();
4356 Results.getCompletionContext(),
4357 Results.data(),Results.size());
4365 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4366 CodeCompleter->getCodeCompletionTUInfo(),
4368 &ResultBuilder::IsNamespaceOrAlias);
4369 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4371 CodeCompleter->includeGlobals());
4373 Results.getCompletionContext(),
4374 Results.data(),Results.size());
4382 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4383 CodeCompleter->getCodeCompletionTUInfo(),
4385 &ResultBuilder::IsType);
4386 Results.EnterNewScope();
4389 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
4390 if (std::strcmp(Spelling, "?")) \
4391 Results.AddResult(Result(Spelling));
4392 #include "clang/Basic/OperatorKinds.def"
4395 Results.allowNestedNameSpecifiers();
4396 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4398 CodeCompleter->includeGlobals());
4402 Results.ExitScope();
4406 Results.data(),Results.size());
4415 AdjustDeclIfTemplate(ConstructorD);
4421 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4422 CodeCompleter->getCodeCompletionTUInfo(),
4424 Results.EnterNewScope();
4427 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
4428 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
4429 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
4430 if (Initializers[I]->isBaseInitializer())
4431 InitializedBases.insert(
4434 InitializedFields.insert(cast<FieldDecl>(
4435 Initializers[I]->getAnyMember()));
4440 Results.getCodeCompletionTUInfo());
4442 bool SawLastInitializer = Initializers.empty();
4444 for (
const auto &
Base : ClassDecl->
bases()) {
4448 = !Initializers.empty() &&
4449 Initializers.back()->isBaseInitializer() &&
4451 QualType(Initializers.back()->getBaseClass(), 0));
4456 Results.getAllocator().CopyString(
4457 Base.getType().getAsString(Policy)));
4459 Builder.AddPlaceholderChunk(
"args");
4464 SawLastInitializer =
false;
4468 for (
const auto &
Base : ClassDecl->
vbases()) {
4472 = !Initializers.empty() &&
4473 Initializers.back()->isBaseInitializer() &&
4475 QualType(Initializers.back()->getBaseClass(), 0));
4480 Builder.getAllocator().CopyString(
4481 Base.getType().getAsString(Policy)));
4483 Builder.AddPlaceholderChunk(
"args");
4488 SawLastInitializer =
false;
4492 for (
auto *Field : ClassDecl->
fields()) {
4493 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
4496 = !Initializers.empty() &&
4497 Initializers.back()->isAnyMemberInitializer() &&
4498 Initializers.back()->getAnyMember() == Field;
4502 if (!Field->getDeclName())
4506 Field->getIdentifier()->getName()));
4508 Builder.AddPlaceholderChunk(
"args");
4516 SawLastInitializer =
false;
4518 Results.ExitScope();
4521 Results.data(), Results.size());
4534 bool AfterAmpersand) {
4535 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4536 CodeCompleter->getCodeCompletionTUInfo(),
4538 Results.EnterNewScope();
4541 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
4542 bool IncludedThis =
false;
4545 IncludedThis =
true;
4554 for (
const auto *D : S->
decls()) {
4555 const auto *Var = dyn_cast<
VarDecl>(D);
4563 CurContext,
nullptr,
false);
4571 Results.ExitScope();
4574 Results.data(), Results.size());
4579 #define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword)
4582 ResultBuilder &Results,
4589 Results.getCodeCompletionTUInfo());
4590 if (LangOpts.ObjC2) {
4594 Builder.AddPlaceholderChunk(
"property");
4595 Results.AddResult(Result(
Builder.TakeString()));
4600 Builder.AddPlaceholderChunk(
"property");
4601 Results.AddResult(Result(
Builder.TakeString()));
4606 ResultBuilder &Results,
4613 if (LangOpts.ObjC2) {
4628 Results.getCodeCompletionTUInfo());
4633 Builder.AddPlaceholderChunk(
"name");
4634 Results.AddResult(Result(
Builder.TakeString()));
4636 if (Results.includeCodePatterns()) {
4642 Builder.AddPlaceholderChunk(
"class");
4643 Results.AddResult(Result(
Builder.TakeString()));
4648 Builder.AddPlaceholderChunk(
"protocol");
4649 Results.AddResult(Result(
Builder.TakeString()));
4654 Builder.AddPlaceholderChunk(
"class");
4655 Results.AddResult(Result(
Builder.TakeString()));
4661 Builder.AddPlaceholderChunk(
"alias");
4663 Builder.AddPlaceholderChunk(
"class");
4664 Results.AddResult(Result(
Builder.TakeString()));
4666 if (Results.getSema().getLangOpts().Modules) {
4670 Builder.AddPlaceholderChunk(
"module");
4671 Results.AddResult(Result(
Builder.TakeString()));
4676 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4677 CodeCompleter->getCodeCompletionTUInfo(),
4679 Results.EnterNewScope();
4680 if (isa<ObjCImplDecl>(CurContext))
4686 Results.ExitScope();
4689 Results.data(),Results.size());
4695 Results.getCodeCompletionTUInfo());
4698 const char *EncodeType =
"char[]";
4699 if (Results.getSema().getLangOpts().CPlusPlus ||
4700 Results.getSema().getLangOpts().ConstStrings)
4701 EncodeType =
"const char[]";
4702 Builder.AddResultTypeChunk(EncodeType);
4705 Builder.AddPlaceholderChunk(
"type-name");
4707 Results.AddResult(Result(
Builder.TakeString()));
4710 Builder.AddResultTypeChunk(
"Protocol *");
4713 Builder.AddPlaceholderChunk(
"protocol-name");
4715 Results.AddResult(Result(
Builder.TakeString()));
4718 Builder.AddResultTypeChunk(
"SEL");
4721 Builder.AddPlaceholderChunk(
"selector");
4723 Results.AddResult(Result(
Builder.TakeString()));
4726 Builder.AddResultTypeChunk(
"NSString *");
4728 Builder.AddPlaceholderChunk(
"string");
4730 Results.AddResult(Result(
Builder.TakeString()));
4733 Builder.AddResultTypeChunk(
"NSArray *");
4735 Builder.AddPlaceholderChunk(
"objects, ...");
4737 Results.AddResult(Result(
Builder.TakeString()));
4740 Builder.AddResultTypeChunk(
"NSDictionary *");
4742 Builder.AddPlaceholderChunk(
"key");
4745 Builder.AddPlaceholderChunk(
"object, ...");
4747 Results.AddResult(Result(
Builder.TakeString()));
4750 Builder.AddResultTypeChunk(
"id");
4752 Builder.AddPlaceholderChunk(
"expression");
4754 Results.AddResult(Result(
Builder.TakeString()));
4760 Results.getCodeCompletionTUInfo());
4762 if (Results.includeCodePatterns()) {
4767 Builder.AddPlaceholderChunk(
"statements");
4769 Builder.AddTextChunk(
"@catch");
4771 Builder.AddPlaceholderChunk(
"parameter");
4774 Builder.AddPlaceholderChunk(
"statements");
4776 Builder.AddTextChunk(
"@finally");
4778 Builder.AddPlaceholderChunk(
"statements");
4780 Results.AddResult(Result(
Builder.TakeString()));
4786 Builder.AddPlaceholderChunk(
"expression");
4787 Results.AddResult(Result(
Builder.TakeString()));
4789 if (Results.includeCodePatterns()) {
4794 Builder.AddPlaceholderChunk(
"expression");
4797 Builder.AddPlaceholderChunk(
"statements");
4799 Results.AddResult(Result(
Builder.TakeString()));
4804 ResultBuilder &Results,
4815 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4816 CodeCompleter->getCodeCompletionTUInfo(),
4818 Results.EnterNewScope();
4820 Results.ExitScope();
4823 Results.data(),Results.size());
4827 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4828 CodeCompleter->getCodeCompletionTUInfo(),
4830 Results.EnterNewScope();
4833 Results.ExitScope();
4836 Results.data(),Results.size());
4840 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4841 CodeCompleter->getCodeCompletionTUInfo(),
4843 Results.EnterNewScope();
4845 Results.ExitScope();
4848 Results.data(),Results.size());
4855 if (Attributes & NewFlag)
4858 Attributes |= NewFlag;
4872 if (AssignCopyRetMask &&
4890 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4891 CodeCompleter->getCodeCompletionTUInfo(),
4893 Results.EnterNewScope();
4921 Results.getCodeCompletionTUInfo());
4923 Setter.AddTextChunk(
"=");
4924 Setter.AddPlaceholderChunk(
"method");
4929 Results.getCodeCompletionTUInfo());
4931 Getter.AddTextChunk(
"=");
4932 Getter.AddPlaceholderChunk(
"method");
4941 Results.ExitScope();
4944 Results.data(),Results.size());
4957 ArrayRef<IdentifierInfo *> SelIdents,
4958 bool AllowSameLength =
true) {
4959 unsigned NumSelIdents = SelIdents.size();
4969 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
4972 for (
unsigned I = 0; I != NumSelIdents; ++I)
4981 ArrayRef<IdentifierInfo *> SelIdents,
4982 bool AllowSameLength =
true) {
4990 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5014 bool WantInstanceMethods,
5016 ArrayRef<IdentifierInfo *> SelIdents,
5018 VisitedSelectorSet &Selectors,
5019 bool AllowSameLength,
5020 ResultBuilder &Results,
5021 bool InOriginalClass =
true) {
5026 for (
auto *M : Container->
methods()) {
5029 if (M->isInstanceMethod() == WantInstanceMethods ||
5030 (isRootClass && !WantInstanceMethods)) {
5036 if (!Selectors.insert(M->getSelector()).second)
5039 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5040 R.StartParameter = SelIdents.size();
5041 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5042 if (!InOriginalClass)
5044 Results.MaybeAddResult(R, CurContext);
5050 if (Protocol->hasDefinition()) {
5052 = Protocol->getReferencedProtocols();
5054 E = Protocols.
end();
5057 CurContext, Selectors, AllowSameLength, Results,
false);
5067 CurContext, Selectors, AllowSameLength, Results,
false);
5071 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5072 CurContext, Selectors, AllowSameLength,
5073 Results, InOriginalClass);
5077 = CatDecl->getReferencedProtocols();
5079 E = Protocols.
end();
5082 CurContext, Selectors, AllowSameLength,
5088 CurContext, Selectors, AllowSameLength,
5089 Results, InOriginalClass);
5095 SelIdents, CurContext, Selectors,
5096 AllowSameLength, Results,
false);
5101 CurContext, Selectors, AllowSameLength,
5102 Results, InOriginalClass);
5111 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5112 Class = Category->getClassInterface();
5119 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5120 CodeCompleter->getCodeCompletionTUInfo(),
5122 Results.EnterNewScope();
5124 VisitedSelectorSet Selectors;
5127 Results.ExitScope();
5130 Results.data(),Results.size());
5136 = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
5139 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5140 Class = Category->getClassInterface();
5147 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5148 CodeCompleter->getCodeCompletionTUInfo(),
5150 Results.EnterNewScope();
5152 VisitedSelectorSet Selectors;
5154 Selectors,
true, Results);
5156 Results.ExitScope();
5159 Results.data(),Results.size());
5164 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5165 CodeCompleter->getCodeCompletionTUInfo(),
5167 Results.EnterNewScope();
5170 bool AddedInOut =
false;
5173 Results.AddResult(
"in");
5174 Results.AddResult(
"inout");
5179 Results.AddResult(
"out");
5181 Results.AddResult(
"inout");
5186 Results.AddResult(
"bycopy");
5187 Results.AddResult(
"byref");
5188 Results.AddResult(
"oneway");
5191 Results.AddResult(
"nonnull");
5192 Results.AddResult(
"nullable");
5193 Results.AddResult(
"null_unspecified");
5201 PP.isMacroDefined(
"IBAction")) {
5203 Results.getCodeCompletionTUInfo(),
5205 Builder.AddTypedTextChunk(
"IBAction");
5207 Builder.AddPlaceholderChunk(
"selector");
5212 Builder.AddTextChunk(
"sender");
5223 Results.ExitScope();
5226 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
5227 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5229 CodeCompleter->includeGlobals());
5231 if (CodeCompleter->includeMacros())
5236 Results.data(), Results.size());
5266 IFace = ObjType->getInterface();
5272 IFace = Ptr->getInterfaceDecl();
5286 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5287 .Case(
"retain", IFace)
5288 .Case(
"strong", IFace)
5289 .Case(
"autorelease", IFace)
5290 .Case(
"copy", IFace)
5291 .Case(
"copyWithZone", IFace)
5292 .Case(
"mutableCopy", IFace)
5293 .Case(
"mutableCopyWithZone", IFace)
5294 .Case(
"awakeFromCoder", IFace)
5295 .Case(
"replacementObjectFromCoder", IFace)
5296 .Case(
"class", IFace)
5297 .Case(
"classForCoder", IFace)
5298 .Case(
"superclass", Super)
5301 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5303 .Case(
"alloc", IFace)
5304 .Case(
"allocWithZone", IFace)
5305 .Case(
"class", IFace)
5306 .Case(
"superclass", Super)
5327 Sema &
S,
bool NeedSuperKeyword,
5328 ArrayRef<IdentifierInfo *> SelIdents,
5329 ResultBuilder &Results) {
5348 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
5366 CurP != CurPEnd; ++CurP, ++SuperP) {
5369 (*SuperP)->getType()))
5373 if (!(*CurP)->getIdentifier())
5379 Results.getCodeCompletionTUInfo());
5383 Results.getCompletionContext().getBaseType(),
5387 if (NeedSuperKeyword) {
5388 Builder.AddTypedTextChunk(
"super");
5394 if (NeedSuperKeyword)
5402 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
5403 if (I > SelIdents.size())
5406 if (I < SelIdents.size())
5408 Builder.getAllocator().CopyString(
5410 else if (NeedSuperKeyword || I > SelIdents.size()) {
5412 Builder.getAllocator().CopyString(
5415 (*CurP)->getIdentifier()->getName()));
5418 Builder.getAllocator().CopyString(
5421 (*CurP)->getIdentifier()->getName()));
5433 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5434 CodeCompleter->getCodeCompletionTUInfo(),
5436 getLangOpts().CPlusPlus11
5437 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
5438 : &ResultBuilder::IsObjCMessageReceiver);
5440 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5441 Results.EnterNewScope();
5443 CodeCompleter->includeGlobals());
5449 if (Iface->getSuperClass()) {
5450 Results.AddResult(Result(
"super"));
5458 Results.ExitScope();
5460 if (CodeCompleter->includeMacros())
5463 Results.data(), Results.size());
5469 bool AtArgumentExpression) {
5473 CDecl = CurMethod->getClassInterface();
5482 if (CurMethod->isInstanceMethod()) {
5486 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
5487 AtArgumentExpression,
5496 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc,
5497 LookupOrdinaryName);
5498 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
5500 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
5503 CDecl = Iface->getInterface();
5504 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
5511 id.setIdentifier(Super, SuperLoc);
5512 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
5514 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
5516 AtArgumentExpression);
5525 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
5526 AtArgumentExpression,
5533 unsigned NumSelIdents) {
5535 ASTContext &Context = Results.getSema().Context;
5539 Result *ResultsData = Results.data();
5540 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
5541 Result &R = ResultsData[I];
5542 if (R.Kind == Result::RK_Declaration &&
5543 isa<ObjCMethodDecl>(R.Declaration)) {
5544 if (R.Priority <= BestPriority) {
5545 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
5546 if (NumSelIdents <= Method->param_size()) {
5549 if (R.Priority < BestPriority || PreferredType.
isNull()) {
5550 BestPriority = R.Priority;
5551 PreferredType = MyPreferredType;
5561 return PreferredType;
5566 ArrayRef<IdentifierInfo *> SelIdents,
5567 bool AtArgumentExpression,
5569 ResultBuilder &Results) {
5579 CDecl = Interface->getInterface();
5584 Results.EnterNewScope();
5591 Results.Ignore(SuperMethod);
5597 Results.setPreferredSelector(CurMethod->getSelector());
5599 VisitedSelectorSet Selectors;
5602 SemaRef.
CurContext, Selectors, AtArgumentExpression,
5610 for (uint32_t I = 0,
5621 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
5626 MethList = MethList->getNext()) {
5630 Result R(MethList->getMethod(),
5631 Results.getBasePriority(MethList->getMethod()),
nullptr);
5632 R.StartParameter = SelIdents.size();
5633 R.AllParametersAreInformative =
false;
5634 Results.MaybeAddResult(R, SemaRef.
CurContext);
5639 Results.ExitScope();
5644 bool AtArgumentExpression,
5647 QualType T = this->GetTypeFromParser(Receiver);
5649 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5650 CodeCompleter->getCodeCompletionTUInfo(),
5655 AtArgumentExpression, IsSuper, Results);
5662 if (AtArgumentExpression) {
5665 if (PreferredType.
isNull())
5666 CodeCompleteOrdinaryName(S, PCC_Expression);
5668 CodeCompleteExpression(S, PreferredType);
5673 Results.getCompletionContext(),
5674 Results.data(), Results.size());
5679 bool AtArgumentExpression,
5683 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
5688 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
5691 RecExpr = Conv.
get();
5704 return CodeCompleteObjCClassMessage(S,
5707 AtArgumentExpression, Super);
5712 }
else if (RecExpr && getLangOpts().CPlusPlus) {
5713 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
5715 RecExpr = Conv.
get();
5716 ReceiverType = RecExpr->
getType();
5721 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5722 CodeCompleter->getCodeCompletionTUInfo(),
5724 ReceiverType, SelIdents));
5726 Results.EnterNewScope();
5733 Results.Ignore(SuperMethod);
5739 Results.setPreferredSelector(CurMethod->getSelector());
5742 VisitedSelectorSet Selectors;
5752 CurContext, Selectors, AtArgumentExpression, Results);
5759 for (
auto *I : QualID->quals())
5761 Selectors, AtArgumentExpression, Results);
5768 CurContext, Selectors, AtArgumentExpression,
5772 for (
auto *I : IFacePtr->quals())
5774 Selectors, AtArgumentExpression, Results);
5783 if (ExternalSource) {
5784 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
5786 Selector Sel = ExternalSource->GetExternalSelector(I);
5787 if (Sel.
isNull() || MethodPool.count(Sel))
5790 ReadMethodPool(Sel);
5794 for (GlobalMethodPool::iterator M = MethodPool.begin(),
5795 MEnd = MethodPool.end();
5799 MethList = MethList->getNext()) {
5803 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
5806 Result R(MethList->getMethod(),
5807 Results.getBasePriority(MethList->getMethod()),
nullptr);
5808 R.StartParameter = SelIdents.size();
5809 R.AllParametersAreInformative =
false;
5810 Results.MaybeAddResult(R, CurContext);
5814 Results.ExitScope();
5822 if (AtArgumentExpression) {
5825 if (PreferredType.
isNull())
5826 CodeCompleteOrdinaryName(S, PCC_Expression);
5828 CodeCompleteExpression(S, PreferredType);
5833 Results.getCompletionContext(),
5834 Results.data(),Results.size());
5850 CodeCompleteExpression(S, Data);
5857 if (ExternalSource) {
5858 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
5860 Selector Sel = ExternalSource->GetExternalSelector(I);
5861 if (Sel.
isNull() || MethodPool.count(Sel))
5864 ReadMethodPool(Sel);
5868 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5869 CodeCompleter->getCodeCompletionTUInfo(),
5871 Results.EnterNewScope();
5872 for (GlobalMethodPool::iterator M = MethodPool.begin(),
5873 MEnd = MethodPool.end();
5881 Results.getCodeCompletionTUInfo());
5885 Results.AddResult(
Builder.TakeString());
5889 std::string Accumulator;
5890 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
5891 if (I == SelIdents.size()) {
5892 if (!Accumulator.empty()) {
5895 Accumulator.clear();
5902 Builder.AddTypedTextChunk(
Builder.getAllocator().CopyString( Accumulator));
5903 Results.AddResult(
Builder.TakeString());
5905 Results.ExitScope();
5909 Results.data(), Results.size());
5915 bool OnlyForwardDeclarations,
5916 ResultBuilder &Results) {
5919 for (
const auto *D : Ctx->
decls()) {
5921 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
5922 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
5923 Results.AddResult(Result(Proto, Results.getBasePriority(Proto),
nullptr),
5924 CurContext,
nullptr,
false);
5929 unsigned NumProtocols) {
5930 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5931 CodeCompleter->getCodeCompletionTUInfo(),
5934 if (CodeCompleter && CodeCompleter->includeGlobals()) {
5935 Results.EnterNewScope();
5940 for (
unsigned I = 0; I != NumProtocols; ++I)
5942 Protocols[I].second))
5943 Results.Ignore(Protocol);
5949 Results.ExitScope();
5954 Results.data(),Results.size());
5958 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5959 CodeCompleter->getCodeCompletionTUInfo(),
5962 if (CodeCompleter && CodeCompleter->includeGlobals()) {
5963 Results.EnterNewScope();
5969 Results.ExitScope();
5974 Results.data(),Results.size());
5980 bool OnlyForwardDeclarations,
5981 bool OnlyUnimplemented,
5982 ResultBuilder &Results) {
5985 for (
const auto *D : Ctx->
decls()) {
5987 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
5988 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
5989 (!OnlyUnimplemented || !Class->getImplementation()))
5990 Results.AddResult(Result(Class, Results.getBasePriority(Class),
nullptr),
5991 CurContext,
nullptr,
false);
5996 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5997 CodeCompleter->getCodeCompletionTUInfo(),
5999 Results.EnterNewScope();
6001 if (CodeCompleter->includeGlobals()) {
6007 Results.ExitScope();
6011 Results.data(),Results.size());
6016 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6017 CodeCompleter->getCodeCompletionTUInfo(),
6019 Results.EnterNewScope();
6023 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6024 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6025 Results.Ignore(CurClass);
6027 if (CodeCompleter->includeGlobals()) {
6033 Results.ExitScope();
6037 Results.data(),Results.size());
6041 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6042 CodeCompleter->getCodeCompletionTUInfo(),
6044 Results.EnterNewScope();
6046 if (CodeCompleter->includeGlobals()) {
6052 Results.ExitScope();
6056 Results.data(),Results.size());
6064 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6065 CodeCompleter->getCodeCompletionTUInfo(),
6070 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6072 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6074 for (
const auto *Cat : Class->visible_categories())
6075 CategoryNames.insert(Cat->getIdentifier());
6079 Results.EnterNewScope();
6081 for (
const auto *D : TU->
decls())
6082 if (
const auto *Category = dyn_cast<ObjCCategoryDecl>(D))
6083 if (CategoryNames.insert(Category->getIdentifier()).second)
6084 Results.AddResult(Result(Category, Results.getBasePriority(Category),
6086 CurContext,
nullptr,
false);
6087 Results.ExitScope();
6091 Results.data(),Results.size());
6103 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6106 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6108 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6109 CodeCompleter->getCodeCompletionTUInfo(),
6115 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6116 Results.EnterNewScope();
6117 bool IgnoreImplemented =
true;
6120 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6121 CategoryNames.insert(Cat->getIdentifier()).second)
6122 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6123 CurContext,
nullptr,
false);
6127 IgnoreImplemented =
false;
6129 Results.ExitScope();
6133 Results.data(),Results.size());
6138 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6139 CodeCompleter->getCodeCompletionTUInfo(),
6144 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6146 (!isa<ObjCImplementationDecl>(Container) &&
6147 !isa<ObjCCategoryImplDecl>(Container)))
6152 for (
const auto *D : Container->decls())
6153 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6154 Results.Ignore(PropertyImpl->getPropertyDecl());
6158 Results.EnterNewScope();
6160 = dyn_cast<ObjCImplementationDecl>(Container))
6163 AddedProperties, Results);
6166 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6167 false,
false, CurContext,
6168 AddedProperties, Results);
6169 Results.ExitScope();
6173 Results.data(),Results.size());
6179 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6180 CodeCompleter->getCodeCompletionTUInfo(),
6185 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6187 (!isa<ObjCImplementationDecl>(Container) &&
6188 !isa<ObjCCategoryImplDecl>(Container)))
6194 = dyn_cast<ObjCImplementationDecl>(Container))
6195 Class = ClassImpl->getClassInterface();
6197 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl()
6198 ->getClassInterface();
6206 =
Property->getType().getNonReferenceType().getUnqualifiedType();
6209 Results.setPreferredType(PropertyType);
6214 Results.EnterNewScope();
6215 bool SawSimilarlyNamedIvar =
false;
6216 std::string NameWithPrefix;
6217 NameWithPrefix +=
'_';
6218 NameWithPrefix += PropertyName->
getName();
6219 std::string NameWithSuffix = PropertyName->
getName().str();
6220 NameWithSuffix +=
'_';
6224 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6225 CurContext,
nullptr,
false);
6229 if ((PropertyName == Ivar->getIdentifier() ||
6230 NameWithPrefix == Ivar->
getName() ||
6231 NameWithSuffix == Ivar->getName())) {
6232 SawSimilarlyNamedIvar =
true;
6236 if (Results.size() &&
6237 Results.data()[Results.size() - 1].Kind
6239 Results.data()[Results.size() - 1].Declaration == Ivar)
6240 Results.data()[Results.size() - 1].Priority--;
6245 if (!SawSimilarlyNamedIvar) {
6256 Policy, Allocator));
6258 Results.AddResult(Result(
Builder.TakeString(), Priority,
6262 Results.ExitScope();
6266 Results.data(),Results.size());
6271 typedef llvm::DenseMap<
6280 bool WantInstanceMethods,
6283 bool InOriginalClass =
true) {
6286 if (!IFace->hasDefinition())
6289 IFace = IFace->getDefinition();
6293 = IFace->getReferencedProtocols();
6295 E = Protocols.
end();
6298 KnownMethods, InOriginalClass);
6301 for (
auto *Cat : IFace->visible_categories()) {
6303 KnownMethods,
false);
6307 if (IFace->getSuperClass())
6309 WantInstanceMethods, ReturnType,
6310 KnownMethods,
false);
6316 = Category->getReferencedProtocols();
6318 E = Protocols.
end();
6321 KnownMethods, InOriginalClass);
6324 if (InOriginalClass && Category->getClassInterface())
6326 WantInstanceMethods, ReturnType, KnownMethods,
6332 if (!Protocol->hasDefinition())
6334 Protocol = Protocol->getDefinition();
6335 Container = Protocol;
6339 = Protocol->getReferencedProtocols();
6341 E = Protocols.
end();
6344 KnownMethods,
false);
6350 for (
auto *M : Container->
methods()) {
6351 if (M->isInstanceMethod() == WantInstanceMethods) {
6352 if (!ReturnType.
isNull() &&
6356 KnownMethods[M->getSelector()] =
6357 KnownMethodsMap::mapped_type(M, InOriginalClass);
6365 unsigned ObjCDeclQuals,
6394 bool IsInstanceMethod,
6397 VisitedSelectorSet &KnownSelectors,
6398 ResultBuilder &Results) {
6400 if (!PropName || PropName->
getLength() == 0)
6418 const char *CopiedKey;
6421 :
Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
6423 operator const char *() {
6427 return CopiedKey = Allocator.
CopyString(Key);
6429 } Key(Allocator, PropName->
getName());
6432 std::string UpperKey = PropName->
getName();
6433 if (!UpperKey.empty())
6436 bool ReturnTypeMatchesProperty = ReturnType.
isNull() ||
6439 bool ReturnTypeMatchesVoid
6443 if (IsInstanceMethod &&
6444 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
6450 Builder.AddTypedTextChunk(Key);
6457 if (IsInstanceMethod &&
6458 ((!ReturnType.
isNull() &&
6463 std::string SelectorName = (Twine(
"is") + UpperKey).str();
6465 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6467 if (ReturnType.
isNull()) {
6481 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
6483 std::string SelectorName = (Twine(
"set") + UpperKey).str();
6485 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6486 if (ReturnType.
isNull()) {
6494 Builder.AddTypedTextChunk(
":");
6533 if (IsInstanceMethod &&
6535 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
6537 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6539 if (ReturnType.
isNull()) {
6541 Builder.AddTextChunk(
"NSUInteger");
6547 Results.AddResult(Result(
Builder.TakeString(),
6548 std::min(IndexedGetterPriority,
6549 UnorderedGetterPriority),
6556 if (IsInstanceMethod &&
6558 std::string SelectorName
6559 = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
6561 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6562 if (ReturnType.
isNull()) {
6570 Builder.AddTextChunk(
"NSUInteger");
6572 Builder.AddTextChunk(
"index");
6573 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6579 if (IsInstanceMethod &&
6584 ->getName() ==
"NSArray"))) {
6585 std::string SelectorName
6586 = (Twine(Property->
getName()) +
"AtIndexes").str();
6588 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6589 if (ReturnType.
isNull()) {
6591 Builder.AddTextChunk(
"NSArray *");
6597 Builder.AddTextChunk(
"NSIndexSet *");
6599 Builder.AddTextChunk(
"indexes");
6600 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6606 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6607 std::string SelectorName = (Twine(
"get") + UpperKey).str();
6613 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6614 if (ReturnType.
isNull()) {
6622 Builder.AddPlaceholderChunk(
"object-type");
6625 Builder.AddTextChunk(
"buffer");
6627 Builder.AddTypedTextChunk(
"range:");
6629 Builder.AddTextChunk(
"NSRange");
6631 Builder.AddTextChunk(
"inRange");
6632 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6640 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6641 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
6647 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6648 if (ReturnType.
isNull()) {
6654 Builder.AddTypedTextChunk(
"insertObject:");
6656 Builder.AddPlaceholderChunk(
"object-type");
6659 Builder.AddTextChunk(
"object");
6663 Builder.AddPlaceholderChunk(
"NSUInteger");
6665 Builder.AddTextChunk(
"index");
6666 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6672 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6673 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
6679 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6680 if (ReturnType.
isNull()) {
6688 Builder.AddTextChunk(
"NSArray *");
6690 Builder.AddTextChunk(
"array");
6692 Builder.AddTypedTextChunk(
"atIndexes:");
6694 Builder.AddPlaceholderChunk(
"NSIndexSet *");
6696 Builder.AddTextChunk(
"indexes");
6697 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6703 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6704 std::string SelectorName
6705 = (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
6707 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6708 if (ReturnType.
isNull()) {
6716 Builder.AddTextChunk(
"NSUInteger");
6718 Builder.AddTextChunk(
"index");
6719 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6725 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6726 std::string SelectorName
6727 = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
6729 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6730 if (ReturnType.
isNull()) {
6738 Builder.AddTextChunk(
"NSIndexSet *");
6740 Builder.AddTextChunk(
"indexes");
6741 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6747 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6748 std::string SelectorName
6749 = (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
6755 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6756 if (ReturnType.
isNull()) {
6764 Builder.AddPlaceholderChunk(
"NSUInteger");
6766 Builder.AddTextChunk(
"index");
6768 Builder.AddTypedTextChunk(
"withObject:");
6772 Builder.AddTextChunk(
"object");
6773 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6779 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6780 std::string SelectorName1
6781 = (Twine(
"replace") + UpperKey +
"AtIndexes").str();
6782 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
6788 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6789 if (ReturnType.
isNull()) {
6797 Builder.AddPlaceholderChunk(
"NSIndexSet *");
6799 Builder.AddTextChunk(
"indexes");
6803 Builder.AddTextChunk(
"NSArray *");
6805 Builder.AddTextChunk(
"array");
6806 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6813 if (IsInstanceMethod &&
6818 ->getName() ==
"NSEnumerator"))) {
6819 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
6821 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6823 if (ReturnType.
isNull()) {
6825 Builder.AddTextChunk(
"NSEnumerator *");
6830 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
6836 if (IsInstanceMethod &&
6838 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
6840 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6841 if (ReturnType.
isNull()) {
6843 Builder.AddPlaceholderChunk(
"object-type");
6850 if (ReturnType.
isNull()) {
6851 Builder.AddPlaceholderChunk(
"object-type");
6859 Builder.AddTextChunk(
"object");
6860 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
6867 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6868 std::string SelectorName
6869 = (Twine(
"add") + UpperKey + Twine(
"Object")).str();
6871 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6872 if (ReturnType.
isNull()) {
6880 Builder.AddPlaceholderChunk(
"object-type");
6883 Builder.AddTextChunk(
"object");
6884 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6890 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6891 std::string SelectorName = (Twine(
"add") + UpperKey).str();
6893 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6894 if (ReturnType.
isNull()) {
6902 Builder.AddTextChunk(
"NSSet *");
6904 Builder.AddTextChunk(
"objects");
6905 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6911 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6912 std::string SelectorName
6913 = (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
6915 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6916 if (ReturnType.
isNull()) {
6924 Builder.AddPlaceholderChunk(
"object-type");
6927 Builder.AddTextChunk(
"object");
6928 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6934 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6935 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
6937 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6938 if (ReturnType.
isNull()) {
6946 Builder.AddTextChunk(
"NSSet *");
6948 Builder.AddTextChunk(
"objects");
6949 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6955 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6956 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
6958 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6959 if (ReturnType.
isNull()) {
6967 Builder.AddTextChunk(
"NSSet *");
6969 Builder.AddTextChunk(
"objects");
6970 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6977 if (!IsInstanceMethod &&
6982 ->getName() ==
"NSSet"))) {
6983 std::string SelectorName
6984 = (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
6986 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6988 if (ReturnType.
isNull()) {
6990 Builder.AddTextChunk(
"NSSet *");
7001 if (!IsInstanceMethod &&
7005 std::string SelectorName
7006 = (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
7008 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7010 if (ReturnType.
isNull()) {
7024 bool IsInstanceMethod,
7028 QualType ReturnType = GetTypeFromParser(ReturnTy);
7029 Decl *IDecl =
nullptr;
7032 IDecl = cast<Decl>(OCD);
7036 bool IsInImplementation =
false;
7037 if (
Decl *D = IDecl) {
7039 SearchDecl = Impl->getClassInterface();
7040 IsInImplementation =
true;
7042 = dyn_cast<ObjCCategoryImplDecl>(D)) {
7043 SearchDecl = CatImpl->getCategoryDecl();
7044 IsInImplementation =
true;
7049 if (!SearchDecl && S) {
7051 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7064 ReturnType, KnownMethods);
7068 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7069 CodeCompleter->getCodeCompletionTUInfo(),
7071 Results.EnterNewScope();
7073 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7074 MEnd = KnownMethods.end();
7078 Results.getCodeCompletionTUInfo());
7098 P != PEnd; (void)++
P, ++I) {
7101 Builder.AddTypedTextChunk(
":");
7112 ParamType = (*P)->getType();
7114 ParamType = (*P)->getOriginalType();
7118 (*P)->getObjCDeclQualifier(),
7123 Builder.AddTextChunk(
Builder.getAllocator().CopyString( Id->getName()));
7132 if (IsInImplementation && Results.includeCodePatterns()) {
7139 Builder.AddTextChunk(
"return");
7141 Builder.AddPlaceholderChunk(
"expression");
7144 Builder.AddPlaceholderChunk(
"statements");
7151 if (!M->second.getInt())
7154 Results.AddResult(Result(
Builder.TakeString(), Method, Priority));
7161 Containers.push_back(SearchDecl);
7163 VisitedSelectorSet KnownSelectors;
7164 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7165 MEnd = KnownMethods.end();
7167 KnownSelectors.insert(M->first);
7173 IFace = Category->getClassInterface();
7177 Containers.push_back(Cat);
7179 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
7180 for (
auto *
P : Containers[I]->properties())
7182 KnownSelectors, Results);
7185 Results.ExitScope();
7189 Results.data(),Results.size());
7193 bool IsInstanceMethod,
7194 bool AtParameterName,
7199 if (ExternalSource) {
7200 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
7202 Selector Sel = ExternalSource->GetExternalSelector(I);
7203 if (Sel.
isNull() || MethodPool.count(Sel))
7206 ReadMethodPool(Sel);
7212 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7213 CodeCompleter->getCodeCompletionTUInfo(),
7217 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7219 Results.EnterNewScope();
7220 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7221 MEnd = MethodPool.end();
7223 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first :
7226 MethList = MethList->getNext()) {
7230 if (AtParameterName) {
7232 unsigned NumSelIdents = SelIdents.size();
7234 NumSelIdents <= MethList->getMethod()->param_size()) {
7236 MethList->getMethod()->parameters()[NumSelIdents - 1];
7239 Results.getCodeCompletionTUInfo());
7242 Results.AddResult(
Builder.TakeString());
7249 Result R(MethList->getMethod(),
7250 Results.getBasePriority(MethList->getMethod()),
nullptr);
7251 R.StartParameter = SelIdents.size();
7252 R.AllParametersAreInformative =
false;
7253 R.DeclaringEntity =
true;
7254 Results.MaybeAddResult(R, CurContext);
7258 Results.ExitScope();
7261 Results.data(),Results.size());
7265 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7266 CodeCompleter->getCodeCompletionTUInfo(),
7268 Results.EnterNewScope();
7272 Results.getCodeCompletionTUInfo());
7273 Builder.AddTypedTextChunk(
"if");
7275 Builder.AddPlaceholderChunk(
"condition");
7276 Results.AddResult(
Builder.TakeString());
7279 Builder.AddTypedTextChunk(
"ifdef");
7281 Builder.AddPlaceholderChunk(
"macro");
7282 Results.AddResult(
Builder.TakeString());
7285 Builder.AddTypedTextChunk(
"ifndef");
7287 Builder.AddPlaceholderChunk(
"macro");
7288 Results.AddResult(
Builder.TakeString());
7290 if (InConditional) {
7292 Builder.AddTypedTextChunk(
"elif");
7294 Builder.AddPlaceholderChunk(
"condition");
7295 Results.AddResult(
Builder.TakeString());
7298 Builder.AddTypedTextChunk(
"else");
7299 Results.AddResult(
Builder.TakeString());
7302 Builder.AddTypedTextChunk(
"endif");
7303 Results.AddResult(
Builder.TakeString());
7307 Builder.AddTypedTextChunk(
"include");
7310 Builder.AddPlaceholderChunk(
"header");
7312 Results.AddResult(
Builder.TakeString());
7315 Builder.AddTypedTextChunk(
"include");
7318 Builder.AddPlaceholderChunk(
"header");
7320 Results.AddResult(
Builder.TakeString());
7323 Builder.AddTypedTextChunk(
"define");
7325 Builder.AddPlaceholderChunk(
"macro");
7326 Results.AddResult(
Builder.TakeString());
7329 Builder.AddTypedTextChunk(
"define");
7331 Builder.AddPlaceholderChunk(
"macro");
7333 Builder.AddPlaceholderChunk(
"args");
7335 Results.AddResult(
Builder.TakeString());
7338 Builder.AddTypedTextChunk(
"undef");
7340 Builder.AddPlaceholderChunk(
"macro");
7341 Results.AddResult(
Builder.TakeString());
7344 Builder.AddTypedTextChunk(
"line");
7346 Builder.AddPlaceholderChunk(
"number");
7347 Results.AddResult(
Builder.TakeString());
7350 Builder.AddTypedTextChunk(
"line");
7352 Builder.AddPlaceholderChunk(
"number");
7355 Builder.AddPlaceholderChunk(
"filename");
7357 Results.AddResult(
Builder.TakeString());
7360 Builder.AddTypedTextChunk(
"error");
7362 Builder.AddPlaceholderChunk(
"message");
7363 Results.AddResult(
Builder.TakeString());
7366 Builder.AddTypedTextChunk(
"pragma");
7368 Builder.AddPlaceholderChunk(
"arguments");
7369 Results.AddResult(
Builder.TakeString());
7371 if (getLangOpts().ObjC1) {
7373 Builder.AddTypedTextChunk(
"import");
7376 Builder.AddPlaceholderChunk(
"header");
7378 Results.AddResult(
Builder.TakeString());
7381 Builder.AddTypedTextChunk(
"import");
7384 Builder.AddPlaceholderChunk(
"header");
7386 Results.AddResult(
Builder.TakeString());
7390 Builder.AddTypedTextChunk(
"include_next");
7393 Builder.AddPlaceholderChunk(
"header");
7395 Results.AddResult(
Builder.TakeString());
7398 Builder.AddTypedTextChunk(
"include_next");
7401 Builder.AddPlaceholderChunk(
"header");
7403 Results.AddResult(
Builder.TakeString());
7406 Builder.AddTypedTextChunk(
"warning");
7408 Builder.AddPlaceholderChunk(
"message");
7409 Results.AddResult(
Builder.TakeString());
7416 Results.ExitScope();
7420 Results.data(), Results.size());
7424 CodeCompleteOrdinaryName(S,
7430 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7431 CodeCompleter->getCodeCompletionTUInfo(),
7434 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
7437 Results.getCodeCompletionTUInfo());
7438 Results.EnterNewScope();
7440 MEnd = PP.macro_end();
7443 M->first->getName()));
7448 Results.ExitScope();
7449 }
else if (IsDefinition) {
7454 Results.data(), Results.size());
7458 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7459 CodeCompleter->getCodeCompletionTUInfo(),
7462 if (!CodeCompleter || CodeCompleter->includeMacros())
7466 Results.EnterNewScope();
7468 Results.getCodeCompletionTUInfo());
7469 Builder.AddTypedTextChunk(
"defined");
7472 Builder.AddPlaceholderChunk(
"macro");
7474 Results.AddResult(
Builder.TakeString());
7475 Results.ExitScope();
7479 Results.data(), Results.size());
7485 unsigned Argument) {
7502 ResultBuilder
Builder(*
this, Allocator, CCTUInfo,
7504 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
7505 CodeCompletionDeclConsumer Consumer(Builder,
7511 if (!CodeCompleter || CodeCompleter->includeMacros())
7515 Results.insert(Results.end(),
7516 Builder.data(), Builder.data() + Builder.size());
pointer operator->() const
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
unsigned getFlags() const
The receiver is the instance of the superclass object.
static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, bool IsInstanceMethod, QualType ReturnType, ASTContext &Context, VisitedSelectorSet &KnownSelectors, ResultBuilder &Results)
Add code completions for Objective-C Key-Value Coding (KVC) and Key-Value Observing (KVO)...
param_const_iterator param_begin() const
bool hasDefinition() const
Determine whether this class has been defined.
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
bool isObjCObjectOrInterfaceType() const
const SwitchCase * getNextSwitchCase() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
StringRef getName() const
A C++ namespace alias declaration.
Smart pointer class that efficiently represents Objective-C method names.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const
Create a new code-completion string that describes the function signature of this overload candidate...
Any kind of method, provided it means other specified criteria.
bool isObjCContainer() const
This is a scope that corresponds to the parameters within a function prototype.
ObjCInterfaceDecl * getClassInterface()
static void AddQualifierToCompletionString(CodeCompletionBuilder &Result, NestedNameSpecifier *Qualifier, bool QualifierIsInformative, ASTContext &Context, const PrintingPolicy &Policy)
Add a qualifier to the given code-completion string, if the provided nested-name-specifier is non-NUL...
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program...
bool isMemberPointerType() const
Code completion occurs within a class, struct, or union.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Priority for the Objective-C "_cmd" implicit parameter.
Code completion for a selector, as in an @selector expression.
IdentifierInfo * getIdentifier() const
const LangOptions & getLangOpts() const
CodeCompleteConsumer::OverloadCandidate ResultCandidate
submodule_iterator submodule_begin()
const Scope * getFnParent() const
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true)
Add all of the Objective-C methods in the given Objective-C container to the set of results...
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
Code completion where an Objective-C class message is expected.
static bool isObjCReceiverType(ASTContext &C, QualType T)
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
const Scope * getParent() const
Code completion within a type-qualifier list.
bool isRecordType() const
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Captures information about "declaration specifiers" specific to Objective-C.
void CodeCompleteUsing(Scope *S)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for...
static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
bool isEnumeralType() const
std::ptrdiff_t difference_type
Defines the clang::MacroInfo and clang::MacroDirective classes.
std::string getAsString() const
void CodeCompleteNaturalLanguage()
pointer(const DeclIndexPair &Value)
bool isObjCQualifiedClassType() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getLength() const
Efficiently return the length of this identifier info.
An unspecified code-completion context.
NamespaceDecl - Represent a C++ namespace.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
Wrapper for source info for typedefs.
A C++ non-type template parameter.
ObjCDeclQualifier getObjCDeclQualifier() const
An Objective-C @interface for a category.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext)
bool isBooleanType() const
A container of type source information.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
bool isBlockPointerType() const
Scope * getContinueParent()
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
MacroMap::const_iterator macro_iterator
Represents a C++ constructor within a class.
Code completion occurred where an Objective-C message receiver is expected.
iterator(const NamedDecl *SingleDecl, unsigned Index)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteObjCPropertyGetter(Scope *S)
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr * > Args)
Priority for a member declaration found from the current method or member function.
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
static const char * GetCompletionTypeString(QualType T, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionAllocator &Allocator)
Retrieve the string representation of the given type as a string that has the appropriate lifetime fo...
visible_categories_range visible_categories() const
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
SmallVector< SwitchStmt *, 8 > SwitchStack
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited)
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
AccessSpecifier getAccess() const
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
TypeSpecifierType
Specifies the kind of type.
The "__interface" keyword.
An Objective-C @synthesize definition.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static const TST TST_interface
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Expr * IgnoreImplicit() LLVM_READONLY
Priority for a constant value (e.g., enumerator).
Code completion occurred within the instance variable list of an Objective-C interface, implementation, or category implementation.
Stores a list of template parameters for a TemplateDecl and its derived classes.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
Describes how types, statements, expressions, and declarations should be printed. ...
decl_iterator decls_end() const
Code completion occurs within an Objective-C implementation or category implementation.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
The entity is not available; any use of it will be an error.
unsigned param_size() const
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
tok::TokenKind ContextKind
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
unsigned getNumParams() const
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args)
static void AddTypedefResult(ResultBuilder &Results)
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
CodeCompletionString * TakeString()
Take the resulting completion string.
method_iterator end_overridden_methods() const
This table allows us to fully hide how we implement multi-keyword caching.
void CodeCompleteObjCInterfaceDecl(Scope *S)
SmallVector< Decl *, 4 > IgnoreDecls
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
A "string" used to describe how code completion can be performed for an entity.
TSS getTypeSpecSign() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const TST TST_class
bool isAnyPointerType() const
An Objective-C @protocol declaration.
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results)
Add type specifiers for the current language as keyword results.
ParmVarDecl * getParam(unsigned i) const
Code completion occurs following one or more template headers within a class.
unsigned getIdentifierNamespace() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
CXXRecordDecl * getDefinition() const
const LangOptions & getLangOpts() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
An Objective-C instance method.
method_range methods() const
static const TST TST_enum
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
bool isNull() const
Determine whether this is the empty selector.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Describes a module or submodule.
Code completion occurs where only a type is permitted.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Code completion occurs at top-level or namespace context.
Values of this type can be null.
An Objective-C @property declaration.
static ObjCContainerDecl * getContainerDef(ObjCContainerDecl *Container)
Retrieve the container definition, if any?
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
An allocator used specifically for the purpose of code completion.
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, bool AllowSameLength=true)
static void AddObjCProperties(const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results)
Represents a C++ unqualified-id that has been parsed.
Represents the results of name lookup.
static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag)
Determine whether the addition of the given flag to an Objective-C property's attributes will cause a...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
Code completion occurs following one or more template headers.
QualType getReturnType() const
Wrapper for source info for functions.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
Code completion occurs within an expression.
const CXXRecordDecl * getParent() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Code completion occurred where a preprocessor directive is expected.
field_range fields() const
A friend of a previously-undeclared entity.
GlobalMethodPool MethodPool
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
Selector getSelector() const
Code completion occurred within an Objective-C implementation or category implementation.
static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, bool OnlyUnimplemented, ResultBuilder &Results)
Add all of the Objective-C interface declarations that we find in the given (translation unit) contex...
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
std::string getNameAsString() const
Expr * IgnoreParenCasts() LLVM_READONLY
Values of this type can never be null.
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
bool isVariadic() const
Whether this function is variadic.
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
submodule_iterator submodule_end()
QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression...
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
void append(iterator I, iterator E)
Code completion occurred where a namespace or namespace alias is expected.
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
Represents an Objective-C protocol declaration.
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool IncludeUndefined, bool TargetTypeIsPointer=false)
DeclContext * getLexicalDeclContext()
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
Represents an ObjC class declaration.
ObjCMethodDecl * getMethod() const
decl_iterator decls_begin() const
unsigned getNumParams() const
static QualType getPreferredArgumentTypeForMessageSend(ResultBuilder &Results, unsigned NumSelIdents)
Given a set of code-completion results for the argument of a message send, determine the preferred ty...
known_categories_range known_categories() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
CXCursorKind
Describes the kind of entity that a cursor refers to.
const UnresolvedSetImpl & asUnresolvedSet() const
std::vector< Module * >::iterator submodule_iterator
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID)
Lookup a property by name in the specified DeclContext.
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
std::input_iterator_tag iterator_category
void CodeCompleteObjCMethodDecl(Scope *S, bool IsInstanceMethod, ParsedType ReturnType)
A right parenthesis (')').
Code completion where an Objective-C category name is expected.
static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
const ParmVarDecl *const * param_const_iterator
Sema - This implements semantic analysis and AST building for C.
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression)
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, bool UserDefinedConversion=false)
TST getTypeSpecType() const
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Divide by this factor when a code-completion result's type exactly matches the type we expect...
QualType getParamType(unsigned i) const
static ObjCInterfaceDecl * GetAssumedMessageSendExprType(Expr *E)
When we have an expression with type "id", we may assume that it has some more-specific class type ba...
ObjCPropertyAttributeKind getPropertyAttributes() const
Zero-argument (unary) selector.
DeclarationNameTable DeclarationNames
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, bool WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
Find all of the methods that reside in the given container (and its superclasses, protocols...
ObjCDeclQualifier getObjCDeclQualifier() const
SmallVector< LambdaCapture, 4 > Captures
static bool isReservedName(const IdentifierInfo *Id)
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
ID
Defines the set of possible language-specific address spaces.
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
iterator(const DeclIndexPair *Iterator)
Code completion occurred where a protocol name is expected.
IdentifierInfo *const * arg_iterator
const ObjCMethodDecl * getMethodDecl() const
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
Retains information about a block that is currently being parsed.
Type source information for an attributed type.
static bool InheritsFromClassNamed(ObjCInterfaceDecl *Class, StringRef Name)
Determine whether the given class is or inherits from a class by the given name.
StringRef getName() const
Return the actual identifier string.
Code completion occurred where a new name is expected.
unsigned getNumArgs() const
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
bool isObjCClassType() const
Declaration of a template type parameter.
void CodeCompleteObjCPropertyDefinition(Scope *S)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
TranslationUnitDecl * getTranslationUnitDecl() const
Code completion occurs within an Objective-C interface, protocol, or category.
Defines the clang::Preprocessor interface.
The result is in a base class.
const ParmVarDecl * getParamDecl(unsigned i) const
void CodeCompleteObjCAtVisibility(Scope *S)
An Objective-C @implementation for a category.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
DeclContext * getDeclContext()
ParmVarDecl *const * param_iterator
bool hasDefaultArg() const
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void CodeCompletePreprocessorExpression()
bool isObjCIdType() const
Code completion occurs within a statement, which may also be an expression or a declaration.
Captures a result of code completion.
Code completion occurred where a new name is expected and a qualified name is permissible.
A C++ class template partial specialization.
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
const SwitchCase * getSwitchCaseList() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
bool isDependentType() const
bool isInstanceMethod() const
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
bool isFunctionOrMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getCXXNameType() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
An expression that sends a message to the given Objective-C object or class.
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
arg_iterator arg_end() const
DeclarationName getDeclName() const
The result type of a method or function.
Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.
void CodeCompleteNamespaceDecl(Scope *S)
Priority for the next initialization in a constructor initializer list.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
TypeSourceInfo * getTypeSourceInfo() const
void CodeCompleteInitializer(Scope *S, Decl *D)
bool isC99Varargs() const
void CodeCompleteObjCPropertySetter(Scope *S)
const char * getBriefComment() const
const TypeClass * getTypePtr() const
static bool anyNullArguments(ArrayRef< Expr * > Args)
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt)
The context in which code completion occurred, so that the code-completion consumer can process the r...
void CodeCompleteObjCAtExpression(Scope *S)
param_const_iterator param_end() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void CodeCompleteTypeQualifiers(DeclSpec &DS)
ArrayRef< ParmVarDecl * > parameters() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
static void AddFunctionParameterChunks(Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false)
Add function parameter chunks to the given code completion string.
DeclContext * getEntity() const
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
Code completion occurred within a class, struct, or union.
void CodeCompleteObjCAtDirective(Scope *S)
SelectorTable & Selectors
const DeclIndexPair * operator->() const
A C++ template type parameter.
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
enumerator_range enumerators() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
unsigned getNumParams() const
const Type * getTypePtr() const
method_iterator begin_overridden_methods() const
OverloadedOperatorKind getCXXOverloadedOperator() const
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
TagDecl - Represents the declaration of a struct/union/class/enum.
This is a scope that corresponds to the Objective-C @catch statement.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
ASTContext & getASTContext() const LLVM_READONLY
ASTContext & getASTContext() const
macro_iterator macro_end(bool IncludeExternalMacros=true) const
static const TST TST_union
const Expr * getCond() const
ParsedType getRepAsType() const
TSC getTypeSpecComplex() const
void CodeCompleteReturn(Scope *S)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion where the name of an Objective-C class is expected.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
Represents a static or instance method of a struct/union/class.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.
Code completion occurred within an Objective-C interface, protocol, or category interface.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void CodeCompleteOperatorName(Scope *S)
void CodeCompletePreprocessorDirective(bool InConditional)
static void AddOverloadParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const FunctionDecl *Function, const FunctionProtoType *Prototype, CodeCompletionBuilder &Result, unsigned CurrentArg, unsigned Start=0, bool InOptional=false)
Add function overload parameter chunks to the given code completion string.
static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
Add language constructs that show up for "ordinary" names.
static void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, bool CompleteExpressionWithCurrentArg=true)
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Priority for a non-type declaration.
Represents one property declaration in an Objective-C interface.
QualType getReturnType() const
bool isTypeDependent() const
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
lookup_result lookup(DeclarationName Name) const
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
bool isFileContext() const
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
sema::FunctionScopeInfo * getCurFunction() const
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
void addBriefComment(StringRef Comment)
SourceLocation getExprLoc() const LLVM_READONLY
The injected class name of a C++ class template or class template partial specialization. Used to record that a type was spelled with a bare identifier rather than as a template-id; the equivalent for non-templated classes is just RecordType.
Priority for a nested-name-specifier.
Priority for a declaration that is in the local scope.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
The scope of a struct/union/class definition.
ObjCIvarDecl * getNextIvar()
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getParentName() const
bool isMacroDefined(StringRef Id)
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results)
Add all of the protocol declarations that we find in the given (translation unit) context...
Abstract interface for a consumer of code-completion information.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
An Objective-C instance variable.
ParserCompletionContext
Describes the context in which code completion occurs.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
Code completion occurred where an macro is being defined.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Adjustment for KVC code pattern priorities when it doesn't look like the.
static NestedNameSpecifier * getRequiredQualification(ASTContext &Context, const DeclContext *CurContext, const DeclContext *TargetContext)
Compute the qualification required to get from the current context (CurContext) to the target context...
prop_range properties() const
A function or method parameter.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
void CodeCompleteTag(Scope *S, unsigned TagSpec)
TypeLoc IgnoreParens() const
This is a scope that corresponds to the template parameters of a C++ template. Template parameter sco...
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Selector getSelector() const
Priority for a send-to-super completion.
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
Code completion occurred on the right-hand side of an Objective-C property access expression...
All of the names in this module are visible.
void CodeCompleteNamespaceAliasDecl(Scope *S)
QualType getNonReferenceType() const
void CodeCompleteUsingDirective(Scope *S)
bool isFunctionLike() const
Encapsulates the data about a macro definition (e.g. its tokens).
bool SuppressUnwrittenScope
Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonym...
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration. Returns NULL if no comment is attac...
bool isObjCObjectType() const
Not an overloaded operator.
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
ObjCMethodDecl * getGetterMethodDecl() const
ExternalSemaSource * getExternalSource() const
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
unsigned getTypeQuals() const
A reference to a member of a struct, union, or class that occurs in some non-expression context...
ObjCInterfaceDecl * getInterfaceDecl() const
ObjCMethodDecl * getSetterMethodDecl() const
A module import declaration.
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo * > SelIdents)
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
enum Kind getKind() const
Retrieve the kind of code-completion context.
A declaration whose specific kind is not exposed via this interface.
A piece of text that describes the parameter that corresponds to the code-completion location within ...
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
static const TST TST_typename
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId) const
DeclContext * getRedeclContext()
An Objective-C @dynamic definition.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void * getAsOpaquePtr() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
void CodeCompleteObjCAtStatement(Scope *S)
ObjCImplementationDecl * getImplementation() const
protocol_range protocols() const
const TypeClass * getTypePtr() const
Capturing the this pointer.
An Objective-C method being used as a property.
An Objective-C class method.
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
friend bool operator!=(const iterator &X, const iterator &Y)
QualType getPointeeType() const
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't co...
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
A left parenthesis ('(').
__PTRDIFF_TYPE__ ptrdiff_t
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
static bool isInstanceMethod(const Decl *D)
Captures information about "declaration specifiers".
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
An Objective-C @implementation.
CodeCompleteExpressionData(QualType PreferredType=QualType())
bool isObjCObjectPointerType() const
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo * > SelIdents)
static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext, ResultBuilder &Results)
If we're in a C++ virtual member function, add completion results that invoke the functions we overri...
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
An unspecified code-completion context where we should also add macro completions.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
The parameter type of a method or function.
A left angle bracket ('<').
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
A right angle bracket ('>').
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Cursor that represents the translation unit itself.
Declaration of a class template.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
Vertical whitespace ('\n' or '\r\n', depending on the platform).
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Represents a complete lambda introducer.
a linked list of methods with the same selector name but different signatures.
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param, bool SuppressName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
ObjCInterfaceDecl * getSuperClass() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
bool AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>"). Otherwise, just prints "(anonymous)" for the name.
static Qualifiers fromCVRMask(unsigned CVR)
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function. This replaces the type par...
static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC)
static void AddObjCPassingTypeChunk(QualType Type, unsigned ObjCDeclQuals, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder)
Add the parenthesized return or parameter type chunk to a code completion string. ...
static OpaquePtr make(QualTypeP)
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
TranslationUnitDecl - The top declaration context.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
bool isTypeAltiVecVector() const
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
static void AddTemplateParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false)
Add template parameter chunks to the given code completion string.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
Code completion occurred on the right-hand side of a member access expression using the dot operator...
Code completion occurs within the condition of an if, while, switch, or for statement.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion...
static bool isNamespaceScope(Scope *S)
Determine whether this scope denotes a namespace.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Code completion occurred where a type name is expected.
Horizontal whitespace (' ').
SourceManager & SourceMgr
void CodeCompleteObjCImplementationDecl(Scope *S)
static const TST TST_struct
void AddAnnotation(const char *A)
reference operator*() const
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, bool AllowSameLength=true)
void suppressDiagnostics()
arg_iterator arg_begin() const
static LLVM_READONLY char toUppercase(char c)
SourceLocation getLocation() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
ObjCIvarDecl * all_declared_ivar_begin()
bool IntegralConstantExpression
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
EnumDecl * getDefinition() const
friend bool operator==(const iterator &X, const iterator &Y)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
An Objective-C @interface.
A C++ conversion function.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
The receiver is a superclass.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
void CodeCompleteAfterIf(Scope *S)
Wrapper for source info for block pointers.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
base_class_range vbases()
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Declaration of a template function.
Code completion occurs in a parenthesized expression, which might also be a type cast.
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
void CodeCompleteObjCProtocolDecl(Scope *S)
Priority for a code pattern.
void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols, unsigned NumProtocols)
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo * > SelIdents, ResultBuilder &Results)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
bool isIntegerType() const
bool hasLocalStorage() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Priority for a preprocessor macro.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...