26 #include "llvm/ADT/DenseSet.h"
27 #include "llvm/ADT/SmallBitVector.h"
28 #include "llvm/ADT/SmallPtrSet.h"
29 #include "llvm/ADT/SmallString.h"
30 #include "llvm/ADT/StringExtras.h"
31 #include "llvm/ADT/StringSwitch.h"
32 #include "llvm/ADT/Twine.h"
37 using namespace clang;
48 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
54 std::vector<Result> Results;
59 llvm::SmallPtrSet<const Decl*, 16> AllDeclsFound;
61 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
66 class ShadowMapEntry {
71 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector*> DeclOrVector;
75 unsigned SingleDeclIndex;
78 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) { }
80 void Add(
const NamedDecl *ND,
unsigned Index) {
81 if (DeclOrVector.isNull()) {
84 SingleDeclIndex = Index;
89 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
92 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
93 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
98 DeclOrVector.get<DeclIndexPairVector*>()->push_back(
99 DeclIndexPair(ND, Index));
103 if (DeclIndexPairVector *Vec
104 = DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
119 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
136 bool AllowNestedNameSpecifiers;
147 std::list<ShadowMap> ShadowMaps;
154 bool HasObjectTypeQualifiers;
166 void AdjustResultPriorityForDecl(Result &R);
168 void MaybeAddConstructorResults(Result R);
174 LookupFilter Filter =
nullptr)
175 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
177 AllowNestedNameSpecifiers(
false), HasObjectTypeQualifiers(
false),
178 CompletionContext(CompletionContext),
179 ObjCImplementation(nullptr)
183 switch (CompletionContext.
getKind()) {
190 if (Method->isInstanceMethod())
192 ObjCImplementation = Interface->getImplementation();
201 unsigned getBasePriority(
const NamedDecl *D);
205 bool includeCodePatterns()
const {
211 void setFilter(LookupFilter Filter) {
212 this->Filter = Filter;
215 Result *data() {
return Results.empty()?
nullptr : &Results.front(); }
216 unsigned size()
const {
return Results.size(); }
217 bool empty()
const {
return Results.empty(); }
231 void setObjectTypeQualifiers(
Qualifiers Quals) {
232 ObjectTypeQualifiers = Quals;
233 HasObjectTypeQualifiers =
true;
241 void setPreferredSelector(
Selector Sel) {
242 PreferredSelector = Sel;
248 return CompletionContext;
252 void allowNestedNameSpecifiers(
bool Allow =
true) {
253 AllowNestedNameSpecifiers = Allow;
258 Sema &getSema()
const {
return SemaRef; }
272 bool isInterestingDecl(
const NamedDecl *ND,
273 bool &AsNestedNameSpecifier)
const;
281 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
291 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
308 void AddResult(Result R);
311 void EnterNewScope();
317 void Ignore(
const Decl *D) { AllDeclsFound.insert(D->getCanonicalDecl()); }
325 bool IsOrdinaryName(
const NamedDecl *ND)
const;
326 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
327 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
328 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
329 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
331 bool IsClassOrStruct(
const NamedDecl *ND)
const;
333 bool IsNamespace(
const NamedDecl *ND)
const;
334 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
336 bool IsMember(
const NamedDecl *ND)
const;
337 bool IsObjCIvar(
const NamedDecl *ND)
const;
338 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
339 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
340 bool IsObjCCollection(
const NamedDecl *ND)
const;
341 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
347 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
348 unsigned SingleDeclIndex;
370 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) { }
373 : DeclOrIterator(Iterator), SingleDeclIndex(0) { }
376 if (DeclOrIterator.is<
const NamedDecl *>()) {
382 const DeclIndexPair *
I = DeclOrIterator.get<
const DeclIndexPair*>();
398 return *DeclOrIterator.get<
const DeclIndexPair*>();
406 return X.DeclOrIterator.getOpaqueValue()
407 == Y.DeclOrIterator.getOpaqueValue() &&
408 X.SingleDeclIndex == Y.SingleDeclIndex;
418 if (DeclOrVector.isNull())
422 return iterator(ND, SingleDeclIndex);
424 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
429 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
432 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
454 for (
const DeclContext *CommonAncestor = TargetContext;
455 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
456 CommonAncestor = CommonAncestor->getLookupParent()) {
457 if (CommonAncestor->isTransparentContext() ||
458 CommonAncestor->isFunctionOrMethod())
461 TargetParents.push_back(CommonAncestor);
465 while (!TargetParents.empty()) {
466 const DeclContext *Parent = TargetParents.pop_back_val();
468 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
469 if (!Namespace->getIdentifier())
474 else if (
const TagDecl *TD = dyn_cast<TagDecl>(Parent))
485 bool doubleUnderscoreOnly =
false) {
489 return Name[0] ==
'_' &&
490 (Name[1] ==
'_' || (Name[1] >=
'A' && Name[1] <=
'Z' &&
491 !doubleUnderscoreOnly));
517 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
518 bool &AsNestedNameSpecifier)
const {
519 AsNestedNameSpecifier =
false;
530 if (ND->getFriendObjectKind() == Decl::FOK_Undeclared)
534 if (isa<ClassTemplateSpecializationDecl>(ND) ||
535 isa<ClassTemplatePartialSpecializationDecl>(ND))
539 if (isa<UsingDecl>(ND))
545 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
546 (isa<NamespaceDecl>(ND) &&
547 Filter != &ResultBuilder::IsNamespace &&
548 Filter != &ResultBuilder::IsNamespaceOrAlias &&
550 AsNestedNameSpecifier =
true;
553 if (Filter && !(this->*Filter)(Named)) {
555 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
556 IsNestedNameSpecifier(ND) &&
557 (Filter != &ResultBuilder::IsMember ||
558 (isa<CXXRecordDecl>(ND) &&
559 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
560 AsNestedNameSpecifier =
true;
570 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
585 if (HiddenCtx == Hiding->getDeclContext()->getRedeclContext())
590 R.QualifierIsInformative =
false;
595 R.Declaration->getDeclContext());
602 switch (T->getTypeClass()) {
604 switch (cast<BuiltinType>(T)->getKind()) {
605 case BuiltinType::Void:
608 case BuiltinType::NullPtr:
611 case BuiltinType::Overload:
612 case BuiltinType::Dependent:
615 case BuiltinType::ObjCId:
616 case BuiltinType::ObjCClass:
617 case BuiltinType::ObjCSel:
630 case Type::BlockPointer:
633 case Type::LValueReference:
634 case Type::RValueReference:
637 case Type::ConstantArray:
638 case Type::IncompleteArray:
639 case Type::VariableArray:
640 case Type::DependentSizedArray:
643 case Type::DependentSizedExtVector:
645 case Type::ExtVector:
648 case Type::FunctionProto:
649 case Type::FunctionNoProto:
658 case Type::ObjCObject:
659 case Type::ObjCInterface:
660 case Type::ObjCObjectPointer:
680 T = Function->getCallResultType();
681 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
682 T = Method->getSendResultType();
683 else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
688 T =
Value->getType();
702 if (Pointer->getPointeeType()->isFunctionType()) {
716 T = Function->getReturnType();
726 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
731 const DeclContext *LexicalDC = ND->getLexicalDeclContext();
735 dyn_cast<ImplicitParamDecl>(ND))
736 if (ImplicitParam->getIdentifier() &&
737 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
743 const DeclContext *DC = ND->getDeclContext()->getRedeclContext();
744 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC))
748 if (isa<EnumConstantDecl>(ND))
754 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
765 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
768 if (!PreferredSelector.isNull())
769 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
770 if (PreferredSelector == Method->getSelector())
775 if (!PreferredType.isNull()) {
785 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
791 void ResultBuilder::MaybeAddConstructorResults(Result R) {
792 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
800 Record = ClassTemplate->getTemplatedDecl();
801 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
803 if (isa<ClassTemplateSpecializationDecl>(Record))
825 Results.push_back(R);
829 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
830 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
832 if (R.Kind != Result::RK_Declaration) {
834 Results.push_back(R);
840 dyn_cast<UsingShadowDecl>(R.Declaration)) {
841 MaybeAddResult(
Result(Using->getTargetDecl(),
842 getBasePriority(Using->getTargetDecl()),
848 const Decl *CanonDecl = R.Declaration->getCanonicalDecl();
849 unsigned IDNS = CanonDecl->getIdentifierNamespace();
851 bool AsNestedNameSpecifier =
false;
852 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
856 if (isa<CXXConstructorDecl>(R.Declaration))
859 ShadowMap &
SMap = ShadowMaps.back();
862 if (NamePos != SMap.end()) {
863 I = NamePos->second.begin();
864 IEnd = NamePos->second.end();
867 for (; I != IEnd; ++
I) {
869 unsigned Index = I->second;
870 if (ND->getCanonicalDecl() == CanonDecl) {
872 Results[Index].Declaration = R.Declaration;
884 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
887 if (NamePos != SM->end()) {
888 I = NamePos->second.begin();
889 IEnd = NamePos->second.end();
891 for (; I != IEnd; ++
I) {
893 if (I->first->hasTagIdentifierNamespace() &&
894 (IDNS & (Decl::IDNS_Member | Decl::IDNS_Ordinary |
895 Decl::IDNS_LocalExtern | Decl::IDNS_ObjCProtocol)))
899 if (((I->first->getIdentifierNamespace() & Decl::IDNS_ObjCProtocol)
900 || (IDNS & Decl::IDNS_ObjCProtocol)) &&
901 I->first->getIdentifierNamespace() != IDNS)
905 if (CheckHiddenResult(R, CurContext, I->first))
913 if (!AllDeclsFound.insert(CanonDecl).second)
918 if (AsNestedNameSpecifier) {
919 R.StartsNestedNameSpecifier =
true;
922 AdjustResultPriorityForDecl(R);
925 if (R.QualifierIsInformative && !R.Qualifier &&
926 !R.StartsNestedNameSpecifier) {
927 const DeclContext *Ctx = R.Declaration->getDeclContext();
928 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
931 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
935 R.QualifierIsInformative =
false;
940 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
941 Results.push_back(R);
943 if (!AsNestedNameSpecifier)
944 MaybeAddConstructorResults(R);
947 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
948 NamedDecl *Hiding,
bool InBaseClass =
false) {
949 if (R.Kind != Result::RK_Declaration) {
951 Results.push_back(R);
956 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
957 AddResult(
Result(Using->getTargetDecl(),
958 getBasePriority(Using->getTargetDecl()),
964 bool AsNestedNameSpecifier =
false;
965 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
969 if (isa<CXXConstructorDecl>(R.Declaration))
972 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
976 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
981 if (AsNestedNameSpecifier) {
982 R.StartsNestedNameSpecifier =
true;
985 else if (Filter == &ResultBuilder::IsMember && !R.Qualifier && InBaseClass &&
986 isa<CXXRecordDecl>(R.Declaration->getDeclContext()
987 ->getRedeclContext()))
988 R.QualifierIsInformative =
true;
991 if (R.QualifierIsInformative && !R.Qualifier &&
992 !R.StartsNestedNameSpecifier) {
993 const DeclContext *Ctx = R.Declaration->getDeclContext();
994 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
997 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1001 R.QualifierIsInformative =
false;
1008 AdjustResultPriorityForDecl(R);
1010 if (HasObjectTypeQualifiers)
1011 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1012 if (Method->isInstance()) {
1015 if (ObjectTypeQualifiers == MethodQuals)
1017 else if (ObjectTypeQualifiers - MethodQuals) {
1025 Results.push_back(R);
1027 if (!AsNestedNameSpecifier)
1028 MaybeAddConstructorResults(R);
1031 void ResultBuilder::AddResult(Result R) {
1032 assert(R.Kind != Result::RK_Declaration &&
1033 "Declaration results need more context");
1034 Results.push_back(R);
1038 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1041 void ResultBuilder::ExitScope() {
1043 EEnd = ShadowMaps.back().end();
1046 E->second.Destroy();
1048 ShadowMaps.pop_back();
1053 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1058 unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_LocalExtern;
1060 IDNS |= Decl::IDNS_Tag | Decl::IDNS_Namespace | Decl::IDNS_Member;
1062 if (isa<ObjCIvarDecl>(ND))
1066 return ND->getIdentifierNamespace() & IDNS;
1071 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1073 if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
1076 unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_LocalExtern;
1078 IDNS |= Decl::IDNS_Tag | Decl::IDNS_Namespace | Decl::IDNS_Member;
1080 if (isa<ObjCIvarDecl>(ND))
1084 return ND->getIdentifierNamespace() & IDNS;
1087 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1088 if (!IsOrdinaryNonTypeName(ND))
1092 if (VD->getType()->isIntegralOrEnumerationType())
1100 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1103 unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_LocalExtern;
1105 IDNS |= Decl::IDNS_Tag | Decl::IDNS_Namespace;
1107 return (ND->getIdentifierNamespace() & IDNS) &&
1108 !isa<ValueDecl>(ND) && !isa<FunctionTemplateDecl>(ND) &&
1109 !isa<ObjCPropertyDecl>(ND);
1114 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1117 ND = ClassTemplate->getTemplatedDecl();
1123 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1124 return isa<EnumDecl>(ND);
1128 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1131 ND = ClassTemplate->getTemplatedDecl();
1134 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1143 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1146 ND = ClassTemplate->getTemplatedDecl();
1148 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1155 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1156 return isa<NamespaceDecl>(ND);
1161 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1166 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1168 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1174 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1176 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1177 isa<ObjCPropertyDecl>(ND);
1183 case Type::ObjCObject:
1184 case Type::ObjCInterface:
1185 case Type::ObjCObjectPointer:
1189 switch (cast<BuiltinType>(T)->getKind()) {
1190 case BuiltinType::ObjCId:
1191 case BuiltinType::ObjCClass:
1192 case BuiltinType::ObjCSel:
1213 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1222 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const {
1223 if (IsObjCMessageReceiver(ND))
1233 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1234 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1235 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1248 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1254 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1255 return isa<ObjCIvarDecl>(ND);
1262 ResultBuilder &Results;
1266 CodeCompletionDeclConsumer(ResultBuilder &Results,
DeclContext *CurContext)
1267 : Results(Results), CurContext(CurContext) { }
1270 bool InBaseClass)
override {
1271 bool Accessible =
true;
1273 Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
1277 Results.AddResult(Result, CurContext, Hiding, InBaseClass);
1284 ResultBuilder &Results) {
1286 Results.AddResult(Result(
"short",
CCP_Type));
1287 Results.AddResult(Result(
"long",
CCP_Type));
1288 Results.AddResult(Result(
"signed",
CCP_Type));
1289 Results.AddResult(Result(
"unsigned",
CCP_Type));
1290 Results.AddResult(Result(
"void",
CCP_Type));
1291 Results.AddResult(Result(
"char",
CCP_Type));
1292 Results.AddResult(Result(
"int",
CCP_Type));
1293 Results.AddResult(Result(
"float",
CCP_Type));
1294 Results.AddResult(Result(
"double",
CCP_Type));
1295 Results.AddResult(Result(
"enum",
CCP_Type));
1296 Results.AddResult(Result(
"struct",
CCP_Type));
1297 Results.AddResult(Result(
"union",
CCP_Type));
1298 Results.AddResult(Result(
"const",
CCP_Type));
1299 Results.AddResult(Result(
"volatile",
CCP_Type));
1303 Results.AddResult(Result(
"_Complex",
CCP_Type));
1304 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1305 Results.AddResult(Result(
"_Bool",
CCP_Type));
1306 Results.AddResult(Result(
"restrict",
CCP_Type));
1310 Results.getCodeCompletionTUInfo());
1311 if (LangOpts.CPlusPlus) {
1313 Results.AddResult(Result(
"bool",
CCP_Type +
1315 Results.AddResult(Result(
"class",
CCP_Type));
1316 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1319 Builder.AddTypedTextChunk(
"typename");
1321 Builder.AddPlaceholderChunk(
"qualifier");
1323 Builder.AddPlaceholderChunk(
"name");
1324 Results.AddResult(Result(
Builder.TakeString()));
1326 if (LangOpts.CPlusPlus11) {
1327 Results.AddResult(Result(
"auto",
CCP_Type));
1328 Results.AddResult(Result(
"char16_t",
CCP_Type));
1329 Results.AddResult(Result(
"char32_t",
CCP_Type));
1331 Builder.AddTypedTextChunk(
"decltype");
1333 Builder.AddPlaceholderChunk(
"expression");
1335 Results.AddResult(Result(
Builder.TakeString()));
1340 if (LangOpts.GNUMode) {
1346 Builder.AddTypedTextChunk(
"typeof");
1348 Builder.AddPlaceholderChunk(
"expression");
1349 Results.AddResult(Result(
Builder.TakeString()));
1351 Builder.AddTypedTextChunk(
"typeof");
1353 Builder.AddPlaceholderChunk(
"type");
1355 Results.AddResult(Result(
Builder.TakeString()));
1359 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1360 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1361 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1366 ResultBuilder &Results) {
1371 Results.AddResult(Result(
"extern"));
1372 Results.AddResult(Result(
"static"));
1377 ResultBuilder &Results) {
1382 if (LangOpts.CPlusPlus) {
1383 Results.AddResult(Result(
"explicit"));
1384 Results.AddResult(Result(
"friend"));
1385 Results.AddResult(Result(
"mutable"));
1386 Results.AddResult(Result(
"virtual"));
1394 if (LangOpts.CPlusPlus || LangOpts.C99)
1395 Results.AddResult(Result(
"inline"));
1414 ResultBuilder &Results,
1417 ResultBuilder &Results,
1420 ResultBuilder &Results,
1426 Results.getCodeCompletionTUInfo());
1427 Builder.AddTypedTextChunk(
"typedef");
1429 Builder.AddPlaceholderChunk(
"type");
1431 Builder.AddPlaceholderChunk(
"name");
1452 return LangOpts.CPlusPlus;
1459 return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
1462 llvm_unreachable(
"Invalid ParserCompletionContext!");
1490 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1491 return BT->getNameAsCString(Policy);
1494 if (
const TagType *TagT = dyn_cast<TagType>(T))
1495 if (
TagDecl *Tag = TagT->getDecl())
1496 if (!Tag->hasNameForLinkage()) {
1497 switch (Tag->getTagKind()) {
1498 case TTK_Struct:
return "struct <anonymous>";
1500 case TTK_Class:
return "class <anonymous>";
1501 case TTK_Union:
return "union <anonymous>";
1502 case TTK_Enum:
return "enum <anonymous>";
1526 Builder.AddTypedTextChunk(
"this");
1534 ResultBuilder &Results) {
1542 if (Results.includeCodePatterns()) {
1544 Builder.AddTypedTextChunk(
"namespace");
1546 Builder.AddPlaceholderChunk(
"identifier");
1548 Builder.AddPlaceholderChunk(
"declarations");
1551 Results.AddResult(Result(
Builder.TakeString()));
1555 Builder.AddTypedTextChunk(
"namespace");
1557 Builder.AddPlaceholderChunk(
"name");
1559 Builder.AddPlaceholderChunk(
"namespace");
1560 Results.AddResult(Result(
Builder.TakeString()));
1563 Builder.AddTypedTextChunk(
"using");
1565 Builder.AddTextChunk(
"namespace");
1567 Builder.AddPlaceholderChunk(
"identifier");
1568 Results.AddResult(Result(
Builder.TakeString()));
1571 Builder.AddTypedTextChunk(
"asm");
1573 Builder.AddPlaceholderChunk(
"string-literal");
1575 Results.AddResult(Result(
Builder.TakeString()));
1577 if (Results.includeCodePatterns()) {
1579 Builder.AddTypedTextChunk(
"template");
1581 Builder.AddPlaceholderChunk(
"declaration");
1582 Results.AddResult(Result(
Builder.TakeString()));
1595 Builder.AddTypedTextChunk(
"using");
1597 Builder.AddPlaceholderChunk(
"qualifier");
1599 Builder.AddPlaceholderChunk(
"name");
1600 Results.AddResult(Result(
Builder.TakeString()));
1604 Builder.AddTypedTextChunk(
"using");
1606 Builder.AddTextChunk(
"typename");
1608 Builder.AddPlaceholderChunk(
"qualifier");
1610 Builder.AddPlaceholderChunk(
"name");
1611 Results.AddResult(Result(
Builder.TakeString()));
1618 Builder.AddTypedTextChunk(
"public");
1619 if (Results.includeCodePatterns())
1621 Results.AddResult(Result(
Builder.TakeString()));
1624 Builder.AddTypedTextChunk(
"protected");
1625 if (Results.includeCodePatterns())
1627 Results.AddResult(Result(
Builder.TakeString()));
1630 Builder.AddTypedTextChunk(
"private");
1631 if (Results.includeCodePatterns())
1633 Results.AddResult(Result(
Builder.TakeString()));
1640 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1642 Builder.AddTypedTextChunk(
"template");
1644 Builder.AddPlaceholderChunk(
"parameters");
1646 Results.AddResult(Result(
Builder.TakeString()));
1673 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1675 Builder.AddTypedTextChunk(
"try");
1677 Builder.AddPlaceholderChunk(
"statements");
1680 Builder.AddTextChunk(
"catch");
1682 Builder.AddPlaceholderChunk(
"declaration");
1685 Builder.AddPlaceholderChunk(
"statements");
1688 Results.AddResult(Result(
Builder.TakeString()));
1693 if (Results.includeCodePatterns()) {
1695 Builder.AddTypedTextChunk(
"if");
1698 Builder.AddPlaceholderChunk(
"condition");
1700 Builder.AddPlaceholderChunk(
"expression");
1703 Builder.AddPlaceholderChunk(
"statements");
1706 Results.AddResult(Result(
Builder.TakeString()));
1709 Builder.AddTypedTextChunk(
"switch");
1712 Builder.AddPlaceholderChunk(
"condition");
1714 Builder.AddPlaceholderChunk(
"expression");
1719 Results.AddResult(Result(
Builder.TakeString()));
1725 Builder.AddTypedTextChunk(
"case");
1727 Builder.AddPlaceholderChunk(
"expression");
1729 Results.AddResult(Result(
Builder.TakeString()));
1732 Builder.AddTypedTextChunk(
"default");
1734 Results.AddResult(Result(
Builder.TakeString()));
1737 if (Results.includeCodePatterns()) {
1739 Builder.AddTypedTextChunk(
"while");
1742 Builder.AddPlaceholderChunk(
"condition");
1744 Builder.AddPlaceholderChunk(
"expression");
1747 Builder.AddPlaceholderChunk(
"statements");
1750 Results.AddResult(Result(
Builder.TakeString()));
1753 Builder.AddTypedTextChunk(
"do");
1755 Builder.AddPlaceholderChunk(
"statements");
1758 Builder.AddTextChunk(
"while");
1760 Builder.AddPlaceholderChunk(
"expression");
1762 Results.AddResult(Result(
Builder.TakeString()));
1765 Builder.AddTypedTextChunk(
"for");
1768 Builder.AddPlaceholderChunk(
"init-statement");
1770 Builder.AddPlaceholderChunk(
"init-expression");
1772 Builder.AddPlaceholderChunk(
"condition");
1774 Builder.AddPlaceholderChunk(
"inc-expression");
1778 Builder.AddPlaceholderChunk(
"statements");
1781 Results.AddResult(Result(
Builder.TakeString()));
1786 Builder.AddTypedTextChunk(
"continue");
1787 Results.AddResult(Result(
Builder.TakeString()));
1792 Builder.AddTypedTextChunk(
"break");
1793 Results.AddResult(Result(
Builder.TakeString()));
1798 bool isVoid =
false;
1800 isVoid = Function->getReturnType()->isVoidType();
1802 = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1803 isVoid = Method->getReturnType()->isVoidType();
1807 Builder.AddTypedTextChunk(
"return");
1810 Builder.AddPlaceholderChunk(
"expression");
1812 Results.AddResult(Result(
Builder.TakeString()));
1815 Builder.AddTypedTextChunk(
"goto");
1817 Builder.AddPlaceholderChunk(
"label");
1818 Results.AddResult(Result(
Builder.TakeString()));
1821 Builder.AddTypedTextChunk(
"using");
1823 Builder.AddTextChunk(
"namespace");
1825 Builder.AddPlaceholderChunk(
"identifier");
1826 Results.AddResult(Result(
Builder.TakeString()));
1839 Builder.AddTypedTextChunk(
"__bridge");
1841 Builder.AddPlaceholderChunk(
"type");
1843 Builder.AddPlaceholderChunk(
"expression");
1844 Results.AddResult(Result(
Builder.TakeString()));
1847 Builder.AddTypedTextChunk(
"__bridge_transfer");
1849 Builder.AddPlaceholderChunk(
"Objective-C type");
1851 Builder.AddPlaceholderChunk(
"expression");
1852 Results.AddResult(Result(
Builder.TakeString()));
1855 Builder.AddTypedTextChunk(
"__bridge_retained");
1857 Builder.AddPlaceholderChunk(
"CF type");
1859 Builder.AddPlaceholderChunk(
"expression");
1860 Results.AddResult(Result(
Builder.TakeString()));
1870 Builder.AddResultTypeChunk(
"bool");
1871 Builder.AddTypedTextChunk(
"true");
1872 Results.AddResult(Result(
Builder.TakeString()));
1875 Builder.AddResultTypeChunk(
"bool");
1876 Builder.AddTypedTextChunk(
"false");
1877 Results.AddResult(Result(
Builder.TakeString()));
1881 Builder.AddTypedTextChunk(
"dynamic_cast");
1883 Builder.AddPlaceholderChunk(
"type");
1886 Builder.AddPlaceholderChunk(
"expression");
1888 Results.AddResult(Result(
Builder.TakeString()));
1892 Builder.AddTypedTextChunk(
"static_cast");
1894 Builder.AddPlaceholderChunk(
"type");
1897 Builder.AddPlaceholderChunk(
"expression");
1899 Results.AddResult(Result(
Builder.TakeString()));
1902 Builder.AddTypedTextChunk(
"reinterpret_cast");
1904 Builder.AddPlaceholderChunk(
"type");
1907 Builder.AddPlaceholderChunk(
"expression");
1909 Results.AddResult(Result(
Builder.TakeString()));
1912 Builder.AddTypedTextChunk(
"const_cast");
1914 Builder.AddPlaceholderChunk(
"type");
1917 Builder.AddPlaceholderChunk(
"expression");
1919 Results.AddResult(Result(
Builder.TakeString()));
1923 Builder.AddResultTypeChunk(
"std::type_info");
1924 Builder.AddTypedTextChunk(
"typeid");
1926 Builder.AddPlaceholderChunk(
"expression-or-type");
1928 Results.AddResult(Result(
Builder.TakeString()));
1932 Builder.AddTypedTextChunk(
"new");
1934 Builder.AddPlaceholderChunk(
"type");
1936 Builder.AddPlaceholderChunk(
"expressions");
1938 Results.AddResult(Result(
Builder.TakeString()));
1941 Builder.AddTypedTextChunk(
"new");
1943 Builder.AddPlaceholderChunk(
"type");
1945 Builder.AddPlaceholderChunk(
"size");
1948 Builder.AddPlaceholderChunk(
"expressions");
1950 Results.AddResult(Result(
Builder.TakeString()));
1953 Builder.AddResultTypeChunk(
"void");
1954 Builder.AddTypedTextChunk(
"delete");
1956 Builder.AddPlaceholderChunk(
"expression");
1957 Results.AddResult(Result(
Builder.TakeString()));
1960 Builder.AddResultTypeChunk(
"void");
1961 Builder.AddTypedTextChunk(
"delete");
1966 Builder.AddPlaceholderChunk(
"expression");
1967 Results.AddResult(Result(
Builder.TakeString()));
1971 Builder.AddResultTypeChunk(
"void");
1972 Builder.AddTypedTextChunk(
"throw");
1974 Builder.AddPlaceholderChunk(
"expression");
1975 Results.AddResult(Result(
Builder.TakeString()));
1982 Builder.AddResultTypeChunk(
"std::nullptr_t");
1983 Builder.AddTypedTextChunk(
"nullptr");
1984 Results.AddResult(Result(
Builder.TakeString()));
1987 Builder.AddResultTypeChunk(
"size_t");
1988 Builder.AddTypedTextChunk(
"alignof");
1990 Builder.AddPlaceholderChunk(
"type");
1992 Results.AddResult(Result(
Builder.TakeString()));
1995 Builder.AddResultTypeChunk(
"bool");
1996 Builder.AddTypedTextChunk(
"noexcept");
1998 Builder.AddPlaceholderChunk(
"expression");
2000 Results.AddResult(Result(
Builder.TakeString()));
2003 Builder.AddResultTypeChunk(
"size_t");
2004 Builder.AddTypedTextChunk(
"sizeof...");
2006 Builder.AddPlaceholderChunk(
"parameter-pack");
2008 Results.AddResult(Result(
Builder.TakeString()));
2017 if (
ID->getSuperClass()) {
2018 std::string SuperType;
2019 SuperType =
ID->getSuperClass()->getNameAsString();
2020 if (Method->isInstanceMethod())
2024 Builder.AddTypedTextChunk(
"super");
2025 Results.AddResult(Result(
Builder.TakeString()));
2034 Builder.AddResultTypeChunk(
"size_t");
2036 Builder.AddTypedTextChunk(
"alignof");
2038 Builder.AddTypedTextChunk(
"_Alignof");
2040 Builder.AddPlaceholderChunk(
"type");
2042 Results.AddResult(Result(
Builder.TakeString()));
2046 Builder.AddResultTypeChunk(
"size_t");
2047 Builder.AddTypedTextChunk(
"sizeof");
2049 Builder.AddPlaceholderChunk(
"expression-or-type");
2051 Results.AddResult(Result(
Builder.TakeString()));
2064 Results.AddResult(Result(
"operator"));
2079 if (isa<CXXConstructorDecl>(ND) || isa<CXXConversionDecl>(ND))
2084 if (
const FunctionDecl *Function = ND->getAsFunction())
2085 T = Function->getReturnType();
2086 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2088 T = Method->getSendResultType(BaseType);
2090 T = Method->getReturnType();
2091 }
else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
2092 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2093 else if (isa<UnresolvedUsingValueDecl>(ND)) {
2095 }
else if (
const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2097 T = Ivar->getUsageType(BaseType);
2099 T = Ivar->getType();
2101 T =
Value->getType();
2104 T =
Property->getUsageType(BaseType);
2119 if (SentinelAttr *Sentinel = FunctionOrMethod->getAttr<SentinelAttr>())
2120 if (Sentinel->getSentinel() == 0) {
2133 if (ObjCQuals & Decl::OBJC_TQ_In)
2135 else if (ObjCQuals & Decl::OBJC_TQ_Inout)
2137 else if (ObjCQuals & Decl::OBJC_TQ_Out)
2139 if (ObjCQuals & Decl::OBJC_TQ_Bycopy)
2140 Result +=
"bycopy ";
2141 else if (ObjCQuals & Decl::OBJC_TQ_Byref)
2143 if (ObjCQuals & Decl::OBJC_TQ_Oneway)
2144 Result +=
"oneway ";
2145 if (ObjCQuals & Decl::OBJC_TQ_CSNullability) {
2147 switch (*nullability) {
2149 Result +=
"nonnull ";
2153 Result +=
"nullable ";
2157 Result +=
"null_unspecified ";
2167 bool SuppressName =
false,
2168 bool SuppressBlock =
false,
2169 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2170 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->getDeclContext());
2177 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2184 if (ObjCMethodParam) {
2205 if (!SuppressBlock) {
2208 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2221 TL = AttrTL.getModifiedLoc();
2246 if (ObjCMethodParam) {
2249 Result += Type.
getAsString(Policy) + Result +
")";
2267 if (!ResultType->
isVoidType() || SuppressBlock)
2279 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++
I) {
2293 if (SuppressBlock) {
2295 Result = Result +
" (^";
2302 Result =
'^' + Result;
2318 bool InOptional =
false) {
2319 bool FirstParameter =
true;
2329 if (!FirstParameter)
2337 FirstParameter =
false;
2347 PlaceholderStr +=
", ...";
2356 if (Proto->isVariadic()) {
2357 if (Proto->getNumParams() == 0)
2369 unsigned MaxParameters = 0,
2371 bool InDefaultArg =
false) {
2372 bool FirstParameter =
true;
2376 Template = cast<TemplateDecl>(Template->getCanonicalDecl());
2381 PEnd = Params->begin() + MaxParameters;
2384 bool HasDefaultArg =
false;
2385 std::string PlaceholderStr;
2387 if (TTP->wasDeclaredWithTypename())
2388 PlaceholderStr =
"typename";
2390 PlaceholderStr =
"class";
2392 if (TTP->getIdentifier()) {
2393 PlaceholderStr +=
' ';
2397 HasDefaultArg = TTP->hasDefaultArgument();
2399 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2400 if (NTTP->getIdentifier())
2401 PlaceholderStr = NTTP->getIdentifier()->getName();
2402 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2403 HasDefaultArg = NTTP->hasDefaultArgument();
2405 assert(isa<TemplateTemplateParmDecl>(*
P));
2410 PlaceholderStr =
"template<...> class";
2412 PlaceholderStr +=
' ';
2419 if (HasDefaultArg && !InDefaultArg) {
2424 if (!FirstParameter)
2427 P - Params->begin(),
true);
2432 InDefaultArg =
false;
2435 FirstParameter =
false;
2450 bool QualifierIsInformative,
2456 std::string PrintedNNS;
2458 llvm::raw_string_ostream OS(PrintedNNS);
2459 Qualifier->
print(OS, Policy);
2461 if (QualifierIsInformative)
2494 std::string QualsStr;
2496 QualsStr +=
" const";
2498 QualsStr +=
" volatile";
2500 QualsStr +=
" restrict";
2514 const char *OperatorName =
nullptr;
2517 case OO_Conditional:
2519 OperatorName =
"operator";
2522 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2523 case OO_##Name: OperatorName = "operator" Spelling; break;
2524 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2525 #include "clang/Basic/OperatorKinds.def"
2527 case OO_New: OperatorName =
"operator new";
break;
2528 case OO_Delete: OperatorName =
"operator delete";
break;
2529 case OO_Array_New: OperatorName =
"operator new[]";
break;
2530 case OO_Array_Delete: OperatorName =
"operator delete[]";
break;
2531 case OO_Call: OperatorName =
"operator()";
break;
2532 case OO_Subscript: OperatorName =
"operator[]";
break;
2556 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2559 Record = InjectedTy->getDecl();
2582 bool IncludeBriefComments) {
2583 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2584 CCTUInfo, IncludeBriefComments);
2599 bool IncludeBriefComments) {
2603 if (
Kind == RK_Pattern) {
2604 Pattern->Priority = Priority;
2605 Pattern->Availability = Availability;
2616 if (M->isPropertyAccessor())
2618 if (PDecl->getGetterName() == M->getSelector() &&
2619 PDecl->getIdentifier() != M->getIdentifier()) {
2636 if (
Kind == RK_Keyword) {
2641 if (
Kind == RK_Macro) {
2684 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2688 if (IncludeBriefComments) {
2693 else if (
const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
2694 if (OMD->isPropertyAccessor())
2700 if (StartsNestedNameSpecifier) {
2707 for (
const auto *I : ND->specific_attrs<AnnotateAttr>())
2712 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
2731 llvm::SmallBitVector Deduced;
2733 unsigned LastDeducibleArgument;
2734 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
2735 --LastDeducibleArgument) {
2736 if (!Deduced[LastDeducibleArgument - 1]) {
2740 bool HasDefaultArg =
false;
2741 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
2742 LastDeducibleArgument - 1);
2744 HasDefaultArg = TTP->hasDefaultArgument();
2746 = dyn_cast<NonTypeTemplateParmDecl>(Param))
2747 HasDefaultArg = NTTP->hasDefaultArgument();
2749 assert(isa<TemplateTemplateParmDecl>(Param));
2751 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
2759 if (LastDeducibleArgument) {
2765 LastDeducibleArgument);
2777 if (
const TemplateDecl *Template = dyn_cast<TemplateDecl>(ND)) {
2788 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2789 Selector Sel = Method->getSelector();
2798 if (StartParameter == 0)
2805 if (Method->param_size() == 1)
2810 PEnd = Method->param_end();
2811 P != PEnd; (void)++
P, ++Idx) {
2813 std::string Keyword;
2814 if (Idx > StartParameter)
2817 Keyword += II->getName();
2819 if (Idx < StartParameter || AllParametersAreInformative)
2826 if (Idx < StartParameter)
2830 QualType ParamType = (*P)->getType();
2847 if (DeclaringEntity || AllParametersAreInformative)
2848 Arg += II->getName();
2851 if (Method->isVariadic() && (
P + 1) == PEnd)
2854 if (DeclaringEntity)
2856 else if (AllParametersAreInformative)
2862 if (Method->isVariadic()) {
2863 if (Method->param_size() == 0) {
2864 if (DeclaringEntity)
2866 else if (AllParametersAreInformative)
2894 unsigned CurrentArg,
2896 bool InOptional =
false) {
2897 bool FirstParameter =
true;
2898 unsigned NumParams = Function ? Function->
getNumParams()
2901 for (
unsigned P = Start;
P != NumParams; ++
P) {
2907 if (!FirstParameter)
2911 CurrentArg,
P,
true);
2917 FirstParameter =
false;
2924 std::string Placeholder;
2930 if (
P == CurrentArg)
2940 if (!FirstParameter)
2943 if (CurrentArg < NumParams)
2944 Opt.AddPlaceholderChunk(
"...");
2946 Opt.AddCurrentParameterChunk(
"...");
2954 unsigned CurrentArg,
Sema &
S,
2957 bool IncludeBriefComments)
const {
2965 if (!FDecl && !Proto) {
2978 if (IncludeBriefComments && CurrentArg < FDecl->getNumParams())
2996 return Result.TakeString();
3001 bool PreferredTypeIsPointer) {
3005 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3006 MacroName.equals(
"Nil")) {
3008 if (PreferredTypeIsPointer)
3012 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3013 MacroName.equals(
"true") || MacroName.equals(
"false"))
3016 else if (MacroName.equals(
"bool"))
3027 switch (D->getKind()) {
3031 case Decl::Function:
3039 case Decl::ObjCMethod:
3061 case Decl::ClassTemplatePartialSpecialization:
3068 case Decl::UnresolvedUsingValue:
3069 case Decl::UnresolvedUsingTypename:
3072 case Decl::ObjCPropertyImpl:
3073 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3087 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3088 switch (TD->getTagKind()) {
3102 bool IncludeUndefined,
3103 bool TargetTypeIsPointer =
false) {
3106 Results.EnterNewScope();
3112 if (IncludeUndefined || MD) {
3114 if (MI->isUsedForHeaderGuard())
3117 Results.AddResult(Result(M->first,
3120 TargetTypeIsPointer)));
3124 Results.ExitScope();
3129 ResultBuilder &Results) {
3132 Results.EnterNewScope();
3134 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3135 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3136 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3138 Results.ExitScope();
3145 unsigned NumResults) {
3203 llvm_unreachable(
"Invalid ParserCompletionContext!");
3215 ResultBuilder &Results) {
3218 while (isa<BlockDecl>(CurContext))
3229 if (!
P->getDeclName())
3237 Results.getCodeCompletionTUInfo());
3246 Overridden->getDeclContext());
3249 llvm::raw_string_ostream OS(Str);
3250 NNS->
print(OS, Policy);
3251 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3253 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3256 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
3257 Overridden->getNameAsString()));
3259 bool FirstParam =
true;
3267 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3275 Results.Ignore(Overridden);
3282 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3283 CodeCompleter->getCodeCompletionTUInfo(),
3285 Results.EnterNewScope();
3293 PP.getHeaderSearchInfo().collectAllModules(Modules);
3294 for (
unsigned I = 0, N = Modules.size(); I != N; ++
I) {
3296 Builder.getAllocator().CopyString(Modules[I]->
Name));
3297 Results.AddResult(Result(
Builder.TakeString(),
3300 Modules[
I]->isAvailable()
3304 }
else if (getLangOpts().Modules) {
3306 Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path,
3313 Sub != SubEnd; ++Sub) {
3316 Builder.getAllocator().CopyString((*Sub)->Name));
3317 Results.AddResult(Result(
Builder.TakeString(),
3320 (*Sub)->isAvailable()
3326 Results.ExitScope();
3328 Results.data(),Results.size());
3333 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3334 CodeCompleter->getCodeCompletionTUInfo(),
3336 Results.EnterNewScope();
3341 switch (CompletionContext) {
3344 case PCC_ObjCInterface:
3345 case PCC_ObjCImplementation:
3346 case PCC_ObjCInstanceVariableList:
3348 case PCC_MemberTemplate:
3350 case PCC_LocalDeclarationSpecifiers:
3351 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3355 case PCC_ParenthesizedExpression:
3356 case PCC_Expression:
3360 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3362 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3368 case PCC_RecoveryInFunction:
3375 if (
CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
3376 if (CurMethod->isInstance())
3377 Results.setObjectTypeQualifiers(
3380 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3382 CodeCompleter->includeGlobals());
3385 Results.ExitScope();
3387 switch (CompletionContext) {
3388 case PCC_ParenthesizedExpression:
3389 case PCC_Expression:
3391 case PCC_RecoveryInFunction:
3398 case PCC_ObjCInterface:
3399 case PCC_ObjCImplementation:
3400 case PCC_ObjCInstanceVariableList:
3402 case PCC_MemberTemplate:
3406 case PCC_LocalDeclarationSpecifiers:
3410 if (CodeCompleter->includeMacros())
3414 Results.data(),Results.size());
3420 bool AtArgumentExpression,
3422 ResultBuilder &Results);
3425 bool AllowNonIdentifiers,
3426 bool AllowNestedNameSpecifiers) {
3428 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3429 CodeCompleter->getCodeCompletionTUInfo(),
3430 AllowNestedNameSpecifiers
3433 Results.EnterNewScope();
3436 Results.AddResult(Result(
"const"));
3437 Results.AddResult(Result(
"volatile"));
3438 if (getLangOpts().
C99)
3439 Results.AddResult(Result(
"restrict"));
3442 if (AllowNonIdentifiers) {
3443 Results.AddResult(Result(
"operator"));
3447 if (AllowNestedNameSpecifiers) {
3448 Results.allowNestedNameSpecifiers();
3449 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3450 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3452 CodeCompleter->includeGlobals());
3453 Results.setFilter(
nullptr);
3456 Results.ExitScope();
3462 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3482 Results.getCompletionContext(),
3483 Results.data(), Results.size());
3488 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3489 ObjCCollection(
false) { }
3501 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3502 CodeCompleter->getCodeCompletionTUInfo(),
3505 Results.setFilter(&ResultBuilder::IsObjCCollection);
3507 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3509 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3511 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3517 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++
I)
3520 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3522 CodeCompleter->includeGlobals());
3524 Results.EnterNewScope();
3526 Results.ExitScope();
3528 bool PreferredTypeIsPointer =
false;
3539 if (CodeCompleter->includeMacros())
3544 Results.data(),Results.size());
3549 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3550 else if (getLangOpts().ObjC1)
3551 CodeCompleteObjCInstanceMessage(S, E.
get(),
None,
false);
3561 if (Interface->hasDefinition())
3562 return Interface->getDefinition();
3568 if (Protocol->hasDefinition())
3569 return Protocol->getDefinition();
3578 bool AllowCategories,
3579 bool AllowNullaryMethods,
3582 ResultBuilder &Results) {
3590 if (AddedProperties.insert(
P->getIdentifier()).second)
3591 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3595 if (AllowNullaryMethods) {
3596 ASTContext &Context = Container->getASTContext();
3598 for (
auto *M : Container->
methods()) {
3599 if (M->getSelector().isUnarySelector())
3601 if (AddedProperties.insert(
Name).second) {
3603 Results.getCodeCompletionTUInfo());
3607 Results.getAllocator().CopyString(
Name->
getName()));
3609 Results.MaybeAddResult(Result(
Builder.TakeString(), M,
3619 for (
auto *
P : Protocol->protocols())
3621 CurContext, AddedProperties, Results);
3623 if (AllowCategories) {
3625 for (
auto *Cat : IFace->known_categories())
3627 CurContext, AddedProperties, Results);
3631 for (
auto *I : IFace->all_referenced_protocols())
3633 CurContext, AddedProperties, Results);
3636 if (IFace->getSuperClass())
3638 AllowNullaryMethods, CurContext,
3639 AddedProperties, Results);
3641 = dyn_cast<ObjCCategoryDecl>(Container)) {
3645 CurContext, AddedProperties, Results);
3652 if (!Base || !CodeCompleter)
3655 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
3658 Base = ConvertedBase.
get();
3689 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3690 CodeCompleter->getCodeCompletionTUInfo(),
3692 &ResultBuilder::IsMember);
3693 Results.EnterNewScope();
3700 Results.allowNestedNameSpecifiers();
3701 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3703 CodeCompleter->includeGlobals());
3705 if (getLangOpts().CPlusPlus) {
3706 if (!Results.empty()) {
3712 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
3720 Results.AddResult(Result(
"template"));
3730 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
3733 AddedProperties, Results);
3736 for (
auto *I : ObjCPtr->
quals())
3738 CurContext, AddedProperties, Results);
3745 Class = ObjCPtr->getInterfaceDecl();
3751 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3752 Results.setFilter(&ResultBuilder::IsObjCIvar);
3754 CodeCompleter->includeGlobals());
3760 Results.ExitScope();
3764 Results.getCompletionContext(),
3765 Results.data(),Results.size());
3772 ResultBuilder::LookupFilter Filter =
nullptr;
3777 Filter = &ResultBuilder::IsEnum;
3782 Filter = &ResultBuilder::IsUnion;
3789 Filter = &ResultBuilder::IsClassOrStruct;
3794 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
3797 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3798 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
3799 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3802 Results.setFilter(Filter);
3804 CodeCompleter->includeGlobals());
3806 if (CodeCompleter->includeGlobals()) {
3808 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
3813 Results.data(),Results.size());
3817 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3818 CodeCompleter->getCodeCompletionTUInfo(),
3820 Results.EnterNewScope();
3822 Results.AddResult(
"const");
3824 Results.AddResult(
"volatile");
3825 if (getLangOpts().
C99 &&
3827 Results.AddResult(
"restrict");
3828 if (getLangOpts().
C11 &&
3830 Results.AddResult(
"_Atomic");
3831 if (getLangOpts().MSVCCompat &&
3833 Results.AddResult(
"__unaligned");
3834 Results.ExitScope();
3836 Results.getCompletionContext(),
3837 Results.data(), Results.size());
3841 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
3845 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
3848 SwitchStmt *Switch = getCurFunction()->SwitchStack.back();
3853 CodeCompleteExpression(S, Data);
3867 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
3876 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseVal))
3878 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
3885 EnumeratorsSeen.insert(Enumerator);
3898 Qualifier = DRE->getQualifier();
3902 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
3910 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3911 CodeCompleter->getCodeCompletionTUInfo(),
3913 Results.EnterNewScope();
3915 if (EnumeratorsSeen.count(
E))
3919 Results.AddResult(R, CurContext,
nullptr,
false);
3921 Results.ExitScope();
3926 if (CodeCompleter->includeMacros()) {
3933 Results.data(),Results.size());
3937 if (Args.size() && !Args.data())
3940 for (
unsigned I = 0; I != Args.size(); ++
I)
3953 if (!CandidateSet.
empty()) {
3956 CandidateSet.
begin(), CandidateSet.
end(),
3962 for (
auto &Candidate : CandidateSet)
3963 if (Candidate.Viable)
3971 ArrayRef<ResultCandidate> Candidates,
3978 for (
auto &Candidate : Candidates) {
3979 if (
auto FType = Candidate.getFunctionType())
3980 if (
auto Proto = dyn_cast<FunctionProtoType>(FType))
3981 if (N < Proto->getNumParams()) {
3983 ParamType = Proto->getParamType(N);
3986 Proto->getParamType(N).getNonReferenceType()))
3997 unsigned CurrentArg,
3998 bool CompleteExpressionWithCurrentArg =
true) {
4000 if (CompleteExpressionWithCurrentArg)
4001 ParamType =
getParamType(SemaRef, Candidates, CurrentArg);
4008 if (!Candidates.empty())
4028 CodeCompleteOrdinaryName(S, PCC_Expression);
4039 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4040 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4042 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4044 if (UME->hasExplicitTemplateArgs()) {
4045 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4046 TemplateArgs = &TemplateArgsBuffer;
4049 ArgExprs.append(Args.begin(), Args.end());
4051 Decls.
append(UME->decls_begin(), UME->decls_end());
4052 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4057 if (
auto MCE = dyn_cast<MemberExpr>(NakedFn))
4059 else if (
auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
4060 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4062 if (!getLangOpts().CPlusPlus ||
4075 if (isCompleteType(Loc, NakedFn->
getType())) {
4078 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4079 LookupQualifiedName(R, DC);
4082 ArgExprs.append(Args.begin(), Args.end());
4096 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4108 !CandidateSet.
empty());
4117 if (!isCompleteType(Loc, Type))
4122 CodeCompleteExpression(S, Type);
4131 for (
auto C : LookupConstructors(RD)) {
4132 if (
auto FD = dyn_cast<FunctionDecl>(C)) {
4137 }
else if (
auto FTD = dyn_cast<FunctionTemplateDecl>(C)) {
4138 AddTemplateOverloadCandidate(FTD,
4153 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4155 CodeCompleteOrdinaryName(S, PCC_Expression);
4159 CodeCompleteExpression(S, VD->
getType());
4164 if (isa<BlockDecl>(CurContext)) {
4166 ResultType = BSI->ReturnType;
4167 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
4168 ResultType = Function->getReturnType();
4169 else if (
ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4170 ResultType = Method->getReturnType();
4173 CodeCompleteOrdinaryName(S, PCC_Expression);
4175 CodeCompleteExpression(S, ResultType);
4179 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4180 CodeCompleter->getCodeCompletionTUInfo(),
4182 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4183 Results.EnterNewScope();
4185 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4187 CodeCompleter->includeGlobals());
4193 Results.getCodeCompletionTUInfo());
4194 Builder.AddTypedTextChunk(
"else");
4195 if (Results.includeCodePatterns()) {
4199 Builder.AddPlaceholderChunk(
"statements");
4203 Results.AddResult(
Builder.TakeString());
4206 Builder.AddTypedTextChunk(
"else");
4212 Builder.AddPlaceholderChunk(
"condition");
4214 Builder.AddPlaceholderChunk(
"expression");
4216 if (Results.includeCodePatterns()) {
4220 Builder.AddPlaceholderChunk(
"statements");
4224 Results.AddResult(
Builder.TakeString());
4226 Results.ExitScope();
4231 if (CodeCompleter->includeMacros())
4235 Results.data(),Results.size());
4240 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType());
4242 CodeCompleteOrdinaryName(S, PCC_Expression);
4246 bool EnteringContext) {
4250 DeclContext *Ctx = computeDeclContext(SS, EnteringContext);
4256 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4259 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4260 CodeCompleter->getCodeCompletionTUInfo(),
4262 Results.EnterNewScope();
4268 Results.AddResult(
"template");
4275 if (!EnteringContext)
4277 Results.ExitScope();
4279 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4283 Results.getCompletionContext(),
4284 Results.data(),Results.size());
4291 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4292 CodeCompleter->getCodeCompletionTUInfo(),
4294 &ResultBuilder::IsNestedNameSpecifier);
4295 Results.EnterNewScope();
4303 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4305 CodeCompleter->includeGlobals());
4306 Results.ExitScope();
4310 Results.data(),Results.size());
4319 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4320 CodeCompleter->getCodeCompletionTUInfo(),
4322 &ResultBuilder::IsNamespaceOrAlias);
4323 Results.EnterNewScope();
4324 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4326 CodeCompleter->includeGlobals());
4327 Results.ExitScope();
4330 Results.data(),Results.size());
4341 bool SuppressedGlobalResults
4342 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
4344 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4345 CodeCompleter->getCodeCompletionTUInfo(),
4346 SuppressedGlobalResults
4349 &ResultBuilder::IsNamespace);
4351 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
4356 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
4360 OrigToLatest[NS->getOriginalNamespace()] = *NS;
4364 Results.EnterNewScope();
4366 NS = OrigToLatest.begin(),
4367 NSEnd = OrigToLatest.end();
4370 NS->second, Results.getBasePriority(NS->second),
4372 CurContext,
nullptr,
false);
4373 Results.ExitScope();
4377 Results.getCompletionContext(),
4378 Results.data(),Results.size());
4386 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4387 CodeCompleter->getCodeCompletionTUInfo(),
4389 &ResultBuilder::IsNamespaceOrAlias);
4390 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4392 CodeCompleter->includeGlobals());
4394 Results.getCompletionContext(),
4395 Results.data(),Results.size());
4403 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4404 CodeCompleter->getCodeCompletionTUInfo(),
4406 &ResultBuilder::IsType);
4407 Results.EnterNewScope();
4410 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
4411 if (std::strcmp(Spelling, "?")) \
4412 Results.AddResult(Result(Spelling));
4413 #include "clang/Basic/OperatorKinds.def"
4416 Results.allowNestedNameSpecifiers();
4417 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4419 CodeCompleter->includeGlobals());
4423 Results.ExitScope();
4427 Results.data(),Results.size());
4436 AdjustDeclIfTemplate(ConstructorD);
4442 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4443 CodeCompleter->getCodeCompletionTUInfo(),
4445 Results.EnterNewScope();
4448 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
4449 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
4450 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++
I) {
4451 if (Initializers[I]->isBaseInitializer())
4452 InitializedBases.insert(
4455 InitializedFields.insert(cast<FieldDecl>(
4456 Initializers[I]->getAnyMember()));
4461 Results.getCodeCompletionTUInfo());
4463 bool SawLastInitializer = Initializers.empty();
4465 for (
const auto &
Base : ClassDecl->
bases()) {
4469 = !Initializers.empty() &&
4470 Initializers.back()->isBaseInitializer() &&
4472 QualType(Initializers.back()->getBaseClass(), 0));
4477 Results.getAllocator().CopyString(
4478 Base.getType().getAsString(Policy)));
4480 Builder.AddPlaceholderChunk(
"args");
4485 SawLastInitializer =
false;
4489 for (
const auto &
Base : ClassDecl->
vbases()) {
4493 = !Initializers.empty() &&
4494 Initializers.back()->isBaseInitializer() &&
4496 QualType(Initializers.back()->getBaseClass(), 0));
4501 Builder.getAllocator().CopyString(
4502 Base.getType().getAsString(Policy)));
4504 Builder.AddPlaceholderChunk(
"args");
4509 SawLastInitializer =
false;
4513 for (
auto *Field : ClassDecl->
fields()) {
4514 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
4517 = !Initializers.empty() &&
4518 Initializers.back()->isAnyMemberInitializer() &&
4519 Initializers.back()->getAnyMember() == Field;
4523 if (!Field->getDeclName())
4527 Field->getIdentifier()->getName()));
4529 Builder.AddPlaceholderChunk(
"args");
4537 SawLastInitializer =
false;
4539 Results.ExitScope();
4542 Results.data(), Results.size());
4555 bool AfterAmpersand) {
4556 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4557 CodeCompleter->getCodeCompletionTUInfo(),
4559 Results.EnterNewScope();
4562 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
4563 bool IncludedThis =
false;
4564 for (
const auto &C : Intro.
Captures) {
4566 IncludedThis =
true;
4575 for (
const auto *D : S->
decls()) {
4576 const auto *Var = dyn_cast<
VarDecl>(D);
4579 Var->hasAttr<BlocksAttr>())
4584 CurContext,
nullptr,
false);
4592 Results.ExitScope();
4595 Results.data(), Results.size());
4600 #define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword)
4603 ResultBuilder &Results,
4610 Results.getCodeCompletionTUInfo());
4611 if (LangOpts.ObjC2) {
4615 Builder.AddPlaceholderChunk(
"property");
4616 Results.AddResult(Result(
Builder.TakeString()));
4621 Builder.AddPlaceholderChunk(
"property");
4622 Results.AddResult(Result(
Builder.TakeString()));
4627 ResultBuilder &Results,
4634 if (LangOpts.ObjC2) {
4649 Results.getCodeCompletionTUInfo());
4654 Builder.AddPlaceholderChunk(
"name");
4655 Results.AddResult(Result(
Builder.TakeString()));
4657 if (Results.includeCodePatterns()) {
4663 Builder.AddPlaceholderChunk(
"class");
4664 Results.AddResult(Result(
Builder.TakeString()));
4669 Builder.AddPlaceholderChunk(
"protocol");
4670 Results.AddResult(Result(
Builder.TakeString()));
4675 Builder.AddPlaceholderChunk(
"class");
4676 Results.AddResult(Result(
Builder.TakeString()));
4682 Builder.AddPlaceholderChunk(
"alias");
4684 Builder.AddPlaceholderChunk(
"class");
4685 Results.AddResult(Result(
Builder.TakeString()));
4687 if (Results.getSema().getLangOpts().Modules) {
4691 Builder.AddPlaceholderChunk(
"module");
4692 Results.AddResult(Result(
Builder.TakeString()));
4697 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4698 CodeCompleter->getCodeCompletionTUInfo(),
4700 Results.EnterNewScope();
4701 if (isa<ObjCImplDecl>(CurContext))
4707 Results.ExitScope();
4710 Results.data(),Results.size());
4716 Results.getCodeCompletionTUInfo());
4719 const char *EncodeType =
"char[]";
4720 if (Results.getSema().getLangOpts().CPlusPlus ||
4721 Results.getSema().getLangOpts().ConstStrings)
4722 EncodeType =
"const char[]";
4723 Builder.AddResultTypeChunk(EncodeType);
4726 Builder.AddPlaceholderChunk(
"type-name");
4728 Results.AddResult(Result(
Builder.TakeString()));
4731 Builder.AddResultTypeChunk(
"Protocol *");
4734 Builder.AddPlaceholderChunk(
"protocol-name");
4736 Results.AddResult(Result(
Builder.TakeString()));
4739 Builder.AddResultTypeChunk(
"SEL");
4742 Builder.AddPlaceholderChunk(
"selector");
4744 Results.AddResult(Result(
Builder.TakeString()));
4747 Builder.AddResultTypeChunk(
"NSString *");
4749 Builder.AddPlaceholderChunk(
"string");
4751 Results.AddResult(Result(
Builder.TakeString()));
4754 Builder.AddResultTypeChunk(
"NSArray *");
4756 Builder.AddPlaceholderChunk(
"objects, ...");
4758 Results.AddResult(Result(
Builder.TakeString()));
4761 Builder.AddResultTypeChunk(
"NSDictionary *");
4763 Builder.AddPlaceholderChunk(
"key");
4766 Builder.AddPlaceholderChunk(
"object, ...");
4768 Results.AddResult(Result(
Builder.TakeString()));
4771 Builder.AddResultTypeChunk(
"id");
4773 Builder.AddPlaceholderChunk(
"expression");
4775 Results.AddResult(Result(
Builder.TakeString()));
4781 Results.getCodeCompletionTUInfo());
4783 if (Results.includeCodePatterns()) {
4788 Builder.AddPlaceholderChunk(
"statements");
4790 Builder.AddTextChunk(
"@catch");
4792 Builder.AddPlaceholderChunk(
"parameter");
4795 Builder.AddPlaceholderChunk(
"statements");
4797 Builder.AddTextChunk(
"@finally");
4799 Builder.AddPlaceholderChunk(
"statements");
4801 Results.AddResult(Result(
Builder.TakeString()));
4807 Builder.AddPlaceholderChunk(
"expression");
4808 Results.AddResult(Result(
Builder.TakeString()));
4810 if (Results.includeCodePatterns()) {
4815 Builder.AddPlaceholderChunk(
"expression");
4818 Builder.AddPlaceholderChunk(
"statements");
4820 Results.AddResult(Result(
Builder.TakeString()));
4825 ResultBuilder &Results,
4836 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4837 CodeCompleter->getCodeCompletionTUInfo(),
4839 Results.EnterNewScope();
4841 Results.ExitScope();
4844 Results.data(),Results.size());
4848 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4849 CodeCompleter->getCodeCompletionTUInfo(),
4851 Results.EnterNewScope();
4854 Results.ExitScope();
4857 Results.data(),Results.size());
4861 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4862 CodeCompleter->getCodeCompletionTUInfo(),
4864 Results.EnterNewScope();
4866 Results.ExitScope();
4869 Results.data(),Results.size());
4876 if (Attributes & NewFlag)
4879 Attributes |= NewFlag;
4893 if (AssignCopyRetMask &&
4911 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4912 CodeCompleter->getCodeCompletionTUInfo(),
4914 Results.EnterNewScope();
4942 Results.getCodeCompletionTUInfo());
4944 Setter.AddTextChunk(
"=");
4945 Setter.AddPlaceholderChunk(
"method");
4950 Results.getCodeCompletionTUInfo());
4952 Getter.AddTextChunk(
"=");
4953 Getter.AddPlaceholderChunk(
"method");
4962 Results.ExitScope();
4965 Results.data(),Results.size());
4978 ArrayRef<IdentifierInfo *> SelIdents,
4979 bool AllowSameLength =
true) {
4980 unsigned NumSelIdents = SelIdents.size();
4990 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
4993 for (
unsigned I = 0; I != NumSelIdents; ++
I)
5002 ArrayRef<IdentifierInfo *> SelIdents,
5003 bool AllowSameLength =
true) {
5011 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5035 bool WantInstanceMethods,
5037 ArrayRef<IdentifierInfo *> SelIdents,
5039 VisitedSelectorSet &Selectors,
5040 bool AllowSameLength,
5041 ResultBuilder &Results,
5042 bool InOriginalClass =
true) {
5047 for (
auto *M : Container->
methods()) {
5050 if (M->isInstanceMethod() == WantInstanceMethods ||
5051 (isRootClass && !WantInstanceMethods)) {
5057 if (!Selectors.insert(M->getSelector()).second)
5060 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5061 R.StartParameter = SelIdents.size();
5062 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5063 if (!InOriginalClass)
5065 Results.MaybeAddResult(R, CurContext);
5071 if (Protocol->hasDefinition()) {
5073 = Protocol->getReferencedProtocols();
5075 E = Protocols.
end();
5078 CurContext, Selectors, AllowSameLength, Results,
false);
5088 CurContext, Selectors, AllowSameLength, Results,
false);
5092 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5093 CurContext, Selectors, AllowSameLength,
5094 Results, InOriginalClass);
5098 = CatDecl->getReferencedProtocols();
5100 E = Protocols.
end();
5103 CurContext, Selectors, AllowSameLength,
5109 CurContext, Selectors, AllowSameLength,
5110 Results, InOriginalClass);
5116 SelIdents, CurContext, Selectors,
5117 AllowSameLength, Results,
false);
5122 CurContext, Selectors, AllowSameLength,
5123 Results, InOriginalClass);
5132 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5133 Class =
Category->getClassInterface();
5140 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5141 CodeCompleter->getCodeCompletionTUInfo(),
5143 Results.EnterNewScope();
5145 VisitedSelectorSet Selectors;
5148 Results.ExitScope();
5151 Results.data(),Results.size());
5157 = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
5160 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5161 Class =
Category->getClassInterface();
5168 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5169 CodeCompleter->getCodeCompletionTUInfo(),
5171 Results.EnterNewScope();
5173 VisitedSelectorSet Selectors;
5175 Selectors,
true, Results);
5177 Results.ExitScope();
5180 Results.data(),Results.size());
5185 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5186 CodeCompleter->getCodeCompletionTUInfo(),
5188 Results.EnterNewScope();
5191 bool AddedInOut =
false;
5194 Results.AddResult(
"in");
5195 Results.AddResult(
"inout");
5200 Results.AddResult(
"out");
5202 Results.AddResult(
"inout");
5207 Results.AddResult(
"bycopy");
5208 Results.AddResult(
"byref");
5209 Results.AddResult(
"oneway");
5212 Results.AddResult(
"nonnull");
5213 Results.AddResult(
"nullable");
5214 Results.AddResult(
"null_unspecified");
5222 PP.isMacroDefined(
"IBAction")) {
5224 Results.getCodeCompletionTUInfo(),
5226 Builder.AddTypedTextChunk(
"IBAction");
5228 Builder.AddPlaceholderChunk(
"selector");
5233 Builder.AddTextChunk(
"sender");
5244 Results.ExitScope();
5247 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
5248 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5250 CodeCompleter->includeGlobals());
5252 if (CodeCompleter->includeMacros())
5257 Results.data(), Results.size());
5287 IFace = ObjType->getInterface();
5293 IFace = Ptr->getInterfaceDecl();
5307 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5308 .Case(
"retain", IFace)
5309 .Case(
"strong", IFace)
5310 .Case(
"autorelease", IFace)
5311 .Case(
"copy", IFace)
5312 .Case(
"copyWithZone", IFace)
5313 .Case(
"mutableCopy", IFace)
5314 .Case(
"mutableCopyWithZone", IFace)
5315 .Case(
"awakeFromCoder", IFace)
5316 .Case(
"replacementObjectFromCoder", IFace)
5317 .Case(
"class", IFace)
5318 .Case(
"classForCoder", IFace)
5319 .Case(
"superclass", Super)
5322 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5324 .Case(
"alloc", IFace)
5325 .Case(
"allocWithZone", IFace)
5326 .Case(
"class", IFace)
5327 .Case(
"superclass", Super)
5348 Sema &
S,
bool NeedSuperKeyword,
5349 ArrayRef<IdentifierInfo *> SelIdents,
5350 ResultBuilder &Results) {
5369 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
5387 CurP != CurPEnd; ++CurP, ++SuperP) {
5390 (*SuperP)->getType()))
5394 if (!(*CurP)->getIdentifier())
5400 Results.getCodeCompletionTUInfo());
5404 Results.getCompletionContext().getBaseType(),
5408 if (NeedSuperKeyword) {
5409 Builder.AddTypedTextChunk(
"super");
5415 if (NeedSuperKeyword)
5423 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++
I, ++CurP) {
5424 if (I > SelIdents.size())
5427 if (I < SelIdents.size())
5429 Builder.getAllocator().CopyString(
5431 else if (NeedSuperKeyword || I > SelIdents.size()) {
5433 Builder.getAllocator().CopyString(
5436 (*CurP)->getIdentifier()->getName()));
5439 Builder.getAllocator().CopyString(
5442 (*CurP)->getIdentifier()->getName()));
5454 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5455 CodeCompleter->getCodeCompletionTUInfo(),
5457 getLangOpts().CPlusPlus11
5458 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
5459 : &ResultBuilder::IsObjCMessageReceiver);
5461 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5462 Results.EnterNewScope();
5464 CodeCompleter->includeGlobals());
5470 if (Iface->getSuperClass()) {
5471 Results.AddResult(Result(
"super"));
5479 Results.ExitScope();
5481 if (CodeCompleter->includeMacros())
5484 Results.data(), Results.size());
5490 bool AtArgumentExpression) {
5494 CDecl = CurMethod->getClassInterface();
5503 if (CurMethod->isInstanceMethod()) {
5507 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
5508 AtArgumentExpression,
5517 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc,
5518 LookupOrdinaryName);
5519 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
5521 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
5524 CDecl = Iface->getInterface();
5525 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
5532 id.setIdentifier(Super, SuperLoc);
5533 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
5535 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
5537 AtArgumentExpression);
5546 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
5547 AtArgumentExpression,
5554 unsigned NumSelIdents) {
5556 ASTContext &Context = Results.getSema().Context;
5560 Result *ResultsData = Results.data();
5561 for (
unsigned I = 0, N = Results.size(); I != N; ++
I) {
5562 Result &R = ResultsData[
I];
5563 if (R.Kind == Result::RK_Declaration &&
5564 isa<ObjCMethodDecl>(R.Declaration)) {
5565 if (R.Priority <= BestPriority) {
5566 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
5567 if (NumSelIdents <= Method->param_size()) {
5570 if (R.Priority < BestPriority || PreferredType.
isNull()) {
5571 BestPriority = R.Priority;
5572 PreferredType = MyPreferredType;
5582 return PreferredType;
5587 ArrayRef<IdentifierInfo *> SelIdents,
5588 bool AtArgumentExpression,
5590 ResultBuilder &Results) {
5600 CDecl = Interface->getInterface();
5605 Results.EnterNewScope();
5612 Results.Ignore(SuperMethod);
5618 Results.setPreferredSelector(CurMethod->getSelector());
5620 VisitedSelectorSet Selectors;
5623 SemaRef.
CurContext, Selectors, AtArgumentExpression,
5631 for (uint32_t I = 0,
5647 MethList = MethList->getNext()) {
5651 Result R(MethList->getMethod(),
5652 Results.getBasePriority(MethList->getMethod()),
nullptr);
5653 R.StartParameter = SelIdents.size();
5654 R.AllParametersAreInformative =
false;
5655 Results.MaybeAddResult(R, SemaRef.
CurContext);
5660 Results.ExitScope();
5665 bool AtArgumentExpression,
5668 QualType T = this->GetTypeFromParser(Receiver);
5670 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5671 CodeCompleter->getCodeCompletionTUInfo(),
5676 AtArgumentExpression, IsSuper, Results);
5683 if (AtArgumentExpression) {
5686 if (PreferredType.
isNull())
5687 CodeCompleteOrdinaryName(S, PCC_Expression);
5689 CodeCompleteExpression(S, PreferredType);
5694 Results.getCompletionContext(),
5695 Results.data(), Results.size());
5700 bool AtArgumentExpression,
5704 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
5709 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
5712 RecExpr = Conv.
get();
5725 return CodeCompleteObjCClassMessage(S,
5728 AtArgumentExpression, Super);
5733 }
else if (RecExpr && getLangOpts().CPlusPlus) {
5734 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
5736 RecExpr = Conv.
get();
5737 ReceiverType = RecExpr->
getType();
5742 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5743 CodeCompleter->getCodeCompletionTUInfo(),
5745 ReceiverType, SelIdents));
5747 Results.EnterNewScope();
5754 Results.Ignore(SuperMethod);
5760 Results.setPreferredSelector(CurMethod->getSelector());
5763 VisitedSelectorSet Selectors;
5773 CurContext, Selectors, AtArgumentExpression, Results);
5780 for (
auto *I : QualID->quals())
5782 Selectors, AtArgumentExpression, Results);
5789 CurContext, Selectors, AtArgumentExpression,
5793 for (
auto *I : IFacePtr->quals())
5795 Selectors, AtArgumentExpression, Results);
5804 if (ExternalSource) {
5805 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
5807 Selector Sel = ExternalSource->GetExternalSelector(I);
5808 if (Sel.
isNull() || MethodPool.count(Sel))
5811 ReadMethodPool(Sel);
5816 MEnd = MethodPool.end();
5820 MethList = MethList->getNext()) {
5824 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
5827 Result R(MethList->getMethod(),
5828 Results.getBasePriority(MethList->getMethod()),
nullptr);
5829 R.StartParameter = SelIdents.size();
5830 R.AllParametersAreInformative =
false;
5831 Results.MaybeAddResult(R, CurContext);
5835 Results.ExitScope();
5843 if (AtArgumentExpression) {
5846 if (PreferredType.
isNull())
5847 CodeCompleteOrdinaryName(S, PCC_Expression);
5849 CodeCompleteExpression(S, PreferredType);
5854 Results.getCompletionContext(),
5855 Results.data(),Results.size());
5871 CodeCompleteExpression(S, Data);
5878 if (ExternalSource) {
5879 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
5881 Selector Sel = ExternalSource->GetExternalSelector(I);
5882 if (Sel.
isNull() || MethodPool.count(Sel))
5885 ReadMethodPool(Sel);
5889 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5890 CodeCompleter->getCodeCompletionTUInfo(),
5892 Results.EnterNewScope();
5894 MEnd = MethodPool.end();
5902 Results.getCodeCompletionTUInfo());
5906 Results.AddResult(
Builder.TakeString());
5910 std::string Accumulator;
5911 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++
I) {
5912 if (I == SelIdents.size()) {
5913 if (!Accumulator.empty()) {
5916 Accumulator.clear();
5923 Builder.AddTypedTextChunk(
Builder.getAllocator().CopyString( Accumulator));
5924 Results.AddResult(
Builder.TakeString());
5926 Results.ExitScope();
5930 Results.data(), Results.size());
5936 bool OnlyForwardDeclarations,
5937 ResultBuilder &Results) {
5940 for (
const auto *D : Ctx->
decls()) {
5942 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
5943 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
5944 Results.AddResult(Result(Proto, Results.getBasePriority(Proto),
nullptr),
5945 CurContext,
nullptr,
false);
5951 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5952 CodeCompleter->getCodeCompletionTUInfo(),
5955 if (CodeCompleter && CodeCompleter->includeGlobals()) {
5956 Results.EnterNewScope();
5964 Results.Ignore(Protocol);
5970 Results.ExitScope();
5975 Results.data(),Results.size());
5979 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5980 CodeCompleter->getCodeCompletionTUInfo(),
5983 if (CodeCompleter && CodeCompleter->includeGlobals()) {
5984 Results.EnterNewScope();
5990 Results.ExitScope();
5995 Results.data(),Results.size());
6001 bool OnlyForwardDeclarations,
6002 bool OnlyUnimplemented,
6003 ResultBuilder &Results) {
6006 for (
const auto *D : Ctx->
decls()) {
6008 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
6009 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
6010 (!OnlyUnimplemented || !Class->getImplementation()))
6011 Results.AddResult(Result(Class, Results.getBasePriority(Class),
nullptr),
6012 CurContext,
nullptr,
false);
6017 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6018 CodeCompleter->getCodeCompletionTUInfo(),
6020 Results.EnterNewScope();
6022 if (CodeCompleter->includeGlobals()) {
6028 Results.ExitScope();
6032 Results.data(),Results.size());
6037 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6038 CodeCompleter->getCodeCompletionTUInfo(),
6040 Results.EnterNewScope();
6044 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6045 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6046 Results.Ignore(CurClass);
6048 if (CodeCompleter->includeGlobals()) {
6054 Results.ExitScope();
6058 Results.data(),Results.size());
6062 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6063 CodeCompleter->getCodeCompletionTUInfo(),
6065 Results.EnterNewScope();
6067 if (CodeCompleter->includeGlobals()) {
6073 Results.ExitScope();
6077 Results.data(),Results.size());
6085 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6086 CodeCompleter->getCodeCompletionTUInfo(),
6091 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6093 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6095 for (
const auto *Cat : Class->visible_categories())
6096 CategoryNames.insert(Cat->getIdentifier());
6100 Results.EnterNewScope();
6102 for (
const auto *D : TU->
decls())
6103 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6104 if (CategoryNames.insert(
Category->getIdentifier()).second)
6107 CurContext,
nullptr,
false);
6108 Results.ExitScope();
6112 Results.data(),Results.size());
6124 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6127 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6129 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6130 CodeCompleter->getCodeCompletionTUInfo(),
6136 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6137 Results.EnterNewScope();
6138 bool IgnoreImplemented =
true;
6141 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6142 CategoryNames.insert(Cat->getIdentifier()).second)
6143 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6144 CurContext,
nullptr,
false);
6148 IgnoreImplemented =
false;
6150 Results.ExitScope();
6154 Results.data(),Results.size());
6159 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6160 CodeCompleter->getCodeCompletionTUInfo(),
6165 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6167 (!isa<ObjCImplementationDecl>(Container) &&
6168 !isa<ObjCCategoryImplDecl>(Container)))
6173 for (
const auto *D : Container->decls())
6174 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6175 Results.Ignore(PropertyImpl->getPropertyDecl());
6179 Results.EnterNewScope();
6181 = dyn_cast<ObjCImplementationDecl>(Container))
6184 AddedProperties, Results);
6187 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6188 false,
false, CurContext,
6189 AddedProperties, Results);
6190 Results.ExitScope();
6194 Results.data(),Results.size());
6200 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6201 CodeCompleter->getCodeCompletionTUInfo(),
6206 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6208 (!isa<ObjCImplementationDecl>(Container) &&
6209 !isa<ObjCCategoryImplDecl>(Container)))
6215 = dyn_cast<ObjCImplementationDecl>(Container))
6216 Class = ClassImpl->getClassInterface();
6218 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl()
6219 ->getClassInterface();
6227 =
Property->getType().getNonReferenceType().getUnqualifiedType();
6230 Results.setPreferredType(PropertyType);
6235 Results.EnterNewScope();
6236 bool SawSimilarlyNamedIvar =
false;
6237 std::string NameWithPrefix;
6238 NameWithPrefix +=
'_';
6239 NameWithPrefix += PropertyName->
getName();
6240 std::string NameWithSuffix = PropertyName->
getName().str();
6241 NameWithSuffix +=
'_';
6245 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6246 CurContext,
nullptr,
false);
6250 if ((PropertyName == Ivar->getIdentifier() ||
6251 NameWithPrefix == Ivar->
getName() ||
6252 NameWithSuffix == Ivar->getName())) {
6253 SawSimilarlyNamedIvar =
true;
6257 if (Results.size() &&
6258 Results.data()[Results.size() - 1].Kind
6260 Results.data()[Results.size() - 1].Declaration == Ivar)
6261 Results.data()[Results.size() - 1].Priority--;
6266 if (!SawSimilarlyNamedIvar) {
6277 Policy, Allocator));
6279 Results.AddResult(Result(
Builder.TakeString(), Priority,
6283 Results.ExitScope();
6287 Results.data(),Results.size());
6292 typedef llvm::DenseMap<
6301 bool WantInstanceMethods,
6304 bool InOriginalClass =
true) {
6307 if (!IFace->hasDefinition())
6310 IFace = IFace->getDefinition();
6314 = IFace->getReferencedProtocols();
6316 E = Protocols.
end();
6319 KnownMethods, InOriginalClass);
6322 for (
auto *Cat : IFace->visible_categories()) {
6324 KnownMethods,
false);
6328 if (IFace->getSuperClass())
6330 WantInstanceMethods, ReturnType,
6331 KnownMethods,
false);
6337 =
Category->getReferencedProtocols();
6339 E = Protocols.
end();
6342 KnownMethods, InOriginalClass);
6345 if (InOriginalClass &&
Category->getClassInterface())
6347 WantInstanceMethods, ReturnType, KnownMethods,
6353 if (!Protocol->hasDefinition())
6355 Protocol = Protocol->getDefinition();
6356 Container = Protocol;
6360 = Protocol->getReferencedProtocols();
6362 E = Protocols.
end();
6365 KnownMethods,
false);
6371 for (
auto *M : Container->
methods()) {
6372 if (M->isInstanceMethod() == WantInstanceMethods) {
6373 if (!ReturnType.
isNull() &&
6377 KnownMethods[M->getSelector()] =
6378 KnownMethodsMap::mapped_type(M, InOriginalClass);
6386 unsigned ObjCDeclQuals,
6415 bool IsInstanceMethod,
6418 VisitedSelectorSet &KnownSelectors,
6419 ResultBuilder &Results) {
6421 if (!PropName || PropName->
getLength() == 0)
6439 const char *CopiedKey;
6442 :
Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
6444 operator const char *() {
6448 return CopiedKey = Allocator.
CopyString(Key);
6450 } Key(Allocator, PropName->
getName());
6453 std::string UpperKey = PropName->
getName();
6454 if (!UpperKey.empty())
6457 bool ReturnTypeMatchesProperty = ReturnType.
isNull() ||
6460 bool ReturnTypeMatchesVoid
6464 if (IsInstanceMethod &&
6465 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
6471 Builder.AddTypedTextChunk(Key);
6478 if (IsInstanceMethod &&
6479 ((!ReturnType.
isNull() &&
6484 std::string SelectorName = (Twine(
"is") + UpperKey).str();
6486 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6488 if (ReturnType.
isNull()) {
6502 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
6504 std::string SelectorName = (Twine(
"set") + UpperKey).str();
6506 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6507 if (ReturnType.
isNull()) {
6515 Builder.AddTypedTextChunk(
":");
6554 if (IsInstanceMethod &&
6556 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
6558 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6560 if (ReturnType.
isNull()) {
6562 Builder.AddTextChunk(
"NSUInteger");
6568 Results.AddResult(Result(
Builder.TakeString(),
6570 UnorderedGetterPriority),
6577 if (IsInstanceMethod &&
6579 std::string SelectorName
6580 = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
6582 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6583 if (ReturnType.
isNull()) {
6591 Builder.AddTextChunk(
"NSUInteger");
6593 Builder.AddTextChunk(
"index");
6594 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6600 if (IsInstanceMethod &&
6605 ->getName() ==
"NSArray"))) {
6606 std::string SelectorName
6607 = (Twine(Property->
getName()) +
"AtIndexes").str();
6609 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6610 if (ReturnType.
isNull()) {
6612 Builder.AddTextChunk(
"NSArray *");
6618 Builder.AddTextChunk(
"NSIndexSet *");
6620 Builder.AddTextChunk(
"indexes");
6621 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6627 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6628 std::string SelectorName = (Twine(
"get") + UpperKey).str();
6634 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6635 if (ReturnType.
isNull()) {
6643 Builder.AddPlaceholderChunk(
"object-type");
6646 Builder.AddTextChunk(
"buffer");
6648 Builder.AddTypedTextChunk(
"range:");
6650 Builder.AddTextChunk(
"NSRange");
6652 Builder.AddTextChunk(
"inRange");
6653 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6661 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6662 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
6668 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6669 if (ReturnType.
isNull()) {
6675 Builder.AddTypedTextChunk(
"insertObject:");
6677 Builder.AddPlaceholderChunk(
"object-type");
6680 Builder.AddTextChunk(
"object");
6684 Builder.AddPlaceholderChunk(
"NSUInteger");
6686 Builder.AddTextChunk(
"index");
6687 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6693 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6694 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
6700 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6701 if (ReturnType.
isNull()) {
6709 Builder.AddTextChunk(
"NSArray *");
6711 Builder.AddTextChunk(
"array");
6713 Builder.AddTypedTextChunk(
"atIndexes:");
6715 Builder.AddPlaceholderChunk(
"NSIndexSet *");
6717 Builder.AddTextChunk(
"indexes");
6718 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6724 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6725 std::string SelectorName
6726 = (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
6728 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6729 if (ReturnType.
isNull()) {
6737 Builder.AddTextChunk(
"NSUInteger");
6739 Builder.AddTextChunk(
"index");
6740 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6746 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6747 std::string SelectorName
6748 = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
6750 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6751 if (ReturnType.
isNull()) {
6759 Builder.AddTextChunk(
"NSIndexSet *");
6761 Builder.AddTextChunk(
"indexes");
6762 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6768 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6769 std::string SelectorName
6770 = (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
6776 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6777 if (ReturnType.
isNull()) {
6785 Builder.AddPlaceholderChunk(
"NSUInteger");
6787 Builder.AddTextChunk(
"index");
6789 Builder.AddTypedTextChunk(
"withObject:");
6793 Builder.AddTextChunk(
"object");
6794 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6800 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6801 std::string SelectorName1
6802 = (Twine(
"replace") + UpperKey +
"AtIndexes").str();
6803 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
6809 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6810 if (ReturnType.
isNull()) {
6818 Builder.AddPlaceholderChunk(
"NSIndexSet *");
6820 Builder.AddTextChunk(
"indexes");
6824 Builder.AddTextChunk(
"NSArray *");
6826 Builder.AddTextChunk(
"array");
6827 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
6834 if (IsInstanceMethod &&
6839 ->getName() ==
"NSEnumerator"))) {
6840 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
6842 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6844 if (ReturnType.
isNull()) {
6846 Builder.AddTextChunk(
"NSEnumerator *");
6851 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
6857 if (IsInstanceMethod &&
6859 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
6861 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6862 if (ReturnType.
isNull()) {
6864 Builder.AddPlaceholderChunk(
"object-type");
6871 if (ReturnType.
isNull()) {
6872 Builder.AddPlaceholderChunk(
"object-type");
6880 Builder.AddTextChunk(
"object");
6881 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
6888 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6889 std::string SelectorName
6890 = (Twine(
"add") + UpperKey + Twine(
"Object")).str();
6892 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6893 if (ReturnType.
isNull()) {
6901 Builder.AddPlaceholderChunk(
"object-type");
6904 Builder.AddTextChunk(
"object");
6905 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6911 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6912 std::string SelectorName = (Twine(
"add") + UpperKey).str();
6914 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6915 if (ReturnType.
isNull()) {
6923 Builder.AddTextChunk(
"NSSet *");
6925 Builder.AddTextChunk(
"objects");
6926 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6932 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6933 std::string SelectorName
6934 = (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
6936 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6937 if (ReturnType.
isNull()) {
6945 Builder.AddPlaceholderChunk(
"object-type");
6948 Builder.AddTextChunk(
"object");
6949 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6955 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6956 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
6958 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6959 if (ReturnType.
isNull()) {
6967 Builder.AddTextChunk(
"NSSet *");
6969 Builder.AddTextChunk(
"objects");
6970 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6976 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6977 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
6979 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6980 if (ReturnType.
isNull()) {
6988 Builder.AddTextChunk(
"NSSet *");
6990 Builder.AddTextChunk(
"objects");
6991 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
6998 if (!IsInstanceMethod &&
7003 ->getName() ==
"NSSet"))) {
7004 std::string SelectorName
7005 = (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
7007 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7009 if (ReturnType.
isNull()) {
7011 Builder.AddTextChunk(
"NSSet *");
7022 if (!IsInstanceMethod &&
7026 std::string SelectorName
7027 = (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
7029 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7031 if (ReturnType.
isNull()) {
7045 bool IsInstanceMethod,
7049 QualType ReturnType = GetTypeFromParser(ReturnTy);
7050 Decl *IDecl =
nullptr;
7053 IDecl = cast<Decl>(OCD);
7057 bool IsInImplementation =
false;
7058 if (
Decl *D = IDecl) {
7060 SearchDecl = Impl->getClassInterface();
7061 IsInImplementation =
true;
7063 = dyn_cast<ObjCCategoryImplDecl>(D)) {
7064 SearchDecl = CatImpl->getCategoryDecl();
7065 IsInImplementation =
true;
7070 if (!SearchDecl && S) {
7072 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7085 ReturnType, KnownMethods);
7089 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7090 CodeCompleter->getCodeCompletionTUInfo(),
7092 Results.EnterNewScope();
7095 MEnd = KnownMethods.end();
7099 Results.getCodeCompletionTUInfo());
7103 if (ReturnType.
isNull()) {
7121 P != PEnd; (void)++
P, ++I) {
7124 Builder.AddTypedTextChunk(
":");
7134 if ((*P)->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability)
7135 ParamType = (*P)->getType();
7137 ParamType = (*P)->getOriginalType();
7142 (*P)->getObjCDeclQualifier(),
7147 Builder.AddTextChunk(
Builder.getAllocator().CopyString( Id->getName()));
7156 if (IsInImplementation && Results.includeCodePatterns()) {
7163 Builder.AddTextChunk(
"return");
7165 Builder.AddPlaceholderChunk(
"expression");
7168 Builder.AddPlaceholderChunk(
"statements");
7175 if (!M->second.getInt())
7178 Results.AddResult(Result(
Builder.TakeString(), Method, Priority));
7185 Containers.push_back(SearchDecl);
7187 VisitedSelectorSet KnownSelectors;
7189 MEnd = KnownMethods.end();
7191 KnownSelectors.insert(M->first);
7197 IFace =
Category->getClassInterface();
7201 Containers.push_back(Cat);
7203 for (
unsigned I = 0, N = Containers.size(); I != N; ++
I)
7204 for (
auto *
P : Containers[I]->instance_properties())
7206 KnownSelectors, Results);
7209 Results.ExitScope();
7213 Results.data(),Results.size());
7217 bool IsInstanceMethod,
7218 bool AtParameterName,
7223 if (ExternalSource) {
7224 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
7226 Selector Sel = ExternalSource->GetExternalSelector(I);
7227 if (Sel.
isNull() || MethodPool.count(Sel))
7230 ReadMethodPool(Sel);
7236 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7237 CodeCompleter->getCodeCompletionTUInfo(),
7241 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7243 Results.EnterNewScope();
7245 MEnd = MethodPool.end();
7247 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first :
7250 MethList = MethList->getNext()) {
7254 if (AtParameterName) {
7256 unsigned NumSelIdents = SelIdents.size();
7258 NumSelIdents <= MethList->getMethod()->param_size()) {
7260 MethList->getMethod()->parameters()[NumSelIdents - 1];
7263 Results.getCodeCompletionTUInfo());
7266 Results.AddResult(
Builder.TakeString());
7273 Result R(MethList->getMethod(),
7274 Results.getBasePriority(MethList->getMethod()),
nullptr);
7275 R.StartParameter = SelIdents.size();
7276 R.AllParametersAreInformative =
false;
7277 R.DeclaringEntity =
true;
7278 Results.MaybeAddResult(R, CurContext);
7282 Results.ExitScope();
7285 Results.data(),Results.size());
7289 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7290 CodeCompleter->getCodeCompletionTUInfo(),
7292 Results.EnterNewScope();
7296 Results.getCodeCompletionTUInfo());
7297 Builder.AddTypedTextChunk(
"if");
7299 Builder.AddPlaceholderChunk(
"condition");
7300 Results.AddResult(
Builder.TakeString());
7303 Builder.AddTypedTextChunk(
"ifdef");
7305 Builder.AddPlaceholderChunk(
"macro");
7306 Results.AddResult(
Builder.TakeString());
7309 Builder.AddTypedTextChunk(
"ifndef");
7311 Builder.AddPlaceholderChunk(
"macro");
7312 Results.AddResult(
Builder.TakeString());
7314 if (InConditional) {
7316 Builder.AddTypedTextChunk(
"elif");
7318 Builder.AddPlaceholderChunk(
"condition");
7319 Results.AddResult(
Builder.TakeString());
7322 Builder.AddTypedTextChunk(
"else");
7323 Results.AddResult(
Builder.TakeString());
7326 Builder.AddTypedTextChunk(
"endif");
7327 Results.AddResult(
Builder.TakeString());
7331 Builder.AddTypedTextChunk(
"include");
7334 Builder.AddPlaceholderChunk(
"header");
7336 Results.AddResult(
Builder.TakeString());
7339 Builder.AddTypedTextChunk(
"include");
7342 Builder.AddPlaceholderChunk(
"header");
7344 Results.AddResult(
Builder.TakeString());
7347 Builder.AddTypedTextChunk(
"define");
7349 Builder.AddPlaceholderChunk(
"macro");
7350 Results.AddResult(
Builder.TakeString());
7353 Builder.AddTypedTextChunk(
"define");
7355 Builder.AddPlaceholderChunk(
"macro");
7357 Builder.AddPlaceholderChunk(
"args");
7359 Results.AddResult(
Builder.TakeString());
7362 Builder.AddTypedTextChunk(
"undef");
7364 Builder.AddPlaceholderChunk(
"macro");
7365 Results.AddResult(
Builder.TakeString());
7368 Builder.AddTypedTextChunk(
"line");
7370 Builder.AddPlaceholderChunk(
"number");
7371 Results.AddResult(
Builder.TakeString());
7374 Builder.AddTypedTextChunk(
"line");
7376 Builder.AddPlaceholderChunk(
"number");
7379 Builder.AddPlaceholderChunk(
"filename");
7381 Results.AddResult(
Builder.TakeString());
7384 Builder.AddTypedTextChunk(
"error");
7386 Builder.AddPlaceholderChunk(
"message");
7387 Results.AddResult(
Builder.TakeString());
7390 Builder.AddTypedTextChunk(
"pragma");
7392 Builder.AddPlaceholderChunk(
"arguments");
7393 Results.AddResult(
Builder.TakeString());
7395 if (getLangOpts().ObjC1) {
7397 Builder.AddTypedTextChunk(
"import");
7400 Builder.AddPlaceholderChunk(
"header");
7402 Results.AddResult(
Builder.TakeString());
7405 Builder.AddTypedTextChunk(
"import");
7408 Builder.AddPlaceholderChunk(
"header");
7410 Results.AddResult(
Builder.TakeString());
7414 Builder.AddTypedTextChunk(
"include_next");
7417 Builder.AddPlaceholderChunk(
"header");
7419 Results.AddResult(
Builder.TakeString());
7422 Builder.AddTypedTextChunk(
"include_next");
7425 Builder.AddPlaceholderChunk(
"header");
7427 Results.AddResult(
Builder.TakeString());
7430 Builder.AddTypedTextChunk(
"warning");
7432 Builder.AddPlaceholderChunk(
"message");
7433 Results.AddResult(
Builder.TakeString());
7440 Results.ExitScope();
7444 Results.data(), Results.size());
7448 CodeCompleteOrdinaryName(S,
7454 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7455 CodeCompleter->getCodeCompletionTUInfo(),
7458 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
7461 Results.getCodeCompletionTUInfo());
7462 Results.EnterNewScope();
7464 MEnd = PP.macro_end();
7467 M->first->getName()));
7472 Results.ExitScope();
7473 }
else if (IsDefinition) {
7478 Results.data(), Results.size());
7482 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7483 CodeCompleter->getCodeCompletionTUInfo(),
7486 if (!CodeCompleter || CodeCompleter->includeMacros())
7490 Results.EnterNewScope();
7492 Results.getCodeCompletionTUInfo());
7493 Builder.AddTypedTextChunk(
"defined");
7496 Builder.AddPlaceholderChunk(
"macro");
7498 Results.AddResult(
Builder.TakeString());
7499 Results.ExitScope();
7503 Results.data(), Results.size());
7509 unsigned Argument) {
7526 ResultBuilder
Builder(*
this, Allocator, CCTUInfo,
7528 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
7529 CodeCompletionDeclConsumer Consumer(Builder,
7535 if (!CodeCompleter || CodeCompleter->includeMacros())
7539 Results.insert(Results.end(),
7540 Builder.data(), Builder.data() + Builder.size());
pointer operator->() const
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
unsigned getFlags() const
getFlags - Return the flags for this scope.
The receiver is the instance of the superclass object.
static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, bool IsInstanceMethod, QualType ReturnType, ASTContext &Context, VisitedSelectorSet &KnownSelectors, ResultBuilder &Results)
Add code completions for Objective-C Key-Value Coding (KVC) and Key-Value Observing (KVO)...
param_const_iterator param_begin() const
bool hasDefinition() const
Determine whether this class has been defined.
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
bool isObjCObjectOrInterfaceType() const
const SwitchCase * getNextSwitchCase() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
A C++ namespace alias declaration.
Smart pointer class that efficiently represents Objective-C method names.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const
Create a new code-completion string that describes the function signature of this overload candidate...
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Any kind of method, provided it means other specified criteria.
bool isObjCContainer() const
This is a scope that corresponds to the parameters within a function prototype.
A static_assert or _Static_assert node.
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...
Priority for a send-to-super completion.
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program...
bool isMemberPointerType() const
Code completion occurs within a class, struct, or union.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Divide by this factor when a code-completion result's type exactly matches the type we expect...
Code completion for a selector, as in an @selector expression.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
CodeCompleteConsumer::OverloadCandidate ResultCandidate
submodule_iterator submodule_begin()
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true)
Add all of the Objective-C methods in the given Objective-C container to the set of results...
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
Code completion where an Objective-C class message is expected.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
FunctionType - C99 6.7.5.3 - Function Declarators.
static bool isObjCReceiverType(ASTContext &C, QualType T)
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
An Objective-C method being used as a property.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Code completion within a type-qualifier list.
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 isRecordType() const
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Captures information about "declaration specifiers" specific to Objective-C.
void CodeCompleteUsing(Scope *S)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for...
static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
bool isEnumeralType() const
std::ptrdiff_t difference_type
Defines the clang::MacroInfo and clang::MacroDirective classes.
std::string getAsString() const
void CodeCompleteNaturalLanguage()
pointer(const DeclIndexPair &Value)
The base class of the type hierarchy.
bool isObjCQualifiedClassType() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getLength() const
Efficiently return the length of this identifier info.
An unspecified code-completion context.
NamespaceDecl - Represent a C++ namespace.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
Wrapper for source info for typedefs.
A C++ non-type template parameter.
ObjCDeclQualifier getObjCDeclQualifier() const
An Objective-C @interface for a category.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext)
bool isBooleanType() const
A container of type source information.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
bool isBlockPointerType() const
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
MacroMap::const_iterator macro_iterator
Represents a C++ constructor within a class.
Code completion occurred where an Objective-C message receiver is expected.
iterator(const NamedDecl *SingleDecl, unsigned Index)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteObjCPropertyGetter(Scope *S)
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr * > Args)
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
static const char * GetCompletionTypeString(QualType T, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionAllocator &Allocator)
Retrieve the string representation of the given type as a string that has the appropriate lifetime fo...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
visible_categories_range visible_categories() const
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited)
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
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.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Describes how types, statements, expressions, and declarations should be printed. ...
decl_iterator decls_end() const
Code completion occurs within an Objective-C implementation or category implementation.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
The entity is not available; any use of it will be an error.
unsigned param_size() const
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
tok::TokenKind ContextKind
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
unsigned getNumParams() const
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args)
Priority for a constant value (e.g., enumerator).
RecordDecl - Represents a struct/union/class.
static void AddTypedefResult(ResultBuilder &Results)
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
One of these records is kept for each identifier that is lexed.
CodeCompletionString * TakeString()
Take the resulting completion string.
method_iterator end_overridden_methods() const
This table allows us to fully hide how we implement multi-keyword caching.
void CodeCompleteObjCInterfaceDecl(Scope *S)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Priority for the next initialization in a constructor initializer list.
SmallVector< Decl *, 4 > IgnoreDecls
Represents a class type in Objective C.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
A "string" used to describe how code completion can be performed for an entity.
Adjustment for KVC code pattern priorities when it doesn't look like the.
TSS getTypeSpecSign() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const TST TST_class
bool isAnyPointerType() const
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
An Objective-C @protocol declaration.
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results)
Add type specifiers for the current language as keyword results.
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
ParmVarDecl * getParam(unsigned i) const
Code completion occurs following one or more template headers within a class.
CXXMethodDecl * getCanonicalDecl() override
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
CXXRecordDecl * getDefinition() const
const LangOptions & getLangOpts() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
An Objective-C instance method.
method_range methods() const
static const TST TST_enum
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
bool isNull() const
Determine whether this is the empty selector.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
Describes a module or submodule.
Code completion occurs where only a type is permitted.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Code completion occurs at top-level or namespace context.
Values of this type can be null.
An Objective-C @property declaration.
static 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)
The result is in a base class.
An allocator used specifically for the purpose of code completion.
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, bool AllowSameLength=true)
static void AddObjCProperties(const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results)
Represents a C++ unqualified-id that has been parsed.
Represents the results of name lookup.
static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag)
Determine whether the addition of the given flag to an Objective-C property's attributes will cause a...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
A convenient class for passing around template argument information.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
Code completion occurs following one or more template headers.
void CodeCompleteBracketDeclarator(Scope *S)
QualType getReturnType() const
Wrapper for source info for functions.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
Code completion occurs within an expression.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Whether values of this type can be null is (explicitly) unspecified.
Code completion occurred where a preprocessor directive is expected.
field_range fields() const
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
TypeDecl - Represents a declaration of a type.
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
Selector getSelector() const
Code completion occurred within an Objective-C implementation or category implementation.
static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, bool OnlyUnimplemented, ResultBuilder &Results)
Add all of the Objective-C interface declarations that we find in the given (translation unit) contex...
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
bool isVariadic() const
Whether this function is variadic.
Scope - A scope is a transient data structure that is used while parsing the program.
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
submodule_iterator submodule_end()
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...
Priority for a nested-name-specifier.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
void append(iterator I, iterator E)
Code completion occurred where a namespace or namespace alias is expected.
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
Represents an Objective-C protocol declaration.
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool IncludeUndefined, bool TargetTypeIsPointer=false)
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
Represents an ObjC class declaration.
ObjCMethodDecl * getMethod() const
decl_iterator decls_begin() const
detail::InMemoryDirectory::const_iterator I
unsigned getNumParams() const
static QualType getPreferredArgumentTypeForMessageSend(ResultBuilder &Results, unsigned NumSelIdents)
Given a set of code-completion results for the argument of a message send, determine the preferred ty...
known_categories_range known_categories() const
CXCursorKind
Describes the kind of entity that a cursor refers to.
const UnresolvedSetImpl & asUnresolvedSet() const
std::vector< Module * >::iterator submodule_iterator
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
std::input_iterator_tag iterator_category
void CodeCompleteObjCMethodDecl(Scope *S, bool IsInstanceMethod, ParsedType ReturnType)
A right parenthesis (')').
Code completion where an Objective-C category name is expected.
static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
const ParmVarDecl *const * param_const_iterator
Sema - This implements semantic analysis and AST building for C.
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression)
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, bool UserDefinedConversion=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
TST getTypeSpecType() const
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
static ObjCInterfaceDecl * GetAssumedMessageSendExprType(Expr *E)
When we have an expression with type "id", we may assume that it has some more-specific class type ba...
ObjCPropertyAttributeKind getPropertyAttributes() const
Zero-argument (unary) selector.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
DeclarationNameTable DeclarationNames
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, bool WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
Find all of the methods that reside in the given container (and its superclasses, protocols...
ObjCDeclQualifier getObjCDeclQualifier() const
SmallVector< LambdaCapture, 4 > Captures
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
iterator(const DeclIndexPair *Iterator)
Code completion occurred where a protocol name is expected.
IdentifierInfo *const * arg_iterator
Arguments - The list of arguments for a function-like macro.
const ObjCMethodDecl * getMethodDecl() const
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Retains information about a block that is currently being parsed.
Type source information for an attributed type.
static bool InheritsFromClassNamed(ObjCInterfaceDecl *Class, StringRef Name)
Determine whether the given class is or inherits from a class by the given name.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
Code completion occurred where a new name is expected.
unsigned getNumArgs() const
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
bool isObjCClassType() const
Declaration of a template type parameter.
void CodeCompleteObjCPropertyDefinition(Scope *S)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
TranslationUnitDecl * getTranslationUnitDecl() const
Code completion occurs within an Objective-C interface, protocol, or category.
Defines the clang::Preprocessor interface.
const ParmVarDecl * getParamDecl(unsigned i) const
void CodeCompleteObjCAtVisibility(Scope *S)
An Objective-C @implementation for a category.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
ParmVarDecl *const * param_iterator
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void CodeCompletePreprocessorExpression()
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
bool isObjCIdType() const
Code completion occurs within a statement, which may also be an expression or a declaration.
Captures a result of code completion.
Code completion occurred where a new name is expected and a qualified name is permissible.
A C++ class template partial specialization.
const SwitchCase * getSwitchCaseList() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isInstanceMethod() const
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
bool isFunctionOrMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
QualType getObjCIdType() const
Represents the Objective-CC id type.
An expression that sends a message to the given Objective-C object or class.
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
arg_iterator arg_end() const
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
The result type of a method or function.
Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.
void CodeCompleteNamespaceDecl(Scope *S)
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
TypeSourceInfo * getTypeSourceInfo() const
void CodeCompleteInitializer(Scope *S, Decl *D)
bool isC99Varargs() const
void CodeCompleteObjCPropertySetter(Scope *S)
const char * getBriefComment() const
const TypeClass * getTypePtr() const
static bool anyNullArguments(ArrayRef< Expr * > Args)
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt)
Priority for a code pattern.
The context in which code completion occurred, so that the code-completion consumer can process the r...
void CodeCompleteObjCAtExpression(Scope *S)
param_const_iterator param_end() const
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void CodeCompleteTypeQualifiers(DeclSpec &DS)
ArrayRef< ParmVarDecl * > parameters() const
static void AddFunctionParameterChunks(Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false)
Add function parameter chunks to the given code completion string.
DeclContext * getEntity() const
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
Code completion occurred within a class, struct, or union.
void CodeCompleteObjCAtDirective(Scope *S)
SelectorTable & Selectors
const DeclIndexPair * operator->() const
A C++ template type parameter.
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Encodes a location in the source.
enumerator_range enumerators() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
const TemplateArgument * iterator
method_iterator begin_overridden_methods() const
Priority for the Objective-C "_cmd" implicit parameter.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
TagDecl - Represents the declaration of a struct/union/class/enum.
This is a scope that corresponds to the Objective-C @catch statement.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
ASTContext & getASTContext() const
macro_iterator macro_end(bool IncludeExternalMacros=true) const
static const TST TST_union
const Expr * getCond() const
ParsedType getRepAsType() const
TSC getTypeSpecComplex() const
void CodeCompleteReturn(Scope *S)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion where the name of an Objective-C class is expected.
Represents a static or instance method of a struct/union/class.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.
Code completion occurred within an Objective-C interface, protocol, or category interface.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void CodeCompleteOperatorName(Scope *S)
void CodeCompletePreprocessorDirective(bool InConditional)
ArrayRef< ParmVarDecl * > parameters() 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.
ObjCCategoryDecl - Represents a category declaration.
static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
Add language constructs that show up for "ordinary" names.
static void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, bool CompleteExpressionWithCurrentArg=true)
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Represents one property declaration in an Objective-C interface.
QualType getReturnType() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
bool isFileContext() const
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
sema::FunctionScopeInfo * getCurFunction() const
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
unsigned TypeAlias
Whether this template specialization type is a substituted type alias.
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
void addBriefComment(StringRef Comment)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Priority for a preprocessor macro.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
The scope of a struct/union/class definition.
ObjCIvarDecl * getNextIvar()
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getParentName() const
bool isMacroDefined(StringRef Id)
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results)
Add all of the protocol declarations that we find in the given (translation unit) context...
Abstract interface for a consumer of code-completion information.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
An Objective-C instance variable.
Represents a template argument.
ParserCompletionContext
Describes the context in which code completion occurs.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
Code completion occurred where an macro is being defined.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Priority for a non-type declaration.
The base class of all kinds of template declarations (e.g., class, function, etc.).
static NestedNameSpecifier * getRequiredQualification(ASTContext &Context, const DeclContext *CurContext, const DeclContext *TargetContext)
Compute the qualification required to get from the current context (CurContext) to the target context...
A function or method parameter.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
void CodeCompleteTag(Scope *S, unsigned TagSpec)
TypeLoc IgnoreParens() const
This is a scope that corresponds to the template parameters of a C++ template.
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
DeclarationName - The name of a declaration.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Selector getSelector() const
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
Code completion occurred on the right-hand side of an Objective-C property access expression...
All of the names in this module are visible.
void CodeCompleteNamespaceAliasDecl(Scope *S)
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void CodeCompleteUsingDirective(Scope *S)
bool isFunctionLike() const
Represents a pointer to an Objective C object.
SwitchStmt - This represents a 'switch' stmt.
Encapsulates the data about a macro definition (e.g.
bool SuppressUnwrittenScope
Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonym...
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Not an overloaded operator.
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
ObjCMethodDecl * getGetterMethodDecl() const
Priority for a member declaration found from the current method or member function.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
ExternalSemaSource * getExternalSource() const
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
unsigned getTypeQuals() const
A reference to a member of a struct, union, or class that occurs in some non-expression context...
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
ObjCMethodDecl * getSetterMethodDecl() const
A module import declaration.
instprop_range instance_properties() const
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo * > SelIdents)
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
enum Kind getKind() const
Retrieve the kind of code-completion context.
A declaration whose specific kind is not exposed via this interface.
A piece of text that describes the parameter that corresponds to the code-completion location within ...
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
static const TST TST_typename
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
An Objective-C @dynamic definition.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void * getAsOpaquePtr() const
void CodeCompleteObjCAtStatement(Scope *S)
ObjCImplementationDecl * getImplementation() const
protocol_range protocols() const
const TypeClass * getTypePtr() const
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)
QualType getPointeeType() const
This is a scope that can contain a declaration.
A left parenthesis ('(').
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
static bool isInstanceMethod(const Decl *D)
Captures information about "declaration specifiers".
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
An Objective-C @implementation.
CodeCompleteExpressionData(QualType PreferredType=QualType())
bool isObjCObjectPointerType() const
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo * > SelIdents)
static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext, ResultBuilder &Results)
If we're in a C++ virtual member function, add completion results that invoke the functions we overri...
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
An unspecified code-completion context where we should also add macro completions.
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
A left angle bracket ('<').
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
A right angle bracket ('>').
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Cursor that represents the translation unit itself.
Declaration of a class template.
Priority for a declaration that is in the local scope.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
This class is used for builtin types like 'int'.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
Vertical whitespace ('\n' or '\r\n', depending on the platform).
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Represents a complete lambda introducer.
a linked list of methods with the same selector name but different signatures.
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param, bool SuppressName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
ObjCInterfaceDecl * getSuperClass() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
bool AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>").
static Qualifiers fromCVRMask(unsigned CVR)
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC)
static void AddObjCPassingTypeChunk(QualType Type, unsigned ObjCDeclQuals, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder)
Add the parenthesized return or parameter type chunk to a code completion string. ...
static OpaquePtr make(QualTypeP)
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
TranslationUnitDecl - The top declaration context.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
bool isTypeAltiVecVector() const
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
static void AddTemplateParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false)
Add template parameter chunks to the given code completion string.
A reference to a declared variable, function, enum, etc.
Code completion occurred on the right-hand side of a member access expression using the dot operator...
Code completion occurs within the condition of an if, while, switch, or for statement.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion...
static bool isNamespaceScope(Scope *S)
Determine whether this scope denotes a namespace.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
Code completion occurred where a type name is expected.
Horizontal whitespace (' ').
SourceManager & SourceMgr
void CodeCompleteObjCImplementationDecl(Scope *S)
static const TST TST_struct
void AddAnnotation(const char *A)
reference operator*() const
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, bool AllowSameLength=true)
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
arg_iterator arg_begin() const
static LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
NamedDecl - This represents a decl with a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
bool IntegralConstantExpression
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
Macro that optionally prepends an "@" to the string literal passed in via Keyword, depending on whether NeedAt is true or false.
EnumDecl * getDefinition() const
friend bool operator==(const iterator &X, const iterator &Y)
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
An Objective-C @interface.
A C++ conversion function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The receiver is a superclass.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
void CodeCompleteAfterIf(Scope *S)
Wrapper for source info for block pointers.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
base_class_range vbases()
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Declaration of a template function.
Code completion occurs in a parenthesized expression, which might also be a type cast.
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
void CodeCompleteObjCProtocolDecl(Scope *S)
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo * > SelIdents, ResultBuilder &Results)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.