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 *>()) {
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;
419 if (DeclOrVector.isNull())
423 return iterator(ND, SingleDeclIndex);
425 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
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;
510 if (isa<ClassTemplateSpecializationDecl>(ND) ||
511 isa<ClassTemplatePartialSpecializationDecl>(ND))
515 if (isa<UsingDecl>(ND))
529 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
530 (isa<NamespaceDecl>(ND) &&
531 Filter != &ResultBuilder::IsNamespace &&
532 Filter != &ResultBuilder::IsNamespaceOrAlias &&
534 AsNestedNameSpecifier =
true;
537 if (Filter && !(this->*Filter)(Named)) {
539 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
540 IsNestedNameSpecifier(ND) &&
541 (Filter != &ResultBuilder::IsMember ||
542 (isa<CXXRecordDecl>(ND) &&
543 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
544 AsNestedNameSpecifier =
true;
554 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
574 R.QualifierIsInformative =
false;
579 R.Declaration->getDeclContext());
586 switch (T->getTypeClass()) {
588 switch (cast<BuiltinType>(T)->getKind()) {
589 case BuiltinType::Void:
592 case BuiltinType::NullPtr:
595 case BuiltinType::Overload:
596 case BuiltinType::Dependent:
599 case BuiltinType::ObjCId:
600 case BuiltinType::ObjCClass:
601 case BuiltinType::ObjCSel:
614 case Type::BlockPointer:
617 case Type::LValueReference:
618 case Type::RValueReference:
621 case Type::ConstantArray:
622 case Type::IncompleteArray:
623 case Type::VariableArray:
624 case Type::DependentSizedArray:
627 case Type::DependentSizedExtVector:
629 case Type::ExtVector:
632 case Type::FunctionProto:
633 case Type::FunctionNoProto:
642 case Type::ObjCObject:
643 case Type::ObjCInterface:
644 case Type::ObjCObjectPointer:
664 T = Function->getCallResultType();
665 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
666 T = Method->getSendResultType();
667 else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
672 T =
Value->getType();
686 if (Pointer->getPointeeType()->isFunctionType()) {
700 T = Function->getReturnType();
710 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
719 dyn_cast<ImplicitParamDecl>(ND))
720 if (ImplicitParam->getIdentifier() &&
721 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
728 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC))
732 if (isa<EnumConstantDecl>(ND))
738 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
749 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
752 if (!PreferredSelector.isNull())
753 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
754 if (PreferredSelector == Method->getSelector())
759 if (!PreferredType.isNull()) {
769 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
775 void ResultBuilder::MaybeAddConstructorResults(Result R) {
776 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
784 Record = ClassTemplate->getTemplatedDecl();
785 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
787 if (isa<ClassTemplateSpecializationDecl>(Record))
809 Results.push_back(R);
813 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
814 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
816 if (R.Kind != Result::RK_Declaration) {
818 Results.push_back(R);
824 dyn_cast<UsingShadowDecl>(R.Declaration)) {
825 MaybeAddResult(
Result(Using->getTargetDecl(),
826 getBasePriority(Using->getTargetDecl()),
835 bool AsNestedNameSpecifier =
false;
836 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
840 if (isa<CXXConstructorDecl>(R.Declaration))
843 ShadowMap &
SMap = ShadowMaps.back();
846 if (NamePos != SMap.end()) {
847 I = NamePos->second.begin();
848 IEnd = NamePos->second.end();
851 for (; I != IEnd; ++
I) {
853 unsigned Index = I->second;
856 Results[Index].Declaration = R.Declaration;
868 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
871 if (NamePos != SM->end()) {
872 I = NamePos->second.begin();
873 IEnd = NamePos->second.end();
875 for (; I != IEnd; ++
I) {
877 if (I->first->hasTagIdentifierNamespace() &&
885 I->first->getIdentifierNamespace() != IDNS)
889 if (CheckHiddenResult(R, CurContext, I->first))
897 if (!AllDeclsFound.insert(CanonDecl).second)
902 if (AsNestedNameSpecifier) {
903 R.StartsNestedNameSpecifier =
true;
906 AdjustResultPriorityForDecl(R);
909 if (R.QualifierIsInformative && !R.Qualifier &&
910 !R.StartsNestedNameSpecifier) {
911 const DeclContext *Ctx = R.Declaration->getDeclContext();
912 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
915 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
919 R.QualifierIsInformative =
false;
924 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
925 Results.push_back(R);
927 if (!AsNestedNameSpecifier)
928 MaybeAddConstructorResults(R);
931 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
932 NamedDecl *Hiding,
bool InBaseClass =
false) {
933 if (R.Kind != Result::RK_Declaration) {
935 Results.push_back(R);
940 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
941 AddResult(
Result(Using->getTargetDecl(),
942 getBasePriority(Using->getTargetDecl()),
948 bool AsNestedNameSpecifier =
false;
949 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
953 if (isa<CXXConstructorDecl>(R.Declaration))
956 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
960 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
965 if (AsNestedNameSpecifier) {
966 R.StartsNestedNameSpecifier =
true;
969 else if (Filter == &ResultBuilder::IsMember && !R.Qualifier && InBaseClass &&
970 isa<CXXRecordDecl>(R.Declaration->getDeclContext()
971 ->getRedeclContext()))
972 R.QualifierIsInformative =
true;
975 if (R.QualifierIsInformative && !R.Qualifier &&
976 !R.StartsNestedNameSpecifier) {
977 const DeclContext *Ctx = R.Declaration->getDeclContext();
978 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
981 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
985 R.QualifierIsInformative =
false;
992 AdjustResultPriorityForDecl(R);
994 if (HasObjectTypeQualifiers)
995 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
996 if (Method->isInstance()) {
999 if (ObjectTypeQualifiers == MethodQuals)
1001 else if (ObjectTypeQualifiers - MethodQuals) {
1009 Results.push_back(R);
1011 if (!AsNestedNameSpecifier)
1012 MaybeAddConstructorResults(R);
1015 void ResultBuilder::AddResult(Result R) {
1016 assert(R.Kind != Result::RK_Declaration &&
1017 "Declaration results need more context");
1018 Results.push_back(R);
1022 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1025 void ResultBuilder::ExitScope() {
1027 EEnd = ShadowMaps.back().end();
1030 E->second.Destroy();
1032 ShadowMaps.pop_back();
1037 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1046 if (isa<ObjCIvarDecl>(ND))
1055 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1057 if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
1064 if (isa<ObjCIvarDecl>(ND))
1071 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1072 if (!IsOrdinaryNonTypeName(ND))
1076 if (VD->getType()->isIntegralOrEnumerationType())
1084 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1092 !isa<ValueDecl>(ND) && !isa<FunctionTemplateDecl>(ND) &&
1093 !isa<ObjCPropertyDecl>(ND);
1098 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1101 ND = ClassTemplate->getTemplatedDecl();
1107 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1108 return isa<EnumDecl>(ND);
1112 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1115 ND = ClassTemplate->getTemplatedDecl();
1118 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1127 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1130 ND = ClassTemplate->getTemplatedDecl();
1132 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1139 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1140 return isa<NamespaceDecl>(ND);
1145 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1150 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1152 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1158 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1160 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1161 isa<ObjCPropertyDecl>(ND);
1167 case Type::ObjCObject:
1168 case Type::ObjCInterface:
1169 case Type::ObjCObjectPointer:
1173 switch (cast<BuiltinType>(T)->getKind()) {
1174 case BuiltinType::ObjCId:
1175 case BuiltinType::ObjCClass:
1176 case BuiltinType::ObjCSel:
1197 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1206 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const {
1207 if (IsObjCMessageReceiver(ND))
1217 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1218 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1219 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1232 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1238 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1239 return isa<ObjCIvarDecl>(ND);
1246 ResultBuilder &Results;
1250 CodeCompletionDeclConsumer(ResultBuilder &Results,
DeclContext *CurContext)
1251 : Results(Results), CurContext(CurContext) { }
1254 bool InBaseClass)
override {
1255 bool Accessible =
true;
1257 Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
1261 Results.AddResult(Result, CurContext, Hiding, InBaseClass);
1268 ResultBuilder &Results) {
1270 Results.AddResult(Result(
"short",
CCP_Type));
1271 Results.AddResult(Result(
"long",
CCP_Type));
1272 Results.AddResult(Result(
"signed",
CCP_Type));
1273 Results.AddResult(Result(
"unsigned",
CCP_Type));
1274 Results.AddResult(Result(
"void",
CCP_Type));
1275 Results.AddResult(Result(
"char",
CCP_Type));
1276 Results.AddResult(Result(
"int",
CCP_Type));
1277 Results.AddResult(Result(
"float",
CCP_Type));
1278 Results.AddResult(Result(
"double",
CCP_Type));
1279 Results.AddResult(Result(
"enum",
CCP_Type));
1280 Results.AddResult(Result(
"struct",
CCP_Type));
1281 Results.AddResult(Result(
"union",
CCP_Type));
1282 Results.AddResult(Result(
"const",
CCP_Type));
1283 Results.AddResult(Result(
"volatile",
CCP_Type));
1287 Results.AddResult(Result(
"_Complex",
CCP_Type));
1288 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1289 Results.AddResult(Result(
"_Bool",
CCP_Type));
1290 Results.AddResult(Result(
"restrict",
CCP_Type));
1294 Results.getCodeCompletionTUInfo());
1295 if (LangOpts.CPlusPlus) {
1297 Results.AddResult(Result(
"bool",
CCP_Type +
1299 Results.AddResult(Result(
"class",
CCP_Type));
1300 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1303 Builder.AddTypedTextChunk(
"typename");
1305 Builder.AddPlaceholderChunk(
"qualifier");
1307 Builder.AddPlaceholderChunk(
"name");
1308 Results.AddResult(Result(
Builder.TakeString()));
1310 if (LangOpts.CPlusPlus11) {
1311 Results.AddResult(Result(
"auto",
CCP_Type));
1312 Results.AddResult(Result(
"char16_t",
CCP_Type));
1313 Results.AddResult(Result(
"char32_t",
CCP_Type));
1315 Builder.AddTypedTextChunk(
"decltype");
1317 Builder.AddPlaceholderChunk(
"expression");
1319 Results.AddResult(Result(
Builder.TakeString()));
1324 if (LangOpts.GNUMode) {
1330 Builder.AddTypedTextChunk(
"typeof");
1332 Builder.AddPlaceholderChunk(
"expression");
1333 Results.AddResult(Result(
Builder.TakeString()));
1335 Builder.AddTypedTextChunk(
"typeof");
1337 Builder.AddPlaceholderChunk(
"type");
1339 Results.AddResult(Result(
Builder.TakeString()));
1343 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1344 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1345 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1350 ResultBuilder &Results) {
1355 Results.AddResult(Result(
"extern"));
1356 Results.AddResult(Result(
"static"));
1361 ResultBuilder &Results) {
1366 if (LangOpts.CPlusPlus) {
1367 Results.AddResult(Result(
"explicit"));
1368 Results.AddResult(Result(
"friend"));
1369 Results.AddResult(Result(
"mutable"));
1370 Results.AddResult(Result(
"virtual"));
1378 if (LangOpts.CPlusPlus || LangOpts.C99)
1379 Results.AddResult(Result(
"inline"));
1398 ResultBuilder &Results,
1401 ResultBuilder &Results,
1404 ResultBuilder &Results,
1410 Results.getCodeCompletionTUInfo());
1411 Builder.AddTypedTextChunk(
"typedef");
1413 Builder.AddPlaceholderChunk(
"type");
1415 Builder.AddPlaceholderChunk(
"name");
1436 return LangOpts.CPlusPlus;
1443 return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
1446 llvm_unreachable(
"Invalid ParserCompletionContext!");
1474 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1475 return BT->getNameAsCString(Policy);
1478 if (
const TagType *TagT = dyn_cast<TagType>(T))
1479 if (
TagDecl *Tag = TagT->getDecl())
1480 if (!Tag->hasNameForLinkage()) {
1481 switch (Tag->getTagKind()) {
1482 case TTK_Struct:
return "struct <anonymous>";
1484 case TTK_Class:
return "class <anonymous>";
1485 case TTK_Union:
return "union <anonymous>";
1486 case TTK_Enum:
return "enum <anonymous>";
1510 Builder.AddTypedTextChunk(
"this");
1518 ResultBuilder &Results) {
1527 if (Results.includeCodePatterns()) {
1529 Builder.AddTypedTextChunk(
"namespace");
1531 Builder.AddPlaceholderChunk(
"identifier");
1533 Builder.AddPlaceholderChunk(
"declarations");
1536 Results.AddResult(Result(
Builder.TakeString()));
1540 Builder.AddTypedTextChunk(
"namespace");
1542 Builder.AddPlaceholderChunk(
"name");
1544 Builder.AddPlaceholderChunk(
"namespace");
1545 Results.AddResult(Result(
Builder.TakeString()));
1548 Builder.AddTypedTextChunk(
"using");
1550 Builder.AddTextChunk(
"namespace");
1552 Builder.AddPlaceholderChunk(
"identifier");
1553 Results.AddResult(Result(
Builder.TakeString()));
1556 Builder.AddTypedTextChunk(
"asm");
1558 Builder.AddPlaceholderChunk(
"string-literal");
1560 Results.AddResult(Result(
Builder.TakeString()));
1562 if (Results.includeCodePatterns()) {
1564 Builder.AddTypedTextChunk(
"template");
1566 Builder.AddPlaceholderChunk(
"declaration");
1567 Results.AddResult(Result(
Builder.TakeString()));
1580 Builder.AddTypedTextChunk(
"using");
1582 Builder.AddPlaceholderChunk(
"qualifier");
1584 Builder.AddPlaceholderChunk(
"name");
1585 Results.AddResult(Result(
Builder.TakeString()));
1589 Builder.AddTypedTextChunk(
"using");
1591 Builder.AddTextChunk(
"typename");
1593 Builder.AddPlaceholderChunk(
"qualifier");
1595 Builder.AddPlaceholderChunk(
"name");
1596 Results.AddResult(Result(
Builder.TakeString()));
1603 Builder.AddTypedTextChunk(
"public");
1604 if (Results.includeCodePatterns())
1606 Results.AddResult(Result(
Builder.TakeString()));
1609 Builder.AddTypedTextChunk(
"protected");
1610 if (Results.includeCodePatterns())
1612 Results.AddResult(Result(
Builder.TakeString()));
1615 Builder.AddTypedTextChunk(
"private");
1616 if (Results.includeCodePatterns())
1618 Results.AddResult(Result(
Builder.TakeString()));
1625 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1627 Builder.AddTypedTextChunk(
"template");
1629 Builder.AddPlaceholderChunk(
"parameters");
1631 Results.AddResult(Result(
Builder.TakeString()));
1658 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1660 Builder.AddTypedTextChunk(
"try");
1662 Builder.AddPlaceholderChunk(
"statements");
1665 Builder.AddTextChunk(
"catch");
1667 Builder.AddPlaceholderChunk(
"declaration");
1670 Builder.AddPlaceholderChunk(
"statements");
1673 Results.AddResult(Result(
Builder.TakeString()));
1678 if (Results.includeCodePatterns()) {
1680 Builder.AddTypedTextChunk(
"if");
1683 Builder.AddPlaceholderChunk(
"condition");
1685 Builder.AddPlaceholderChunk(
"expression");
1688 Builder.AddPlaceholderChunk(
"statements");
1691 Results.AddResult(Result(
Builder.TakeString()));
1694 Builder.AddTypedTextChunk(
"switch");
1697 Builder.AddPlaceholderChunk(
"condition");
1699 Builder.AddPlaceholderChunk(
"expression");
1704 Results.AddResult(Result(
Builder.TakeString()));
1710 Builder.AddTypedTextChunk(
"case");
1712 Builder.AddPlaceholderChunk(
"expression");
1714 Results.AddResult(Result(
Builder.TakeString()));
1717 Builder.AddTypedTextChunk(
"default");
1719 Results.AddResult(Result(
Builder.TakeString()));
1722 if (Results.includeCodePatterns()) {
1724 Builder.AddTypedTextChunk(
"while");
1727 Builder.AddPlaceholderChunk(
"condition");
1729 Builder.AddPlaceholderChunk(
"expression");
1732 Builder.AddPlaceholderChunk(
"statements");
1735 Results.AddResult(Result(
Builder.TakeString()));
1738 Builder.AddTypedTextChunk(
"do");
1740 Builder.AddPlaceholderChunk(
"statements");
1743 Builder.AddTextChunk(
"while");
1745 Builder.AddPlaceholderChunk(
"expression");
1747 Results.AddResult(Result(
Builder.TakeString()));
1750 Builder.AddTypedTextChunk(
"for");
1753 Builder.AddPlaceholderChunk(
"init-statement");
1755 Builder.AddPlaceholderChunk(
"init-expression");
1757 Builder.AddPlaceholderChunk(
"condition");
1759 Builder.AddPlaceholderChunk(
"inc-expression");
1763 Builder.AddPlaceholderChunk(
"statements");
1766 Results.AddResult(Result(
Builder.TakeString()));
1771 Builder.AddTypedTextChunk(
"continue");
1772 Results.AddResult(Result(
Builder.TakeString()));
1777 Builder.AddTypedTextChunk(
"break");
1778 Results.AddResult(Result(
Builder.TakeString()));
1783 bool isVoid =
false;
1785 isVoid = Function->getReturnType()->isVoidType();
1787 = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1788 isVoid = Method->getReturnType()->isVoidType();
1792 Builder.AddTypedTextChunk(
"return");
1795 Builder.AddPlaceholderChunk(
"expression");
1797 Results.AddResult(Result(
Builder.TakeString()));
1800 Builder.AddTypedTextChunk(
"goto");
1802 Builder.AddPlaceholderChunk(
"label");
1803 Results.AddResult(Result(
Builder.TakeString()));
1806 Builder.AddTypedTextChunk(
"using");
1808 Builder.AddTextChunk(
"namespace");
1810 Builder.AddPlaceholderChunk(
"identifier");
1811 Results.AddResult(Result(
Builder.TakeString()));
1824 Builder.AddTypedTextChunk(
"__bridge");
1826 Builder.AddPlaceholderChunk(
"type");
1828 Builder.AddPlaceholderChunk(
"expression");
1829 Results.AddResult(Result(
Builder.TakeString()));
1832 Builder.AddTypedTextChunk(
"__bridge_transfer");
1834 Builder.AddPlaceholderChunk(
"Objective-C type");
1836 Builder.AddPlaceholderChunk(
"expression");
1837 Results.AddResult(Result(
Builder.TakeString()));
1840 Builder.AddTypedTextChunk(
"__bridge_retained");
1842 Builder.AddPlaceholderChunk(
"CF type");
1844 Builder.AddPlaceholderChunk(
"expression");
1845 Results.AddResult(Result(
Builder.TakeString()));
1855 Builder.AddResultTypeChunk(
"bool");
1856 Builder.AddTypedTextChunk(
"true");
1857 Results.AddResult(Result(
Builder.TakeString()));
1860 Builder.AddResultTypeChunk(
"bool");
1861 Builder.AddTypedTextChunk(
"false");
1862 Results.AddResult(Result(
Builder.TakeString()));
1866 Builder.AddTypedTextChunk(
"dynamic_cast");
1868 Builder.AddPlaceholderChunk(
"type");
1871 Builder.AddPlaceholderChunk(
"expression");
1873 Results.AddResult(Result(
Builder.TakeString()));
1877 Builder.AddTypedTextChunk(
"static_cast");
1879 Builder.AddPlaceholderChunk(
"type");
1882 Builder.AddPlaceholderChunk(
"expression");
1884 Results.AddResult(Result(
Builder.TakeString()));
1887 Builder.AddTypedTextChunk(
"reinterpret_cast");
1889 Builder.AddPlaceholderChunk(
"type");
1892 Builder.AddPlaceholderChunk(
"expression");
1894 Results.AddResult(Result(
Builder.TakeString()));
1897 Builder.AddTypedTextChunk(
"const_cast");
1899 Builder.AddPlaceholderChunk(
"type");
1902 Builder.AddPlaceholderChunk(
"expression");
1904 Results.AddResult(Result(
Builder.TakeString()));
1908 Builder.AddResultTypeChunk(
"std::type_info");
1909 Builder.AddTypedTextChunk(
"typeid");
1911 Builder.AddPlaceholderChunk(
"expression-or-type");
1913 Results.AddResult(Result(
Builder.TakeString()));
1917 Builder.AddTypedTextChunk(
"new");
1919 Builder.AddPlaceholderChunk(
"type");
1921 Builder.AddPlaceholderChunk(
"expressions");
1923 Results.AddResult(Result(
Builder.TakeString()));
1926 Builder.AddTypedTextChunk(
"new");
1928 Builder.AddPlaceholderChunk(
"type");
1930 Builder.AddPlaceholderChunk(
"size");
1933 Builder.AddPlaceholderChunk(
"expressions");
1935 Results.AddResult(Result(
Builder.TakeString()));
1938 Builder.AddResultTypeChunk(
"void");
1939 Builder.AddTypedTextChunk(
"delete");
1941 Builder.AddPlaceholderChunk(
"expression");
1942 Results.AddResult(Result(
Builder.TakeString()));
1945 Builder.AddResultTypeChunk(
"void");
1946 Builder.AddTypedTextChunk(
"delete");
1951 Builder.AddPlaceholderChunk(
"expression");
1952 Results.AddResult(Result(
Builder.TakeString()));
1956 Builder.AddResultTypeChunk(
"void");
1957 Builder.AddTypedTextChunk(
"throw");
1959 Builder.AddPlaceholderChunk(
"expression");
1960 Results.AddResult(Result(
Builder.TakeString()));
1967 Builder.AddResultTypeChunk(
"std::nullptr_t");
1968 Builder.AddTypedTextChunk(
"nullptr");
1969 Results.AddResult(Result(
Builder.TakeString()));
1972 Builder.AddResultTypeChunk(
"size_t");
1973 Builder.AddTypedTextChunk(
"alignof");
1975 Builder.AddPlaceholderChunk(
"type");
1977 Results.AddResult(Result(
Builder.TakeString()));
1980 Builder.AddResultTypeChunk(
"bool");
1981 Builder.AddTypedTextChunk(
"noexcept");
1983 Builder.AddPlaceholderChunk(
"expression");
1985 Results.AddResult(Result(
Builder.TakeString()));
1988 Builder.AddResultTypeChunk(
"size_t");
1989 Builder.AddTypedTextChunk(
"sizeof...");
1991 Builder.AddPlaceholderChunk(
"parameter-pack");
1993 Results.AddResult(Result(
Builder.TakeString()));
2002 if (
ID->getSuperClass()) {
2003 std::string SuperType;
2004 SuperType =
ID->getSuperClass()->getNameAsString();
2005 if (Method->isInstanceMethod())
2009 Builder.AddTypedTextChunk(
"super");
2010 Results.AddResult(Result(
Builder.TakeString()));
2019 Builder.AddResultTypeChunk(
"size_t");
2021 Builder.AddTypedTextChunk(
"alignof");
2023 Builder.AddTypedTextChunk(
"_Alignof");
2025 Builder.AddPlaceholderChunk(
"type");
2027 Results.AddResult(Result(
Builder.TakeString()));
2031 Builder.AddResultTypeChunk(
"size_t");
2032 Builder.AddTypedTextChunk(
"sizeof");
2034 Builder.AddPlaceholderChunk(
"expression-or-type");
2036 Results.AddResult(Result(
Builder.TakeString()));
2049 Results.AddResult(Result(
"operator"));
2064 if (isa<CXXConstructorDecl>(ND) || isa<CXXConversionDecl>(ND))
2070 T = Function->getReturnType();
2071 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2073 T = Method->getSendResultType(BaseType);
2075 T = Method->getReturnType();
2076 }
else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
2077 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2078 else if (isa<UnresolvedUsingValueDecl>(ND)) {
2080 }
else if (
const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2082 T = Ivar->getUsageType(BaseType);
2084 T = Ivar->getType();
2086 T =
Value->getType();
2089 T =
Property->getUsageType(BaseType);
2104 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2105 if (Sentinel->getSentinel() == 0) {
2125 Result +=
"bycopy ";
2129 Result +=
"oneway ";
2132 switch (*nullability) {
2134 Result +=
"nonnull ";
2138 Result +=
"nullable ";
2142 Result +=
"null_unspecified ";
2152 bool SuppressName =
false,
2153 bool SuppressBlock =
false,
2154 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2155 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2162 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2169 if (ObjCMethodParam) {
2190 if (!SuppressBlock) {
2193 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2206 TL = AttrTL.getModifiedLoc();
2231 if (ObjCMethodParam) {
2234 Result += Type.
getAsString(Policy) + Result +
")";
2252 if (!ResultType->
isVoidType() || SuppressBlock)
2264 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++
I) {
2278 if (SuppressBlock) {
2280 Result = Result +
" (^";
2287 Result =
'^' + Result;
2303 bool InOptional =
false) {
2304 bool FirstParameter =
true;
2314 if (!FirstParameter)
2322 FirstParameter =
false;
2332 PlaceholderStr +=
", ...";
2341 if (Proto->isVariadic()) {
2342 if (Proto->getNumParams() == 0)
2354 unsigned MaxParameters = 0,
2356 bool InDefaultArg =
false) {
2357 bool FirstParameter =
true;
2366 PEnd = Params->begin() + MaxParameters;
2369 bool HasDefaultArg =
false;
2370 std::string PlaceholderStr;
2372 if (TTP->wasDeclaredWithTypename())
2373 PlaceholderStr =
"typename";
2375 PlaceholderStr =
"class";
2377 if (TTP->getIdentifier()) {
2378 PlaceholderStr +=
' ';
2382 HasDefaultArg = TTP->hasDefaultArgument();
2384 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2385 if (NTTP->getIdentifier())
2386 PlaceholderStr = NTTP->getIdentifier()->getName();
2387 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2388 HasDefaultArg = NTTP->hasDefaultArgument();
2390 assert(isa<TemplateTemplateParmDecl>(*
P));
2395 PlaceholderStr =
"template<...> class";
2397 PlaceholderStr +=
' ';
2404 if (HasDefaultArg && !InDefaultArg) {
2409 if (!FirstParameter)
2412 P - Params->begin(),
true);
2417 InDefaultArg =
false;
2420 FirstParameter =
false;
2435 bool QualifierIsInformative,
2441 std::string PrintedNNS;
2443 llvm::raw_string_ostream OS(PrintedNNS);
2444 Qualifier->
print(OS, Policy);
2446 if (QualifierIsInformative)
2479 std::string QualsStr;
2481 QualsStr +=
" const";
2483 QualsStr +=
" volatile";
2485 QualsStr +=
" restrict";
2499 const char *OperatorName =
nullptr;
2502 case OO_Conditional:
2504 OperatorName =
"operator";
2507 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2508 case OO_##Name: OperatorName = "operator" Spelling; break;
2509 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2510 #include "clang/Basic/OperatorKinds.def"
2512 case OO_New: OperatorName =
"operator new";
break;
2513 case OO_Delete: OperatorName =
"operator delete";
break;
2514 case OO_Array_New: OperatorName =
"operator new[]";
break;
2515 case OO_Array_Delete: OperatorName =
"operator delete[]";
break;
2516 case OO_Call: OperatorName =
"operator()";
break;
2517 case OO_Subscript: OperatorName =
"operator[]";
break;
2541 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2544 Record = InjectedTy->getDecl();
2567 bool IncludeBriefComments) {
2568 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2569 CCTUInfo, IncludeBriefComments);
2584 bool IncludeBriefComments) {
2588 if (
Kind == RK_Pattern) {
2589 Pattern->Priority = Priority;
2590 Pattern->Availability = Availability;
2601 if (M->isPropertyAccessor())
2603 if (PDecl->getGetterName() == M->getSelector() &&
2604 PDecl->getIdentifier() != M->getIdentifier()) {
2621 if (
Kind == RK_Keyword) {
2626 if (
Kind == RK_Macro) {
2669 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2673 if (IncludeBriefComments) {
2678 else if (
const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
2679 if (OMD->isPropertyAccessor())
2685 if (StartsNestedNameSpecifier) {
2697 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
2716 llvm::SmallBitVector Deduced;
2718 unsigned LastDeducibleArgument;
2719 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
2720 --LastDeducibleArgument) {
2721 if (!Deduced[LastDeducibleArgument - 1]) {
2725 bool HasDefaultArg =
false;
2726 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
2727 LastDeducibleArgument - 1);
2729 HasDefaultArg = TTP->hasDefaultArgument();
2731 = dyn_cast<NonTypeTemplateParmDecl>(Param))
2732 HasDefaultArg = NTTP->hasDefaultArgument();
2734 assert(isa<TemplateTemplateParmDecl>(Param));
2736 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
2744 if (LastDeducibleArgument) {
2750 LastDeducibleArgument);
2762 if (
const TemplateDecl *Template = dyn_cast<TemplateDecl>(ND)) {
2773 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2774 Selector Sel = Method->getSelector();
2783 if (StartParameter == 0)
2790 if (Method->param_size() == 1)
2795 PEnd = Method->param_end();
2796 P != PEnd; (void)++
P, ++Idx) {
2798 std::string Keyword;
2799 if (Idx > StartParameter)
2802 Keyword += II->getName();
2804 if (Idx < StartParameter || AllParametersAreInformative)
2811 if (Idx < StartParameter)
2815 QualType ParamType = (*P)->getType();
2832 if (DeclaringEntity || AllParametersAreInformative)
2833 Arg += II->getName();
2836 if (Method->isVariadic() && (
P + 1) == PEnd)
2839 if (DeclaringEntity)
2841 else if (AllParametersAreInformative)
2847 if (Method->isVariadic()) {
2848 if (Method->param_size() == 0) {
2849 if (DeclaringEntity)
2851 else if (AllParametersAreInformative)
2879 unsigned CurrentArg,
2881 bool InOptional =
false) {
2882 bool FirstParameter =
true;
2883 unsigned NumParams = Function ? Function->
getNumParams()
2886 for (
unsigned P = Start;
P != NumParams; ++
P) {
2892 if (!FirstParameter)
2896 CurrentArg,
P,
true);
2902 FirstParameter =
false;
2909 std::string Placeholder;
2915 if (
P == CurrentArg)
2925 if (!FirstParameter)
2928 if (CurrentArg < NumParams)
2929 Opt.AddPlaceholderChunk(
"...");
2931 Opt.AddCurrentParameterChunk(
"...");
2939 unsigned CurrentArg,
Sema &
S,
2942 bool IncludeBriefComments)
const {
2950 if (!FDecl && !Proto) {
2963 if (IncludeBriefComments && CurrentArg < FDecl->getNumParams())
2981 return Result.TakeString();
2986 bool PreferredTypeIsPointer) {
2990 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
2991 MacroName.equals(
"Nil")) {
2993 if (PreferredTypeIsPointer)
2997 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
2998 MacroName.equals(
"true") || MacroName.equals(
"false"))
3001 else if (MacroName.equals(
"bool"))
3016 case Decl::Function:
3024 case Decl::ObjCMethod:
3046 case Decl::ClassTemplatePartialSpecialization:
3052 case Decl::UnresolvedUsingValue:
3053 case Decl::UnresolvedUsingTypename:
3056 case Decl::ObjCPropertyImpl:
3057 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3071 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3072 switch (TD->getTagKind()) {
3086 bool IncludeUndefined,
3087 bool TargetTypeIsPointer =
false) {
3090 Results.EnterNewScope();
3096 if (IncludeUndefined || MD) {
3098 if (MI->isUsedForHeaderGuard())
3101 Results.AddResult(Result(M->first,
3104 TargetTypeIsPointer)));
3108 Results.ExitScope();
3113 ResultBuilder &Results) {
3116 Results.EnterNewScope();
3118 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3119 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3120 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3122 Results.ExitScope();
3129 unsigned NumResults) {
3187 llvm_unreachable(
"Invalid ParserCompletionContext!");
3199 ResultBuilder &Results) {
3202 while (isa<BlockDecl>(CurContext))
3212 for (
auto P : Method->
params())
3213 if (!
P->getDeclName())
3221 Results.getCodeCompletionTUInfo());
3230 Overridden->getDeclContext());
3233 llvm::raw_string_ostream OS(Str);
3234 NNS->
print(OS, Policy);
3235 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3237 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3240 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
3241 Overridden->getNameAsString()));
3243 bool FirstParam =
true;
3244 for (
auto P : Method->
params()) {
3251 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3259 Results.Ignore(Overridden);
3266 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3267 CodeCompleter->getCodeCompletionTUInfo(),
3269 Results.EnterNewScope();
3277 PP.getHeaderSearchInfo().collectAllModules(Modules);
3278 for (
unsigned I = 0, N = Modules.size(); I != N; ++
I) {
3280 Builder.getAllocator().CopyString(Modules[I]->
Name));
3281 Results.AddResult(Result(
Builder.TakeString(),
3284 Modules[
I]->isAvailable()
3288 }
else if (getLangOpts().Modules) {
3290 Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path,
3297 Sub != SubEnd; ++Sub) {
3300 Builder.getAllocator().CopyString((*Sub)->Name));
3301 Results.AddResult(Result(
Builder.TakeString(),
3304 (*Sub)->isAvailable()
3310 Results.ExitScope();
3312 Results.data(),Results.size());
3317 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3318 CodeCompleter->getCodeCompletionTUInfo(),
3320 Results.EnterNewScope();
3325 switch (CompletionContext) {
3328 case PCC_ObjCInterface:
3329 case PCC_ObjCImplementation:
3330 case PCC_ObjCInstanceVariableList:
3332 case PCC_MemberTemplate:
3334 case PCC_LocalDeclarationSpecifiers:
3335 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3339 case PCC_ParenthesizedExpression:
3340 case PCC_Expression:
3344 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3346 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3352 case PCC_RecoveryInFunction:
3359 if (
CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
3360 if (CurMethod->isInstance())
3361 Results.setObjectTypeQualifiers(
3364 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3366 CodeCompleter->includeGlobals());
3369 Results.ExitScope();
3371 switch (CompletionContext) {
3372 case PCC_ParenthesizedExpression:
3373 case PCC_Expression:
3375 case PCC_RecoveryInFunction:
3382 case PCC_ObjCInterface:
3383 case PCC_ObjCImplementation:
3384 case PCC_ObjCInstanceVariableList:
3386 case PCC_MemberTemplate:
3390 case PCC_LocalDeclarationSpecifiers:
3394 if (CodeCompleter->includeMacros())
3398 Results.data(),Results.size());
3404 bool AtArgumentExpression,
3406 ResultBuilder &Results);
3409 bool AllowNonIdentifiers,
3410 bool AllowNestedNameSpecifiers) {
3412 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3413 CodeCompleter->getCodeCompletionTUInfo(),
3414 AllowNestedNameSpecifiers
3417 Results.EnterNewScope();
3420 Results.AddResult(Result(
"const"));
3421 Results.AddResult(Result(
"volatile"));
3422 if (getLangOpts().
C99)
3423 Results.AddResult(Result(
"restrict"));
3426 if (AllowNonIdentifiers) {
3427 Results.AddResult(Result(
"operator"));
3431 if (AllowNestedNameSpecifiers) {
3432 Results.allowNestedNameSpecifiers();
3433 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3434 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3436 CodeCompleter->includeGlobals());
3437 Results.setFilter(
nullptr);
3440 Results.ExitScope();
3446 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3466 Results.getCompletionContext(),
3467 Results.data(), Results.size());
3472 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3473 ObjCCollection(
false) { }
3485 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3486 CodeCompleter->getCodeCompletionTUInfo(),
3489 Results.setFilter(&ResultBuilder::IsObjCCollection);
3491 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3493 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3495 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3501 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++
I)
3504 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3506 CodeCompleter->includeGlobals());
3508 Results.EnterNewScope();
3510 Results.ExitScope();
3512 bool PreferredTypeIsPointer =
false;
3523 if (CodeCompleter->includeMacros())
3528 Results.data(),Results.size());
3533 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3534 else if (getLangOpts().ObjC1)
3535 CodeCompleteObjCInstanceMessage(S, E.
get(),
None,
false);
3545 if (Interface->hasDefinition())
3546 return Interface->getDefinition();
3552 if (Protocol->hasDefinition())
3553 return Protocol->getDefinition();
3562 bool AllowCategories,
3563 bool AllowNullaryMethods,
3566 ResultBuilder &Results) {
3574 if (AddedProperties.insert(
P->getIdentifier()).second)
3575 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3579 if (AllowNullaryMethods) {
3582 for (
auto *M : Container->
methods()) {
3583 if (M->getSelector().isUnarySelector())
3585 if (AddedProperties.insert(
Name).second) {
3587 Results.getCodeCompletionTUInfo());
3591 Results.getAllocator().CopyString(
Name->
getName()));
3593 Results.MaybeAddResult(Result(
Builder.TakeString(), M,
3603 for (
auto *
P : Protocol->protocols())
3605 CurContext, AddedProperties, Results);
3607 if (AllowCategories) {
3609 for (
auto *Cat : IFace->known_categories())
3611 CurContext, AddedProperties, Results);
3615 for (
auto *I : IFace->all_referenced_protocols())
3617 CurContext, AddedProperties, Results);
3620 if (IFace->getSuperClass())
3622 AllowNullaryMethods, CurContext,
3623 AddedProperties, Results);
3625 = dyn_cast<ObjCCategoryDecl>(Container)) {
3629 CurContext, AddedProperties, Results);
3636 if (!Base || !CodeCompleter)
3639 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
3642 Base = ConvertedBase.
get();
3673 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3674 CodeCompleter->getCodeCompletionTUInfo(),
3676 &ResultBuilder::IsMember);
3677 Results.EnterNewScope();
3684 Results.allowNestedNameSpecifiers();
3685 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3687 CodeCompleter->includeGlobals());
3689 if (getLangOpts().CPlusPlus) {
3690 if (!Results.empty()) {
3696 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
3704 Results.AddResult(Result(
"template"));
3714 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
3717 AddedProperties, Results);
3720 for (
auto *I : ObjCPtr->
quals())
3722 CurContext, AddedProperties, Results);
3729 Class = ObjCPtr->getInterfaceDecl();
3735 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3736 Results.setFilter(&ResultBuilder::IsObjCIvar);
3738 CodeCompleter->includeGlobals());
3744 Results.ExitScope();
3748 Results.getCompletionContext(),
3749 Results.data(),Results.size());
3756 ResultBuilder::LookupFilter Filter =
nullptr;
3761 Filter = &ResultBuilder::IsEnum;
3766 Filter = &ResultBuilder::IsUnion;
3773 Filter = &ResultBuilder::IsClassOrStruct;
3778 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
3781 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3782 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
3783 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3786 Results.setFilter(Filter);
3788 CodeCompleter->includeGlobals());
3790 if (CodeCompleter->includeGlobals()) {
3792 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
3797 Results.data(),Results.size());
3801 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3802 CodeCompleter->getCodeCompletionTUInfo(),
3804 Results.EnterNewScope();
3806 Results.AddResult(
"const");
3808 Results.AddResult(
"volatile");
3809 if (getLangOpts().
C99 &&
3811 Results.AddResult(
"restrict");
3812 if (getLangOpts().
C11 &&
3814 Results.AddResult(
"_Atomic");
3815 Results.ExitScope();
3817 Results.getCompletionContext(),
3818 Results.data(), Results.size());
3822 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
3825 SwitchStmt *Switch = getCurFunction()->SwitchStack.back();
3830 CodeCompleteExpression(S, Data);
3844 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
3853 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseVal))
3855 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
3862 EnumeratorsSeen.insert(Enumerator);
3875 Qualifier = DRE->getQualifier();
3879 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
3887 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3888 CodeCompleter->getCodeCompletionTUInfo(),
3890 Results.EnterNewScope();
3892 if (EnumeratorsSeen.count(
E))
3896 Results.AddResult(R, CurContext,
nullptr,
false);
3898 Results.ExitScope();
3903 if (CodeCompleter->includeMacros()) {
3910 Results.data(),Results.size());
3914 if (Args.size() && !Args.data())
3917 for (
unsigned I = 0; I != Args.size(); ++
I)
3930 if (!CandidateSet.
empty()) {
3933 CandidateSet.
begin(), CandidateSet.
end(),
3939 for (
auto &Candidate : CandidateSet)
3940 if (Candidate.Viable)
3948 ArrayRef<ResultCandidate> Candidates,
3955 for (
auto &Candidate : Candidates) {
3956 if (
auto FType = Candidate.getFunctionType())
3957 if (
auto Proto = dyn_cast<FunctionProtoType>(FType))
3958 if (N < Proto->getNumParams()) {
3960 ParamType = Proto->getParamType(N);
3963 Proto->getParamType(N).getNonReferenceType()))
3974 unsigned CurrentArg,
3975 bool CompleteExpressionWithCurrentArg =
true) {
3977 if (CompleteExpressionWithCurrentArg)
3978 ParamType =
getParamType(SemaRef, Candidates, CurrentArg);
3985 if (!Candidates.empty())
4005 CodeCompleteOrdinaryName(S, PCC_Expression);
4016 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4017 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4019 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4021 if (UME->hasExplicitTemplateArgs()) {
4022 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4023 TemplateArgs = &TemplateArgsBuffer;
4026 ArgExprs.append(Args.begin(), Args.end());
4028 Decls.
append(UME->decls_begin(), UME->decls_end());
4029 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4034 if (
auto MCE = dyn_cast<MemberExpr>(NakedFn))
4036 else if (
auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
4037 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4039 if (!getLangOpts().CPlusPlus ||
4052 if (isCompleteType(Loc, NakedFn->
getType())) {
4055 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4056 LookupQualifiedName(R, DC);
4059 ArgExprs.append(Args.begin(), Args.end());
4073 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4085 !CandidateSet.
empty());
4094 if (!isCompleteType(Loc, Type))
4099 CodeCompleteExpression(S, Type);
4108 for (
auto C : LookupConstructors(RD)) {
4109 if (
auto FD = dyn_cast<FunctionDecl>(
C)) {
4114 }
else if (
auto FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
4115 AddTemplateOverloadCandidate(FTD,
4130 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4132 CodeCompleteOrdinaryName(S, PCC_Expression);
4136 CodeCompleteExpression(S, VD->
getType());
4141 if (isa<BlockDecl>(CurContext)) {
4143 ResultType = BSI->ReturnType;
4144 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
4145 ResultType = Function->getReturnType();
4146 else if (
ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4147 ResultType = Method->getReturnType();
4150 CodeCompleteOrdinaryName(S, PCC_Expression);
4152 CodeCompleteExpression(S, ResultType);
4156 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4157 CodeCompleter->getCodeCompletionTUInfo(),
4159 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4160 Results.EnterNewScope();
4162 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4164 CodeCompleter->includeGlobals());
4170 Results.getCodeCompletionTUInfo());
4171 Builder.AddTypedTextChunk(
"else");
4172 if (Results.includeCodePatterns()) {
4176 Builder.AddPlaceholderChunk(
"statements");
4180 Results.AddResult(
Builder.TakeString());
4183 Builder.AddTypedTextChunk(
"else");
4189 Builder.AddPlaceholderChunk(
"condition");
4191 Builder.AddPlaceholderChunk(
"expression");
4193 if (Results.includeCodePatterns()) {
4197 Builder.AddPlaceholderChunk(
"statements");
4201 Results.AddResult(
Builder.TakeString());
4203 Results.ExitScope();
4208 if (CodeCompleter->includeMacros())
4212 Results.data(),Results.size());
4217 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType());
4219 CodeCompleteOrdinaryName(S, PCC_Expression);
4223 bool EnteringContext) {
4227 DeclContext *Ctx = computeDeclContext(SS, EnteringContext);
4233 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4236 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4237 CodeCompleter->getCodeCompletionTUInfo(),
4239 Results.EnterNewScope();
4245 Results.AddResult(
"template");
4252 if (!EnteringContext)
4254 Results.ExitScope();
4256 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4260 Results.getCompletionContext(),
4261 Results.data(),Results.size());
4268 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4269 CodeCompleter->getCodeCompletionTUInfo(),
4271 &ResultBuilder::IsNestedNameSpecifier);
4272 Results.EnterNewScope();
4280 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4282 CodeCompleter->includeGlobals());
4283 Results.ExitScope();
4287 Results.data(),Results.size());
4296 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4297 CodeCompleter->getCodeCompletionTUInfo(),
4299 &ResultBuilder::IsNamespaceOrAlias);
4300 Results.EnterNewScope();
4301 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4303 CodeCompleter->includeGlobals());
4304 Results.ExitScope();
4307 Results.data(),Results.size());
4318 bool SuppressedGlobalResults
4319 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
4321 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4322 CodeCompleter->getCodeCompletionTUInfo(),
4323 SuppressedGlobalResults
4326 &ResultBuilder::IsNamespace);
4328 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
4333 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
4337 OrigToLatest[NS->getOriginalNamespace()] = *NS;
4341 Results.EnterNewScope();
4343 NS = OrigToLatest.begin(),
4344 NSEnd = OrigToLatest.end();
4347 NS->second, Results.getBasePriority(NS->second),
4349 CurContext,
nullptr,
false);
4350 Results.ExitScope();
4354 Results.getCompletionContext(),
4355 Results.data(),Results.size());
4363 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4364 CodeCompleter->getCodeCompletionTUInfo(),
4366 &ResultBuilder::IsNamespaceOrAlias);
4367 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4369 CodeCompleter->includeGlobals());
4371 Results.getCompletionContext(),
4372 Results.data(),Results.size());
4380 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4381 CodeCompleter->getCodeCompletionTUInfo(),
4383 &ResultBuilder::IsType);
4384 Results.EnterNewScope();
4387 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
4388 if (std::strcmp(Spelling, "?")) \
4389 Results.AddResult(Result(Spelling));
4390 #include "clang/Basic/OperatorKinds.def"
4393 Results.allowNestedNameSpecifiers();
4394 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4396 CodeCompleter->includeGlobals());
4400 Results.ExitScope();
4404 Results.data(),Results.size());
4413 AdjustDeclIfTemplate(ConstructorD);
4419 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4420 CodeCompleter->getCodeCompletionTUInfo(),
4422 Results.EnterNewScope();
4425 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
4426 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
4427 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++
I) {
4428 if (Initializers[I]->isBaseInitializer())
4429 InitializedBases.insert(
4432 InitializedFields.insert(cast<FieldDecl>(
4433 Initializers[I]->getAnyMember()));
4438 Results.getCodeCompletionTUInfo());
4440 bool SawLastInitializer = Initializers.empty();
4442 for (
const auto &
Base : ClassDecl->
bases()) {
4446 = !Initializers.empty() &&
4447 Initializers.back()->isBaseInitializer() &&
4449 QualType(Initializers.back()->getBaseClass(), 0));
4454 Results.getAllocator().CopyString(
4455 Base.getType().getAsString(Policy)));
4457 Builder.AddPlaceholderChunk(
"args");
4462 SawLastInitializer =
false;
4466 for (
const auto &
Base : ClassDecl->
vbases()) {
4470 = !Initializers.empty() &&
4471 Initializers.back()->isBaseInitializer() &&
4473 QualType(Initializers.back()->getBaseClass(), 0));
4478 Builder.getAllocator().CopyString(
4479 Base.getType().getAsString(Policy)));
4481 Builder.AddPlaceholderChunk(
"args");
4486 SawLastInitializer =
false;
4490 for (
auto *Field : ClassDecl->
fields()) {
4491 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
4494 = !Initializers.empty() &&
4495 Initializers.back()->isAnyMemberInitializer() &&
4496 Initializers.back()->getAnyMember() == Field;
4500 if (!Field->getDeclName())
4504 Field->getIdentifier()->getName()));
4506 Builder.AddPlaceholderChunk(
"args");
4514 SawLastInitializer =
false;
4516 Results.ExitScope();
4519 Results.data(), Results.size());
4532 bool AfterAmpersand) {
4533 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4534 CodeCompleter->getCodeCompletionTUInfo(),
4536 Results.EnterNewScope();
4539 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
4540 bool IncludedThis =
false;
4543 IncludedThis =
true;
4552 for (
const auto *D : S->
decls()) {
4553 const auto *Var = dyn_cast<
VarDecl>(D);
4561 CurContext,
nullptr,
false);
4569 Results.ExitScope();
4572 Results.data(), Results.size());
4577 #define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword)
4580 ResultBuilder &Results,
4587 Results.getCodeCompletionTUInfo());
4588 if (LangOpts.ObjC2) {
4592 Builder.AddPlaceholderChunk(
"property");
4593 Results.AddResult(Result(
Builder.TakeString()));
4598 Builder.AddPlaceholderChunk(
"property");
4599 Results.AddResult(Result(
Builder.TakeString()));
4604 ResultBuilder &Results,
4611 if (LangOpts.ObjC2) {
4626 Results.getCodeCompletionTUInfo());
4631 Builder.AddPlaceholderChunk(
"name");
4632 Results.AddResult(Result(
Builder.TakeString()));
4634 if (Results.includeCodePatterns()) {
4640 Builder.AddPlaceholderChunk(
"class");
4641 Results.AddResult(Result(
Builder.TakeString()));
4646 Builder.AddPlaceholderChunk(
"protocol");
4647 Results.AddResult(Result(
Builder.TakeString()));
4652 Builder.AddPlaceholderChunk(
"class");
4653 Results.AddResult(Result(
Builder.TakeString()));
4659 Builder.AddPlaceholderChunk(
"alias");
4661 Builder.AddPlaceholderChunk(
"class");
4662 Results.AddResult(Result(
Builder.TakeString()));
4664 if (Results.getSema().getLangOpts().Modules) {
4668 Builder.AddPlaceholderChunk(
"module");
4669 Results.AddResult(Result(
Builder.TakeString()));
4674 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4675 CodeCompleter->getCodeCompletionTUInfo(),
4677 Results.EnterNewScope();
4678 if (isa<ObjCImplDecl>(CurContext))
4684 Results.ExitScope();
4687 Results.data(),Results.size());
4693 Results.getCodeCompletionTUInfo());
4696 const char *EncodeType =
"char[]";
4697 if (Results.getSema().getLangOpts().CPlusPlus ||
4698 Results.getSema().getLangOpts().ConstStrings)
4699 EncodeType =
"const char[]";
4700 Builder.AddResultTypeChunk(EncodeType);
4703 Builder.AddPlaceholderChunk(
"type-name");
4705 Results.AddResult(Result(
Builder.TakeString()));
4708 Builder.AddResultTypeChunk(
"Protocol *");
4711 Builder.AddPlaceholderChunk(
"protocol-name");
4713 Results.AddResult(Result(
Builder.TakeString()));
4716 Builder.AddResultTypeChunk(
"SEL");
4719 Builder.AddPlaceholderChunk(
"selector");
4721 Results.AddResult(Result(
Builder.TakeString()));
4724 Builder.AddResultTypeChunk(
"NSString *");
4726 Builder.AddPlaceholderChunk(
"string");
4728 Results.AddResult(Result(
Builder.TakeString()));
4731 Builder.AddResultTypeChunk(
"NSArray *");
4733 Builder.AddPlaceholderChunk(
"objects, ...");
4735 Results.AddResult(Result(
Builder.TakeString()));
4738 Builder.AddResultTypeChunk(
"NSDictionary *");
4740 Builder.AddPlaceholderChunk(
"key");
4743 Builder.AddPlaceholderChunk(
"object, ...");
4745 Results.AddResult(Result(
Builder.TakeString()));
4748 Builder.AddResultTypeChunk(
"id");
4750 Builder.AddPlaceholderChunk(
"expression");
4752 Results.AddResult(Result(
Builder.TakeString()));
4758 Results.getCodeCompletionTUInfo());
4760 if (Results.includeCodePatterns()) {
4765 Builder.AddPlaceholderChunk(
"statements");
4767 Builder.AddTextChunk(
"@catch");
4769 Builder.AddPlaceholderChunk(
"parameter");
4772 Builder.AddPlaceholderChunk(
"statements");
4774 Builder.AddTextChunk(
"@finally");
4776 Builder.AddPlaceholderChunk(
"statements");
4778 Results.AddResult(Result(
Builder.TakeString()));
4784 Builder.AddPlaceholderChunk(
"expression");
4785 Results.AddResult(Result(
Builder.TakeString()));
4787 if (Results.includeCodePatterns()) {
4792 Builder.AddPlaceholderChunk(
"expression");
4795 Builder.AddPlaceholderChunk(
"statements");
4797 Results.AddResult(Result(
Builder.TakeString()));
4802 ResultBuilder &Results,
4813 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4814 CodeCompleter->getCodeCompletionTUInfo(),
4816 Results.EnterNewScope();
4818 Results.ExitScope();
4821 Results.data(),Results.size());
4825 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4826 CodeCompleter->getCodeCompletionTUInfo(),
4828 Results.EnterNewScope();
4831 Results.ExitScope();
4834 Results.data(),Results.size());
4838 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4839 CodeCompleter->getCodeCompletionTUInfo(),
4841 Results.EnterNewScope();
4843 Results.ExitScope();
4846 Results.data(),Results.size());
4853 if (Attributes & NewFlag)
4856 Attributes |= NewFlag;
4870 if (AssignCopyRetMask &&
4888 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4889 CodeCompleter->getCodeCompletionTUInfo(),
4891 Results.EnterNewScope();
4919 Results.getCodeCompletionTUInfo());
4921 Setter.AddTextChunk(
"=");
4922 Setter.AddPlaceholderChunk(
"method");
4927 Results.getCodeCompletionTUInfo());
4929 Getter.AddTextChunk(
"=");
4930 Getter.AddPlaceholderChunk(
"method");
4939 Results.ExitScope();
4942 Results.data(),Results.size());
4955 ArrayRef<IdentifierInfo *> SelIdents,
4956 bool AllowSameLength =
true) {
4957 unsigned NumSelIdents = SelIdents.size();
4967 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
4970 for (
unsigned I = 0; I != NumSelIdents; ++
I)
4979 ArrayRef<IdentifierInfo *> SelIdents,
4980 bool AllowSameLength =
true) {
4988 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5012 bool WantInstanceMethods,
5014 ArrayRef<IdentifierInfo *> SelIdents,
5016 VisitedSelectorSet &Selectors,
5017 bool AllowSameLength,
5018 ResultBuilder &Results,
5019 bool InOriginalClass =
true) {
5024 for (
auto *M : Container->
methods()) {
5027 if (M->isInstanceMethod() == WantInstanceMethods ||
5028 (isRootClass && !WantInstanceMethods)) {
5034 if (!Selectors.insert(M->getSelector()).second)
5037 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5038 R.StartParameter = SelIdents.size();
5039 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5040 if (!InOriginalClass)
5042 Results.MaybeAddResult(R, CurContext);
5048 if (Protocol->hasDefinition()) {
5050 = Protocol->getReferencedProtocols();
5052 E = Protocols.
end();
5055 CurContext, Selectors, AllowSameLength, Results,
false);
5065 CurContext, Selectors, AllowSameLength, Results,
false);
5069 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5070 CurContext, Selectors, AllowSameLength,
5071 Results, InOriginalClass);
5075 = CatDecl->getReferencedProtocols();
5077 E = Protocols.
end();
5080 CurContext, Selectors, AllowSameLength,
5086 CurContext, Selectors, AllowSameLength,
5087 Results, InOriginalClass);
5093 SelIdents, CurContext, Selectors,
5094 AllowSameLength, Results,
false);
5099 CurContext, Selectors, AllowSameLength,
5100 Results, InOriginalClass);
5109 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5110 Class =
Category->getClassInterface();
5117 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5118 CodeCompleter->getCodeCompletionTUInfo(),
5120 Results.EnterNewScope();
5122 VisitedSelectorSet Selectors;
5125 Results.ExitScope();
5128 Results.data(),Results.size());
5134 = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
5137 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5138 Class =
Category->getClassInterface();
5145 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5146 CodeCompleter->getCodeCompletionTUInfo(),
5148 Results.EnterNewScope();
5150 VisitedSelectorSet Selectors;
5152 Selectors,
true, Results);
5154 Results.ExitScope();
5157 Results.data(),Results.size());
5162 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5163 CodeCompleter->getCodeCompletionTUInfo(),
5165 Results.EnterNewScope();
5168 bool AddedInOut =
false;
5171 Results.AddResult(
"in");
5172 Results.AddResult(
"inout");
5177 Results.AddResult(
"out");
5179 Results.AddResult(
"inout");
5184 Results.AddResult(
"bycopy");
5185 Results.AddResult(
"byref");
5186 Results.AddResult(
"oneway");
5189 Results.AddResult(
"nonnull");
5190 Results.AddResult(
"nullable");
5191 Results.AddResult(
"null_unspecified");
5199 PP.isMacroDefined(
"IBAction")) {
5201 Results.getCodeCompletionTUInfo(),
5203 Builder.AddTypedTextChunk(
"IBAction");
5205 Builder.AddPlaceholderChunk(
"selector");
5210 Builder.AddTextChunk(
"sender");
5221 Results.ExitScope();
5224 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
5225 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5227 CodeCompleter->includeGlobals());
5229 if (CodeCompleter->includeMacros())
5234 Results.data(), Results.size());
5264 IFace = ObjType->getInterface();
5270 IFace = Ptr->getInterfaceDecl();
5284 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5285 .Case(
"retain", IFace)
5286 .Case(
"strong", IFace)
5287 .Case(
"autorelease", IFace)
5288 .Case(
"copy", IFace)
5289 .Case(
"copyWithZone", IFace)
5290 .Case(
"mutableCopy", IFace)
5291 .Case(
"mutableCopyWithZone", IFace)
5292 .Case(
"awakeFromCoder", IFace)
5293 .Case(
"replacementObjectFromCoder", IFace)
5294 .Case(
"class", IFace)
5295 .Case(
"classForCoder", IFace)
5296 .Case(
"superclass", Super)
5299 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5301 .Case(
"alloc", IFace)
5302 .Case(
"allocWithZone", IFace)
5303 .Case(
"class", IFace)
5304 .Case(
"superclass", Super)
5325 Sema &
S,
bool NeedSuperKeyword,
5326 ArrayRef<IdentifierInfo *> SelIdents,
5327 ResultBuilder &Results) {
5346 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
5364 CurP != CurPEnd; ++CurP, ++SuperP) {
5367 (*SuperP)->getType()))
5371 if (!(*CurP)->getIdentifier())
5377 Results.getCodeCompletionTUInfo());
5381 Results.getCompletionContext().getBaseType(),
5385 if (NeedSuperKeyword) {
5386 Builder.AddTypedTextChunk(
"super");
5392 if (NeedSuperKeyword)
5400 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++
I, ++CurP) {
5401 if (I > SelIdents.size())
5404 if (I < SelIdents.size())
5406 Builder.getAllocator().CopyString(
5408 else if (NeedSuperKeyword || I > SelIdents.size()) {
5410 Builder.getAllocator().CopyString(
5413 (*CurP)->getIdentifier()->getName()));
5416 Builder.getAllocator().CopyString(
5419 (*CurP)->getIdentifier()->getName()));
5431 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5432 CodeCompleter->getCodeCompletionTUInfo(),
5434 getLangOpts().CPlusPlus11
5435 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
5436 : &ResultBuilder::IsObjCMessageReceiver);
5438 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5439 Results.EnterNewScope();
5441 CodeCompleter->includeGlobals());
5447 if (Iface->getSuperClass()) {
5448 Results.AddResult(Result(
"super"));
5456 Results.ExitScope();
5458 if (CodeCompleter->includeMacros())
5461 Results.data(), Results.size());
5467 bool AtArgumentExpression) {
5471 CDecl = CurMethod->getClassInterface();
5480 if (CurMethod->isInstanceMethod()) {
5484 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
5485 AtArgumentExpression,
5494 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc,
5495 LookupOrdinaryName);
5496 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
5498 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
5501 CDecl = Iface->getInterface();
5502 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
5509 id.setIdentifier(Super, SuperLoc);
5510 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
5512 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
5514 AtArgumentExpression);
5523 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
5524 AtArgumentExpression,
5531 unsigned NumSelIdents) {
5533 ASTContext &Context = Results.getSema().Context;
5537 Result *ResultsData = Results.data();
5538 for (
unsigned I = 0, N = Results.size(); I != N; ++
I) {
5539 Result &R = ResultsData[
I];
5540 if (R.Kind == Result::RK_Declaration &&
5541 isa<ObjCMethodDecl>(R.Declaration)) {
5542 if (R.Priority <= BestPriority) {
5543 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
5544 if (NumSelIdents <= Method->param_size()) {
5547 if (R.Priority < BestPriority || PreferredType.
isNull()) {
5548 BestPriority = R.Priority;
5549 PreferredType = MyPreferredType;
5559 return PreferredType;
5564 ArrayRef<IdentifierInfo *> SelIdents,
5565 bool AtArgumentExpression,
5567 ResultBuilder &Results) {
5577 CDecl = Interface->getInterface();
5582 Results.EnterNewScope();
5589 Results.Ignore(SuperMethod);
5595 Results.setPreferredSelector(CurMethod->getSelector());
5597 VisitedSelectorSet Selectors;
5600 SemaRef.
CurContext, Selectors, AtArgumentExpression,
5608 for (uint32_t I = 0,
5624 MethList = MethList->getNext()) {
5628 Result R(MethList->getMethod(),
5629 Results.getBasePriority(MethList->getMethod()),
nullptr);
5630 R.StartParameter = SelIdents.size();
5631 R.AllParametersAreInformative =
false;
5632 Results.MaybeAddResult(R, SemaRef.
CurContext);
5637 Results.ExitScope();
5642 bool AtArgumentExpression,
5645 QualType T = this->GetTypeFromParser(Receiver);
5647 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5648 CodeCompleter->getCodeCompletionTUInfo(),
5653 AtArgumentExpression, IsSuper, Results);
5660 if (AtArgumentExpression) {
5663 if (PreferredType.
isNull())
5664 CodeCompleteOrdinaryName(S, PCC_Expression);
5666 CodeCompleteExpression(S, PreferredType);
5671 Results.getCompletionContext(),
5672 Results.data(), Results.size());
5677 bool AtArgumentExpression,
5681 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
5686 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
5689 RecExpr = Conv.
get();
5702 return CodeCompleteObjCClassMessage(S,
5705 AtArgumentExpression, Super);
5710 }
else if (RecExpr && getLangOpts().CPlusPlus) {
5711 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
5713 RecExpr = Conv.
get();
5714 ReceiverType = RecExpr->
getType();
5719 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5720 CodeCompleter->getCodeCompletionTUInfo(),
5722 ReceiverType, SelIdents));
5724 Results.EnterNewScope();
5731 Results.Ignore(SuperMethod);
5737 Results.setPreferredSelector(CurMethod->getSelector());
5740 VisitedSelectorSet Selectors;
5750 CurContext, Selectors, AtArgumentExpression, Results);
5757 for (
auto *I : QualID->quals())
5759 Selectors, AtArgumentExpression, Results);
5766 CurContext, Selectors, AtArgumentExpression,
5770 for (
auto *I : IFacePtr->quals())
5772 Selectors, AtArgumentExpression, Results);
5781 if (ExternalSource) {
5782 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
5784 Selector Sel = ExternalSource->GetExternalSelector(I);
5785 if (Sel.
isNull() || MethodPool.count(Sel))
5788 ReadMethodPool(Sel);
5793 MEnd = MethodPool.end();
5797 MethList = MethList->getNext()) {
5801 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
5804 Result R(MethList->getMethod(),
5805 Results.getBasePriority(MethList->getMethod()),
nullptr);
5806 R.StartParameter = SelIdents.size();
5807 R.AllParametersAreInformative =
false;
5808 Results.MaybeAddResult(R, CurContext);
5812 Results.ExitScope();
5820 if (AtArgumentExpression) {
5823 if (PreferredType.
isNull())
5824 CodeCompleteOrdinaryName(S, PCC_Expression);
5826 CodeCompleteExpression(S, PreferredType);
5831 Results.getCompletionContext(),
5832 Results.data(),Results.size());
5848 CodeCompleteExpression(S, Data);
5855 if (ExternalSource) {
5856 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
5858 Selector Sel = ExternalSource->GetExternalSelector(I);
5859 if (Sel.
isNull() || MethodPool.count(Sel))
5862 ReadMethodPool(Sel);
5866 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5867 CodeCompleter->getCodeCompletionTUInfo(),
5869 Results.EnterNewScope();
5871 MEnd = MethodPool.end();
5879 Results.getCodeCompletionTUInfo());
5883 Results.AddResult(
Builder.TakeString());
5887 std::string Accumulator;
5888 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++
I) {
5889 if (I == SelIdents.size()) {
5890 if (!Accumulator.empty()) {
5893 Accumulator.clear();
5900 Builder.AddTypedTextChunk(
Builder.getAllocator().CopyString( Accumulator));
5901 Results.AddResult(
Builder.TakeString());
5903 Results.ExitScope();
5907 Results.data(), Results.size());
5913 bool OnlyForwardDeclarations,
5914 ResultBuilder &Results) {
5917 for (
const auto *D : Ctx->
decls()) {
5919 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
5920 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
5921 Results.AddResult(Result(Proto, Results.getBasePriority(Proto),
nullptr),
5922 CurContext,
nullptr,
false);
5928 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5929 CodeCompleter->getCodeCompletionTUInfo(),
5932 if (CodeCompleter && CodeCompleter->includeGlobals()) {
5933 Results.EnterNewScope();
5941 Results.Ignore(Protocol);
5947 Results.ExitScope();
5952 Results.data(),Results.size());
5956 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5957 CodeCompleter->getCodeCompletionTUInfo(),
5960 if (CodeCompleter && CodeCompleter->includeGlobals()) {
5961 Results.EnterNewScope();
5967 Results.ExitScope();
5972 Results.data(),Results.size());
5978 bool OnlyForwardDeclarations,
5979 bool OnlyUnimplemented,
5980 ResultBuilder &Results) {
5983 for (
const auto *D : Ctx->
decls()) {
5985 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
5986 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
5987 (!OnlyUnimplemented || !Class->getImplementation()))
5988 Results.AddResult(Result(Class, Results.getBasePriority(Class),
nullptr),
5989 CurContext,
nullptr,
false);
5994 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5995 CodeCompleter->getCodeCompletionTUInfo(),
5997 Results.EnterNewScope();
5999 if (CodeCompleter->includeGlobals()) {
6005 Results.ExitScope();
6009 Results.data(),Results.size());
6014 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6015 CodeCompleter->getCodeCompletionTUInfo(),
6017 Results.EnterNewScope();
6021 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6022 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6023 Results.Ignore(CurClass);
6025 if (CodeCompleter->includeGlobals()) {
6031 Results.ExitScope();
6035 Results.data(),Results.size());
6039 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6040 CodeCompleter->getCodeCompletionTUInfo(),
6042 Results.EnterNewScope();
6044 if (CodeCompleter->includeGlobals()) {
6050 Results.ExitScope();
6054 Results.data(),Results.size());
6062 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6063 CodeCompleter->getCodeCompletionTUInfo(),
6068 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6070 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6072 for (
const auto *Cat : Class->visible_categories())
6073 CategoryNames.insert(Cat->getIdentifier());
6077 Results.EnterNewScope();
6079 for (
const auto *D : TU->
decls())
6080 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6081 if (CategoryNames.insert(
Category->getIdentifier()).second)
6084 CurContext,
nullptr,
false);
6085 Results.ExitScope();
6089 Results.data(),Results.size());
6101 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6104 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6106 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6107 CodeCompleter->getCodeCompletionTUInfo(),
6113 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6114 Results.EnterNewScope();
6115 bool IgnoreImplemented =
true;
6118 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6119 CategoryNames.insert(Cat->getIdentifier()).second)
6120 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6121 CurContext,
nullptr,
false);
6125 IgnoreImplemented =
false;
6127 Results.ExitScope();
6131 Results.data(),Results.size());
6136 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6137 CodeCompleter->getCodeCompletionTUInfo(),
6142 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6144 (!isa<ObjCImplementationDecl>(Container) &&
6145 !isa<ObjCCategoryImplDecl>(Container)))
6150 for (
const auto *D : Container->decls())
6151 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6152 Results.Ignore(PropertyImpl->getPropertyDecl());
6156 Results.EnterNewScope();
6158 = dyn_cast<ObjCImplementationDecl>(Container))
6161 AddedProperties, Results);
6164 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6165 false,
false, CurContext,
6166 AddedProperties, Results);
6167 Results.ExitScope();
6171 Results.data(),Results.size());
6177 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6178 CodeCompleter->getCodeCompletionTUInfo(),
6183 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6185 (!isa<ObjCImplementationDecl>(Container) &&
6186 !isa<ObjCCategoryImplDecl>(Container)))
6192 = dyn_cast<ObjCImplementationDecl>(Container))
6193 Class = ClassImpl->getClassInterface();
6195 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl()
6196 ->getClassInterface();
6204 =
Property->getType().getNonReferenceType().getUnqualifiedType();
6207 Results.setPreferredType(PropertyType);
6212 Results.EnterNewScope();
6213 bool SawSimilarlyNamedIvar =
false;
6214 std::string NameWithPrefix;
6215 NameWithPrefix +=
'_';
6216 NameWithPrefix += PropertyName->
getName();
6217 std::string NameWithSuffix = PropertyName->
getName().str();
6218 NameWithSuffix +=
'_';
6222 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6223 CurContext,
nullptr,
false);
6227 if ((PropertyName == Ivar->getIdentifier() ||
6228 NameWithPrefix == Ivar->
getName() ||
6229 NameWithSuffix == Ivar->getName())) {
6230 SawSimilarlyNamedIvar =
true;
6234 if (Results.size() &&
6235 Results.data()[Results.size() - 1].Kind
6237 Results.data()[Results.size() - 1].Declaration == Ivar)
6238 Results.data()[Results.size() - 1].Priority--;
6243 if (!SawSimilarlyNamedIvar) {
6254 Policy, Allocator));
6256 Results.AddResult(Result(
Builder.TakeString(), Priority,
6260 Results.ExitScope();
6264 Results.data(),Results.size());
6269 typedef llvm::DenseMap<
6278 bool WantInstanceMethods,
6281 bool InOriginalClass =
true) {
6284 if (!IFace->hasDefinition())
6287 IFace = IFace->getDefinition();
6291 = IFace->getReferencedProtocols();
6293 E = Protocols.
end();
6296 KnownMethods, InOriginalClass);
6299 for (
auto *Cat : IFace->visible_categories()) {
6301 KnownMethods,
false);
6305 if (IFace->getSuperClass())
6307 WantInstanceMethods, ReturnType,
6308 KnownMethods,
false);
6314 =
Category->getReferencedProtocols();
6316 E = Protocols.
end();
6319 KnownMethods, InOriginalClass);
6322 if (InOriginalClass &&
Category->getClassInterface())
6324 WantInstanceMethods, ReturnType, KnownMethods,
6330 if (!Protocol->hasDefinition())
6332 Protocol = Protocol->getDefinition();
6333 Container = Protocol;
6337 = Protocol->getReferencedProtocols();
6339 E = Protocols.
end();
6342 KnownMethods,
false);
6348 for (
auto *M : Container->
methods()) {
6349 if (M->isInstanceMethod() == WantInstanceMethods) {
6350 if (!ReturnType.
isNull() &&
6354 KnownMethods[M->getSelector()] =
6355 KnownMethodsMap::mapped_type(M, InOriginalClass);
6363 unsigned ObjCDeclQuals,
6392 bool IsInstanceMethod,
6395 VisitedSelectorSet &KnownSelectors,
6396 ResultBuilder &Results) {
6398 if (!PropName || PropName->
getLength() == 0)
6416 const char *CopiedKey;
6419 :
Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
6421 operator const char *() {
6425 return CopiedKey = Allocator.
CopyString(Key);
6427 } Key(Allocator, PropName->
getName());
6430 std::string UpperKey = PropName->
getName();
6431 if (!UpperKey.empty())
6434 bool ReturnTypeMatchesProperty = ReturnType.
isNull() ||
6437 bool ReturnTypeMatchesVoid
6441 if (IsInstanceMethod &&
6442 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
6448 Builder.AddTypedTextChunk(Key);
6455 if (IsInstanceMethod &&
6456 ((!ReturnType.
isNull() &&
6461 std::string SelectorName = (Twine(
"is") + UpperKey).str();
6463 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6465 if (ReturnType.
isNull()) {
6479 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
6481 std::string SelectorName = (Twine(
"set") + UpperKey).str();
6483 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6484 if (ReturnType.
isNull()) {
6492 Builder.AddTypedTextChunk(
":");
6531 if (IsInstanceMethod &&
6533 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
6535 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6537 if (ReturnType.
isNull()) {
6539 Builder.AddTextChunk(
"NSUInteger");
6545 Results.AddResult(Result(
Builder.TakeString(),
6546 std::min(IndexedGetterPriority,
6547 UnorderedGetterPriority),
6554 if (IsInstanceMethod &&
6556 std::string SelectorName
6557 = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
6559 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6560 if (ReturnType.
isNull()) {
6568 Builder.AddTextChunk(
"NSUInteger");
6570 Builder.AddTextChunk(
"index");
6571 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6577 if (IsInstanceMethod &&
6582 ->getName() ==
"NSArray"))) {
6583 std::string SelectorName
6584 = (Twine(Property->
getName()) +
"AtIndexes").str();
6586 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6587 if (ReturnType.
isNull()) {
6589 Builder.AddTextChunk(
"NSArray *");
6595 Builder.AddTextChunk(
"NSIndexSet *");
6597 Builder.AddTextChunk(
"indexes");
6598 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6604 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6605 std::string SelectorName = (Twine(
"get") + UpperKey).str();
6611 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6612 if (ReturnType.
isNull()) {
6620 Builder.AddPlaceholderChunk(
"object-type");
6623 Builder.AddTextChunk(
"buffer");
6625 Builder.AddTypedTextChunk(
"range:");
6627 Builder.AddTextChunk(
"NSRange");
6629 Builder.AddTextChunk(
"inRange");
6630 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6638 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6639 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
6645 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6646 if (ReturnType.
isNull()) {
6652 Builder.AddTypedTextChunk(
"insertObject:");
6654 Builder.AddPlaceholderChunk(
"object-type");
6657 Builder.AddTextChunk(
"object");
6661 Builder.AddPlaceholderChunk(
"NSUInteger");
6663 Builder.AddTextChunk(
"index");
6664 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6670 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6671 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
6677 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6678 if (ReturnType.
isNull()) {
6686 Builder.AddTextChunk(
"NSArray *");
6688 Builder.AddTextChunk(
"array");
6690 Builder.AddTypedTextChunk(
"atIndexes:");
6692 Builder.AddPlaceholderChunk(
"NSIndexSet *");
6694 Builder.AddTextChunk(
"indexes");
6695 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6701 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6702 std::string SelectorName
6703 = (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
6705 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6706 if (ReturnType.
isNull()) {
6714 Builder.AddTextChunk(
"NSUInteger");
6716 Builder.AddTextChunk(
"index");
6717 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6723 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6724 std::string SelectorName
6725 = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
6727 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6728 if (ReturnType.
isNull()) {
6736 Builder.AddTextChunk(
"NSIndexSet *");
6738 Builder.AddTextChunk(
"indexes");
6739 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6745 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6746 std::string SelectorName
6747 = (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
6753 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6754 if (ReturnType.
isNull()) {
6762 Builder.AddPlaceholderChunk(
"NSUInteger");
6764 Builder.AddTextChunk(
"index");
6766 Builder.AddTypedTextChunk(
"withObject:");
6770 Builder.AddTextChunk(
"object");
6771 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6777 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6778 std::string SelectorName1
6779 = (Twine(
"replace") + UpperKey +
"AtIndexes").str();
6780 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
6786 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6787 if (ReturnType.
isNull()) {
6795 Builder.AddPlaceholderChunk(
"NSIndexSet *");
6797 Builder.AddTextChunk(
"indexes");
6801 Builder.AddTextChunk(
"NSArray *");
6803 Builder.AddTextChunk(
"array");
6804 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6811 if (IsInstanceMethod &&
6816 ->getName() ==
"NSEnumerator"))) {
6817 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
6819 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6821 if (ReturnType.
isNull()) {
6823 Builder.AddTextChunk(
"NSEnumerator *");
6828 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
6834 if (IsInstanceMethod &&
6836 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
6838 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6839 if (ReturnType.
isNull()) {
6841 Builder.AddPlaceholderChunk(
"object-type");
6848 if (ReturnType.
isNull()) {
6849 Builder.AddPlaceholderChunk(
"object-type");
6857 Builder.AddTextChunk(
"object");
6858 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
6865 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6866 std::string SelectorName
6867 = (Twine(
"add") + UpperKey + Twine(
"Object")).str();
6869 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6870 if (ReturnType.
isNull()) {
6878 Builder.AddPlaceholderChunk(
"object-type");
6881 Builder.AddTextChunk(
"object");
6882 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6888 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6889 std::string SelectorName = (Twine(
"add") + UpperKey).str();
6891 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6892 if (ReturnType.
isNull()) {
6900 Builder.AddTextChunk(
"NSSet *");
6902 Builder.AddTextChunk(
"objects");
6903 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6909 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6910 std::string SelectorName
6911 = (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
6913 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6914 if (ReturnType.
isNull()) {
6922 Builder.AddPlaceholderChunk(
"object-type");
6925 Builder.AddTextChunk(
"object");
6926 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6932 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6933 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
6935 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6936 if (ReturnType.
isNull()) {
6944 Builder.AddTextChunk(
"NSSet *");
6946 Builder.AddTextChunk(
"objects");
6947 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6953 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6954 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
6956 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6957 if (ReturnType.
isNull()) {
6965 Builder.AddTextChunk(
"NSSet *");
6967 Builder.AddTextChunk(
"objects");
6968 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6975 if (!IsInstanceMethod &&
6980 ->getName() ==
"NSSet"))) {
6981 std::string SelectorName
6982 = (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
6984 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6986 if (ReturnType.
isNull()) {
6988 Builder.AddTextChunk(
"NSSet *");
6999 if (!IsInstanceMethod &&
7003 std::string SelectorName
7004 = (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
7006 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7008 if (ReturnType.
isNull()) {
7022 bool IsInstanceMethod,
7026 QualType ReturnType = GetTypeFromParser(ReturnTy);
7027 Decl *IDecl =
nullptr;
7030 IDecl = cast<Decl>(OCD);
7034 bool IsInImplementation =
false;
7035 if (
Decl *D = IDecl) {
7037 SearchDecl = Impl->getClassInterface();
7038 IsInImplementation =
true;
7040 = dyn_cast<ObjCCategoryImplDecl>(D)) {
7041 SearchDecl = CatImpl->getCategoryDecl();
7042 IsInImplementation =
true;
7047 if (!SearchDecl && S) {
7049 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7062 ReturnType, KnownMethods);
7066 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7067 CodeCompleter->getCodeCompletionTUInfo(),
7069 Results.EnterNewScope();
7072 MEnd = KnownMethods.end();
7076 Results.getCodeCompletionTUInfo());
7080 if (ReturnType.
isNull()) {
7098 P != PEnd; (void)++
P, ++I) {
7101 Builder.AddTypedTextChunk(
":");
7112 ParamType = (*P)->getType();
7114 ParamType = (*P)->getOriginalType();
7119 (*P)->getObjCDeclQualifier(),
7124 Builder.AddTextChunk(
Builder.getAllocator().CopyString( Id->getName()));
7133 if (IsInImplementation && Results.includeCodePatterns()) {
7140 Builder.AddTextChunk(
"return");
7142 Builder.AddPlaceholderChunk(
"expression");
7145 Builder.AddPlaceholderChunk(
"statements");
7152 if (!M->second.getInt())
7155 Results.AddResult(Result(
Builder.TakeString(), Method, Priority));
7162 Containers.push_back(SearchDecl);
7164 VisitedSelectorSet KnownSelectors;
7166 MEnd = KnownMethods.end();
7168 KnownSelectors.insert(M->first);
7174 IFace =
Category->getClassInterface();
7178 Containers.push_back(Cat);
7180 for (
unsigned I = 0, N = Containers.size(); I != N; ++
I)
7181 for (
auto *
P : Containers[I]->properties())
7183 KnownSelectors, Results);
7186 Results.ExitScope();
7190 Results.data(),Results.size());
7194 bool IsInstanceMethod,
7195 bool AtParameterName,
7200 if (ExternalSource) {
7201 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
7203 Selector Sel = ExternalSource->GetExternalSelector(I);
7204 if (Sel.
isNull() || MethodPool.count(Sel))
7207 ReadMethodPool(Sel);
7213 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7214 CodeCompleter->getCodeCompletionTUInfo(),
7218 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7220 Results.EnterNewScope();
7222 MEnd = MethodPool.end();
7224 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first :
7227 MethList = MethList->getNext()) {
7231 if (AtParameterName) {
7233 unsigned NumSelIdents = SelIdents.size();
7235 NumSelIdents <= MethList->getMethod()->param_size()) {
7237 MethList->getMethod()->parameters()[NumSelIdents - 1];
7240 Results.getCodeCompletionTUInfo());
7243 Results.AddResult(
Builder.TakeString());
7250 Result R(MethList->getMethod(),
7251 Results.getBasePriority(MethList->getMethod()),
nullptr);
7252 R.StartParameter = SelIdents.size();
7253 R.AllParametersAreInformative =
false;
7254 R.DeclaringEntity =
true;
7255 Results.MaybeAddResult(R, CurContext);
7259 Results.ExitScope();
7262 Results.data(),Results.size());
7266 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7267 CodeCompleter->getCodeCompletionTUInfo(),
7269 Results.EnterNewScope();
7273 Results.getCodeCompletionTUInfo());
7274 Builder.AddTypedTextChunk(
"if");
7276 Builder.AddPlaceholderChunk(
"condition");
7277 Results.AddResult(
Builder.TakeString());
7280 Builder.AddTypedTextChunk(
"ifdef");
7282 Builder.AddPlaceholderChunk(
"macro");
7283 Results.AddResult(
Builder.TakeString());
7286 Builder.AddTypedTextChunk(
"ifndef");
7288 Builder.AddPlaceholderChunk(
"macro");
7289 Results.AddResult(
Builder.TakeString());
7291 if (InConditional) {
7293 Builder.AddTypedTextChunk(
"elif");
7295 Builder.AddPlaceholderChunk(
"condition");
7296 Results.AddResult(
Builder.TakeString());
7299 Builder.AddTypedTextChunk(
"else");
7300 Results.AddResult(
Builder.TakeString());
7303 Builder.AddTypedTextChunk(
"endif");
7304 Results.AddResult(
Builder.TakeString());
7308 Builder.AddTypedTextChunk(
"include");
7311 Builder.AddPlaceholderChunk(
"header");
7313 Results.AddResult(
Builder.TakeString());
7316 Builder.AddTypedTextChunk(
"include");
7319 Builder.AddPlaceholderChunk(
"header");
7321 Results.AddResult(
Builder.TakeString());
7324 Builder.AddTypedTextChunk(
"define");
7326 Builder.AddPlaceholderChunk(
"macro");
7327 Results.AddResult(
Builder.TakeString());
7330 Builder.AddTypedTextChunk(
"define");
7332 Builder.AddPlaceholderChunk(
"macro");
7334 Builder.AddPlaceholderChunk(
"args");
7336 Results.AddResult(
Builder.TakeString());
7339 Builder.AddTypedTextChunk(
"undef");
7341 Builder.AddPlaceholderChunk(
"macro");
7342 Results.AddResult(
Builder.TakeString());
7345 Builder.AddTypedTextChunk(
"line");
7347 Builder.AddPlaceholderChunk(
"number");
7348 Results.AddResult(
Builder.TakeString());
7351 Builder.AddTypedTextChunk(
"line");
7353 Builder.AddPlaceholderChunk(
"number");
7356 Builder.AddPlaceholderChunk(
"filename");
7358 Results.AddResult(
Builder.TakeString());
7361 Builder.AddTypedTextChunk(
"error");
7363 Builder.AddPlaceholderChunk(
"message");
7364 Results.AddResult(
Builder.TakeString());
7367 Builder.AddTypedTextChunk(
"pragma");
7369 Builder.AddPlaceholderChunk(
"arguments");
7370 Results.AddResult(
Builder.TakeString());
7372 if (getLangOpts().ObjC1) {
7374 Builder.AddTypedTextChunk(
"import");
7377 Builder.AddPlaceholderChunk(
"header");
7379 Results.AddResult(
Builder.TakeString());
7382 Builder.AddTypedTextChunk(
"import");
7385 Builder.AddPlaceholderChunk(
"header");
7387 Results.AddResult(
Builder.TakeString());
7391 Builder.AddTypedTextChunk(
"include_next");
7394 Builder.AddPlaceholderChunk(
"header");
7396 Results.AddResult(
Builder.TakeString());
7399 Builder.AddTypedTextChunk(
"include_next");
7402 Builder.AddPlaceholderChunk(
"header");
7404 Results.AddResult(
Builder.TakeString());
7407 Builder.AddTypedTextChunk(
"warning");
7409 Builder.AddPlaceholderChunk(
"message");
7410 Results.AddResult(
Builder.TakeString());
7417 Results.ExitScope();
7421 Results.data(), Results.size());
7425 CodeCompleteOrdinaryName(S,
7431 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7432 CodeCompleter->getCodeCompletionTUInfo(),
7435 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
7438 Results.getCodeCompletionTUInfo());
7439 Results.EnterNewScope();
7441 MEnd = PP.macro_end();
7444 M->first->getName()));
7449 Results.ExitScope();
7450 }
else if (IsDefinition) {
7455 Results.data(), Results.size());
7459 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7460 CodeCompleter->getCodeCompletionTUInfo(),
7463 if (!CodeCompleter || CodeCompleter->includeMacros())
7467 Results.EnterNewScope();
7469 Results.getCodeCompletionTUInfo());
7470 Builder.AddTypedTextChunk(
"defined");
7473 Builder.AddPlaceholderChunk(
"macro");
7475 Results.AddResult(
Builder.TakeString());
7476 Results.ExitScope();
7480 Results.data(), Results.size());
7486 unsigned Argument) {
7503 ResultBuilder
Builder(*
this, Allocator, CCTUInfo,
7505 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
7506 CodeCompletionDeclConsumer Consumer(Builder,
7512 if (!CodeCompleter || CodeCompleter->includeMacros())
7516 Results.insert(Results.end(),
7517 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
getFlags - Return the flags for this scope.
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...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
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...
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
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...
Priority for the next initialization in a constructor initializer list.
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.
Code completion for a selector, as in an @selector expression.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
CodeCompleteConsumer::OverloadCandidate ResultCandidate
submodule_iterator submodule_begin()
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
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...
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
Code completion where an Objective-C class message is expected.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
FunctionType - C99 6.7.5.3 - Function Declarators.
static bool isObjCReceiverType(ASTContext &C, QualType T)
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
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)
Decl - This represents one declaration (or definition), e.g.
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...
Priority for a constant value (e.g., enumerator).
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
Substitute type arguments for the Objective-C type parameters used in the subject type...
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)
The base class of the type hierarchy.
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
Priority for a member declaration found from the current method or member function.
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()
getContinueParent - Return the closest scope that a continue statement would be affected by...
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)
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...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
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
SwitchStack - This is the current set of active switch statements in the block.
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.
ObjCMethodDecl - Represents an instance or class method declaration.
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
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
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.
The collection of all-type qualifiers we support.
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)
RecordDecl - Represents a struct/union/class.
static void AddTypedefResult(ResultBuilder &Results)
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
One of these records is kept for each identifier that is lexed.
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)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
SmallVector< Decl *, 4 > IgnoreDecls
Represents a class type in Objective C.
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.
Priority for a code pattern.
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.
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
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
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
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)
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.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
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)
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Namespaces, declared with 'namespace foo {}'.
A convenient class for passing around template argument information.
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
Returns the parent of this method declaration, which is the class in which this method is defined...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Whether values of this type can be null is (explicitly) unspecified.
Code completion occurred where a preprocessor directive is expected.
field_range fields() const
A friend of a previously-undeclared entity.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
TypeDecl - Represents a declaration of a type.
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
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
bool isVariadic() const
Whether this function is variadic.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Scope - A scope is a transient data structure that is used while parsing the program.
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
submodule_iterator submodule_end()
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
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()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
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
detail::InMemoryDirectory::const_iterator I
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
An Objective-C method being used as a property.
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)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
TST getTypeSpecType() const
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
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)
Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).
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
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
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
Arguments - The list of arguments for a function-like macro.
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.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
Code completion occurred where a new name is expected.
Priority for a declaration that is in the local scope.
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)
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
Adjustment for KVC code pattern priorities when it doesn't look like the.
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.
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
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
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.
const SwitchCase * getSwitchCaseList() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Priority for a preprocessor macro.
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)
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
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.
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
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Members, declared with object declarations within tag definitions.
const TemplateArgument * iterator
method_iterator begin_overridden_methods() const
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
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
Priority for a nested-name-specifier.
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.
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.
ObjCCategoryDecl - Represents a category declaration.
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.
Represents one property declaration in an Objective-C interface.
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
QualType getReturnType() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
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.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
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
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
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.
Represents a template argument.
ParserCompletionContext
Describes the context in which code completion occurs.
The result is in a base class.
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.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
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.
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...
Priority for a non-type declaration.
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
DeclarationName - The name of a declaration.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Selector getSelector() const
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
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)
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
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
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void CodeCompleteUsingDirective(Scope *S)
bool isFunctionLike() const
Represents a pointer to an Objective C object.
SwitchStmt - This represents a 'switch' stmt.
Encapsulates the data about a macro definition (e.g.
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.
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Not an overloaded operator.
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
ObjCMethodDecl * getGetterMethodDecl() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
bool TypeAlias
Whether this template specialization type is a substituted type alias.
const T * getAs() const
Member-template getAs<specific type>'.
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
If this pointer points to an Objective @interface type, gets the declaration for that interface...
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
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
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)
Priority for the Objective-C "_cmd" implicit parameter.
ObjCImplementationDecl * getImplementation() const
protocol_range protocols() const
const TypeClass * getTypePtr() const
Capturing the this pointer.
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.
Priority for a send-to-super completion.
A left parenthesis ('(').
__PTRDIFF_TYPE__ ptrdiff_t
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
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.
ObjCIvarDecl - Represents an ObjC instance variable.
A left angle bracket ('<').
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
A right angle bracket ('>').
Divide by this factor when a code-completion result's type exactly matches the type we expect...
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.
This class is used for builtin types like 'int'.
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)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
bool AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>").
static Qualifiers fromCVRMask(unsigned CVR)
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
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.
This declaration is a function-local extern declaration of a variable or function.
A reference to a declared variable, function, enum, etc.
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.
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
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()
Suppress the diagnostics that would normally fire because of this lookup.
arg_iterator arg_begin() const
static LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
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)
NamedDecl - This represents a decl with a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
bool IntegralConstantExpression
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
Macro that optionally prepends an "@" to the string literal passed in via Keyword, depending on whether NeedAt is true or false.
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
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.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
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)
void CodeCompleteObjCProtocolDecl(Scope *S)
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
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
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.