28 #include "llvm/ADT/DenseSet.h" 29 #include "llvm/ADT/SmallBitVector.h" 30 #include "llvm/ADT/SmallPtrSet.h" 31 #include "llvm/ADT/SmallString.h" 32 #include "llvm/ADT/StringExtras.h" 33 #include "llvm/ADT/StringSwitch.h" 34 #include "llvm/ADT/Twine.h" 39 using namespace clang;
50 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
56 std::vector<Result> Results;
61 llvm::SmallPtrSet<const Decl*, 16> AllDeclsFound;
63 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
68 class ShadowMapEntry {
73 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector*> DeclOrVector;
77 unsigned SingleDeclIndex;
80 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) { }
82 void Add(
const NamedDecl *ND,
unsigned Index) {
83 if (DeclOrVector.isNull()) {
86 SingleDeclIndex = Index;
91 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
94 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
95 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
100 DeclOrVector.get<DeclIndexPairVector*>()->push_back(
101 DeclIndexPair(ND, Index));
105 if (DeclIndexPairVector *Vec
106 = DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
114 iterator begin()
const;
115 iterator end()
const;
121 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
138 bool AllowNestedNameSpecifiers;
149 std::list<ShadowMap> ShadowMaps;
156 bool HasObjectTypeQualifiers;
168 void AdjustResultPriorityForDecl(Result &R);
170 void MaybeAddConstructorResults(Result R);
176 LookupFilter Filter =
nullptr)
177 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
179 AllowNestedNameSpecifiers(
false), HasObjectTypeQualifiers(
false),
180 CompletionContext(CompletionContext),
181 ObjCImplementation(nullptr)
185 switch (CompletionContext.
getKind()) {
192 if (Method->isInstanceMethod())
194 ObjCImplementation = Interface->getImplementation();
203 unsigned getBasePriority(
const NamedDecl *D);
207 bool includeCodePatterns()
const {
213 void setFilter(LookupFilter Filter) {
214 this->Filter = Filter;
217 Result *data() {
return Results.empty()? nullptr : &Results.front(); }
218 unsigned size()
const {
return Results.size(); }
219 bool empty()
const {
return Results.empty(); }
233 void setObjectTypeQualifiers(
Qualifiers Quals) {
234 ObjectTypeQualifiers = Quals;
235 HasObjectTypeQualifiers =
true;
243 void setPreferredSelector(
Selector Sel) {
244 PreferredSelector = Sel;
250 return CompletionContext;
254 void allowNestedNameSpecifiers(
bool Allow =
true) {
255 AllowNestedNameSpecifiers = Allow;
260 Sema &getSema()
const {
return SemaRef; }
274 bool isInterestingDecl(
const NamedDecl *ND,
275 bool &AsNestedNameSpecifier)
const;
283 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
293 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
310 void AddResult(Result R);
313 void EnterNewScope();
332 bool IsOrdinaryName(
const NamedDecl *ND)
const;
333 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
334 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
335 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
336 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
338 bool IsClassOrStruct(
const NamedDecl *ND)
const;
340 bool IsNamespace(
const NamedDecl *ND)
const;
341 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
343 bool IsMember(
const NamedDecl *ND)
const;
344 bool IsObjCIvar(
const NamedDecl *ND)
const;
345 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
346 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
347 bool IsObjCCollection(
const NamedDecl *ND)
const;
348 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
354 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
355 unsigned SingleDeclIndex;
367 pointer(
const DeclIndexPair &Value) : Value(Value) { }
377 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) { }
380 : DeclOrIterator(Iterator), SingleDeclIndex(0) { }
383 if (DeclOrIterator.is<
const NamedDecl *>()) {
389 const DeclIndexPair *I = DeclOrIterator.get<
const DeclIndexPair*>();
403 return reference(ND, SingleDeclIndex);
405 return *DeclOrIterator.get<
const DeclIndexPair*>();
413 return X.DeclOrIterator.getOpaqueValue()
414 == Y.DeclOrIterator.getOpaqueValue() &&
415 X.SingleDeclIndex == Y.SingleDeclIndex;
424 ResultBuilder::ShadowMapEntry::begin()
const {
425 if (DeclOrVector.isNull())
429 return iterator(ND, SingleDeclIndex);
431 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
435 ResultBuilder::ShadowMapEntry::end()
const {
436 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
439 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
461 for (
const DeclContext *CommonAncestor = TargetContext;
462 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
463 CommonAncestor = CommonAncestor->getLookupParent()) {
464 if (CommonAncestor->isTransparentContext() ||
465 CommonAncestor->isFunctionOrMethod())
468 TargetParents.push_back(CommonAncestor);
472 while (!TargetParents.empty()) {
475 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
476 if (!Namespace->getIdentifier())
481 else if (
const TagDecl *TD = dyn_cast<TagDecl>(Parent))
492 bool doubleUnderscoreOnly =
false) {
496 return Name[0] ==
'_' &&
497 (Name[1] ==
'_' || (Name[1] >=
'A' && Name[1] <=
'Z' &&
498 !doubleUnderscoreOnly));
524 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
525 bool &AsNestedNameSpecifier)
const {
526 AsNestedNameSpecifier =
false;
541 if (isa<ClassTemplateSpecializationDecl>(ND) ||
542 isa<ClassTemplatePartialSpecializationDecl>(ND))
546 if (isa<UsingDecl>(ND))
552 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
553 (isa<NamespaceDecl>(ND) &&
554 Filter != &ResultBuilder::IsNamespace &&
555 Filter != &ResultBuilder::IsNamespaceOrAlias &&
557 AsNestedNameSpecifier =
true;
560 if (Filter && !(this->*Filter)(Named)) {
562 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
563 IsNestedNameSpecifier(ND) &&
564 (Filter != &ResultBuilder::IsMember ||
565 (isa<CXXRecordDecl>(ND) &&
566 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
567 AsNestedNameSpecifier =
true;
577 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
597 R.QualifierIsInformative =
false;
602 R.Declaration->getDeclContext());
609 switch (T->getTypeClass()) {
611 switch (cast<BuiltinType>(T)->getKind()) {
612 case BuiltinType::Void:
615 case BuiltinType::NullPtr:
618 case BuiltinType::Overload:
619 case BuiltinType::Dependent:
622 case BuiltinType::ObjCId:
623 case BuiltinType::ObjCClass:
624 case BuiltinType::ObjCSel:
637 case Type::BlockPointer:
640 case Type::LValueReference:
641 case Type::RValueReference:
644 case Type::ConstantArray:
645 case Type::IncompleteArray:
646 case Type::VariableArray:
647 case Type::DependentSizedArray:
650 case Type::DependentSizedExtVector:
652 case Type::ExtVector:
655 case Type::FunctionProto:
656 case Type::FunctionNoProto:
665 case Type::ObjCObject:
666 case Type::ObjCInterface:
667 case Type::ObjCObjectPointer:
687 T = Function->getCallResultType();
688 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
689 T = Method->getSendResultType();
690 else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
695 T =
Value->getType();
709 if (
Pointer->getPointeeType()->isFunctionType()) {
723 T = Function->getReturnType();
733 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
742 dyn_cast<ImplicitParamDecl>(ND))
743 if (ImplicitParam->getIdentifier() &&
744 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
751 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
753 if (isa<CXXDestructorDecl>(ND))
765 if (isa<EnumConstantDecl>(ND))
771 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
782 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
785 if (!PreferredSelector.
isNull())
786 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
787 if (PreferredSelector == Method->getSelector())
802 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
808 void ResultBuilder::MaybeAddConstructorResults(Result R) {
809 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
817 Record = ClassTemplate->getTemplatedDecl();
818 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
820 if (isa<ClassTemplateSpecializationDecl>(Record))
842 Results.push_back(R);
847 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
848 ND = Tmpl->getTemplatedDecl();
849 return isa<CXXConstructorDecl>(ND);
852 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
853 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
855 if (R.Kind != Result::RK_Declaration) {
857 Results.push_back(R);
862 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
864 getBasePriority(Using->getTargetDecl()),
867 MaybeAddResult(Result, CurContext);
874 bool AsNestedNameSpecifier =
false;
875 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
882 ShadowMap &
SMap = ShadowMaps.back();
883 ShadowMapEntry::iterator I, IEnd;
884 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
885 if (NamePos != SMap.end()) {
886 I = NamePos->second.begin();
887 IEnd = NamePos->second.end();
890 for (; I != IEnd; ++I) {
892 unsigned Index = I->second;
895 Results[Index].Declaration = R.Declaration;
905 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
907 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
908 ShadowMapEntry::iterator I, IEnd;
909 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
910 if (NamePos != SM->end()) {
911 I = NamePos->second.begin();
912 IEnd = NamePos->second.end();
914 for (; I != IEnd; ++I) {
916 if (I->first->hasTagIdentifierNamespace() &&
924 I->first->getIdentifierNamespace() != IDNS)
928 if (CheckHiddenResult(R, CurContext, I->first))
936 if (!AllDeclsFound.insert(CanonDecl).second)
941 if (AsNestedNameSpecifier) {
942 R.StartsNestedNameSpecifier =
true;
945 AdjustResultPriorityForDecl(R);
948 if (R.QualifierIsInformative && !R.Qualifier &&
949 !R.StartsNestedNameSpecifier) {
950 const DeclContext *Ctx = R.Declaration->getDeclContext();
951 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
954 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
958 R.QualifierIsInformative =
false;
963 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
964 Results.push_back(R);
966 if (!AsNestedNameSpecifier)
967 MaybeAddConstructorResults(R);
970 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
971 NamedDecl *Hiding,
bool InBaseClass =
false) {
972 if (R.Kind != Result::RK_Declaration) {
974 Results.push_back(R);
979 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
981 getBasePriority(Using->getTargetDecl()),
984 AddResult(Result, CurContext, Hiding);
988 bool AsNestedNameSpecifier =
false;
989 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
996 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1000 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
1005 if (AsNestedNameSpecifier) {
1006 R.StartsNestedNameSpecifier =
true;
1008 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1011 R.Declaration->getDeclContext()->getRedeclContext()))
1012 R.QualifierIsInformative =
true;
1015 if (R.QualifierIsInformative && !R.Qualifier &&
1016 !R.StartsNestedNameSpecifier) {
1017 const DeclContext *Ctx = R.Declaration->getDeclContext();
1018 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1021 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1025 R.QualifierIsInformative =
false;
1032 AdjustResultPriorityForDecl(R);
1034 if (HasObjectTypeQualifiers)
1035 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1036 if (Method->isInstance()) {
1039 if (ObjectTypeQualifiers == MethodQuals)
1041 else if (ObjectTypeQualifiers - MethodQuals) {
1049 Results.push_back(R);
1051 if (!AsNestedNameSpecifier)
1052 MaybeAddConstructorResults(R);
1055 void ResultBuilder::AddResult(Result R) {
1056 assert(R.Kind != Result::RK_Declaration &&
1057 "Declaration results need more context");
1058 Results.push_back(R);
1062 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1065 void ResultBuilder::ExitScope() {
1066 for (ShadowMap::iterator E = ShadowMaps.back().begin(),
1067 EEnd = ShadowMaps.back().end();
1070 E->second.Destroy();
1072 ShadowMaps.pop_back();
1077 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1086 if (isa<ObjCIvarDecl>(ND))
1095 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1097 if (isa<TypeDecl>(ND))
1102 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1103 if (!
ID->getDefinition())
1111 if (isa<ObjCIvarDecl>(ND))
1118 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1119 if (!IsOrdinaryNonTypeName(ND))
1123 if (VD->getType()->isIntegralOrEnumerationType())
1131 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1139 !isa<ValueDecl>(ND) && !isa<FunctionTemplateDecl>(ND) &&
1140 !isa<ObjCPropertyDecl>(ND);
1145 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1148 ND = ClassTemplate->getTemplatedDecl();
1154 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1155 return isa<EnumDecl>(ND);
1159 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1162 ND = ClassTemplate->getTemplatedDecl();
1165 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1174 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1177 ND = ClassTemplate->getTemplatedDecl();
1179 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1186 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1187 return isa<NamespaceDecl>(ND);
1192 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1197 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1199 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1205 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1207 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1208 isa<ObjCPropertyDecl>(ND);
1214 case Type::ObjCObject:
1215 case Type::ObjCInterface:
1216 case Type::ObjCObjectPointer:
1220 switch (cast<BuiltinType>(T)->getKind()) {
1221 case BuiltinType::ObjCId:
1222 case BuiltinType::ObjCClass:
1223 case BuiltinType::ObjCSel:
1244 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1253 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const {
1254 if (IsObjCMessageReceiver(ND))
1264 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1265 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1266 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1279 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1285 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1286 return isa<ObjCIvarDecl>(ND);
1293 ResultBuilder &Results;
1295 std::vector<FixItHint> FixIts;
1298 CodeCompletionDeclConsumer(
1300 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1301 : Results(Results), CurContext(CurContext), FixIts(std::move(FixIts)) {}
1304 bool InBaseClass)
override {
1305 bool Accessible =
true;
1307 Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
1309 false, Accessible, FixIts);
1310 Results.AddResult(Result, CurContext, Hiding, InBaseClass);
1314 Results.addVisitedContext(Ctx);
1321 ResultBuilder &Results) {
1323 Results.AddResult(Result(
"short",
CCP_Type));
1324 Results.AddResult(Result(
"long",
CCP_Type));
1325 Results.AddResult(Result(
"signed",
CCP_Type));
1326 Results.AddResult(Result(
"unsigned",
CCP_Type));
1327 Results.AddResult(Result(
"void",
CCP_Type));
1328 Results.AddResult(Result(
"char",
CCP_Type));
1329 Results.AddResult(Result(
"int",
CCP_Type));
1330 Results.AddResult(Result(
"float",
CCP_Type));
1331 Results.AddResult(Result(
"double",
CCP_Type));
1332 Results.AddResult(Result(
"enum",
CCP_Type));
1333 Results.AddResult(Result(
"struct",
CCP_Type));
1334 Results.AddResult(Result(
"union",
CCP_Type));
1335 Results.AddResult(Result(
"const",
CCP_Type));
1336 Results.AddResult(Result(
"volatile",
CCP_Type));
1340 Results.AddResult(Result(
"_Complex",
CCP_Type));
1341 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1342 Results.AddResult(Result(
"_Bool",
CCP_Type));
1343 Results.AddResult(Result(
"restrict",
CCP_Type));
1347 Results.getCodeCompletionTUInfo());
1348 if (LangOpts.CPlusPlus) {
1350 Results.AddResult(Result(
"bool",
CCP_Type +
1352 Results.AddResult(Result(
"class",
CCP_Type));
1353 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1356 Builder.AddTypedTextChunk(
"typename");
1358 Builder.AddPlaceholderChunk(
"qualifier");
1359 Builder.AddTextChunk(
"::");
1360 Builder.AddPlaceholderChunk(
"name");
1361 Results.AddResult(Result(Builder.TakeString()));
1363 if (LangOpts.CPlusPlus11) {
1364 Results.AddResult(Result(
"auto",
CCP_Type));
1365 Results.AddResult(Result(
"char16_t",
CCP_Type));
1366 Results.AddResult(Result(
"char32_t",
CCP_Type));
1368 Builder.AddTypedTextChunk(
"decltype");
1370 Builder.AddPlaceholderChunk(
"expression");
1372 Results.AddResult(Result(Builder.TakeString()));
1375 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1378 if (LangOpts.GNUKeywords) {
1384 Builder.AddTypedTextChunk(
"typeof");
1386 Builder.AddPlaceholderChunk(
"expression");
1387 Results.AddResult(Result(Builder.TakeString()));
1389 Builder.AddTypedTextChunk(
"typeof");
1391 Builder.AddPlaceholderChunk(
"type");
1393 Results.AddResult(Result(Builder.TakeString()));
1397 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1398 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1399 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1404 ResultBuilder &Results) {
1409 Results.AddResult(Result(
"extern"));
1410 Results.AddResult(Result(
"static"));
1412 if (LangOpts.CPlusPlus11) {
1417 Builder.AddTypedTextChunk(
"alignas");
1419 Builder.AddPlaceholderChunk(
"expression");
1421 Results.AddResult(Result(Builder.TakeString()));
1423 Results.AddResult(Result(
"constexpr"));
1424 Results.AddResult(Result(
"thread_local"));
1430 ResultBuilder &Results) {
1435 if (LangOpts.CPlusPlus) {
1436 Results.AddResult(Result(
"explicit"));
1437 Results.AddResult(Result(
"friend"));
1438 Results.AddResult(Result(
"mutable"));
1439 Results.AddResult(Result(
"virtual"));
1447 if (LangOpts.CPlusPlus || LangOpts.C99)
1448 Results.AddResult(Result(
"inline"));
1467 ResultBuilder &Results,
1470 ResultBuilder &Results,
1473 ResultBuilder &Results,
1479 Results.getCodeCompletionTUInfo());
1480 Builder.AddTypedTextChunk(
"typedef");
1482 Builder.AddPlaceholderChunk(
"type");
1484 Builder.AddPlaceholderChunk(
"name");
1505 return LangOpts.CPlusPlus;
1512 return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
1515 llvm_unreachable(
"Invalid ParserCompletionContext!");
1544 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1545 return BT->getNameAsCString(Policy);
1548 if (
const TagType *TagT = dyn_cast<TagType>(T))
1549 if (
TagDecl *Tag = TagT->getDecl())
1550 if (!Tag->hasNameForLinkage()) {
1551 switch (Tag->getTagKind()) {
1552 case TTK_Struct:
return "struct <anonymous>";
1554 case TTK_Class:
return "class <anonymous>";
1555 case TTK_Union:
return "union <anonymous>";
1556 case TTK_Enum:
return "enum <anonymous>";
1580 Builder.AddTypedTextChunk(
"this");
1585 ResultBuilder &Results,
1587 if (!LangOpts.CPlusPlus11)
1603 ResultBuilder &Results) {
1611 if (Results.includeCodePatterns()) {
1613 Builder.AddTypedTextChunk(
"namespace");
1615 Builder.AddPlaceholderChunk(
"identifier");
1617 Builder.AddPlaceholderChunk(
"declarations");
1620 Results.AddResult(Result(Builder.TakeString()));
1624 Builder.AddTypedTextChunk(
"namespace");
1626 Builder.AddPlaceholderChunk(
"name");
1628 Builder.AddPlaceholderChunk(
"namespace");
1629 Results.AddResult(Result(Builder.TakeString()));
1632 Builder.AddTypedTextChunk(
"using");
1634 Builder.AddTextChunk(
"namespace");
1636 Builder.AddPlaceholderChunk(
"identifier");
1637 Results.AddResult(Result(Builder.TakeString()));
1640 Builder.AddTypedTextChunk(
"asm");
1642 Builder.AddPlaceholderChunk(
"string-literal");
1644 Results.AddResult(Result(Builder.TakeString()));
1646 if (Results.includeCodePatterns()) {
1648 Builder.AddTypedTextChunk(
"template");
1650 Builder.AddPlaceholderChunk(
"declaration");
1651 Results.AddResult(Result(Builder.TakeString()));
1664 Builder.AddTypedTextChunk(
"using");
1666 Builder.AddPlaceholderChunk(
"qualifier");
1667 Builder.AddTextChunk(
"::");
1668 Builder.AddPlaceholderChunk(
"name");
1669 Results.AddResult(Result(Builder.TakeString()));
1673 Builder.AddTypedTextChunk(
"using");
1675 Builder.AddTextChunk(
"typename");
1677 Builder.AddPlaceholderChunk(
"qualifier");
1678 Builder.AddTextChunk(
"::");
1679 Builder.AddPlaceholderChunk(
"name");
1680 Results.AddResult(Result(Builder.TakeString()));
1688 bool IsNotInheritanceScope =
1691 Builder.AddTypedTextChunk(
"public");
1692 if (IsNotInheritanceScope && Results.includeCodePatterns())
1694 Results.AddResult(Result(Builder.TakeString()));
1697 Builder.AddTypedTextChunk(
"protected");
1698 if (IsNotInheritanceScope && Results.includeCodePatterns())
1700 Results.AddResult(Result(Builder.TakeString()));
1703 Builder.AddTypedTextChunk(
"private");
1704 if (IsNotInheritanceScope && Results.includeCodePatterns())
1706 Results.AddResult(Result(Builder.TakeString()));
1713 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1715 Builder.AddTypedTextChunk(
"template");
1717 Builder.AddPlaceholderChunk(
"parameters");
1719 Results.AddResult(Result(Builder.TakeString()));
1746 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1748 Builder.AddTypedTextChunk(
"try");
1750 Builder.AddPlaceholderChunk(
"statements");
1753 Builder.AddTextChunk(
"catch");
1755 Builder.AddPlaceholderChunk(
"declaration");
1758 Builder.AddPlaceholderChunk(
"statements");
1761 Results.AddResult(Result(Builder.TakeString()));
1766 if (Results.includeCodePatterns()) {
1768 Builder.AddTypedTextChunk(
"if");
1771 Builder.AddPlaceholderChunk(
"condition");
1773 Builder.AddPlaceholderChunk(
"expression");
1776 Builder.AddPlaceholderChunk(
"statements");
1779 Results.AddResult(Result(Builder.TakeString()));
1782 Builder.AddTypedTextChunk(
"switch");
1785 Builder.AddPlaceholderChunk(
"condition");
1787 Builder.AddPlaceholderChunk(
"expression");
1792 Results.AddResult(Result(Builder.TakeString()));
1798 Builder.AddTypedTextChunk(
"case");
1800 Builder.AddPlaceholderChunk(
"expression");
1802 Results.AddResult(Result(Builder.TakeString()));
1805 Builder.AddTypedTextChunk(
"default");
1807 Results.AddResult(Result(Builder.TakeString()));
1810 if (Results.includeCodePatterns()) {
1812 Builder.AddTypedTextChunk(
"while");
1815 Builder.AddPlaceholderChunk(
"condition");
1817 Builder.AddPlaceholderChunk(
"expression");
1820 Builder.AddPlaceholderChunk(
"statements");
1823 Results.AddResult(Result(Builder.TakeString()));
1826 Builder.AddTypedTextChunk(
"do");
1828 Builder.AddPlaceholderChunk(
"statements");
1831 Builder.AddTextChunk(
"while");
1833 Builder.AddPlaceholderChunk(
"expression");
1835 Results.AddResult(Result(Builder.TakeString()));
1838 Builder.AddTypedTextChunk(
"for");
1841 Builder.AddPlaceholderChunk(
"init-statement");
1843 Builder.AddPlaceholderChunk(
"init-expression");
1845 Builder.AddPlaceholderChunk(
"condition");
1847 Builder.AddPlaceholderChunk(
"inc-expression");
1851 Builder.AddPlaceholderChunk(
"statements");
1854 Results.AddResult(Result(Builder.TakeString()));
1859 Builder.AddTypedTextChunk(
"continue");
1860 Results.AddResult(Result(Builder.TakeString()));
1865 Builder.AddTypedTextChunk(
"break");
1866 Results.AddResult(Result(Builder.TakeString()));
1871 bool isVoid =
false;
1873 isVoid = Function->getReturnType()->isVoidType();
1875 = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1876 isVoid = Method->getReturnType()->isVoidType();
1880 Builder.AddTypedTextChunk(
"return");
1883 Builder.AddPlaceholderChunk(
"expression");
1885 Results.AddResult(Result(Builder.TakeString()));
1888 Builder.AddTypedTextChunk(
"goto");
1890 Builder.AddPlaceholderChunk(
"label");
1891 Results.AddResult(Result(Builder.TakeString()));
1894 Builder.AddTypedTextChunk(
"using");
1896 Builder.AddTextChunk(
"namespace");
1898 Builder.AddPlaceholderChunk(
"identifier");
1899 Results.AddResult(Result(Builder.TakeString()));
1916 Builder.AddTypedTextChunk(
"__bridge");
1918 Builder.AddPlaceholderChunk(
"type");
1920 Builder.AddPlaceholderChunk(
"expression");
1921 Results.AddResult(Result(Builder.TakeString()));
1924 Builder.AddTypedTextChunk(
"__bridge_transfer");
1926 Builder.AddPlaceholderChunk(
"Objective-C type");
1928 Builder.AddPlaceholderChunk(
"expression");
1929 Results.AddResult(Result(Builder.TakeString()));
1932 Builder.AddTypedTextChunk(
"__bridge_retained");
1934 Builder.AddPlaceholderChunk(
"CF type");
1936 Builder.AddPlaceholderChunk(
"expression");
1937 Results.AddResult(Result(Builder.TakeString()));
1948 Builder.AddResultTypeChunk(
"bool");
1949 Builder.AddTypedTextChunk(
"true");
1950 Results.AddResult(Result(Builder.TakeString()));
1953 Builder.AddResultTypeChunk(
"bool");
1954 Builder.AddTypedTextChunk(
"false");
1955 Results.AddResult(Result(Builder.TakeString()));
1959 Builder.AddTypedTextChunk(
"dynamic_cast");
1961 Builder.AddPlaceholderChunk(
"type");
1964 Builder.AddPlaceholderChunk(
"expression");
1966 Results.AddResult(Result(Builder.TakeString()));
1970 Builder.AddTypedTextChunk(
"static_cast");
1972 Builder.AddPlaceholderChunk(
"type");
1975 Builder.AddPlaceholderChunk(
"expression");
1977 Results.AddResult(Result(Builder.TakeString()));
1980 Builder.AddTypedTextChunk(
"reinterpret_cast");
1982 Builder.AddPlaceholderChunk(
"type");
1985 Builder.AddPlaceholderChunk(
"expression");
1987 Results.AddResult(Result(Builder.TakeString()));
1990 Builder.AddTypedTextChunk(
"const_cast");
1992 Builder.AddPlaceholderChunk(
"type");
1995 Builder.AddPlaceholderChunk(
"expression");
1997 Results.AddResult(Result(Builder.TakeString()));
2001 Builder.AddResultTypeChunk(
"std::type_info");
2002 Builder.AddTypedTextChunk(
"typeid");
2004 Builder.AddPlaceholderChunk(
"expression-or-type");
2006 Results.AddResult(Result(Builder.TakeString()));
2010 Builder.AddTypedTextChunk(
"new");
2012 Builder.AddPlaceholderChunk(
"type");
2014 Builder.AddPlaceholderChunk(
"expressions");
2016 Results.AddResult(Result(Builder.TakeString()));
2019 Builder.AddTypedTextChunk(
"new");
2021 Builder.AddPlaceholderChunk(
"type");
2023 Builder.AddPlaceholderChunk(
"size");
2026 Builder.AddPlaceholderChunk(
"expressions");
2028 Results.AddResult(Result(Builder.TakeString()));
2031 Builder.AddResultTypeChunk(
"void");
2032 Builder.AddTypedTextChunk(
"delete");
2034 Builder.AddPlaceholderChunk(
"expression");
2035 Results.AddResult(Result(Builder.TakeString()));
2038 Builder.AddResultTypeChunk(
"void");
2039 Builder.AddTypedTextChunk(
"delete");
2044 Builder.AddPlaceholderChunk(
"expression");
2045 Results.AddResult(Result(Builder.TakeString()));
2049 Builder.AddResultTypeChunk(
"void");
2050 Builder.AddTypedTextChunk(
"throw");
2052 Builder.AddPlaceholderChunk(
"expression");
2053 Results.AddResult(Result(Builder.TakeString()));
2060 Builder.AddResultTypeChunk(
"std::nullptr_t");
2061 Builder.AddTypedTextChunk(
"nullptr");
2062 Results.AddResult(Result(Builder.TakeString()));
2065 Builder.AddResultTypeChunk(
"size_t");
2066 Builder.AddTypedTextChunk(
"alignof");
2068 Builder.AddPlaceholderChunk(
"type");
2070 Results.AddResult(Result(Builder.TakeString()));
2073 Builder.AddResultTypeChunk(
"bool");
2074 Builder.AddTypedTextChunk(
"noexcept");
2076 Builder.AddPlaceholderChunk(
"expression");
2078 Results.AddResult(Result(Builder.TakeString()));
2081 Builder.AddResultTypeChunk(
"size_t");
2082 Builder.AddTypedTextChunk(
"sizeof...");
2084 Builder.AddPlaceholderChunk(
"parameter-pack");
2086 Results.AddResult(Result(Builder.TakeString()));
2095 if (
ID->getSuperClass()) {
2096 std::string SuperType;
2097 SuperType =
ID->getSuperClass()->getNameAsString();
2098 if (Method->isInstanceMethod())
2101 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2102 Builder.AddTypedTextChunk(
"super");
2103 Results.AddResult(Result(Builder.TakeString()));
2112 Builder.AddResultTypeChunk(
"size_t");
2114 Builder.AddTypedTextChunk(
"alignof");
2116 Builder.AddTypedTextChunk(
"_Alignof");
2118 Builder.AddPlaceholderChunk(
"type");
2120 Results.AddResult(Result(Builder.TakeString()));
2124 Builder.AddResultTypeChunk(
"size_t");
2125 Builder.AddTypedTextChunk(
"sizeof");
2127 Builder.AddPlaceholderChunk(
"expression-or-type");
2129 Results.AddResult(Result(Builder.TakeString()));
2142 Results.AddResult(Result(
"operator"));
2163 T = Function->getReturnType();
2164 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2166 T = Method->getSendResultType(BaseType);
2168 T = Method->getReturnType();
2169 }
else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2170 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2172 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2174 }
else if (
const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2176 T = Ivar->getUsageType(BaseType);
2178 T = Ivar->getType();
2180 T =
Value->getType();
2183 T =
Property->getUsageType(BaseType);
2198 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2199 if (Sentinel->getSentinel() == 0) {
2219 Result +=
"bycopy ";
2223 Result +=
"oneway ";
2226 switch (*nullability) {
2228 Result +=
"nonnull ";
2232 Result +=
"nullable ";
2236 Result +=
"null_unspecified ";
2253 bool SuppressBlock =
false) {
2259 if (!SuppressBlock) {
2262 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2275 TL = AttrTL.getModifiedLoc();
2294 bool SuppressBlockName =
false,
2295 bool SuppressBlock =
false,
2296 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2300 bool SuppressName =
false,
2301 bool SuppressBlock =
false,
2302 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2303 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2310 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2317 if (ObjCMethodParam) {
2337 if (!Block && ObjCMethodParam &&
2338 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2339 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2340 ->findPropertyDecl(
false))
2354 if (ObjCMethodParam) {
2359 Result =
"(" + Quals +
" " + Result +
")";
2360 if (Result.back() !=
')')
2374 false, SuppressBlock,
2390 bool SuppressBlockName,
bool SuppressBlock,
2391 Optional<ArrayRef<QualType>> ObjCSubsts) {
2398 if (!ResultType->
isVoidType() || SuppressBlock)
2410 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2423 if (SuppressBlock) {
2425 Result = Result +
" (^";
2432 Result =
'^' + Result;
2447 bool Invalid = CharSrcRange.
isInvalid();
2454 if (srcText.empty() || srcText ==
"=") {
2459 std::string DefValue(srcText.str());
2462 if (DefValue.at(0) !=
'=') {
2465 return " = " + DefValue;
2467 return " " + DefValue;
2476 bool InOptional =
false) {
2477 bool FirstParameter =
true;
2487 if (!FirstParameter)
2495 FirstParameter =
false;
2507 PlaceholderStr +=
", ...";
2516 if (Proto->isVariadic()) {
2517 if (Proto->getNumParams() == 0)
2529 unsigned MaxParameters = 0,
2531 bool InDefaultArg =
false) {
2532 bool FirstParameter =
true;
2541 PEnd = Params->begin() + MaxParameters;
2544 bool HasDefaultArg =
false;
2545 std::string PlaceholderStr;
2547 if (TTP->wasDeclaredWithTypename())
2548 PlaceholderStr =
"typename";
2550 PlaceholderStr =
"class";
2552 if (TTP->getIdentifier()) {
2553 PlaceholderStr +=
' ';
2557 HasDefaultArg = TTP->hasDefaultArgument();
2559 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2560 if (NTTP->getIdentifier())
2561 PlaceholderStr = NTTP->getIdentifier()->getName();
2562 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2563 HasDefaultArg = NTTP->hasDefaultArgument();
2565 assert(isa<TemplateTemplateParmDecl>(*
P));
2570 PlaceholderStr =
"template<...> class";
2572 PlaceholderStr +=
' ';
2579 if (HasDefaultArg && !InDefaultArg) {
2584 if (!FirstParameter)
2587 P - Params->begin(),
true);
2592 InDefaultArg =
false;
2595 FirstParameter =
false;
2610 bool QualifierIsInformative,
2616 std::string PrintedNNS;
2618 llvm::raw_string_ostream OS(PrintedNNS);
2619 Qualifier->
print(OS, Policy);
2621 if (QualifierIsInformative)
2654 std::string QualsStr;
2656 QualsStr +=
" const";
2658 QualsStr +=
" volatile";
2660 QualsStr +=
" restrict";
2674 const char *OperatorName =
nullptr;
2677 case OO_Conditional:
2679 OperatorName =
"operator";
2682 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 2683 case OO_##Name: OperatorName = "operator" Spelling; break; 2684 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) 2685 #include "clang/Basic/OperatorKinds.def" 2687 case OO_New: OperatorName =
"operator new";
break;
2688 case OO_Delete: OperatorName =
"operator delete";
break;
2689 case OO_Array_New: OperatorName =
"operator new[]";
break;
2690 case OO_Array_Delete: OperatorName =
"operator delete[]";
break;
2691 case OO_Call: OperatorName =
"operator()";
break;
2692 case OO_Subscript: OperatorName =
"operator[]";
break;
2717 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2720 Record = InjectedTy->getDecl();
2743 bool IncludeBriefComments) {
2744 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2745 CCTUInfo, IncludeBriefComments);
2751 assert(
Kind == RK_Macro);
2806 bool IncludeBriefComments) {
2807 if (
Kind == RK_Macro)
2808 return CreateCodeCompletionStringForMacro(PP, Allocator, CCTUInfo);
2813 if (
Kind == RK_Pattern) {
2814 Pattern->Priority = Priority;
2815 Pattern->Availability = Availability;
2830 if (
Kind == RK_Keyword) {
2834 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2838 if (IncludeBriefComments) {
2845 if (StartsNestedNameSpecifier) {
2857 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
2876 llvm::SmallBitVector Deduced;
2878 unsigned LastDeducibleArgument;
2879 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
2880 --LastDeducibleArgument) {
2881 if (!Deduced[LastDeducibleArgument - 1]) {
2885 bool HasDefaultArg =
false;
2886 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
2887 LastDeducibleArgument - 1);
2889 HasDefaultArg = TTP->hasDefaultArgument();
2891 = dyn_cast<NonTypeTemplateParmDecl>(Param))
2892 HasDefaultArg = NTTP->hasDefaultArgument();
2894 assert(isa<TemplateTemplateParmDecl>(Param));
2896 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
2904 if (LastDeducibleArgument) {
2910 LastDeducibleArgument);
2922 if (
const TemplateDecl *Template = dyn_cast<TemplateDecl>(ND)) {
2933 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2934 Selector Sel = Method->getSelector();
2943 if (StartParameter == 0)
2950 if (Method->param_size() == 1)
2955 PEnd = Method->param_end();
2956 P != PEnd; (void)++
P, ++Idx) {
2958 std::string Keyword;
2959 if (Idx > StartParameter)
2962 Keyword += II->getName();
2964 if (Idx < StartParameter || AllParametersAreInformative)
2971 if (Idx < StartParameter)
2975 QualType ParamType = (*P)->getType();
2992 if (DeclaringEntity || AllParametersAreInformative)
2993 Arg += II->getName();
2996 if (Method->isVariadic() && (
P + 1) == PEnd)
2999 if (DeclaringEntity)
3001 else if (AllParametersAreInformative)
3007 if (Method->isVariadic()) {
3008 if (Method->param_size() == 0) {
3009 if (DeclaringEntity)
3011 else if (AllParametersAreInformative)
3076 unsigned ArgIndex) {
3080 if (ArgIndex < FDecl->getNumParams())
3092 unsigned CurrentArg,
3094 bool InOptional =
false) {
3095 bool FirstParameter =
true;
3096 unsigned NumParams = Function ? Function->
getNumParams()
3099 for (
unsigned P = Start;
P != NumParams; ++
P) {
3105 if (!FirstParameter)
3109 CurrentArg,
P,
true);
3115 FirstParameter =
false;
3122 std::string Placeholder;
3132 if (
P == CurrentArg)
3142 if (!FirstParameter)
3145 if (CurrentArg < NumParams)
3146 Opt.AddPlaceholderChunk(
"...");
3148 Opt.AddCurrentParameterChunk(
"...");
3156 unsigned CurrentArg,
Sema &S,
3159 bool IncludeBriefComments)
const {
3167 if (!FDecl && !Proto) {
3180 if (IncludeBriefComments) {
3198 return Result.TakeString();
3203 bool PreferredTypeIsPointer) {
3207 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3208 MacroName.equals(
"Nil")) {
3210 if (PreferredTypeIsPointer)
3214 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3215 MacroName.equals(
"true") || MacroName.equals(
"false"))
3218 else if (MacroName.equals(
"bool"))
3241 case Decl::ObjCMethod:
3263 case Decl::ClassTemplatePartialSpecialization:
3271 case Decl::UnresolvedUsingValue:
3272 case Decl::UnresolvedUsingTypename:
3275 case Decl::ObjCPropertyImpl:
3276 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3290 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3291 switch (TD->getTagKind()) {
3305 bool IncludeUndefined,
3306 bool TargetTypeIsPointer =
false) {
3309 Results.EnterNewScope();
3315 if (IncludeUndefined || MD) {
3317 if (MI->isUsedForHeaderGuard())
3320 Results.AddResult(Result(M->first,
3323 TargetTypeIsPointer)));
3327 Results.ExitScope();
3332 ResultBuilder &Results) {
3335 Results.EnterNewScope();
3337 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3338 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3339 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3341 Results.ExitScope();
3348 unsigned NumResults) {
3406 llvm_unreachable(
"Invalid ParserCompletionContext!");
3418 ResultBuilder &Results) {
3421 while (isa<BlockDecl>(CurContext))
3432 if (!
P->getDeclName())
3438 Results.getCodeCompletionTUInfo());
3446 Overridden->getDeclContext());
3449 llvm::raw_string_ostream OS(Str);
3450 NNS->
print(OS, Policy);
3451 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3453 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3456 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
3457 Overridden->getNameAsString()));
3459 bool FirstParam =
true;
3466 Builder.AddPlaceholderChunk(
3467 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3475 Results.Ignore(Overridden);
3482 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3483 CodeCompleter->getCodeCompletionTUInfo(),
3485 Results.EnterNewScope();
3493 PP.getHeaderSearchInfo().collectAllModules(Modules);
3494 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
3495 Builder.AddTypedTextChunk(
3496 Builder.getAllocator().CopyString(Modules[I]->Name));
3497 Results.AddResult(Result(Builder.TakeString(),
3500 Modules[I]->isAvailable()
3504 }
else if (getLangOpts().Modules) {
3506 Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path,
3513 Sub != SubEnd; ++Sub) {
3515 Builder.AddTypedTextChunk(
3516 Builder.getAllocator().CopyString((*Sub)->Name));
3517 Results.AddResult(Result(Builder.TakeString(),
3520 (*Sub)->isAvailable()
3526 Results.ExitScope();
3528 Results.data(),Results.size());
3533 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3534 CodeCompleter->getCodeCompletionTUInfo(),
3536 Results.EnterNewScope();
3541 switch (CompletionContext) {
3544 case PCC_ObjCInterface:
3545 case PCC_ObjCImplementation:
3546 case PCC_ObjCInstanceVariableList:
3548 case PCC_MemberTemplate:
3550 case PCC_LocalDeclarationSpecifiers:
3551 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3555 case PCC_ParenthesizedExpression:
3556 case PCC_Expression:
3560 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3562 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3568 case PCC_RecoveryInFunction:
3575 if (
CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
3576 if (CurMethod->isInstance())
3577 Results.setObjectTypeQualifiers(
3580 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3582 CodeCompleter->includeGlobals(),
3583 CodeCompleter->loadExternal());
3586 Results.ExitScope();
3588 switch (CompletionContext) {
3589 case PCC_ParenthesizedExpression:
3590 case PCC_Expression:
3592 case PCC_RecoveryInFunction:
3599 case PCC_ObjCInterface:
3600 case PCC_ObjCImplementation:
3601 case PCC_ObjCInstanceVariableList:
3603 case PCC_MemberTemplate:
3607 case PCC_LocalDeclarationSpecifiers:
3611 if (CodeCompleter->includeMacros())
3615 Results.data(),Results.size());
3621 bool AtArgumentExpression,
3623 ResultBuilder &Results);
3626 bool AllowNonIdentifiers,
3627 bool AllowNestedNameSpecifiers) {
3629 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3630 CodeCompleter->getCodeCompletionTUInfo(),
3631 AllowNestedNameSpecifiers
3634 Results.EnterNewScope();
3637 Results.AddResult(Result(
"const"));
3638 Results.AddResult(Result(
"volatile"));
3639 if (getLangOpts().
C99)
3640 Results.AddResult(Result(
"restrict"));
3646 Results.AddResult(
"final");
3648 if (AllowNonIdentifiers) {
3649 Results.AddResult(Result(
"operator"));
3653 if (AllowNestedNameSpecifiers) {
3654 Results.allowNestedNameSpecifiers();
3655 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3656 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3658 CodeCompleter->includeGlobals(),
3659 CodeCompleter->loadExternal());
3660 Results.setFilter(
nullptr);
3663 Results.ExitScope();
3669 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3689 Results.getCompletionContext(),
3690 Results.data(), Results.size());
3695 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3696 ObjCCollection(
false) { }
3708 ResultBuilder Results(
3709 *
this, CodeCompleter->getAllocator(),
3710 CodeCompleter->getCodeCompletionTUInfo(),
3714 Results.setFilter(&ResultBuilder::IsObjCCollection);
3716 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3718 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3720 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3726 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
3729 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3731 CodeCompleter->includeGlobals(),
3732 CodeCompleter->loadExternal());
3734 Results.EnterNewScope();
3736 Results.ExitScope();
3738 bool PreferredTypeIsPointer =
false;
3749 if (CodeCompleter->includeMacros())
3752 Results.data(), Results.size());
3757 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3758 else if (getLangOpts().ObjC1)
3759 CodeCompleteObjCInstanceMessage(S, E.
get(), None,
false);
3769 if (Interface->hasDefinition())
3770 return Interface->getDefinition();
3776 if (Protocol->hasDefinition())
3777 return Protocol->getDefinition();
3801 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
3806 std::string PlaceholderStr =
3809 if (I == N - 1 && BlockProtoLoc &&
3811 PlaceholderStr +=
", ...";
3824 bool AllowCategories,
bool AllowNullaryMethods,
DeclContext *CurContext,
3825 AddedPropertiesSet &AddedProperties, ResultBuilder &Results,
3826 bool IsBaseExprStatement =
false,
bool IsClassProperty =
false) {
3834 if (!AddedProperties.insert(
P->getIdentifier()).second)
3839 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
3840 !IsBaseExprStatement) {
3841 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3853 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3861 Results.getCodeCompletionTUInfo());
3864 BlockLoc, BlockProtoLoc);
3865 Results.MaybeAddResult(
3866 Result(Builder.TakeString(),
P, Results.getBasePriority(
P)),
3871 if (!
P->isReadOnly()) {
3873 Results.getCodeCompletionTUInfo());
3877 Builder.AddTypedTextChunk(
3878 Results.getAllocator().CopyString(
P->getName()));
3883 BlockProtoLoc,
true);
3885 Builder.AddPlaceholderChunk(
3886 Builder.getAllocator().CopyString(PlaceholderStr));
3893 Results.MaybeAddResult(
3894 Result(Builder.TakeString(),
P,
3895 Results.getBasePriority(
P) +
3903 if (IsClassProperty) {
3912 if (AllowNullaryMethods) {
3917 IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
3920 if (!AddedProperties.insert(Name).second)
3923 Results.getCodeCompletionTUInfo());
3925 Builder.AddTypedTextChunk(
3926 Results.getAllocator().CopyString(Name->
getName()));
3927 Results.MaybeAddResult(
3928 Result(Builder.TakeString(), M,
3933 if (IsClassProperty) {
3934 for (
const auto *M : Container->
methods()) {
3938 if (!M->getSelector().isUnarySelector() ||
3939 M->getReturnType()->isVoidType() || M->isInstanceMethod())
3944 for (
auto *M : Container->
methods()) {
3945 if (M->getSelector().isUnarySelector())
3953 for (
auto *
P : Protocol->protocols())
3955 CurContext, AddedProperties, Results,
3956 IsBaseExprStatement, IsClassProperty);
3958 if (AllowCategories) {
3960 for (
auto *Cat : IFace->known_categories())
3962 CurContext, AddedProperties, Results,
3963 IsBaseExprStatement, IsClassProperty);
3967 for (
auto *I : IFace->all_referenced_protocols())
3969 CurContext, AddedProperties, Results,
3970 IsBaseExprStatement, IsClassProperty);
3973 if (IFace->getSuperClass())
3975 AllowNullaryMethods, CurContext, AddedProperties,
3976 Results, IsBaseExprStatement, IsClassProperty);
3978 = dyn_cast<ObjCCategoryDecl>(Container)) {
3982 CurContext, AddedProperties, Results,
3983 IsBaseExprStatement, IsClassProperty);
3988 ResultBuilder &Results,
Scope *S,
3991 Optional<FixItHint> AccessOpFixIt) {
3997 Results.allowNestedNameSpecifiers();
3998 std::vector<FixItHint> FixIts;
4000 FixIts.emplace_back(AccessOpFixIt.getValue());
4001 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext, std::move(FixIts));
4008 if (!Results.empty()) {
4014 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
4016 IsDependent = Ctx->isDependentContext();
4030 bool IsBaseExprStatement) {
4031 if (!Base || !CodeCompleter)
4034 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4037 QualType ConvertedBaseType = ConvertedBase.
get()->getType();
4058 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4059 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4060 &ResultBuilder::IsMember);
4066 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4069 Base = ConvertedBase.
get();
4085 std::move(AccessOpFixIt));
4086 }
else if (
const auto *TST =
4089 if (
const auto *TD =
4093 std::move(AccessOpFixIt));
4096 if (
auto *RD = ICNT->getDecl())
4098 std::move(AccessOpFixIt));
4101 AddedPropertiesSet AddedProperties;
4106 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4109 AddedProperties, Results, IsBaseExprStatement);
4115 CurContext, AddedProperties, Results,
4116 IsBaseExprStatement);
4123 Class = ObjCPtr->getInterfaceDecl();
4129 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4130 Results.setFilter(&ResultBuilder::IsObjCIvar);
4132 Class, LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
4133 false, CodeCompleter->loadExternal());
4141 Results.EnterNewScope();
4143 bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
4144 if (CodeCompleter->includeFixIts()) {
4147 CompletionSucceded |= DoCompletion(
4148 OtherOpBase, !IsArrow,
4152 Results.ExitScope();
4154 if (!CompletionSucceded)
4159 Results.data(), Results.size());
4165 bool IsBaseExprStatement) {
4172 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4173 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4174 &ResultBuilder::IsMember);
4175 Results.EnterNewScope();
4176 AddedPropertiesSet AddedProperties;
4178 true, CurContext, AddedProperties,
4179 Results, IsBaseExprStatement,
4181 Results.ExitScope();
4183 Results.data(), Results.size());
4190 ResultBuilder::LookupFilter Filter =
nullptr;
4195 Filter = &ResultBuilder::IsEnum;
4200 Filter = &ResultBuilder::IsUnion;
4207 Filter = &ResultBuilder::IsClassOrStruct;
4212 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4215 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4216 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4217 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4220 Results.setFilter(Filter);
4222 CodeCompleter->includeGlobals(),
4223 CodeCompleter->loadExternal());
4225 if (CodeCompleter->includeGlobals()) {
4227 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4229 CodeCompleter->includeGlobals(),
4230 CodeCompleter->loadExternal());
4234 Results.data(),Results.size());
4240 Results.AddResult(
"const");
4242 Results.AddResult(
"volatile");
4244 Results.AddResult(
"restrict");
4246 Results.AddResult(
"_Atomic");
4248 Results.AddResult(
"__unaligned");
4252 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4253 CodeCompleter->getCodeCompletionTUInfo(),
4255 Results.EnterNewScope();
4257 Results.ExitScope();
4259 Results.getCompletionContext(),
4260 Results.data(), Results.size());
4265 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4266 CodeCompleter->getCodeCompletionTUInfo(),
4268 Results.EnterNewScope();
4270 if (LangOpts.CPlusPlus11) {
4271 Results.AddResult(
"noexcept");
4275 Results.AddResult(
"final");
4277 Results.AddResult(
"override");
4280 Results.ExitScope();
4282 Results.data(), Results.size());
4286 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4290 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4293 SwitchStmt *Switch = getCurFunction()->SwitchStack.back().getPointer();
4298 CodeCompleteExpression(S, Data);
4312 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
4321 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseVal))
4323 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
4330 EnumeratorsSeen.insert(Enumerator);
4343 Qualifier = DRE->getQualifier();
4347 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
4355 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4356 CodeCompleter->getCodeCompletionTUInfo(),
4358 Results.EnterNewScope();
4360 if (EnumeratorsSeen.count(E))
4364 Results.AddResult(R, CurContext,
nullptr,
false);
4366 Results.ExitScope();
4368 if (CodeCompleter->includeMacros()) {
4372 Results.data(), Results.size());
4376 if (Args.size() && !Args.data())
4379 for (
unsigned I = 0; I != Args.size(); ++I)
4392 if (!CandidateSet.
empty()) {
4395 CandidateSet.
begin(), CandidateSet.
end(),
4402 for (
auto &Candidate : CandidateSet) {
4403 if (Candidate.Function && Candidate.Function->isDeleted())
4405 if (Candidate.Viable)
4414 ArrayRef<ResultCandidate> Candidates,
4421 for (
auto &Candidate : Candidates) {
4422 if (
auto FType = Candidate.getFunctionType())
4423 if (
auto Proto = dyn_cast<FunctionProtoType>(FType))
4424 if (N < Proto->getNumParams()) {
4426 ParamType = Proto->getParamType(N);
4429 Proto->getParamType(N).getNonReferenceType()))
4440 unsigned CurrentArg,
4441 bool CompleteExpressionWithCurrentArg =
true) {
4443 if (CompleteExpressionWithCurrentArg)
4444 ParamType =
getParamType(SemaRef, Candidates, CurrentArg);
4451 if (!Candidates.empty())
4471 CodeCompleteOrdinaryName(S, PCC_Expression);
4482 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4483 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4485 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4487 if (UME->hasExplicitTemplateArgs()) {
4488 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4489 TemplateArgs = &TemplateArgsBuffer;
4494 1, UME->isImplicitAccess() ? nullptr : UME->getBase());
4495 ArgExprs.append(Args.begin(), Args.end());
4497 Decls.
append(UME->decls_begin(), UME->decls_end());
4498 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
4499 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4502 FirstArgumentIsBase);
4505 if (
auto MCE = dyn_cast<MemberExpr>(NakedFn))
4507 else if (
auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
4508 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4510 if (!getLangOpts().CPlusPlus ||
4523 if (isCompleteType(Loc, NakedFn->
getType())) {
4526 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4527 LookupQualifiedName(R, DC);
4530 ArgExprs.append(Args.begin(), Args.end());
4544 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4547 Results.push_back(ResultCandidate(FP));
4556 !CandidateSet.
empty());
4568 CodeCompleteExpression(S, Type);
4577 for (
auto C : LookupConstructors(RD)) {
4578 if (
auto FD = dyn_cast<FunctionDecl>(C)) {
4583 }
else if (
auto FTD = dyn_cast<FunctionTemplateDecl>(C)) {
4584 AddTemplateOverloadCandidate(FTD,
4599 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4601 CodeCompleteOrdinaryName(S, PCC_Expression);
4605 CodeCompleteExpression(S, VD->
getType());
4610 if (isa<BlockDecl>(CurContext)) {
4612 ResultType = BSI->ReturnType;
4613 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
4614 ResultType = Function->getReturnType();
4615 else if (
ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4616 ResultType = Method->getReturnType();
4619 CodeCompleteOrdinaryName(S, PCC_Expression);
4621 CodeCompleteExpression(S, ResultType);
4625 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4626 CodeCompleter->getCodeCompletionTUInfo(),
4628 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4629 Results.EnterNewScope();
4631 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4633 CodeCompleter->includeGlobals(),
4634 CodeCompleter->loadExternal());
4640 Results.getCodeCompletionTUInfo());
4641 Builder.AddTypedTextChunk(
"else");
4642 if (Results.includeCodePatterns()) {
4646 Builder.AddPlaceholderChunk(
"statements");
4650 Results.AddResult(Builder.TakeString());
4653 Builder.AddTypedTextChunk(
"else");
4655 Builder.AddTextChunk(
"if");
4659 Builder.AddPlaceholderChunk(
"condition");
4661 Builder.AddPlaceholderChunk(
"expression");
4663 if (Results.includeCodePatterns()) {
4667 Builder.AddPlaceholderChunk(
"statements");
4671 Results.AddResult(Builder.TakeString());
4673 Results.ExitScope();
4678 if (CodeCompleter->includeMacros())
4682 Results.data(),Results.size());
4687 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType());
4689 CodeCompleteOrdinaryName(S, PCC_Expression);
4693 bool EnteringContext) {
4694 if (SS.
isEmpty() || !CodeCompleter)
4715 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4718 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4719 CodeCompleter->getCodeCompletionTUInfo(),
4721 Results.EnterNewScope();
4727 Results.AddResult(
"template");
4734 if (!EnteringContext)
4736 Results.ExitScope();
4738 if (CodeCompleter->includeNamespaceLevelDecls() ||
4740 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4744 CodeCompleter->loadExternal());
4747 auto CC = Results.getCompletionContext();
4748 CC.setCXXScopeSpecifier(SS);
4758 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4759 CodeCompleter->getCodeCompletionTUInfo(),
4761 &ResultBuilder::IsNestedNameSpecifier);
4762 Results.EnterNewScope();
4770 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4772 CodeCompleter->includeGlobals(),
4773 CodeCompleter->loadExternal());
4774 Results.ExitScope();
4777 Results.data(), Results.size());
4786 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4787 CodeCompleter->getCodeCompletionTUInfo(),
4789 &ResultBuilder::IsNamespaceOrAlias);
4790 Results.EnterNewScope();
4791 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4793 CodeCompleter->includeGlobals(),
4794 CodeCompleter->loadExternal());
4795 Results.ExitScope();
4797 Results.data(), Results.size());
4808 bool SuppressedGlobalResults
4809 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
4811 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4812 CodeCompleter->getCodeCompletionTUInfo(),
4813 SuppressedGlobalResults
4816 &ResultBuilder::IsNamespace);
4818 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
4823 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
4827 OrigToLatest[NS->getOriginalNamespace()] = *NS;
4831 Results.EnterNewScope();
4832 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
4833 NS = OrigToLatest.begin(),
4834 NSEnd = OrigToLatest.end();
4837 NS->second, Results.getBasePriority(NS->second),
4839 CurContext,
nullptr,
false);
4840 Results.ExitScope();
4844 Results.getCompletionContext(),
4845 Results.data(),Results.size());
4853 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4854 CodeCompleter->getCodeCompletionTUInfo(),
4856 &ResultBuilder::IsNamespaceOrAlias);
4857 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4859 CodeCompleter->includeGlobals(),
4860 CodeCompleter->loadExternal());
4862 Results.getCompletionContext(),
4863 Results.data(),Results.size());
4871 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4872 CodeCompleter->getCodeCompletionTUInfo(),
4874 &ResultBuilder::IsType);
4875 Results.EnterNewScope();
4878 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 4879 if (std::strcmp(Spelling, "?")) \ 4880 Results.AddResult(Result(Spelling)); 4881 #include "clang/Basic/OperatorKinds.def" 4884 Results.allowNestedNameSpecifiers();
4885 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4887 CodeCompleter->includeGlobals(),
4888 CodeCompleter->loadExternal());
4892 Results.ExitScope();
4895 Results.data(), Results.size());
4904 AdjustDeclIfTemplate(ConstructorD);
4910 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4911 CodeCompleter->getCodeCompletionTUInfo(),
4913 Results.EnterNewScope();
4916 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
4917 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
4918 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
4919 if (Initializers[I]->isBaseInitializer())
4920 InitializedBases.insert(
4923 InitializedFields.insert(cast<FieldDecl>(
4924 Initializers[I]->getAnyMember()));
4929 Results.getCodeCompletionTUInfo());
4931 bool SawLastInitializer = Initializers.empty();
4933 for (
const auto &
Base : ClassDecl->
bases()) {
4937 = !Initializers.empty() &&
4938 Initializers.back()->isBaseInitializer() &&
4940 QualType(Initializers.back()->getBaseClass(), 0));
4944 Builder.AddTypedTextChunk(
4945 Results.getAllocator().CopyString(
4946 Base.getType().getAsString(Policy)));
4948 Builder.AddPlaceholderChunk(
"args");
4953 SawLastInitializer =
false;
4957 for (
const auto &
Base : ClassDecl->
vbases()) {
4961 = !Initializers.empty() &&
4962 Initializers.back()->isBaseInitializer() &&
4964 QualType(Initializers.back()->getBaseClass(), 0));
4968 Builder.AddTypedTextChunk(
4969 Builder.getAllocator().CopyString(
4970 Base.getType().getAsString(Policy)));
4972 Builder.AddPlaceholderChunk(
"args");
4977 SawLastInitializer =
false;
4981 for (
auto *Field : ClassDecl->
fields()) {
4982 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
4985 = !Initializers.empty() &&
4986 Initializers.back()->isAnyMemberInitializer() &&
4987 Initializers.back()->getAnyMember() == Field;
4991 if (!Field->getDeclName())
4994 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
4995 Field->getIdentifier()->getName()));
4997 Builder.AddPlaceholderChunk(
"args");
5005 SawLastInitializer =
false;
5007 Results.ExitScope();
5010 Results.data(), Results.size());
5023 bool AfterAmpersand) {
5024 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5025 CodeCompleter->getCodeCompletionTUInfo(),
5027 Results.EnterNewScope();
5030 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
5031 bool IncludedThis =
false;
5032 for (
const auto &C : Intro.
Captures) {
5034 IncludedThis =
true;
5043 for (
const auto *D : S->
decls()) {
5044 const auto *Var = dyn_cast<
VarDecl>(D);
5046 !Var->hasLocalStorage() ||
5047 Var->hasAttr<BlocksAttr>())
5050 if (Known.insert(Var->getIdentifier()).second)
5052 CurContext,
nullptr,
false);
5060 Results.ExitScope();
5063 Results.data(), Results.size());
5068 #define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword) 5071 ResultBuilder &Results,
5078 Results.getCodeCompletionTUInfo());
5079 if (LangOpts.ObjC2) {
5083 Builder.AddPlaceholderChunk(
"property");
5084 Results.AddResult(Result(Builder.TakeString()));
5089 Builder.AddPlaceholderChunk(
"property");
5090 Results.AddResult(Result(Builder.TakeString()));
5095 ResultBuilder &Results,
5102 if (LangOpts.ObjC2) {
5117 Results.getCodeCompletionTUInfo());
5122 Builder.AddPlaceholderChunk(
"name");
5123 Results.AddResult(Result(Builder.TakeString()));
5125 if (Results.includeCodePatterns()) {
5131 Builder.AddPlaceholderChunk(
"class");
5132 Results.AddResult(Result(Builder.TakeString()));
5137 Builder.AddPlaceholderChunk(
"protocol");
5138 Results.AddResult(Result(Builder.TakeString()));
5143 Builder.AddPlaceholderChunk(
"class");
5144 Results.AddResult(Result(Builder.TakeString()));
5150 Builder.AddPlaceholderChunk(
"alias");
5152 Builder.AddPlaceholderChunk(
"class");
5153 Results.AddResult(Result(Builder.TakeString()));
5155 if (Results.getSema().getLangOpts().Modules) {
5159 Builder.AddPlaceholderChunk(
"module");
5160 Results.AddResult(Result(Builder.TakeString()));
5165 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5166 CodeCompleter->getCodeCompletionTUInfo(),
5168 Results.EnterNewScope();
5169 if (isa<ObjCImplDecl>(CurContext))
5175 Results.ExitScope();
5177 Results.data(), Results.size());
5183 Results.getCodeCompletionTUInfo());
5186 const char *EncodeType =
"char[]";
5187 if (Results.getSema().getLangOpts().CPlusPlus ||
5188 Results.getSema().getLangOpts().ConstStrings)
5189 EncodeType =
"const char[]";
5190 Builder.AddResultTypeChunk(EncodeType);
5193 Builder.AddPlaceholderChunk(
"type-name");
5195 Results.AddResult(Result(Builder.TakeString()));
5198 Builder.AddResultTypeChunk(
"Protocol *");
5201 Builder.AddPlaceholderChunk(
"protocol-name");
5203 Results.AddResult(Result(Builder.TakeString()));
5206 Builder.AddResultTypeChunk(
"SEL");
5209 Builder.AddPlaceholderChunk(
"selector");
5211 Results.AddResult(Result(Builder.TakeString()));
5214 Builder.AddResultTypeChunk(
"NSString *");
5216 Builder.AddPlaceholderChunk(
"string");
5217 Builder.AddTextChunk(
"\"");
5218 Results.AddResult(Result(Builder.TakeString()));
5221 Builder.AddResultTypeChunk(
"NSArray *");
5223 Builder.AddPlaceholderChunk(
"objects, ...");
5225 Results.AddResult(Result(Builder.TakeString()));
5228 Builder.AddResultTypeChunk(
"NSDictionary *");
5230 Builder.AddPlaceholderChunk(
"key");
5233 Builder.AddPlaceholderChunk(
"object, ...");
5235 Results.AddResult(Result(Builder.TakeString()));
5238 Builder.AddResultTypeChunk(
"id");
5240 Builder.AddPlaceholderChunk(
"expression");
5242 Results.AddResult(Result(Builder.TakeString()));
5248 Results.getCodeCompletionTUInfo());
5250 if (Results.includeCodePatterns()) {
5255 Builder.AddPlaceholderChunk(
"statements");
5257 Builder.AddTextChunk(
"@catch");
5259 Builder.AddPlaceholderChunk(
"parameter");
5262 Builder.AddPlaceholderChunk(
"statements");
5264 Builder.AddTextChunk(
"@finally");
5266 Builder.AddPlaceholderChunk(
"statements");
5268 Results.AddResult(Result(Builder.TakeString()));
5274 Builder.AddPlaceholderChunk(
"expression");
5275 Results.AddResult(Result(Builder.TakeString()));
5277 if (Results.includeCodePatterns()) {
5282 Builder.AddPlaceholderChunk(
"expression");
5285 Builder.AddPlaceholderChunk(
"statements");
5287 Results.AddResult(Result(Builder.TakeString()));
5292 ResultBuilder &Results,
5303 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5304 CodeCompleter->getCodeCompletionTUInfo(),
5306 Results.EnterNewScope();
5308 Results.ExitScope();
5310 Results.data(), Results.size());
5314 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5315 CodeCompleter->getCodeCompletionTUInfo(),
5317 Results.EnterNewScope();
5320 Results.ExitScope();
5322 Results.data(), Results.size());
5326 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5327 CodeCompleter->getCodeCompletionTUInfo(),
5329 Results.EnterNewScope();
5331 Results.ExitScope();
5333 Results.data(), Results.size());
5340 if (Attributes & NewFlag)
5343 Attributes |= NewFlag;
5357 if (AssignCopyRetMask &&
5375 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5376 CodeCompleter->getCodeCompletionTUInfo(),
5378 Results.EnterNewScope();
5406 Results.getCodeCompletionTUInfo());
5408 Setter.AddTextChunk(
"=");
5409 Setter.AddPlaceholderChunk(
"method");
5414 Results.getCodeCompletionTUInfo());
5416 Getter.AddTextChunk(
"=");
5417 Getter.AddPlaceholderChunk(
"method");
5426 Results.ExitScope();
5428 Results.data(), Results.size());
5441 ArrayRef<IdentifierInfo *> SelIdents,
5442 bool AllowSameLength =
true) {
5443 unsigned NumSelIdents = SelIdents.size();
5453 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
5456 for (
unsigned I = 0; I != NumSelIdents; ++I)
5465 ArrayRef<IdentifierInfo *> SelIdents,
5466 bool AllowSameLength =
true) {
5474 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5499 ArrayRef<IdentifierInfo *> SelIdents,
5501 VisitedSelectorSet &Selectors,
bool AllowSameLength,
5502 ResultBuilder &Results,
bool InOriginalClass =
true,
5503 bool IsRootClass =
false) {
5507 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
5508 for (
auto *M : Container->
methods()) {
5511 if (M->isInstanceMethod() == WantInstanceMethods ||
5512 (IsRootClass && !WantInstanceMethods)) {
5518 if (!Selectors.insert(M->getSelector()).second)
5521 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5522 R.StartParameter = SelIdents.size();
5523 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5524 if (!InOriginalClass)
5526 Results.MaybeAddResult(R, CurContext);
5532 if (Protocol->hasDefinition()) {
5534 = Protocol->getReferencedProtocols();
5536 E = Protocols.
end();
5538 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5539 Selectors, AllowSameLength, Results,
false, IsRootClass);
5548 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5549 Selectors, AllowSameLength, Results,
false, IsRootClass);
5553 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5554 CurContext, Selectors, AllowSameLength, Results,
5555 InOriginalClass, IsRootClass);
5559 = CatDecl->getReferencedProtocols();
5561 E = Protocols.
end();
5563 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5564 Selectors, AllowSameLength, Results,
false, IsRootClass);
5568 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5569 Selectors, AllowSameLength, Results, InOriginalClass,
5577 SelIdents, CurContext, Selectors, AllowSameLength, Results,
5582 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5583 Selectors, AllowSameLength, Results, InOriginalClass,
5593 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5594 Class =
Category->getClassInterface();
5601 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5602 CodeCompleter->getCodeCompletionTUInfo(),
5604 Results.EnterNewScope();
5606 VisitedSelectorSet Selectors;
5609 Results.ExitScope();
5611 Results.data(), Results.size());
5617 = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
5620 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5621 Class =
Category->getClassInterface();
5628 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5629 CodeCompleter->getCodeCompletionTUInfo(),
5631 Results.EnterNewScope();
5633 VisitedSelectorSet Selectors;
5635 Selectors,
true, Results);
5637 Results.ExitScope();
5639 Results.data(), Results.size());
5644 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5645 CodeCompleter->getCodeCompletionTUInfo(),
5647 Results.EnterNewScope();
5650 bool AddedInOut =
false;
5653 Results.AddResult(
"in");
5654 Results.AddResult(
"inout");
5659 Results.AddResult(
"out");
5661 Results.AddResult(
"inout");
5666 Results.AddResult(
"bycopy");
5667 Results.AddResult(
"byref");
5668 Results.AddResult(
"oneway");
5671 Results.AddResult(
"nonnull");
5672 Results.AddResult(
"nullable");
5673 Results.AddResult(
"null_unspecified");
5681 PP.isMacroDefined(
"IBAction")) {
5683 Results.getCodeCompletionTUInfo(),
5685 Builder.AddTypedTextChunk(
"IBAction");
5687 Builder.AddPlaceholderChunk(
"selector");
5690 Builder.AddTextChunk(
"id");
5692 Builder.AddTextChunk(
"sender");
5703 Results.ExitScope();
5706 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
5707 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5709 CodeCompleter->includeGlobals(),
5710 CodeCompleter->loadExternal());
5712 if (CodeCompleter->includeMacros())
5716 Results.data(), Results.size());
5746 IFace = ObjType->getInterface();
5752 IFace = Ptr->getInterfaceDecl();
5766 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5767 .Case(
"retain", IFace)
5768 .Case(
"strong", IFace)
5769 .Case(
"autorelease", IFace)
5770 .Case(
"copy", IFace)
5771 .Case(
"copyWithZone", IFace)
5772 .Case(
"mutableCopy", IFace)
5773 .Case(
"mutableCopyWithZone", IFace)
5774 .Case(
"awakeFromCoder", IFace)
5775 .Case(
"replacementObjectFromCoder", IFace)
5776 .Case(
"class", IFace)
5777 .Case(
"classForCoder", IFace)
5778 .Case(
"superclass", Super)
5781 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5783 .Case(
"alloc", IFace)
5784 .Case(
"allocWithZone", IFace)
5785 .Case(
"class", IFace)
5786 .Case(
"superclass", Super)
5807 Sema &S,
bool NeedSuperKeyword,
5808 ArrayRef<IdentifierInfo *> SelIdents,
5809 ResultBuilder &Results) {
5828 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
5846 CurP != CurPEnd; ++CurP, ++SuperP) {
5849 (*SuperP)->getType()))
5853 if (!(*CurP)->getIdentifier())
5859 Results.getCodeCompletionTUInfo());
5863 Results.getCompletionContext().getBaseType(),
5867 if (NeedSuperKeyword) {
5868 Builder.AddTypedTextChunk(
"super");
5874 if (NeedSuperKeyword)
5875 Builder.AddTextChunk(Builder.getAllocator().CopyString(
5878 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
5882 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
5883 if (I > SelIdents.size())
5886 if (I < SelIdents.size())
5887 Builder.AddInformativeChunk(
5888 Builder.getAllocator().CopyString(
5890 else if (NeedSuperKeyword || I > SelIdents.size()) {
5891 Builder.AddTextChunk(
5892 Builder.getAllocator().CopyString(
5894 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
5895 (*CurP)->getIdentifier()->getName()));
5897 Builder.AddTypedTextChunk(
5898 Builder.getAllocator().CopyString(
5900 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
5901 (*CurP)->getIdentifier()->getName()));
5913 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5914 CodeCompleter->getCodeCompletionTUInfo(),
5916 getLangOpts().CPlusPlus11
5917 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
5918 : &ResultBuilder::IsObjCMessageReceiver);
5920 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5921 Results.EnterNewScope();
5923 CodeCompleter->includeGlobals(),
5924 CodeCompleter->loadExternal());
5930 if (Iface->getSuperClass()) {
5931 Results.AddResult(Result(
"super"));
5939 Results.ExitScope();
5941 if (CodeCompleter->includeMacros())
5944 Results.data(), Results.size());
5950 bool AtArgumentExpression) {
5954 CDecl = CurMethod->getClassInterface();
5963 if (CurMethod->isInstanceMethod()) {
5967 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
5968 AtArgumentExpression,
5977 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc,
5978 LookupOrdinaryName);
5979 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
5981 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
5984 CDecl = Iface->getInterface();
5985 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
5992 id.setIdentifier(Super, SuperLoc);
5993 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
5995 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
5997 AtArgumentExpression);
6006 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
6007 AtArgumentExpression,
6014 unsigned NumSelIdents) {
6016 ASTContext &Context = Results.getSema().Context;
6020 Result *ResultsData = Results.data();
6021 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
6022 Result &R = ResultsData[I];
6023 if (R.Kind == Result::RK_Declaration &&
6024 isa<ObjCMethodDecl>(R.Declaration)) {
6025 if (R.Priority <= BestPriority) {
6026 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
6027 if (NumSelIdents <= Method->param_size()) {
6030 if (R.Priority < BestPriority || PreferredType.
isNull()) {
6031 BestPriority = R.Priority;
6032 PreferredType = MyPreferredType;
6042 return PreferredType;
6047 ArrayRef<IdentifierInfo *> SelIdents,
6048 bool AtArgumentExpression,
6050 ResultBuilder &Results) {
6060 CDecl = Interface->getInterface();
6065 Results.EnterNewScope();
6072 Results.Ignore(SuperMethod);
6078 Results.setPreferredSelector(CurMethod->getSelector());
6080 VisitedSelectorSet Selectors;
6083 SemaRef.
CurContext, Selectors, AtArgumentExpression,
6091 for (uint32_t I = 0,
6102 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
6107 MethList = MethList->getNext()) {
6111 Result R(MethList->getMethod(),
6112 Results.getBasePriority(MethList->getMethod()),
nullptr);
6113 R.StartParameter = SelIdents.size();
6114 R.AllParametersAreInformative =
false;
6115 Results.MaybeAddResult(R, SemaRef.
CurContext);
6120 Results.ExitScope();
6125 bool AtArgumentExpression,
6128 QualType T = this->GetTypeFromParser(Receiver);
6130 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6131 CodeCompleter->getCodeCompletionTUInfo(),
6136 AtArgumentExpression, IsSuper, Results);
6143 if (AtArgumentExpression) {
6146 if (PreferredType.
isNull())
6147 CodeCompleteOrdinaryName(S, PCC_Expression);
6149 CodeCompleteExpression(S, PreferredType);
6154 Results.getCompletionContext(),
6155 Results.data(), Results.size());
6160 bool AtArgumentExpression,
6164 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6169 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6172 RecExpr = Conv.
get();
6185 return CodeCompleteObjCClassMessage(S,
6188 AtArgumentExpression, Super);
6193 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6194 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6196 RecExpr = Conv.
get();
6197 ReceiverType = RecExpr->
getType();
6202 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6203 CodeCompleter->getCodeCompletionTUInfo(),
6205 ReceiverType, SelIdents));
6207 Results.EnterNewScope();
6214 Results.Ignore(SuperMethod);
6220 Results.setPreferredSelector(CurMethod->getSelector());
6223 VisitedSelectorSet Selectors;
6233 CurContext, Selectors, AtArgumentExpression, Results);
6240 for (
auto *I : QualID->quals())
6242 Selectors, AtArgumentExpression, Results);
6249 CurContext, Selectors, AtArgumentExpression,
6253 for (
auto *I : IFacePtr->quals())
6255 Selectors, AtArgumentExpression, Results);
6264 if (ExternalSource) {
6265 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6267 Selector Sel = ExternalSource->GetExternalSelector(I);
6268 if (Sel.
isNull() || MethodPool.count(Sel))
6271 ReadMethodPool(Sel);
6275 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6276 MEnd = MethodPool.end();
6280 MethList = MethList->getNext()) {
6284 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6287 Result R(MethList->getMethod(),
6288 Results.getBasePriority(MethList->getMethod()),
nullptr);
6289 R.StartParameter = SelIdents.size();
6290 R.AllParametersAreInformative =
false;
6291 Results.MaybeAddResult(R, CurContext);
6295 Results.ExitScope();
6303 if (AtArgumentExpression) {
6306 if (PreferredType.
isNull())
6307 CodeCompleteOrdinaryName(S, PCC_Expression);
6309 CodeCompleteExpression(S, PreferredType);
6314 Results.getCompletionContext(),
6315 Results.data(),Results.size());
6331 CodeCompleteExpression(S, Data);
6338 if (ExternalSource) {
6339 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6341 Selector Sel = ExternalSource->GetExternalSelector(I);
6342 if (Sel.
isNull() || MethodPool.count(Sel))
6345 ReadMethodPool(Sel);
6349 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6350 CodeCompleter->getCodeCompletionTUInfo(),
6352 Results.EnterNewScope();
6353 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6354 MEnd = MethodPool.end();
6362 Results.getCodeCompletionTUInfo());
6364 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
6366 Results.AddResult(Builder.TakeString());
6370 std::string Accumulator;
6371 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
6372 if (I == SelIdents.size()) {
6373 if (!Accumulator.empty()) {
6374 Builder.AddInformativeChunk(Builder.getAllocator().CopyString(
6376 Accumulator.clear();
6383 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString( Accumulator));
6384 Results.AddResult(Builder.TakeString());
6386 Results.ExitScope();
6389 Results.data(), Results.size());
6395 bool OnlyForwardDeclarations,
6396 ResultBuilder &Results) {
6399 for (
const auto *D : Ctx->
decls()) {
6401 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
6402 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
6403 Results.AddResult(Result(Proto, Results.getBasePriority(Proto),
nullptr),
6404 CurContext,
nullptr,
false);
6410 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6411 CodeCompleter->getCodeCompletionTUInfo(),
6414 if (CodeCompleter->includeGlobals()) {
6415 Results.EnterNewScope();
6423 Results.Ignore(Protocol);
6429 Results.ExitScope();
6433 Results.data(), Results.size());
6437 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6438 CodeCompleter->getCodeCompletionTUInfo(),
6441 if (CodeCompleter->includeGlobals()) {
6442 Results.EnterNewScope();
6448 Results.ExitScope();
6452 Results.data(), Results.size());
6458 bool OnlyForwardDeclarations,
6459 bool OnlyUnimplemented,
6460 ResultBuilder &Results) {
6463 for (
const auto *D : Ctx->
decls()) {
6465 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
6466 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
6467 (!OnlyUnimplemented || !Class->getImplementation()))
6468 Results.AddResult(Result(Class, Results.getBasePriority(Class),
nullptr),
6469 CurContext,
nullptr,
false);
6474 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6475 CodeCompleter->getCodeCompletionTUInfo(),
6477 Results.EnterNewScope();
6479 if (CodeCompleter->includeGlobals()) {
6485 Results.ExitScope();
6488 Results.data(), Results.size());
6493 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6494 CodeCompleter->getCodeCompletionTUInfo(),
6496 Results.EnterNewScope();
6500 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6501 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6502 Results.Ignore(CurClass);
6504 if (CodeCompleter->includeGlobals()) {
6510 Results.ExitScope();
6513 Results.data(), Results.size());
6517 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6518 CodeCompleter->getCodeCompletionTUInfo(),
6520 Results.EnterNewScope();
6522 if (CodeCompleter->includeGlobals()) {
6528 Results.ExitScope();
6531 Results.data(), Results.size());
6539 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6540 CodeCompleter->getCodeCompletionTUInfo(),
6545 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6547 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6549 for (
const auto *Cat : Class->visible_categories())
6550 CategoryNames.insert(Cat->getIdentifier());
6554 Results.EnterNewScope();
6556 for (
const auto *D : TU->
decls())
6557 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6558 if (CategoryNames.insert(
Category->getIdentifier()).second)
6561 CurContext,
nullptr,
false);
6562 Results.ExitScope();
6565 Results.data(), Results.size());
6577 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6580 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6582 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6583 CodeCompleter->getCodeCompletionTUInfo(),
6589 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6590 Results.EnterNewScope();
6591 bool IgnoreImplemented =
true;
6594 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6595 CategoryNames.insert(Cat->getIdentifier()).second)
6596 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6597 CurContext,
nullptr,
false);
6601 IgnoreImplemented =
false;
6603 Results.ExitScope();
6606 Results.data(), Results.size());
6611 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6612 CodeCompleter->getCodeCompletionTUInfo(),
6617 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6619 (!isa<ObjCImplementationDecl>(Container) &&
6620 !isa<ObjCCategoryImplDecl>(Container)))
6625 for (
const auto *D : Container->decls())
6626 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6627 Results.Ignore(PropertyImpl->getPropertyDecl());
6630 AddedPropertiesSet AddedProperties;
6631 Results.EnterNewScope();
6633 = dyn_cast<ObjCImplementationDecl>(Container))
6636 AddedProperties, Results);
6639 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6640 false,
false, CurContext,
6641 AddedProperties, Results);
6642 Results.ExitScope();
6645 Results.data(), Results.size());
6651 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6652 CodeCompleter->getCodeCompletionTUInfo(),
6657 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6659 (!isa<ObjCImplementationDecl>(Container) &&
6660 !isa<ObjCCategoryImplDecl>(Container)))
6666 = dyn_cast<ObjCImplementationDecl>(Container))
6667 Class = ClassImpl->getClassInterface();
6669 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl()
6670 ->getClassInterface();
6678 =
Property->getType().getNonReferenceType().getUnqualifiedType();
6681 Results.setPreferredType(PropertyType);
6686 Results.EnterNewScope();
6687 bool SawSimilarlyNamedIvar =
false;
6688 std::string NameWithPrefix;
6689 NameWithPrefix +=
'_';
6690 NameWithPrefix += PropertyName->
getName();
6691 std::string NameWithSuffix = PropertyName->
getName().str();
6692 NameWithSuffix +=
'_';
6696 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6697 CurContext,
nullptr,
false);
6701 if ((PropertyName == Ivar->getIdentifier() ||
6702 NameWithPrefix == Ivar->
getName() ||
6703 NameWithSuffix == Ivar->getName())) {
6704 SawSimilarlyNamedIvar =
true;
6708 if (Results.size() &&
6709 Results.data()[Results.size() - 1].Kind
6711 Results.data()[Results.size() - 1].Declaration == Ivar)
6712 Results.data()[Results.size() - 1].Priority--;
6717 if (!SawSimilarlyNamedIvar) {
6728 Policy, Allocator));
6729 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
6730 Results.AddResult(Result(Builder.TakeString(), Priority,
6734 Results.ExitScope();
6737 Results.data(), Results.size());
6742 typedef llvm::DenseMap<
6751 Optional<bool> WantInstanceMethods,
6753 KnownMethodsMap &KnownMethods,
6754 bool InOriginalClass =
true) {
6757 if (!IFace->hasDefinition())
6760 IFace = IFace->getDefinition();
6764 = IFace->getReferencedProtocols();
6766 E = Protocols.
end();
6769 KnownMethods, InOriginalClass);
6772 for (
auto *Cat : IFace->visible_categories()) {
6774 KnownMethods,
false);
6778 if (IFace->getSuperClass())
6780 WantInstanceMethods, ReturnType,
6781 KnownMethods,
false);
6787 =
Category->getReferencedProtocols();
6789 E = Protocols.
end();
6792 KnownMethods, InOriginalClass);
6795 if (InOriginalClass &&
Category->getClassInterface())
6797 WantInstanceMethods, ReturnType, KnownMethods,
6803 if (!Protocol->hasDefinition())
6805 Protocol = Protocol->getDefinition();
6806 Container = Protocol;
6810 = Protocol->getReferencedProtocols();
6812 E = Protocols.
end();
6815 KnownMethods,
false);
6821 for (
auto *M : Container->
methods()) {
6822 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
6823 if (!ReturnType.
isNull() &&
6827 KnownMethods[M->getSelector()] =
6828 KnownMethodsMap::mapped_type(M, InOriginalClass);
6836 unsigned ObjCDeclQuals,
6865 bool IsInstanceMethod,
6868 VisitedSelectorSet &KnownSelectors,
6869 ResultBuilder &Results) {
6871 if (!PropName || PropName->
getLength() == 0)
6889 const char *CopiedKey;
6892 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
6894 operator const char *() {
6898 return CopiedKey = Allocator.
CopyString(Key);
6900 } Key(Allocator, PropName->
getName());
6903 std::string UpperKey = PropName->
getName();
6904 if (!UpperKey.empty())
6907 bool ReturnTypeMatchesProperty = ReturnType.
isNull() ||
6910 bool ReturnTypeMatchesVoid
6914 if (IsInstanceMethod &&
6915 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
6919 Context, Policy, Builder);
6921 Builder.AddTypedTextChunk(Key);
6928 if (IsInstanceMethod &&
6929 ((!ReturnType.
isNull() &&
6934 std::string SelectorName = (Twine(
"is") + UpperKey).str();
6936 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6938 if (ReturnType.
isNull()) {
6940 Builder.AddTextChunk(
"BOOL");
6944 Builder.AddTypedTextChunk(
6952 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
6954 std::string SelectorName = (Twine(
"set") + UpperKey).str();
6956 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6957 if (ReturnType.
isNull()) {
6959 Builder.AddTextChunk(
"void");
6963 Builder.AddTypedTextChunk(
6965 Builder.AddTypedTextChunk(
":");
6967 Context, Policy, Builder);
6968 Builder.AddTextChunk(Key);
7004 if (IsInstanceMethod &&
7006 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
7008 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7010 if (ReturnType.
isNull()) {
7012 Builder.AddTextChunk(
"NSUInteger");
7016 Builder.AddTypedTextChunk(
7018 Results.AddResult(Result(Builder.TakeString(),
7020 UnorderedGetterPriority),
7027 if (IsInstanceMethod &&
7029 std::string SelectorName
7030 = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
7032 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7033 if (ReturnType.
isNull()) {
7035 Builder.AddTextChunk(
"id");
7039 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7041 Builder.AddTextChunk(
"NSUInteger");
7043 Builder.AddTextChunk(
"index");
7044 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7050 if (IsInstanceMethod &&
7055 ->getName() ==
"NSArray"))) {
7056 std::string SelectorName
7057 = (Twine(Property->
getName()) +
"AtIndexes").str();
7059 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7060 if (ReturnType.
isNull()) {
7062 Builder.AddTextChunk(
"NSArray *");
7066 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7068 Builder.AddTextChunk(
"NSIndexSet *");
7070 Builder.AddTextChunk(
"indexes");
7071 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7077 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7078 std::string SelectorName = (Twine(
"get") + UpperKey).str();
7084 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7085 if (ReturnType.
isNull()) {
7087 Builder.AddTextChunk(
"void");
7091 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7093 Builder.AddPlaceholderChunk(
"object-type");
7094 Builder.AddTextChunk(
" **");
7096 Builder.AddTextChunk(
"buffer");
7098 Builder.AddTypedTextChunk(
"range:");
7100 Builder.AddTextChunk(
"NSRange");
7102 Builder.AddTextChunk(
"inRange");
7103 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7111 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7112 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
7118 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7119 if (ReturnType.
isNull()) {
7121 Builder.AddTextChunk(
"void");
7125 Builder.AddTypedTextChunk(
"insertObject:");
7127 Builder.AddPlaceholderChunk(
"object-type");
7128 Builder.AddTextChunk(
" *");
7130 Builder.AddTextChunk(
"object");
7132 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7134 Builder.AddPlaceholderChunk(
"NSUInteger");
7136 Builder.AddTextChunk(
"index");
7137 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7143 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7144 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
7150 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7151 if (ReturnType.
isNull()) {
7153 Builder.AddTextChunk(
"void");
7157 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7159 Builder.AddTextChunk(
"NSArray *");
7161 Builder.AddTextChunk(
"array");
7163 Builder.AddTypedTextChunk(
"atIndexes:");
7165 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7167 Builder.AddTextChunk(
"indexes");
7168 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7174 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7175 std::string SelectorName
7176 = (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
7178 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7179 if (ReturnType.
isNull()) {
7181 Builder.AddTextChunk(
"void");
7185 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7187 Builder.AddTextChunk(
"NSUInteger");
7189 Builder.AddTextChunk(
"index");
7190 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7196 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7197 std::string SelectorName
7198 = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
7200 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7201 if (ReturnType.
isNull()) {
7203 Builder.AddTextChunk(
"void");
7207 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7209 Builder.AddTextChunk(
"NSIndexSet *");
7211 Builder.AddTextChunk(
"indexes");
7212 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7218 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7219 std::string SelectorName
7220 = (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
7226 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7227 if (ReturnType.
isNull()) {
7229 Builder.AddTextChunk(
"void");
7233 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7235 Builder.AddPlaceholderChunk(
"NSUInteger");
7237 Builder.AddTextChunk(
"index");
7239 Builder.AddTypedTextChunk(
"withObject:");
7241 Builder.AddTextChunk(
"id");
7243 Builder.AddTextChunk(
"object");
7244 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7250 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7251 std::string SelectorName1
7252 = (Twine(
"replace") + UpperKey +
"AtIndexes").str();
7253 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
7259 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7260 if (ReturnType.
isNull()) {
7262 Builder.AddTextChunk(
"void");
7266 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
7268 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7270 Builder.AddTextChunk(
"indexes");
7272 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
7274 Builder.AddTextChunk(
"NSArray *");
7276 Builder.AddTextChunk(
"array");
7277 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7284 if (IsInstanceMethod &&
7289 ->getName() ==
"NSEnumerator"))) {
7290 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
7292 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7294 if (ReturnType.
isNull()) {
7296 Builder.AddTextChunk(
"NSEnumerator *");
7300 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7301 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7307 if (IsInstanceMethod &&
7309 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
7311 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7312 if (ReturnType.
isNull()) {
7314 Builder.AddPlaceholderChunk(
"object-type");
7315 Builder.AddTextChunk(
" *");
7319 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7321 if (ReturnType.
isNull()) {
7322 Builder.AddPlaceholderChunk(
"object-type");
7323 Builder.AddTextChunk(
" *");
7327 Builder.getAllocator()));
7330 Builder.AddTextChunk(
"object");
7331 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7338 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7339 std::string SelectorName
7340 = (Twine(
"add") + UpperKey + Twine(
"Object")).str();
7342 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7343 if (ReturnType.
isNull()) {
7345 Builder.AddTextChunk(
"void");
7349 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7351 Builder.AddPlaceholderChunk(
"object-type");
7352 Builder.AddTextChunk(
" *");
7354 Builder.AddTextChunk(
"object");
7355 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7361 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7362 std::string SelectorName = (Twine(
"add") + UpperKey).str();
7364 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7365 if (ReturnType.
isNull()) {
7367 Builder.AddTextChunk(
"void");
7371 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7373 Builder.AddTextChunk(
"NSSet *");
7375 Builder.AddTextChunk(
"objects");
7376 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7382 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7383 std::string SelectorName
7384 = (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
7386 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7387 if (ReturnType.
isNull()) {
7389 Builder.AddTextChunk(
"void");
7393 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7395 Builder.AddPlaceholderChunk(
"object-type");
7396 Builder.AddTextChunk(
" *");
7398 Builder.AddTextChunk(
"object");
7399 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7405 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7406 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
7408 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7409 if (ReturnType.
isNull()) {
7411 Builder.AddTextChunk(
"void");
7415 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7417 Builder.AddTextChunk(
"NSSet *");
7419 Builder.AddTextChunk(
"objects");
7420 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7426 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7427 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
7429 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7430 if (ReturnType.
isNull()) {
7432 Builder.AddTextChunk(
"void");
7436 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7438 Builder.AddTextChunk(
"NSSet *");
7440 Builder.AddTextChunk(
"objects");
7441 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7448 if (!IsInstanceMethod &&
7453 ->getName() ==
"NSSet"))) {
7454 std::string SelectorName
7455 = (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
7457 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7459 if (ReturnType.
isNull()) {
7461 Builder.AddTextChunk(
"NSSet<NSString *> *");
7465 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7472 if (!IsInstanceMethod &&
7476 std::string SelectorName
7477 = (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
7479 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7481 if (ReturnType.
isNull()) {
7483 Builder.AddTextChunk(
"BOOL");
7487 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7498 QualType ReturnType = GetTypeFromParser(ReturnTy);
7499 Decl *IDecl =
nullptr;
7506 bool IsInImplementation =
false;
7507 if (
Decl *D = IDecl) {
7509 SearchDecl = Impl->getClassInterface();
7510 IsInImplementation =
true;
7512 = dyn_cast<ObjCCategoryImplDecl>(D)) {
7513 SearchDecl = CatImpl->getCategoryDecl();
7514 IsInImplementation =
true;
7519 if (!SearchDecl && S) {
7521 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7532 KnownMethodsMap KnownMethods;
7534 ReturnType, KnownMethods);
7538 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7539 CodeCompleter->getCodeCompletionTUInfo(),
7541 Results.EnterNewScope();
7543 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7544 MEnd = KnownMethods.end();
7548 Results.getCodeCompletionTUInfo());
7551 if (!IsInstanceMethod) {
7558 if (ReturnType.
isNull()) {
7569 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7570 Sel.getNameForSlot(0)));
7576 P != PEnd; (void)++
P, ++I) {
7579 Builder.AddTypedTextChunk(
":");
7580 else if (I < Sel.getNumArgs()) {
7582 Builder.AddTypedTextChunk(
7583 Builder.getAllocator().CopyString(Sel.getNameForSlot(I) +
":"));
7590 ParamType = (*P)->getType();
7592 ParamType = (*P)->getOriginalType();
7597 (*P)->getObjCDeclQualifier(),
7602 Builder.AddTextChunk(Builder.getAllocator().CopyString(
Id->getName()));
7608 Builder.AddTextChunk(
"...");
7611 if (IsInImplementation && Results.includeCodePatterns()) {
7618 Builder.AddTextChunk(
"return");
7620 Builder.AddPlaceholderChunk(
"expression");
7623 Builder.AddPlaceholderChunk(
"statements");
7630 if (!M->second.getInt())
7633 Results.AddResult(Result(Builder.TakeString(), Method, Priority));
7640 Containers.push_back(SearchDecl);
7642 VisitedSelectorSet KnownSelectors;
7643 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7644 MEnd = KnownMethods.end();
7646 KnownSelectors.insert(M->first);
7652 IFace =
Category->getClassInterface();
7656 Containers.push_back(Cat);
7658 if (IsInstanceMethod) {
7659 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
7660 for (
auto *
P : Containers[I]->instance_properties())
7662 KnownSelectors, Results);
7666 Results.ExitScope();
7669 Results.data(), Results.size());
7673 bool IsInstanceMethod,
7674 bool AtParameterName,
7679 if (ExternalSource) {
7680 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
7682 Selector Sel = ExternalSource->GetExternalSelector(I);
7683 if (Sel.
isNull() || MethodPool.count(Sel))
7686 ReadMethodPool(Sel);
7692 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7693 CodeCompleter->getCodeCompletionTUInfo(),
7697 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7699 Results.EnterNewScope();
7700 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7701 MEnd = MethodPool.end();
7703 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first :
7706 MethList = MethList->getNext()) {
7710 if (AtParameterName) {
7712 unsigned NumSelIdents = SelIdents.size();
7714 NumSelIdents <= MethList->getMethod()->param_size()) {
7716 MethList->getMethod()->parameters()[NumSelIdents - 1];
7719 Results.getCodeCompletionTUInfo());
7720 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7722 Results.AddResult(Builder.TakeString());
7729 Result R(MethList->getMethod(),
7730 Results.getBasePriority(MethList->getMethod()),
nullptr);
7731 R.StartParameter = SelIdents.size();
7732 R.AllParametersAreInformative =
false;
7733 R.DeclaringEntity =
true;
7734 Results.MaybeAddResult(R, CurContext);
7738 Results.ExitScope();
7740 if (!AtParameterName && !SelIdents.empty() &&
7741 SelIdents.front()->getName().startswith(
"init")) {
7742 for (
const auto &M : PP.macros()) {
7743 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
7745 Results.EnterNewScope();
7747 Results.getCodeCompletionTUInfo());
7748 Builder.AddTypedTextChunk(
7749 Builder.getAllocator().CopyString(M.first->getName()));
7752 Results.ExitScope();
7757 Results.data(), Results.size());
7761 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7762 CodeCompleter->getCodeCompletionTUInfo(),
7764 Results.EnterNewScope();
7768 Results.getCodeCompletionTUInfo());
7769 Builder.AddTypedTextChunk(
"if");
7771 Builder.AddPlaceholderChunk(
"condition");
7772 Results.AddResult(Builder.TakeString());
7775 Builder.AddTypedTextChunk(
"ifdef");
7777 Builder.AddPlaceholderChunk(
"macro");
7778 Results.AddResult(Builder.TakeString());
7781 Builder.AddTypedTextChunk(
"ifndef");
7783 Builder.AddPlaceholderChunk(
"macro");
7784 Results.AddResult(Builder.TakeString());
7786 if (InConditional) {
7788 Builder.AddTypedTextChunk(
"elif");
7790 Builder.AddPlaceholderChunk(
"condition");
7791 Results.AddResult(Builder.TakeString());
7794 Builder.AddTypedTextChunk(
"else");
7795 Results.AddResult(Builder.TakeString());
7798 Builder.AddTypedTextChunk(
"endif");
7799 Results.AddResult(Builder.TakeString());
7803 Builder.AddTypedTextChunk(
"include");
7805 Builder.AddTextChunk(
"\"");
7806 Builder.AddPlaceholderChunk(
"header");
7807 Builder.AddTextChunk(
"\"");
7808 Results.AddResult(Builder.TakeString());
7811 Builder.AddTypedTextChunk(
"include");
7813 Builder.AddTextChunk(
"<");
7814 Builder.AddPlaceholderChunk(
"header");
7815 Builder.AddTextChunk(
">");
7816 Results.AddResult(Builder.TakeString());
7819 Builder.AddTypedTextChunk(
"define");
7821 Builder.AddPlaceholderChunk(
"macro");
7822 Results.AddResult(Builder.TakeString());
7825 Builder.AddTypedTextChunk(
"define");
7827 Builder.AddPlaceholderChunk(
"macro");
7829 Builder.AddPlaceholderChunk(
"args");
7831 Results.AddResult(Builder.TakeString());
7834 Builder.AddTypedTextChunk(
"undef");
7836 Builder.AddPlaceholderChunk(
"macro");
7837 Results.AddResult(Builder.TakeString());
7840 Builder.AddTypedTextChunk(
"line");
7842 Builder.AddPlaceholderChunk(
"number");
7843 Results.AddResult(Builder.TakeString());
7846 Builder.AddTypedTextChunk(
"line");
7848 Builder.AddPlaceholderChunk(
"number");
7850 Builder.AddTextChunk(
"\"");
7851 Builder.AddPlaceholderChunk(
"filename");
7852 Builder.AddTextChunk(
"\"");
7853 Results.AddResult(Builder.TakeString());
7856 Builder.AddTypedTextChunk(
"error");
7858 Builder.AddPlaceholderChunk(
"message");
7859 Results.AddResult(Builder.TakeString());
7862 Builder.AddTypedTextChunk(
"pragma");
7864 Builder.AddPlaceholderChunk(
"arguments");
7865 Results.AddResult(Builder.TakeString());
7867 if (getLangOpts().ObjC1) {
7869 Builder.AddTypedTextChunk(
"import");
7871 Builder.AddTextChunk(
"\"");
7872 Builder.AddPlaceholderChunk(
"header");
7873 Builder.AddTextChunk(
"\"");
7874 Results.AddResult(Builder.TakeString());
7877 Builder.AddTypedTextChunk(
"import");
7879 Builder.AddTextChunk(
"<");
7880 Builder.AddPlaceholderChunk(
"header");
7881 Builder.AddTextChunk(
">");
7882 Results.AddResult(Builder.TakeString());
7886 Builder.AddTypedTextChunk(
"include_next");
7888 Builder.AddTextChunk(
"\"");
7889 Builder.AddPlaceholderChunk(
"header");
7890 Builder.AddTextChunk(
"\"");
7891 Results.AddResult(Builder.TakeString());
7894 Builder.AddTypedTextChunk(
"include_next");
7896 Builder.AddTextChunk(
"<");
7897 Builder.AddPlaceholderChunk(
"header");
7898 Builder.AddTextChunk(
">");
7899 Results.AddResult(Builder.TakeString());
7902 Builder.AddTypedTextChunk(
"warning");
7904 Builder.AddPlaceholderChunk(
"message");
7905 Results.AddResult(Builder.TakeString());
7912 Results.ExitScope();
7915 Results.data(), Results.size());
7919 CodeCompleteOrdinaryName(S,
7925 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7926 CodeCompleter->getCodeCompletionTUInfo(),
7929 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
7932 Results.getCodeCompletionTUInfo());
7933 Results.EnterNewScope();
7935 MEnd = PP.macro_end();
7937 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7938 M->first->getName()));
7943 Results.ExitScope();
7944 }
else if (IsDefinition) {
7949 Results.data(), Results.size());
7953 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7954 CodeCompleter->getCodeCompletionTUInfo(),
7957 if (!CodeCompleter || CodeCompleter->includeMacros())
7961 Results.EnterNewScope();
7963 Results.getCodeCompletionTUInfo());
7964 Builder.AddTypedTextChunk(
"defined");
7967 Builder.AddPlaceholderChunk(
"macro");
7969 Results.AddResult(Builder.TakeString());
7970 Results.ExitScope();
7973 Results.data(), Results.size());
7979 unsigned Argument) {
7994 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7995 CodeCompleter->getCodeCompletionTUInfo(),
7997 Results.EnterNewScope();
7998 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
7999 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
8002 Twine(Platform) +
"ApplicationExtension")));
8004 Results.ExitScope();
8006 Results.data(), Results.size());
8012 ResultBuilder Builder(*
this, Allocator, CCTUInfo,
8014 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
8015 CodeCompletionDeclConsumer Consumer(Builder,
8019 !CodeCompleter || CodeCompleter->loadExternal());
8022 if (!CodeCompleter || CodeCompleter->includeMacros())
8026 Results.insert(Results.end(),
8027 Builder.data(), Builder.data() + Builder.size());
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
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)...
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
bool hasDefinition() const
Determine whether this class has been defined.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
Represents a function declaration or definition.
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
ExternalSemaSource * getExternalSource() const
A C++ namespace alias declaration.
protocol_range protocols() const
Priority for the Objective-C "_cmd" implicit parameter.
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Any kind of method, provided it means other specified criteria.
bool isBlockPointerType() const
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
This is a scope that corresponds to the parameters within a function prototype.
param_iterator param_begin() const
bool isMemberPointerType() const
std::vector< Module * >::iterator submodule_iterator
unsigned param_size() const
A static_assert or _Static_assert node.
Selector getSelector() const
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...
ObjCDeclQualifier getObjCDeclQualifier() const
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases, bool LoadExternal)
const TypeClass * getTypePtr() const
Code completion occurs within a class, struct, or union.
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion for a selector, as in an @selector expression.
CodeCompleteConsumer::OverloadCandidate ResultCandidate
submodule_iterator submodule_begin()
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
Code completion where an Objective-C class message is expected.
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
FunctionType - C99 6.7.5.3 - Function Declarators.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
static bool isObjCReceiverType(ASTContext &C, QualType T)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
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)
static CharSourceRange getTokenRange(SourceRange R)
Code completion within a type-qualifier list.
bool isRecordType() const
static bool isReservedName(const IdentifierInfo *Id, bool doubleUnderscoreOnly=false)
Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).
bool isEmpty() const
No scope specifier.
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.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
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...
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.
bool isOverrideSpecified() const
known_categories_range known_categories() const
std::ptrdiff_t difference_type
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression)
Defines the clang::MacroInfo and clang::MacroDirective classes.
void CodeCompleteNaturalLanguage()
pointer(const DeclIndexPair &Value)
The base class of the type hierarchy.
An unspecified code-completion context.
bool isObjCContainer() const
Represent a C++ namespace.
Wrapper for source info for typedefs.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
A C++ non-type template parameter.
An Objective-C @interface for a category.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext)
A container of type source information.
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...
constexpr XRayInstrMask Function
ObjCMethodDecl * getMethod() const
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results. ...
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
Priority for a member declaration found from the current method or member function.
param_const_iterator param_end() const
unsigned getIdentifierNamespace() const
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)
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.
enumerator_range enumerators() const
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...
Represents a variable declaration or definition.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
A left bracket ('[').
Information about one declarator, including the parsed type information and the identifier.
unsigned getNumParams() const
bool isEnumeralType() const
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
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.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
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. ...
Code completion occurs within an Objective-C implementation or category implementation.
The entity is not available; any use of it will be an error.
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
bool isObjCObjectOrInterfaceType() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
Represents a struct/union/class.
static void AddTypedefResult(ResultBuilder &Results)
static void AddObjCProperties(const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results, bool IsBaseExprStatement=false, bool IsClassProperty=false)
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
instprop_range instance_properties() const
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
One of these records is kept for each identifier that is lexed.
CodeCompletionString * TakeString()
Take the resulting completion string.
This table allows us to fully hide how we implement multi-keyword caching.
void CodeCompleteObjCInterfaceDecl(Scope *S)
SmallVector< Decl *, 4 > IgnoreDecls
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
The results of name lookup within a DeclContext.
const ParmVarDecl *const * param_const_iterator
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr *> Args)
A "string" used to describe how code completion can be performed for an entity.
field_range fields() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const TST TST_class
bool isObjCIdType() const
An Objective-C @protocol declaration.
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
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)
Code completion occurs following one or more template headers within a class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
method_range methods() const
ObjCMethodDecl * getSetterMethodDecl() const
Kind getKind() const
Retrieve the kind of code-completion context.
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
ParmVarDecl * getParam(unsigned i) const
An Objective-C instance method.
static const TST TST_enum
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
TSC getTypeSpecComplex() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
visible_categories_range visible_categories() const
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
const LangOptions & getLangOpts() const
bool isObjCQualifiedClassType() const
void * getAsOpaquePtr() const
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 getTypeQuals() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Code completion occurs at top-level or namespace context.
ArrayRef< ParmVarDecl * > parameters() const
Values of this type can be null.
bool isUnarySelector() const
An Objective-C @property declaration.
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
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...
Represents a C++ unqualified-id that has been parsed.
param_iterator param_end() const
Represents the results of name lookup.
Divide by this factor when a code-completion result's type exactly matches the type we expect...
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.
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.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
Code completion occurs following one or more template headers.
void CodeCompleteBracketDeclarator(Scope *S)
static void AddStaticAssertResult(CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
Wrapper for source info for functions.
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
Code completion occurs within an expression.
Whether values of this type can be null is (explicitly) unspecified.
Code completion occurred where a preprocessor directive is expected.
A friend of a previously-undeclared entity.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Represents a declaration of a type.
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
bool SuppressScope
Suppresses printing of scope specifiers.
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)
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true, bool IsRootClass=false)
Add all of the Objective-C methods in the given Objective-C container to the set of results...
static void AddObjCBlockCall(ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder, const NamedDecl *BD, const FunctionTypeLoc &BlockLoc, const FunctionProtoTypeLoc &BlockProtoLoc)
Adds a block invocation code completion result for the given block declaration BD.
TSS getTypeSpecSign() const
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)
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
reference operator*() const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
submodule_iterator submodule_end()
Priority for a constant value (e.g., enumerator).
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...
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.
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)...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
const LangOptions & getLangOpts() 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.
static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlock=false)
Tries to find the most appropriate type location for an Objective-C block placeholder.
A right brace ('}').
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
Represents an ObjC class declaration.
An Objective-C method being used as a property.
QualType getReturnType() const
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
Member name lookup, which finds the names of class/struct/union members.
A comma separator (',').
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
macro_iterator macro_end(bool IncludeExternalMacros=true) const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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...
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Priority for a preprocessor macro.
const DeclIndexPair * operator->() const
CXCursorKind
Describes the kind of entity that a cursor refers to.
void CodeCompleteAvailabilityPlatformName()
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
std::input_iterator_tag iterator_category
bool isFinalSpecified() const
A right parenthesis (')').
unsigned getFlags() const
getFlags - Return the flags for this scope.
Code completion where an Objective-C category name is expected.
static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
Sema - This implements semantic analysis and AST building for C.
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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...
Zero-argument (unary) selector.
DeclarationNameTable DeclarationNames
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
CandidateSetKind getKind() const
SmallVector< LambdaCapture, 4 > Captures
const UsingShadowDecl * ShadowDecl
If this Decl was unshadowed by using declaration, this can store a pointer to the UsingShadowDecl whi...
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
TST getTypeSpecType() const
iterator(const DeclIndexPair *Iterator)
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Code completion occurred where a protocol name is expected.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Retains information about a block that is currently being parsed.
classprop_range class_properties() const
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.
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
void CodeCompleteObjCMethodDecl(Scope *S, Optional< bool > IsInstanceMethod, ParsedType ReturnType)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
QualType getPointeeType() const
Code completion occurred where a new name is expected.
Represents a character-granular source range.
bool isVariadic() const
Whether this function is variadic.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
Declaration of a template type parameter.
void CodeCompleteObjCPropertyDefinition(Scope *S)
DeclContext * getEntity() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
const T * castAs() const
Member-template castAs<specific type>.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool isTypeAltiVecVector() const
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr *> Args)
static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Priority for a non-type declaration.
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Code completion occurs within an Objective-C interface, protocol, or category.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
Defines the clang::Preprocessor interface.
An Objective-C block property completed as a setter with a block placeholder.
void CodeCompleteObjCAtVisibility(Scope *S)
overridden_method_range overridden_methods() const
bool isFileContext() const
An Objective-C @implementation for a category.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
bool isObjCClassType() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
ObjCInterfaceDecl * getSuperClass() const
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
A semicolon (';').
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
void CodeCompletePreprocessorExpression()
EnumDecl * getDefinition() const
ParmVarDecl *const * param_iterator
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 MacroInfo * getMacroInfo(const IdentifierInfo *II) const
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isFunctionOrMethod() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer *> Initializers)
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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...
static std::string formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
Returns a placeholder string that corresponds to an Objective-C block declaration.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
bool isInstanceMethod() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getNumArgs() const
Selector getSelector() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
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)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
void CodeCompleteInitializer(Scope *S, Decl *D)
TypeLoc getReturnLoc() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
void CodeCompleteObjCPropertySetter(Scope *S)
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)
SourceManager & getSourceManager() const
Priority for the next initialization in a constructor initializer list.
void CodeCompleteTypeQualifiers(DeclSpec &DS)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
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.
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo *> SelIdents)
Code completion occurred within a class, struct, or union.
void CodeCompleteObjCAtDirective(Scope *S)
Priority for a send-to-super completion.
SelectorTable & Selectors
A C++ template type parameter.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement)
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
TypeLoc IgnoreParens() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
Encodes a location in the source.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Members, declared with object declarations within tag definitions.
decl_iterator decls_begin() const
const SwitchCase * getSwitchCaseList() const
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
pointer operator->() const
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Represents the declaration of a struct/union/class/enum.
This is a scope that corresponds to the Objective-C @catch statement.
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...
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
ASTContext & getASTContext() const LLVM_READONLY
static const TST TST_union
static void AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, RecordDecl *RD, Optional< FixItHint > AccessOpFixIt)
void CodeCompleteReturn(Scope *S)
Code completion where the name of an Objective-C class is expected.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
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)
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
const ParmVarDecl * getParamDecl(unsigned i) const
ObjCPropertyAttributeKind getPropertyAttributes() const
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.
A right bracket (']').
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.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
static void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, bool CompleteExpressionWithCurrentArg=true)
Represents a C++11 virt-specifier-seq.
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Represents one property declaration in an Objective-C interface.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
TypeClass getTypeClass() const
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
ObjCDeclQualifier getObjCDeclQualifier() const
bool isC99Varargs() const
const ObjCMethodDecl * getMethodDecl() const
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
bool isStaticMember()
Returns true if this declares a static member.
const char * getBriefComment() const
static bool anyNullArguments(ArrayRef< Expr *> Args)
A left brace ('{').
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
ObjCImplementationDecl * getImplementation() const
llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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.
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getName() const
Return the actual identifier string.
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()
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.
An Objective-C instance variable.
ParserCompletionContext
Describes the context in which code completion occurs.
static bool isConstructor(const Decl *ND)
Dataflow Directional Tag Classes.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
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...
QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix=false)
Generates a QualType that can be used to name the same type if used at the end of the current transla...
Priority for a declaration that is in the local scope.
bool isFunctionLike() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo *> SelIdents)
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...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
A function or method parameter.
QualType getType() const
Get the type for which this source info wrapper provides information.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
void CodeCompleteTag(Scope *S, unsigned TagSpec)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
AccessSpecifier getAccess() const
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
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...
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
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.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern...
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
The result is in a base class.
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.
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo *> SelIdents, ResultBuilder &Results)
void CodeCompleteNamespaceAliasDecl(Scope *S)
unsigned getNumParams() const
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, Optional< bool > WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
Find all of the methods that reside in the given container (and its superclasses, protocols...
void CodeCompleteUsingDirective(Scope *S)
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
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...
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.
const UnresolvedSetImpl & asUnresolvedSet() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
A reference to a member of a struct, union, or class that occurs in some non-expression context...
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
A module import declaration.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
A declaration whose specific kind is not exposed via this interface.
TypeSourceInfo * getTypeSourceInfo() const
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
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
An Objective-C @dynamic definition.
void CodeCompleteObjCAtStatement(Scope *S)
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...
We are between inheritance colon and the real class/struct definition scope.
Capturing the *this object by reference.
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)
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
bool isObjCObjectType() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A left parenthesis ('(').
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
StringRef getParentName() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
const SwitchCase * getNextSwitchCase() const
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
TranslationUnitDecl * getTranslationUnitDecl() const
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.
Priority for a nested-name-specifier.
An Objective-C @implementation.
CodeCompleteExpressionData(QualType PreferredType=QualType())
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...
sema::FunctionScopeInfo * getCurFunction() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
The parameter type of a method or function.
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
ObjCIvarDecl - Represents an ObjC instance variable.
A left angle bracket ('<').
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
A right angle bracket ('>').
bool isNull() const
Determine whether this is the empty selector.
Adjustment for KVC code pattern priorities when it doesn't look like the.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Cursor that represents the translation unit itself.
Declaration of a class template.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
ParsedType getRepAsType() const
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
Vertical whitespace ('\n' or '\r\n', depending on the platform).
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)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
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)
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
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. ...
MacroMap::const_iterator macro_iterator
static OpaquePtr make(QualType P)
The top declaration context.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Code completion occurred on the right-hand side of a member access expression using the dot operator...
Represents a type template specialization; the template must be a class template, a type alias templa...
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.
static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts)
Code completion occurred where a type name is expected.
__DEVICE__ int min(int __a, int __b)
Horizontal whitespace (' ').
SourceManager & SourceMgr
void CodeCompleteObjCImplementationDecl(Scope *S)
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
static const TST TST_struct
void AddAnnotation(const char *A)
DeclaratorContext getContext() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
A trivial tuple used to represent a source range.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
ObjCMethodDecl * getGetterMethodDecl() const
This represents a decl that may have 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
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
#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.
friend bool operator==(const iterator &X, const iterator &Y)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
bool isPropertyAccessor() const
Priority for a code pattern.
An Objective-C @interface.
Selector getGetterName() const
A C++ conversion function.
const Expr * getCond() const
The receiver is a superclass.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void CodeCompleteAfterIf(Scope *S)
const LangOptions & getLangOpts() const
Wrapper for source info for block pointers.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
base_class_range vbases()
This class handles loading and caching of source files into memory.
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)
SourceLocation getLocation() const
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
ArrayRef< ParmVarDecl * > parameters() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
decl_iterator decls_end() const
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
bool includeGlobals() const
Whether to include global (top-level) declaration results.