30 #include "llvm/ADT/DenseSet.h" 31 #include "llvm/ADT/SmallBitVector.h" 32 #include "llvm/ADT/SmallPtrSet.h" 33 #include "llvm/ADT/SmallString.h" 34 #include "llvm/ADT/StringExtras.h" 35 #include "llvm/ADT/StringSwitch.h" 36 #include "llvm/ADT/Twine.h" 37 #include "llvm/ADT/iterator_range.h" 38 #include "llvm/Support/Path.h" 43 using namespace clang;
54 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
60 std::vector<Result> Results;
65 llvm::SmallPtrSet<const Decl *, 16> AllDeclsFound;
67 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
72 class ShadowMapEntry {
77 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
81 unsigned SingleDeclIndex;
84 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) {}
86 void Add(
const NamedDecl *ND,
unsigned Index) {
87 if (DeclOrVector.isNull()) {
90 SingleDeclIndex = Index;
95 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
98 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
99 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
104 DeclOrVector.get<DeclIndexPairVector *>()->push_back(
105 DeclIndexPair(ND, Index));
109 if (DeclIndexPairVector *Vec =
110 DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
118 iterator begin()
const;
119 iterator end()
const;
125 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
142 bool AllowNestedNameSpecifiers;
153 std::list<ShadowMap> ShadowMaps;
160 bool HasObjectTypeQualifiers;
172 void AdjustResultPriorityForDecl(Result &R);
174 void MaybeAddConstructorResults(Result R);
180 LookupFilter Filter =
nullptr)
181 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
182 Filter(Filter), AllowNestedNameSpecifiers(
false),
183 HasObjectTypeQualifiers(
false), CompletionContext(CompletionContext),
184 ObjCImplementation(nullptr) {
187 switch (CompletionContext.
getKind()) {
194 if (Method->isInstanceMethod())
196 ObjCImplementation = Interface->getImplementation();
205 unsigned getBasePriority(
const NamedDecl *D);
209 bool includeCodePatterns()
const {
215 void setFilter(LookupFilter Filter) { this->Filter =
Filter; }
217 Result *data() {
return Results.empty() ? nullptr : &Results.front(); }
218 unsigned size()
const {
return Results.size(); }
219 bool empty()
const {
return Results.empty(); }
233 void setObjectTypeQualifiers(
Qualifiers Quals) {
234 ObjectTypeQualifiers = Quals;
235 HasObjectTypeQualifiers =
true;
243 void setPreferredSelector(
Selector Sel) { 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();
330 bool IsOrdinaryName(
const NamedDecl *ND)
const;
331 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
332 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
333 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
334 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
336 bool IsClassOrStruct(
const NamedDecl *ND)
const;
338 bool IsNamespace(
const NamedDecl *ND)
const;
339 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
341 bool IsMember(
const NamedDecl *ND)
const;
342 bool IsObjCIvar(
const NamedDecl *ND)
const;
343 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
344 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
345 bool IsObjCCollection(
const NamedDecl *ND)
const;
346 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
352 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
353 unsigned SingleDeclIndex;
365 pointer(
const DeclIndexPair &Value) : Value(Value) {}
373 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
376 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
379 if (DeclOrIterator.is<
const NamedDecl *>()) {
385 const DeclIndexPair *I = DeclOrIterator.get<
const DeclIndexPair *>();
399 return reference(ND, SingleDeclIndex);
401 return *DeclOrIterator.get<
const DeclIndexPair *>();
407 return X.DeclOrIterator.getOpaqueValue() ==
408 Y.DeclOrIterator.getOpaqueValue() &&
409 X.SingleDeclIndex == Y.SingleDeclIndex;
418 ResultBuilder::ShadowMapEntry::begin()
const {
419 if (DeclOrVector.isNull())
423 return iterator(ND, SingleDeclIndex);
425 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
429 ResultBuilder::ShadowMapEntry::end()
const {
430 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
433 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
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()) {
468 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
469 if (!Namespace->getIdentifier())
473 }
else if (
const auto *TD = dyn_cast<TagDecl>(Parent))
483 bool doubleUnderscoreOnly =
false) {
487 return Name[0] ==
'_' &&
489 (Name[1] >=
'A' && Name[1] <=
'Z' && !doubleUnderscoreOnly));
515 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
516 bool &AsNestedNameSpecifier)
const {
517 AsNestedNameSpecifier =
false;
532 if (isa<ClassTemplateSpecializationDecl>(ND) ||
533 isa<ClassTemplatePartialSpecializationDecl>(ND))
537 if (isa<UsingDecl>(ND))
543 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
544 (isa<NamespaceDecl>(ND) && Filter != &ResultBuilder::IsNamespace &&
545 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
546 AsNestedNameSpecifier =
true;
549 if (Filter && !(this->*Filter)(Named)) {
551 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
552 IsNestedNameSpecifier(ND) &&
553 (Filter != &ResultBuilder::IsMember ||
554 (isa<CXXRecordDecl>(ND) &&
555 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
556 AsNestedNameSpecifier =
true;
566 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
586 R.QualifierIsInformative =
false;
590 R.Declaration->getDeclContext());
597 switch (T->getTypeClass()) {
599 switch (cast<BuiltinType>(T)->getKind()) {
600 case BuiltinType::Void:
603 case BuiltinType::NullPtr:
606 case BuiltinType::Overload:
607 case BuiltinType::Dependent:
610 case BuiltinType::ObjCId:
611 case BuiltinType::ObjCClass:
612 case BuiltinType::ObjCSel:
625 case Type::BlockPointer:
628 case Type::LValueReference:
629 case Type::RValueReference:
632 case Type::ConstantArray:
633 case Type::IncompleteArray:
634 case Type::VariableArray:
635 case Type::DependentSizedArray:
638 case Type::DependentSizedExtVector:
640 case Type::ExtVector:
643 case Type::FunctionProto:
644 case Type::FunctionNoProto:
653 case Type::ObjCObject:
654 case Type::ObjCInterface:
655 case Type::ObjCObjectPointer:
668 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
670 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
675 T = Function->getCallResultType();
676 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND))
677 T = Method->getSendResultType();
678 else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND))
680 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
682 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
683 T =
Value->getType();
697 if (
Pointer->getPointeeType()->isFunctionType()) {
711 T = Function->getReturnType();
721 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
729 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
730 if (ImplicitParam->getIdentifier() &&
731 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
738 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
740 if (isa<CXXDestructorDecl>(ND))
752 if (isa<EnumConstantDecl>(ND))
758 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
769 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
772 if (!PreferredSelector.
isNull())
773 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
774 if (PreferredSelector == Method->getSelector())
789 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
801 return Record->
lookup(ConstructorName);
804 void ResultBuilder::MaybeAddConstructorResults(Result R) {
805 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
812 Record = ClassTemplate->getTemplatedDecl();
813 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
815 if (isa<ClassTemplateSpecializationDecl>(Record))
827 R.Declaration = Ctor;
829 Results.push_back(R);
834 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
835 ND = Tmpl->getTemplatedDecl();
836 return isa<CXXConstructorDecl>(ND);
839 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
840 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
842 if (R.Kind != Result::RK_Declaration) {
844 Results.push_back(R);
849 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
851 getBasePriority(Using->getTargetDecl()),
854 MaybeAddResult(Result, CurContext);
861 bool AsNestedNameSpecifier =
false;
862 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
869 ShadowMap &
SMap = ShadowMaps.back();
870 ShadowMapEntry::iterator I, IEnd;
871 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
872 if (NamePos != SMap.end()) {
873 I = NamePos->second.begin();
874 IEnd = NamePos->second.end();
877 for (; I != IEnd; ++I) {
879 unsigned Index = I->second;
882 Results[Index].Declaration = R.Declaration;
892 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
894 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
895 ShadowMapEntry::iterator I, IEnd;
896 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
897 if (NamePos != SM->end()) {
898 I = NamePos->second.begin();
899 IEnd = NamePos->second.end();
901 for (; I != IEnd; ++I) {
903 if (I->first->hasTagIdentifierNamespace() &&
911 I->first->getIdentifierNamespace() != IDNS)
915 if (CheckHiddenResult(R, CurContext, I->first))
923 if (!AllDeclsFound.insert(CanonDecl).second)
928 if (AsNestedNameSpecifier) {
929 R.StartsNestedNameSpecifier =
true;
932 AdjustResultPriorityForDecl(R);
935 if (R.QualifierIsInformative && !R.Qualifier &&
936 !R.StartsNestedNameSpecifier) {
937 const DeclContext *Ctx = R.Declaration->getDeclContext();
938 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
941 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
943 SemaRef.
Context,
nullptr,
false,
946 R.QualifierIsInformative =
false;
951 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
952 Results.push_back(R);
954 if (!AsNestedNameSpecifier)
955 MaybeAddConstructorResults(R);
963 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
964 NamedDecl *Hiding,
bool InBaseClass =
false) {
965 if (R.Kind != Result::RK_Declaration) {
967 Results.push_back(R);
972 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
974 getBasePriority(Using->getTargetDecl()),
977 AddResult(Result, CurContext, Hiding);
981 bool AsNestedNameSpecifier =
false;
982 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
989 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
993 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
998 if (AsNestedNameSpecifier) {
999 R.StartsNestedNameSpecifier =
true;
1001 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1004 R.Declaration->getDeclContext()->getRedeclContext()))
1005 R.QualifierIsInformative =
true;
1008 if (R.QualifierIsInformative && !R.Qualifier &&
1009 !R.StartsNestedNameSpecifier) {
1010 const DeclContext *Ctx = R.Declaration->getDeclContext();
1011 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1014 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1016 SemaRef.
Context,
nullptr,
false,
1019 R.QualifierIsInformative =
false;
1026 AdjustResultPriorityForDecl(R);
1028 if (HasObjectTypeQualifiers)
1029 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1030 if (Method->isInstance()) {
1031 Qualifiers MethodQuals = Method->getTypeQualifiers();
1032 if (ObjectTypeQualifiers == MethodQuals)
1034 else if (ObjectTypeQualifiers - MethodQuals) {
1042 Results.push_back(R);
1044 if (!AsNestedNameSpecifier)
1045 MaybeAddConstructorResults(R);
1048 void ResultBuilder::AddResult(Result R) {
1049 assert(R.Kind != Result::RK_Declaration &&
1050 "Declaration results need more context");
1051 Results.push_back(R);
1055 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1058 void ResultBuilder::ExitScope() {
1059 for (ShadowMap::iterator E = ShadowMaps.back().begin(),
1060 EEnd = ShadowMaps.back().end();
1062 E->second.Destroy();
1064 ShadowMaps.pop_back();
1069 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1078 if (isa<ObjCIvarDecl>(ND))
1087 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1089 if (isa<TypeDecl>(ND))
1094 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1095 if (!
ID->getDefinition())
1103 if (isa<ObjCIvarDecl>(ND))
1110 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1111 if (!IsOrdinaryNonTypeName(ND))
1115 if (VD->getType()->isIntegralOrEnumerationType())
1123 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1131 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1136 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1138 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1139 ND = ClassTemplate->getTemplatedDecl();
1145 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1146 return isa<EnumDecl>(ND);
1150 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1152 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1153 ND = ClassTemplate->getTemplatedDecl();
1156 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1164 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1166 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1167 ND = ClassTemplate->getTemplatedDecl();
1169 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1176 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1177 return isa<NamespaceDecl>(ND);
1182 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1187 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1189 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1195 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1197 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1198 isa<ObjCPropertyDecl>(ND);
1204 case Type::ObjCObject:
1205 case Type::ObjCInterface:
1206 case Type::ObjCObjectPointer:
1210 switch (cast<BuiltinType>(T)->getKind()) {
1211 case BuiltinType::ObjCId:
1212 case BuiltinType::ObjCClass:
1213 case BuiltinType::ObjCSel:
1234 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1243 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1245 if (IsObjCMessageReceiver(ND))
1248 const auto *Var = dyn_cast<
VarDecl>(ND);
1255 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1256 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1257 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1270 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1276 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1277 return isa<ObjCIvarDecl>(ND);
1285 ResultBuilder &Results;
1291 std::vector<FixItHint> FixIts;
1294 CodeCompletionDeclConsumer(
1295 ResultBuilder &Results,
DeclContext *InitialLookupCtx,
1297 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1298 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1299 FixIts(std::move(FixIts)) {
1300 NamingClass = llvm::dyn_cast<
CXXRecordDecl>(InitialLookupCtx);
1303 auto ThisType = Results.getSema().getCurrentThisType();
1304 if (!ThisType.isNull()) {
1305 assert(ThisType->isPointerType());
1308 NamingClass = BaseType->getAsCXXRecordDecl();
1311 this->BaseType = BaseType;
1315 bool InBaseClass)
override {
1318 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
1322 Results.addVisitedContext(Ctx);
1331 auto *NamingClass = this->NamingClass;
1332 QualType BaseType = this->BaseType;
1333 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1348 NamingClass =
nullptr;
1351 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1358 ResultBuilder &Results) {
1360 Results.AddResult(Result(
"short",
CCP_Type));
1361 Results.AddResult(Result(
"long",
CCP_Type));
1362 Results.AddResult(Result(
"signed",
CCP_Type));
1363 Results.AddResult(Result(
"unsigned",
CCP_Type));
1364 Results.AddResult(Result(
"void",
CCP_Type));
1365 Results.AddResult(Result(
"char",
CCP_Type));
1366 Results.AddResult(Result(
"int",
CCP_Type));
1367 Results.AddResult(Result(
"float",
CCP_Type));
1368 Results.AddResult(Result(
"double",
CCP_Type));
1369 Results.AddResult(Result(
"enum",
CCP_Type));
1370 Results.AddResult(Result(
"struct",
CCP_Type));
1371 Results.AddResult(Result(
"union",
CCP_Type));
1372 Results.AddResult(Result(
"const",
CCP_Type));
1373 Results.AddResult(Result(
"volatile",
CCP_Type));
1377 Results.AddResult(Result(
"_Complex",
CCP_Type));
1378 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1379 Results.AddResult(Result(
"_Bool",
CCP_Type));
1380 Results.AddResult(Result(
"restrict",
CCP_Type));
1384 Results.getCodeCompletionTUInfo());
1385 if (LangOpts.CPlusPlus) {
1389 Results.AddResult(Result(
"class",
CCP_Type));
1390 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1393 Builder.AddTypedTextChunk(
"typename");
1395 Builder.AddPlaceholderChunk(
"qualifier");
1396 Builder.AddTextChunk(
"::");
1397 Builder.AddPlaceholderChunk(
"name");
1398 Results.AddResult(Result(Builder.TakeString()));
1400 if (LangOpts.CPlusPlus11) {
1401 Results.AddResult(Result(
"auto",
CCP_Type));
1402 Results.AddResult(Result(
"char16_t",
CCP_Type));
1403 Results.AddResult(Result(
"char32_t",
CCP_Type));
1405 Builder.AddTypedTextChunk(
"decltype");
1407 Builder.AddPlaceholderChunk(
"expression");
1409 Results.AddResult(Result(Builder.TakeString()));
1412 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1415 if (LangOpts.GNUKeywords) {
1421 Builder.AddTypedTextChunk(
"typeof");
1423 Builder.AddPlaceholderChunk(
"expression");
1424 Results.AddResult(Result(Builder.TakeString()));
1426 Builder.AddTypedTextChunk(
"typeof");
1428 Builder.AddPlaceholderChunk(
"type");
1430 Results.AddResult(Result(Builder.TakeString()));
1434 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1435 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1436 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1441 ResultBuilder &Results) {
1446 Results.AddResult(Result(
"extern"));
1447 Results.AddResult(Result(
"static"));
1449 if (LangOpts.CPlusPlus11) {
1454 Builder.AddTypedTextChunk(
"alignas");
1456 Builder.AddPlaceholderChunk(
"expression");
1458 Results.AddResult(Result(Builder.TakeString()));
1460 Results.AddResult(Result(
"constexpr"));
1461 Results.AddResult(Result(
"thread_local"));
1467 ResultBuilder &Results) {
1472 if (LangOpts.CPlusPlus) {
1473 Results.AddResult(Result(
"explicit"));
1474 Results.AddResult(Result(
"friend"));
1475 Results.AddResult(Result(
"mutable"));
1476 Results.AddResult(Result(
"virtual"));
1484 if (LangOpts.CPlusPlus || LangOpts.C99)
1485 Results.AddResult(Result(
"inline"));
1504 ResultBuilder &Results,
bool NeedAt);
1506 ResultBuilder &Results,
bool NeedAt);
1508 ResultBuilder &Results,
bool NeedAt);
1513 Results.getCodeCompletionTUInfo());
1514 Builder.AddTypedTextChunk(
"typedef");
1516 Builder.AddPlaceholderChunk(
"type");
1518 Builder.AddPlaceholderChunk(
"name");
1539 return LangOpts.CPlusPlus;
1546 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
1549 llvm_unreachable(
"Invalid ParserCompletionContext!");
1577 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1578 return BT->getNameAsCString(Policy);
1581 if (
const TagType *TagT = dyn_cast<TagType>(T))
1582 if (
TagDecl *Tag = TagT->getDecl())
1583 if (!Tag->hasNameForLinkage()) {
1584 switch (Tag->getTagKind()) {
1586 return "struct <anonymous>";
1588 return "__interface <anonymous>";
1590 return "class <anonymous>";
1592 return "union <anonymous>";
1594 return "enum <anonymous>";
1614 Builder.AddResultTypeChunk(
1616 Builder.AddTypedTextChunk(
"this");
1621 ResultBuilder &Results,
1623 if (!LangOpts.CPlusPlus11)
1637 for (
const auto &C : *CCS) {
1651 Sema &S = Results.getSema();
1658 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
1659 for (
auto *Method : CR->methods()) {
1660 if (!Method->isVirtual() || !Method->getIdentifier())
1662 Overrides[Method->getName()].push_back(Method);
1665 for (
const auto &
Base : CR->bases()) {
1666 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
1669 for (
auto *Method : BR->methods()) {
1670 if (!Method->isVirtual() || !Method->getIdentifier())
1672 const auto it = Overrides.find(Method->getName());
1673 bool IsOverriden =
false;
1674 if (it != Overrides.end()) {
1675 for (
auto *MD : it->second) {
1688 std::string OverrideSignature;
1689 llvm::raw_string_ostream OS(OverrideSignature);
1695 false, CCContext, Policy);
1704 Sema &SemaRef, ResultBuilder &Results) {
1712 if (Results.includeCodePatterns()) {
1714 Builder.AddTypedTextChunk(
"namespace");
1716 Builder.AddPlaceholderChunk(
"identifier");
1718 Builder.AddPlaceholderChunk(
"declarations");
1721 Results.AddResult(Result(Builder.TakeString()));
1725 Builder.AddTypedTextChunk(
"namespace");
1727 Builder.AddPlaceholderChunk(
"name");
1729 Builder.AddPlaceholderChunk(
"namespace");
1730 Results.AddResult(Result(Builder.TakeString()));
1733 Builder.AddTypedTextChunk(
"using");
1735 Builder.AddTextChunk(
"namespace");
1737 Builder.AddPlaceholderChunk(
"identifier");
1738 Results.AddResult(Result(Builder.TakeString()));
1741 Builder.AddTypedTextChunk(
"asm");
1743 Builder.AddPlaceholderChunk(
"string-literal");
1745 Results.AddResult(Result(Builder.TakeString()));
1747 if (Results.includeCodePatterns()) {
1749 Builder.AddTypedTextChunk(
"template");
1751 Builder.AddPlaceholderChunk(
"declaration");
1752 Results.AddResult(Result(Builder.TakeString()));
1767 Builder.AddTypedTextChunk(
"using");
1769 Builder.AddPlaceholderChunk(
"qualifier");
1770 Builder.AddTextChunk(
"::");
1771 Builder.AddPlaceholderChunk(
"name");
1772 Results.AddResult(Result(Builder.TakeString()));
1776 Builder.AddTypedTextChunk(
"using");
1778 Builder.AddTextChunk(
"typename");
1780 Builder.AddPlaceholderChunk(
"qualifier");
1781 Builder.AddTextChunk(
"::");
1782 Builder.AddPlaceholderChunk(
"name");
1783 Results.AddResult(Result(Builder.TakeString()));
1791 bool IsNotInheritanceScope =
1794 Builder.AddTypedTextChunk(
"public");
1795 if (IsNotInheritanceScope && Results.includeCodePatterns())
1797 Results.AddResult(Result(Builder.TakeString()));
1800 Builder.AddTypedTextChunk(
"protected");
1801 if (IsNotInheritanceScope && Results.includeCodePatterns())
1803 Results.AddResult(Result(Builder.TakeString()));
1806 Builder.AddTypedTextChunk(
"private");
1807 if (IsNotInheritanceScope && Results.includeCodePatterns())
1809 Results.AddResult(Result(Builder.TakeString()));
1822 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1824 Builder.AddTypedTextChunk(
"template");
1826 Builder.AddPlaceholderChunk(
"parameters");
1828 Results.AddResult(Result(Builder.TakeString()));
1857 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1859 Builder.AddTypedTextChunk(
"try");
1861 Builder.AddPlaceholderChunk(
"statements");
1864 Builder.AddTextChunk(
"catch");
1866 Builder.AddPlaceholderChunk(
"declaration");
1869 Builder.AddPlaceholderChunk(
"statements");
1872 Results.AddResult(Result(Builder.TakeString()));
1877 if (Results.includeCodePatterns()) {
1879 Builder.AddTypedTextChunk(
"if");
1882 Builder.AddPlaceholderChunk(
"condition");
1884 Builder.AddPlaceholderChunk(
"expression");
1887 Builder.AddPlaceholderChunk(
"statements");
1890 Results.AddResult(Result(Builder.TakeString()));
1893 Builder.AddTypedTextChunk(
"switch");
1896 Builder.AddPlaceholderChunk(
"condition");
1898 Builder.AddPlaceholderChunk(
"expression");
1903 Results.AddResult(Result(Builder.TakeString()));
1910 Builder.AddTypedTextChunk(
"case");
1912 Builder.AddPlaceholderChunk(
"expression");
1914 Results.AddResult(Result(Builder.TakeString()));
1917 Builder.AddTypedTextChunk(
"default");
1919 Results.AddResult(Result(Builder.TakeString()));
1922 if (Results.includeCodePatterns()) {
1924 Builder.AddTypedTextChunk(
"while");
1927 Builder.AddPlaceholderChunk(
"condition");
1929 Builder.AddPlaceholderChunk(
"expression");
1932 Builder.AddPlaceholderChunk(
"statements");
1935 Results.AddResult(Result(Builder.TakeString()));
1938 Builder.AddTypedTextChunk(
"do");
1940 Builder.AddPlaceholderChunk(
"statements");
1943 Builder.AddTextChunk(
"while");
1945 Builder.AddPlaceholderChunk(
"expression");
1947 Results.AddResult(Result(Builder.TakeString()));
1950 Builder.AddTypedTextChunk(
"for");
1953 Builder.AddPlaceholderChunk(
"init-statement");
1955 Builder.AddPlaceholderChunk(
"init-expression");
1957 Builder.AddPlaceholderChunk(
"condition");
1959 Builder.AddPlaceholderChunk(
"inc-expression");
1963 Builder.AddPlaceholderChunk(
"statements");
1966 Results.AddResult(Result(Builder.TakeString()));
1971 Builder.AddTypedTextChunk(
"continue");
1972 Results.AddResult(Result(Builder.TakeString()));
1977 Builder.AddTypedTextChunk(
"break");
1978 Results.AddResult(Result(Builder.TakeString()));
1983 bool isVoid =
false;
1984 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext))
1985 isVoid = Function->getReturnType()->isVoidType();
1986 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1987 isVoid = Method->getReturnType()->isVoidType();
1991 Builder.AddTypedTextChunk(
"return");
1994 Builder.AddPlaceholderChunk(
"expression");
1996 Results.AddResult(Result(Builder.TakeString()));
1999 Builder.AddTypedTextChunk(
"goto");
2001 Builder.AddPlaceholderChunk(
"label");
2002 Results.AddResult(Result(Builder.TakeString()));
2005 Builder.AddTypedTextChunk(
"using");
2007 Builder.AddTextChunk(
"namespace");
2009 Builder.AddPlaceholderChunk(
"identifier");
2010 Results.AddResult(Result(Builder.TakeString()));
2027 Builder.AddTypedTextChunk(
"__bridge");
2029 Builder.AddPlaceholderChunk(
"type");
2031 Builder.AddPlaceholderChunk(
"expression");
2032 Results.AddResult(Result(Builder.TakeString()));
2035 Builder.AddTypedTextChunk(
"__bridge_transfer");
2037 Builder.AddPlaceholderChunk(
"Objective-C type");
2039 Builder.AddPlaceholderChunk(
"expression");
2040 Results.AddResult(Result(Builder.TakeString()));
2043 Builder.AddTypedTextChunk(
"__bridge_retained");
2045 Builder.AddPlaceholderChunk(
"CF type");
2047 Builder.AddPlaceholderChunk(
"expression");
2048 Results.AddResult(Result(Builder.TakeString()));
2059 Builder.AddResultTypeChunk(
"bool");
2060 Builder.AddTypedTextChunk(
"true");
2061 Results.AddResult(Result(Builder.TakeString()));
2064 Builder.AddResultTypeChunk(
"bool");
2065 Builder.AddTypedTextChunk(
"false");
2066 Results.AddResult(Result(Builder.TakeString()));
2070 Builder.AddTypedTextChunk(
"dynamic_cast");
2072 Builder.AddPlaceholderChunk(
"type");
2075 Builder.AddPlaceholderChunk(
"expression");
2077 Results.AddResult(Result(Builder.TakeString()));
2081 Builder.AddTypedTextChunk(
"static_cast");
2083 Builder.AddPlaceholderChunk(
"type");
2086 Builder.AddPlaceholderChunk(
"expression");
2088 Results.AddResult(Result(Builder.TakeString()));
2091 Builder.AddTypedTextChunk(
"reinterpret_cast");
2093 Builder.AddPlaceholderChunk(
"type");
2096 Builder.AddPlaceholderChunk(
"expression");
2098 Results.AddResult(Result(Builder.TakeString()));
2101 Builder.AddTypedTextChunk(
"const_cast");
2103 Builder.AddPlaceholderChunk(
"type");
2106 Builder.AddPlaceholderChunk(
"expression");
2108 Results.AddResult(Result(Builder.TakeString()));
2112 Builder.AddResultTypeChunk(
"std::type_info");
2113 Builder.AddTypedTextChunk(
"typeid");
2115 Builder.AddPlaceholderChunk(
"expression-or-type");
2117 Results.AddResult(Result(Builder.TakeString()));
2121 Builder.AddTypedTextChunk(
"new");
2123 Builder.AddPlaceholderChunk(
"type");
2125 Builder.AddPlaceholderChunk(
"expressions");
2127 Results.AddResult(Result(Builder.TakeString()));
2130 Builder.AddTypedTextChunk(
"new");
2132 Builder.AddPlaceholderChunk(
"type");
2134 Builder.AddPlaceholderChunk(
"size");
2137 Builder.AddPlaceholderChunk(
"expressions");
2139 Results.AddResult(Result(Builder.TakeString()));
2142 Builder.AddResultTypeChunk(
"void");
2143 Builder.AddTypedTextChunk(
"delete");
2145 Builder.AddPlaceholderChunk(
"expression");
2146 Results.AddResult(Result(Builder.TakeString()));
2149 Builder.AddResultTypeChunk(
"void");
2150 Builder.AddTypedTextChunk(
"delete");
2155 Builder.AddPlaceholderChunk(
"expression");
2156 Results.AddResult(Result(Builder.TakeString()));
2160 Builder.AddResultTypeChunk(
"void");
2161 Builder.AddTypedTextChunk(
"throw");
2163 Builder.AddPlaceholderChunk(
"expression");
2164 Results.AddResult(Result(Builder.TakeString()));
2171 Builder.AddResultTypeChunk(
"std::nullptr_t");
2172 Builder.AddTypedTextChunk(
"nullptr");
2173 Results.AddResult(Result(Builder.TakeString()));
2176 Builder.AddResultTypeChunk(
"size_t");
2177 Builder.AddTypedTextChunk(
"alignof");
2179 Builder.AddPlaceholderChunk(
"type");
2181 Results.AddResult(Result(Builder.TakeString()));
2184 Builder.AddResultTypeChunk(
"bool");
2185 Builder.AddTypedTextChunk(
"noexcept");
2187 Builder.AddPlaceholderChunk(
"expression");
2189 Results.AddResult(Result(Builder.TakeString()));
2192 Builder.AddResultTypeChunk(
"size_t");
2193 Builder.AddTypedTextChunk(
"sizeof...");
2195 Builder.AddPlaceholderChunk(
"parameter-pack");
2197 Results.AddResult(Result(Builder.TakeString()));
2206 if (
ID->getSuperClass()) {
2207 std::string SuperType;
2208 SuperType =
ID->getSuperClass()->getNameAsString();
2209 if (Method->isInstanceMethod())
2212 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2213 Builder.AddTypedTextChunk(
"super");
2214 Results.AddResult(Result(Builder.TakeString()));
2223 Builder.AddResultTypeChunk(
"size_t");
2225 Builder.AddTypedTextChunk(
"alignof");
2227 Builder.AddTypedTextChunk(
"_Alignof");
2229 Builder.AddPlaceholderChunk(
"type");
2231 Results.AddResult(Result(Builder.TakeString()));
2235 Builder.AddResultTypeChunk(
"size_t");
2236 Builder.AddTypedTextChunk(
"sizeof");
2238 Builder.AddPlaceholderChunk(
"expression-or-type");
2240 Results.AddResult(Result(Builder.TakeString()));
2253 Results.AddResult(Result(
"operator"));
2273 T = Function->getReturnType();
2274 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2276 T = Method->getSendResultType(BaseType);
2278 T = Method->getReturnType();
2279 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2280 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2282 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2284 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2286 T = Ivar->getUsageType(BaseType);
2288 T = Ivar->getType();
2289 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2290 T =
Value->getType();
2291 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2293 T =
Property->getUsageType(BaseType);
2308 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2309 if (Sentinel->getSentinel() == 0) {
2329 Result +=
"bycopy ";
2333 Result +=
"oneway ";
2336 switch (*nullability) {
2338 Result +=
"nonnull ";
2342 Result +=
"nullable ";
2346 Result +=
"null_unspecified ";
2363 bool SuppressBlock =
false) {
2369 if (!SuppressBlock) {
2372 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2385 TL = AttrTL.getModifiedLoc();
2404 bool SuppressBlockName =
false,
2405 bool SuppressBlock =
false,
2406 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2410 bool SuppressName =
false,
bool SuppressBlock =
false,
2411 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2412 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2419 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2426 if (ObjCMethodParam) {
2446 if (!Block && ObjCMethodParam &&
2447 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2448 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2449 ->findPropertyDecl(
false))
2463 if (ObjCMethodParam) {
2468 Result =
"(" + Quals +
" " + Result +
")";
2469 if (Result.back() !=
')')
2483 false, SuppressBlock,
2499 bool SuppressBlockName,
bool SuppressBlock,
2500 Optional<ArrayRef<QualType>> ObjCSubsts) {
2507 if (!ResultType->
isVoidType() || SuppressBlock)
2519 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2532 if (SuppressBlock) {
2534 Result = Result +
" (^";
2541 Result =
'^' + Result;
2556 bool Invalid = CharSrcRange.
isInvalid();
2564 if (srcText.empty() || srcText ==
"=") {
2570 std::string DefValue(srcText.str());
2573 if (DefValue.at(0) !=
'=') {
2577 return " = " + DefValue;
2579 return " " + DefValue;
2588 bool InOptional =
false) {
2589 bool FirstParameter =
true;
2599 if (!FirstParameter)
2607 FirstParameter =
false;
2620 PlaceholderStr +=
", ...";
2628 if (Proto->isVariadic()) {
2629 if (Proto->getNumParams() == 0)
2640 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
2641 bool FirstParameter =
true;
2650 PEnd = Params->begin() + MaxParameters;
2653 bool HasDefaultArg =
false;
2654 std::string PlaceholderStr;
2656 if (TTP->wasDeclaredWithTypename())
2657 PlaceholderStr =
"typename";
2659 PlaceholderStr =
"class";
2661 if (TTP->getIdentifier()) {
2662 PlaceholderStr +=
' ';
2666 HasDefaultArg = TTP->hasDefaultArgument();
2668 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2669 if (NTTP->getIdentifier())
2670 PlaceholderStr = NTTP->getIdentifier()->getName();
2671 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2672 HasDefaultArg = NTTP->hasDefaultArgument();
2674 assert(isa<TemplateTemplateParmDecl>(*
P));
2679 PlaceholderStr =
"template<...> class";
2681 PlaceholderStr +=
' ';
2688 if (HasDefaultArg && !InDefaultArg) {
2693 if (!FirstParameter)
2696 P - Params->begin(),
true);
2701 InDefaultArg =
false;
2704 FirstParameter =
false;
2718 bool QualifierIsInformative,
2724 std::string PrintedNNS;
2726 llvm::raw_string_ostream OS(PrintedNNS);
2727 Qualifier->
print(OS, Policy);
2729 if (QualifierIsInformative)
2739 if (!Proto || !Proto->getTypeQuals())
2745 if (Proto->getTypeQuals().hasOnlyConst()) {
2750 if (Proto->getTypeQuals().hasOnlyVolatile()) {
2755 if (Proto->getTypeQuals().hasOnlyRestrict()) {
2761 std::string QualsStr;
2762 if (Proto->isConst())
2763 QualsStr +=
" const";
2764 if (Proto->isVolatile())
2765 QualsStr +=
" volatile";
2766 if (Proto->isRestrict())
2767 QualsStr +=
" restrict";
2781 const char *OperatorName =
nullptr;
2784 case OO_Conditional:
2786 OperatorName =
"operator";
2789 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 2791 OperatorName = "operator" Spelling; \ 2793 #define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly) 2794 #include "clang/Basic/OperatorKinds.def" 2797 OperatorName =
"operator new";
2800 OperatorName =
"operator delete";
2803 OperatorName =
"operator new[]";
2805 case OO_Array_Delete:
2806 OperatorName =
"operator delete[]";
2809 OperatorName =
"operator()";
2812 OperatorName =
"operator[]";
2838 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2840 Record = InjectedTy->getDecl();
2862 bool IncludeBriefComments) {
2863 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2864 CCTUInfo, IncludeBriefComments);
2870 assert(
Kind == RK_Macro);
2922 bool IncludeBriefComments) {
2923 if (
Kind == RK_Macro)
2924 return CreateCodeCompletionStringForMacro(PP, Allocator, CCTUInfo);
2929 if (
Kind == RK_Pattern) {
2930 Pattern->Priority = Priority;
2931 Pattern->Availability = Availability;
2946 if (
Kind == RK_Keyword) {
2950 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2951 return createCodeCompletionStringForDecl(
2952 PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
2960 std::string OverrideSignature;
2961 llvm::raw_string_ostream OS(OverrideSignature);
2962 auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
2978 if (IncludeBriefComments) {
2985 if (StartsNestedNameSpecifier) {
2997 if (
const auto *Function = dyn_cast<FunctionDecl>(ND)) {
3009 dyn_cast<FunctionTemplateDecl>(ND)) {
3017 llvm::SmallBitVector Deduced;
3019 unsigned LastDeducibleArgument;
3020 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3021 --LastDeducibleArgument) {
3022 if (!Deduced[LastDeducibleArgument - 1]) {
3026 bool HasDefaultArg =
false;
3027 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3028 LastDeducibleArgument - 1);
3030 HasDefaultArg = TTP->hasDefaultArgument();
3032 dyn_cast<NonTypeTemplateParmDecl>(Param))
3033 HasDefaultArg = NTTP->hasDefaultArgument();
3035 assert(isa<TemplateTemplateParmDecl>(Param));
3037 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3045 if (LastDeducibleArgument) {
3051 LastDeducibleArgument);
3063 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3073 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3074 Selector Sel = Method->getSelector();
3083 if (StartParameter == 0)
3090 if (Method->param_size() == 1)
3095 PEnd = Method->param_end();
3096 P != PEnd; (void)++
P, ++Idx) {
3098 std::string Keyword;
3099 if (Idx > StartParameter)
3102 Keyword += II->getName();
3104 if (Idx < StartParameter || AllParametersAreInformative)
3111 if (Idx < StartParameter)
3115 QualType ParamType = (*P)->getType();
3131 if (DeclaringEntity || AllParametersAreInformative)
3132 Arg += II->getName();
3135 if (Method->isVariadic() && (
P + 1) == PEnd)
3138 if (DeclaringEntity)
3140 else if (AllParametersAreInformative)
3146 if (Method->isVariadic()) {
3147 if (Method->param_size() == 0) {
3148 if (DeclaringEntity)
3150 else if (AllParametersAreInformative)
3191 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3192 if (!M || !M->isPropertyAccessor())
3218 if (ArgIndex < FDecl->getNumParams())
3230 unsigned CurrentArg,
unsigned Start = 0,
3231 bool InOptional =
false) {
3232 bool FirstParameter =
true;
3233 unsigned NumParams =
3236 for (
unsigned P = Start;
P != NumParams; ++
P) {
3242 if (!FirstParameter)
3246 CurrentArg,
P,
true);
3252 FirstParameter =
false;
3259 std::string Placeholder;
3270 if (
P == CurrentArg)
3280 if (!FirstParameter)
3283 if (CurrentArg < NumParams)
3284 Opt.AddPlaceholderChunk(
"...");
3286 Opt.AddCurrentParameterChunk(
"...");
3304 if (!FDecl && !Proto) {
3317 if (IncludeBriefComments) {
3334 return Result.TakeString();
3339 bool PreferredTypeIsPointer) {
3343 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3344 MacroName.equals(
"Nil")) {
3346 if (PreferredTypeIsPointer)
3350 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3351 MacroName.equals(
"true") || MacroName.equals(
"false"))
3354 else if (MacroName.equals(
"bool"))
3367 case Decl::EnumConstant:
3373 case Decl::ObjCCategory:
3375 case Decl::ObjCCategoryImpl:
3377 case Decl::ObjCImplementation:
3380 case Decl::ObjCInterface:
3382 case Decl::ObjCIvar:
3384 case Decl::ObjCMethod:
3388 case Decl::CXXMethod:
3390 case Decl::CXXConstructor:
3392 case Decl::CXXDestructor:
3394 case Decl::CXXConversion:
3396 case Decl::ObjCProperty:
3398 case Decl::ObjCProtocol:
3404 case Decl::TypeAlias:
3406 case Decl::TypeAliasTemplate:
3410 case Decl::Namespace:
3412 case Decl::NamespaceAlias:
3414 case Decl::TemplateTypeParm:
3416 case Decl::NonTypeTemplateParm:
3418 case Decl::TemplateTemplateParm:
3420 case Decl::FunctionTemplate:
3422 case Decl::ClassTemplate:
3424 case Decl::AccessSpec:
3426 case Decl::ClassTemplatePartialSpecialization:
3428 case Decl::UsingDirective:
3430 case Decl::StaticAssert:
3434 case Decl::TranslationUnit:
3438 case Decl::UnresolvedUsingValue:
3439 case Decl::UnresolvedUsingTypename:
3442 case Decl::ObjCPropertyImpl:
3443 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3450 llvm_unreachable(
"Unexpected Kind!");
3455 case Decl::ObjCTypeParam:
3459 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
3460 switch (TD->getTagKind()) {
3478 bool LoadExternal,
bool IncludeUndefined,
3479 bool TargetTypeIsPointer =
false) {
3482 Results.EnterNewScope();
3488 if (IncludeUndefined || MD) {
3494 Result(M->first, MI,
3496 TargetTypeIsPointer)));
3500 Results.ExitScope();
3504 ResultBuilder &Results) {
3507 Results.EnterNewScope();
3509 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3510 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3511 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3513 Results.ExitScope();
3520 unsigned NumResults) {
3580 llvm_unreachable(
"Invalid ParserCompletionContext!");
3592 ResultBuilder &Results) {
3595 while (isa<BlockDecl>(CurContext))
3605 if (!
P->getDeclName())
3611 Results.getCodeCompletionTUInfo());
3618 S.
Context, CurContext, Overridden->getDeclContext());
3621 llvm::raw_string_ostream OS(Str);
3622 NNS->
print(OS, Policy);
3623 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3625 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3628 Builder.AddTypedTextChunk(
3629 Results.getAllocator().CopyString(Overridden->getNameAsString()));
3631 bool FirstParam =
true;
3638 Builder.AddPlaceholderChunk(
3639 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3645 Results.Ignore(Overridden);
3652 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3653 CodeCompleter->getCodeCompletionTUInfo(),
3655 Results.EnterNewScope();
3663 PP.getHeaderSearchInfo().collectAllModules(Modules);
3664 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
3665 Builder.AddTypedTextChunk(
3666 Builder.getAllocator().CopyString(Modules[I]->Name));
3667 Results.AddResult(Result(
3672 }
else if (getLangOpts().Modules) {
3681 Sub != SubEnd; ++Sub) {
3683 Builder.AddTypedTextChunk(
3684 Builder.getAllocator().CopyString((*Sub)->Name));
3685 Results.AddResult(Result(
3692 Results.ExitScope();
3694 Results.data(), Results.size());
3699 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3700 CodeCompleter->getCodeCompletionTUInfo(),
3702 Results.EnterNewScope();
3707 switch (CompletionContext) {
3710 case PCC_ObjCInterface:
3711 case PCC_ObjCImplementation:
3712 case PCC_ObjCInstanceVariableList:
3714 case PCC_MemberTemplate:
3716 case PCC_LocalDeclarationSpecifiers:
3717 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3721 case PCC_ParenthesizedExpression:
3722 case PCC_Expression:
3726 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3728 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3734 case PCC_RecoveryInFunction:
3741 auto ThisType = getCurrentThisType();
3742 if (!ThisType.isNull())
3743 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers());
3745 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3747 CodeCompleter->includeGlobals(),
3748 CodeCompleter->loadExternal());
3751 Results.ExitScope();
3753 switch (CompletionContext) {
3754 case PCC_ParenthesizedExpression:
3755 case PCC_Expression:
3757 case PCC_RecoveryInFunction:
3764 case PCC_ObjCInterface:
3765 case PCC_ObjCImplementation:
3766 case PCC_ObjCInstanceVariableList:
3768 case PCC_MemberTemplate:
3772 case PCC_LocalDeclarationSpecifiers:
3776 if (CodeCompleter->includeMacros())
3780 Results.data(), Results.size());
3786 bool AtArgumentExpression,
bool IsSuper,
3787 ResultBuilder &Results);
3790 bool AllowNonIdentifiers,
3791 bool AllowNestedNameSpecifiers) {
3793 ResultBuilder Results(
3794 *
this, CodeCompleter->getAllocator(),
3795 CodeCompleter->getCodeCompletionTUInfo(),
3796 AllowNestedNameSpecifiers
3801 Results.EnterNewScope();
3804 Results.AddResult(Result(
"const"));
3805 Results.AddResult(Result(
"volatile"));
3806 if (getLangOpts().
C99)
3807 Results.AddResult(Result(
"restrict"));
3813 Results.AddResult(
"final");
3815 if (AllowNonIdentifiers) {
3816 Results.AddResult(Result(
"operator"));
3820 if (AllowNestedNameSpecifiers) {
3821 Results.allowNestedNameSpecifiers();
3822 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3823 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3825 CodeCompleter->includeGlobals(),
3826 CodeCompleter->loadExternal());
3827 Results.setFilter(
nullptr);
3830 Results.ExitScope();
3836 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3855 Results.data(), Results.size());
3860 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3861 ObjCCollection(
false) {}
3873 ResultBuilder Results(
3874 *
this, CodeCompleter->getAllocator(),
3875 CodeCompleter->getCodeCompletionTUInfo(),
3879 Results.setFilter(&ResultBuilder::IsObjCCollection);
3881 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3883 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3885 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3891 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
3894 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3896 CodeCompleter->includeGlobals(),
3897 CodeCompleter->loadExternal());
3899 Results.EnterNewScope();
3901 Results.ExitScope();
3903 bool PreferredTypeIsPointer =
false;
3913 if (CodeCompleter->includeMacros())
3915 PreferredTypeIsPointer);
3917 Results.data(), Results.size());
3926 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3927 else if (getLangOpts().ObjC)
3928 CodeCompleteObjCInstanceMessage(S, E.
get(), None,
false);
3938 if (Interface->hasDefinition())
3939 return Interface->getDefinition();
3945 if (Protocol->hasDefinition())
3946 return Protocol->getDefinition();
3970 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
3975 std::string PlaceholderStr =
3978 if (I == N - 1 && BlockProtoLoc &&
3980 PlaceholderStr +=
", ...";
3994 bool AllowNullaryMethods,
DeclContext *CurContext,
3995 AddedPropertiesSet &AddedProperties, ResultBuilder &Results,
3996 bool IsBaseExprStatement =
false,
3997 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
4005 if (!AddedProperties.insert(
P->getIdentifier()).second)
4010 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
4011 !IsBaseExprStatement) {
4012 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4013 if (!InOriginalClass)
4015 Results.MaybeAddResult(R, CurContext);
4026 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4027 if (!InOriginalClass)
4029 Results.MaybeAddResult(R, CurContext);
4036 Results.getCodeCompletionTUInfo());
4039 BlockLoc, BlockProtoLoc);
4040 Result R = Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
4041 if (!InOriginalClass)
4043 Results.MaybeAddResult(R, CurContext);
4047 if (!
P->isReadOnly()) {
4049 Results.getCodeCompletionTUInfo());
4053 Builder.AddTypedTextChunk(
4054 Results.getAllocator().CopyString(
P->getName()));
4059 BlockProtoLoc,
true);
4061 Builder.AddPlaceholderChunk(
4062 Builder.getAllocator().CopyString(PlaceholderStr));
4070 Result(Builder.TakeString(),
P,
4071 Results.getBasePriority(
P) +
4075 if (!InOriginalClass)
4077 Results.MaybeAddResult(R, CurContext);
4081 if (IsClassProperty) {
4090 if (AllowNullaryMethods) {
4095 IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
4098 if (!AddedProperties.insert(Name).second)
4101 Results.getCodeCompletionTUInfo());
4103 Builder.AddTypedTextChunk(
4104 Results.getAllocator().CopyString(Name->
getName()));
4105 Result R = Result(Builder.TakeString(), M,
4107 if (!InOriginalClass)
4109 Results.MaybeAddResult(R, CurContext);
4112 if (IsClassProperty) {
4113 for (
const auto *M : Container->
methods()) {
4117 if (!M->getSelector().isUnarySelector() ||
4118 M->getReturnType()->isVoidType() || M->isInstanceMethod())
4123 for (
auto *M : Container->
methods()) {
4124 if (M->getSelector().isUnarySelector())
4132 for (
auto *
P : Protocol->protocols())
4134 CurContext, AddedProperties, Results,
4135 IsBaseExprStatement, IsClassProperty,
4138 dyn_cast<ObjCInterfaceDecl>(Container)) {
4139 if (AllowCategories) {
4141 for (
auto *Cat : IFace->known_categories())
4143 CurContext, AddedProperties, Results,
4144 IsBaseExprStatement, IsClassProperty,
4149 for (
auto *I : IFace->all_referenced_protocols())
4151 CurContext, AddedProperties, Results,
4152 IsBaseExprStatement, IsClassProperty,
4156 if (IFace->getSuperClass())
4158 AllowNullaryMethods, CurContext, AddedProperties,
4159 Results, IsBaseExprStatement, IsClassProperty,
4162 dyn_cast<ObjCCategoryDecl>(Container)) {
4166 CurContext, AddedProperties, Results,
4167 IsBaseExprStatement, IsClassProperty,
4175 Optional<FixItHint> AccessOpFixIt) {
4181 Results.allowNestedNameSpecifiers();
4182 std::vector<FixItHint> FixIts;
4184 FixIts.emplace_back(AccessOpFixIt.getValue());
4185 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
4192 if (!Results.empty()) {
4198 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
4200 IsDependent = Ctx->isDependentContext();
4214 bool IsBaseExprStatement) {
4215 if (!Base || !CodeCompleter)
4218 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4221 QualType ConvertedBaseType = ConvertedBase.
get()->getType();
4242 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4243 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4244 &ResultBuilder::IsMember);
4246 auto DoCompletion = [&](
Expr *Base,
bool IsArrow,
4251 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4254 Base = ConvertedBase.
get();
4270 std::move(AccessOpFixIt));
4271 }
else if (
const auto *TST =
4274 if (
const auto *TD =
4278 std::move(AccessOpFixIt));
4281 if (
auto *RD = ICNT->getDecl())
4283 std::move(AccessOpFixIt));
4286 AddedPropertiesSet AddedProperties;
4291 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4294 AddedProperties, Results, IsBaseExprStatement);
4300 CurContext, AddedProperties, Results,
4301 IsBaseExprStatement,
false,
4309 Class = ObjCPtr->getInterfaceDecl();
4315 CodeCompletionDeclConsumer Consumer(Results, Class, BaseType);
4316 Results.setFilter(&ResultBuilder::IsObjCIvar);
4318 Class, LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
4319 false, CodeCompleter->loadExternal());
4327 Results.EnterNewScope();
4329 bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
4330 if (CodeCompleter->includeFixIts()) {
4333 CompletionSucceded |= DoCompletion(
4334 OtherOpBase, !IsArrow,
4338 Results.ExitScope();
4340 if (!CompletionSucceded)
4345 Results.data(), Results.size());
4351 bool IsBaseExprStatement) {
4358 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4359 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4360 &ResultBuilder::IsMember);
4361 Results.EnterNewScope();
4362 AddedPropertiesSet AddedProperties;
4364 true, CurContext, AddedProperties,
4365 Results, IsBaseExprStatement,
4367 Results.ExitScope();
4369 Results.data(), Results.size());
4376 ResultBuilder::LookupFilter Filter =
nullptr;
4381 Filter = &ResultBuilder::IsEnum;
4386 Filter = &ResultBuilder::IsUnion;
4393 Filter = &ResultBuilder::IsClassOrStruct;
4398 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4401 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4402 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4403 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4406 Results.setFilter(Filter);
4408 CodeCompleter->includeGlobals(),
4409 CodeCompleter->loadExternal());
4411 if (CodeCompleter->includeGlobals()) {
4413 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4415 CodeCompleter->includeGlobals(),
4416 CodeCompleter->loadExternal());
4420 Results.data(), Results.size());
4426 Results.AddResult(
"const");
4428 Results.AddResult(
"volatile");
4430 Results.AddResult(
"restrict");
4432 Results.AddResult(
"_Atomic");
4434 Results.AddResult(
"__unaligned");
4438 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4439 CodeCompleter->getCodeCompletionTUInfo(),
4441 Results.EnterNewScope();
4443 Results.ExitScope();
4445 Results.data(), Results.size());
4450 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4451 CodeCompleter->getCodeCompletionTUInfo(),
4453 Results.EnterNewScope();
4455 if (LangOpts.CPlusPlus11) {
4456 Results.AddResult(
"noexcept");
4460 Results.AddResult(
"final");
4462 Results.AddResult(
"override");
4465 Results.ExitScope();
4467 Results.data(), Results.size());
4471 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4475 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4478 SwitchStmt *Switch = getCurFunction()->SwitchStack.back().getPointer();
4486 CodeCompleteExpression(S, Data);
4500 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
4509 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
4510 if (
auto *Enumerator =
4511 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
4518 EnumeratorsSeen.insert(Enumerator);
4531 Qualifier = DRE->getQualifier();
4535 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
4543 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4544 CodeCompleter->getCodeCompletionTUInfo(),
4546 Results.EnterNewScope();
4548 if (EnumeratorsSeen.count(E))
4552 Results.AddResult(R, CurContext,
nullptr,
false);
4554 Results.ExitScope();
4556 if (CodeCompleter->includeMacros()) {
4560 Results.data(), Results.size());
4564 if (Args.size() && !Args.data())
4567 for (
unsigned I = 0; I != Args.size(); ++I)
4579 if (!CandidateSet.
empty()) {
4582 CandidateSet.
begin(), CandidateSet.
end(),
4590 if (Candidate.Function && Candidate.Function->isDeleted())
4592 if (Candidate.Viable)
4601 ArrayRef<ResultCandidate> Candidates,
unsigned N) {
4607 for (
auto &Candidate : Candidates) {
4608 if (
const auto *FType = Candidate.getFunctionType())
4609 if (
const auto *Proto = dyn_cast<FunctionProtoType>(FType))
4610 if (N < Proto->getNumParams()) {
4612 ParamType = Proto->getParamType(N);
4615 Proto->getParamType(N).getNonReferenceType()))
4628 if (Candidates.empty())
4631 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
4655 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4656 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4658 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4660 if (UME->hasExplicitTemplateArgs()) {
4661 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4662 TemplateArgs = &TemplateArgsBuffer;
4667 1, UME->isImplicitAccess() ? nullptr : UME->getBase());
4668 ArgExprs.append(Args.begin(), Args.end());
4670 Decls.
append(UME->decls_begin(), UME->decls_end());
4671 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
4672 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4674 true, FirstArgumentIsBase);
4677 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
4679 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
4680 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4682 if (!getLangOpts().CPlusPlus ||
4695 if (isCompleteType(Loc, NakedFn->
getType())) {
4698 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4699 LookupQualifiedName(R, DC);
4702 ArgExprs.append(Args.begin(), Args.end());
4716 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4719 Results.push_back(ResultCandidate(FP));
4749 for (
NamedDecl *C : LookupConstructors(RD)) {
4750 if (
auto *FD = dyn_cast<FunctionDecl>(C)) {
4755 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(C)) {
4756 AddTemplateOverloadCandidate(
4758 nullptr, Args, CandidateSet,
4780 if (
ValueDecl *MemberDecl = tryLookupCtorInitMemberDecl(
4781 Constructor->
getParent(), SS, TemplateTypeTy, II))
4782 return ProduceConstructorSignatureHelp(getCurScope(), MemberDecl->getType(),
4783 MemberDecl->getLocation(), ArgExprs,
4789 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4791 CodeCompleteOrdinaryName(S, PCC_Expression);
4800 CodeCompleteExpression(S, Data);
4805 if (isa<BlockDecl>(CurContext)) {
4807 ResultType = BSI->ReturnType;
4808 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(CurContext))
4809 ResultType = Function->getReturnType();
4810 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4811 ResultType = Method->getReturnType();
4814 CodeCompleteOrdinaryName(S, PCC_Expression);
4816 CodeCompleteExpression(S, ResultType);
4820 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4821 CodeCompleter->getCodeCompletionTUInfo(),
4823 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4824 Results.EnterNewScope();
4826 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4828 CodeCompleter->includeGlobals(),
4829 CodeCompleter->loadExternal());
4835 Results.getCodeCompletionTUInfo());
4836 Builder.AddTypedTextChunk(
"else");
4837 if (Results.includeCodePatterns()) {
4841 Builder.AddPlaceholderChunk(
"statements");
4845 Results.AddResult(Builder.TakeString());
4848 Builder.AddTypedTextChunk(
"else");
4850 Builder.AddTextChunk(
"if");
4854 Builder.AddPlaceholderChunk(
"condition");
4856 Builder.AddPlaceholderChunk(
"expression");
4858 if (Results.includeCodePatterns()) {
4862 Builder.AddPlaceholderChunk(
"statements");
4866 Results.AddResult(Builder.TakeString());
4868 Results.ExitScope();
4873 if (CodeCompleter->includeMacros())
4877 Results.data(), Results.size());
4887 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
4890 if (Op == tok::minus)
4901 case tok::plusequal:
4903 case tok::minusequal:
4905 case tok::percentequal:
4907 case tok::slashequal:
4909 case tok::starequal:
4913 case tok::equalequal:
4914 case tok::exclaimequal:
4916 case tok::lessequal:
4918 case tok::greaterequal:
4919 case tok::spaceship:
4922 case tok::greatergreater:
4923 case tok::greatergreaterequal:
4925 case tok::lesslessequal:
4932 case tok::caretcaret:
4937 case tok::pipeequal:
4939 case tok::caretequal:
4947 case tok::periodstar:
4948 case tok::arrowstar:
4959 if (!PreferredType.
isNull())
4960 CodeCompleteExpression(S, PreferredType);
4962 CodeCompleteOrdinaryName(S, PCC_Expression);
4966 bool EnteringContext,
QualType BaseType) {
4967 if (SS.
isEmpty() || !CodeCompleter)
4988 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4991 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4992 CodeCompleter->getCodeCompletionTUInfo(),
4994 Results.EnterNewScope();
5000 Results.AddResult(
"template");
5007 if (!EnteringContext)
5009 Results.ExitScope();
5011 if (CodeCompleter->includeNamespaceLevelDecls() ||
5013 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
5017 CodeCompleter->loadExternal());
5020 auto CC = Results.getCompletionContext();
5021 CC.setCXXScopeSpecifier(SS);
5031 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5032 CodeCompleter->getCodeCompletionTUInfo(),
5037 &ResultBuilder::IsNestedNameSpecifier);
5038 Results.EnterNewScope();
5046 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5048 CodeCompleter->includeGlobals(),
5049 CodeCompleter->loadExternal());
5050 Results.ExitScope();
5053 Results.data(), Results.size());
5062 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5063 CodeCompleter->getCodeCompletionTUInfo(),
5065 &ResultBuilder::IsNamespaceOrAlias);
5066 Results.EnterNewScope();
5067 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5069 CodeCompleter->includeGlobals(),
5070 CodeCompleter->loadExternal());
5071 Results.ExitScope();
5073 Results.data(), Results.size());
5084 bool SuppressedGlobalResults =
5085 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
5087 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5088 CodeCompleter->getCodeCompletionTUInfo(),
5089 SuppressedGlobalResults
5092 &ResultBuilder::IsNamespace);
5094 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
5099 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
5104 OrigToLatest[NS->getOriginalNamespace()] = *NS;
5108 Results.EnterNewScope();
5109 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
5110 NS = OrigToLatest.begin(),
5111 NSEnd = OrigToLatest.end();
5116 CurContext,
nullptr,
false);
5117 Results.ExitScope();
5121 Results.data(), Results.size());
5129 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5130 CodeCompleter->getCodeCompletionTUInfo(),
5132 &ResultBuilder::IsNamespaceOrAlias);
5133 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5135 CodeCompleter->includeGlobals(),
5136 CodeCompleter->loadExternal());
5138 Results.data(), Results.size());
5146 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5147 CodeCompleter->getCodeCompletionTUInfo(),
5149 &ResultBuilder::IsType);
5150 Results.EnterNewScope();
5153 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 5154 if (std::strcmp(Spelling, "?")) \ 5155 Results.AddResult(Result(Spelling)); 5156 #include "clang/Basic/OperatorKinds.def" 5159 Results.allowNestedNameSpecifiers();
5160 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5162 CodeCompleter->includeGlobals(),
5163 CodeCompleter->loadExternal());
5167 Results.ExitScope();
5170 Results.data(), Results.size());
5178 AdjustDeclIfTemplate(ConstructorD);
5184 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5185 CodeCompleter->getCodeCompletionTUInfo(),
5187 Results.EnterNewScope();
5190 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
5191 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
5192 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
5193 if (Initializers[I]->isBaseInitializer())
5195 QualType(Initializers[I]->getBaseClass(), 0)));
5197 InitializedFields.insert(
5198 cast<FieldDecl>(Initializers[I]->getAnyMember()));
5203 bool SawLastInitializer = Initializers.empty();
5206 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
5208 Results.getCodeCompletionTUInfo());
5209 Builder.AddTypedTextChunk(Name);
5211 if (
const auto *Function = dyn_cast<FunctionDecl>(ND))
5213 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
5217 return Builder.TakeString();
5219 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
5222 Results.getCodeCompletionTUInfo());
5223 Builder.AddTypedTextChunk(Name);
5225 Builder.AddPlaceholderChunk(Type);
5229 Builder.TakeString(), ND,
5231 if (isa<FieldDecl>(ND))
5233 return Results.AddResult(CCR);
5236 Builder.TakeString(),
5239 auto AddCtorsWithName = [&](
const CXXRecordDecl *RD,
unsigned int Priority,
5240 const char *Name,
const FieldDecl *FD) {
5242 return AddDefaultCtorInit(Name,
5243 FD ? Results.getAllocator().CopyString(
5244 FD->getType().getAsString(Policy))
5248 if (Ctors.begin() == Ctors.end())
5249 return AddDefaultCtorInit(Name, Name, RD);
5253 Results.AddResult(CCR);
5257 const char *BaseName =
5258 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
5259 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
5264 auto AddField = [&](
const FieldDecl *FD) {
5265 const char *FieldName =
5266 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
5267 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
5273 for (
const auto &
Base : ClassDecl->
bases()) {
5276 SawLastInitializer =
5277 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5279 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5284 SawLastInitializer =
false;
5288 for (
const auto &
Base : ClassDecl->
vbases()) {
5291 SawLastInitializer =
5292 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5294 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5299 SawLastInitializer =
false;
5303 for (
auto *Field : ClassDecl->
fields()) {
5304 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
5306 SawLastInitializer = !Initializers.empty() &&
5307 Initializers.back()->isAnyMemberInitializer() &&
5308 Initializers.back()->getAnyMember() == Field;
5312 if (!Field->getDeclName())
5316 SawLastInitializer =
false;
5318 Results.ExitScope();
5321 Results.data(), Results.size());
5334 bool AfterAmpersand) {
5335 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5336 CodeCompleter->getCodeCompletionTUInfo(),
5338 Results.EnterNewScope();
5341 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
5342 bool IncludedThis =
false;
5343 for (
const auto &C : Intro.
Captures) {
5345 IncludedThis =
true;
5354 for (
const auto *D : S->
decls()) {
5355 const auto *Var = dyn_cast<
VarDecl>(D);
5356 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
5359 if (Known.insert(Var->getIdentifier()).second)
5361 CurContext,
nullptr,
false);
5369 Results.ExitScope();
5372 Results.data(), Results.size());
5377 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword) 5380 ResultBuilder &Results,
bool NeedAt) {
5386 Results.getCodeCompletionTUInfo());
5387 if (LangOpts.ObjC) {
5391 Builder.AddPlaceholderChunk(
"property");
5392 Results.AddResult(Result(Builder.TakeString()));
5397 Builder.AddPlaceholderChunk(
"property");
5398 Results.AddResult(Result(Builder.TakeString()));
5403 ResultBuilder &Results,
bool NeedAt) {
5409 if (LangOpts.ObjC) {
5424 Results.getCodeCompletionTUInfo());
5429 Builder.AddPlaceholderChunk(
"name");
5430 Results.AddResult(Result(Builder.TakeString()));
5432 if (Results.includeCodePatterns()) {
5438 Builder.AddPlaceholderChunk(
"class");
5439 Results.AddResult(Result(Builder.TakeString()));
5444 Builder.AddPlaceholderChunk(
"protocol");
5445 Results.AddResult(Result(Builder.TakeString()));
5450 Builder.AddPlaceholderChunk(
"class");
5451 Results.AddResult(Result(Builder.TakeString()));
5455 Builder.AddTypedTextChunk(
5458 Builder.AddPlaceholderChunk(
"alias");
5460 Builder.AddPlaceholderChunk(
"class");
5461 Results.AddResult(Result(Builder.TakeString()));
5463 if (Results.getSema().getLangOpts().Modules) {
5467 Builder.AddPlaceholderChunk(
"module");
5468 Results.AddResult(Result(Builder.TakeString()));
5473 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5474 CodeCompleter->getCodeCompletionTUInfo(),
5476 Results.EnterNewScope();
5477 if (isa<ObjCImplDecl>(CurContext))
5483 Results.ExitScope();
5485 Results.data(), Results.size());
5491 Results.getCodeCompletionTUInfo());
5494 const char *EncodeType =
"char[]";
5495 if (Results.getSema().getLangOpts().CPlusPlus ||
5496 Results.getSema().getLangOpts().ConstStrings)
5497 EncodeType =
"const char[]";
5498 Builder.AddResultTypeChunk(EncodeType);
5501 Builder.AddPlaceholderChunk(
"type-name");
5503 Results.AddResult(Result(Builder.TakeString()));
5506 Builder.AddResultTypeChunk(
"Protocol *");
5509 Builder.AddPlaceholderChunk(
"protocol-name");
5511 Results.AddResult(Result(Builder.TakeString()));
5514 Builder.AddResultTypeChunk(
"SEL");
5517 Builder.AddPlaceholderChunk(
"selector");
5519 Results.AddResult(Result(Builder.TakeString()));
5522 Builder.AddResultTypeChunk(
"NSString *");
5524 Builder.AddPlaceholderChunk(
"string");
5525 Builder.AddTextChunk(
"\"");
5526 Results.AddResult(Result(Builder.TakeString()));
5529 Builder.AddResultTypeChunk(
"NSArray *");
5531 Builder.AddPlaceholderChunk(
"objects, ...");
5533 Results.AddResult(Result(Builder.TakeString()));
5536 Builder.AddResultTypeChunk(
"NSDictionary *");
5538 Builder.AddPlaceholderChunk(
"key");
5541 Builder.AddPlaceholderChunk(
"object, ...");
5543 Results.AddResult(Result(Builder.TakeString()));
5546 Builder.AddResultTypeChunk(
"id");
5548 Builder.AddPlaceholderChunk(
"expression");
5550 Results.AddResult(Result(Builder.TakeString()));
5556 Results.getCodeCompletionTUInfo());
5558 if (Results.includeCodePatterns()) {
5563 Builder.AddPlaceholderChunk(
"statements");
5565 Builder.AddTextChunk(
"@catch");
5567 Builder.AddPlaceholderChunk(
"parameter");
5570 Builder.AddPlaceholderChunk(
"statements");
5572 Builder.AddTextChunk(
"@finally");
5574 Builder.AddPlaceholderChunk(
"statements");
5576 Results.AddResult(Result(Builder.TakeString()));
5582 Builder.AddPlaceholderChunk(
"expression");
5583 Results.AddResult(Result(Builder.TakeString()));
5585 if (Results.includeCodePatterns()) {
5590 Builder.AddPlaceholderChunk(
"expression");
5593 Builder.AddPlaceholderChunk(
"statements");
5595 Results.AddResult(Result(Builder.TakeString()));
5600 ResultBuilder &Results,
bool NeedAt) {
5610 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5611 CodeCompleter->getCodeCompletionTUInfo(),
5613 Results.EnterNewScope();
5615 Results.ExitScope();
5617 Results.data(), Results.size());
5621 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5622 CodeCompleter->getCodeCompletionTUInfo(),
5624 Results.EnterNewScope();
5627 Results.ExitScope();
5629 Results.data(), Results.size());
5633 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5634 CodeCompleter->getCodeCompletionTUInfo(),
5636 Results.EnterNewScope();
5638 Results.ExitScope();
5640 Results.data(), Results.size());
5647 if (Attributes & NewFlag)
5650 Attributes |= NewFlag;
5658 unsigned AssignCopyRetMask =
5680 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5681 CodeCompleter->getCodeCompletionTUInfo(),
5683 Results.EnterNewScope();
5711 Results.getCodeCompletionTUInfo());
5713 Setter.AddTextChunk(
"=");
5714 Setter.AddPlaceholderChunk(
"method");
5719 Results.getCodeCompletionTUInfo());
5721 Getter.AddTextChunk(
"=");
5722 Getter.AddPlaceholderChunk(
"method");
5731 Results.ExitScope();
5733 Results.data(), Results.size());
5745 ArrayRef<IdentifierInfo *> SelIdents,
5746 bool AllowSameLength =
true) {
5747 unsigned NumSelIdents = SelIdents.size();
5760 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
5763 for (
unsigned I = 0; I != NumSelIdents; ++I)
5772 ArrayRef<IdentifierInfo *> SelIdents,
5773 bool AllowSameLength =
true) {
5804 ArrayRef<IdentifierInfo *> SelIdents,
5806 VisitedSelectorSet &Selectors,
bool AllowSameLength,
5807 ResultBuilder &Results,
bool InOriginalClass =
true,
5808 bool IsRootClass =
false) {
5812 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
5816 if (M->isInstanceMethod() == WantInstanceMethods ||
5817 (IsRootClass && !WantInstanceMethods)) {
5823 if (!Selectors.insert(M->getSelector()).second)
5826 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5827 R.StartParameter = SelIdents.size();
5828 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5829 if (!InOriginalClass)
5831 Results.MaybeAddResult(R, CurContext);
5836 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
5837 if (Protocol->hasDefinition()) {
5839 Protocol->getReferencedProtocols();
5841 E = Protocols.
end();
5843 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5844 Selectors, AllowSameLength, Results,
false, IsRootClass);
5853 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5854 Selectors, AllowSameLength, Results,
false, IsRootClass);
5858 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5859 CurContext, Selectors, AllowSameLength, Results,
5860 InOriginalClass, IsRootClass);
5864 CatDecl->getReferencedProtocols();
5866 E = Protocols.
end();
5868 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5869 Selectors, AllowSameLength, Results,
false, IsRootClass);
5873 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5874 Selectors, AllowSameLength, Results, InOriginalClass,
5882 SelIdents, CurContext, Selectors, AllowSameLength, Results,
5887 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5888 Selectors, AllowSameLength, Results, InOriginalClass,
5897 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5898 Class =
Category->getClassInterface();
5905 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5906 CodeCompleter->getCodeCompletionTUInfo(),
5908 Results.EnterNewScope();
5910 VisitedSelectorSet Selectors;
5913 Results.ExitScope();
5915 Results.data(), Results.size());
5923 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5924 Class =
Category->getClassInterface();
5931 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5932 CodeCompleter->getCodeCompletionTUInfo(),
5934 Results.EnterNewScope();
5936 VisitedSelectorSet Selectors;
5940 Results.ExitScope();
5942 Results.data(), Results.size());
5947 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5948 CodeCompleter->getCodeCompletionTUInfo(),
5950 Results.EnterNewScope();
5953 bool AddedInOut =
false;
5956 Results.AddResult(
"in");
5957 Results.AddResult(
"inout");
5962 Results.AddResult(
"out");
5964 Results.AddResult(
"inout");
5969 Results.AddResult(
"bycopy");
5970 Results.AddResult(
"byref");
5971 Results.AddResult(
"oneway");
5974 Results.AddResult(
"nonnull");
5975 Results.AddResult(
"nullable");
5976 Results.AddResult(
"null_unspecified");
5984 PP.isMacroDefined(
"IBAction")) {
5986 Results.getCodeCompletionTUInfo(),
5988 Builder.AddTypedTextChunk(
"IBAction");
5990 Builder.AddPlaceholderChunk(
"selector");
5993 Builder.AddTextChunk(
"id");
5995 Builder.AddTextChunk(
"sender");
6006 Results.ExitScope();
6009 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
6010 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6012 CodeCompleter->includeGlobals(),
6013 CodeCompleter->loadExternal());
6015 if (CodeCompleter->includeMacros())
6019 Results.data(), Results.size());
6027 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
6045 switch (Msg->getReceiverKind()) {
6049 IFace = ObjType->getInterface();
6053 QualType T = Msg->getInstanceReceiver()->getType();
6055 IFace = Ptr->getInterfaceDecl();
6069 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6070 .Case(
"retain", IFace)
6071 .Case(
"strong", IFace)
6072 .Case(
"autorelease", IFace)
6073 .Case(
"copy", IFace)
6074 .Case(
"copyWithZone", IFace)
6075 .Case(
"mutableCopy", IFace)
6076 .Case(
"mutableCopyWithZone", IFace)
6077 .Case(
"awakeFromCoder", IFace)
6078 .Case(
"replacementObjectFromCoder", IFace)
6079 .Case(
"class", IFace)
6080 .Case(
"classForCoder", IFace)
6081 .Case(
"superclass", Super)
6084 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6086 .Case(
"alloc", IFace)
6087 .Case(
"allocWithZone", IFace)
6088 .Case(
"class", IFace)
6089 .Case(
"superclass", Super)
6111 ArrayRef<IdentifierInfo *> SelIdents,
6112 ResultBuilder &Results) {
6131 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
6149 CurP != CurPEnd; ++CurP, ++SuperP) {
6152 (*SuperP)->getType()))
6156 if (!(*CurP)->getIdentifier())
6162 Results.getCodeCompletionTUInfo());
6166 Results.getCompletionContext().getBaseType(), Builder);
6169 if (NeedSuperKeyword) {
6170 Builder.AddTypedTextChunk(
"super");
6176 if (NeedSuperKeyword)
6177 Builder.AddTextChunk(
6180 Builder.AddTypedTextChunk(
6184 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
6185 if (I > SelIdents.size())
6188 if (I < SelIdents.size())
6189 Builder.AddInformativeChunk(
6191 else if (NeedSuperKeyword || I > SelIdents.size()) {
6192 Builder.AddTextChunk(
6194 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6195 (*CurP)->getIdentifier()->getName()));
6197 Builder.AddTypedTextChunk(
6199 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6200 (*CurP)->getIdentifier()->getName()));
6212 ResultBuilder Results(
6213 *
this, CodeCompleter->getAllocator(),
6214 CodeCompleter->getCodeCompletionTUInfo(),
6216 getLangOpts().CPlusPlus11
6217 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
6218 : &ResultBuilder::IsObjCMessageReceiver);
6220 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6221 Results.EnterNewScope();
6223 CodeCompleter->includeGlobals(),
6224 CodeCompleter->loadExternal());
6230 if (Iface->getSuperClass()) {
6231 Results.AddResult(Result(
"super"));
6239 Results.ExitScope();
6241 if (CodeCompleter->includeMacros())
6244 Results.data(), Results.size());
6249 bool AtArgumentExpression) {
6253 CDecl = CurMethod->getClassInterface();
6262 if (CurMethod->isInstanceMethod()) {
6266 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
6267 AtArgumentExpression, CDecl);
6275 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc, LookupOrdinaryName);
6276 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
6278 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
6281 CDecl = Iface->getInterface();
6282 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
6289 id.setIdentifier(Super, SuperLoc);
6291 ActOnIdExpression(S, SS, TemplateKWLoc,
id,
false,
false);
6292 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
6293 SelIdents, AtArgumentExpression);
6302 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
6303 AtArgumentExpression,
6310 unsigned NumSelIdents) {
6312 ASTContext &Context = Results.getSema().Context;
6316 Result *ResultsData = Results.data();
6317 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
6318 Result &R = ResultsData[I];
6319 if (R.Kind == Result::RK_Declaration &&
6320 isa<ObjCMethodDecl>(R.Declaration)) {
6321 if (R.Priority <= BestPriority) {
6322 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
6323 if (NumSelIdents <= Method->param_size()) {
6325 Method->
parameters()[NumSelIdents - 1]->getType();
6326 if (R.Priority < BestPriority || PreferredType.
isNull()) {
6327 BestPriority = R.Priority;
6328 PreferredType = MyPreferredType;
6338 return PreferredType;
6343 ArrayRef<IdentifierInfo *> SelIdents,
6344 bool AtArgumentExpression,
bool IsSuper,
6345 ResultBuilder &Results) {
6355 CDecl = Interface->getInterface();
6360 Results.EnterNewScope();
6367 Results.Ignore(SuperMethod);
6373 Results.setPreferredSelector(CurMethod->getSelector());
6375 VisitedSelectorSet Selectors;
6378 Selectors, AtArgumentExpression, Results);
6385 for (uint32_t I = 0,
6396 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
6400 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6404 Result R(MethList->getMethod(),
6405 Results.getBasePriority(MethList->getMethod()),
nullptr);
6406 R.StartParameter = SelIdents.size();
6407 R.AllParametersAreInformative =
false;
6408 Results.MaybeAddResult(R, SemaRef.
CurContext);
6413 Results.ExitScope();
6418 bool AtArgumentExpression,
6421 QualType T = this->GetTypeFromParser(Receiver);
6423 ResultBuilder Results(
6424 *
this, CodeCompleter->getAllocator(),
6425 CodeCompleter->getCodeCompletionTUInfo(),
6430 AtArgumentExpression, IsSuper, Results);
6437 if (AtArgumentExpression) {
6440 if (PreferredType.
isNull())
6441 CodeCompleteOrdinaryName(S, PCC_Expression);
6443 CodeCompleteExpression(S, PreferredType);
6448 Results.data(), Results.size());
6453 bool AtArgumentExpression,
6457 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6462 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6465 RecExpr = Conv.
get();
6479 return CodeCompleteObjCClassMessage(
6481 AtArgumentExpression, Super);
6486 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6487 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6489 RecExpr = Conv.
get();
6490 ReceiverType = RecExpr->
getType();
6495 ResultBuilder Results(
6496 *
this, CodeCompleter->getAllocator(),
6497 CodeCompleter->getCodeCompletionTUInfo(),
6499 ReceiverType, SelIdents));
6501 Results.EnterNewScope();
6508 Results.Ignore(SuperMethod);
6514 Results.setPreferredSelector(CurMethod->getSelector());
6517 VisitedSelectorSet Selectors;
6527 Selectors, AtArgumentExpression, Results);
6534 for (
auto *I : QualID->quals())
6536 AtArgumentExpression, Results);
6543 CurContext, Selectors, AtArgumentExpression, Results);
6546 for (
auto *I : IFacePtr->quals())
6548 AtArgumentExpression, Results);
6557 if (ExternalSource) {
6558 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6560 Selector Sel = ExternalSource->GetExternalSelector(I);
6561 if (Sel.
isNull() || MethodPool.count(Sel))
6564 ReadMethodPool(Sel);
6568 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6569 MEnd = MethodPool.end();
6572 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6576 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6579 Result R(MethList->getMethod(),
6580 Results.getBasePriority(MethList->getMethod()),
nullptr);
6581 R.StartParameter = SelIdents.size();
6582 R.AllParametersAreInformative =
false;
6583 Results.MaybeAddResult(R, CurContext);
6587 Results.ExitScope();
6594 if (AtArgumentExpression) {
6597 if (PreferredType.
isNull())
6598 CodeCompleteOrdinaryName(S, PCC_Expression);
6600 CodeCompleteExpression(S, PreferredType);
6605 Results.data(), Results.size());
6621 CodeCompleteExpression(S, Data);
6628 if (ExternalSource) {
6629 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
6631 Selector Sel = ExternalSource->GetExternalSelector(I);
6632 if (Sel.
isNull() || MethodPool.count(Sel))
6635 ReadMethodPool(Sel);
6639 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6640 CodeCompleter->getCodeCompletionTUInfo(),
6642 Results.EnterNewScope();
6643 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6644 MEnd = MethodPool.end();
6652 Results.getCodeCompletionTUInfo());
6654 Builder.AddTypedTextChunk(
6656 Results.AddResult(Builder.TakeString());
6660 std::string Accumulator;
6661 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
6662 if (I == SelIdents.size()) {
6663 if (!Accumulator.empty()) {
6664 Builder.AddInformativeChunk(
6665 Builder.getAllocator().CopyString(Accumulator));
6666 Accumulator.clear();
6673 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
6674 Results.AddResult(Builder.TakeString());
6676 Results.ExitScope();
6679 Results.data(), Results.size());
6685 bool OnlyForwardDeclarations,
6686 ResultBuilder &Results) {
6689 for (
const auto *D : Ctx->
decls()) {
6691 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
6692 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
6694 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
6701 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6702 CodeCompleter->getCodeCompletionTUInfo(),
6705 if (CodeCompleter->includeGlobals()) {
6706 Results.EnterNewScope();
6713 Results.Ignore(Protocol);
6719 Results.ExitScope();
6723 Results.data(), Results.size());
6727 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6728 CodeCompleter->getCodeCompletionTUInfo(),
6731 if (CodeCompleter->includeGlobals()) {
6732 Results.EnterNewScope();
6738 Results.ExitScope();
6742 Results.data(), Results.size());
6748 bool OnlyForwardDeclarations,
6749 bool OnlyUnimplemented,
6750 ResultBuilder &Results) {
6753 for (
const auto *D : Ctx->
decls()) {
6755 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
6756 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
6757 (!OnlyUnimplemented || !Class->getImplementation()))
6759 Result(Class, Results.getBasePriority(Class),
nullptr), CurContext,
6765 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6766 CodeCompleter->getCodeCompletionTUInfo(),
6768 Results.EnterNewScope();
6770 if (CodeCompleter->includeGlobals()) {
6776 Results.ExitScope();
6779 Results.data(), Results.size());
6784 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6785 CodeCompleter->getCodeCompletionTUInfo(),
6787 Results.EnterNewScope();
6791 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6792 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6793 Results.Ignore(CurClass);
6795 if (CodeCompleter->includeGlobals()) {
6801 Results.ExitScope();
6804 Results.data(), Results.size());
6808 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6809 CodeCompleter->getCodeCompletionTUInfo(),
6811 Results.EnterNewScope();
6813 if (CodeCompleter->includeGlobals()) {
6819 Results.ExitScope();
6822 Results.data(), Results.size());
6830 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6831 CodeCompleter->getCodeCompletionTUInfo(),
6836 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6838 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6840 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
6841 for (
const auto *Cat : Class->visible_categories())
6842 CategoryNames.insert(Cat->getIdentifier());
6846 Results.EnterNewScope();
6848 for (
const auto *D : TU->
decls())
6849 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6850 if (CategoryNames.insert(
Category->getIdentifier()).second)
6853 CurContext,
nullptr,
false);
6854 Results.ExitScope();
6857 Results.data(), Results.size());
6869 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6872 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6874 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6875 CodeCompleter->getCodeCompletionTUInfo(),
6881 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6882 Results.EnterNewScope();
6883 bool IgnoreImplemented =
true;
6886 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6887 CategoryNames.insert(Cat->getIdentifier()).second)
6888 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6889 CurContext,
nullptr,
false);
6893 IgnoreImplemented =
false;
6895 Results.ExitScope();
6898 Results.data(), Results.size());
6903 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6904 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
6908 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6909 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
6910 !isa<ObjCCategoryImplDecl>(Container)))
6915 for (
const auto *D : Container->decls())
6916 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6917 Results.Ignore(PropertyImpl->getPropertyDecl());
6920 AddedPropertiesSet AddedProperties;
6921 Results.EnterNewScope();
6923 dyn_cast<ObjCImplementationDecl>(Container))
6926 AddedProperties, Results);
6929 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6930 false,
false, CurContext,
6931 AddedProperties, Results);
6932 Results.ExitScope();
6935 Results.data(), Results.size());
6941 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6942 CodeCompleter->getCodeCompletionTUInfo(),
6947 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6948 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
6949 !isa<ObjCCategoryImplDecl>(Container)))
6955 dyn_cast<ObjCImplementationDecl>(Container))
6956 Class = ClassImpl->getClassInterface();
6958 Class = cast<ObjCCategoryImplDecl>(Container)
6960 ->getClassInterface();
6968 Property->getType().getNonReferenceType().getUnqualifiedType();
6971 Results.setPreferredType(PropertyType);
6976 Results.EnterNewScope();
6977 bool SawSimilarlyNamedIvar =
false;
6978 std::string NameWithPrefix;
6979 NameWithPrefix +=
'_';
6980 NameWithPrefix += PropertyName->
getName();
6981 std::string NameWithSuffix = PropertyName->
getName().str();
6982 NameWithSuffix +=
'_';
6986 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6987 CurContext,
nullptr,
false);
6991 if ((PropertyName == Ivar->getIdentifier() ||
6992 NameWithPrefix == Ivar->
getName() ||
6993 NameWithSuffix == Ivar->getName())) {
6994 SawSimilarlyNamedIvar =
true;
6998 if (Results.size() &&
6999 Results.data()[Results.size() - 1].Kind ==
7001 Results.data()[Results.size() - 1].Declaration == Ivar)
7002 Results.data()[Results.size() - 1].Priority--;
7007 if (!SawSimilarlyNamedIvar) {
7017 Builder.AddResultTypeChunk(
7019 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
7024 Results.ExitScope();
7027 Results.data(), Results.size());
7033 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
7042 Optional<bool> WantInstanceMethods,
7045 bool InOriginalClass =
true) {
7048 if (!IFace->hasDefinition())
7051 IFace = IFace->getDefinition();
7055 IFace->getReferencedProtocols();
7057 E = Protocols.
end();
7060 KnownMethods, InOriginalClass);
7063 for (
auto *Cat : IFace->visible_categories()) {
7065 KnownMethods,
false);
7069 if (IFace->getSuperClass())
7071 WantInstanceMethods, ReturnType, KnownMethods,
7078 Category->getReferencedProtocols();
7080 E = Protocols.
end();
7083 KnownMethods, InOriginalClass);
7086 if (InOriginalClass &&
Category->getClassInterface())
7088 WantInstanceMethods, ReturnType, KnownMethods,
7094 if (!Protocol->hasDefinition())
7096 Protocol = Protocol->getDefinition();
7097 Container = Protocol;
7101 Protocol->getReferencedProtocols();
7103 E = Protocols.
end();
7106 KnownMethods,
false);
7112 for (
auto *M : Container->
methods()) {
7113 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
7114 if (!ReturnType.
isNull() &&
7118 KnownMethods[M->getSelector()] =
7119 KnownMethodsMap::mapped_type(M, InOriginalClass);
7154 bool IsInstanceMethod,
7156 VisitedSelectorSet &KnownSelectors,
7157 ResultBuilder &Results) {
7159 if (!PropName || PropName->
getLength() == 0)
7177 const char *CopiedKey;
7180 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
7182 operator const char *() {
7186 return CopiedKey = Allocator.
CopyString(Key);
7188 } Key(Allocator, PropName->
getName());
7191 std::string UpperKey = PropName->
getName();
7192 if (!UpperKey.empty())
7195 bool ReturnTypeMatchesProperty =
7199 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
7202 if (IsInstanceMethod &&
7203 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
7209 Builder.AddTypedTextChunk(Key);
7216 if (IsInstanceMethod &&
7217 ((!ReturnType.
isNull() &&
7221 std::string SelectorName = (Twine(
"is") + UpperKey).
str();
7223 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7225 if (ReturnType.
isNull()) {
7227 Builder.AddTextChunk(
"BOOL");
7238 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
7240 std::string SelectorName = (Twine(
"set") + UpperKey).
str();
7242 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7243 if (ReturnType.
isNull()) {
7245 Builder.AddTextChunk(
"void");
7250 Builder.AddTypedTextChunk(
":");
7253 Builder.AddTextChunk(Key);
7264 if (
const auto *ObjCPointer =
7289 if (IsInstanceMethod &&
7291 std::string SelectorName = (Twine(
"countOf") + UpperKey).
str();
7293 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7295 if (ReturnType.
isNull()) {
7297 Builder.AddTextChunk(
"NSUInteger");
7303 Result(Builder.TakeString(),
7304 std::min(IndexedGetterPriority, UnorderedGetterPriority),
7311 if (IsInstanceMethod &&
7313 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").
str();
7315 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7316 if (ReturnType.
isNull()) {
7318 Builder.AddTextChunk(
"id");
7322 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7324 Builder.AddTextChunk(
"NSUInteger");
7326 Builder.AddTextChunk(
"index");
7327 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7333 if (IsInstanceMethod &&
7338 ->getInterfaceDecl()
7339 ->getName() ==
"NSArray"))) {
7340 std::string SelectorName = (Twine(Property->
getName()) +
"AtIndexes").str();
7342 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7343 if (ReturnType.
isNull()) {
7345 Builder.AddTextChunk(
"NSArray *");
7349 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7351 Builder.AddTextChunk(
"NSIndexSet *");
7353 Builder.AddTextChunk(
"indexes");
7354 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7360 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7361 std::string SelectorName = (Twine(
"get") + UpperKey).
str();
7365 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7366 if (ReturnType.
isNull()) {
7368 Builder.AddTextChunk(
"void");
7372 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7374 Builder.AddPlaceholderChunk(
"object-type");
7375 Builder.AddTextChunk(
" **");
7377 Builder.AddTextChunk(
"buffer");
7379 Builder.AddTypedTextChunk(
"range:");
7381 Builder.AddTextChunk(
"NSRange");
7383 Builder.AddTextChunk(
"inRange");
7384 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7392 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7393 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").
str();
7397 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7398 if (ReturnType.
isNull()) {
7400 Builder.AddTextChunk(
"void");
7404 Builder.AddTypedTextChunk(
"insertObject:");
7406 Builder.AddPlaceholderChunk(
"object-type");
7407 Builder.AddTextChunk(
" *");
7409 Builder.AddTextChunk(
"object");
7411 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7413 Builder.AddPlaceholderChunk(
"NSUInteger");
7415 Builder.AddTextChunk(
"index");
7416 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7422 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7423 std::string SelectorName = (Twine(
"insert") + UpperKey).
str();
7427 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7428 if (ReturnType.
isNull()) {
7430 Builder.AddTextChunk(
"void");
7434 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7436 Builder.AddTextChunk(
"NSArray *");
7438 Builder.AddTextChunk(
"array");
7440 Builder.AddTypedTextChunk(
"atIndexes:");
7442 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7444 Builder.AddTextChunk(
"indexes");
7445 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7451 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7452 std::string SelectorName =
7453 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").
str();
7455 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7456 if (ReturnType.
isNull()) {
7458 Builder.AddTextChunk(
"void");
7462 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7464 Builder.AddTextChunk(
"NSUInteger");
7466 Builder.AddTextChunk(
"index");
7467 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7473 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7474 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").
str();
7476 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7477 if (ReturnType.
isNull()) {
7479 Builder.AddTextChunk(
"void");
7483 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7485 Builder.AddTextChunk(
"NSIndexSet *");
7487 Builder.AddTextChunk(
"indexes");
7488 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7494 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7495 std::string SelectorName =
7496 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").
str();
7500 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7501 if (ReturnType.
isNull()) {
7503 Builder.AddTextChunk(
"void");
7507 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7509 Builder.AddPlaceholderChunk(
"NSUInteger");
7511 Builder.AddTextChunk(
"index");
7513 Builder.AddTypedTextChunk(
"withObject:");
7515 Builder.AddTextChunk(
"id");
7517 Builder.AddTextChunk(
"object");
7518 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7524 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7525 std::string SelectorName1 =
7526 (Twine(
"replace") + UpperKey +
"AtIndexes").
str();
7527 std::string SelectorName2 = (Twine(
"with") + UpperKey).
str();
7531 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7532 if (ReturnType.
isNull()) {
7534 Builder.AddTextChunk(
"void");
7538 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
7540 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7542 Builder.AddTextChunk(
"indexes");
7544 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
7546 Builder.AddTextChunk(
"NSArray *");
7548 Builder.AddTextChunk(
"array");
7549 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7556 if (IsInstanceMethod &&
7561 ->getInterfaceDecl()
7562 ->getName() ==
"NSEnumerator"))) {
7563 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).
str();
7565 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7567 if (ReturnType.
isNull()) {
7569 Builder.AddTextChunk(
"NSEnumerator *");
7573 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7574 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7580 if (IsInstanceMethod &&
7582 std::string SelectorName = (Twine(
"memberOf") + UpperKey).
str();
7584 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7585 if (ReturnType.
isNull()) {
7587 Builder.AddPlaceholderChunk(
"object-type");
7588 Builder.AddTextChunk(
" *");
7592 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7594 if (ReturnType.
isNull()) {
7595 Builder.AddPlaceholderChunk(
"object-type");
7596 Builder.AddTextChunk(
" *");
7599 ReturnType, Context, Policy, Builder.getAllocator()));
7602 Builder.AddTextChunk(
"object");
7603 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7610 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7611 std::string SelectorName =
7612 (Twine(
"add") + UpperKey + Twine(
"Object")).
str();
7614 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7615 if (ReturnType.
isNull()) {
7617 Builder.AddTextChunk(
"void");
7621 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7623 Builder.AddPlaceholderChunk(
"object-type");
7624 Builder.AddTextChunk(
" *");
7626 Builder.AddTextChunk(
"object");
7627 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7633 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7634 std::string SelectorName = (Twine(
"add") + UpperKey).
str();
7636 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7637 if (ReturnType.
isNull()) {
7639 Builder.AddTextChunk(
"void");
7643 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7645 Builder.AddTextChunk(
"NSSet *");
7647 Builder.AddTextChunk(
"objects");
7648 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7654 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7655 std::string SelectorName =
7656 (Twine(
"remove") + UpperKey + Twine(
"Object")).
str();
7658 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7659 if (ReturnType.
isNull()) {
7661 Builder.AddTextChunk(
"void");
7665 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7667 Builder.AddPlaceholderChunk(
"object-type");
7668 Builder.AddTextChunk(
" *");
7670 Builder.AddTextChunk(
"object");
7671 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7677 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7678 std::string SelectorName = (Twine(
"remove") + UpperKey).
str();
7680 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7681 if (ReturnType.
isNull()) {
7683 Builder.AddTextChunk(
"void");
7687 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7689 Builder.AddTextChunk(
"NSSet *");
7691 Builder.AddTextChunk(
"objects");
7692 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7698 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7699 std::string SelectorName = (Twine(
"intersect") + UpperKey).
str();
7701 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7702 if (ReturnType.
isNull()) {
7704 Builder.AddTextChunk(
"void");
7708 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7710 Builder.AddTextChunk(
"NSSet *");
7712 Builder.AddTextChunk(
"objects");
7713 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7720 if (!IsInstanceMethod &&
7725 ->getInterfaceDecl()
7726 ->getName() ==
"NSSet"))) {
7727 std::string SelectorName =
7728 (Twine(
"keyPathsForValuesAffecting") + UpperKey).
str();
7730 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7732 if (ReturnType.
isNull()) {
7734 Builder.AddTextChunk(
"NSSet<NSString *> *");
7738 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7745 if (!IsInstanceMethod &&
7748 std::string SelectorName =
7749 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).
str();
7751 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7753 if (ReturnType.
isNull()) {
7755 Builder.AddTextChunk(
"BOOL");
7759 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7770 QualType ReturnType = GetTypeFromParser(ReturnTy);
7771 Decl *IDecl =
nullptr;
7778 bool IsInImplementation =
false;
7779 if (
Decl *D = IDecl) {
7781 SearchDecl = Impl->getClassInterface();
7782 IsInImplementation =
true;
7784 dyn_cast<ObjCCategoryImplDecl>(D)) {
7785 SearchDecl = CatImpl->getCategoryDecl();
7786 IsInImplementation =
true;
7791 if (!SearchDecl && S) {
7793 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7809 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7810 CodeCompleter->getCodeCompletionTUInfo(),
7812 Results.EnterNewScope();
7814 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7815 MEnd = KnownMethods.end();
7819 Results.getCodeCompletionTUInfo());
7822 if (!IsInstanceMethod) {
7829 if (ReturnType.
isNull()) {
7839 Builder.AddTypedTextChunk(
7840 Builder.getAllocator().CopyString(Sel.getNameForSlot(0)));
7846 P != PEnd; (void)++
P, ++I) {
7849 Builder.AddTypedTextChunk(
":");
7850 else if (I < Sel.getNumArgs()) {
7852 Builder.AddTypedTextChunk(
7853 Builder.getAllocator().CopyString(Sel.getNameForSlot(I) +
":"));
7860 ParamType = (*P)->getType();
7862 ParamType = (*P)->getOriginalType();
7870 Builder.AddTextChunk(Builder.getAllocator().CopyString(
Id->getName()));
7876 Builder.AddTextChunk(
"...");
7879 if (IsInImplementation && Results.includeCodePatterns()) {
7886 Builder.AddTextChunk(
"return");
7888 Builder.AddPlaceholderChunk(
"expression");
7891 Builder.AddPlaceholderChunk(
"statements");
7898 auto R = Result(Builder.TakeString(), Method, Priority);
7899 if (!M->second.getInt())
7901 Results.AddResult(std::move(R));
7908 Containers.push_back(SearchDecl);
7910 VisitedSelectorSet KnownSelectors;
7911 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7912 MEnd = KnownMethods.end();
7914 KnownSelectors.insert(M->first);
7919 IFace =
Category->getClassInterface();
7923 Containers.push_back(Cat);
7925 if (IsInstanceMethod) {
7926 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
7927 for (
auto *
P : Containers[I]->instance_properties())
7929 KnownSelectors, Results);
7933 Results.ExitScope();
7936 Results.data(), Results.size());
7940 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
7944 if (ExternalSource) {
7945 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
7947 Selector Sel = ExternalSource->GetExternalSelector(I);
7948 if (Sel.
isNull() || MethodPool.count(Sel))
7951 ReadMethodPool(Sel);
7957 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7958 CodeCompleter->getCodeCompletionTUInfo(),
7962 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7964 Results.EnterNewScope();
7965 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7966 MEnd = MethodPool.end();
7968 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
7969 : &M->second.second;
7970 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
7974 if (AtParameterName) {
7976 unsigned NumSelIdents = SelIdents.size();
7978 NumSelIdents <= MethList->getMethod()->param_size()) {
7980 MethList->getMethod()->parameters()[NumSelIdents - 1];
7983 Results.getCodeCompletionTUInfo());
7984 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7986 Results.AddResult(Builder.TakeString());
7993 Result R(MethList->getMethod(),
7994 Results.getBasePriority(MethList->getMethod()),
nullptr);
7995 R.StartParameter = SelIdents.size();
7996 R.AllParametersAreInformative =
false;
7997 R.DeclaringEntity =
true;
7998 Results.MaybeAddResult(R, CurContext);
8002 Results.ExitScope();
8004 if (!AtParameterName && !SelIdents.empty() &&
8005 SelIdents.front()->getName().startswith(
"init")) {
8006 for (
const auto &M : PP.macros()) {
8007 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
8009 Results.EnterNewScope();
8011 Results.getCodeCompletionTUInfo());
8012 Builder.AddTypedTextChunk(
8013 Builder.getAllocator().CopyString(M.first->getName()));
8016 Results.ExitScope();
8021 Results.data(), Results.size());
8025 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8026 CodeCompleter->getCodeCompletionTUInfo(),
8028 Results.EnterNewScope();
8032 Results.getCodeCompletionTUInfo());
8033 Builder.AddTypedTextChunk(
"if");
8035 Builder.AddPlaceholderChunk(
"condition");
8036 Results.AddResult(Builder.TakeString());
8039 Builder.AddTypedTextChunk(
"ifdef");
8041 Builder.AddPlaceholderChunk(
"macro");
8042 Results.AddResult(Builder.TakeString());
8045 Builder.AddTypedTextChunk(
"ifndef");
8047 Builder.AddPlaceholderChunk(
"macro");
8048 Results.AddResult(Builder.TakeString());
8050 if (InConditional) {
8052 Builder.AddTypedTextChunk(
"elif");
8054 Builder.AddPlaceholderChunk(
"condition");
8055 Results.AddResult(Builder.TakeString());
8058 Builder.AddTypedTextChunk(
"else");
8059 Results.AddResult(Builder.TakeString());
8062 Builder.AddTypedTextChunk(
"endif");
8063 Results.AddResult(Builder.TakeString());
8067 Builder.AddTypedTextChunk(
"include");
8069 Builder.AddTextChunk(
"\"");
8070 Builder.AddPlaceholderChunk(
"header");
8071 Builder.AddTextChunk(
"\"");
8072 Results.AddResult(Builder.TakeString());
8075 Builder.AddTypedTextChunk(
"include");
8077 Builder.AddTextChunk(
"<");
8078 Builder.AddPlaceholderChunk(
"header");
8079 Builder.AddTextChunk(
">");
8080 Results.AddResult(Builder.TakeString());
8083 Builder.AddTypedTextChunk(
"define");
8085 Builder.AddPlaceholderChunk(
"macro");
8086 Results.AddResult(Builder.TakeString());
8089 Builder.AddTypedTextChunk(
"define");
8091 Builder.AddPlaceholderChunk(
"macro");
8093 Builder.AddPlaceholderChunk(
"args");
8095 Results.AddResult(Builder.TakeString());
8098 Builder.AddTypedTextChunk(
"undef");
8100 Builder.AddPlaceholderChunk(
"macro");
8101 Results.AddResult(Builder.TakeString());
8104 Builder.AddTypedTextChunk(
"line");
8106 Builder.AddPlaceholderChunk(
"number");
8107 Results.AddResult(Builder.TakeString());
8110 Builder.AddTypedTextChunk(
"line");
8112 Builder.AddPlaceholderChunk(
"number");
8114 Builder.AddTextChunk(
"\"");
8115 Builder.AddPlaceholderChunk(
"filename");
8116 Builder.AddTextChunk(
"\"");
8117 Results.AddResult(Builder.TakeString());
8120 Builder.AddTypedTextChunk(
"error");
8122 Builder.AddPlaceholderChunk(
"message");
8123 Results.AddResult(Builder.TakeString());
8126 Builder.AddTypedTextChunk(
"pragma");
8128 Builder.AddPlaceholderChunk(
"arguments");
8129 Results.AddResult(Builder.TakeString());
8131 if (getLangOpts().ObjC) {
8133 Builder.AddTypedTextChunk(
"import");
8135 Builder.AddTextChunk(
"\"");
8136 Builder.AddPlaceholderChunk(
"header");
8137 Builder.AddTextChunk(
"\"");
8138 Results.AddResult(Builder.TakeString());
8141 Builder.AddTypedTextChunk(
"import");
8143 Builder.AddTextChunk(
"<");
8144 Builder.AddPlaceholderChunk(
"header");
8145 Builder.AddTextChunk(
">");
8146 Results.AddResult(Builder.TakeString());
8150 Builder.AddTypedTextChunk(
"include_next");
8152 Builder.AddTextChunk(
"\"");
8153 Builder.AddPlaceholderChunk(
"header");
8154 Builder.AddTextChunk(
"\"");
8155 Results.AddResult(Builder.TakeString());
8158 Builder.AddTypedTextChunk(
"include_next");
8160 Builder.AddTextChunk(
"<");
8161 Builder.AddPlaceholderChunk(
"header");
8162 Builder.AddTextChunk(
">");
8163 Results.AddResult(Builder.TakeString());
8166 Builder.AddTypedTextChunk(
"warning");
8168 Builder.AddPlaceholderChunk(
"message");
8169 Results.AddResult(Builder.TakeString());
8176 Results.ExitScope();
8179 Results.data(), Results.size());
8188 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8189 CodeCompleter->getCodeCompletionTUInfo(),
8192 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
8195 Results.getCodeCompletionTUInfo());
8196 Results.EnterNewScope();
8198 MEnd = PP.macro_end();
8200 Builder.AddTypedTextChunk(
8201 Builder.getAllocator().CopyString(M->first->getName()));
8205 Results.ExitScope();
8206 }
else if (IsDefinition) {
8211 Results.data(), Results.size());
8215 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8216 CodeCompleter->getCodeCompletionTUInfo(),
8219 if (!CodeCompleter || CodeCompleter->includeMacros())
8221 CodeCompleter ? CodeCompleter->loadExternal() :
false,
8225 Results.EnterNewScope();
8227 Results.getCodeCompletionTUInfo());
8228 Builder.AddTypedTextChunk(
"defined");
8231 Builder.AddPlaceholderChunk(
"macro");
8233 Results.AddResult(Builder.TakeString());
8234 Results.ExitScope();
8237 Results.data(), Results.size());
8243 unsigned Argument) {
8257 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
8260 llvm::sys::path::native(NativeRelDir);
8261 auto FS = getSourceManager().getFileManager().getVirtualFileSystem();
8263 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8264 CodeCompleter->getCodeCompletionTUInfo(),
8269 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
8272 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
8273 auto R = SeenResults.insert(TypedChunk);
8275 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
8276 *R.first = InternedTyped;
8278 CodeCompleter->getCodeCompletionTUInfo());
8279 Builder.AddTypedTextChunk(InternedTyped);
8287 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
bool IsSystem) {
8289 if (!NativeRelDir.empty())
8290 llvm::sys::path::append(Dir, NativeRelDir);
8294 for (
auto It = FS->dir_begin(Dir, EC);
8295 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
8296 if (++Count == 2500)
8298 StringRef Filename = llvm::sys::path::filename(It->path());
8299 switch (It->type()) {
8300 case llvm::sys::fs::file_type::directory_file:
8301 AddCompletion(Filename,
true);
8303 case llvm::sys::fs::file_type::regular_file:
8307 if (!(Filename.endswith_lower(
".h") ||
8308 Filename.endswith_lower(
".hh") ||
8309 Filename.endswith_lower(
".hpp") ||
8310 Filename.endswith_lower(
".inc")))
8313 AddCompletion(Filename,
false);
8329 AddFilesFromIncludeDir(IncludeDir.
getDir()->
getName(), IsSystem);
8340 const auto &S = PP.getHeaderSearchInfo();
8341 using llvm::make_range;
8344 auto *CurFile = PP.getCurrentFileLexer()->getFileEntry();
8345 if (CurFile && CurFile->getDir())
8346 AddFilesFromIncludeDir(CurFile->getDir()->getName(),
false);
8347 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
8348 AddFilesFromDirLookup(D,
false);
8350 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
8351 AddFilesFromDirLookup(D,
false);
8352 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
8353 AddFilesFromDirLookup(D,
true);
8356 Results.data(), Results.size());
8366 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8367 CodeCompleter->getCodeCompletionTUInfo(),
8369 Results.EnterNewScope();
8370 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
8371 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
8374 Twine(Platform) +
"ApplicationExtension")));
8376 Results.ExitScope();
8378 Results.data(), Results.size());
8384 ResultBuilder Builder(*
this, Allocator, CCTUInfo,
8386 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
8387 CodeCompletionDeclConsumer Consumer(Builder,
8391 !CodeCompleter || CodeCompleter->loadExternal());
8394 if (!CodeCompleter || CodeCompleter->includeMacros())
8396 CodeCompleter ? CodeCompleter->loadExternal() :
false,
8400 Results.insert(Results.end(), Builder.data(),
8401 Builder.data() + Builder.size());
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
A code completion string that is entirely optional.
The receiver is the instance of the superclass object.
static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, bool IsInstanceMethod, QualType ReturnType, ASTContext &Context, VisitedSelectorSet &KnownSelectors, ResultBuilder &Results)
Add code completions for Objective-C Key-Value Coding (KVC) and Key-Value Observing (KVO)...
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
bool hasDefinition() const
Determine whether this class has been defined.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool LoadExternal, bool IncludeUndefined, bool TargetTypeIsPointer=false)
Represents a function declaration or definition.
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
An Objective-C method being used as a property.
ExternalSemaSource * getExternalSource() const
A C++ namespace alias declaration.
Paths for '#include <>' added by '-I'.
protocol_range protocols() const
CXCursorKind CursorKind
The cursor kind that describes this result.
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
Priority for a constant value (e.g., enumerator).
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Any kind of method, provided it means other specified criteria.
bool isBlockPointerType() const
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
This is a scope that corresponds to the parameters within a function prototype.
param_iterator param_begin() const
bool isMemberPointerType() const
std::vector< Module * >::iterator submodule_iterator
unsigned param_size() const
A static_assert or _Static_assert node.
ObjCInterfaceDecl * getClassInterface()
static void AddQualifierToCompletionString(CodeCompletionBuilder &Result, NestedNameSpecifier *Qualifier, bool QualifierIsInformative, ASTContext &Context, const PrintingPolicy &Policy)
Add a qualifier to the given code-completion string, if the provided nested-name-specifier is non-NUL...
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program...
ObjCDeclQualifier getObjCDeclQualifier() const
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases, bool LoadExternal)
const TypeClass * getTypePtr() const
Code completion occurs within a class, struct, or union.
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion for a selector, as in an @selector expression.
CodeCompleteConsumer::OverloadCandidate ResultCandidate
Code completion occurred where an existing name(such as type, function or variable) is expected...
submodule_iterator submodule_begin()
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
void AddTextChunk(const char *Text)
Add a new text chunk.
Priority for a code pattern.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
Code completion where an Objective-C class message is expected.
FunctionType - C99 6.7.5.3 - Function Declarators.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
static bool isObjCReceiverType(ASTContext &C, QualType T)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
static CharSourceRange getTokenRange(SourceRange R)
Code completion within a type-qualifier list.
Priority for a non-type declaration.
bool isRecordType() const
static bool isReservedName(const IdentifierInfo *Id, bool doubleUnderscoreOnly=false)
Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).
bool isEmpty() const
No scope specifier.
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
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...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
bool isOverrideSpecified() const
known_categories_range known_categories() const
std::ptrdiff_t difference_type
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression)
Defines the clang::MacroInfo and clang::MacroDirective classes.
void CodeCompleteNaturalLanguage()
pointer(const DeclIndexPair &Value)
The base class of the type hierarchy.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
An unspecified code-completion context.
bool isObjCContainer() const
Represent a C++ namespace.
Wrapper for source info for typedefs.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
A C++ non-type template parameter.
An Objective-C @interface for a category.
A container of type source information.
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
constexpr XRayInstrMask Function
ObjCMethodDecl * getMethod() const
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results. ...
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
param_const_iterator param_end() const
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
Code completion occurred where an Objective-C message receiver is expected.
iterator(const NamedDecl *SingleDecl, unsigned Index)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteObjCPropertyGetter(Scope *S)
unsigned Priority
The priority of this particular code-completion result.
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
enumerator_range enumerators() const
static const char * GetCompletionTypeString(QualType T, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionAllocator &Allocator)
Retrieve the string representation of the given type as a string that has the appropriate lifetime fo...
Represents a variable declaration or definition.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
A left bracket ('[').
Information about one declarator, including the parsed type information and the identifier.
unsigned getNumParams() const
bool isEnumeralType() const
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
A piece of text that describes the type of an entity or, for functions and methods, the return type.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
An Objective-C block property completed as a setter with a block placeholder.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
TypeSpecifierType
Specifies the kind of type.
The "__interface" keyword.
An Objective-C @synthesize definition.
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static const TST TST_interface
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
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 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. ...
Code completion occurs within an Objective-C implementation or category implementation.
The entity is not available; any use of it will be an error.
The result is in a base class.
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
tok::TokenKind ContextKind
bool isObjCObjectOrInterfaceType() const
Code completion occurred where both a new name and an existing symbol is permissible.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
Represents a struct/union/class.
static void AddTypedefResult(ResultBuilder &Results)
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
instprop_range instance_properties() const
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
One of these records is kept for each identifier that is lexed.
CodeCompletionString * TakeString()
Take the resulting completion string.
void CodeCompleteBinaryRHS(Scope *S, Expr *LHS, tok::TokenKind Op)
static AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity)
Determines whether the accessed entity is accessible.
This table allows us to fully hide how we implement multi-keyword caching.
void CodeCompleteObjCInterfaceDecl(Scope *S)
SmallVector< Decl *, 4 > IgnoreDecls
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
The results of name lookup within a DeclContext.
const ParmVarDecl *const * param_const_iterator
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
A "string" used to describe how code completion can be performed for an entity.
field_range fields() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const TST TST_class
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
Represents a member of a struct/union/class.
llvm::SmallPtrSet< Selector, 16 > VisitedSelectorSet
A set of selectors, which is used to avoid introducing multiple completions with the same selector in...
An Objective-C @protocol declaration.
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results)
Add type specifiers for the current language as keyword results.
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
Code completion occurs following one or more template headers within a class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
method_range methods() const
ObjCMethodDecl * getSetterMethodDecl() const
Kind getKind() const
Retrieve the kind of code-completion context.
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
ParmVarDecl * getParam(unsigned i) const
An Objective-C instance method.
static const TST TST_enum
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
TSC getTypeSpecComplex() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
visible_categories_range visible_categories() const
QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef< Expr *> Args, SourceLocation OpenParLoc)
Reports signatures for a call to CodeCompleteConsumer and returns the preferred type for the current ...
const LangOptions & getLangOpts() const
bool isObjCQualifiedClassType() const
void * getAsOpaquePtr() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
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.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Priority for a member declaration found from the current method or member function.
Code completion occurs at top-level or namespace context.
ArrayRef< ParmVarDecl * > parameters() const
Values of this type can be null.
bool isUnarySelector() const
An Objective-C @property declaration.
Divide by this factor when a code-completion result's type exactly matches the type we expect...
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
static ObjCContainerDecl * getContainerDef(ObjCContainerDecl *Container)
Retrieve the container definition, if any?
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
An allocator used specifically for the purpose of code completion.
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Represents a C++ unqualified-id that has been parsed.
param_iterator param_end() const
Represents the results of name lookup.
static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag)
Determine whether the addition of the given flag to an Objective-C property's attributes will cause a...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Namespaces, declared with 'namespace foo {}'.
A convenient class for passing around template argument information.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
Code completion occurs following one or more template headers.
void CodeCompleteBracketDeclarator(Scope *S)
static void AddStaticAssertResult(CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
Wrapper for source info for functions.
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
Code completion occurs within an expression.
Whether values of this type can be null is (explicitly) unspecified.
Code completion occurred where a preprocessor directive is expected.
A friend of a previously-undeclared entity.
QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr *> Args, SourceLocation OpenParLoc)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Represents a declaration of a type.
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
Code completion occurred within an Objective-C implementation or category implementation.
static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, bool OnlyUnimplemented, ResultBuilder &Results)
Add all of the Objective-C interface declarations that we find in the given (translation unit) contex...
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true, bool IsRootClass=false)
Add all of the Objective-C methods in the given Objective-C container to the set of results...
static void AddObjCBlockCall(ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder, const NamedDecl *BD, const FunctionTypeLoc &BlockLoc, const FunctionProtoTypeLoc &BlockProtoLoc)
Adds a block invocation code completion result for the given block declaration BD.
TSS getTypeSpecSign() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
reference operator*() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
CaseStmt - Represent a case statement.
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...
void append(iterator I, iterator E)
Code completion occurred where a namespace or namespace alias is expected.
Represents a C++ nested-name-specifier or a global scope specifier.
Represents an Objective-C protocol declaration.
void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
const LangOptions & getLangOpts() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlock=false)
Tries to find the most appropriate type location for an Objective-C block placeholder.
A right brace ('}').
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
Represents an ObjC class declaration.
QualType getReturnType() const
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
Member name lookup, which finds the names of class/struct/union members.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
A comma separator (',').
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
macro_iterator macro_end(bool IncludeExternalMacros=true) const
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...
Priority for a send-to-super completion.
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Refers to a keyword or symbol.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc)
const DeclIndexPair * operator->() const
CXCursorKind
Describes the kind of entity that a cursor refers to.
void CodeCompleteAvailabilityPlatformName()
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
std::input_iterator_tag iterator_category
bool isFinalSpecified() const
A right parenthesis (')').
unsigned getFlags() const
getFlags - Return the flags for this scope.
Code completion where an Objective-C category name is expected.
static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
Priority for a preprocessor macro.
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
Sema - This implements semantic analysis and AST building for C.
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
static ObjCInterfaceDecl * GetAssumedMessageSendExprType(Expr *E)
When we have an expression with type "id", we may assume that it has some more-specific class type ba...
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Zero-argument (unary) selector.
DeclarationNameTable DeclarationNames
CandidateSetKind getKind() const
SmallVector< LambdaCapture, 4 > Captures
const UsingShadowDecl * ShadowDecl
If this Decl was unshadowed by using declaration, this can store a pointer to the UsingShadowDecl whi...
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
static void AddOverrideResults(ResultBuilder &Results, const CodeCompletionContext &CCContext, CodeCompletionBuilder &Builder)
TST getTypeSpecType() const
iterator(const DeclIndexPair *Iterator)
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Code completion occurred where a protocol name is expected.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Retains information about a block that is currently being parsed.
classprop_range class_properties() const
Type source information for an attributed type.
static bool InheritsFromClassNamed(ObjCInterfaceDecl *Class, StringRef Name)
Determine whether the given class is or inherits from a class by the given name.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
void CodeCompleteObjCMethodDecl(Scope *S, Optional< bool > IsInstanceMethod, ParsedType ReturnType)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
QualType getPointeeType() const
Represents a character-granular source range.
bool isVariadic() const
Whether this function is variadic.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
Declaration of a template type parameter.
void CodeCompleteObjCPropertyDefinition(Scope *S)
DeclContext * getEntity() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
const T * castAs() const
Member-template castAs<specific type>.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool isTypeAltiVecVector() const
static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Code completion occurs within an Objective-C interface, protocol, or category.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
Defines the clang::Preprocessor interface.
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
void CodeCompleteObjCAtVisibility(Scope *S)
overridden_method_range overridden_methods() const
bool isFileContext() const
An Objective-C @implementation for a category.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
bool isObjCClassType() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
ObjCInterfaceDecl * getSuperClass() const
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
static void setInBaseClass(ResultBuilder::Result &R)
A semicolon (';').
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
void CodeCompletePreprocessorExpression()
EnumDecl * getDefinition() const
ParmVarDecl *const * param_iterator
Adjustment for KVC code pattern priorities when it doesn't look like the.
Code completion occurs within a statement, which may also be an expression or a declaration.
Captures a result of code completion.
A C++ class template partial specialization.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isFunctionOrMethod() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer *> Initializers)
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
SwitchCase * getSwitchCaseList()
static std::string formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
Returns a placeholder string that corresponds to an Objective-C block declaration.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
bool isInstanceMethod() const
Preprocessor & getPreprocessor() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getNumArgs() const
Selector getSelector() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.
void CodeCompleteNamespaceDecl(Scope *S)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
void CodeCompleteInitializer(Scope *S, Decl *D)
TypeLoc getReturnLoc() const
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
void CodeCompleteObjCPropertySetter(Scope *S)
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
unsigned AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>").
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt)
The context in which code completion occurred, so that the code-completion consumer can process the r...
void CodeCompleteObjCAtExpression(Scope *S)
SourceManager & getSourceManager() const
void CodeCompleteTypeQualifiers(DeclSpec &DS)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
static void AddFunctionParameterChunks(Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false)
Add function parameter chunks to the given code completion string.
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo *> SelIdents)
Code completion occurred within a class, struct, or union.
void CodeCompleteObjCAtDirective(Scope *S)
SelectorTable & Selectors
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
A C++ template type parameter.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement)
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
TypeLoc IgnoreParens() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
Encodes a location in the source.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
Code completion occurred where a new name is expected.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Members, declared with object declarations within tag definitions.
decl_iterator decls_begin() const
static QualType ProduceSignatureHelp(Sema &SemaRef, Scope *S, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, SourceLocation OpenParLoc)
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
unsigned SuppressScope
Suppresses printing of scope specifiers.
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
LookupType_t getLookupType() const
getLookupType - Return the kind of directory lookup that this is: either a normal directory...
pointer operator->() const
static void AddObjCProperties(const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results, bool IsBaseExprStatement=false, bool IsClassProperty=false, bool InOriginalClass=true)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Represents the declaration of a struct/union/class/enum.
This is a scope that corresponds to the Objective-C @catch statement.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const
Create a new code-completion string that describes the function signature of this overload candidate...
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
ASTContext & getASTContext() const LLVM_READONLY
static const TST TST_union
static void AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, RecordDecl *RD, Optional< FixItHint > AccessOpFixIt)
void CodeCompleteReturn(Scope *S)
Code completion where the name of an Objective-C class is expected.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonym...
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.
llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void CodeCompleteOperatorName(Scope *S)
void CodeCompletePreprocessorDirective(bool InConditional)
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
const ParmVarDecl * getParamDecl(unsigned i) const
ObjCPropertyAttributeKind getPropertyAttributes() const
static void AddOverloadParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const FunctionDecl *Function, const FunctionProtoType *Prototype, CodeCompletionBuilder &Result, unsigned CurrentArg, unsigned Start=0, bool InOptional=false)
Add function overload parameter chunks to the given code completion string.
A right bracket (']').
ObjCCategoryDecl - Represents a category declaration.
static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
Add language constructs that show up for "ordinary" names.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
Represents a C++11 virt-specifier-seq.
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Represents one property declaration in an Objective-C interface.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
TypeClass getTypeClass() const
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
ObjCDeclQualifier getObjCDeclQualifier() const
bool isC99Varargs() const
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
bool isStaticMember()
Returns true if this declares a static member.
const char * getBriefComment() const
static bool anyNullArguments(ArrayRef< Expr *> Args)
A left brace ('{').
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
ObjCImplementationDecl * getImplementation() const
bool InBaseClass
Whether this is a class member from base class.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addBriefComment(StringRef Comment)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getName() const
Return the actual identifier string.
The scope of a struct/union/class definition.
ObjCIvarDecl * getNextIvar()
Priority for a nested-name-specifier.
bool isMacroDefined(StringRef Id)
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results)
Add all of the protocol declarations that we find in the given (translation unit) context...
Abstract interface for a consumer of code-completion information.
An Objective-C instance variable.
ParserCompletionContext
Describes the context in which code completion occurs.
static bool isConstructor(const Decl *ND)
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, QualType BaseType)
Dataflow Directional Tag Classes.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Code completion occurred where an macro is being defined.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix=false)
Generates a QualType that can be used to name the same type if used at the end of the current transla...
bool isFunctionLike() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
Priority for the Objective-C "_cmd" implicit parameter.
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo *> SelIdents)
static NestedNameSpecifier * getRequiredQualification(ASTContext &Context, const DeclContext *CurContext, const DeclContext *TargetContext)
Compute the qualification required to get from the current context (CurContext) to the target context...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
A function or method parameter.
QualType getType() const
Get the type for which this source info wrapper provides information.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
void CodeCompleteTag(Scope *S, unsigned TagSpec)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
Priority for the next initialization in a constructor initializer list.
AccessSpecifier getAccess() const
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
This is a scope that corresponds to the template parameters of a C++ template.
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
The name of a declaration.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern...
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
const DirectoryEntry * getDir() const
getDir - Return the directory that this entry refers to.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
Code completion occurred on the right-hand side of an Objective-C property access expression...
All of the names in this module are visible.
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo *> SelIdents, ResultBuilder &Results)
void CodeCompleteNamespaceAliasDecl(Scope *S)
unsigned getNumParams() const
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, Optional< bool > WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
Find all of the methods that reside in the given container (and its superclasses, protocols...
void CodeCompleteUsingDirective(Scope *S)
Represents a pointer to an Objective C object.
SwitchStmt - This represents a 'switch' stmt.
Encapsulates the data about a macro definition (e.g.
static CodeCompletionContext mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Not an overloaded operator.
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
const UnresolvedSetImpl & asUnresolvedSet() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
A reference to a member of a struct, union, or class that occurs in some non-expression context...
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
A module import declaration.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
A declaration whose specific kind is not exposed via this interface.
TypeSourceInfo * getTypeSourceInfo() const
A piece of text that describes the parameter that corresponds to the code-completion location within ...
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
static const TST TST_typename
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
An Objective-C @dynamic definition.
void CodeCompleteObjCAtStatement(Scope *S)
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
We are between inheritance colon and the real class/struct definition scope.
Capturing the *this object by reference.
Represents a base class of a C++ class.
An Objective-C class method.
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
friend bool operator!=(const iterator &X, const iterator &Y)
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
bool isObjCObjectType() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A left parenthesis ('(').
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
StringRef getParentName() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
const SwitchCase * getNextSwitchCase() const
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
TranslationUnitDecl * getTranslationUnitDecl() const
static bool isInstanceMethod(const Decl *D)
Captures information about "declaration specifiers".
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
static void printOverrideString(llvm::raw_ostream &OS, CodeCompletionString *CCS)
Code completion inside the filename part of a #include directive.
Represents a C++ struct/union/class.
An Objective-C @implementation.
CodeCompleteExpressionData(QualType PreferredType=QualType())
static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext, ResultBuilder &Results)
If we're in a C++ virtual member function, add completion results that invoke the functions we overri...
sema::FunctionScopeInfo * getCurFunction() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
Priority for a declaration that is in the local scope.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
A left angle bracket ('<').
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
A right angle bracket ('>').
static QualType getPreferredTypeOfBinaryRHS(Sema &S, Expr *LHS, tok::TokenKind Op)
bool isNull() const
Determine whether this is the empty selector.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Cursor that represents the translation unit itself.
Declaration of a class template.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
ParsedType getRepAsType() const
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
Vertical whitespace ('\n' or '\r\n', depending on the platform).
Represents a complete lambda introducer.
a linked list of methods with the same selector name but different signatures.
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param, bool SuppressName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
QualType ProduceCtorInitMemberSignatureHelp(Scope *S, Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr *> ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc)
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
static void AddObjCPassingTypeChunk(QualType Type, unsigned ObjCDeclQuals, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder)
Add the parenthesized return or parameter type chunk to a code completion string. ...
MacroMap::const_iterator macro_iterator
static OpaquePtr make(QualType P)
The top declaration context.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
DeclContext::lookup_result getConstructors(ASTContext &Context, const CXXRecordDecl *Record)
static void AddTemplateParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false)
Add template parameter chunks to the given code completion string.
This declaration is a function-local extern declaration of a variable or function.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Code completion occurred on the right-hand side of a member access expression using the dot operator...
Represents a type template specialization; the template must be a class template, a type alias templa...
Code completion occurs within the condition of an if, while, switch, or for statement.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion...
static bool isNamespaceScope(Scope *S)
Determine whether this scope denotes a namespace.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
bool isPointerType() const
static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts)
Code completion occurred where a type name is expected.
__DEVICE__ int min(int __a, int __b)
Horizontal whitespace (' ').
SourceManager & SourceMgr
void CodeCompleteObjCImplementationDecl(Scope *S)
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
static const TST TST_struct
void AddAnnotation(const char *A)
DeclaratorContext getContext() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
A trivial tuple used to represent a source range.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
ObjCMethodDecl * getGetterMethodDecl() const
This represents a decl that may have a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
bool IntegralConstantExpression
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
Macro that optionally prepends an "@" to the string literal passed in via Keyword, depending on whether NeedAt is true or false.
friend bool operator==(const iterator &X, const iterator &Y)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
An Objective-C @interface.
Selector getGetterName() const
A C++ conversion function.
The receiver is a superclass.
const DirectoryEntry * getFrameworkDir() const
getFrameworkDir - Return the directory that this framework refers to.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void CodeCompleteAfterIf(Scope *S)
const LangOptions & getLangOpts() const
Wrapper for source info for block pointers.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
base_class_range vbases()
This class handles loading and caching of source files into memory.
Declaration of a template function.
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
Code completion occurs in a parenthesized expression, which might also be a type cast.
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
void CodeCompleteObjCProtocolDecl(Scope *S)
SourceLocation getLocation() const
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
ArrayRef< ParmVarDecl * > parameters() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
decl_iterator decls_end() const
StringRef getName() const
bool includeGlobals() const
Whether to include global (top-level) declaration results.