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;
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 *>()) {
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))
718 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
719 bool &AsNestedNameSpecifier)
const {
720 AsNestedNameSpecifier =
false;
735 if (isa<ClassTemplateSpecializationDecl>(ND) ||
736 isa<ClassTemplatePartialSpecializationDecl>(ND))
740 if (isa<UsingDecl>(ND))
746 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
747 (isa<NamespaceDecl>(ND) && Filter != &ResultBuilder::IsNamespace &&
748 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
749 AsNestedNameSpecifier =
true;
752 if (Filter && !(this->*Filter)(Named)) {
754 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
755 IsNestedNameSpecifier(ND) &&
756 (Filter != &ResultBuilder::IsMember ||
757 (isa<CXXRecordDecl>(ND) &&
758 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
759 AsNestedNameSpecifier =
true;
769 bool ResultBuilder::CheckHiddenResult(Result &R, DeclContext *CurContext,
777 const DeclContext *HiddenCtx =
789 R.QualifierIsInformative =
false;
793 R.Declaration->getDeclContext());
800 switch (T->getTypeClass()) {
802 switch (cast<BuiltinType>(T)->getKind()) {
803 case BuiltinType::Void:
806 case BuiltinType::NullPtr:
809 case BuiltinType::Overload:
810 case BuiltinType::Dependent:
813 case BuiltinType::ObjCId:
814 case BuiltinType::ObjCClass:
815 case BuiltinType::ObjCSel:
828 case Type::BlockPointer:
831 case Type::LValueReference:
832 case Type::RValueReference:
835 case Type::ConstantArray:
836 case Type::IncompleteArray:
837 case Type::VariableArray:
838 case Type::DependentSizedArray:
841 case Type::DependentSizedExtVector:
843 case Type::ExtVector:
846 case Type::FunctionProto:
847 case Type::FunctionNoProto:
856 case Type::ObjCObject:
857 case Type::ObjCInterface:
858 case Type::ObjCObjectPointer:
871 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
873 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
878 T = Function->getCallResultType();
879 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND))
880 T = Method->getSendResultType();
881 else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND))
883 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
885 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
886 T =
Value->getType();
901 if (
Pointer->getPointeeType()->isFunctionType()) {
915 T = Function->getReturnType();
925 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
933 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
934 if (ImplicitParam->getIdentifier() &&
935 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
942 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
944 if (isa<CXXDestructorDecl>(ND))
956 if (isa<EnumConstantDecl>(ND))
962 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
973 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
976 if (!PreferredSelector.
isNull())
977 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
978 if (PreferredSelector == Method->getSelector())
993 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1005 return Record->
lookup(ConstructorName);
1008 void ResultBuilder::MaybeAddConstructorResults(Result R) {
1009 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
1016 Record = ClassTemplate->getTemplatedDecl();
1017 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
1019 if (isa<ClassTemplateSpecializationDecl>(Record))
1031 R.Declaration = Ctor;
1033 Results.push_back(R);
1038 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1039 ND = Tmpl->getTemplatedDecl();
1040 return isa<CXXConstructorDecl>(ND);
1043 void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
1044 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1046 if (R.Kind != Result::RK_Declaration) {
1048 Results.push_back(R);
1053 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1055 getBasePriority(Using->getTargetDecl()),
1058 MaybeAddResult(Result, CurContext);
1065 bool AsNestedNameSpecifier =
false;
1066 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1073 ShadowMap &
SMap = ShadowMaps.back();
1074 ShadowMapEntry::iterator I, IEnd;
1075 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
1076 if (NamePos != SMap.end()) {
1077 I = NamePos->second.begin();
1078 IEnd = NamePos->second.end();
1081 for (; I != IEnd; ++I) {
1083 unsigned Index = I->second;
1086 Results[Index].Declaration = R.Declaration;
1096 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
1098 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
1099 ShadowMapEntry::iterator I, IEnd;
1100 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
1101 if (NamePos != SM->end()) {
1102 I = NamePos->second.begin();
1103 IEnd = NamePos->second.end();
1105 for (; I != IEnd; ++I) {
1107 if (I->first->hasTagIdentifierNamespace() &&
1115 I->first->getIdentifierNamespace() != IDNS)
1119 if (CheckHiddenResult(R, CurContext, I->first))
1127 if (!AllDeclsFound.insert(CanonDecl).second)
1132 if (AsNestedNameSpecifier) {
1133 R.StartsNestedNameSpecifier =
true;
1136 AdjustResultPriorityForDecl(R);
1139 if (R.QualifierIsInformative && !R.Qualifier &&
1140 !R.StartsNestedNameSpecifier) {
1141 const DeclContext *Ctx = R.Declaration->getDeclContext();
1142 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1145 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1147 SemaRef.
Context,
nullptr,
false,
1150 R.QualifierIsInformative =
false;
1155 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
1156 Results.push_back(R);
1158 if (!AsNestedNameSpecifier)
1159 MaybeAddConstructorResults(R);
1184 for (
unsigned I = 0, E = Candidate.
getNumParams(); I != E; ++I)
1185 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1186 Incumbent.
parameters()[I]->getType().getCanonicalType())
1195 if (CandidateRef != IncumbentRef) {
1211 if (CandidateSuperset == IncumbentSuperset)
1217 void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
1218 NamedDecl *Hiding,
bool InBaseClass =
false) {
1219 if (R.Kind != Result::RK_Declaration) {
1221 Results.push_back(R);
1226 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1228 getBasePriority(Using->getTargetDecl()),
1231 AddResult(Result, CurContext, Hiding);
1235 bool AsNestedNameSpecifier =
false;
1236 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1243 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1247 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
1252 if (AsNestedNameSpecifier) {
1253 R.StartsNestedNameSpecifier =
true;
1255 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1258 R.Declaration->getDeclContext()->getRedeclContext()))
1259 R.QualifierIsInformative =
true;
1262 if (R.QualifierIsInformative && !R.Qualifier &&
1263 !R.StartsNestedNameSpecifier) {
1264 const DeclContext *Ctx = R.Declaration->getDeclContext();
1265 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1268 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1270 SemaRef.
Context,
nullptr,
false,
1273 R.QualifierIsInformative =
false;
1280 AdjustResultPriorityForDecl(R);
1282 if (HasObjectTypeQualifiers)
1283 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1284 if (Method->isInstance()) {
1285 Qualifiers MethodQuals = Method->getMethodQualifiers();
1286 if (ObjectTypeQualifiers == MethodQuals)
1288 else if (ObjectTypeQualifiers - MethodQuals) {
1294 switch (Method->getRefQualifier()) {
1310 auto &OverloadSet = OverloadMap[std::make_pair(
1311 CurContext, Method->getDeclName().getAsOpaqueInteger())];
1312 for (
const DeclIndexPair Entry : OverloadSet) {
1313 Result &Incumbent = Results[Entry.second];
1315 *cast<CXXMethodDecl>(Incumbent.Declaration),
1316 ObjectTypeQualifiers, ObjectKind)) {
1321 Incumbent = std::move(R);
1330 OverloadSet.Add(Method, Results.size());
1334 Results.push_back(R);
1336 if (!AsNestedNameSpecifier)
1337 MaybeAddConstructorResults(R);
1340 void ResultBuilder::AddResult(Result R) {
1341 assert(R.Kind != Result::RK_Declaration &&
1342 "Declaration results need more context");
1343 Results.push_back(R);
1347 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1350 void ResultBuilder::ExitScope() {
1351 ShadowMaps.pop_back();
1356 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1365 if (isa<ObjCIvarDecl>(ND))
1374 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1376 if (isa<TypeDecl>(ND))
1381 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1382 if (!
ID->getDefinition())
1390 if (isa<ObjCIvarDecl>(ND))
1397 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1398 if (!IsOrdinaryNonTypeName(ND))
1402 if (VD->getType()->isIntegralOrEnumerationType())
1410 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1418 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1423 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1425 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1426 ND = ClassTemplate->getTemplatedDecl();
1432 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1433 return isa<EnumDecl>(ND);
1437 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1439 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1440 ND = ClassTemplate->getTemplatedDecl();
1443 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1451 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1453 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1454 ND = ClassTemplate->getTemplatedDecl();
1456 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1463 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1464 return isa<NamespaceDecl>(ND);
1469 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1474 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1476 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1482 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1484 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1485 isa<ObjCPropertyDecl>(ND);
1491 case Type::ObjCObject:
1492 case Type::ObjCInterface:
1493 case Type::ObjCObjectPointer:
1497 switch (cast<BuiltinType>(T)->getKind()) {
1498 case BuiltinType::ObjCId:
1499 case BuiltinType::ObjCClass:
1500 case BuiltinType::ObjCSel:
1521 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1530 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1532 if (IsObjCMessageReceiver(ND))
1535 const auto *Var = dyn_cast<
VarDecl>(ND);
1542 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1543 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1544 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1557 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1563 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1564 return isa<ObjCIvarDecl>(ND);
1572 ResultBuilder &Results;
1573 DeclContext *InitialLookupCtx;
1578 std::vector<FixItHint> FixIts;
1581 CodeCompletionDeclConsumer(
1582 ResultBuilder &Results, DeclContext *InitialLookupCtx,
1584 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1585 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1586 FixIts(std::move(FixIts)) {
1587 NamingClass = llvm::dyn_cast<
CXXRecordDecl>(InitialLookupCtx);
1590 auto ThisType = Results.getSema().getCurrentThisType();
1591 if (!ThisType.isNull()) {
1592 assert(ThisType->isPointerType());
1595 NamingClass = BaseType->getAsCXXRecordDecl();
1598 this->BaseType = BaseType;
1602 bool InBaseClass)
override {
1605 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass);
1608 void EnteredContext(DeclContext *Ctx)
override {
1609 Results.addVisitedContext(Ctx);
1618 auto *NamingClass = this->NamingClass;
1619 QualType BaseType = this->BaseType;
1620 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1635 NamingClass =
nullptr;
1638 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1645 ResultBuilder &Results) {
1647 Results.AddResult(Result(
"short",
CCP_Type));
1648 Results.AddResult(Result(
"long",
CCP_Type));
1649 Results.AddResult(Result(
"signed",
CCP_Type));
1650 Results.AddResult(Result(
"unsigned",
CCP_Type));
1651 Results.AddResult(Result(
"void",
CCP_Type));
1652 Results.AddResult(Result(
"char",
CCP_Type));
1653 Results.AddResult(Result(
"int",
CCP_Type));
1654 Results.AddResult(Result(
"float",
CCP_Type));
1655 Results.AddResult(Result(
"double",
CCP_Type));
1656 Results.AddResult(Result(
"enum",
CCP_Type));
1657 Results.AddResult(Result(
"struct",
CCP_Type));
1658 Results.AddResult(Result(
"union",
CCP_Type));
1659 Results.AddResult(Result(
"const",
CCP_Type));
1660 Results.AddResult(Result(
"volatile",
CCP_Type));
1664 Results.AddResult(Result(
"_Complex",
CCP_Type));
1665 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1666 Results.AddResult(Result(
"_Bool",
CCP_Type));
1667 Results.AddResult(Result(
"restrict",
CCP_Type));
1671 Results.getCodeCompletionTUInfo());
1672 if (LangOpts.CPlusPlus) {
1676 Results.AddResult(Result(
"class",
CCP_Type));
1677 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1680 Builder.AddTypedTextChunk(
"typename");
1682 Builder.AddPlaceholderChunk(
"qualifier");
1683 Builder.AddTextChunk(
"::");
1684 Builder.AddPlaceholderChunk(
"name");
1685 Results.AddResult(Result(Builder.TakeString()));
1687 if (LangOpts.CPlusPlus11) {
1688 Results.AddResult(Result(
"auto",
CCP_Type));
1689 Results.AddResult(Result(
"char16_t",
CCP_Type));
1690 Results.AddResult(Result(
"char32_t",
CCP_Type));
1692 Builder.AddTypedTextChunk(
"decltype");
1694 Builder.AddPlaceholderChunk(
"expression");
1696 Results.AddResult(Result(Builder.TakeString()));
1699 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1702 if (LangOpts.GNUKeywords) {
1708 Builder.AddTypedTextChunk(
"typeof");
1710 Builder.AddPlaceholderChunk(
"expression");
1711 Results.AddResult(Result(Builder.TakeString()));
1713 Builder.AddTypedTextChunk(
"typeof");
1715 Builder.AddPlaceholderChunk(
"type");
1717 Results.AddResult(Result(Builder.TakeString()));
1721 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1722 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1723 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1728 ResultBuilder &Results) {
1733 Results.AddResult(Result(
"extern"));
1734 Results.AddResult(Result(
"static"));
1736 if (LangOpts.CPlusPlus11) {
1741 Builder.AddTypedTextChunk(
"alignas");
1743 Builder.AddPlaceholderChunk(
"expression");
1745 Results.AddResult(Result(Builder.TakeString()));
1747 Results.AddResult(Result(
"constexpr"));
1748 Results.AddResult(Result(
"thread_local"));
1754 ResultBuilder &Results) {
1759 if (LangOpts.CPlusPlus) {
1760 Results.AddResult(Result(
"explicit"));
1761 Results.AddResult(Result(
"friend"));
1762 Results.AddResult(Result(
"mutable"));
1763 Results.AddResult(Result(
"virtual"));
1771 if (LangOpts.CPlusPlus || LangOpts.C99)
1772 Results.AddResult(Result(
"inline"));
1791 ResultBuilder &Results,
bool NeedAt);
1793 ResultBuilder &Results,
bool NeedAt);
1795 ResultBuilder &Results,
bool NeedAt);
1800 Results.getCodeCompletionTUInfo());
1801 Builder.AddTypedTextChunk(
"typedef");
1803 Builder.AddPlaceholderChunk(
"type");
1805 Builder.AddPlaceholderChunk(
"name");
1827 return LangOpts.CPlusPlus;
1834 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
1837 llvm_unreachable(
"Invalid ParserCompletionContext!");
1865 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1866 return BT->getNameAsCString(Policy);
1869 if (
const TagType *TagT = dyn_cast<TagType>(T))
1870 if (
TagDecl *Tag = TagT->getDecl())
1871 if (!Tag->hasNameForLinkage()) {
1872 switch (Tag->getTagKind()) {
1874 return "struct <anonymous>";
1876 return "__interface <anonymous>";
1878 return "class <anonymous>";
1880 return "union <anonymous>";
1882 return "enum <anonymous>";
1902 Builder.AddResultTypeChunk(
1904 Builder.AddTypedTextChunk(
"this");
1909 ResultBuilder &Results,
1911 if (!LangOpts.CPlusPlus11)
1927 Sema &S = Results.getSema();
1934 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
1935 for (
auto *Method : CR->methods()) {
1936 if (!Method->isVirtual() || !Method->getIdentifier())
1938 Overrides[Method->getName()].push_back(Method);
1941 for (
const auto &
Base : CR->bases()) {
1942 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
1945 for (
auto *Method : BR->methods()) {
1946 if (!Method->isVirtual() || !Method->getIdentifier())
1948 const auto it = Overrides.find(Method->getName());
1949 bool IsOverriden =
false;
1950 if (it != Overrides.end()) {
1951 for (
auto *MD : it->second) {
1964 std::string OverrideSignature;
1965 llvm::raw_string_ostream OS(OverrideSignature);
1971 false, CCContext, Policy);
1980 Sema &SemaRef, ResultBuilder &Results) {
1988 if (Results.includeCodePatterns()) {
1990 Builder.AddTypedTextChunk(
"namespace");
1992 Builder.AddPlaceholderChunk(
"identifier");
1996 Builder.AddPlaceholderChunk(
"declarations");
1999 Results.AddResult(Result(Builder.TakeString()));
2003 Builder.AddTypedTextChunk(
"namespace");
2005 Builder.AddPlaceholderChunk(
"name");
2007 Builder.AddPlaceholderChunk(
"namespace");
2009 Results.AddResult(Result(Builder.TakeString()));
2012 Builder.AddTypedTextChunk(
"using namespace");
2014 Builder.AddPlaceholderChunk(
"identifier");
2016 Results.AddResult(Result(Builder.TakeString()));
2019 Builder.AddTypedTextChunk(
"asm");
2021 Builder.AddPlaceholderChunk(
"string-literal");
2023 Results.AddResult(Result(Builder.TakeString()));
2025 if (Results.includeCodePatterns()) {
2027 Builder.AddTypedTextChunk(
"template");
2029 Builder.AddPlaceholderChunk(
"declaration");
2030 Results.AddResult(Result(Builder.TakeString()));
2045 Builder.AddTypedTextChunk(
"using");
2047 Builder.AddPlaceholderChunk(
"qualifier");
2048 Builder.AddTextChunk(
"::");
2049 Builder.AddPlaceholderChunk(
"name");
2051 Results.AddResult(Result(Builder.TakeString()));
2055 Builder.AddTypedTextChunk(
"using typename");
2057 Builder.AddPlaceholderChunk(
"qualifier");
2058 Builder.AddTextChunk(
"::");
2059 Builder.AddPlaceholderChunk(
"name");
2061 Results.AddResult(Result(Builder.TakeString()));
2069 bool IsNotInheritanceScope =
2072 Builder.AddTypedTextChunk(
"public");
2073 if (IsNotInheritanceScope && Results.includeCodePatterns())
2075 Results.AddResult(Result(Builder.TakeString()));
2078 Builder.AddTypedTextChunk(
"protected");
2079 if (IsNotInheritanceScope && Results.includeCodePatterns())
2081 Results.AddResult(Result(Builder.TakeString()));
2084 Builder.AddTypedTextChunk(
"private");
2085 if (IsNotInheritanceScope && Results.includeCodePatterns())
2087 Results.AddResult(Result(Builder.TakeString()));
2100 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2102 Builder.AddTypedTextChunk(
"template");
2104 Builder.AddPlaceholderChunk(
"parameters");
2106 Results.AddResult(Result(Builder.TakeString()));
2135 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2137 Builder.AddTypedTextChunk(
"try");
2141 Builder.AddPlaceholderChunk(
"statements");
2145 Builder.AddTextChunk(
"catch");
2148 Builder.AddPlaceholderChunk(
"declaration");
2153 Builder.AddPlaceholderChunk(
"statements");
2156 Results.AddResult(Result(Builder.TakeString()));
2161 if (Results.includeCodePatterns()) {
2163 Builder.AddTypedTextChunk(
"if");
2167 Builder.AddPlaceholderChunk(
"condition");
2169 Builder.AddPlaceholderChunk(
"expression");
2174 Builder.AddPlaceholderChunk(
"statements");
2177 Results.AddResult(Result(Builder.TakeString()));
2180 Builder.AddTypedTextChunk(
"switch");
2184 Builder.AddPlaceholderChunk(
"condition");
2186 Builder.AddPlaceholderChunk(
"expression");
2191 Builder.AddPlaceholderChunk(
"cases");
2194 Results.AddResult(Result(Builder.TakeString()));
2201 Builder.AddTypedTextChunk(
"case");
2203 Builder.AddPlaceholderChunk(
"expression");
2205 Results.AddResult(Result(Builder.TakeString()));
2208 Builder.AddTypedTextChunk(
"default");
2210 Results.AddResult(Result(Builder.TakeString()));
2213 if (Results.includeCodePatterns()) {
2215 Builder.AddTypedTextChunk(
"while");
2219 Builder.AddPlaceholderChunk(
"condition");
2221 Builder.AddPlaceholderChunk(
"expression");
2226 Builder.AddPlaceholderChunk(
"statements");
2229 Results.AddResult(Result(Builder.TakeString()));
2232 Builder.AddTypedTextChunk(
"do");
2236 Builder.AddPlaceholderChunk(
"statements");
2239 Builder.AddTextChunk(
"while");
2242 Builder.AddPlaceholderChunk(
"expression");
2244 Results.AddResult(Result(Builder.TakeString()));
2247 Builder.AddTypedTextChunk(
"for");
2251 Builder.AddPlaceholderChunk(
"init-statement");
2253 Builder.AddPlaceholderChunk(
"init-expression");
2256 Builder.AddPlaceholderChunk(
"condition");
2259 Builder.AddPlaceholderChunk(
"inc-expression");
2264 Builder.AddPlaceholderChunk(
"statements");
2267 Results.AddResult(Result(Builder.TakeString()));
2272 Builder.AddTypedTextChunk(
"continue");
2274 Results.AddResult(Result(Builder.TakeString()));
2279 Builder.AddTypedTextChunk(
"break");
2281 Results.AddResult(Result(Builder.TakeString()));
2286 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext))
2287 ReturnType = Function->getReturnType();
2288 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2289 ReturnType = Method->getReturnType();
2294 Builder.AddTypedTextChunk(
"return");
2296 Results.AddResult(Result(Builder.TakeString()));
2298 assert(!ReturnType.
isNull());
2300 Builder.AddTypedTextChunk(
"return");
2302 Builder.AddPlaceholderChunk(
"expression");
2304 Results.AddResult(Result(Builder.TakeString()));
2307 Builder.AddTypedTextChunk(
"return true");
2309 Results.AddResult(Result(Builder.TakeString()));
2311 Builder.AddTypedTextChunk(
"return false");
2313 Results.AddResult(Result(Builder.TakeString()));
2318 Builder.AddTypedTextChunk(
"return nullptr");
2320 Results.AddResult(Result(Builder.TakeString()));
2325 Builder.AddTypedTextChunk(
"goto");
2327 Builder.AddPlaceholderChunk(
"label");
2329 Results.AddResult(Result(Builder.TakeString()));
2332 Builder.AddTypedTextChunk(
"using namespace");
2334 Builder.AddPlaceholderChunk(
"identifier");
2336 Results.AddResult(Result(Builder.TakeString()));
2353 Builder.AddTypedTextChunk(
"__bridge");
2355 Builder.AddPlaceholderChunk(
"type");
2357 Builder.AddPlaceholderChunk(
"expression");
2358 Results.AddResult(Result(Builder.TakeString()));
2361 Builder.AddTypedTextChunk(
"__bridge_transfer");
2363 Builder.AddPlaceholderChunk(
"Objective-C type");
2365 Builder.AddPlaceholderChunk(
"expression");
2366 Results.AddResult(Result(Builder.TakeString()));
2369 Builder.AddTypedTextChunk(
"__bridge_retained");
2371 Builder.AddPlaceholderChunk(
"CF type");
2373 Builder.AddPlaceholderChunk(
"expression");
2374 Results.AddResult(Result(Builder.TakeString()));
2385 Builder.AddResultTypeChunk(
"bool");
2386 Builder.AddTypedTextChunk(
"true");
2387 Results.AddResult(Result(Builder.TakeString()));
2390 Builder.AddResultTypeChunk(
"bool");
2391 Builder.AddTypedTextChunk(
"false");
2392 Results.AddResult(Result(Builder.TakeString()));
2396 Builder.AddTypedTextChunk(
"dynamic_cast");
2398 Builder.AddPlaceholderChunk(
"type");
2401 Builder.AddPlaceholderChunk(
"expression");
2403 Results.AddResult(Result(Builder.TakeString()));
2407 Builder.AddTypedTextChunk(
"static_cast");
2409 Builder.AddPlaceholderChunk(
"type");
2412 Builder.AddPlaceholderChunk(
"expression");
2414 Results.AddResult(Result(Builder.TakeString()));
2417 Builder.AddTypedTextChunk(
"reinterpret_cast");
2419 Builder.AddPlaceholderChunk(
"type");
2422 Builder.AddPlaceholderChunk(
"expression");
2424 Results.AddResult(Result(Builder.TakeString()));
2427 Builder.AddTypedTextChunk(
"const_cast");
2429 Builder.AddPlaceholderChunk(
"type");
2432 Builder.AddPlaceholderChunk(
"expression");
2434 Results.AddResult(Result(Builder.TakeString()));
2438 Builder.AddResultTypeChunk(
"std::type_info");
2439 Builder.AddTypedTextChunk(
"typeid");
2441 Builder.AddPlaceholderChunk(
"expression-or-type");
2443 Results.AddResult(Result(Builder.TakeString()));
2447 Builder.AddTypedTextChunk(
"new");
2449 Builder.AddPlaceholderChunk(
"type");
2451 Builder.AddPlaceholderChunk(
"expressions");
2453 Results.AddResult(Result(Builder.TakeString()));
2456 Builder.AddTypedTextChunk(
"new");
2458 Builder.AddPlaceholderChunk(
"type");
2460 Builder.AddPlaceholderChunk(
"size");
2463 Builder.AddPlaceholderChunk(
"expressions");
2465 Results.AddResult(Result(Builder.TakeString()));
2468 Builder.AddResultTypeChunk(
"void");
2469 Builder.AddTypedTextChunk(
"delete");
2471 Builder.AddPlaceholderChunk(
"expression");
2472 Results.AddResult(Result(Builder.TakeString()));
2475 Builder.AddResultTypeChunk(
"void");
2476 Builder.AddTypedTextChunk(
"delete");
2481 Builder.AddPlaceholderChunk(
"expression");
2482 Results.AddResult(Result(Builder.TakeString()));
2486 Builder.AddResultTypeChunk(
"void");
2487 Builder.AddTypedTextChunk(
"throw");
2489 Builder.AddPlaceholderChunk(
"expression");
2490 Results.AddResult(Result(Builder.TakeString()));
2497 Builder.AddResultTypeChunk(
"std::nullptr_t");
2498 Builder.AddTypedTextChunk(
"nullptr");
2499 Results.AddResult(Result(Builder.TakeString()));
2502 Builder.AddResultTypeChunk(
"size_t");
2503 Builder.AddTypedTextChunk(
"alignof");
2505 Builder.AddPlaceholderChunk(
"type");
2507 Results.AddResult(Result(Builder.TakeString()));
2510 Builder.AddResultTypeChunk(
"bool");
2511 Builder.AddTypedTextChunk(
"noexcept");
2513 Builder.AddPlaceholderChunk(
"expression");
2515 Results.AddResult(Result(Builder.TakeString()));
2518 Builder.AddResultTypeChunk(
"size_t");
2519 Builder.AddTypedTextChunk(
"sizeof...");
2521 Builder.AddPlaceholderChunk(
"parameter-pack");
2523 Results.AddResult(Result(Builder.TakeString()));
2532 if (
ID->getSuperClass()) {
2533 std::string SuperType;
2534 SuperType =
ID->getSuperClass()->getNameAsString();
2535 if (Method->isInstanceMethod())
2538 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2539 Builder.AddTypedTextChunk(
"super");
2540 Results.AddResult(Result(Builder.TakeString()));
2549 Builder.AddResultTypeChunk(
"size_t");
2551 Builder.AddTypedTextChunk(
"alignof");
2553 Builder.AddTypedTextChunk(
"_Alignof");
2555 Builder.AddPlaceholderChunk(
"type");
2557 Results.AddResult(Result(Builder.TakeString()));
2561 Builder.AddResultTypeChunk(
"size_t");
2562 Builder.AddTypedTextChunk(
"sizeof");
2564 Builder.AddPlaceholderChunk(
"expression-or-type");
2566 Results.AddResult(Result(Builder.TakeString()));
2579 Results.AddResult(Result(
"operator"));
2599 T = Function->getReturnType();
2600 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2602 T = Method->getSendResultType(BaseType);
2604 T = Method->getReturnType();
2605 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2606 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2608 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2610 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2612 T = Ivar->getUsageType(BaseType);
2614 T = Ivar->getType();
2615 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2616 T =
Value->getType();
2617 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2619 T =
Property->getUsageType(BaseType);
2634 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2635 if (Sentinel->getSentinel() == 0) {
2655 Result +=
"bycopy ";
2659 Result +=
"oneway ";
2662 switch (*nullability) {
2664 Result +=
"nonnull ";
2668 Result +=
"nullable ";
2672 Result +=
"null_unspecified ";
2689 bool SuppressBlock =
false) {
2695 if (!SuppressBlock) {
2698 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2711 TL = AttrTL.getModifiedLoc();
2730 bool SuppressBlockName =
false,
2731 bool SuppressBlock =
false,
2732 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2736 bool SuppressName =
false,
bool SuppressBlock =
false,
2737 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2743 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2750 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2757 if (ObjCMethodParam) {
2777 if (!Block && ObjCMethodParam &&
2778 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2779 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2780 ->findPropertyDecl(
false))
2794 if (ObjCMethodParam) {
2799 Result =
"(" + Quals +
" " + Result +
")";
2800 if (Result.back() !=
')')
2814 false, SuppressBlock,
2830 bool SuppressBlockName,
bool SuppressBlock,
2831 Optional<ArrayRef<QualType>> ObjCSubsts) {
2838 if (!ResultType->
isVoidType() || SuppressBlock)
2850 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2863 if (SuppressBlock) {
2865 Result = Result +
" (^";
2872 Result =
'^' + Result;
2887 bool Invalid = CharSrcRange.
isInvalid();
2895 if (srcText.empty() || srcText ==
"=") {
2901 std::string DefValue(srcText.str());
2904 if (DefValue.at(0) !=
'=') {
2908 return " = " + DefValue;
2910 return " " + DefValue;
2919 bool InOptional =
false) {
2920 bool FirstParameter =
true;
2930 if (!FirstParameter)
2938 FirstParameter =
false;
2951 PlaceholderStr +=
", ...";
2959 if (Proto->isVariadic()) {
2960 if (Proto->getNumParams() == 0)
2971 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
2972 bool FirstParameter =
true;
2981 PEnd = Params->begin() + MaxParameters;
2984 bool HasDefaultArg =
false;
2985 std::string PlaceholderStr;
2987 if (TTP->wasDeclaredWithTypename())
2988 PlaceholderStr =
"typename";
2989 else if (
const auto *TC = TTP->getTypeConstraint()) {
2990 llvm::raw_string_ostream OS(PlaceholderStr);
2991 TC->print(OS, Policy);
2994 PlaceholderStr =
"class";
2996 if (TTP->getIdentifier()) {
2997 PlaceholderStr +=
' ';
2998 PlaceholderStr += TTP->getIdentifier()->getName();
3001 HasDefaultArg = TTP->hasDefaultArgument();
3003 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
3004 if (NTTP->getIdentifier())
3005 PlaceholderStr = NTTP->getIdentifier()->getName();
3006 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3007 HasDefaultArg = NTTP->hasDefaultArgument();
3009 assert(isa<TemplateTemplateParmDecl>(*
P));
3014 PlaceholderStr =
"template<...> class";
3016 PlaceholderStr +=
' ';
3023 if (HasDefaultArg && !InDefaultArg) {
3028 if (!FirstParameter)
3031 P - Params->begin(),
true);
3036 InDefaultArg =
false;
3039 FirstParameter =
false;
3053 bool QualifierIsInformative,
3059 std::string PrintedNNS;
3061 llvm::raw_string_ostream OS(PrintedNNS);
3062 Qualifier->
print(OS, Policy);
3064 if (QualifierIsInformative)
3074 if (!Proto || !Proto->getMethodQuals())
3080 if (Proto->getMethodQuals().hasOnlyConst()) {
3085 if (Proto->getMethodQuals().hasOnlyVolatile()) {
3090 if (Proto->getMethodQuals().hasOnlyRestrict()) {
3096 std::string QualsStr;
3097 if (Proto->isConst())
3098 QualsStr +=
" const";
3099 if (Proto->isVolatile())
3100 QualsStr +=
" volatile";
3101 if (Proto->isRestrict())
3102 QualsStr +=
" restrict";
3116 const char *OperatorName =
nullptr;
3119 case OO_Conditional:
3121 OperatorName =
"operator";
3124 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 3126 OperatorName = "operator" Spelling; \ 3128 #define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly) 3129 #include "clang/Basic/OperatorKinds.def" 3132 OperatorName =
"operator new";
3135 OperatorName =
"operator delete";
3138 OperatorName =
"operator new[]";
3140 case OO_Array_Delete:
3141 OperatorName =
"operator delete[]";
3144 OperatorName =
"operator()";
3147 OperatorName =
"operator[]";
3173 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
3175 Record = InjectedTy->getDecl();
3197 bool IncludeBriefComments) {
3198 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
3199 CCTUInfo, IncludeBriefComments);
3205 assert(
Kind == RK_Macro);
3257 bool IncludeBriefComments) {
3258 if (
Kind == RK_Macro)
3259 return CreateCodeCompletionStringForMacro(PP, Allocator, CCTUInfo);
3264 if (
Kind == RK_Pattern) {
3266 Pattern->Availability = Availability;
3281 if (
Kind == RK_Keyword) {
3285 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
3286 return createCodeCompletionStringForDecl(
3287 PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
3291 std::string &BeforeName,
3292 std::string &NameAndSignature) {
3293 bool SeenTypedChunk =
false;
3294 for (
auto &Chunk : CCS) {
3296 assert(SeenTypedChunk &&
"optional parameter before name");
3303 NameAndSignature += Chunk.Text;
3305 BeforeName += Chunk.Text;
3314 auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
3317 std::string BeforeName;
3318 std::string NameAndSignature;
3321 NameAndSignature +=
" override";
3332 const auto *VD = dyn_cast<
VarDecl>(ND);
3335 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3348 if (IncludeBriefComments) {
3355 if (StartsNestedNameSpecifier) {
3365 auto AddFunctionTypeAndResult = [&](
const FunctionDecl *Function) {
3376 if (
const auto *Function = dyn_cast<FunctionDecl>(ND)) {
3377 AddFunctionTypeAndResult(Function);
3381 if (
const auto *CallOperator =
3383 AddFunctionTypeAndResult(CallOperator);
3390 dyn_cast<FunctionTemplateDecl>(ND)) {
3398 llvm::SmallBitVector Deduced;
3400 unsigned LastDeducibleArgument;
3401 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3402 --LastDeducibleArgument) {
3403 if (!Deduced[LastDeducibleArgument - 1]) {
3407 bool HasDefaultArg =
false;
3408 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3409 LastDeducibleArgument - 1);
3411 HasDefaultArg = TTP->hasDefaultArgument();
3413 dyn_cast<NonTypeTemplateParmDecl>(Param))
3414 HasDefaultArg = NTTP->hasDefaultArgument();
3416 assert(isa<TemplateTemplateParmDecl>(Param));
3418 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3426 if (LastDeducibleArgument) {
3432 LastDeducibleArgument);
3444 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3455 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3456 Selector Sel = Method->getSelector();
3465 if (StartParameter == 0)
3472 if (Method->param_size() == 1)
3477 PEnd = Method->param_end();
3478 P != PEnd; (void)++
P, ++Idx) {
3480 std::string Keyword;
3481 if (Idx > StartParameter)
3484 Keyword += II->getName();
3486 if (Idx < StartParameter || AllParametersAreInformative)
3493 if (Idx < StartParameter)
3497 QualType ParamType = (*P)->getType();
3513 if (DeclaringEntity || AllParametersAreInformative)
3514 Arg += II->getName();
3517 if (Method->isVariadic() && (
P + 1) == PEnd)
3520 if (DeclaringEntity)
3522 else if (AllParametersAreInformative)
3528 if (Method->isVariadic()) {
3529 if (Method->param_size() == 0) {
3530 if (DeclaringEntity)
3532 else if (AllParametersAreInformative)
3573 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3574 if (!M || !M->isPropertyAccessor())
3600 if (ArgIndex < FDecl->getNumParams())
3612 unsigned CurrentArg,
unsigned Start = 0,
3613 bool InOptional =
false) {
3614 bool FirstParameter =
true;
3615 unsigned NumParams =
3618 for (
unsigned P = Start;
P != NumParams; ++
P) {
3624 if (!FirstParameter)
3628 CurrentArg,
P,
true);
3634 FirstParameter =
false;
3641 std::string Placeholder;
3652 if (
P == CurrentArg)
3662 if (!FirstParameter)
3665 if (CurrentArg < NumParams)
3666 Opt.AddPlaceholderChunk(
"...");
3668 Opt.AddCurrentParameterChunk(
"...");
3690 if (!FDecl && !Proto) {
3703 if (IncludeBriefComments) {
3720 return Result.TakeString();
3725 bool PreferredTypeIsPointer) {
3729 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3730 MacroName.equals(
"Nil")) {
3732 if (PreferredTypeIsPointer)
3736 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3737 MacroName.equals(
"true") || MacroName.equals(
"false"))
3740 else if (MacroName.equals(
"bool"))
3753 case Decl::EnumConstant:
3759 case Decl::ObjCCategory:
3761 case Decl::ObjCCategoryImpl:
3763 case Decl::ObjCImplementation:
3766 case Decl::ObjCInterface:
3768 case Decl::ObjCIvar:
3770 case Decl::ObjCMethod:
3774 case Decl::CXXMethod:
3776 case Decl::CXXConstructor:
3778 case Decl::CXXDestructor:
3780 case Decl::CXXConversion:
3782 case Decl::ObjCProperty:
3784 case Decl::ObjCProtocol:
3790 case Decl::TypeAlias:
3792 case Decl::TypeAliasTemplate:
3796 case Decl::Namespace:
3798 case Decl::NamespaceAlias:
3800 case Decl::TemplateTypeParm:
3802 case Decl::NonTypeTemplateParm:
3804 case Decl::TemplateTemplateParm:
3806 case Decl::FunctionTemplate:
3808 case Decl::ClassTemplate:
3810 case Decl::AccessSpec:
3812 case Decl::ClassTemplatePartialSpecialization:
3814 case Decl::UsingDirective:
3816 case Decl::StaticAssert:
3820 case Decl::TranslationUnit:
3824 case Decl::UnresolvedUsingValue:
3825 case Decl::UnresolvedUsingTypename:
3828 case Decl::ObjCPropertyImpl:
3829 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3836 llvm_unreachable(
"Unexpected Kind!");
3841 case Decl::ObjCTypeParam:
3845 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
3846 switch (TD->getTagKind()) {
3864 bool LoadExternal,
bool IncludeUndefined,
3865 bool TargetTypeIsPointer =
false) {
3868 Results.EnterNewScope();
3874 if (IncludeUndefined || MD) {
3880 Result(M->first, MI,
3882 TargetTypeIsPointer)));
3886 Results.ExitScope();
3890 ResultBuilder &Results) {
3893 Results.EnterNewScope();
3895 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3896 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3897 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3899 Results.ExitScope();
3906 unsigned NumResults) {
3966 llvm_unreachable(
"Invalid ParserCompletionContext!");
3978 ResultBuilder &Results) {
3981 while (isa<BlockDecl>(CurContext))
3991 if (!
P->getDeclName())
3997 Results.getCodeCompletionTUInfo());
4004 S.
Context, CurContext, Overridden->getDeclContext());
4007 llvm::raw_string_ostream OS(Str);
4008 NNS->
print(OS, Policy);
4009 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
4011 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4014 Builder.AddTypedTextChunk(
4015 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4017 bool FirstParam =
true;
4024 Builder.AddPlaceholderChunk(
4025 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
4031 Results.Ignore(Overridden);
4038 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4039 CodeCompleter->getCodeCompletionTUInfo(),
4041 Results.EnterNewScope();
4049 PP.getHeaderSearchInfo().collectAllModules(Modules);
4050 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4051 Builder.AddTypedTextChunk(
4052 Builder.getAllocator().CopyString(Modules[I]->Name));
4053 Results.AddResult(Result(
4058 }
else if (getLangOpts().Modules) {
4069 Builder.AddTypedTextChunk(
4070 Builder.getAllocator().CopyString((*Sub)->Name));
4071 Results.AddResult(Result(
4078 Results.ExitScope();
4080 Results.data(), Results.size());
4085 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4086 CodeCompleter->getCodeCompletionTUInfo(),
4088 Results.EnterNewScope();
4093 switch (CompletionContext) {
4096 case PCC_ObjCInterface:
4097 case PCC_ObjCImplementation:
4098 case PCC_ObjCInstanceVariableList:
4100 case PCC_MemberTemplate:
4102 case PCC_LocalDeclarationSpecifiers:
4103 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4107 case PCC_ParenthesizedExpression:
4108 case PCC_Expression:
4112 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4114 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4120 case PCC_RecoveryInFunction:
4127 auto ThisType = getCurrentThisType();
4128 if (!ThisType.isNull())
4129 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4132 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4133 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
4134 CodeCompleter->includeGlobals(),
4135 CodeCompleter->loadExternal());
4138 Results.ExitScope();
4140 switch (CompletionContext) {
4141 case PCC_ParenthesizedExpression:
4142 case PCC_Expression:
4144 case PCC_RecoveryInFunction:
4151 case PCC_ObjCInterface:
4152 case PCC_ObjCImplementation:
4153 case PCC_ObjCInstanceVariableList:
4155 case PCC_MemberTemplate:
4159 case PCC_LocalDeclarationSpecifiers:
4163 if (CodeCompleter->includeMacros())
4167 Results.data(), Results.size());
4173 bool AtArgumentExpression,
bool IsSuper,
4174 ResultBuilder &Results);
4177 bool AllowNonIdentifiers,
4178 bool AllowNestedNameSpecifiers) {
4180 ResultBuilder Results(
4181 *
this, CodeCompleter->getAllocator(),
4182 CodeCompleter->getCodeCompletionTUInfo(),
4183 AllowNestedNameSpecifiers
4188 Results.EnterNewScope();
4191 Results.AddResult(Result(
"const"));
4192 Results.AddResult(Result(
"volatile"));
4193 if (getLangOpts().
C99)
4194 Results.AddResult(Result(
"restrict"));
4200 Results.AddResult(
"final");
4202 if (AllowNonIdentifiers) {
4203 Results.AddResult(Result(
"operator"));
4207 if (AllowNestedNameSpecifiers) {
4208 Results.allowNestedNameSpecifiers();
4209 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4210 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4211 LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer,
4212 CodeCompleter->includeGlobals(),
4213 CodeCompleter->loadExternal());
4214 Results.setFilter(
nullptr);
4217 Results.ExitScope();
4223 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4242 Results.data(), Results.size());
4247 bool IsParenthesized =
false)
4248 : PreferredType(PreferredType), IntegralConstantExpression(
false),
4249 ObjCCollection(
false), IsParenthesized(IsParenthesized) {}
4260 struct CoveredEnumerators {
4261 llvm::SmallPtrSet<EnumConstantDecl *, 8> Seen;
4267 EnumDecl *Enum, DeclContext *CurContext,
4268 const CoveredEnumerators &Enumerators) {
4270 if (Context.
getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
4277 Results.EnterNewScope();
4279 if (Enumerators.Seen.count(E))
4283 Results.AddResult(R, CurContext,
nullptr,
false);
4285 Results.ExitScope();
4296 if (Specialization->getNumArgs() != 1)
4314 if (!Results.includeCodePatterns())
4317 Results.getCodeCompletionTUInfo());
4320 Completion.AddPlaceholderChunk(
"=");
4322 if (!Parameters.empty()) {
4327 Completion.AddChunk(CodeCompletionString::ChunkKind::CK_Comma);
4331 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
4332 std::string
Type = NamePlaceholder;
4334 llvm::StringRef Prefix, Suffix;
4335 std::tie(Prefix, Suffix) = llvm::StringRef(Type).split(NamePlaceholder);
4336 Prefix = Prefix.rtrim();
4337 Suffix = Suffix.ltrim();
4339 Completion.AddTextChunk(Completion.getAllocator().CopyString(Prefix));
4341 Completion.AddPlaceholderChunk(
"parameter");
4342 Completion.AddTextChunk(Completion.getAllocator().CopyString(Suffix));
4349 Completion.AddPlaceholderChunk(
"body");
4353 Results.AddResult(Completion.TakeString());
4360 ResultBuilder Results(
4361 *
this, CodeCompleter->getAllocator(),
4362 CodeCompleter->getCodeCompletionTUInfo(),
4371 Results.setFilter(&ResultBuilder::IsObjCCollection);
4373 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
4375 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4377 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4383 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
4386 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4387 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
4388 CodeCompleter->includeGlobals(),
4389 CodeCompleter->loadExternal());
4391 Results.EnterNewScope();
4393 Results.ExitScope();
4395 bool PreferredTypeIsPointer =
false;
4406 AddEnumerators(Results, Context, Enum, CurContext, CoveredEnumerators());
4414 if (CodeCompleter->includeMacros())
4416 PreferredTypeIsPointer);
4426 Results.data(), Results.size());
4430 bool IsParenthesized) {
4431 return CodeCompleteExpression(
4438 CodeCompleteExpression(S, PreferredType);
4439 else if (getLangOpts().ObjC)
4440 CodeCompleteObjCInstanceMessage(S, E.
get(), None,
false);
4450 if (Interface->hasDefinition())
4451 return Interface->getDefinition();
4457 if (Protocol->hasDefinition())
4458 return Protocol->getDefinition();
4482 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
4487 std::string PlaceholderStr =
4490 if (I == N - 1 && BlockProtoLoc &&
4492 PlaceholderStr +=
", ...";
4506 bool AllowNullaryMethods, DeclContext *CurContext,
4507 AddedPropertiesSet &AddedProperties, ResultBuilder &Results,
4508 bool IsBaseExprStatement =
false,
4509 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
4517 if (!AddedProperties.insert(
P->getIdentifier()).second)
4522 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
4523 !IsBaseExprStatement) {
4524 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4525 if (!InOriginalClass)
4527 Results.MaybeAddResult(R, CurContext);
4538 Result R = Result(
P, Results.getBasePriority(
P),
nullptr);
4539 if (!InOriginalClass)
4541 Results.MaybeAddResult(R, CurContext);
4548 Results.getCodeCompletionTUInfo());
4551 BlockLoc, BlockProtoLoc);
4552 Result R = Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
4553 if (!InOriginalClass)
4555 Results.MaybeAddResult(R, CurContext);
4559 if (!
P->isReadOnly()) {
4561 Results.getCodeCompletionTUInfo());
4565 Builder.AddTypedTextChunk(
4566 Results.getAllocator().CopyString(
P->getName()));
4571 BlockProtoLoc,
true);
4573 Builder.AddPlaceholderChunk(
4574 Builder.getAllocator().CopyString(PlaceholderStr));
4582 Result(Builder.TakeString(),
P,
4583 Results.getBasePriority(
P) +
4587 if (!InOriginalClass)
4589 Results.MaybeAddResult(R, CurContext);
4593 if (IsClassProperty) {
4602 if (AllowNullaryMethods) {
4607 IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
4610 if (!AddedProperties.insert(Name).second)
4613 Results.getCodeCompletionTUInfo());
4615 Builder.AddTypedTextChunk(
4616 Results.getAllocator().CopyString(Name->
getName()));
4617 Result R = Result(Builder.TakeString(), M,
4619 if (!InOriginalClass)
4621 Results.MaybeAddResult(R, CurContext);
4624 if (IsClassProperty) {
4625 for (
const auto *M : Container->
methods()) {
4629 if (!M->getSelector().isUnarySelector() ||
4630 M->getReturnType()->isVoidType() || M->isInstanceMethod())
4635 for (
auto *M : Container->
methods()) {
4636 if (M->getSelector().isUnarySelector())
4644 for (
auto *
P : Protocol->protocols())
4646 CurContext, AddedProperties, Results,
4647 IsBaseExprStatement, IsClassProperty,
4650 dyn_cast<ObjCInterfaceDecl>(Container)) {
4651 if (AllowCategories) {
4653 for (
auto *Cat : IFace->known_categories())
4655 CurContext, AddedProperties, Results,
4656 IsBaseExprStatement, IsClassProperty,
4661 for (
auto *I : IFace->all_referenced_protocols())
4663 CurContext, AddedProperties, Results,
4664 IsBaseExprStatement, IsClassProperty,
4668 if (IFace->getSuperClass())
4670 AllowNullaryMethods, CurContext, AddedProperties,
4671 Results, IsBaseExprStatement, IsClassProperty,
4674 dyn_cast<ObjCCategoryDecl>(Container)) {
4678 CurContext, AddedProperties, Results,
4679 IsBaseExprStatement, IsClassProperty,
4689 Results.setObjectTypeQualifiers(BaseType.
getQualifiers(), BaseKind);
4692 Results.allowNestedNameSpecifiers();
4693 std::vector<FixItHint> FixIts;
4695 FixIts.emplace_back(AccessOpFixIt.getValue());
4696 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
4703 if (!Results.empty()) {
4709 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
4710 if (DeclContext *Ctx = DepScope->getEntity()) {
4711 IsDependent = Ctx->isDependentContext();
4725 bool IsBaseExprStatement,
4727 if (!Base || !CodeCompleter)
4730 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4733 QualType ConvertedBaseType = ConvertedBase.
get()->getType();
4755 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4756 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4757 &ResultBuilder::IsMember);
4759 auto DoCompletion = [&](
Expr *Base,
bool IsArrow,
4764 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
4767 Base = ConvertedBase.
get();
4785 std::move(AccessOpFixIt));
4786 }
else if (
const auto *TST =
4789 if (
const auto *TD =
4793 RD, std::move(AccessOpFixIt));
4796 if (
auto *RD = ICNT->getDecl())
4798 RD, std::move(AccessOpFixIt));
4801 AddedPropertiesSet AddedProperties;
4806 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4809 AddedProperties, Results, IsBaseExprStatement);
4815 CurContext, AddedProperties, Results,
4816 IsBaseExprStatement,
false,
4824 Class = ObjCPtr->getInterfaceDecl();
4830 CodeCompletionDeclConsumer Consumer(Results, Class, BaseType);
4831 Results.setFilter(&ResultBuilder::IsObjCIvar);
4833 Class, LookupMemberName, Consumer, CodeCompleter->includeGlobals(),
4834 false, CodeCompleter->loadExternal());
4842 Results.EnterNewScope();
4844 bool CompletionSucceded = DoCompletion(Base, IsArrow, None);
4845 if (CodeCompleter->includeFixIts()) {
4848 CompletionSucceded |= DoCompletion(
4849 OtherOpBase, !IsArrow,
4853 Results.ExitScope();
4855 if (!CompletionSucceded)
4860 Results.data(), Results.size());
4866 bool IsBaseExprStatement) {
4873 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4874 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4875 &ResultBuilder::IsMember);
4876 Results.EnterNewScope();
4877 AddedPropertiesSet AddedProperties;
4879 true, CurContext, AddedProperties,
4880 Results, IsBaseExprStatement,
4882 Results.ExitScope();
4884 Results.data(), Results.size());
4891 ResultBuilder::LookupFilter Filter =
nullptr;
4896 Filter = &ResultBuilder::IsEnum;
4901 Filter = &ResultBuilder::IsUnion;
4908 Filter = &ResultBuilder::IsClassOrStruct;
4913 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4916 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4917 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4918 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4921 Results.setFilter(Filter);
4922 LookupVisibleDecls(S, LookupTagName, Consumer,
4923 CodeCompleter->includeGlobals(),
4924 CodeCompleter->loadExternal());
4926 if (CodeCompleter->includeGlobals()) {
4928 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4929 LookupVisibleDecls(S, LookupNestedNameSpecifierName, Consumer,
4930 CodeCompleter->includeGlobals(),
4931 CodeCompleter->loadExternal());
4935 Results.data(), Results.size());
4941 Results.AddResult(
"const");
4943 Results.AddResult(
"volatile");
4945 Results.AddResult(
"restrict");
4947 Results.AddResult(
"_Atomic");
4949 Results.AddResult(
"__unaligned");
4953 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4954 CodeCompleter->getCodeCompletionTUInfo(),
4956 Results.EnterNewScope();
4958 Results.ExitScope();
4960 Results.data(), Results.size());
4965 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4966 CodeCompleter->getCodeCompletionTUInfo(),
4968 Results.EnterNewScope();
4970 if (LangOpts.CPlusPlus11) {
4971 Results.AddResult(
"noexcept");
4975 Results.AddResult(
"final");
4977 Results.AddResult(
"override");
4980 Results.ExitScope();
4982 Results.data(), Results.size());
4986 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4990 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4993 SwitchStmt *Switch = getCurFunction()->SwitchStack.back().getPointer();
5001 CodeCompleteExpression(S, Data);
5015 CoveredEnumerators Enumerators;
5023 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
5024 if (
auto *Enumerator =
5025 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
5032 Enumerators.Seen.insert(Enumerator);
5045 Enumerators.SuggestedQualifier = DRE->getQualifier();
5050 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5051 CodeCompleter->getCodeCompletionTUInfo(),
5055 if (CodeCompleter->includeMacros()) {
5059 Results.data(), Results.size());
5063 if (Args.size() && !Args.data())
5066 for (
unsigned I = 0; I != Args.size(); ++I)
5087 if (Candidate.Function && Candidate.Function->isDeleted())
5089 if (Candidate.Viable)
5097 ArrayRef<ResultCandidate> Candidates,
unsigned N) {
5103 for (
auto &Candidate : Candidates) {
5104 if (
const auto *FType = Candidate.getFunctionType())
5105 if (
const auto *Proto = dyn_cast<FunctionProtoType>(FType))
5106 if (N < Proto->getNumParams()) {
5108 ParamType = Proto->getParamType(N);
5111 Proto->getParamType(N).getNonReferenceType()))
5124 if (Candidates.empty())
5127 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc);
5151 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
5152 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
5154 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
5156 if (UME->hasExplicitTemplateArgs()) {
5157 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
5158 TemplateArgs = &TemplateArgsBuffer;
5163 1, UME->isImplicitAccess() ? nullptr : UME->getBase());
5164 ArgExprs.append(Args.begin(), Args.end());
5166 Decls.
append(UME->decls_begin(), UME->decls_end());
5167 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
5168 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
5170 true, FirstArgumentIsBase);
5173 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
5175 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
5176 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
5178 if (!getLangOpts().CPlusPlus ||
5191 if (isCompleteType(Loc, NakedFn->
getType())) {
5194 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
5195 LookupQualifiedName(R, DC);
5198 ArgExprs.append(Args.begin(), Args.end());
5212 if (!TooManyArguments(FP->getNumParams(), Args.size(),
5215 Results.push_back(ResultCandidate(FP));
5245 for (
NamedDecl *C : LookupConstructors(RD)) {
5246 if (
auto *FD = dyn_cast<FunctionDecl>(C)) {
5252 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(C)) {
5253 AddTemplateOverloadCandidate(
5255 nullptr, Args, CandidateSet,
5277 if (
ValueDecl *MemberDecl = tryLookupCtorInitMemberDecl(
5278 Constructor->
getParent(), SS, TemplateTypeTy, II))
5279 return ProduceConstructorSignatureHelp(getCurScope(), MemberDecl->getType(),
5280 MemberDecl->getLocation(), ArgExprs,
5286 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
5288 CodeCompleteOrdinaryName(S, PCC_Expression);
5297 CodeCompleteExpression(S, Data);
5301 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5302 CodeCompleter->getCodeCompletionTUInfo(),
5304 Results.setFilter(&ResultBuilder::IsOrdinaryName);
5305 Results.EnterNewScope();
5307 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5308 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
5309 CodeCompleter->includeGlobals(),
5310 CodeCompleter->loadExternal());
5316 Results.getCodeCompletionTUInfo());
5317 Builder.AddTypedTextChunk(
"else");
5318 if (Results.includeCodePatterns()) {
5322 Builder.AddPlaceholderChunk(
"statements");
5326 Results.AddResult(Builder.TakeString());
5329 Builder.AddTypedTextChunk(
"else if");
5333 Builder.AddPlaceholderChunk(
"condition");
5335 Builder.AddPlaceholderChunk(
"expression");
5337 if (Results.includeCodePatterns()) {
5341 Builder.AddPlaceholderChunk(
"statements");
5345 Results.AddResult(Builder.TakeString());
5347 Results.ExitScope();
5352 if (CodeCompleter->includeMacros())
5356 Results.data(), Results.size());
5360 bool EnteringContext,
5361 bool IsUsingDeclaration,
QualType BaseType,
5363 if (SS.
isEmpty() || !CodeCompleter)
5378 ResultBuilder DummyResults(*
this, CodeCompleter->getAllocator(),
5379 CodeCompleter->getCodeCompletionTUInfo(), CC);
5380 if (!PreferredType.
isNull())
5381 DummyResults.setPreferredType(PreferredType);
5383 CodeCompletionDeclConsumer Consumer(DummyResults, S->
getEntity(),
5385 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
5390 DummyResults.getCompletionContext(),
nullptr, 0);
5395 DeclContext *Ctx = computeDeclContext(SS,
true);
5401 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
5404 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5405 CodeCompleter->getCodeCompletionTUInfo(), CC);
5406 if (!PreferredType.
isNull())
5407 Results.setPreferredType(PreferredType);
5408 Results.EnterNewScope();
5414 Results.AddResult(
"template");
5421 if (!EnteringContext)
5423 Results.ExitScope();
5425 if (CodeCompleter->includeNamespaceLevelDecls() ||
5427 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
5428 LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer,
5431 CodeCompleter->loadExternal());
5435 Results.data(), Results.size());
5447 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5448 CodeCompleter->getCodeCompletionTUInfo(), Context,
5449 &ResultBuilder::IsNestedNameSpecifier);
5450 Results.EnterNewScope();
5458 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5459 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
5460 CodeCompleter->includeGlobals(),
5461 CodeCompleter->loadExternal());
5462 Results.ExitScope();
5465 Results.data(), Results.size());
5474 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5475 CodeCompleter->getCodeCompletionTUInfo(),
5477 &ResultBuilder::IsNamespaceOrAlias);
5478 Results.EnterNewScope();
5479 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5480 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
5481 CodeCompleter->includeGlobals(),
5482 CodeCompleter->loadExternal());
5483 Results.ExitScope();
5485 Results.data(), Results.size());
5496 bool SuppressedGlobalResults =
5497 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
5499 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5500 CodeCompleter->getCodeCompletionTUInfo(),
5501 SuppressedGlobalResults
5504 &ResultBuilder::IsNamespace);
5506 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
5511 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
5516 OrigToLatest[NS->getOriginalNamespace()] = *NS;
5520 Results.EnterNewScope();
5521 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
5522 NS = OrigToLatest.begin(),
5523 NSEnd = OrigToLatest.end();
5528 CurContext,
nullptr,
false);
5529 Results.ExitScope();
5533 Results.data(), Results.size());
5541 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5542 CodeCompleter->getCodeCompletionTUInfo(),
5544 &ResultBuilder::IsNamespaceOrAlias);
5545 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5546 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
5547 CodeCompleter->includeGlobals(),
5548 CodeCompleter->loadExternal());
5550 Results.data(), Results.size());
5558 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5559 CodeCompleter->getCodeCompletionTUInfo(),
5561 &ResultBuilder::IsType);
5562 Results.EnterNewScope();
5566 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 5567 if (OO_##Name != OO_Conditional) \ 5568 Results.AddResult(Result(Spelling)); 5569 #include "clang/Basic/OperatorKinds.def" 5572 Results.allowNestedNameSpecifiers();
5573 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5574 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
5575 CodeCompleter->includeGlobals(),
5576 CodeCompleter->loadExternal());
5580 Results.ExitScope();
5583 Results.data(), Results.size());
5591 AdjustDeclIfTemplate(ConstructorD);
5597 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5598 CodeCompleter->getCodeCompletionTUInfo(),
5600 Results.EnterNewScope();
5603 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
5604 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
5605 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
5606 if (Initializers[I]->isBaseInitializer())
5608 QualType(Initializers[I]->getBaseClass(), 0)));
5610 InitializedFields.insert(
5611 cast<FieldDecl>(Initializers[I]->getAnyMember()));
5616 bool SawLastInitializer = Initializers.empty();
5619 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
5621 Results.getCodeCompletionTUInfo());
5622 Builder.AddTypedTextChunk(Name);
5624 if (
const auto *Function = dyn_cast<FunctionDecl>(ND))
5626 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
5630 return Builder.TakeString();
5632 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
5635 Results.getCodeCompletionTUInfo());
5636 Builder.AddTypedTextChunk(Name);
5638 Builder.AddPlaceholderChunk(Type);
5642 Builder.TakeString(), ND,
5644 if (isa<FieldDecl>(ND))
5646 return Results.AddResult(CCR);
5649 Builder.TakeString(),
5653 const char *Name,
const FieldDecl *FD) {
5655 return AddDefaultCtorInit(Name,
5656 FD ? Results.getAllocator().CopyString(
5657 FD->getType().getAsString(Policy))
5661 if (Ctors.begin() == Ctors.end())
5662 return AddDefaultCtorInit(Name, Name, RD);
5666 Results.AddResult(CCR);
5670 const char *BaseName =
5671 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
5672 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
5677 auto AddField = [&](
const FieldDecl *FD) {
5678 const char *FieldName =
5679 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
5680 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
5686 for (
const auto &
Base : ClassDecl->
bases()) {
5689 SawLastInitializer =
5690 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5692 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5697 SawLastInitializer =
false;
5701 for (
const auto &
Base : ClassDecl->
vbases()) {
5704 SawLastInitializer =
5705 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
5707 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
5712 SawLastInitializer =
false;
5716 for (
auto *Field : ClassDecl->
fields()) {
5717 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
5719 SawLastInitializer = !Initializers.empty() &&
5720 Initializers.back()->isAnyMemberInitializer() &&
5721 Initializers.back()->getAnyMember() == Field;
5725 if (!Field->getDeclName())
5729 SawLastInitializer =
false;
5731 Results.ExitScope();
5734 Results.data(), Results.size());
5747 bool AfterAmpersand) {
5748 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5749 CodeCompleter->getCodeCompletionTUInfo(),
5751 Results.EnterNewScope();
5754 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
5755 bool IncludedThis =
false;
5756 for (
const auto &C : Intro.
Captures) {
5758 IncludedThis =
true;
5767 for (
const auto *D : S->
decls()) {
5768 const auto *Var = dyn_cast<
VarDecl>(D);
5769 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
5772 if (Known.insert(Var->getIdentifier()).second)
5774 CurContext,
nullptr,
false);
5782 Results.ExitScope();
5785 Results.data(), Results.size());
5790 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword) 5793 ResultBuilder &Results,
bool NeedAt) {
5799 Results.getCodeCompletionTUInfo());
5800 if (LangOpts.ObjC) {
5804 Builder.AddPlaceholderChunk(
"property");
5805 Results.AddResult(Result(Builder.TakeString()));
5810 Builder.AddPlaceholderChunk(
"property");
5811 Results.AddResult(Result(Builder.TakeString()));
5816 ResultBuilder &Results,
bool NeedAt) {
5822 if (LangOpts.ObjC) {
5837 Results.getCodeCompletionTUInfo());
5842 Builder.AddPlaceholderChunk(
"name");
5843 Results.AddResult(Result(Builder.TakeString()));
5845 if (Results.includeCodePatterns()) {
5851 Builder.AddPlaceholderChunk(
"class");
5852 Results.AddResult(Result(Builder.TakeString()));
5857 Builder.AddPlaceholderChunk(
"protocol");
5858 Results.AddResult(Result(Builder.TakeString()));
5863 Builder.AddPlaceholderChunk(
"class");
5864 Results.AddResult(Result(Builder.TakeString()));
5868 Builder.AddTypedTextChunk(
5871 Builder.AddPlaceholderChunk(
"alias");
5873 Builder.AddPlaceholderChunk(
"class");
5874 Results.AddResult(Result(Builder.TakeString()));
5876 if (Results.getSema().getLangOpts().Modules) {
5880 Builder.AddPlaceholderChunk(
"module");
5881 Results.AddResult(Result(Builder.TakeString()));
5886 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5887 CodeCompleter->getCodeCompletionTUInfo(),
5889 Results.EnterNewScope();
5890 if (isa<ObjCImplDecl>(CurContext))
5896 Results.ExitScope();
5898 Results.data(), Results.size());
5904 Results.getCodeCompletionTUInfo());
5907 const char *EncodeType =
"char[]";
5908 if (Results.getSema().getLangOpts().CPlusPlus ||
5909 Results.getSema().getLangOpts().ConstStrings)
5910 EncodeType =
"const char[]";
5911 Builder.AddResultTypeChunk(EncodeType);
5914 Builder.AddPlaceholderChunk(
"type-name");
5916 Results.AddResult(Result(Builder.TakeString()));
5919 Builder.AddResultTypeChunk(
"Protocol *");
5922 Builder.AddPlaceholderChunk(
"protocol-name");
5924 Results.AddResult(Result(Builder.TakeString()));
5927 Builder.AddResultTypeChunk(
"SEL");
5930 Builder.AddPlaceholderChunk(
"selector");
5932 Results.AddResult(Result(Builder.TakeString()));
5935 Builder.AddResultTypeChunk(
"NSString *");
5937 Builder.AddPlaceholderChunk(
"string");
5938 Builder.AddTextChunk(
"\"");
5939 Results.AddResult(Result(Builder.TakeString()));
5942 Builder.AddResultTypeChunk(
"NSArray *");
5944 Builder.AddPlaceholderChunk(
"objects, ...");
5946 Results.AddResult(Result(Builder.TakeString()));
5949 Builder.AddResultTypeChunk(
"NSDictionary *");
5951 Builder.AddPlaceholderChunk(
"key");
5954 Builder.AddPlaceholderChunk(
"object, ...");
5956 Results.AddResult(Result(Builder.TakeString()));
5959 Builder.AddResultTypeChunk(
"id");
5961 Builder.AddPlaceholderChunk(
"expression");
5963 Results.AddResult(Result(Builder.TakeString()));
5969 Results.getCodeCompletionTUInfo());
5971 if (Results.includeCodePatterns()) {
5976 Builder.AddPlaceholderChunk(
"statements");
5978 Builder.AddTextChunk(
"@catch");
5980 Builder.AddPlaceholderChunk(
"parameter");
5983 Builder.AddPlaceholderChunk(
"statements");
5985 Builder.AddTextChunk(
"@finally");
5987 Builder.AddPlaceholderChunk(
"statements");
5989 Results.AddResult(Result(Builder.TakeString()));
5995 Builder.AddPlaceholderChunk(
"expression");
5996 Results.AddResult(Result(Builder.TakeString()));
5998 if (Results.includeCodePatterns()) {
6003 Builder.AddPlaceholderChunk(
"expression");
6006 Builder.AddPlaceholderChunk(
"statements");
6008 Results.AddResult(Result(Builder.TakeString()));
6013 ResultBuilder &Results,
bool NeedAt) {
6023 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6024 CodeCompleter->getCodeCompletionTUInfo(),
6026 Results.EnterNewScope();
6028 Results.ExitScope();
6030 Results.data(), Results.size());
6034 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6035 CodeCompleter->getCodeCompletionTUInfo(),
6037 Results.EnterNewScope();
6040 Results.ExitScope();
6042 Results.data(), Results.size());
6046 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6047 CodeCompleter->getCodeCompletionTUInfo(),
6049 Results.EnterNewScope();
6051 Results.ExitScope();
6053 Results.data(), Results.size());
6060 if (Attributes & NewFlag)
6063 Attributes |= NewFlag;
6071 unsigned AssignCopyRetMask =
6093 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6094 CodeCompleter->getCodeCompletionTUInfo(),
6096 Results.EnterNewScope();
6124 Results.getCodeCompletionTUInfo());
6126 Setter.AddTextChunk(
"=");
6127 Setter.AddPlaceholderChunk(
"method");
6132 Results.getCodeCompletionTUInfo());
6134 Getter.AddTextChunk(
"=");
6135 Getter.AddPlaceholderChunk(
"method");
6144 Results.ExitScope();
6146 Results.data(), Results.size());
6158 ArrayRef<IdentifierInfo *> SelIdents,
6159 bool AllowSameLength =
true) {
6160 unsigned NumSelIdents = SelIdents.size();
6173 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
6176 for (
unsigned I = 0; I != NumSelIdents; ++I)
6185 ArrayRef<IdentifierInfo *> SelIdents,
6186 bool AllowSameLength =
true) {
6217 ArrayRef<IdentifierInfo *> SelIdents,
6218 DeclContext *CurContext,
6219 VisitedSelectorSet &Selectors,
bool AllowSameLength,
6220 ResultBuilder &Results,
bool InOriginalClass =
true,
6221 bool IsRootClass =
false) {
6225 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
6229 if (M->isInstanceMethod() == WantInstanceMethods ||
6230 (IsRootClass && !WantInstanceMethods)) {
6236 if (!Selectors.insert(M->getSelector()).second)
6239 Result R = Result(M, Results.getBasePriority(M),
nullptr);
6240 R.StartParameter = SelIdents.size();
6241 R.AllParametersAreInformative = (WantKind !=
MK_Any);
6242 if (!InOriginalClass)
6244 Results.MaybeAddResult(R, CurContext);
6249 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
6250 if (Protocol->hasDefinition()) {
6252 Protocol->getReferencedProtocols();
6254 E = Protocols.
end();
6256 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
6257 Selectors, AllowSameLength, Results,
false, IsRootClass);
6266 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
6267 Selectors, AllowSameLength, Results,
false, IsRootClass);
6271 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
6272 CurContext, Selectors, AllowSameLength, Results,
6273 InOriginalClass, IsRootClass);
6277 CatDecl->getReferencedProtocols();
6279 E = Protocols.
end();
6281 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
6282 Selectors, AllowSameLength, Results,
false, IsRootClass);
6286 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
6287 Selectors, AllowSameLength, Results, InOriginalClass,
6295 SelIdents, CurContext, Selectors, AllowSameLength, Results,
6300 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
6301 Selectors, AllowSameLength, Results, InOriginalClass,
6310 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
6311 Class =
Category->getClassInterface();
6318 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6319 CodeCompleter->getCodeCompletionTUInfo(),
6321 Results.EnterNewScope();
6323 VisitedSelectorSet Selectors;
6326 Results.ExitScope();
6328 Results.data(), Results.size());
6336 dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
6337 Class =
Category->getClassInterface();
6344 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6345 CodeCompleter->getCodeCompletionTUInfo(),
6347 Results.EnterNewScope();
6349 VisitedSelectorSet Selectors;
6353 Results.ExitScope();
6355 Results.data(), Results.size());
6360 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6361 CodeCompleter->getCodeCompletionTUInfo(),
6363 Results.EnterNewScope();
6366 bool AddedInOut =
false;
6369 Results.AddResult(
"in");
6370 Results.AddResult(
"inout");
6375 Results.AddResult(
"out");
6377 Results.AddResult(
"inout");
6382 Results.AddResult(
"bycopy");
6383 Results.AddResult(
"byref");
6384 Results.AddResult(
"oneway");
6387 Results.AddResult(
"nonnull");
6388 Results.AddResult(
"nullable");
6389 Results.AddResult(
"null_unspecified");
6397 PP.isMacroDefined(
"IBAction")) {
6399 Results.getCodeCompletionTUInfo(),
6401 Builder.AddTypedTextChunk(
"IBAction");
6403 Builder.AddPlaceholderChunk(
"selector");
6406 Builder.AddTextChunk(
"id");
6408 Builder.AddTextChunk(
"sender");
6419 Results.ExitScope();
6422 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
6423 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6424 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
6425 CodeCompleter->includeGlobals(),
6426 CodeCompleter->loadExternal());
6428 if (CodeCompleter->includeMacros())
6432 Results.data(), Results.size());
6440 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
6458 switch (Msg->getReceiverKind()) {
6462 IFace = ObjType->getInterface();
6466 QualType T = Msg->getInstanceReceiver()->getType();
6468 IFace = Ptr->getInterfaceDecl();
6482 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6483 .Case(
"retain", IFace)
6484 .Case(
"strong", IFace)
6485 .Case(
"autorelease", IFace)
6486 .Case(
"copy", IFace)
6487 .Case(
"copyWithZone", IFace)
6488 .Case(
"mutableCopy", IFace)
6489 .Case(
"mutableCopyWithZone", IFace)
6490 .Case(
"awakeFromCoder", IFace)
6491 .Case(
"replacementObjectFromCoder", IFace)
6492 .Case(
"class", IFace)
6493 .Case(
"classForCoder", IFace)
6494 .Case(
"superclass", Super)
6497 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
6499 .Case(
"alloc", IFace)
6500 .Case(
"allocWithZone", IFace)
6501 .Case(
"class", IFace)
6502 .Case(
"superclass", Super)
6524 ArrayRef<IdentifierInfo *> SelIdents,
6525 ResultBuilder &Results) {
6544 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
6562 CurP != CurPEnd; ++CurP, ++SuperP) {
6565 (*SuperP)->getType()))
6569 if (!(*CurP)->getIdentifier())
6575 Results.getCodeCompletionTUInfo());
6579 Results.getCompletionContext().getBaseType(), Builder);
6582 if (NeedSuperKeyword) {
6583 Builder.AddTypedTextChunk(
"super");
6589 if (NeedSuperKeyword)
6590 Builder.AddTextChunk(
6593 Builder.AddTypedTextChunk(
6597 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
6598 if (I > SelIdents.size())
6601 if (I < SelIdents.size())
6602 Builder.AddInformativeChunk(
6604 else if (NeedSuperKeyword || I > SelIdents.size()) {
6605 Builder.AddTextChunk(
6607 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6608 (*CurP)->getIdentifier()->getName()));
6610 Builder.AddTypedTextChunk(
6612 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
6613 (*CurP)->getIdentifier()->getName()));
6625 ResultBuilder Results(
6626 *
this, CodeCompleter->getAllocator(),
6627 CodeCompleter->getCodeCompletionTUInfo(),
6629 getLangOpts().CPlusPlus11
6630 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
6631 : &ResultBuilder::IsObjCMessageReceiver);
6633 CodeCompletionDeclConsumer Consumer(Results, CurContext);
6634 Results.EnterNewScope();
6635 LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
6636 CodeCompleter->includeGlobals(),
6637 CodeCompleter->loadExternal());
6643 if (Iface->getSuperClass()) {
6644 Results.AddResult(Result(
"super"));
6652 Results.ExitScope();
6654 if (CodeCompleter->includeMacros())
6657 Results.data(), Results.size());
6662 bool AtArgumentExpression) {
6666 CDecl = CurMethod->getClassInterface();
6675 if (CurMethod->isInstanceMethod()) {
6679 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
6680 AtArgumentExpression, CDecl);
6688 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc, LookupOrdinaryName);
6689 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
6691 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
6694 CDecl = Iface->getInterface();
6695 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
6703 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
6706 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
6707 SelIdents, AtArgumentExpression);
6716 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
6717 AtArgumentExpression,
6724 unsigned NumSelIdents) {
6726 ASTContext &Context = Results.getSema().Context;
6730 Result *ResultsData = Results.data();
6731 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
6732 Result &R = ResultsData[I];
6733 if (R.Kind == Result::RK_Declaration &&
6734 isa<ObjCMethodDecl>(R.Declaration)) {
6735 if (R.Priority <= BestPriority) {
6736 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
6737 if (NumSelIdents <= Method->param_size()) {
6739 Method->
parameters()[NumSelIdents - 1]->getType();
6740 if (R.Priority < BestPriority || PreferredType.
isNull()) {
6741 BestPriority = R.Priority;
6742 PreferredType = MyPreferredType;
6752 return PreferredType;
6757 ArrayRef<IdentifierInfo *> SelIdents,
6758 bool AtArgumentExpression,
bool IsSuper,
6759 ResultBuilder &Results) {
6769 CDecl = Interface->getInterface();
6774 Results.EnterNewScope();
6781 Results.Ignore(SuperMethod);
6787 Results.setPreferredSelector(CurMethod->getSelector());
6789 VisitedSelectorSet Selectors;
6792 Selectors, AtArgumentExpression, Results);
6799 for (uint32_t I = 0,
6810 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
6814 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6818 Result R(MethList->getMethod(),
6819 Results.getBasePriority(MethList->getMethod()),
nullptr);
6820 R.StartParameter = SelIdents.size();
6821 R.AllParametersAreInformative =
false;
6822 Results.MaybeAddResult(R, SemaRef.
CurContext);
6827 Results.ExitScope();
6832 bool AtArgumentExpression,
6835 QualType T = this->GetTypeFromParser(Receiver);
6837 ResultBuilder Results(
6838 *
this, CodeCompleter->getAllocator(),
6839 CodeCompleter->getCodeCompletionTUInfo(),
6844 AtArgumentExpression, IsSuper, Results);
6851 if (AtArgumentExpression) {
6854 if (PreferredType.
isNull())
6855 CodeCompleteOrdinaryName(S, PCC_Expression);
6857 CodeCompleteExpression(S, PreferredType);
6862 Results.data(), Results.size());
6867 bool AtArgumentExpression,
6871 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6876 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6879 RecExpr = Conv.
get();
6893 return CodeCompleteObjCClassMessage(
6895 AtArgumentExpression, Super);
6900 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6901 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6903 RecExpr = Conv.
get();
6904 ReceiverType = RecExpr->
getType();
6909 ResultBuilder Results(
6910 *
this, CodeCompleter->getAllocator(),
6911 CodeCompleter->getCodeCompletionTUInfo(),
6913 ReceiverType, SelIdents));
6915 Results.EnterNewScope();
6922 Results.Ignore(SuperMethod);
6928 Results.setPreferredSelector(CurMethod->getSelector());
6931 VisitedSelectorSet Selectors;
6941 Selectors, AtArgumentExpression, Results);
6948 for (
auto *I : QualID->quals())
6950 AtArgumentExpression, Results);
6957 CurContext, Selectors, AtArgumentExpression, Results);
6960 for (
auto *I : IFacePtr->quals())
6962 AtArgumentExpression, Results);
6971 if (ExternalSource) {
6972 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6974 Selector Sel = ExternalSource->GetExternalSelector(I);
6975 if (Sel.
isNull() || MethodPool.count(Sel))
6978 ReadMethodPool(Sel);
6982 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6983 MEnd = MethodPool.end();
6986 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
6990 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6993 Result R(MethList->getMethod(),
6994 Results.getBasePriority(MethList->getMethod()),
nullptr);
6995 R.StartParameter = SelIdents.size();
6996 R.AllParametersAreInformative =
false;
6997 Results.MaybeAddResult(R, CurContext);
7001 Results.ExitScope();
7008 if (AtArgumentExpression) {
7011 if (PreferredType.
isNull())
7012 CodeCompleteOrdinaryName(S, PCC_Expression);
7014 CodeCompleteExpression(S, PreferredType);
7019 Results.data(), Results.size());
7035 CodeCompleteExpression(S, Data);
7042 if (ExternalSource) {
7043 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
7045 Selector Sel = ExternalSource->GetExternalSelector(I);
7046 if (Sel.
isNull() || MethodPool.count(Sel))
7049 ReadMethodPool(Sel);
7053 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7054 CodeCompleter->getCodeCompletionTUInfo(),
7056 Results.EnterNewScope();
7057 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7058 MEnd = MethodPool.end();
7066 Results.getCodeCompletionTUInfo());
7068 Builder.AddTypedTextChunk(
7070 Results.AddResult(Builder.TakeString());
7074 std::string Accumulator;
7075 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
7076 if (I == SelIdents.size()) {
7077 if (!Accumulator.empty()) {
7078 Builder.AddInformativeChunk(
7079 Builder.getAllocator().CopyString(Accumulator));
7080 Accumulator.clear();
7087 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
7088 Results.AddResult(Builder.TakeString());
7090 Results.ExitScope();
7093 Results.data(), Results.size());
7099 bool OnlyForwardDeclarations,
7100 ResultBuilder &Results) {
7103 for (
const auto *D : Ctx->
decls()) {
7105 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
7106 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
7108 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
7115 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7116 CodeCompleter->getCodeCompletionTUInfo(),
7119 if (CodeCompleter->includeGlobals()) {
7120 Results.EnterNewScope();
7127 Results.Ignore(Protocol);
7133 Results.ExitScope();
7137 Results.data(), Results.size());
7141 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7142 CodeCompleter->getCodeCompletionTUInfo(),
7145 if (CodeCompleter->includeGlobals()) {
7146 Results.EnterNewScope();
7152 Results.ExitScope();
7156 Results.data(), Results.size());
7162 bool OnlyForwardDeclarations,
7163 bool OnlyUnimplemented,
7164 ResultBuilder &Results) {
7167 for (
const auto *D : Ctx->
decls()) {
7169 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
7170 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
7171 (!OnlyUnimplemented || !Class->getImplementation()))
7173 Result(Class, Results.getBasePriority(Class),
nullptr), CurContext,
7179 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7180 CodeCompleter->getCodeCompletionTUInfo(),
7182 Results.EnterNewScope();
7184 if (CodeCompleter->includeGlobals()) {
7190 Results.ExitScope();
7193 Results.data(), Results.size());
7198 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7199 CodeCompleter->getCodeCompletionTUInfo(),
7201 Results.EnterNewScope();
7205 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
7206 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
7207 Results.Ignore(CurClass);
7209 if (CodeCompleter->includeGlobals()) {
7215 Results.ExitScope();
7218 Results.data(), Results.size());
7222 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7223 CodeCompleter->getCodeCompletionTUInfo(),
7225 Results.EnterNewScope();
7227 if (CodeCompleter->includeGlobals()) {
7233 Results.ExitScope();
7236 Results.data(), Results.size());
7244 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7245 CodeCompleter->getCodeCompletionTUInfo(),
7250 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
7252 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
7254 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
7255 for (
const auto *Cat : Class->visible_categories())
7256 CategoryNames.insert(Cat->getIdentifier());
7260 Results.EnterNewScope();
7262 for (
const auto *D : TU->
decls())
7263 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
7264 if (CategoryNames.insert(
Category->getIdentifier()).second)
7267 CurContext,
nullptr,
false);
7268 Results.ExitScope();
7271 Results.data(), Results.size());
7283 LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
7286 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
7288 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7289 CodeCompleter->getCodeCompletionTUInfo(),
7295 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
7296 Results.EnterNewScope();
7297 bool IgnoreImplemented =
true;
7300 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
7301 CategoryNames.insert(Cat->getIdentifier()).second)
7302 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
7303 CurContext,
nullptr,
false);
7307 IgnoreImplemented =
false;
7309 Results.ExitScope();
7312 Results.data(), Results.size());
7317 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7318 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
7322 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
7323 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
7324 !isa<ObjCCategoryImplDecl>(Container)))
7329 for (
const auto *D : Container->decls())
7330 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
7331 Results.Ignore(PropertyImpl->getPropertyDecl());
7334 AddedPropertiesSet AddedProperties;
7335 Results.EnterNewScope();
7337 dyn_cast<ObjCImplementationDecl>(Container))
7340 AddedProperties, Results);
7343 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
7344 false,
false, CurContext,
7345 AddedProperties, Results);
7346 Results.ExitScope();
7349 Results.data(), Results.size());
7355 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7356 CodeCompleter->getCodeCompletionTUInfo(),
7361 dyn_cast_or_null<ObjCContainerDecl>(CurContext);
7362 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
7363 !isa<ObjCCategoryImplDecl>(Container)))
7369 dyn_cast<ObjCImplementationDecl>(Container))
7370 Class = ClassImpl->getClassInterface();
7372 Class = cast<ObjCCategoryImplDecl>(Container)
7374 ->getClassInterface();
7382 Property->getType().getNonReferenceType().getUnqualifiedType();
7385 Results.setPreferredType(PropertyType);
7390 Results.EnterNewScope();
7391 bool SawSimilarlyNamedIvar =
false;
7392 std::string NameWithPrefix;
7393 NameWithPrefix +=
'_';
7394 NameWithPrefix += PropertyName->
getName();
7395 std::string NameWithSuffix = PropertyName->
getName().str();
7396 NameWithSuffix +=
'_';
7400 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
7401 CurContext,
nullptr,
false);
7405 if ((PropertyName == Ivar->getIdentifier() ||
7406 NameWithPrefix == Ivar->
getName() ||
7407 NameWithSuffix == Ivar->getName())) {
7408 SawSimilarlyNamedIvar =
true;
7412 if (Results.size() &&
7413 Results.data()[Results.size() - 1].Kind ==
7415 Results.data()[Results.size() - 1].Declaration == Ivar)
7416 Results.data()[Results.size() - 1].Priority--;
7421 if (!SawSimilarlyNamedIvar) {
7431 Builder.AddResultTypeChunk(
7433 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
7438 Results.ExitScope();
7441 Results.data(), Results.size());
7447 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
7459 bool InOriginalClass =
true) {
7462 if (!IFace->hasDefinition())
7465 IFace = IFace->getDefinition();
7469 IFace->getReferencedProtocols();
7471 E = Protocols.
end();
7474 KnownMethods, InOriginalClass);
7477 for (
auto *Cat : IFace->visible_categories()) {
7479 KnownMethods,
false);
7483 if (IFace->getSuperClass())
7485 WantInstanceMethods, ReturnType, KnownMethods,
7492 Category->getReferencedProtocols();
7494 E = Protocols.
end();
7497 KnownMethods, InOriginalClass);
7500 if (InOriginalClass &&
Category->getClassInterface())
7502 WantInstanceMethods, ReturnType, KnownMethods,
7508 if (!Protocol->hasDefinition())
7510 Protocol = Protocol->getDefinition();
7511 Container = Protocol;
7515 Protocol->getReferencedProtocols();
7517 E = Protocols.
end();
7520 KnownMethods,
false);
7526 for (
auto *M : Container->
methods()) {
7527 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
7528 if (!ReturnType.
isNull() &&
7532 KnownMethods[M->getSelector()] =
7533 KnownMethodsMap::mapped_type(M, InOriginalClass);
7568 bool IsInstanceMethod,
7570 VisitedSelectorSet &KnownSelectors,
7571 ResultBuilder &Results) {
7573 if (!PropName || PropName->
getLength() == 0)
7591 const char *CopiedKey;
7594 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
7596 operator const char *() {
7600 return CopiedKey = Allocator.
CopyString(Key);
7602 } Key(Allocator, PropName->
getName());
7605 std::string UpperKey = PropName->
getName();
7606 if (!UpperKey.empty())
7609 bool ReturnTypeMatchesProperty =
7613 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
7616 if (IsInstanceMethod &&
7617 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
7623 Builder.AddTypedTextChunk(Key);
7630 if (IsInstanceMethod &&
7631 ((!ReturnType.
isNull() &&
7635 std::string SelectorName = (Twine(
"is") + UpperKey).str();
7637 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7639 if (ReturnType.
isNull()) {
7641 Builder.AddTextChunk(
"BOOL");
7652 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
7654 std::string SelectorName = (Twine(
"set") + UpperKey).str();
7656 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7657 if (ReturnType.
isNull()) {
7659 Builder.AddTextChunk(
"void");
7664 Builder.AddTypedTextChunk(
":");
7667 Builder.AddTextChunk(Key);
7678 if (
const auto *ObjCPointer =
7703 if (IsInstanceMethod &&
7705 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
7707 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7709 if (ReturnType.
isNull()) {
7711 Builder.AddTextChunk(
"NSUInteger");
7717 Result(Builder.TakeString(),
7718 std::min(IndexedGetterPriority, UnorderedGetterPriority),
7725 if (IsInstanceMethod &&
7727 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
7729 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7730 if (ReturnType.
isNull()) {
7732 Builder.AddTextChunk(
"id");
7736 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7738 Builder.AddTextChunk(
"NSUInteger");
7740 Builder.AddTextChunk(
"index");
7741 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7747 if (IsInstanceMethod &&
7752 ->getInterfaceDecl()
7753 ->getName() ==
"NSArray"))) {
7754 std::string SelectorName = (Twine(Property->
getName()) +
"AtIndexes").str();
7756 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7757 if (ReturnType.
isNull()) {
7759 Builder.AddTextChunk(
"NSArray *");
7763 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7765 Builder.AddTextChunk(
"NSIndexSet *");
7767 Builder.AddTextChunk(
"indexes");
7768 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7774 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7775 std::string SelectorName = (Twine(
"get") + UpperKey).str();
7779 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7780 if (ReturnType.
isNull()) {
7782 Builder.AddTextChunk(
"void");
7786 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7788 Builder.AddPlaceholderChunk(
"object-type");
7789 Builder.AddTextChunk(
" **");
7791 Builder.AddTextChunk(
"buffer");
7793 Builder.AddTypedTextChunk(
"range:");
7795 Builder.AddTextChunk(
"NSRange");
7797 Builder.AddTextChunk(
"inRange");
7798 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7806 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7807 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
7811 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7812 if (ReturnType.
isNull()) {
7814 Builder.AddTextChunk(
"void");
7818 Builder.AddTypedTextChunk(
"insertObject:");
7820 Builder.AddPlaceholderChunk(
"object-type");
7821 Builder.AddTextChunk(
" *");
7823 Builder.AddTextChunk(
"object");
7825 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7827 Builder.AddPlaceholderChunk(
"NSUInteger");
7829 Builder.AddTextChunk(
"index");
7830 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7836 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7837 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
7841 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7842 if (ReturnType.
isNull()) {
7844 Builder.AddTextChunk(
"void");
7848 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7850 Builder.AddTextChunk(
"NSArray *");
7852 Builder.AddTextChunk(
"array");
7854 Builder.AddTypedTextChunk(
"atIndexes:");
7856 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7858 Builder.AddTextChunk(
"indexes");
7859 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7865 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7866 std::string SelectorName =
7867 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
7869 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7870 if (ReturnType.
isNull()) {
7872 Builder.AddTextChunk(
"void");
7876 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7878 Builder.AddTextChunk(
"NSUInteger");
7880 Builder.AddTextChunk(
"index");
7881 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7887 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7888 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
7890 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7891 if (ReturnType.
isNull()) {
7893 Builder.AddTextChunk(
"void");
7897 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7899 Builder.AddTextChunk(
"NSIndexSet *");
7901 Builder.AddTextChunk(
"indexes");
7902 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7908 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7909 std::string SelectorName =
7910 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
7914 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7915 if (ReturnType.
isNull()) {
7917 Builder.AddTextChunk(
"void");
7921 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7923 Builder.AddPlaceholderChunk(
"NSUInteger");
7925 Builder.AddTextChunk(
"index");
7927 Builder.AddTypedTextChunk(
"withObject:");
7929 Builder.AddTextChunk(
"id");
7931 Builder.AddTextChunk(
"object");
7932 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7938 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7939 std::string SelectorName1 =
7940 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
7941 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
7945 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7946 if (ReturnType.
isNull()) {
7948 Builder.AddTextChunk(
"void");
7952 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
7954 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7956 Builder.AddTextChunk(
"indexes");
7958 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
7960 Builder.AddTextChunk(
"NSArray *");
7962 Builder.AddTextChunk(
"array");
7963 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7970 if (IsInstanceMethod &&
7975 ->getInterfaceDecl()
7976 ->getName() ==
"NSEnumerator"))) {
7977 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
7979 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7981 if (ReturnType.
isNull()) {
7983 Builder.AddTextChunk(
"NSEnumerator *");
7987 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7988 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7994 if (IsInstanceMethod &&
7996 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
7998 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7999 if (ReturnType.
isNull()) {
8001 Builder.AddPlaceholderChunk(
"object-type");
8002 Builder.AddTextChunk(
" *");
8006 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8008 if (ReturnType.
isNull()) {
8009 Builder.AddPlaceholderChunk(
"object-type");
8010 Builder.AddTextChunk(
" *");
8013 ReturnType, Context, Policy, Builder.getAllocator()));
8016 Builder.AddTextChunk(
"object");
8017 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
8024 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8025 std::string SelectorName =
8026 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
8028 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8029 if (ReturnType.
isNull()) {
8031 Builder.AddTextChunk(
"void");
8035 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8037 Builder.AddPlaceholderChunk(
"object-type");
8038 Builder.AddTextChunk(
" *");
8040 Builder.AddTextChunk(
"object");
8041 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8047 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8048 std::string SelectorName = (Twine(
"add") + UpperKey).str();
8050 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8051 if (ReturnType.
isNull()) {
8053 Builder.AddTextChunk(
"void");
8057 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8059 Builder.AddTextChunk(
"NSSet *");
8061 Builder.AddTextChunk(
"objects");
8062 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8068 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8069 std::string SelectorName =
8070 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
8072 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8073 if (ReturnType.
isNull()) {
8075 Builder.AddTextChunk(
"void");
8079 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8081 Builder.AddPlaceholderChunk(
"object-type");
8082 Builder.AddTextChunk(
" *");
8084 Builder.AddTextChunk(
"object");
8085 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8091 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8092 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
8094 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8095 if (ReturnType.
isNull()) {
8097 Builder.AddTextChunk(
"void");
8101 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8103 Builder.AddTextChunk(
"NSSet *");
8105 Builder.AddTextChunk(
"objects");
8106 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8112 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
8113 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
8115 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
8116 if (ReturnType.
isNull()) {
8118 Builder.AddTextChunk(
"void");
8122 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
8124 Builder.AddTextChunk(
"NSSet *");
8126 Builder.AddTextChunk(
"objects");
8127 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
8134 if (!IsInstanceMethod &&
8139 ->getInterfaceDecl()
8140 ->getName() ==
"NSSet"))) {
8141 std::string SelectorName =
8142 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
8144 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
8146 if (ReturnType.
isNull()) {
8148 Builder.AddTextChunk(
"NSSet<NSString *> *");
8152 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
8159 if (!IsInstanceMethod &&
8162 std::string SelectorName =
8163 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
8165 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
8167 if (ReturnType.
isNull()) {
8169 Builder.AddTextChunk(
"BOOL");
8173 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
8184 QualType ReturnType = GetTypeFromParser(ReturnTy);
8185 Decl *IDecl =
nullptr;
8192 bool IsInImplementation =
false;
8193 if (
Decl *D = IDecl) {
8195 SearchDecl = Impl->getClassInterface();
8196 IsInImplementation =
true;
8198 dyn_cast<ObjCCategoryImplDecl>(D)) {
8199 SearchDecl = CatImpl->getCategoryDecl();
8200 IsInImplementation =
true;
8205 if (!SearchDecl && S) {
8207 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
8223 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8224 CodeCompleter->getCodeCompletionTUInfo(),
8226 Results.EnterNewScope();
8228 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
8229 MEnd = KnownMethods.end();
8233 Results.getCodeCompletionTUInfo());
8236 if (!IsInstanceMethod) {
8243 if (ReturnType.
isNull()) {
8253 Builder.AddTypedTextChunk(
8254 Builder.getAllocator().CopyString(Sel.getNameForSlot(0)));
8260 P != PEnd; (void)++
P, ++I) {
8263 Builder.AddTypedTextChunk(
":");
8264 else if (I < Sel.getNumArgs()) {
8266 Builder.AddTypedTextChunk(
8267 Builder.getAllocator().CopyString(Sel.getNameForSlot(I) +
":"));
8274 ParamType = (*P)->getType();
8276 ParamType = (*P)->getOriginalType();
8284 Builder.AddTextChunk(Builder.getAllocator().CopyString(
Id->getName()));
8290 Builder.AddTextChunk(
"...");
8293 if (IsInImplementation && Results.includeCodePatterns()) {
8300 Builder.AddTextChunk(
"return");
8302 Builder.AddPlaceholderChunk(
"expression");
8305 Builder.AddPlaceholderChunk(
"statements");
8312 auto R = Result(Builder.TakeString(), Method,
Priority);
8313 if (!M->second.getInt())
8315 Results.AddResult(std::move(R));
8322 Containers.push_back(SearchDecl);
8324 VisitedSelectorSet KnownSelectors;
8325 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
8326 MEnd = KnownMethods.end();
8328 KnownSelectors.insert(M->first);
8333 IFace =
Category->getClassInterface();
8337 Containers.push_back(Cat);
8339 if (IsInstanceMethod) {
8340 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
8341 for (
auto *
P : Containers[I]->instance_properties())
8343 KnownSelectors, Results);
8347 Results.ExitScope();
8350 Results.data(), Results.size());
8354 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
8358 if (ExternalSource) {
8359 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); I != N;
8361 Selector Sel = ExternalSource->GetExternalSelector(I);
8362 if (Sel.
isNull() || MethodPool.count(Sel))
8365 ReadMethodPool(Sel);
8371 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8372 CodeCompleter->getCodeCompletionTUInfo(),
8376 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
8378 Results.EnterNewScope();
8379 for (GlobalMethodPool::iterator M = MethodPool.begin(),
8380 MEnd = MethodPool.end();
8382 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
8383 : &M->second.second;
8384 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8388 if (AtParameterName) {
8390 unsigned NumSelIdents = SelIdents.size();
8392 NumSelIdents <= MethList->getMethod()->param_size()) {
8394 MethList->getMethod()->parameters()[NumSelIdents - 1];
8397 Results.getCodeCompletionTUInfo());
8398 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
8400 Results.AddResult(Builder.TakeString());
8407 Result R(MethList->getMethod(),
8408 Results.getBasePriority(MethList->getMethod()),
nullptr);
8409 R.StartParameter = SelIdents.size();
8410 R.AllParametersAreInformative =
false;
8411 R.DeclaringEntity =
true;
8412 Results.MaybeAddResult(R, CurContext);
8416 Results.ExitScope();
8418 if (!AtParameterName && !SelIdents.empty() &&
8419 SelIdents.front()->getName().startswith(
"init")) {
8420 for (
const auto &M : PP.macros()) {
8421 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
8423 Results.EnterNewScope();
8425 Results.getCodeCompletionTUInfo());
8426 Builder.AddTypedTextChunk(
8427 Builder.getAllocator().CopyString(M.first->getName()));
8430 Results.ExitScope();
8435 Results.data(), Results.size());
8439 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8440 CodeCompleter->getCodeCompletionTUInfo(),
8442 Results.EnterNewScope();
8446 Results.getCodeCompletionTUInfo());
8447 Builder.AddTypedTextChunk(
"if");
8449 Builder.AddPlaceholderChunk(
"condition");
8450 Results.AddResult(Builder.TakeString());
8453 Builder.AddTypedTextChunk(
"ifdef");
8455 Builder.AddPlaceholderChunk(
"macro");
8456 Results.AddResult(Builder.TakeString());
8459 Builder.AddTypedTextChunk(
"ifndef");
8461 Builder.AddPlaceholderChunk(
"macro");
8462 Results.AddResult(Builder.TakeString());
8464 if (InConditional) {
8466 Builder.AddTypedTextChunk(
"elif");
8468 Builder.AddPlaceholderChunk(
"condition");
8469 Results.AddResult(Builder.TakeString());
8472 Builder.AddTypedTextChunk(
"else");
8473 Results.AddResult(Builder.TakeString());
8476 Builder.AddTypedTextChunk(
"endif");
8477 Results.AddResult(Builder.TakeString());
8481 Builder.AddTypedTextChunk(
"include");
8483 Builder.AddTextChunk(
"\"");
8484 Builder.AddPlaceholderChunk(
"header");
8485 Builder.AddTextChunk(
"\"");
8486 Results.AddResult(Builder.TakeString());
8489 Builder.AddTypedTextChunk(
"include");
8491 Builder.AddTextChunk(
"<");
8492 Builder.AddPlaceholderChunk(
"header");
8493 Builder.AddTextChunk(
">");
8494 Results.AddResult(Builder.TakeString());
8497 Builder.AddTypedTextChunk(
"define");
8499 Builder.AddPlaceholderChunk(
"macro");
8500 Results.AddResult(Builder.TakeString());
8503 Builder.AddTypedTextChunk(
"define");
8505 Builder.AddPlaceholderChunk(
"macro");
8507 Builder.AddPlaceholderChunk(
"args");
8509 Results.AddResult(Builder.TakeString());
8512 Builder.AddTypedTextChunk(
"undef");
8514 Builder.AddPlaceholderChunk(
"macro");
8515 Results.AddResult(Builder.TakeString());
8518 Builder.AddTypedTextChunk(
"line");
8520 Builder.AddPlaceholderChunk(
"number");
8521 Results.AddResult(Builder.TakeString());
8524 Builder.AddTypedTextChunk(
"line");
8526 Builder.AddPlaceholderChunk(
"number");
8528 Builder.AddTextChunk(
"\"");
8529 Builder.AddPlaceholderChunk(
"filename");
8530 Builder.AddTextChunk(
"\"");
8531 Results.AddResult(Builder.TakeString());
8534 Builder.AddTypedTextChunk(
"error");
8536 Builder.AddPlaceholderChunk(
"message");
8537 Results.AddResult(Builder.TakeString());
8540 Builder.AddTypedTextChunk(
"pragma");
8542 Builder.AddPlaceholderChunk(
"arguments");
8543 Results.AddResult(Builder.TakeString());
8545 if (getLangOpts().ObjC) {
8547 Builder.AddTypedTextChunk(
"import");
8549 Builder.AddTextChunk(
"\"");
8550 Builder.AddPlaceholderChunk(
"header");
8551 Builder.AddTextChunk(
"\"");
8552 Results.AddResult(Builder.TakeString());
8555 Builder.AddTypedTextChunk(
"import");
8557 Builder.AddTextChunk(
"<");
8558 Builder.AddPlaceholderChunk(
"header");
8559 Builder.AddTextChunk(
">");
8560 Results.AddResult(Builder.TakeString());
8564 Builder.AddTypedTextChunk(
"include_next");
8566 Builder.AddTextChunk(
"\"");
8567 Builder.AddPlaceholderChunk(
"header");
8568 Builder.AddTextChunk(
"\"");
8569 Results.AddResult(Builder.TakeString());
8572 Builder.AddTypedTextChunk(
"include_next");
8574 Builder.AddTextChunk(
"<");
8575 Builder.AddPlaceholderChunk(
"header");
8576 Builder.AddTextChunk(
">");
8577 Results.AddResult(Builder.TakeString());
8580 Builder.AddTypedTextChunk(
"warning");
8582 Builder.AddPlaceholderChunk(
"message");
8583 Results.AddResult(Builder.TakeString());
8590 Results.ExitScope();
8593 Results.data(), Results.size());
8602 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8603 CodeCompleter->getCodeCompletionTUInfo(),
8606 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
8609 Results.getCodeCompletionTUInfo());
8610 Results.EnterNewScope();
8612 MEnd = PP.macro_end();
8614 Builder.AddTypedTextChunk(
8615 Builder.getAllocator().CopyString(M->first->getName()));
8619 Results.ExitScope();
8620 }
else if (IsDefinition) {
8625 Results.data(), Results.size());
8629 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8630 CodeCompleter->getCodeCompletionTUInfo(),
8633 if (!CodeCompleter || CodeCompleter->includeMacros())
8635 !CodeCompleter || CodeCompleter->loadExternal(),
true);
8638 Results.EnterNewScope();
8640 Results.getCodeCompletionTUInfo());
8641 Builder.AddTypedTextChunk(
"defined");
8644 Builder.AddPlaceholderChunk(
"macro");
8646 Results.AddResult(Builder.TakeString());
8647 Results.ExitScope();
8650 Results.data(), Results.size());
8656 unsigned Argument) {
8670 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
8673 llvm::sys::path::native(NativeRelDir);
8674 llvm::vfs::FileSystem &FS =
8675 getSourceManager().getFileManager().getVirtualFileSystem();
8677 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8678 CodeCompleter->getCodeCompletionTUInfo(),
8683 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
8686 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
8687 auto R = SeenResults.insert(TypedChunk);
8689 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
8690 *R.first = InternedTyped;
8692 CodeCompleter->getCodeCompletionTUInfo());
8693 Builder.AddTypedTextChunk(InternedTyped);
8701 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
8705 if (!NativeRelDir.empty()) {
8709 auto Begin = llvm::sys::path::begin(NativeRelDir);
8710 auto End = llvm::sys::path::end(NativeRelDir);
8712 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
8713 llvm::sys::path::append(Dir, ++
Begin,
End);
8715 llvm::sys::path::append(Dir, NativeRelDir);
8721 for (
auto It = FS.dir_begin(Dir, EC);
8722 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
8723 if (++Count == 2500)
8725 StringRef Filename = llvm::sys::path::filename(It->path());
8726 switch (It->type()) {
8727 case llvm::sys::fs::file_type::directory_file:
8731 NativeRelDir.empty() && !Filename.consume_back(
".framework"))
8734 AddCompletion(Filename,
true);
8736 case llvm::sys::fs::file_type::regular_file:
8740 if (!(Filename.endswith_lower(
".h") ||
8741 Filename.endswith_lower(
".hh") ||
8742 Filename.endswith_lower(
".hpp") ||
8743 Filename.endswith_lower(
".inc")))
8746 AddCompletion(Filename,
false);
8762 AddFilesFromIncludeDir(IncludeDir.
getDir()->
getName(), IsSystem,
8775 const auto &S = PP.getHeaderSearchInfo();
8776 using llvm::make_range;
8779 auto *CurFile = PP.getCurrentFileLexer()->getFileEntry();
8780 if (CurFile && CurFile->getDir())
8781 AddFilesFromIncludeDir(CurFile->getDir()->getName(),
false,
8783 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
8784 AddFilesFromDirLookup(D,
false);
8786 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
8787 AddFilesFromDirLookup(D,
false);
8788 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
8789 AddFilesFromDirLookup(D,
true);
8792 Results.data(), Results.size());
8802 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
8803 CodeCompleter->getCodeCompletionTUInfo(),
8805 Results.EnterNewScope();
8806 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
8807 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
8810 Twine(Platform) +
"ApplicationExtension")));
8812 Results.ExitScope();
8814 Results.data(), Results.size());
8820 ResultBuilder Builder(*
this, Allocator, CCTUInfo,
8822 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
8823 CodeCompletionDeclConsumer Consumer(Builder,
8827 !CodeCompleter || CodeCompleter->loadExternal());
8830 if (!CodeCompleter || CodeCompleter->includeMacros())
8832 !CodeCompleter || CodeCompleter->loadExternal(),
true);
8835 Results.insert(Results.end(), Builder.data(),
8836 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)
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.
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
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...
Priority for a declaration that is in the local scope.
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
const TypeClass * getTypePtr() const
Code completion occurs within a class, struct, or union.
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion for a selector, as in an @selector expression.
CodeCompleteConsumer::OverloadCandidate ResultCandidate
Code completion occurred where an existing name(such as type, function or variable) is expected...
submodule_iterator submodule_begin()
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name...
Code completion where an Objective-C class message is expected.
FunctionType - C99 6.7.5.3 - Function Declarators.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
static bool isObjCReceiverType(ASTContext &C, QualType T)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
C Language Family Type Representation.
static CharSourceRange getTokenRange(SourceRange R)
Code completion within a type-qualifier list.
bool isRecordType() const
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.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Captures information about "declaration specifiers" specific to Objective-C.
void CodeCompleteUsing(Scope *S)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for...
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
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
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.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
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.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
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.
Priority for a send-to-super completion.
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...
Priority for a preprocessor macro.
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)
void setIsUsingDeclaration(bool V)
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.
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.
Priority for the next initialization in a constructor initializer list.
bool isObjCIdType() const
Adjustment for KVC code pattern priorities when it doesn't look like the.
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
An Objective-C method being used as a property.
ObjCMethodDecl * getSetterMethodDecl() const
Kind getKind() const
Retrieve the kind of code-completion context.
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
ParmVarDecl * getParam(unsigned i) const
An Objective-C instance method.
static const TST TST_enum
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
TSC getTypeSpecComplex() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
visible_categories_range visible_categories() const
QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef< Expr *> Args, SourceLocation OpenParLoc)
Reports signatures for a call to CodeCompleteConsumer and returns the preferred type for the current ...
const LangOptions & getLangOpts() const
bool isObjCQualifiedClassType() const
void * getAsOpaquePtr() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
Describes a module or submodule.
Code completion occurs where only a type is permitted.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Code completion occurs at top-level or namespace context.
ArrayRef< ParmVarDecl * > parameters() const
Values of this type can be null.
bool isUnarySelector() const
Priority for a code pattern.
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.
The result is in a base class.
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.
Priority for a nested-name-specifier.
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 non-type declaration.
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. ...
Priority for a constant value (e.g., enumerator).
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
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
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...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
Priority for a member declaration found from the current method or member function.
Divide by this factor when a code-completion result's type exactly matches the type we expect...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Priority for the Objective-C "_cmd" implicit parameter.
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)
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 const NamedDecl * extractFunctorCallOperator(const NamedDecl *ND)
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
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 ...
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.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
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.
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
Code completion occurred within 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 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.
bool isReservedName(bool doubleUnderscoreOnly=false) const
Determine whether this is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).
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.
Represents one property declaration in an Objective-C interface.
An Objective-C block property completed as a setter with a block placeholder.
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.
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
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
This is a scope that corresponds to the template parameters of a C++ template.
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
The name of a declaration.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const CXXRecordDecl * getParent() const
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.
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...
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.
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.
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.
bool Add(InterpState &S, CodePtr OpPC)
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
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
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
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
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
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)
bool Sub(InterpState &S, CodePtr OpPC)
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.
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.