31 #include "llvm/ADT/DenseSet.h" 32 #include "llvm/ADT/SmallBitVector.h" 33 #include "llvm/ADT/SmallPtrSet.h" 34 #include "llvm/ADT/SmallString.h" 35 #include "llvm/ADT/StringExtras.h" 36 #include "llvm/ADT/StringSwitch.h" 37 #include "llvm/ADT/Twine.h" 38 #include "llvm/ADT/iterator_range.h" 39 #include "llvm/Support/Path.h" 45 using namespace clang;
56 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
62 std::vector<Result> Results;
67 llvm::SmallPtrSet<const Decl *, 16> AllDeclsFound;
69 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
74 class ShadowMapEntry {
79 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
83 unsigned SingleDeclIndex;
86 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) {}
87 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
88 ShadowMapEntry(ShadowMapEntry &&
Move) { *
this = std::move(
Move); }
89 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
90 ShadowMapEntry &operator=(ShadowMapEntry &&
Move) {
91 SingleDeclIndex =
Move.SingleDeclIndex;
92 DeclOrVector =
Move.DeclOrVector;
93 Move.DeclOrVector =
nullptr;
97 void Add(
const NamedDecl *ND,
unsigned Index) {
98 if (DeclOrVector.isNull()) {
101 SingleDeclIndex = Index;
106 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
109 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
110 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
115 DeclOrVector.get<DeclIndexPairVector *>()->push_back(
116 DeclIndexPair(ND, Index));
120 if (DeclIndexPairVector *Vec =
121 DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
129 iterator begin()
const;
130 iterator end()
const;
136 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
153 bool AllowNestedNameSpecifiers;
164 std::list<ShadowMap> ShadowMaps;
178 bool HasObjectTypeQualifiers;
190 void AdjustResultPriorityForDecl(Result &R);
192 void MaybeAddConstructorResults(Result R);
198 LookupFilter Filter =
nullptr)
199 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
200 Filter(Filter), AllowNestedNameSpecifiers(
false),
201 HasObjectTypeQualifiers(
false), CompletionContext(CompletionContext),
202 ObjCImplementation(nullptr) {
205 switch (CompletionContext.
getKind()) {
212 if (Method->isInstanceMethod())
214 ObjCImplementation = Interface->getImplementation();
223 unsigned getBasePriority(
const NamedDecl *D);
227 bool includeCodePatterns()
const {
233 void setFilter(LookupFilter Filter) { this->Filter =
Filter; }
235 Result *data() {
return Results.empty() ? nullptr : &Results.front(); }
236 unsigned size()
const {
return Results.size(); }
237 bool empty()
const {
return Results.empty(); }
252 ObjectTypeQualifiers = Quals;
254 HasObjectTypeQualifiers =
true;
262 void setPreferredSelector(
Selector Sel) { PreferredSelector = Sel; }
267 return CompletionContext;
271 void allowNestedNameSpecifiers(
bool Allow =
true) {
272 AllowNestedNameSpecifiers = Allow;
277 Sema &getSema()
const {
return SemaRef; }
291 bool isInterestingDecl(
const NamedDecl *ND,
292 bool &AsNestedNameSpecifier)
const;
300 bool CheckHiddenResult(Result &R, DeclContext *CurContext,
310 void MaybeAddResult(Result R, DeclContext *CurContext =
nullptr);
323 void AddResult(Result R, DeclContext *CurContext,
NamedDecl *Hiding,
327 void AddResult(Result R);
330 void EnterNewScope();
339 void addVisitedContext(DeclContext *Ctx) {
349 bool IsOrdinaryName(
const NamedDecl *ND)
const;
350 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
351 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
352 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
353 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
355 bool IsClassOrStruct(
const NamedDecl *ND)
const;
357 bool IsNamespace(
const NamedDecl *ND)
const;
358 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
360 bool IsMember(
const NamedDecl *ND)
const;
361 bool IsObjCIvar(
const NamedDecl *ND)
const;
362 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
363 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
364 bool IsObjCCollection(
const NamedDecl *ND)
const;
365 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
373 ComputeType =
nullptr;
374 Type = BSI->ReturnType;
378 ComputeType =
nullptr;
381 }
else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(S.
CurContext)) {
382 ComputeType =
nullptr;
383 Type = Method->getReturnType();
389 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
390 ComputeType =
nullptr;
397 this->ComputeType = ComputeType;
405 if (ExpectedLoc == LParLoc)
416 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
419 if (Op == tok::minus)
432 case tok::minusequal:
434 case tok::percentequal:
436 case tok::slashequal:
442 case tok::equalequal:
443 case tok::exclaimequal:
447 case tok::greaterequal:
451 case tok::greatergreater:
452 case tok::greatergreaterequal:
454 case tok::lesslessequal:
461 case tok::caretcaret:
468 case tok::caretequal:
476 case tok::periodstar:
504 case tok::minusminus:
514 assert(
false &&
"unhandled unary op");
521 ComputeType =
nullptr;
541 ComputeType =
nullptr;
548 ComputeType =
nullptr;
555 ComputeType =
nullptr;
561 ComputeType =
nullptr;
567 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
568 unsigned SingleDeclIndex;
580 pointer(
const DeclIndexPair &Value) : Value(Value) {}
588 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
591 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
594 if (DeclOrIterator.is<
const NamedDecl *>()) {
600 const DeclIndexPair *I = DeclOrIterator.get<
const DeclIndexPair *>();
614 return reference(ND, SingleDeclIndex);
616 return *DeclOrIterator.get<
const DeclIndexPair *>();
622 return X.DeclOrIterator.getOpaqueValue() ==
623 Y.DeclOrIterator.getOpaqueValue() &&
624 X.SingleDeclIndex == Y.SingleDeclIndex;
633 ResultBuilder::ShadowMapEntry::begin()
const {
634 if (DeclOrVector.isNull())
638 return iterator(ND, SingleDeclIndex);
640 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
644 ResultBuilder::ShadowMapEntry::end()
const {
645 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
648 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
666 const DeclContext *TargetContext) {
669 for (
const DeclContext *CommonAncestor = TargetContext;
670 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
671 CommonAncestor = CommonAncestor->getLookupParent()) {
672 if (CommonAncestor->isTransparentContext() ||
673 CommonAncestor->isFunctionOrMethod())
676 TargetParents.push_back(CommonAncestor);
680 while (!TargetParents.empty()) {
681 const DeclContext *
Parent = TargetParents.pop_back_val();
683 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
684 if (!Namespace->getIdentifier())
688 }
else if (
const auto *TD = dyn_cast<TagDecl>(Parent))
698 bool doubleUnderscoreOnly =
false) {
702 return Name[0] ==
'_' &&
704 (Name[1] >=
'A' && Name[1] <=
'Z' && !doubleUnderscoreOnly));
730 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
731 bool &AsNestedNameSpecifier)
const {
732 AsNestedNameSpecifier =
false;
747 if (isa<ClassTemplateSpecializationDecl>(ND) ||
748 isa<ClassTemplatePartialSpecializationDecl>(ND))
752 if (isa<UsingDecl>(ND))
758 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
759 (isa<NamespaceDecl>(ND) && Filter != &ResultBuilder::IsNamespace &&
760 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
761 AsNestedNameSpecifier =
true;
764 if (Filter && !(this->*Filter)(Named)) {
766 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
767 IsNestedNameSpecifier(ND) &&
768 (Filter != &ResultBuilder::IsMember ||
769 (isa<CXXRecordDecl>(ND) &&
770 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
771 AsNestedNameSpecifier =
true;
781 bool ResultBuilder::CheckHiddenResult(Result &R, DeclContext *CurContext,
789 const DeclContext *HiddenCtx =
801 R.QualifierIsInformative =
false;
805 R.Declaration->getDeclContext());
812 switch (T->getTypeClass()) {
814 switch (cast<BuiltinType>(T)->getKind()) {
815 case BuiltinType::Void:
818 case BuiltinType::NullPtr:
821 case BuiltinType::Overload:
822 case BuiltinType::Dependent:
825 case BuiltinType::ObjCId:
826 case BuiltinType::ObjCClass:
827 case BuiltinType::ObjCSel:
840 case Type::BlockPointer:
843 case Type::LValueReference:
844 case Type::RValueReference:
847 case Type::ConstantArray:
848 case Type::IncompleteArray:
849 case Type::VariableArray:
850 case Type::DependentSizedArray:
853 case Type::DependentSizedExtVector:
855 case Type::ExtVector:
858 case Type::FunctionProto:
859 case Type::FunctionNoProto:
868 case Type::ObjCObject:
869 case Type::ObjCInterface:
870 case Type::ObjCObjectPointer:
883 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
885 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
890 T = Function->getCallResultType();
891 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND))
892 T = Method->getSendResultType();
893 else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND))
895 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
897 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
898 T =
Value->getType();
913 if (
Pointer->getPointeeType()->isFunctionType()) {
927 T = Function->getReturnType();
937 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
945 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
946 if (ImplicitParam->getIdentifier() &&
947 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
954 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
956 if (isa<CXXDestructorDecl>(ND))
968 if (isa<EnumConstantDecl>(ND))
974 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
985 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
988 if (!PreferredSelector.
isNull())
989 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
990 if (PreferredSelector == Method->getSelector())
1005 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1017 return Record->
lookup(ConstructorName);
1020 void ResultBuilder::MaybeAddConstructorResults(Result R) {
1021 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
1028 Record = ClassTemplate->getTemplatedDecl();
1029 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
1031 if (isa<ClassTemplateSpecializationDecl>(Record))
1043 R.Declaration = Ctor;
1045 Results.push_back(R);
1050 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1051 ND = Tmpl->getTemplatedDecl();
1052 return isa<CXXConstructorDecl>(ND);
1055 void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
1056 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1058 if (R.Kind != Result::RK_Declaration) {
1060 Results.push_back(R);
1065 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1067 getBasePriority(Using->getTargetDecl()),
1070 MaybeAddResult(Result, CurContext);
1077 bool AsNestedNameSpecifier =
false;
1078 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1085 ShadowMap &
SMap = ShadowMaps.back();
1086 ShadowMapEntry::iterator I, IEnd;
1087 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
1088 if (NamePos != SMap.end()) {
1089 I = NamePos->second.begin();
1090 IEnd = NamePos->second.end();
1093 for (; I != IEnd; ++I) {
1095 unsigned Index = I->second;
1098 Results[Index].Declaration = R.Declaration;
1108 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
1110 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
1111 ShadowMapEntry::iterator I, IEnd;
1112 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
1113 if (NamePos != SM->end()) {
1114 I = NamePos->second.begin();
1115 IEnd = NamePos->second.end();
1117 for (; I != IEnd; ++I) {
1119 if (I->first->hasTagIdentifierNamespace() &&
1127 I->first->getIdentifierNamespace() != IDNS)
1131 if (CheckHiddenResult(R, CurContext, I->first))
1139 if (!AllDeclsFound.insert(CanonDecl).second)
1144 if (AsNestedNameSpecifier) {
1145 R.StartsNestedNameSpecifier =
true;
1148 AdjustResultPriorityForDecl(R);
1151 if (R.QualifierIsInformative && !R.Qualifier &&
1152 !R.StartsNestedNameSpecifier) {
1153 const DeclContext *Ctx = R.Declaration->getDeclContext();
1154 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1157 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1159 SemaRef.
Context,
nullptr,
false,
1162 R.QualifierIsInformative =
false;
1167 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
1168 Results.push_back(R);
1170 if (!AsNestedNameSpecifier)
1171 MaybeAddConstructorResults(R);
1193 for (
unsigned I = 0, E = Candidate.
getNumParams(); I != E; ++I)
1194 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1195 Incumbent.
parameters()[I]->getType().getCanonicalType())
1204 if (CandidateRef != IncumbentRef) {
1220 if (CandidateSuperset == IncumbentSuperset)
1226 void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
1227 NamedDecl *Hiding,
bool InBaseClass =
false) {
1228 if (R.Kind != Result::RK_Declaration) {
1230 Results.push_back(R);
1235 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1237 getBasePriority(Using->getTargetDecl()),
1240 AddResult(Result, CurContext, Hiding);
1244 bool AsNestedNameSpecifier =
false;
1245 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1252 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1256 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
1261 if (AsNestedNameSpecifier) {
1262 R.StartsNestedNameSpecifier =
true;
1264 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1267 R.Declaration->getDeclContext()->getRedeclContext()))
1268 R.QualifierIsInformative =
true;
1271 if (R.QualifierIsInformative && !R.Qualifier &&
1272 !R.StartsNestedNameSpecifier) {
1273 const DeclContext *Ctx = R.Declaration->getDeclContext();
1274 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1277 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1279 SemaRef.
Context,
nullptr,
false,
1282 R.QualifierIsInformative =
false;
1289 AdjustResultPriorityForDecl(R);
1291 if (HasObjectTypeQualifiers)
1292 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1293 if (Method->isInstance()) {
1294 Qualifiers MethodQuals = Method->getMethodQualifiers();
1295 if (ObjectTypeQualifiers == MethodQuals)
1297 else if (ObjectTypeQualifiers - MethodQuals) {
1303 switch (Method->getRefQualifier()) {
1319 auto &OverloadSet = OverloadMap[std::make_pair(
1320 CurContext, Method->getDeclName().getAsOpaqueInteger())];
1321 for (
const DeclIndexPair& Entry : OverloadSet) {
1322 Result &Incumbent = Results[Entry.second];
1324 *cast<CXXMethodDecl>(Incumbent.Declaration),
1325 ObjectTypeQualifiers, ObjectKind)) {
1330 Incumbent = std::move(R);
1339 OverloadSet.Add(Method, Results.size());
1343 Results.push_back(R);
1345 if (!AsNestedNameSpecifier)
1346 MaybeAddConstructorResults(R);
1349 void ResultBuilder::AddResult(Result R) {
1350 assert(R.Kind != Result::RK_Declaration &&
1351 "Declaration results need more context");
1352 Results.push_back(R);
1356 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1359 void ResultBuilder::ExitScope() {
1360 ShadowMaps.pop_back();
1365 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1374 if (isa<ObjCIvarDecl>(ND))
1383 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1385 if (isa<TypeDecl>(ND))
1390 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1391 if (!
ID->getDefinition())
1399 if (isa<ObjCIvarDecl>(ND))
1406 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1407 if (!IsOrdinaryNonTypeName(ND))
1411 if (VD->getType()->isIntegralOrEnumerationType())
1419 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1427 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1432 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1434 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1435 ND = ClassTemplate->getTemplatedDecl();
1441 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1442 return isa<EnumDecl>(ND);
1446 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1448 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1449 ND = ClassTemplate->getTemplatedDecl();
1452 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1460 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1462 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1463 ND = ClassTemplate->getTemplatedDecl();
1465 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1472 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1473 return isa<NamespaceDecl>(ND);
1478 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1483 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1485 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1491 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1493 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1494 isa<ObjCPropertyDecl>(ND);
1500 case Type::ObjCObject:
1501 case Type::ObjCInterface:
1502 case Type::ObjCObjectPointer:
1506 switch (cast<BuiltinType>(T)->getKind()) {
1507 case BuiltinType::ObjCId:
1508 case BuiltinType::ObjCClass:
1509 case BuiltinType::ObjCSel:
1530 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1539 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1541 if (IsObjCMessageReceiver(ND))
1544 const auto *Var = dyn_cast<
VarDecl>(ND);
1551 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1552 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1553 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1566 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1572 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1573 return isa<ObjCIvarDecl>(ND);
1581 ResultBuilder &Results;
1582 DeclContext *InitialLookupCtx;
1587 std::vector<FixItHint> FixIts;
1590 CodeCompletionDeclConsumer(
1591 ResultBuilder &Results, DeclContext *InitialLookupCtx,
1593 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1594 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1595 FixIts(std::move(FixIts)) {
1596 NamingClass = llvm::dyn_cast<
CXXRecordDecl>(InitialLookupCtx);
1599 auto ThisType = Results.getSema().getCurrentThisType();
1600 if (!ThisType.isNull()) {
1601 assert(ThisType->isPointerType());
1604 NamingClass = BaseType->getAsCXXRecordDecl();
1607 this->BaseType = BaseType;
1611 bool InBaseClass)
override {
1614 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
1617 void EnteredContext(DeclContext *Ctx)
override {
1618 Results.addVisitedContext(Ctx);
1627 auto *NamingClass = this->NamingClass;
1628 QualType BaseType = this->BaseType;
1629 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1644 NamingClass =
nullptr;
1647 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1654 ResultBuilder &Results) {
1656 Results.AddResult(Result(
"short",
CCP_Type));
1657 Results.AddResult(Result(
"long",
CCP_Type));
1658 Results.AddResult(Result(
"signed",
CCP_Type));
1659 Results.AddResult(Result(
"unsigned",
CCP_Type));
1660 Results.AddResult(Result(
"void",
CCP_Type));
1661 Results.AddResult(Result(
"char",
CCP_Type));
1662 Results.AddResult(Result(
"int",
CCP_Type));
1663 Results.AddResult(Result(
"float",
CCP_Type));
1664 Results.AddResult(Result(
"double",
CCP_Type));
1665 Results.AddResult(Result(
"enum",
CCP_Type));
1666 Results.AddResult(Result(
"struct",
CCP_Type));
1667 Results.AddResult(Result(
"union",
CCP_Type));
1668 Results.AddResult(Result(
"const",
CCP_Type));
1669 Results.AddResult(Result(
"volatile",
CCP_Type));
1673 Results.AddResult(Result(
"_Complex",
CCP_Type));
1674 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1675 Results.AddResult(Result(
"_Bool",
CCP_Type));
1676 Results.AddResult(Result(
"restrict",
CCP_Type));
1680 Results.getCodeCompletionTUInfo());
1681 if (LangOpts.CPlusPlus) {
1685 Results.AddResult(Result(
"class",
CCP_Type));
1686 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1689 Builder.AddTypedTextChunk(
"typename");
1691 Builder.AddPlaceholderChunk(
"qualifier");
1692 Builder.AddTextChunk(
"::");
1693 Builder.AddPlaceholderChunk(
"name");
1694 Results.AddResult(Result(Builder.TakeString()));
1696 if (LangOpts.CPlusPlus11) {
1697 Results.AddResult(Result(
"auto",
CCP_Type));
1698 Results.AddResult(Result(
"char16_t",
CCP_Type));
1699 Results.AddResult(Result(
"char32_t",
CCP_Type));
1701 Builder.AddTypedTextChunk(
"decltype");
1703 Builder.AddPlaceholderChunk(
"expression");
1705 Results.AddResult(Result(Builder.TakeString()));
1708 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1711 if (LangOpts.GNUKeywords) {
1717 Builder.AddTypedTextChunk(
"typeof");
1719 Builder.AddPlaceholderChunk(
"expression");
1720 Results.AddResult(Result(Builder.TakeString()));
1722 Builder.AddTypedTextChunk(
"typeof");
1724 Builder.AddPlaceholderChunk(
"type");
1726 Results.AddResult(Result(Builder.TakeString()));
1730 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1731 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1732 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1737 ResultBuilder &Results) {
1742 Results.AddResult(Result(
"extern"));
1743 Results.AddResult(Result(
"static"));
1745 if (LangOpts.CPlusPlus11) {
1750 Builder.AddTypedTextChunk(
"alignas");
1752 Builder.AddPlaceholderChunk(
"expression");
1754 Results.AddResult(Result(Builder.TakeString()));
1756 Results.AddResult(Result(
"constexpr"));
1757 Results.AddResult(Result(
"thread_local"));
1763 ResultBuilder &Results) {
1768 if (LangOpts.CPlusPlus) {
1769 Results.AddResult(Result(
"explicit"));
1770 Results.AddResult(Result(
"friend"));
1771 Results.AddResult(Result(
"mutable"));
1772 Results.AddResult(Result(
"virtual"));
1780 if (LangOpts.CPlusPlus || LangOpts.C99)
1781 Results.AddResult(Result(
"inline"));
1800 ResultBuilder &Results,
bool NeedAt);
1802 ResultBuilder &Results,
bool NeedAt);
1804 ResultBuilder &Results,
bool NeedAt);
1809 Results.getCodeCompletionTUInfo());
1810 Builder.AddTypedTextChunk(
"typedef");
1812 Builder.AddPlaceholderChunk(
"type");
1814 Builder.AddPlaceholderChunk(
"name");
1836 return LangOpts.CPlusPlus;
1843 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
1846 llvm_unreachable(
"Invalid ParserCompletionContext!");
1874 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1875 return BT->getNameAsCString(Policy);
1878 if (
const TagType *TagT = dyn_cast<TagType>(T))
1879 if (
TagDecl *Tag = TagT->getDecl())
1880 if (!Tag->hasNameForLinkage()) {
1881 switch (Tag->getTagKind()) {
1883 return "struct <anonymous>";
1885 return "__interface <anonymous>";
1887 return "class <anonymous>";
1889 return "union <anonymous>";
1891 return "enum <anonymous>";
1911 Builder.AddResultTypeChunk(
1913 Builder.AddTypedTextChunk(
"this");
1918 ResultBuilder &Results,
1920 if (!LangOpts.CPlusPlus11)
1936 Sema &S = Results.getSema();
1943 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
1944 for (
auto *Method : CR->methods()) {
1945 if (!Method->isVirtual() || !Method->getIdentifier())
1947 Overrides[Method->getName()].push_back(Method);
1950 for (
const auto &
Base : CR->bases()) {
1951 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
1954 for (
auto *Method : BR->methods()) {
1955 if (!Method->isVirtual() || !Method->getIdentifier())
1957 const auto it = Overrides.find(Method->getName());
1958 bool IsOverriden =
false;
1959 if (it != Overrides.end()) {
1960 for (
auto *MD : it->second) {
1973 std::string OverrideSignature;
1974 llvm::raw_string_ostream OS(OverrideSignature);
1980 false, CCContext, Policy);
1989 Sema &SemaRef, ResultBuilder &Results) {
1997 if (Results.includeCodePatterns()) {
1999 Builder.AddTypedTextChunk(
"namespace");
2001 Builder.AddPlaceholderChunk(
"identifier");
2005 Builder.AddPlaceholderChunk(
"declarations");
2008 Results.AddResult(Result(Builder.TakeString()));
2012 Builder.AddTypedTextChunk(
"namespace");
2014 Builder.AddPlaceholderChunk(
"name");
2016 Builder.AddPlaceholderChunk(
"namespace");
2018 Results.AddResult(Result(Builder.TakeString()));
2021 Builder.AddTypedTextChunk(
"using namespace");
2023 Builder.AddPlaceholderChunk(
"identifier");
2025 Results.AddResult(Result(Builder.TakeString()));
2028 Builder.AddTypedTextChunk(
"asm");
2030 Builder.AddPlaceholderChunk(
"string-literal");
2032 Results.AddResult(Result(Builder.TakeString()));
2034 if (Results.includeCodePatterns()) {
2036 Builder.AddTypedTextChunk(
"template");
2038 Builder.AddPlaceholderChunk(
"declaration");
2039 Results.AddResult(Result(Builder.TakeString()));
2054 Builder.AddTypedTextChunk(
"using");
2056 Builder.AddPlaceholderChunk(
"qualifier");
2057 Builder.AddTextChunk(
"::");
2058 Builder.AddPlaceholderChunk(
"name");
2060 Results.AddResult(Result(Builder.TakeString()));
2064 Builder.AddTypedTextChunk(
"using typename");
2066 Builder.AddPlaceholderChunk(
"qualifier");
2067 Builder.AddTextChunk(
"::");
2068 Builder.AddPlaceholderChunk(
"name");
2070 Results.AddResult(Result(Builder.TakeString()));
2078 bool IsNotInheritanceScope =
2081 Builder.AddTypedTextChunk(
"public");
2082 if (IsNotInheritanceScope && Results.includeCodePatterns())
2084 Results.AddResult(Result(Builder.TakeString()));
2087 Builder.AddTypedTextChunk(
"protected");
2088 if (IsNotInheritanceScope && Results.includeCodePatterns())
2090 Results.AddResult(Result(Builder.TakeString()));
2093 Builder.AddTypedTextChunk(
"private");
2094 if (IsNotInheritanceScope && Results.includeCodePatterns())
2096 Results.AddResult(Result(Builder.TakeString()));
2109 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2111 Builder.AddTypedTextChunk(
"template");
2113 Builder.AddPlaceholderChunk(
"parameters");
2115 Results.AddResult(Result(Builder.TakeString()));
2144 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2146 Builder.AddTypedTextChunk(
"try");
2150 Builder.AddPlaceholderChunk(
"statements");
2154 Builder.AddTextChunk(
"catch");
2157 Builder.AddPlaceholderChunk(
"declaration");
2162 Builder.AddPlaceholderChunk(
"statements");
2165 Results.AddResult(Result(Builder.TakeString()));
2170 if (Results.includeCodePatterns()) {
2172 Builder.AddTypedTextChunk(
"if");
2176 Builder.AddPlaceholderChunk(
"condition");
2178 Builder.AddPlaceholderChunk(
"expression");
2183 Builder.AddPlaceholderChunk(
"statements");
2186 Results.AddResult(Result(Builder.TakeString()));
2189 Builder.AddTypedTextChunk(
"switch");
2193 Builder.AddPlaceholderChunk(
"condition");
2195 Builder.AddPlaceholderChunk(
"expression");
2200 Builder.AddPlaceholderChunk(
"cases");
2203 Results.AddResult(Result(Builder.TakeString()));
2210 Builder.AddTypedTextChunk(
"case");
2212 Builder.AddPlaceholderChunk(
"expression");
2214 Results.AddResult(Result(Builder.TakeString()));
2217 Builder.AddTypedTextChunk(
"default");
2219 Results.AddResult(Result(Builder.TakeString()));
2222 if (Results.includeCodePatterns()) {
2224 Builder.AddTypedTextChunk(
"while");
2228 Builder.AddPlaceholderChunk(
"condition");
2230 Builder.AddPlaceholderChunk(
"expression");
2235 Builder.AddPlaceholderChunk(
"statements");
2238 Results.AddResult(Result(Builder.TakeString()));
2241 Builder.AddTypedTextChunk(
"do");
2245 Builder.AddPlaceholderChunk(
"statements");
2248 Builder.AddTextChunk(
"while");
2251 Builder.AddPlaceholderChunk(
"expression");
2253 Results.AddResult(Result(Builder.TakeString()));
2256 Builder.AddTypedTextChunk(
"for");
2260 Builder.AddPlaceholderChunk(
"init-statement");
2262 Builder.AddPlaceholderChunk(
"init-expression");
2265 Builder.AddPlaceholderChunk(
"condition");
2268 Builder.AddPlaceholderChunk(
"inc-expression");
2273 Builder.AddPlaceholderChunk(
"statements");
2276 Results.AddResult(Result(Builder.TakeString()));
2281 Builder.AddTypedTextChunk(
"continue");
2283 Results.AddResult(Result(Builder.TakeString()));
2288 Builder.AddTypedTextChunk(
"break");
2290 Results.AddResult(Result(Builder.TakeString()));
2295 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext))
2296 ReturnType = Function->getReturnType();
2297 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2298 ReturnType = Method->getReturnType();
2303 Builder.AddTypedTextChunk(
"return");
2305 Results.AddResult(Result(Builder.TakeString()));
2307 assert(!ReturnType.
isNull());
2309 Builder.AddTypedTextChunk(
"return");
2311 Builder.AddPlaceholderChunk(
"expression");
2313 Results.AddResult(Result(Builder.TakeString()));
2316 Builder.AddTypedTextChunk(
"return true");
2318 Results.AddResult(Result(Builder.TakeString()));
2320 Builder.AddTypedTextChunk(
"return false");
2322 Results.AddResult(Result(Builder.TakeString()));
2327 Builder.AddTypedTextChunk(
"goto");
2329 Builder.AddPlaceholderChunk(
"label");
2331 Results.AddResult(Result(Builder.TakeString()));
2334 Builder.AddTypedTextChunk(
"using namespace");
2336 Builder.AddPlaceholderChunk(
"identifier");
2338 Results.AddResult(Result(Builder.TakeString()));
2355 Builder.AddTypedTextChunk(
"__bridge");
2357 Builder.AddPlaceholderChunk(
"type");
2359 Builder.AddPlaceholderChunk(
"expression");
2360 Results.AddResult(Result(Builder.TakeString()));
2363 Builder.AddTypedTextChunk(
"__bridge_transfer");
2365 Builder.AddPlaceholderChunk(
"Objective-C type");
2367 Builder.AddPlaceholderChunk(
"expression");
2368 Results.AddResult(Result(Builder.TakeString()));
2371 Builder.AddTypedTextChunk(
"__bridge_retained");
2373 Builder.AddPlaceholderChunk(
"CF type");
2375 Builder.AddPlaceholderChunk(
"expression");
2376 Results.AddResult(Result(Builder.TakeString()));
2387 Builder.AddResultTypeChunk(
"bool");
2388 Builder.AddTypedTextChunk(
"true");
2389 Results.AddResult(Result(Builder.TakeString()));
2392 Builder.AddResultTypeChunk(
"bool");
2393 Builder.AddTypedTextChunk(
"false");
2394 Results.AddResult(Result(Builder.TakeString()));
2398 Builder.AddTypedTextChunk(
"dynamic_cast");
2400 Builder.AddPlaceholderChunk(
"type");
2403 Builder.AddPlaceholderChunk(
"expression");
2405 Results.AddResult(Result(Builder.TakeString()));
2409 Builder.AddTypedTextChunk(
"static_cast");
2411 Builder.AddPlaceholderChunk(
"type");
2414 Builder.AddPlaceholderChunk(
"expression");
2416 Results.AddResult(Result(Builder.TakeString()));
2419 Builder.AddTypedTextChunk(
"reinterpret_cast");
2421 Builder.AddPlaceholderChunk(
"type");
2424 Builder.AddPlaceholderChunk(
"expression");
2426 Results.AddResult(Result(Builder.TakeString()));
2429 Builder.AddTypedTextChunk(
"const_cast");
2431 Builder.AddPlaceholderChunk(
"type");
2434 Builder.AddPlaceholderChunk(
"expression");
2436 Results.AddResult(Result(Builder.TakeString()));
2440 Builder.AddResultTypeChunk(
"std::type_info");
2441 Builder.AddTypedTextChunk(
"typeid");
2443 Builder.AddPlaceholderChunk(
"expression-or-type");
2445 Results.AddResult(Result(Builder.TakeString()));
2449 Builder.AddTypedTextChunk(
"new");
2451 Builder.AddPlaceholderChunk(
"type");
2453 Builder.AddPlaceholderChunk(
"expressions");
2455 Results.AddResult(Result(Builder.TakeString()));
2458 Builder.AddTypedTextChunk(
"new");
2460 Builder.AddPlaceholderChunk(
"type");
2462 Builder.AddPlaceholderChunk(
"size");
2465 Builder.AddPlaceholderChunk(
"expressions");
2467 Results.AddResult(Result(Builder.TakeString()));
2470 Builder.AddResultTypeChunk(
"void");
2471 Builder.AddTypedTextChunk(
"delete");
2473 Builder.AddPlaceholderChunk(
"expression");
2474 Results.AddResult(Result(Builder.TakeString()));
2477 Builder.AddResultTypeChunk(
"void");
2478 Builder.AddTypedTextChunk(
"delete");
2483 Builder.AddPlaceholderChunk(
"expression");
2484 Results.AddResult(Result(Builder.TakeString()));
2488 Builder.AddResultTypeChunk(
"void");
2489 Builder.AddTypedTextChunk(
"throw");
2491 Builder.AddPlaceholderChunk(
"expression");
2492 Results.AddResult(Result(Builder.TakeString()));
2499 Builder.AddResultTypeChunk(
"std::nullptr_t");
2500 Builder.AddTypedTextChunk(
"nullptr");
2501 Results.AddResult(Result(Builder.TakeString()));
2504 Builder.AddResultTypeChunk(
"size_t");
2505 Builder.AddTypedTextChunk(
"alignof");
2507 Builder.AddPlaceholderChunk(
"type");
2509 Results.AddResult(Result(Builder.TakeString()));
2512 Builder.AddResultTypeChunk(
"bool");
2513 Builder.AddTypedTextChunk(
"noexcept");
2515 Builder.AddPlaceholderChunk(
"expression");
2517 Results.AddResult(Result(Builder.TakeString()));
2520 Builder.AddResultTypeChunk(
"size_t");
2521 Builder.AddTypedTextChunk(
"sizeof...");
2523 Builder.AddPlaceholderChunk(
"parameter-pack");
2525 Results.AddResult(Result(Builder.TakeString()));
2534 if (
ID->getSuperClass()) {
2535 std::string SuperType;
2536 SuperType =
ID->getSuperClass()->getNameAsString();
2537 if (Method->isInstanceMethod())
2540 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2541 Builder.AddTypedTextChunk(
"super");
2542 Results.AddResult(Result(Builder.TakeString()));
2551 Builder.AddResultTypeChunk(
"size_t");
2553 Builder.AddTypedTextChunk(
"alignof");
2555 Builder.AddTypedTextChunk(
"_Alignof");
2557 Builder.AddPlaceholderChunk(
"type");
2559 Results.AddResult(Result(Builder.TakeString()));
2563 Builder.AddResultTypeChunk(
"size_t");
2564 Builder.AddTypedTextChunk(
"sizeof");
2566 Builder.AddPlaceholderChunk(
"expression-or-type");
2568 Results.AddResult(Result(Builder.TakeString()));
2581 Results.AddResult(Result(
"operator"));
2601 T = Function->getReturnType();
2602 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2604 T = Method->getSendResultType(BaseType);
2606 T = Method->getReturnType();
2607 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2608 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2610 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2612 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2614 T = Ivar->getUsageType(BaseType);
2616 T = Ivar->getType();
2617 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2618 T =
Value->getType();
2619 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2621 T =
Property->getUsageType(BaseType);
2636 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2637 if (Sentinel->getSentinel() == 0) {
2657 Result +=
"bycopy ";
2661 Result +=
"oneway ";
2664 switch (*nullability) {
2666 Result +=
"nonnull ";
2670 Result +=
"nullable ";
2674 Result +=
"null_unspecified ";
2691 bool SuppressBlock =
false) {
2697 if (!SuppressBlock) {
2700 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2713 TL = AttrTL.getModifiedLoc();
2732 bool SuppressBlockName =
false,
2733 bool SuppressBlock =
false,
2734 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2738 bool SuppressName =
false,
bool SuppressBlock =
false,
2739 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2745 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2752 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2759 if (ObjCMethodParam) {
2779 if (!Block && ObjCMethodParam &&
2780 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2781 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2782 ->findPropertyDecl(
false))
2796 if (ObjCMethodParam) {
2801 Result =
"(" + Quals +
" " + Result +
")";
2802 if (Result.back() !=
')')
2816 false, SuppressBlock,
2832 bool SuppressBlockName,
bool SuppressBlock,
2833 Optional<ArrayRef<QualType>> ObjCSubsts) {
2840 if (!ResultType->
isVoidType() || SuppressBlock)
2852 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2865 if (SuppressBlock) {
2867 Result = Result +
" (^";
2874 Result =
'^' + Result;
2889 bool Invalid = CharSrcRange.
isInvalid();
2897 if (srcText.empty() || srcText ==
"=") {
2903 std::string DefValue(srcText.str());
2906 if (DefValue.at(0) !=
'=') {
2910 return " = " + DefValue;
2912 return " " + DefValue;
2921 bool InOptional =
false) {
2922 bool FirstParameter =
true;
2932 if (!FirstParameter)
2940 FirstParameter =
false;
2953 PlaceholderStr +=
", ...";
2961 if (Proto->isVariadic()) {
2962 if (Proto->getNumParams() == 0)
2973 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
2974 bool FirstParameter =
true;
2983 PEnd = Params->begin() + MaxParameters;
2986 bool HasDefaultArg =
false;
2987 std::string PlaceholderStr;
2989 if (TTP->wasDeclaredWithTypename())
2990 PlaceholderStr =
"typename";
2992 PlaceholderStr =
"class";
2994 if (TTP->getIdentifier()) {
2995 PlaceholderStr +=
' ';
2999 HasDefaultArg = TTP->hasDefaultArgument();
3001 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
3002 if (NTTP->getIdentifier())
3003 PlaceholderStr = NTTP->getIdentifier()->getName();
3004 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3005 HasDefaultArg = NTTP->hasDefaultArgument();
3007 assert(isa<TemplateTemplateParmDecl>(*
P));
3012 PlaceholderStr =
"template<...> class";
3014 PlaceholderStr +=
' ';
3021 if (HasDefaultArg && !InDefaultArg) {
3026 if (!FirstParameter)
3029 P - Params->begin(),
true);
3034 InDefaultArg =
false;
3037 FirstParameter =
false;
3051 bool QualifierIsInformative,
3057 std::string PrintedNNS;
3059 llvm::raw_string_ostream OS(PrintedNNS);
3060 Qualifier->
print(OS, Policy);
3062 if (QualifierIsInformative)
3072 if (!Proto || !Proto->getMethodQuals())
3078 if (Proto->getMethodQuals().hasOnlyConst()) {
3083 if (Proto->getMethodQuals().hasOnlyVolatile()) {
3088 if (Proto->getMethodQuals().hasOnlyRestrict()) {
3094 std::string QualsStr;
3095 if (Proto->isConst())
3096 QualsStr +=
" const";
3097 if (Proto->isVolatile())
3098 QualsStr +=
" volatile";
3099 if (Proto->isRestrict())
3100 QualsStr +=
" restrict";
3114 const char *OperatorName =
nullptr;
3117 case OO_Conditional:
3119 OperatorName =
"operator";
3122 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 3124 OperatorName = "operator" Spelling; \ 3126 #define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly) 3127 #include "clang/Basic/OperatorKinds.def" 3130 OperatorName =
"operator new";
3133 OperatorName =
"operator delete";
3136 OperatorName =
"operator new[]";
3138 case OO_Array_Delete:
3139 OperatorName =
"operator delete[]";
3142 OperatorName =
"operator()";
3145 OperatorName =
"operator[]";
3171 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
3173 Record = InjectedTy->getDecl();
3195 bool IncludeBriefComments) {
3196 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
3197 CCTUInfo, IncludeBriefComments);
3203 assert(
Kind == RK_Macro);
3255 bool IncludeBriefComments) {
3256 if (
Kind == RK_Macro)
3257 return CreateCodeCompletionStringForMacro(PP, Allocator, CCTUInfo);
3262 if (
Kind == RK_Pattern) {
3263 Pattern->Priority = Priority;
3264 Pattern->Availability = Availability;
3279 if (
Kind == RK_Keyword) {
3283 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
3284 return createCodeCompletionStringForDecl(
3285 PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
3289 std::string &BeforeName,
3290 std::string &NameAndSignature) {
3291 bool SeenTypedChunk =
false;
3292 for (
auto &Chunk : CCS) {
3294 assert(SeenTypedChunk &&
"optional parameter before name");
3301 NameAndSignature += Chunk.Text;
3303 BeforeName += Chunk.Text;
3312 auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
3315 std::string BeforeName;
3316 std::string NameAndSignature;
3319 NameAndSignature +=
" override";
3334 if (IncludeBriefComments) {
3341 if (StartsNestedNameSpecifier) {
3353 if (
const auto *Function = dyn_cast<FunctionDecl>(ND)) {
3365 dyn_cast<FunctionTemplateDecl>(ND)) {
3373 llvm::SmallBitVector Deduced;
3375 unsigned LastDeducibleArgument;
3376 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3377 --LastDeducibleArgument) {
3378 if (!Deduced[LastDeducibleArgument - 1]) {
3382 bool HasDefaultArg =
false;
3383 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3384 LastDeducibleArgument - 1);
3386 HasDefaultArg = TTP->hasDefaultArgument();
3388 dyn_cast<NonTypeTemplateParmDecl>(Param))
3389 HasDefaultArg = NTTP->hasDefaultArgument();
3391 assert(isa<TemplateTemplateParmDecl>(Param));
3393 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3401 if (LastDeducibleArgument) {
3407 LastDeducibleArgument);
3419 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3429 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3430 Selector Sel = Method->getSelector();
3439 if (StartParameter == 0)
3446 if (Method->param_size() == 1)
3451 PEnd = Method->param_end();
3452 P != PEnd; (void)++
P, ++Idx) {
3454 std::string Keyword;
3455 if (Idx > StartParameter)
3458 Keyword += II->getName();
3460 if (Idx < StartParameter || AllParametersAreInformative)
3467 if (Idx < StartParameter)
3471 QualType ParamType = (*P)->getType();
3487 if (DeclaringEntity || AllParametersAreInformative)
3488 Arg += II->getName();
3491 if (Method->isVariadic() && (
P + 1) == PEnd)
3494 if (DeclaringEntity)
3496 else if (AllParametersAreInformative)
3502 if (Method->isVariadic()) {
3503 if (Method->param_size() == 0) {
3504 if (DeclaringEntity)
3506 else if (AllParametersAreInformative)
3547 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3548 if (!M || !M->isPropertyAccessor())
3574 if (ArgIndex < FDecl->getNumParams())
3586 unsigned CurrentArg,
unsigned Start = 0,
3587 bool InOptional =
false) {
3588 bool FirstParameter =
true;
3589 unsigned NumParams =
3592 for (
unsigned P = Start;
P != NumParams; ++
P) {
3598 if (!FirstParameter)
3602 CurrentArg,
P,
true);
3608 FirstParameter =
false;
3615 std::string Placeholder;
3626 if (
P == CurrentArg)
3636 if (!FirstParameter)
3639 if (CurrentArg < NumParams)
3640 Opt.AddPlaceholderChunk(
"...");
3642 Opt.AddCurrentParameterChunk(
"...");
3660 if (!FDecl && !Proto) {
3673 if (IncludeBriefComments) {
3690 return Result.TakeString();
3695 bool PreferredTypeIsPointer) {
3699 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3700 MacroName.equals(
"Nil")) {
3702 if (PreferredTypeIsPointer)
3706 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3707 MacroName.equals(
"true") || MacroName.equals(
"false"))
3710 else if (MacroName.equals(
"bool"))
3723 case Decl::EnumConstant:
3729 case Decl::ObjCCategory:
3731 case Decl::ObjCCategoryImpl:
3733 case Decl::ObjCImplementation:
3736 case Decl::ObjCInterface:
3738 case Decl::ObjCIvar:
3740 case Decl::ObjCMethod:
3744 case Decl::CXXMethod:
3746 case Decl::CXXConstructor:
3748 case Decl::CXXDestructor:
3750 case Decl::CXXConversion:
3752 case Decl::ObjCProperty:
3754 case Decl::ObjCProtocol:
3760 case Decl::TypeAlias:
3762 case Decl::TypeAliasTemplate:
3766 case Decl::Namespace:
3768 case Decl::NamespaceAlias:
3770 case Decl::TemplateTypeParm:
3772 case Decl::NonTypeTemplateParm:
3774 case Decl::TemplateTemplateParm:
3776 case Decl::FunctionTemplate:
3778 case Decl::ClassTemplate:
3780 case Decl::AccessSpec:
3782 case Decl::ClassTemplatePartialSpecialization:
3784 case Decl::UsingDirective:
3786 case Decl::StaticAssert:
3790 case Decl::TranslationUnit:
3794 case Decl::UnresolvedUsingValue:
3795 case Decl::UnresolvedUsingTypename:
3798 case Decl::ObjCPropertyImpl:
3799 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3806 llvm_unreachable(
"Unexpected Kind!");
3811 case Decl::ObjCTypeParam:
3815 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
3816 switch (TD->getTagKind()) {
3834 bool LoadExternal,
bool IncludeUndefined,
3835 bool TargetTypeIsPointer =
false) {
3838 Results.EnterNewScope();
3844 if (IncludeUndefined || MD) {
3850 Result(M->first, MI,
3852 TargetTypeIsPointer)));
3856 Results.ExitScope();
3860 ResultBuilder &Results) {
3863 Results.EnterNewScope();
3865 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3866 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3867 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3869 Results.ExitScope();
3876 unsigned NumResults) {
3936 llvm_unreachable(
"Invalid ParserCompletionContext!");
3948 ResultBuilder &Results) {
3951 while (isa<BlockDecl>(CurContext))
3961 if (!
P->getDeclName())
3967 Results.getCodeCompletionTUInfo());
3974 S.
Context, CurContext, Overridden->getDeclContext());
3977 llvm::raw_string_ostream OS(Str);
3978 NNS->
print(OS, Policy);
3979 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3981 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3984 Builder.AddTypedTextChunk(
3985 Results.getAllocator().CopyString(Overridden->getNameAsString()));
3987 bool FirstParam =
true;
3994 Builder.AddPlaceholderChunk(
3995 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
4001 Results.Ignore(Overridden);
4008 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4009 CodeCompleter->getCodeCompletionTUInfo(),
4011 Results.EnterNewScope();
4019 PP.getHeaderSearchInfo().collectAllModules(Modules);
4020 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4021 Builder.AddTypedTextChunk(
4022 Builder.getAllocator().CopyString(Modules[I]->Name));
4023 Results.AddResult(Result(
4028 }
else if (getLangOpts().Modules) {
4037 Sub != SubEnd; ++Sub) {
4039 Builder.AddTypedTextChunk(
4040 Builder.getAllocator().CopyString((*Sub)->Name));
4041 Results.AddResult(Result(
4048 Results.ExitScope();
4050 Results.data(), Results.size());
4055 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4056 CodeCompleter->getCodeCompletionTUInfo(),
4058 Results.EnterNewScope();
4063 switch (CompletionContext) {
4066 case PCC_ObjCInterface:
4067 case PCC_ObjCImplementation:
4068 case PCC_ObjCInstanceVariableList:
4070 case PCC_MemberTemplate:
4072 case PCC_LocalDeclarationSpecifiers:
4073 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4077 case PCC_ParenthesizedExpression:
4078 case PCC_Expression:
4082 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4084 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4090 case PCC_RecoveryInFunction:
4097 auto ThisType = getCurrentThisType();
4098 if (!ThisType.isNull())
4099 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4102 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4104 CodeCompleter->includeGlobals(),
4105 CodeCompleter->loadExternal());
4108 Results.ExitScope();
4110 switch (CompletionContext) {
4111 case PCC_ParenthesizedExpression:
4112 case PCC_Expression:
4114 case PCC_RecoveryInFunction:
4121 case PCC_ObjCInterface:
4122 case PCC_ObjCImplementation:
4123 case PCC_ObjCInstanceVariableList:
4125 case PCC_MemberTemplate:
4129 case PCC_LocalDeclarationSpecifiers:
4133 if (CodeCompleter->includeMacros())
4137 Results.data(), Results.size());
4143 bool AtArgumentExpression,
bool IsSuper,
4144 ResultBuilder &Results);
4147 bool AllowNonIdentifiers,
4148 bool AllowNestedNameSpecifiers) {
4150 ResultBuilder Results(
4151 *
this, CodeCompleter->getAllocator(),
4152 CodeCompleter->getCodeCompletionTUInfo(),
4153 AllowNestedNameSpecifiers
4158 Results.EnterNewScope();
4161 Results.AddResult(Result(
"const"));
4162 Results.AddResult(Result(
"volatile"));
4163 if (getLangOpts().
C99)
4164 Results.AddResult(Result(
"restrict"));
4170 Results.AddResult(
"final");
4172 if (AllowNonIdentifiers) {
4173 Results.AddResult(Result(
"operator"));
4177 if (AllowNestedNameSpecifiers) {
4178 Results.allowNestedNameSpecifiers();
4179 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4180 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4182 CodeCompleter->includeGlobals(),
4183 CodeCompleter->loadExternal());
4184 Results.setFilter(
nullptr);
4187 Results.ExitScope();
4193 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4212 Results.data(), Results.size());
4217 bool IsParenthesized =
false)
4218 : PreferredType(PreferredType), IntegralConstantExpression(
false),
4219 ObjCCollection(
false), IsParenthesized(IsParenthesized) {}
4230 struct CoveredEnumerators {
4231 llvm::SmallPtrSet<EnumConstantDecl *, 8> Seen;
4237 EnumDecl *Enum, DeclContext *CurContext,
4238 const CoveredEnumerators &Enumerators) {
4240 if (Context.
getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
4247 Results.EnterNewScope();
4249 if (Enumerators.Seen.count(E))
4253 Results.AddResult(R, CurContext,
nullptr,
false);
4255 Results.ExitScope();
4266 if (Specialization->getNumArgs() != 1)
4284 if (!Results.includeCodePatterns())
4287 Results.getCodeCompletionTUInfo());
4290 Completion.AddPlaceholderChunk(
"=");
4292 if (!Parameters.empty()) {
4297 Completion.AddChunk(CodeCompletionString::ChunkKind::CK_Comma);
4301 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
4302 std::string
Type = NamePlaceholder;
4304 llvm::StringRef Prefix, Suffix;
4305 std::tie(Prefix, Suffix) = llvm::StringRef(Type).split(NamePlaceholder);
4306 Prefix = Prefix.rtrim();
4307 Suffix = Suffix.ltrim();
4309 Completion.AddTextChunk(Completion.getAllocator().CopyString(Prefix));
4311 Completion.AddPlaceholderChunk(
"parameter");
4312 Completion.AddTextChunk(Completion.getAllocator().CopyString(Suffix));
4319 Completion.AddPlaceholderChunk(
"body");
4323 Results.AddResult(Completion.TakeString());
4330 ResultBuilder Results(
4331 *
this, CodeCompleter->getAllocator(),
4332 CodeCompleter->getCodeCompletionTUInfo(),
4341 Results.setFilter(&ResultBuilder::IsObjCCollection);
4343 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
4345 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4347 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4353 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
4356 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4358 CodeCompleter->includeGlobals(),
4359 CodeCompleter->loadExternal());
4361 Results.EnterNewScope();
4363 Results.ExitScope();
4365 bool PreferredTypeIsPointer =
false;
4376 AddEnumerators(Results, Context, Enum, CurContext, CoveredEnumerators());
4384 if (CodeCompleter->includeMacros())
4386 PreferredTypeIsPointer);
4396 Results.data(), Results.size());
4400 bool IsParenthesized) {
4401 return CodeCompleteExpression(
4408 CodeCompleteExpression(S, PreferredType);
4409 else if (getLangOpts().ObjC)
4410 CodeCompleteObjCInstanceMessage(S, E.
get(), None,
false);
4420 if (Interface->hasDefinition())
4421 return Interface->getDefinition();
4427 if (Protocol->hasDefinition())
4428 return Protocol->getDefinition();
4452 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
4457 std::string PlaceholderStr =
4460 if (I == N - 1 && BlockProtoLoc &&
4462 PlaceholderStr +=
", ...";
4476 bool AllowNullaryMethods, DeclContext *CurContext,
4477 AddedPropertiesSet &AddedProperties, ResultBuilder &Results,
4478 bool IsBaseExprStatement =
false,
4479 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
4487 if (!AddedProperties.insert(
P->getIdentifier()).second)
4492 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
4493 !IsBaseExprStatement) {
4494 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4495 if (!InOriginalClass)
4497 Results.MaybeAddResult(R, CurContext);
4508 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4509 if (!InOriginalClass)
4511 Results.MaybeAddResult(R, CurContext);
4518 Results.getCodeCompletionTUInfo());
4521 BlockLoc, BlockProtoLoc);
4522 Result R = Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
4523 if (!InOriginalClass)
4525 Results.MaybeAddResult(R, CurContext);
4529 if (!
P->isReadOnly()) {
4531 Results.getCodeCompletionTUInfo());
4535 Builder.AddTypedTextChunk(
4536 Results.getAllocator().CopyString(
P->getName()));
4541 BlockProtoLoc,
true);
4543 Builder.AddPlaceholderChunk(
4544 Builder.getAllocator().CopyString(PlaceholderStr));
4552 Result(Builder.TakeString(),
P,
4553 Results.getBasePriority(
P) +
4557 if (!InOriginalClass)
4559 Results.MaybeAddResult(R, CurContext);
4563 if (IsClassProperty) {
4572 if (AllowNullaryMethods) {
4577 IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
4580 if (!AddedProperties.insert(Name).second)
4583 Results.getCodeCompletionTUInfo());
4585 Builder.AddTypedTextChunk(
4586 Results.getAllocator().CopyString(Name->
getName()));
4587 Result R = Result(Builder.TakeString(), M,
4589 if (!InOriginalClass)
4591 Results.MaybeAddResult(R, CurContext);
4594 if (IsClassProperty) {
4595 for (
const auto *M : Container->
methods()) {
4599 if (!M->getSelector().isUnarySelector() ||
4600 M->getReturnType()->isVoidType() || M->isInstanceMethod())
4605 for (
auto *M : Container->
methods()) {
4606 if (M->getSelector().isUnarySelector())
4614 for (
auto *
P : Protocol->protocols())
4616 CurContext, AddedProperties, Results,
4617 IsBaseExprStatement, IsClassProperty,
4620 dyn_cast<ObjCInterfaceDecl>(Container)) {
4621 if (AllowCategories) {
4623 for (
auto *Cat : IFace->known_categories())
4625 CurContext, AddedProperties, Results,
4626 IsBaseExprStatement, IsClassProperty,
4631 for (
auto *I : IFace->all_referenced_protocols())
4633 CurContext, AddedProperties, Results,
4634 IsBaseExprStatement, IsClassProperty,
4638 if (IFace->getSuperClass())
4640 AllowNullaryMethods, CurContext, AddedProperties,
4641 Results, IsBaseExprStatement, IsClassProperty,
4644 dyn_cast<ObjCCategoryDecl>(Container)) {
4648 CurContext, AddedProperties, Results,
4649 IsBaseExprStatement, IsClassProperty,
4659 Results.setObjectTypeQualifiers(BaseType.
getQualifiers(), BaseKind);
4662 Results.allowNestedNameSpecifiers();
4663 std::vector<FixItHint> FixIts;
4665 FixIts.emplace_back(AccessOpFixIt.getValue());
4666 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
4673 if (!Results.empty()) {
4679 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
4680 if (DeclContext *Ctx = DepScope->getEntity()) {
4681 IsDependent = Ctx->isDependentContext();
4695 bool IsBaseExprStatement,
4697 if (!Base || !CodeCompleter)
4700 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4703 QualType ConvertedBaseType = ConvertedBase.
get()->getType();
4725 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4726 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4727 &ResultBuilder::IsMember);
4729 auto DoCompletion = [&](
Expr *Base,
bool IsArrow,
4734 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4737 Base = ConvertedBase.
get();
4755 std::move(AccessOpFixIt));
4756 }
else if (
const auto *TST =
4759 if (
const auto *TD =
4763 RD, std::move(AccessOpFixIt));
4766 if (
auto *RD = ICNT->getDecl())
4768 RD, std::move(AccessOpFixIt));
4771 AddedPropertiesSet AddedProperties;
4776 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4779 AddedProperties, Results, IsBaseExprStatement);
4785 CurContext, AddedProperties, Results,
4786 IsBaseExprStatement,
false,
4794 Class = ObjCPtr->getInterfaceDecl();
4800 CodeCompletionDeclConsumer Consumer(Results, Class, BaseType);
4801 Results.setFilter(&ResultBuilder::IsObjCIvar);
4803 Class, LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
4804 false, CodeCompleter->loadExternal());
4812 Results.EnterNewScope();
4814 bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
4815 if (CodeCompleter->includeFixIts()) {
4818 CompletionSucceded |= DoCompletion(
4819 OtherOpBase, !IsArrow,
4823 Results.ExitScope();
4825 if (!CompletionSucceded)
4830 Results.data(), Results.size());
4836 bool IsBaseExprStatement) {
4843 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4844 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4845 &ResultBuilder::IsMember);
4846 Results.EnterNewScope();
4847 AddedPropertiesSet AddedProperties;
4849 true, CurContext, AddedProperties,
4850 Results, IsBaseExprStatement,
4852 Results.ExitScope();
4854 Results.data(), Results.size());
4861 ResultBuilder::LookupFilter Filter =
nullptr;
4866 Filter = &ResultBuilder::IsEnum;
4871 Filter = &ResultBuilder::IsUnion;
4878 Filter = &ResultBuilder::IsClassOrStruct;
4883 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4886 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4887 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4888 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4891 Results.setFilter(Filter);
4893 CodeCompleter->includeGlobals(),
4894 CodeCompleter->loadExternal());
4896 if (CodeCompleter->includeGlobals()) {
4898 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4900 CodeCompleter->includeGlobals(),
4901 CodeCompleter->loadExternal());
4905 Results.data(), Results.size());
4911 Results.AddResult(
"const");
4913 Results.AddResult(
"volatile");
4915 Results.AddResult(
"restrict");
4917 Results.AddResult(
"_Atomic");
4919 Results.AddResult(
"__unaligned");
4923 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4924 CodeCompleter->getCodeCompletionTUInfo(),
4926 Results.EnterNewScope();
4928 Results.ExitScope();
4930 Results.data(), Results.size());
4935 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4936 CodeCompleter->getCodeCompletionTUInfo(),
4938 Results.EnterNewScope();
4940 if (LangOpts.CPlusPlus11) {
4941 Results.AddResult(
"noexcept");
4945 Results.AddResult(
"final");
4947 Results.AddResult(
"override");
4950 Results.ExitScope();
4952 Results.data(), Results.size());
4956 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4960 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4963 SwitchStmt *Switch = getCurFunction()->SwitchStack.back().getPointer();
4971 CodeCompleteExpression(S, Data);
4985 CoveredEnumerators Enumerators;
4993 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
4994 if (
auto *Enumerator =
4995 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
5002 Enumerators.Seen.insert(Enumerator);
5015 Enumerators.SuggestedQualifier = DRE->getQualifier();
5020 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5021 CodeCompleter->getCodeCompletionTUInfo(),
5025 if (CodeCompleter->includeMacros()) {
5029 Results.data(), Results.size());
5033 if (Args.size() && !Args.data())
5036 for (
unsigned I = 0; I != Args.size(); ++I)
5057 if (Candidate.Function && Candidate.Function->isDeleted())
5059 if (Candidate.Viable)
5067 ArrayRef<ResultCandidate> Candidates,
unsigned N) {
5073 for (
auto &Candidate : Candidates) {
5074 if (
const auto *FType = Candidate.getFunctionType())
5075 if (
const auto *Proto = dyn_cast<FunctionProtoType>(FType))
5076 if (N < Proto->getNumParams()) {
5078 ParamType = Proto->getParamType(N);
5081 Proto->getParamType(N).getNonReferenceType()))
5094 if (Candidates.empty())
5097 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
5121 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
5122 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
5124 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
5126 if (UME->hasExplicitTemplateArgs()) {
5127 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
5128 TemplateArgs = &TemplateArgsBuffer;
5133 1, UME->isImplicitAccess() ? nullptr : UME->getBase());
5134 ArgExprs.append(Args.begin(), Args.end());
5136 Decls.
append(UME->decls_begin(), UME->decls_end());
5137 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
5138 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
5140 true, FirstArgumentIsBase);
5143 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
5145 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
5146 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
5148 if (!getLangOpts().CPlusPlus ||
5161 if (isCompleteType(Loc, NakedFn->
getType())) {
5164 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
5165 LookupQualifiedName(R, DC);
5168 ArgExprs.append(Args.begin(), Args.end());
5182 if (!TooManyArguments(FP->getNumParams(), Args.size(),
5185 Results.push_back(ResultCandidate(FP));
5215 for (
NamedDecl *C : LookupConstructors(RD)) {
5216 if (
auto *FD = dyn_cast<FunctionDecl>(C)) {
5222 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(C)) {
5223 AddTemplateOverloadCandidate(
5225 nullptr, Args, CandidateSet,
5247 if (
ValueDecl *MemberDecl = tryLookupCtorInitMemberDecl(
5248 Constructor->
getParent(), SS, TemplateTypeTy, II))
5249 return ProduceConstructorSignatureHelp(getCurScope(), MemberDecl->getType(),
5250 MemberDecl->getLocation(), ArgExprs,
5256 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
5258 CodeCompleteOrdinaryName(S, PCC_Expression);
5267 CodeCompleteExpression(S, Data);
5271 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5272 CodeCompleter->getCodeCompletionTUInfo(),
5274 Results.setFilter(&ResultBuilder::IsOrdinaryName);
5275 Results.EnterNewScope();
5277 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5279 CodeCompleter->includeGlobals(),
5280 CodeCompleter->loadExternal());
5286 Results.getCodeCompletionTUInfo());
5287 Builder.AddTypedTextChunk(
"else");
5288 if (Results.includeCodePatterns()) {
5292 Builder.AddPlaceholderChunk(
"statements");
5296 Results.AddResult(Builder.TakeString());
5299 Builder.AddTypedTextChunk(
"else if");
5303 Builder.AddPlaceholderChunk(
"condition");
5305 Builder.AddPlaceholderChunk(
"expression");
5307 if (Results.includeCodePatterns()) {
5311 Builder.AddPlaceholderChunk(
"statements");
5315 Results.AddResult(Builder.TakeString());
5317 Results.ExitScope();
5322 if (CodeCompleter->includeMacros())
5326 Results.data(), Results.size());
5330 bool EnteringContext,
QualType BaseType,
5332 if (SS.
isEmpty() || !CodeCompleter)
5345 ResultBuilder DummyResults(*
this, CodeCompleter->getAllocator(),
5346 CodeCompleter->getCodeCompletionTUInfo(), CC);
5347 if (!PreferredType.
isNull())
5348 DummyResults.setPreferredType(PreferredType);
5350 CodeCompletionDeclConsumer Consumer(DummyResults, S->
getEntity(),
5357 DummyResults.getCompletionContext(),
nullptr, 0);
5362 DeclContext *Ctx = computeDeclContext(SS,
true);
5368 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
5371 ResultBuilder Results(
5372 *
this, CodeCompleter->getAllocator(),
5373 CodeCompleter->getCodeCompletionTUInfo(),
5375 if (!PreferredType.
isNull())
5376 Results.setPreferredType(PreferredType);
5377 Results.EnterNewScope();
5383 Results.AddResult(
"template");
5390 if (!EnteringContext)
5392 Results.ExitScope();
5394 if (CodeCompleter->includeNamespaceLevelDecls() ||
5396 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
5400 CodeCompleter->loadExternal());
5403 auto CC = Results.getCompletionContext();
5404 CC.setCXXScopeSpecifier(SS);
5414 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5415 CodeCompleter->getCodeCompletionTUInfo(),
5420 &ResultBuilder::IsNestedNameSpecifier);
5421 Results.EnterNewScope();
5429 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5431 CodeCompleter->includeGlobals(),
5432 CodeCompleter->loadExternal());
5433 Results.ExitScope();
5436 Results.data(), Results.size());
5445 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5446 CodeCompleter->getCodeCompletionTUInfo(),
5448 &ResultBuilder::IsNamespaceOrAlias);
5449 Results.EnterNewScope();
5450 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5452 CodeCompleter->includeGlobals(),
5453 CodeCompleter->loadExternal());
5454 Results.ExitScope();
5456 Results.data(), Results.size());
5467 bool SuppressedGlobalResults =
5468 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
5470 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5471 CodeCompleter->getCodeCompletionTUInfo(),
5472 SuppressedGlobalResults
5475 &ResultBuilder::IsNamespace);
5477 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
5482 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
5487 OrigToLatest[NS->getOriginalNamespace()] = *NS;
5491 Results.EnterNewScope();
5492 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
5493 NS = OrigToLatest.begin(),
5494 NSEnd = OrigToLatest.end();
5499 CurContext,
nullptr,
false);
5500 Results.ExitScope();
5504 Results.data(), Results.size());
5512 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5513 CodeCompleter->getCodeCompletionTUInfo(),
5515 &ResultBuilder::IsNamespaceOrAlias);
5516 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5518 CodeCompleter->includeGlobals(),
5519 CodeCompleter->loadExternal());
5521 Results.data(), Results.size());
5529 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5530 CodeCompleter->getCodeCompletionTUInfo(),
5532 &ResultBuilder::IsType);
5533 Results.EnterNewScope();
5537 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 5538 if (OO_##Name != OO_Conditional) \ 5539 Results.AddResult(Result(Spelling)); 5540 #include "clang/Basic/OperatorKinds.def" 5543 Results.allowNestedNameSpecifiers();
5544 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5546 CodeCompleter->includeGlobals(),
5547 CodeCompleter->loadExternal());
5551 Results.ExitScope();
5554 Results.data(), Results.size());
5562 AdjustDeclIfTemplate(ConstructorD);
5568 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5569 CodeCompleter->getCodeCompletionTUInfo(),
5571 Results.EnterNewScope();
5574 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
5575 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
5576 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
5577 if (Initializers[I]->isBaseInitializer())
5579 QualType(Initializers[I]->getBaseClass(), 0)));
5581 InitializedFields.insert(
5582 cast<FieldDecl>(Initializers[I]->getAnyMember()));
5587 bool SawLastInitializer = Initializers.empty();
5590 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
5592 Results.getCodeCompletionTUInfo());
5593 Builder.AddTypedTextChunk(Name);
5595 if (
const auto *Function = dyn_cast<FunctionDecl>(ND))
5597 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
5601 return Builder.TakeString();
5603 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
5606 Results.getCodeCompletionTUInfo());
5607 Builder.AddTypedTextChunk(Name);
5609 Builder.AddPlaceholderChunk(Type);
5613 Builder.TakeString(), ND,
5615 if (isa<FieldDecl>(ND))
5617 return Results.AddResult(CCR);
5620 Builder.TakeString(),
5623 auto AddCtorsWithName = [&](
const CXXRecordDecl *RD,
unsigned int Priority,
5624 const char *Name,
const FieldDecl *FD) {
5626 return AddDefaultCtorInit(Name,
5627 FD ? Results.getAllocator().CopyString(
5628 FD->getType().getAsString(Policy))
5632 if (Ctors.begin() == Ctors.end())
5633 return AddDefaultCtorInit(Name, Name, RD);
5637 Results.AddResult(CCR);
5641 const char *BaseName =
5642 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
5643 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
5648 auto AddField = [&](
const FieldDecl *FD) {
5649 const char *FieldName =
5650 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
5651 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
5657 for (
const auto &
Base : ClassDecl->
bases()) {
5660 SawLastInitializer =
5661 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5663 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5668 SawLastInitializer =
false;
5672 for (
const auto &
Base : ClassDecl->
vbases()) {
5675 SawLastInitializer =
5676 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5678 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5683 SawLastInitializer =
false;
5687 for (
auto *Field : ClassDecl->
fields()) {
5688 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
5690 SawLastInitializer = !Initializers.empty() &&
5691 Initializers.back()->isAnyMemberInitializer() &&
5692 Initializers.back()->getAnyMember() == Field;
5696 if (!Field->getDeclName())
5700 SawLastInitializer =
false;
5702 Results.ExitScope();
5705 Results.data(), Results.size());
5718 bool AfterAmpersand) {
5719 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5720 CodeCompleter->getCodeCompletionTUInfo(),
5722 Results.EnterNewScope();
5725 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
5726 bool IncludedThis =
false;
5727 for (
const auto &C : Intro.
Captures) {
5729 IncludedThis =
true;
5738 for (
const auto *D : S->
decls()) {
5739 const auto *Var = dyn_cast<
VarDecl>(D);
5740 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
5743 if (Known.insert(Var->getIdentifier()).second)
5745 CurContext,
nullptr,
false);
5753 Results.ExitScope();
5756 Results.data(), Results.size());
5761 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword) 5764 ResultBuilder &Results,
bool NeedAt) {
5770 Results.getCodeCompletionTUInfo());
5771 if (LangOpts.ObjC) {
5775 Builder.AddPlaceholderChunk(
"property");
5776 Results.AddResult(Result(Builder.TakeString()));
5781 Builder.AddPlaceholderChunk(
"property");
5782 Results.AddResult(Result(Builder.TakeString()));
5787 ResultBuilder &Results,
bool NeedAt) {
5793 if (LangOpts.ObjC) {
5808 Results.getCodeCompletionTUInfo());
5813 Builder.AddPlaceholderChunk(
"name");
5814 Results.AddResult(Result(Builder.TakeString()));
5816 if (Results.includeCodePatterns()) {
5822 Builder.AddPlaceholderChunk(
"class");
5823 Results.AddResult(Result(Builder.TakeString()));
5828 Builder.AddPlaceholderChunk(
"protocol");
5829 Results.AddResult(Result(Builder.TakeString()));
5834 Builder.AddPlaceholderChunk(
"class");
5835 Results.AddResult(Result(Builder.TakeString()));
5839 Builder.AddTypedTextChunk(
5842 Builder.AddPlaceholderChunk(
"alias");
5844 Builder.AddPlaceholderChunk(
"class");
5845 Results.AddResult(Result(Builder.TakeString()));
5847 if (Results.getSema().getLangOpts().Modules) {
5851 Builder.AddPlaceholderChunk(
"module");
5852 Results.AddResult(Result(Builder.TakeString()));
5857 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5858 CodeCompleter->getCodeCompletionTUInfo(),
5860 Results.EnterNewScope();
5861 if (isa<ObjCImplDecl>(CurContext))
5867 Results.ExitScope();
5869 Results.data(), Results.size());
5875 Results.getCodeCompletionTUInfo());
5878 const char *EncodeType =
"char[]";
5879 if (Results.getSema().getLangOpts().CPlusPlus ||
5880 Results.getSema().getLangOpts().ConstStrings)
5881 EncodeType =
"const char[]";
5882 Builder.AddResultTypeChunk(EncodeType);
5885 Builder.AddPlaceholderChunk(
"type-name");
5887 Results.AddResult(Result(Builder.TakeString()));
5890 Builder.AddResultTypeChunk(
"Protocol *");
5893 Builder.AddPlaceholderChunk(
"protocol-name");
5895 Results.AddResult(Result(Builder.TakeString()));
5898 Builder.AddResultTypeChunk(
"SEL");
5901 Builder.AddPlaceholderChunk(
"selector");
5903 Results.AddResult(Result(Builder.TakeString()));
5906 Builder.AddResultTypeChunk(
"NSString *");
5908 Builder.AddPlaceholderChunk(
"string");
5909 Builder.AddTextChunk(
"\"");
5910 Results.AddResult(Result(Builder.TakeString()));
5913 Builder.AddResultTypeChunk(
"NSArray *");
5915 Builder.AddPlaceholderChunk(
"objects, ...");
5917 Results.AddResult(Result(Builder.TakeString()));
5920 Builder.AddResultTypeChunk(
"NSDictionary *");
5922 Builder.AddPlaceholderChunk(
"key");
5925 Builder.AddPlaceholderChunk(
"object, ...");
5927 Results.AddResult(Result(Builder.TakeString()));
5930 Builder.AddResultTypeChunk(
"id");
5932 Builder.AddPlaceholderChunk(
"expression");
5934 Results.AddResult(Result(Builder.TakeString()));
5940 Results.getCodeCompletionTUInfo());
5942 if (Results.includeCodePatterns()) {
5947 Builder.AddPlaceholderChunk(
"statements");
5949 Builder.AddTextChunk(
"@catch");
5951 Builder.AddPlaceholderChunk(
"parameter");
5954 Builder.AddPlaceholderChunk(
"statements");
5956 Builder.AddTextChunk(
"@finally");
5958 Builder.AddPlaceholderChunk(
"statements");
5960 Results.AddResult(Result(Builder.TakeString()));
5966 Builder.AddPlaceholderChunk(
"expression");
5967 Results.AddResult(Result(Builder.TakeString()));
5969 if (Results.includeCodePatterns()) {
5974 Builder.AddPlaceholderChunk(
"expression");
5977 Builder.AddPlaceholderChunk(
"statements");
5979 Results.AddResult(Result(Builder.TakeString()));
5984 ResultBuilder &Results,
bool NeedAt) {
5994 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5995 CodeCompleter->getCodeCompletionTUInfo(),
5997 Results.EnterNewScope();
5999 Results.ExitScope();
6001 Results.data(), Results.size());
6005 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6006 CodeCompleter->getCodeCompletionTUInfo(),
6008 Results.EnterNewScope();
6011 Results.ExitScope();
6013 Results.data(), Results.size());
6017 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6018 CodeCompleter->getCodeCompletionTUInfo(),
6020 Results.EnterNewScope();
6022 Results.ExitScope();
6024 Results.data(), Results.size());
6031 if (Attributes & NewFlag)
6034 Attributes |= NewFlag;
6042 unsigned AssignCopyRetMask =
6064 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6065 CodeCompleter->getCodeCompletionTUInfo(),
6067 Results.EnterNewScope();
6095 Results.getCodeCompletionTUInfo());
6097 Setter.AddTextChunk(
"=");
6098 Setter.AddPlaceholderChunk(
"method");
6103 Results.getCodeCompletionTUInfo());
6105 Getter.AddTextChunk(
"=");
6106 Getter.AddPlaceholderChunk(
"method");
6115 Results.ExitScope();
6117 Results.data(), Results.size());
6129 ArrayRef<IdentifierInfo *> SelIdents,
6130 bool AllowSameLength =
true) {
6131 unsigned NumSelIdents = SelIdents.size();
6144 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
6147 for (
unsigned I = 0; I != NumSelIdents; ++I)
6156 ArrayRef<IdentifierInfo *> SelIdents,
6157 bool AllowSameLength =
true) {
6188 ArrayRef<IdentifierInfo *> SelIdents,
6189 DeclContext *CurContext,
6190 VisitedSelectorSet &Selectors,
bool AllowSameLength,
6191 ResultBuilder &Results,
bool InOriginalClass =
true,
6192 bool IsRootClass =
false) {
6196 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
6200 if (M->isInstanceMethod() == WantInstanceMethods ||
6201 (IsRootClass && !WantInstanceMethods)) {
6207 if (!Selectors.insert(M->getSelector()).second)
6210 Result R = Result(M, Results.getBasePriority(M),
nullptr);
6211 R.StartParameter = SelIdents.size();
6212 R.AllParametersAreInformative = (WantKind !=
MK_Any);
6213 if (!InOriginalClass)
6215 Results.MaybeAddResult(R, CurContext);
6220 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
6221 if (Protocol->hasDefinition()) {
6223 Protocol->getReferencedProtocols();
6225 E = Protocols.
end();
6227 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
6228 Selectors, AllowSameLength, Results,
false, IsRootClass);
6237 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
6238 Selectors, AllowSameLength, Results,
false, IsRootClass);
6242 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
6243 CurContext, Selectors, AllowSameLength, Results,
6244 InOriginalClass, IsRootClass);
6248 CatDecl->getReferencedProtocols();
6250 E = Protocols.
end();
6252 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
6253 Selectors, AllowSameLength, Results,
false, IsRootClass);
6257 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
6258 Selectors, AllowSameLength, Results, InOriginalClass,
6266 SelIdents, CurContext, Selectors, AllowSameLength, Results,
6271 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
6272 Selectors, AllowSameLength, Results, InOriginalClass,
6281 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
6282 Class =
Category->getClassInterface();
6289 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6290 CodeCompleter->getCodeCompletionTUInfo(),
6292 Results.EnterNewScope();
6294 VisitedSelectorSet Selectors;
6297 Results.ExitScope();
6299 Results.data(), Results.size());
6307 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
6308 Class =
Category->getClassInterface();
6315 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6316 CodeCompleter->getCodeCompletionTUInfo(),
6318 Results.EnterNewScope();
6320 VisitedSelectorSet Selectors;
6324 Results.ExitScope();
6326 Results.data(), Results.size());
6331 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6332 CodeCompleter->getCodeCompletionTUInfo(),
6334 Results.EnterNewScope();
6337 bool AddedInOut =
false;
6340 Results.AddResult(
"in");
6341 Results.AddResult(
"inout");
6346 Results.AddResult(
"out");
6348 Results.AddResult(
"inout");
6353 Results.AddResult(
"bycopy");
6354 Results.AddResult(
"byref");
6355 Results.AddResult(
"oneway");
6358 Results.AddResult(
"nonnull");
6359 Results.AddResult(
"nullable");
6360 Results.AddResult(
"null_unspecified");
6368 PP.isMacroDefined(
"IBAction")) {
6370 Results.getCodeCompletionTUInfo(),
6372 Builder.AddTypedTextChunk(
"IBAction");
6374 Builder.AddPlaceholderChunk(
"selector");
6377 Builder.AddTextChunk(
"id");
6379 Builder.AddTextChunk(
"sender");
6390 Results.ExitScope();
6393 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
6394 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6396 CodeCompleter->includeGlobals(),
6397 CodeCompleter->loadExternal());
6399 if (CodeCompleter->includeMacros())
6403 Results.data(), Results.size());
6411 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
6429 switch (Msg->getReceiverKind()) {
6433 IFace = ObjType->getInterface();
6437 QualType T = Msg->getInstanceReceiver()->getType();
6439 IFace = Ptr->getInterfaceDecl();
6453 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6454 .Case(
"retain", IFace)
6455 .Case(
"strong", IFace)
6456 .Case(
"autorelease", IFace)
6457 .Case(
"copy", IFace)
6458 .Case(
"copyWithZone", IFace)
6459 .Case(
"mutableCopy", IFace)
6460 .Case(
"mutableCopyWithZone", IFace)
6461 .Case(
"awakeFromCoder", IFace)
6462 .Case(
"replacementObjectFromCoder", IFace)
6463 .Case(
"class", IFace)
6464 .Case(
"classForCoder", IFace)
6465 .Case(
"superclass", Super)
6468 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6470 .Case(
"alloc", IFace)
6471 .Case(
"allocWithZone", IFace)
6472 .Case(
"class", IFace)
6473 .Case(
"superclass", Super)
6495 ArrayRef<IdentifierInfo *> SelIdents,
6496 ResultBuilder &Results) {
6515 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
6533 CurP != CurPEnd; ++CurP, ++SuperP) {
6536 (*SuperP)->getType()))
6540 if (!(*CurP)->getIdentifier())
6546 Results.getCodeCompletionTUInfo());
6550 Results.getCompletionContext().getBaseType(), Builder);
6553 if (NeedSuperKeyword) {
6554 Builder.AddTypedTextChunk(
"super");
6560 if (NeedSuperKeyword)
6561 Builder.AddTextChunk(
6564 Builder.AddTypedTextChunk(
6568 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
6569 if (I > SelIdents.size())
6572 if (I < SelIdents.size())
6573 Builder.AddInformativeChunk(
6575 else if (NeedSuperKeyword || I > SelIdents.size()) {
6576 Builder.AddTextChunk(
6578 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6579 (*CurP)->getIdentifier()->getName()));
6581 Builder.AddTypedTextChunk(
6583 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6584 (*CurP)->getIdentifier()->getName()));
6596 ResultBuilder Results(
6597 *
this, CodeCompleter->getAllocator(),
6598 CodeCompleter->getCodeCompletionTUInfo(),
6600 getLangOpts().CPlusPlus11
6601 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
6602 : &ResultBuilder::IsObjCMessageReceiver);
6604 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6605 Results.EnterNewScope();
6607 CodeCompleter->includeGlobals(),
6608 CodeCompleter->loadExternal());
6614 if (Iface->getSuperClass()) {
6615 Results.AddResult(Result(
"super"));
6623 Results.ExitScope();
6625 if (CodeCompleter->includeMacros())
6628 Results.data(), Results.size());
6633 bool AtArgumentExpression) {
6637 CDecl = CurMethod->getClassInterface();
6646 if (CurMethod->isInstanceMethod()) {
6650 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
6651 AtArgumentExpression, CDecl);
6659 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc, LookupOrdinaryName);
6660 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
6662 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
6665 CDecl = Iface->getInterface();
6666 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
6673 id.setIdentifier(Super, SuperLoc);
6674 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
6677 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
6678 SelIdents, AtArgumentExpression);
6687 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
6688 AtArgumentExpression,
6695 unsigned NumSelIdents) {
6697 ASTContext &Context = Results.getSema().Context;
6701 Result *ResultsData = Results.data();
6702 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
6703 Result &R = ResultsData[I];
6704 if (R.Kind == Result::RK_Declaration &&
6705 isa<ObjCMethodDecl>(R.Declaration)) {
6706 if (R.Priority <= BestPriority) {
6707 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
6708 if (NumSelIdents <= Method->param_size()) {
6710 Method->
parameters()[NumSelIdents - 1]->getType();
6711 if (R.Priority < BestPriority || PreferredType.
isNull()) {
6712 BestPriority = R.Priority;
6713 PreferredType = MyPreferredType;
6723 return PreferredType;
6728 ArrayRef<IdentifierInfo *> SelIdents,
6729 bool AtArgumentExpression,
bool IsSuper,
6730 ResultBuilder &Results) {
6740 CDecl = Interface->getInterface();
6745 Results.EnterNewScope();
6752 Results.Ignore(SuperMethod);
6758 Results.setPreferredSelector(CurMethod->getSelector());
6760 VisitedSelectorSet Selectors;
6763 Selectors, AtArgumentExpression, Results);
6770 for (uint32_t I = 0,
6781 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
6785 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6789 Result R(MethList->getMethod(),
6790 Results.getBasePriority(MethList->getMethod()),
nullptr);
6791 R.StartParameter = SelIdents.size();
6792 R.AllParametersAreInformative =
false;
6793 Results.MaybeAddResult(R, SemaRef.
CurContext);
6798 Results.ExitScope();
6803 bool AtArgumentExpression,
6806 QualType T = this->GetTypeFromParser(Receiver);
6808 ResultBuilder Results(
6809 *
this, CodeCompleter->getAllocator(),
6810 CodeCompleter->getCodeCompletionTUInfo(),
6815 AtArgumentExpression, IsSuper, Results);
6822 if (AtArgumentExpression) {
6825 if (PreferredType.
isNull())
6826 CodeCompleteOrdinaryName(S, PCC_Expression);
6828 CodeCompleteExpression(S, PreferredType);
6833 Results.data(), Results.size());
6838 bool AtArgumentExpression,
6842 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6847 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6850 RecExpr = Conv.
get();
6864 return CodeCompleteObjCClassMessage(
6866 AtArgumentExpression, Super);
6871 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6872 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6874 RecExpr = Conv.
get();
6875 ReceiverType = RecExpr->
getType();
6880 ResultBuilder Results(
6881 *
this, CodeCompleter->getAllocator(),
6882 CodeCompleter->getCodeCompletionTUInfo(),
6884 ReceiverType, SelIdents));
6886 Results.EnterNewScope();
6893 Results.Ignore(SuperMethod);
6899 Results.setPreferredSelector(CurMethod->getSelector());
6902 VisitedSelectorSet Selectors;
6912 Selectors, AtArgumentExpression, Results);
6919 for (
auto *I : QualID->quals())
6921 AtArgumentExpression, Results);
6928 CurContext, Selectors, AtArgumentExpression, Results);
6931 for (
auto *I : IFacePtr->quals())
6933 AtArgumentExpression, Results);
6942 if (ExternalSource) {
6943 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6945 Selector Sel = ExternalSource->GetExternalSelector(I);
6946 if (Sel.
isNull() || MethodPool.count(Sel))
6949 ReadMethodPool(Sel);
6953 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6954 MEnd = MethodPool.end();
6957 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6961 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6964 Result R(MethList->getMethod(),
6965 Results.getBasePriority(MethList->getMethod()),
nullptr);
6966 R.StartParameter = SelIdents.size();
6967 R.AllParametersAreInformative =
false;
6968 Results.MaybeAddResult(R, CurContext);
6972 Results.ExitScope();
6979 if (AtArgumentExpression) {
6982 if (PreferredType.
isNull())
6983 CodeCompleteOrdinaryName(S, PCC_Expression);
6985 CodeCompleteExpression(S, PreferredType);
6990 Results.data(), Results.size());
7006 CodeCompleteExpression(S, Data);
7013 if (ExternalSource) {
7014 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
7016 Selector Sel = ExternalSource->GetExternalSelector(I);
7017 if (Sel.
isNull() || MethodPool.count(Sel))
7020 ReadMethodPool(Sel);
7024 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7025 CodeCompleter->getCodeCompletionTUInfo(),
7027 Results.EnterNewScope();
7028 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7029 MEnd = MethodPool.end();
7037 Results.getCodeCompletionTUInfo());
7039 Builder.AddTypedTextChunk(
7041 Results.AddResult(Builder.TakeString());
7045 std::string Accumulator;
7046 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
7047 if (I == SelIdents.size()) {
7048 if (!Accumulator.empty()) {
7049 Builder.AddInformativeChunk(
7050 Builder.getAllocator().CopyString(Accumulator));
7051 Accumulator.clear();
7058 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
7059 Results.AddResult(Builder.TakeString());
7061 Results.ExitScope();
7064 Results.data(), Results.size());
7070 bool OnlyForwardDeclarations,
7071 ResultBuilder &Results) {
7074 for (
const auto *D : Ctx->
decls()) {
7076 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
7077 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
7079 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
7086 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7087 CodeCompleter->getCodeCompletionTUInfo(),
7090 if (CodeCompleter->includeGlobals()) {
7091 Results.EnterNewScope();
7098 Results.Ignore(Protocol);
7104 Results.ExitScope();
7108 Results.data(), Results.size());
7112 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7113 CodeCompleter->getCodeCompletionTUInfo(),
7116 if (CodeCompleter->includeGlobals()) {
7117 Results.EnterNewScope();
7123 Results.ExitScope();
7127 Results.data(), Results.size());
7133 bool OnlyForwardDeclarations,
7134 bool OnlyUnimplemented,
7135 ResultBuilder &Results) {
7138 for (
const auto *D : Ctx->
decls()) {
7140 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
7141 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
7142 (!OnlyUnimplemented || !Class->getImplementation()))
7144 Result(Class, Results.getBasePriority(Class),
nullptr), CurContext,
7150 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7151 CodeCompleter->getCodeCompletionTUInfo(),
7153 Results.EnterNewScope();
7155 if (CodeCompleter->includeGlobals()) {
7161 Results.ExitScope();
7164 Results.data(), Results.size());
7169 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7170 CodeCompleter->getCodeCompletionTUInfo(),
7172 Results.EnterNewScope();
7176 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
7177 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
7178 Results.Ignore(CurClass);
7180 if (CodeCompleter->includeGlobals()) {
7186 Results.ExitScope();
7189 Results.data(), Results.size());
7193 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7194 CodeCompleter->getCodeCompletionTUInfo(),
7196 Results.EnterNewScope();
7198 if (CodeCompleter->includeGlobals()) {
7204 Results.ExitScope();
7207 Results.data(), Results.size());
7215 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7216 CodeCompleter->getCodeCompletionTUInfo(),
7221 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
7223 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
7225 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
7226 for (
const auto *Cat : Class->visible_categories())
7227 CategoryNames.insert(Cat->getIdentifier());
7231 Results.EnterNewScope();
7233 for (
const auto *D : TU->
decls())
7234 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
7235 if (CategoryNames.insert(
Category->getIdentifier()).second)
7238 CurContext,
nullptr,
false);
7239 Results.ExitScope();
7242 Results.data(), Results.size());
7254 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
7257 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
7259 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7260 CodeCompleter->getCodeCompletionTUInfo(),
7266 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
7267 Results.EnterNewScope();
7268 bool IgnoreImplemented =
true;
7271 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
7272 CategoryNames.insert(Cat->getIdentifier()).second)
7273 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
7274 CurContext,
nullptr,
false);
7278 IgnoreImplemented =
false;
7280 Results.ExitScope();
7283 Results.data(), Results.size());
7288 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7289 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
7293 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
7294 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
7295 !isa<ObjCCategoryImplDecl>(Container)))
7300 for (
const auto *D : Container->decls())
7301 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
7302 Results.Ignore(PropertyImpl->getPropertyDecl());
7305 AddedPropertiesSet AddedProperties;
7306 Results.EnterNewScope();
7308 dyn_cast<ObjCImplementationDecl>(Container))
7311 AddedProperties, Results);
7314 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
7315 false,
false, CurContext,
7316 AddedProperties, Results);
7317 Results.ExitScope();
7320 Results.data(), Results.size());
7326 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7327 CodeCompleter->getCodeCompletionTUInfo(),
7332 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
7333 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
7334 !isa<ObjCCategoryImplDecl>(Container)))
7340 dyn_cast<ObjCImplementationDecl>(Container))
7341 Class = ClassImpl->getClassInterface();
7343 Class = cast<ObjCCategoryImplDecl>(Container)
7345 ->getClassInterface();
7353 Property->getType().getNonReferenceType().getUnqualifiedType();
7356 Results.setPreferredType(PropertyType);
7361 Results.EnterNewScope();
7362 bool SawSimilarlyNamedIvar =
false;
7363 std::string NameWithPrefix;
7364 NameWithPrefix +=
'_';
7365 NameWithPrefix += PropertyName->
getName();
7366 std::string NameWithSuffix = PropertyName->
getName().str();
7367 NameWithSuffix +=
'_';
7371 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
7372 CurContext,
nullptr,
false);
7376 if ((PropertyName == Ivar->getIdentifier() ||
7377 NameWithPrefix == Ivar->
getName() ||
7378 NameWithSuffix == Ivar->getName())) {
7379 SawSimilarlyNamedIvar =
true;
7383 if (Results.size() &&
7384 Results.data()[Results.size() - 1].Kind ==
7386 Results.data()[Results.size() - 1].Declaration == Ivar)
7387 Results.data()[Results.size() - 1].Priority--;
7392 if (!SawSimilarlyNamedIvar) {
7402 Builder.AddResultTypeChunk(
7404 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
7409 Results.ExitScope();
7412 Results.data(), Results.size());
7418 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
7430 bool InOriginalClass =
true) {
7433 if (!IFace->hasDefinition())
7436 IFace = IFace->getDefinition();
7440 IFace->getReferencedProtocols();
7442 E = Protocols.
end();
7445 KnownMethods, InOriginalClass);
7448 for (
auto *Cat : IFace->visible_categories()) {
7450 KnownMethods,
false);
7454 if (IFace->getSuperClass())
7456 WantInstanceMethods, ReturnType, KnownMethods,
7463 Category->getReferencedProtocols();
7465 E = Protocols.
end();
7468 KnownMethods, InOriginalClass);
7471 if (InOriginalClass &&
Category->getClassInterface())
7473 WantInstanceMethods, ReturnType, KnownMethods,
7479 if (!Protocol->hasDefinition())
7481 Protocol = Protocol->getDefinition();
7482 Container = Protocol;
7486 Protocol->getReferencedProtocols();
7488 E = Protocols.
end();
7491 KnownMethods,
false);
7497 for (
auto *M : Container->
methods()) {
7498 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
7499 if (!ReturnType.
isNull() &&
7503 KnownMethods[M->getSelector()] =
7504 KnownMethodsMap::mapped_type(M, InOriginalClass);
7539 bool IsInstanceMethod,
7541 VisitedSelectorSet &KnownSelectors,
7542 ResultBuilder &Results) {
7544 if (!PropName || PropName->
getLength() == 0)
7562 const char *CopiedKey;
7565 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
7567 operator const char *() {
7571 return CopiedKey = Allocator.
CopyString(Key);
7573 } Key(Allocator, PropName->
getName());
7576 std::string UpperKey = PropName->
getName();
7577 if (!UpperKey.empty())
7580 bool ReturnTypeMatchesProperty =
7584 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
7587 if (IsInstanceMethod &&
7588 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
7594 Builder.AddTypedTextChunk(Key);
7601 if (IsInstanceMethod &&
7602 ((!ReturnType.
isNull() &&
7606 std::string SelectorName = (Twine(
"is") + UpperKey).str();
7608 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7610 if (ReturnType.
isNull()) {
7612 Builder.AddTextChunk(
"BOOL");
7623 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
7625 std::string SelectorName = (Twine(
"set") + UpperKey).str();
7627 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7628 if (ReturnType.
isNull()) {
7630 Builder.AddTextChunk(
"void");
7635 Builder.AddTypedTextChunk(
":");
7638 Builder.AddTextChunk(Key);
7649 if (
const auto *ObjCPointer =
7674 if (IsInstanceMethod &&
7676 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
7678 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7680 if (ReturnType.
isNull()) {
7682 Builder.AddTextChunk(
"NSUInteger");
7688 Result(Builder.TakeString(),
7689 std::min(IndexedGetterPriority, UnorderedGetterPriority),
7696 if (IsInstanceMethod &&
7698 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
7700 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7701 if (ReturnType.
isNull()) {
7703 Builder.AddTextChunk(
"id");
7707 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7709 Builder.AddTextChunk(
"NSUInteger");
7711 Builder.AddTextChunk(
"index");
7712 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7718 if (IsInstanceMethod &&
7723 ->getInterfaceDecl()
7724 ->getName() ==
"NSArray"))) {
7725 std::string SelectorName = (Twine(Property->
getName()) +
"AtIndexes").str();
7727 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7728 if (ReturnType.
isNull()) {
7730 Builder.AddTextChunk(
"NSArray *");
7734 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7736 Builder.AddTextChunk(
"NSIndexSet *");
7738 Builder.AddTextChunk(
"indexes");
7739 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7745 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7746 std::string SelectorName = (Twine(
"get") + UpperKey).str();
7750 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7751 if (ReturnType.
isNull()) {
7753 Builder.AddTextChunk(
"void");
7757 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7759 Builder.AddPlaceholderChunk(
"object-type");
7760 Builder.AddTextChunk(
" **");
7762 Builder.AddTextChunk(
"buffer");
7764 Builder.AddTypedTextChunk(
"range:");
7766 Builder.AddTextChunk(
"NSRange");
7768 Builder.AddTextChunk(
"inRange");
7769 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7777 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7778 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
7782 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7783 if (ReturnType.
isNull()) {
7785 Builder.AddTextChunk(
"void");
7789 Builder.AddTypedTextChunk(
"insertObject:");
7791 Builder.AddPlaceholderChunk(
"object-type");
7792 Builder.AddTextChunk(
" *");
7794 Builder.AddTextChunk(
"object");
7796 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7798 Builder.AddPlaceholderChunk(
"NSUInteger");
7800 Builder.AddTextChunk(
"index");
7801 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7807 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7808 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
7812 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7813 if (ReturnType.
isNull()) {
7815 Builder.AddTextChunk(
"void");
7819 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7821 Builder.AddTextChunk(
"NSArray *");
7823 Builder.AddTextChunk(
"array");
7825 Builder.AddTypedTextChunk(
"atIndexes:");
7827 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7829 Builder.AddTextChunk(
"indexes");
7830 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7836 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7837 std::string SelectorName =
7838 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
7840 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7841 if (ReturnType.
isNull()) {
7843 Builder.AddTextChunk(
"void");
7847 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7849 Builder.AddTextChunk(
"NSUInteger");
7851 Builder.AddTextChunk(
"index");
7852 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7858 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7859 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
7861 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7862 if (ReturnType.
isNull()) {
7864 Builder.AddTextChunk(
"void");
7868 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7870 Builder.AddTextChunk(
"NSIndexSet *");
7872 Builder.AddTextChunk(
"indexes");
7873 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7879 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7880 std::string SelectorName =
7881 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
7885 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7886 if (ReturnType.
isNull()) {
7888 Builder.AddTextChunk(
"void");
7892 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7894 Builder.AddPlaceholderChunk(
"NSUInteger");
7896 Builder.AddTextChunk(
"index");
7898 Builder.AddTypedTextChunk(
"withObject:");
7900 Builder.AddTextChunk(
"id");
7902 Builder.AddTextChunk(
"object");
7903 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7909 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7910 std::string SelectorName1 =
7911 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
7912 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
7916 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7917 if (ReturnType.
isNull()) {
7919 Builder.AddTextChunk(
"void");
7923 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
7925 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7927 Builder.AddTextChunk(
"indexes");
7929 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
7931 Builder.AddTextChunk(
"NSArray *");
7933 Builder.AddTextChunk(
"array");
7934 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7941 if (IsInstanceMethod &&
7946 ->getInterfaceDecl()
7947 ->getName() ==
"NSEnumerator"))) {
7948 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
7950 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7952 if (ReturnType.
isNull()) {
7954 Builder.AddTextChunk(
"NSEnumerator *");
7958 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7959 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7965 if (IsInstanceMethod &&
7967 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
7969 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7970 if (ReturnType.
isNull()) {
7972 Builder.AddPlaceholderChunk(
"object-type");
7973 Builder.AddTextChunk(
" *");
7977 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7979 if (ReturnType.
isNull()) {
7980 Builder.AddPlaceholderChunk(
"object-type");
7981 Builder.AddTextChunk(
" *");
7984 ReturnType, Context, Policy, Builder.getAllocator()));
7987 Builder.AddTextChunk(
"object");
7988 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7995 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7996 std::string SelectorName =
7997 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
7999 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8000 if (ReturnType.
isNull()) {
8002 Builder.AddTextChunk(
"void");
8006 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8008 Builder.AddPlaceholderChunk(
"object-type");
8009 Builder.AddTextChunk(
" *");
8011 Builder.AddTextChunk(
"object");
8012 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8018 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8019 std::string SelectorName = (Twine(
"add") + UpperKey).str();
8021 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8022 if (ReturnType.
isNull()) {
8024 Builder.AddTextChunk(
"void");
8028 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8030 Builder.AddTextChunk(
"NSSet *");
8032 Builder.AddTextChunk(
"objects");
8033 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8039 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8040 std::string SelectorName =
8041 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
8043 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8044 if (ReturnType.
isNull()) {
8046 Builder.AddTextChunk(
"void");
8050 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8052 Builder.AddPlaceholderChunk(
"object-type");
8053 Builder.AddTextChunk(
" *");
8055 Builder.AddTextChunk(
"object");
8056 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8062 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8063 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
8065 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8066 if (ReturnType.
isNull()) {
8068 Builder.AddTextChunk(
"void");
8072 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8074 Builder.AddTextChunk(
"NSSet *");
8076 Builder.AddTextChunk(
"objects");
8077 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8083 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8084 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
8086 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8087 if (ReturnType.
isNull()) {
8089 Builder.AddTextChunk(
"void");
8093 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8095 Builder.AddTextChunk(
"NSSet *");
8097 Builder.AddTextChunk(
"objects");
8098 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8105 if (!IsInstanceMethod &&
8110 ->getInterfaceDecl()
8111 ->getName() ==
"NSSet"))) {
8112 std::string SelectorName =
8113 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
8115 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
8117 if (ReturnType.
isNull()) {
8119 Builder.AddTextChunk(
"NSSet<NSString *> *");
8123 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
8130 if (!IsInstanceMethod &&
8133 std::string SelectorName =
8134 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
8136 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
8138 if (ReturnType.
isNull()) {
8140 Builder.AddTextChunk(
"BOOL");
8144 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
8155 QualType ReturnType = GetTypeFromParser(ReturnTy);
8156 Decl *IDecl =
nullptr;
8163 bool IsInImplementation =
false;
8164 if (
Decl *D = IDecl) {
8166 SearchDecl = Impl->getClassInterface();
8167 IsInImplementation =
true;
8169 dyn_cast<ObjCCategoryImplDecl>(D)) {
8170 SearchDecl = CatImpl->getCategoryDecl();
8171 IsInImplementation =
true;
8176 if (!SearchDecl && S) {
8178 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
8194 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8195 CodeCompleter->getCodeCompletionTUInfo(),
8197 Results.EnterNewScope();
8199 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
8200 MEnd = KnownMethods.end();
8204 Results.getCodeCompletionTUInfo());
8207 if (!IsInstanceMethod) {
8214 if (ReturnType.
isNull()) {
8224 Builder.AddTypedTextChunk(
8225 Builder.getAllocator().CopyString(Sel.getNameForSlot(0)));
8231 P != PEnd; (void)++
P, ++I) {
8234 Builder.AddTypedTextChunk(
":");
8235 else if (I < Sel.getNumArgs()) {
8237 Builder.AddTypedTextChunk(
8238 Builder.getAllocator().CopyString(Sel.getNameForSlot(I) +
":"));
8245 ParamType = (*P)->getType();
8247 ParamType = (*P)->getOriginalType();
8255 Builder.AddTextChunk(Builder.getAllocator().CopyString(
Id->getName()));
8261 Builder.AddTextChunk(
"...");
8264 if (IsInImplementation && Results.includeCodePatterns()) {
8271 Builder.AddTextChunk(
"return");
8273 Builder.AddPlaceholderChunk(
"expression");
8276 Builder.AddPlaceholderChunk(
"statements");
8283 auto R = Result(Builder.TakeString(), Method, Priority);
8284 if (!M->second.getInt())
8286 Results.AddResult(std::move(R));
8293 Containers.push_back(SearchDecl);
8295 VisitedSelectorSet KnownSelectors;
8296 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
8297 MEnd = KnownMethods.end();
8299 KnownSelectors.insert(M->first);
8304 IFace =
Category->getClassInterface();
8308 Containers.push_back(Cat);
8310 if (IsInstanceMethod) {
8311 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
8312 for (
auto *
P : Containers[I]->instance_properties())
8314 KnownSelectors, Results);
8318 Results.ExitScope();
8321 Results.data(), Results.size());
8325 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
8329 if (ExternalSource) {
8330 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
8332 Selector Sel = ExternalSource->GetExternalSelector(I);
8333 if (Sel.
isNull() || MethodPool.count(Sel))
8336 ReadMethodPool(Sel);
8342 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8343 CodeCompleter->getCodeCompletionTUInfo(),
8347 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
8349 Results.EnterNewScope();
8350 for (GlobalMethodPool::iterator M = MethodPool.begin(),
8351 MEnd = MethodPool.end();
8353 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
8354 : &M->second.second;
8355 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8359 if (AtParameterName) {
8361 unsigned NumSelIdents = SelIdents.size();
8363 NumSelIdents <= MethList->getMethod()->param_size()) {
8365 MethList->getMethod()->parameters()[NumSelIdents - 1];
8368 Results.getCodeCompletionTUInfo());
8369 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
8371 Results.AddResult(Builder.TakeString());
8378 Result R(MethList->getMethod(),
8379 Results.getBasePriority(MethList->getMethod()),
nullptr);
8380 R.StartParameter = SelIdents.size();
8381 R.AllParametersAreInformative =
false;
8382 R.DeclaringEntity =
true;
8383 Results.MaybeAddResult(R, CurContext);
8387 Results.ExitScope();
8389 if (!AtParameterName && !SelIdents.empty() &&
8390 SelIdents.front()->getName().startswith(
"init")) {
8391 for (
const auto &M : PP.macros()) {
8392 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
8394 Results.EnterNewScope();
8396 Results.getCodeCompletionTUInfo());
8397 Builder.AddTypedTextChunk(
8398 Builder.getAllocator().CopyString(M.first->getName()));
8401 Results.ExitScope();
8406 Results.data(), Results.size());
8410 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8411 CodeCompleter->getCodeCompletionTUInfo(),
8413 Results.EnterNewScope();
8417 Results.getCodeCompletionTUInfo());
8418 Builder.AddTypedTextChunk(
"if");
8420 Builder.AddPlaceholderChunk(
"condition");
8421 Results.AddResult(Builder.TakeString());
8424 Builder.AddTypedTextChunk(
"ifdef");
8426 Builder.AddPlaceholderChunk(
"macro");
8427 Results.AddResult(Builder.TakeString());
8430 Builder.AddTypedTextChunk(
"ifndef");
8432 Builder.AddPlaceholderChunk(
"macro");
8433 Results.AddResult(Builder.TakeString());
8435 if (InConditional) {
8437 Builder.AddTypedTextChunk(
"elif");
8439 Builder.AddPlaceholderChunk(
"condition");
8440 Results.AddResult(Builder.TakeString());
8443 Builder.AddTypedTextChunk(
"else");
8444 Results.AddResult(Builder.TakeString());
8447 Builder.AddTypedTextChunk(
"endif");
8448 Results.AddResult(Builder.TakeString());
8452 Builder.AddTypedTextChunk(
"include");
8454 Builder.AddTextChunk(
"\"");
8455 Builder.AddPlaceholderChunk(
"header");
8456 Builder.AddTextChunk(
"\"");
8457 Results.AddResult(Builder.TakeString());
8460 Builder.AddTypedTextChunk(
"include");
8462 Builder.AddTextChunk(
"<");
8463 Builder.AddPlaceholderChunk(
"header");
8464 Builder.AddTextChunk(
">");
8465 Results.AddResult(Builder.TakeString());
8468 Builder.AddTypedTextChunk(
"define");
8470 Builder.AddPlaceholderChunk(
"macro");
8471 Results.AddResult(Builder.TakeString());
8474 Builder.AddTypedTextChunk(
"define");
8476 Builder.AddPlaceholderChunk(
"macro");
8478 Builder.AddPlaceholderChunk(
"args");
8480 Results.AddResult(Builder.TakeString());
8483 Builder.AddTypedTextChunk(
"undef");
8485 Builder.AddPlaceholderChunk(
"macro");
8486 Results.AddResult(Builder.TakeString());
8489 Builder.AddTypedTextChunk(
"line");
8491 Builder.AddPlaceholderChunk(
"number");
8492 Results.AddResult(Builder.TakeString());
8495 Builder.AddTypedTextChunk(
"line");
8497 Builder.AddPlaceholderChunk(
"number");
8499 Builder.AddTextChunk(
"\"");
8500 Builder.AddPlaceholderChunk(
"filename");
8501 Builder.AddTextChunk(
"\"");
8502 Results.AddResult(Builder.TakeString());
8505 Builder.AddTypedTextChunk(
"error");
8507 Builder.AddPlaceholderChunk(
"message");
8508 Results.AddResult(Builder.TakeString());
8511 Builder.AddTypedTextChunk(
"pragma");
8513 Builder.AddPlaceholderChunk(
"arguments");
8514 Results.AddResult(Builder.TakeString());
8516 if (getLangOpts().ObjC) {
8518 Builder.AddTypedTextChunk(
"import");
8520 Builder.AddTextChunk(
"\"");
8521 Builder.AddPlaceholderChunk(
"header");
8522 Builder.AddTextChunk(
"\"");
8523 Results.AddResult(Builder.TakeString());
8526 Builder.AddTypedTextChunk(
"import");
8528 Builder.AddTextChunk(
"<");
8529 Builder.AddPlaceholderChunk(
"header");
8530 Builder.AddTextChunk(
">");
8531 Results.AddResult(Builder.TakeString());
8535 Builder.AddTypedTextChunk(
"include_next");
8537 Builder.AddTextChunk(
"\"");
8538 Builder.AddPlaceholderChunk(
"header");
8539 Builder.AddTextChunk(
"\"");
8540 Results.AddResult(Builder.TakeString());
8543 Builder.AddTypedTextChunk(
"include_next");
8545 Builder.AddTextChunk(
"<");
8546 Builder.AddPlaceholderChunk(
"header");
8547 Builder.AddTextChunk(
">");
8548 Results.AddResult(Builder.TakeString());
8551 Builder.AddTypedTextChunk(
"warning");
8553 Builder.AddPlaceholderChunk(
"message");
8554 Results.AddResult(Builder.TakeString());
8561 Results.ExitScope();
8564 Results.data(), Results.size());
8573 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8574 CodeCompleter->getCodeCompletionTUInfo(),
8577 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
8580 Results.getCodeCompletionTUInfo());
8581 Results.EnterNewScope();
8583 MEnd = PP.macro_end();
8585 Builder.AddTypedTextChunk(
8586 Builder.getAllocator().CopyString(M->first->getName()));
8590 Results.ExitScope();
8591 }
else if (IsDefinition) {
8596 Results.data(), Results.size());
8600 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8601 CodeCompleter->getCodeCompletionTUInfo(),
8604 if (!CodeCompleter || CodeCompleter->includeMacros())
8606 !CodeCompleter || CodeCompleter->loadExternal(),
true);
8609 Results.EnterNewScope();
8611 Results.getCodeCompletionTUInfo());
8612 Builder.AddTypedTextChunk(
"defined");
8615 Builder.AddPlaceholderChunk(
"macro");
8617 Results.AddResult(Builder.TakeString());
8618 Results.ExitScope();
8621 Results.data(), Results.size());
8627 unsigned Argument) {
8641 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
8644 llvm::sys::path::native(NativeRelDir);
8645 llvm::vfs::FileSystem &FS =
8646 getSourceManager().getFileManager().getVirtualFileSystem();
8648 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8649 CodeCompleter->getCodeCompletionTUInfo(),
8654 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
8657 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
8658 auto R = SeenResults.insert(TypedChunk);
8660 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
8661 *R.first = InternedTyped;
8663 CodeCompleter->getCodeCompletionTUInfo());
8664 Builder.AddTypedTextChunk(InternedTyped);
8672 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
8676 if (!NativeRelDir.empty()) {
8680 auto Begin = llvm::sys::path::begin(NativeRelDir);
8681 auto End = llvm::sys::path::end(NativeRelDir);
8683 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
8684 llvm::sys::path::append(Dir, ++
Begin,
End);
8686 llvm::sys::path::append(Dir, NativeRelDir);
8692 for (
auto It = FS.dir_begin(Dir, EC);
8693 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
8694 if (++Count == 2500)
8696 StringRef Filename = llvm::sys::path::filename(It->path());
8697 switch (It->type()) {
8698 case llvm::sys::fs::file_type::directory_file:
8702 NativeRelDir.empty() && !Filename.consume_back(
".framework"))
8705 AddCompletion(Filename,
true);
8707 case llvm::sys::fs::file_type::regular_file:
8711 if (!(Filename.endswith_lower(
".h") ||
8712 Filename.endswith_lower(
".hh") ||
8713 Filename.endswith_lower(
".hpp") ||
8714 Filename.endswith_lower(
".inc")))
8717 AddCompletion(Filename,
false);
8733 AddFilesFromIncludeDir(IncludeDir.
getDir()->
getName(), IsSystem,
8746 const auto &S = PP.getHeaderSearchInfo();
8747 using llvm::make_range;
8750 auto *CurFile = PP.getCurrentFileLexer()->getFileEntry();
8751 if (CurFile && CurFile->getDir())
8752 AddFilesFromIncludeDir(CurFile->getDir()->getName(),
false,
8754 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
8755 AddFilesFromDirLookup(D,
false);
8757 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
8758 AddFilesFromDirLookup(D,
false);
8759 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
8760 AddFilesFromDirLookup(D,
true);
8763 Results.data(), Results.size());
8773 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8774 CodeCompleter->getCodeCompletionTUInfo(),
8776 Results.EnterNewScope();
8777 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
8778 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
8781 Twine(Platform) +
"ApplicationExtension")));
8783 Results.ExitScope();
8785 Results.data(), Results.size());
8791 ResultBuilder Builder(*
this, Allocator, CCTUInfo,
8793 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
8794 CodeCompletionDeclConsumer Consumer(Builder,
8798 !CodeCompleter || CodeCompleter->loadExternal());
8801 if (!CodeCompleter || CodeCompleter->includeMacros())
8803 !CodeCompleter || CodeCompleter->loadExternal(),
true);
8806 Results.insert(Results.end(), Builder.data(),
8807 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)
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool LoadExternal, bool IncludeUndefined, bool TargetTypeIsPointer=false)
Priority for a preprocessor macro.
Represents a function declaration or definition.
static OverloadCompare compareOverloads(const CXXMethodDecl &Candidate, const CXXMethodDecl &Incumbent, const Qualifiers &ObjectQuals, ExprValueKind ObjectKind)
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
ExternalSemaSource * getExternalSource() const
A C++ namespace alias declaration.
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.
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.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
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>.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
Code completion where an Objective-C class message is expected.
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...
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
C Language Family Type Representation.
static CharSourceRange getTokenRange(SourceRange R)
Code completion within a type-qualifier list.
Priority for the next initialization in a constructor initializer list.
bool isRecordType() const
static bool isReservedName(const IdentifierInfo *Id, bool doubleUnderscoreOnly=false)
Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).
bool isEmpty() const
No scope specifier.
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
Divide by this factor when a code-completion result's type exactly matches the type we expect...
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.
void setPreferredType(QualType T)
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
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
bool isEnumeralType() const
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
TypeSpecifierType
Specifies the kind of type.
The "__interface" keyword.
An Objective-C @synthesize definition.
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static const TST TST_interface
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
CodeCompleteExpressionData(QualType PreferredType=QualType(), bool IsParenthesized=false)
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.
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
void enterFunctionArgument(SourceLocation Tok, llvm::function_ref< QualType()> ComputeType)
Computing a type for the function argument may require running overloading, so we postpone its comput...
bool isObjCObjectOrInterfaceType() const
Code completion occurred where both a new name and an existing symbol is permissible.
void enterVariableInit(SourceLocation Tok, Decl *D)
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.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)
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.
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
void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)
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.
An Objective-C block property completed as a setter with a block placeholder.
field_range fields() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const FunctionProtoType * TryDeconstructFunctionLike(QualType T)
Try to find a corresponding FunctionProtoType for function-like types (e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
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
Priority for a declaration that is in the local scope.
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.
Code completion occurs at top-level or namespace context.
ArrayRef< ParmVarDecl * > parameters() const
Values of this type can be null.
bool isUnarySelector() const
An Objective-C @property declaration.
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
static ObjCContainerDecl * getContainerDef(ObjCContainerDecl *Container)
Retrieve the container definition, if any?
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
An allocator used specifically for the purpose of code completion.
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Represents a C++ unqualified-id that has been parsed.
param_iterator param_end() const
Represents the results of name lookup.
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...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
An lvalue ref-qualifier was provided (&).
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.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
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)
void enterCondition(Sema &S, SourceLocation Tok)
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
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
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)
Priority for a send-to-super completion.
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.
The piece of text that the user is expected to type to match the code-completion string, typically a keyword or the name of a declarator or macro.
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...
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)
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...
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
Zero-argument (unary) selector.
DeclarationNameTable DeclarationNames
static DeclContext::lookup_result getConstructors(ASTContext &Context, const CXXRecordDecl *Record)
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)
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
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...
void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
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)...
Represents 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.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
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)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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 AddEnumerators(ResultBuilder &Results, ASTContext &Context, EnumDecl *Enum, DeclContext *CurContext, const CoveredEnumerators &Enumerators)
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
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 CodeCompletePostfixExpression(Scope *S, ExprResult LHS, QualType PreferredType)
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 ...
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
The result is in a base class.
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)
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.
QualType getCanonicalType() const
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
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.
static QualType getPreferredTypeOfUnaryArg(Sema &S, QualType ContextType, tok::TokenKind Op)
Get preferred type for an argument of an unary expression.
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>::".
No ref-qualifier was provided.
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
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
Represents a C++11 virt-specifier-seq.
static void printOverrideString(const CodeCompletionString &CCS, std::string &BeforeName, std::string &NameAndSignature)
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Adjustment for KVC code pattern priorities when it doesn't look like the.
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
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
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
An rvalue ref-qualifier was provided (&&).
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.
An Objective-C method being used as a property.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
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...
Defines various enumerations that describe declaration and type specifiers.
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getName() const
Return the actual identifier string.
The scope of a struct/union/class definition.
ObjCIvarDecl * getNextIvar()
bool isMacroDefined(StringRef Id)
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results)
Add all of the protocol declarations that we find in the given (translation unit) context...
Abstract interface for a consumer of code-completion information.
Represents a template argument.
An Objective-C instance variable.
ParserCompletionContext
Describes the context in which code completion occurs.
static bool isConstructor(const Decl *ND)
Dataflow Directional Tag Classes.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Code completion occurred where an macro is being defined.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix=false)
Generates a QualType that can be used to name the same type if used at the end of the current transla...
bool isFunctionLike() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo *> SelIdents)
static NestedNameSpecifier * getRequiredQualification(ASTContext &Context, const DeclContext *CurContext, const DeclContext *TargetContext)
Compute the qualification required to get from the current context (CurContext) to the target context...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
A function or method parameter.
QualType getType() const
Get the type for which this source info wrapper provides information.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
Qualifiers getMethodQualifiers() const
void CodeCompleteTag(Scope *S, unsigned TagSpec)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
AccessSpecifier getAccess() const
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, QualType BaseType, QualType PreferredType)
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.
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const CXXRecordDecl * getParent() const
Return 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.
Priority for a constant value (e.g., enumerator).
static CodeCompletionContext mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
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...
Priority for the Objective-C "_cmd" implicit parameter.
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 enterParenExpr(SourceLocation Tok, SourceLocation LParLoc)
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)
The template argument is a type.
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.
ArgKind getKind() const
Return the kind of stored template argument.
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
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
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.
Code completion inside the filename part of a #include directive.
Represents a C++ struct/union/class.
Priority for a code pattern.
An Objective-C @implementation.
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.
Priority for a nested-name-specifier.
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.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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
__DEVICE__ int min(int __a, int __b)
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)
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
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...
QualType getAsType() const
Retrieve the type for a type template argument.
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.
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 enterReturn(Sema &S, SourceLocation Tok)
void AddAnnotation(const char *A)
DeclaratorContext getContext() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
An l-value expression is a reference to an object with independent storage.
static void AddLambdaCompletion(ResultBuilder &Results, llvm::ArrayRef< QualType > Parameters, const LangOptions &LangOpts)
Adds a pattern completion for a lambda expression with the specified parameter types and placeholders...
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)
static void AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, ExprValueKind BaseKind, RecordDecl *RD, Optional< FixItHint > AccessOpFixIt)
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
Priority for a member declaration found from the current method or member function.
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.
void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
Priority for a non-type declaration.
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.