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();
698 if (
Pointer->getPointeeType()->isFunctionType()) {
712 T = Function->getReturnType();
722 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
730 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
731 if (ImplicitParam->getIdentifier() &&
732 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
739 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
741 if (isa<CXXDestructorDecl>(ND))
753 if (isa<EnumConstantDecl>(ND))
759 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
770 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
773 if (!PreferredSelector.
isNull())
774 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
775 if (PreferredSelector == Method->getSelector())
790 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
802 return Record->
lookup(ConstructorName);
805 void ResultBuilder::MaybeAddConstructorResults(Result R) {
806 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
813 Record = ClassTemplate->getTemplatedDecl();
814 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
816 if (isa<ClassTemplateSpecializationDecl>(Record))
828 R.Declaration = Ctor;
830 Results.push_back(R);
835 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
836 ND = Tmpl->getTemplatedDecl();
837 return isa<CXXConstructorDecl>(ND);
840 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
841 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
843 if (R.Kind != Result::RK_Declaration) {
845 Results.push_back(R);
850 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
852 getBasePriority(Using->getTargetDecl()),
855 MaybeAddResult(Result, CurContext);
862 bool AsNestedNameSpecifier =
false;
863 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
870 ShadowMap &
SMap = ShadowMaps.back();
871 ShadowMapEntry::iterator I, IEnd;
872 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
873 if (NamePos != SMap.end()) {
874 I = NamePos->second.begin();
875 IEnd = NamePos->second.end();
878 for (; I != IEnd; ++I) {
880 unsigned Index = I->second;
883 Results[Index].Declaration = R.Declaration;
893 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
895 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
896 ShadowMapEntry::iterator I, IEnd;
897 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
898 if (NamePos != SM->end()) {
899 I = NamePos->second.begin();
900 IEnd = NamePos->second.end();
902 for (; I != IEnd; ++I) {
904 if (I->first->hasTagIdentifierNamespace() &&
912 I->first->getIdentifierNamespace() != IDNS)
916 if (CheckHiddenResult(R, CurContext, I->first))
924 if (!AllDeclsFound.insert(CanonDecl).second)
929 if (AsNestedNameSpecifier) {
930 R.StartsNestedNameSpecifier =
true;
933 AdjustResultPriorityForDecl(R);
936 if (R.QualifierIsInformative && !R.Qualifier &&
937 !R.StartsNestedNameSpecifier) {
938 const DeclContext *Ctx = R.Declaration->getDeclContext();
939 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
942 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
944 SemaRef.
Context,
nullptr,
false,
947 R.QualifierIsInformative =
false;
952 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
953 Results.push_back(R);
955 if (!AsNestedNameSpecifier)
956 MaybeAddConstructorResults(R);
964 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
965 NamedDecl *Hiding,
bool InBaseClass =
false) {
966 if (R.Kind != Result::RK_Declaration) {
968 Results.push_back(R);
973 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
975 getBasePriority(Using->getTargetDecl()),
978 AddResult(Result, CurContext, Hiding);
982 bool AsNestedNameSpecifier =
false;
983 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
990 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
994 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
999 if (AsNestedNameSpecifier) {
1000 R.StartsNestedNameSpecifier =
true;
1002 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1005 R.Declaration->getDeclContext()->getRedeclContext()))
1006 R.QualifierIsInformative =
true;
1009 if (R.QualifierIsInformative && !R.Qualifier &&
1010 !R.StartsNestedNameSpecifier) {
1011 const DeclContext *Ctx = R.Declaration->getDeclContext();
1012 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1015 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1017 SemaRef.
Context,
nullptr,
false,
1020 R.QualifierIsInformative =
false;
1027 AdjustResultPriorityForDecl(R);
1029 if (HasObjectTypeQualifiers)
1030 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1031 if (Method->isInstance()) {
1032 Qualifiers MethodQuals = Method->getTypeQualifiers();
1033 if (ObjectTypeQualifiers == MethodQuals)
1035 else if (ObjectTypeQualifiers - MethodQuals) {
1043 Results.push_back(R);
1045 if (!AsNestedNameSpecifier)
1046 MaybeAddConstructorResults(R);
1049 void ResultBuilder::AddResult(Result R) {
1050 assert(R.Kind != Result::RK_Declaration &&
1051 "Declaration results need more context");
1052 Results.push_back(R);
1056 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1059 void ResultBuilder::ExitScope() {
1060 for (ShadowMap::iterator E = ShadowMaps.back().begin(),
1061 EEnd = ShadowMaps.back().end();
1063 E->second.Destroy();
1065 ShadowMaps.pop_back();
1070 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1079 if (isa<ObjCIvarDecl>(ND))
1088 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1090 if (isa<TypeDecl>(ND))
1095 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1096 if (!
ID->getDefinition())
1104 if (isa<ObjCIvarDecl>(ND))
1111 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1112 if (!IsOrdinaryNonTypeName(ND))
1116 if (VD->getType()->isIntegralOrEnumerationType())
1124 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1132 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1137 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1139 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1140 ND = ClassTemplate->getTemplatedDecl();
1146 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1147 return isa<EnumDecl>(ND);
1151 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1153 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1154 ND = ClassTemplate->getTemplatedDecl();
1157 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1165 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1167 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1168 ND = ClassTemplate->getTemplatedDecl();
1170 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1177 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1178 return isa<NamespaceDecl>(ND);
1183 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1188 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1190 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1196 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1198 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1199 isa<ObjCPropertyDecl>(ND);
1205 case Type::ObjCObject:
1206 case Type::ObjCInterface:
1207 case Type::ObjCObjectPointer:
1211 switch (cast<BuiltinType>(T)->getKind()) {
1212 case BuiltinType::ObjCId:
1213 case BuiltinType::ObjCClass:
1214 case BuiltinType::ObjCSel:
1235 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1244 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1246 if (IsObjCMessageReceiver(ND))
1249 const auto *Var = dyn_cast<
VarDecl>(ND);
1256 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1257 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1258 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1271 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1277 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1278 return isa<ObjCIvarDecl>(ND);
1286 ResultBuilder &Results;
1292 std::vector<FixItHint> FixIts;
1295 CodeCompletionDeclConsumer(
1296 ResultBuilder &Results,
DeclContext *InitialLookupCtx,
1298 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1299 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1300 FixIts(std::move(FixIts)) {
1301 NamingClass = llvm::dyn_cast<
CXXRecordDecl>(InitialLookupCtx);
1304 auto ThisType = Results.getSema().getCurrentThisType();
1305 if (!ThisType.isNull()) {
1306 assert(ThisType->isPointerType());
1309 NamingClass = BaseType->getAsCXXRecordDecl();
1312 this->BaseType = BaseType;
1316 bool InBaseClass)
override {
1319 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
1323 Results.addVisitedContext(Ctx);
1332 auto *NamingClass = this->NamingClass;
1333 QualType BaseType = this->BaseType;
1334 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1349 NamingClass =
nullptr;
1352 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1359 ResultBuilder &Results) {
1361 Results.AddResult(Result(
"short",
CCP_Type));
1362 Results.AddResult(Result(
"long",
CCP_Type));
1363 Results.AddResult(Result(
"signed",
CCP_Type));
1364 Results.AddResult(Result(
"unsigned",
CCP_Type));
1365 Results.AddResult(Result(
"void",
CCP_Type));
1366 Results.AddResult(Result(
"char",
CCP_Type));
1367 Results.AddResult(Result(
"int",
CCP_Type));
1368 Results.AddResult(Result(
"float",
CCP_Type));
1369 Results.AddResult(Result(
"double",
CCP_Type));
1370 Results.AddResult(Result(
"enum",
CCP_Type));
1371 Results.AddResult(Result(
"struct",
CCP_Type));
1372 Results.AddResult(Result(
"union",
CCP_Type));
1373 Results.AddResult(Result(
"const",
CCP_Type));
1374 Results.AddResult(Result(
"volatile",
CCP_Type));
1378 Results.AddResult(Result(
"_Complex",
CCP_Type));
1379 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1380 Results.AddResult(Result(
"_Bool",
CCP_Type));
1381 Results.AddResult(Result(
"restrict",
CCP_Type));
1385 Results.getCodeCompletionTUInfo());
1386 if (LangOpts.CPlusPlus) {
1390 Results.AddResult(Result(
"class",
CCP_Type));
1391 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1394 Builder.AddTypedTextChunk(
"typename");
1396 Builder.AddPlaceholderChunk(
"qualifier");
1397 Builder.AddTextChunk(
"::");
1398 Builder.AddPlaceholderChunk(
"name");
1399 Results.AddResult(Result(Builder.TakeString()));
1401 if (LangOpts.CPlusPlus11) {
1402 Results.AddResult(Result(
"auto",
CCP_Type));
1403 Results.AddResult(Result(
"char16_t",
CCP_Type));
1404 Results.AddResult(Result(
"char32_t",
CCP_Type));
1406 Builder.AddTypedTextChunk(
"decltype");
1408 Builder.AddPlaceholderChunk(
"expression");
1410 Results.AddResult(Result(Builder.TakeString()));
1413 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1416 if (LangOpts.GNUKeywords) {
1422 Builder.AddTypedTextChunk(
"typeof");
1424 Builder.AddPlaceholderChunk(
"expression");
1425 Results.AddResult(Result(Builder.TakeString()));
1427 Builder.AddTypedTextChunk(
"typeof");
1429 Builder.AddPlaceholderChunk(
"type");
1431 Results.AddResult(Result(Builder.TakeString()));
1435 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1436 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1437 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1442 ResultBuilder &Results) {
1447 Results.AddResult(Result(
"extern"));
1448 Results.AddResult(Result(
"static"));
1450 if (LangOpts.CPlusPlus11) {
1455 Builder.AddTypedTextChunk(
"alignas");
1457 Builder.AddPlaceholderChunk(
"expression");
1459 Results.AddResult(Result(Builder.TakeString()));
1461 Results.AddResult(Result(
"constexpr"));
1462 Results.AddResult(Result(
"thread_local"));
1468 ResultBuilder &Results) {
1473 if (LangOpts.CPlusPlus) {
1474 Results.AddResult(Result(
"explicit"));
1475 Results.AddResult(Result(
"friend"));
1476 Results.AddResult(Result(
"mutable"));
1477 Results.AddResult(Result(
"virtual"));
1485 if (LangOpts.CPlusPlus || LangOpts.C99)
1486 Results.AddResult(Result(
"inline"));
1505 ResultBuilder &Results,
bool NeedAt);
1507 ResultBuilder &Results,
bool NeedAt);
1509 ResultBuilder &Results,
bool NeedAt);
1514 Results.getCodeCompletionTUInfo());
1515 Builder.AddTypedTextChunk(
"typedef");
1517 Builder.AddPlaceholderChunk(
"type");
1519 Builder.AddPlaceholderChunk(
"name");
1540 return LangOpts.CPlusPlus;
1547 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
1550 llvm_unreachable(
"Invalid ParserCompletionContext!");
1578 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1579 return BT->getNameAsCString(Policy);
1582 if (
const TagType *TagT = dyn_cast<TagType>(T))
1583 if (
TagDecl *Tag = TagT->getDecl())
1584 if (!Tag->hasNameForLinkage()) {
1585 switch (Tag->getTagKind()) {
1587 return "struct <anonymous>";
1589 return "__interface <anonymous>";
1591 return "class <anonymous>";
1593 return "union <anonymous>";
1595 return "enum <anonymous>";
1615 Builder.AddResultTypeChunk(
1617 Builder.AddTypedTextChunk(
"this");
1622 ResultBuilder &Results,
1624 if (!LangOpts.CPlusPlus11)
1638 for (
const auto &C : *CCS) {
1652 Sema &S = Results.getSema();
1659 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
1660 for (
auto *Method : CR->methods()) {
1661 if (!Method->isVirtual() || !Method->getIdentifier())
1663 Overrides[Method->getName()].push_back(Method);
1666 for (
const auto &
Base : CR->bases()) {
1667 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
1670 for (
auto *Method : BR->methods()) {
1671 if (!Method->isVirtual() || !Method->getIdentifier())
1673 const auto it = Overrides.find(Method->getName());
1674 bool IsOverriden =
false;
1675 if (it != Overrides.end()) {
1676 for (
auto *MD : it->second) {
1689 std::string OverrideSignature;
1690 llvm::raw_string_ostream OS(OverrideSignature);
1696 false, CCContext, Policy);
1705 Sema &SemaRef, ResultBuilder &Results) {
1713 if (Results.includeCodePatterns()) {
1715 Builder.AddTypedTextChunk(
"namespace");
1717 Builder.AddPlaceholderChunk(
"identifier");
1719 Builder.AddPlaceholderChunk(
"declarations");
1722 Results.AddResult(Result(Builder.TakeString()));
1726 Builder.AddTypedTextChunk(
"namespace");
1728 Builder.AddPlaceholderChunk(
"name");
1730 Builder.AddPlaceholderChunk(
"namespace");
1731 Results.AddResult(Result(Builder.TakeString()));
1734 Builder.AddTypedTextChunk(
"using");
1736 Builder.AddTextChunk(
"namespace");
1738 Builder.AddPlaceholderChunk(
"identifier");
1739 Results.AddResult(Result(Builder.TakeString()));
1742 Builder.AddTypedTextChunk(
"asm");
1744 Builder.AddPlaceholderChunk(
"string-literal");
1746 Results.AddResult(Result(Builder.TakeString()));
1748 if (Results.includeCodePatterns()) {
1750 Builder.AddTypedTextChunk(
"template");
1752 Builder.AddPlaceholderChunk(
"declaration");
1753 Results.AddResult(Result(Builder.TakeString()));
1768 Builder.AddTypedTextChunk(
"using");
1770 Builder.AddPlaceholderChunk(
"qualifier");
1771 Builder.AddTextChunk(
"::");
1772 Builder.AddPlaceholderChunk(
"name");
1773 Results.AddResult(Result(Builder.TakeString()));
1777 Builder.AddTypedTextChunk(
"using");
1779 Builder.AddTextChunk(
"typename");
1781 Builder.AddPlaceholderChunk(
"qualifier");
1782 Builder.AddTextChunk(
"::");
1783 Builder.AddPlaceholderChunk(
"name");
1784 Results.AddResult(Result(Builder.TakeString()));
1792 bool IsNotInheritanceScope =
1795 Builder.AddTypedTextChunk(
"public");
1796 if (IsNotInheritanceScope && Results.includeCodePatterns())
1798 Results.AddResult(Result(Builder.TakeString()));
1801 Builder.AddTypedTextChunk(
"protected");
1802 if (IsNotInheritanceScope && Results.includeCodePatterns())
1804 Results.AddResult(Result(Builder.TakeString()));
1807 Builder.AddTypedTextChunk(
"private");
1808 if (IsNotInheritanceScope && Results.includeCodePatterns())
1810 Results.AddResult(Result(Builder.TakeString()));
1823 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1825 Builder.AddTypedTextChunk(
"template");
1827 Builder.AddPlaceholderChunk(
"parameters");
1829 Results.AddResult(Result(Builder.TakeString()));
1858 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1860 Builder.AddTypedTextChunk(
"try");
1862 Builder.AddPlaceholderChunk(
"statements");
1865 Builder.AddTextChunk(
"catch");
1867 Builder.AddPlaceholderChunk(
"declaration");
1870 Builder.AddPlaceholderChunk(
"statements");
1873 Results.AddResult(Result(Builder.TakeString()));
1878 if (Results.includeCodePatterns()) {
1880 Builder.AddTypedTextChunk(
"if");
1883 Builder.AddPlaceholderChunk(
"condition");
1885 Builder.AddPlaceholderChunk(
"expression");
1888 Builder.AddPlaceholderChunk(
"statements");
1891 Results.AddResult(Result(Builder.TakeString()));
1894 Builder.AddTypedTextChunk(
"switch");
1897 Builder.AddPlaceholderChunk(
"condition");
1899 Builder.AddPlaceholderChunk(
"expression");
1904 Results.AddResult(Result(Builder.TakeString()));
1911 Builder.AddTypedTextChunk(
"case");
1913 Builder.AddPlaceholderChunk(
"expression");
1915 Results.AddResult(Result(Builder.TakeString()));
1918 Builder.AddTypedTextChunk(
"default");
1920 Results.AddResult(Result(Builder.TakeString()));
1923 if (Results.includeCodePatterns()) {
1925 Builder.AddTypedTextChunk(
"while");
1928 Builder.AddPlaceholderChunk(
"condition");
1930 Builder.AddPlaceholderChunk(
"expression");
1933 Builder.AddPlaceholderChunk(
"statements");
1936 Results.AddResult(Result(Builder.TakeString()));
1939 Builder.AddTypedTextChunk(
"do");
1941 Builder.AddPlaceholderChunk(
"statements");
1944 Builder.AddTextChunk(
"while");
1946 Builder.AddPlaceholderChunk(
"expression");
1948 Results.AddResult(Result(Builder.TakeString()));
1951 Builder.AddTypedTextChunk(
"for");
1954 Builder.AddPlaceholderChunk(
"init-statement");
1956 Builder.AddPlaceholderChunk(
"init-expression");
1958 Builder.AddPlaceholderChunk(
"condition");
1960 Builder.AddPlaceholderChunk(
"inc-expression");
1964 Builder.AddPlaceholderChunk(
"statements");
1967 Results.AddResult(Result(Builder.TakeString()));
1972 Builder.AddTypedTextChunk(
"continue");
1973 Results.AddResult(Result(Builder.TakeString()));
1978 Builder.AddTypedTextChunk(
"break");
1979 Results.AddResult(Result(Builder.TakeString()));
1984 bool isVoid =
false;
1985 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext))
1986 isVoid = Function->getReturnType()->isVoidType();
1987 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1988 isVoid = Method->getReturnType()->isVoidType();
1992 Builder.AddTypedTextChunk(
"return");
1995 Builder.AddPlaceholderChunk(
"expression");
1997 Results.AddResult(Result(Builder.TakeString()));
2000 Builder.AddTypedTextChunk(
"goto");
2002 Builder.AddPlaceholderChunk(
"label");
2003 Results.AddResult(Result(Builder.TakeString()));
2006 Builder.AddTypedTextChunk(
"using");
2008 Builder.AddTextChunk(
"namespace");
2010 Builder.AddPlaceholderChunk(
"identifier");
2011 Results.AddResult(Result(Builder.TakeString()));
2028 Builder.AddTypedTextChunk(
"__bridge");
2030 Builder.AddPlaceholderChunk(
"type");
2032 Builder.AddPlaceholderChunk(
"expression");
2033 Results.AddResult(Result(Builder.TakeString()));
2036 Builder.AddTypedTextChunk(
"__bridge_transfer");
2038 Builder.AddPlaceholderChunk(
"Objective-C type");
2040 Builder.AddPlaceholderChunk(
"expression");
2041 Results.AddResult(Result(Builder.TakeString()));
2044 Builder.AddTypedTextChunk(
"__bridge_retained");
2046 Builder.AddPlaceholderChunk(
"CF type");
2048 Builder.AddPlaceholderChunk(
"expression");
2049 Results.AddResult(Result(Builder.TakeString()));
2060 Builder.AddResultTypeChunk(
"bool");
2061 Builder.AddTypedTextChunk(
"true");
2062 Results.AddResult(Result(Builder.TakeString()));
2065 Builder.AddResultTypeChunk(
"bool");
2066 Builder.AddTypedTextChunk(
"false");
2067 Results.AddResult(Result(Builder.TakeString()));
2071 Builder.AddTypedTextChunk(
"dynamic_cast");
2073 Builder.AddPlaceholderChunk(
"type");
2076 Builder.AddPlaceholderChunk(
"expression");
2078 Results.AddResult(Result(Builder.TakeString()));
2082 Builder.AddTypedTextChunk(
"static_cast");
2084 Builder.AddPlaceholderChunk(
"type");
2087 Builder.AddPlaceholderChunk(
"expression");
2089 Results.AddResult(Result(Builder.TakeString()));
2092 Builder.AddTypedTextChunk(
"reinterpret_cast");
2094 Builder.AddPlaceholderChunk(
"type");
2097 Builder.AddPlaceholderChunk(
"expression");
2099 Results.AddResult(Result(Builder.TakeString()));
2102 Builder.AddTypedTextChunk(
"const_cast");
2104 Builder.AddPlaceholderChunk(
"type");
2107 Builder.AddPlaceholderChunk(
"expression");
2109 Results.AddResult(Result(Builder.TakeString()));
2113 Builder.AddResultTypeChunk(
"std::type_info");
2114 Builder.AddTypedTextChunk(
"typeid");
2116 Builder.AddPlaceholderChunk(
"expression-or-type");
2118 Results.AddResult(Result(Builder.TakeString()));
2122 Builder.AddTypedTextChunk(
"new");
2124 Builder.AddPlaceholderChunk(
"type");
2126 Builder.AddPlaceholderChunk(
"expressions");
2128 Results.AddResult(Result(Builder.TakeString()));
2131 Builder.AddTypedTextChunk(
"new");
2133 Builder.AddPlaceholderChunk(
"type");
2135 Builder.AddPlaceholderChunk(
"size");
2138 Builder.AddPlaceholderChunk(
"expressions");
2140 Results.AddResult(Result(Builder.TakeString()));
2143 Builder.AddResultTypeChunk(
"void");
2144 Builder.AddTypedTextChunk(
"delete");
2146 Builder.AddPlaceholderChunk(
"expression");
2147 Results.AddResult(Result(Builder.TakeString()));
2150 Builder.AddResultTypeChunk(
"void");
2151 Builder.AddTypedTextChunk(
"delete");
2156 Builder.AddPlaceholderChunk(
"expression");
2157 Results.AddResult(Result(Builder.TakeString()));
2161 Builder.AddResultTypeChunk(
"void");
2162 Builder.AddTypedTextChunk(
"throw");
2164 Builder.AddPlaceholderChunk(
"expression");
2165 Results.AddResult(Result(Builder.TakeString()));
2172 Builder.AddResultTypeChunk(
"std::nullptr_t");
2173 Builder.AddTypedTextChunk(
"nullptr");
2174 Results.AddResult(Result(Builder.TakeString()));
2177 Builder.AddResultTypeChunk(
"size_t");
2178 Builder.AddTypedTextChunk(
"alignof");
2180 Builder.AddPlaceholderChunk(
"type");
2182 Results.AddResult(Result(Builder.TakeString()));
2185 Builder.AddResultTypeChunk(
"bool");
2186 Builder.AddTypedTextChunk(
"noexcept");
2188 Builder.AddPlaceholderChunk(
"expression");
2190 Results.AddResult(Result(Builder.TakeString()));
2193 Builder.AddResultTypeChunk(
"size_t");
2194 Builder.AddTypedTextChunk(
"sizeof...");
2196 Builder.AddPlaceholderChunk(
"parameter-pack");
2198 Results.AddResult(Result(Builder.TakeString()));
2207 if (
ID->getSuperClass()) {
2208 std::string SuperType;
2209 SuperType =
ID->getSuperClass()->getNameAsString();
2210 if (Method->isInstanceMethod())
2213 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2214 Builder.AddTypedTextChunk(
"super");
2215 Results.AddResult(Result(Builder.TakeString()));
2224 Builder.AddResultTypeChunk(
"size_t");
2226 Builder.AddTypedTextChunk(
"alignof");
2228 Builder.AddTypedTextChunk(
"_Alignof");
2230 Builder.AddPlaceholderChunk(
"type");
2232 Results.AddResult(Result(Builder.TakeString()));
2236 Builder.AddResultTypeChunk(
"size_t");
2237 Builder.AddTypedTextChunk(
"sizeof");
2239 Builder.AddPlaceholderChunk(
"expression-or-type");
2241 Results.AddResult(Result(Builder.TakeString()));
2254 Results.AddResult(Result(
"operator"));
2274 T = Function->getReturnType();
2275 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2277 T = Method->getSendResultType(BaseType);
2279 T = Method->getReturnType();
2280 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2281 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2283 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2285 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2287 T = Ivar->getUsageType(BaseType);
2289 T = Ivar->getType();
2290 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2291 T =
Value->getType();
2292 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2294 T =
Property->getUsageType(BaseType);
2309 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2310 if (Sentinel->getSentinel() == 0) {
2330 Result +=
"bycopy ";
2334 Result +=
"oneway ";
2337 switch (*nullability) {
2339 Result +=
"nonnull ";
2343 Result +=
"nullable ";
2347 Result +=
"null_unspecified ";
2364 bool SuppressBlock =
false) {
2370 if (!SuppressBlock) {
2373 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2386 TL = AttrTL.getModifiedLoc();
2405 bool SuppressBlockName =
false,
2406 bool SuppressBlock =
false,
2407 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2411 bool SuppressName =
false,
bool SuppressBlock =
false,
2412 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2413 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2420 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2427 if (ObjCMethodParam) {
2447 if (!Block && ObjCMethodParam &&
2448 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2449 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2450 ->findPropertyDecl(
false))
2464 if (ObjCMethodParam) {
2469 Result =
"(" + Quals +
" " + Result +
")";
2470 if (Result.back() !=
')')
2484 false, SuppressBlock,
2500 bool SuppressBlockName,
bool SuppressBlock,
2501 Optional<ArrayRef<QualType>> ObjCSubsts) {
2508 if (!ResultType->
isVoidType() || SuppressBlock)
2520 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2533 if (SuppressBlock) {
2535 Result = Result +
" (^";
2542 Result =
'^' + Result;
2557 bool Invalid = CharSrcRange.
isInvalid();
2565 if (srcText.empty() || srcText ==
"=") {
2571 std::string DefValue(srcText.str());
2574 if (DefValue.at(0) !=
'=') {
2578 return " = " + DefValue;
2580 return " " + DefValue;
2589 bool InOptional =
false) {
2590 bool FirstParameter =
true;
2600 if (!FirstParameter)
2608 FirstParameter =
false;
2621 PlaceholderStr +=
", ...";
2629 if (Proto->isVariadic()) {
2630 if (Proto->getNumParams() == 0)
2641 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
2642 bool FirstParameter =
true;
2651 PEnd = Params->begin() + MaxParameters;
2654 bool HasDefaultArg =
false;
2655 std::string PlaceholderStr;
2657 if (TTP->wasDeclaredWithTypename())
2658 PlaceholderStr =
"typename";
2660 PlaceholderStr =
"class";
2662 if (TTP->getIdentifier()) {
2663 PlaceholderStr +=
' ';
2667 HasDefaultArg = TTP->hasDefaultArgument();
2669 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2670 if (NTTP->getIdentifier())
2671 PlaceholderStr = NTTP->getIdentifier()->getName();
2672 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2673 HasDefaultArg = NTTP->hasDefaultArgument();
2675 assert(isa<TemplateTemplateParmDecl>(*
P));
2680 PlaceholderStr =
"template<...> class";
2682 PlaceholderStr +=
' ';
2689 if (HasDefaultArg && !InDefaultArg) {
2694 if (!FirstParameter)
2697 P - Params->begin(),
true);
2702 InDefaultArg =
false;
2705 FirstParameter =
false;
2719 bool QualifierIsInformative,
2725 std::string PrintedNNS;
2727 llvm::raw_string_ostream OS(PrintedNNS);
2728 Qualifier->
print(OS, Policy);
2730 if (QualifierIsInformative)
2740 if (!Proto || !Proto->getTypeQuals())
2746 if (Proto->getTypeQuals().hasOnlyConst()) {
2751 if (Proto->getTypeQuals().hasOnlyVolatile()) {
2756 if (Proto->getTypeQuals().hasOnlyRestrict()) {
2762 std::string QualsStr;
2763 if (Proto->isConst())
2764 QualsStr +=
" const";
2765 if (Proto->isVolatile())
2766 QualsStr +=
" volatile";
2767 if (Proto->isRestrict())
2768 QualsStr +=
" restrict";
2782 const char *OperatorName =
nullptr;
2785 case OO_Conditional:
2787 OperatorName =
"operator";
2790 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 2792 OperatorName = "operator" Spelling; \ 2794 #define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly) 2795 #include "clang/Basic/OperatorKinds.def" 2798 OperatorName =
"operator new";
2801 OperatorName =
"operator delete";
2804 OperatorName =
"operator new[]";
2806 case OO_Array_Delete:
2807 OperatorName =
"operator delete[]";
2810 OperatorName =
"operator()";
2813 OperatorName =
"operator[]";
2839 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2841 Record = InjectedTy->getDecl();
2863 bool IncludeBriefComments) {
2864 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2865 CCTUInfo, IncludeBriefComments);
2871 assert(
Kind == RK_Macro);
2923 bool IncludeBriefComments) {
2924 if (
Kind == RK_Macro)
2925 return CreateCodeCompletionStringForMacro(PP, Allocator, CCTUInfo);
2930 if (
Kind == RK_Pattern) {
2931 Pattern->Priority = Priority;
2932 Pattern->Availability = Availability;
2947 if (
Kind == RK_Keyword) {
2951 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2952 return createCodeCompletionStringForDecl(
2953 PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
2961 std::string OverrideSignature;
2962 llvm::raw_string_ostream OS(OverrideSignature);
2963 auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
2979 if (IncludeBriefComments) {
2986 if (StartsNestedNameSpecifier) {
2998 if (
const auto *Function = dyn_cast<FunctionDecl>(ND)) {
3010 dyn_cast<FunctionTemplateDecl>(ND)) {
3018 llvm::SmallBitVector Deduced;
3020 unsigned LastDeducibleArgument;
3021 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3022 --LastDeducibleArgument) {
3023 if (!Deduced[LastDeducibleArgument - 1]) {
3027 bool HasDefaultArg =
false;
3028 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3029 LastDeducibleArgument - 1);
3031 HasDefaultArg = TTP->hasDefaultArgument();
3033 dyn_cast<NonTypeTemplateParmDecl>(Param))
3034 HasDefaultArg = NTTP->hasDefaultArgument();
3036 assert(isa<TemplateTemplateParmDecl>(Param));
3038 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3046 if (LastDeducibleArgument) {
3052 LastDeducibleArgument);
3064 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3074 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3075 Selector Sel = Method->getSelector();
3084 if (StartParameter == 0)
3091 if (Method->param_size() == 1)
3096 PEnd = Method->param_end();
3097 P != PEnd; (void)++
P, ++Idx) {
3099 std::string Keyword;
3100 if (Idx > StartParameter)
3103 Keyword += II->getName();
3105 if (Idx < StartParameter || AllParametersAreInformative)
3112 if (Idx < StartParameter)
3116 QualType ParamType = (*P)->getType();
3132 if (DeclaringEntity || AllParametersAreInformative)
3133 Arg += II->getName();
3136 if (Method->isVariadic() && (
P + 1) == PEnd)
3139 if (DeclaringEntity)
3141 else if (AllParametersAreInformative)
3147 if (Method->isVariadic()) {
3148 if (Method->param_size() == 0) {
3149 if (DeclaringEntity)
3151 else if (AllParametersAreInformative)
3192 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3193 if (!M || !M->isPropertyAccessor())
3219 if (ArgIndex < FDecl->getNumParams())
3231 unsigned CurrentArg,
unsigned Start = 0,
3232 bool InOptional =
false) {
3233 bool FirstParameter =
true;
3234 unsigned NumParams =
3237 for (
unsigned P = Start;
P != NumParams; ++
P) {
3243 if (!FirstParameter)
3247 CurrentArg,
P,
true);
3253 FirstParameter =
false;
3260 std::string Placeholder;
3271 if (
P == CurrentArg)
3281 if (!FirstParameter)
3284 if (CurrentArg < NumParams)
3285 Opt.AddPlaceholderChunk(
"...");
3287 Opt.AddCurrentParameterChunk(
"...");
3305 if (!FDecl && !Proto) {
3318 if (IncludeBriefComments) {
3335 return Result.TakeString();
3340 bool PreferredTypeIsPointer) {
3344 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3345 MacroName.equals(
"Nil")) {
3347 if (PreferredTypeIsPointer)
3351 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3352 MacroName.equals(
"true") || MacroName.equals(
"false"))
3355 else if (MacroName.equals(
"bool"))
3368 case Decl::EnumConstant:
3374 case Decl::ObjCCategory:
3376 case Decl::ObjCCategoryImpl:
3378 case Decl::ObjCImplementation:
3381 case Decl::ObjCInterface:
3383 case Decl::ObjCIvar:
3385 case Decl::ObjCMethod:
3389 case Decl::CXXMethod:
3391 case Decl::CXXConstructor:
3393 case Decl::CXXDestructor:
3395 case Decl::CXXConversion:
3397 case Decl::ObjCProperty:
3399 case Decl::ObjCProtocol:
3405 case Decl::TypeAlias:
3407 case Decl::TypeAliasTemplate:
3411 case Decl::Namespace:
3413 case Decl::NamespaceAlias:
3415 case Decl::TemplateTypeParm:
3417 case Decl::NonTypeTemplateParm:
3419 case Decl::TemplateTemplateParm:
3421 case Decl::FunctionTemplate:
3423 case Decl::ClassTemplate:
3425 case Decl::AccessSpec:
3427 case Decl::ClassTemplatePartialSpecialization:
3429 case Decl::UsingDirective:
3431 case Decl::StaticAssert:
3435 case Decl::TranslationUnit:
3439 case Decl::UnresolvedUsingValue:
3440 case Decl::UnresolvedUsingTypename:
3443 case Decl::ObjCPropertyImpl:
3444 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3451 llvm_unreachable(
"Unexpected Kind!");
3456 case Decl::ObjCTypeParam:
3460 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
3461 switch (TD->getTagKind()) {
3479 bool LoadExternal,
bool IncludeUndefined,
3480 bool TargetTypeIsPointer =
false) {
3483 Results.EnterNewScope();
3489 if (IncludeUndefined || MD) {
3495 Result(M->first, MI,
3497 TargetTypeIsPointer)));
3501 Results.ExitScope();
3505 ResultBuilder &Results) {
3508 Results.EnterNewScope();
3510 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3511 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3512 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3514 Results.ExitScope();
3521 unsigned NumResults) {
3581 llvm_unreachable(
"Invalid ParserCompletionContext!");
3593 ResultBuilder &Results) {
3596 while (isa<BlockDecl>(CurContext))
3606 if (!
P->getDeclName())
3612 Results.getCodeCompletionTUInfo());
3619 S.
Context, CurContext, Overridden->getDeclContext());
3622 llvm::raw_string_ostream OS(Str);
3623 NNS->
print(OS, Policy);
3624 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3626 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3629 Builder.AddTypedTextChunk(
3630 Results.getAllocator().CopyString(Overridden->getNameAsString()));
3632 bool FirstParam =
true;
3639 Builder.AddPlaceholderChunk(
3640 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3646 Results.Ignore(Overridden);
3653 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3654 CodeCompleter->getCodeCompletionTUInfo(),
3656 Results.EnterNewScope();
3664 PP.getHeaderSearchInfo().collectAllModules(Modules);
3665 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
3666 Builder.AddTypedTextChunk(
3667 Builder.getAllocator().CopyString(Modules[I]->Name));
3668 Results.AddResult(Result(
3673 }
else if (getLangOpts().Modules) {
3682 Sub != SubEnd; ++Sub) {
3684 Builder.AddTypedTextChunk(
3685 Builder.getAllocator().CopyString((*Sub)->Name));
3686 Results.AddResult(Result(
3693 Results.ExitScope();
3695 Results.data(), Results.size());
3700 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3701 CodeCompleter->getCodeCompletionTUInfo(),
3703 Results.EnterNewScope();
3708 switch (CompletionContext) {
3711 case PCC_ObjCInterface:
3712 case PCC_ObjCImplementation:
3713 case PCC_ObjCInstanceVariableList:
3715 case PCC_MemberTemplate:
3717 case PCC_LocalDeclarationSpecifiers:
3718 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3722 case PCC_ParenthesizedExpression:
3723 case PCC_Expression:
3727 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3729 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3735 case PCC_RecoveryInFunction:
3742 auto ThisType = getCurrentThisType();
3743 if (!ThisType.isNull())
3744 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers());
3746 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3748 CodeCompleter->includeGlobals(),
3749 CodeCompleter->loadExternal());
3752 Results.ExitScope();
3754 switch (CompletionContext) {
3755 case PCC_ParenthesizedExpression:
3756 case PCC_Expression:
3758 case PCC_RecoveryInFunction:
3765 case PCC_ObjCInterface:
3766 case PCC_ObjCImplementation:
3767 case PCC_ObjCInstanceVariableList:
3769 case PCC_MemberTemplate:
3773 case PCC_LocalDeclarationSpecifiers:
3777 if (CodeCompleter->includeMacros())
3781 Results.data(), Results.size());
3787 bool AtArgumentExpression,
bool IsSuper,
3788 ResultBuilder &Results);
3791 bool AllowNonIdentifiers,
3792 bool AllowNestedNameSpecifiers) {
3794 ResultBuilder Results(
3795 *
this, CodeCompleter->getAllocator(),
3796 CodeCompleter->getCodeCompletionTUInfo(),
3797 AllowNestedNameSpecifiers
3802 Results.EnterNewScope();
3805 Results.AddResult(Result(
"const"));
3806 Results.AddResult(Result(
"volatile"));
3807 if (getLangOpts().
C99)
3808 Results.AddResult(Result(
"restrict"));
3814 Results.AddResult(
"final");
3816 if (AllowNonIdentifiers) {
3817 Results.AddResult(Result(
"operator"));
3821 if (AllowNestedNameSpecifiers) {
3822 Results.allowNestedNameSpecifiers();
3823 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3824 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3826 CodeCompleter->includeGlobals(),
3827 CodeCompleter->loadExternal());
3828 Results.setFilter(
nullptr);
3831 Results.ExitScope();
3837 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3856 Results.data(), Results.size());
3861 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3862 ObjCCollection(
false) {}
3874 ResultBuilder Results(
3875 *
this, CodeCompleter->getAllocator(),
3876 CodeCompleter->getCodeCompletionTUInfo(),
3880 Results.setFilter(&ResultBuilder::IsObjCCollection);
3882 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3884 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3886 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3892 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
3895 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3897 CodeCompleter->includeGlobals(),
3898 CodeCompleter->loadExternal());
3900 Results.EnterNewScope();
3902 Results.ExitScope();
3904 bool PreferredTypeIsPointer =
false;
3914 if (CodeCompleter->includeMacros())
3916 PreferredTypeIsPointer);
3918 Results.data(), Results.size());
3927 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3928 else if (getLangOpts().ObjC)
3929 CodeCompleteObjCInstanceMessage(S, E.
get(), None,
false);
3939 if (Interface->hasDefinition())
3940 return Interface->getDefinition();
3946 if (Protocol->hasDefinition())
3947 return Protocol->getDefinition();
3971 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
3976 std::string PlaceholderStr =
3979 if (I == N - 1 && BlockProtoLoc &&
3981 PlaceholderStr +=
", ...";
3995 bool AllowNullaryMethods,
DeclContext *CurContext,
3996 AddedPropertiesSet &AddedProperties, ResultBuilder &Results,
3997 bool IsBaseExprStatement =
false,
3998 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
4006 if (!AddedProperties.insert(
P->getIdentifier()).second)
4011 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
4012 !IsBaseExprStatement) {
4013 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4014 if (!InOriginalClass)
4016 Results.MaybeAddResult(R, CurContext);
4027 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4028 if (!InOriginalClass)
4030 Results.MaybeAddResult(R, CurContext);
4037 Results.getCodeCompletionTUInfo());
4040 BlockLoc, BlockProtoLoc);
4041 Result R = Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
4042 if (!InOriginalClass)
4044 Results.MaybeAddResult(R, CurContext);
4048 if (!
P->isReadOnly()) {
4050 Results.getCodeCompletionTUInfo());
4054 Builder.AddTypedTextChunk(
4055 Results.getAllocator().CopyString(
P->getName()));
4060 BlockProtoLoc,
true);
4062 Builder.AddPlaceholderChunk(
4063 Builder.getAllocator().CopyString(PlaceholderStr));
4071 Result(Builder.TakeString(),
P,
4072 Results.getBasePriority(
P) +
4076 if (!InOriginalClass)
4078 Results.MaybeAddResult(R, CurContext);
4082 if (IsClassProperty) {
4091 if (AllowNullaryMethods) {
4096 IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
4099 if (!AddedProperties.insert(Name).second)
4102 Results.getCodeCompletionTUInfo());
4104 Builder.AddTypedTextChunk(
4105 Results.getAllocator().CopyString(Name->
getName()));
4106 Result R = Result(Builder.TakeString(), M,
4108 if (!InOriginalClass)
4110 Results.MaybeAddResult(R, CurContext);
4113 if (IsClassProperty) {
4114 for (
const auto *M : Container->
methods()) {
4118 if (!M->getSelector().isUnarySelector() ||
4119 M->getReturnType()->isVoidType() || M->isInstanceMethod())
4124 for (
auto *M : Container->
methods()) {
4125 if (M->getSelector().isUnarySelector())
4133 for (
auto *
P : Protocol->protocols())
4135 CurContext, AddedProperties, Results,
4136 IsBaseExprStatement, IsClassProperty,
4139 dyn_cast<ObjCInterfaceDecl>(Container)) {
4140 if (AllowCategories) {
4142 for (
auto *Cat : IFace->known_categories())
4144 CurContext, AddedProperties, Results,
4145 IsBaseExprStatement, IsClassProperty,
4150 for (
auto *I : IFace->all_referenced_protocols())
4152 CurContext, AddedProperties, Results,
4153 IsBaseExprStatement, IsClassProperty,
4157 if (IFace->getSuperClass())
4159 AllowNullaryMethods, CurContext, AddedProperties,
4160 Results, IsBaseExprStatement, IsClassProperty,
4163 dyn_cast<ObjCCategoryDecl>(Container)) {
4167 CurContext, AddedProperties, Results,
4168 IsBaseExprStatement, IsClassProperty,
4176 Optional<FixItHint> AccessOpFixIt) {
4182 Results.allowNestedNameSpecifiers();
4183 std::vector<FixItHint> FixIts;
4185 FixIts.emplace_back(AccessOpFixIt.getValue());
4186 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
4193 if (!Results.empty()) {
4199 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
4201 IsDependent = Ctx->isDependentContext();
4215 bool IsBaseExprStatement) {
4216 if (!Base || !CodeCompleter)
4219 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4222 QualType ConvertedBaseType = ConvertedBase.
get()->getType();
4243 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4244 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4245 &ResultBuilder::IsMember);
4247 auto DoCompletion = [&](
Expr *Base,
bool IsArrow,
4252 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4255 Base = ConvertedBase.
get();
4271 std::move(AccessOpFixIt));
4272 }
else if (
const auto *TST =
4275 if (
const auto *TD =
4279 std::move(AccessOpFixIt));
4282 if (
auto *RD = ICNT->getDecl())
4284 std::move(AccessOpFixIt));
4287 AddedPropertiesSet AddedProperties;
4292 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4295 AddedProperties, Results, IsBaseExprStatement);
4301 CurContext, AddedProperties, Results,
4302 IsBaseExprStatement,
false,
4310 Class = ObjCPtr->getInterfaceDecl();
4316 CodeCompletionDeclConsumer Consumer(Results, Class, BaseType);
4317 Results.setFilter(&ResultBuilder::IsObjCIvar);
4319 Class, LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
4320 false, CodeCompleter->loadExternal());
4328 Results.EnterNewScope();
4330 bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
4331 if (CodeCompleter->includeFixIts()) {
4334 CompletionSucceded |= DoCompletion(
4335 OtherOpBase, !IsArrow,
4339 Results.ExitScope();
4341 if (!CompletionSucceded)
4346 Results.data(), Results.size());
4352 bool IsBaseExprStatement) {
4359 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4360 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4361 &ResultBuilder::IsMember);
4362 Results.EnterNewScope();
4363 AddedPropertiesSet AddedProperties;
4365 true, CurContext, AddedProperties,
4366 Results, IsBaseExprStatement,
4368 Results.ExitScope();
4370 Results.data(), Results.size());
4377 ResultBuilder::LookupFilter Filter =
nullptr;
4382 Filter = &ResultBuilder::IsEnum;
4387 Filter = &ResultBuilder::IsUnion;
4394 Filter = &ResultBuilder::IsClassOrStruct;
4399 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4402 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4403 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4404 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4407 Results.setFilter(Filter);
4409 CodeCompleter->includeGlobals(),
4410 CodeCompleter->loadExternal());
4412 if (CodeCompleter->includeGlobals()) {
4414 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4416 CodeCompleter->includeGlobals(),
4417 CodeCompleter->loadExternal());
4421 Results.data(), Results.size());
4427 Results.AddResult(
"const");
4429 Results.AddResult(
"volatile");
4431 Results.AddResult(
"restrict");
4433 Results.AddResult(
"_Atomic");
4435 Results.AddResult(
"__unaligned");
4439 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4440 CodeCompleter->getCodeCompletionTUInfo(),
4442 Results.EnterNewScope();
4444 Results.ExitScope();
4446 Results.data(), Results.size());
4451 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4452 CodeCompleter->getCodeCompletionTUInfo(),
4454 Results.EnterNewScope();
4456 if (LangOpts.CPlusPlus11) {
4457 Results.AddResult(
"noexcept");
4461 Results.AddResult(
"final");
4463 Results.AddResult(
"override");
4466 Results.ExitScope();
4468 Results.data(), Results.size());
4472 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4476 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4479 SwitchStmt *Switch = getCurFunction()->SwitchStack.back().getPointer();
4487 CodeCompleteExpression(S, Data);
4501 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
4510 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
4511 if (
auto *Enumerator =
4512 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
4519 EnumeratorsSeen.insert(Enumerator);
4532 Qualifier = DRE->getQualifier();
4536 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
4544 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4545 CodeCompleter->getCodeCompletionTUInfo(),
4547 Results.EnterNewScope();
4549 if (EnumeratorsSeen.count(E))
4553 Results.AddResult(R, CurContext,
nullptr,
false);
4555 Results.ExitScope();
4557 if (CodeCompleter->includeMacros()) {
4561 Results.data(), Results.size());
4565 if (Args.size() && !Args.data())
4568 for (
unsigned I = 0; I != Args.size(); ++I)
4580 if (!CandidateSet.
empty()) {
4583 CandidateSet.
begin(), CandidateSet.
end(),
4591 if (Candidate.Function && Candidate.Function->isDeleted())
4593 if (Candidate.Viable)
4602 ArrayRef<ResultCandidate> Candidates,
unsigned N) {
4608 for (
auto &Candidate : Candidates) {
4609 if (
const auto *FType = Candidate.getFunctionType())
4610 if (
const auto *Proto = dyn_cast<FunctionProtoType>(FType))
4611 if (N < Proto->getNumParams()) {
4613 ParamType = Proto->getParamType(N);
4616 Proto->getParamType(N).getNonReferenceType()))
4629 if (Candidates.empty())
4632 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
4656 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4657 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4659 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4661 if (UME->hasExplicitTemplateArgs()) {
4662 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4663 TemplateArgs = &TemplateArgsBuffer;
4668 1, UME->isImplicitAccess() ? nullptr : UME->getBase());
4669 ArgExprs.append(Args.begin(), Args.end());
4671 Decls.
append(UME->decls_begin(), UME->decls_end());
4672 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
4673 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4675 true, FirstArgumentIsBase);
4678 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
4680 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
4681 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4683 if (!getLangOpts().CPlusPlus ||
4696 if (isCompleteType(Loc, NakedFn->
getType())) {
4699 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4700 LookupQualifiedName(R, DC);
4703 ArgExprs.append(Args.begin(), Args.end());
4717 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4720 Results.push_back(ResultCandidate(FP));
4750 for (
NamedDecl *C : LookupConstructors(RD)) {
4751 if (
auto *FD = dyn_cast<FunctionDecl>(C)) {
4756 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(C)) {
4757 AddTemplateOverloadCandidate(
4759 nullptr, Args, CandidateSet,
4781 if (
ValueDecl *MemberDecl = tryLookupCtorInitMemberDecl(
4782 Constructor->
getParent(), SS, TemplateTypeTy, II))
4783 return ProduceConstructorSignatureHelp(getCurScope(), MemberDecl->getType(),
4784 MemberDecl->getLocation(), ArgExprs,
4790 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4792 CodeCompleteOrdinaryName(S, PCC_Expression);
4801 CodeCompleteExpression(S, Data);
4806 if (isa<BlockDecl>(CurContext)) {
4808 ResultType = BSI->ReturnType;
4809 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(CurContext))
4810 ResultType = Function->getReturnType();
4811 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4812 ResultType = Method->getReturnType();
4815 CodeCompleteOrdinaryName(S, PCC_Expression);
4817 CodeCompleteExpression(S, ResultType);
4821 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4822 CodeCompleter->getCodeCompletionTUInfo(),
4824 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4825 Results.EnterNewScope();
4827 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4829 CodeCompleter->includeGlobals(),
4830 CodeCompleter->loadExternal());
4836 Results.getCodeCompletionTUInfo());
4837 Builder.AddTypedTextChunk(
"else");
4838 if (Results.includeCodePatterns()) {
4842 Builder.AddPlaceholderChunk(
"statements");
4846 Results.AddResult(Builder.TakeString());
4849 Builder.AddTypedTextChunk(
"else");
4851 Builder.AddTextChunk(
"if");
4855 Builder.AddPlaceholderChunk(
"condition");
4857 Builder.AddPlaceholderChunk(
"expression");
4859 if (Results.includeCodePatterns()) {
4863 Builder.AddPlaceholderChunk(
"statements");
4867 Results.AddResult(Builder.TakeString());
4869 Results.ExitScope();
4874 if (CodeCompleter->includeMacros())
4878 Results.data(), Results.size());
4888 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
4891 if (Op == tok::minus)
4902 case tok::plusequal:
4904 case tok::minusequal:
4906 case tok::percentequal:
4908 case tok::slashequal:
4910 case tok::starequal:
4914 case tok::equalequal:
4915 case tok::exclaimequal:
4917 case tok::lessequal:
4919 case tok::greaterequal:
4920 case tok::spaceship:
4923 case tok::greatergreater:
4924 case tok::greatergreaterequal:
4926 case tok::lesslessequal:
4933 case tok::caretcaret:
4938 case tok::pipeequal:
4940 case tok::caretequal:
4948 case tok::periodstar:
4949 case tok::arrowstar:
4960 if (!PreferredType.
isNull())
4961 CodeCompleteExpression(S, PreferredType);
4963 CodeCompleteOrdinaryName(S, PCC_Expression);
4967 bool EnteringContext,
QualType BaseType) {
4968 if (SS.
isEmpty() || !CodeCompleter)
4989 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4992 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4993 CodeCompleter->getCodeCompletionTUInfo(),
4995 Results.EnterNewScope();
5001 Results.AddResult(
"template");
5008 if (!EnteringContext)
5010 Results.ExitScope();
5012 if (CodeCompleter->includeNamespaceLevelDecls() ||
5014 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
5018 CodeCompleter->loadExternal());
5021 auto CC = Results.getCompletionContext();
5022 CC.setCXXScopeSpecifier(SS);
5032 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5033 CodeCompleter->getCodeCompletionTUInfo(),
5038 &ResultBuilder::IsNestedNameSpecifier);
5039 Results.EnterNewScope();
5047 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5049 CodeCompleter->includeGlobals(),
5050 CodeCompleter->loadExternal());
5051 Results.ExitScope();
5054 Results.data(), Results.size());
5063 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5064 CodeCompleter->getCodeCompletionTUInfo(),
5066 &ResultBuilder::IsNamespaceOrAlias);
5067 Results.EnterNewScope();
5068 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5070 CodeCompleter->includeGlobals(),
5071 CodeCompleter->loadExternal());
5072 Results.ExitScope();
5074 Results.data(), Results.size());
5085 bool SuppressedGlobalResults =
5086 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
5088 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5089 CodeCompleter->getCodeCompletionTUInfo(),
5090 SuppressedGlobalResults
5093 &ResultBuilder::IsNamespace);
5095 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
5100 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
5105 OrigToLatest[NS->getOriginalNamespace()] = *NS;
5109 Results.EnterNewScope();
5110 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
5111 NS = OrigToLatest.begin(),
5112 NSEnd = OrigToLatest.end();
5117 CurContext,
nullptr,
false);
5118 Results.ExitScope();
5122 Results.data(), Results.size());
5130 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5131 CodeCompleter->getCodeCompletionTUInfo(),
5133 &ResultBuilder::IsNamespaceOrAlias);
5134 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5136 CodeCompleter->includeGlobals(),
5137 CodeCompleter->loadExternal());
5139 Results.data(), Results.size());
5147 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5148 CodeCompleter->getCodeCompletionTUInfo(),
5150 &ResultBuilder::IsType);
5151 Results.EnterNewScope();
5154 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 5155 if (std::strcmp(Spelling, "?")) \ 5156 Results.AddResult(Result(Spelling)); 5157 #include "clang/Basic/OperatorKinds.def" 5160 Results.allowNestedNameSpecifiers();
5161 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5163 CodeCompleter->includeGlobals(),
5164 CodeCompleter->loadExternal());
5168 Results.ExitScope();
5171 Results.data(), Results.size());
5179 AdjustDeclIfTemplate(ConstructorD);
5185 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5186 CodeCompleter->getCodeCompletionTUInfo(),
5188 Results.EnterNewScope();
5191 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
5192 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
5193 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
5194 if (Initializers[I]->isBaseInitializer())
5196 QualType(Initializers[I]->getBaseClass(), 0)));
5198 InitializedFields.insert(
5199 cast<FieldDecl>(Initializers[I]->getAnyMember()));
5204 bool SawLastInitializer = Initializers.empty();
5207 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
5209 Results.getCodeCompletionTUInfo());
5210 Builder.AddTypedTextChunk(Name);
5212 if (
const auto *Function = dyn_cast<FunctionDecl>(ND))
5214 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
5218 return Builder.TakeString();
5220 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
5223 Results.getCodeCompletionTUInfo());
5224 Builder.AddTypedTextChunk(Name);
5226 Builder.AddPlaceholderChunk(Type);
5230 Builder.TakeString(), ND,
5232 if (isa<FieldDecl>(ND))
5234 return Results.AddResult(CCR);
5237 Builder.TakeString(),
5240 auto AddCtorsWithName = [&](
const CXXRecordDecl *RD,
unsigned int Priority,
5241 const char *Name,
const FieldDecl *FD) {
5243 return AddDefaultCtorInit(Name,
5244 FD ? Results.getAllocator().CopyString(
5245 FD->getType().getAsString(Policy))
5249 if (Ctors.begin() == Ctors.end())
5250 return AddDefaultCtorInit(Name, Name, RD);
5254 Results.AddResult(CCR);
5258 const char *BaseName =
5259 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
5260 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
5265 auto AddField = [&](
const FieldDecl *FD) {
5266 const char *FieldName =
5267 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
5268 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
5274 for (
const auto &
Base : ClassDecl->
bases()) {
5277 SawLastInitializer =
5278 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5280 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5285 SawLastInitializer =
false;
5289 for (
const auto &
Base : ClassDecl->
vbases()) {
5292 SawLastInitializer =
5293 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5295 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5300 SawLastInitializer =
false;
5304 for (
auto *Field : ClassDecl->
fields()) {
5305 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
5307 SawLastInitializer = !Initializers.empty() &&
5308 Initializers.back()->isAnyMemberInitializer() &&
5309 Initializers.back()->getAnyMember() == Field;
5313 if (!Field->getDeclName())
5317 SawLastInitializer =
false;
5319 Results.ExitScope();
5322 Results.data(), Results.size());
5335 bool AfterAmpersand) {
5336 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5337 CodeCompleter->getCodeCompletionTUInfo(),
5339 Results.EnterNewScope();
5342 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
5343 bool IncludedThis =
false;
5344 for (
const auto &C : Intro.
Captures) {
5346 IncludedThis =
true;
5355 for (
const auto *D : S->
decls()) {
5356 const auto *Var = dyn_cast<
VarDecl>(D);
5357 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
5360 if (Known.insert(Var->getIdentifier()).second)
5362 CurContext,
nullptr,
false);
5370 Results.ExitScope();
5373 Results.data(), Results.size());
5378 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword) 5381 ResultBuilder &Results,
bool NeedAt) {
5387 Results.getCodeCompletionTUInfo());
5388 if (LangOpts.ObjC) {
5392 Builder.AddPlaceholderChunk(
"property");
5393 Results.AddResult(Result(Builder.TakeString()));
5398 Builder.AddPlaceholderChunk(
"property");
5399 Results.AddResult(Result(Builder.TakeString()));
5404 ResultBuilder &Results,
bool NeedAt) {
5410 if (LangOpts.ObjC) {
5425 Results.getCodeCompletionTUInfo());
5430 Builder.AddPlaceholderChunk(
"name");
5431 Results.AddResult(Result(Builder.TakeString()));
5433 if (Results.includeCodePatterns()) {
5439 Builder.AddPlaceholderChunk(
"class");
5440 Results.AddResult(Result(Builder.TakeString()));
5445 Builder.AddPlaceholderChunk(
"protocol");
5446 Results.AddResult(Result(Builder.TakeString()));
5451 Builder.AddPlaceholderChunk(
"class");
5452 Results.AddResult(Result(Builder.TakeString()));
5456 Builder.AddTypedTextChunk(
5459 Builder.AddPlaceholderChunk(
"alias");
5461 Builder.AddPlaceholderChunk(
"class");
5462 Results.AddResult(Result(Builder.TakeString()));
5464 if (Results.getSema().getLangOpts().Modules) {
5468 Builder.AddPlaceholderChunk(
"module");
5469 Results.AddResult(Result(Builder.TakeString()));
5474 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5475 CodeCompleter->getCodeCompletionTUInfo(),
5477 Results.EnterNewScope();
5478 if (isa<ObjCImplDecl>(CurContext))
5484 Results.ExitScope();
5486 Results.data(), Results.size());
5492 Results.getCodeCompletionTUInfo());
5495 const char *EncodeType =
"char[]";
5496 if (Results.getSema().getLangOpts().CPlusPlus ||
5497 Results.getSema().getLangOpts().ConstStrings)
5498 EncodeType =
"const char[]";
5499 Builder.AddResultTypeChunk(EncodeType);
5502 Builder.AddPlaceholderChunk(
"type-name");
5504 Results.AddResult(Result(Builder.TakeString()));
5507 Builder.AddResultTypeChunk(
"Protocol *");
5510 Builder.AddPlaceholderChunk(
"protocol-name");
5512 Results.AddResult(Result(Builder.TakeString()));
5515 Builder.AddResultTypeChunk(
"SEL");
5518 Builder.AddPlaceholderChunk(
"selector");
5520 Results.AddResult(Result(Builder.TakeString()));
5523 Builder.AddResultTypeChunk(
"NSString *");
5525 Builder.AddPlaceholderChunk(
"string");
5526 Builder.AddTextChunk(
"\"");
5527 Results.AddResult(Result(Builder.TakeString()));
5530 Builder.AddResultTypeChunk(
"NSArray *");
5532 Builder.AddPlaceholderChunk(
"objects, ...");
5534 Results.AddResult(Result(Builder.TakeString()));
5537 Builder.AddResultTypeChunk(
"NSDictionary *");
5539 Builder.AddPlaceholderChunk(
"key");
5542 Builder.AddPlaceholderChunk(
"object, ...");
5544 Results.AddResult(Result(Builder.TakeString()));
5547 Builder.AddResultTypeChunk(
"id");
5549 Builder.AddPlaceholderChunk(
"expression");
5551 Results.AddResult(Result(Builder.TakeString()));
5557 Results.getCodeCompletionTUInfo());
5559 if (Results.includeCodePatterns()) {
5564 Builder.AddPlaceholderChunk(
"statements");
5566 Builder.AddTextChunk(
"@catch");
5568 Builder.AddPlaceholderChunk(
"parameter");
5571 Builder.AddPlaceholderChunk(
"statements");
5573 Builder.AddTextChunk(
"@finally");
5575 Builder.AddPlaceholderChunk(
"statements");
5577 Results.AddResult(Result(Builder.TakeString()));
5583 Builder.AddPlaceholderChunk(
"expression");
5584 Results.AddResult(Result(Builder.TakeString()));
5586 if (Results.includeCodePatterns()) {
5591 Builder.AddPlaceholderChunk(
"expression");
5594 Builder.AddPlaceholderChunk(
"statements");
5596 Results.AddResult(Result(Builder.TakeString()));
5601 ResultBuilder &Results,
bool NeedAt) {
5611 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5612 CodeCompleter->getCodeCompletionTUInfo(),
5614 Results.EnterNewScope();
5616 Results.ExitScope();
5618 Results.data(), Results.size());
5622 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5623 CodeCompleter->getCodeCompletionTUInfo(),
5625 Results.EnterNewScope();
5628 Results.ExitScope();
5630 Results.data(), Results.size());
5634 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5635 CodeCompleter->getCodeCompletionTUInfo(),
5637 Results.EnterNewScope();
5639 Results.ExitScope();
5641 Results.data(), Results.size());
5648 if (Attributes & NewFlag)
5651 Attributes |= NewFlag;
5659 unsigned AssignCopyRetMask =
5681 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5682 CodeCompleter->getCodeCompletionTUInfo(),
5684 Results.EnterNewScope();
5712 Results.getCodeCompletionTUInfo());
5714 Setter.AddTextChunk(
"=");
5715 Setter.AddPlaceholderChunk(
"method");
5720 Results.getCodeCompletionTUInfo());
5722 Getter.AddTextChunk(
"=");
5723 Getter.AddPlaceholderChunk(
"method");
5732 Results.ExitScope();
5734 Results.data(), Results.size());
5746 ArrayRef<IdentifierInfo *> SelIdents,
5747 bool AllowSameLength =
true) {
5748 unsigned NumSelIdents = SelIdents.size();
5761 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
5764 for (
unsigned I = 0; I != NumSelIdents; ++I)
5773 ArrayRef<IdentifierInfo *> SelIdents,
5774 bool AllowSameLength =
true) {
5805 ArrayRef<IdentifierInfo *> SelIdents,
5807 VisitedSelectorSet &Selectors,
bool AllowSameLength,
5808 ResultBuilder &Results,
bool InOriginalClass =
true,
5809 bool IsRootClass =
false) {
5813 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
5817 if (M->isInstanceMethod() == WantInstanceMethods ||
5818 (IsRootClass && !WantInstanceMethods)) {
5824 if (!Selectors.insert(M->getSelector()).second)
5827 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5828 R.StartParameter = SelIdents.size();
5829 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5830 if (!InOriginalClass)
5832 Results.MaybeAddResult(R, CurContext);
5837 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
5838 if (Protocol->hasDefinition()) {
5840 Protocol->getReferencedProtocols();
5842 E = Protocols.
end();
5844 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5845 Selectors, AllowSameLength, Results,
false, IsRootClass);
5854 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5855 Selectors, AllowSameLength, Results,
false, IsRootClass);
5859 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5860 CurContext, Selectors, AllowSameLength, Results,
5861 InOriginalClass, IsRootClass);
5865 CatDecl->getReferencedProtocols();
5867 E = Protocols.
end();
5869 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5870 Selectors, AllowSameLength, Results,
false, IsRootClass);
5874 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5875 Selectors, AllowSameLength, Results, InOriginalClass,
5883 SelIdents, CurContext, Selectors, AllowSameLength, Results,
5888 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5889 Selectors, AllowSameLength, Results, InOriginalClass,
5898 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5899 Class =
Category->getClassInterface();
5906 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5907 CodeCompleter->getCodeCompletionTUInfo(),
5909 Results.EnterNewScope();
5911 VisitedSelectorSet Selectors;
5914 Results.ExitScope();
5916 Results.data(), Results.size());
5924 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5925 Class =
Category->getClassInterface();
5932 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5933 CodeCompleter->getCodeCompletionTUInfo(),
5935 Results.EnterNewScope();
5937 VisitedSelectorSet Selectors;
5941 Results.ExitScope();
5943 Results.data(), Results.size());
5948 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5949 CodeCompleter->getCodeCompletionTUInfo(),
5951 Results.EnterNewScope();
5954 bool AddedInOut =
false;
5957 Results.AddResult(
"in");
5958 Results.AddResult(
"inout");
5963 Results.AddResult(
"out");
5965 Results.AddResult(
"inout");
5970 Results.AddResult(
"bycopy");
5971 Results.AddResult(
"byref");
5972 Results.AddResult(
"oneway");
5975 Results.AddResult(
"nonnull");
5976 Results.AddResult(
"nullable");
5977 Results.AddResult(
"null_unspecified");
5985 PP.isMacroDefined(
"IBAction")) {
5987 Results.getCodeCompletionTUInfo(),
5989 Builder.AddTypedTextChunk(
"IBAction");
5991 Builder.AddPlaceholderChunk(
"selector");
5994 Builder.AddTextChunk(
"id");
5996 Builder.AddTextChunk(
"sender");
6007 Results.ExitScope();
6010 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
6011 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6013 CodeCompleter->includeGlobals(),
6014 CodeCompleter->loadExternal());
6016 if (CodeCompleter->includeMacros())
6020 Results.data(), Results.size());
6028 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
6046 switch (Msg->getReceiverKind()) {
6050 IFace = ObjType->getInterface();
6054 QualType T = Msg->getInstanceReceiver()->getType();
6056 IFace = Ptr->getInterfaceDecl();
6070 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6071 .Case(
"retain", IFace)
6072 .Case(
"strong", IFace)
6073 .Case(
"autorelease", IFace)
6074 .Case(
"copy", IFace)
6075 .Case(
"copyWithZone", IFace)
6076 .Case(
"mutableCopy", IFace)
6077 .Case(
"mutableCopyWithZone", IFace)
6078 .Case(
"awakeFromCoder", IFace)
6079 .Case(
"replacementObjectFromCoder", IFace)
6080 .Case(
"class", IFace)
6081 .Case(
"classForCoder", IFace)
6082 .Case(
"superclass", Super)
6085 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6087 .Case(
"alloc", IFace)
6088 .Case(
"allocWithZone", IFace)
6089 .Case(
"class", IFace)
6090 .Case(
"superclass", Super)
6112 ArrayRef<IdentifierInfo *> SelIdents,
6113 ResultBuilder &Results) {
6132 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
6150 CurP != CurPEnd; ++CurP, ++SuperP) {
6153 (*SuperP)->getType()))
6157 if (!(*CurP)->getIdentifier())
6163 Results.getCodeCompletionTUInfo());
6167 Results.getCompletionContext().getBaseType(), Builder);
6170 if (NeedSuperKeyword) {
6171 Builder.AddTypedTextChunk(
"super");
6177 if (NeedSuperKeyword)
6178 Builder.AddTextChunk(
6181 Builder.AddTypedTextChunk(
6185 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
6186 if (I > SelIdents.size())
6189 if (I < SelIdents.size())
6190 Builder.AddInformativeChunk(
6192 else if (NeedSuperKeyword || I > SelIdents.size()) {
6193 Builder.AddTextChunk(
6195 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6196 (*CurP)->getIdentifier()->getName()));
6198 Builder.AddTypedTextChunk(
6200 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6201 (*CurP)->getIdentifier()->getName()));
6213 ResultBuilder Results(
6214 *
this, CodeCompleter->getAllocator(),
6215 CodeCompleter->getCodeCompletionTUInfo(),
6217 getLangOpts().CPlusPlus11
6218 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
6219 : &ResultBuilder::IsObjCMessageReceiver);
6221 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6222 Results.EnterNewScope();
6224 CodeCompleter->includeGlobals(),
6225 CodeCompleter->loadExternal());
6231 if (Iface->getSuperClass()) {
6232 Results.AddResult(Result(
"super"));
6240 Results.ExitScope();
6242 if (CodeCompleter->includeMacros())
6245 Results.data(), Results.size());
6250 bool AtArgumentExpression) {
6254 CDecl = CurMethod->getClassInterface();
6263 if (CurMethod->isInstanceMethod()) {
6267 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
6268 AtArgumentExpression, CDecl);
6276 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc, LookupOrdinaryName);
6277 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
6279 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
6282 CDecl = Iface->getInterface();
6283 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
6290 id.setIdentifier(Super, SuperLoc);
6292 ActOnIdExpression(S, SS, TemplateKWLoc,
id,
false,
false);
6293 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
6294 SelIdents, AtArgumentExpression);
6303 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
6304 AtArgumentExpression,
6311 unsigned NumSelIdents) {
6313 ASTContext &Context = Results.getSema().Context;
6317 Result *ResultsData = Results.data();
6318 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
6319 Result &R = ResultsData[I];
6320 if (R.Kind == Result::RK_Declaration &&
6321 isa<ObjCMethodDecl>(R.Declaration)) {
6322 if (R.Priority <= BestPriority) {
6323 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
6324 if (NumSelIdents <= Method->param_size()) {
6326 Method->
parameters()[NumSelIdents - 1]->getType();
6327 if (R.Priority < BestPriority || PreferredType.
isNull()) {
6328 BestPriority = R.Priority;
6329 PreferredType = MyPreferredType;
6339 return PreferredType;
6344 ArrayRef<IdentifierInfo *> SelIdents,
6345 bool AtArgumentExpression,
bool IsSuper,
6346 ResultBuilder &Results) {
6356 CDecl = Interface->getInterface();
6361 Results.EnterNewScope();
6368 Results.Ignore(SuperMethod);
6374 Results.setPreferredSelector(CurMethod->getSelector());
6376 VisitedSelectorSet Selectors;
6379 Selectors, AtArgumentExpression, Results);
6386 for (uint32_t I = 0,
6397 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
6401 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6405 Result R(MethList->getMethod(),
6406 Results.getBasePriority(MethList->getMethod()),
nullptr);
6407 R.StartParameter = SelIdents.size();
6408 R.AllParametersAreInformative =
false;
6409 Results.MaybeAddResult(R, SemaRef.
CurContext);
6414 Results.ExitScope();
6419 bool AtArgumentExpression,
6422 QualType T = this->GetTypeFromParser(Receiver);
6424 ResultBuilder Results(
6425 *
this, CodeCompleter->getAllocator(),
6426 CodeCompleter->getCodeCompletionTUInfo(),
6431 AtArgumentExpression, IsSuper, Results);
6438 if (AtArgumentExpression) {
6441 if (PreferredType.
isNull())
6442 CodeCompleteOrdinaryName(S, PCC_Expression);
6444 CodeCompleteExpression(S, PreferredType);
6449 Results.data(), Results.size());
6454 bool AtArgumentExpression,
6458 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6463 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6466 RecExpr = Conv.
get();
6480 return CodeCompleteObjCClassMessage(
6482 AtArgumentExpression, Super);
6487 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6488 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6490 RecExpr = Conv.
get();
6491 ReceiverType = RecExpr->
getType();
6496 ResultBuilder Results(
6497 *
this, CodeCompleter->getAllocator(),
6498 CodeCompleter->getCodeCompletionTUInfo(),
6500 ReceiverType, SelIdents));
6502 Results.EnterNewScope();
6509 Results.Ignore(SuperMethod);
6515 Results.setPreferredSelector(CurMethod->getSelector());
6518 VisitedSelectorSet Selectors;
6528 Selectors, AtArgumentExpression, Results);
6535 for (
auto *I : QualID->quals())
6537 AtArgumentExpression, Results);
6544 CurContext, Selectors, AtArgumentExpression, Results);
6547 for (
auto *I : IFacePtr->quals())
6549 AtArgumentExpression, Results);
6558 if (ExternalSource) {
6559 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6561 Selector Sel = ExternalSource->GetExternalSelector(I);
6562 if (Sel.
isNull() || MethodPool.count(Sel))
6565 ReadMethodPool(Sel);
6569 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6570 MEnd = MethodPool.end();
6573 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6577 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6580 Result R(MethList->getMethod(),
6581 Results.getBasePriority(MethList->getMethod()),
nullptr);
6582 R.StartParameter = SelIdents.size();
6583 R.AllParametersAreInformative =
false;
6584 Results.MaybeAddResult(R, CurContext);
6588 Results.ExitScope();
6595 if (AtArgumentExpression) {
6598 if (PreferredType.
isNull())
6599 CodeCompleteOrdinaryName(S, PCC_Expression);
6601 CodeCompleteExpression(S, PreferredType);
6606 Results.data(), Results.size());
6622 CodeCompleteExpression(S, Data);
6629 if (ExternalSource) {
6630 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
6632 Selector Sel = ExternalSource->GetExternalSelector(I);
6633 if (Sel.
isNull() || MethodPool.count(Sel))
6636 ReadMethodPool(Sel);
6640 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6641 CodeCompleter->getCodeCompletionTUInfo(),
6643 Results.EnterNewScope();
6644 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6645 MEnd = MethodPool.end();
6653 Results.getCodeCompletionTUInfo());
6655 Builder.AddTypedTextChunk(
6657 Results.AddResult(Builder.TakeString());
6661 std::string Accumulator;
6662 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
6663 if (I == SelIdents.size()) {
6664 if (!Accumulator.empty()) {
6665 Builder.AddInformativeChunk(
6666 Builder.getAllocator().CopyString(Accumulator));
6667 Accumulator.clear();
6674 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
6675 Results.AddResult(Builder.TakeString());
6677 Results.ExitScope();
6680 Results.data(), Results.size());
6686 bool OnlyForwardDeclarations,
6687 ResultBuilder &Results) {
6690 for (
const auto *D : Ctx->
decls()) {
6692 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
6693 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
6695 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
6702 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6703 CodeCompleter->getCodeCompletionTUInfo(),
6706 if (CodeCompleter->includeGlobals()) {
6707 Results.EnterNewScope();
6714 Results.Ignore(Protocol);
6720 Results.ExitScope();
6724 Results.data(), Results.size());
6728 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6729 CodeCompleter->getCodeCompletionTUInfo(),
6732 if (CodeCompleter->includeGlobals()) {
6733 Results.EnterNewScope();
6739 Results.ExitScope();
6743 Results.data(), Results.size());
6749 bool OnlyForwardDeclarations,
6750 bool OnlyUnimplemented,
6751 ResultBuilder &Results) {
6754 for (
const auto *D : Ctx->
decls()) {
6756 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
6757 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
6758 (!OnlyUnimplemented || !Class->getImplementation()))
6760 Result(Class, Results.getBasePriority(Class),
nullptr), CurContext,
6766 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6767 CodeCompleter->getCodeCompletionTUInfo(),
6769 Results.EnterNewScope();
6771 if (CodeCompleter->includeGlobals()) {
6777 Results.ExitScope();
6780 Results.data(), Results.size());
6785 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6786 CodeCompleter->getCodeCompletionTUInfo(),
6788 Results.EnterNewScope();
6792 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6793 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6794 Results.Ignore(CurClass);
6796 if (CodeCompleter->includeGlobals()) {
6802 Results.ExitScope();
6805 Results.data(), Results.size());
6809 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6810 CodeCompleter->getCodeCompletionTUInfo(),
6812 Results.EnterNewScope();
6814 if (CodeCompleter->includeGlobals()) {
6820 Results.ExitScope();
6823 Results.data(), Results.size());
6831 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6832 CodeCompleter->getCodeCompletionTUInfo(),
6837 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6839 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6841 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
6842 for (
const auto *Cat : Class->visible_categories())
6843 CategoryNames.insert(Cat->getIdentifier());
6847 Results.EnterNewScope();
6849 for (
const auto *D : TU->
decls())
6850 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6851 if (CategoryNames.insert(
Category->getIdentifier()).second)
6854 CurContext,
nullptr,
false);
6855 Results.ExitScope();
6858 Results.data(), Results.size());
6870 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6873 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6875 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6876 CodeCompleter->getCodeCompletionTUInfo(),
6882 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6883 Results.EnterNewScope();
6884 bool IgnoreImplemented =
true;
6887 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6888 CategoryNames.insert(Cat->getIdentifier()).second)
6889 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6890 CurContext,
nullptr,
false);
6894 IgnoreImplemented =
false;
6896 Results.ExitScope();
6899 Results.data(), Results.size());
6904 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6905 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
6909 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6910 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
6911 !isa<ObjCCategoryImplDecl>(Container)))
6916 for (
const auto *D : Container->decls())
6917 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6918 Results.Ignore(PropertyImpl->getPropertyDecl());
6921 AddedPropertiesSet AddedProperties;
6922 Results.EnterNewScope();
6924 dyn_cast<ObjCImplementationDecl>(Container))
6927 AddedProperties, Results);
6930 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6931 false,
false, CurContext,
6932 AddedProperties, Results);
6933 Results.ExitScope();
6936 Results.data(), Results.size());
6942 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6943 CodeCompleter->getCodeCompletionTUInfo(),
6948 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6949 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
6950 !isa<ObjCCategoryImplDecl>(Container)))
6956 dyn_cast<ObjCImplementationDecl>(Container))
6957 Class = ClassImpl->getClassInterface();
6959 Class = cast<ObjCCategoryImplDecl>(Container)
6961 ->getClassInterface();
6969 Property->getType().getNonReferenceType().getUnqualifiedType();
6972 Results.setPreferredType(PropertyType);
6977 Results.EnterNewScope();
6978 bool SawSimilarlyNamedIvar =
false;
6979 std::string NameWithPrefix;
6980 NameWithPrefix +=
'_';
6981 NameWithPrefix += PropertyName->
getName();
6982 std::string NameWithSuffix = PropertyName->
getName().str();
6983 NameWithSuffix +=
'_';
6987 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6988 CurContext,
nullptr,
false);
6992 if ((PropertyName == Ivar->getIdentifier() ||
6993 NameWithPrefix == Ivar->
getName() ||
6994 NameWithSuffix == Ivar->getName())) {
6995 SawSimilarlyNamedIvar =
true;
6999 if (Results.size() &&
7000 Results.data()[Results.size() - 1].Kind ==
7002 Results.data()[Results.size() - 1].Declaration == Ivar)
7003 Results.data()[Results.size() - 1].Priority--;
7008 if (!SawSimilarlyNamedIvar) {
7018 Builder.AddResultTypeChunk(
7020 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
7025 Results.ExitScope();
7028 Results.data(), Results.size());
7034 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
7043 Optional<bool> WantInstanceMethods,
7046 bool InOriginalClass =
true) {
7049 if (!IFace->hasDefinition())
7052 IFace = IFace->getDefinition();
7056 IFace->getReferencedProtocols();
7058 E = Protocols.
end();
7061 KnownMethods, InOriginalClass);
7064 for (
auto *Cat : IFace->visible_categories()) {
7066 KnownMethods,
false);
7070 if (IFace->getSuperClass())
7072 WantInstanceMethods, ReturnType, KnownMethods,
7079 Category->getReferencedProtocols();
7081 E = Protocols.
end();
7084 KnownMethods, InOriginalClass);
7087 if (InOriginalClass &&
Category->getClassInterface())
7089 WantInstanceMethods, ReturnType, KnownMethods,
7095 if (!Protocol->hasDefinition())
7097 Protocol = Protocol->getDefinition();
7098 Container = Protocol;
7102 Protocol->getReferencedProtocols();
7104 E = Protocols.
end();
7107 KnownMethods,
false);
7113 for (
auto *M : Container->
methods()) {
7114 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
7115 if (!ReturnType.
isNull() &&
7119 KnownMethods[M->getSelector()] =
7120 KnownMethodsMap::mapped_type(M, InOriginalClass);
7155 bool IsInstanceMethod,
7157 VisitedSelectorSet &KnownSelectors,
7158 ResultBuilder &Results) {
7160 if (!PropName || PropName->
getLength() == 0)
7178 const char *CopiedKey;
7181 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
7183 operator const char *() {
7187 return CopiedKey = Allocator.
CopyString(Key);
7189 } Key(Allocator, PropName->
getName());
7192 std::string UpperKey = PropName->
getName();
7193 if (!UpperKey.empty())
7196 bool ReturnTypeMatchesProperty =
7200 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
7203 if (IsInstanceMethod &&
7204 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
7210 Builder.AddTypedTextChunk(Key);
7217 if (IsInstanceMethod &&
7218 ((!ReturnType.
isNull() &&
7222 std::string SelectorName = (Twine(
"is") + UpperKey).
str();
7224 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7226 if (ReturnType.
isNull()) {
7228 Builder.AddTextChunk(
"BOOL");
7239 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
7241 std::string SelectorName = (Twine(
"set") + UpperKey).
str();
7243 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7244 if (ReturnType.
isNull()) {
7246 Builder.AddTextChunk(
"void");
7251 Builder.AddTypedTextChunk(
":");
7254 Builder.AddTextChunk(Key);
7265 if (
const auto *ObjCPointer =
7290 if (IsInstanceMethod &&
7292 std::string SelectorName = (Twine(
"countOf") + UpperKey).
str();
7294 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7296 if (ReturnType.
isNull()) {
7298 Builder.AddTextChunk(
"NSUInteger");
7304 Result(Builder.TakeString(),
7305 std::min(IndexedGetterPriority, UnorderedGetterPriority),
7312 if (IsInstanceMethod &&
7314 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").
str();
7316 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7317 if (ReturnType.
isNull()) {
7319 Builder.AddTextChunk(
"id");
7323 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7325 Builder.AddTextChunk(
"NSUInteger");
7327 Builder.AddTextChunk(
"index");
7328 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7334 if (IsInstanceMethod &&
7339 ->getInterfaceDecl()
7340 ->getName() ==
"NSArray"))) {
7341 std::string SelectorName = (Twine(Property->
getName()) +
"AtIndexes").str();
7343 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7344 if (ReturnType.
isNull()) {
7346 Builder.AddTextChunk(
"NSArray *");
7350 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7352 Builder.AddTextChunk(
"NSIndexSet *");
7354 Builder.AddTextChunk(
"indexes");
7355 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7361 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7362 std::string SelectorName = (Twine(
"get") + UpperKey).
str();
7366 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7367 if (ReturnType.
isNull()) {
7369 Builder.AddTextChunk(
"void");
7373 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7375 Builder.AddPlaceholderChunk(
"object-type");
7376 Builder.AddTextChunk(
" **");
7378 Builder.AddTextChunk(
"buffer");
7380 Builder.AddTypedTextChunk(
"range:");
7382 Builder.AddTextChunk(
"NSRange");
7384 Builder.AddTextChunk(
"inRange");
7385 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7393 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7394 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").
str();
7398 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7399 if (ReturnType.
isNull()) {
7401 Builder.AddTextChunk(
"void");
7405 Builder.AddTypedTextChunk(
"insertObject:");
7407 Builder.AddPlaceholderChunk(
"object-type");
7408 Builder.AddTextChunk(
" *");
7410 Builder.AddTextChunk(
"object");
7412 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7414 Builder.AddPlaceholderChunk(
"NSUInteger");
7416 Builder.AddTextChunk(
"index");
7417 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7423 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7424 std::string SelectorName = (Twine(
"insert") + UpperKey).
str();
7428 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7429 if (ReturnType.
isNull()) {
7431 Builder.AddTextChunk(
"void");
7435 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7437 Builder.AddTextChunk(
"NSArray *");
7439 Builder.AddTextChunk(
"array");
7441 Builder.AddTypedTextChunk(
"atIndexes:");
7443 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7445 Builder.AddTextChunk(
"indexes");
7446 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7452 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7453 std::string SelectorName =
7454 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").
str();
7456 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7457 if (ReturnType.
isNull()) {
7459 Builder.AddTextChunk(
"void");
7463 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7465 Builder.AddTextChunk(
"NSUInteger");
7467 Builder.AddTextChunk(
"index");
7468 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7474 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7475 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").
str();
7477 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7478 if (ReturnType.
isNull()) {
7480 Builder.AddTextChunk(
"void");
7484 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7486 Builder.AddTextChunk(
"NSIndexSet *");
7488 Builder.AddTextChunk(
"indexes");
7489 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7495 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7496 std::string SelectorName =
7497 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").
str();
7501 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7502 if (ReturnType.
isNull()) {
7504 Builder.AddTextChunk(
"void");
7508 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7510 Builder.AddPlaceholderChunk(
"NSUInteger");
7512 Builder.AddTextChunk(
"index");
7514 Builder.AddTypedTextChunk(
"withObject:");
7516 Builder.AddTextChunk(
"id");
7518 Builder.AddTextChunk(
"object");
7519 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7525 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7526 std::string SelectorName1 =
7527 (Twine(
"replace") + UpperKey +
"AtIndexes").
str();
7528 std::string SelectorName2 = (Twine(
"with") + UpperKey).
str();
7532 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7533 if (ReturnType.
isNull()) {
7535 Builder.AddTextChunk(
"void");
7539 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
7541 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7543 Builder.AddTextChunk(
"indexes");
7545 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
7547 Builder.AddTextChunk(
"NSArray *");
7549 Builder.AddTextChunk(
"array");
7550 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7557 if (IsInstanceMethod &&
7562 ->getInterfaceDecl()
7563 ->getName() ==
"NSEnumerator"))) {
7564 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).
str();
7566 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7568 if (ReturnType.
isNull()) {
7570 Builder.AddTextChunk(
"NSEnumerator *");
7574 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7575 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7581 if (IsInstanceMethod &&
7583 std::string SelectorName = (Twine(
"memberOf") + UpperKey).
str();
7585 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7586 if (ReturnType.
isNull()) {
7588 Builder.AddPlaceholderChunk(
"object-type");
7589 Builder.AddTextChunk(
" *");
7593 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7595 if (ReturnType.
isNull()) {
7596 Builder.AddPlaceholderChunk(
"object-type");
7597 Builder.AddTextChunk(
" *");
7600 ReturnType, Context, Policy, Builder.getAllocator()));
7603 Builder.AddTextChunk(
"object");
7604 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7611 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7612 std::string SelectorName =
7613 (Twine(
"add") + UpperKey + Twine(
"Object")).
str();
7615 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7616 if (ReturnType.
isNull()) {
7618 Builder.AddTextChunk(
"void");
7622 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7624 Builder.AddPlaceholderChunk(
"object-type");
7625 Builder.AddTextChunk(
" *");
7627 Builder.AddTextChunk(
"object");
7628 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7634 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7635 std::string SelectorName = (Twine(
"add") + UpperKey).
str();
7637 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7638 if (ReturnType.
isNull()) {
7640 Builder.AddTextChunk(
"void");
7644 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7646 Builder.AddTextChunk(
"NSSet *");
7648 Builder.AddTextChunk(
"objects");
7649 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7655 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7656 std::string SelectorName =
7657 (Twine(
"remove") + UpperKey + Twine(
"Object")).
str();
7659 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7660 if (ReturnType.
isNull()) {
7662 Builder.AddTextChunk(
"void");
7666 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7668 Builder.AddPlaceholderChunk(
"object-type");
7669 Builder.AddTextChunk(
" *");
7671 Builder.AddTextChunk(
"object");
7672 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7678 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7679 std::string SelectorName = (Twine(
"remove") + UpperKey).
str();
7681 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7682 if (ReturnType.
isNull()) {
7684 Builder.AddTextChunk(
"void");
7688 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7690 Builder.AddTextChunk(
"NSSet *");
7692 Builder.AddTextChunk(
"objects");
7693 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7699 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7700 std::string SelectorName = (Twine(
"intersect") + UpperKey).
str();
7702 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7703 if (ReturnType.
isNull()) {
7705 Builder.AddTextChunk(
"void");
7709 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7711 Builder.AddTextChunk(
"NSSet *");
7713 Builder.AddTextChunk(
"objects");
7714 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7721 if (!IsInstanceMethod &&
7726 ->getInterfaceDecl()
7727 ->getName() ==
"NSSet"))) {
7728 std::string SelectorName =
7729 (Twine(
"keyPathsForValuesAffecting") + UpperKey).
str();
7731 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7733 if (ReturnType.
isNull()) {
7735 Builder.AddTextChunk(
"NSSet<NSString *> *");
7739 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7746 if (!IsInstanceMethod &&
7749 std::string SelectorName =
7750 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).
str();
7752 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7754 if (ReturnType.
isNull()) {
7756 Builder.AddTextChunk(
"BOOL");
7760 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7771 QualType ReturnType = GetTypeFromParser(ReturnTy);
7772 Decl *IDecl =
nullptr;
7779 bool IsInImplementation =
false;
7780 if (
Decl *D = IDecl) {
7782 SearchDecl = Impl->getClassInterface();
7783 IsInImplementation =
true;
7785 dyn_cast<ObjCCategoryImplDecl>(D)) {
7786 SearchDecl = CatImpl->getCategoryDecl();
7787 IsInImplementation =
true;
7792 if (!SearchDecl && S) {
7794 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7810 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7811 CodeCompleter->getCodeCompletionTUInfo(),
7813 Results.EnterNewScope();
7815 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7816 MEnd = KnownMethods.end();
7820 Results.getCodeCompletionTUInfo());
7823 if (!IsInstanceMethod) {
7830 if (ReturnType.
isNull()) {
7840 Builder.AddTypedTextChunk(
7841 Builder.getAllocator().CopyString(Sel.getNameForSlot(0)));
7847 P != PEnd; (void)++
P, ++I) {
7850 Builder.AddTypedTextChunk(
":");
7851 else if (I < Sel.getNumArgs()) {
7853 Builder.AddTypedTextChunk(
7854 Builder.getAllocator().CopyString(Sel.getNameForSlot(I) +
":"));
7861 ParamType = (*P)->getType();
7863 ParamType = (*P)->getOriginalType();
7871 Builder.AddTextChunk(Builder.getAllocator().CopyString(
Id->getName()));
7877 Builder.AddTextChunk(
"...");
7880 if (IsInImplementation && Results.includeCodePatterns()) {
7887 Builder.AddTextChunk(
"return");
7889 Builder.AddPlaceholderChunk(
"expression");
7892 Builder.AddPlaceholderChunk(
"statements");
7899 auto R = Result(Builder.TakeString(), Method, Priority);
7900 if (!M->second.getInt())
7902 Results.AddResult(std::move(R));
7909 Containers.push_back(SearchDecl);
7911 VisitedSelectorSet KnownSelectors;
7912 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7913 MEnd = KnownMethods.end();
7915 KnownSelectors.insert(M->first);
7920 IFace =
Category->getClassInterface();
7924 Containers.push_back(Cat);
7926 if (IsInstanceMethod) {
7927 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
7928 for (
auto *
P : Containers[I]->instance_properties())
7930 KnownSelectors, Results);
7934 Results.ExitScope();
7937 Results.data(), Results.size());
7941 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
7945 if (ExternalSource) {
7946 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
7948 Selector Sel = ExternalSource->GetExternalSelector(I);
7949 if (Sel.
isNull() || MethodPool.count(Sel))
7952 ReadMethodPool(Sel);
7958 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7959 CodeCompleter->getCodeCompletionTUInfo(),
7963 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7965 Results.EnterNewScope();
7966 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7967 MEnd = MethodPool.end();
7969 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
7970 : &M->second.second;
7971 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
7975 if (AtParameterName) {
7977 unsigned NumSelIdents = SelIdents.size();
7979 NumSelIdents <= MethList->getMethod()->param_size()) {
7981 MethList->getMethod()->parameters()[NumSelIdents - 1];
7984 Results.getCodeCompletionTUInfo());
7985 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7987 Results.AddResult(Builder.TakeString());
7994 Result R(MethList->getMethod(),
7995 Results.getBasePriority(MethList->getMethod()),
nullptr);
7996 R.StartParameter = SelIdents.size();
7997 R.AllParametersAreInformative =
false;
7998 R.DeclaringEntity =
true;
7999 Results.MaybeAddResult(R, CurContext);
8003 Results.ExitScope();
8005 if (!AtParameterName && !SelIdents.empty() &&
8006 SelIdents.front()->getName().startswith(
"init")) {
8007 for (
const auto &M : PP.macros()) {
8008 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
8010 Results.EnterNewScope();
8012 Results.getCodeCompletionTUInfo());
8013 Builder.AddTypedTextChunk(
8014 Builder.getAllocator().CopyString(M.first->getName()));
8017 Results.ExitScope();
8022 Results.data(), Results.size());
8026 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8027 CodeCompleter->getCodeCompletionTUInfo(),
8029 Results.EnterNewScope();
8033 Results.getCodeCompletionTUInfo());
8034 Builder.AddTypedTextChunk(
"if");
8036 Builder.AddPlaceholderChunk(
"condition");
8037 Results.AddResult(Builder.TakeString());
8040 Builder.AddTypedTextChunk(
"ifdef");
8042 Builder.AddPlaceholderChunk(
"macro");
8043 Results.AddResult(Builder.TakeString());
8046 Builder.AddTypedTextChunk(
"ifndef");
8048 Builder.AddPlaceholderChunk(
"macro");
8049 Results.AddResult(Builder.TakeString());
8051 if (InConditional) {
8053 Builder.AddTypedTextChunk(
"elif");
8055 Builder.AddPlaceholderChunk(
"condition");
8056 Results.AddResult(Builder.TakeString());
8059 Builder.AddTypedTextChunk(
"else");
8060 Results.AddResult(Builder.TakeString());
8063 Builder.AddTypedTextChunk(
"endif");
8064 Results.AddResult(Builder.TakeString());
8068 Builder.AddTypedTextChunk(
"include");
8070 Builder.AddTextChunk(
"\"");
8071 Builder.AddPlaceholderChunk(
"header");
8072 Builder.AddTextChunk(
"\"");
8073 Results.AddResult(Builder.TakeString());
8076 Builder.AddTypedTextChunk(
"include");
8078 Builder.AddTextChunk(
"<");
8079 Builder.AddPlaceholderChunk(
"header");
8080 Builder.AddTextChunk(
">");
8081 Results.AddResult(Builder.TakeString());
8084 Builder.AddTypedTextChunk(
"define");
8086 Builder.AddPlaceholderChunk(
"macro");
8087 Results.AddResult(Builder.TakeString());
8090 Builder.AddTypedTextChunk(
"define");
8092 Builder.AddPlaceholderChunk(
"macro");
8094 Builder.AddPlaceholderChunk(
"args");
8096 Results.AddResult(Builder.TakeString());
8099 Builder.AddTypedTextChunk(
"undef");
8101 Builder.AddPlaceholderChunk(
"macro");
8102 Results.AddResult(Builder.TakeString());
8105 Builder.AddTypedTextChunk(
"line");
8107 Builder.AddPlaceholderChunk(
"number");
8108 Results.AddResult(Builder.TakeString());
8111 Builder.AddTypedTextChunk(
"line");
8113 Builder.AddPlaceholderChunk(
"number");
8115 Builder.AddTextChunk(
"\"");
8116 Builder.AddPlaceholderChunk(
"filename");
8117 Builder.AddTextChunk(
"\"");
8118 Results.AddResult(Builder.TakeString());
8121 Builder.AddTypedTextChunk(
"error");
8123 Builder.AddPlaceholderChunk(
"message");
8124 Results.AddResult(Builder.TakeString());
8127 Builder.AddTypedTextChunk(
"pragma");
8129 Builder.AddPlaceholderChunk(
"arguments");
8130 Results.AddResult(Builder.TakeString());
8132 if (getLangOpts().ObjC) {
8134 Builder.AddTypedTextChunk(
"import");
8136 Builder.AddTextChunk(
"\"");
8137 Builder.AddPlaceholderChunk(
"header");
8138 Builder.AddTextChunk(
"\"");
8139 Results.AddResult(Builder.TakeString());
8142 Builder.AddTypedTextChunk(
"import");
8144 Builder.AddTextChunk(
"<");
8145 Builder.AddPlaceholderChunk(
"header");
8146 Builder.AddTextChunk(
">");
8147 Results.AddResult(Builder.TakeString());
8151 Builder.AddTypedTextChunk(
"include_next");
8153 Builder.AddTextChunk(
"\"");
8154 Builder.AddPlaceholderChunk(
"header");
8155 Builder.AddTextChunk(
"\"");
8156 Results.AddResult(Builder.TakeString());
8159 Builder.AddTypedTextChunk(
"include_next");
8161 Builder.AddTextChunk(
"<");
8162 Builder.AddPlaceholderChunk(
"header");
8163 Builder.AddTextChunk(
">");
8164 Results.AddResult(Builder.TakeString());
8167 Builder.AddTypedTextChunk(
"warning");
8169 Builder.AddPlaceholderChunk(
"message");
8170 Results.AddResult(Builder.TakeString());
8177 Results.ExitScope();
8180 Results.data(), Results.size());
8189 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8190 CodeCompleter->getCodeCompletionTUInfo(),
8193 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
8196 Results.getCodeCompletionTUInfo());
8197 Results.EnterNewScope();
8199 MEnd = PP.macro_end();
8201 Builder.AddTypedTextChunk(
8202 Builder.getAllocator().CopyString(M->first->getName()));
8206 Results.ExitScope();
8207 }
else if (IsDefinition) {
8212 Results.data(), Results.size());
8216 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8217 CodeCompleter->getCodeCompletionTUInfo(),
8220 if (!CodeCompleter || CodeCompleter->includeMacros())
8222 CodeCompleter ? CodeCompleter->loadExternal() :
false,
8226 Results.EnterNewScope();
8228 Results.getCodeCompletionTUInfo());
8229 Builder.AddTypedTextChunk(
"defined");
8232 Builder.AddPlaceholderChunk(
"macro");
8234 Results.AddResult(Builder.TakeString());
8235 Results.ExitScope();
8238 Results.data(), Results.size());
8244 unsigned Argument) {
8258 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
8261 llvm::sys::path::native(NativeRelDir);
8262 auto FS = getSourceManager().getFileManager().getVirtualFileSystem();
8264 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8265 CodeCompleter->getCodeCompletionTUInfo(),
8270 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
8273 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
8274 auto R = SeenResults.insert(TypedChunk);
8276 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
8277 *R.first = InternedTyped;
8279 CodeCompleter->getCodeCompletionTUInfo());
8280 Builder.AddTypedTextChunk(InternedTyped);
8288 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
bool IsSystem) {
8290 if (!NativeRelDir.empty())
8291 llvm::sys::path::append(Dir, NativeRelDir);
8295 for (
auto It = FS->dir_begin(Dir, EC);
8296 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
8297 if (++Count == 2500)
8299 StringRef Filename = llvm::sys::path::filename(It->path());
8300 switch (It->type()) {
8301 case llvm::sys::fs::file_type::directory_file:
8302 AddCompletion(Filename,
true);
8304 case llvm::sys::fs::file_type::regular_file:
8308 if (!(Filename.endswith_lower(
".h") ||
8309 Filename.endswith_lower(
".hh") ||
8310 Filename.endswith_lower(
".hpp") ||
8311 Filename.endswith_lower(
".inc")))
8314 AddCompletion(Filename,
false);
8330 AddFilesFromIncludeDir(IncludeDir.
getDir()->
getName(), IsSystem);
8341 const auto &S = PP.getHeaderSearchInfo();
8342 using llvm::make_range;
8345 auto *CurFile = PP.getCurrentFileLexer()->getFileEntry();
8346 if (CurFile && CurFile->getDir())
8347 AddFilesFromIncludeDir(CurFile->getDir()->getName(),
false);
8348 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
8349 AddFilesFromDirLookup(D,
false);
8351 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
8352 AddFilesFromDirLookup(D,
false);
8353 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
8354 AddFilesFromDirLookup(D,
true);
8357 Results.data(), Results.size());
8367 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8368 CodeCompleter->getCodeCompletionTUInfo(),
8370 Results.EnterNewScope();
8371 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
8372 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
8375 Twine(Platform) +
"ApplicationExtension")));
8377 Results.ExitScope();
8379 Results.data(), Results.size());
8385 ResultBuilder Builder(*
this, Allocator, CCTUInfo,
8387 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
8388 CodeCompletionDeclConsumer Consumer(Builder,
8392 !CodeCompleter || CodeCompleter->loadExternal());
8395 if (!CodeCompleter || CodeCompleter->includeMacros())
8397 CodeCompleter ? CodeCompleter->loadExternal() :
false,
8401 Results.insert(Results.end(), Builder.data(),
8402 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.